Tuesday, 3 July 2012

How to use promiscuous mode in AODV NS2

Introduction:-

          In Promiscuous mode each node in the network listens the packets transmitted by its own neighbor nodes. 
          In NS-2, some time we have to calculate the packet drops or analyze the process. For the same we need to set the network to operate in promiscuous mode. Here, I am going to explain how we can set our wireless network in promiscuous mode with AODV as Routing protocol using NS2 simulator.

1) We need to modify in total 3 files, so it's good to take a backup of it.
    Files are:
    • ns-allinone-2.34/ns-2.34/aodv/aodv.cc
    • ns-allinone-2.34/ns-2.34/aodv/aodv.h
    • ns-allinone-2.34/ns-2.34/tcl/lib/ns-mobilenode.tcl
2) Open the file ns-allinone-2.34/ns-2.34/aodv/aodv.h in your favorite editor
    and make the changes as shown in blue color.

  #include <mac.h>
  class AODV: public Tap, public Agent {
  public:
  void tap(const Packet *p);
  ......
  protected:
  Mac *mac_;
  ......
 }
3) Open the file ns-allinone-2.34/ns-2.34/aodv/aodv.cc and make the changes as  
    shown in blue color.
int
AODV::command(int argc, const char* const * argv) {
......
else if(argc == 3) {
......
else if (strcmp(argv[1], "install-tap") == 0) {
mac_ = (Mac*)TclObject::lookup(argv[2]);
if (mac_ == 0) return TCL_ERROR;
mac_->installTap(this);
return TCL_OK;
}
}
return Agent::command(argc, argv);

}
void
AODV::tap(const Packet *p) {
// put your code here
   
4) Open the file ns-allinone-2.34/ns-2.34/tcl/lib/ns-mobilenode.tcl and make the  
    changes as shown in blue color.

Node/MobileNode instproc add-target { agent port } {
$self instvar dmux_ imep_ toraDebug_ mac_
......
# Special processing for AODV
set aodvonly [string first "AODV" [$agent info class]]
if {$aodvonly != -1 } {
$agent if-queue [$self set ifq_(0)] ;
# ifq between LL and MAC

$agent install-tap $mac_(0)
......

}


Explanation:-

         The above procedure will put all the nodes in the wireless network in promiscuous mode. If a node A wants to listen the packets from a node B in promiscuous mode to check whether to check B is forwarding the packets which are sent by A to B or not we can write the code in function tap()


5) To simulate a node as a malicious node in AODV here is a nice blog
    http://elmurod.net/index.php/2009/10/24/adding-malicious-node-in-aodv/

