Install and Run NS-2.35 on Ubuntu 16.04

NS-2 is a very popular network simulation platform. Further, you can install it on windows. However, Linux provides all environments for network simulator version 2. In addition, it was developed considering the Linux environment. Such as it needs GCC compiler.

Moreover, NS-2 provides protocols such as TCP ( Transmission Control Protocol), UDP ( User Datagram Protocol) at the transport layer. At the application layer, it provides  CBR (Constant Bit Rate), FTP (File Transfer Protocol ), Exponential traffic, and Pareto traffic.

Furthermore, it provides ad hoc networks protocols for simulation in default version NS-2 are.

1- DSDV ( Destination Sequenced Distance Vector)

3- DSR ( Dynamic Source Routing)

3- AODV ( Ad Hoc On-Demand Distance Vector)

4- TORA( Temporarily Ordered Routing Algorithm)

Besides ad hoc network routing protocols it provides Ethernet model (802.3), wireless network

model ( IEEE 802.11) and IEEE 802.15.4 for PAN ( Personal Area Network) and sensor networks.

 

In this post, I will explain that how to install and run NS-2 TCL scripts stepwise.

 

Step-1 Update and install prerequisites packages.

Using these commands

$sudo apt-get update
$sudo apt-get dist-upgrade
$sudo apt-get update
$sudo apt-get gcc
$sudo apt-get install build-essential autoconf automake
$sudo apt-get install tcl8.5-dev tk8.5-dev
$sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev

 

Step-2 Download  ns-allinone-2.35.tar.gz, and you will see the following file.

NS-2 tar file
NS-2 tar file

Step-3 Select the file and click the right mouse button and choose option extract here.

Step-4 After extracting type on the command prompt.

$cd  ns-allinone-2.35

Step-5 Run Command   ./install  see in the image.

 

 

NS-2 Install
NS-2 Install

Step-6 Set the path of the NS-2 for global access.

Use command

$sudo gedit ~/.bashrc

It will open a file .bashrc

Set the path

# LD_LIBRARY_PATH
OTCL_LIB=/Yourpath/ns-allinone-2.35/otcl-1.14
NS2_LIB=Yourpath/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=/Yourpath/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/Yourpath/ns-allinone-2.35/bin:/Yourpath/ns-allinone-2.35/tcl8.5.10/unix:/Yourpath/ns-allinone-2.35/tk8.5.10/unix
NS=/Yourpath/ns-allinone-2.35/ns-2.35/ 
NAM=/Yourpath/ns-allinone-2.35/nam-1.15/ 
PATH=$PATH:$XGRAPH:$NS:$NAM

 

When you set the path, save the file and restart the system.

And type the command ns

The symbol % will appear that means NS-2.35 is correctly installed.

 

Ns-2 TCL ( Tool Command Language)-

TCL file in NS-2 is used for network configuration such as.

Size of network area, mobility, nodes of energy, TCP/IP protocols and simulation time.

When you run a tcl file in example aodv.tcl using command $ns aodv.tcl. It will generate two files out .nam and out.tr. The first one is for animation and the second one for statistics.

As you can see in figure.

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

©Postnetwork-All rights reserved.