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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 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 {
11 namespace { 11 namespace {
12 12
13 // The minimum delay before a packet will be considered lost, 13 // The minimum delay before a packet will be considered lost,
14 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only 14 // regardless of SRTT. Half of the minimum TLP, since the loss algorithm only
15 // triggers when a nack has been receieved for the packet. 15 // triggers when a nack has been receieved for the packet.
16 static const size_t kMinLossDelayMs = 5; 16 static const size_t kMinLossDelayMs = 5;
17 17
18 // How many RTTs the algorithm waits before determining a packet is lost. 18 // How many RTTs the algorithm waits before determining a packet is lost.
19 static const double kLossDelayMultiplier = 1.25; 19 static const double kLossDelayMultiplier = 1.25;
20 20
21 } // namespace 21 } // namespace
22 22
23 TimeLossAlgorithm::TimeLossAlgorithm() 23 TimeLossAlgorithm::TimeLossAlgorithm()
24 : loss_detection_timeout_(QuicTime::Zero()) { } 24 : loss_detection_timeout_(QuicTime::Zero()) {
25 }
25 26
26 LossDetectionType TimeLossAlgorithm::GetLossDetectionType() const { 27 LossDetectionType TimeLossAlgorithm::GetLossDetectionType() const {
27 return kTime; 28 return kTime;
28 } 29 }
29 30
30 SequenceNumberSet TimeLossAlgorithm::DetectLostPackets( 31 SequenceNumberSet TimeLossAlgorithm::DetectLostPackets(
31 const QuicUnackedPacketMap& unacked_packets, 32 const QuicUnackedPacketMap& unacked_packets,
32 const QuicTime& time, 33 const QuicTime& time,
33 QuicPacketSequenceNumber largest_observed, 34 QuicPacketSequenceNumber largest_observed,
34 const RttStats& rtt_stats) { 35 const RttStats& rtt_stats) {
35 SequenceNumberSet lost_packets; 36 SequenceNumberSet lost_packets;
36 loss_detection_timeout_ = QuicTime::Zero(); 37 loss_detection_timeout_ = QuicTime::Zero();
37 QuicTime::Delta loss_delay = QuicTime::Delta::Max( 38 QuicTime::Delta loss_delay = QuicTime::Delta::Max(
38 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs), 39 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs),
39 QuicTime::Delta::Max(rtt_stats.SmoothedRtt(), rtt_stats.latest_rtt()) 40 QuicTime::Delta::Max(rtt_stats.SmoothedRtt(), rtt_stats.latest_rtt())
40 .Multiply(kLossDelayMultiplier)); 41 .Multiply(kLossDelayMultiplier));
41 42
42 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin(); 43 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
43 it != unacked_packets.end() && it->first <= largest_observed; ++it) { 44 it != unacked_packets.end() && it->first <= largest_observed;
45 ++it) {
44 if (!it->second.pending) { 46 if (!it->second.pending) {
45 continue; 47 continue;
46 } 48 }
47 LOG_IF(DFATAL, it->second.nack_count == 0) 49 LOG_IF(DFATAL, it->second.nack_count == 0)
48 << "All packets less than largest observed should have been nacked."; 50 << "All packets less than largest observed should have been nacked.";
49 51
50 // Packets are sent in order, so break when we haven't waited long enough 52 // 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. 53 // 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); 54 QuicTime when_lost = it->second.sent_time.Add(loss_delay);
53 if (time < when_lost) { 55 if (time < when_lost) {
54 loss_detection_timeout_ = when_lost; 56 loss_detection_timeout_ = when_lost;
55 break; 57 break;
56 } 58 }
57 lost_packets.insert(it->first); 59 lost_packets.insert(it->first);
58 } 60 }
59 61
60 return lost_packets; 62 return lost_packets;
61 } 63 }
62 64
63 // loss_time_ is updated in DetectLostPackets, which must be called every time 65 // loss_time_ is updated in DetectLostPackets, which must be called every time
64 // an ack is received or the timeout expires. 66 // an ack is received or the timeout expires.
65 QuicTime TimeLossAlgorithm::GetLossTimeout() const { 67 QuicTime TimeLossAlgorithm::GetLossTimeout() const {
66 return loss_detection_timeout_; 68 return loss_detection_timeout_;
67 } 69 }
68 70
69 } // namespace net 71 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698