NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
rtt-estimator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (C) 2016-2018, Arizona Board of Regents.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  *
21  * @author Shuo Yang
22  * @author Weiwei Liu
23  * @author Chavoosh Ghasemi
24  */
25 
26 #ifndef NDN_CXX_UTIL_RTT_ESTIMATOR_HPP
27 #define NDN_CXX_UTIL_RTT_ESTIMATOR_HPP
28 
29 #include "ndn-cxx/util/signal.hpp"
30 #include "ndn-cxx/util/time.hpp"
31 
32 namespace ndn {
33 namespace util {
34 
42 {
43 public:
44  using MillisecondsDouble = time::duration<double, time::milliseconds::period>;
45 
46 public:
47  class Options
48  {
49  public:
50  constexpr
51  Options() noexcept
52  {
53  }
54 
55  public:
56  double alpha = 0.125;
57  double beta = 0.25;
58  int k = 4;
63  };
64 
71  explicit
72  RttEstimator(const Options& options = Options());
73 
83  void
84  addMeasurement(MillisecondsDouble rtt, size_t nExpectedSamples);
85 
91  {
92  return m_rto;
93  }
94 
99  getMinRtt() const
100  {
101  return m_rttMin;
102  }
103 
108  getMaxRtt() const
109  {
110  return m_rttMax;
111  }
112 
117  getAvgRtt() const
118  {
119  return m_rttAvg;
120  }
121 
125  void
126  backoffRto();
127 
128 private:
129  const Options m_options;
130  MillisecondsDouble m_sRtt;
131  MillisecondsDouble m_rttVar;
132  MillisecondsDouble m_rto;
133  MillisecondsDouble m_rttMin;
134  MillisecondsDouble m_rttMax;
135  MillisecondsDouble m_rttAvg;
136  int64_t m_nRttSamples;
137 };
138 
139 } // namespace util
140 } // namespace ndn
141 
142 #endif // NDN_CXX_UTIL_RTT_ESTIMATOR_HPP
Copyright (c) 2011-2015 Regents of the University of California.
MillisecondsDouble getAvgRtt() const
Returns the average RTT.
MillisecondsDouble minRto
lower bound of RTO
MillisecondsDouble getMaxRtt() const
Returns the maximum RTT observed.
double alpha
weight of exponential moving average for meanRtt
double beta
weight of exponential moving average for varRtt
void backoffRto()
Backoff RTO by a factor of Options::rtoBackoffMultiplier.
RttEstimator(const Options &options=Options())
Create a RTT Estimator.
MillisecondsDouble initialRto
initial RTO value
void addMeasurement(MillisecondsDouble rtt, size_t nExpectedSamples)
Add a new RTT measurement to the estimator.
MillisecondsDouble maxRto
upper bound of RTO
MillisecondsDouble getMinRtt() const
Returns the minimum RTT observed.
int k
factor of RTT variation when calculating RTO
MillisecondsDouble getEstimatedRto() const
Returns the estimated RTO value.
time::duration< double, time::milliseconds::period > MillisecondsDouble