12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 10AgentsAgents represent endpoints where network-layer packets are co<strong>ns</strong>tructed or co<strong>ns</strong>umed, <strong>and</strong> are used in the implement<strong>at</strong>ionof protocols <strong>at</strong> various layers. <strong>The</strong> class Agent has an implement<strong>at</strong>ion partly in OTcl <strong>and</strong> partly in C++. <strong>The</strong> C++implement<strong>at</strong>ion is contained in ~<strong>ns</strong>/agent.cc <strong>and</strong> ~<strong>ns</strong>/agent.h, <strong>and</strong> the OTcl support is in ~<strong>ns</strong>/tcl/lib/<strong>ns</strong>-agent.tcl.10.1 Agent st<strong>at</strong>e<strong>The</strong> C++ class Agent includes enough internal st<strong>at</strong>e to assign various fields to a simul<strong>at</strong>ed packet before it is sent. Thisst<strong>at</strong>e includes the following:addr_dst_size_type_fid_prio_flags_defttl_node address of myself (source address in packets)where I am sending packets topacket size in bytes (placed into the common packet header)type of packet (in the common header, see packet.h)the IP flow identifier (<strong>formerly</strong> class in <strong>ns</strong>-1)the IP priority fieldpacket flags (similar to <strong>ns</strong>-1)default IP ttl value<strong>The</strong>se variables may be modified by any class derived from Agent, although not all of them may be needed by any particularagent.10.2 Agent methods<strong>The</strong> class Agent supports packet gener<strong>at</strong>ion <strong>and</strong> reception. <strong>The</strong> following member functio<strong>ns</strong> are implemented by theC++ Agent class, <strong>and</strong> are generally not over-ridden by derived classes:Packet* allocpkt()Packet* allocpkt(int)alloc<strong>at</strong>e new packet <strong>and</strong> assign its fieldsalloc<strong>at</strong>e new packet with a d<strong>at</strong>a payload of n bytes <strong>and</strong> assign its fields96

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!