32 : m_options(options ? std::move(options) : std::make_shared<const
Options>())
33 , m_rto(m_options->initialRto)
37 BOOST_ASSERT(
m_options->initialRto >= 0_ns);
41 BOOST_ASSERT(
m_options->rtoBackoffMultiplier >= 1);
47 BOOST_ASSERT(rtt >= 0_ns);
48 BOOST_ASSERT(nExpectedSamples > 0);
52 m_rttVar = m_sRtt / 2;
55 double alpha =
m_options->alpha / nExpectedSamples;
56 double beta =
m_options->beta / nExpectedSamples;
57 m_rttVar = time::duration_cast<time::nanoseconds>((1 - beta) * m_rttVar +
59 m_sRtt = time::duration_cast<time::nanoseconds>((1 - alpha) * m_sRtt + alpha * rtt);
61 m_rto = std::clamp(m_sRtt +
m_options->k * m_rttVar,
68 m_rto = std::clamp(m_rto *
m_options->rtoBackoffMultiplier,
77 m_rttAvg = (m_nRttSamples * m_rttAvg + rtt) / (m_nRttSamples + 1);
78 m_rttMax = std::max(rtt, m_rttMax);
79 m_rttMin = std::min(rtt, m_rttMin);
void addMeasurement(time::nanoseconds rtt, size_t nExpectedSamples=1)
Records a new RTT measurement.
std::shared_ptr< const Options > m_options
void backoffRto()
Backoff RTO by a factor of Options::rtoBackoffMultiplier.
void addMeasurement(time::nanoseconds rtt, size_t nExpectedSamples=1)
Records a new RTT measurement.
RttEstimator(std::shared_ptr< const Options > options=nullptr)
Constructor.
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
Returns the absolute value of the duration d.
::boost::chrono::nanoseconds nanoseconds