[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Re: how to access packet header ?



Hi all!

John Heidemann wrote:

> >hi,
> >
> >when configuring a packet header, I found there are two approaches to access
> >the packet header. For example, assuming p is the packet, to access the IP
> >header of p, two approaches can be used :
> >1)  hdr_ip *iph = (hdr_ip *) p->access(hdr_ip::offset_);
> >2)  In initializing :
> >         bind("off_ip_", &off_ip_);
> >    Then use :
> >         hdr_ip *iph = (hdr_ip *) p->access(off_ip_);
> >
> >What is the difference between these two approaches ? Which one is correct ?
> >
> >Thanks in advance for any answers.
>
> They're equivalent, but choice (1) is faster because it doesn't
> require the tcl bind initialization code.
>
>    -John Heidemann

Ns Manual explains the second choice in detail. It says that PacketHeaderManager
initializes all tcl variables off_<proto>_ and one shall do the C++ binding.
But how hdr_<proto>::offset_ variables get initialized? PacketHeader classes
contain an int* offset_ that is used to point to hdr_xxx:::offset_. But I still
don't know who initializes hdr_xxx::offset_.

Thaks!