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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 largest_received_packet_size_(0), | 311 largest_received_packet_size_(0), |
312 goaway_sent_(false), | 312 goaway_sent_(false), |
313 goaway_received_(false), | 313 goaway_received_(false), |
314 multipath_enabled_(false) { | 314 multipath_enabled_(false) { |
315 DVLOG(1) << ENDPOINT | 315 DVLOG(1) << ENDPOINT |
316 << "Created connection with connection_id: " << connection_id; | 316 << "Created connection with connection_id: " << connection_id; |
317 framer_.set_visitor(this); | 317 framer_.set_visitor(this); |
318 framer_.set_received_entropy_calculator(&received_packet_manager_); | 318 framer_.set_received_entropy_calculator(&received_packet_manager_); |
319 last_stop_waiting_frame_.least_unacked = 0; | 319 last_stop_waiting_frame_.least_unacked = 0; |
320 stats_.connection_creation_time = clock_->ApproximateNow(); | 320 stats_.connection_creation_time = clock_->ApproximateNow(); |
| 321 // TODO(ianswett): Supply the NetworkChangeVisitor as a constructor argument |
| 322 // and make it required non-null, because it's always used. |
321 sent_packet_manager_->SetNetworkChangeVisitor(this); | 323 sent_packet_manager_->SetNetworkChangeVisitor(this); |
322 // Allow the packet writer to potentially reduce the packet size to a value | 324 // Allow the packet writer to potentially reduce the packet size to a value |
323 // even smaller than kDefaultMaxPacketSize. | 325 // even smaller than kDefaultMaxPacketSize. |
324 SetMaxPacketLength(perspective_ == Perspective::IS_SERVER | 326 SetMaxPacketLength(perspective_ == Perspective::IS_SERVER |
325 ? kDefaultServerMaxPacketSize | 327 ? kDefaultServerMaxPacketSize |
326 : kDefaultMaxPacketSize); | 328 : kDefaultMaxPacketSize); |
327 received_packet_manager_.SetVersion(version()); | 329 received_packet_manager_.SetVersion(version()); |
328 } | 330 } |
329 | 331 |
330 QuicConnection::~QuicConnection() { | 332 QuicConnection::~QuicConnection() { |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 } | 1801 } |
1800 | 1802 |
1801 if (debug_visitor_) | 1803 if (debug_visitor_) |
1802 debug_visitor_->OnRttChanged(rtt); | 1804 debug_visitor_->OnRttChanged(rtt); |
1803 } | 1805 } |
1804 | 1806 |
1805 void QuicConnection::OnPathDegrading() { | 1807 void QuicConnection::OnPathDegrading() { |
1806 visitor_->OnPathDegrading(); | 1808 visitor_->OnPathDegrading(); |
1807 } | 1809 } |
1808 | 1810 |
| 1811 void QuicConnection::OnPathMtuIncreased(QuicPacketLength packet_size) { |
| 1812 DCHECK(FLAGS_quic_no_mtu_discovery_ack_listener); |
| 1813 if (packet_size > max_packet_length()) { |
| 1814 SetMaxPacketLength(packet_size); |
| 1815 } |
| 1816 } |
| 1817 |
1809 void QuicConnection::OnHandshakeComplete() { | 1818 void QuicConnection::OnHandshakeComplete() { |
1810 sent_packet_manager_->SetHandshakeConfirmed(); | 1819 sent_packet_manager_->SetHandshakeConfirmed(); |
1811 // The client should immediately ack the SHLO to confirm the handshake is | 1820 // The client should immediately ack the SHLO to confirm the handshake is |
1812 // complete with the server. | 1821 // complete with the server. |
1813 if (perspective_ == Perspective::IS_CLIENT && !ack_queued_ && | 1822 if (perspective_ == Perspective::IS_CLIENT && !ack_queued_ && |
1814 ack_frame_updated()) { | 1823 ack_frame_updated()) { |
1815 ack_alarm_->Cancel(); | 1824 ack_alarm_->Cancel(); |
1816 ack_alarm_->Set(clock_->ApproximateNow()); | 1825 ack_alarm_->Set(clock_->ApproximateNow()); |
1817 } | 1826 } |
1818 } | 1827 } |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 | 2373 |
2365 // Create a listener for the new probe. The ownership of the listener is | 2374 // Create a listener for the new probe. The ownership of the listener is |
2366 // transferred to the AckNotifierManager. The notifier will get destroyed | 2375 // transferred to the AckNotifierManager. The notifier will get destroyed |
2367 // before the connection (because it's stored in one of the connection's | 2376 // before the connection (because it's stored in one of the connection's |
2368 // subfields), hence |this| pointer is guaranteed to stay valid at all times. | 2377 // subfields), hence |this| pointer is guaranteed to stay valid at all times. |
2369 scoped_refptr<MtuDiscoveryAckListener> last_mtu_discovery_ack_listener( | 2378 scoped_refptr<MtuDiscoveryAckListener> last_mtu_discovery_ack_listener( |
2370 new MtuDiscoveryAckListener(this, target_mtu)); | 2379 new MtuDiscoveryAckListener(this, target_mtu)); |
2371 | 2380 |
2372 // Send the probe. | 2381 // Send the probe. |
2373 packet_generator_.GenerateMtuDiscoveryPacket( | 2382 packet_generator_.GenerateMtuDiscoveryPacket( |
2374 target_mtu, last_mtu_discovery_ack_listener.get()); | 2383 target_mtu, FLAGS_quic_no_mtu_discovery_ack_listener |
| 2384 ? nullptr |
| 2385 : last_mtu_discovery_ack_listener.get()); |
2375 } | 2386 } |
2376 | 2387 |
2377 void QuicConnection::DiscoverMtu() { | 2388 void QuicConnection::DiscoverMtu() { |
2378 DCHECK(!mtu_discovery_alarm_->IsSet()); | 2389 DCHECK(!mtu_discovery_alarm_->IsSet()); |
2379 | 2390 |
2380 // Chcek if the MTU has been already increased. | 2391 // Check if the MTU has been already increased. |
2381 if (mtu_discovery_target_ <= max_packet_length()) { | 2392 if (mtu_discovery_target_ <= max_packet_length()) { |
2382 return; | 2393 return; |
2383 } | 2394 } |
2384 | 2395 |
2385 // Schedule the next probe *before* sending the current one. This is | 2396 // Calculate the packet number of the next probe *before* sending the current |
2386 // important, otherwise, when SendMtuDiscoveryPacket() is called, | 2397 // one. Otherwise, when SendMtuDiscoveryPacket() is called, |
2387 // MaybeSetMtuAlarm() will not realize that the probe has been just sent, and | 2398 // MaybeSetMtuAlarm() will not realize that the probe has been just sent, and |
2388 // will reschedule this probe again. | 2399 // will reschedule this probe again. |
2389 packets_between_mtu_probes_ *= 2; | 2400 packets_between_mtu_probes_ *= 2; |
2390 next_mtu_probe_at_ = | 2401 next_mtu_probe_at_ = |
2391 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; | 2402 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; |
2392 ++mtu_probe_count_; | 2403 ++mtu_probe_count_; |
2393 | 2404 |
2394 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; | 2405 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; |
2395 SendMtuDiscoveryPacket(mtu_discovery_target_); | 2406 SendMtuDiscoveryPacket(mtu_discovery_target_); |
2396 | 2407 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 // the sender and a signaling mechanism -- if the sender uses a | 2501 // the sender and a signaling mechanism -- if the sender uses a |
2491 // different MinRTO, we may get spurious retransmissions. May not have | 2502 // different MinRTO, we may get spurious retransmissions. May not have |
2492 // any benefits, but if the delayed ack becomes a significant source | 2503 // any benefits, but if the delayed ack becomes a significant source |
2493 // of (likely, tail) latency, then consider such a mechanism. | 2504 // of (likely, tail) latency, then consider such a mechanism. |
2494 const QuicTime::Delta QuicConnection::DelayedAckTime() { | 2505 const QuicTime::Delta QuicConnection::DelayedAckTime() { |
2495 return QuicTime::Delta::FromMilliseconds( | 2506 return QuicTime::Delta::FromMilliseconds( |
2496 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); | 2507 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); |
2497 } | 2508 } |
2498 | 2509 |
2499 } // namespace net | 2510 } // namespace net |
OLD | NEW |