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 | |
8 | |
7 using std::max; | 9 using std::max; |
8 | 10 |
9 namespace net { | 11 namespace net { |
10 | 12 |
11 namespace { | 13 namespace { |
12 | 14 |
13 // Default initial rtt used before any samples are received. | 15 // Default initial rtt used before any samples are received. |
14 const int kInitialRttMs = 100; | 16 const int kInitialRttMs = 100; |
15 const float kAlpha = 0.125f; | 17 const float kAlpha = 0.125f; |
16 const float kOneMinusAlpha = (1 - kAlpha); | 18 const float kOneMinusAlpha = (1 - kAlpha); |
(...skipping 16 matching lines...) Expand all Loading... | |
33 bool RttStats::HasUpdates() const { | 35 bool RttStats::HasUpdates() const { |
34 return !smoothed_rtt_.IsZero(); | 36 return !smoothed_rtt_.IsZero(); |
35 } | 37 } |
36 | 38 |
37 void RttStats::SampleNewRecentMinRtt(uint32 num_samples) { | 39 void RttStats::SampleNewRecentMinRtt(uint32 num_samples) { |
38 num_min_rtt_samples_remaining_ = num_samples; | 40 num_min_rtt_samples_remaining_ = num_samples; |
39 new_min_rtt_ = RttSample(); | 41 new_min_rtt_ = RttSample(); |
40 } | 42 } |
41 | 43 |
42 void RttStats::ExpireSmoothedMetrics() { | 44 void RttStats::ExpireSmoothedMetrics() { |
43 mean_deviation_ = max(mean_deviation_, latest_rtt_.Subtract(smoothed_rtt_)); | 45 mean_deviation_ = |
46 max(mean_deviation_, | |
47 QuicTime::Delta::FromMicroseconds( | |
48 std::abs(smoothed_rtt_.Subtract(latest_rtt_).ToMicroseconds()))); | |
wtc
2014/07/23 23:31:42
Why do we need to convert to microseconds and then
ramant (doing other things)
2014/07/23 23:56:47
Seems like that.
Ian Swett: wdyt?
| |
44 smoothed_rtt_ = max(smoothed_rtt_, latest_rtt_); | 49 smoothed_rtt_ = max(smoothed_rtt_, latest_rtt_); |
45 } | 50 } |
46 | 51 |
47 // Updates the RTT based on a new sample. | 52 // Updates the RTT based on a new sample. |
48 void RttStats::UpdateRtt(QuicTime::Delta send_delta, | 53 void RttStats::UpdateRtt(QuicTime::Delta send_delta, |
49 QuicTime::Delta ack_delay, | 54 QuicTime::Delta ack_delay, |
50 QuicTime now) { | 55 QuicTime now) { |
51 QuicTime::Delta rtt_sample(QuicTime::Delta::Zero()); | 56 QuicTime::Delta rtt_sample(QuicTime::Delta::Zero()); |
52 if (send_delta > ack_delay) { | 57 if (send_delta > ack_delay) { |
53 rtt_sample = send_delta.Subtract(ack_delay); | 58 rtt_sample = send_delta.Subtract(ack_delay); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 } | 132 } |
128 | 133 |
129 QuicTime::Delta RttStats::SmoothedRtt() const { | 134 QuicTime::Delta RttStats::SmoothedRtt() const { |
130 if (!HasUpdates()) { | 135 if (!HasUpdates()) { |
131 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); | 136 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); |
132 } | 137 } |
133 return smoothed_rtt_; | 138 return smoothed_rtt_; |
134 } | 139 } |
135 | 140 |
136 } // namespace net | 141 } // namespace net |
OLD | NEW |