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 using std::max; | 7 using std::max; |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (!HasUpdates()) { | 76 if (!HasUpdates()) { |
77 smoothed_rtt_ = rtt_sample; | 77 smoothed_rtt_ = rtt_sample; |
78 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 78 mean_deviation_ = QuicTime::Delta::FromMicroseconds( |
79 rtt_sample.ToMicroseconds() / 2); | 79 rtt_sample.ToMicroseconds() / 2); |
80 } else { | 80 } else { |
81 mean_deviation_ = QuicTime::Delta::FromMicroseconds( | 81 mean_deviation_ = QuicTime::Delta::FromMicroseconds( |
82 kOneMinusBeta * mean_deviation_.ToMicroseconds() + | 82 kOneMinusBeta * mean_deviation_.ToMicroseconds() + |
83 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds())); | 83 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds())); |
84 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( | 84 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( |
85 rtt_sample.Multiply(kAlpha)); | 85 rtt_sample.Multiply(kAlpha)); |
86 DVLOG(1) << "Cubic; smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds() | 86 DVLOG(1) << " smoothed_rtt(us):" << smoothed_rtt_.ToMicroseconds() |
87 << " mean_deviation(us):" << mean_deviation_.ToMicroseconds(); | 87 << " mean_deviation(us):" << mean_deviation_.ToMicroseconds(); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void RttStats::UpdateRecentMinRtt(QuicTime::Delta rtt_sample, QuicTime now) { | 91 void RttStats::UpdateRecentMinRtt(QuicTime::Delta rtt_sample, QuicTime now) { |
92 // Recent min_rtt update. | 92 // Recent min_rtt update. |
93 if (num_min_rtt_samples_remaining_ > 0) { | 93 if (num_min_rtt_samples_remaining_ > 0) { |
94 --num_min_rtt_samples_remaining_; | 94 --num_min_rtt_samples_remaining_; |
95 if (new_min_rtt_.rtt.IsZero() || rtt_sample <= new_min_rtt_.rtt) { | 95 if (new_min_rtt_.rtt.IsZero() || rtt_sample <= new_min_rtt_.rtt) { |
96 new_min_rtt_ = RttSample(rtt_sample, now); | 96 new_min_rtt_ = RttSample(rtt_sample, now); |
(...skipping 30 matching lines...) Expand all Loading... |
127 } | 127 } |
128 | 128 |
129 QuicTime::Delta RttStats::SmoothedRtt() const { | 129 QuicTime::Delta RttStats::SmoothedRtt() const { |
130 if (!HasUpdates()) { | 130 if (!HasUpdates()) { |
131 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); | 131 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); |
132 } | 132 } |
133 return smoothed_rtt_; | 133 return smoothed_rtt_; |
134 } | 134 } |
135 | 135 |
136 } // namespace net | 136 } // namespace net |
OLD | NEW |