public void AddSample(double ms_rtt) {
if( ms_rtt > _max_rtt ) { _max_rtt = ms_rtt; }
double ms_rtt2 = ms_rtt * ms_rtt;
_exp_moving_rtt = _exp_factor * (_exp_moving_rtt - ms_rtt) + ms_rtt;
_exp_moving_square_rtt = _exp_factor * (_exp_moving_square_rtt - ms_rtt2) + ms_rtt2;
/*
* Now we can compute the std_dev:
*/
double sd2 = _exp_moving_square_rtt - _exp_moving_rtt * _exp_moving_rtt;
if( sd2 > 0 ) {
_exp_moving_stdev = Math.Sqrt( sd2 );
}
else {
_exp_moving_stdev = 0.0;
}
#if REQREP_DEBUG
double timeout = _exp_moving_rtt + _STD_DEVS * std_dev;
Console.Error.WriteLine("mean: {0}, std-dev: {1}, max: {2}, timeout: {3}", _exp_moving_rtt, std_dev, _max_rtt, timeout);
#endif
}