00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 // 00003 // Copyright (c) 2006 Georgia Tech Research Corporation 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License version 2 as 00007 // published by the Free Software Foundation; 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 // 00018 // Author: Rajib Bhattacharjea<raj.b@gatech.edu> 00019 // 00020 00021 // Georgia Tech Network Simulator - Round Trip Time Estimation Class 00022 // George F. Riley. Georgia Tech, Spring 2002 00023 00024 00025 #ifndef __rtt_estimator_h__ 00026 #define __rtt_estimator_h__ 00027 00028 #include <deque> 00029 #include "sequence-number.h" 00030 #include "ns3/nstime.h" 00031 #include "ns3/object.h" 00032 00033 namespace ns3 { 00034 00035 /** 00036 * \ingroup tcp 00037 * 00038 * \brief Implements several variations of round trip time estimators 00039 */ 00040 class RttHistory { 00041 public: 00042 RttHistory (SequenceNumber s, uint32_t c, Time t); 00043 RttHistory (const RttHistory& h); // Copy constructor 00044 public: 00045 SequenceNumber seq; // First sequence number in packet sent 00046 uint32_t count; // Number of bytes sent 00047 Time time; // Time this one was sent 00048 bool retx; // True if this has been retransmitted 00049 }; 00050 00051 typedef std::deque<RttHistory> RttHistory_t; 00052 00053 class RttEstimator : public Object { // Base class for all RTT Estimators 00054 public: 00055 static TypeId GetTypeId (void); 00056 00057 RttEstimator(); 00058 RttEstimator(const RttEstimator&); // Copy constructor 00059 virtual ~RttEstimator(); 00060 00061 virtual void SentSeq(SequenceNumber, uint32_t); 00062 virtual Time AckSeq(SequenceNumber); 00063 virtual void ClearSent(); 00064 virtual void Measurement(Time t) = 0; 00065 virtual Time Estimate() = 0; 00066 virtual Time RetransmitTimeout() = 0; 00067 void Init(SequenceNumber s) { next = s;} 00068 virtual Ptr<RttEstimator> Copy() const = 0; 00069 virtual void IncreaseMultiplier(); 00070 virtual void ResetMultiplier(); 00071 virtual void Reset(); 00072 00073 private: 00074 SequenceNumber next; // Next expected sequence to be sent 00075 RttHistory_t history; // List of sent packet 00076 double m_maxMultiplier; 00077 public: 00078 Time est; // Current estimate 00079 Time minrto; // minimum value of the timeout 00080 uint32_t nSamples;// Number of samples 00081 double multiplier; // RTO Multiplier 00082 }; 00083 00084 // The "Mean-Deviation" estimator, as discussed by Van Jacobson 00085 // "Congestion Avoidance and Control", SIGCOMM 88, Appendix A 00086 00087 //Doc:Class Class {\tt RttMeanDeviation} implements the "Mean--Deviation" estimator 00088 //Doc:Class as described by Van Jacobson 00089 //Doc:Class "Congestion Avoidance and Control", SIGCOMM 88, Appendix A 00090 class RttMeanDeviation : public RttEstimator { 00091 public : 00092 static TypeId GetTypeId (void); 00093 00094 RttMeanDeviation (); 00095 00096 00097 //Doc:Method 00098 RttMeanDeviation (const RttMeanDeviation&); // Copy constructor 00099 //Doc:Desc Copy constructor. 00100 //Doc:Arg1 {\tt RttMeanDeviation} object to copy. 00101 00102 void Measurement (Time); 00103 Time Estimate () { return est;} 00104 Time Variance () { return variance;} 00105 Time RetransmitTimeout (); 00106 Ptr<RttEstimator> Copy () const; 00107 void Reset (); 00108 void Gain (double g) { gain = g;} 00109 00110 public: 00111 double gain; // Filter gain 00112 Time variance; // Current variance 00113 }; 00114 }//namespace ns3 00115 #endif 00116 00117 00118