Friday, March 12, 2010

Adding Malicious Node in AODV

How to implement malicious drop in AODV. To write simple code for adding malicious node in AODV ( or in any routing protocol).

First you need to modify aodv.cc and aodv.h files. In aodv.h after

/* The Routing Agent */
class AODV: public Agent {
...
/*
* History management
*/
double PerHopTime(aodv_rt_entry *rt);
...

add following line

bool malicious;

/*
Constructor
*/
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;

add following line

malicious = false;

The above code is needed to initialize, and all nodes are initially not malicious. Then we will write a code to catch which node is set as malicious. In aodv.cc after

if(argc == 2) {
Tcl& tcl = Tcl::instance();

if(strncasecmp(argv[1], "id", 2) == 0) {
tcl.resultf("%d", index);
return TCL_OK;
}

add following line

if(strcmp(argv[1], "hacker") == 0) {
malicious = true;
return TCL_OK;
}

Now we will do some work in TCL to set a malicious node. Using script in my post , we add following line to set node 5 as malicious node.

$ns at 0.0 "[$mnode_(5) set ragent_] hacker"

You may add this line after

for {set i 0} {$i < $val(nn)} { incr i } {
$ns initial_node_pos $mnode_($i) 10
}
...

Alright, we have set malicious node but we did not tell malicious node what to do. As it is known, rt_resolve(Packet *p) function is used to select next hop node when routing data packets. So, we tell malicious node just drop any packet when it receives. To do that after

/*
Route Handling Functions
*/
void
AODV::rt_resolve(Packet *p) {
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
aodv_rt_entry *rt;
...

We add a few lines

// if I am malicious node
if (malicious == true ) {
drop(p, DROP_RTR_ROUTE_LOOP);
// DROP_RTR_ROUTE_LOOP is added for no reason.
}

And implementing malicious node is done. I hope the post will be helpful to design your secure routing protocol.

9 comments:

Unknown said...

sir when i change aodv.cc and aodv.h after run ./configure and make i found errror expected -id before else pls help me i m using ns 2.34

Unknown said...

Hi Sir, I wish u can help me...Actually I want to add malicious nodes to DSR...How can I do that???

Unknown said...

Dhaval,

Im not sure if you need the responce now... but, for the id error, im quite sure that you need to create a GOD-object in your TCL simulation script.

You need to associate each node in your simulation with a GOD object.

Hope this helps.

Mohan Dass. said...

I had tried this steps lot
nothing i get and i have got only this error only .........

IN tcl file

"hacker is invalid command name...."


i didn't get anything from this "Adding malicious Node in AODV " content only wasting my time only....

plz tell me its working or not
?? and you had tried this.....??
If it doest work plz you remove it becoz lot of people following this steps only finally they onl failure that'swhy ...i 'm also one of them....

Rubiya said...

hi sir
i want to know how to add malicious nodes to aodv in glomosim environment or simulator kindly help me and thanx in advance

arvind said...

sir i followed your above steps and modified aodv.h and aodv.cc files successfully but when i run my clusterhead.tcl file it shows following error:-
INITIALIZE THE LIST xListHead
for node_(0) to node(0) 0.0
for node_(0) to node(1) 57.801384066473702
for node_(0) to node(2) 240.26027553467927
for node_(0) to node(3) 234.79565583715555
for node_(0) to node(4) 220.65584062063709
for node_(0) to node(5) 23.853720883753127
for node_(2) to node(0) 240.26027553467927
for node_(2) to node(1) 228.98908270919816
for node_(2) to node(2) 0.0
for node_(2) to node(3) 12.806248474865697
for node_(2) to node(4) 20.591260281974002
for node_(2) to node(5) 249.80792621532248

(_o5 cmd line 1)
invoked from within
"_o5 cmd at 0.0 “_o105 hacker”"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o5" line 2)
(SplitObject unknown line 2)
invoked from within
"_o5 at 0.0 “_o105 hacker”"
("eval" body line 1)
invoked from within
"eval $scheduler_ at $args"
(procedure "_o3" line 3)
(Simulator at line 3)
invoked from within
"$ns at 0.0 “[$node_(4) set ragent_] hacker”"
(file "clusterhead1.tcl" line 243)
plzzzz help me to fix it..

Unknown said...

at which line we have to add these codes in .h and .cc files?

Unknown said...

ns: _o180 hacker:
(_o180 cmd line 1)
invoked from within
"_o180 cmd hacker"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o180" line 2)
(SplitObject unknown line 2)
invoked from within
"_o180 hacker"

Can anyone Please resolve this problem...

Unknown said...

even me getting the same error as ekta..plz help