Hi all, sorry bout the repost but my last mail looked strange :\

I would be really happy if anyone could help me with my ns2 problem.

Im trying to write my own ping protocol running on AODV, and I am 
getting some strange behaviour.

It seems like the packets arent recognised in the trace files (I might 
be wrong here), and after a short while I get a seg. fault.

I based my Ping protocol on the one found in Marc's tutorial and used 
the new recommended way of setting the offset.

My ns2 is 2.29 built from the packages (not all-in-one).

When I run my tcl-script I get this as output:

$ ns wtf_AODV_ping.tcl > debug.txt
INITIALIZE THE LIST xListHead
SORTING LISTS ...DONE!
Segmentation fault
$

my topology is 1000x1000 with 16 nodes evenly spread out.
The nodes are set up like this:

set opt(chan) Channel/WirelessChannel
set chan_1_ [new $opt(chan)]

$ns_ node-config -adhocRouting     AODV \
                  -llType     LL \
                  -macType     Mac/802_11 \
                  -ifqType     Queue/DropTail/PriQueue \
                  -ifqLen     50 \
                  -antType     Antenna/OmniAntenna \
           -propType     Propagation/FreeSpace \
                  -phyType     Phy/WirelessPhy \
                   #-channelType     Channel/WirelessChannel \
                  -topoInstance     $topo \
                  -agentTrace     ON \
                  -routerTrace     OFF \
                  -macTrace     OFF \
          -movementTrace OFF \
          -channel     $chan_1_

And the nodes all have one agent each (Agent/PingAodv). The agents are 
getting connected to it self to prevent some error messages from ns:

$ns_ connect $PA($i) $PA($i)

Everything runs fine till after the first ping packet is sent:
$ns_ at 50 "$PA(0) send 5".

My ::command looks like this.

int PingAodvAgent::command(int argc, const char*const* argv) {
   if (argc == 3) {
     if (strcmp(argv[1], "send") == 0){

       //create new packet
       Packet* send_pkt = allocpkt();

       //get the ip header of the new packet
       hdr_ip* send_iph = hdr_ip::access(send_pkt);

       //set the dst_.addr to the requested node's ip
       send_iph->dst_.addr_ = (atoi(argv[2]));

       //get the ping header from the packet
       hdr_pingaodv* pingaodvh = hdr_pingaodv::access(send_pkt);

       //set the direction and the time the ping packet was sent
       pingaodvh->direction = 0; // 0 = request
       pingaodvh->sent_time = Scheduler::instance().clock();

       // Send the packet
       send(send_pkt, 0);

       cout << "send -> TCL_OK" << endl << flush;

       //tell TCL everything is allright
       return(TCL_OK);
     }
   }
   return (Agent::command(argc, argv));
}

::command returns so it seems to work fine (the debuglines are printed 
after the send-command).

in my common/packets.h I changed it to look like this:
...
         // insert new packet types here

         //inserted by me
         PT_PINGAODV,
         //--------------
         PT_NTYPE // This MUST be the LAST one
};
...

and

...
                 // XCP
                 name_[PT_XCP]="xcp";

                 //added by me
                 name_[PT_PINGAODV]="PingAodv";

                 name_[PT_NTYPE]= "undefined";

         }
...

In my ns-default.tcl I changed it to look like this

...
#
# Agents
#

# pingaodv inserted by me
Agent/PingAodv set packetSize_ 64
...


The first lines in my trace file:

------start------
s 50.000000000 _0_ AGT  --- 0 undefined 64 [0 0 0 0] ------- [0:0 5:0 32 0]
r 50.018762000 _5_ AGT  --- 0 undefined 84 [13a 5 0 800] ------- [0:0 
5:0 30 5]
s 50.018762000 _5_ AGT  --- 1 undefined 64 [0 0 0 0] ------- [5:0 5:0 32 0]
r 50.018762000 _5_ AGT  --- 1 undefined 64 [0 0 0 0] ------- [5:0 5:0 32 0]

I thought that it should say PingAodv instead of undefined here.
The tracefile just look like this for another 39000 lines and then the 
seg fault kicks in at time 50.018762000.


Does anyone have any clue on what I am doing wrong here?

Henrik

Reply via email to