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 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ | 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ |
6 #define NET_QUIC_QUIC_PROTOCOL_H_ | 6 #define NET_QUIC_QUIC_PROTOCOL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <limits> | 9 #include <limits> |
10 #include <list> | 10 #include <list> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // introduction of a new QUIC version. | 207 // introduction of a new QUIC version. |
208 PADDING_FRAME = 0, | 208 PADDING_FRAME = 0, |
209 RST_STREAM_FRAME = 1, | 209 RST_STREAM_FRAME = 1, |
210 CONNECTION_CLOSE_FRAME = 2, | 210 CONNECTION_CLOSE_FRAME = 2, |
211 GOAWAY_FRAME = 3, | 211 GOAWAY_FRAME = 3, |
212 WINDOW_UPDATE_FRAME = 4, | 212 WINDOW_UPDATE_FRAME = 4, |
213 BLOCKED_FRAME = 5, | 213 BLOCKED_FRAME = 5, |
214 STOP_WAITING_FRAME = 6, | 214 STOP_WAITING_FRAME = 6, |
215 PING_FRAME = 7, | 215 PING_FRAME = 7, |
216 | 216 |
217 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are | 217 // STREAM and ACK frames are special frames. They are encoded differently on |
218 // encoded differently on the wire and their values do not need to be stable. | 218 // the wire and their values do not need to be stable. |
219 STREAM_FRAME, | 219 STREAM_FRAME, |
220 ACK_FRAME, | 220 ACK_FRAME, |
221 CONGESTION_FEEDBACK_FRAME, | |
222 NUM_FRAME_TYPES | 221 NUM_FRAME_TYPES |
223 }; | 222 }; |
224 | 223 |
225 enum QuicConnectionIdLength { | 224 enum QuicConnectionIdLength { |
226 PACKET_0BYTE_CONNECTION_ID = 0, | 225 PACKET_0BYTE_CONNECTION_ID = 0, |
227 PACKET_1BYTE_CONNECTION_ID = 1, | 226 PACKET_1BYTE_CONNECTION_ID = 1, |
228 PACKET_4BYTE_CONNECTION_ID = 4, | 227 PACKET_4BYTE_CONNECTION_ID = 4, |
229 PACKET_8BYTE_CONNECTION_ID = 8 | 228 PACKET_8BYTE_CONNECTION_ID = 8 |
230 }; | 229 }; |
231 | 230 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // The available versions of QUIC. Guaranteed that the integer value of the enum | 302 // The available versions of QUIC. Guaranteed that the integer value of the enum |
304 // will match the version number. | 303 // will match the version number. |
305 // When adding a new version to this enum you should add it to | 304 // When adding a new version to this enum you should add it to |
306 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 305 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
307 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 306 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
308 // QuicVersionToString. | 307 // QuicVersionToString. |
309 enum QuicVersion { | 308 enum QuicVersion { |
310 // Special case to indicate unknown/unsupported QUIC version. | 309 // Special case to indicate unknown/unsupported QUIC version. |
311 QUIC_VERSION_UNSUPPORTED = 0, | 310 QUIC_VERSION_UNSUPPORTED = 0, |
312 | 311 |
313 QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled. | |
314 QUIC_VERSION_22 = 22, // Send Server Config Update messages on crypto stream. | |
315 QUIC_VERSION_23 = 23, // Timestamp in the ack frame. | 312 QUIC_VERSION_23 = 23, // Timestamp in the ack frame. |
| 313 QUIC_VERSION_24 = 24, // SPDY/4 header compression. |
316 }; | 314 }; |
317 | 315 |
318 // This vector contains QUIC versions which we currently support. | 316 // This vector contains QUIC versions which we currently support. |
319 // This should be ordered such that the highest supported version is the first | 317 // This should be ordered such that the highest supported version is the first |
320 // element, with subsequent elements in descending order (versions can be | 318 // element, with subsequent elements in descending order (versions can be |
321 // skipped as necessary). | 319 // skipped as necessary). |
322 // | 320 // |
323 // IMPORTANT: if you are adding to this list, follow the instructions at | 321 // IMPORTANT: if you are adding to this list, follow the instructions at |
324 // http://sites/quic/adding-and-removing-versions | 322 // http://sites/quic/adding-and-removing-versions |
325 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_23, | 323 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_24, |
326 QUIC_VERSION_22}; | 324 QUIC_VERSION_23}; |
327 | 325 |
328 typedef std::vector<QuicVersion> QuicVersionVector; | 326 typedef std::vector<QuicVersion> QuicVersionVector; |
329 | 327 |
330 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 328 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
331 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 329 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
332 | 330 |
333 // QuicTag is written to and read from the wire, but we prefer to use | 331 // QuicTag is written to and read from the wire, but we prefer to use |
334 // the more readable QuicVersion at other levels. | 332 // the more readable QuicVersion at other levels. |
335 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 | 333 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
336 // if QuicVersion is unsupported. | 334 // if QuicVersion is unsupported. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 // GOAWAY frame data is malformed. | 442 // GOAWAY frame data is malformed. |
445 QUIC_INVALID_GOAWAY_DATA = 8, | 443 QUIC_INVALID_GOAWAY_DATA = 8, |
446 // WINDOW_UPDATE frame data is malformed. | 444 // WINDOW_UPDATE frame data is malformed. |
447 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, | 445 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, |
448 // BLOCKED frame data is malformed. | 446 // BLOCKED frame data is malformed. |
449 QUIC_INVALID_BLOCKED_DATA = 58, | 447 QUIC_INVALID_BLOCKED_DATA = 58, |
450 // STOP_WAITING frame data is malformed. | 448 // STOP_WAITING frame data is malformed. |
451 QUIC_INVALID_STOP_WAITING_DATA = 60, | 449 QUIC_INVALID_STOP_WAITING_DATA = 60, |
452 // ACK frame data is malformed. | 450 // ACK frame data is malformed. |
453 QUIC_INVALID_ACK_DATA = 9, | 451 QUIC_INVALID_ACK_DATA = 9, |
454 // CONGESTION_FEEDBACK frame data is malformed. | 452 |
455 QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, | 453 // deprecated: QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, |
| 454 |
456 // Version negotiation packet is malformed. | 455 // Version negotiation packet is malformed. |
457 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, | 456 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, |
458 // Public RST packet is malformed. | 457 // Public RST packet is malformed. |
459 QUIC_INVALID_PUBLIC_RST_PACKET = 11, | 458 QUIC_INVALID_PUBLIC_RST_PACKET = 11, |
460 // There was an error decrypting. | 459 // There was an error decrypting. |
461 QUIC_DECRYPTION_FAILURE = 12, | 460 QUIC_DECRYPTION_FAILURE = 12, |
462 // There was an error encrypting. | 461 // There was an error encrypting. |
463 QUIC_ENCRYPTION_FAILURE = 13, | 462 QUIC_ENCRYPTION_FAILURE = 13, |
464 // The packet exceeded kMaxPacketSize. | 463 // The packet exceeded kMaxPacketSize. |
465 QUIC_PACKET_TOO_LARGE = 14, | 464 QUIC_PACKET_TOO_LARGE = 14, |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 bool NET_EXPORT_PRIVATE IsAwaitingPacket( | 734 bool NET_EXPORT_PRIVATE IsAwaitingPacket( |
736 const QuicAckFrame& ack_frame, | 735 const QuicAckFrame& ack_frame, |
737 QuicPacketSequenceNumber sequence_number); | 736 QuicPacketSequenceNumber sequence_number); |
738 | 737 |
739 // Inserts missing packets between [lower, higher). | 738 // Inserts missing packets between [lower, higher). |
740 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( | 739 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( |
741 QuicAckFrame* ack_frame, | 740 QuicAckFrame* ack_frame, |
742 QuicPacketSequenceNumber lower, | 741 QuicPacketSequenceNumber lower, |
743 QuicPacketSequenceNumber higher); | 742 QuicPacketSequenceNumber higher); |
744 | 743 |
745 // Defines for all types of congestion feedback that will be negotiated in QUIC, | |
746 // kTCP MUST be supported by all QUIC implementations to guarantee 100% | |
747 // compatibility. | |
748 // TODO(cyr): Remove this when removing QUIC_VERSION_22. | |
749 enum CongestionFeedbackType { | |
750 kTCP, // Used to mimic TCP. | |
751 }; | |
752 | |
753 // Defines for all types of congestion control algorithms that can be used in | 744 // Defines for all types of congestion control algorithms that can be used in |
754 // QUIC. Note that this is separate from the congestion feedback type - | 745 // QUIC. Note that this is separate from the congestion feedback type - |
755 // some congestion control algorithms may use the same feedback type | 746 // some congestion control algorithms may use the same feedback type |
756 // (Reno and Cubic are the classic example for that). | 747 // (Reno and Cubic are the classic example for that). |
757 enum CongestionControlType { | 748 enum CongestionControlType { |
758 kCubic, | 749 kCubic, |
759 kReno, | 750 kReno, |
760 kBBR, | 751 kBBR, |
761 }; | 752 }; |
762 | 753 |
763 enum LossDetectionType { | 754 enum LossDetectionType { |
764 kNack, // Used to mimic TCP's loss detection. | 755 kNack, // Used to mimic TCP's loss detection. |
765 kTime, // Time based loss detection. | 756 kTime, // Time based loss detection. |
766 }; | 757 }; |
767 | 758 |
768 // TODO(cyr): Remove this when removing QUIC_VERSION_22. | |
769 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { | |
770 CongestionFeedbackMessageTCP(); | |
771 | |
772 QuicByteCount receive_window; | |
773 }; | |
774 | |
775 // TODO(cyr): Remove this when removing QUIC_VERSION_22. | |
776 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { | |
777 QuicCongestionFeedbackFrame(); | |
778 ~QuicCongestionFeedbackFrame(); | |
779 | |
780 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | |
781 std::ostream& os, const QuicCongestionFeedbackFrame& c); | |
782 | |
783 CongestionFeedbackType type; | |
784 // This should really be a union, but since the timestamp struct | |
785 // is non-trivial, C++ prohibits it. | |
786 CongestionFeedbackMessageTCP tcp; | |
787 }; | |
788 | |
789 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { | 759 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { |
790 QuicRstStreamFrame(); | 760 QuicRstStreamFrame(); |
791 QuicRstStreamFrame(QuicStreamId stream_id, | 761 QuicRstStreamFrame(QuicStreamId stream_id, |
792 QuicRstStreamErrorCode error_code, | 762 QuicRstStreamErrorCode error_code, |
793 QuicStreamOffset bytes_written); | 763 QuicStreamOffset bytes_written); |
794 | 764 |
795 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 765 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
796 std::ostream& os, const QuicRstStreamFrame& r); | 766 std::ostream& os, const QuicRstStreamFrame& r); |
797 | 767 |
798 QuicStreamId stream_id; | 768 QuicStreamId stream_id; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 848 |
879 NUM_ENCRYPTION_LEVELS, | 849 NUM_ENCRYPTION_LEVELS, |
880 }; | 850 }; |
881 | 851 |
882 struct NET_EXPORT_PRIVATE QuicFrame { | 852 struct NET_EXPORT_PRIVATE QuicFrame { |
883 QuicFrame(); | 853 QuicFrame(); |
884 explicit QuicFrame(QuicPaddingFrame* padding_frame); | 854 explicit QuicFrame(QuicPaddingFrame* padding_frame); |
885 explicit QuicFrame(QuicStreamFrame* stream_frame); | 855 explicit QuicFrame(QuicStreamFrame* stream_frame); |
886 explicit QuicFrame(QuicAckFrame* frame); | 856 explicit QuicFrame(QuicAckFrame* frame); |
887 | 857 |
888 // TODO(cyr): Remove this when removing QUIC_VERSION_22. | |
889 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); | |
890 | |
891 explicit QuicFrame(QuicRstStreamFrame* frame); | 858 explicit QuicFrame(QuicRstStreamFrame* frame); |
892 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 859 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
893 explicit QuicFrame(QuicStopWaitingFrame* frame); | 860 explicit QuicFrame(QuicStopWaitingFrame* frame); |
894 explicit QuicFrame(QuicPingFrame* frame); | 861 explicit QuicFrame(QuicPingFrame* frame); |
895 explicit QuicFrame(QuicGoAwayFrame* frame); | 862 explicit QuicFrame(QuicGoAwayFrame* frame); |
896 explicit QuicFrame(QuicWindowUpdateFrame* frame); | 863 explicit QuicFrame(QuicWindowUpdateFrame* frame); |
897 explicit QuicFrame(QuicBlockedFrame* frame); | 864 explicit QuicFrame(QuicBlockedFrame* frame); |
898 | 865 |
899 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 866 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
900 std::ostream& os, const QuicFrame& frame); | 867 std::ostream& os, const QuicFrame& frame); |
901 | 868 |
902 QuicFrameType type; | 869 QuicFrameType type; |
903 union { | 870 union { |
904 QuicPaddingFrame* padding_frame; | 871 QuicPaddingFrame* padding_frame; |
905 QuicStreamFrame* stream_frame; | 872 QuicStreamFrame* stream_frame; |
906 QuicAckFrame* ack_frame; | 873 QuicAckFrame* ack_frame; |
907 | 874 |
908 // TODO(cyr): Remove this when removing QUIC_VERSION_22. | |
909 QuicCongestionFeedbackFrame* congestion_feedback_frame; | |
910 QuicStopWaitingFrame* stop_waiting_frame; | 875 QuicStopWaitingFrame* stop_waiting_frame; |
911 | 876 |
912 QuicPingFrame* ping_frame; | 877 QuicPingFrame* ping_frame; |
913 QuicRstStreamFrame* rst_stream_frame; | 878 QuicRstStreamFrame* rst_stream_frame; |
914 QuicConnectionCloseFrame* connection_close_frame; | 879 QuicConnectionCloseFrame* connection_close_frame; |
915 QuicGoAwayFrame* goaway_frame; | 880 QuicGoAwayFrame* goaway_frame; |
916 QuicWindowUpdateFrame* window_update_frame; | 881 QuicWindowUpdateFrame* window_update_frame; |
917 QuicBlockedFrame* blocked_frame; | 882 QuicBlockedFrame* blocked_frame; |
918 }; | 883 }; |
919 }; | 884 }; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 bool in_flight; | 1063 bool in_flight; |
1099 // True if the packet can never be acked, so it can be removed. | 1064 // True if the packet can never be acked, so it can be removed. |
1100 bool is_unackable; | 1065 bool is_unackable; |
1101 // True if the packet is an FEC packet. | 1066 // True if the packet is an FEC packet. |
1102 bool is_fec_packet; | 1067 bool is_fec_packet; |
1103 }; | 1068 }; |
1104 | 1069 |
1105 } // namespace net | 1070 } // namespace net |
1106 | 1071 |
1107 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1072 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |