- Once a connector receives a packet, it immediately passes the packet to its forwarding object.
- Once a queue receives a packet, it puts the packet in its buffer. The queue will send out only the head-of-the-line packet.
In general, an NsObject forwards packets in two following ways:
- Immediate packet forwarding: A packet forwarder forwards a packet as soon as it receives the packet. The packet receiver receives the packet at the same time as the packet forwarder does. For example, a Connector forwards a packet to its downstream object by invoking target_->recv(p,h). In this case, the packet receiver (i.e., "*target_") receives the packet "*p" at the same time as the Connector does.
- Delayed packet forwarding: To delay packet forwarding, the packet "*p" is cast to be an Event object, associated with a packet receiving NsObject (i.e., handler "*h"), and placed on the simulation timeline at a given simulation time"t". This is to schedule a packet reception event at time "t". When the simulation runs to time "t", function handle of the NsObject "*h" is invoked. From within function NsObject::handle, function recv is executed, and the packet "*p" is received by the NsObject "*h".
The handler is optional for immediate packet forwarding. It is not used when executing recv(p,h). We can simply provide the "h" as a null pointer. However, in some cases, the handler will be passed to the downstream objects. At the place where a delayed packet forwarding is invoked, the handler "h" will be used as an input argument.
For more information about NsObject and packet forwarding, see the
following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
1 comment:
Dear Teerawat,
I tried getting your email address but got no luck. This looks like the only way I can get in touch with you.
I have your 2008 ns2 book. I have a question about the figure on page 169.
Should the IP header be to the left of the TCP header? In reality, the IP header is at the outer layer and the TCP header is at the inner layer.
Also, where are the static vairables offset_ (of different headers) assigned a value?
Thanks a lot and best regards.
Post a Comment