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

Workshop on Cyber Security and Forensics (16th to 20th August 2016)
http://svecw.edu.in/docs/CSEFDPCS.pdf 

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

http://svecw.edu.in/docs/CSEFDPBigDataAnalytics2016.pdf


The following scenario consists of 25 nodes, in which 1,7 and 13 nodes are blackholenodes and other nodes are non-malicious.




          To create multiple blackhole  attackers in AODV protocol
  
i)             In aodv.h the following blue colour lines needs to be added to define balckhole attackers
    
/*
      * History management
      */
    
double               PerHopTime(aodv_rt_entry *rt);

nsaddr_t malicious1;
nsaddr_t malicious2;
nsaddr_t malicious3;

  
ii)            In  aodv.cc the following blue colour lines needs to be added to initialize the 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(strcmp(argv[1], "blackhole1") == 0) {
     malicious1= index;
          printf("malicious %d", malicious1);
return TCL_OK;
    }
                   if(strcmp(argv[1], "blackhole2") == 0) {
malicious2=index;
                             printf("malicious %d", malicious2);
return TCL_OK;
    }
                   if(strcmp(argv[1], "blackhole3") == 0) {
                             malicious3= index;
printf("malicious %d", malicious3);
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);
malicious1=999;
  malicious2=999;
  malicious3=999;
  


   Malicious nodes 1,7 and 13 generates fake route replies using following blue colour code

//add in receive route request

if(rq->rq_dst == index) {

#ifdef DEBUG
fprintf(stderr, "%d - %s: destination sending reply\n",
index, __FUNCTION__);
#endif // DEBUG


   // Just to be safe, I use the max. Somebody may have
   // incremented the dstseqno.
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;

sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
index,                // Dest IP Address
seqno,                // Dest Sequence Num
             MY_ROUTE_TIMEOUT,     // Lifetime
rq->rq_timestamp);    // timestamp

   Packet::free(p);
 }
 //blackhole attackers

else if(index==malicious1)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;

sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }      
else if(index==malicious2)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;

sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }
else if(index==malicious3)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;

sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }

Since, all attackers do not have route to destination, attacker have to disable the send (error).



The following blue colour 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((index==malicious1)||(index==malicious2)|| (index==malicious3));
else
sendError(rerr, false);

drop(p, DROP_RTR_NO_ROUTE);




iii)    To define the blackhole attackers in tcl add these lines after node initializations

$ns at 0.0 "[$n1 set ragent_] blackhole1"
$ns at 0.0 "[$n7 set ragent_] blackhole2"
$ns at 0.0 "[$n13 set ragent_] blackhole3"


  Above scenario example tcl  file blackhole attacks scenario


Goodput calculation file goodput


 To calculate goodput:  type-> perl goodput.pl outputfile name  granularity(for 1 or 2... n seconds) > filename
 ex :-> perl goodput.pl out.tr 10 > results   

Packet Delivery Ratio (pdr) file: pdr


To calculate Packet Delivery Ratio:
 
$ perl pdr trafile_name sour-node1 sour_node2 sour_node3 sour_node4 dest_node >fname

eg :

 $perl
pdr.pl our.tr _20_ _21_ _11_ _17_ _18_  > result

