Skip to main content

Runtime packet loss calculation in NS2

Hello friend, here I am going to present a method to calculate the runtime packet loss. I am going to show this using ns2 2.34 and AODV.
      Sometime we require packet loss to calculate trust value (in case of Trust Based protocols where it is done by no. of packets sent - no. of packets received).
       I am going to show the calculation for a particular pair of nodes.
Steps involved:-


A) We will have to add a node as a malicious node which will drop the packets
     intentionally. You can add a malicious node using this link.

B) Second, we'll set the AODV in promiscuous mode, where every node will
     listen to its neighbors.


1) We need to modify in total 3 files to set AODV in promiscuous mode, 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.
This code goes at top in header section.
  #include <mac.h>
 ..............................................
 ..............................................
//This code goes at line 128.
class MalTimer : public Handler {
public:
        MalTimer(AODV* a) : agent(a) {}
        void    handle(Event*);
private:
        AODV    *agent;
    Event    intr;
};
 
..............................................
 ..............................................
// This code is below the text 
/*
  The Routing Agent
*/
//Approximately at line 203

  class AODV: public Tap, public Agent {
  public:
  void  tap(const Packet *p);
  void  check_mal(void);
  int  fcount;
  int  rcount;
  ......
  protected:
  Mac *mac_;
  ......
 }
 ..............................................
 ..............................................
 //This code is below the text 
 /*
  * Timers
  */
// Approximately at line 308
 MalTimer        maltimer;
3) Open the file ns-allinone-2.34/ns-2.34/aodv/aodv.cc and make the changes as  
    shown in blue color.
 This blue code is approximately at line 94
if (strncasecmp(argv[1], "start", 2) == 0) {
            btimer.handle((Event*) 0);
            maltimer.handle((Event*) 0);
#ifndef AODV_LINK_LAYER_DETECTION
            htimer.handle((Event*) 0);
            ntimer.handle((Event*) 0);
#endif // LINK LAYER DETECTION
            rtimer.handle((Event*) 0);
            return TCL_OK;
        }
//  This blue code is approximately at line 133
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);

}

 //Add the following blue code just below the above code

void
AODV::tap(const Packet *p) {
struct hdr_cmn* hdcmn = HDR_CMN(p);
    if (index == 0) {
        if (hdcmn->ptype_ == PT_CBR) {
            rcount++;
        }
    }
}
 ..............................................
 ..............................................
//This blue code is approximately at line 160 
AODV::AODV(nsaddr_t id) : Agent(PT_AODV),
              btimer(this), htimer(this), ntimer(this),
              rtimer(this), lrtimer(this), maltimer(this), rqueue() {

              
  index = id;
  seqno = 2;
  bid = 1;
  malicious = false;
  rcount = 0;
  fcount = 0;

  LIST_INIT(&nbhead);
  LIST_INIT(&bihead);

  logtarget = 0;
  ifqueue = 0;
}
 
 //This code is above the text 
/*
   Broadcast ID Management  Functions
*/
// Approximately at line 233
 void MalTimer::handle(Event*) {
    agent->check_mal();
    Scheduler::instance().schedule(this, &intr, 0.5);
}
void AODV::check_mal() {
    if (index == 0) {
        if (fcount > rcount + 1 ) {
                fprintf(stderr, "No. of packets dropped are %d\n", fcount-rcount);
        }   

    }
}
Note:- When you are adding malicious node module, please replace author code  
// if I am malicious node
 if (malicious == true ) {
    drop(p, DROP_RTR_ROUTE_LOOP);
    // DROP_RTR_ROUTE_LOOP is added for no reason.
 }
to
if (malicious == true) {
         if (ch->ptype_ == PT_CBR) {          
             drop(p, DROP_RTR_ROUTE_LOOP);

             return;//Required if you get pkt flow not specified error.
        // DROP_RTR_ROUTE_LOOP is added for no reason.
         }
     }
 //Add the following blue code just below the above code
