29 March 2015

Security Protocol (packet) in NS2

Security is not my area of work, but most of the places, I have been bombarded with questions like , is it possible to implement security protocol in ns2.
The answer is yes, here is the solution for that.  Here is the document to read
This work is done in 2005 and developed for ns version 2.26 or 2.27. I have done the compilation for ns-2.35
The files to be modified
1. Create a new agent called "Security_packet" and two files Security_packet.h and Security_packet.cc are created.
2. Add a new packet type in ~ns-2.35/common/packet.h
3. Add a new packet type in ~ns-2.35/tcl/lib/ns-default.tcl
4. Add a new packet type in ~ns-2.35/tcl/lib/ns-packet.tcl
5. modify the ~ns-2.35/Makefile.in

Steps
1. Download the two files here
2. Copy the security.cc and security.h file in ~ns-2.35/security folder (create the security/ folder and paste both the files)
3. Open ~ns-2.35/Makefile.in and make an entry as shown below,
OBJ_CC =
......
...
             security/security.o

security
Makefile
4. Open the ~ns-2.35/common/packet.h file
There will be two changes
Change one
static const packet_t PT_SECURITY_PACKET=74;
as shown below
security
packet.h
and another change
name_[PT_SECURITY_PACKET]= "Security_packet";
as shown below

security
packet.h


5. Open the file ~ns-2.35/tcl/lib/ns-default.tcl, and paste the following line at the end of the file
Agent/Security_packet set packetSize_ 0

See below
security
ns-default.tcl
6.  open the file ~ns-2.35/tcl/lib/ns-packet.tcl, Input the following line 
Security_packet
as shown below
Security
ns-packet.tcl

To Compile

Open the terminal, 
$] cd ~ns-allinone-2.35/ns-2.35/
$] ./configure
$] make

Run the security.tcl file using the ns command 
$] ns security.tcl

See the output, Since my area is not on the security, read the document/source code yourself
Security
Security

Thats it!!!

T S Pradeep Kumar