#include <queue-monitor.h>
Inheritance diagram for QueueMonitor:


Public Member Functions | |
| QueueMonitor () | |
| int | size () const |
| int | pkts () const |
| int | parrivals () const |
| int | barrivals () const |
| int | pdepartures () const |
| int | bdepartures () const |
| int | pdrops () const |
| int | pmarks () const |
| int | bdrops () const |
| void | printRTTs () |
| void | printSeqnos () |
| void | printStats () |
| virtual void | in (Packet *) |
| virtual void | out (Packet *) |
| virtual void | drop (Packet *) |
| virtual void | edrop (Packet *) |
| virtual int | command (int argc, const char *const *argv) |
Public Attributes | |
| int | estimate_rate_ |
| double | k_ |
| double | estRate_ |
| double | prevTime_ |
| double | startTime_ |
Protected Member Functions | |
| void | estimateRate (Packet *p) |
| void | keepRTTstats (Packet *p) |
| void | keepSeqnoStats (Packet *p) |
Protected Attributes | |
| Integrator * | bytesInt_ |
| Integrator * | pktsInt_ |
| Samples * | delaySamp_ |
| int | size_ |
| int | pkts_ |
| int | parrivals_ |
| int | barrivals_ |
| int | pdepartures_ |
| int | bdepartures_ |
| int | pdrops_ |
| int | pmarks_ |
| int | bdrops_ |
| int | keepRTTstats_ |
| int | maxRTT_ |
| int | numRTTs_ |
| int | binsPerSec_ |
| int * | RTTbins_ |
| int | keepSeqnoStats_ |
| int | maxSeqno_ |
| int | numSeqnos_ |
| int | SeqnoBinSize_ |
| int * | SeqnoBins_ |
| int | srcId_ |
| int | dstId_ |
| Tcl_Channel | channel_ |
| Tcl_Channel | channel1_ |
| int | temp_size_ |
|
|
Definition at line 48 of file queue-monitor.h. References barrivals_, bdepartures_, bdrops_, binsPerSec_, bytesInt_, channel1_, channel_, Scheduler::clock(), delaySamp_, dstId_, estimate_rate_, estRate_, Scheduler::instance(), k_, keepRTTstats_, keepSeqnoStats_, maxRTT_, maxSeqno_, numRTTs_, numSeqnos_, parrivals_, pdepartures_, pdrops_, pkts_, pktsInt_, pmarks_, prevTime_, SeqnoBinSize_, size_, srcId_, startTime_, and temp_size_.
00048 : bytesInt_(NULL), pktsInt_(NULL), delaySamp_(NULL), 00049 size_(0), pkts_(0), 00050 parrivals_(0), barrivals_(0), 00051 pdepartures_(0), bdepartures_(0), 00052 pdrops_(0), pmarks_(0), bdrops_(0), 00053 keepRTTstats_(0), maxRTT_(1), numRTTs_(0), binsPerSec_(10), 00054 keepSeqnoStats_(0), maxSeqno_(1000), 00055 numSeqnos_(0), SeqnoBinSize_(1), 00056 k_(0.1), 00057 srcId_(0), dstId_(0), channel_(0), channel1_(0), 00058 estimate_rate_(0), estRate_(0.0), 00059 temp_size_(0) { 00060 00061 bind("size_", &size_); 00062 bind("pkts_", &pkts_); 00063 bind("parrivals_", &parrivals_); 00064 bind("barrivals_", &barrivals_); 00065 bind("pdepartures_", &pdepartures_); 00066 bind("bdepartures_", &bdepartures_); 00067 bind("pdrops_", &pdrops_); 00068 bind("pmarks_", &pmarks_); 00069 bind("bdrops_", &bdrops_); 00070 00071 //for keeping RTT statistics 00072 bind_bool("keepRTTstats_", &keepRTTstats_); 00073 bind("maxRTT_", &maxRTT_); 00074 bind("binsPerSec_", &binsPerSec_); 00075 00076 //for keeping sequence number statistics 00077 bind_bool("keepSeqnoStats_", &keepSeqnoStats_); 00078 bind("maxSeqno_", &maxSeqno_); 00079 bind("SeqnoBinSize_", &SeqnoBinSize_); 00080 00081 //variable binding for flow rate estimation 00082 bind_bool("estimate_rate_", &estimate_rate_); 00083 bind("k_", &k_); 00084 bind("prevTime_", &prevTime_); 00085 bind("startTime_", &startTime_); 00086 bind("estRate_", &estRate_); 00087 00088 startTime_ = Scheduler::instance().clock(); 00089 prevTime_ = startTime_; 00090 }; |
Here is the call graph for this function:

|
|
Definition at line 101 of file queue-monitor.h. References barrivals_. Referenced by FlowMon::fformat(), Tagger::fformat(), and PushbackQueue::timeout().
00101 { return (barrivals_); }
|
|
|
Definition at line 103 of file queue-monitor.h. References bdepartures_. Referenced by PushbackQueue::timeout().
00103 { return (bdepartures_); }
|
|
|
Definition at line 107 of file queue-monitor.h. References bdrops_. Referenced by FlowMon::fformat(), Tagger::fformat(), and PushbackQueue::timeout().
00107 { return (bdrops_); }
|
|
||||||||||||
|
Reimplemented in Tagger, FlowMon, and QueueMonitorCompat. Definition at line 44 of file queue-monitor.cc. References bytesInt_, channel1_, channel_, delaySamp_, dstId_, keepRTTstats_, keepSeqnoStats_, pktsInt_, printRTTs(), printSeqnos(), and srcId_. Referenced by QueueMonitorCompat::command(), FlowMon::command(), and Tagger::command().
00045 {
00046 Tcl& tcl = Tcl::instance();
00047
00048 if (argc == 2) {
00049 if (strcmp(argv[1], "get-bytes-integrator") == 0) {
00050 if (bytesInt_)
00051 tcl.resultf("%s", bytesInt_->name());
00052 else
00053 tcl.resultf("");
00054 return (TCL_OK);
00055 }
00056 if (strcmp(argv[1], "get-pkts-integrator") == 0) {
00057 if (pktsInt_)
00058 tcl.resultf("%s", pktsInt_->name());
00059 else
00060 tcl.resultf("");
00061 return (TCL_OK);
00062 }
00063 if (strcmp(argv[1], "get-delay-samples") == 0) {
00064 if (delaySamp_)
00065 tcl.resultf("%s", delaySamp_->name());
00066 else
00067 tcl.resultf("");
00068 return (TCL_OK);
00069 }
00070 if (strcmp(argv[1], "printRTTs") == 0) {
00071 if (keepRTTstats_ && channel1_) {
00072 printRTTs();
00073 }
00074 return (TCL_OK);
00075 }
00076 if (strcmp(argv[1], "printSeqnos") == 0) {
00077 if (keepSeqnoStats_ && channel1_) {
00078 printSeqnos();
00079 }
00080 return (TCL_OK);
00081 }
00082 }
00083
00084 if (argc == 3) {
00085 if (strcmp(argv[1], "set-bytes-integrator") == 0) {
00086 bytesInt_ = (Integrator *)
00087 TclObject::lookup(argv[2]);
00088 if (bytesInt_ == NULL)
00089 return (TCL_ERROR);
00090 return (TCL_OK);
00091 }
00092 if (strcmp(argv[1], "set-pkts-integrator") == 0) {
00093 pktsInt_ = (Integrator *)
00094 TclObject::lookup(argv[2]);
00095 if (pktsInt_ == NULL)
00096 return (TCL_ERROR);
00097 return (TCL_OK);
00098 }
00099 if (strcmp(argv[1], "set-delay-samples") == 0) {
00100 delaySamp_ = (Samples*)
00101 TclObject::lookup(argv[2]);
00102 if (delaySamp_ == NULL)
00103 return (TCL_ERROR);
00104 return (TCL_OK);
00105 }
00106 if (strcmp(argv[1], "trace") == 0) {
00107 // for printStats
00108 int mode;
00109 const char* id = argv[2];
00110 channel_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode);
00111 if (channel_ == 0) {
00112 tcl.resultf("trace: can't attach %s for writing", id);
00113 return (TCL_ERROR);
00114 }
00115 return (TCL_OK);
00116 }
00117 if (strcmp(argv[1], "traceDist") == 0) {
00118 // for printRTTs and printSeqnos distributions
00119 int mode;
00120 const char* id = argv[2];
00121 channel1_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode);
00122 if (channel1_ == 0) {
00123 tcl.resultf("trace: can't attach %s for writing", id);
00124 return (TCL_ERROR);
00125 }
00126 return (TCL_OK);
00127 }
00128 }
00129 if (argc == 4) {
00130 if (strcmp(argv[1], "set-src-dst") == 0) {
00131 srcId_ = atoi(argv[2]);
00132 dstId_ = atoi(argv[3]);
00133 return (TCL_OK);
00134 }
00135 }
00136 return TclObject::command(argc, argv); // else control reaches end of
00137 // non-void function, see? :-)
00138 }
|
Here is the call graph for this function:

