Showing posts with label NS-2. Show all posts
Showing posts with label NS-2. Show all posts

Saturday, 19 October 2013

NS2 : Simulating Link State Routing


  The post provides the NS2 Script (TCL Script) to simulate a wired network using Link State Routing Protocol.

Execution of the Script

Network Topology in NAM

Data Transfer & Link Failure

Data Transfer through Alternate Path

Second Link Fails & Data Transfer through Alternate Path



NS2 : Simulating Distance Vector Routing


  The post provides the NS2 Script (Tcl Script) to simulate a wired network using Distance Vector Routing Protocol.

Execution of the Script

NAM Showing the Network Topology

Data Transfer in NAM

First Link Fails

Data Transfer through Alternate Path

Second Link Fails & Data Transfer through Alternate Path



Sunday, 15 September 2013

NS2 : Simulating TCP in Wireless Networks


   This post provides the NS2 Script (Tcl Script) to simulate a wireless network using TCP.

Execution of the Script

Topology in NAM

Data Transfer in NAM


NS2 : Simulating UDP in Wireless Networks


   This post provides the NS2 Script (Tcl Script) to simulate a Wireless Network using UDP.

Execution of the Script

Topology in NAM


Data Transfer in NAM


OTcl Class Program


   OTcl refers to the object oriented extension of TclIt is used in Network Simulator (NS2). This post provides an example program involving OTcl Classes.

Program Execution


Tcl Program to Find the Square of a Number


      This post discusses the Tcl program to find the Square of a Number. 

Program Execution




NS2 : Simulating a Network using SFQ Queue Management Algorithm


   In this post the NS2 Script (TCL Script) to simulate a wired network using SFQ (Stochastic Fairness Queuing) queue management algorithm is provided.

Executing the TCL Script

Topology in NAM

Data Transfer in NAM

   
Click here to download the NS2 Script.

NS2 : Simulating Multicast in Wired Networks


      In this post I have added the NS2 Script (TCL Script) to simulate multicast in wired networks.   

Executing the TCL Script

Topology Shown in NAM

Data Transfer in NAM

Data Transfer in NAM


Thursday, 5 September 2013

NS2 : Simulating a Network using RED Queue Management Algorithm


   In this post the NS2 Script (TCL Script) to simulate a wired network using RED (Random Early Discard) queue management algorithm is provided.

Executing the TCL Script

Topology in NAM Animator

NAM Showing Packet Drop



NS2 : Simulating a Network using Drop Tail Queue Management Algorithm


   This post contains NS2 Script (TCL Script) to simulate a wired network using Drop Tail queue management algorithm.

Executing the TCL Script

NAM Animator Showing the Topology

NAM Showing Data Transfer 



Tuesday, 20 August 2013

NS2 : Wireless Simulation 2


   This post contains NS2 Script (TCL Script) to simulate a simple Wireless Network. The simulation involves wireless nodes which move from one position to another occasionally. 

Executing the TCL Script

Initial Node Position

Node Position after Movement



Wednesday, 7 August 2013

NS2 : Simulating Link Failure in Wired Networks


   In this post I have included the NS2 Script (TCL Script) for simulating link failure in wired networks. 

$ns rtmodel-at 1.0 down $n1 $n2
The code given above will fail the link between Node n1 and Node n2 at time 1.0.

$ns rtmodel-at 2.0 up $n1 $n2
The code given above will reconnect the link between Node n1 and Node n2 at time 2.0.

Executing the TCL Script

Simulated Network in NAM

Initial Traffic Flow Simulation in NAM

Link Between Node1 and Node2 Failed

 Traffic Flow through a Different Path

Link Between Node1 and Node2 is Up Again


NS2 : Simulating a Simple Wired Network Using TCP


   In this post I have added the NS2 Script (TCL Script) to simulate a Simple Wired Network using TCP (Transmission Control Protocol). 

Executing the TCL Script


NAM Window Showing the Network


NAM Window Showing the Traffic


  Click here to download the NS2 Script.

NS2 : Simulating a Simple Wired Network Using UDP

  
  This post gives the NS2 Script (TCL Script) to simulate a simple network using UDP (User Datagram Protocol ). The Shell command to execute the script is shown below.

Executing the script udp.tcl

NAM Window Showing the Simulation


Tuesday, 6 August 2013

Installing NAM on Fedora 17


  After installing NS-2.35 on Fedora 17 by calling the script ./install on the shell the following message is printed on the screen many often. "Please compile your nam separately". The message tells us that the NAM utility has not been installed properly. In order to install the NAM utility change the file xwd.c

The location of the file xwd.c is ns-allinone-2.35/nam-1.15/xwd.c. In the file xwd.c comment the following line of code as shown below.

// #include <X11/Xmu/WinUtil.h>

Save the file xwd.c.

Run the ./install script on the Shell again. NAM utility will be installed properly.

       

Installing NS-2.35 on Fedora 17


  Installing NS-2 on Fedora 17 only requires executing the ./install command on the Shell. But many often the Make process will fail. If the Make process fails then change the file ls.h.

The location of ls.h is the location of ls.h is  ~/ns-allinone-2.35/ns-2.35/linkstate/ls.h.

Open the file ls.h and change the code in line number 137.

The code in line line number 137 is  void eraseAll( ) { erase(baseMap::begin( ), baseMap::end( )); }  

Change it into the code given below,
void eraseAll( ) { this->erase(baseMap::begin( ), baseMap::end( )); } 

After making the change save the file ls.h.

Now again run the script ./install in the Shell. The installation will be complete.

Friday, 9 November 2012

Xgraph for plotting in NS-2



After running your NS-2 program you will have a trace file as output.

Let us assume the name of the output file is "trace1.tr"

The trace file might look like below

+ 1             0 2 cbr 210 ------- 0 0.0 3.1 0 0
- 1              0 2 cbr 210 ------- 0 0.0 3.1 0 0
r  1.00212  0 2 cbr 210 ------- 0 0.0 3.1 0 0
+ 1.00212  0 2 cbr 210 ------- 0 0.0 3.1 0 0
+ 1.055      0 3 cbr 210 ------- 0 0.0 3.1 0 0

I am not explaining the meaning of the trace file. Instead I am giving instructions to use xgraph to draw a graph involving data extracted from the trace file.

To use xgraph we need 2 columns of data. The Unix command called "cut" is used for this purpose.

Open terminal and type the following commands

###############################

    cut  -d  " "  -f  2  trace1.tr  >  file1

    cut  -d  " "  -f  6  trace1.tr  >  file2

    paste      file1     file2    >   output

    xgraph   output

###############################

This will extract columns 2 and 6 and then draw a graph using the xgraph utility.

 
 for "cut" keyword -d specifies the delimiter between columns.
 Here the delimiter is white space ("  ").
 -f specifies the column number of the data to be extracted.