Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

Thursday, 24 April 2014

MALICIOUS NODE IN AODV PROTOCOL

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]
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])







11 comments :

  1. How can find the flow in .cc and .h files inorder to edit these?

    ReplyDelete
  2. its showing some errors:
    Starting Simulation...
    ns: _o179 malicious:
    (_o179 cmd line 1)
    invoked from within
    "_o179 cmd malicious"
    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 "_o179" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o179 malicious"

    ReplyDelete
  3. @benson micheal -- the error is in your .tcl file. While adding
    $ns at 0.0"[$n2 set ragent_]malicious"
    make sure u dont have space after 0.0 and after ]
    That was the error in mine too but when i made these change i was able to run my program

    ReplyDelete
  4. I perform above steps,it run successfully but how I identify the change in result.Because old and new scenario looks like same & awk script also gives same results

    ReplyDelete
    Replies
    1. old and new scenario look same evn afer adding malicious node

      Delete
  5. The script add the malicious node manually.
    It should generate malicious node randomly. means each time when script is run, malicious node should be generated randomly.(Means If scenario of 30 node is there, then malicious node be any node in between 0 to 29).

    ReplyDelete
  6. thank you ..the code is working fine please can you help me to remove the malicious node..

    ReplyDelete
    Replies
    1. MAM can i get code because i have same project so please will u send me on my mailid:b150032cs@nitsikkim.ac.in

      Delete