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


Public Member Functions | |
| ErrorModel () | |
| virtual void | recv (Packet *, Handler *) |
| virtual void | reset () |
| virtual int | corrupt (Packet *) |
| double | rate () |
| ErrorUnit | unit () |
| NsObject * | target () |
| virtual void | drop (Packet *p) |
| virtual void | recv (Packet *p, const char *s) |
| 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 | |
| virtual int | command (int argc, const char *const *argv) |
| 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 *) |
Protected Attributes | |
| 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 102 of file errmodel.cc. References bandwidth_, delay_, delay_pkt_, enable_, EU_PKT, markecn_, and rate_.
00102 : firstTime_(1), unit_(EU_PKT), ranvar_(0), FECstrength_(1) 00103 { 00104 bind("enable_", &enable_); 00105 bind("rate_", &rate_); 00106 bind("delay_", &delay_); 00107 bind_bw("bandwidth_", &bandwidth_); // required for EU_TIME 00108 bind_bool("markecn_", &markecn_); 00109 bind_bool("delay_pkt_", &delay_pkt_); 00110 } |
|
||||||||||||
|
Reimplemented from Connector. Reimplemented in SRMErrorModel, TwoStateErrorModel, MultiStateErrorModel, ListErrorModel, SelectErrorModel, MrouteErrorModel, and LMSErrorModel. Definition at line 112 of file errmodel.cc. References cntrlpktsize_, Connector::command(), datapktsize_, eu_names, FECstrength_, ranvar_, STR2EU, and unit_. Referenced by LMSErrorModel::command(), MrouteErrorModel::command(), SRMErrorModel::command(), SelectErrorModel::command(), ListErrorModel::command(), MultiStateErrorModel::command(), and TwoStateErrorModel::command().
00113 {
00114 Tcl& tcl = Tcl::instance();
00115 //ErrorModel *em;
00116 if (argc == 3) {
00117 if (strcmp(argv[1], "unit") == 0) {
00118 unit_ = STR2EU(argv[2]);
00119 return (TCL_OK);
00120 }
00121 if (strcmp(argv[1], "ranvar") == 0) {
00122 ranvar_ = (RandomVariable*) TclObject::lookup(argv[2]);
00123 return (TCL_OK);
00124 }
00125 if (strcmp(argv[1], "FECstrength") == 0) {
00126 FECstrength_ = atoi(argv[2]);
00127 return (TCL_OK);
00128 }
00129 if (strcmp(argv[1], "datapktsize") == 0) {
00130 datapktsize_ = atoi(argv[2]);
00131 return (TCL_OK);
00132 }
00133 if (strcmp(argv[1], "cntrlpktsize") == 0) {
00134 cntrlpktsize_ = atoi(argv[2]);
00135 return (TCL_OK);
00136 }
00137 } else if (argc == 2) {
00138 if (strcmp(argv[1], "unit") == 0) {
00139 tcl.resultf("%s", eu_names[unit_]);
00140 return (TCL_OK);
00141 }
00142 if (strcmp(argv[1], "ranvar") == 0) {
00143 tcl.resultf("%s", ranvar_->name());
00144 return (TCL_OK);
00145 }
00146 if (strcmp(argv[1], "FECstrength") == 0) {
00147 tcl.resultf("%d", FECstrength_);
00148 return (TCL_OK);
00149 }
00150 }
00151 return Connector::command(argc, argv);
00152 }
|
Here is the call graph for this function:

|
|
Definition at line 231 of file errmodel.cc. References comb(), FECstrength_, pow(), and rate_. Referenced by 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 in SRMErrorModel, TwoStateErrorModel, MultiStateErrorModel, TraceErrorModel, PeriodicErrorModel, ListErrorModel, SelectErrorModel, and LMSErrorModel. Definition at line 198 of file errmodel.cc. References hdr_cmn::access(), CorruptBit(), CorruptByte(), CorruptPkt(), CorruptTime(), enable_, hdr_cmn::errbitcnt(), EU_BIT, EU_BYTE, EU_TIME, and unit_. Referenced by MultiStateErrorModel::corrupt(), SessionHelper::get_dropped(), and recv().
00199 {
00200 hdr_cmn* ch;
00201 if (enable_ == 0)
00202 return 0;
00203 switch (unit_) {
00204 case EU_TIME:
00205 return (CorruptTime(p) != 0);
00206 case EU_BYTE:
00207 return (CorruptByte(p) != 0);
00208 case EU_BIT:
00209 ch = hdr_cmn::access(p);
00210 ch->errbitcnt() = CorruptBit(p);
00211 return (ch->errbitcnt() != 0);
00212 default:
00213 return (CorruptPkt(p) != 0);
00214 }
00215 return 0;
00216 }
|
Here is the call graph for this function:

|
|
Definition at line 270 of file errmodel.cc. References hdr_cmn::access(), cntrlpktsize_, cntrlprb_, ComputeBitErrProb(), datapktsize_, dataprb_, FECstrength_, firstTime_, ranvar_, hdr_cmn::size(), Random::uniform(), and RandomVariable::value(). Referenced by 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 PktLength(), pow(), ranvar_, rate_, Random::uniform(), and RandomVariable::value(). Referenced by corrupt().
|
Here is the call graph for this function:

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

|
|
Definition at line 290 of file errmodel.cc. Referenced by 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 61 of file object.h. References NsObject::debug_.
00061 { return debug_; }
|
|
|
Definition at line 218 of file errmodel.cc. References hdr_cmn::access(), bandwidth_, EU_BIT, EU_BYTE, EU_PKT, hdr_cmn::size(), and unit_. Referenced by TwoStateErrorModel::corrupt(), and 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 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(), bandwidth_, hdr_flags::ce(), corrupt(), delay_, delay_pkt_, Connector::drop_, hdr_cmn::error(), Scheduler::instance(), intr_, 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 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 unit_.
00071 { return unit_; }
|
|
|
Definition at line 89 of file errmodel.h. Referenced by ErrorModel(), PktLength(), and recv(). |
|
|
Definition at line 94 of file errmodel.h. Referenced by command(), and CorruptBit(). |
|
|
Definition at line 95 of file errmodel.h. Referenced by CorruptBit(). |
|
|
Definition at line 93 of file errmodel.h. Referenced by command(), and CorruptBit(). |
|
|
Definition at line 96 of file errmodel.h. Referenced by 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(), and recv(). |
|
|
Definition at line 84 of file errmodel.h. Referenced by ErrorModel(), and recv(). |
|
|
Definition at line 57 of file connector.h. Referenced by Connector::command(), Connector::drop(), and recv(). |
|
|
Definition at line 82 of file errmodel.h. Referenced by corrupt(), and ErrorModel(). |
|
|
Definition at line 92 of file errmodel.h. Referenced by command(), ComputeBitErrProb(), and CorruptBit(). |
|
|
Definition at line 85 of file errmodel.h. Referenced by MultiStateErrorModel::corrupt(), TwoStateErrorModel::corrupt(), CorruptBit(), and reset(). |
|
|
Definition at line 97 of file errmodel.h. Referenced by recv(). |
|
|
Definition at line 83 of file errmodel.h. Referenced by ErrorModel(), and recv(). |
|
|
Reimplemented in TwoStateErrorModel. Definition at line 90 of file errmodel.h. Referenced by command(), CorruptBit(), CorruptByte(), and CorruptPkt(). |
|
|
Definition at line 87 of file errmodel.h. Referenced by ComputeBitErrProb(), CorruptByte(), CorruptPkt(), ErrorModel(), and rate(). |
|
|
|
Definition at line 86 of file errmodel.h. Referenced by command(), LMSErrorModel::corrupt(), SRMErrorModel::corrupt(), SelectErrorModel::corrupt(), ListErrorModel::corrupt(), PeriodicErrorModel::corrupt(), corrupt(), PktLength(), and unit(). |
1.3.3