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

Side by Side Diff: net/quic/congestion_control/tcp_cubic_bytes_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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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_bytes_sender.h" 5 #include "net/quic/congestion_control/tcp_cubic_bytes_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "net/quic/congestion_control/prr_sender.h" 9 #include "net/quic/congestion_control/prr_sender.h"
10 #include "net/quic/congestion_control/rtt_stats.h" 10 #include "net/quic/congestion_control/rtt_stats.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 70 }
71 if (using_pacing) { 71 if (using_pacing) {
72 // Disable the ack train mode in hystart when pacing is enabled, since it 72 // Disable the ack train mode in hystart when pacing is enabled, since it
73 // may be falsely triggered. 73 // may be falsely triggered.
74 hybrid_slow_start_.set_ack_train_detection(false); 74 hybrid_slow_start_.set_ack_train_detection(false);
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 bool TcpCubicBytesSender::ResumeConnectionState( 79 bool TcpCubicBytesSender::ResumeConnectionState(
80 const CachedNetworkParameters& cached_network_params) { 80 const CachedNetworkParameters& cached_network_params,
81 bool max_bandwidth_resumption) {
81 // If the previous bandwidth estimate is less than an hour old, store in 82 // If the previous bandwidth estimate is less than an hour old, store in
82 // preparation for doing bandwidth resumption. 83 // preparation for doing bandwidth resumption.
83 int64 seconds_since_estimate = 84 int64 seconds_since_estimate =
84 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp(); 85 clock_->WallNow().ToUNIXSeconds() - cached_network_params.timestamp();
85 if (seconds_since_estimate > kNumSecondsPerHour) { 86 if (seconds_since_estimate > kNumSecondsPerHour) {
86 return false; 87 return false;
87 } 88 }
88 89
89 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond( 90 QuicBandwidth bandwidth = QuicBandwidth::FromBytesPerSecond(
90 cached_network_params.bandwidth_estimate_bytes_per_second()); 91 max_bandwidth_resumption
92 ? cached_network_params.max_bandwidth_estimate_bytes_per_second()
93 : cached_network_params.bandwidth_estimate_bytes_per_second());
91 QuicTime::Delta rtt_ms = 94 QuicTime::Delta rtt_ms =
92 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms()); 95 QuicTime::Delta::FromMilliseconds(cached_network_params.min_rtt_ms());
93 96
94 // Make sure CWND is in appropriate range (in case of bad data). 97 // Make sure CWND is in appropriate range (in case of bad data).
95 QuicByteCount new_congestion_window = bandwidth.ToBytesPerPeriod(rtt_ms); 98 QuicByteCount new_congestion_window = bandwidth.ToBytesPerPeriod(rtt_ms);
96 congestion_window_ = 99 congestion_window_ =
97 max(min(new_congestion_window, kMaxTcpCongestionWindow * kMaxSegmentSize), 100 max(min(new_congestion_window, kMaxTcpCongestionWindow * kMaxSegmentSize),
98 kMinCongestionWindowForBandwidthResumption * kMaxSegmentSize); 101 kMinCongestionWindowForBandwidthResumption * kMaxSegmentSize);
99 102
100 // TODO(rjshade): Set appropriate CWND when previous connection was in slow 103 // TODO(rjshade): Set appropriate CWND when previous connection was in slow
101 // start at time of estimate. 104 // start at time of estimate.
102 return true; 105 return true;
103 } 106 }
104 107
105 void TcpCubicBytesSender::SetNumEmulatedConnections(int num_connections) { 108 void TcpCubicBytesSender::SetNumEmulatedConnections(int num_connections) {
106 num_connections_ = max(1, num_connections); 109 num_connections_ = max(1, num_connections);
107 cubic_.SetNumConnections(num_connections_); 110 cubic_.SetNumConnections(num_connections_);
108 } 111 }
109 112
113 void TcpCubicBytesSender::SetMaxCongestionWindow(
114 QuicByteCount max_congestion_window) {
115 max_congestion_window_ = max_congestion_window;
116 }
117
110 float TcpCubicBytesSender::RenoBeta() const { 118 float TcpCubicBytesSender::RenoBeta() const {
111 // kNConnectionBeta is the backoff factor after loss for our N-connection 119 // kNConnectionBeta is the backoff factor after loss for our N-connection
112 // emulation, which emulates the effective backoff of an ensemble of N 120 // emulation, which emulates the effective backoff of an ensemble of N
113 // TCP-Reno connections on a single loss event. The effective multiplier is 121 // TCP-Reno connections on a single loss event. The effective multiplier is
114 // computed as: 122 // computed as:
115 return (num_connections_ - 1 + kRenoBeta) / num_connections_; 123 return (num_connections_ - 1 + kRenoBeta) / num_connections_;
116 } 124 }
117 125
118 void TcpCubicBytesSender::OnCongestionEvent( 126 void TcpCubicBytesSender::OnCongestionEvent(
119 bool rtt_updated, 127 bool rtt_updated,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_ 198 DVLOG(1) << "Incoming loss; congestion window: " << congestion_window_
191 << " slowstart threshold: " << slowstart_threshold_; 199 << " slowstart threshold: " << slowstart_threshold_;
192 } 200 }
193 201
194 bool TcpCubicBytesSender::OnPacketSent( 202 bool TcpCubicBytesSender::OnPacketSent(
195 QuicTime /*sent_time*/, 203 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 hybrid_slow_start_.Restart(); 359 hybrid_slow_start_.Restart();
348 slowstart_threshold_ = congestion_window_ / 2; 360 slowstart_threshold_ = congestion_window_ / 2;
349 congestion_window_ = min_congestion_window_; 361 congestion_window_ = min_congestion_window_;
350 } 362 }
351 363
352 CongestionControlType TcpCubicBytesSender::GetCongestionControlType() const { 364 CongestionControlType TcpCubicBytesSender::GetCongestionControlType() const {
353 return reno_ ? kRenoBytes : kCubicBytes; 365 return reno_ ? kRenoBytes : kCubicBytes;
354 } 366 }
355 367
356 } // namespace net 368 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_bytes_sender.h ('k') | net/quic/congestion_control/tcp_cubic_bytes_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698