36 , m_sRtt(
std::numeric_limits<double>::quiet_NaN())
37 , m_rttVar(
std::numeric_limits<double>::quiet_NaN())
38 , m_rto(m_options.initialRto.count())
39 , m_rttMin(
std::numeric_limits<double>::max())
40 , m_rttMax(
std::numeric_limits<double>::min())
49 BOOST_ASSERT(nExpectedSamples > 0);
51 if (m_nRttSamples == 0) {
53 m_rttVar = m_sRtt / 2;
54 m_rto = m_sRtt + m_options.
k * m_rttVar;
57 double alpha = m_options.
alpha / nExpectedSamples;
58 double beta = m_options.
beta / nExpectedSamples;
59 m_rttVar = (1 - beta) * m_rttVar + beta *
time::abs(m_sRtt - rtt);
60 m_sRtt = (1 - alpha) * m_sRtt + alpha * rtt;
61 m_rto = m_sRtt + m_options.
k * m_rttVar;
66 m_rttAvg =
MillisecondsDouble((m_nRttSamples * m_rttAvg.count() + rtt.count()) / (m_nRttSamples + 1));
67 m_rttMax = std::max<MillisecondsDouble>(rtt, m_rttMax);
68 m_rttMin = std::min<MillisecondsDouble>(rtt, m_rttMin);
MillisecondsDouble minRto
lower bound of RTO
double alpha
weight of exponential moving average for meanRtt
double beta
weight of exponential moving average for varRtt
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
void backoffRto()
Backoff RTO by a factor of Options::rtoBackoffMultiplier.
RttEstimator(const Options &options=Options())
Create a RTT Estimator.
void addMeasurement(MillisecondsDouble rtt, size_t nExpectedSamples)
Add a new RTT measurement to the estimator.
MillisecondsDouble maxRto
upper bound of RTO
int k
factor of RTT variation when calculating RTO
time::duration< double, time::milliseconds::period > MillisecondsDouble