[ns] where is the packet header offset set when a new packet is generated?
Teerawat Issariyakul
teerawat at ece.ubc.ca
Fri Oct 31 22:21:58 PDT 2008
Packet construction is fairly subtle. In fact it consist of three phases:
1) At the compilation (when you type "make"):
In this phase, NS2 allocate the memory for all TclClasses.
PacketHeaderClass defined in file ~ns/common/packet.h,cc is one of them.
In the constructor of this class, the sizeof() is used to determine
space needed to store the packet header. The size is passed up the
hierarchy and stored in the variable hdrlen_.
2) At the network configuration phase: Remember that we have just compute
the size of each header. But the offset is the accumulation of the size.
When you invokes "$ns run", instproc create_packetformat() is invoked.
Here the offset is computed by repeatedly added all the active header
together.
3) During the simulation phase: You may invoke function allocpkt() of
class Agent. Here the value of offset_ has already been set, and can be
used at will.
I suggest you to go through chapter 8 (specifically Section 8.3.8) in the
following book from Springer. You will find everything you need about
packets:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
Here is the link:
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You might also find the following slide useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm<http://www.ece.ubc.ca/%7Eteerawat/NS2.htm>
Best,
Teerawat
On 10/31/2008, "matt Wood" <withhighprob at gmail.com> wrote:
>
>Dear all,
> In NS2, the packet header must be accessed through its offset. But I can
>not find where the offset_ is initialized. Please look and see if my
>understanding of this issue is right or not:
>
> In the RTPAgent, it is directly use hdr_cmn::access(p) to access the
>header part. When the RTPAgent is configured in TCL, a binding is made to
>connect the RTP header's offset to the "offset_" of struct "hdr_cmn".
>Therefore, through the forced type conversion "return (hdr_rtp*)
>p->access(offset_);" (in ns/apps/rtp.cc, and p is a pointer to a new Packet
>instance), the "offset_" in hdr_rtp (which is a child of hdr_cmn) is
>initialized to the value configured through TCL.
>
> Thank you.
>
More information about the Ns-users
mailing list