Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: net/quic/congestion_control/tcp_loss_algorithm.cc

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
11 11
12 namespace { 12 namespace {
13
14 // The minimum delay before a packet will be considered lost,
15 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only
16 // triggers when a nack has been receieved for the packet.
17 static const size_t kMinLossDelayMs = 5;
18
13 // How many RTTs the algorithm waits before determining a packet is lost due 19 // How many RTTs the algorithm waits before determining a packet is lost due
14 // to early retransmission. 20 // to early retransmission.
15 static const double kEarlyRetransmitLossDelayMultiplier = 1.25; 21 static const double kEarlyRetransmitLossDelayMultiplier = 1.25;
16 } 22
23 } // namespace
17 24
18 TCPLossAlgorithm::TCPLossAlgorithm() 25 TCPLossAlgorithm::TCPLossAlgorithm()
19 : loss_detection_timeout_(QuicTime::Zero()) { } 26 : loss_detection_timeout_(QuicTime::Zero()) { }
20 27
21 LossDetectionType TCPLossAlgorithm::GetLossDetectionType() const { 28 LossDetectionType TCPLossAlgorithm::GetLossDetectionType() const {
22 return kNack; 29 return kNack;
23 } 30 }
24 31
25 // Uses nack counts to decide when packets are lost. 32 // Uses nack counts to decide when packets are lost.
26 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( 33 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets(
27 const QuicUnackedPacketMap& unacked_packets, 34 const QuicUnackedPacketMap& unacked_packets,
28 const QuicTime& time, 35 const QuicTime& time,
29 QuicPacketSequenceNumber largest_observed, 36 QuicPacketSequenceNumber largest_observed,
30 const RttStats& rtt_stats) { 37 const RttStats& rtt_stats) {
31 SequenceNumberSet lost_packets; 38 SequenceNumberSet lost_packets;
32 loss_detection_timeout_ = QuicTime::Zero(); 39 loss_detection_timeout_ = QuicTime::Zero();
33 QuicTime::Delta loss_delay = 40 QuicTime::Delta early_retransmit_delay = QuicTime::Delta::Max(
34 rtt_stats.smoothed_rtt().Multiply(kEarlyRetransmitLossDelayMultiplier); 41 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs),
42 rtt_stats.smoothed_rtt().Multiply(kEarlyRetransmitLossDelayMultiplier));
43
35 QuicPacketSequenceNumber sequence_number = unacked_packets.GetLeastUnacked(); 44 QuicPacketSequenceNumber sequence_number = unacked_packets.GetLeastUnacked();
36 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); 45 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
37 it != unacked_packets.end() && sequence_number <= largest_observed; 46 it != unacked_packets.end() && sequence_number <= largest_observed;
38 ++it, ++sequence_number) { 47 ++it, ++sequence_number) {
39 if (!it->in_flight) { 48 if (!it->in_flight) {
40 continue; 49 continue;
41 } 50 }
42 51
43 LOG_IF(DFATAL, it->nack_count == 0 && it->sent_time.IsInitialized()) 52 LOG_IF(DFATAL, it->nack_count == 0 && it->sent_time.IsInitialized())
44 << "All packets less than largest observed should have been nacked." 53 << "All packets less than largest observed should have been nacked."
45 << "sequence_number:" << sequence_number 54 << "sequence_number:" << sequence_number
46 << " largest_observed:" << largest_observed; 55 << " largest_observed:" << largest_observed;
47 if (it->nack_count >= kNumberOfNacksBeforeRetransmission) { 56 if (it->nack_count >= kNumberOfNacksBeforeRetransmission) {
48 lost_packets.insert(sequence_number); 57 lost_packets.insert(sequence_number);
49 continue; 58 continue;
50 } 59 }
51 60
61 // Immediately lose the packet if it's been an srtt between the sent time
62 // of it and the largest observed. This speeds recovery from timer based
63 // retransmissions, such as TLP and RTO, when there may be fewer than
64 // kNumberOfNacksBeforeRetransmission nacks.
65 if (it->sent_time.Add(rtt_stats.smoothed_rtt()) <
66 unacked_packets.GetTransmissionInfo(largest_observed).sent_time) {
67 lost_packets.insert(sequence_number);
68 continue;
69 }
70
52 // Only early retransmit(RFC5827) when the last packet gets acked and 71 // Only early retransmit(RFC5827) when the last packet gets acked and
53 // there are retransmittable packets in flight. 72 // there are retransmittable packets in flight.
54 // This also implements a timer-protected variant of FACK. 73 // This also implements a timer-protected variant of FACK.
55 if (it->retransmittable_frames && 74 if (it->retransmittable_frames &&
56 unacked_packets.largest_sent_packet() == largest_observed) { 75 unacked_packets.largest_sent_packet() == largest_observed) {
57 // Early retransmit marks the packet as lost once 1.25RTTs have passed 76 // Early retransmit marks the packet as lost once 1.25RTTs have passed
58 // since the packet was sent and otherwise sets an alarm. 77 // since the packet was sent and otherwise sets an alarm.
59 if (time >= it->sent_time.Add(loss_delay)) { 78 if (time >= it->sent_time.Add(early_retransmit_delay)) {
60 lost_packets.insert(sequence_number); 79 lost_packets.insert(sequence_number);
61 } else { 80 } else {
62 // Set the timeout for the earliest retransmittable packet where early 81 // Set the timeout for the earliest retransmittable packet where early
63 // retransmit applies. 82 // retransmit applies.
64 loss_detection_timeout_ = it->sent_time.Add(loss_delay); 83 loss_detection_timeout_ = it->sent_time.Add(early_retransmit_delay);
65 break; 84 break;
66 } 85 }
67 } 86 }
68 } 87 }
69 88
70 return lost_packets; 89 return lost_packets;
71 } 90 }
72 91
73 QuicTime TCPLossAlgorithm::GetLossTimeout() const { 92 QuicTime TCPLossAlgorithm::GetLossTimeout() const {
74 return loss_detection_timeout_; 93 return loss_detection_timeout_;
75 } 94 }
76 95
77 } // namespace net 96 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_test.cc ('k') | net/quic/congestion_control/tcp_loss_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698