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

Side by Side Diff: net/quic/quic_sent_packet_manager.cc

Issue 391383002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with TOT Created 6 years, 5 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
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_server_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/quic_sent_packet_manager.h" 5 #include "net/quic/quic_sent_packet_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "net/quic/congestion_control/pacing_sender.h" 11 #include "net/quic/congestion_control/pacing_sender.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 #include "net/quic/quic_ack_notifier_manager.h" 13 #include "net/quic/quic_ack_notifier_manager.h"
14 #include "net/quic/quic_connection_stats.h" 14 #include "net/quic/quic_connection_stats.h"
15 #include "net/quic/quic_flags.h" 15 #include "net/quic/quic_flags.h"
16 #include "net/quic/quic_utils_chromium.h" 16 #include "net/quic/quic_utils_chromium.h"
17 17
18 using std::make_pair; 18 using std::make_pair;
19 using std::max; 19 using std::max;
20 using std::min; 20 using std::min;
21 21
22 namespace net { 22 namespace net {
23
24 // The length of the recent min rtt window in seconds. Windowing is disabled for
25 // values less than or equal to 0.
26 int32 FLAGS_quic_recent_min_rtt_window_s = 60;
27
23 namespace { 28 namespace {
24 static const int kDefaultRetransmissionTimeMs = 500; 29 static const int kDefaultRetransmissionTimeMs = 500;
25 // TCP RFC calls for 1 second RTO however Linux differs from this default and 30 // TCP RFC calls for 1 second RTO however Linux differs from this default and
26 // define the minimum RTO to 200ms, we will use the same until we have data to 31 // define the minimum RTO to 200ms, we will use the same until we have data to
27 // support a higher or lower value. 32 // support a higher or lower value.
28 static const int kMinRetransmissionTimeMs = 200; 33 static const int kMinRetransmissionTimeMs = 200;
29 static const int kMaxRetransmissionTimeMs = 60000; 34 static const int kMaxRetransmissionTimeMs = 60000;
30 static const size_t kMaxRetransmissions = 10; 35 static const size_t kMaxRetransmissions = 10;
31 36
32 // Only exponentially back off the handshake timer 5 times due to a timeout. 37 // Only exponentially back off the handshake timer 5 times due to a timeout.
33 static const size_t kMaxHandshakeRetransmissionBackoffs = 5; 38 static const size_t kMaxHandshakeRetransmissionBackoffs = 5;
34 static const size_t kMinHandshakeTimeoutMs = 10; 39 static const size_t kMinHandshakeTimeoutMs = 10;
35 40
36 // Sends up to two tail loss probes before firing an RTO, 41 // Sends up to two tail loss probes before firing an RTO,
37 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe. 42 // per draft RFC draft-dukkipati-tcpm-tcp-loss-probe.
38 static const size_t kDefaultMaxTailLossProbes = 2; 43 static const size_t kDefaultMaxTailLossProbes = 2;
39 static const int64 kMinTailLossProbeTimeoutMs = 10; 44 static const int64 kMinTailLossProbeTimeoutMs = 10;
40 45
41 // Number of samples before we force a new recent min rtt to be captured. 46 // Number of samples before we force a new recent min rtt to be captured.
42 static const size_t kNumMinRttSamplesAfterQuiescence = 2; 47 static const size_t kNumMinRttSamplesAfterQuiescence = 2;
43 48
44 // Number of unpaced packets to send after quiescence. 49 // Number of unpaced packets to send after quiescence.
45 static const size_t kInitialUnpacedBurst = 10; 50 static const size_t kInitialUnpacedBurst = 10;
46 51
52 // Use a 1 minute window for Recent Min RTT with BBR.
53
47 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) { 54 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) {
48 if (transmission_info.retransmittable_frames == NULL) { 55 if (transmission_info.retransmittable_frames == NULL) {
49 return false; 56 return false;
50 } 57 }
51 return transmission_info.retransmittable_frames->HasCryptoHandshake() == 58 return transmission_info.retransmittable_frames->HasCryptoHandshake() ==
52 IS_HANDSHAKE; 59 IS_HANDSHAKE;
53 } 60 }
54 61
55 } // namespace 62 } // namespace
56 63
(...skipping 27 matching lines...) Expand all
84 91
85 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) { 92 void QuicSentPacketManager::SetFromConfig(const QuicConfig& config) {
86 if (config.HasReceivedInitialRoundTripTimeUs() && 93 if (config.HasReceivedInitialRoundTripTimeUs() &&
87 config.ReceivedInitialRoundTripTimeUs() > 0) { 94 config.ReceivedInitialRoundTripTimeUs() > 0) {
88 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs, 95 rtt_stats_.set_initial_rtt_us(min(kMaxInitialRoundTripTimeUs,
89 config.ReceivedInitialRoundTripTimeUs())); 96 config.ReceivedInitialRoundTripTimeUs()));
90 } 97 }
91 // TODO(ianswett): BBR is currently a server only feature. 98 // TODO(ianswett): BBR is currently a server only feature.
92 if (config.HasReceivedConnectionOptions() && 99 if (config.HasReceivedConnectionOptions() &&
93 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) { 100 ContainsQuicTag(config.ReceivedConnectionOptions(), kTBBR)) {
101 if (FLAGS_quic_recent_min_rtt_window_s > 0) {
102 rtt_stats_.set_recent_min_rtt_window(
103 QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s));
104 }
94 send_algorithm_.reset( 105 send_algorithm_.reset(
95 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kTCPBBR, stats_)); 106 SendAlgorithmInterface::Create(clock_, &rtt_stats_, kTCPBBR, stats_));
96 } 107 }
97 if (config.congestion_feedback() == kPACE || 108 if (config.congestion_feedback() == kPACE ||
98 (config.HasReceivedConnectionOptions() && 109 (config.HasReceivedConnectionOptions() &&
99 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE))) { 110 ContainsQuicTag(config.ReceivedConnectionOptions(), kPACE))) {
100 MaybeEnablePacing(); 111 MaybeEnablePacing();
101 } 112 }
102 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once 113 // TODO(ianswett): Remove the "HasReceivedLossDetection" branch once
103 // the ConnectionOptions code is live everywhere. 114 // the ConnectionOptions code is live everywhere.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 148 }
138 149
139 // A notifier may be waiting to hear about ACKs for the original sequence 150 // A notifier may be waiting to hear about ACKs for the original sequence
140 // number. Inform them that the sequence number has changed. 151 // number. Inform them that the sequence number has changed.
141 ack_notifier_manager_.UpdateSequenceNumber(old_sequence_number, 152 ack_notifier_manager_.UpdateSequenceNumber(old_sequence_number,
142 new_sequence_number); 153 new_sequence_number);
143 154
144 unacked_packets_.OnRetransmittedPacket(old_sequence_number, 155 unacked_packets_.OnRetransmittedPacket(old_sequence_number,
145 new_sequence_number, 156 new_sequence_number,
146 transmission_type); 157 transmission_type);
158
159 if (debug_delegate_ != NULL) {
160 debug_delegate_->OnRetransmittedPacket(old_sequence_number,
161 new_sequence_number,
162 transmission_type,
163 clock_->ApproximateNow());
164 }
147 } 165 }
148 166
149 void QuicSentPacketManager::OnIncomingAck( 167 void QuicSentPacketManager::OnIncomingAck(
150 const ReceivedPacketInfo& received_info, 168 const ReceivedPacketInfo& received_info,
151 QuicTime ack_receive_time) { 169 QuicTime ack_receive_time) {
152 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight(); 170 QuicByteCount bytes_in_flight = unacked_packets_.bytes_in_flight();
153 171
154 // We rely on delta_time_largest_observed to compute an RTT estimate, so 172 // We rely on delta_time_largest_observed to compute an RTT estimate, so
155 // we only update rtt when the largest observed gets acked. 173 // we only update rtt when the largest observed gets acked.
156 bool largest_observed_acked = MaybeUpdateRTT(received_info, ack_receive_time); 174 bool largest_observed_acked = MaybeUpdateRTT(received_info, ack_receive_time);
(...skipping 13 matching lines...) Expand all
170 } 188 }
171 189
172 // Anytime we are making forward progress and have a new RTT estimate, reset 190 // Anytime we are making forward progress and have a new RTT estimate, reset
173 // the backoff counters. 191 // the backoff counters.
174 if (largest_observed_acked) { 192 if (largest_observed_acked) {
175 // Reset all retransmit counters any time a new packet is acked. 193 // Reset all retransmit counters any time a new packet is acked.
176 consecutive_rto_count_ = 0; 194 consecutive_rto_count_ = 0;
177 consecutive_tlp_count_ = 0; 195 consecutive_tlp_count_ = 0;
178 consecutive_crypto_retransmission_count_ = 0; 196 consecutive_crypto_retransmission_count_ = 0;
179 } 197 }
198
199 if (debug_delegate_ != NULL) {
200 debug_delegate_->OnIncomingAck(received_info,
201 ack_receive_time,
202 largest_observed_,
203 largest_observed_acked,
204 GetLeastUnackedSentPacket());
205 }
180 } 206 }
181 207
182 void QuicSentPacketManager::MaybeInvokeCongestionEvent( 208 void QuicSentPacketManager::MaybeInvokeCongestionEvent(
183 bool rtt_updated, QuicByteCount bytes_in_flight) { 209 bool rtt_updated, QuicByteCount bytes_in_flight) {
184 if (rtt_updated || !packets_acked_.empty() || 210 if (rtt_updated || !packets_acked_.empty() ||
185 !packets_lost_.empty()) { 211 !packets_lost_.empty()) {
186 send_algorithm_->OnCongestionEvent( 212 send_algorithm_->OnCongestionEvent(
187 rtt_updated, bytes_in_flight, packets_acked_, packets_lost_); 213 rtt_updated, bytes_in_flight, packets_acked_, packets_lost_);
188 packets_acked_.clear(); 214 packets_acked_.clear();
189 packets_lost_.clear(); 215 packets_lost_.clear();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 506
481 // Only track packets as in flight that the send algorithm wants us to track. 507 // Only track packets as in flight that the send algorithm wants us to track.
482 const bool in_flight = 508 const bool in_flight =
483 send_algorithm_->OnPacketSent(sent_time, 509 send_algorithm_->OnPacketSent(sent_time,
484 unacked_packets_.bytes_in_flight(), 510 unacked_packets_.bytes_in_flight(),
485 sequence_number, 511 sequence_number,
486 bytes, 512 bytes,
487 has_retransmittable_data); 513 has_retransmittable_data);
488 unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight); 514 unacked_packets_.SetSent(sequence_number, sent_time, bytes, in_flight);
489 515
516 if (debug_delegate_ != NULL) {
517 debug_delegate_->OnSentPacket(sequence_number, sent_time, bytes);
518 }
519
490 // Reset the retransmission timer anytime a pending packet is sent. 520 // Reset the retransmission timer anytime a pending packet is sent.
491 return in_flight; 521 return in_flight;
492 } 522 }
493 523
494 void QuicSentPacketManager::OnRetransmissionTimeout() { 524 void QuicSentPacketManager::OnRetransmissionTimeout() {
495 DCHECK(unacked_packets_.HasInFlightPackets()); 525 DCHECK(unacked_packets_.HasInFlightPackets());
496 DCHECK(!pending_tlp_transmission_); 526 DCHECK(!pending_tlp_transmission_);
497 // Handshake retransmission, timer based loss detection, TLP, and RTO are 527 // Handshake retransmission, timer based loss detection, TLP, and RTO are
498 // implemented with a single alarm. The handshake alarm is set when the 528 // implemented with a single alarm. The handshake alarm is set when the
499 // handshake has not completed, the loss alarm is set when the loss detection 529 // handshake has not completed, the loss alarm is set when the loss detection
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 821 }
792 822
793 bool QuicSentPacketManager::HasReliableBandwidthEstimate() const { 823 bool QuicSentPacketManager::HasReliableBandwidthEstimate() const {
794 return send_algorithm_->HasReliableBandwidthEstimate(); 824 return send_algorithm_->HasReliableBandwidthEstimate();
795 } 825 }
796 826
797 QuicByteCount QuicSentPacketManager::GetCongestionWindow() const { 827 QuicByteCount QuicSentPacketManager::GetCongestionWindow() const {
798 return send_algorithm_->GetCongestionWindow(); 828 return send_algorithm_->GetCongestionWindow();
799 } 829 }
800 830
831 QuicByteCount QuicSentPacketManager::GetSlowStartThreshold() const {
832 return send_algorithm_->GetSlowStartThreshold();
833 }
834
801 void QuicSentPacketManager::MaybeEnablePacing() { 835 void QuicSentPacketManager::MaybeEnablePacing() {
802 if (!FLAGS_enable_quic_pacing) { 836 if (!FLAGS_enable_quic_pacing) {
803 return; 837 return;
804 } 838 }
805 839
806 if (using_pacing_) { 840 if (using_pacing_) {
807 return; 841 return;
808 } 842 }
809 843
810 // Set up a pacing sender with a 5 millisecond alarm granularity. 844 // Set up a pacing sender with a 5 millisecond alarm granularity.
811 using_pacing_ = true; 845 using_pacing_ = true;
812 send_algorithm_.reset( 846 send_algorithm_.reset(
813 new PacingSender(send_algorithm_.release(), 847 new PacingSender(send_algorithm_.release(),
814 QuicTime::Delta::FromMilliseconds(5), 848 QuicTime::Delta::FromMilliseconds(5),
815 kInitialUnpacedBurst)); 849 kInitialUnpacedBurst));
816 } 850 }
817 851
818 } // namespace net 852 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager.h ('k') | net/quic/quic_server_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698