from website

First of all create a directory in your ns-2.34 directory with the following files.

  1. protoname_pkt.h
  3. protoname_rtable.h
  4.        # Note the capital P in the beginning and must be capital P
  5. protoname.h
The code for protoname_pkt.h is given below


The code for is given below

The code for protoname_rtable.h is given below


The code for is given below


The code for protoname.h is given below

Note: Now we have to make changes to certain ns-2.34 files. The steps given below are most important for successful implementation so perform them very carefully.
Open file packet.h under ns-2.34/common/packet.h. Do the changes given below.
Under typedef unsigned int packet_t; lots of constants would have been defined.
Go down and at Line 182 u will find



Open the file ns-packet.tcl under ns-2.34/tcl/lib/ns-packet.tcl

Search at Line 113 for

foreach prot {

Enter the following after to it to make it look like this


Open the file ns-default.tcl under ns-2.34/tcl/lib/ns-default.tcl

In the end of the file enter the following line

Open the file ns-lib.tcl under ns-2.34/tcl/lib/ns-lib.tcl

Search at Line 604 for the function


To make it look like this


Now in the same file go at last or end and enter the following lines


Open file under ns-2.34/queue/
Search for the function at Line 82.

After case PT_AOMDV: enter the following line


It should look like this


Now changes to be done in
Under INCLUDES add the following directory

Under OBJ_CC do the following changes at the end.

Now save your project and move to the command line Ctrl + Alt + T.

Browse to directory ns-2.34 under ns-allinone-2.34 directory.

Perform the following commands in order.

make clean
make depend // Optional
sudo make install
U shall get no errors. If you are getting any errors ask in the comments section.

Now we have to make a tcl file to test the protocol.


In home directory. Create a tcl file with the name exproto.tcl. The contents of the tcl file are as follows (I have defined 6 nodes)


$ns run

Save and close it.Now open terminal and type ns exproto.tcl.It shall run perfectly and nam should open.


now u have successfully implemented the unicast routing protocol for MANETs. U should not face any problems if you follow the above steps.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: