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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/rtt_stats.h" 10 #include "net/quic/congestion_control/rtt_stats.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_); 56 UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_);
57 } 57 }
58 58
59 bool TcpCubicSender::InSlowStart() const { 59 bool TcpCubicSender::InSlowStart() const {
60 return congestion_window_ < slowstart_threshold_; 60 return congestion_window_ < slowstart_threshold_;
61 } 61 }
62 62
63 void TcpCubicSender::SetFromConfig(const QuicConfig& config, bool is_server) { 63 void TcpCubicSender::SetFromConfig(const QuicConfig& config, bool is_server) {
64 if (is_server && config.HasReceivedInitialCongestionWindow()) { 64 if (is_server && config.HasReceivedInitialCongestionWindow()) {
65 // Set the initial window size. 65 // Set the initial window size.
66 congestion_window_ = min(kMaxInitialWindow, 66 congestion_window_ =
67 config.ReceivedInitialCongestionWindow()); 67 min(kMaxInitialWindow, config.ReceivedInitialCongestionWindow());
68 } 68 }
69 } 69 }
70 70
71 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( 71 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame(
72 const QuicCongestionFeedbackFrame& feedback, 72 const QuicCongestionFeedbackFrame& feedback,
73 QuicTime feedback_receive_time) { 73 QuicTime feedback_receive_time) {
74 receive_window_ = feedback.tcp.receive_window; 74 receive_window_ = feedback.tcp.receive_window;
75 } 75 }
76 76
77 void TcpCubicSender::OnPacketAcked( 77 void TcpCubicSender::OnPacketAcked(
78 QuicPacketSequenceNumber acked_sequence_number, QuicByteCount acked_bytes) { 78 QuicPacketSequenceNumber acked_sequence_number,
79 QuicByteCount acked_bytes) {
79 DCHECK_GE(bytes_in_flight_, acked_bytes); 80 DCHECK_GE(bytes_in_flight_, acked_bytes);
80 bytes_in_flight_ -= acked_bytes; 81 bytes_in_flight_ -= acked_bytes;
81 largest_acked_sequence_number_ = max(acked_sequence_number, 82 largest_acked_sequence_number_ =
82 largest_acked_sequence_number_); 83 max(acked_sequence_number, largest_acked_sequence_number_);
83 if (InRecovery()) { 84 if (InRecovery()) {
84 PrrOnPacketAcked(acked_bytes); 85 PrrOnPacketAcked(acked_bytes);
85 return; 86 return;
86 } 87 }
87 MaybeIncreaseCwnd(acked_sequence_number); 88 MaybeIncreaseCwnd(acked_sequence_number);
88 // TODO(ianswett): Should this even be called when not in slow start? 89 // TODO(ianswett): Should this even be called when not in slow start?
89 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart()); 90 hybrid_slow_start_.OnPacketAcked(acked_sequence_number, InSlowStart());
90 } 91 }
91 92
92 void TcpCubicSender::OnPacketLost(QuicPacketSequenceNumber sequence_number, 93 void TcpCubicSender::OnPacketLost(QuicPacketSequenceNumber sequence_number,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return QuicTime::Delta::FromMicroseconds( 199 return QuicTime::Delta::FromMicroseconds(
199 rtt_stats_->SmoothedRtt().ToMicroseconds() + 200 rtt_stats_->SmoothedRtt().ToMicroseconds() +
200 4 * rtt_stats_->mean_deviation().ToMicroseconds()); 201 4 * rtt_stats_->mean_deviation().ToMicroseconds());
201 } 202 }
202 203
203 QuicByteCount TcpCubicSender::GetCongestionWindow() const { 204 QuicByteCount TcpCubicSender::GetCongestionWindow() const {
204 return congestion_window_ * kMaxSegmentSize; 205 return congestion_window_ * kMaxSegmentSize;
205 } 206 }
206 207
207 bool TcpCubicSender::IsCwndLimited() const { 208 bool TcpCubicSender::IsCwndLimited() const {
208 const QuicByteCount congestion_window_bytes = congestion_window_ * 209 const QuicByteCount congestion_window_bytes =
209 kMaxSegmentSize; 210 congestion_window_ * kMaxSegmentSize;
210 if (bytes_in_flight_ >= congestion_window_bytes) { 211 if (bytes_in_flight_ >= congestion_window_bytes) {
211 return true; 212 return true;
212 } 213 }
213 const QuicByteCount tcp_max_burst = kMaxBurstLength * kMaxSegmentSize; 214 const QuicByteCount tcp_max_burst = kMaxBurstLength * kMaxSegmentSize;
214 const QuicByteCount left = congestion_window_bytes - bytes_in_flight_; 215 const QuicByteCount left = congestion_window_bytes - bytes_in_flight_;
215 return left <= tcp_max_burst; 216 return left <= tcp_max_burst;
216 } 217 }
217 218
218 bool TcpCubicSender::InRecovery() const { 219 bool TcpCubicSender::InRecovery() const {
219 return largest_acked_sequence_number_ <= largest_sent_at_last_cutback_ && 220 return largest_acked_sequence_number_ <= largest_sent_at_last_cutback_ &&
220 largest_acked_sequence_number_ != 0; 221 largest_acked_sequence_number_ != 0;
221 } 222 }
222 223
223 // Called when we receive an ack. Normal TCP tracks how many packets one ack 224 // Called when we receive an ack. Normal TCP tracks how many packets one ack
224 // represents, but quic has a separate ack for each packet. 225 // represents, but quic has a separate ack for each packet.
225 void TcpCubicSender::MaybeIncreaseCwnd( 226 void TcpCubicSender::MaybeIncreaseCwnd(
226 QuicPacketSequenceNumber acked_sequence_number) { 227 QuicPacketSequenceNumber acked_sequence_number) {
227 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery."; 228 LOG_IF(DFATAL, InRecovery()) << "Never increase the CWND during recovery.";
228 if (!IsCwndLimited()) { 229 if (!IsCwndLimited()) {
229 // We don't update the congestion window unless we are close to using the 230 // We don't update the congestion window unless we are close to using the
230 // window we have available. 231 // window we have available.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 congestion_window_ = kMinimumCongestionWindow; 275 congestion_window_ = kMinimumCongestionWindow;
275 } 276 }
276 } 277 }
277 278
278 void TcpCubicSender::OnRttUpdated( 279 void TcpCubicSender::OnRttUpdated(
279 QuicPacketSequenceNumber /*largest_observed*/) { 280 QuicPacketSequenceNumber /*largest_observed*/) {
280 if (InSlowStart() && 281 if (InSlowStart() &&
281 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(), 282 hybrid_slow_start_.ShouldExitSlowStart(rtt_stats_->latest_rtt(),
282 rtt_stats_->min_rtt(), 283 rtt_stats_->min_rtt(),
283 congestion_window_)) { 284 congestion_window_)) {
284 slowstart_threshold_ = congestion_window_; 285 slowstart_threshold_ = congestion_window_;
285 } 286 }
286 } 287 }
287 288
288 void TcpCubicSender::PrrOnPacketLost() { 289 void TcpCubicSender::PrrOnPacketLost() {
289 prr_out_ = 0; 290 prr_out_ = 0;
290 bytes_in_flight_before_loss_ = bytes_in_flight_; 291 bytes_in_flight_before_loss_ = bytes_in_flight_;
291 // Since all losses are triggered by an incoming ack currently, and acks are 292 // Since all losses are triggered by an incoming ack currently, and acks are
292 // registered before losses by the SentPacketManager, initialize the variables 293 // registered before losses by the SentPacketManager, initialize the variables
293 // as though one ack was received directly after the loss. This is too low 294 // as though one ack was received directly after the loss. This is too low
294 // for stretch acks, but we expect missing packets to be immediately acked. 295 // for stretch acks, but we expect missing packets to be immediately acked.
(...skipping 18 matching lines...) Expand all
313 if (prr_delivered_ + ack_count_since_loss_ * kMaxSegmentSize < prr_out_) { 314 if (prr_delivered_ + ack_count_since_loss_ * kMaxSegmentSize < prr_out_) {
314 return QuicTime::Delta::Infinite(); 315 return QuicTime::Delta::Infinite();
315 } 316 }
316 return QuicTime::Delta::Zero(); 317 return QuicTime::Delta::Zero();
317 } 318 }
318 // Implement Proportional Rate Reduction (RFC6937) 319 // Implement Proportional Rate Reduction (RFC6937)
319 // Checks a simplified version of the PRR formula that doesn't use division: 320 // Checks a simplified version of the PRR formula that doesn't use division:
320 // AvailableSendWindow = 321 // AvailableSendWindow =
321 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent 322 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent
322 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > 323 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize >
323 prr_out_ * bytes_in_flight_before_loss_) { 324 prr_out_ * bytes_in_flight_before_loss_) {
324 return QuicTime::Delta::Zero(); 325 return QuicTime::Delta::Zero();
325 } 326 }
326 return QuicTime::Delta::Infinite(); 327 return QuicTime::Delta::Infinite();
327 } 328 }
328 329
329 } // namespace net 330 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698