|
|
Reimplemented in FlowMon, and QueueMonitorCompat. Definition at line 282 of file queue-monitor.cc. References hdr_cmn::access(), bdrops_, bytesInt_, channel_, Scheduler::clock(), Scheduler::instance(), Integrator::newPoint(), pdrops_, pkts_, pktsInt_, printStats(), hdr_cmn::size(), and size_. Referenced by QueueMonitorCompat::drop(), FlowMon::drop(), EDQueueMonitor::edrop(), EDQueueMonitor::mon_edrop(), and SnoopQueueDrop::recv().
00283 {
00284 hdr_cmn* hdr = hdr_cmn::access(p);
00285 double now = Scheduler::instance().clock();
00286 int pktsz = hdr->size();
00287
00288 size_ -= pktsz;
00289 pkts_--;
00290 bdrops_ += pktsz;
00291 pdrops_++;
00292 if (bytesInt_)
00293 bytesInt_->newPoint(now, double(size_));
00294 if (pktsInt_)
00295 pktsInt_->newPoint(now, double(pkts_));
00296 if (channel_)
00297 printStats();
00298 }
|
Here is the call graph for this function:

|
|
Reimplemented in FlowMon, and EDQueueMonitor. Definition at line 114 of file queue-monitor.h. References abort(). Referenced by SnoopQueueEDrop::recv().
00114 { abort(); }; // not here
|
Here is the call graph for this function:

