Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: net/quic/congestion_control/rtt_stats.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 QuicTime::Delta rtt_sample(QuicTime::Delta::Zero()); 56 if (send_delta.IsInfinite() || send_delta <= QuicTime::Delta::Zero()) {
57 if (send_delta > ack_delay) { 57 LOG(WARNING) << "Ignoring measured send_delta, because it's is "
58 rtt_sample = send_delta.Subtract(ack_delay); 58 << "either infinite, zero, or negative. send_delta = "
59 } else if (!HasUpdates()) { 59 << send_delta.ToMicroseconds();
60 // Even though we received information from the peer suggesting 60 return;
61 // an invalid (negative) RTT, we can use the send delta as an
62 // approximation until we get a better estimate.
63 rtt_sample = send_delta;
64 } 61 }
65 62
66 if (rtt_sample.IsInfinite() || rtt_sample.IsZero()) { 63 // Update min_rtt_ first. min_rtt_ does not use an rtt_sample corrected for
67 DVLOG(1) << "Ignoring rtt, because it's " 64 // ack_delay but the raw observed send_delta, since poor clock granularity at
68 << (rtt_sample.IsZero() ? "Zero" : "Infinite"); 65 // the client may cause a high ack_delay to result in underestimation of the
69 return; 66 // min_rtt_.
67 if (min_rtt_.IsZero() || min_rtt_ > send_delta) {
68 min_rtt_ = send_delta;
70 } 69 }
71 // RTT can't be non-positive. 70 UpdateRecentMinRtt(send_delta, now);
72 DCHECK_LT(0, rtt_sample.ToMicroseconds());
73 71
72 // Correct for ack_delay if information received from the peer results in a
73 // positive RTT sample. Otherwise, we use the send_delta as a reasonable
74 // measure for smoothed_rtt.
75 QuicTime::Delta rtt_sample(send_delta);
76 if (rtt_sample > ack_delay) {
77 rtt_sample = rtt_sample.Subtract(ack_delay);
78 }
74 latest_rtt_ = rtt_sample; 79 latest_rtt_ = rtt_sample;
75 // First time call or link delay decreases.
76 if (min_rtt_.IsZero() || min_rtt_ > rtt_sample) {
77 min_rtt_ = rtt_sample;
78 }
79 UpdateRecentMinRtt(rtt_sample, now);
80 // First time call. 80 // First time call.
81 if (!HasUpdates()) { 81 if (!HasUpdates()) {
82 smoothed_rtt_ = rtt_sample; 82 smoothed_rtt_ = rtt_sample;
83 mean_deviation_ = QuicTime::Delta::FromMicroseconds( 83 mean_deviation_ = QuicTime::Delta::FromMicroseconds(
84 rtt_sample.ToMicroseconds() / 2); 84 rtt_sample.ToMicroseconds() / 2);
85 } else { 85 } else {
86 mean_deviation_ = QuicTime::Delta::FromMicroseconds( 86 mean_deviation_ = QuicTime::Delta::FromMicroseconds(
87 kOneMinusBeta * mean_deviation_.ToMicroseconds() + 87 kOneMinusBeta * mean_deviation_.ToMicroseconds() +
88 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds())); 88 kBeta * std::abs(smoothed_rtt_.Subtract(rtt_sample).ToMicroseconds()));
89 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add( 89 smoothed_rtt_ = smoothed_rtt_.Multiply(kOneMinusAlpha).Add(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 QuicTime::Delta RttStats::MinRtt() const { 141 QuicTime::Delta RttStats::MinRtt() const {
142 if (!HasUpdates()) { 142 if (!HasUpdates()) {
143 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_); 143 return QuicTime::Delta::FromMicroseconds(initial_rtt_us_);
144 } 144 }
145 return min_rtt_; 145 return min_rtt_;
146 } 146 }
147 147
148 } // namespace net 148 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/prr_sender_test.cc ('k') | net/quic/congestion_control/rtt_stats_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698