NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
rtt-estimator.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
rtt-estimator.hpp
"
27
28
namespace
nfd
{
29
30
RttEstimator::RttEstimator
(uint16_t maxMultiplier,
Duration
minRto,
double
gain)
31
: m_maxMultiplier(maxMultiplier)
32
, m_minRto(minRto.count())
33
, m_rtt(
RttEstimator
::getInitialRtt().count())
34
, m_gain(gain)
35
, m_variance(0)
36
, m_multiplier(1)
37
, m_nSamples(0)
38
{
39
}
40
41
void
42
RttEstimator::addMeasurement
(
Duration
measure)
43
{
44
double
m =
static_cast<
double
>
(measure.count());
45
if
(m_nSamples > 0) {
46
double
err = m - m_rtt;
47
double
gErr = err * m_gain;
48
m_rtt += gErr;
49
double
difference =
std::abs
(err) - m_variance;
50
m_variance += difference * m_gain;
51
}
else
{
52
m_rtt = m;
53
m_variance = m;
54
}
55
++m_nSamples;
56
m_multiplier = 1;
57
}
58
59
void
60
RttEstimator::incrementMultiplier
()
61
{
62
m_multiplier = std::min(static_cast<uint16_t>(m_multiplier + 1), m_maxMultiplier);
63
}
64
65
void
66
RttEstimator::doubleMultiplier
()
67
{
68
m_multiplier = std::min(static_cast<uint16_t>(m_multiplier * 2), m_maxMultiplier);
69
}
70
71
RttEstimator::Duration
72
RttEstimator::computeRto
()
const
73
{
74
double
rto = std::max(m_minRto, m_rtt + 4 * m_variance);
75
rto *= m_multiplier;
76
return
Duration
(static_cast<Duration::rep>(rto));
77
}
78
79
}
// namespace nfd
nfd::RttEstimator::computeRto
Duration computeRto() const
Definition:
rtt-estimator.cpp:72
nfd::RttEstimator::Duration
time::microseconds Duration
Definition:
rtt-estimator.hpp:46
rtt-estimator.hpp
nfd::RttEstimator::RttEstimator
RttEstimator(uint16_t maxMultiplier=16, Duration minRto=time::milliseconds(1), double gain=0.1)
Definition:
rtt-estimator.cpp:30
nfd::RttEstimator::doubleMultiplier
void doubleMultiplier()
Definition:
rtt-estimator.cpp:66
nfd::RttEstimator::incrementMultiplier
void incrementMultiplier()
Definition:
rtt-estimator.cpp:60
ndn::time::abs
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
Definition:
time.hpp:53
nfd::RttEstimator::addMeasurement
void addMeasurement(Duration measure)
Definition:
rtt-estimator.cpp:42
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::RttEstimator
implements the Mean-Deviation RTT estimator
Definition:
rtt-estimator.hpp:43
ndnSIM
NFD
daemon
fw
rtt-estimator.cpp
Generated on Wed Jan 11 2017 18:17:15 for ndnSIM by
1.8.13