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 <map> | 11 #include <map> |
11 #include <ostream> | 12 #include <ostream> |
12 #include <set> | 13 #include <set> |
13 #include <string> | 14 #include <string> |
14 #include <utility> | 15 #include <utility> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
18 #include "base/containers/hash_tables.h" | 19 #include "base/containers/hash_tables.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 enum QuicVersion { | 285 enum QuicVersion { |
285 // Special case to indicate unknown/unsupported QUIC version. | 286 // Special case to indicate unknown/unsupported QUIC version. |
286 QUIC_VERSION_UNSUPPORTED = 0, | 287 QUIC_VERSION_UNSUPPORTED = 0, |
287 | 288 |
288 QUIC_VERSION_16 = 16, // STOP_WAITING frame. | 289 QUIC_VERSION_16 = 16, // STOP_WAITING frame. |
289 QUIC_VERSION_18 = 18, // PING frame. | 290 QUIC_VERSION_18 = 18, // PING frame. |
290 QUIC_VERSION_19 = 19, // Connection level flow control. | 291 QUIC_VERSION_19 = 19, // Connection level flow control. |
291 QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows. | 292 QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows. |
292 QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled. | 293 QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled. |
293 QUIC_VERSION_22 = 22, // Send Server Config Update messages on crypto stream. | 294 QUIC_VERSION_22 = 22, // Send Server Config Update messages on crypto stream. |
| 295 QUIC_VERSION_23 = 23, // Timestamp in the ack frame. |
294 }; | 296 }; |
295 | 297 |
296 // This vector contains QUIC versions which we currently support. | 298 // This vector contains QUIC versions which we currently support. |
297 // This should be ordered such that the highest supported version is the first | 299 // This should be ordered such that the highest supported version is the first |
298 // element, with subsequent elements in descending order (versions can be | 300 // element, with subsequent elements in descending order (versions can be |
299 // skipped as necessary). | 301 // skipped as necessary). |
300 // | 302 // |
301 // IMPORTANT: if you are adding to this list, follow the instructions at | 303 // IMPORTANT: if you are adding to this list, follow the instructions at |
302 // http://sites/quic/adding-and-removing-versions | 304 // http://sites/quic/adding-and-removing-versions |
303 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_22, | 305 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_23, |
| 306 QUIC_VERSION_22, |
304 QUIC_VERSION_21, | 307 QUIC_VERSION_21, |
305 QUIC_VERSION_20, | 308 QUIC_VERSION_20, |
306 QUIC_VERSION_19, | 309 QUIC_VERSION_19, |
307 QUIC_VERSION_18, | 310 QUIC_VERSION_18, |
308 QUIC_VERSION_16}; | 311 QUIC_VERSION_16}; |
309 | 312 |
310 typedef std::vector<QuicVersion> QuicVersionVector; | 313 typedef std::vector<QuicVersion> QuicVersionVector; |
311 | 314 |
312 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 315 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
313 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 316 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 IOVector data; | 640 IOVector data; |
638 | 641 |
639 // If this is set, then when this packet is ACKed the AckNotifier will be | 642 // If this is set, then when this packet is ACKed the AckNotifier will be |
640 // informed. | 643 // informed. |
641 QuicAckNotifier* notifier; | 644 QuicAckNotifier* notifier; |
642 }; | 645 }; |
643 | 646 |
644 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing | 647 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing |
645 // is finalized. | 648 // is finalized. |
646 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; | 649 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; |
647 // TODO(pwestin): Add a way to enforce the max size of this map. | 650 |
648 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; | 651 typedef std::list<std::pair<QuicPacketSequenceNumber, QuicTime>> PacketTimeList; |
649 | 652 |
650 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { | 653 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { |
651 QuicStopWaitingFrame(); | 654 QuicStopWaitingFrame(); |
652 ~QuicStopWaitingFrame(); | 655 ~QuicStopWaitingFrame(); |
653 | 656 |
654 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 657 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
655 std::ostream& os, const QuicStopWaitingFrame& s); | 658 std::ostream& os, const QuicStopWaitingFrame& s); |
656 // Entropy hash of all packets up to, but not including, the least unacked | 659 // Entropy hash of all packets up to, but not including, the least unacked |
657 // packet. | 660 // packet. |
658 QuicPacketEntropyHash entropy_hash; | 661 QuicPacketEntropyHash entropy_hash; |
(...skipping 30 matching lines...) Expand all Loading... |
689 // structure. | 692 // structure. |
690 // The set of packets which we're expecting and have not received. | 693 // The set of packets which we're expecting and have not received. |
691 SequenceNumberSet missing_packets; | 694 SequenceNumberSet missing_packets; |
692 | 695 |
693 // Whether the ack had to be truncated when sent. | 696 // Whether the ack had to be truncated when sent. |
694 bool is_truncated; | 697 bool is_truncated; |
695 | 698 |
696 // Packets which have been revived via FEC. | 699 // Packets which have been revived via FEC. |
697 // All of these must also be in missing_packets. | 700 // All of these must also be in missing_packets. |
698 SequenceNumberSet revived_packets; | 701 SequenceNumberSet revived_packets; |
| 702 |
| 703 // List of <sequence_number, time> for when packets arrived. |
| 704 PacketTimeList received_packet_times; |
699 }; | 705 }; |
700 | 706 |
701 // True if the sequence number is greater than largest_observed or is listed | 707 // True if the sequence number is greater than largest_observed or is listed |
702 // as missing. | 708 // as missing. |
703 // Always returns false for sequence numbers less than least_unacked. | 709 // Always returns false for sequence numbers less than least_unacked. |
704 bool NET_EXPORT_PRIVATE IsAwaitingPacket( | 710 bool NET_EXPORT_PRIVATE IsAwaitingPacket( |
705 const QuicAckFrame& ack_frame, | 711 const QuicAckFrame& ack_frame, |
706 QuicPacketSequenceNumber sequence_number); | 712 QuicPacketSequenceNumber sequence_number); |
707 | 713 |
708 // Inserts missing packets between [lower, higher). | 714 // Inserts missing packets between [lower, higher). |
709 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( | 715 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( |
710 QuicAckFrame* ack_frame, | 716 QuicAckFrame* ack_frame, |
711 QuicPacketSequenceNumber lower, | 717 QuicPacketSequenceNumber lower, |
712 QuicPacketSequenceNumber higher); | 718 QuicPacketSequenceNumber higher); |
713 | 719 |
714 // Defines for all types of congestion feedback that will be negotiated in QUIC, | 720 // Defines for all types of congestion feedback that will be negotiated in QUIC, |
715 // kTCP MUST be supported by all QUIC implementations to guarantee 100% | 721 // kTCP MUST be supported by all QUIC implementations to guarantee 100% |
716 // compatibility. | 722 // compatibility. |
| 723 // TODO(cyr): Remove this when removing QUIC_VERSION_22. |
717 enum CongestionFeedbackType { | 724 enum CongestionFeedbackType { |
718 kTCP, // Used to mimic TCP. | 725 kTCP, // Used to mimic TCP. |
719 kTimestamp, // Use additional inter arrival timestamp information. | |
720 }; | 726 }; |
721 | 727 |
722 // Defines for all types of congestion control algorithms that can be used in | 728 // Defines for all types of congestion control algorithms that can be used in |
723 // QUIC. Note that this is separate from the congestion feedback type - | 729 // QUIC. Note that this is separate from the congestion feedback type - |
724 // some congestion control algorithms may use the same feedback type | 730 // some congestion control algorithms may use the same feedback type |
725 // (Reno and Cubic are the classic example for that). | 731 // (Reno and Cubic are the classic example for that). |
726 enum CongestionControlType { | 732 enum CongestionControlType { |
727 kCubic, | 733 kCubic, |
728 kReno, | 734 kReno, |
729 kBBR, | 735 kBBR, |
730 }; | 736 }; |
731 | 737 |
732 enum LossDetectionType { | 738 enum LossDetectionType { |
733 kNack, // Used to mimic TCP's loss detection. | 739 kNack, // Used to mimic TCP's loss detection. |
734 kTime, // Time based loss detection. | 740 kTime, // Time based loss detection. |
735 }; | 741 }; |
736 | 742 |
| 743 // TODO(cyr): Remove this when removing QUIC_VERSION_22. |
737 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { | 744 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { |
738 CongestionFeedbackMessageTCP(); | 745 CongestionFeedbackMessageTCP(); |
739 | 746 |
740 QuicByteCount receive_window; | 747 QuicByteCount receive_window; |
741 }; | 748 }; |
742 | 749 |
743 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTimestamp { | 750 // TODO(cyr): Remove this when removing QUIC_VERSION_22. |
744 CongestionFeedbackMessageTimestamp(); | |
745 ~CongestionFeedbackMessageTimestamp(); | |
746 | |
747 // The set of received packets since the last feedback was sent, along with | |
748 // their arrival times. | |
749 TimeMap received_packet_times; | |
750 }; | |
751 | |
752 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { | 751 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { |
753 QuicCongestionFeedbackFrame(); | 752 QuicCongestionFeedbackFrame(); |
754 ~QuicCongestionFeedbackFrame(); | 753 ~QuicCongestionFeedbackFrame(); |
755 | 754 |
756 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 755 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
757 std::ostream& os, const QuicCongestionFeedbackFrame& c); | 756 std::ostream& os, const QuicCongestionFeedbackFrame& c); |
758 | 757 |
759 CongestionFeedbackType type; | 758 CongestionFeedbackType type; |
760 // This should really be a union, but since the timestamp struct | 759 // This should really be a union, but since the timestamp struct |
761 // is non-trivial, C++ prohibits it. | 760 // is non-trivial, C++ prohibits it. |
762 CongestionFeedbackMessageTCP tcp; | 761 CongestionFeedbackMessageTCP tcp; |
763 CongestionFeedbackMessageTimestamp timestamp; | |
764 }; | 762 }; |
765 | 763 |
766 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { | 764 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { |
767 QuicRstStreamFrame(); | 765 QuicRstStreamFrame(); |
768 QuicRstStreamFrame(QuicStreamId stream_id, | 766 QuicRstStreamFrame(QuicStreamId stream_id, |
769 QuicRstStreamErrorCode error_code, | 767 QuicRstStreamErrorCode error_code, |
770 QuicStreamOffset bytes_written); | 768 QuicStreamOffset bytes_written); |
771 | 769 |
772 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 770 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
773 std::ostream& os, const QuicRstStreamFrame& r); | 771 std::ostream& os, const QuicRstStreamFrame& r); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 ENCRYPTION_FORWARD_SECURE = 2, | 852 ENCRYPTION_FORWARD_SECURE = 2, |
855 | 853 |
856 NUM_ENCRYPTION_LEVELS, | 854 NUM_ENCRYPTION_LEVELS, |
857 }; | 855 }; |
858 | 856 |
859 struct NET_EXPORT_PRIVATE QuicFrame { | 857 struct NET_EXPORT_PRIVATE QuicFrame { |
860 QuicFrame(); | 858 QuicFrame(); |
861 explicit QuicFrame(QuicPaddingFrame* padding_frame); | 859 explicit QuicFrame(QuicPaddingFrame* padding_frame); |
862 explicit QuicFrame(QuicStreamFrame* stream_frame); | 860 explicit QuicFrame(QuicStreamFrame* stream_frame); |
863 explicit QuicFrame(QuicAckFrame* frame); | 861 explicit QuicFrame(QuicAckFrame* frame); |
| 862 |
| 863 // TODO(cyr): Remove this when removing QUIC_VERSION_22. |
864 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); | 864 explicit QuicFrame(QuicCongestionFeedbackFrame* frame); |
| 865 |
865 explicit QuicFrame(QuicRstStreamFrame* frame); | 866 explicit QuicFrame(QuicRstStreamFrame* frame); |
866 explicit QuicFrame(QuicConnectionCloseFrame* frame); | 867 explicit QuicFrame(QuicConnectionCloseFrame* frame); |
867 explicit QuicFrame(QuicStopWaitingFrame* frame); | 868 explicit QuicFrame(QuicStopWaitingFrame* frame); |
868 explicit QuicFrame(QuicPingFrame* frame); | 869 explicit QuicFrame(QuicPingFrame* frame); |
869 explicit QuicFrame(QuicGoAwayFrame* frame); | 870 explicit QuicFrame(QuicGoAwayFrame* frame); |
870 explicit QuicFrame(QuicWindowUpdateFrame* frame); | 871 explicit QuicFrame(QuicWindowUpdateFrame* frame); |
871 explicit QuicFrame(QuicBlockedFrame* frame); | 872 explicit QuicFrame(QuicBlockedFrame* frame); |
872 | 873 |
873 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 874 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
874 std::ostream& os, const QuicFrame& frame); | 875 std::ostream& os, const QuicFrame& frame); |
875 | 876 |
876 QuicFrameType type; | 877 QuicFrameType type; |
877 union { | 878 union { |
878 QuicPaddingFrame* padding_frame; | 879 QuicPaddingFrame* padding_frame; |
879 QuicStreamFrame* stream_frame; | 880 QuicStreamFrame* stream_frame; |
880 QuicAckFrame* ack_frame; | 881 QuicAckFrame* ack_frame; |
| 882 |
| 883 // TODO(cyr): Remove this when removing QUIC_VERSION_22. |
881 QuicCongestionFeedbackFrame* congestion_feedback_frame; | 884 QuicCongestionFeedbackFrame* congestion_feedback_frame; |
882 QuicStopWaitingFrame* stop_waiting_frame; | 885 QuicStopWaitingFrame* stop_waiting_frame; |
| 886 |
883 QuicPingFrame* ping_frame; | 887 QuicPingFrame* ping_frame; |
884 QuicRstStreamFrame* rst_stream_frame; | 888 QuicRstStreamFrame* rst_stream_frame; |
885 QuicConnectionCloseFrame* connection_close_frame; | 889 QuicConnectionCloseFrame* connection_close_frame; |
886 QuicGoAwayFrame* goaway_frame; | 890 QuicGoAwayFrame* goaway_frame; |
887 QuicWindowUpdateFrame* window_update_frame; | 891 QuicWindowUpdateFrame* window_update_frame; |
888 QuicBlockedFrame* blocked_frame; | 892 QuicBlockedFrame* blocked_frame; |
889 }; | 893 }; |
890 }; | 894 }; |
891 | 895 |
892 typedef std::vector<QuicFrame> QuicFrames; | 896 typedef std::vector<QuicFrame> QuicFrames; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 // Stores the sequence numbers of all transmissions of this packet. | 1076 // Stores the sequence numbers of all transmissions of this packet. |
1073 // Can never be null. | 1077 // Can never be null. |
1074 SequenceNumberSet* all_transmissions; | 1078 SequenceNumberSet* all_transmissions; |
1075 // In flight packets have not been abandoned or lost. | 1079 // In flight packets have not been abandoned or lost. |
1076 bool in_flight; | 1080 bool in_flight; |
1077 }; | 1081 }; |
1078 | 1082 |
1079 } // namespace net | 1083 } // namespace net |
1080 | 1084 |
1081 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1085 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |