#include <errmodel.h>
Inheritance diagram for ListErrorModel:


Public Member Functions | |
| ListErrorModel () | |
| ~ListErrorModel () | |
| virtual int | corrupt (Packet *) |
| int | command (int argc, const char *const *argv) |
| virtual void | recv (Packet *, Handler *) |
| virtual void | recv (Packet *p, const char *s) |
| virtual void | reset () |
| double | rate () |
| ErrorUnit | unit () |
| NsObject * | target () |
| virtual void | drop (Packet *p) |
| virtual void | recvOnly (Packet *) |
| virtual void | delay_bind_init_all () |
| virtual int | delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer) |
| int | isdebug () const |
| virtual void | debug (const char *fmt,...) |
Protected Member Functions | |
| int | parse_droplist (int argc, const char *const *) |
| int | CorruptPkt (Packet *) |
| int | CorruptTime (Packet *) |
| int | CorruptByte (Packet *) |
| int | CorruptBit (Packet *) |
| double | PktLength (Packet *) |
| double * | ComputeBitErrProb (int) |
| virtual void | drop (Packet *p, const char *s) |
| void | send (Packet *p, Handler *h) |
| void | handle (Event *) |
Static Protected Member Functions | |
| int | nextval (const char *&p) |
| int | intcomp (const void *, const void *) |
Protected Attributes | |
| int | cnt_ |
| int * | droplist_ |
| int | dropcnt_ |
| int | cur_ |
| int | enable_ |
| int | markecn_ |
| int | delay_pkt_ |
| int | firstTime_ |
| ErrorUnit | unit_ |
| double | rate_ |
| double | delay_ |
| double | bandwidth_ |
| RandomVariable * | ranvar_ |
| int | FECstrength_ |
| int | datapktsize_ |
| int | cntrlpktsize_ |
| double * | cntrlprb_ |
| double * | dataprb_ |
| Event | intr_ |
| NsObject * | target_ |
| NsObject * | drop_ |
| int | debug_ |
|
|
Definition at line 163 of file errmodel.h. References cnt_, cur_, dropcnt_, and droplist_.
|
|
|
Definition at line 165 of file errmodel.h. References droplist_.
|
|
||||||||||||
|
Reimplemented from ErrorModel. Definition at line 596 of file errmodel.cc. References ErrorModel::command(), and parse_droplist().
00597 {
00598 /*
00599 * works for variable args:
00600 * $lem droplist "1 3 4 5"
00601 * and
00602 * $lem droplist 1 3 4 5
00603 */
00604 Tcl& tcl = Tcl::instance();
00605 if (strcmp(argv[1], "droplist") == 0) {
00606 int cnt;
00607 if ((cnt = parse_droplist(argc-2, argv + 2)) < 0)
00608 return (TCL_ERROR);
00609 tcl.resultf("%u", cnt);
00610 return(TCL_OK);
00611 }
00612 return (ErrorModel::command(argc, argv));
00613 }
|
Here is the call graph for this function:

|
|
Definition at line 231 of file errmodel.cc. References comb(), ErrorModel::FECstrength_, pow(), and ErrorModel::rate_. Referenced by ErrorModel::CorruptBit().
00232 {
00233 double *dptr;
00234 int i;
00235
00236 dptr = (double *)calloc((FECstrength_ + 2), sizeof(double));
00237
00238 for (i = 0; i < (FECstrength_ + 1) ; i++)
00239 dptr[i] = comb(size, i) * pow(rate_, (double)i) * pow(1.0 - rate_, (double)(size - i));
00240
00241 // Cumulative probability
00242 for (i = 0; i < FECstrength_ ; i++)
00243 dptr[i + 1] += dptr[i];
00244
00245 dptr[FECstrength_ + 1] = 1.0;
00246
00247 /* printf("Size = %d\n", size);
00248 for (i = 0; i <(FECstrength_ + 2); i++)
00249 printf("Ptr[%d] = %g\n", i, dptr[i]); */
00250
00251 return dptr;
00252
00253 }
|
Here is the call graph for this function:

