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.

which cre<strong>at</strong>es a trace object, sndT, of the type CMUTrace/Send for tracing all packets th<strong>at</strong> are sent out in a router. <strong>The</strong> traceobjects may be used to trace packets in MAC, agents (routing or others), routers or any other NsObject.<strong>The</strong> cmu-trace object CMUTrace is derived from the base class Trace. See Chapter 26 for details on class Trace. <strong>The</strong>class CMUTrace is defined as the following:class CMUTrace : public Trace {public:CMUTrace(co<strong>ns</strong>t char *s, char t);void recv(Packet *p, H<strong>and</strong>ler *h);void recv(Packet *p, co<strong>ns</strong>t char* why);priv<strong>at</strong>e:int off_arp_;int off_mac_;int off_sr_;char tracename[MAX_ID_LEN + 1];int tracetype;MobileNode *node_;int initialized() { return node_ && 1; }};intvoidvoidvoidvoidvoidvoidvoidvoidcomm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);form<strong>at</strong>(Packet *p, co<strong>ns</strong>t char *why);form<strong>at</strong>_mac(Packet *p, co<strong>ns</strong>t char *why, int offset);form<strong>at</strong>_ip(Packet *p, int offset);form<strong>at</strong>_arp(Packet *p, int offset);form<strong>at</strong>_dsr(Packet *p, int offset);form<strong>at</strong>_msg(Packet *p, int offset);form<strong>at</strong>_tcp(Packet *p, int offset);form<strong>at</strong>_rtp(Packet *p, int offset);<strong>The</strong> type field (described in Trace class definition) is used to differenti<strong>at</strong>e among different types of traces. For cmu-tracethis can be s for sending, r for receiving or D for dropping a packet. A fourth type f is used to denote forwarding of a packet(When the node is not the origin<strong>at</strong>or of the packet). Similar to the method Trace::form<strong>at</strong>(), the CMUTrace::form<strong>at</strong>() defines<strong>and</strong> dict<strong>at</strong>es the trace file form<strong>at</strong>. <strong>The</strong> method is shown below:void CMUTrace::form<strong>at</strong>(Packet* p, co<strong>ns</strong>t char *why){hdr_cmn *ch = HDR_CMN(p);int offset = 0;/** Log the MAC Header*/form<strong>at</strong>_mac(p, why, offset);offset = strlen(wrk_);155

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

Saved successfully!

Ooh no, something went wrong!