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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tcp_cubic_sender.h" 5 #include "net/quic/congestion_control/tcp_cubic_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "net/quic/congestion_control/prr_sender.h" 10 #include "net/quic/congestion_control/prr_sender.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 congestion_window_ = 10; 65 congestion_window_ = 10;
66 } 66 }
67 if (using_pacing) { 67 if (using_pacing) {
68 // Disable the ack train mode in hystart when pacing is enabled, since it 68 // Disable the ack train mode in hystart when pacing is enabled, since it
69 // may be falsely triggered. 69 // may be falsely triggered.
70 hybrid_slow_start_.set_ack_train_detection(false); 70 hybrid_slow_start_.set_ack_train_detection(false);
71 } 71 }
72 } 72 }
73 } 73 }
74 74
75 void TcpCubicSender::ResumeConnectionState( 75 bool TcpCubicSender::ResumeConnectionState(
76 const CachedNetworkParameters& cached_network_params) { 76 const CachedNetworkParameters& cached_network_params) {
77 // If the previous bandwidth estimate is less than an hour old, store in 77 // If the previous bandwidth estimate is less than an hour old, store in
78 // preparation for doing bandwidth resumption. 78 // preparation for doing bandwidth resumption.
79 int64 seconds_since_estimate = 79 int64 seconds_since_estimate =
80 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp(); 80 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp();
81 if (seconds_since_estimate > kNumSecondsPerHour) { 81 if (seconds_since_estimate > kNumSecondsPerHour) {
82 return; 82 return false;
83 } 83 }
84 84
85 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( 85 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond(
86 cached_network_params.bandwidth_estimate_bytes_per_second()); 86 cached_network_params.bandwidth_estimate_bytes_per_second());
87 QuicTime::Delta rtt_ms = 87 QuicTime::Delta rtt_ms =
88 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); 88 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms());
89 congestion_window_ = bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize; 89
90 // Make sure CWND is in appropriate range (in case of bad data).
91 QuicPacketCount new_congestion_window =
92 bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize;
93 congestion_window_ = max(min(new_congestion_window, kMaxTcpCongestionWindow),
94 kMinCongestionWindowForBandwidthResumption);
90 95
91 // TODO(rjshade): Set appropriate CWND when previous connection was in slow 96 // TODO(rjshade): Set appropriate CWND when previous connection was in slow
92 // start at time of estimate. 97 // start at time of estimate.
98 return true;
93 } 99 }
94 100
95 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) { 101 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) {
96 num_connections_ = max(1, num_connections); 102 num_connections_ = max(1, num_connections);
97 cubic_.SetNumConnections(num_connections_); 103 cubic_.SetNumConnections(num_connections_);
98 } 104 }
99 105
100 float TcpCubicSender::RenoBeta() const { 106 float TcpCubicSender::RenoBeta() const {
101 // kNConnectionBeta is the backoff factor after loss for our N-connection 107 // kNConnectionBeta is the backoff factor after loss for our N-connection
102 // emulation, which emulates the effective backoff of an ensemble of N 108 // emulation, which emulates the effective backoff of an ensemble of N
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 congestion_window_ = previous_congestion_window_; 359 congestion_window_ = previous_congestion_window_;
354 slowstart_threshold_ = previous_slowstart_threshold_; 360 slowstart_threshold_ = previous_slowstart_threshold_;
355 previous_congestion_window_ = 0; 361 previous_congestion_window_ = 0;
356 } 362 }
357 363
358 CongestionControlType TcpCubicSender::GetCongestionControlType() const { 364 CongestionControlType TcpCubicSender::GetCongestionControlType() const {
359 return reno_ ? kReno : kCubic; 365 return reno_ ? kReno : kCubic;
360 } 366 }
361 367
362 } // namespace net 368 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.h ('k') | net/quic/congestion_control/tcp_cubic_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698