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.

};bind("pdrops_", &pdrops_);bind("bdrops_", &bdrops_);bind("off_cmn_", &off_cmn_);int size() co<strong>ns</strong>t { return (size_); }int pkts() co<strong>ns</strong>t { return (pkts_); }int parrivals() co<strong>ns</strong>t { return (parrivals_); }int barrivals() co<strong>ns</strong>t { return (barrivals_); }int pdepartures() co<strong>ns</strong>t { return (pdepartures_); }int bdepartures() co<strong>ns</strong>t { return (bdepartures_); }int pdrops() co<strong>ns</strong>t { return (pdrops_); }int bdrops() co<strong>ns</strong>t { return (bdrops_); }void printSt<strong>at</strong>s();virtual void in(Packet*);virtual void out(Packet*);virtual void drop(Packet*);virtual void edrop(Packet*) { abort(); }; // not herevirtual int comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv);...// packet arrival to a queuevoid QueueMonitor::in(Packet* p){hdr_cmn* hdr = (hdr_cmn*)p->access(off_cmn_);double now = Scheduler::i<strong>ns</strong>tance().clock();int pktsz = hdr->size();}barrivals_ += pktsz;parrivals_++;size_ += pktsz;pkts_++;if (bytesInt_)bytesInt_->newPoint(now, double(size_));if (pktsInt_)pktsInt_->newPoint(now, double(pkts_));if (delaySamp_)hdr->timestamp() = now;if (channel_)printSt<strong>at</strong>s();... in(), out(), drop() are all defined similarly ...It addition to the packet <strong>and</strong> byte counters, a queue monitor may optionally refer to objects th<strong>at</strong> keep an integral of the queuesize over time using Integr<strong>at</strong>or objects, which are defined in Section 25.3. <strong>The</strong> Integr<strong>at</strong>or class provides a simpleimplement<strong>at</strong>ion of integral approxim<strong>at</strong>ion by discrete sums.All bound variables beginning with p refer to packet counts, <strong>and</strong> all variables beginning with b refer to byte counts. <strong>The</strong>variable size_ records the i<strong>ns</strong>tantaneous queue size in bytes, <strong>and</strong> the variable pkts_ records the same value in packets.When a QueueMonitor is configured to include the integral functio<strong>ns</strong> (on bytes or packets or both), it computes theapproxim<strong>at</strong>e integral of the queue size (in bytes) with respect to time over the interval [t 0 , now], where t 0 is either the start ofthe simul<strong>at</strong>ion or the last time the sum_ field of the underlying Integr<strong>at</strong>or class was reset.239

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

Saved successfully!

Ooh no, something went wrong!