Wednesday, February 9, 2011

Installing NS2 in UBUNTU

I am using Ubuntu 9.04 and the steps to install  ns-allinone-2.34 on it are as follows:

(1) Download ns-allinone-2.34 and Install

$ wget http://www.isi.edu/nsnam/ns/ns-build.html#allinone

$ tar -xzvf ns-allinone-2.34.tar.gz
$ cd ns-allinone-2.34
$ sudo apt-get install build-essential autoconf automake libxmu-dev

$ ./install
$ sudo apt-get install -f build-essential libxt-dev libxt6 libsm-dev
libsm6 libice-dev libice6 libxmu-dev

(2) Change your environment variance

$ gedit ~/.bashrc

Add the following lines to the end ofthe file bashrc

# LD_LIBRARY_PATH

OTCL_LIB=/your path/ns-allinone-2.34/otcl-1.13

NS2_LIB=/your path/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=/your path/ns-allinone-2.34/tcl8.4.18/library

USR_LIB=/usr/lib

export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH

XGRAPH=/your path/ns-allinone-2.34/bin:/your path/ns-allinone-2.34/tcl8.4.18/unix:/your path/ns-allinone-2.34/tk8.4.18/unix

NS=/your path/ns-allinone-2.34/ns-2.34/

NAM=/your path/ns-allinone-2.34/nam-1.14/

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

(PS:  your path should be replaced by the path to " ns-allinone-2.34" folder in the system,  
 2.34 should be replaced by the latest version or update of the NS2 software being installed,
tcl8.4.18 or tk8.4.18 or nam-1.14 should be replaced by the exact folder name in the ns-allinone-2.34 directory)

$ source ~/.bashrc
If installation is complete the above command won't show any bash errors.

$ ns
then a "%" will appear on the screen.type "exit" to quit the mode and
back to "$"

(3) Validation
After these steps, you can now run the ns validation suite with


$ cd ns-2.34
$ ./validate