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

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

Issue 182083002: Implement an early retransmit timer in QUIC's TcpLossAlgorithm to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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/congestion_control/tcp_loss_algorithm.h" 5 #include "net/quic/congestion_control/tcp_loss_algorithm.h"
6 6
7 #include "net/quic/quic_protocol.h" 7 #include "net/quic/quic_protocol.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 namespace { 11 namespace {
12
12 // TCP retransmits after 3 nacks. 13 // TCP retransmits after 3 nacks.
13 static const size_t kNumberOfNacksBeforeRetransmission = 3; 14 static const size_t kNumberOfNacksBeforeRetransmission = 3;
15
16 // How many RTTs the algorithm waits before determining a packet is lost due
17 // to early retransmission.
18 static const double kEarlyRetransmitLossDelayMultiplier = 1.25;
19
14 } 20 }
15 21
16 TCPLossAlgorithm::TCPLossAlgorithm() { } 22 TCPLossAlgorithm::TCPLossAlgorithm()
23 : loss_detection_timeout_(QuicTime::Zero()) { }
17 24
18 // Uses nack counts to decide when packets are lost. 25 // Uses nack counts to decide when packets are lost.
19 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( 26 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets(
20 const QuicUnackedPacketMap& unacked_packets, 27 const QuicUnackedPacketMap& unacked_packets,
21 const QuicTime& time, 28 const QuicTime& time,
22 QuicPacketSequenceNumber largest_observed, 29 QuicPacketSequenceNumber largest_observed,
23 QuicTime::Delta srtt, 30 QuicTime::Delta srtt,
24 QuicTime::Delta latest_rtt) { 31 QuicTime::Delta latest_rtt) {
25 SequenceNumberSet lost_packets; 32 SequenceNumberSet lost_packets;
33 loss_detection_timeout_ = QuicTime::Zero();
34 QuicTime::Delta loss_delay =
35 srtt.Multiply(kEarlyRetransmitLossDelayMultiplier);
26 36
27 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); 37 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
28 it != unacked_packets.end() && it->first <= largest_observed; ++it) { 38 it != unacked_packets.end() && it->first <= largest_observed; ++it) {
29 if (!it->second.pending) { 39 if (!it->second.pending) {
30 continue; 40 continue;
31 } 41 }
32 size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission;
33 // Check for early retransmit(RFC5827) when the last packet gets acked and
34 // the there are fewer than 4 pending packets.
35 // TODO(ianswett): Set a retransmission timer instead of losing the packet
36 // and retransmitting immediately.
37 if (it->second.retransmittable_frames &&
38 unacked_packets.largest_sent_packet() == largest_observed) {
39 num_nacks_needed = largest_observed - it->first;
40 }
41 42
42 if (it->second.nack_count < num_nacks_needed) { 43 LOG_IF(DFATAL, it->second.nack_count == 0)
44 << "All packets less than largest observed should have been nacked.";
45 if (it->second.nack_count >= kNumberOfNacksBeforeRetransmission) {
46 lost_packets.insert(it->first);
43 continue; 47 continue;
44 } 48 }
45 49
46 lost_packets.insert(it->first); 50 // Only early retransmit(RFC5827) when the last packet gets acked and
51 // there are pending retransmittable packets.
52 // This also implements a timer-protected variant of FACK.
53 if (it->second.retransmittable_frames &&
54 unacked_packets.largest_sent_packet() == largest_observed) {
55 // Early retransmit marks the packet as lost once 1.25RTTs have passed
56 // since the packet was sent and otherwise sets an alarm.
57 if (time >= it->second.sent_time.Add(loss_delay)) {
58 lost_packets.insert(it->first);
59 } else {
60 // Set the timeout for the earliest retransmittable packet where early
61 // retransmit applies.
62 loss_detection_timeout_ = it->second.sent_time.Add(loss_delay);
63 break;
64 }
65 }
47 } 66 }
48 67
49 return lost_packets; 68 return lost_packets;
50 } 69 }
51 70
52 QuicTime TCPLossAlgorithm::GetLossTimeout() const { 71 QuicTime TCPLossAlgorithm::GetLossTimeout() const {
53 return QuicTime::Zero(); 72 return loss_detection_timeout_;
54 } 73 }
55 74
56 } // namespace net 75 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_loss_algorithm.h ('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