Network Simulator 2 Installation (NS2)

Ns is a discrete event simulator targeted at networking research. Ns provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks.[1]

You can download ns2 files from http://sourceforge.net/projects/nsnam/files/allinone/. In this documentation we use Ubuntu 10.04 32bit as operating system. You can download iso file from http://old-releases.ubuntu.com/releases/lucid/ubuntu-10.04-desktop-i386.iso

1. NS 2.35

  • Root access
sudo su
  • Re-synchronize the package index files from sources
apt-get update
  • Extract the tar.gz file
tar -xvf ns-allinone-2.35.tar.gz

Note

Check the directory which ns-allinone-2.35.tar.gz downloaded

  • Install packages
sudo apt-get install build-essential autoconf automake libxmu-dev
_images/ns2.png
  • Move to ns2 directory
cd /home/cnc/ns-allinone-2.35
_images/ns5.png

Note

Check your own path, in this documentation we use /home/cnc/

  • Install ns2
./install
  • When the installation succed it will be like this
_images/ns3.png
  • Edit bashrc
nano ~/.bashrc
  • Add this to bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/cnc/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/cnc/ns-allinone-2.35/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/cnc/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/cnc/ns-allinone-2.35/bin:/home/cnc/ns-allinone-2.35/tcl8.5.10/unix:/home/cnc/ns-allinone-2.35/tk8.5.10/unix
NS=/home/cnc/ns-allinone-2.35/ns-2.35/
NAM=/home/cnc/ns-allinone-2.35/nam-1.15/
PATH=$PATH:$XGRAPH:$NS:$NAM
  • Source
source ~/.bashrc
  • check ns-ver
ns

ns-ver
_images/ns6.PNG
ns ns-simple.tcl
_images/ns7.png

2. NS 2.34

  • Root access
sudo su
  • Re-synchronize the package index files from sources
apt-get update
  • Extract the tar.gz file
tar -xvf ns-allinone-2.34.tar.gz

Note

Check the directory which ns-allinone-2.34.tar.gz downloaded

  • Install packages
sudo apt-get install build-essential autoconf automake libxmu-dev
_images/ns2.png
  • Open file in otcl-1.13/configure
nano +6304 /home/cnc/ns-allinone-2.34/otcl-1.13/configure
  • Replace SHLIB_LD=”ld -shared” into SHLIB_LD=”gcc -shared”
_images/ns8.png
  • Move to ns2 directory
cd /home/cnc/ns-allinone-2.34

Note

Check your own path, in this documentation we use /home/cnc/

  • Install ns2
./install
  • When the installation succed it will be like this
_images/ns234.png
  • Edit bashrc
nano ~/.bashrc
  • Add this to bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/cnc/ns-allinone-2.34/otcl-1.13
NS2_LIB=/home/cnc/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/cnc/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/cnc/ns-allinone-2.34/bin:/home/cnc/ns-allinone-2.34/tcl8.4.18/unix:/home/cnc/ns-allinone-2.34/tk8.4.18/unix
NS=/home/cnc/ns-allinone-2.34/ns-2.34/
NAM=/home/cnc/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM
  • Source
source ~/.bashrc
  • check ns-ver
ns

ns-ver
_images/ns234ver.png
ns ns-simple.tcl
_images/ns234nam.png

3. NS 2.33

  • Root access
sudo su
  • Re-synchronize the package index files from sources
apt-get update
  • Extract the tar.gz file
tar -xvf ns-allinone-2.33.tar.gz

Note

Check the directory which ns-allinone-2.33.tar.gz downloaded

  • Install packages
sudo apt-get install build-essential autoconf automake libxmu-dev
_images/ns2.png
  • Open file in otcl-1.13/configure
nano +5518 /home/cnc/ns-allinone-2.33/otcl-1.13/configure
  • Replace SHLIB_LD=”ld -shared” into SHLIB_LD=”gcc -shared”
_images/ns8.png
  • Patch for NAM [2]
cd /home/cnc/ns-allinone-2.33/tk8.4.18
  • Create a document
nano tk-8.4-lastevent.patch
_images/ns233tk.png
  • To apply the patch
patch -p0 < ./tk-8.4-lastevent.patch
_images/nampatch.png
  • Move to ns2 directory
cd /home/cnc/ns-allinone-2.33

Note

Check your own path, in this documentation we use /home/cnc/

  • Install ns2
./install
  • When the installation succed it will be like this
_images/ns233.png
  • Edit bashrc
nano ~/.bashrc
  • Add this to bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/cnc/ns-allinone-2.33/otcl-1.13
