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 28 matching lines...) Expand all Loading... |
39 #include "net/quic/core/quic_blocked_writer_interface.h" | 39 #include "net/quic/core/quic_blocked_writer_interface.h" |
40 #include "net/quic/core/quic_connection_stats.h" | 40 #include "net/quic/core/quic_connection_stats.h" |
41 #include "net/quic/core/quic_framer.h" | 41 #include "net/quic/core/quic_framer.h" |
42 #include "net/quic/core/quic_multipath_sent_packet_manager.h" | 42 #include "net/quic/core/quic_multipath_sent_packet_manager.h" |
43 #include "net/quic/core/quic_one_block_arena.h" | 43 #include "net/quic/core/quic_one_block_arena.h" |
44 #include "net/quic/core/quic_packet_creator.h" | 44 #include "net/quic/core/quic_packet_creator.h" |
45 #include "net/quic/core/quic_packet_generator.h" | 45 #include "net/quic/core/quic_packet_generator.h" |
46 #include "net/quic/core/quic_packet_writer.h" | 46 #include "net/quic/core/quic_packet_writer.h" |
47 #include "net/quic/core/quic_protocol.h" | 47 #include "net/quic/core/quic_protocol.h" |
48 #include "net/quic/core/quic_received_packet_manager.h" | 48 #include "net/quic/core/quic_received_packet_manager.h" |
49 #include "net/quic/core/quic_sent_entropy_manager.h" | |
50 #include "net/quic/core/quic_sent_packet_manager_interface.h" | 49 #include "net/quic/core/quic_sent_packet_manager_interface.h" |
51 #include "net/quic/core/quic_time.h" | 50 #include "net/quic/core/quic_time.h" |
52 #include "net/quic/core/quic_types.h" | 51 #include "net/quic/core/quic_types.h" |
53 | 52 |
54 namespace net { | 53 namespace net { |
55 | 54 |
56 class QuicClock; | 55 class QuicClock; |
57 class QuicConfig; | 56 class QuicConfig; |
58 class QuicConnection; | 57 class QuicConnection; |
59 class QuicEncrypter; | 58 class QuicEncrypter; |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 776 |
778 // Sends a version negotiation packet to the peer. | 777 // Sends a version negotiation packet to the peer. |
779 void SendVersionNegotiationPacket(); | 778 void SendVersionNegotiationPacket(); |
780 | 779 |
781 // Clears any accumulated frames from the last received packet. | 780 // Clears any accumulated frames from the last received packet. |
782 void ClearLastFrames(); | 781 void ClearLastFrames(); |
783 | 782 |
784 // Deletes and clears any queued packets. | 783 // Deletes and clears any queued packets. |
785 void ClearQueuedPackets(); | 784 void ClearQueuedPackets(); |
786 | 785 |
787 // Closes the connection if the sent or received packet manager are tracking | |
788 // too many outstanding packets. | |
789 void MaybeCloseIfTooManyOutstandingPackets(); | |
790 | |
791 // Writes as many queued packets as possible. The connection must not be | 786 // Writes as many queued packets as possible. The connection must not be |
792 // blocked when this is called. | 787 // blocked when this is called. |
793 void WriteQueuedPackets(); | 788 void WriteQueuedPackets(); |
794 | 789 |
795 // Writes as many pending retransmissions as possible. | 790 // Writes as many pending retransmissions as possible. |
796 void WritePendingRetransmissions(); | 791 void WritePendingRetransmissions(); |
797 | 792 |
798 // Returns true if the packet should be discarded and not sent. | 793 // Returns true if the packet should be discarded and not sent. |
799 bool ShouldDiscardPacket(const SerializedPacket& packet); | 794 bool ShouldDiscardPacket(const SerializedPacket& packet); |
800 | 795 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 // after idle timeout due to lack of network activity. | 941 // after idle timeout due to lack of network activity. |
947 // This is particularly important on mobile, where waking up the radio is | 942 // This is particularly important on mobile, where waking up the radio is |
948 // undesirable. | 943 // undesirable. |
949 ConnectionCloseBehavior idle_timeout_connection_close_behavior_; | 944 ConnectionCloseBehavior idle_timeout_connection_close_behavior_; |
950 | 945 |
951 // When true, close the QUIC connection after 5 RTOs. Due to the min rto of | 946 // When true, close the QUIC connection after 5 RTOs. Due to the min rto of |
952 // 200ms, this is over 5 seconds. | 947 // 200ms, this is over 5 seconds. |
953 bool close_connection_after_five_rtos_; | 948 bool close_connection_after_five_rtos_; |
954 | 949 |
955 QuicReceivedPacketManager received_packet_manager_; | 950 QuicReceivedPacketManager received_packet_manager_; |
956 QuicSentEntropyManager sent_entropy_manager_; | |
957 | 951 |
958 // Indicates whether an ack should be sent the next time we try to write. | 952 // Indicates whether an ack should be sent the next time we try to write. |
959 bool ack_queued_; | 953 bool ack_queued_; |
960 // How many retransmittable packets have arrived without sending an ack. | 954 // How many retransmittable packets have arrived without sending an ack. |
961 QuicPacketCount num_retransmittable_packets_received_since_last_ack_sent_; | 955 QuicPacketCount num_retransmittable_packets_received_since_last_ack_sent_; |
962 // Whether there were missing packets in the last sent ack. | 956 // Whether there were missing packets in the last sent ack. |
963 bool last_ack_had_missing_packets_; | 957 bool last_ack_had_missing_packets_; |
964 // How many consecutive packets have arrived without sending an ack. | 958 // How many consecutive packets have arrived without sending an ack. |
965 QuicPacketCount num_packets_received_since_last_ack_sent_; | 959 QuicPacketCount num_packets_received_since_last_ack_sent_; |
966 // Indicates how many consecutive times an ack has arrived which indicates | 960 // Indicates how many consecutive times an ack has arrived which indicates |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 // packet number of the last sent packet. Packets are guaranteed to be sent | 1029 // packet number of the last sent packet. Packets are guaranteed to be sent |
1036 // in packet number order. | 1030 // in packet number order. |
1037 QuicPacketNumber packet_number_of_last_sent_packet_; | 1031 QuicPacketNumber packet_number_of_last_sent_packet_; |
1038 | 1032 |
1039 // Sent packet manager which tracks the status of packets sent by this | 1033 // Sent packet manager which tracks the status of packets sent by this |
1040 // connection and contains the send and receive algorithms to determine when | 1034 // connection and contains the send and receive algorithms to determine when |
1041 // to send packets. | 1035 // to send packets. |
1042 std::unique_ptr<QuicSentPacketManagerInterface> sent_packet_manager_; | 1036 std::unique_ptr<QuicSentPacketManagerInterface> sent_packet_manager_; |
1043 | 1037 |
1044 // The state of connection in version negotiation finite state machine. | 1038 // The state of connection in version negotiation finite state machine. |
| 1039 enum QuicVersionNegotiationState { |
| 1040 START_NEGOTIATION = 0, |
| 1041 // Server-side this implies we've sent a version negotiation packet and are |
| 1042 // waiting on the client to select a compatible version. Client-side this |
| 1043 // implies we've gotten a version negotiation packet, are retransmitting the |
| 1044 // initial packets with a supported version and are waiting for our first |
| 1045 // packet from the server. |
| 1046 NEGOTIATION_IN_PROGRESS, |
| 1047 // This indicates this endpoint has received a packet from the peer with a |
| 1048 // version this endpoint supports. Version negotiation is complete, and the |
| 1049 // version number will no longer be sent with future packets. |
| 1050 NEGOTIATED_VERSION |
| 1051 }; |
1045 QuicVersionNegotiationState version_negotiation_state_; | 1052 QuicVersionNegotiationState version_negotiation_state_; |
1046 | 1053 |
1047 // Tracks if the connection was created by the server or the client. | 1054 // Tracks if the connection was created by the server or the client. |
1048 Perspective perspective_; | 1055 Perspective perspective_; |
1049 | 1056 |
1050 // True by default. False if we've received or sent an explicit connection | 1057 // True by default. False if we've received or sent an explicit connection |
1051 // close. | 1058 // close. |
1052 bool connected_; | 1059 bool connected_; |
1053 | 1060 |
1054 // Destination address of the last received packet. | 1061 // Destination address of the last received packet. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 // Indicates whether a write error is encountered currently. This is used to | 1107 // Indicates whether a write error is encountered currently. This is used to |
1101 // avoid infinite write errors. | 1108 // avoid infinite write errors. |
1102 bool write_error_occured_; | 1109 bool write_error_occured_; |
1103 | 1110 |
1104 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1111 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
1105 }; | 1112 }; |
1106 | 1113 |
1107 } // namespace net | 1114 } // namespace net |
1108 | 1115 |
1109 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1116 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |