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 <map> | 10 #include <map> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Default and initial maximum size in bytes of a QUIC packet. | 53 // Default and initial maximum size in bytes of a QUIC packet. |
54 const QuicByteCount kDefaultMaxPacketSize = 1200; | 54 const QuicByteCount kDefaultMaxPacketSize = 1200; |
55 // The maximum packet size of any QUIC packet, based on ethernet's max size, | 55 // The maximum packet size of any QUIC packet, based on ethernet's max size, |
56 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an | 56 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an |
57 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's | 57 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's |
58 // max packet size is 1500 bytes, 1500 - 48 = 1452. | 58 // max packet size is 1500 bytes, 1500 - 48 = 1452. |
59 const QuicByteCount kMaxPacketSize = 1452; | 59 const QuicByteCount kMaxPacketSize = 1452; |
60 | 60 |
61 // Maximum size of the initial congestion window in packets. | 61 // Maximum size of the initial congestion window in packets. |
62 const size_t kDefaultInitialWindow = 10; | 62 const size_t kDefaultInitialWindow = 10; |
63 // TODO(ianswett): Temporarily changed to 10 due to a large number of clients | 63 const size_t kMaxInitialWindow = 100; |
64 // mistakenly negotiating 100 initially and suffering the consequences. | |
65 const size_t kMaxInitialWindow = 10; | |
66 | 64 |
67 // Maximum size of the congestion window, in packets, for TCP congestion control | 65 // Maximum size of the congestion window, in packets, for TCP congestion control |
68 // algorithms. | 66 // algorithms. |
69 const size_t kMaxTcpCongestionWindow = 200; | 67 const size_t kMaxTcpCongestionWindow = 200; |
70 | 68 |
71 // Don't allow a client to suggest an RTT longer than 15 seconds. | 69 // Don't allow a client to suggest an RTT longer than 15 seconds. |
72 const size_t kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond; | 70 const size_t kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond; |
73 | 71 |
74 // Maximum number of open streams per connection. | 72 // Maximum number of open streams per connection. |
75 const size_t kDefaultMaxStreamsPerConnection = 100; | 73 const size_t kDefaultMaxStreamsPerConnection = 100; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 148 |
151 enum QuicFrameType { | 149 enum QuicFrameType { |
152 // Regular frame types. The values set here cannot change without the | 150 // Regular frame types. The values set here cannot change without the |
153 // introduction of a new QUIC version. | 151 // introduction of a new QUIC version. |
154 PADDING_FRAME = 0, | 152 PADDING_FRAME = 0, |
155 RST_STREAM_FRAME = 1, | 153 RST_STREAM_FRAME = 1, |
156 CONNECTION_CLOSE_FRAME = 2, | 154 CONNECTION_CLOSE_FRAME = 2, |
157 GOAWAY_FRAME = 3, | 155 GOAWAY_FRAME = 3, |
158 WINDOW_UPDATE_FRAME = 4, | 156 WINDOW_UPDATE_FRAME = 4, |
159 BLOCKED_FRAME = 5, | 157 BLOCKED_FRAME = 5, |
| 158 STOP_WAITING_FRAME = 6, |
160 | 159 |
161 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are | 160 // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are |
162 // encoded differently on the wire and their values do not need to be stable. | 161 // encoded differently on the wire and their values do not need to be stable. |
163 STREAM_FRAME, | 162 STREAM_FRAME, |
164 ACK_FRAME, | 163 ACK_FRAME, |
165 CONGESTION_FEEDBACK_FRAME, | 164 CONGESTION_FEEDBACK_FRAME, |
166 NUM_FRAME_TYPES | 165 NUM_FRAME_TYPES |
167 }; | 166 }; |
168 | 167 |
169 enum QuicGuidLength { | 168 enum QuicGuidLength { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 249 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
251 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 250 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
252 // QuicVersionToString. | 251 // QuicVersionToString. |
253 enum QuicVersion { | 252 enum QuicVersion { |
254 // Special case to indicate unknown/unsupported QUIC version. | 253 // Special case to indicate unknown/unsupported QUIC version. |
255 QUIC_VERSION_UNSUPPORTED = 0, | 254 QUIC_VERSION_UNSUPPORTED = 0, |
256 | 255 |
257 QUIC_VERSION_12 = 12, | 256 QUIC_VERSION_12 = 12, |
258 QUIC_VERSION_13 = 13, | 257 QUIC_VERSION_13 = 13, |
259 QUIC_VERSION_14 = 14, | 258 QUIC_VERSION_14 = 14, |
260 QUIC_VERSION_15 = 15, // Current version. | 259 QUIC_VERSION_15 = 15, |
| 260 QUIC_VERSION_16 = 16, // Current version. |
261 }; | 261 }; |
262 | 262 |
263 // This vector contains QUIC versions which we currently support. | 263 // This vector contains QUIC versions which we currently support. |
264 // This should be ordered such that the highest supported version is the first | 264 // This should be ordered such that the highest supported version is the first |
265 // element, with subsequent elements in descending order (versions can be | 265 // element, with subsequent elements in descending order (versions can be |
266 // skipped as necessary). | 266 // skipped as necessary). |
267 // | 267 // |
268 // IMPORTANT: if you are addding to this list, follow the instructions at | 268 // IMPORTANT: if you are addding to this list, follow the instructions at |
269 // http://sites/quic/adding-and-removing-versions | 269 // http://sites/quic/adding-and-removing-versions |
270 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_15, | 270 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_16, |
| 271 QUIC_VERSION_15, |
271 QUIC_VERSION_14, | 272 QUIC_VERSION_14, |
272 QUIC_VERSION_13, | 273 QUIC_VERSION_13, |
273 QUIC_VERSION_12}; | 274 QUIC_VERSION_12}; |
274 | 275 |
275 typedef std::vector<QuicVersion> QuicVersionVector; | 276 typedef std::vector<QuicVersion> QuicVersionVector; |
276 | 277 |
277 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 278 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
278 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 279 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
279 | 280 |
280 // QuicTag is written to and read from the wire, but we prefer to use | 281 // QuicTag is written to and read from the wire, but we prefer to use |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // RST_STREAM frame data is malformed. | 372 // RST_STREAM frame data is malformed. |
372 QUIC_INVALID_RST_STREAM_DATA = 6, | 373 QUIC_INVALID_RST_STREAM_DATA = 6, |
373 // CONNECTION_CLOSE frame data is malformed. | 374 // CONNECTION_CLOSE frame data is malformed. |
374 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7, | 375 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7, |
375 // GOAWAY frame data is malformed. | 376 // GOAWAY frame data is malformed. |
376 QUIC_INVALID_GOAWAY_DATA = 8, | 377 QUIC_INVALID_GOAWAY_DATA = 8, |
377 // WINDOW_UPDATE frame data is malformed. | 378 // WINDOW_UPDATE frame data is malformed. |
378 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, | 379 QUIC_INVALID_WINDOW_UPDATE_DATA = 57, |
379 // BLOCKED frame data is malformed. | 380 // BLOCKED frame data is malformed. |
380 QUIC_INVALID_BLOCKED_DATA = 58, | 381 QUIC_INVALID_BLOCKED_DATA = 58, |
| 382 // STOP_WAITING frame data is malformed. |
| 383 QUIC_INVALID_STOP_WAITING_DATA = 60, |
381 // ACK frame data is malformed. | 384 // ACK frame data is malformed. |
382 QUIC_INVALID_ACK_DATA = 9, | 385 QUIC_INVALID_ACK_DATA = 9, |
383 // CONGESTION_FEEDBACK frame data is malformed. | 386 // CONGESTION_FEEDBACK frame data is malformed. |
384 QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, | 387 QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, |
385 // Version negotiation packet is malformed. | 388 // Version negotiation packet is malformed. |
386 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, | 389 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, |
387 // Public RST packet is malformed. | 390 // Public RST packet is malformed. |
388 QUIC_INVALID_PUBLIC_RST_PACKET = 11, | 391 QUIC_INVALID_PUBLIC_RST_PACKET = 11, |
389 // There was an error decrypting. | 392 // There was an error decrypting. |
390 QUIC_DECRYPTION_FAILURE = 12, | 393 QUIC_DECRYPTION_FAILURE = 12, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // We failed to setup the symmetric keys for a connection. | 479 // We failed to setup the symmetric keys for a connection. |
477 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53, | 480 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53, |
478 // A handshake message arrived, but we are still validating the | 481 // A handshake message arrived, but we are still validating the |
479 // previous handshake message. | 482 // previous handshake message. |
480 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, | 483 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, |
481 // This connection involved a version negotiation which appears to have been | 484 // This connection involved a version negotiation which appears to have been |
482 // tampered with. | 485 // tampered with. |
483 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, | 486 QUIC_VERSION_NEGOTIATION_MISMATCH = 55, |
484 | 487 |
485 // No error. Used as bound while iterating. | 488 // No error. Used as bound while iterating. |
486 QUIC_LAST_ERROR = 60, | 489 QUIC_LAST_ERROR = 61, |
487 }; | 490 }; |
488 | 491 |
489 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { | 492 struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { |
490 QuicPacketPublicHeader(); | 493 QuicPacketPublicHeader(); |
491 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); | 494 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); |
492 ~QuicPacketPublicHeader(); | 495 ~QuicPacketPublicHeader(); |
493 | 496 |
494 // Universal header. All QuicPacket headers will have a guid and public flags. | 497 // Universal header. All QuicPacket headers will have a guid and public flags. |
495 QuicGuid guid; | 498 QuicGuid guid; |
496 QuicGuidLength guid_length; | 499 QuicGuidLength guid_length; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 bool NET_EXPORT_PRIVATE IsAwaitingPacket( | 625 bool NET_EXPORT_PRIVATE IsAwaitingPacket( |
623 const ReceivedPacketInfo& received_info, | 626 const ReceivedPacketInfo& received_info, |
624 QuicPacketSequenceNumber sequence_number); | 627 QuicPacketSequenceNumber sequence_number); |
625 | 628 |
626 // Inserts missing packets between [lower, higher). | 629 // Inserts missing packets between [lower, higher). |
627 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( | 630 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( |
628 ReceivedPacketInfo* received_info, | 631 ReceivedPacketInfo* received_info, |
629 QuicPacketSequenceNumber lower, | 632 QuicPacketSequenceNumber lower, |
630 QuicPacketSequenceNumber higher); | 633 QuicPacketSequenceNumber higher); |
631 | 634 |
632 struct NET_EXPORT_PRIVATE SentPacketInfo { | 635 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { |
633 SentPacketInfo(); | 636 QuicStopWaitingFrame(); |
634 ~SentPacketInfo(); | 637 ~QuicStopWaitingFrame(); |
635 | 638 |
636 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 639 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
637 std::ostream& os, const SentPacketInfo& s); | 640 std::ostream& os, const QuicStopWaitingFrame& s); |
| 641 |
638 // Entropy hash of all packets up to, but not including, the least unacked | 642 // Entropy hash of all packets up to, but not including, the least unacked |
639 // packet. | 643 // packet. |
640 QuicPacketEntropyHash entropy_hash; | 644 QuicPacketEntropyHash entropy_hash; |
641 // The lowest packet we've sent which is unacked, and we expect an ack for. | 645 // The lowest packet we've sent which is unacked, and we expect an ack for. |
642 QuicPacketSequenceNumber least_unacked; | 646 QuicPacketSequenceNumber least_unacked; |
643 }; | 647 }; |
644 | 648 |
645 struct NET_EXPORT_PRIVATE QuicAckFrame { | 649 struct NET_EXPORT_PRIVATE QuicAckFrame { |
646 QuicAckFrame(); | 650 QuicAckFrame(); |
647 // Testing convenience method to construct a QuicAckFrame with all packets | 651 // Testing convenience method to construct a QuicAckFrame with all packets |
648 // from least_unacked to largest_observed acked. | 652 // from least_unacked to largest_observed acked. |
649 QuicAckFrame(QuicPacketSequenceNumber largest_observed, | 653 QuicAckFrame(QuicPacketSequenceNumber largest_observed, |
650 QuicTime largest_observed_receive_time, | 654 QuicTime largest_observed_receive_time, |
651 QuicPacketSequenceNumber least_unacked); | 655 QuicPacketSequenceNumber least_unacked); |
652 | 656 |
653 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 657 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
654 std::ostream& os, const QuicAckFrame& s); | 658 std::ostream& os, const QuicAckFrame& s); |
655 | 659 |
656 SentPacketInfo sent_info; | 660 QuicStopWaitingFrame sent_info; |
657 ReceivedPacketInfo received_info; | 661 ReceivedPacketInfo received_info; |
658 }; | 662 }; |
659 | 663 |
660 // Defines for all types of congestion feedback that will be negotiated in QUIC, | 664 // Defines for all types of congestion feedback that will be negotiated in QUIC, |
661 // kTCP MUST be supported by all QUIC implementations to guarantee 100% | 665 // kTCP MUST be supported by all QUIC implementations to guarantee 100% |
662 // compatibility. | 666 // compatibility. |
663 enum CongestionFeedbackType { | 667 enum CongestionFeedbackType { |
664 kTCP, // Used to mimic TCP. | 668 kTCP, // Used to mimic TCP. |
665 kInterArrival, // Use additional inter arrival information. | 669 kInterArrival, // Use additional inter arrival information. |
666 kFixRate, // Provided for testing. | 670 kFixRate, // Provided for testing. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 }; | 799 }; |
796 | 800 |
797 struct NET_EXPORT_PRIVATE QuicFrame { | 801 struct NET_EXPORT_PRIVATE QuicFrame { |
798 QuicFrame(); | 802 QuicFrame(); |
799 explicit QuicFrame(QuicPaddingFrame* padding_frame); | 803 explicit QuicFrame(QuicPaddingFrame* padding_frame); |
800 explicit QuicFrame(QuicStreamFrame* stream_frame); | 804 explicit QuicFrame(QuicStreamFrame* stream_frame); |
801 explicit QuicFrame(QuicAckFrame* frame); | 805 explicit QuicFrame(QuicAckFrame* frame); |
802 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); | 806 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); |
803 explicit QuicFrame(QuicRstStreamFrame* frame); | 807 explicit QuicFrame(QuicRstStreamFrame* frame); |
804 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 808 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
| 809 explicit QuicFrame(QuicStopWaitingFrame* frame); |
805 explicit QuicFrame(QuicGoAwayFrame* frame); | 810 explicit QuicFrame(QuicGoAwayFrame* frame); |
806 explicit QuicFrame(QuicWindowUpdateFrame* frame); | 811 explicit QuicFrame(QuicWindowUpdateFrame* frame); |
807 explicit QuicFrame(QuicBlockedFrame* frame); | 812 explicit QuicFrame(QuicBlockedFrame* frame); |
808 | 813 |
809 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 814 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
810 std::ostream& os, const QuicFrame& frame); | 815 std::ostream& os, const QuicFrame& frame); |
811 | 816 |
812 QuicFrameType type; | 817 QuicFrameType type; |
813 union { | 818 union { |
814 QuicPaddingFrame* padding_frame; | 819 QuicPaddingFrame* padding_frame; |
815 QuicStreamFrame* stream_frame; | 820 QuicStreamFrame* stream_frame; |
816 QuicAckFrame* ack_frame; | 821 QuicAckFrame* ack_frame; |
817 QuicCongestionFeedbackFrame* congestion_feedback_frame; | 822 QuicCongestionFeedbackFrame* congestion_feedback_frame; |
| 823 QuicStopWaitingFrame* stop_waiting_frame; |
818 QuicRstStreamFrame* rst_stream_frame; | 824 QuicRstStreamFrame* rst_stream_frame; |
819 QuicConnectionCloseFrame* connection_close_frame; | 825 QuicConnectionCloseFrame* connection_close_frame; |
820 QuicGoAwayFrame* goaway_frame; | 826 QuicGoAwayFrame* goaway_frame; |
821 QuicWindowUpdateFrame* window_update_frame; | 827 QuicWindowUpdateFrame* window_update_frame; |
822 QuicBlockedFrame* blocked_frame; | 828 QuicBlockedFrame* blocked_frame; |
823 }; | 829 }; |
824 }; | 830 }; |
825 | 831 |
826 typedef std::vector<QuicFrame> QuicFrames; | 832 typedef std::vector<QuicFrame> QuicFrames; |
827 | 833 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 WriteStatus status; | 1011 WriteStatus status; |
1006 union { | 1012 union { |
1007 int bytes_written; // only valid when status is OK | 1013 int bytes_written; // only valid when status is OK |
1008 int error_code; // only valid when status is ERROR | 1014 int error_code; // only valid when status is ERROR |
1009 }; | 1015 }; |
1010 }; | 1016 }; |
1011 | 1017 |
1012 } // namespace net | 1018 } // namespace net |
1013 | 1019 |
1014 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1020 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |