Pages

Friday, June 25, 2010

Installing ns2 on Ubuntu 9.10

A lot of people dread having to install ns2. Well here is a simple tutorial to get you through in just a single go. Mostly people fail at installing ns2 in the first go because of the missing libraries and dependencies.

Here is what you do to install ns2 in the first go.

1. Download ns-allinone-2.34

2. cd into the directory where you have downloaded the ns-allinone-2.34.tar.gz file. Then issue the command cp ns-allinone-2.34.tar.gz ~/

3. Then type cd ~/ to get into your home folder

4. Then use the command tar -xvzf ns-allinone-2.34.tar.gz

5. But before you can continue you need to install the following libraries

autoconf
automake
gcc
g++
build-essential
libxmu-dev
libtool
libxt-dev

6. You can download and install the libraries individually using the command sudo apt-get install libraryname e.g
sudo apt-get install autoconf

7. Now you are all set to proceed, but before you do there is one more modification that needs to be made, cd into ns-allinone-2.34/otcl-1.13 and then use the command gedit configure to make the following changes to the configure file.

change the following line
SHLIB_LD = "ld -shared" to SHLIB_LD = "gcc -shared", you would find that the string SHLIB_LD occurs at many places, you are to change the one that is written under Linux*)

OR you may try typing export CC = gcc-4.3 to change the environment variable, though i have not tried this seemingly easier method. (note: run the command gcc -v to check your version to use in the above command)

8. Now cd into the ns-allinone-2.34 directory and do ./install , hopefully everything will go smoothly and you ns-2 will be installed. But before you can proceed you need to set the environment variables.

gedit ~/.bashrc

copy the following lines at the end of the file, be sure to change /your/path to the path where ns is installed on your system.

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

# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

for instance on my system i would replace /your/path with /home/z3d

9. source ~/.bashrc to have the changes take effect or you can simply reopen terminal.

10. Now cd into the folder /ns-allinone-2.34/ns-2.34/ and type the command ./validate
it will take a considerably longer time than it did to install and in almost an hour you should get a message all tests successful.

11. Now you can type ns and begin doing your work :)

No comments:

Post a Comment