The Agent../ns-2/agent.h supports packet generation and reception. The following member functions are implemented by the C++ Agent class, and are generally not over-ridden by derived classes:
|Packet* allocpkt||allocate new packet and assign its fields|
|[int]Packet* allocpkt||allocate new packet with a data payload of n bytes and assign its fields|
The following member functions are also defined by the class Agent, but are intended to be over-ridden by classes deriving from Agent:
|[timeout number]void timeout||subclass-specific time out method|
|[Packet*, Handler*]void recv||receiving agent main receive path|
The allocpkt method is used by derived classes to create packets to send. The function fills in the following fields in the common packet headerSectionchap:pformat: uid, ptype, size, and the following fields in the IP header: src, dst, flowid, prio, ttl. It also zero-fills in the following fields of the Flags header: ecn, pri, usr1, usr2. Any packet header information not included in these lists must be must be handled in the classes derived from Agent.
The recv method is the main entry point for an Agent which receives packets, and is invoked by upstream nodes when sending a packet. In most cases, Agents make no use of the second argument (the handler defined by upstream nodes).
Tom Henderson 2011-11-05