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 // The entity that handles framing writes for a Quic client or server. | 5 // The entity that handles framing writes for a Quic client or server. |
6 // Each QuicSession will have a connection associated with it. | 6 // Each QuicSession will have a connection associated with it. |
7 // | 7 // |
8 // On the server side, the Dispatcher handles the raw reads, and hands off | 8 // On the server side, the Dispatcher handles the raw reads, and hands off |
9 // packets via ProcessUdpPacket for framing and processing. | 9 // packets via ProcessUdpPacket for framing and processing. |
10 // | 10 // |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 // remaining unacked packets. | 410 // remaining unacked packets. |
411 void OnRetransmissionTimeout(); | 411 void OnRetransmissionTimeout(); |
412 | 412 |
413 // Retransmits all unacked packets with retransmittable frames if | 413 // Retransmits all unacked packets with retransmittable frames if |
414 // |retransmission_type| is ALL_PACKETS, otherwise retransmits only initially | 414 // |retransmission_type| is ALL_PACKETS, otherwise retransmits only initially |
415 // encrypted packets. Used when the negotiated protocol version is different | 415 // encrypted packets. Used when the negotiated protocol version is different |
416 // from what was initially assumed and when the visitor wants to re-transmit | 416 // from what was initially assumed and when the visitor wants to re-transmit |
417 // initially encrypted packets when the initial encrypter changes. | 417 // initially encrypted packets when the initial encrypter changes. |
418 void RetransmitUnackedPackets(RetransmissionType retransmission_type); | 418 void RetransmitUnackedPackets(RetransmissionType retransmission_type); |
419 | 419 |
420 // Calls |sent_packet_manager_|'s DiscardUnencryptedPackets. Used when the | 420 // Calls |sent_packet_manager_|'s NeuterUnencryptedPackets. Used when the |
421 // connection becomes forward secure and hasn't received acks for all packets. | 421 // connection becomes forward secure and hasn't received acks for all packets. |
422 void DiscardUnencryptedPackets(); | 422 void NeuterUnencryptedPackets(); |
423 | 423 |
424 // Changes the encrypter used for level |level| to |encrypter|. The function | 424 // Changes the encrypter used for level |level| to |encrypter|. The function |
425 // takes ownership of |encrypter|. | 425 // takes ownership of |encrypter|. |
426 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter); | 426 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter); |
427 const QuicEncrypter* encrypter(EncryptionLevel level) const; | 427 const QuicEncrypter* encrypter(EncryptionLevel level) const; |
428 | 428 |
429 // SetDefaultEncryptionLevel sets the encryption level that will be applied | 429 // SetDefaultEncryptionLevel sets the encryption level that will be applied |
430 // to new packets. | 430 // to new packets. |
431 void SetDefaultEncryptionLevel(EncryptionLevel level); | 431 void SetDefaultEncryptionLevel(EncryptionLevel level); |
432 | 432 |
(...skipping 18 matching lines...) Expand all Loading... |
451 const QuicDecrypter* alternative_decrypter() const; | 451 const QuicDecrypter* alternative_decrypter() const; |
452 | 452 |
453 bool is_server() const { return is_server_; } | 453 bool is_server() const { return is_server_; } |
454 | 454 |
455 // Returns the underlying sent packet manager. | 455 // Returns the underlying sent packet manager. |
456 const QuicSentPacketManager& sent_packet_manager() const { | 456 const QuicSentPacketManager& sent_packet_manager() const { |
457 return sent_packet_manager_; | 457 return sent_packet_manager_; |
458 } | 458 } |
459 | 459 |
460 bool CanWrite(TransmissionType transmission_type, | 460 bool CanWrite(TransmissionType transmission_type, |
461 HasRetransmittableData retransmittable, | 461 HasRetransmittableData retransmittable); |
462 IsHandshake handshake); | |
463 | 462 |
464 uint32 max_flow_control_receive_window_bytes() const { | 463 uint32 max_flow_control_receive_window_bytes() const { |
465 return max_flow_control_receive_window_bytes_; | 464 return max_flow_control_receive_window_bytes_; |
466 } | 465 } |
467 | 466 |
468 // Stores current batch state for connection, puts the connection | 467 // Stores current batch state for connection, puts the connection |
469 // into batch mode, and destruction restores the stored batch state. | 468 // into batch mode, and destruction restores the stored batch state. |
470 // While the bundler is in scope, any generated frames are bundled | 469 // While the bundler is in scope, any generated frames are bundled |
471 // as densely as possible into packets. In addition, this bundler | 470 // as densely as possible into packets. In addition, this bundler |
472 // can be configured to ensure that an ACK frame is included in the | 471 // can be configured to ensure that an ACK frame is included in the |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // Get the FEC group associate with the last processed packet or NULL, if the | 603 // Get the FEC group associate with the last processed packet or NULL, if the |
605 // group has already been deleted. | 604 // group has already been deleted. |
606 QuicFecGroup* GetFecGroup(); | 605 QuicFecGroup* GetFecGroup(); |
607 | 606 |
608 // Closes any FEC groups protecting packets before |sequence_number|. | 607 // Closes any FEC groups protecting packets before |sequence_number|. |
609 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); | 608 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); |
610 | 609 |
611 // Sets the ping alarm to the appropriate value, if any. | 610 // Sets the ping alarm to the appropriate value, if any. |
612 void SetPingAlarm(); | 611 void SetPingAlarm(); |
613 | 612 |
| 613 // On arrival of a new packet, checks to see if the socket addresses have |
| 614 // changed since the last packet we saw on this connection. |
| 615 void CheckForAddressMigration(const IPEndPoint& self_address, |
| 616 const IPEndPoint& peer_address); |
| 617 |
614 QuicFramer framer_; | 618 QuicFramer framer_; |
615 QuicConnectionHelperInterface* helper_; // Not owned. | 619 QuicConnectionHelperInterface* helper_; // Not owned. |
616 QuicPacketWriter* writer_; // Not owned. | 620 QuicPacketWriter* writer_; // Not owned. |
617 EncryptionLevel encryption_level_; | 621 EncryptionLevel encryption_level_; |
618 const QuicClock* clock_; | 622 const QuicClock* clock_; |
619 QuicRandom* random_generator_; | 623 QuicRandom* random_generator_; |
620 | 624 |
621 const QuicConnectionId connection_id_; | 625 const QuicConnectionId connection_id_; |
622 // Address on the last successfully processed packet received from the | 626 // Address on the last successfully processed packet received from the |
623 // client. | 627 // client. |
624 IPEndPoint self_address_; | 628 IPEndPoint self_address_; |
625 IPEndPoint peer_address_; | 629 IPEndPoint peer_address_; |
| 630 // Used to store latest peer port to possibly migrate to later. |
| 631 int migrating_peer_port_; |
626 | 632 |
627 bool last_packet_revived_; // True if the last packet was revived from FEC. | 633 bool last_packet_revived_; // True if the last packet was revived from FEC. |
628 size_t last_size_; // Size of the last received packet. | 634 size_t last_size_; // Size of the last received packet. |
629 EncryptionLevel last_decrypted_packet_level_; | 635 EncryptionLevel last_decrypted_packet_level_; |
630 QuicPacketHeader last_header_; | 636 QuicPacketHeader last_header_; |
631 std::vector<QuicStreamFrame> last_stream_frames_; | 637 std::vector<QuicStreamFrame> last_stream_frames_; |
632 std::vector<QuicAckFrame> last_ack_frames_; | 638 std::vector<QuicAckFrame> last_ack_frames_; |
633 std::vector<QuicCongestionFeedbackFrame> last_congestion_frames_; | 639 std::vector<QuicCongestionFeedbackFrame> last_congestion_frames_; |
634 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; | 640 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; |
635 std::vector<QuicRstStreamFrame> last_rst_frames_; | 641 std::vector<QuicRstStreamFrame> last_rst_frames_; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 // The state of connection in version negotiation finite state machine. | 733 // The state of connection in version negotiation finite state machine. |
728 QuicVersionNegotiationState version_negotiation_state_; | 734 QuicVersionNegotiationState version_negotiation_state_; |
729 | 735 |
730 // Tracks if the connection was created by the server. | 736 // Tracks if the connection was created by the server. |
731 bool is_server_; | 737 bool is_server_; |
732 | 738 |
733 // True by default. False if we've received or sent an explicit connection | 739 // True by default. False if we've received or sent an explicit connection |
734 // close. | 740 // close. |
735 bool connected_; | 741 bool connected_; |
736 | 742 |
737 // Set to true if the udp packet headers have a new self or peer address. | 743 // Set to true if the UDP packet headers have a new IP address for the peer. |
738 // This is checked later on validating a data or version negotiation packet. | 744 // If true, do not perform connection migration. |
739 bool address_migrating_; | 745 bool peer_ip_changed_; |
| 746 |
| 747 // Set to true if the UDP packet headers have a new port for the peer. |
| 748 // If true, and the IP has not changed, then we can migrate the connection. |
| 749 bool peer_port_changed_; |
| 750 |
| 751 // Set to true if the UDP packet headers are addressed to a different IP. |
| 752 // We do not support connection migration when the self IP changed. |
| 753 bool self_ip_changed_; |
| 754 |
| 755 // Set to true if the UDP packet headers are addressed to a different port. |
| 756 // If true, and the IP has not changed, then we can migrate the connection. |
| 757 bool self_port_changed_; |
740 | 758 |
741 // If non-empty this contains the set of versions received in a | 759 // If non-empty this contains the set of versions received in a |
742 // version negotiation packet. | 760 // version negotiation packet. |
743 QuicVersionVector server_supported_versions_; | 761 QuicVersionVector server_supported_versions_; |
744 | 762 |
745 // Initial flow control receive window size for new streams. | 763 // Initial flow control receive window size for new streams. |
746 uint32 max_flow_control_receive_window_bytes_; | 764 uint32 max_flow_control_receive_window_bytes_; |
747 | 765 |
748 // Used for connection level flow control. | 766 // Used for connection level flow control. |
749 scoped_ptr<QuicFlowController> flow_controller_; | 767 scoped_ptr<QuicFlowController> flow_controller_; |
750 | 768 |
751 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 769 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
752 }; | 770 }; |
753 | 771 |
754 } // namespace net | 772 } // namespace net |
755 | 773 |
756 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 774 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |