ns-allinone-2.35/rap/media-app.cc
double QA::bufOptScen2(int layer, int layers, double currrate, 
		       double slope, int backoffs)
{
	double bufopt = 0.0;
	int bmin, done;

	if(backoffs < 0) {
		panic("# ERROR: backoff: %d in bufOptScen2\n", 
			backoffs);
	}
	if ((currrate/pow(2,backoffs)) >= layers*LAYERBW_)
		return(0.0);

	bmin = 0;
	done = 0;
	while ((!done) && bmin<=backoffs) {
		if(currrate/pow(2,bmin) >= LAYERBW_*layers)
			bmin++;
		else 
			done++;
	}
	// buf required for the first triangle
	// we could have dec bmin and go for 1 backoff as well
	bufopt = bufOptScen1(layer, layers, currrate/pow(2,bmin), slope, 0);
  
	// remaining sequential backoffs
	bufopt += (backoffs - bmin)*BufNeed(layers*LAYERBW_/2, slope);
	return(bufopt);
}
//
// This routine calculate optimal buffer distribution for a layer
// in scenario 2 based on the 
// 1) current rate, 2) no of layers, 3) no of backoffs
//
// Jan 28, 99bufOptScen1(layer, layers, currrate, slope, backoffs)
//
This routine calculate optimal buffer distribution for a layer
in scenario 2 based on the
1) current rate, 2) no of layers, 3) no of backoffs

Jan 28, 99bufOptScen1(layer, layers, currrate, slope, backoffs)
This routine calculate optimal buffer distribution for a layer in scenario 2 based on the 1 ) current rate 2 ) no of layers 3 ) no of backoffs Jan 28 99bufOptScen1 ( layer layers currrate slope backoffs )
double QA::bufOptScen2(int layer, int layers, double currrate, 
		       double slope, int backoffs)
{
	double bufopt = 0.0;
	int bmin, done;
	if(backoffs < 0) {
		panic("# ERROR: backoff: %d in bufOptScen2\n", 
			backoffs);
	}
	if ((currrate/pow(2,backoffs)) >= layers*LAYERBW_)
		return(0.0);
	bmin = 0;
	done = 0;
	while ((!done) && bmin<=backoffs) {
		if(currrate/pow(2,bmin) >= LAYERBW_*layers)
			bmin++;
		else 
			done++;
	}
	bufopt = bufOptScen1(layer, layers, currrate/pow(2,bmin), slope, 0);
	bufopt += (backoffs - bmin)*BufNeed(layers*LAYERBW_/2, slope);
	return(bufopt);
}
double QA :: bufOptScen2 ( int layer , int layers , double currrate , double slope , int backoffs ) { double bufopt = 0.0 ; int bmin , done ; if ( backoffs < 0 ) { panic ( " \n " , backoffs ) ; } if ( ( currrate / pow ( 2 , backoffs ) ) >= layers * LAYERBW_ ) return ( 0.0 ) ; bmin = 0 ; done = 0 ; while ( ( ! done ) && bmin <= backoffs ) { if ( currrate / pow ( 2 , bmin ) >= LAYERBW_ * layers ) bmin ++ ; else done ++ ; } bufopt = bufOptScen1 ( layer , layers , currrate / pow ( 2 , bmin ) , slope , 0 ) ; bufopt += ( backoffs - bmin ) * BufNeed ( layers * LAYERBW_ / 2 , slope ) ; return ( bufopt ) ; }
This routine calculate optimal buffer distribution for a layer
in scenario 2 based on the
1) current rate, 2) no of layers, 3) no of backoffs
This routine calculate optimal buffer distribution for a layer in scenario 2 based on the 1 ) current rate 2 ) no of layers 3 ) no of backoffs
// buf required for the first triangle // we could have dec bmin and go for 1 backoff as well // remaining sequential backoffs