| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 const QuicClock* clock, | 29 const QuicClock* clock, |
| 30 const RttStats* rtt_stats, | 30 const RttStats* rtt_stats, |
| 31 bool reno, | 31 bool reno, |
| 32 QuicTcpCongestionWindow max_tcp_congestion_window, | 32 QuicTcpCongestionWindow max_tcp_congestion_window, |
| 33 QuicConnectionStats* stats) | 33 QuicConnectionStats* stats) |
| 34 : hybrid_slow_start_(clock), | 34 : hybrid_slow_start_(clock), |
| 35 cubic_(clock, stats), | 35 cubic_(clock, stats), |
| 36 rtt_stats_(rtt_stats), | 36 rtt_stats_(rtt_stats), |
| 37 stats_(stats), | 37 stats_(stats), |
| 38 reno_(reno), | 38 reno_(reno), |
| 39 num_connections_(2), |
| 39 congestion_window_count_(0), | 40 congestion_window_count_(0), |
| 40 receive_window_(kDefaultSocketReceiveBuffer), | 41 receive_window_(kDefaultSocketReceiveBuffer), |
| 41 prr_out_(0), | 42 prr_out_(0), |
| 42 prr_delivered_(0), | 43 prr_delivered_(0), |
| 43 ack_count_since_loss_(0), | 44 ack_count_since_loss_(0), |
| 44 bytes_in_flight_before_loss_(0), | 45 bytes_in_flight_before_loss_(0), |
| 45 largest_sent_sequence_number_(0), | 46 largest_sent_sequence_number_(0), |
| 46 largest_acked_sequence_number_(0), | 47 largest_acked_sequence_number_(0), |
| 47 largest_sent_at_last_cutback_(0), | 48 largest_sent_at_last_cutback_(0), |
| 48 congestion_window_(kInitialCongestionWindow), | 49 congestion_window_(kInitialCongestionWindow), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 congestion_window_ = min(kMaxInitialWindow, | 71 congestion_window_ = min(kMaxInitialWindow, |
| 71 config.ReceivedInitialCongestionWindow()); | 72 config.ReceivedInitialCongestionWindow()); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 if (config.HasReceivedSocketReceiveBuffer()) { | 75 if (config.HasReceivedSocketReceiveBuffer()) { |
| 75 // Set the initial socket receive buffer size in bytes. | 76 // Set the initial socket receive buffer size in bytes. |
| 76 receive_window_ = config.ReceivedSocketReceiveBuffer(); | 77 receive_window_ = config.ReceivedSocketReceiveBuffer(); |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 81 void TcpCubicSender::SetNumEmulatedConnections(int num_connections) { |
| 82 num_connections_ = num_connections; |
| 83 cubic_.SetNumConnections(num_connections); |
| 84 } |
| 85 |
| 80 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( | 86 void TcpCubicSender::OnIncomingQuicCongestionFeedbackFrame( |
| 81 const QuicCongestionFeedbackFrame& feedback, | 87 const QuicCongestionFeedbackFrame& feedback, |
| 82 QuicTime feedback_receive_time) { | 88 QuicTime feedback_receive_time) { |
| 83 if (feedback.type == kTCP) { | 89 if (feedback.type == kTCP) { |
| 84 receive_window_ = feedback.tcp.receive_window; | 90 receive_window_ = feedback.tcp.receive_window; |
| 85 } | 91 } |
| 86 } | 92 } |
| 87 | 93 |
| 88 void TcpCubicSender::OnCongestionEvent( | 94 void TcpCubicSender::OnCongestionEvent( |
| 89 bool rtt_updated, | 95 bool rtt_updated, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 272 } |
| 267 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ | 273 DVLOG(1) << "Slow start; congestion window: " << congestion_window_ |
| 268 << " slowstart threshold: " << slowstart_threshold_; | 274 << " slowstart threshold: " << slowstart_threshold_; |
| 269 return; | 275 return; |
| 270 } | 276 } |
| 271 if (congestion_window_ >= max_tcp_congestion_window_) { | 277 if (congestion_window_ >= max_tcp_congestion_window_) { |
| 272 return; | 278 return; |
| 273 } | 279 } |
| 274 // Congestion avoidance | 280 // Congestion avoidance |
| 275 if (reno_) { | 281 if (reno_) { |
| 276 // Classic Reno congestion avoidance provided for testing. | 282 // Classic Reno congestion avoidance. |
| 277 | |
| 278 ++congestion_window_count_; | 283 ++congestion_window_count_; |
| 279 if (congestion_window_count_ >= congestion_window_) { | 284 // Divide by num_connections to smoothly increase the CWND at a faster |
| 285 // rate than conventional Reno. |
| 286 if (congestion_window_count_ * num_connections_ >= congestion_window_) { |
| 280 ++congestion_window_; | 287 ++congestion_window_; |
| 281 congestion_window_count_ = 0; | 288 congestion_window_count_ = 0; |
| 282 } | 289 } |
| 283 | 290 |
| 284 DVLOG(1) << "Reno; congestion window: " << congestion_window_ | 291 DVLOG(1) << "Reno; congestion window: " << congestion_window_ |
| 285 << " slowstart threshold: " << slowstart_threshold_ | 292 << " slowstart threshold: " << slowstart_threshold_ |
| 286 << " congestion window count: " << congestion_window_count_; | 293 << " congestion window count: " << congestion_window_count_; |
| 287 } else { | 294 } else { |
| 288 congestion_window_ = min(max_tcp_congestion_window_, | 295 congestion_window_ = min(max_tcp_congestion_window_, |
| 289 cubic_.CongestionWindowAfterAck( | 296 cubic_.CongestionWindowAfterAck( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 return QuicTime::Delta::Zero(); | 361 return QuicTime::Delta::Zero(); |
| 355 } | 362 } |
| 356 return QuicTime::Delta::Infinite(); | 363 return QuicTime::Delta::Infinite(); |
| 357 } | 364 } |
| 358 | 365 |
| 359 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 366 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 360 return reno_ ? kReno : kCubic; | 367 return reno_ ? kReno : kCubic; |
| 361 } | 368 } |
| 362 | 369 |
| 363 } // namespace net | 370 } // namespace net |
| OLD | NEW |