76 comments:

  1. while i was running tcl script getting errors.........

    ReplyDelete
    Replies
    1. I am also geting the errors while running the tcl scripts. please let me know the solutions for it

      Delete
    2. i have a solution. plz contact me 9978026818

      Delete
  2. What r the errors? Can u post them here?

    ReplyDelete
  3. How can I set a certain node to be a promiscuous node on tcl?

    Thanks

    ReplyDelete
  4. Hello! In CPP code you need to filter the traffic for that node in tap() method.

    e.g. If I want node 1 to be in promiscuous mode, I should check the packets received by node 1 in tap() method as below,

    if(index==1)//index is the current node.
    {
    //Your code for all packets captured by node 1 in promiscuous mode.
    }

    One more thing I would like to share, in NS2 every node runs its own copy of code. As we have to differentiate between the code run by node 1 and that by other nodes, we have to use if condition.

    In TCL you will have to use a boolean to pass as argument with that node and u can check this with cpp code in tap() method. This is a longer way and requires binding between TCL and CPP variables. All the best!

    ReplyDelete
    Replies
    1. sir i want to drop or loss RERR message in aodv routing protocol i am using ns2 can u please help me in to write tcl script for this....please

      Delete
  5. is it necessary to add any code in tcl script to make promiscuous mode active, or it will work automatically? could you help me to make a tap function to overhear packet forwarding, am trying to build a watchdog in MANET

    thanks.....

    ReplyDelete
  6. No! it is not necessary. I can help you, but I will require more information from you. Mail me regarding it.

    ReplyDelete
  7. sir, am trying to implement a collaborative watchdog in MANET, in this approach by making each node in the MANET with a collaborative approach, they can easily identify the malicious nodes in the MANET, and then they can generate a new route if any route failure occurs, i did the malicious node simulation successfully, and now i need to make my nodes in promiscuous mode to overhear packet forwarding.... and i need the information about how to build or regenerate a route if a route failure occurs.... i hope u will me way to complete my task... i put install-tap in AODV::command(...) , how i can call this install-tap in tcl script, what is the exact statement to call the install-tap method.... pls help me sir... thanking you in advance.....

    ReplyDelete
  8. sir can u help me to know, how the tcl command will looks like to enable tap agent ie to enable promiscuous mode.... i don't know how to invoke that promiscuous mode aodv

    Thanks....

    ReplyDelete
  9. sir can u help me to know how the tcl commands will looks like to enable promiscuous mode in aodv ie how can i invoke the defined tap agent... there is a shadow object install-tap, and how cud i use that under tcl

    ReplyDelete
    Replies
    1. hi, can u help me by sharing your ns2 code for promiscuous node

      Thanks in Advance

      Delete
    2. Hi, can you share your code to me? Thanks very much.

      Delete
    3. sir i want to drop or loss RERR message in aodv routing protocol i am using ns2 can u please help me in to write tcl script for this....please

      Delete
  10. First of all, Promiscuous mode does not need any command from TCL code. You only have to modify the CPP code as given above. To overhear the packet you need to add method

    void
    AODV::tap(const Packet *p) {
    // put your code here
    }
    Here, your code is required for filtering purpose. Reason is, in NS2 each of the nodes is running its own copy of code. So, tap method run by every node will be in its own space. So on command prompt while execution, you will get outputs from all nodes and this output has to be filtered.
    e.g.

    void
    AODV::tap(const Packet *p) {
    fprintf(stderr,"I am node %d ",index);
    }

    Above code will print the node which is executing. Node which receives any kind of packet will execute tap method. Try above code.

    Suppose u have 10 nodes and u want node 2 should monitor node 3, in this case, code will be like below

    void
    AODV::tap(const Packet *p) {
    // put your code here

    if(index==2)
    {
    //Check if packet is from node 3
    //If yes then node 2 received packet from 3 by overhearing method.
    }
    }

    If required any help drop me a mail. All the Best!



    ReplyDelete
    Replies
    1. sir how could i calculate number of route request ,number of RREP forwarded, number of RREQ forwarded and number of Data packets dropped by each node?
      pls mail me to krish05051990@gmail.com

      Delete
  11. I would like to modify AODV protocol based on fuzzy optimization for Multiple Qos Constraints(delay, jitter, buffer, energy level) Routing.

    ReplyDelete
  12. hiii what is overhearing method or can you explain the code for tap method

    ReplyDelete
  13. hi sir after following your procedure and changes i did
    $make

    and gettin gfollowing errors
    void AODV::tap(const Packet*)’ cannot be overloaded

    can u help me please

    ReplyDelete
  14. Hi Sir
    I added this line fprintf(stderr,"Node in Promiscuous Mode\n"); in void tap but it shows nothing . what is instruction that called the function tap ?

    can you help me

    ReplyDelete
  15. Hi..

    Can we write a tcl code for making a node drop packets.?

    ReplyDelete
  16. hello Sir,
    i did make the promicious mode and now i want to add an algo. "if the node does not forward the packet then check that the node is malicious or not by sending FakeRREQ to that node and if he reply to the req. then add it in the blacklist and broadcast the alarm msg"

    but sir i don't know how to implement a new list or queue in ns2 and use the info. given by promicious mode.....plz tell me if you have any idea/link related to this.

    thank you sir for your time.

    ReplyDelete
  17. promicious mode is not working could you give the ns-mobilenode.tcl file

    thanks........

    ReplyDelete
  18. now it run i made a silly mistake ...........
    thanks yaar

    ReplyDelete
  19. m getting dis error after making changes...aodv/aodv.cc: In member function ‘virtual int AODV::command(int, const char* const*)’:
    aodv/aodv.cc:146:30: error: ‘agrv’ was not declared in this scope
    aodv/aodv.cc:148:8: error: ‘TCl_ERROR’ was not declared in this scope
    make: *** [aodv/aodv.o] Error 1

    ReplyDelete
  20. wat to put inside the tap function???i want to implement watchdog and in dat i want all nodes to be in promiscous mode...plz tell me d code wat to write in tap method???

    ReplyDelete
  21. while installing watchdog in ns2.i m having this error...please help me
    aodv/aodv.cc: In member function ‘virtual void LocalRepairTimer::handle(Event*)’:
    aodv/aodv.cc:246:80: error: overloaded function with no contextual type information
    make: *** [aodv/aodv.o] Error 1

    ReplyDelete
    Replies
    1. replace that fucntion from ur own LocalRepairTimer function in original aodv.cc...i was also getting d same error which resolved by this method only

      Delete
  22. i have successfully detected the malicious node with help of watchdog..but how to avoid that malicious node from the route???

    ReplyDelete
    Replies
    1. Deepika can you please tell me how to implement watchdog mechanism and what code to write in tap function. I want all the nodes to be in promiscous modde and monitoring the next neighbour pleease help me

      Delete
    2. Good morning Deepika,
      Could you send me the code of watchdog, please ? And how to detect the malicious node ?
      I need a help...!
      Thank you

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

      Delete
    4. hi deepika, can you please tell me how do you detect malicious node for that what code you are using in aodv protocol.if possible pls send me the code for detecting malicious node(black hole node),,I realy needed it....Thanks in advance
      my eid is krish05051990@gmail.com...

      Delete
    5. hi deepika,
      do you have the code for pathrater, if you have please mail it to vensu108@gmail.com

      thankyou

      Delete
    6. hi, could anyone please sent me the code of watchdog. I already install watchdog in ns2. But I did'nt know how to detect malicious node using watchdog. Please help me to solve this

      Delete
  23. whether the given code will run in fedora??

    ReplyDelete
    Replies
    1. Ya! you need to add this code, configure and make.

      Delete
  24. Sir,
    Among 10 nodes, only few nodes want to act as in promiscuous mode(eg:4,7,9 nodes).. can you tell me the coding sir.{id:(shanthicse@rediffmail.com)}.. i am waiting for your reply sir..it is very urgent.

    ReplyDelete
  25. How to collect information from all the nodes in the network in order to calculate the mean of the information.Is it possible by using the promiscuous mode in AODV

    ReplyDelete
  26. Sir I am implementing the grayhole attack in manet, In that whenever the source sends the data packets I want all the nodes to be in promiscous mode to overhear the next node. please tell me what code to do in tap function.

    ReplyDelete
  27. Sir can u describe the code in tap function to get the packet received and forwarded by each neighbor node

    ReplyDelete
  28. Sir, can you please give the code of tap() function ?
    Thanks in advance.

    ReplyDelete
  29. Can u please mail me code of aodv modified with watchdog in ns2
    So it'll be a great help from U...
    thx

    ReplyDelete
  30. Good morning,
    I need the code of aodv whith watchdog in ns-2.35.
    Please help me !!
    Thank you.

    ReplyDelete
  31. Sir,
    Can anyone tell how to monitor or use flow and queue monitor for wireless networks.
    I am working in ADHOC networks aodv protocol
    please mail me to
    mohanmecse2010@gmail.com

    ReplyDelete
  32. I want to put only one node in promiscuous mode is it possible?
    If yes then how?
    please help me sir, Thank you in advance

    ReplyDelete
  33. hello sir..my final year project title is to develop sniffing detection in MANET...it is possible?? if possible, how could i do it? using NS2?? thank you..

    ReplyDelete
    Replies
    1. Drop me a detailed mail about your project.

      Delete
  34. hi, i had a very basic doubt. please reply for this ( even though it might sound silly)
    if i am using promiscuous mode to overhear other packets say the RREP packet, can the overheard RREP packet make its way into the network layer or just the mac layer( since the tap agent is added in mac).

    i feel it will be completely received. please clear my doubt asap, i need to be clear with this concpt

    ReplyDelete
  35. Yes! All packets will be received irrespective of promiscuous mode.

    ReplyDelete
  36. promicious mode is not working could you give the ns-mobilenode.tcl file so i need tcl file

    ReplyDelete
  37. hi durgesh thanks for the reply. i was working on promiscuous mode in my work.
    In that work, an intermediate node which happens to overhear a RREP will delete the reverse route to the RREP's next hop( next hop info is present in the rrep header).

    My question is:

    The overheard pkt will reach the n/w layer. In n/w layer, the destination ip addr does not match node's ip address. Now can the info related to RREP pkt be decoded inspite of the fact that the address match is not taking place at routing layer. ( I need the RREP pkt info to be decoded because i want the "type field" value in RREP pkt to ensure that the overheard pkt is RREP indeed and then make use of the ip header info to delete the reverse route to the RREP's next hop).

    ReplyDelete
  38. corrected version of above question:

    hi durgesh thanks for the reply. i was working on promiscuous mode in my work.
    In that work, an intermediate node which happens to overhear a RREP will delete the reverse route to the RREP's next hop( next hop info is present in the rrep's ip header).

    My question is:

    The overheard pkt will reach the n/w layer. In n/w layer, the destination ip addr does not match node's ip address. Now can the info related to RREP pkt be decoded inspite of the fact that the address match is not taking place at routing layer. ( I need the RREP pkt info to be decoded because i want the "type field" value in RREP pkt to ensure that the overheard pkt is RREP indeed and then make use of the ip header info to delete the reverse route to the RREP's next hop).

    kindly reply asap

    ReplyDelete
    Replies
    1. struct hdr_cmn* hdcmn = HDR_CMN(p);

      if (hdcmn->ptype_ == PT_AODV) {
      //Your code if packet is AODV there you can check for RREP packet
      }

      Delete
    2. sir, i have completed the code myself and is working fine, i only need a conceptual clarification, a second opinion from ur side:

      see, after overhearing, the RREP pkt will enter the network layer via mac layer. In the network layer, the destination ip addr will not match the node's ip. so, can the node be allowed to read the "type field" information in RREP pkt even if the ip addr match does not take place. I believe it can read because RREP is a routing control packet (i.e, routing layer data) and RREP is manufactured in network layer.(am i right?) and then we can make use of the ip header info to delete the reverse route.

      Delete
    3. whats ur opinion on this ?

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

    ReplyDelete
  40. whats ur opinion on the above 2 comments of mine(my recent replies to your reply, in which u have posted sample code for my work)

    ReplyDelete
  41. hi i guess i figured it out myself, yes its possible. thankyou for your help

    ReplyDelete
  42. Hello friends, please help me out from these questions and confusion...
    1. can I alter the data flowing in ns2, or can intermediate node compromise the integrity of the message, without the knowledge of sender and receiver.

    2. can I generate exact 64 bit key or 80 bit key, using diffie hellman key generation algorithm.

    3. which layer is better for encryption ??

    4. if i will use, network layer for encrypting the packet.. will IP address also be encrypted... i mean header of IP address will also be encrypted..

    I urgently need solution to above queries.. please reply ASAP

    ReplyDelete
  43. Suppose in a network, nodes A, B, C and D are present . Node A broadcasts a packet . Let B and C be within the range of A. So, both B and C will receive the packet . Let D be in the transmission range of B but not of node A. So, can D hear this broadcasted packet? and use the information of that packet.

    I ask this question because node D is not in the range of A, so can D receive that packet inspite of low power levels ( power level will be low since D is out of range of node A and hence probably i think it cant receive it)

    ReplyDelete
  44. kindly reply sir, i need only this one answer now

    ReplyDelete
    Replies
    1. No, node D cannot listen packet broadcast by node A. I hope you would have got your answer. If not then mail me on durgeshpkshirsagar@gmail.com

      Delete
  45. Hello sir .. I use Black Hole through a special independent protocol called Black Hole protocol, and works well with the AODV Protocol, when i using the Tap function within the AODV protocol , I can not control or access to a Black Hole.
    only i can access to AODV nodes.
    How can I access to the Black Hole nodes through AODV protocol ?? Knowing that separate Protocols.
    I hope to help me PLZ
    Thanks in advance

    ReplyDelete
  46. hi sir i am dharman v currently doing my project on Detection of gray hole attack its only for aodv.cc,aodv.h ....i can add malicious node in aodv.cc and aodv.h
    and i try to make camnd use i get make****.no target to specified make..
    make clean
    make
    make depend
    make install
    above mention the line give my terminal i get only for error...
    ./configure i will run means its working ...what is t6he that problem sir ...after that i give ns % get percetage symbols sir its sucessfully ns2 is installed my machine....
    its very urget for my project pls help me i am struck this step


    ReplyDelete
  47. and lot of forum i will say sir but no use nobody say the answer sir ...pls help

    ReplyDelete
  48. my mail id is vdharmanv@gmail.com pls say this mail id sir pls..

    ReplyDelete
  49. Sir, can u please explain me how using this tap() node over hear communication of neighbor node ...means the logic of this code

    ReplyDelete
  50. hello sir,how could i calculate number of route request ,number of RREP forwarded, number of RREQ forwarded and number of Data packets dropped by each node and number of cbr packets? in tap method coding.plz send me some help for code.
    pls mail me to sachi20shah@gmail.com
    Thank you

    ReplyDelete
  51. Can i get the code for detection of blackhole node(malicious node) in MANET using AODV protocol. Thank you in advance.

    ReplyDelete
  52. what i should do after these changes made???

    ReplyDelete
  53. sir i want to drop or loss RERR message in aodv routing protocol i am using ns2 can u please help me in to write tcl script for this....please

    ReplyDelete
  54. hi sir
    would you pleas help me about trust AODV.
    Im going to calculate and Detecting packet Forwards and Drops and calculate trustvalue and then define Malicious and faulty nodes and then bared them from the network.
    i found below address for this issue but i dont know how can i use it.

    ReplyDelete
  55. hi sir
    would you pleas help me about trust AODV.
    Im going to calculate and Detecting packet Forwards and Drops and calculate trustvalue and then define Malicious and faulty nodes and then bared them from the network.
    i found below address for this issue but i dont know how can i use it.
    http://www.dcs.warwick.ac.uk/~adhoc1/trustaodv.html#precision

    pleas help me
    Thank you very much

    ReplyDelete