| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 // Called when the complete header of a packet has been parsed. | 156 // Called when the complete header of a packet has been parsed. |
| 157 virtual void OnPacketHeader(const QuicPacketHeader& header) {} | 157 virtual void OnPacketHeader(const QuicPacketHeader& header) {} |
| 158 | 158 |
| 159 // Called when a StreamFrame has been parsed. | 159 // Called when a StreamFrame has been parsed. |
| 160 virtual void OnStreamFrame(const QuicStreamFrame& frame) {} | 160 virtual void OnStreamFrame(const QuicStreamFrame& frame) {} |
| 161 | 161 |
| 162 // Called when a AckFrame has been parsed. | 162 // Called when a AckFrame has been parsed. |
| 163 virtual void OnAckFrame(const QuicAckFrame& frame) {} | 163 virtual void OnAckFrame(const QuicAckFrame& frame) {} |
| 164 | 164 |
| 165 // Called when a CongestionFeedbackFrame has been parsed. | |
| 166 virtual void OnCongestionFeedbackFrame( | |
| 167 const QuicCongestionFeedbackFrame& frame) {} | |
| 168 | |
| 169 // Called when a StopWaitingFrame has been parsed. | 165 // Called when a StopWaitingFrame has been parsed. |
| 170 virtual void OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {} | 166 virtual void OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {} |
| 171 | 167 |
| 172 // Called when a Ping has been parsed. | 168 // Called when a Ping has been parsed. |
| 173 virtual void OnPingFrame(const QuicPingFrame& frame) {} | 169 virtual void OnPingFrame(const QuicPingFrame& frame) {} |
| 174 | 170 |
| 175 // Called when a GoAway has been parsed. | 171 // Called when a GoAway has been parsed. |
| 176 virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) {} | 172 virtual void OnGoAwayFrame(const QuicGoAwayFrame& frame) {} |
| 177 | 173 |
| 178 // Called when a RstStreamFrame has been parsed. | 174 // Called when a RstStreamFrame has been parsed. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 const QuicVersionNegotiationPacket& packet) override; | 349 const QuicVersionNegotiationPacket& packet) override; |
| 354 void OnRevivedPacket() override; | 350 void OnRevivedPacket() override; |
| 355 bool OnUnauthenticatedPublicHeader( | 351 bool OnUnauthenticatedPublicHeader( |
| 356 const QuicPacketPublicHeader& header) override; | 352 const QuicPacketPublicHeader& header) override; |
| 357 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; | 353 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; |
| 358 void OnDecryptedPacket(EncryptionLevel level) override; | 354 void OnDecryptedPacket(EncryptionLevel level) override; |
| 359 bool OnPacketHeader(const QuicPacketHeader& header) override; | 355 bool OnPacketHeader(const QuicPacketHeader& header) override; |
| 360 void OnFecProtectedPayload(base::StringPiece payload) override; | 356 void OnFecProtectedPayload(base::StringPiece payload) override; |
| 361 bool OnStreamFrame(const QuicStreamFrame& frame) override; | 357 bool OnStreamFrame(const QuicStreamFrame& frame) override; |
| 362 bool OnAckFrame(const QuicAckFrame& frame) override; | 358 bool OnAckFrame(const QuicAckFrame& frame) override; |
| 363 bool OnCongestionFeedbackFrame( | |
| 364 const QuicCongestionFeedbackFrame& frame) override; | |
| 365 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override; | 359 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override; |
| 366 bool OnPingFrame(const QuicPingFrame& frame) override; | 360 bool OnPingFrame(const QuicPingFrame& frame) override; |
| 367 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override; | 361 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override; |
| 368 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override; | 362 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override; |
| 369 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; | 363 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; |
| 370 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; | 364 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; |
| 371 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; | 365 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; |
| 372 void OnFecData(const QuicFecData& fec) override; | 366 void OnFecData(const QuicFecData& fec) override; |
| 373 void OnPacketComplete() override; | 367 void OnPacketComplete() override; |
| 374 | 368 |
| 375 // QuicPacketGenerator::DelegateInterface | 369 // QuicPacketGenerator::DelegateInterface |
| 376 bool ShouldGeneratePacket(TransmissionType transmission_type, | 370 bool ShouldGeneratePacket(TransmissionType transmission_type, |
| 377 HasRetransmittableData retransmittable, | 371 HasRetransmittableData retransmittable, |
| 378 IsHandshake handshake) override; | 372 IsHandshake handshake) override; |
| 379 QuicAckFrame* CreateAckFrame() override; | 373 QuicAckFrame* CreateAckFrame() override; |
| 380 QuicCongestionFeedbackFrame* CreateFeedbackFrame() override; | |
| 381 QuicStopWaitingFrame* CreateStopWaitingFrame() override; | 374 QuicStopWaitingFrame* CreateStopWaitingFrame() override; |
| 382 void OnSerializedPacket(const SerializedPacket& packet) override; | 375 void OnSerializedPacket(const SerializedPacket& packet) override; |
| 383 | 376 |
| 384 // QuicSentPacketManager::NetworkChangeVisitor | 377 // QuicSentPacketManager::NetworkChangeVisitor |
| 385 void OnCongestionWindowChange() override; | 378 void OnCongestionWindowChange() override; |
| 386 void OnRttChange() override; | 379 void OnRttChange() override; |
| 387 | 380 |
| 388 // Called by the crypto stream when the handshake completes. In the server's | 381 // Called by the crypto stream when the handshake completes. In the server's |
| 389 // case this is when the SHLO has been ACKed. Clients call this on receipt of | 382 // case this is when the SHLO has been ACKed. Clients call this on receipt of |
| 390 // the SHLO. | 383 // the SHLO. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // Sends a ping, and resets the ping alarm. | 437 // Sends a ping, and resets the ping alarm. |
| 445 void SendPing(); | 438 void SendPing(); |
| 446 | 439 |
| 447 // Sets up a packet with an QuicAckFrame and sends it out. | 440 // Sets up a packet with an QuicAckFrame and sends it out. |
| 448 void SendAck(); | 441 void SendAck(); |
| 449 | 442 |
| 450 // Called when an RTO fires. Resets the retransmission alarm if there are | 443 // Called when an RTO fires. Resets the retransmission alarm if there are |
| 451 // remaining unacked packets. | 444 // remaining unacked packets. |
| 452 void OnRetransmissionTimeout(); | 445 void OnRetransmissionTimeout(); |
| 453 | 446 |
| 447 // Called when a data packet is sent. Starts an alarm if the data sent in |
| 448 // |sequence_number| was FEC protected. |
| 449 void MaybeSetFecAlarm(QuicPacketSequenceNumber sequence_number); |
| 450 |
| 454 // Retransmits all unacked packets with retransmittable frames if | 451 // Retransmits all unacked packets with retransmittable frames if |
| 455 // |retransmission_type| is ALL_UNACKED_PACKETS, otherwise retransmits only | 452 // |retransmission_type| is ALL_UNACKED_PACKETS, otherwise retransmits only |
| 456 // initially encrypted packets. Used when the negotiated protocol version is | 453 // initially encrypted packets. Used when the negotiated protocol version is |
| 457 // different from what was initially assumed and when the initial encryption | 454 // different from what was initially assumed and when the initial encryption |
| 458 // changes. | 455 // changes. |
| 459 void RetransmitUnackedPackets(TransmissionType retransmission_type); | 456 void RetransmitUnackedPackets(TransmissionType retransmission_type); |
| 460 | 457 |
| 461 // Calls |sent_packet_manager_|'s NeuterUnencryptedPackets. Used when the | 458 // Calls |sent_packet_manager_|'s NeuterUnencryptedPackets. Used when the |
| 462 // connection becomes forward secure and hasn't received acks for all packets. | 459 // connection becomes forward secure and hasn't received acks for all packets. |
| 463 void NeuterUnencryptedPackets(); | 460 void NeuterUnencryptedPackets(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 697 |
| 701 // True if the last packet has gotten far enough in the framer to be | 698 // True if the last packet has gotten far enough in the framer to be |
| 702 // decrypted. | 699 // decrypted. |
| 703 bool last_packet_decrypted_; | 700 bool last_packet_decrypted_; |
| 704 bool last_packet_revived_; // True if the last packet was revived from FEC. | 701 bool last_packet_revived_; // True if the last packet was revived from FEC. |
| 705 QuicByteCount last_size_; // Size of the last received packet. | 702 QuicByteCount last_size_; // Size of the last received packet. |
| 706 EncryptionLevel last_decrypted_packet_level_; | 703 EncryptionLevel last_decrypted_packet_level_; |
| 707 QuicPacketHeader last_header_; | 704 QuicPacketHeader last_header_; |
| 708 std::vector<QuicStreamFrame> last_stream_frames_; | 705 std::vector<QuicStreamFrame> last_stream_frames_; |
| 709 std::vector<QuicAckFrame> last_ack_frames_; | 706 std::vector<QuicAckFrame> last_ack_frames_; |
| 710 std::vector<QuicCongestionFeedbackFrame> last_congestion_frames_; | |
| 711 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; | 707 std::vector<QuicStopWaitingFrame> last_stop_waiting_frames_; |
| 712 std::vector<QuicRstStreamFrame> last_rst_frames_; | 708 std::vector<QuicRstStreamFrame> last_rst_frames_; |
| 713 std::vector<QuicGoAwayFrame> last_goaway_frames_; | 709 std::vector<QuicGoAwayFrame> last_goaway_frames_; |
| 714 std::vector<QuicWindowUpdateFrame> last_window_update_frames_; | 710 std::vector<QuicWindowUpdateFrame> last_window_update_frames_; |
| 715 std::vector<QuicBlockedFrame> last_blocked_frames_; | 711 std::vector<QuicBlockedFrame> last_blocked_frames_; |
| 716 std::vector<QuicPingFrame> last_ping_frames_; | 712 std::vector<QuicPingFrame> last_ping_frames_; |
| 717 std::vector<QuicConnectionCloseFrame> last_close_frames_; | 713 std::vector<QuicConnectionCloseFrame> last_close_frames_; |
| 718 | 714 |
| 719 QuicCongestionFeedbackFrame outgoing_congestion_feedback_; | |
| 720 | |
| 721 // Track some peer state so we can do less bookkeeping | 715 // Track some peer state so we can do less bookkeeping |
| 722 // Largest sequence sent by the peer which had an ack frame (latest ack info). | 716 // Largest sequence sent by the peer which had an ack frame (latest ack info). |
| 723 QuicPacketSequenceNumber largest_seen_packet_with_ack_; | 717 QuicPacketSequenceNumber largest_seen_packet_with_ack_; |
| 724 | 718 |
| 725 // Largest sequence number sent by the peer which had a stop waiting frame. | 719 // Largest sequence number sent by the peer which had a stop waiting frame. |
| 726 QuicPacketSequenceNumber largest_seen_packet_with_stop_waiting_; | 720 QuicPacketSequenceNumber largest_seen_packet_with_stop_waiting_; |
| 727 | 721 |
| 728 // Collection of packets which were received before encryption was | 722 // Collection of packets which were received before encryption was |
| 729 // established, but which could not be decrypted. We buffer these on | 723 // established, but which could not be decrypted. We buffer these on |
| 730 // the assumption that they could not be processed because they were | 724 // the assumption that they could not be processed because they were |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 scoped_ptr<QuicAlarm> resume_writes_alarm_; | 768 scoped_ptr<QuicAlarm> resume_writes_alarm_; |
| 775 // An alarm that fires when the connection may have timed out. | 769 // An alarm that fires when the connection may have timed out. |
| 776 scoped_ptr<QuicAlarm> timeout_alarm_; | 770 scoped_ptr<QuicAlarm> timeout_alarm_; |
| 777 // An alarm that fires when a ping should be sent. | 771 // An alarm that fires when a ping should be sent. |
| 778 scoped_ptr<QuicAlarm> ping_alarm_; | 772 scoped_ptr<QuicAlarm> ping_alarm_; |
| 779 | 773 |
| 780 QuicConnectionVisitorInterface* visitor_; | 774 QuicConnectionVisitorInterface* visitor_; |
| 781 scoped_ptr<QuicConnectionDebugVisitor> debug_visitor_; | 775 scoped_ptr<QuicConnectionDebugVisitor> debug_visitor_; |
| 782 QuicPacketGenerator packet_generator_; | 776 QuicPacketGenerator packet_generator_; |
| 783 | 777 |
| 778 // An alarm that fires when an FEC packet should be sent. |
| 779 scoped_ptr<QuicAlarm> fec_alarm_; |
| 780 |
| 784 // Network idle time before we kill of this connection. | 781 // Network idle time before we kill of this connection. |
| 785 QuicTime::Delta idle_network_timeout_; | 782 QuicTime::Delta idle_network_timeout_; |
| 786 // Overall connection timeout. | 783 // Overall connection timeout. |
| 787 QuicTime::Delta overall_connection_timeout_; | 784 QuicTime::Delta overall_connection_timeout_; |
| 788 | 785 |
| 789 // Statistics for this session. | 786 // Statistics for this session. |
| 790 QuicConnectionStats stats_; | 787 QuicConnectionStats stats_; |
| 791 | 788 |
| 792 // The time that we got a packet for this connection. | 789 // The time that we got a packet for this connection. |
| 793 // This is used for timeouts, and does not indicate the packet was processed. | 790 // This is used for timeouts, and does not indicate the packet was processed. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 839 |
| 843 // True if this is a secure QUIC connection. | 840 // True if this is a secure QUIC connection. |
| 844 bool is_secure_; | 841 bool is_secure_; |
| 845 | 842 |
| 846 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 843 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 847 }; | 844 }; |
| 848 | 845 |
| 849 } // namespace net | 846 } // namespace net |
| 850 | 847 |
| 851 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 848 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |