- 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