NS2_LIB=/home/cnc/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/cnc/ns-allinone-2.33/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/cnc/ns-allinone-2.33/bin:/home/cnc/ns-allinone-2.33/tcl8.4.18/unix:/home/cnc/ns-allinone-2.33/tk8.4.18/unix
NS=/home/cnc/ns-allinone-2.33/ns-2.33/
NAM=/home/cnc/ns-allinone-2.33/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM
  • Source
source ~/.bashrc
  • check ns-ver
ns

ns-ver
_images/ns233ver.png
ns ns-simple.tcl
_images/ns233nam.png

4. NS 2.32

  • Root access
sudo su
  • Re-synchronize the package index files from sources
apt-get update
  • Extract the tar.gz file
tar -xvf ns-allinone-2.32.tar.gz

Note

Check the directory which ns-allinone-2.32.tar.gz downloaded

  • Install packages
sudo apt-get install build-essential autoconf automake libxmu-dev
_images/ns2.png
  • Open file in otcl-1.13/configure
nano +5516 /home/cnc/ns-allinone-2.32/otcl-1.13/configure
  • Replace SHLIB_LD=”ld -shared” into SHLIB_LD=”gcc -shared”
_images/ns8.png
  • Patch for NAM [2]
cd /home/cnc/ns-allinone-2.32/tk8.4.15
  • Create a document
nano tk-8.4-lastevent.patch
_images/ns232tk.png
  • To apply the patch
patch -p0 < ./tk-8.4-lastevent.patch
_images/nampatch232.png

Note

Check your own path, in this documentation we use /home/cnc/

  • Move to ns2 directory
cd /home/cnc/ns-allinone-2.32
  • Install ns2
./install
  • When the installation succed it will be like this
_images/ns232.png
  • Edit bashrc
nano ~/.bashrc
  • Add this to bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/cnc/ns-allinone-2.32/otcl-1.13
NS2_LIB=/home/cnc/ns-allinone-2.32/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/cnc/ns-allinone-2.32/tcl8.4.15/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/cnc/ns-allinone-2.32/bin:/home/cnc/ns-allinone-2.32/tcl8.4.15/unix:/home/cnc/ns-allinone-2.32/tk8.4.15/unix
NS=/home/cnc/ns-allinone-2.32/ns-2.32/
NAM=/home/cnc/ns-allinone-2.32/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM
  • Source
source ~/.bashrc
  • check ns-ver
ns

ns-ver
_images/ns232ver.png
ns ns-simple.tcl
_images/ns232nam.png

5. NS 2.31

  • Root access
sudo su
  • Re-synchronize the package index files from sources
apt-get update
  • Extract the tar.gz file
tar -xvf ns-allinone-2.31.tar.gz

Note

Check the directory which ns-allinone-2.31.tar.gz downloaded

  • Install packages
sudo apt-get install build-essential autoconf automake libxmu-dev
_images/ns2.png
  • Open file in otcl-1.13/configure
nano +5516 /home/cnc/ns-allinone-2.31/otcl-1.13/configure
  • Replace SHLIB_LD=”ld -shared” into SHLIB_LD=”gcc -shared”
_images/ns8.png
  • Patch for NAM [2]
cd /home/cnc/ns-allinone-2.31/tk8.4.14
  • Create a document
nano tk-8.4-lastevent.patch
_images/ns232tk.png
  • To apply the patch
patch -p0 < ./tk-8.4-lastevent.patch
_images/nampatch232.png
  • Move to ns2 directory
cd /home/cnc/ns-allinone-2.31

Note

Check your own path, in this documentation we use /home/cnc/

  • Install ns2
./install
  • When the installation succed it will be like this
_images/ns231.png
  • Edit bashrc
nano ~/.bashrc
  • Add this to bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/cnc/ns-allinone-2.31/otcl-1.13
NS2_LIB=/home/cnc/ns-allinone-2.31/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/cnc/ns-allinone-2.31/tcl8.4.14/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/cnc/ns-allinone-2.31/bin:/home/cnc/ns-allinone-2.31/tcl8.4.14/unix:/home/cnc/ns-allinone-2.31/tk8.4.14/unix
NS=/home/cnc/ns-allinone-2.31/ns-2.31/
NAM=/home/cnc/ns-allinone-2.31/nam-1.13/
PATH=$PATH:$XGRAPH:$NS:$NAM
  • Source
source ~/.bashrc
  • check ns-ver
ns

ns-ver
_images/ns231ver.png
ns ns-simple.tcl
_images/ns231nam.png
Sources :