| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A convenience class to store rtt samples and calculate smoothed rtt. | 5 // A convenience class to store rtt samples and calculate smoothed rtt. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ | 7 #ifndef NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
| 8 #define NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ | 8 #define NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Causes the smoothed_rtt to be increased to the latest_rtt if the latest_rtt | 35 // Causes the smoothed_rtt to be increased to the latest_rtt if the latest_rtt |
| 36 // is larger. The mean deviation is increased to the most recent deviation if | 36 // is larger. The mean deviation is increased to the most recent deviation if |
| 37 // it's larger. | 37 // it's larger. |
| 38 void ExpireSmoothedMetrics(); | 38 void ExpireSmoothedMetrics(); |
| 39 | 39 |
| 40 // Forces RttStats to sample a new recent min rtt within the next | 40 // Forces RttStats to sample a new recent min rtt within the next |
| 41 // |num_samples| UpdateRtt calls. | 41 // |num_samples| UpdateRtt calls. |
| 42 void SampleNewRecentMinRtt(uint32 num_samples); | 42 void SampleNewRecentMinRtt(uint32 num_samples); |
| 43 | 43 |
| 44 QuicTime::Delta SmoothedRtt() const; | 44 // Returns the EWMA smoothed RTT for the connection. |
| 45 | 45 // May return Zero if no valid updates have occurred. |
| 46 // Returns the min_rtt for the entire connection if a min has been measured. | 46 QuicTime::Delta smoothed_rtt() const { |
| 47 // This returns an initial non-zero RTT estimate if no measurements have yet | 47 return smoothed_rtt_; |
| 48 // been made. | 48 } |
| 49 QuicTime::Delta MinRtt() const; | |
| 50 | 49 |
| 51 int64 initial_rtt_us() const { | 50 int64 initial_rtt_us() const { |
| 52 return initial_rtt_us_; | 51 return initial_rtt_us_; |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Sets an initial RTT to be used for SmoothedRtt before any RTT updates. | 54 // Sets an initial RTT to be used for SmoothedRtt before any RTT updates. |
| 56 void set_initial_rtt_us(int64 initial_rtt_us) { | 55 void set_initial_rtt_us(int64 initial_rtt_us) { |
| 57 initial_rtt_us_ = initial_rtt_us; | 56 initial_rtt_us_ = initial_rtt_us; |
| 58 } | 57 } |
| 59 | 58 |
| 59 // The most recent rtt measurement. |
| 60 // May return Zero if no valid updates have occurred. |
| 60 QuicTime::Delta latest_rtt() const { | 61 QuicTime::Delta latest_rtt() const { |
| 61 return latest_rtt_; | 62 return latest_rtt_; |
| 62 } | 63 } |
| 63 | 64 |
| 65 // Returns the min_rtt for the entire connection. |
| 66 // May return Zero if no valid updates have occurred. |
| 67 QuicTime::Delta min_rtt() const { |
| 68 return min_rtt_; |
| 69 } |
| 70 |
| 64 // Returns the min_rtt since SampleNewRecentMinRtt has been called, or the | 71 // Returns the min_rtt since SampleNewRecentMinRtt has been called, or the |
| 65 // min_rtt for the entire connection if SampleNewMinRtt was never called. | 72 // min_rtt for the entire connection if SampleNewMinRtt was never called. |
| 66 QuicTime::Delta recent_min_rtt() const { | 73 QuicTime::Delta recent_min_rtt() const { |
| 67 return recent_min_rtt_.rtt; | 74 return recent_min_rtt_.rtt; |
| 68 } | 75 } |
| 69 | 76 |
| 70 QuicTime::Delta mean_deviation() const { | 77 QuicTime::Delta mean_deviation() const { |
| 71 return mean_deviation_; | 78 return mean_deviation_; |
| 72 } | 79 } |
| 73 | 80 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 RttSample recent_min_rtt_; // a in the windowed algorithm. | 115 RttSample recent_min_rtt_; // a in the windowed algorithm. |
| 109 RttSample half_window_rtt_; // b in the sampled algorithm. | 116 RttSample half_window_rtt_; // b in the sampled algorithm. |
| 110 RttSample quarter_window_rtt_; // c in the sampled algorithm. | 117 RttSample quarter_window_rtt_; // c in the sampled algorithm. |
| 111 | 118 |
| 112 DISALLOW_COPY_AND_ASSIGN(RttStats); | 119 DISALLOW_COPY_AND_ASSIGN(RttStats); |
| 113 }; | 120 }; |
| 114 | 121 |
| 115 } // namespace net | 122 } // namespace net |
| 116 | 123 |
| 117 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ | 124 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
| OLD | NEW |