Tag Archive: ns2


Installing ns2 in RHEL 6

Download the “ns-2”, “otcl”, “Tclcl” and “nam” packages separately.

Login as “root” in RHEL 6.

Extract the tarballs on the Desktop by following commands:

#  cd  Desktop

#  tar  -xvzf  [package name]

Install following packages from repository:

gcc  autoconf  automake  libXmu  tcl  tk

Installing otcl:

#  cd  [otcl directory]

#  ./configure

#  vi  Makefile

Edit line no. 31

INST_OLIBSH=               NONE/lib

to

INST_OLIBSH=               /usr/local/lib

#  make

#  make  install

Installing tclcl:

#  ./configure

#  make

#  make  install

Installing ns-2:

#  ./configure

#  make

#  make  install

#  echo  ‘ export  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib: ‘  >  /etc/profile.d/ns.sh

#  chmod  733  /etc/profile.d/ns.sh

Installing nam:

#  ./configure

#  make

#  make  install

Now perform a reboot of the system.

You can Validate the ns2 install (optional) (takes very long time):

#  cd  ns-2.35

#  ./validate

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.

Installing ns2 in Ubuntu 10.04

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.