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

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

Issue 1037643002: Land Recent QUIC Changes until 03/22/2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: deleted duplicated using statements in net/tools/quic/test_tools/quic_test_utils.cc Created 5 years, 9 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
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 71 }
72 if (using_pacing) { 72 if (using_pacing) {
73 // Disable the ack train mode in hystart when pacing is enabled, since it 73 // Disable the ack train mode in hystart when pacing is enabled, since it
74 // may be falsely triggered. 74 // may be falsely triggered.
75 hybrid_slow_start_.set_ack_train_detection(false); 75 hybrid_slow_start_.set_ack_train_detection(false);
76 } 76 }
77 } 77 }
78 } 78 }
79 79
80 bool TcpCubicSender::ResumeConnectionState( 80 bool TcpCubicSender::ResumeConnectionState(
81 const CachedNetworkParameters& cached_network_params) { 81 const CachedNetworkParameters& cached_network_params,
82 bool max_bandwidth_resumption) {
82 // If the previous bandwidth estimate is less than an hour old, store in 83 // If the previous bandwidth estimate is less than an hour old, store in
83 // preparation for doing bandwidth resumption. 84 // preparation for doing bandwidth resumption.
84 int64 seconds_since_estimate = 85 int64 seconds_since_estimate =
85 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp(); 86 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp();
86 if (seconds_since_estimate > kNumSecondsPerHour) { 87 if (seconds_since_estimate > kNumSecondsPerHour) {
87 return false; 88 return false;
88 } 89 }
89 90
90 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( 91 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond(
91 cached_network_params.bandwidth_estimate_bytes_per_second()); 92 max_bandwidth_resumption
93 ? cached_network_params.max_bandwidth_estimate_bytes_per_second()
94 : cached_network_params.bandwidth_estimate_bytes_per_second());
92 QuicTime::Delta rtt_ms = 95 QuicTime::Delta rtt_ms =
93 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); 96 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms());
94 97
95 // Make sure CWND is in appropriate range (in case of bad data). 98 // Make sure CWND is in appropriate range (in case of bad data).
96 QuicPacketCount new_congestion_window = 99 QuicPacketCount new_congestion_window =
97 bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize; 100 bandwidth.ToBytesPerPeriod(rtt_ms) / kMaxPacketSize;
98 congestion_window_ = max(min(new_congestion_window, kMaxTcpCongestionWindow), 101 congestion_window_ = max(min(new_congestion_window, kMaxTcpCongestionWindow),
99 kMinCongestionWindowForBandwidthResumption); 102 kMinCongestionWindowForBandwidthResumption);
100 103
101 // TODO(rjshade): Set appropriate CWND when previous connection was in slow 104 // TODO(rjshade): Set appropriate CWND when previous connection was in slow
102 // start at time of estimate. 105 // start at time of estimate.
103 return true; 106 return true;
104 } 107 }
105 108
106 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) { 109 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) {
107 num_connections_ = max(1, num_connections); 110 num_connections_ = max(1, num_connections);
108 cubic_.SetNumConnections(num_connections_); 111 cubic_.SetNumConnections(num_connections_);
109 } 112 }
110 113
114 void TcpCubicSender::SetMaxCongestionWindow(
115 QuicByteCount max_congestion_window) {
116 max_tcp_congestion_window_ = max_congestion_window / kMaxPacketSize;
117 }
118
111 float TcpCubicSender::RenoBeta() const { 119 float TcpCubicSender::RenoBeta() const {
112 // kNConnectionBeta is the backoff factor after loss for our N-connection 120 // kNConnectionBeta is the backoff factor after loss for our N-connection
113 // emulation, which emulates the effective backoff of an ensemble of N 121 // emulation, which emulates the effective backoff of an ensemble of N
114 // TCP-Reno connections on a single loss event. The effective multiplier is 122 // TCP-Reno connections on a single loss event. The effective multiplier is
115 // computed as: 123 // computed as:
116 return (num_connections_ - 1 + kRenoBeta) / num_connections_; 124 return (num_connections_ - 1 + kRenoBeta) / num_connections_;
117 } 125 }
118 126
119 void TcpCubicSender::OnCongestionEvent( 127 void TcpCubicSender::OnCongestionEvent(
120 bool rtt_updated, 128 bool rtt_updated,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 congestion_window_count_ = 0; 198 congestion_window_count_ = 0;
191 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ 199 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_
192 << " slowstart threshold: " << slowstart_threshold_; 200 << " slowstart threshold: " << slowstart_threshold_;
193 } 201 }
194 202
195 bool TcpCubicSender::OnPacketSent(QuicTime /*sent_time*/, 203 bool TcpCubicSender::OnPacketSent(QuicTime /*sent_time*/,
196 QuicByteCount /*bytes_in_flight*/, 204 QuicByteCount /*bytes_in_flight*/,
197 QuicPacketSequenceNumber sequence_number, 205 QuicPacketSequenceNumber sequence_number,
198 QuicByteCount bytes, 206 QuicByteCount bytes,
199 HasRetransmittableData is_retransmittable) { 207 HasRetransmittableData is_retransmittable) {
208 if (InSlowStart()) {
209 ++(stats_->slowstart_packets_sent);
210 }
211
200 // Only update bytes_in_flight_ for data packets. 212 // Only update bytes_in_flight_ for data packets.
201 if (is_retransmittable != HAS_RETRANSMITTABLE_DATA) { 213 if (is_retransmittable != HAS_RETRANSMITTABLE_DATA) {
202 return false; 214 return false;
203 } 215 }
204 if (InRecovery()) { 216 if (InRecovery()) {
205 // PRR is used when in recovery. 217 // PRR is used when in recovery.
206 prr_.OnPacketSent(bytes); 218 prr_.OnPacketSent(bytes);
207 } 219 }
208 DCHECK_LT(largest_sent_sequence_number_, sequence_number); 220 DCHECK_LT(largest_sent_sequence_number_, sequence_number);
209 largest_sent_sequence_number_ = sequence_number; 221 largest_sent_sequence_number_ = sequence_number;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 hybrid_slow_start_.Restart(); 364 hybrid_slow_start_.Restart();
353 slowstart_threshold_ = congestion_window_ / 2; 365 slowstart_threshold_ = congestion_window_ / 2;
354 congestion_window_ = min_congestion_window_; 366 congestion_window_ = min_congestion_window_;
355 } 367 }
356 368
357 CongestionControlType TcpCubicSender::GetCongestionControlType() const { 369 CongestionControlType TcpCubicSender::GetCongestionControlType() const {
358 return reno_ ? kReno : kCubic; 370 return reno_ ? kReno : kCubic;
359 } 371 }
360 372
361 } // namespace net 373 } // 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