| 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 #include "net/quic/congestion_control/rtt_stats.h" | 5 #include "net/quic/congestion_control/rtt_stats.h" |
| 6 | 6 |
| 7 #include <complex> // std::abs | 7 #include <complex> // std::abs |
| 8 | 8 |
| 9 using std::max; | 9 using std::max; |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (send_delta > ack_delay) { | 57 if (send_delta > ack_delay) { |
| 58 rtt_sample = send_delta.Subtract(ack_delay); | 58 rtt_sample = send_delta.Subtract(ack_delay); |
| 59 } else if (!HasUpdates()) { | 59 } else if (!HasUpdates()) { |
| 60 // Even though we received information from the peer suggesting | 60 // Even though we received information from the peer suggesting |
| 61 // an invalid (negative) RTT, we can use the send delta as an | 61 // an invalid (negative) RTT, we can use the send delta as an |
| 62 // approximation until we get a better estimate. | 62 // approximation until we get a better estimate. |
| 63 rtt_sample = send_delta; | 63 rtt_sample = send_delta; |
| 64 } | 64 } |
| 65 | 65 |
| 66 if (rtt_sample.IsInfinite() || rtt_sample.IsZero()) { | 66 if (rtt_sample.IsInfinite() || rtt_sample.IsZero()) { |
| 67 DVLOG(1) << "Ignoring rtt, because it's " | 67 LOG(WARNING) << "Ignoring rtt, because it's " |
| 68 << (rtt_sample.IsZero() ? "Zero" : "Infinite"); | 68 << (rtt_sample.IsZero() ? "Zero" : "Infinite"); |
| 69 return; | 69 return; |
| 70 } | 70 } |
| 71 // RTT can't be negative. | 71 // RTT can't be non-positive. |
| 72 DCHECK_LT(0, rtt_sample.ToMicroseconds()); | 72 DCHECK_LT(0, rtt_sample.ToMicroseconds()); |
| 73 | 73 |
| 74 latest_rtt_ = rtt_sample; | 74 latest_rtt_ = rtt_sample; |
| 75 // First time call or link delay decreases. | 75 // First time call or link delay decreases. |
| 76 if (min_rtt_.IsZero() || min_rtt_ > rtt_sample) { | 76 if (min_rtt_.IsZero() || min_rtt_ > rtt_sample) { |
| 77 min_rtt_ = rtt_sample; | 77 min_rtt_ = rtt_sample; |
| 78 } | 78 } |
| 79 UpdateRecentMinRtt(rtt_sample, now); | 79 UpdateRecentMinRtt(rtt_sample, now); |
| 80 // First time call. | 80 // First time call. |
| 81 if (!HasUpdates()) { | 81 if (!HasUpdates()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 | 133 |
| 134 QuicTime::Delta RttStats::SmoothedRtt() const { | 134 QuicTime::Delta RttStats::SmoothedRtt() const { |
| 135 if (!HasUpdates()) { | 135 if (!HasUpdates()) { |
| 136 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); | 136 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); |
| 137 } | 137 } |
| 138 return smoothed_rtt_; | 138 return smoothed_rtt_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 QuicTime::Delta RttStats::MinRtt() const { |
| 142 if (!HasUpdates()) { |
| 143 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); |
| 144 } |
| 145 return min_rtt_; |
| 146 } |
| 147 |
| 141 } // namespace net | 148 } // namespace net |
| OLD | NEW |