A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rtt-estimator.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2006 Georgia Tech Research Corporation
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Rajib Bhattacharjea<raj.b@gatech.edu>
19 //
20 
21 // Georgia Tech Network Simulator - Round Trip Time Estimation Class
22 // George F. Riley. Georgia Tech, Spring 2002
23 
24 
25 #ifndef RTT_ESTIMATOR_H
26 #define RTT_ESTIMATOR_H
27 
28 #include <deque>
29 #include "ns3/sequence-number.h"
30 #include "ns3/nstime.h"
31 #include "ns3/object.h"
32 
33 namespace ns3 {
34 
40 class RttHistory {
41 public:
42  RttHistory (SequenceNumber32 s, uint32_t c, Time t);
43  RttHistory (const RttHistory& h); // Copy constructor
44 public:
45  SequenceNumber32 seq; // First sequence number in packet sent
46  uint32_t count; // Number of bytes sent
47  Time time; // Time this one was sent
48  bool retx; // True if this has been retransmitted
49 };
50 
51 typedef std::deque<RttHistory> RttHistory_t;
52 
58 class RttEstimator : public Object {
59 public:
60  static TypeId GetTypeId (void);
61 
62  RttEstimator();
63  RttEstimator (const RttEstimator&);
64 
65  virtual ~RttEstimator();
66 
67  virtual TypeId GetInstanceTypeId (void) const;
68 
74  virtual void SentSeq (SequenceNumber32 seq, uint32_t size);
75 
81  virtual Time AckSeq (SequenceNumber32 ackSeq);
82 
86  virtual void ClearSent ();
87 
92  virtual void Measurement (Time t) = 0;
93 
98  virtual Time RetransmitTimeout () = 0;
99 
100  virtual Ptr<RttEstimator> Copy () const = 0;
101 
105  virtual void IncreaseMultiplier ();
106 
110  virtual void ResetMultiplier ();
111 
115  virtual void Reset ();
116 
121  void SetMinRto (Time minRto);
122 
127  Time GetMinRto (void) const;
128 
133  void SetCurrentEstimate (Time estimate);
134 
139  Time GetCurrentEstimate (void) const;
140 
141 private:
142  SequenceNumber32 m_next; // Next expected sequence to be sent
143  RttHistory_t m_history; // List of sent packet
144  uint16_t m_maxMultiplier;
145  Time m_initialEstimatedRtt;
146 
147 protected:
148  Time m_currentEstimatedRtt; // Current estimate
149  Time m_minRto; // minimum value of the timeout
150  uint32_t m_nSamples; // Number of samples
151  uint16_t m_multiplier; // RTO Multiplier
152 };
153 
165 public:
166  static TypeId GetTypeId (void);
167 
168  RttMeanDeviation ();
169 
171 
172  virtual TypeId GetInstanceTypeId (void) const;
173 
178  void Measurement (Time measure);
179 
185 
186  Ptr<RttEstimator> Copy () const;
187 
191  void Reset ();
192 
197  void Gain (double g);
198 
199 private:
200  double m_gain; // Filter gain
201  Time m_variance; // Current variance
202 };
203 } // namespace ns3
204 
205 #endif /* RTT_ESTIMATOR_H */
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual Time RetransmitTimeout()=0
Returns the estimated RTO. Pure virtual function.
The "Mean--Deviation" RTT estimator, as discussed by Van Jacobson.
virtual TypeId GetInstanceTypeId(void) const
virtual void ResetMultiplier()
Resets the estimation multiplier to 1.
Time GetCurrentEstimate(void) const
gets the current RTT estimate.
Base class for all RTT Estimators.
Definition: rtt-estimator.h:58
virtual void Measurement(Time t)=0
Add a new measurement to the estimator. Pure virtual function.
virtual void SentSeq(SequenceNumber32 seq, uint32_t size)
Note that a particular sequence has been sent.
Time GetMinRto(void) const
Get the Minimum RTO.
Time RetransmitTimeout()
Returns the estimated RTO.
void SetMinRto(Time minRto)
Sets the Minimum RTO.
virtual void Reset()
Resets the estimation to its initial state.
void Reset()
Resets sthe estimator.
virtual void IncreaseMultiplier()
Increase the estimation multiplier up to MaxMultiplier.
void Measurement(Time measure)
Add a new measurement to the estimator.
virtual TypeId GetInstanceTypeId(void) const
Helper class to store RTT measurements.
Definition: rtt-estimator.h:40
void SetCurrentEstimate(Time estimate)
Sets the current RTT estimate (forcefully).
virtual void ClearSent()
Clear all history entries.
void Gain(double g)
Sets the estimator Gain.
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:44
virtual Time AckSeq(SequenceNumber32 ackSeq)
Note that a particular ack sequence has been received.