1. Download ns-allinone-2.34.tar from here.
2. Place it in somewhere, e.g. /home/simulator, then extract it.
$ cd /
3. Download & install some packages from repository
$ apt-get install build-essential autoconf automake libxmu-dev
4. Install the ns2
$ cd ns-allinone-2.34
5. You might face problem with the installation of otcl-1.13, the problem can be due to the gcc-4.4.1 / g++-4.4.1 compilers. But please try this :
apt-get install g++-4.3
CC=gcc-4.3 CXX=g++-4.3 ./install
try to edit the Makefile.in too
From :
CC= @CC@
to :
CC= gcc-4.3
6. Edit some paths in .bashrc file$ gedit ~/.bashrc
Put these lines on that file. Off course, you might change /home/simulator for it depends on where you extract ns-allinone-2.34.tar.
# LD_LIBRARY_PATH
OTCL_LIB=/home/simulator/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/simulator/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/simulator/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/simulator/ns-allinone-2.34/bin:/home/simulator/ns-allinone-2.34/tcl8.4.18/unix:/home/simulator/ns-allinone-2.34/tk8.4.18/unix
NS=/home/simulator/ns-allinone-2.34/ns-2.34/
NAM=/home/simulator/ns-allinone-2.34/nam-1.13/
export PATH=$PATH:$XGRAPH:$NS:$NAM
7. Validate it
$ cd ns-2.34
$ ./validate
(Optionally) You can create a symlink, so that ns can be called from everywhere
$ sudo ln -s /home/simulator/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns
8. Try to run it.$ ns
external link:http://www.linuxquestions.org/questions/linux-networking-3/ns-installation-wont-let-me-do-it-on-ubuntu-9-10-a-766193/
And here after you can develop and simulate codes using ns :D