Mar 24, 2006

[ns] Ping protocol in greis's tutorial

Been busy with moving to a new lab.. anyway, was checking some of the online site for ns2 earlier, I found this email quite interesting since I faced the same problem some time ago..

[ns] Ping protocol in greis's tutorial
Hajer FERJANI f.hajer at
Fri Jan 27 00:57:31 PST 2006

* Previous message: [ns] Ping protocol in greis's tutorial
* Next message: [ns] ns-2 validation test
* Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi Ramya,

I'm using ns2.28 and I know that packet headers management changed a
little bit so the Marc Greis Tutorial could not work anymore.

Now, to add you new packet you have to :
- add you packet name to the enum structure containing packet names in
packet.h (under Common directory) (sorry I don't remeber its name)
- add the name of you packet as it should appears intraces in the same
file (another class just below the enum structure in the same file).

- define an offset and an access () method in the header structure of
you new agent like this :

struct hdr_newAgent{

// Contents of a newAgent message
double send_time;
double weight;
// Header access methods
static int offset_; // required by PacketHeaderManager
inline static int& offset() { return offset_; }
inline static hdr_newAgent* access(const Packet* p) {
return (hdr_newAgent*) p->access(offset_);


notice also that accessing the header of a protocol changed. So for
example to access the IP headerof a received packet, you should do :

struct hdr_ip *ih = HDR_IP(p);

where HDR_IP(p) is defined as:
#define HDR_IP(p) ((struct hdr_ip*)hdr_ip::access(p)).
and access(p) is the inline method of struct hdr_ip.

I think this is all,
Hope this helps.


On 26 Jan 2006 17:53:40 -0000, ramya r wrote:
> Hi,
> I tried to implement the Ping protocol specified in the Greis's tutorials under the ~ns/tcl/ns-tutorial folder..
> As per the specifications for the necessary changes to be made in order to implement this protocol,
> its mentioned that..-
> -----------------------
> You also have to add an entry for the new ping packets in the file 'tcl/lib/ns-packet.tcl' in the list at the beginning of the file. It would look like the following piece of code.
> { SRMEXT off_srm_ext_}
> { Ping off_ping_ }} {
> set cl PacketHeader/[lindex $pair 0]
> -------------------------
> the problem i have is that i do not find any such list in ns-paclet.tcl
> there is one list but its found commented ie., its an old code..
> What do i do?

1 comment:

Francisco said...

I had the same problem. For the change in ns-packet.tcl, you just have to add a line with your protocol (Ping in this case) in the list of:
foreach prot {
Ping #This is your ping
}} {
add-packet-header $prot

And it should work, at least it worked for me. Good luck