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 // Implements several variations of round trip time estimators |
|
25 |
|
26 #ifndef __rtt_estimator_h__ |
|
27 #define __rtt_estimator_h__ |
|
28 |
|
29 #include <deque> |
|
30 #include "sequence-number.h" |
|
31 #include "ns3/nstime.h" |
|
32 #include "ns3/object.h" |
|
33 |
|
34 namespace ns3 { |
|
35 |
|
36 class RttHistory { |
|
37 public: |
|
38 RttHistory (SequenceNumber s, uint32_t c, Time t); |
|
39 RttHistory (const RttHistory& h); // Copy constructor |
|
40 public: |
|
41 SequenceNumber seq; // First sequence number in packet sent |
|
42 uint32_t count; // Number of bytes sent |
|
43 Time time; // Time this one was sent |
|
44 bool retx; // True if this has been retransmitted |
|
45 }; |
|
46 |
|
47 typedef std::deque<RttHistory> RttHistory_t; |
|
48 |
|
49 class RttEstimator : public Object { // Base class for all RTT Estimators |
|
50 public: |
|
51 static TypeId GetTypeId (void); |
|
52 |
|
53 RttEstimator(); |
|
54 RttEstimator(const RttEstimator&); // Copy constructor |
|
55 virtual ~RttEstimator(); |
|
56 |
|
57 virtual void SentSeq(SequenceNumber, uint32_t); |
|
58 virtual Time AckSeq(SequenceNumber); |
|
59 virtual void ClearSent(); |
|
60 virtual void Measurement(Time t) = 0; |
|
61 virtual Time Estimate() = 0; |
|
62 virtual Time RetransmitTimeout() = 0; |
|
63 void Init(SequenceNumber s) { next = s;} |
|
64 virtual Ptr<RttEstimator> Copy() const = 0; |
|
65 virtual void IncreaseMultiplier(); |
|
66 virtual void ResetMultiplier(); |
|
67 virtual void Reset(); |
|
68 |
|
69 private: |
|
70 SequenceNumber next; // Next expected sequence to be sent |
|
71 RttHistory_t history; // List of sent packet |
|
72 double m_maxMultiplier; |
|
73 public: |
|
74 Time est; // Current estimate |
|
75 uint32_t nSamples;// Number of samples |
|
76 double multiplier; // RTO Multiplier |
|
77 }; |
|
78 |
|
79 // The "Mean-Deviation" estimator, as discussed by Van Jacobson |
|
80 // "Congestion Avoidance and Control", SIGCOMM 88, Appendix A |
|
81 |
|
82 //Doc:Class Class {\tt RttMeanDeviation} implements the "Mean--Deviation" estimator |
|
83 //Doc:Class as described by Van Jacobson |
|
84 //Doc:Class "Congestion Avoidance and Control", SIGCOMM 88, Appendix A |
|
85 class RttMeanDeviation : public RttEstimator { |
|
86 public : |
|
87 static TypeId GetTypeId (void); |
|
88 |
|
89 RttMeanDeviation (); |
|
90 |
|
91 |
|
92 //Doc:Method |
|
93 RttMeanDeviation (const RttMeanDeviation&); // Copy constructor |
|
94 //Doc:Desc Copy constructor. |
|
95 //Doc:Arg1 {\tt RttMeanDeviation} object to copy. |
|
96 |
|
97 void Measurement (Time); |
|
98 Time Estimate () { return est;} |
|
99 Time Variance () { return variance;} |
|
100 Time RetransmitTimeout (); |
|
101 Ptr<RttEstimator> Copy () const; |
|
102 void Reset (); |
|
103 void Gain (double g) { gain = g;} |
|
104 |
|
105 public: |
|
106 double gain; // Filter gain |
|
107 Time variance; // Current variance |
|
108 }; |
|
109 }//namespace ns3 |
|
110 #endif |
|
111 |
|
112 |
|
113 |
|