33 : m_options(options ? std::move(options) : make_shared<const
Options>())
34 , m_rto(m_options->initialRto)
38 BOOST_ASSERT(
m_options->initialRto >= 0_ns);
42 BOOST_ASSERT(
m_options->rtoBackoffMultiplier >= 1);
48 BOOST_ASSERT(rtt >= 0_ns);
49 BOOST_ASSERT(nExpectedSamples > 0);
53 m_rttVar = m_sRtt / 2;
56 double alpha =
m_options->alpha / nExpectedSamples;
57 double beta =
m_options->beta / nExpectedSamples;
58 m_rttVar = time::duration_cast<time::nanoseconds>((1 - beta) * m_rttVar +
60 m_sRtt = time::duration_cast<time::nanoseconds>((1 - alpha) * m_sRtt + alpha * rtt);
78 m_rttAvg = (m_nRttSamples * m_rttAvg + rtt) / (m_nRttSamples + 1);
79 m_rttMax = std::max(rtt, m_rttMax);
80 m_rttMin = std::min(rtt, m_rttMin);
void addMeasurement(time::nanoseconds rtt, size_t nExpectedSamples=1)
Records a new RTT measurement.
void backoffRto()
Backoff RTO by a factor of Options::rtoBackoffMultiplier.
void addMeasurement(time::nanoseconds rtt, size_t nExpectedSamples=1)
Records a new RTT measurement.
shared_ptr< const Options > m_options
RttEstimator(shared_ptr< const Options > options=nullptr)
Constructor.
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
boost::chrono::nanoseconds nanoseconds
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)