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

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

Issue 411823002: Land Recent QUIC Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months 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
« no previous file with comments | « net/quic/congestion_control/rtt_stats.h ('k') | net/quic/congestion_control/rtt_stats_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
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
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
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
OLDNEW
« no previous file with comments | « net/quic/congestion_control/rtt_stats.h ('k') | net/quic/congestion_control/rtt_stats_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698