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.

the system’s memory alloc<strong>at</strong>or. I<strong>ns</strong>tead, they are stored on a free list when Packet::free() is called. <strong>The</strong> copy() membercre<strong>at</strong>es a new, identical copy of a packet with the exception of the uid_ field, which is unique. This function is used byReplic<strong>at</strong>or objects to support multicast distribution <strong>and</strong> LANs.12.2.2 p_info ClassThis class is used as a “glue” to bind numeric packet type values with their symbolic names. When a new packet type isdefined, its numeric code should be added to the enumer<strong>at</strong>ion packet_t (see ~<strong>ns</strong>/packet.h) 2 <strong>and</strong> its symbolic name shouldbe added to the co<strong>ns</strong>tructor of p_info:enum packet_t {PT_TCP,...PT_NTYPE // This MUST be the LAST one};class p_info {public:p_info() {name_[PT_TCP]= "tcp";...}}12.2.3 <strong>The</strong> hdr_cmn ClassEvery packet in the simul<strong>at</strong>or has a “common” header which is defined in ~<strong>ns</strong>/packet.h as follows:struct hdr_cmn {double ts_; /* timestamp: for q-delay measurement */packet_t ptype_; /* packet type (see above) */int uid_; /* unique id */int size_; /* simul<strong>at</strong>ed packet size */int iface_; /* receiving interface (label) *//* Packet header access functio<strong>ns</strong> */st<strong>at</strong>ic int offset_;inline st<strong>at</strong>ic int& offset() { return offset_; }inline st<strong>at</strong>ic hdr_cmn* access(Packet* p) {return (hdr_cmn*) p->access(offset_);}/* per-field member functio<strong>ns</strong> */int& ptype() { return (ptype_); }int& uid() { return (uid_); }int& size() { return (size_); }int& iface() { return (iface_); }2 Note: PT_NTYPE should remain the last element of this enumer<strong>at</strong>ion.122

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

Saved successfully!

Ooh no, something went wrong!