Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: net/quic/quic_protocol.h

Issue 420313005: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0723
Patch Set: change QUIC packet size to 1350 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // QuicTag is the type of a tag in the wire protocol. 42 // QuicTag is the type of a tag in the wire protocol.
43 typedef uint32 QuicTag; 43 typedef uint32 QuicTag;
44 typedef std::vector<QuicTag> QuicTagVector; 44 typedef std::vector<QuicTag> QuicTagVector;
45 typedef std::map<QuicTag, std::string> QuicTagValueMap; 45 typedef std::map<QuicTag, std::string> QuicTagValueMap;
46 // TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and 46 // TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and
47 // QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION. 47 // QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION.
48 typedef uint32 QuicPriority; 48 typedef uint32 QuicPriority;
49 49
50 // TODO(rch): Consider Quic specific names for these constants. 50 // TODO(rch): Consider Quic specific names for these constants.
51 // Default and initial maximum size in bytes of a QUIC packet. 51 // Default and initial maximum size in bytes of a QUIC packet.
52 const QuicByteCount kDefaultMaxPacketSize = 1200; 52 const QuicByteCount kDefaultMaxPacketSize = 1350;
53 // The maximum packet size of any QUIC packet, based on ethernet's max size, 53 // The maximum packet size of any QUIC packet, based on ethernet's max size,
54 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an 54 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an
55 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's 55 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
56 // max packet size is 1500 bytes, 1500 - 48 = 1452. 56 // max packet size is 1500 bytes, 1500 - 48 = 1452.
57 const QuicByteCount kMaxPacketSize = 1452; 57 const QuicByteCount kMaxPacketSize = 1452;
58 // Default maximum packet size used in Linux TCP implementations. 58 // Default maximum packet size used in Linux TCP implementations.
59 const QuicByteCount kDefaultTCPMSS = 1460; 59 const QuicByteCount kDefaultTCPMSS = 1460;
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;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // The available versions of QUIC. Guaranteed that the integer value of the enum 266 // The available versions of QUIC. Guaranteed that the integer value of the enum
267 // will match the version number. 267 // will match the version number.
268 // When adding a new version to this enum you should add it to 268 // When adding a new version to this enum you should add it to
269 // kSupportedQuicVersions (if appropriate), and also add a new case to the 269 // kSupportedQuicVersions (if appropriate), and also add a new case to the
270 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and 270 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and
271 // QuicVersionToString. 271 // QuicVersionToString.
272 enum QuicVersion { 272 enum QuicVersion {
273 // Special case to indicate unknown/unsupported QUIC version. 273 // Special case to indicate unknown/unsupported QUIC version.
274 QUIC_VERSION_UNSUPPORTED = 0, 274 QUIC_VERSION_UNSUPPORTED = 0,
275 275
276 QUIC_VERSION_15 = 15, // Revived packets in ReceivedPacketInfo.
277 QUIC_VERSION_16 = 16, // STOP_WAITING frame. 276 QUIC_VERSION_16 = 16, // STOP_WAITING frame.
278 QUIC_VERSION_18 = 18, // PING frame. 277 QUIC_VERSION_18 = 18, // PING frame.
279 QUIC_VERSION_19 = 19, // Connection level flow control. 278 QUIC_VERSION_19 = 19, // Connection level flow control.
280 QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows. 279 QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows.
281 QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled. 280 QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled.
282 }; 281 };
283 282
284 // This vector contains QUIC versions which we currently support. 283 // This vector contains QUIC versions which we currently support.
285 // This should be ordered such that the highest supported version is the first 284 // This should be ordered such that the highest supported version is the first
286 // element, with subsequent elements in descending order (versions can be 285 // element, with subsequent elements in descending order (versions can be
287 // skipped as necessary). 286 // skipped as necessary).
288 // 287 //
289 // IMPORTANT: if you are addding to this list, follow the instructions at 288 // IMPORTANT: if you are adding to this list, follow the instructions at
290 // http://sites/quic/adding-and-removing-versions 289 // http://sites/quic/adding-and-removing-versions
291 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_21, 290 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_21,
292 QUIC_VERSION_20, 291 QUIC_VERSION_20,
293 QUIC_VERSION_19, 292 QUIC_VERSION_19,
294 QUIC_VERSION_18, 293 QUIC_VERSION_18,
295 QUIC_VERSION_16, 294 QUIC_VERSION_16};
296 QUIC_VERSION_15};
297 295
298 typedef std::vector<QuicVersion> QuicVersionVector; 296 typedef std::vector<QuicVersion> QuicVersionVector;
299 297
300 // Returns a vector of QUIC versions in kSupportedQuicVersions. 298 // Returns a vector of QUIC versions in kSupportedQuicVersions.
301 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); 299 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions();
302 300
303 // QuicTag is written to and read from the wire, but we prefer to use 301 // QuicTag is written to and read from the wire, but we prefer to use
304 // the more readable QuicVersion at other levels. 302 // the more readable QuicVersion at other levels.
305 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 303 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0
306 // if QuicVersion is unsupported. 304 // if QuicVersion is unsupported.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // informed. 624 // informed.
627 QuicAckNotifier* notifier; 625 QuicAckNotifier* notifier;
628 }; 626 };
629 627
630 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing 628 // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing
631 // is finalized. 629 // is finalized.
632 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; 630 typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet;
633 // TODO(pwestin): Add a way to enforce the max size of this map. 631 // TODO(pwestin): Add a way to enforce the max size of this map.
634 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; 632 typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap;
635 633
636 struct NET_EXPORT_PRIVATE ReceivedPacketInfo { 634 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame {
637 ReceivedPacketInfo(); 635 QuicStopWaitingFrame();
638 ~ReceivedPacketInfo(); 636 ~QuicStopWaitingFrame();
639 637
640 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 638 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
641 std::ostream& os, const ReceivedPacketInfo& s); 639 std::ostream& os, const QuicStopWaitingFrame& s);
640 // Entropy hash of all packets up to, but not including, the least unacked
641 // packet.
642 QuicPacketEntropyHash entropy_hash;
643 // The lowest packet we've sent which is unacked, and we expect an ack for.
644 QuicPacketSequenceNumber least_unacked;
645 };
646
647 struct NET_EXPORT_PRIVATE QuicAckFrame {
648 QuicAckFrame();
649 ~QuicAckFrame();
650
651 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
652 std::ostream& os, const QuicAckFrame& s);
642 653
643 // Entropy hash of all packets up to largest observed not including missing 654 // Entropy hash of all packets up to largest observed not including missing
644 // packets. 655 // packets.
645 QuicPacketEntropyHash entropy_hash; 656 QuicPacketEntropyHash entropy_hash;
646 657
647 // The highest packet sequence number we've observed from the peer. 658 // The highest packet sequence number we've observed from the peer.
648 // 659 //
649 // In general, this should be the largest packet number we've received. In 660 // In general, this should be the largest packet number we've received. In
650 // the case of truncated acks, we may have to advertise a lower "upper bound" 661 // the case of truncated acks, we may have to advertise a lower "upper bound"
651 // than largest received, to avoid implicitly acking missing packets that 662 // than largest received, to avoid implicitly acking missing packets that
(...skipping 16 matching lines...) Expand all
668 679
669 // Packets which have been revived via FEC. 680 // Packets which have been revived via FEC.
670 // All of these must also be in missing_packets. 681 // All of these must also be in missing_packets.
671 SequenceNumberSet revived_packets; 682 SequenceNumberSet revived_packets;
672 }; 683 };
673 684
674 // True if the sequence number is greater than largest_observed or is listed 685 // True if the sequence number is greater than largest_observed or is listed
675 // as missing. 686 // as missing.
676 // Always returns false for sequence numbers less than least_unacked. 687 // Always returns false for sequence numbers less than least_unacked.
677 bool NET_EXPORT_PRIVATE IsAwaitingPacket( 688 bool NET_EXPORT_PRIVATE IsAwaitingPacket(
678 const ReceivedPacketInfo& received_info, 689 const QuicAckFrame& ack_frame,
679 QuicPacketSequenceNumber sequence_number); 690 QuicPacketSequenceNumber sequence_number);
680 691
681 // Inserts missing packets between [lower, higher). 692 // Inserts missing packets between [lower, higher).
682 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( 693 void NET_EXPORT_PRIVATE InsertMissingPacketsBetween(
683 ReceivedPacketInfo* received_info, 694 QuicAckFrame* ack_frame,
684 QuicPacketSequenceNumber lower, 695 QuicPacketSequenceNumber lower,
685 QuicPacketSequenceNumber higher); 696 QuicPacketSequenceNumber higher);
686 697
687 struct NET_EXPORT_PRIVATE QuicStopWaitingFrame {
688 QuicStopWaitingFrame();
689 ~QuicStopWaitingFrame();
690
691 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
692 std::ostream& os, const QuicStopWaitingFrame& s);
693
694 // Entropy hash of all packets up to, but not including, the least unacked
695 // packet.
696 QuicPacketEntropyHash entropy_hash;
697 // The lowest packet we've sent which is unacked, and we expect an ack for.
698 QuicPacketSequenceNumber least_unacked;
699 };
700
701 struct NET_EXPORT_PRIVATE QuicAckFrame {
702 QuicAckFrame();
703
704 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
705 std::ostream& os, const QuicAckFrame& s);
706
707 QuicStopWaitingFrame sent_info;
708 ReceivedPacketInfo received_info;
709 };
710
711 // Defines for all types of congestion feedback that will be negotiated in QUIC, 698 // Defines for all types of congestion feedback that will be negotiated in QUIC,
712 // kTCP MUST be supported by all QUIC implementations to guarantee 100% 699 // kTCP MUST be supported by all QUIC implementations to guarantee 100%
713 // compatibility. 700 // compatibility.
714 enum CongestionFeedbackType { 701 enum CongestionFeedbackType {
715 kTCP, // Used to mimic TCP. 702 kTCP, // Used to mimic TCP.
716 kInterArrival, // Use additional inter arrival information. 703 kInterArrival, // Use additional inter arrival information.
717 kFixRate, // Provided for testing.
718 }; 704 };
719 705
720 // Defines for all types of congestion control algorithms that can be used in 706 // Defines for all types of congestion control algorithms that can be used in
721 // QUIC. Note that this is separate from the congestion feedback type - 707 // QUIC. Note that this is separate from the congestion feedback type -
722 // some congestion control algorithms may use the same feedback type 708 // some congestion control algorithms may use the same feedback type
723 // (Reno and Cubic are the classic example for that). 709 // (Reno and Cubic are the classic example for that).
724 enum CongestionControlType { 710 enum CongestionControlType {
725 kCubic, 711 kCubic,
726 kReno, 712 kReno,
727 kFixRateCongestionControl, // Provided for testing.
728 kBBR, 713 kBBR,
729 }; 714 };
730 715
731 enum LossDetectionType { 716 enum LossDetectionType {
732 kNack, // Used to mimic TCP's loss detection. 717 kNack, // Used to mimic TCP's loss detection.
733 kTime, // Time based loss detection. 718 kTime, // Time based loss detection.
734 }; 719 };
735 720
736 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { 721 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP {
737 CongestionFeedbackMessageTCP(); 722 CongestionFeedbackMessageTCP();
738 723
739 QuicByteCount receive_window; 724 QuicByteCount receive_window;
740 }; 725 };
741 726
742 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageInterArrival { 727 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageInterArrival {
743 CongestionFeedbackMessageInterArrival(); 728 CongestionFeedbackMessageInterArrival();
744 ~CongestionFeedbackMessageInterArrival(); 729 ~CongestionFeedbackMessageInterArrival();
745 730
746 // The set of received packets since the last feedback was sent, along with 731 // The set of received packets since the last feedback was sent, along with
747 // their arrival times. 732 // their arrival times.
748 TimeMap received_packet_times; 733 TimeMap received_packet_times;
749 }; 734 };
750 735
751 struct NET_EXPORT_PRIVATE CongestionFeedbackMessageFixRate {
752 CongestionFeedbackMessageFixRate();
753 QuicBandwidth bitrate;
754 };
755
756 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { 736 struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame {
757 QuicCongestionFeedbackFrame(); 737 QuicCongestionFeedbackFrame();
758 ~QuicCongestionFeedbackFrame(); 738 ~QuicCongestionFeedbackFrame();
759 739
760 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 740 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
761 std::ostream& os, const QuicCongestionFeedbackFrame& c); 741 std::ostream& os, const QuicCongestionFeedbackFrame& c);
762 742
763 CongestionFeedbackType type; 743 CongestionFeedbackType type;
764 // This should really be a union, but since the inter arrival struct 744 // This should really be a union, but since the inter arrival struct
765 // is non-trivial, C++ prohibits it. 745 // is non-trivial, C++ prohibits it.
766 CongestionFeedbackMessageTCP tcp; 746 CongestionFeedbackMessageTCP tcp;
767 CongestionFeedbackMessageInterArrival inter_arrival; 747 CongestionFeedbackMessageInterArrival inter_arrival;
768 CongestionFeedbackMessageFixRate fix_rate;
769 }; 748 };
770 749
771 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { 750 struct NET_EXPORT_PRIVATE QuicRstStreamFrame {
772 QuicRstStreamFrame(); 751 QuicRstStreamFrame();
773 QuicRstStreamFrame(QuicStreamId stream_id, 752 QuicRstStreamFrame(QuicStreamId stream_id,
774 QuicRstStreamErrorCode error_code, 753 QuicRstStreamErrorCode error_code,
775 QuicStreamOffset bytes_written); 754 QuicStreamOffset bytes_written);
776 755
777 NET_EXPORT_PRIVATE friend std::ostream& operator<<( 756 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
778 std::ostream& os, const QuicRstStreamFrame& r); 757 std::ostream& os, const QuicRstStreamFrame& r);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 // Stores the sequence numbers of all transmissions of this packet. 1053 // Stores the sequence numbers of all transmissions of this packet.
1075 // Can never be null. 1054 // Can never be null.
1076 SequenceNumberSet* all_transmissions; 1055 SequenceNumberSet* all_transmissions;
1077 // In flight packets have not been abandoned or lost. 1056 // In flight packets have not been abandoned or lost.
1078 bool in_flight; 1057 bool in_flight;
1079 }; 1058 };
1080 1059
1081 } // namespace net 1060 } // namespace net
1082 1061
1083 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 1062 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698