NS-2

Installation Guide for NS-2 under Linux


1- Download and install ns-allinone2.xx :


Go to the ns-2 official website to download the lateest version of ns-2
http://www.isi.edu/nsnam/ns/ns-build.html
or use this link for older versions
http://ftp.isi.edu/nsnam/dist/
or
http://www.isi.edu/nsnam/dist/
Download ns2.xx allinone package
Also you can use this command in your shell after you know the version to replace xx
wget http://ftp.isi.edu/nsnam/dist/ns-allinone-2.xx.tar.gz
or
wget http://www.isi.edu/nsnam/dist/ns-src-2.xx.tar.gz
put the package in an appropriate place and then extract by
tar -xzvf ns-allinone-2.xx.tar.gz
cd ns-allinone-2.xx
Now run this command to install ns-2 :
./install
————————————————————————————————————————————————————————————–

Important Tips :


1- For installing in Ubuntu, you may run this command before installing NS-2:
sudo apt-get install build-essential autoconf automake libxmu-dev

2- For installing ns-allinone2.26, 2.27, 2.28, 2.29, you may need a patch depending on your version of gcc.
You can download all the patches from this link: Click Here

  • For installing ns-allinone2.26, first download ns-allinone-2.26.tar.gz, and then:
    tar -xzvf ns-allinone-2.26.tar.gz
    patch -p0 < ns-2.26-gcc410.patch
    cd ns-allinone-2.26
    ./install
  • For installing ns-allinone2.27, first download ns-allinone-2.27.tar.gz, and then:
    tar -xzvf ns-allinone-2.27.tar.gz
    patch -p0 < ns-2.27-gcc410.patch
    cd ns-allinone-2.27
    ./install
  • For installing ns-allinone2.28, first download ns-allinone-2.28.tar.gz, and then:
    tar -xzvf ns-allinone-2.28.tar.gz
    patch -p0 < ns-2.28-gcc410.patch
    cd ns-allinone-2.28
    ./install

  • For installing ns-allinone2.29, first download ns-allinone-2.29.tar.gz, and then:
    tar -xzvf ns-allinone-2.29.tar.gz
    patch -p0 < ns2292-gcc410.patch
    cd ns-allinone-2.29
    ./install
————————————————————————————————————————————————————————————–

2- Set Environment Variable :

Use your shell  and go to your home folder and then edit this file:
cd
gedit ~/.bashrc

Add the following lines to the end of it. Remember replace “/home/mfouda/” by something like “/home/yourname/” where you put your package, also change the versions of ns-allinone-2, otcl, tcl, tcltk, and nam if required
These are examples for some ns-allinone-2 versions like ns-allinone-2.33, ns-allinone-2.29, and ns-allinone-2.26
————————————————————————————————————————————————————————————–
################### For NS-2.33

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

# PATH
XGRAPH=/home/mfouda/ns-allinone-2.33/bin:/home/mfouda/ns-allinone-2.33/tcl8.4.18/unix:/home/mfouda/ns-allinone-2.33/tk8.4.18/unix
NS=/home/mfouda/ns-allinone-2.33/ns-2.33/
NAM=/home/mfouda/ns-allinone-2.33/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM

################### End For NS-2.33

————————————————————————————————————————————————————————————–
################### For NS-2.29

# LD_LIBRARY_PATH
OTCL_LIB=/home/mfouda/ns-allinone-2.29/otcl-1.11
NS2_LIB=/home/mfouda/ns-allinone-2.29/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/mfouda/ns-allinone-2.29/tcl8.4.11/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/mfouda/ns-allinone-2.29/bin:/home/mfouda/ns-allinone-2.29/tcl8.4.11/unix:/home/mfouda/ns-allinone-2.29/tk8.4.11/unix
NS=/home/mfouda/ns-allinone-2.29/ns-2.29/
NAM=/home/mfouda/ns-allinone-2.29/nam-1.11/
PATH=$PATH:$XGRAPH:$NS:$NAM

################### End For NS-2.29

————————————————————————————————————————————————————————————–
################### For NS-2.26

# LD_LIBRARY_PATH
OTCL_LIB=/home/mfouda/ns-allinone-2.26/otcl-1.0a8
NS2_LIB=/home/mfouda/ns-allinone-2.26/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/mfouda/ns-allinone-2.26/tcl8.3.2/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/home/mfouda/ns-allinone-2.26/bin:/home/mfouda/ns-allinone-2.26/tcl8.3.2/unix:/home/mfouda/ns-allinone-2.26/tk8.3.2/unix
NS=/home/mfouda/ns-allinone-2.26/ns-2.26/
NAM=/home/mfouda/ns-allinone-2.26/nam-1.19/
PATH=$PATH:$XGRAPH:$NS:$NAM

################### End For NS-2.26

————————————————————————————————————————————————————————————–

Let it take effect immediately by running this command to refresh the bash:

source ~/.bashrc

Note: if ns unsuccessfully. you can restart your X windows, or reboot your system, to make it work Now,the installation has been completed. then try:

ns

Then a “%” will appear on the screen, type “exit” to quit the mode and back to “$”
————————————————————————————————————————————————————————————–

3- Validation:


cd ns-2.xx
./validate


you need to wait around 30 minutes to validate
————————————————————————————————————————————————————————————–

Useful Links

Official Website
NS for Beginners
Marc Greis's tutorial
Ns Manual
NS-related Mailing Lists
NS by Example
Network Simulator, NS-2 Blog

Projects


Extended Nam Editor
Packet-level Peer-to-Peer Simulation Framework and GnutellaSim
Simulation of BitTorrent Peer-to-Peer (P2P) Networks [NS 2.29]
802.11MX Reliable MAC Multicast Extension [NS 2.28 on Cygwin]
Multiple Description Coding (MDC) [NS 2.28]
WiMAX module for the ns-2 simulator