NS-2 installation on Ubuntu


Tip 1: Use ubuntu terminal with root privilege before proceeding to any of following steps.



Tip 2: Ubuntu 14.04 LTS is recommended.

Tip 3: Be Careful with the directories. Refer snapshots for the help!


1. Download and extract NS2

Click here to download ns-allinone-2.35.tar.gz and extract as follows:

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


2. Installation of required packages

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


# apt-get install gcc-4.4

3. Important changes

Once all the packages are installed, we have to edit two files as follows:

(a.) Navigate and edit "ls.h"
# cd ns-allinone-2.35/ns2.35/linkstate

#gedit ls.h

(Go to line number 137 of that file and do change as highlighted in the figure:)



(b.) Navigate and edit "Makefile.in"
# cd ns-allinone-2.35/otcl-1.14

# gedit Makefile.in

(add "gcc-4.4" as highlighted in the figure)



4. Install

Navigate to 
# cd ns-allinone-2.35
./install


5. Setting environmental path




(Replace "rahul" with your username)

# LD_LIBRARY_PATH
OTCL_LIB=/home/rahul/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/rahul/ns-allinone-2.35/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/rahul/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/rahul/ns-allinone-2.35/bin:/home/rahul/ns-allinone-2.35/tcl8.5.10/unix:/home/rahul/ns-allinone-2.35/tk8.5.10/unix
#the above two lines beginning from xgraph and ending with unix should come on the same line
NS=/home/rahul/ns-allinone-2.35/ns-2.35/ 
NAM=/home/rahul/ns-allinone-2.35/nam-1.15/ 
PATH=$PATH:$XGRAPH:$NS:$NAM

6. Run!


Type ns and you will get % sign in the next line, i.e., NS2 is successfully installed.
If it shows any error, reboot your system and retry the same.







Comments