|
|
Reimplemented from ErrorModel. Definition at line 558 of file errmodel.cc. References hdr_cmn::access(), cnt_, cur_, dropcnt_, droplist_, EU_BYTE, EU_PKT, EU_TIME, hdr_cmn::size(), and ErrorModel::unit_.
00559 {
00560 /* assumes droplist_ is sorted */
00561 int rval = 0; // no drop
00562
00563 if (unit_ == EU_TIME) {
00564 fprintf(stderr,
00565 "ListErrorModel: error, EU_TIME not supported\n");
00566 return 0;
00567 }
00568
00569 if (droplist_ == NULL || dropcnt_ == 0) {
00570 fprintf(stderr, "warning: ListErrorModel: null drop list\n");
00571 return 0;
00572 }
00573
00574 if (unit_ == EU_PKT) {
00575 //printf("TEST: cur_:%d, dropcnt_:%d, droplist_[cur_]:%d, cnt_:%d\n",
00576 //cur_, dropcnt_, droplist_[cur_], cnt_);
00577 if ((cur_ < dropcnt_) && droplist_[cur_] == cnt_) {
00578 rval = 1;
00579 cur_++;
00580 }
00581 cnt_++;
00582
00583 } else if (unit_ == EU_BYTE) {
00584 int sz = hdr_cmn::access(p)->size();
00585 if ((cur_ < dropcnt_) && (cnt_ + sz) >= droplist_[cur_]) {
00586 rval = 1;
00587 cur_++;
00588 }
00589 cnt_ += sz;
00590 }
00591
00592 return (rval);
00593 }
|
Here is the call graph for this function:

|
|
Definition at line 270 of file errmodel.cc. References hdr_cmn::access(), ErrorModel::cntrlpktsize_, ErrorModel::cntrlprb_, ErrorModel::ComputeBitErrProb(), ErrorModel::datapktsize_, ErrorModel::dataprb_, ErrorModel::FECstrength_, ErrorModel::firstTime_, ErrorModel::ranvar_, hdr_cmn::size(), Random::uniform(), and RandomVariable::value(). Referenced by ErrorModel::corrupt().
00271 {
00272 double u, *dptr;
00273 int i;
00274
00275 if (firstTime_ && FECstrength_) {
00276 // precompute the probabilies for each bit-error cnts
00277 cntrlprb_ = ComputeBitErrProb(cntrlpktsize_);
00278 dataprb_ = ComputeBitErrProb(datapktsize_);
00279
00280 firstTime_ = 0;
00281 }
00282
00283 u = ranvar_ ? ranvar_->value() : Random::uniform();
00284 dptr = (hdr_cmn::access(p)->size() >= datapktsize_) ? dataprb_ : cntrlprb_;
00285 for (i = 0; i < (FECstrength_ + 2); i++)
00286 if (dptr[i] > u) break;
00287 return(i);
00288 }
|
Here is the call graph for this function:

|
|
Definition at line 262 of file errmodel.cc. References ErrorModel::PktLength(), pow(), ErrorModel::ranvar_, ErrorModel::rate_, Random::uniform(), and RandomVariable::value(). Referenced by ErrorModel::corrupt().
|
Here is the call graph for this function:

|
|
Definition at line 255 of file errmodel.cc. References ErrorModel::ranvar_, ErrorModel::rate_, Random::uniform(), and RandomVariable::value(). Referenced by ErrorModel::corrupt().
|
Here is the call graph for this function:

