Friday, 10 February 2012

Installing ns2 in Linux.

Installing ns2 in Ubuntu in very simple steps



NS (version 2) is an object-oriented, discrete event driven network simulator developed at UC Berkely written in C++ and OTcl. Nns is popularly used in the simulation of routing and multicast protocols, among others, and is heavily used in ad-hoc networking research. ns supports an array of popular network protocols, offering simulation results for wired and wireless networks alike. It can be also used as limited-functionality network emulator. It is popular in academia for its extensibility (due to its open source model) and plentiful online documentation.NS was built in C++ and provides a simulation interface through OTcl, an object-oriented dialect of Tcl. The user describes a network topology by writing OTcl scripts, and then the main NS program simulates that topology with specified parameters.


1.  To install ns2 in your system you need to have root privileges.
If you don't know the root password or the root account is disabled you can change its password by referring to my older post here.

2. Open the terminal and switch to the root user mode by typing the command su and entering the root password.

3. Install the missing dependencies by typing the command:
apt-get install build-essential autoconf automake libxmu-dev libxt-dev libxt6 libsm-dev libsm6 libice-dev libice6

4. Now you need to change the otcl configuration file. Type the command:
gedit /<location of ns-allinone>/otcl-1.*/configure

(for eg: if your username is nickhalden and ns-allinone folder is present in your home folder and the ns version is 2.34 and otcl version is otcl-1.13 you will type gedit /home/nickhalden/ns-allinone-2.34/otcl-1.13/configure )

5. Search for Linux* in the file and change the line:
SHLIB_LD="ld -shared"
to
SHLIB_LD="gcc -shared"

6. Go to the location of ns-allinone folder by typing:
cd /home/nickhalden/ns-allionone-2.34

7. Install ns2 by typing the command: ./install

8. Set environmental variables by typing: gedit ~/.bashrc

Append the following lines at the end of the file.

OTCL_LIB=/home/nickhalden/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/nickhalden/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/nickhalden/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/nickhalden/ns-allinone-2.34/bin:/home/nickhalden/ns-allinone-2.34/tcl8.4.18/unix:/home/nickhalden/ns-allinone-2.34/tk8.4.18/unix
NS=/home/nickhalden/ns-allinone-2.34/ns-2.34/
NAM=/home/nickhalden/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM


replace /home/nickhalden/ns-allione-2.34 based on the location of ns2 in your system and the version of ns2 you are installing.

9. Restart the terminal, switch to the root mode and type: ns
If a % sign appears the installation is successful.

No comments:

Post a Comment