|
|
Definition at line 301 of file queue-monitor.cc. References hdr_cmn::access(), Scheduler::clock(), estRate_, Scheduler::instance(), k_, prevTime_, hdr_cmn::size(), and temp_size_. Referenced by in().
00301 {
00302
00303 hdr_cmn* hdr = hdr_cmn::access(pkt);
00304 int pktSize = hdr->size() << 3; /* length of the packet in bits */
00305
00306 double now = Scheduler::instance().clock();
00307 double timeGap = ( now - prevTime_);
00308
00309 if (timeGap == 0) {
00310 temp_size_ += pktSize;
00311 return;
00312 }
00313 else {
00314 pktSize+= temp_size_;
00315 temp_size_ = 0;
00316 }
00317
00318 prevTime_ = now;
00319
00320 estRate_ = (1 - exp(-timeGap/k_))*((double)pktSize)/timeGap + exp(-timeGap/k_)*estRate_;
00321 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Definition at line 324 of file queue-monitor.cc. References hdr_tcp::access(), hdr_cmn::access(), binsPerSec_, hdr_tcp::last_rtt(), maxRTT_, numRTTs_, packet_t, PT_FTP, PT_HTTP, PT_TCP, PT_TELNET, hdr_cmn::ptype(), and RTTbins_. Referenced by out().
00324 {
00325 int i, j, topBin, rttInMs, MsPerBin;
00326 hdr_cmn* hdr = hdr_cmn::access(pkt);
00327 packet_t t = hdr->ptype();
00328 if (t == PT_TCP || t == PT_HTTP || t == PT_FTP || t == PT_TELNET) {
00329 hdr_tcp *tcph = hdr_tcp::access(pkt);
00330 rttInMs = tcph->last_rtt();
00331 if (rttInMs < 0) rttInMs = 0;
00332 topBin = maxRTT_ * binsPerSec_;
00333 if (numRTTs_ == 0) {
00334 RTTbins_ = (int *)malloc(sizeof(int)*topBin);
00335 for (i = 0; i < topBin; i++) {
00336 RTTbins_[i] = 0;
00337 }
00338 }
00339 MsPerBin = int(1000/binsPerSec_);
00340 j = (int)(rttInMs/MsPerBin);
00341 if (j < 0) j = 0;
00342 if (j >= topBin) j = topBin - 1;
00343 ++ RTTbins_[j];
00344 ++ numRTTs_;
00345 }
00346 }
|
Here is the call graph for this function:

|
|
Definition at line 349 of file queue-monitor.cc. References hdr_tcp::access(), hdr_cmn::access(), maxSeqno_, numSeqnos_, packet_t, PT_FTP, PT_HTTP, PT_TCP, PT_TELNET, hdr_cmn::ptype(), hdr_tcp::seqno(), SeqnoBins_, and SeqnoBinSize_. Referenced by out().
00349 {
00350 int i, j, topBin, seqno;
00351 hdr_cmn* hdr = hdr_cmn::access(pkt);
00352 packet_t t = hdr->ptype();
00353 if (t == PT_TCP || t == PT_HTTP || t == PT_FTP || t == PT_TELNET) {
00354 hdr_tcp *tcph = hdr_tcp::access(pkt);
00355 seqno = tcph->seqno();
00356 if (seqno < 0) seqno = 0;
00357 topBin = int(maxSeqno_ / SeqnoBinSize_);
00358 if (numSeqnos_ == 0) {
00359 SeqnoBins_ = (int *)malloc(sizeof(int)*topBin);
00360 for (i = 0; i < topBin; i++) {
00361 SeqnoBins_[i] = 0;
00362 }
00363 }
00364 j = (int)(seqno/SeqnoBinSize_);
00365 if (j < 0) j = 0;
00366 if (j >= topBin) j = topBin - 1;
00367 ++ SeqnoBins_[j];
00368 ++ numSeqnos_;
00369 }
00370 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Definition at line 100 of file queue-monitor.h. References parrivals_. Referenced by FlowMon::fformat(), and Tagger::fformat().
00100 { return (parrivals_); }
|
|
|
Definition at line 102 of file queue-monitor.h. References pdepartures_.
00102 { return (pdepartures_); }
|
|
|
Definition at line 105 of file queue-monitor.h. References pdrops_. Referenced by FlowMon::fformat(), and Tagger::fformat().
00105 { return (pdrops_); }
|
|
|
Definition at line 93 of file queue-monitor.h. References pkts_. Referenced by CBQClass::demand(), and CBQueue::toplevel_departure().
00093 { return (pkts_); }
|
|
|
Definition at line 106 of file queue-monitor.h. References pmarks_. Referenced by Tagger::fformat().
00106 { return (pmarks_); }
|
|
|
Definition at line 150 of file queue-monitor.cc. References binsPerSec_, channel1_, Scheduler::clock(), Scheduler::instance(), maxRTT_, numRTTs_, and RTTbins_. Referenced by command().
00150 {
00151 int i, n, topBin, MsPerBin;
00152 char wrk[500];
00153
00154 topBin = maxRTT_ * binsPerSec_;
00155 MsPerBin = int(1000/binsPerSec_);
00156 double now = Scheduler::instance().clock();
00157 sprintf(wrk, "Distribution of RTTs, %d ms bins, time %4.2f\n", MsPerBin, now);
00158 n = strlen(wrk); wrk[n] = 0;
00159 (void)Tcl_Write(channel1_, wrk, n);
00160 for (i = 0; i < topBin; i++) {
00161 if (RTTbins_[i] > 0) {
00162 sprintf(wrk, "%d to %d ms: frac %5.3f num %d time %4.2f\n",
00163 i*MsPerBin, (i+1)*MsPerBin,
00164 (double)RTTbins_[i]/numRTTs_,
00165 RTTbins_[i], now);
00166 n = strlen(wrk); wrk[n] = 0;
00167 (void)Tcl_Write(channel1_, wrk, n);
00168 }
00169 }
00170 i = topBin - 1;
00171 if (RTTbins_[i] > 0) {
00172 sprintf(wrk, "The last bin might also contain RTTs >= %d ms.\n",
00173 (i+1)*MsPerBin);
00174 n = strlen(wrk); wrk[n] = 0;
00175 (void)Tcl_Write(channel1_, wrk, n);
00176 }
00177 }
|
Here is the call graph for this function:

|
|
Definition at line 180 of file queue-monitor.cc. References channel1_, Scheduler::clock(), Scheduler::instance(), maxSeqno_, numSeqnos_, SeqnoBins_, and SeqnoBinSize_. Referenced by command().
00180 {
00181 int i, n, topBin;
00182 char wrk[500];
00183
00184 topBin = int(maxSeqno_ / SeqnoBinSize_);
00185 double now = Scheduler::instance().clock();
00186 sprintf(wrk, "Distribution of Seqnos, %d seqnos per bin, time %4.2f\n",
00187 SeqnoBinSize_, now);
00188 n = strlen(wrk); wrk[n] = 0;
00189 (void)Tcl_Write(channel1_, wrk, n);
00190 for (i = 0; i < topBin; i++) {
00191 if (SeqnoBins_[i] > 0) {
00192 sprintf(wrk, "%d to %d seqnos: frac %5.3f num %d time %4.2f\n",
00193 i*SeqnoBinSize_, (i+1)*SeqnoBinSize_ - 1,
00194 (double)SeqnoBins_[i]/numSeqnos_,
00195 SeqnoBins_[i], now);
00196 n = strlen(wrk); wrk[n] = 0;
00197 (void)Tcl_Write(channel1_, wrk, n);
00198 }
00199 }
00200 i = topBin - 1;
00201 if (SeqnoBins_[i] > 0) {
00202 sprintf(wrk, "The last bin might also contain Seqnos >= %d. \n",
00203 (i+1)*SeqnoBinSize_);
00204 n = strlen(wrk); wrk[n] = 0;
00205 (void)Tcl_Write(channel1_, wrk, n);
00206 }
00207 }
|
Here is the call graph for this function:

|
|
Definition at line 210 of file queue-monitor.cc. References channel_, Scheduler::clock(), dstId_, Scheduler::instance(), pkts_, size_, srcId_, and TIME_FORMAT. Referenced by drop(), in(), and out().
00210 {
00211 char wrk[500];
00212 int n;
00213 double now = Scheduler::instance().clock();
00214 sprintf(wrk, "q -t "TIME_FORMAT" -s %d -d %d -l %d -p %d", now, srcId_, dstId_, size_, pkts_);
00215 n = strlen(wrk);
00216 wrk[n] = '\n';
00217 wrk[n+1] = 0;
00218 (void)Tcl_Write(channel_, wrk, n+1);
00219 wrk[n] = 0;
00220 }
|
Here is the call graph for this function:

|
|
Definition at line 92 of file queue-monitor.h. References size_.
00092 { return (size_); }
|
|
|
Definition at line 130 of file queue-monitor.h. Referenced by barrivals(), in(), and QueueMonitor(). |
|
|
Definition at line 132 of file queue-monitor.h. Referenced by bdepartures(), out(), and QueueMonitor(). |
|
|
Definition at line 136 of file queue-monitor.h. Referenced by bdrops(), drop(), and QueueMonitor(). |
|
|
Definition at line 141 of file queue-monitor.h. Referenced by keepRTTstats(), printRTTs(), and QueueMonitor(). |
|
|
Definition at line 117 of file queue-monitor.h. Referenced by command(), drop(), in(), out(), and QueueMonitor(). |
|
|
Definition at line 153 of file queue-monitor.h. Referenced by command(), printRTTs(), printSeqnos(), and QueueMonitor(). |
|
|
Reimplemented in Tagger, and FlowMon. Definition at line 152 of file queue-monitor.h. Referenced by command(), drop(), in(), out(), printStats(), and QueueMonitor(). |
|
|
Definition at line 119 of file queue-monitor.h. Referenced by command(), in(), out(), and QueueMonitor(). |
|
|
Definition at line 151 of file queue-monitor.h. Referenced by command(), printStats(), and QueueMonitor(). |
|
|
Definition at line 160 of file queue-monitor.h. Referenced by RedPDQueue::command(), in(), and QueueMonitor(). |
|
|
Definition at line 162 of file queue-monitor.h. Referenced by RedPDQueue::command(), RedPDQueue::enque(), estimateRate(), and QueueMonitor(). |
|
|
Definition at line 161 of file queue-monitor.h. Referenced by estimateRate(), and QueueMonitor(). |
|
|
Definition at line 138 of file queue-monitor.h. Referenced by command(), out(), and QueueMonitor(). |
|
|
Definition at line 144 of file queue-monitor.h. Referenced by command(), out(), and QueueMonitor(). |
|
|
Definition at line 139 of file queue-monitor.h. Referenced by keepRTTstats(), printRTTs(), and QueueMonitor(). |
|
|
Definition at line 145 of file queue-monitor.h. Referenced by keepSeqnoStats(), printSeqnos(), and QueueMonitor(). |
|
|
Definition at line 140 of file queue-monitor.h. Referenced by keepRTTstats(), printRTTs(), and QueueMonitor(). |
|
|
Definition at line 146 of file queue-monitor.h. Referenced by keepSeqnoStats(), printSeqnos(), and QueueMonitor(). |
|
|
Definition at line 129 of file queue-monitor.h. Referenced by in(), parrivals(), and QueueMonitor(). |
|
|
Definition at line 131 of file queue-monitor.h. Referenced by out(), pdepartures(), and QueueMonitor(). |
|
|
Definition at line 134 of file queue-monitor.h. Referenced by drop(), pdrops(), and QueueMonitor(). |
|
|
Reimplemented in QueueMonitorCompat. Definition at line 121 of file queue-monitor.h. Referenced by drop(), in(), out(), pkts(), printStats(), and QueueMonitor(). |
|
|
Definition at line 118 of file queue-monitor.h. Referenced by command(), drop(), in(), out(), and QueueMonitor(). |
|
|
Definition at line 135 of file queue-monitor.h. Referenced by out(), pmarks(), and QueueMonitor(). |
|
|
Definition at line 163 of file queue-monitor.h. Referenced by estimateRate(), in(), and QueueMonitor(). |
|
|
Definition at line 142 of file queue-monitor.h. Referenced by keepRTTstats(), and printRTTs(). |
|
|
Definition at line 148 of file queue-monitor.h. Referenced by keepSeqnoStats(), and printSeqnos(). |
|
|
Definition at line 147 of file queue-monitor.h. Referenced by keepSeqnoStats(), printSeqnos(), and QueueMonitor(). |
|
|
Definition at line 120 of file queue-monitor.h. Referenced by drop(), in(), out(), printStats(), QueueMonitor(), and size(). |
|
|
Definition at line 150 of file queue-monitor.h. Referenced by command(), printStats(), and QueueMonitor(). |
|
|
Definition at line 164 of file queue-monitor.h. Referenced by QueueMonitor(). |
|
|
Definition at line 167 of file queue-monitor.h. Referenced by estimateRate(), and QueueMonitor(). |
1.3.3