|
|
Definition at line 290 of file errmodel.cc. Referenced by ErrorModel::corrupt().
00291 {
00292 fprintf(stderr, "Warning: uniform rate error cannot be time-based\n");
00293 return 0;
00294 }
|
|
||||||||||||
|
Definition at line 102 of file object.cc. References NsObject::debug_.
00103 {
00104 if (!debug_)
00105 return;
00106 va_list ap;
00107 va_start(ap, fmt);
00108 vprintf(fmt, ap);
00109 }
|
|
||||||||||||||||
|
Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent. Definition at line 63 of file object.cc. References NsObject::debug_. Referenced by MPLSAddressClassifier::delay_bind_dispatch(), and Agent::delay_bind_dispatch().
00064 {
00065 if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer))
00066 return TCL_OK;
00067 return TclObject::delay_bind_dispatch(varName, localName, tracer);
00068 }
|
|
|
Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent. Definition at line 57 of file object.cc. Referenced by MPLSAddressClassifier::delay_bind_init_all(), and Agent::delay_bind_init_all().
00058 {
00059 delay_bind_init_one("debug_");
00060 }
|
|
||||||||||||
|
Definition at line 114 of file connector.cc. References Connector::drop_, Packet::free(), and NsObject::recv().
00115 {
00116 if (drop_ != 0)
00117 drop_->recv(p, s);
00118 else
00119 Packet::free(p);
00120 }
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
|
Implements Handler. Reimplemented in LinkDelay, LL, AckRecons, and Snoop. Definition at line 91 of file object.cc. References NsObject::recv().
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 616 of file errmodel.cc. Referenced by parse_droplist().
|
|
|
Definition at line 61 of file object.h. References NsObject::debug_.
00061 { return debug_; }
|
|
|
Definition at line 631 of file errmodel.cc. Referenced by parse_droplist().
00632 {
00633 while (*p && isspace(*p))
00634 ++p;
00635
00636 if (!*p) {
00637 /* end of string */
00638 return (0);
00639 }
00640 const char *q = p;
00641 while (*q && !isspace(*q))
00642 ++q;
00643 return (q-p);
00644 }
|
|
||||||||||||
|
Definition at line 647 of file errmodel.cc. References dropcnt_, droplist_, intcomp(), and nextval(). Referenced by command().
00648 {
00649
00650 int cnt = 0; // counter for argc list
00651 int spaces = 0; // counts # of spaces in an argv entry
00652 int total = 0; // total entries in the drop list
00653 int n; // # of chars in the next drop number
00654 const char *p; // ptr into current string
00655
00656 /*
00657 * loop over argc list: figure out how many numbers
00658 * have been specified
00659 */
00660 while (cnt < argc) {
00661 p = argv[cnt];
00662 spaces = 0;
00663 while ((n = nextval(p))) {
00664 if (!isdigit(*p)) {
00665 /* problem... */
00666 fprintf(stderr, "ListErrorModel(%s): parse_droplist: unknown drop specifier starting at >>>%s\n",
00667 name(), p);
00668 return (-1);
00669 }
00670 ++spaces;
00671 p += n;
00672 }
00673 total += spaces;
00674 cnt++;
00675 }
00676
00677 /*
00678 * parse the numbers, put them in an array (droplist_)
00679 * set dropcnt_ to the total # of drops. Also, free any
00680 * previous drop list.
00681 */
00682
00683 if ((total == 0) || (dropcnt_ > 0 && droplist_ != NULL)) {
00684 delete[] droplist_;
00685 droplist_ = NULL;
00686 }
00687
00688 if ((dropcnt_ = total) == 0)
00689 return (0);
00690
00691 droplist_ = new int[dropcnt_];
00692 if (droplist_ == NULL) {
00693 fprintf(stderr,
00694 "ListErrorModel(%s): no memory for drop list!\n",
00695 name());
00696 return (-1);
00697 }
00698
00699 int idx = 0;
00700 cnt = 0;
00701 while (cnt < argc) {
00702 p = argv[cnt];
00703 while ((n = nextval(p))) {
00704 /*
00705 * this depends on atoi(s) returning the
00706 * value of the first number in s
00707 */
00708 droplist_[idx++] = atoi(p);
00709 p += n;
00710 }
00711 cnt++;
00712 }
00713 qsort(droplist_, dropcnt_, sizeof(int), intcomp);
00714
00715 /*
00716 * sanity check the array, looking for (wrong) dups
00717 */
00718 cnt = 0;
00719 while (cnt < (dropcnt_ - 1)) {
00720 if (droplist_[cnt] == droplist_[cnt+1]) {
00721 fprintf(stderr,
00722 "ListErrorModel: error: dup %d in list\n",
00723 droplist_[cnt]);
00724 total = -1; /* error */
00725 }
00726 ++cnt;
00727 }
00728
00729 if (total < 0) {
00730 if (droplist_)
00731 delete[] droplist_;
00732 dropcnt_ = 0;
00733 droplist_ = NULL;
00734 return (-1);
00735 }
00736
00737 #ifdef notdef
00738 printf("sorted list:\n");
00739 {
00740 register i;
00741 for (i =0; i < dropcnt_; i++) {
00742 printf("list[%d] = %d\n", i, droplist_[i]);
00743 }
00744 }
00745 #endif
00746 return dropcnt_;
00747 }
|
Here is the call graph for this function:

