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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

also used to accumul<strong>at</strong>e packet drop st<strong>at</strong>istics to an associ<strong>at</strong>ed QueueMonitor object. For init-monitor the sameQueueMonitor object is used in all cases. <strong>The</strong> C++ definitio<strong>ns</strong> of the SnoopQueue <strong>and</strong> QueueMonitor classes aredescribed below.26.3 <strong>The</strong> C++ Trace ClassUnderlying C++ objects are cre<strong>at</strong>ed in support of the interface specified in Section 26.3 <strong>and</strong> are linked into the network topologyas network elements. <strong>The</strong> single C++ Trace class is used to implement the OTcl classes Trace/Hop, Trace/Enque,Trace/Deque, <strong>and</strong> Trace/Drop. <strong>The</strong> type_ field is used to differenti<strong>at</strong>e among the various types of traces any particularTrace object might implement. Currently, this field may contain one of the following symbolic characters: + for enque,- for deque, h for hop, <strong>and</strong> d for drop. <strong>The</strong> overall class is defined as follows in ~<strong>ns</strong>/trace.cc:class Trace : public Connector {protected:int type_;<strong>ns</strong>addr_t src_;<strong>ns</strong>addr_t dst_;Tcl_Channel channel_;int callback_;char wrk_[256];void form<strong>at</strong>(int tt, int s, int d, Packet* p);void annot<strong>at</strong>e(co<strong>ns</strong>t char* s);int show_tcphdr_; // bool flags; backward comp<strong>at</strong>public:Trace(int type);~Trace();int comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);void recv(Packet* p, H<strong>and</strong>ler*);void dump();inline char* buffer() { return (wrk_); }};<strong>The</strong> src_, <strong>and</strong> dst_ internal st<strong>at</strong>e is used to label trace output <strong>and</strong> is independent of the corresponding field names in packetheaders. <strong>The</strong> main recv() method is defined as follows:void Trace::recv(Packet* p, H<strong>and</strong>ler* h){form<strong>at</strong>(type_, src_, dst_, p);dump();/* hack: if trace object not <strong>at</strong>tached to anything free packet */if (target_ == 0)Packet::free(p);elsesend(p, h); /* Connector::send() */}<strong>The</strong> function merely form<strong>at</strong>s a trace entry using the source, destin<strong>at</strong>ion, <strong>and</strong> particular trace type character. <strong>The</strong> dump functionwrites the form<strong>at</strong>ted entry out to the I/O h<strong>and</strong>le associ<strong>at</strong>ed with channel_. <strong>The</strong> form<strong>at</strong> function, in effect, dict<strong>at</strong>es thetrace file form<strong>at</strong>.234

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

Saved successfully!

Ooh no, something went wrong!