NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
}
52
else
{
53
m_rtt = m;
54
m_variance = m;
55
}
56
++m_nSamples;
57
m_multiplier = 1;
58
}
59
60
void
61
RttEstimator::incrementMultiplier
()
62
{
63
m_multiplier = std::min(static_cast<uint16_t>(m_multiplier + 1), m_maxMultiplier);
64
}
65
66
void
67
RttEstimator::doubleMultiplier
()
68
{
69
m_multiplier = std::min(static_cast<uint16_t>(m_multiplier * 2), m_maxMultiplier);
70
}
71
72
RttEstimator::Duration
73
RttEstimator::computeRto
()
const
74
{
75
double
rto = std::max(m_minRto, m_rtt + 4 * m_variance);
76
rto *= m_multiplier;
77
return
Duration
(static_cast<Duration::rep>(rto));
78
}
79
80
}
// namespace nfd
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:67
nfd::RttEstimator::incrementMultiplier
void incrementMultiplier()
Definition:
rtt-estimator.cpp:61
nfd::RttEstimator::computeRto
Duration computeRto() const
Definition:
rtt-estimator.cpp:73
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
core
rtt-estimator.cpp
Generated on Thu Nov 2 2017 03:30:29 for ndnSIM by
1.8.11