ns-allinone-2.35/rap/media-app.cc
void QA::DrainPacket(double bufToDrain, double* FinalDrainArray, int layers,
		     double rate, double srtt, double* FinalBuffer)
{
	double DrainArr[MAX_LAYER],  bufAvail[MAX_LAYER], TotBufAvail;
	int l,cnt;
  
	for(l=0; l<MAX_LAYER; l++){
		FinalDrainArray[l] = 0.0;
		bufAvail[l] = buffer_[l];
	}

	TotBufAvail = TotalBuf(layers, bufAvail);
	cnt = 0;
	while ((bufToDrain > 0) && (cnt < 10)) {
		// debug("bufToDrain%d: %.2f\n", cnt, bufToDrain);
		drain_buf(DrainArr, bufToDrain, FinalDrainArray, bufAvail, 
			  layers, rate, srtt);
		
		for(l=0; l<layers; l++){
			bufToDrain -= DrainArr[l];
			TotBufAvail -= DrainArr[l];
			FinalDrainArray[l] += DrainArr[l];
			bufAvail[l] -= DrainArr[l];
			FinalBuffer[l] = buffer_[l] - FinalDrainArray[l];
		}
		cnt++;
	}
}
//
// This routine calculate an optimal distribution of a given 
// amount of buffered data to drain.
// the main algorithm is in drain_buf() and this one mainly init
// the input and calls that routine ad then update FinalDrainArray,
// based on its old value and return value for DrainArr.
//
// FinalDrainArray: output
// FinalBuffer: output, expected buf state at the end of the interval
This routine calculate an optimal distribution of a given
amount of buffered data to drain.
the main algorithm is in drain_buf() and this one mainly init
the input and calls that routine ad then update FinalDrainArray,
based on its old value and return value for DrainArr.

output
FinalBuffer: output, expected buf state at the end of the interval
This routine calculate an optimal distribution of a given amount of buffered data to drain . the main algorithm is in drain_buf () and this one mainly init the input and calls that routine ad then update FinalDrainArray based on its old value and return value for DrainArr . output FinalBuffer : output expected buf state at the end of the interval
void QA::DrainPacket(double bufToDrain, double* FinalDrainArray, int layers,
		     double rate, double srtt, double* FinalBuffer)
{
	double DrainArr[MAX_LAYER],  bufAvail[MAX_LAYER], TotBufAvail;
	int l,cnt;
	for(l=0; l<MAX_LAYER; l++){
		FinalDrainArray[l] = 0.0;
		bufAvail[l] = buffer_[l];
	}
	TotBufAvail = TotalBuf(layers, bufAvail);
	cnt = 0;
	while ((bufToDrain > 0) && (cnt < 10)) {
		drain_buf(DrainArr, bufToDrain, FinalDrainArray, bufAvail, 
			  layers, rate, srtt);
		for(l=0; l<layers; l++){
			bufToDrain -= DrainArr[l];
			TotBufAvail -= DrainArr[l];
			FinalDrainArray[l] += DrainArr[l];
			bufAvail[l] -= DrainArr[l];
			FinalBuffer[l] = buffer_[l] - FinalDrainArray[l];
		}
		cnt++;
	}
}
void QA :: DrainPacket ( double bufToDrain , double * FinalDrainArray , int layers , double rate , double srtt , double * FinalBuffer ) { double DrainArr [ MAX_LAYER ] , bufAvail [ MAX_LAYER ] , TotBufAvail ; int l , cnt ; for ( l = 0 ; l < MAX_LAYER ; l ++ ) { FinalDrainArray [ l ] = 0.0 ; bufAvail [ l ] = buffer_ [ l ] ; } TotBufAvail = TotalBuf ( layers , bufAvail ) ; cnt = 0 ; while ( ( bufToDrain > 0 ) && ( cnt < 10 ) ) { drain_buf ( DrainArr , bufToDrain , FinalDrainArray , bufAvail , layers , rate , srtt ) ; for ( l = 0 ; l < layers ; l ++ ) { bufToDrain -= DrainArr [ l ] ; TotBufAvail -= DrainArr [ l ] ; FinalDrainArray [ l ] += DrainArr [ l ] ; bufAvail [ l ] -= DrainArr [ l ] ; FinalBuffer [ l ] = buffer_ [ l ] - FinalDrainArray [ l ] ; } cnt ++ ; } }
This routine calculate an optimal distribution of a given
amount of buffered data to drain.
This routine calculate an optimal distribution of a given amount of buffered data to drain .
// debug("bufToDrain%d: %.2f\n", cnt, bufToDrain);