Wednesday, March 2, 2011

Install NS2 (ns-allinone-2.35-RC7) in UBUNTU 9.10

Checklist of prerun package installation/command
1.g++
2.repositories updated($sudo apt-get update)
3.if you are behind a proxy, make sure you have $http_proxy variable configured in ~/.bashrc or type the following in the terminal

$ export http_proxy=http://username:password@ipaddr:port/

Step 1: Download the source for NS2 all in one (I used this version ns-allinone-2.35-RC7.tar.gz )

Step 2:
Extract the tar.gz file downloaded into your home folder by right-clicking the tag.gz file

Step 3: Open terminal (Applications–>Accessories–>Terminal) and change the directory (using cd command) to the extracted folder and execute the following:

$ sudo apt-get install build-essential autoconf automake libxmu-dev

This will install the dependencies required to compile NS2 from the source.

The following command is used to compile the source.

$ ./install

It will take long time to compile all the required packages for ns to work…
Step 4: Setting Environmental Variables

Type in terminal:

$ gedit ~/.bashrc

and append the following text to the opened file (Please note that the path contains the path in my system, replace path with yours.)

# LD_LIBRARY_PATH
OTCL_LIB=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/otcl-1.14
NS2_LIB=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/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=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/tcl8.5.8/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/bin:/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/tcl8.5.8/unix:/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/tk8.5.8/unix
NS=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/ns-2.35
NAM=/media/E0BAB170BAB14436/ns-allinone-2.35-RC7/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM

Step 5: Now, after editing the file, save and close it. Then in terminal type:

$ source ~/.bashrc

Try “ns” command, it shud go to the “%” prompt then it just means the installation was successful! Enjoy :D

Note: These steps have been tested and worked like breeze in Ubuntu and is expected work in all the debian based linux.

Reference:
3.) http://www.isi.edu/nsnam/ns/ns-build.html (Might not be needing this, but just in case)