NS2 code for Rushing attacks (Jellyfish and Byzantine attacks)

Workshop on Cyber Security and Forensics (16th to 20th August 2016)

Workshop on Big Data Analytics (2nd to 6th August 2016)

Rushing attack

 Rushing attack is a zero delay attack andmore effective when the attacker nearby source or destination node.On-demand routing protocols like AODV and DSR are more vulnerable to this attack, because whenever source nodefloods the route request packet in the network, an adversary nodereceives the route request packet and sends without any hop_count update and delay intothe network. Whenever the legitimate nodes receive the originalsource request packets, they are dropped because legitimate nodes,would have already received packet from the attacker and treat the currently received packets asduplicate packets. Thus, adversary is included in active routeand disturbs the data forwarding phase. Rushing attack can be takenplace at source side or destination side or at the middle.

** The following conditions the rushing attacker is not included in active route
1. When source and destination nodes have direct communication link
2. When source and destination nodes have better route than rushing attackers route
** Rushing attack is more effective when attacker near to source or destination node

Rushing attacks:

 Rushing attacks mainly classified into two types:
1.    Rushing attack followed by jellyfish attack
2.    Rushing attack followed by byzantine attack
Rushing attacker disturbs the data forwarding phase by either jellyfish or byzantine attack.


Rushing attacks implementation in aodv routing protocol

The following scenario consists of 25 nodes. In which 7, 8 and 10 nodes are rushing attacks other nodes are non-malicious.



To create multiple rushing attackers in aodv protocol

·         In aodv.h, the following blue colour lines needs to be added to define rushing attackers

/*
      * History management
      */
    
double               PerHopTime(aodv_rt_entry *rt);

nsaddr_t malicious;





·         In aodv.cc the following blue colour lines needs to be added to initialize the attackers

// To initialize the rushing attackers

