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 void NotifyConstructionCompleted() override;
93
94 Time m_estimatedRtt; //!< Current estimate
95 Time m_estimatedVariation; //!< Current estimate variation
96 uint32_t m_nSamples; //!< Number of samples
97};
98
99/**
100 * @ingroup tcp
101 *
102 * @brief The "Mean--Deviation" RTT estimator, as discussed by Van Jacobson
103 *
104 * This class implements the "Mean--Deviation" RTT estimator, as discussed
105 * by Van Jacobson and Michael J. Karels, in
106 * "Congestion Avoidance and Control", SIGCOMM 88, Appendix A
107 *
108 * The default values for the gain (alpha and beta) are set as documented
109 * in RFC 6298.
110 *
111 */
113{
114 public:
115 /**
116 * @brief Get the type ID.
117 * @return the object TypeId
118 */
119 static TypeId GetTypeId();
120
122
123 /**
124 * @brief Copy constructor
125 * @param r the object to copy
126 */
128
129 /**
130 * @brief Add a new measurement to the estimator.
131 * @param measure the new RTT measure.
132 */
133 void Measurement(Time measure) override;
134
135 Ptr<RttEstimator> Copy() const override;
136
137 /**
138 * @brief Resets the estimator.
139 */
140 void Reset() override;
141
142 private:
143 /**
144 * Utility function to check for possible conversion
145 * of a double value (0 < value < 1) to a reciprocal power of two
146 *
147 * Values of 1/32, 1/16, 1/8, 1/4, and 1/2 (i.e., within the possible
148 * range of experimentation for this estimator) are supported.
149 *
150 * @param val value to check
151 * @return log base 2 (1/val) if reciprocal power of 2, or zero if not
152 */
153 uint32_t CheckForReciprocalPowerOfTwo(double val) const;
154 /**
155 * Method to update the rtt and variation estimates using integer
156 * arithmetic, used when the values of Alpha and Beta support the
157 * integer conversion.
158 *
159 * @param m time measurement
160 * @param rttShift value corresponding to log base 2 (1/alpha)
161 * @param variationShift value corresponding to log base 2 (1/beta)
162 */
163 void IntegerUpdate(Time m, uint32_t rttShift, uint32_t variationShift);
164 /**
165 * Method to update the rtt and variation estimates using floating
166 * point arithmetic, used when the values of Alpha and Beta are not
167 * both a reciprocal power of two.
168 *
169 * @param m time measurement
170 */
172 double m_alpha; //!< Filter gain for average
173 double m_beta; //!< Filter gain for variation
174};
175
176} // namespace ns3
177
178#endif /* RTT_ESTIMATOR_H */
Object()
Constructor.
Definition object.cc:96
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
Time m_initialEstimatedRtt
Initial RTT estimation.
Time GetEstimate() const
gets the RTT estimate.
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
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
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:96
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.