if (index == 0) {
        if (ch->ptype_ == PT_CBR) {
            fcount++;
        }
    }
 
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)
......

}


6) Now, make the NS2 by using following commands in ns-allinone-2.34/ns-2.34 directory.

  • make clean
  • make depend
  • make
5) Here is my sample tcl file, aodv.tcl
#======================================================================
# Define options
#======================================================================
 set val(chan)         Channel/WirelessChannel  ;# channel type
 set val(prop)         Propagation/TwoRayGround ;# radio-propagation model
 set val(ant)          Antenna/OmniAntenna      ;# Antenna type
 set val(ll)           LL                       ;# Link layer type
 set val(ifq)          Queue/DropTail/PriQueue  ;# Interface queue type
 set val(ifqlen)       50                       ;# max packet in ifq
 set val(netif)        Phy/WirelessPhy          ;# network interface type
 set val(mac)          Mac/802_11               ;# MAC type
 set val(nn)           6                        ;# number of mobilenodes
 set val(rp)           AODV                     ;# routing protocol
 set val(x)            800
 set val(y)            800



set ns [new Simulator]
#ns-random 0

set f [open out.tr w]
$ns trace-all $f
set namtrace [open out.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid 800 800

create-god $val(nn)

set chan_1 [new $val(chan)]
set chan_2 [new $val(chan)]
set chan_3 [new $val(chan)]
set chan_4 [new $val(chan)]
set chan_5 [new $val(chan)]
set chan_6 [new $val(chan)]

# CONFIGURE AND CREATE NODES

$ns node-config  -adhocRouting $val(rp) \
          -llType $val(ll) \
                 -macType $val(mac) \
                 -ifqType $val(ifq) \
                 -ifqLen $val(ifqlen) \
                 -antType $val(ant) \
                 -propType $val(prop) \
                 -phyType $val(netif) \
                 #-channelType $val(chan) \
                 -topoInstance $topo \
                 -agentTrace ON \
                 -routerTrace ON \
                 -macTrace ON \
                 -movementTrace OFF \
                 -channel $chan_1

proc finish {} {
    global ns namtrace
    $ns flush-trace
        close $namtrace  
        exec nam -r 5m out.nam &
    exit 0
}

# define color index
$ns color 0 blue
$ns color 1 red
$ns color 2 chocolate
$ns color 3 red
$ns color 4 brown
$ns color 5 tan
$ns color 6 gold
$ns color 7 black
                       
set n(0) [$ns node]
$ns at 0.0 "$n(0) color blue"
$n(0) color "0"
$n(0) shape "circle"
set n(1) [$ns node]
$ns at 0.0 "$n(1) color red"
$n(1) color "blue"
$n(1) shape "circle"
set n(2) [$ns node]
$n(2) color "tan"
$n(2) shape "circle"
set n(3) [$ns node]
$n(3) color "red"
$n(3) shape "circle"
set n(4) [$ns node]
$n(4) color "tan"
$n(4) shape "circle"
set n(5) [$ns node]
$ns at 0.0 "$n(5) color blue"
$n(5) color "red"
$n(5) shape "circle"


for {set i 0} {$i < $val(nn)} {incr i} {
    $ns initial_node_pos $n($i) 30+i*100
}

$ns at 0.0 "[$n(1) set ragent_] hacker"            
$ns at 0.0 "$n(0) setdest 100.0 100.0 3000.0"
$ns at 0.0 "$n(1) setdest 200.0 200.0 3000.0"
$ns at 0.0 "$n(2) setdest 300.0 200.0 3000.0"
$ns at 0.0 "$n(3) setdest 400.0 300.0 3000.0"
$ns at 0.0 "$n(4) setdest 500.0 300.0 3000.0"
$ns at 0.0 "$n(5) setdest 600.0 400.0 3000.0"

# CONFIGURE AND SET UP A FLOW

set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
set sink3 [new Agent/LossMonitor]
set sink4 [new Agent/LossMonitor]
set sink5 [new Agent/LossMonitor]
$ns attach-agent $n(0) $sink0
$ns attach-agent $n(1) $sink1
$ns attach-agent $n(2) $sink2
$ns attach-agent $n(3) $sink3
$ns attach-agent $n(4) $sink4
$ns attach-agent $n(5) $sink5

#$ns attach-agent $sink2 $sink3
set tcp0 [new Agent/TCP]
$ns attach-agent $n(0) $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n(1) $tcp1
set tcp2 [new Agent/TCP]
$ns attach-agent $n(2) $tcp2
set tcp3 [new Agent/TCP]
$ns attach-agent $n(3) $tcp3
set tcp4 [new Agent/TCP]
$ns attach-agent $n(4) $tcp4
set tcp5 [new Agent/TCP]
$ns attach-agent $n(5) $tcp5


proc attach-CBR-traffic { node sink size interval } {
   #Get an instance of the simulator
   set ns [Simulator instance]
   #Create a CBR  agent and attach it to the node
   set cbr [new Agent/CBR]
   $ns attach-agent $node $cbr
   $cbr set packetSize_ $size
   $cbr set interval_ $interval

   #Attach CBR source to sink;
   $ns connect $cbr $sink
   return $cbr
  }

set cbr0 [attach-CBR-traffic $n(0) $sink5 1000 .030]
$ns at 0.5 "$cbr0 start"
$ns at 5.5 "finish"
puts "Start of simulation.."
$ns run
 

6) In above script, node 0 is source and node 5 is destination. Node 1 is set as
    malicious node.

