07 May 2014

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