Queuing Models in NS2

Image
M/M/1 is a system with poisson arrival time, servicing exponentially and a queue of unlimited capacity and type of FIFO Queue. This is the simplest queuing system.  NS2 supports various distributions like pareto, exponential, constant, unifrom, etc to handle the network dynamics and metrics. So it is very easy to test the given network link to monitor a given queue using any of these queuing models. The listing 3 and 4 are monitoring the link when DropTail queue is used with a capacity of finite and infinite. Listing 13.3 uses infinite capacity and Listing 13.4 uses Finite capacity The output screen shot is shown below the scripts for further understanding
Listing 3 – M/M/1 Queuing Model #new Simulator creation set ns [new Simulator] #trace file creation for capturing the UDP data set tf [open out.tr w] $ns trace-all $tf
#setting the exponential distribution param set lambda 30.0 set mu     33.0
#creation of nodes set n1 [$ns node] set n2 [$ns node] #The queue limit is 1Lakh as the capacity is infin…

TORA Protocol in NS-2.35 (NS2)

This post tells you how to enable the TORA (Temporally ordered routing Algorithm) protocol in Network Simulator 2 (ns-2.35)

TORA is a protocol in wireless adhoc networks that works with timing parameters. NS-2.35 comes with the TORA protocol by default but it has to be tweaked manually to make it run.
This post will help you to do that.
Three files have to be modified

  • ~ns-2.35/tora/tora.cc
  • ~ns-2.35/tora/tora.h
  • ~ns-2.35/imep/imep.cc
There are various websites that tells you how to configure TORA by making changes to the above three files. 
Change 1: tora.h
In the tora.h file, go to the end of the File before the agent completes, include these two lines
protected:
PortClassifier *dmux_;

tora.h
Tora.h Change

Change 2: tora.cc
Open the tora.cc and include the following lines in the "int toraAgent::command(int argc, const char*const* argv) " function as indicated in the figure below.
else if (strcmp(argv[1], "port-dmux") == 0) {
                dmux_ = (PortClassifier *)TclObject::lookup(argv[2]);
            if (dmux_ == 0) {
               fprintf (stderr, "%s: %s lookup of %s failed\n", __FILE__, argv[1], argv[2]);
                return TCL_ERROR;
            }
            return TCL_OK;
            }
tora
Tora.cc Change

Change 3: imep.cc
In the file imep.cc, change the following line 


rexmitTimer.start(rexat - CURRENT_TIME);
to 
if (rexat-CURRENT_TIME<0.000001) // Preventing eternal loop.
rexmitTimer.start(0.000001);
else
rexmitTimer.start(rexat - CURRENT_TIME);

imep
IMEP Change
Once the changes are made, Open the Terminal and go to ~ns-2.35 and execute the command  
prompt$] make 
If you have any problem in implementing the code, download it from here 
Upon compilation, test the TORA protocol using a Tcl file 
Here is the animation screenshot and throughput of the network given in the above link

throughput tora
Throughput of generating packets for TORA
nam
Nam output for TORA protocol


T S Pradeep Kumar

Popular posts from this blog

AWK Scripts for NS2 to process data from Trace Files

Xgraph

LEACH protocol installation in ns2 (ns-2.35)