A node is called as malicious when it will simply drop the router packets DROP_RTR_ROUTE_LOOP. For adding a malicious node to AODV protocol, we have to modify following files;
- aodv.h
- aodv.cc
Changes in aodv.h file
We have to declare a variable as shown below in the protected scope in the class AODV of aodv.h file
bool malicious;
Changes in aodv.cc file
The changes that have to make in .cc file is given below;
Step 1: Initialize the malicious variable with a value "false". Declare it inside the constructor as shown below
AODV::AODV(nsaddr_t id):Agent(PT_AODV)...
{
.......
malicious = false;
}
Step 2: Add the following statement to the aodv.cc file in the "if(argc==2)" statement.
if(strcmp(argv[1], "malicious") == 0) {
malicious = true;
return TCL_OK;
}
Step 3: Implement the behavior of the malicious node by setting the following code in the rt_resolve(Packet *p) function. The malicious node will simply drop the packet as indicated below.
if(malicious==true)
{
drop(p,DROP_RTR_ROUTE_LOOP);
}
Once done, recompile ns2 as given below;
Open Terminal -> Go to ~ns-2.35/ directory and type the command make to compile
cd /home/user/ns-allinone-2.35/ns-2.35/ [its vary with your directory path]
cd /home/user/ns-allinone-2.35/ns-2.35/ [its vary with your directory path]
make
Once the compilation is done, Check the malicious behavior using the Tcl Script by setting any one node as malicious node. The command to set the malicious node is
$ns at 0.0 "[$n2 set ragent_] malicious"
The variable referred for node2 is n2 (set n2 [$ns node])
Comments
Post a Comment