| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 325 |
| 326 void TcpCubicSender::PrrOnPacketAcked(QuicByteCount acked_bytes) { | 326 void TcpCubicSender::PrrOnPacketAcked(QuicByteCount acked_bytes) { |
| 327 prr_delivered_ += acked_bytes; | 327 prr_delivered_ += acked_bytes; |
| 328 ++ack_count_since_loss_; | 328 ++ack_count_since_loss_; |
| 329 } | 329 } |
| 330 | 330 |
| 331 QuicTime::Delta TcpCubicSender::PrrTimeUntilSend( | 331 QuicTime::Delta TcpCubicSender::PrrTimeUntilSend( |
| 332 QuicByteCount bytes_in_flight) const { | 332 QuicByteCount bytes_in_flight) const { |
| 333 DCHECK(InRecovery()); | 333 DCHECK(InRecovery()); |
| 334 // Return QuicTime::Zero In order to ensure limited transmit always works. | 334 // Return QuicTime::Zero In order to ensure limited transmit always works. |
| 335 if (prr_out_ == 0) { | 335 if (prr_out_ == 0 || bytes_in_flight < kMaxSegmentSize) { |
| 336 return QuicTime::Delta::Zero(); | 336 return QuicTime::Delta::Zero(); |
| 337 } | 337 } |
| 338 if (SendWindow() > bytes_in_flight) { | 338 if (SendWindow() > bytes_in_flight) { |
| 339 // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead | 339 // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead |
| 340 // of sending the entire available window. This prevents burst retransmits | 340 // of sending the entire available window. This prevents burst retransmits |
| 341 // when more packets are lost than the CWND reduction. | 341 // when more packets are lost than the CWND reduction. |
| 342 // limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS | 342 // limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS |
| 343 if (prr_delivered_ + ack_count_since_loss_ * kMaxSegmentSize <= prr_out_) { | 343 if (prr_delivered_ + ack_count_since_loss_ * kMaxSegmentSize <= prr_out_) { |
| 344 return QuicTime::Delta::Infinite(); | 344 return QuicTime::Delta::Infinite(); |
| 345 } | 345 } |
| 346 return QuicTime::Delta::Zero(); | 346 return QuicTime::Delta::Zero(); |
| 347 } | 347 } |
| 348 // Implement Proportional Rate Reduction (RFC6937) | 348 // Implement Proportional Rate Reduction (RFC6937) |
| 349 // Checks a simplified version of the PRR formula that doesn't use division: | 349 // Checks a simplified version of the PRR formula that doesn't use division: |
| 350 // AvailableSendWindow = | 350 // AvailableSendWindow = |
| 351 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 351 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent |
| 352 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > | 352 if (prr_delivered_ * slowstart_threshold_ * kMaxSegmentSize > |
| 353 prr_out_ * bytes_in_flight_before_loss_) { | 353 prr_out_ * bytes_in_flight_before_loss_) { |
| 354 return QuicTime::Delta::Zero(); | 354 return QuicTime::Delta::Zero(); |
| 355 } | 355 } |
| 356 return QuicTime::Delta::Infinite(); | 356 return QuicTime::Delta::Infinite(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 CongestionControlType TcpCubicSender::GetCongestionControlType() const { | 359 CongestionControlType TcpCubicSender::GetCongestionControlType() const { |
| 360 return reno_ ? kReno : kCubic; | 360 return reno_ ? kReno : kCubic; |
| 361 } | 361 } |
| 362 | 362 |
| 363 } // namespace net | 363 } // namespace net |
| OLD | NEW |