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

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

Issue 1777293002: Add a new QUIC Ack Decimation mode that is reordering tolerant. Protected by FLAG_quic_ack_decimati… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115844136
Patch Set: Created 4 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
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 should_last_packet_instigate_acks_(false), 271 should_last_packet_instigate_acks_(false),
272 largest_seen_packet_with_ack_(0), 272 largest_seen_packet_with_ack_(0),
273 largest_seen_packet_with_stop_waiting_(0), 273 largest_seen_packet_with_stop_waiting_(0),
274 max_undecryptable_packets_(0), 274 max_undecryptable_packets_(0),
275 pending_version_negotiation_packet_(false), 275 pending_version_negotiation_packet_(false),
276 save_crypto_packets_as_termination_packets_(false), 276 save_crypto_packets_as_termination_packets_(false),
277 silent_close_enabled_(false), 277 silent_close_enabled_(false),
278 received_packet_manager_(&stats_), 278 received_packet_manager_(&stats_),
279 ack_queued_(false), 279 ack_queued_(false),
280 num_retransmittable_packets_received_since_last_ack_sent_(0), 280 num_retransmittable_packets_received_since_last_ack_sent_(0),
281 last_ack_had_missing_packets_(false),
281 num_packets_received_since_last_ack_sent_(0), 282 num_packets_received_since_last_ack_sent_(0),
282 stop_waiting_count_(0), 283 stop_waiting_count_(0),
283 ack_decimation_enabled_(false), 284 ack_mode_(TCP_ACKING),
284 delay_setting_retransmission_alarm_(false), 285 delay_setting_retransmission_alarm_(false),
285 pending_retransmission_alarm_(false), 286 pending_retransmission_alarm_(false),
286 arena_(), 287 arena_(),
287 ack_alarm_(helper->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)), 288 ack_alarm_(helper->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)),
288 retransmission_alarm_( 289 retransmission_alarm_(
289 helper->CreateAlarm(arena_.New<RetransmissionAlarm>(this), &arena_)), 290 helper->CreateAlarm(arena_.New<RetransmissionAlarm>(this), &arena_)),
290 send_alarm_(helper->CreateAlarm(arena_.New<SendAlarm>(this), &arena_)), 291 send_alarm_(helper->CreateAlarm(arena_.New<SendAlarm>(this), &arena_)),
291 resume_writes_alarm_( 292 resume_writes_alarm_(
292 helper->CreateAlarm(arena_.New<SendAlarm>(this), &arena_)), 293 helper->CreateAlarm(arena_.New<SendAlarm>(this), &arena_)),
293 timeout_alarm_( 294 timeout_alarm_(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 if (config.HasClientSentConnectionOption(kMTUH, perspective_)) { 409 if (config.HasClientSentConnectionOption(kMTUH, perspective_)) {
409 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeHigh); 410 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeHigh);
410 } 411 }
411 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) { 412 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) {
412 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow); 413 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow);
413 } 414 }
414 if (debug_visitor_ != nullptr) { 415 if (debug_visitor_ != nullptr) {
415 debug_visitor_->OnSetFromConfig(config); 416 debug_visitor_->OnSetFromConfig(config);
416 } 417 }
417 if (config.HasClientSentConnectionOption(kACKD, perspective_)) { 418 if (config.HasClientSentConnectionOption(kACKD, perspective_)) {
418 ack_decimation_enabled_ = true; 419 ack_mode_ = ACK_DECIMATION;
420 }
421 if (FLAGS_quic_ack_decimation2 &&
422 config.HasClientSentConnectionOption(kAKD2, perspective_)) {
423 ack_mode_ = ACK_DECIMATION_WITH_REORDERING;
419 } 424 }
420 } 425 }
421 426
422 void QuicConnection::OnSendConnectionState( 427 void QuicConnection::OnSendConnectionState(
423 const CachedNetworkParameters& cached_network_params) { 428 const CachedNetworkParameters& cached_network_params) {
424 if (debug_visitor_ != nullptr) { 429 if (debug_visitor_ != nullptr) {
425 debug_visitor_->OnSendConnectionState(cached_network_params); 430 debug_visitor_->OnSendConnectionState(cached_network_params);
426 } 431 }
427 } 432 }
428 433
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 ++num_packets_received_since_last_ack_sent_; 1031 ++num_packets_received_since_last_ack_sent_;
1027 // Always send an ack every 20 packets in order to allow the peer to discard 1032 // Always send an ack every 20 packets in order to allow the peer to discard
1028 // information from the SentPacketManager and provide an RTT measurement. 1033 // information from the SentPacketManager and provide an RTT measurement.
1029 if (num_packets_received_since_last_ack_sent_ >= 1034 if (num_packets_received_since_last_ack_sent_ >=
1030 kMaxPacketsReceivedBeforeAckSend) { 1035 kMaxPacketsReceivedBeforeAckSend) {
1031 ack_queued_ = true; 1036 ack_queued_ = true;
1032 } 1037 }
1033 1038
1034 // Determine whether the newly received packet was missing before recording 1039 // Determine whether the newly received packet was missing before recording
1035 // the received packet. 1040 // the received packet.
1036 if (was_missing) { 1041 // Ack decimation with reordering relies on the timer to send an ack, but if
1042 // missing packets we reported in the previous ack, send an ack immediately.
1043 if (was_missing && (ack_mode_ != ACK_DECIMATION_WITH_REORDERING ||
1044 last_ack_had_missing_packets_)) {
1037 ack_queued_ = true; 1045 ack_queued_ = true;
1038 } 1046 }
1039 1047
1040 if (should_last_packet_instigate_acks_ && !ack_queued_) { 1048 if (should_last_packet_instigate_acks_ && !ack_queued_) {
1041 ++num_retransmittable_packets_received_since_last_ack_sent_; 1049 ++num_retransmittable_packets_received_since_last_ack_sent_;
1042 if (ack_decimation_enabled_ && 1050 if (ack_mode_ != TCP_ACKING &&
1043 last_header_.packet_number > kMinReceivedBeforeAckDecimation) { 1051 last_header_.packet_number > kMinReceivedBeforeAckDecimation) {
1044 // Ack up to 10 packets at once. 1052 // Ack up to 10 packets at once.
1045 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1053 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
1046 kMaxRetransmittablePacketsBeforeAck) { 1054 kMaxRetransmittablePacketsBeforeAck) {
1047 ack_queued_ = true; 1055 ack_queued_ = true;
1048 } else if (!ack_alarm_->IsSet()) { 1056 } else if (!ack_alarm_->IsSet()) {
1049 // Wait the minimum of a quarter min_rtt and the delayed ack time. 1057 // Wait the minimum of a quarter min_rtt and the delayed ack time.
1050 QuicTime::Delta ack_delay = QuicTime::Delta::Min( 1058 QuicTime::Delta ack_delay = QuicTime::Delta::Min(
1051 sent_packet_manager_.DelayedAckTime(), 1059 sent_packet_manager_.DelayedAckTime(),
1052 sent_packet_manager_.GetRttStats()->min_rtt().Multiply(0.25)); 1060 sent_packet_manager_.GetRttStats()->min_rtt().Multiply(0.25));
1053 ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay)); 1061 ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay));
1054 } 1062 }
1055 } else { 1063 } else {
1056 // Ack with a timer or every 2 packets by default. 1064 // Ack with a timer or every 2 packets by default.
1057 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1065 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
1058 kDefaultRetransmittablePacketsBeforeAck) { 1066 kDefaultRetransmittablePacketsBeforeAck) {
1059 ack_queued_ = true; 1067 ack_queued_ = true;
1060 } else if (!ack_alarm_->IsSet()) { 1068 } else if (!ack_alarm_->IsSet()) {
1061 ack_alarm_->Set(clock_->ApproximateNow().Add( 1069 ack_alarm_->Set(clock_->ApproximateNow().Add(
1062 sent_packet_manager_.DelayedAckTime())); 1070 sent_packet_manager_.DelayedAckTime()));
1063 } 1071 }
1064 } 1072 }
1065 1073
1066 // If there are new missing packets to report, send an ack immediately. 1074 // If there are new missing packets to report, send an ack immediately.
1067 // TODO(ianswett): Consider allowing 1ms of reordering for the
1068 // ack decimation experiment.
1069 if (received_packet_manager_.HasNewMissingPackets()) { 1075 if (received_packet_manager_.HasNewMissingPackets()) {
1070 ack_queued_ = true; 1076 if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) {
1077 // Wait the minimum of an eighth min_rtt and the existing ack time.
1078 QuicTime ack_time = clock_->ApproximateNow().Add(
1079 sent_packet_manager_.GetRttStats()->min_rtt().Multiply(0.125));
1080 if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) {
1081 ack_alarm_->Cancel();
1082 ack_alarm_->Set(ack_time);
1083 }
1084 } else {
1085 ack_queued_ = true;
1086 }
1071 } 1087 }
1072 } 1088 }
1073 1089
1074 if (ack_queued_) { 1090 if (ack_queued_) {
1075 ack_alarm_->Cancel(); 1091 ack_alarm_->Cancel();
1076 } 1092 }
1077 } 1093 }
1078 1094
1079 void QuicConnection::ClearLastFrames() { 1095 void QuicConnection::ClearLastFrames() {
1080 should_last_packet_instigate_acks_ = false; 1096 should_last_packet_instigate_acks_ = false;
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame())); 1862 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame()));
1847 // Send PING frame immediately, without checking for congestion window bounds. 1863 // Send PING frame immediately, without checking for congestion window bounds.
1848 packet_generator_.FlushAllQueuedFrames(); 1864 packet_generator_.FlushAllQueuedFrames();
1849 } 1865 }
1850 1866
1851 void QuicConnection::SendAck() { 1867 void QuicConnection::SendAck() {
1852 ack_alarm_->Cancel(); 1868 ack_alarm_->Cancel();
1853 ack_queued_ = false; 1869 ack_queued_ = false;
1854 stop_waiting_count_ = 0; 1870 stop_waiting_count_ = 0;
1855 num_retransmittable_packets_received_since_last_ack_sent_ = 0; 1871 num_retransmittable_packets_received_since_last_ack_sent_ = 0;
1872 last_ack_had_missing_packets_ = received_packet_manager_.HasMissingPackets();
1856 num_packets_received_since_last_ack_sent_ = 0; 1873 num_packets_received_since_last_ack_sent_ = 0;
1857 1874
1858 packet_generator_.SetShouldSendAck(true); 1875 packet_generator_.SetShouldSendAck(true);
1859 } 1876 }
1860 1877
1861 void QuicConnection::OnRetransmissionTimeout() { 1878 void QuicConnection::OnRetransmissionTimeout() {
1862 if (!sent_packet_manager_.HasUnackedPackets()) { 1879 if (!sent_packet_manager_.HasUnackedPackets()) {
1863 return; 1880 return;
1864 } 1881 }
1865 1882
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 void QuicConnection::OnPathClosed(QuicPathId path_id) { 2513 void QuicConnection::OnPathClosed(QuicPathId path_id) {
2497 // Stop receiving packets on this path. 2514 // Stop receiving packets on this path.
2498 framer_.OnPathClosed(path_id); 2515 framer_.OnPathClosed(path_id);
2499 } 2516 }
2500 2517
2501 bool QuicConnection::ack_frame_updated() const { 2518 bool QuicConnection::ack_frame_updated() const {
2502 return received_packet_manager_.ack_frame_updated(); 2519 return received_packet_manager_.ack_frame_updated();
2503 } 2520 }
2504 2521
2505 } // namespace net 2522 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698