#include <REDQueue.h>
Inheritance diagram for REDQueue:
Protected Member Functions | |
virtual void | initialize () |
virtual void | finish () |
virtual bool | enqueue (cMessage *msg) |
virtual cMessage * | dequeue () |
virtual void | sendOut (cMessage *msg) |
Protected Attributes | |
double | wq |
double | minth |
double | maxth |
double | maxp |
double | pkrate |
cQueue | queue |
double | avg |
simtime_t | q_time |
int | count |
cOutVector | avgQlenVec |
cOutVector | qlenVec |
cOutVector | dropVec |
long | numEarlyDrops |
|
Redefined from PassiveQueueBase. Implements PassiveQueueBase. 00137 { 00138 if (queue.empty()) 00139 return NULL; 00140 00141 //" 00142 // when queue becomes empty 00143 // q_time <- time 00144 //" 00145 cMessage *pk = (cMessage *)queue.pop(); 00146 if (queue.length()==0) 00147 q_time = simTime(); 00148 00149 // statistics 00150 qlenVec.record(queue.length()); 00151 00152 return pk; 00153 }
|
|
Redefined from PassiveQueueBase. Implements PassiveQueueBase. 00055 { 00056 //" 00057 // for each packet arrival 00058 // calculate the new average queue size avg: 00059 // if the queue is nonempty 00060 // avg <- (1-wq)*avg + wq*q 00061 // else 00062 // m <- f(time-q_time) 00063 // avg <- (1-wq)^m * avg 00064 //" 00065 if (!queue.empty()) 00066 { 00067 avg = (1-wq)*avg + wq*queue.length(); 00068 } 00069 else 00070 { 00071 // Note: f() is supposed to estimate the number of packets 00072 // that could have arrived during the idle interval (see Section 11 00073 // of the paper). We use pkrate for this purpose. 00074 double m = (simTime()-q_time) * pkrate; 00075 avg = pow(1-wq, m) * avg; 00076 } 00077 00078 // statistics 00079 avgQlenVec.record(avg); 00080 00081 //" 00082 // if minth <= avg < maxth 00083 // increment count 00084 // calculate probability pa: 00085 // pb <- maxp*(avg-minth) / (maxth-minth) 00086 // pa <- pb / (1-count*pb) 00087 // with probability pa: 00088 // mark the arriving packet 00089 // count <- 0 00090 // else if maxth <= avg 00091 // mark the arriving packet 00092 // count <- 0 00093 // else count <- -1 00094 //" 00095 00096 bool mark = false; 00097 if (minth<=avg && avg<maxth) 00098 { 00099 count++; 00100 double pb = maxp*(avg-minth) / (maxth-minth); 00101 double pa = pb / (1-count*pb); 00102 if (dblrand() < pa) 00103 { 00104 EV << "Random early packet drop (avg queue len=" << avg << ", pa=" << pa << ")\n"; 00105 mark = true; 00106 count = 0; 00107 numEarlyDrops++; 00108 } 00109 } 00110 else if (maxth <= avg) 00111 { 00112 EV << "Avg queue len " << avg << " >= maxth, dropping packet.\n"; 00113 mark = true; 00114 count = 0; 00115 } 00116 else 00117 { 00118 count = -1; 00119 } 00120 00121 // carry out decision 00122 if (mark || queue.length()>=maxth) // maxth is also the "hard" limit 00123 { 00124 delete msg; 00125 dropVec.record(1); 00126 return true; 00127 } 00128 else 00129 { 00130 queue.insert(msg); 00131 qlenVec.record(queue.length()); 00132 return false; 00133 } 00134 }
|
|
Reimplemented from PassiveQueueBase. 00161 { 00162 PassiveQueueBase::finish(); 00163 recordScalar("packets dropped early by RED", numEarlyDrops); 00164 }
|
|
Reimplemented from PassiveQueueBase. 00027 { 00028 PassiveQueueBase::initialize(); 00029 queue.setName("l2queue"); 00030 00031 avgQlenVec.setName("avg queue length"); 00032 qlenVec.setName("queue length"); 00033 dropVec.setName("drops"); 00034 00035 // configuration 00036 wq = par("wq"); 00037 minth = par("minth"); 00038 maxth = par("maxth"); 00039 maxp = par("maxp"); 00040 pkrate = par("pkrate"); 00041 00042 // state 00043 avg = 0; 00044 q_time = 0; 00045 count = -1; 00046 numEarlyDrops = 0; 00047 00048 WATCH(avg); 00049 WATCH(q_time); 00050 WATCH(count); 00051 WATCH(numEarlyDrops); 00052 }
|
|
Redefined from PassiveQueueBase. Implements PassiveQueueBase. 00156 {
00157 send(msg, "out");
00158 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|