| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/prr_sender.h" | 5 #include "net/quic/congestion_control/prr_sender.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_protocol.h" | 7 #include "net/quic/quic_protocol.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void PrrSender::OnPacketAcked(QuicByteCount acked_bytes) { | 34 void PrrSender::OnPacketAcked(QuicByteCount acked_bytes) { |
| 35 bytes_delivered_since_loss_ += acked_bytes; | 35 bytes_delivered_since_loss_ += acked_bytes; |
| 36 ++ack_count_since_loss_; | 36 ++ack_count_since_loss_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 QuicTime::Delta PrrSender::TimeUntilSend( | 39 QuicTime::Delta PrrSender::TimeUntilSend( |
| 40 QuicByteCount congestion_window, | 40 QuicByteCount congestion_window, |
| 41 QuicByteCount bytes_in_flight, | 41 QuicByteCount bytes_in_flight, |
| 42 QuicPacketCount slowstart_threshold) const { | 42 QuicByteCount slowstart_threshold) const { |
| 43 // Return QuicTime::Zero In order to ensure limited transmit always works. | 43 // Return QuicTime::Zero In order to ensure limited transmit always works. |
| 44 if (bytes_sent_since_loss_ == 0 || bytes_in_flight < kMaxSegmentSize) { | 44 if (bytes_sent_since_loss_ == 0 || bytes_in_flight < kMaxSegmentSize) { |
| 45 return QuicTime::Delta::Zero(); | 45 return QuicTime::Delta::Zero(); |
| 46 } | 46 } |
| 47 if (congestion_window > bytes_in_flight) { | 47 if (congestion_window > bytes_in_flight) { |
| 48 // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead | 48 // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead |
| 49 // of sending the entire available window. This prevents burst retransmits | 49 // of sending the entire available window. This prevents burst retransmits |
| 50 // when more packets are lost than the CWND reduction. | 50 // when more packets are lost than the CWND reduction. |
| 51 // limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS | 51 // limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS |
| 52 if (bytes_delivered_since_loss_ + ack_count_since_loss_ * kMaxSegmentSize <= | 52 if (bytes_delivered_since_loss_ + ack_count_since_loss_ * kMaxSegmentSize <= |
| 53 bytes_sent_since_loss_) { | 53 bytes_sent_since_loss_) { |
| 54 return QuicTime::Delta::Infinite(); | 54 return QuicTime::Delta::Infinite(); |
| 55 } | 55 } |
| 56 return QuicTime::Delta::Zero(); | 56 return QuicTime::Delta::Zero(); |
| 57 } | 57 } |
| 58 // Implement Proportional Rate Reduction (RFC6937). | 58 // Implement Proportional Rate Reduction (RFC6937). |
| 59 // Checks a simplified version of the PRR formula that doesn't use division: | 59 // Checks a simplified version of the PRR formula that doesn't use division: |
| 60 // AvailableSendWindow = | 60 // AvailableSendWindow = |
| 61 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 61 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent |
| 62 if (bytes_delivered_since_loss_ * slowstart_threshold * kMaxSegmentSize > | 62 if (bytes_delivered_since_loss_ * slowstart_threshold > |
| 63 bytes_sent_since_loss_ * bytes_in_flight_before_loss_) { | 63 bytes_sent_since_loss_ * bytes_in_flight_before_loss_) { |
| 64 return QuicTime::Delta::Zero(); | 64 return QuicTime::Delta::Zero(); |
| 65 } | 65 } |
| 66 return QuicTime::Delta::Infinite(); | 66 return QuicTime::Delta::Infinite(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace net | 69 } // namespace net |
| OLD | NEW |