Download the ns2-allinone-2.35.tar.gz

Login as “root” in Ubuntu in GUI mode (it will be easier this way).

Extract the tarball on the Desktop by following commands:

#  cd  Desktop

#  tar  -xvzf  ns-allinone-2.35.tar.gz

Download and install following packages from repository:

#  apt-get  install  build-essential  autoconf  automake  libxmu-dev

Install the ns2 by following commands:

#  cd  ns-allinone-2.35

#  ./install

This will install all required and some optional packages for ns2.

Now edit some paths (and be careful…):

#  gedit  ~/.bashrc

Put the following lines at the end of the file (/root/Desktop depends on where you extracted the tarball and change the version numbers accordingly):

# LD_LIBRARY_PATH

OTCL_LIB=/root/Desktop/ns-allinone-2.35/otcl-1.14

NS2_LIB=/root/Desktop/ns-allinone-2.35/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=/root/Desktop/ns-allinone-2.35/tcl8.5.10/library

USR_LIB=/usr/lib

export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH

XGRAPH=/root/Desktop/ns-allinone-2.35/bin:/root/Desktop/ns-allinone-2.35/tcl8.5.10/unix:/root/Desktop/ns-allinone-2.35/tk8.5.10/unix:/root/Desktop/ns-allinone-2.35/xgraph-12.2/

NS=/root/Desktop/ns-allinone-2.35/ns-2.35/

NAM=/root/Desktop/ns-allinone-2.35/nam-1.15/

export PATH=$PATH:$XGRAPH:$NS:$NAM

Now Validate ns2 install (takes very long time):

#  cd  ns-2.35

#  ./validate

Create a symlink to ns, with this ns can be started from anywhere

#  ln  -s  /root/Desktop/ns-allinpne-2.35/ns-2.35/ns  /usr/bin/ns

#  source  ~/.bashrc

Now run the ns:

#  ns

If the installation is successful, then you will see % at the command prompt:

%

To exit, type:

%  exit

Testing the ns2 installation

Open gedit and type the following hello world program:

set  ns  [new Simulator]
$ns  at  1  “puts  \“Hello World\””
$ns  at  1.5  “exit”
$ns  run

Save the file as helloworld.tcl and type the following command:

#  ns  helloworld.tcl

It displays the output as follows:

Hello World

Now your ns2 installation is complete and running.

Advertisements