| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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/tcp_loss_algorithm.h" | 5 #include "net/quic/congestion_control/tcp_loss_algorithm.h" |
| 6 | 6 |
| 7 #include "net/quic/congestion_control/rtt_stats.h" | 7 #include "net/quic/congestion_control/rtt_stats.h" |
| 8 #include "net/quic/quic_protocol.h" | 8 #include "net/quic/quic_protocol.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Uses nack counts to decide when packets are lost. | 30 // Uses nack counts to decide when packets are lost. |
| 31 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( | 31 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( |
| 32 const QuicUnackedPacketMap& unacked_packets, | 32 const QuicUnackedPacketMap& unacked_packets, |
| 33 const QuicTime& time, | 33 const QuicTime& time, |
| 34 QuicPacketSequenceNumber largest_observed, | 34 QuicPacketSequenceNumber largest_observed, |
| 35 const RttStats& rtt_stats) { | 35 const RttStats& rtt_stats) { |
| 36 SequenceNumberSet lost_packets; | 36 SequenceNumberSet lost_packets; |
| 37 loss_detection_timeout_ = QuicTime::Zero(); | 37 loss_detection_timeout_ = QuicTime::Zero(); |
| 38 QuicTime::Delta loss_delay = | 38 QuicTime::Delta loss_delay = |
| 39 rtt_stats.SmoothedRtt().Multiply(kEarlyRetransmitLossDelayMultiplier); | 39 rtt_stats.SmoothedRtt().Multiply(kEarlyRetransmitLossDelayMultiplier); |
| 40 QuicPacketSequenceNumber sequence_number = unacked_packets.GetLeastUnacked(); | 40 |
| 41 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); | 41 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); |
| 42 it != unacked_packets.end() && sequence_number <= largest_observed; | 42 it != unacked_packets.end() && it->first <= largest_observed; ++it) { |
| 43 ++it, ++sequence_number) { | 43 if (!it->second.in_flight) { |
| 44 if (!it->in_flight) { | |
| 45 continue; | 44 continue; |
| 46 } | 45 } |
| 47 | 46 |
| 48 LOG_IF(DFATAL, it->nack_count == 0) | 47 LOG_IF(DFATAL, it->second.nack_count == 0) |
| 49 << "All packets less than largest observed should have been nacked."; | 48 << "All packets less than largest observed should have been nacked."; |
| 50 if (it->nack_count >= kNumberOfNacksBeforeRetransmission) { | 49 if (it->second.nack_count >= kNumberOfNacksBeforeRetransmission) { |
| 51 lost_packets.insert(sequence_number); | 50 lost_packets.insert(it->first); |
| 52 continue; | 51 continue; |
| 53 } | 52 } |
| 54 | 53 |
| 55 // Only early retransmit(RFC5827) when the last packet gets acked and | 54 // Only early retransmit(RFC5827) when the last packet gets acked and |
| 56 // there are retransmittable packets in flight. | 55 // there are retransmittable packets in flight. |
| 57 // This also implements a timer-protected variant of FACK. | 56 // This also implements a timer-protected variant of FACK. |
| 58 if (it->retransmittable_frames && | 57 if (it->second.retransmittable_frames && |
| 59 unacked_packets.largest_sent_packet() == largest_observed) { | 58 unacked_packets.largest_sent_packet() == largest_observed) { |
| 60 // Early retransmit marks the packet as lost once 1.25RTTs have passed | 59 // Early retransmit marks the packet as lost once 1.25RTTs have passed |
| 61 // since the packet was sent and otherwise sets an alarm. | 60 // since the packet was sent and otherwise sets an alarm. |
| 62 if (time >= it->sent_time.Add(loss_delay)) { | 61 if (time >= it->second.sent_time.Add(loss_delay)) { |
| 63 lost_packets.insert(sequence_number); | 62 lost_packets.insert(it->first); |
| 64 } else { | 63 } else { |
| 65 // Set the timeout for the earliest retransmittable packet where early | 64 // Set the timeout for the earliest retransmittable packet where early |
| 66 // retransmit applies. | 65 // retransmit applies. |
| 67 loss_detection_timeout_ = it->sent_time.Add(loss_delay); | 66 loss_detection_timeout_ = it->second.sent_time.Add(loss_delay); |
| 68 break; | 67 break; |
| 69 } | 68 } |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 return lost_packets; | 72 return lost_packets; |
| 74 } | 73 } |
| 75 | 74 |
| 76 QuicTime TCPLossAlgorithm::GetLossTimeout() const { | 75 QuicTime TCPLossAlgorithm::GetLossTimeout() const { |
| 77 return loss_detection_timeout_; | 76 return loss_detection_timeout_; |
| 78 } | 77 } |
| 79 | 78 |
| 80 } // namespace net | 79 } // namespace net |
| OLD | NEW |