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:
The following member functions are also defined by the class Agent, but are intended to be over-ridden by classes deriving from Agent:
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).