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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (rtt_sample > ack_delay) { | 72 if (rtt_sample > ack_delay) { |
73 rtt_sample = rtt_sample.Subtract(ack_delay); | 73 rtt_sample = rtt_sample.Subtract(ack_delay); |
74 } | 74 } |
75 latest_rtt_ = rtt_sample; | 75 latest_rtt_ = rtt_sample; |
76 // First time call. | 76 // First time call. |
77 if (smoothed_rtt_.IsZero()) { | 77 if (smoothed_rtt_.IsZero()) { |
78 smoothed_rtt_ = rtt_sample; | 78 smoothed_rtt_ = rtt_sample; |
79 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 79 mean_deviation_ = QuicTime::Delta::FromMicroseconds( |
80 rtt_sample.ToMicroseconds() / 2); | 80 rtt_sample.ToMicroseconds() / 2); |
81 } else { | 81 } else { |
82 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 82 mean_deviation_ = QuicTime::Delta::FromMicroseconds(static_cast<int64>( |
83 kOneMinusBeta * mean_deviation_.ToMicroseconds() + | 83 kOneMinusBeta * mean_deviation_.ToMicroseconds() + |
84 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds())); | 84 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds()))); |
85 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( | 85 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( |
86 rtt_sample.Multiply(kAlpha)); | 86 rtt_sample.Multiply(kAlpha)); |
87 DVLOG(1) << " smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds() | 87 DVLOG(1) << " smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds() |
88 << " mean_deviation(us):" << mean_deviation_.ToMicroseconds(); | 88 << " mean_deviation(us):" << mean_deviation_.ToMicroseconds(); |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 void RttStats::UpdateRecentMinRtt(QuicTime::Delta rtt_sample, QuicTime now) { | 92 void RttStats::UpdateRecentMinRtt(QuicTime::Delta rtt_sample, QuicTime now) { |
93 // Recent min_rtt update. | 93 // Recent min_rtt update. |
94 if (num_min_rtt_samples_remaining_ > 0) { | 94 if (num_min_rtt_samples_remaining_ > 0) { |
(...skipping 26 matching lines...) Expand all Loading... |
121 now.Subtract(recent_min_rtt_window_.Multiply(kHalfWindow))) { | 121 now.Subtract(recent_min_rtt_window_.Multiply(kHalfWindow))) { |
122 half_window_rtt_ = quarter_window_rtt_; | 122 half_window_rtt_ = quarter_window_rtt_; |
123 quarter_window_rtt_ = RttSample(rtt_sample, now); | 123 quarter_window_rtt_ = RttSample(rtt_sample, now); |
124 } else if (quarter_window_rtt_.time < | 124 } else if (quarter_window_rtt_.time < |
125 now.Subtract(recent_min_rtt_window_.Multiply(kQuarterWindow))) { | 125 now.Subtract(recent_min_rtt_window_.Multiply(kQuarterWindow))) { |
126 quarter_window_rtt_ = RttSample(rtt_sample, now); | 126 quarter_window_rtt_ = RttSample(rtt_sample, now); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 } // namespace net | 130 } // namespace net |
OLD | NEW |