Adding a malicious node is ns2 using aodv protocol. The node which is declared as malicious will simply drop the router packet (DROP_RTR_ROUTE_LOOP). Two files have to be modified. 1. aodv.h 2. aodv.cc aodv.h file changes Declare a boolean variable malicious as shown below in the protected scope in the class AODV bool malicious; aodv.cc file changes 1. Initialize the malicious varible with a value "false". Declare it inside the constructor as shown below AODV::AODV(nsaddr_t id):Agent(PT_AODV)... { ....... malicious = false; } 2. Add the following statement to the aodv.cc file in the "if(argc==2)" statment. if(strcmp(argv[1], "malicious") == 0) { malicious = true; return TCL_OK; } 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); } Onc...
Its all about Network Simulations (NS2, NS3), Internet of Things, Sensor Networks, Programming, Embedded Systems, Cyber Physical Systems, etc