int
AODV::command(intargc, 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(strncasecmp(argv[1], "rushingattack", 13) == 0) {
     malicious= 1000;
        return TCL_OK;
    }
                 

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;
  LIST_INIT(&nbhead);
  LIST_INIT(&bihead);
malicious=999;
 

·         Malicious nodes 7, 8 and 10 generate malicious route requests using following blue colour code


Each rushing attacker do not increase the hop_count and simply broadcast without delay. Other than rushing attackers, they will follow the AODV protocol to broadcast route request

//add blue colour lines in send route request packet

/*
  * Can't reply. So forward the  Route Request
  */

else {
ih->saddr() = index;
ih->daddr() = IP_BROADCAST;
if (malicious==1000)
rq->rq_hop_count += 1;
   // Maximum sequence number seen en route
if (rt) rq->rq_dst_seqno = max(rt->rt_seqno, rq->rq_dst_seqno);
if (malicious==1000)
forward((aodv_rt_entry*) 0, p, 0);
else
forward((aodv_rt_entry*) 0, p, DELAY);
 }


// add the blue colour lines code in forward packet

if (ih->daddr() == (nsaddr_t) IP_BROADCAST) {
 // If it is a broadcast packet
assert(rt == 0);
if ((ch->ptype()==PT_AODV) && (malicious!=1000)) {
     /*
*  Jitter the sending of AODV broadcast packets by 10ms
      */
     Scheduler::instance().schedule(target_, p, 0.01 * Random::uniform());
   } else {

     Scheduler::instance().schedule(target_, p, 0.);  // No jitter
   }
 }

  
·         Rushing Attackers can do two attacks: Byzantine and Jellyfish attacks

/*
  * If the route is up, forward the packet
  */
                                                  
if(rt->rt_flags == RTF_UP) {
assert(rt->rt_hops != INFINITY2);

//Byzantine attack can be done : drop all /selective packets
//                       Modify [or]injectflase packets
//Here,  only dropping packets are considered


if((ch->ptype()!=PT_AODV) && (malicious==1000))
                                                   {
                           if(t < CURRENT_TIME)
                                                   {
                                               t=t+2;
                             drop(p, DROP_RTR_NO_ROUTE);
       }
//Jellyfish attack can be done two ways: delaying packets [or] re-ordering //packets.
//Here, only delaying packets and 0.8 can be varied till the good put is zero

else                                            
forward(rt, p, 0.8); 
 }
else
forward(rt, p, NO_DELAY);
 }

·         Since, all attackers drop the packets due to no route to destination, attackers have to disable the send[error]

The following blue colour lines code disables the send (error)


 // add in route resolve function (AODV::rt_resolve(Packet *p) )
else {
 Packet *rerr = Packet::alloc();
structhdr_aodv_error *re = HDR_AODV_ERROR(rerr);
 /*
  * For now, drop the packet and send error upstream.
  * Now the route errors are broadcast to upstream
  * neighbors - Mahesh 09/11/99
  */    

assert (rt->rt_flags == RTF_DOWN);
re->DestCount = 0;
re->unreachable_dst[re->DestCount] = rt->rt_dst;
re->unreachable_dst_seqno[re->DestCount] = rt->rt_seqno;
re->DestCount += 1;
#ifdef DEBUG
fprintf(stderr, "%s: sending RERR...\n", __FUNCTION__);
#endif
if(malicious==1000) drop(p, DROP_RTR_NO_ROUTE);
else
sendError(rerr, false);

drop(p, DROP_RTR_NO_ROUTE);



To define the rushing attackers in tcl add these lines after node initializations

$ns at 0.0 "[$n5 set ragent_] rushingattack"
$ns at 0.0 "[$n7 set ragent_] rushingattack"
$ns at 0.0 "[$n8 set ragent_] rushingattack"

Above scenario example tcl  file : rushing attacks
Rushing attack aodv.cc file : aodv.cc
                         aodv.h file : aodv.h   

Comments

  1. Hello Sir,

    while executing the tcl script, i am getting the following error...

    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o171 rushing1:
    (_o171 cmd line 1)
    invoked from within
    "_o171 cmd rushing1"
    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 "_o171" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o171 rushing1"

    It would be very kind of you if could provide the needful assistance as soon as possible.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  2. In tcl file
    Instead of $ns at 0.0 "[$n5 set ragent_] rushing1" use $ns at 0.0 "[$n5 set ragent_] rushingattack" in all the cases

    ReplyDelete
  3. Hello Sir,
    I followed all the step, but when executing the tcl script it show this message:
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o171 rushingattack:
    (_o171 cmd line 1)
    invoked from within
    "_o171 cmd rushingattack"
    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 "_o171" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o171 rushingattack"
    Please could you help me with that!

    ReplyDelete
    Replies
    1. same problem occurs during running tcl
      It would be very kind of you if could provide the needful assistance as soon as possible.

      Delete
    2. please help me friends
      while running above script its shows same error please give the solution to my mail ajothimani05@gmail.com friends

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. hello sir
      how solution this error :
      http://www.uplooder.net/img/image/76/30a442b8dd718cdbe6370974a9fd0c7d/untitled.JPG

      Delete
  5. No one could help me
    کسی نیست کمکم کنه !

    ReplyDelete
  6. i tried the code but there is no decrease in throughput of aodv after attack

    ReplyDelete
  7. in one if the if condition it is given if(t is it correct. also "t" is not defined within the scope.please clear my doubt

    ReplyDelete
  8. please correct following

    if(t<CURRENT_TIME)
    {
    t=t+2;
    drop(p, DROP_RTR_NO_ROUTE);
    }

    ReplyDelete
  9. Hello Sir,
    I followed all the step, but when executing the tcl script it show this message:
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o127 rushingattack:
    (_o127 cmd line 1)
    invoked from within
    "_o127 cmd rushingattack"
    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 "_o127" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o127 rushingattack"


    any one send me solution on webdope123@gmail.com
    as soon as possible
    thanks

    ReplyDelete
    Replies
    1. i have the same issues .. if u have solved this kindly help me...
      email me plz...
      hamidkhancs@gmail.com

      Delete
  10. I need to implement wired cumwireless scenario, so i waana know can we simulate this scenario without using and base station(intermediate node between wired and wireless node)???
    it would help me alot

    ReplyDelete
  11. hello sir i need to implement jellyfish attack in vanet using ns3 tool.. sir please provide me some help in this

    ReplyDelete
  12. please correct following

    if(t<CURRENT_TIME)
    {
    t=t+2;
    drop(p, DROP_RTR_NO_ROUTE);
    }

    ReplyDelete
    Replies
    1. plz give solution as soon as possible

      Delete
    2. did u find the solution, i have also facing the same problem

      Delete
  13. num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o171 rushingattack1:
    (_o171 cmd line 1)
    invoked from within
    "_o171 cmd rushingattack1"
    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 "_o171" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o171 rushingattack1"

    ReplyDelete
    Replies
    1. i have the same issues .. if u have solved this kindly help me...
      email me plz...
      hamidkhancs@gmail.com

      Delete
  14. can you plz tell me how to prevent the rushing attack using time threshold value.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Dear Sir:

    I want to implement rushing attack using DSR routing protocol in MANETs. kindly Sir if you have the code for the DSR, kindly upload it or mail me. because i need it.
    for me it's so important.
    My email address: sadiqullah.samsoor@gmail.com

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Hello sir,
    I got following error executing the tcl file.Please help me to sort out this problem.
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o171 rushingattack:
    (_o171 cmd line 1)
    invoked from within
    "_o171 cmd rushingattack"
    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 "_o171" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o171 rushingattack"

    ReplyDelete
    Replies
    1. i have the same issues .. if u have solved this kindly help me...

      Delete
    2. i have the same issues .. if u have solved this kindly help me...
      email me plz...
      hamidkhancs@gmail.com

      Delete

Post a Comment

Popular posts from this blog

NS2 Code for Blackhole Attack (multiple blackholes) in AODV Protocol

Intrusion Detection Technique for Wormhole and Following Jellyfish and Byzantine Attacks in Wireless Mesh Network