[ns] Capturing Packets

scharan scharan20 at gmail.com
Sun Mar 1 23:30:29 PST 2009


Thanks again!

But is there no way to dump the entire packet, instead of first the header
and then the payload etc?


Mubashir Rehmani wrote:
> 
> 
> Hi Scharan
> 
> You just need to modify the recv function of each protocol that you need
> to
> capture the packets for.
> 
> You need to declare a header file
> #include<fstream.h>
> 
> ofstream DRN("abc.tr"); //your output file
> 
> Then in the recv() function, you will just do this:
> 
> struct hdr aodv reply * rp = HDR_AODV_REPLY(p); //declare the header
> 
> DRN<<rp->rp_dst <<endl; //it will print the header in the output file (
> abc.tr). In this way, you will dump all the contents of the packet that
> you
> have captured or dropped.
> 
> Regards
> Mubashir Husain Rehmani
> 
> 2009/3/2 scharan <scharan20 at gmail.com>
> 
>>
>>
>> Thanks!
>> I have the following clarification:
>>
>> Do I have to reimplement recv() function for each protocol that I need to
>> capture the packets for? Can u provide some examples or links to some
>> examples on how this should be done?
>>
>> - scharan.
>>
>>
>> Mubashir Rehmani wrote:
>> >
>> >
>> > Hi Sri Charan,
>> >
>> > Yes it is possible. You need to work in the recv() packet function and
>> > dump
>> > the contents of all the packet in the trace file.
>> >
>> > Regards
>> >
>> > Mubashir Husain Rehmani
>> > ASAP/INRIA and LIP6, UPMC
>> > www-rp.lip6.fr/~rehmani <http://www-rp.lip6.fr/%7Erehmani> <
>> http://www-rp.lip6.fr/%7Erehmani>
>> > http://www.irisa.fr/asap/Members/mrehmani/Mubashir
>> >
>> >
>> > 2009/3/2 Sri Charan <scharan20 at gmail.com>
>> >
>> >>
>> >> Hi,
>> >>
>> >> I need to capture each packet arriving at each node in the network (in
>> >> order
>> >> to calculate a hash on the *whole* packet, not just its header).
>> Another
>> >> way
>> >> to ask this is that I need to sniff the packet as it arrives at each
>> node
>> >> and save/dump it to a file. Is this possible in NS2? If yes, how?
>> >>
>> >> - scharan.
>> >>
>> >
>> >
>> >
>> > --
>> > Mubashir Husain Rehmani
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Capturing-Packets-tp22281401p22283043.html
>> Sent from the ns-users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Mubashir Husain Rehmani
> 
> 

-- 
View this message in context: http://www.nabble.com/Capturing-Packets-tp22281401p22283355.html
Sent from the ns-users mailing list archive at Nabble.com.



More information about the Ns-users mailing list