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



Monday 12 August 2013

NS2 : Wireless Simulation 1


   In this post I have included the TCL Script for wireless simulation using NS2. Xgraph utility is used to plot the graph of Congestion Window VS Time.

Executing the TCL Script

NAM Window Showing the Nodes

NAM Window Showing the Traffic

Graph Plotted Using Xgraph


Wednesday 7 August 2013

NS2 : Xgraph Utility Example


   In this post I have included an NS2 Script (TCL Script) calling the Xgraph utility to plot the graph.

The Xgraph utility is called by the following line of code in the TCL Script,

exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &


The three files out0.tr, out1.tr and out2.tr contains the input data for Xgraph. To learn about the data format of Xgraph input files read my post Xgraph for plotting in NS-2.

Executing The TCL Script

NAM Window Showing the Simulated Network

NAM Showing Traffic Flow

Graph Plotted Using Xgraph




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.