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 TypeId GetInstanceTypeId() const override;
50
51 /**
52 * @brief Add a new measurement to the estimator. Pure virtual function.
53 * @param t the new RTT measure.
54 */
55 virtual void Measurement(Time t) = 0;
56
57 /**
58 * @brief Copy object (including current internal state)
59 * @returns a copy of itself
60 */
61 virtual Ptr<RttEstimator> Copy() const = 0;
62
63 /**
64 * @brief Resets the estimation to its initial state.
65 */
66 virtual void Reset();
67
68 /**
69 * @brief gets the RTT estimate.
70 * @return The RTT estimate.
71 */
72 Time GetEstimate() const;
73
74 /**
75 * Note that this is not a formal statistical variance; it has the
76 * the same units as the estimate. Mean deviation or standard deviation
77 * are example quantities that could be provided here.
78 *
79 * @brief gets the RTT estimate variation.
80 * @return The RTT estimate variation.
81 */
82 Time GetVariation() const;
83
84 /**
85 * @brief gets the number of samples used in the estimates
86 * @return the number of samples used in the estimates
87 */
88 uint32_t GetNSamples() const;
89
90 private:
91 Time m_initialEstimatedRtt; //!< Initial RTT estimation
92
93 protected:
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 TypeId GetInstanceTypeId() const override;
130
131 /**
132 * @brief Add a new measurement to the estimator.
133 * @param measure the new RTT measure.
134 */
135 void Measurement(Time measure) override;
136
137 Ptr<RttEstimator> Copy() const override;
138
139 /**
140 * @brief Resets the estimator.
141 */
142 void Reset() override;
143
144 private:
145 /**
146 * Utility function to check for possible conversion
147 * of a double value (0 < value < 1) to a reciprocal power of two
148 *
149 * Values of 1/32, 1/16, 1/8, 1/4, and 1/2 (i.e., within the possible
150 * range of experimentation for this estimator) are supported.
151 *
152 * @param val value to check
153 * @return log base 2 (1/val) if reciprocal power of 2, or zero if not
154 */
155 uint32_t CheckForReciprocalPowerOfTwo(double val) const;
156 /**
157 * Method to update the rtt and variation estimates using integer
158 * arithmetic, used when the values of Alpha and Beta support the
159 * integer conversion.
160 *
161 * @param m time measurement
162 * @param rttShift value corresponding to log base 2 (1/alpha)
163 * @param variationShift value corresponding to log base 2 (1/beta)
164 */
165 void IntegerUpdate(Time m, uint32_t rttShift, uint32_t variationShift);
166 /**
167 * Method to update the rtt and variation estimates using floating
168 * point arithmetic, used when the values of Alpha and Beta are not
169 * both a reciprocal power of two.
170 *
171 * @param m time measurement
172 */
174 double m_alpha; //!< Filter gain for average
175 double m_beta; //!< Filter gain for variation
176};
177
178} // namespace ns3
179
180#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.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
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.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
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:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.