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…

Promiscuous Mode in AODV (ns 2.34)

In a network, promiscuous mode allows a network device to intercept and read each network packet that arrives in its entirety. This mode of operation is sometimes given to a network snoop server that captures and saves all packets for analysis (for example, for monitoring network usage). Its often used to
monitor network activity

Files to be changed
1. ~ns-2.34/aodv/aodv.h
2. ~ns-2.34/aodv/aodv.cc
3. ~ns-2.34/lib/tcl/ns-mobilenode.tcl

1. Make AODV agent a child class of Tap (you should have a member function tap), and define the Mac variable

   1: #include <mac.h>
   2: class AODV: public Tap, public Agent {
   3: public:
   4: void tap(const Packet *p);
   5: ......
   6: protected:
   7: Mac *mac_;
   8: ......
   9: }

2. Modify aodv/aodv.cc
Define TCL command "install-tap" and implement AODV::tap()


   1: int AODV::command(int argc, const char*const* argv) {
   2:  
   3: ......
   4:  
   5: else if(argc == 3) {
   6:  
   7: ......
   8:  
   9: else if (strcmp(argv[1], "install-tap") == 0) {
  10: mac_ = (Mac*)TclObject::lookup(argv[2]);
  11: if (mac_ == 0) return TCL_ERROR;
  12: mac_->installTap(this);
  13: return TCL_OK;
  14: }
  15:  
  16: } 
  17: return Agent::command(argc, argv);
  18:  
  19:  
  20: }
  21:  
  22: void AODV::tap(const Packet *p) {
  23: //put your code here
  24: fprintf(stdout,"Node in Promiscuous Mode");
  25: } 
  26:  


3. Modify tcl/lib/ns-mobilenode.tcl


   1: Node/MobileNode instproc add-target { agent port } {
   2: $self instvar dmux_ imep_ toraDebug_ mac_
   3: ......
   4: # Special processing for AODV
   5: set aodvonly [string first "AODV" [$agent info class]] 
   6: if {$aodvonly != -1 } {
   7: $agent if-queue [$self set ifq_(0)] ; # ifq between LL and MAC
   8: $agent install-tap $mac_(0)
   9: ......
  10: }

Popular posts from this blog

AWK Scripts for NS2 to process data from Trace Files

Xgraph

ns2 installation in Ubuntu 14.04