| 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/core/congestion_control/prr_sender.h" | 5 #include "net/quic/core/congestion_control/prr_sender.h" | 
| 6 | 6 | 
| 7 #include "net/quic/core/quic_packets.h" | 7 #include "net/quic/core/quic_packets.h" | 
| 8 | 8 | 
| 9 namespace net { | 9 namespace net { | 
| 10 | 10 | 
| 11 namespace { | 11 namespace { | 
| 12 // Constant based on TCP defaults. | 12 // Constant based on TCP defaults. | 
| 13 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS; | 13 const QuicByteCount kMaxQuicSegmentSize = kDefaultTCPMSS; | 
| 14 }  // namespace | 14 }  // namespace | 
| 15 | 15 | 
| 16 PrrSender::PrrSender() | 16 PrrSender::PrrSender() | 
| 17     : bytes_sent_since_loss_(0), | 17     : bytes_sent_since_loss_(0), | 
| 18       bytes_delivered_since_loss_(0), | 18       bytes_delivered_since_loss_(0), | 
| 19       ack_count_since_loss_(0), | 19       ack_count_since_loss_(0), | 
| 20       bytes_in_flight_before_loss_(0) {} | 20       bytes_in_flight_before_loss_(0) {} | 
| 21 | 21 | 
| 22 void PrrSender::OnPacketSent(QuicByteCount sent_bytes) { | 22 void PrrSender::OnPacketSent(QuicByteCount sent_bytes) { | 
| 23   bytes_sent_since_loss_ += sent_bytes; | 23   bytes_sent_since_loss_ += sent_bytes; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 QuicTime::Delta PrrSender::TimeUntilSend( | 38 QuicTime::Delta PrrSender::TimeUntilSend( | 
| 39     QuicByteCount congestion_window, | 39     QuicByteCount congestion_window, | 
| 40     QuicByteCount bytes_in_flight, | 40     QuicByteCount bytes_in_flight, | 
| 41     QuicByteCount slowstart_threshold) const { | 41     QuicByteCount slowstart_threshold) const { | 
| 42   //   if (FLAGS_?? && bytes_in_flight < congestion_window) { | 42   //   if (FLAGS_?? && bytes_in_flight < congestion_window) { | 
| 43   //     return QuicTime::Delta::Zero(); | 43   //     return QuicTime::Delta::Zero(); | 
| 44   //   } | 44   //   } | 
| 45   // Return QuicTime::Zero In order to ensure limited transmit always works. | 45   // Return QuicTime::Zero In order to ensure limited transmit always works. | 
| 46   if (bytes_sent_since_loss_ == 0 || bytes_in_flight < kMaxSegmentSize) { | 46   if (bytes_sent_since_loss_ == 0 || bytes_in_flight < kMaxQuicSegmentSize) { | 
| 47     return QuicTime::Delta::Zero(); | 47     return QuicTime::Delta::Zero(); | 
| 48   } | 48   } | 
| 49   if (congestion_window > bytes_in_flight) { | 49   if (congestion_window > bytes_in_flight) { | 
| 50     // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead | 50     // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead | 
| 51     // of sending the entire available window. This prevents burst retransmits | 51     // of sending the entire available window. This prevents burst retransmits | 
| 52     // when more packets are lost than the CWND reduction. | 52     // when more packets are lost than the CWND reduction. | 
| 53     //   limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS | 53     //   limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS | 
| 54     if (bytes_delivered_since_loss_ + ack_count_since_loss_ * kMaxSegmentSize <= | 54     if (bytes_delivered_since_loss_ + ack_count_since_loss_ * kMaxQuicSegmentSiz
    e <= | 
| 55         bytes_sent_since_loss_) { | 55         bytes_sent_since_loss_) { | 
| 56       return QuicTime::Delta::Infinite(); | 56       return QuicTime::Delta::Infinite(); | 
| 57     } | 57     } | 
| 58     return QuicTime::Delta::Zero(); | 58     return QuicTime::Delta::Zero(); | 
| 59   } | 59   } | 
| 60   // Implement Proportional Rate Reduction (RFC6937). | 60   // Implement Proportional Rate Reduction (RFC6937). | 
| 61   // Checks a simplified version of the PRR formula that doesn't use division: | 61   // Checks a simplified version of the PRR formula that doesn't use division: | 
| 62   // AvailableSendWindow = | 62   // AvailableSendWindow = | 
| 63   //   CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 63   //   CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent | 
| 64   if (bytes_delivered_since_loss_ * slowstart_threshold > | 64   if (bytes_delivered_since_loss_ * slowstart_threshold > | 
| 65       bytes_sent_since_loss_ * bytes_in_flight_before_loss_) { | 65       bytes_sent_since_loss_ * bytes_in_flight_before_loss_) { | 
| 66     return QuicTime::Delta::Zero(); | 66     return QuicTime::Delta::Zero(); | 
| 67   } | 67   } | 
| 68   return QuicTime::Delta::Infinite(); | 68   return QuicTime::Delta::Infinite(); | 
| 69 } | 69 } | 
| 70 | 70 | 
| 71 }  // namespace net | 71 }  // namespace net | 
| OLD | NEW | 
|---|