OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // A convenience class to store rtt samples and calculate smoothed rtt. |
| 6 |
| 7 #ifndef NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
| 8 #define NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
| 9 |
| 10 #include <algorithm> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "net/quic/quic_protocol.h" |
| 14 #include "net/quic/quic_time.h" |
| 15 |
| 16 namespace net { |
| 17 |
| 18 class NET_EXPORT_PRIVATE RttStats { |
| 19 public: |
| 20 RttStats(); |
| 21 |
| 22 // Returns true if any RTT measurements have been made. |
| 23 bool HasUpdates() const; |
| 24 |
| 25 // Updates the RTT from an incoming ack which is received |send_delta| after |
| 26 // the packet is sent and the peer reports the ack being delayed |ack_delay|. |
| 27 void UpdateRtt(QuicTime::Delta send_delta, QuicTime::Delta ack_delay); |
| 28 |
| 29 QuicTime::Delta SmoothedRtt() const; |
| 30 |
| 31 // Sets an initial RTT to be used for SmoothedRtt before any RTT updates. |
| 32 void set_initial_rtt_us(int64 initial_rtt_us) { |
| 33 initial_rtt_us_ = initial_rtt_us; |
| 34 } |
| 35 |
| 36 QuicTime::Delta latest_rtt() const { |
| 37 return latest_rtt_; |
| 38 } |
| 39 |
| 40 QuicTime::Delta min_rtt() const { |
| 41 return min_rtt_; |
| 42 } |
| 43 |
| 44 QuicTime::Delta mean_deviation() const { |
| 45 return mean_deviation_; |
| 46 } |
| 47 |
| 48 private: |
| 49 QuicTime::Delta latest_rtt_; |
| 50 QuicTime::Delta min_rtt_; |
| 51 QuicTime::Delta smoothed_rtt_; |
| 52 // Mean RTT deviation during this session. |
| 53 // Approximation of standard deviation, the error is roughly 1.25 times |
| 54 // larger than the standard deviation, for a normally distributed signal. |
| 55 QuicTime::Delta mean_deviation_; |
| 56 int64 initial_rtt_us_; |
| 57 }; |
| 58 |
| 59 } // namespace net |
| 60 |
| 61 #endif // NET_QUIC_CONGESTION_CONTROL_RTT_STATS_H_ |
OLD | NEW |