Comments

  1. Hello Sir,
    I added this code to aodv.h and aodv.cc as per your instructions and in tcl file provided.But i can not understand about Goodput calculation file and perl script.I use ns filename.tcl command to run.but errors are there.How to run this to show results.I have ubuntu 13.04 version and ns2(2.35)simulator.PLease suggest me if any extra thing needs to be added to run this black hole attack project.

    ReplyDelete
  2. hello sir,

    i want the algorithm for this code.

    can you send me so i vill go through it.

    plz send me sir it vill ba great plesure.



    regards Anuradha

    ReplyDelete
  3. wat is the algorithm for creating three blackholes using AODV proocol.

    regards Anuradha

    ReplyDelete
  4. algorithm for blackhole attack in AODV protocol in NS2

    ReplyDelete
  5. can u help me to learn doing the papers in ns2



    regards Anu

    ReplyDelete
  6. hello sir


    i hav a problem in ;

    initially i got the output for all the three mailicious nodes.
    but after that i didnt ge for three instead for only one i.e node number 13(working),when i remove the comment for all three its giving floaing point error(core dumped)
    so sugges were would be the problem for me.plz its very urgent.


    regards Anuradha

    ReplyDelete
  7. thank you for following my blog

    This error occurs due to hop cout value is 0 of a malicious path in aodv.cc code

    you should replace hop cout 0 with 1
    please modify following aodv.cc code

    else if(index==malicious1)
    {
    …………
    ……..
    …………………..
    1, // Hop Count
    ……………………..
    ……………………..
    }
    else if(index==malicious2)
    {
    …………
    ……..
    …………………..
    1, // Hop Count
    ……………………..
    ……………………..
    }
    else if(index==malicious3)
    {
    …………
    ……..
    …………………..
    1, // Hop Count
    ……………………..
    ……………………..
    }
    Then make clean followed by make to create new aodv object files

    ReplyDelete
  8. Hello sir,
    I have replaced modified aodv.cc and aodv.h files with original aodv files..but when i m running the tcl file i m getting the following errors...
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o39 blackhole1:
    (_o39 cmd line 1)
    invoked from within
    "_o39 cmd blackhole1"
    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 "_o39" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o39 blackhole1"

    ReplyDelete
  9. after adding of APEC code please do make operation

    ReplyDelete
  10. hello sir ,
    how will you detect the multiple blackholes and wat technique your going to use for this,plz let me know ,iam not able to understand the algorithm wat you given in the blog.
    regards Anu

    ReplyDelete
  11. Hi shivani i am having the error wat use to have

    ReplyDelete
  12. Hi ganesh, Thanks for your personnel mail and attention.
    I have successfully compiled the code on my machine
    Steps:
    cd ns-allinone folder
    cd ns-2.35
    make clean
    make
    make ./install
    ./configure


    after this the code is running smoothly
    Thank you

    ReplyDelete
    Replies
    1. hai, can you help me to fix the problem. i still can run this code and same error with you. can you help me? please...

      Delete
  13. hello
    after running the tcl script i am getting this error
    num_nodes is set 25
    invalid command name "-antType"
    while executing
    "-antType $val(ant) \
    "
    (file "blackhole.tcl" line 73)
    what does it mean?
    plz help urgent...

    ReplyDelete
  14. set val(ant) Antenna/OmniAntenna is the right command

    an omnidirectional antenna is a class of antenna which radiates radio wave power uniformly in all directions in one plane, with the radiated power decreasing with elevation angle above or below the plane, dropping to zero on the antenna's axis.

    ReplyDelete
  15. When i did make operation ,the following error occurs.
    "make: *** No rule to make target `Makefile.in', needed by `Makefile'. Stop."

    Why?? Please exlain.

    ReplyDelete
    Replies
    1. apply make operation on ns-allinone2.xx/ns.2.xx folder

      Delete
    2. even after applying on ns-allinone2.xx/ns.2.xx folder,still getting an error:
      umit@umit-HP-Compaq-Elite-8300-SFF:~/ns-allinone-2.35/ns-2.35$ make ./install
      for d in /usr/local/man/man1; do \
      if [ ! -d $d ]; then \
      mkdir -p $d ;\
      fi;\
      done
      /usr/bin/install -c -m 755 ns /usr/local/bin
      /usr/bin/install: cannot stat ‘ns’: No such file or directory
      Makefile:555: recipe for target 'install-ns' failed
      make: *** [install-ns] Error 1





      What to do?
      Pls reply,It's urgent.

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


    this the error what I am getting

    ReplyDelete
    Replies
    1. once you replace the original aodv files with blackhole aodv files
      the open ns.2.xx folder
      make clean
      make

      If it wont work follow these steps:

      If it won't work follow these steps:
      To overcome this problem, do the following steps 1:

      1. Un-install all ns2 versions(if you have to are more) and thier path settings.
      2. re-intall ns2.33 or ns2.34 version
      3. follow steps mentioned in this blogg to create blackhole attack


      all the best

      Delete
  17. Thank u sir.

    I am also getting the error
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o39 blackhole1:
    (_o39 cmd line 1)
    invoked from within
    "_o39 cmd blackhole1"
    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 "_o39" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o39 blackhole1"

    ReplyDelete
    Replies
    1. I got the same error but solved it... Follow this steps carefully..

      1) First go to nsallinonexx/ns.2xx folder
      2) There will be a folder called aodv
      3) Inside that folder replace the aodv.cc and aodv.h files with these new ones.
      4) now go to terminal
      5) go to ns folder ... cd nsallinonexx/ns.2xx
      6) Type this commands in order
      7) sudo make clean
      8) sudo make
      9) sudo make ./install
      10) sudo ./configure
      11) Now run the code as "ns blackholeattack.c" it will run

      Delete
    2. How to solve this error?


      umit@umit-HP-Compaq-Elite-8300-SFF:~/ns-allinone-2.35/ns-2.35$ sudo make ./install
      [sudo] password for umit:
      for d in /usr/local/man/man1; do \
      if [ ! -d $d ]; then \
      mkdir -p $d ;\
      fi;\
      done
      /usr/bin/install -c -m 755 ns /usr/local/bin
      /usr/bin/install: cannot stat ‘ns’: No such file or directory
      Makefile:555: recipe for target 'install-ns' failed
      make: *** [install-ns] Error 1

      Delete
  18. once you replace the original aodv files with blackhole aodv files
    the open ns.2.xx folder
    make clean
    make

    If it wont work follow these steps:

    If it won't work follow these steps:
    To overcome this problem, do the following steps 1:

    1. Un-install all ns2 versions(if you have to are more) and thier path settings.
    2. re-intall ns2.33 or ns2.34 version
    3. follow steps mentioned in this blogg to create blackhole attack


    all the best

    ReplyDelete
  19. i am using ns2.35 and when i followed this step,
    Steps:
    cd ns-allinone folder
    cd ns-2.35
    make clean
    make
    make ./install
    ./configure

    I got the following error:-
    queue/priqueue.cc: In member function ‘virtual void PriQueue::recv(Packet*, Handler*)’:
    queue/priqueue.cc:94:6: error: ‘PT_blackholeAODV’ was not declared in this scope
    case PT_blackholeAODV:
    ^
    make: *** [queue/priqueue.o] Error 1


    I also modified aodv.cc and aodv.h file.Can you please help

    ReplyDelete
  20. This error indicates you have already added some blackhole patch, on top this your were trying to add our blackhole code
    my suggestion is better undo the previous patch then add our code
    or
    delete the present ns2 and re-install ns2 then add our code
    all the best

    ReplyDelete
  21. I re-installed ns2.35 and tried again.
    After the make operation,this is the errors which i am getting:-
    make[1]: Leaving directory `/home/ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
    Inspiron-1545:~/ns-allinone-2.35/ns-2.35$ make./install
    bash: make./install: No such file or directory

    Can you please help me out asap

    ReplyDelete
  22. after making changes in aodv.cc and aodv.h file...

    ReplyDelete
  23. same error getting as richu plz help guys

    ReplyDelete
  24. what is APEC code?

    ReplyDelete
  25. #Setup a CBR Application over UDP connection
    set cbr1 [new Application/Traffic/CBR]
    $cbr1 attach-agent $udp1
    $cbr1 set packetSize_ 1000
    $cbr1 set rate_ 0.1Mb
    $cbr1 set random_ null
    $ns at 20.0 "$cbr1 start"
    $ns at 40.0 "$cbr1 stop"

    Can anyone tell me what does this mean??Please asap

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

      Delete
    2. In ns2 when a node is created it will acts like router.i.e it gets functionalities of three layers (physical,data,n/w). Now to make a particular node as source or destination ,we need to add remaining two layers functionalities (i.e transport & application). So for that purpose we are adding UDP agent over node.and then CBR application to generate traffic over udp...UDP belongs to Transport layer and CBR belongs to Application layer .Now the node will act like system ,you can make it as source or destination to transfer data from on node to another...
      Now coming to above code line by line
      1) Creating an object cbr1 for CBR application
      2)attaching it over udp..as we know application layer comes on top of transport layer
      3,4,5 lines are used to set default values for parameters like packet size, rate of generation of packets ,motion
      6,7 lines are used at what time this cbr traffic(i.e generating packets) to start and when to stop ....

      Hope you understand now..

      Delete
  26. Sir, I have made all the changes as per written instructions and it is working fine...but the packet delivery ratio is not coming as per desired. I have run pdf.awk file to calculate the same but i m not getting desired results. Even in nam file the packets are not being dropped as expected. My pdf ratio comes 40% when i m turing only node 1 malicious but it changes to 91% when all three nodes are malicious. Please help me with the same. When i tried run pdr.pl...it is showing following error.
    Illegal division by zero at pdr.pl line 59, line 96977.
    If anyone can help me with this problem..i need solution asap.

    ReplyDelete
    Replies
    1. can you teach me how to overcome this problem. i need your help.

      Delete
  27. hello
    I got the nam output .
    What can I infer from that animation?
    1,7,13 are the malicious nodes..How do they become the blackholes in the animation ?Please explain

    ReplyDelete
  28. ok i got answer.
    In the given tcl file ,1,7,13 are the blackhole nodes.But we can see only node '1' dropping the packets in the simulation.
    Because the roots established by aodv does not take in to account the other nodes.

    We can check by changing the malicious nodes to 15 ..and observe the change.

    ReplyDelete
  29. Many of you are getting the error

    "num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o39 blackhole1:
    (_o39 cmd line 1)
    invoked from within
    "_o39 cmd blackhole1"
    invoked from within
    "catch "$self cmd $arg............"


    I got the output on my first run ..
    Then this error was shown..
    I had updated my nam instance in between..i believe this may be the cause..also if u have installed ubuntu updates or anything ..u may also get this error..
    So before making changes to aodv ,I had kept a copy of ns-allinone folder..So i recopied it and again applied the changes ..

    make
    make clean
    make ./install
    ./configure

    i think may be my makefile or some crucial files may have changed ,because of that i got the error..

    If u do not have a copy uninstall ns2 and then install and try from scratch..

    This code is 100% working :)
    Thanks admin for your efforts..

    ReplyDelete
    Replies
    1. I got the same error but solved it... Follow this steps carefully..

      1) First go to nsallinonexx/ns.2xx folder
      2) There will be a folder called aodv
      3) Inside that folder replace the aodv.cc and aodv.h files with these new ones.
      4) now go to terminal
      5) go to ns folder ... cd nsallinonexx/ns.2xx
      6) Type this commands in order
      7) sudo make clean
      8) sudo make
      9) sudo make ./install
      10) sudo ./configure
      11) Now run the code as "ns blackholeattack.c" it will run

      Delete
  30. Sir, I am new with NS2. Is it possible for you to share the code (tcl script) of constant jamming?

    ReplyDelete
  31. I got thhis error while running,please give me the solution to correct this error
    Thank in Advance


    invalid command name "-llType"
    while executing
    "-llType $val(ll) \
    "

    ReplyDelete
  32. You have to do all the steps to solve this problem but not solved!
    INITIALIZE THE LIST xListHead
    ns: _o707 blackhole1:
    (_o707 cmd line 1)
    invoked from within
    "_o707 cmd blackhole1"
    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 "_o707" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o707 blackhole1"

    ReplyDelete
  33. Sir, i want blackhole attack code in Aodv in ns2 (tcl format). Can you plaese provide me this code in ns2 format (.tcl ) at gauttam2008@gmail.com

    Thanx

    ReplyDelete
  34. sir,i need a code for detection of black hole attack in aodv in ns2.i am completely new to this.i need a detection technique that uses sequence number.please help sir..please.
    please send the code to deepu_2853@yahoo.co.in

    ReplyDelete
  35. sir, can u please send me the dsr code for blackhole attack in ns2.
    please send me the code to rani.rosy143@gmail.com

    ReplyDelete
  36. I am all changes which is g
    iven in this post and also i appy make and make clean all function suggested by you but i get still this error.My OS is ubuntu 12.04 and ns2 version is ns2.35
    Error is-
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o39 blackhole1:
    (_o39 cmd line 1)
    invoked from within
    "_o39 cmd blackhole1"
    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 "_o39" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o39 blackhole1"


    Please suggeste me what i do

    ReplyDelete
  37. please tell me how i make xgarph with tr file. with PDR and throughput
    how calculate that values also
    Thanx in advance

    ReplyDelete
  38. with tar file we cannot generate correct graph
    PDR and throughput, are stored in text files (pdr.txt)
    then use the following command in terminal
    xgraph pdr.txt to generate a graph for pdr.

    ReplyDelete
  39. how we save our result in txt file(pdr.txt). please explain with an example
    thanx@Ganesh

    ReplyDelete
  40. After this step

    $perl pdr.pl our.tr _20_ _21_ _11_ _17_ _18_ > result

    result.txt file will be created

    then to draw graph we need to run following command
    xgraph pdr.txt

    ReplyDelete
    Replies
    1. please help me fix this with: Illegal division by zero at tinhcacnut.pl line 66, line 32 487.

      Delete
    2. please help me fix this with: Illegal division by zero at tinhcacnut.pl line 66, line 32 487

      letankth@gmail.com

      Delete
  41. sir, i want "sinkhole attack code in ns-2 with AODV protocol"
    sir, plz provide me code...
    vivektank201299@gmail.com

    ReplyDelete
    Replies
    1. i also need sinkhole and rushing attack code in ns2 with aodv protocol please provide code for me
      ajothimani05@gmail.com

      Delete
  42. hello sir im still work on my final project n confuse to apply blackhole attack, is it possible to run blackhole attack on different routing protocol such as OLSR, DSR and DSDV using your code? if it can how i can make it,
    thanks for your help sir ^^

    bayuindi2134@gmail.com

    best regard
    Bayu aji

    ReplyDelete
  43. hello sir can you send the code to detect malicious node in ns2

    ReplyDelete
  44. himself asked the bottom line effect whatsoever?
    malicious1 = 999;
       malicious2 = 999;
       malicious3 = 999;

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

    ReplyDelete
  46. I am also getting the following error even after re-installing ns-2
    num_nodes is set 25
    INITIALIZE THE LIST xListHead
    ns: _o39 blackhole1:
    (_o39 cmd line 1)
    invoked from within
    "_o39 cmd blackhole1"
    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 "_o39" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o39 blackhole1"

    also while executing the commands:
    make clean
    make

    i am getting the following errors:
    rm: cannot remove `gen/version.o': Permission denied
    rm: cannot remove `gen/ns_tcl.o': Permission denied
    rm: cannot remove `gen/ptypes.o': Permission denied
    rm: cannot remove `gen/ns_tcl.cc': Permission denied
    rm: cannot remove `gen/ns_tcl.o': Permission denied
    rm: cannot remove `gen/ptypes.cc': Permission denied
    rm: cannot remove `gen/ptypes.o': Permission denied
    rm: cannot remove `gen/version.c': Permission denied
    rm: cannot remove `gen/version.o': Permission denied
    make: *** [clean] Error 1


    /bin/sh: 1: cannot create gen/ptypes.cc: Permission denied
    make: *** [gen/ptypes.cc] Error 2

    please help.

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

      Delete
    2. write sudo before make clean commande

      Delete
    3. write sudo before make clean commande

      Delete
    4. I got the same error but solved it... Follow this steps carefully..

      1) First go to nsallinonexx/ns.2xx folder
      2) There will be a folder called aodv
      3) Inside that folder replace the aodv.cc and aodv.h files with these new ones.
      4) now go to terminal
      5) go to ns folder ... cd nsallinonexx/ns.2xx
      6) Type this commands in order
      7) sudo make clean
      8) sudo make
      9) sudo make ./install
      10) sudo ./configure
      11) Now run the code as "ns blackholeattack.c" it will run

      Delete
  47. Which files do I need to modify to have Blackhole Attack in DSR? And please suggest the modification..

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

    ReplyDelete
  49. I am getting this error after:
    rachna@ubuntu:~/ns-allinone-2.35$ sudo make ./install
    make: Nothing to be done for `install'.

    If i m changing directory to:
    rachna@ubuntu:~/ns-allinone-2.35/ns-2.35$ sudo make ./install
    for d in /usr/local/man/man1; do \
    if [ ! -d $d ]; then \
    mkdir -p $d ;\
    fi;\
    done
    /usr/bin/install -c -m 755 ns /usr/local/bin
    /usr/bin/install: cannot stat `ns': No such file or directory
    make: *** [install-ns] Error 1


    even after ignoring all these errors i am still unable to implement this attack




    rachna@ubuntu:~/Desktop$ ns major20a.tcl
    num_nodes is set 20
    warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
    INITIALIZE THE LIST xListHead
    channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
    highestAntennaZ_ = 1.5, distCST_ = 18883.9
    SORTING LISTS ...DONE!
    ns: _o234 blackhole:
    (_o234 cmd line 1)
    invoked from within
    "_o234 cmd blackhole"
    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 "_o234" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o234 blackhole"

    ReplyDelete
  50. pls help with th above query..it's urgent

    ReplyDelete
  51. Hello Sir, Hello Sir, i'm presently working on black hole, i have an algorithm and i'm stuck for over 8 months, please i need your help sir, will appreciate your response or if you have a code for detection and prevention OR detection technique that uses sequence number and hop count.please help sir..please.
    please send the code to kayzmonie@gmail.com

    I am really stuck and can't graduate from my M.SC program, you are my hope Sir.

    Thank you.

    ReplyDelete
  52. num_nodes is set 53
    INITIALIZE THE LIST xListHead
    channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
    highestAntennaZ_ = 1.5, distCST_ = 550.0
    SORTING LISTS ...DONE!
    Floating point exception (core dumped)
    I am still getting this error while running blackhole attack in ns2. I have followed all the steps on this thread. What should I do?

    ReplyDelete
  53. Can any one share NS2 code using RSA algorithm to mitigate black hole attack ? please share at yousaf.rep@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

NS2 code for Rushing attacks (Jellyfish and Byzantine attacks)

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