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

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

Issue 182523002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed rch's comments in Patch set 1 of CL 181463007 Created 6 years, 9 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/time_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 namespace {
10 11
11 namespace { 12 // The minimum delay before a packet will be considered lost,
12 // TCP retransmits after 3 nacks. 13 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only
13 static const size_t kNumberOfNacksBeforeRetransmission = 3; 14 // triggers when a nack has been receieved for the packet.
14 } 15 static const size_t kMinLossDelayMs = 5;
15 16
16 TCPLossAlgorithm::TCPLossAlgorithm() { } 17 // How many RTTs the algorithm waits before determining a packet is lost.
18 static const double kLossDelayMultiplier = 1.25;
17 19
18 // Uses nack counts to decide when packets are lost. 20 } // namespace
19 SequenceNumberSet TCPLossAlgorithm::DetectLostPackets( 21
22 TimeLossAlgorithm::TimeLossAlgorithm()
23 : loss_detection_timeout_(QuicTime::Zero()) { }
24
25 SequenceNumberSet TimeLossAlgorithm::DetectLostPackets(
20 const QuicUnackedPacketMap& unacked_packets, 26 const QuicUnackedPacketMap& unacked_packets,
21 const QuicTime& time, 27 const QuicTime& time,
22 QuicPacketSequenceNumber largest_observed, 28 QuicPacketSequenceNumber largest_observed,
23 QuicTime::Delta srtt) { 29 QuicTime::Delta srtt,
30 QuicTime::Delta latest_rtt) {
24 SequenceNumberSet lost_packets; 31 SequenceNumberSet lost_packets;
32 loss_detection_timeout_ = QuicTime::Zero();
33 QuicTime::Delta loss_delay = QuicTime::Delta::Max(
34 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs),
35 QuicTime::Delta::Max(srtt, latest_rtt).Multiply(kLossDelayMultiplier));
25 36
26 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); 37 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
27 it != unacked_packets.end() && it->first <= largest_observed; ++it) { 38 it != unacked_packets.end() && it->first <= largest_observed; ++it) {
28 if (!it->second.pending) { 39 if (!it->second.pending) {
29 continue; 40 continue;
30 } 41 }
31 size_t num_nacks_needed = kNumberOfNacksBeforeRetransmission; 42 LOG_IF(DFATAL, it->second.nack_count == 0)
32 // Check for early retransmit(RFC5827) when the last packet gets acked and 43 << "All packets less than largest observed should have been nacked.";
33 // the there are fewer than 4 pending packets. 44
34 // TODO(ianswett): Set a retransmission timer instead of losing the packet 45 // Packets are sent in order, so break when we haven't waited long enough
35 // and retransmitting immediately. 46 // to lose any more packets and leave the loss_time_ set for the timeout.
36 if (it->second.retransmittable_frames && 47 QuicTime when_lost = it->second.sent_time.Add(loss_delay);
37 unacked_packets.largest_sent_packet() == largest_observed) { 48 if (time < when_lost) {
38 num_nacks_needed = largest_observed - it->first; 49 loss_detection_timeout_ = when_lost;
50 break;
39 } 51 }
40
41 if (it->second.nack_count < num_nacks_needed) {
42 continue;
43 }
44
45 lost_packets.insert(it->first); 52 lost_packets.insert(it->first);
46 } 53 }
47 54
48 return lost_packets; 55 return lost_packets;
49 } 56 }
50 57
58 // loss_time_ is updated in DetectLostPackets, which must be called every time
59 // an ack is received or the timeout expires.
60 QuicTime TimeLossAlgorithm::GetLossTimeout() const {
61 return loss_detection_timeout_;
62 }
63
51 } // namespace net 64 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/time_loss_algorithm.h ('k') | net/quic/congestion_control/time_loss_algorithm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698