ns-allinone-2.35/queue/red.cc
void REDQueue::run_estimator(int nqueued, int m)
{
	double f, f_sl;

	f = edv_.v_ave;
	f_sl = edv_.v_slope;
#define RED_EWMA
#ifdef RED_EWMA
	while (--m >= 1) {
		f *= 1.0 - edp_.q_w;
	}
#ifdef RED_HOLT_WINTERS
	double f_old;
	f_old = f;
#endif
	f *= 1.0 - edp_.q_w;
	f += edp_.q_w * nqueued;
#endif
#ifdef RED_HOLT_WINTERS
	while (--m >= 1) {
		f_old = f;
		f += f_sl;
		f *= 1.0 - edp_.q_w;
		f_sl *= 1.0 - 0.5 * edp_.q_w;
		f_sl += 0.5 * edp_.q_w * (f - f_old);
	}
	f_old = f;
	f += f_sl;
	f *= 1.0 - edp_.q_w;
	f += edp_.q_w * nqueued;
	f_sl *= 1.0 - 0.5 * edp_.q_w;
	f_sl += 0.5 * edp_.q_w * (f - f_old);
#endif
	edv_.v_ave = f;
	edv_.v_slope = f_sl;
}
/*
 * Compute the average queue size.
 * The code contains two alternate methods for this, the plain EWMA
 * and the Holt-Winters method.
 * nqueued can be bytes or packets
 */
Compute the average queue size.
The code contains two alternate methods for this, the plain EWMA
and the Holt-Winters method.
nqueued can be bytes or packets
Compute the average queue size . The code contains two alternate methods for this the plain EWMA and the Holt - Winters method . nqueued can be bytes or packets
void REDQueue::run_estimator(int nqueued, int m)
{
	double f, f_sl;
	f = edv_.v_ave;
	f_sl = edv_.v_slope;
#define RED_EWMA
#ifdef RED_EWMA
	while (--m >= 1) {
		f *= 1.0 - edp_.q_w;
	}
#ifdef RED_HOLT_WINTERS
	double f_old;
	f_old = f;
#endif
	f *= 1.0 - edp_.q_w;
	f += edp_.q_w * nqueued;
#endif
#ifdef RED_HOLT_WINTERS
	while (--m >= 1) {
		f_old = f;
		f += f_sl;
		f *= 1.0 - edp_.q_w;
		f_sl *= 1.0 - 0.5 * edp_.q_w;
		f_sl += 0.5 * edp_.q_w * (f - f_old);
	}
	f_old = f;
	f += f_sl;
	f *= 1.0 - edp_.q_w;
	f += edp_.q_w * nqueued;
	f_sl *= 1.0 - 0.5 * edp_.q_w;
	f_sl += 0.5 * edp_.q_w * (f - f_old);
#endif
	edv_.v_ave = f;
	edv_.v_slope = f_sl;
}
void REDQueue :: run_estimator ( int nqueued , int m ) { double f , f_sl ; f = edv_ . v_ave ; f_sl = edv_ . v_slope ; #define RED_EWMA #ifdef RED_EWMA while ( -- m >= 1 ) { f *= 1.0 - edp_ . q_w ; } #ifdef RED_HOLT_WINTERS double f_old ; f_old = f ; #endif f *= 1.0 - edp_ . q_w ; f += edp_ . q_w * nqueued ; #endif #ifdef RED_HOLT_WINTERS while ( -- m >= 1 ) { f_old = f ; f += f_sl ; f *= 1.0 - edp_ . q_w ; f_sl *= 1.0 - 0.5 * edp_ . q_w ; f_sl += 0.5 * edp_ . q_w * ( f - f_old ) ; } f_old = f ; f += f_sl ; f *= 1.0 - edp_ . q_w ; f += edp_ . q_w * nqueued ; f_sl *= 1.0 - 0.5 * edp_ . q_w ; f_sl += 0.5 * edp_ . q_w * ( f - f_old ) ; #endif edv_ . v_ave = f ; edv_ . v_slope = f_sl ; }
Compute the average queue size.
Compute the average queue size .