Tuesday, November 30, 2010

Installing NS2 version 2.34

I tried a lot ...and here is the solution. I think it will work better.

1)Extract ns2....
-if u download it in desktop then go to desktop through "
$ cd Desktop
$ tar -xvf ns-allinone-2.34.tar
$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3

2)It turns out that otcl does not like the version of gcc installed by default in Lucid. So go ahead to the directory and change "cd ns-allinone-2.34/otcl-1.13" and find "Makefile.in". Open "Makefile.in" and find "CC= @CC@". Then do following steps:
#CC= @CC@
CC= gcc-4.3

3)installing ns2
-go back to directory ns-allinone-2.34 you will find "install" file over there. The steps are:
$ cd ns-allinone-2.33
$ ./install

then it will take some time.

4) Then edit some path
$ gedit ~/.bashrc

-this command will open the bash file and at the end of the file put the code that i have given below Here my directory is "/home/rams/ Desktop/" so can replace this with your directory that might be "/home/jeevan/Desktop" but not sure. You have to put the directory of the ns-allinone folder. "pwd" command will show the current directory.


##########################################################################################################
# LD_LIBRARY_PATH
OTCL_LIB=/home/rams/Desktop/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/rams/Desktop/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=/home/rams/Desktop/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/rams/Desktop/ns-allinone-2.34/bin:/home/rams/Desktop/ns-allinone-2.34/tcl8.4.18/unix:/home/rams/Desktop/ns-allinone-2.34/tk8.4.18/unix:/home/rams/Desktop/ns-allinone-2.34/xgraph-12.1/
NS=/home/rams/Desktop/ns-allinone-2.34/ns-2.34/
NAM=/home/rams/Desktop/ns-allinone-2.34/nam-1.14/
export PATH=$PATH:$XGRAPH:$NS:$NAM

##################################################################################################################


5)Validate it (take very long time compare to install process)

$ cd ns-2.34
$ ./validate

6)Create a symlink, so that ns can be called from everywhere (replace /home/rams/Desktop with ur directory)

$ sudo ln -s /home/rams/Desktop/ns-allinone-2.34/ns-2.34/ns /usr/bin/ns

7)Let it take effect immediately

$ source ~/.bashrc


8) Try to run it (and pray :) )

$ ns

9)If the installation success, you will see % at the command prompt. Type following command to exit

% exit