Sunday, 18 January 2015

How to install ns2 network simulator on linux

To install ns2 network simulator on linux you to need download some libraries in addition to downloading the actual package and also have to add some environment vaiables.

Follow these steps to download ns2 in your linux machine.

1. Download these libraries
    $ sudo apt-get update
    $ sudo apt-get install tcl8.5-dev tk8.5-dev build-essential autoconf automake perl xgraph libxv-dev libxt-dev libx11-dev

While you are downloading these libraries you may notice some of these were already installed.

2. Now after downloading all the libraries download ns2 package, you can easily find that on web or you can do this. http://sourceforge.net/projects/nsnam/
  

   $ tar -xzf ns-allinone-2.35.tar.gz
   $ cd ns-allinone-2.35

Before installing it
   $ gedit ns-2.35/linkstate/ls.h

In line 137 change erase() to this->erase() 
   $ ./install 

3. After downloading all the required package and libraries, set the environmental variable path to otcl, ns2 and nam in .bashrc file.
Change /home/shubham/ns2 with your path to ns-allonone-2.34

# LD_LIBRARY_PATH
OTCLLIB=/home/shubham/ns2/ns-allinone-2.35/otcl-1.14
NS2=/home/shubham/ns2/ns-allinone-2.35/lib
USR_LocalLIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCLLIB:$NS2:$USR_LocalLIB

# TCL_LIBRARY
TCLIB=/home/shubham/ns2/ns-allinone-2.35/tk8.5.10/library
USRLIB=/usr/lib
export TCL_LIBRARY=$TCLIB:$USRLIB

# PATH
XGRAPH=/home/shubham/ns2/ns-allinone-2.35/xgraph-12.2/:/path/to/ns-allinone-2.35/bin:/path/to/ns-allinone-2.35/tcl8.5.10/unix:/path/to/ns-allinone-2.35/tk8.5.10/unix
NS=/home/shubham/ns2/ns-allinone-2.35/ns-2.35
NAM=/home/shubham/ns2/ns-allinone-2.35/nam-1.15
export PATH=$PATH:$XGRAPH:$NS:$NAM

4. Now validate it.
   $ source .bashrc
   $ cd ns-allinone-2.35
   $ cd ns-2.35
   $ ./validate

Now ns2 will be installed and to check if it is installed then type ns and press enter if symbol changes to % then ns is installed.
   $ ns
   %
 
 
 

3 comments:

  1. 'sudo apt-get install ns' worked for me

    ReplyDelete
    Replies
    1. If you are true ubuntu fan you will follow the steps

      Delete
  2. thanks man works for fedora too...just use yum instead of apt-get

    ReplyDelete