Comments

  1. i had added what you had given and do the three make steps.whenever i run a tcl file i got the error


    num_nodes is set 6
    INITIALIZE THE LIST xListHead
    can't read "mac_(0)": no such variable
    while executing
    "$agent install-tap $mac_(0) #arifa"
    (procedure "_o19" line 31)
    (Node/MobileNode add-target line 31)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 82)
    (Simulator create-wireless-node line 82)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "mactest.tcl" line 74)


    can you please tell me why this happened

    ReplyDelete
    Replies
    1. $self instvar dmux_ imep_ toraDebug_ mac_

      In this statement leave a space between toraDebug_ and mac_ and it will be done. I was receiving the same error.i have solved it

      Delete
  2. i had added what you had given and do the three make steps.whenever i run a tcl file i got the error


    num_nodes is set 6
    INITIALIZE THE LIST xListHead
    can't read "mac_(0)": no such variable
    while executing
    "$agent install-tap $mac_(0) #arifa"
    (procedure "_o19" line 31)
    (Node/MobileNode add-target line 31)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 82)
    (Simulator create-wireless-node line 82)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "mactest.tcl" line 74)


    can you please tell me why this happened

    12 September 2012 23:23

    ReplyDelete
    Replies
    1. Probably u missed below line.

      $self instvar dmux_ imep_ toraDebug_ mac_

      mac_ has to be there in above line. You have to add it.

      Delete
    2. I add this but still i'm getting the same error.
      plz help

      Delete
  3. Dear sir , This is what i get after executing. Can u verify and do pls post the output too.

    mcq@mcq:~/Desktop/NS 2/Final$ ns vb.tcl
    num_nodes is set 6
    INITIALIZE THE LIST xListHead
    using backward compatible Agent/CBR; use Application/Traffic/CBR instead
    Start of simulation..
    channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
    highestAntennaZ_ = 1.5, distCST_ = 550.0
    SORTING LISTS ...DONE!
    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    Direction for pkt-flow not specified; Sending pkt up the stack on default.

    check_pktTx:Invalid MAC Control subtype

    ReplyDelete
  4. Sorry dear but I have not seen any such error! Better way u can try whole process on a fresh ns2 2.34 installation. All the best!

    ReplyDelete
  5. i want to know which node is monitoring

    ReplyDelete
  6. Node 0 is monitoring!
    In below code index identifies current instance of node, i.e. 0 in this case.
    if (index == 0) {
    if (hdcmn->ptype_ == PT_CBR) {
    rcount++;
    }
    }

    ReplyDelete
    Replies
    1. sir how do i isolate malicious node from the network?
      I have to do temporary isolation and permanent isolation.the isolation should be done by its neighbouring nodes only not all the nodes in the network. can you pls suggest me how to do that.....thanks in advance

      Delete
  7. hai Mr.Durgesh

    i have following error pls help to debug

    (_o5 cmd line 1)
    invoked from within
    "_o5 cmd at 0.0 _o40 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 _o40 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_(1) set ragent_] "hacker" "

    ReplyDelete
  8. (_o5 cmd line 1)
    invoked from within
    "_o5 cmd at 0.0 _o40 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 _o40 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_(1) set ragent_] "hacker" "

    ReplyDelete
    Replies
    1. I think that "$ns at 0.0 [$node_(1) set ragent_] hacker"

      not "$ns at 0.0 [$node_(1) set ragent_] "hacker"

      Delete
  9. if (malicious == true) {
    if (ch->ptype_ == PT_CBR) {
    drop(p, DROP_RTR_ROUTE_LOOP);
    // DROP_RTR_ROUTE_LOOP is added for no reason.
    }
    }

    in which funtion i should add this because i was not able to find the replacable content given above

    ReplyDelete
  10. Hi...what if i only want the count of received and sent packets and also want to check what kind of packet it is..without malicious and promiscuous mode...how can that be accomplished????????????????/

    ReplyDelete
  11. How to find the no. of packets received and sent by a node along with the packet type/size without using promiscuous mode and mal node????

    ReplyDelete
    Replies
    1. u need to use common header to identify packet type and two counters for maintaining sent/received packets. One more thing, according to my knowledge promiscuous mode is required for listening/overhearing packets of neighbors. Otherwise, you can make use of your own acknowledgement packets. All the best!

      Delete
  12. Hi sir,
    I want codes to implement syn and smurf attacks......

    ReplyDelete
  13. Sorry! but, I don't know about these attacks. Drop me a mail in detail about that!

    ReplyDelete
  14. Hi

    Thanks for your great help for ns-2 users

    I want malicious node to drop the packet in some manner. For example, it drops the packets as follows:
    ....
    if (malicious == true) {
    if (ch->ptype_ == PT_CBR) {
    int i;
    i= 1+ rand()% 6;
    if (i>3){
    drop(p, DROP_RTR_ROUTE_LOOP);}
    //DROP_RTR_ROUTE_LOOP is added for no reason.
    }
    }
    ...

    However when I implement this code, it does not work.
    Can you please help me on this ?

    ReplyDelete
  15. Thanks sir, I managed how to drop the packets in certain pattern.

    Please can you help me to handle following questions?

    1. You defined 'fcount' and 'rcount'. Are these for counting received(fcount) and forwarded(rcount) packets?

    2. How we can add drop rate in route selection as criteria?

    Thanks

    ReplyDelete
    Replies
    1. u r right! rcount and fcount are used for same purpose!
      I didn't get about drop rate.

      Delete
  16. Hi
    My point is that for example node 0 monitors not only node 1 but also node 2 (if we allocate the node 2 paralell with node1). So node 0 can estimate packet drop for each node(node1 and node2) and choose the one who has less packet drop.

    So how we can make node 0 monitor both nodes(not in the same time) and estimate packet drop for each node ?

    Morever, how we can change route choosing decision based packet drop(for example if node 2 has less packet drop we will choose node 2 as next node not node 1)?

    ReplyDelete
    Replies
    1. Hello! u can make use of a table to store no. packets transmitted and no. of packets forwarded.
      E.g.
      If u want to monitor nodes 2 & 3 by node 0,
      Node 0 will maintain a table of packets transmitted by itself to node 2 & 3 and no. of packets it receives back in promiscuous mode. No doubt intended receivers of packets should be 2 &3 only. Using this data values u can decide on path. All the best!

      Delete
  17. how to print nexthop?

    Here we can find no. of packeddrop only. we need to print packet transferring path also. how can do?

    ReplyDelete
    Replies
    1. I am assuming u r using AODV. If u want print whole path, u need to add an extra field in ur data/control (as per requirement) packet. There u can append whole path to packet and later extract it. All the best!

      Delete
  18. hi i want to implement trust based routing in aodv. kindly pls help me to figure out what will change in aodv and which module. if any idea related to trust based routing, plz reply me as soon as possible..............

    ReplyDelete
  19. For trust based routing, u need to decide on which parameters u r going to calculate trust of each node. If AODV is protocol, u need to modify, aodv_rtable.h, aodv_rtable.cc, aodv.cc and aodv.h files. All the best!

    ReplyDelete
    Replies
    1. how to monitor the number of rts/cts packets.

      Delete
  20. Hi
    Can u please help me to implement trust based AODV ? I am writing paper for journal. I need to add some simulation results. If we can get some results, you also will be one of the authors of the paper....

    ReplyDelete
  21. I will help you. Drop me a mail at durgeshpkshirsagar@gmail.com and we'll discuss!

    ReplyDelete
    Replies
    1. i am also working in trust value.pls send me code to implement trust based aodv . pls send it soon. its urgent

      Delete
  22. Hello ,

    it works with ns 2.35 ?

    ReplyDelete
    Replies
    1. Sorry! I have not tried it on 2.35. Better way is to check it yourself! If you get some errors ask me.

      Delete
    2. I have following error
      ns: _o44 hacker:
      (_o44 cmd line 1)
      invoked from within
      "_o44 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 "_o44" line 2)
      (SplitObject unknown line 2)
      invoked from within
      "_o44 hacker"

      Delete
    3. i think it means miss-match of the word used "hacker" must check it bcoz i'm having the same problem

      Delete
  23. Hi,
    the monitor (node 0)calculate the packets dropped for only the malicious node(node 1) or for all its neighbors?

    ReplyDelete
  24. hi,

    I followed the steps as described, but when i execute the sample tcl file,the folloing error appears on terminal

    num_nodes is set 6
    INITIALIZE THE LIST xListHead

    (_o22 cmd line 1)
    invoked from within
    "_o22 cmd install-tap _o24"
    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 "_o22" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "$agent install-tap $mac_(0)"
    (procedure "_o19" line 24)
    (Node/MobileNode add-target line 24)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 85)
    (Simulator create-wireless-node line 85)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "vanet.tcl" line 74)

    can you reply the reason for this error.

    Thank you.

    ReplyDelete
  25. hi,

    I followed the steps as described, but when I execute the sample tcl file,the following error appears on the terminal

    num_nodes is set 6
    INITIALIZE THE LIST xListHead

    (_o22 cmd line 1)
    invoked from within
    "_o22 cmd install-tap _o24"
    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 "_o22" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "$agent install-tap $mac_(0)"
    (procedure "_o19" line 24)
    (Node/MobileNode add-target line 24)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 85)
    (Simulator create-wireless-node line 85)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "vanet.tcl" line 74)

    can you reply the reason for this error. Kindly help to resolve this issue.

    Thank you.

    ReplyDelete
    Replies
    1. did u add return TCL_OK? Please check that!

      Delete
  26. sir,could you send me ns2.34/tcl/lib/ns-mobilenode.tcl file
    b'coz i'm having the error msg i think ns-mobilenode.tcl file has some problem.......

    can't read "mac_(0)": no such variable
    while executing
    "$agent install-tap $mac_(0)"
    (procedure "_o19" line 24)
    (Node/MobileNode add-target line 24)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 84)
    (Simulator create-wireless-node line 84)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "sample-test.tcl" line 71)

    ReplyDelete
  27. 1) If I replace line :
    $ns at 0.0 "[$n(1) set ragent_] hacker" with
    $ns at 0.0 "[$n(2) set ragent_] hacker"
    then node 2 is not dropping the packets. Where should i make changes
    so that it will work properly?

    2) Before I click on play forward button it shows following message on the
    terminal:

    No. of packets dropped are 17
    No. of packets dropped are 34
    No. of packets dropped are 50
    No. of packets dropped are 67
    No. of packets dropped are 84
    No. of packets dropped are 101
    No. of packets dropped are 117
    No. of packets dropped are 134
    No. of packets dropped are 151

    How it could be?

    ReplyDelete
    Replies
    1. First thing is node 2 should not be source or destination. Second thing, you can use like
      if(index==2)
      {
      fprintf(stderr,"I am node %d and dropping packet\n",index);
      }

      add this is rt_resolve() method. All the best

      Delete
  28. How to detect this malicious node?

    ReplyDelete
  29. Decide ur threshold for drops first! Then u can check with that value and isolate node.

    ReplyDelete
    Replies
    1. Dear Durgesh .
      I did all the above step-by-step. But I do not know how to detect the malicious nodes and isolate in the network.
      pleas send me executable files for me .if can. thank u very much.

      Delete
    2. my email: babaei.mehrdad@gmail.com
      thank's

      Delete
  30. hello Durgesh,
    could you send me the .tcl file for this b'coz i did same this to implement promiscious mode in AODV.
    but i getting the error msg like:"can't read "mac_(0)": no such variable...."
    so plz send me the tcl file... may be that would help...
    thank you

    ReplyDelete
    Replies
    1. or you could send me these three files...........

      Delete
    2. Drop me a test mail I will send you code!

      Delete
  31. hello Sir,

    I am trying to implement trust based routing in zrp. please guide me for this.

    How can I count number of packets forwarded or dropped by all other in order to calculate trust, as you did between node 0 and node 1?
    please help

    ReplyDelete
  32. Drop me a test mail I will send you code!

    ReplyDelete
    Replies
    1. Plz send code to resmi345@gmail.com

      Delete
    2. sir can you please send the same code to v20021994@gmail.com ... it's urgent.

      Delete
  33. Hi Durgesh,

    I am working on AODV and have a similar question to kriti:

    kriti10 August 2013 06:44

    hello Sir,

    I am trying to implement trust based routing in zrp. please guide me for this.

    How can I count number of packets forwarded or dropped by all other in order to calculate trust, as you did between node 0 and node 1?
    please help

    My thesis is on AODV. Can you please help?
    Respectfully,
    Koffka.

    ReplyDelete
  34. i have the following error

    _o44 hacker:
    (_o44 cmd line 1)
    invoked from within
    "_o44 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 "_o44" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o44 hacker"

    ReplyDelete
  35. sir,
    where should we add the author code....???

    ReplyDelete
  36. Hello sir..I am trying to implement intrusion detetion using fuzzy logic..Could u please tell me how would I able to simlute in ns2.35.And give me your mail id also..

    ReplyDelete
  37. hello sir, afer running make depend
    error :
    emulate/net-pcap.cc:64:18: fatal error: pcap.h: No such file or directory
    compilation terminated.

    ReplyDelete
  38. Sir,
    When I run make clean I end up with
    make: *** No rule to make target `clean'. Stop.
    Is there any alternative for this?

    ReplyDelete
    Replies
    1. hello sir, afer running make depend
      error :
      emulate/net-pcap.cc:64:18: fatal error: pcap.h: No such file or directory
      compilation terminated.

      Delete
  39. sir,
    i have added malicious node in aodv protocol, it must drop the packet and need to send acknowledgment to source node. i have code for drop the packet but its not working properly. i have included in rt_ resolve function. i dont know where to include the code in rt_resolve. i want to know how to send acknowledgment .please any one help.my mail id :manocse89@gmail.com

    ReplyDelete
  40. Hello Durgesh i have tried all the changes that you have told but still i am getting error as Ritu Sori21 October 2013 04:15
    can u plz mail me all three files at suvira.1310@gmail.com
    thanx in advance

    ReplyDelete
  41. sir,
    i am using blackhole routing protocol to add malicious node so can u please tell me where to insert fcount code...

    ReplyDelete
  42. num_nodes is set 6
    INITIALIZE THE LIST xListHead
    using backward compatible Agent/CBR; use Application/Traffic/CBR instead
    Start of simulation..
    ns: _o44 hacker:
    (_o44 cmd line 1)
    invoked from within
    "_o44 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 "_o44" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o44 hacker"

    ReplyDelete
  43. hello..
    i need your help..
    can you please tell me the code of adding simple malicious node in aodv...how to edit aodv.cc and aodv.h file for malicious node

    ReplyDelete
  44. i am getting this error pls pls help me

    num_nodes is set 6
    INITIALIZE THE LIST xListHead
    using backward compatible Agent/CBR; use Application/Traffic/CBR instead
    Start of simulation..
    ns: _o44 hacker:
    (_o44 cmd line 1)
    invoked from within
    "_o44 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 "_o44" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o44 hacker

    ReplyDelete
  45. Thank u so much.. It was very useful for me..

    ReplyDelete
  46. please tell how to introduce more than one malicious node in aodv source code

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

    ReplyDelete
  48. num_nodes is set 25
    INITIALIZE THE LIST xListHead
    Starting Simulation...
    channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
    highestAntennaZ_ = 1.5, distCST_ = 550.0
    SORTING LISTS ...DONE!
    ns: _o215 hacker:
    (_o215 cmd line 1)
    invoked from within
    "_o215 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 "_o215" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o215 hacker"

    plss tell e what to do....make command is also not working
    plss rply me on roohi.mini227@gm

    ReplyDelete
  49. How can I calculate the number of rts and cts packets exchanged at mac layer during a simulation.

    ReplyDelete
  50. How can I calculate the number of rts and cts packets exchanged at mac layer during a simulation.

    ReplyDelete
  51. Hi,

    I get this error while executing.

    ns: _o107 hacker:
    (_o107 cmd line 1)
    invoked from within
    "_o107 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 "_o107" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o107 hacker"

    Please do help. Its very important for me

    ReplyDelete
  52. I try to include malicious nodes in my tcl script sir.Help me sir when running my tcl script it shows the following error

    num_nodes is set 6
    INITIALIZE THE LIST xListHead
    using backward compatible Agent/CBR; use Application/Traffic/CBR instead
    Start of simulation..
    ns: _o44 hacker:
    (_o44 cmd line 1)
    invoked from within
    "_o44 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 "_o44" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "_o44 hacker"

    ReplyDelete
  53. hi,
    How to simulate DDOS attack in ns2?

    ReplyDelete
  54. hi sir ..
    i wore in NS2.35 when i implement this code i get this error
    virtual int AODV::command(int, const char* const*)’:
    aodv/aodv.cc:88:5: error: ‘maltimer’ was not declared in this scope
    maltimer.handle((Event*) 0);
    aodv/aodv.cc: In constructor ‘AODV::AODV(nsaddr_t)’:
    aodv/aodv.cc:158:34: error: class ‘AODV’ does not have any field named ‘maltimer’
    rtimer(this), lrtimer(this),maltimer(this), rqueue()
    PLZ help me .. what is wrong???

    ReplyDelete
    Replies
    1. You need to declare maltimer in aodv.h file.

      Delete
  55. Sir , Please give your mail id

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

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

    ReplyDelete
  58. sir
    I wanted a code for packet dropping attack in DSR.(7 nodes)
    In which if the receiver gets the packet properly receiver has to send back an acknowledgement(ACK) packet to sender (No packet dropping attack)

    can you please help
    Thank you
    Abhi

    ReplyDelete
    Replies
    1. hello @abhishek plz mail me project2.matrixarc@gmail.com i will provide that code

      Delete
  59. plz help me to do watchdog mechanism in ns2

    ReplyDelete
  60. Hi..I m doing project in MANET. in that i want to send bait packets(packet with fake destination address) to bait or catch malicious nodes.can u provide code for this.

    ReplyDelete
  61. Hi..I m doing project in MANET. in that i want to send bait packets(packet with fake destination address) to bait or catch malicious nodes.can u provide code for this.

    ReplyDelete
  62. sir,can u send me the code for calculating trust values

    ReplyDelete
  63. sir can u please send me code for calculating round trip time for round trip path for finding faulty node

    ReplyDelete
  64. hi,
    can anyone tell me how to get current system in ns2?
    i want to have function which displays current real time and also helps to find duration of session using time

    ReplyDelete
  65. how to change the environment for AODV from IPv4 to IPv6

    ReplyDelete
  66. can u please tell me how can i drop or loss RERR message in aodv tcl script

    ReplyDelete
  67. Hello.....

    Need assistance in creating two dimensional arrays.

    I need to create the below scenario

    nblist_0 = {1,2,3,4}
    nblist_1 = {3,7,5,9,1}
    nblist_2 = {7,4,9,2,5}
    nblist_3 = {1,2,4,6}
    nblist_4 = {1,5,4} and soon

    Since my logic hereafter follows the above two dimensional array, I also need the logic to access the individual data (just like an array). Kindly help!!

    ReplyDelete
  68. Hello sir..I am trying to implement intrusion detetion using IDSAODV Could u please tell me how would I able to simlute in ns2.35.And i want to implement trustedAODV with blackhole attack added. pls sir send me .tcl file , Trusted AODV .cc file and Trusted AODV.h file to find the packetdropp, throughput and delay.pls help me it is urgent to me. my email nilam.nlm@gmail.com thanks sir in advance

    ReplyDelete
  69. sir , i have change AODV.cc , AODV.h and ns-mobilenode.tcl according to the above given code. after change i given make clean make depent and make command but i found following error /filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o aodv/aodv.o aodv/aodv.cc
    aodv/aodv.cc:99:3: error: expected unqualified-id before ‘else’
    else if(argc == 3) {
    ^
    aodv/aodv.cc: In member function ‘virtual int AODV::command(int, const char* const*)’:
    aodv/aodv.cc:98:3: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    make: *** [aodv/aodv.o] Error 1
    pls help me how to remove it.

    ReplyDelete

Post a Comment

Popular posts from this blog

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_;   ......  }

How to add trust table in NS2.

I am assuming AODV protocol. In rtable.cc add below code trust_entry::trust_entry() {    //Initialize as per your need. } trust_entry::~trust_entry() {   //Deconstruct as per your need. } trust_entry* trust_store::trust_lookup( nsaddr_t node_id) {      trust_entry *rp = trusthead.lh_first;      for (; rp; rp = rp->trust_link.le_next) {              if (rp->node_id == node_id)                  break;      }     return rp; } void trust_store::trust_delete( nsaddr_t node_id) {     trust_entry *rp = trust_lookup(node_id);     if (rp)     {         LIST_REMOVE(rp, trust_link);         delete rp;     } } trust_entry* trust_store::trust_insert( nsaddr_t node_id, nsaddr_t prev_node,nsaddr_t next_node,int32_t trust_value) {     trust_entry *rp;     //assert(tr_lookup(dst_seq_no) == 0);     rp = new trust_entry;     assert(rp);     rp->node_id = node_id;     rp->prev_node = prev_node;     rp->next_node = next_node;     rp->trust_value = trust_value;     LIS