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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 max(mean_deviation_, | 46 max(mean_deviation_, |
47 QuicTime::Delta::FromMicroseconds( | 47 QuicTime::Delta::FromMicroseconds( |
48 std::abs(smoothed_rtt_.Subtract(latest_rtt_).ToMicroseconds()))); | 48 std::abs(smoothed_rtt_.Subtract(latest_rtt_).ToMicroseconds()))); |
49 smoothed_rtt_ = max(smoothed_rtt_, latest_rtt_); | 49 smoothed_rtt_ = max(smoothed_rtt_, latest_rtt_); |
50 } | 50 } |
51 | 51 |
52 // Updates the RTT based on a new sample. | 52 // Updates the RTT based on a new sample. |
53 void RttStats::UpdateRtt(QuicTime::Delta send_delta, | 53 void RttStats::UpdateRtt(QuicTime::Delta send_delta, |
54 QuicTime::Delta ack_delay, | 54 QuicTime::Delta ack_delay, |
55 QuicTime now) { | 55 QuicTime now) { |
56 if (send_delta.IsInfinite() || send_delta.IsZero()) { | 56 if (send_delta.IsInfinite() || send_delta <= QuicTime::Delta::Zero()) { |
57 DVLOG(1) << "Ignoring measured send_delta, because it's " | 57 LOG(WARNING) << "Ignoring measured send_delta, because it's is " |
58 << (send_delta.IsZero() ? "Zero" : "Infinite"); | 58 << "either infinite, zero, or negative. send_delta = " |
| 59 << send_delta.ToMicroseconds(); |
59 return; | 60 return; |
60 } | 61 } |
61 | 62 |
62 // Update min_rtt_ first. min_rtt_ does not use an rtt_sample corrected for | 63 // Update min_rtt_ first. min_rtt_ does not use an rtt_sample corrected for |
63 // ack_delay but the raw observed send_delta, since poor clock granularity at | 64 // ack_delay but the raw observed send_delta, since poor clock granularity at |
64 // the client may cause a high ack_delay to result in underestimation of the | 65 // the client may cause a high ack_delay to result in underestimation of the |
65 // min_rtt_. | 66 // min_rtt_. |
66 if (min_rtt_.IsZero() || min_rtt_ > send_delta) { | 67 if (min_rtt_.IsZero() || min_rtt_ > send_delta) { |
67 min_rtt_ = send_delta; | 68 min_rtt_ = send_delta; |
68 } | 69 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 139 } |
139 | 140 |
140 QuicTime::Delta RttStats::MinRtt() const { | 141 QuicTime::Delta RttStats::MinRtt() const { |
141 if (!HasUpdates()) { | 142 if (!HasUpdates()) { |
142 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); | 143 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); |
143 } | 144 } |
144 return min_rtt_; | 145 return min_rtt_; |
145 } | 146 } |
146 | 147 |
147 } // namespace net | 148 } // namespace net |
OLD | NEW |