Archive

Posts Tagged ‘ubuntu 12.10’

How to Install NS-2 in Ubuntu

February 12, 2013 28 comments

I presume that you already know what NS-2 is. I am gonna skip the details, and show you the steps that you need to follow for NS2 installation.

Download NS-allinone-2.35 from here. And, unzip your contents to your desired location. For example:

tar -zxvf ns-allinone-2.35.tar.gz -C /home/your_user_accnt

Before you install NS-2, please install some essential packages:

sudo apt-get install tcl8.5-dev tk8.5-dev

sudo apt-get install gcc-4.4 g++-4.4

sudo apt-get install build-essential autoconf automake

sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev

Open OTcl make file and change CC = @CC@ to CC=gcc-4.4, and save it. i.e.

gedit /home/your_user_accnt/ns-allinone-2.35/otcl-1.14/Makefile.in

Remove  CC = @CC@ and paste CC=gcc-4.4

You are now ready to install your ns-2.

cd /home/your_user_accnt/ns-allinone-2.35

./install

Now, you need to set some environmental variables to your hidden bashrc file.

gedit ~/.bashrc

Go to the end of the file and append the following lines :

#LD_LIBRARY_PATH

OTCL_LIB=/home/your_user_accnt/ns-allinone-2.35/otcl-1.14

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

USR_LIB=/usr/lib

export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH

XGRAPH=/home/your_user_accnt/ns-allinone-2.35/bin:/home/your_user_accnt/ns-allinone-2.35/tcl8.5.10/unix:/home/your_user_accnt/ns-allinone-2.35/tk8.5.10/unix

NS=/home/your_user_accnt/ns-allinone-2.35/ns-2.35/

NAM=/home/your_user_accnt/ns-allinone-2.34/nam-1.15/

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

Save, close and reload the bashrc file.

source ~/.bashrc

If you have completed all the steps successfully, then you should be able to run NS-2. Try the following to see :

cd /home/your_user_accnt/ns-allinone-2.35/ns-2.35/tcl/ex

ns simple.tcl

Make sure, you replace your_user_accnt with your user name.

Cheers.


								
Categories: NS-2 Tags: , , , ,