A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
rtt-estimator.h
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
3//
4// SPDX-License-Identifier: GPL-2.0-only
5//
6// Author: Rajib Bhattacharjea<raj.b@gatech.edu>
7//
8
9// Georgia Tech Network Simulator - Round Trip Time Estimation Class
10// George F. Riley. Georgia Tech, Spring 2002
11
12#ifndef RTT_ESTIMATOR_H
13#define RTT_ESTIMATOR_H
14
15#include "ns3/nstime.h"
16#include "ns3/object.h"
17
18namespace ns3
19{
20
21/**
22 * @ingroup tcp
23 *
24 * @brief Base class for all RTT Estimators
25 *
26 * The RTT Estimator class computes an estimate of the round trip time
27 * observed in a series of Time measurements. The estimate is provided in
28 * the form of an estimate and a sample variation. Subclasses can implement
29 * different algorithms to provide values for the estimate and variation.
30 */
31class RttEstimator : public Object
32{
33 public:
34 /**
35 * @brief Get the type ID.
36 * @return the object TypeId
37 */
38 static TypeId GetTypeId();
39
41 /**
42 * @brief Copy constructor
43 * @param r the object to copy
44 */
45 RttEstimator(const RttEstimator& r);
46
47 ~RttEstimator() override;
48
49 /**
50 * @brief Add a new measurement to the estimator. Pure virtual function.
51 * @param t the new RTT measure.
52 */
53 virtual void Measurement(Time t) = 0;
54
55 /**
56 * @brief Copy object (including current internal state)
57 * @returns a copy of itself
58 */
59 virtual Ptr<RttEstimator> Copy() const = 0;
60
61 /**
62 * @brief Resets the estimation to its initial state.
63 */
64 virtual void Reset();
65
66 /**
67 * @brief gets the RTT estimate.
68 * @return The RTT estimate.
69 */
70 Time GetEstimate() const;
71
72 /**
73 * Note that this is not a formal statistical variance; it has the
74 * the same units as the estimate. Mean deviation or standard deviation
75 * are example quantities that could be provided here.
76 *
77 * @brief gets the RTT estimate variation.
78 * @return The RTT estimate variation.
79 */
80 Time GetVariation() const;
81
82 /**
83 * @brief gets the number of samples used in the estimates
84 * @return the number of samples used in the estimates
85 */
86 uint32_t GetNSamples() const;
87
88 private:
89 Time m_initialEstimatedRtt; //!< Initial RTT estimation
90
91 protected:
92 Time m_estimatedRtt; //!< Current estimate
93 Time m_estimatedVariation; //!< Current estimate variation
94 uint32_t m_nSamples; //!< Number of samples
95};
96
97/**
98 * @ingroup tcp
99 *
100 * @brief The "Mean--Deviation" RTT estimator, as discussed by Van Jacobson
101 *
102 * This class implements the "Mean--Deviation" RTT estimator, as discussed
103 * by Van Jacobson and Michael J. Karels, in
104 * "Congestion Avoidance and Control", SIGCOMM 88, Appendix A
105 *
106 * The default values for the gain (alpha and beta) are set as documented
107 * in RFC 6298.
108 *
109 */
111{
112 public:
113 /**
114 * @brief Get the type ID.
115 * @return the object TypeId
116 */
117 static TypeId GetTypeId();
118
120
121 /**
122 * @brief Copy constructor
123 * @param r the object to copy
124 */
126
127 /**
128 * @brief Add a new measurement to the estimator.
129 * @param measure the new RTT measure.
130 */
131 void Measurement(Time measure) override;
132
133 Ptr<RttEstimator> Copy() const override;
134
135 /**
136 * @brief Resets the estimator.
137 */
138 void Reset() override;
139
140 private:
141 /**
142 * Utility function to check for possible conversion
143 * of a double value (0 < value < 1) to a reciprocal power of two
144 *
145 * Values of 1/32, 1/16, 1/8, 1/4, and 1/2 (i.e., within the possible
146 * range of experimentation for this estimator) are supported.
147 *
148 * @param val value to check
149 * @return log base 2 (1/val) if reciprocal power of 2, or zero if not
150 */
151 uint32_t CheckForReciprocalPowerOfTwo(double val) const;
152 /**
153 * Method to update the rtt and variation estimates using integer
154 * arithmetic, used when the values of Alpha and Beta support the
155 * integer conversion.
156 *
157 * @param m time measurement
158 * @param rttShift value corresponding to log base 2 (1/alpha)
159 * @param variationShift value corresponding to log base 2 (1/beta)
160 */
161 void IntegerUpdate(Time m, uint32_t rttShift, uint32_t variationShift);
162 /**
163 * Method to update the rtt and variation estimates using floating
164 * point arithmetic, used when the values of Alpha and Beta are not
165 * both a reciprocal power of two.
166 *
167 * @param m time measurement
168 */
170 double m_alpha; //!< Filter gain for average
171 double m_beta; //!< Filter gain for variation
172};
173
174} // namespace ns3
175
176#endif /* RTT_ESTIMATOR_H */
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Base class for all RTT Estimators.
Time m_initialEstimatedRtt
Initial RTT estimation.
Time GetEstimate() const
gets the RTT estimate.
virtual void Reset()
Resets the estimation to its initial state.
~RttEstimator() override
Time m_estimatedVariation
Current estimate variation.
uint32_t m_nSamples
Number of samples.
Time m_estimatedRtt
Current estimate.
Time GetVariation() const
Note that this is not a formal statistical variance; it has the the same units as the estimate.
virtual Ptr< RttEstimator > Copy() const =0
Copy object (including current internal state)
virtual void Measurement(Time t)=0
Add a new measurement to the estimator.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetNSamples() const
gets the number of samples used in the estimates
The "Mean--Deviation" RTT estimator, as discussed by Van Jacobson.
double m_beta
Filter gain for variation.
void Reset() override
Resets the estimator.
void FloatingPointUpdate(Time m)
Method to update the rtt and variation estimates using floating point arithmetic, used when the value...
Ptr< RttEstimator > Copy() const override
Copy object (including current internal state)
static TypeId GetTypeId()
Get the type ID.
uint32_t CheckForReciprocalPowerOfTwo(double val) const
Utility function to check for possible conversion of a double value (0 < value < 1) to a reciprocal p...
void Measurement(Time measure) override
Add a new measurement to the estimator.
double m_alpha
Filter gain for average.
void IntegerUpdate(Time m, uint32_t rttShift, uint32_t variationShift)
Method to update the rtt and variation estimates using integer arithmetic, used when the values of Al...
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.