| OLD | NEW |
| 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/core/quic_connection.h" | 5 #include "net/quic/core/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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 should_last_packet_instigate_acks_(false), | 200 should_last_packet_instigate_acks_(false), |
| 201 was_last_packet_missing_(false), | 201 was_last_packet_missing_(false), |
| 202 largest_seen_packet_with_ack_(0), | 202 largest_seen_packet_with_ack_(0), |
| 203 largest_seen_packet_with_stop_waiting_(0), | 203 largest_seen_packet_with_stop_waiting_(0), |
| 204 max_undecryptable_packets_(0), | 204 max_undecryptable_packets_(0), |
| 205 pending_version_negotiation_packet_(false), | 205 pending_version_negotiation_packet_(false), |
| 206 save_crypto_packets_as_termination_packets_(false), | 206 save_crypto_packets_as_termination_packets_(false), |
| 207 idle_timeout_connection_close_behavior_( | 207 idle_timeout_connection_close_behavior_( |
| 208 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET), | 208 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET), |
| 209 close_connection_after_five_rtos_(false), | 209 close_connection_after_five_rtos_(false), |
| 210 close_connection_after_three_rtos_(false), |
| 210 received_packet_manager_(&stats_), | 211 received_packet_manager_(&stats_), |
| 211 ack_queued_(false), | 212 ack_queued_(false), |
| 212 num_retransmittable_packets_received_since_last_ack_sent_(0), | 213 num_retransmittable_packets_received_since_last_ack_sent_(0), |
| 213 last_ack_had_missing_packets_(false), | 214 last_ack_had_missing_packets_(false), |
| 214 num_packets_received_since_last_ack_sent_(0), | 215 num_packets_received_since_last_ack_sent_(0), |
| 215 stop_waiting_count_(0), | 216 stop_waiting_count_(0), |
| 216 ack_mode_(TCP_ACKING), | 217 ack_mode_(TCP_ACKING), |
| 217 ack_decimation_delay_(kAckDecimationDelay), | 218 ack_decimation_delay_(kAckDecimationDelay), |
| 218 delay_setting_retransmission_alarm_(false), | 219 delay_setting_retransmission_alarm_(false), |
| 219 pending_retransmission_alarm_(false), | 220 pending_retransmission_alarm_(false), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 ack_mode_ = ACK_DECIMATION; | 345 ack_mode_ = ACK_DECIMATION; |
| 345 ack_decimation_delay_ = kShortAckDecimationDelay; | 346 ack_decimation_delay_ = kShortAckDecimationDelay; |
| 346 } | 347 } |
| 347 if (config.HasClientSentConnectionOption(kAKD4, perspective_)) { | 348 if (config.HasClientSentConnectionOption(kAKD4, perspective_)) { |
| 348 ack_mode_ = ACK_DECIMATION_WITH_REORDERING; | 349 ack_mode_ = ACK_DECIMATION_WITH_REORDERING; |
| 349 ack_decimation_delay_ = kShortAckDecimationDelay; | 350 ack_decimation_delay_ = kShortAckDecimationDelay; |
| 350 } | 351 } |
| 351 if (config.HasClientSentConnectionOption(k5RTO, perspective_)) { | 352 if (config.HasClientSentConnectionOption(k5RTO, perspective_)) { |
| 352 close_connection_after_five_rtos_ = true; | 353 close_connection_after_five_rtos_ = true; |
| 353 } | 354 } |
| 355 if (FLAGS_quic_reloadable_flag_quic_enable_3rtos && |
| 356 config.HasClientSentConnectionOption(k3RTO, perspective_)) { |
| 357 QUIC_FLAG_COUNT(quic_reloadable_flag_quic_enable_3rtos); |
| 358 close_connection_after_three_rtos_ = true; |
| 359 } |
| 354 if (packet_generator_.latched_flag_no_stop_waiting_frames() && | 360 if (packet_generator_.latched_flag_no_stop_waiting_frames() && |
| 355 version() > QUIC_VERSION_37 && | 361 version() > QUIC_VERSION_37 && |
| 356 config.HasClientSentConnectionOption(kNSTP, perspective_)) { | 362 config.HasClientSentConnectionOption(kNSTP, perspective_)) { |
| 357 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_no_stop_waiting_frames, 2, 2); | 363 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_no_stop_waiting_frames, 2, 2); |
| 358 no_stop_waiting_frames_ = true; | 364 no_stop_waiting_frames_ = true; |
| 359 } | 365 } |
| 360 } | 366 } |
| 361 | 367 |
| 362 void QuicConnection::OnSendConnectionState( | 368 void QuicConnection::OnSendConnectionState( |
| 363 const CachedNetworkParameters& cached_network_params) { | 369 const CachedNetworkParameters& cached_network_params) { |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 } | 1122 } |
| 1117 RemoveFramesForStream(retransmittable_frames, id); | 1123 RemoveFramesForStream(retransmittable_frames, id); |
| 1118 if (!retransmittable_frames->empty()) { | 1124 if (!retransmittable_frames->empty()) { |
| 1119 ++packet_iterator; | 1125 ++packet_iterator; |
| 1120 continue; | 1126 continue; |
| 1121 } | 1127 } |
| 1122 delete[] packet_iterator->encrypted_buffer; | 1128 delete[] packet_iterator->encrypted_buffer; |
| 1123 ClearSerializedPacket(&(*packet_iterator)); | 1129 ClearSerializedPacket(&(*packet_iterator)); |
| 1124 packet_iterator = queued_packets_.erase(packet_iterator); | 1130 packet_iterator = queued_packets_.erase(packet_iterator); |
| 1125 } | 1131 } |
| 1132 // TODO(ianswett): Consider checking for 3 RTOs when the last stream is |
| 1133 // cancelled as well. |
| 1126 } | 1134 } |
| 1127 | 1135 |
| 1128 void QuicConnection::SendWindowUpdate(QuicStreamId id, | 1136 void QuicConnection::SendWindowUpdate(QuicStreamId id, |
| 1129 QuicStreamOffset byte_offset) { | 1137 QuicStreamOffset byte_offset) { |
| 1130 // Opportunistically bundle an ack with this outgoing packet. | 1138 // Opportunistically bundle an ack with this outgoing packet. |
| 1131 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1139 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
| 1132 packet_generator_.AddControlFrame( | 1140 packet_generator_.AddControlFrame( |
| 1133 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset))); | 1141 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset))); |
| 1134 } | 1142 } |
| 1135 | 1143 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 visitor_->OnAckNeedsRetransmittableFrame(); | 1787 visitor_->OnAckNeedsRetransmittableFrame(); |
| 1780 if (!packet_generator_.HasRetransmittableFrames()) { | 1788 if (!packet_generator_.HasRetransmittableFrames()) { |
| 1781 // Visitor did not add a retransmittable frame, add a ping frame. | 1789 // Visitor did not add a retransmittable frame, add a ping frame. |
| 1782 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame())); | 1790 packet_generator_.AddControlFrame(QuicFrame(QuicPingFrame())); |
| 1783 } | 1791 } |
| 1784 } | 1792 } |
| 1785 | 1793 |
| 1786 void QuicConnection::OnRetransmissionTimeout() { | 1794 void QuicConnection::OnRetransmissionTimeout() { |
| 1787 DCHECK(sent_packet_manager_.HasUnackedPackets()); | 1795 DCHECK(sent_packet_manager_.HasUnackedPackets()); |
| 1788 | 1796 |
| 1797 if (close_connection_after_three_rtos_ && |
| 1798 sent_packet_manager_.GetConsecutiveRtoCount() >= 2 && |
| 1799 !visitor_->HasOpenDynamicStreams()) { |
| 1800 // Close on the 3rd consecutive RTO, so after 2 previous RTOs have occurred. |
| 1801 CloseConnection(QUIC_TOO_MANY_RTOS, "3 consecutive retransmission timeouts", |
| 1802 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1803 return; |
| 1804 } |
| 1789 if (close_connection_after_five_rtos_ && | 1805 if (close_connection_after_five_rtos_ && |
| 1790 sent_packet_manager_.GetConsecutiveRtoCount() >= 4) { | 1806 sent_packet_manager_.GetConsecutiveRtoCount() >= 4) { |
| 1791 // Close on the 5th consecutive RTO, so after 4 previous RTOs have occurred. | 1807 // Close on the 5th consecutive RTO, so after 4 previous RTOs have occurred. |
| 1792 CloseConnection(QUIC_TOO_MANY_RTOS, "5 consecutive retransmission timeouts", | 1808 CloseConnection(QUIC_TOO_MANY_RTOS, "5 consecutive retransmission timeouts", |
| 1793 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1809 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1794 return; | 1810 return; |
| 1795 } | 1811 } |
| 1796 | 1812 |
| 1797 sent_packet_manager_.OnRetransmissionTimeout(); | 1813 sent_packet_manager_.OnRetransmissionTimeout(); |
| 1798 WriteIfNotBlocked(); | 1814 WriteIfNotBlocked(); |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 | 2436 |
| 2421 void QuicConnection::CheckIfApplicationLimited() { | 2437 void QuicConnection::CheckIfApplicationLimited() { |
| 2422 if (queued_packets_.empty() && | 2438 if (queued_packets_.empty() && |
| 2423 !sent_packet_manager_.HasPendingRetransmissions() && | 2439 !sent_packet_manager_.HasPendingRetransmissions() && |
| 2424 !visitor_->WillingAndAbleToWrite()) { | 2440 !visitor_->WillingAndAbleToWrite()) { |
| 2425 sent_packet_manager_.OnApplicationLimited(); | 2441 sent_packet_manager_.OnApplicationLimited(); |
| 2426 } | 2442 } |
| 2427 } | 2443 } |
| 2428 | 2444 |
| 2429 } // namespace net | 2445 } // namespace net |
| OLD | NEW |