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/time_loss_algorithm.h" | 5 #include "net/quic/congestion_control/time_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 23 matching lines...) Expand all Loading... |
34 const RttStats& rtt_stats) { | 34 const RttStats& rtt_stats) { |
35 SequenceNumberSet lost_packets; | 35 SequenceNumberSet lost_packets; |
36 loss_detection_timeout_ = QuicTime::Zero(); | 36 loss_detection_timeout_ = QuicTime::Zero(); |
37 QuicTime::Delta loss_delay = QuicTime::Delta::Max( | 37 QuicTime::Delta loss_delay = QuicTime::Delta::Max( |
38 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs), | 38 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs), |
39 QuicTime::Delta::Max(rtt_stats.SmoothedRtt(), rtt_stats.latest_rtt()) | 39 QuicTime::Delta::Max(rtt_stats.SmoothedRtt(), rtt_stats.latest_rtt()) |
40 .Multiply(kLossDelayMultiplier)); | 40 .Multiply(kLossDelayMultiplier)); |
41 | 41 |
42 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); | 42 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); |
43 it != unacked_packets.end() && it->first <= largest_observed; ++it) { | 43 it != unacked_packets.end() && it->first <= largest_observed; ++it) { |
44 if (!it->second.pending) { | 44 if (!it->second.in_flight) { |
45 continue; | 45 continue; |
46 } | 46 } |
47 LOG_IF(DFATAL, it->second.nack_count == 0) | 47 LOG_IF(DFATAL, it->second.nack_count == 0) |
48 << "All packets less than largest observed should have been nacked."; | 48 << "All packets less than largest observed should have been nacked."; |
49 | 49 |
50 // Packets are sent in order, so break when we haven't waited long enough | 50 // Packets are sent in order, so break when we haven't waited long enough |
51 // to lose any more packets and leave the loss_time_ set for the timeout. | 51 // to lose any more packets and leave the loss_time_ set for the timeout. |
52 QuicTime when_lost = it->second.sent_time.Add(loss_delay); | 52 QuicTime when_lost = it->second.sent_time.Add(loss_delay); |
53 if (time < when_lost) { | 53 if (time < when_lost) { |
54 loss_detection_timeout_ = when_lost; | 54 loss_detection_timeout_ = when_lost; |
55 break; | 55 break; |
56 } | 56 } |
57 lost_packets.insert(it->first); | 57 lost_packets.insert(it->first); |
58 } | 58 } |
59 | 59 |
60 return lost_packets; | 60 return lost_packets; |
61 } | 61 } |
62 | 62 |
63 // loss_time_ is updated in DetectLostPackets, which must be called every time | 63 // loss_time_ is updated in DetectLostPackets, which must be called every time |
64 // an ack is received or the timeout expires. | 64 // an ack is received or the timeout expires. |
65 QuicTime TimeLossAlgorithm::GetLossTimeout() const { | 65 QuicTime TimeLossAlgorithm::GetLossTimeout() const { |
66 return loss_detection_timeout_; | 66 return loss_detection_timeout_; |
67 } | 67 } |
68 | 68 |
69 } // namespace net | 69 } // namespace net |
OLD | NEW |