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

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

Issue 1918953003: Landing Recent QUIC changes until 4/22/2016 14:55 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deleted SpdyFramerTests missed while mergeing 120451808 Created 4 years, 8 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const QuicPacketCount kMaxPacketsReceivedBeforeAckSend = 20; 62 const QuicPacketCount kMaxPacketsReceivedBeforeAckSend = 20;
63 63
64 // Maximum number of retransmittable packets received before sending an ack. 64 // Maximum number of retransmittable packets received before sending an ack.
65 const QuicPacketCount kDefaultRetransmittablePacketsBeforeAck = 2; 65 const QuicPacketCount kDefaultRetransmittablePacketsBeforeAck = 2;
66 // Minimum number of packets received before ack decimation is enabled. 66 // Minimum number of packets received before ack decimation is enabled.
67 // This intends to avoid the beginning of slow start, when CWNDs may be 67 // This intends to avoid the beginning of slow start, when CWNDs may be
68 // rapidly increasing. 68 // rapidly increasing.
69 const QuicPacketCount kMinReceivedBeforeAckDecimation = 100; 69 const QuicPacketCount kMinReceivedBeforeAckDecimation = 100;
70 // Wait for up to 10 retransmittable packets before sending an ack. 70 // Wait for up to 10 retransmittable packets before sending an ack.
71 const QuicPacketCount kMaxRetransmittablePacketsBeforeAck = 10; 71 const QuicPacketCount kMaxRetransmittablePacketsBeforeAck = 10;
72 // One quarter RTT delay when doing ack decimation.
73 const float kAckDecimationDelay = 0.25;
74 // One eighth RTT delay when doing ack decimation.
75 const float kShortAckDecimationDelay = 0.125;
72 76
73 bool Near(QuicPacketNumber a, QuicPacketNumber b) { 77 bool Near(QuicPacketNumber a, QuicPacketNumber b) {
74 QuicPacketNumber delta = (a > b) ? a - b : b - a; 78 QuicPacketNumber delta = (a > b) ? a - b : b - a;
75 return delta <= kMaxPacketGap; 79 return delta <= kMaxPacketGap;
76 } 80 }
77 81
78 bool IsInitializedIPEndPoint(const IPEndPoint& address) { 82 bool IsInitializedIPEndPoint(const IPEndPoint& address) {
79 return net::GetAddressFamily(address.address()) != 83 return net::GetAddressFamily(address.address()) !=
80 net::ADDRESS_FAMILY_UNSPECIFIED; 84 net::ADDRESS_FAMILY_UNSPECIFIED;
81 } 85 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 idle_timeout_connection_close_behavior_( 243 idle_timeout_connection_close_behavior_(
240 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET), 244 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET),
241 close_connection_after_five_rtos_(false), 245 close_connection_after_five_rtos_(false),
242 received_packet_manager_(&stats_), 246 received_packet_manager_(&stats_),
243 ack_queued_(false), 247 ack_queued_(false),
244 num_retransmittable_packets_received_since_last_ack_sent_(0), 248 num_retransmittable_packets_received_since_last_ack_sent_(0),
245 last_ack_had_missing_packets_(false), 249 last_ack_had_missing_packets_(false),
246 num_packets_received_since_last_ack_sent_(0), 250 num_packets_received_since_last_ack_sent_(0),
247 stop_waiting_count_(0), 251 stop_waiting_count_(0),
248 ack_mode_(TCP_ACKING), 252 ack_mode_(TCP_ACKING),
253 ack_decimation_delay_(kAckDecimationDelay),
249 delay_setting_retransmission_alarm_(false), 254 delay_setting_retransmission_alarm_(false),
250 pending_retransmission_alarm_(false), 255 pending_retransmission_alarm_(false),
251 defer_send_in_response_to_packets_(false), 256 defer_send_in_response_to_packets_(false),
252 arena_(), 257 arena_(),
253 ack_alarm_( 258 ack_alarm_(
254 alarm_factory_->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)), 259 alarm_factory_->CreateAlarm(arena_.New<AckAlarm>(this), &arena_)),
255 retransmission_alarm_( 260 retransmission_alarm_(
256 alarm_factory_->CreateAlarm(arena_.New<RetransmissionAlarm>(this), 261 alarm_factory_->CreateAlarm(arena_.New<RetransmissionAlarm>(this),
257 &arena_)), 262 &arena_)),
258 send_alarm_( 263 send_alarm_(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 370 }
366 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) { 371 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) {
367 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow); 372 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow);
368 } 373 }
369 if (debug_visitor_ != nullptr) { 374 if (debug_visitor_ != nullptr) {
370 debug_visitor_->OnSetFromConfig(config); 375 debug_visitor_->OnSetFromConfig(config);
371 } 376 }
372 if (config.HasClientSentConnectionOption(kACKD, perspective_)) { 377 if (config.HasClientSentConnectionOption(kACKD, perspective_)) {
373 ack_mode_ = ACK_DECIMATION; 378 ack_mode_ = ACK_DECIMATION;
374 } 379 }
375 if (FLAGS_quic_ack_decimation2 && 380 if (config.HasClientSentConnectionOption(kAKD2, perspective_)) {
376 config.HasClientSentConnectionOption(kAKD2, perspective_)) {
377 ack_mode_ = ACK_DECIMATION_WITH_REORDERING; 381 ack_mode_ = ACK_DECIMATION_WITH_REORDERING;
378 } 382 }
383 if (config.HasClientSentConnectionOption(kAKD3, perspective_)) {
384 ack_mode_ = ACK_DECIMATION;
385 ack_decimation_delay_ = kShortAckDecimationDelay;
386 }
387 if (config.HasClientSentConnectionOption(kAKD4, perspective_)) {
388 ack_mode_ = ACK_DECIMATION_WITH_REORDERING;
389 ack_decimation_delay_ = kShortAckDecimationDelay;
390 }
379 if (FLAGS_quic_enable_rto_timeout && 391 if (FLAGS_quic_enable_rto_timeout &&
380 config.HasClientSentConnectionOption(k5RTO, perspective_)) { 392 config.HasClientSentConnectionOption(k5RTO, perspective_)) {
381 close_connection_after_five_rtos_ = true; 393 close_connection_after_five_rtos_ = true;
382 } 394 }
383 } 395 }
384 396
385 void QuicConnection::OnSendConnectionState( 397 void QuicConnection::OnSendConnectionState(
386 const CachedNetworkParameters& cached_network_params) { 398 const CachedNetworkParameters& cached_network_params) {
387 if (debug_visitor_ != nullptr) { 399 if (debug_visitor_ != nullptr) {
388 debug_visitor_->OnSendConnectionState(cached_network_params); 400 debug_visitor_->OnSendConnectionState(cached_network_params);
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 769 }
758 770
759 if (debug_visitor_ != nullptr) { 771 if (debug_visitor_ != nullptr) {
760 debug_visitor_->OnStopWaitingFrame(frame); 772 debug_visitor_->OnStopWaitingFrame(frame);
761 } 773 }
762 774
763 last_stop_waiting_frame_ = frame; 775 last_stop_waiting_frame_ = frame;
764 return connected_; 776 return connected_;
765 } 777 }
766 778
779 bool QuicConnection::OnPaddingFrame(const QuicPaddingFrame& frame) {
780 DCHECK(connected_);
781 if (debug_visitor_ != nullptr) {
782 debug_visitor_->OnPaddingFrame(frame);
783 }
784 return true;
785 }
786
767 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { 787 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) {
768 DCHECK(connected_); 788 DCHECK(connected_);
769 if (debug_visitor_ != nullptr) { 789 if (debug_visitor_ != nullptr) {
770 debug_visitor_->OnPingFrame(frame); 790 debug_visitor_->OnPingFrame(frame);
771 } 791 }
772 should_last_packet_instigate_acks_ = true; 792 should_last_packet_instigate_acks_ = true;
773 return true; 793 return true;
774 } 794 }
775 795
776 const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { 796 const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 if (ack_mode_ != TCP_ACKING && 1011 if (ack_mode_ != TCP_ACKING &&
992 last_header_.packet_number > kMinReceivedBeforeAckDecimation) { 1012 last_header_.packet_number > kMinReceivedBeforeAckDecimation) {
993 // Ack up to 10 packets at once. 1013 // Ack up to 10 packets at once.
994 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1014 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
995 kMaxRetransmittablePacketsBeforeAck) { 1015 kMaxRetransmittablePacketsBeforeAck) {
996 ack_queued_ = true; 1016 ack_queued_ = true;
997 } else if (!ack_alarm_->IsSet()) { 1017 } else if (!ack_alarm_->IsSet()) {
998 // Wait the minimum of a quarter min_rtt and the delayed ack time. 1018 // Wait the minimum of a quarter min_rtt and the delayed ack time.
999 QuicTime::Delta ack_delay = QuicTime::Delta::Min( 1019 QuicTime::Delta ack_delay = QuicTime::Delta::Min(
1000 sent_packet_manager_.DelayedAckTime(), 1020 sent_packet_manager_.DelayedAckTime(),
1001 sent_packet_manager_.GetRttStats()->min_rtt().Multiply(0.25)); 1021 sent_packet_manager_.GetRttStats()->min_rtt().Multiply(
1022 ack_decimation_delay_));
1002 ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay)); 1023 ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay));
1003 } 1024 }
1004 } else { 1025 } else {
1005 // Ack with a timer or every 2 packets by default. 1026 // Ack with a timer or every 2 packets by default.
1006 if (num_retransmittable_packets_received_since_last_ack_sent_ >= 1027 if (num_retransmittable_packets_received_since_last_ack_sent_ >=
1007 kDefaultRetransmittablePacketsBeforeAck) { 1028 kDefaultRetransmittablePacketsBeforeAck) {
1008 ack_queued_ = true; 1029 ack_queued_ = true;
1009 } else if (!ack_alarm_->IsSet()) { 1030 } else if (!ack_alarm_->IsSet()) {
1010 ack_alarm_->Set(clock_->ApproximateNow().Add( 1031 ack_alarm_->Set(clock_->ApproximateNow().Add(
1011 sent_packet_manager_.DelayedAckTime())); 1032 sent_packet_manager_.DelayedAckTime()));
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 ack_queued_ = false; 1804 ack_queued_ = false;
1784 stop_waiting_count_ = 0; 1805 stop_waiting_count_ = 0;
1785 num_retransmittable_packets_received_since_last_ack_sent_ = 0; 1806 num_retransmittable_packets_received_since_last_ack_sent_ = 0;
1786 last_ack_had_missing_packets_ = received_packet_manager_.HasMissingPackets(); 1807 last_ack_had_missing_packets_ = received_packet_manager_.HasMissingPackets();
1787 num_packets_received_since_last_ack_sent_ = 0; 1808 num_packets_received_since_last_ack_sent_ = 0;
1788 1809
1789 packet_generator_.SetShouldSendAck(true); 1810 packet_generator_.SetShouldSendAck(true);
1790 } 1811 }
1791 1812
1792 void QuicConnection::OnRetransmissionTimeout() { 1813 void QuicConnection::OnRetransmissionTimeout() {
1793 if (!sent_packet_manager_.HasUnackedPackets()) { 1814 if (FLAGS_quic_always_has_unacked_packets_on_timeout) {
1794 return; 1815 DCHECK(sent_packet_manager_.HasUnackedPackets());
1816 } else {
1817 if (!sent_packet_manager_.HasUnackedPackets()) {
1818 return;
1819 }
1795 } 1820 }
1796 1821
1797 if (close_connection_after_five_rtos_ && 1822 if (close_connection_after_five_rtos_ &&
1798 sent_packet_manager_.consecutive_rto_count() >= 4) { 1823 sent_packet_manager_.consecutive_rto_count() >= 4) {
1799 // Close on the 5th consecutive RTO, so after 4 previous RTOs have occurred. 1824 // Close on the 5th consecutive RTO, so after 4 previous RTOs have occurred.
1800 CloseConnection(QUIC_TOO_MANY_RTOS, "5 consecutive retransmission timeouts", 1825 CloseConnection(QUIC_TOO_MANY_RTOS, "5 consecutive retransmission timeouts",
1801 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 1826 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
1802 return; 1827 return;
1803 } 1828 }
1804 1829
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 } 2387 }
2363 2388
2364 StringPiece QuicConnection::GetCurrentPacket() { 2389 StringPiece QuicConnection::GetCurrentPacket() {
2365 if (current_packet_data_ == nullptr) { 2390 if (current_packet_data_ == nullptr) {
2366 return StringPiece(); 2391 return StringPiece();
2367 } 2392 }
2368 return StringPiece(current_packet_data_, last_size_); 2393 return StringPiece(current_packet_data_, last_size_);
2369 } 2394 }
2370 2395
2371 } // namespace net 2396 } // 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