|
|
Definition at line 218 of file errmodel.cc. References hdr_cmn::access(), ErrorModel::bandwidth_, EU_BIT, EU_BYTE, EU_PKT, hdr_cmn::size(), and ErrorModel::unit_. Referenced by TwoStateErrorModel::corrupt(), and ErrorModel::CorruptByte().
00219 {
00220 //double now;
00221 if (unit_ == EU_PKT)
00222 return 1;
00223 int byte = hdr_cmn::access(p)->size();
00224 if (unit_ == EU_BYTE)
00225 return byte;
00226 if (unit_ == EU_BIT)
00227 return 8.0 * byte;
00228 return 8.0 * byte / bandwidth_;
00229 }
|
Here is the call graph for this function:

|
|
Definition at line 70 of file errmodel.h. References ErrorModel::rate_.
00070 { return rate_; }
|
|
||||||||||||
|
Reimplemented in CMUTrace. Definition at line 96 of file object.cc. References Packet::free().
00097 {
00098 Packet::free(p);
00099 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from Connector. Definition at line 160 of file errmodel.cc. References hdr_flags::access(), hdr_cmn::access(), ErrorModel::bandwidth_, hdr_flags::ce(), ErrorModel::corrupt(), ErrorModel::delay_, ErrorModel::delay_pkt_, Connector::drop_, hdr_cmn::error(), Scheduler::instance(), ErrorModel::intr_, ErrorModel::markecn_, NsObject::recv(), Scheduler::schedule(), hdr_cmn::size(), Connector::target_, and Random::uniform().
00161 {
00162 // 1. Determine the error by calling corrupt(p)
00163 // 2. Set the packet's error flag if it is corrupted
00164 // 3. If there is no error, no drop_ target or markecn is true,
00165 // let pkt continue, otherwise hand the corrupted packet to drop_
00166
00167 hdr_cmn* ch = hdr_cmn::access(p);
00168 int error = corrupt(p);
00169
00170 // XXX When we do ECN, the packet is marked but NOT dropped.
00171 // So we don't resume handler here.
00172 if (!markecn_ && !delay_pkt_ && (h && ((error && drop_) || !target_))) {
00173 // if we drop or there is no target_, then resume handler
00174 double delay = Random::uniform(8.0 * ch->size() / bandwidth_);
00175 Scheduler::instance().schedule(h, &intr_, delay);
00176 }
00177 if (error) {
00178 ch->error() |= error;
00179
00180 if (markecn_) {
00181 hdr_flags* hf = hdr_flags::access(p);
00182 hf->ce() = 1;
00183 } else if (delay_pkt_) {
00184 // Delay the packet.
00185 Scheduler::instance().schedule(target_, p, delay_);
00186 return;
00187 } else if (drop_) {
00188 drop_->recv(p);
00189 return;
00190 }
00191 }
00192
00193 if (target_) {
00194 target_->recv(p, h);
00195 }
00196 }
|
Here is the call graph for this function:

|
|
Reimplemented in Agent, and Trace. Definition at line 56 of file object.h. Referenced by Trace::recvOnly().
00056 {};
|
|
|
Reimplemented from NsObject. Definition at line 154 of file errmodel.cc. References ErrorModel::firstTime_.
00155 {
00156 firstTime_ = 1;
00157 }
|
|
||||||||||||
|
Reimplemented in Agent, and LinkDelay. Definition at line 54 of file connector.h. References NsObject::recv(), and Connector::target_. Referenced by SessionTTLChecker::recv(), TTLChecker::recv(), DequeTrace::recv(), Trace::recv(), TraceIpMac::recv(), TraceIp::recv(), SatDequeTrace::recv(), SALink::recv(), SnoopQueueEDrop::recv(), SnoopQueueTagger::recv(), SnoopQueueDrop::recv(), SnoopQueueOut::recv(), SnoopQueueIn::recv(), PktCounter::recv(), NetworkInterface::recv(), MeasureMod::recv(), Filter::recv(), Connector::recv(), CMUTrace::recv(), CBQClass::recv(), and AddSR::recv().
|
Here is the call graph for this function:

|
|
Definition at line 48 of file connector.h. References Connector::target_. Referenced by JoBS::assignRateDropsADC(), FQ::deque(), QSAgent::recv(), and MIPMHAgent::reg().
00048 { return target_; }
|
|
|
Definition at line 71 of file errmodel.h. References ErrorUnit, and ErrorModel::unit_.
00071 { return unit_; }
|
|
|
Definition at line 89 of file errmodel.h. Referenced by ErrorModel::ErrorModel(), ErrorModel::PktLength(), and ErrorModel::recv(). |
|
|
Definition at line 172 of file errmodel.h. Referenced by corrupt(), and ListErrorModel(). |
|
|
Definition at line 94 of file errmodel.h. Referenced by ErrorModel::command(), and ErrorModel::CorruptBit(). |
|
|
Definition at line 95 of file errmodel.h. Referenced by ErrorModel::CorruptBit(). |
|
|
Definition at line 175 of file errmodel.h. Referenced by corrupt(), and ListErrorModel(). |
|
|
Definition at line 93 of file errmodel.h. Referenced by ErrorModel::command(), and ErrorModel::CorruptBit(). |
|
|
Definition at line 96 of file errmodel.h. Referenced by ErrorModel::CorruptBit(). |
|
|
Reimplemented in FECModel, FloodAgent, and LandmarkAgent. Definition at line 66 of file object.h. Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset(). |
|
|
Definition at line 88 of file errmodel.h. Referenced by ErrorModel::ErrorModel(), and ErrorModel::recv(). |
|
|
Definition at line 84 of file errmodel.h. Referenced by ErrorModel::ErrorModel(), and ErrorModel::recv(). |
|
|
Definition at line 57 of file connector.h. Referenced by Connector::command(), Connector::drop(), and ErrorModel::recv(). |
|
|
Definition at line 174 of file errmodel.h. Referenced by corrupt(), ListErrorModel(), and parse_droplist(). |
|
|
Definition at line 173 of file errmodel.h. Referenced by corrupt(), ListErrorModel(), parse_droplist(), and ~ListErrorModel(). |
|
|
Definition at line 82 of file errmodel.h. Referenced by ErrorModel::corrupt(), and ErrorModel::ErrorModel(). |
|
|
Definition at line 92 of file errmodel.h. Referenced by ErrorModel::command(), ErrorModel::ComputeBitErrProb(), and ErrorModel::CorruptBit(). |
|
|
Definition at line 85 of file errmodel.h. Referenced by MultiStateErrorModel::corrupt(), TwoStateErrorModel::corrupt(), ErrorModel::CorruptBit(), and ErrorModel::reset(). |
|
|
Definition at line 97 of file errmodel.h. Referenced by ErrorModel::recv(). |
|
|
Definition at line 83 of file errmodel.h. Referenced by ErrorModel::ErrorModel(), and ErrorModel::recv(). |
|
|
Reimplemented in TwoStateErrorModel. Definition at line 90 of file errmodel.h. Referenced by ErrorModel::command(), ErrorModel::CorruptBit(), ErrorModel::CorruptByte(), and ErrorModel::CorruptPkt(). |
|
|
Definition at line 87 of file errmodel.h. Referenced by ErrorModel::ComputeBitErrProb(), ErrorModel::CorruptByte(), ErrorModel::CorruptPkt(), ErrorModel::ErrorModel(), and ErrorModel::rate(). |
|
|
|
Definition at line 86 of file errmodel.h. Referenced by ErrorModel::command(), LMSErrorModel::corrupt(), SRMErrorModel::corrupt(), SelectErrorModel::corrupt(), corrupt(), PeriodicErrorModel::corrupt(), ErrorModel::corrupt(), ErrorModel::PktLength(), and ErrorModel::unit(). |
1.3.3