[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] DSRED-Avg_queue



 
    I�m looking at the dsred.cc, in particular at calcAvg procedure.
   This procedure calculates the average size of RED queue. But to calculate this size, we have two conditions if the queue is empty or nonempty. I didn�t find this condition at the procedure, so if could explain how it was maken, I�ll be very thankful.  
 
    Thank You
   
    Felipe Mathias
/*------------------------------------------------------------------------------
void calcAvg(int prec, int m)
This method calculates avg queue length, given the prec number, m (a value
used to adjust the queue size appropriately during idle times).
If mredMode is rio_c, each virtual queue size is calculated
independently. If it is true, the calculated size of queue n includes the sizes
of all virtual queues up to and including n.
------------------------------------------------------------------------------*/
void redQueue::calcAvg(int prec, int m) {
float f;
int i;
f = qParam_[prec].edv_.v_ave;
while (--m >= 1) {
f *= 1.0 - qParam_[prec].edp_.q_w;
}
f *= 1.0 - qParam_[prec].edp_.q_w;
if (mredMode == rio_c)
for (i = 0; i <= prec; i ++)
f += qParam_[i].edp_.q_w * qParam_[i].qlen;
else if (mredMode == rio_d)
f += qParam_[prec].edp_.q_w * qParam_[prec].qlen;
else //wred
f += qParam_[prec].edp_.q_w * q_->length();
if (mredMode == wred)
for (i = 0; i < numPrec; i ++)
qParam_[prec].edv_.v_ave = f;
else //rio_c, rio_d
qParam_[prec].edv_.v_ave = f;
}