| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_QUIC_CONGESTION_CONTROL_GENERAL_LOSS_ALGORITHM_H_ | |
| 6 #define NET_QUIC_CONGESTION_CONTROL_GENERAL_LOSS_ALGORITHM_H_ | |
| 7 | |
| 8 #include <algorithm> | |
| 9 #include <map> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "net/quic/congestion_control/loss_detection_interface.h" | |
| 13 #include "net/quic/quic_protocol.h" | |
| 14 #include "net/quic/quic_time.h" | |
| 15 #include "net/quic/quic_unacked_packet_map.h" | |
| 16 | |
| 17 namespace net { | |
| 18 | |
| 19 // Class which can be configured to implement's TCP's approach of detecting loss | |
| 20 // when 3 nacks have been received for a packet or with a time threshold. | |
| 21 // Also implements TCP's early retransmit(RFC5827). | |
| 22 class NET_EXPORT_PRIVATE GeneralLossAlgorithm : public LossDetectionInterface { | |
| 23 public: | |
| 24 // TCP retransmits after 3 nacks. | |
| 25 static const QuicPacketCount kNumberOfNacksBeforeRetransmission = 3; | |
| 26 | |
| 27 GeneralLossAlgorithm(); | |
| 28 explicit GeneralLossAlgorithm(LossDetectionType loss_type); | |
| 29 ~GeneralLossAlgorithm() override {} | |
| 30 | |
| 31 LossDetectionType GetLossDetectionType() const override; | |
| 32 void SetLossDetectionType(LossDetectionType loss_type); | |
| 33 | |
| 34 // Uses |largest_acked| and time to decide when packets are lost. | |
| 35 void DetectLosses( | |
| 36 const QuicUnackedPacketMap& unacked_packets, | |
| 37 QuicTime time, | |
| 38 const RttStats& rtt_stats, | |
| 39 QuicPacketNumber largest_newly_acked, | |
| 40 SendAlgorithmInterface::CongestionVector* packets_lost) override; | |
| 41 | |
| 42 // Returns a non-zero value when the early retransmit timer is active. | |
| 43 QuicTime GetLossTimeout() const override; | |
| 44 | |
| 45 // Increases the loss detection threshold for time loss detection. | |
| 46 void SpuriousRetransmitDetected( | |
| 47 const QuicUnackedPacketMap& unacked_packets, | |
| 48 QuicTime time, | |
| 49 const RttStats& rtt_stats, | |
| 50 QuicPacketNumber spurious_retransmission) override; | |
| 51 | |
| 52 int reordering_shift() const { return reordering_shift_; } | |
| 53 | |
| 54 private: | |
| 55 LossDetectionType loss_type_; | |
| 56 QuicTime loss_detection_timeout_; | |
| 57 // Largest sent packet when a spurious retransmit is detected. | |
| 58 // Prevents increasing the reordering threshold multiple times per epoch. | |
| 59 QuicPacketNumber largest_sent_on_spurious_retransmit_; | |
| 60 // Fraction of a max(SRTT, latest_rtt) to permit reordering before declaring | |
| 61 // loss. Fraction calculated by shifting max(SRTT, latest_rtt) to the right | |
| 62 // by reordering_shift. | |
| 63 int reordering_shift_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(GeneralLossAlgorithm); | |
| 66 }; | |
| 67 | |
| 68 } // namespace net | |
| 69 | |
| 70 #endif // NET_QUIC_CONGESTION_CONTROL_GENERAL_LOSS_ALGORITHM_H_ | |
| OLD | NEW |