> We need to modify two files,
i) aodv.h
ii) aodv.cc
> In aodv.h,
i)
/*
The Routing Agent
*/
class AODV: public Agent
{
..........
/*
* History management
*/
bool malicious;
..........
}
> In aodv.cc,
i)
AODV::AODV(nsaddr_t id) : Agent(PT_AODV), btimer(this), htimer(this),
ntimer(this), rtimer(this), lrtimer(this), rqueue()
{
index = id;
seqno = 2;
bid = 1;
malicious=false;
............
}
ii)
int AODV::command(int argc, const char*const* argv)
{
if(argc == 2)
{
Tcl& tcl = Tcl::instance();
if(strncasecmp(argv[1], "id", 2) == 0)
{
tcl.resultf("%d", index);
return TCL_OK;
}
if(strcmp(argv[1], "hacker") == 0)
{
malicious=true;
return TCL_OK;
}
...........
}
}
iii)
/*
Route Handling Functions
*/
void AODV::rt_resolve(Packet *p)
{
..........
// If i am a malicious node,
if (malicious == true)
{
drop(p, DROP_RTR_NO_ROUTE);
// DROP_RTR_NO_ROUTE is added for no reason
return; //Required if you get pkt flow not specified error.
}
.........
}
> In your tcl code,
> After packet transmission, add the following line
$ns at 0.0 "[$node_(0) set ragent_] hacker"
> Node 0 is set as malicious. It won't forward a packet.