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// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: Rajib Bhattacharjea<raj.b@gatech.edu>
18//
19
20// Georgia Tech Network Simulator - Round Trip Time Estimation Class
21// George F. Riley. Georgia Tech, Spring 2002
22
23#ifndef RTT_ESTIMATOR_H
24#define RTT_ESTIMATOR_H
25
26#include "ns3/nstime.h"
27#include "ns3/object.h"
28
29namespace ns3
30{
31
32/**
33 * \ingroup tcp
34 *
35 * \brief Base class for all RTT Estimators
36 *
37 * The RTT Estimator class computes an estimate of the round trip time
38 * observed in a series of Time measurements. The estimate is provided in
39 * the form of an estimate and a sample variation. Subclasses can implement
40 * different algorithms to provide values for the estimate and variation.
41 */
42class RttEstimator : public Object
43{
44 public:
45 /**
46 * \brief Get the type ID.
47 * \return the object TypeId
48 */
49 static TypeId GetTypeId();
50
52 /**
53 * \brief Copy constructor
54 * \param r the object to copy
55 */
56 RttEstimator(const RttEstimator& r);
57
58 ~RttEstimator() override;
59
60 TypeId GetInstanceTypeId() const override;
61
62 /**
63 * \brief Add a new measurement to the estimator. Pure virtual function.
64 * \param t the new RTT measure.
65 */
66 virtual void Measurement(Time t) = 0;
67
68 /**
69 * \brief Copy object (including current internal state)
70 * \returns a copy of itself
71 */
72 virtual Ptr<RttEstimator> Copy() const = 0;
73
74 /**
75 * \brief Resets the estimation to its initial state.
76 */
77 virtual void Reset();
78
79 /**
80 * \brief gets the RTT estimate.
81 * \return The RTT estimate.
82 */
83 Time GetEstimate() const;
84
85 /**
86 * Note that this is not a formal statistical variance; it has the
87 * the same units as the estimate. Mean deviation or standard deviation
88 * are example quantities that could be provided here.
89 *
90 * \brief gets the RTT estimate variation.
91 * \return The RTT estimate variation.
92 */
93 Time GetVariation() const;
94
95 /**
96 * \brief gets the number of samples used in the estimates
97 * \return the number of samples used in the estimates
98 */
99 uint32_t GetNSamples() const;
100
101 private:
102 Time m_initialEstimatedRtt; //!< Initial RTT estimation
103
104 protected:
105 Time m_estimatedRtt; //!< Current estimate
106 Time m_estimatedVariation; //!< Current estimate variation
107 uint32_t m_nSamples; //!< Number of samples
108};
109
110/**
111 * \ingroup tcp
112 *
113 * \brief The "Mean--Deviation" RTT estimator, as discussed by Van Jacobson
114 *
115 * This class implements the "Mean--Deviation" RTT estimator, as discussed
116 * by Van Jacobson and Michael J. Karels, in
117 * "Congestion Avoidance and Control", SIGCOMM 88, Appendix A
118 *
119 * The default values for the gain (alpha and beta) are set as documented
120 * in RFC 6298.
121 *
122 */
124{
125 public:
126 /**
127 * \brief Get the type ID.
128 * \return the object TypeId
129 */
130 static TypeId GetTypeId();
131
133
134 /**
135 * \brief Copy constructor
136 * \param r the object to copy
137 */
139
140 TypeId GetInstanceTypeId() const override;
141
142 /**
143 * \brief Add a new measurement to the estimator.
144 * \param measure the new RTT measure.
145 */
146 void Measurement(Time measure) override;
147
148 Ptr<RttEstimator> Copy() const override;
149
150 /**
151 * \brief Resets the estimator.
152 */
153 void Reset() override;
154
155 private:
156 /**
157 * Utility function to check for possible conversion
158 * of a double value (0 < value < 1) to a reciprocal power of two
159 *
160 * Values of 1/32, 1/16, 1/8, 1/4, and 1/2 (i.e., within the possible
161 * range of experimentation for this estimator) are supported.
162 *
163 * \param val value to check
164 * \return log base 2 (1/val) if reciprocal power of 2, or zero if not
165 */
166 uint32_t CheckForReciprocalPowerOfTwo(double val) const;
167 /**
168 * Method to update the rtt and variation estimates using integer
169 * arithmetic, used when the values of Alpha and Beta support the
170 * integer conversion.
171 *
172 * \param m time measurement
173 * \param rttShift value corresponding to log base 2 (1/alpha)
174 * \param variationShift value corresponding to log base 2 (1/beta)
175 */
176 void IntegerUpdate(Time m, uint32_t rttShift, uint32_t variationShift);
177 /**
178 * Method to update the rtt and variation estimates using floating
179 * point arithmetic, used when the values of Alpha and Beta are not
180 * both a reciprocal power of two.
181 *
182 * \param m time measurement
183 */
185 double m_alpha; //!< Filter gain for average
186 double m_beta; //!< Filter gain for variation
187};
188
189} // namespace ns3
190
191#endif /* RTT_ESTIMATOR_H */
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Base class for all RTT Estimators.
Definition: rtt-estimator.h:43
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:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.