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

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

Issue 1660593004: Landing Recent QUIC changes until 01/28/2016 18:41 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0202
Patch Set: Created 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/quic/congestion_control/time_loss_algorithm.h"
6
7 #include "net/quic/congestion_control/rtt_stats.h"
8 #include "net/quic/quic_bug_tracker.h"
9 #include "net/quic/quic_protocol.h"
10
11 namespace net {
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
19 // How many RTTs the algorithm waits before determining a packet is lost.
20 static const double kLossDelayMultiplier = 1.25;
21
22 } // namespace
23
24 TimeLossAlgorithm::TimeLossAlgorithm()
25 : loss_detection_timeout_(QuicTime::Zero()) {}
26
27 LossDetectionType TimeLossAlgorithm::GetLossDetectionType() const {
28 return kTime;
29 }
30
31 PacketNumberSet TimeLossAlgorithm::DetectLostPackets(
32 const QuicUnackedPacketMap& unacked_packets,
33 const QuicTime& time,
34 QuicPacketNumber largest_observed,
35 const RttStats& rtt_stats) {
36 PacketNumberSet lost_packets;
37 loss_detection_timeout_ = QuicTime::Zero();
38 QuicTime::Delta loss_delay = QuicTime::Delta::Max(
39 QuicTime::Delta::FromMilliseconds(kMinLossDelayMs),
40 QuicTime::Delta::Max(rtt_stats.smoothed_rtt(), rtt_stats.latest_rtt())
41 .Multiply(kLossDelayMultiplier));
42
43 QuicPacketNumber packet_number = unacked_packets.GetLeastUnacked();
44 for (QuicUnackedPacketMap::const_iterator it = unacked_packets.begin();
45 it != unacked_packets.end() && packet_number <= largest_observed;
46 ++it, ++packet_number) {
47 if (!it->in_flight) {
48 continue;
49 }
50 QUIC_BUG_IF(it->nack_count == 0 && it->sent_time.IsInitialized())
51 << "All packets less than largest observed should have been nacked."
52 << " packet_number:" << packet_number
53 << " largest_observed:" << largest_observed;
54
55 // Packets are sent in order, so break when we haven't waited long enough
56 // to lose any more packets and leave the loss_time_ set for the timeout.
57 QuicTime when_lost = it->sent_time.Add(loss_delay);
58 if (time < when_lost) {
59 loss_detection_timeout_ = when_lost;
60 break;
61 }
62 lost_packets.insert(packet_number);
63 }
64
65 return lost_packets;
66 }
67
68 void TimeLossAlgorithm::DetectLosses(
69 const QuicUnackedPacketMap& unacked_packets,
70 const QuicTime& time,
71 const RttStats& rtt_stats,
72 SendAlgorithmInterface::CongestionVector* packets_lost) {
73 QUIC_BUG << "DetectLoss is unsupported by TimeLossAlgorithm.";
74 }
75
76 // loss_time_ is updated in DetectLostPackets, which must be called every time
77 // an ack is received or the timeout expires.
78 QuicTime TimeLossAlgorithm::GetLossTimeout() const {
79 return loss_detection_timeout_;
80 }
81
82 } // 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