| 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/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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 last_size_(0), | 228 last_size_(0), |
| 229 current_packet_data_(nullptr), | 229 current_packet_data_(nullptr), |
| 230 last_decrypted_packet_level_(ENCRYPTION_NONE), | 230 last_decrypted_packet_level_(ENCRYPTION_NONE), |
| 231 should_last_packet_instigate_acks_(false), | 231 should_last_packet_instigate_acks_(false), |
| 232 largest_seen_packet_with_ack_(0), | 232 largest_seen_packet_with_ack_(0), |
| 233 largest_seen_packet_with_stop_waiting_(0), | 233 largest_seen_packet_with_stop_waiting_(0), |
| 234 max_undecryptable_packets_(0), | 234 max_undecryptable_packets_(0), |
| 235 pending_version_negotiation_packet_(false), | 235 pending_version_negotiation_packet_(false), |
| 236 save_crypto_packets_as_termination_packets_(false), | 236 save_crypto_packets_as_termination_packets_(false), |
| 237 silent_close_enabled_(false), | 237 silent_close_enabled_(false), |
| 238 close_connection_after_five_rtos_(false), |
| 238 received_packet_manager_(&stats_), | 239 received_packet_manager_(&stats_), |
| 239 ack_queued_(false), | 240 ack_queued_(false), |
| 240 num_retransmittable_packets_received_since_last_ack_sent_(0), | 241 num_retransmittable_packets_received_since_last_ack_sent_(0), |
| 241 last_ack_had_missing_packets_(false), | 242 last_ack_had_missing_packets_(false), |
| 242 num_packets_received_since_last_ack_sent_(0), | 243 num_packets_received_since_last_ack_sent_(0), |
| 243 stop_waiting_count_(0), | 244 stop_waiting_count_(0), |
| 244 ack_mode_(TCP_ACKING), | 245 ack_mode_(TCP_ACKING), |
| 245 delay_setting_retransmission_alarm_(false), | 246 delay_setting_retransmission_alarm_(false), |
| 246 pending_retransmission_alarm_(false), | 247 pending_retransmission_alarm_(false), |
| 247 defer_send_in_response_to_packets_(false), | 248 defer_send_in_response_to_packets_(false), |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 if (debug_visitor_ != nullptr) { | 364 if (debug_visitor_ != nullptr) { |
| 364 debug_visitor_->OnSetFromConfig(config); | 365 debug_visitor_->OnSetFromConfig(config); |
| 365 } | 366 } |
| 366 if (config.HasClientSentConnectionOption(kACKD, perspective_)) { | 367 if (config.HasClientSentConnectionOption(kACKD, perspective_)) { |
| 367 ack_mode_ = ACK_DECIMATION; | 368 ack_mode_ = ACK_DECIMATION; |
| 368 } | 369 } |
| 369 if (FLAGS_quic_ack_decimation2 && | 370 if (FLAGS_quic_ack_decimation2 && |
| 370 config.HasClientSentConnectionOption(kAKD2, perspective_)) { | 371 config.HasClientSentConnectionOption(kAKD2, perspective_)) { |
| 371 ack_mode_ = ACK_DECIMATION_WITH_REORDERING; | 372 ack_mode_ = ACK_DECIMATION_WITH_REORDERING; |
| 372 } | 373 } |
| 374 if (FLAGS_quic_enable_rto_timeout && |
| 375 config.HasClientSentConnectionOption(k5RTO, perspective_)) { |
| 376 close_connection_after_five_rtos_ = true; |
| 377 } |
| 373 } | 378 } |
| 374 | 379 |
| 375 void QuicConnection::OnSendConnectionState( | 380 void QuicConnection::OnSendConnectionState( |
| 376 const CachedNetworkParameters& cached_network_params) { | 381 const CachedNetworkParameters& cached_network_params) { |
| 377 if (debug_visitor_ != nullptr) { | 382 if (debug_visitor_ != nullptr) { |
| 378 debug_visitor_->OnSendConnectionState(cached_network_params); | 383 debug_visitor_->OnSendConnectionState(cached_network_params); |
| 379 } | 384 } |
| 380 } | 385 } |
| 381 | 386 |
| 382 void QuicConnection::OnReceiveConnectionState( | 387 void QuicConnection::OnReceiveConnectionState( |
| (...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 num_packets_received_since_last_ack_sent_ = 0; | 1780 num_packets_received_since_last_ack_sent_ = 0; |
| 1776 | 1781 |
| 1777 packet_generator_.SetShouldSendAck(true); | 1782 packet_generator_.SetShouldSendAck(true); |
| 1778 } | 1783 } |
| 1779 | 1784 |
| 1780 void QuicConnection::OnRetransmissionTimeout() { | 1785 void QuicConnection::OnRetransmissionTimeout() { |
| 1781 if (!sent_packet_manager_.HasUnackedPackets()) { | 1786 if (!sent_packet_manager_.HasUnackedPackets()) { |
| 1782 return; | 1787 return; |
| 1783 } | 1788 } |
| 1784 | 1789 |
| 1790 if (close_connection_after_five_rtos_ && |
| 1791 sent_packet_manager_.consecutive_rto_count() >= 4) { |
| 1792 // Close on the 5th consecutive RTO, so after 4 previous RTOs have occurred. |
| 1793 SendConnectionCloseWithDetails(QUIC_TOO_MANY_RTOS, |
| 1794 "5 consecutive retransmission timeouts"); |
| 1795 return; |
| 1796 } |
| 1797 |
| 1785 sent_packet_manager_.OnRetransmissionTimeout(); | 1798 sent_packet_manager_.OnRetransmissionTimeout(); |
| 1786 WriteIfNotBlocked(); | 1799 WriteIfNotBlocked(); |
| 1787 | 1800 |
| 1788 // A write failure can result in the connection being closed, don't attempt to | 1801 // A write failure can result in the connection being closed, don't attempt to |
| 1789 // write further packets, or to set alarms. | 1802 // write further packets, or to set alarms. |
| 1790 if (!connected_) { | 1803 if (!connected_) { |
| 1791 return; | 1804 return; |
| 1792 } | 1805 } |
| 1793 | 1806 |
| 1794 // In the TLP case, the SentPacketManager gives the connection the opportunity | 1807 // In the TLP case, the SentPacketManager gives the connection the opportunity |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 } | 2349 } |
| 2337 | 2350 |
| 2338 StringPiece QuicConnection::GetCurrentPacket() { | 2351 StringPiece QuicConnection::GetCurrentPacket() { |
| 2339 if (current_packet_data_ == nullptr) { | 2352 if (current_packet_data_ == nullptr) { |
| 2340 return StringPiece(); | 2353 return StringPiece(); |
| 2341 } | 2354 } |
| 2342 return StringPiece(current_packet_data_, last_size_); | 2355 return StringPiece(current_packet_data_, last_size_); |
| 2343 } | 2356 } |
| 2344 | 2357 |
| 2345 } // namespace net | 2358 } // namespace net |
| OLD | NEW |