To install ns2.34 in ubuntu11.04
This method , pls, read carefully...!
Step 1 : Download the ns-allinone-2.34 from this site:
http://bit.ly/downloadns
Step 2 : Place the ns-allinone-2.34.tar.gz package in your home folder(/home/micman in my case). Right click the package and extract the contents in the same folder.
Step 3: Next, open the Terminal (Applications --> Accessories --> Terminal) or [ctrl+ alt + t]
Step 4: Change to ns-allinone2.34 directory
$ cd /home/kuldip/ns-allinone-2.34
Step 5: First install all the dependencies
$ sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.4 g++-4.4
$ sudo apt-get install xorg-dev xgraph
Edit Makefile.in found at this location ns-allinone-2.34/otcl-1.13/Makefile.in as follows:
Find the line that says:
CC= @CC@
and change it to:
CC= gcc-4.4
Fix the error in the linking of otcl by editing line 6304 of otcl-1.13/configure so that it reads
SHLIB_LD="gcc -shared"
instead of
SHLIB_LD="ld -shared"
Change the line 270 in tcl8.4.18/unix/Makefile.in that reads
CC = @CC@
so it appends the version parameter for version 4.4:
CC = @CC@ -V 4.4
Make sure it is a capital V.
$ sudo gedit ns-2.34/tools/ranvar.cc
change the line 219 from
return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
to
return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
$ sudo gedit ns-2.34/mobile/nakagami.cc
change the lines 183 and 185 in file ns-2.34/mobile/nakagami.cc to read
resultPower = ErlangRandomVariable(Pr/m, int_m).value();
and
resultPower = GammaRandomVariable(m, Pr/m).value();
Now the code will compile if you run ./install.
Change the line 270 in tcl8.4.18/unix/Makefile.in that reads
CC = @CC@
so it appends the version parameter for version 4.4:
CC = @CC@ -V 4.4
Make sure it is a capital V.
Finally, run ./install from the ns-allinone-2.34 top folder again.
Step 6 : Begin ns2.34 installation
$ sudo su
# ./install
step7: Once the installation is successful i.e without any errors, we need to add the path information to the file /home/micman/.bashrc
$ sudo gedit /home/kuldip/.bashrc
Append the following lines to the file /home/kuldip/.bashrc (after replacing the instances where you find kuldip with your username)
# LD_LIBRARY_PATH
OTCL_LIB=/home/kuldip/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/kuldip/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/kuldip/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/kuldip/ns-allinone-2.34/bin:/home/kuldip/ns-allinone-2.34/tcl8.4.18/unix:/home/kuldip/ns-allinone-2.34/tk8.4.18/unix
#the above two lines beginning from xgraph and ending with unix should come on the same line
NS=/home/kuldip/ns-allinone-2.34/ns-2.34/
NAM=/home/kuldip/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM
For the changes to take effect immediately, do the following:
$ sudo su
# source /home/kuldip/.bashrc
$ ns
$ %
means mission complete
for tcl file testing
$ ns example.tcl
$ nam
IF Network Animator is not opening, then
$ sudo apt-get install nam