[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_QUIC_QUIC_PROTOCOL_H_ |
| 6 | #define NET_QUIC_QUIC_PROTOCOL_H_ |
| 7 | |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 8 | #include <stddef.h> |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 9 | #include <limits> |
[email protected] | a674b4c | 2012-12-05 03:44:30 | [diff] [blame] | 10 | #include <map> |
[email protected] | 5640d0a | 2012-10-22 18:17:02 | [diff] [blame] | 11 | #include <ostream> |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 12 | #include <set> |
| 13 | #include <string> |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 14 | #include <utility> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "base/basictypes.h" |
[email protected] | 14c1c23 | 2013-06-11 17:52:44 | [diff] [blame] | 18 | #include "base/containers/hash_tables.h" |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 19 | #include "base/logging.h" |
[email protected] | d069c11a | 2013-04-13 00:01:55 | [diff] [blame] | 20 | #include "base/strings/string_piece.h" |
[email protected] | 165e075 | 2012-11-16 07:49:44 | [diff] [blame] | 21 | #include "net/base/int128.h" |
[email protected] | 79d13dcb | 2014-02-05 07:23:13 | [diff] [blame] | 22 | #include "net/base/ip_endpoint.h" |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 23 | #include "net/base/net_export.h" |
[email protected] | 5dafdb6 | 2013-11-14 01:24:26 | [diff] [blame] | 24 | #include "net/quic/iovector.h" |
[email protected] | fee17f7 | 2013-02-03 07:47:41 | [diff] [blame] | 25 | #include "net/quic/quic_bandwidth.h" |
[email protected] | 2a960e0 | 2012-11-11 14:48:10 | [diff] [blame] | 26 | #include "net/quic/quic_time.h" |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 27 | |
| 28 | namespace net { |
| 29 | |
[email protected] | 97cf302 | 2013-09-05 14:30:16 | [diff] [blame] | 30 | class QuicAckNotifier; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 31 | class QuicPacket; |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 32 | struct QuicPacketHeader; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 33 | |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 34 | typedef uint64 QuicConnectionId; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 35 | typedef uint32 QuicStreamId; |
| 36 | typedef uint64 QuicStreamOffset; |
| 37 | typedef uint64 QuicPacketSequenceNumber; |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 38 | typedef QuicPacketSequenceNumber QuicFecGroupNumber; |
[email protected] | 86a318d | 2013-01-23 21:16:04 | [diff] [blame] | 39 | typedef uint64 QuicPublicResetNonceProof; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 40 | typedef uint8 QuicPacketEntropyHash; |
[email protected] | c244c5a1 | 2013-05-07 20:55:04 | [diff] [blame] | 41 | typedef uint32 QuicHeaderId; |
[email protected] | 2532de1 | 2013-05-09 12:29:33 | [diff] [blame] | 42 | // QuicTag is the type of a tag in the wire protocol. |
| 43 | typedef uint32 QuicTag; |
| 44 | typedef std::vector<QuicTag> QuicTagVector; |
[email protected] | 79d13dcb | 2014-02-05 07:23:13 | [diff] [blame] | 45 | typedef std::map<QuicTag, std::string> QuicTagValueMap; |
[email protected] | 497bfb2 | 2014-01-08 01:28:03 | [diff] [blame] | 46 | // TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and |
| 47 | // QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION. |
[email protected] | 8edeb8d | 2013-08-28 06:11:43 | [diff] [blame] | 48 | typedef uint32 QuicPriority; |
[email protected] | cff7b7b | 2013-01-11 08:49:07 | [diff] [blame] | 49 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 50 | // TODO(rch): Consider Quic specific names for these constants. |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 51 | // Default and initial maximum size in bytes of a QUIC packet. |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 52 | const QuicByteCount kDefaultMaxPacketSize = 1350; |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 53 | // The maximum packet size of any QUIC packet, based on ethernet's max size, |
[email protected] | 41fb637 | 2013-12-10 05:26:40 | [diff] [blame] | 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 |
| 56 | // max packet size is 1500 bytes, 1500 - 48 = 1452. |
| 57 | const QuicByteCount kMaxPacketSize = 1452; |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 58 | // Default maximum packet size used in Linux TCP implementations. |
| 59 | const QuicByteCount kDefaultTCPMSS = 1460; |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 60 | |
| 61 | // Maximum size of the initial congestion window in packets. |
| 62 | const size_t kDefaultInitialWindow = 10; |
[email protected] | 2d43c4012 | 2014-04-21 14:51:27 | [diff] [blame] | 63 | const uint32 kMaxInitialWindow = 100; |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 64 | |
[email protected] | 7d56135 | 2014-06-20 09:09:21 | [diff] [blame] | 65 | // Default size of initial flow control window, for both stream and session. |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 66 | const uint32 kDefaultFlowControlSendWindow = 16 * 1024; // 16 KB |
| 67 | |
[email protected] | 0ac0c5b | 2013-11-20 05:55:58 | [diff] [blame] | 68 | // Maximum size of the congestion window, in packets, for TCP congestion control |
| 69 | // algorithms. |
| 70 | const size_t kMaxTcpCongestionWindow = 200; |
| 71 | |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 72 | // Size of the socket receive buffer in bytes. |
[email protected] | 648f8114 | 2014-08-15 21:38:46 | [diff] [blame] | 73 | const QuicByteCount kDefaultSocketReceiveBuffer = 256 * 1024; |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 74 | |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 75 | // Don't allow a client to suggest an RTT longer than 15 seconds. |
[email protected] | 2d43c4012 | 2014-04-21 14:51:27 | [diff] [blame] | 76 | const uint32 kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 77 | |
| 78 | // Maximum number of open streams per connection. |
| 79 | const size_t kDefaultMaxStreamsPerConnection = 100; |
| 80 | |
[email protected] | af806e6 | 2013-05-22 14:47:50 | [diff] [blame] | 81 | // Number of bytes reserved for public flags in the packet header. |
| 82 | const size_t kPublicFlagsSize = 1; |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 83 | // Number of bytes reserved for version number in the packet header. |
| 84 | const size_t kQuicVersionSize = 4; |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 85 | // Number of bytes reserved for private flags in the packet header. |
| 86 | const size_t kPrivateFlagsSize = 1; |
| 87 | // Number of bytes reserved for FEC group in the packet header. |
| 88 | const size_t kFecGroupSize = 1; |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 89 | |
| 90 | // Signifies that the QuicPacket will contain version of the protocol. |
| 91 | const bool kIncludeVersion = true; |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 92 | |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 93 | // Index of the first byte in a QUIC packet which is used in hash calculation. |
| 94 | const size_t kStartOfHashData = 0; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 95 | |
| 96 | // Limit on the delta between stream IDs. |
[email protected] | c5cc9bd | 2014-03-31 23:17:14 | [diff] [blame] | 97 | const QuicStreamId kMaxStreamIdDelta = 200; |
[email protected] | c244c5a1 | 2013-05-07 20:55:04 | [diff] [blame] | 98 | // Limit on the delta between header IDs. |
[email protected] | c5cc9bd | 2014-03-31 23:17:14 | [diff] [blame] | 99 | const QuicHeaderId kMaxHeaderIdDelta = 200; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 100 | |
| 101 | // Reserved ID for the crypto stream. |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 102 | const QuicStreamId kCryptoStreamId = 1; |
| 103 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 104 | // Reserved ID for the headers stream. |
| 105 | const QuicStreamId kHeadersStreamId = 3; |
| 106 | |
[email protected] | 648f8114 | 2014-08-15 21:38:46 | [diff] [blame] | 107 | // Maximum delayed ack time, in ms. |
| 108 | const int kMaxDelayedAckTime = 25; |
| 109 | |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 110 | // This is the default network timeout a for connection till the crypto |
| 111 | // handshake succeeds and the negotiated timeout from the handshake is received. |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 112 | const int64 kDefaultInitialTimeoutSecs = 120; // 2 mins. |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 113 | const int64 kDefaultTimeoutSecs = 60 * 10; // 10 minutes. |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 114 | const int64 kDefaultMaxTimeForCryptoHandshakeSecs = 5; // 5 secs. |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 115 | |
[email protected] | 525948df | 2014-04-21 06:26:58 | [diff] [blame] | 116 | // Default ping timeout. |
| 117 | const int64 kPingTimeoutSecs = 15; // 15 secs. |
| 118 | |
[email protected] | b007e63 | 2013-10-28 08:39:25 | [diff] [blame] | 119 | // We define an unsigned 16-bit floating point value, inspired by IEEE floats |
| 120 | // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), |
| 121 | // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden |
| 122 | // bit) and denormals, but without signs, transfinites or fractions. Wire format |
| 123 | // 16 bits (little-endian byte order) are split into exponent (high 5) and |
| 124 | // mantissa (low 11) and decoded as: |
| 125 | // uint64 value; |
| 126 | // if (exponent == 0) value = mantissa; |
| 127 | // else value = (mantissa | 1 << 11) << (exponent - 1) |
| 128 | const int kUFloat16ExponentBits = 5; |
| 129 | const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30 |
| 130 | const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11 |
| 131 | const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12 |
| 132 | const uint64 kUFloat16MaxValue = // 0x3FFC0000000 |
| 133 | ((GG_UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) << |
| 134 | kUFloat16MaxExponent; |
| 135 | |
[email protected] | c67a82cb | 2013-09-24 02:53:21 | [diff] [blame] | 136 | enum TransmissionType { |
[email protected] | 2532de1 | 2013-05-09 12:29:33 | [diff] [blame] | 137 | NOT_RETRANSMISSION, |
[email protected] | b9475b58 | 2014-03-20 20:04:33 | [diff] [blame] | 138 | FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION, |
| 139 | HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts. |
| 140 | ALL_UNACKED_RETRANSMISSION, // Retransmits of all unacked packets. |
| 141 | LOSS_RETRANSMISSION, // Retransmits due to loss detection. |
| 142 | RTO_RETRANSMISSION, // Retransmits due to retransmit time out. |
| 143 | TLP_RETRANSMISSION, // Tail loss probes. |
| 144 | LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION, |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 145 | }; |
| 146 | |
[email protected] | 41fb637 | 2013-12-10 05:26:40 | [diff] [blame] | 147 | enum RetransmissionType { |
| 148 | INITIAL_ENCRYPTION_ONLY, |
| 149 | ALL_PACKETS |
| 150 | }; |
| 151 | |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 152 | enum HasRetransmittableData { |
[email protected] | 2532de1 | 2013-05-09 12:29:33 | [diff] [blame] | 153 | NO_RETRANSMITTABLE_DATA, |
| 154 | HAS_RETRANSMITTABLE_DATA, |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 155 | }; |
| 156 | |
[email protected] | 575cce6 | 2013-08-03 02:06:43 | [diff] [blame] | 157 | enum IsHandshake { |
| 158 | NOT_HANDSHAKE, |
| 159 | IS_HANDSHAKE |
| 160 | }; |
| 161 | |
[email protected] | bbb1007 | 2014-06-13 07:41:59 | [diff] [blame] | 162 | // Indicates FEC protection level for data being written. |
| 163 | enum FecProtection { |
| 164 | MUST_FEC_PROTECT, // Callee must FEC protect this data. |
[email protected] | a5b9817 | 2014-06-18 07:01:59 | [diff] [blame] | 165 | MAY_FEC_PROTECT // Callee does not have to but may FEC protect this data. |
| 166 | }; |
| 167 | |
[email protected] | bc356fe | 2014-06-19 11:14:14 | [diff] [blame] | 168 | // Indicates FEC policy. |
[email protected] | a5b9817 | 2014-06-18 07:01:59 | [diff] [blame] | 169 | enum FecPolicy { |
| 170 | FEC_PROTECT_ALWAYS, // All data in the stream should be FEC protected. |
| 171 | FEC_PROTECT_OPTIONAL // Data in the stream does not need FEC protection. |
[email protected] | bbb1007 | 2014-06-13 07:41:59 | [diff] [blame] | 172 | }; |
| 173 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 174 | enum QuicFrameType { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 175 | // Regular frame types. The values set here cannot change without the |
| 176 | // introduction of a new QUIC version. |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 177 | PADDING_FRAME = 0, |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 178 | RST_STREAM_FRAME = 1, |
| 179 | CONNECTION_CLOSE_FRAME = 2, |
| 180 | GOAWAY_FRAME = 3, |
| 181 | WINDOW_UPDATE_FRAME = 4, |
| 182 | BLOCKED_FRAME = 5, |
[email protected] | 93dd91f | 2014-02-27 00:09:03 | [diff] [blame] | 183 | STOP_WAITING_FRAME = 6, |
[email protected] | d8c52211 | 2014-04-23 09:23:25 | [diff] [blame] | 184 | PING_FRAME = 7, |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 185 | |
| 186 | // STREAM, ACK, and CONGESTION_FEEDBACK frames are special frames. They are |
| 187 | // encoded differently on the wire and their values do not need to be stable. |
[email protected] | 97cf302 | 2013-09-05 14:30:16 | [diff] [blame] | 188 | STREAM_FRAME, |
| 189 | ACK_FRAME, |
| 190 | CONGESTION_FEEDBACK_FRAME, |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 191 | NUM_FRAME_TYPES |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 192 | }; |
| 193 | |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 194 | enum QuicConnectionIdLength { |
| 195 | PACKET_0BYTE_CONNECTION_ID = 0, |
| 196 | PACKET_1BYTE_CONNECTION_ID = 1, |
| 197 | PACKET_4BYTE_CONNECTION_ID = 4, |
| 198 | PACKET_8BYTE_CONNECTION_ID = 8 |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 199 | }; |
| 200 | |
| 201 | enum InFecGroup { |
| 202 | NOT_IN_FEC_GROUP, |
| 203 | IN_FEC_GROUP, |
| 204 | }; |
| 205 | |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 206 | enum QuicSequenceNumberLength { |
| 207 | PACKET_1BYTE_SEQUENCE_NUMBER = 1, |
| 208 | PACKET_2BYTE_SEQUENCE_NUMBER = 2, |
| 209 | PACKET_4BYTE_SEQUENCE_NUMBER = 4, |
| 210 | PACKET_6BYTE_SEQUENCE_NUMBER = 6 |
| 211 | }; |
| 212 | |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 213 | // Used to indicate a QuicSequenceNumberLength using two flag bits. |
| 214 | enum QuicSequenceNumberLengthFlags { |
| 215 | PACKET_FLAGS_1BYTE_SEQUENCE = 0, // 00 |
| 216 | PACKET_FLAGS_2BYTE_SEQUENCE = 1, // 01 |
| 217 | PACKET_FLAGS_4BYTE_SEQUENCE = 1 << 1, // 10 |
| 218 | PACKET_FLAGS_6BYTE_SEQUENCE = 1 << 1 | 1, // 11 |
| 219 | }; |
| 220 | |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 221 | // The public flags are specified in one byte. |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 222 | enum QuicPacketPublicFlags { |
| 223 | PACKET_PUBLIC_FLAGS_NONE = 0, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 224 | |
| 225 | // Bit 0: Does the packet header contains version info? |
| 226 | PACKET_PUBLIC_FLAGS_VERSION = 1 << 0, |
| 227 | |
| 228 | // Bit 1: Is this packet a public reset packet? |
| 229 | PACKET_PUBLIC_FLAGS_RST = 1 << 1, |
| 230 | |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 231 | // Bits 2 and 3 specify the length of the ConnectionId as follows: |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 232 | // ----00--: 0 bytes |
| 233 | // ----01--: 1 byte |
| 234 | // ----10--: 4 bytes |
| 235 | // ----11--: 8 bytes |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 236 | PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID = 0, |
| 237 | PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID = 1 << 2, |
| 238 | PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID = 1 << 3, |
| 239 | PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID = 1 << 3 | 1 << 2, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 240 | |
| 241 | // Bits 4 and 5 describe the packet sequence number length as follows: |
| 242 | // --00----: 1 byte |
| 243 | // --01----: 2 bytes |
| 244 | // --10----: 4 bytes |
| 245 | // --11----: 6 bytes |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 246 | PACKET_PUBLIC_FLAGS_1BYTE_SEQUENCE = PACKET_FLAGS_1BYTE_SEQUENCE << 4, |
| 247 | PACKET_PUBLIC_FLAGS_2BYTE_SEQUENCE = PACKET_FLAGS_2BYTE_SEQUENCE << 4, |
| 248 | PACKET_PUBLIC_FLAGS_4BYTE_SEQUENCE = PACKET_FLAGS_4BYTE_SEQUENCE << 4, |
| 249 | PACKET_PUBLIC_FLAGS_6BYTE_SEQUENCE = PACKET_FLAGS_6BYTE_SEQUENCE << 4, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 250 | |
| 251 | // All bits set (bits 6 and 7 are not currently used): 00111111 |
| 252 | PACKET_PUBLIC_FLAGS_MAX = (1 << 6) - 1 |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 253 | }; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 254 | |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 255 | // The private flags are specified in one byte. |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 256 | enum QuicPacketPrivateFlags { |
| 257 | PACKET_PRIVATE_FLAGS_NONE = 0, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 258 | |
| 259 | // Bit 0: Does this packet contain an entropy bit? |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 260 | PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 0, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 261 | |
| 262 | // Bit 1: Payload is part of an FEC group? |
| 263 | PACKET_PRIVATE_FLAGS_FEC_GROUP = 1 << 1, |
| 264 | |
| 265 | // Bit 2: Payload is FEC as opposed to frames? |
| 266 | PACKET_PRIVATE_FLAGS_FEC = 1 << 2, |
| 267 | |
| 268 | // All bits set (bits 3-7 are not currently used): 00000111 |
| 269 | PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1 |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 270 | }; |
| 271 | |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 272 | // The available versions of QUIC. Guaranteed that the integer value of the enum |
| 273 | // will match the version number. |
| 274 | // When adding a new version to this enum you should add it to |
[email protected] | 8bbfaeb7 | 2013-08-09 06:38:26 | [diff] [blame] | 275 | // kSupportedQuicVersions (if appropriate), and also add a new case to the |
| 276 | // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
| 277 | // QuicVersionToString. |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 278 | enum QuicVersion { |
| 279 | // Special case to indicate unknown/unsupported QUIC version. |
| 280 | QUIC_VERSION_UNSUPPORTED = 0, |
| 281 | |
[email protected] | 0c6b10ad | 2014-07-02 19:47:00 | [diff] [blame] | 282 | QUIC_VERSION_16 = 16, // STOP_WAITING frame. |
| 283 | QUIC_VERSION_18 = 18, // PING frame. |
[email protected] | 7afc2ebe | 2014-07-18 16:06:23 | [diff] [blame] | 284 | QUIC_VERSION_19 = 19, // Connection level flow control. |
| 285 | QUIC_VERSION_20 = 20, // Independent stream/connection flow control windows. |
[email protected] | 0c6b10ad | 2014-07-02 19:47:00 | [diff] [blame] | 286 | QUIC_VERSION_21 = 21, // Headers/crypto streams are flow controlled. |
[email protected] | 9693157b | 2014-08-08 11:13:49 | [diff] [blame] | 287 | QUIC_VERSION_22 = 22, // Send Server Config Update messages on crypto stream. |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 288 | }; |
| 289 | |
| 290 | // This vector contains QUIC versions which we currently support. |
| 291 | // This should be ordered such that the highest supported version is the first |
| 292 | // element, with subsequent elements in descending order (versions can be |
| 293 | // skipped as necessary). |
[email protected] | 31ae85484 | 2013-11-27 00:05:46 | [diff] [blame] | 294 | // |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 295 | // IMPORTANT: if you are adding to this list, follow the instructions at |
[email protected] | 31ae85484 | 2013-11-27 00:05:46 | [diff] [blame] | 296 | // http://sites/quic/adding-and-removing-versions |
[email protected] | 9693157b | 2014-08-08 11:13:49 | [diff] [blame] | 297 | static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_22, |
| 298 | QUIC_VERSION_21, |
[email protected] | 0c6b10ad | 2014-07-02 19:47:00 | [diff] [blame] | 299 | QUIC_VERSION_20, |
[email protected] | 7d56135 | 2014-06-20 09:09:21 | [diff] [blame] | 300 | QUIC_VERSION_19, |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 301 | QUIC_VERSION_18, |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 302 | QUIC_VERSION_16}; |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 303 | |
| 304 | typedef std::vector<QuicVersion> QuicVersionVector; |
| 305 | |
[email protected] | b007e63 | 2013-10-28 08:39:25 | [diff] [blame] | 306 | // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| 307 | NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
[email protected] | ea2ab47b | 2013-08-13 00:44:11 | [diff] [blame] | 308 | |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 309 | // QuicTag is written to and read from the wire, but we prefer to use |
| 310 | // the more readable QuicVersion at other levels. |
| 311 | // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
| 312 | // if QuicVersion is unsupported. |
| 313 | NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); |
| 314 | |
| 315 | // Returns appropriate QuicVersion from a QuicTag. |
| 316 | // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. |
| 317 | NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); |
| 318 | |
| 319 | // Helper function which translates from a QuicVersion to a string. |
| 320 | // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6). |
| 321 | NET_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version); |
| 322 | |
| 323 | // Returns comma separated list of string representations of QuicVersion enum |
[email protected] | b007e63 | 2013-10-28 08:39:25 | [diff] [blame] | 324 | // values in the supplied |versions| vector. |
| 325 | NET_EXPORT_PRIVATE std::string QuicVersionVectorToString( |
| 326 | const QuicVersionVector& versions); |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 327 | |
| 328 | // Version and Crypto tags are written to the wire with a big-endian |
| 329 | // representation of the name of the tag. For example |
| 330 | // the client hello tag (CHLO) will be written as the |
| 331 | // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is |
| 332 | // stored in memory as a little endian uint32, we need |
| 333 | // to reverse the order of the bytes. |
| 334 | |
| 335 | // MakeQuicTag returns a value given the four bytes. For example: |
| 336 | // MakeQuicTag('C', 'H', 'L', 'O'); |
| 337 | NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); |
| 338 | |
[email protected] | 9cda5fd | 2014-06-03 10:20:28 | [diff] [blame] | 339 | // Returns true if the tag vector contains the specified tag. |
[email protected] | cc1aa27 | 2014-06-30 19:48:22 | [diff] [blame] | 340 | NET_EXPORT_PRIVATE bool ContainsQuicTag(const QuicTagVector& tag_vector, |
| 341 | QuicTag tag); |
[email protected] | 9cda5fd | 2014-06-03 10:20:28 | [diff] [blame] | 342 | |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 343 | // Size in bytes of the data or fec packet header. |
[email protected] | 79d13dcb | 2014-02-05 07:23:13 | [diff] [blame] | 344 | NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 345 | |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 346 | NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 347 | QuicConnectionIdLength connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 348 | bool include_version, |
| 349 | QuicSequenceNumberLength sequence_number_length, |
| 350 | InFecGroup is_in_fec_group); |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 351 | |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 352 | // Index of the first byte in a QUIC packet of FEC protected data. |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 353 | NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData( |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 354 | QuicConnectionIdLength connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 355 | bool include_version, |
| 356 | QuicSequenceNumberLength sequence_number_length); |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 357 | // Index of the first byte in a QUIC packet of encrypted data. |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 358 | NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData( |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 359 | QuicConnectionIdLength connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 360 | bool include_version, |
| 361 | QuicSequenceNumberLength sequence_number_length); |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 362 | |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 363 | enum QuicRstStreamErrorCode { |
| 364 | QUIC_STREAM_NO_ERROR = 0, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 365 | |
[email protected] | 24e5bc5 | 2013-09-18 15:36:58 | [diff] [blame] | 366 | // There was some error which halted stream processing. |
| 367 | QUIC_ERROR_PROCESSING_STREAM, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 368 | // We got two fin or reset offsets which did not match. |
| 369 | QUIC_MULTIPLE_TERMINATION_OFFSETS, |
| 370 | // We got bad payload and can not respond to it at the protocol level. |
| 371 | QUIC_BAD_APPLICATION_PAYLOAD, |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 372 | // Stream closed due to connection error. No reset frame is sent when this |
| 373 | // happens. |
| 374 | QUIC_STREAM_CONNECTION_ERROR, |
| 375 | // GoAway frame sent. No more stream can be created. |
| 376 | QUIC_STREAM_PEER_GOING_AWAY, |
[email protected] | 06ff515 | 2013-08-29 01:03:05 | [diff] [blame] | 377 | // The stream has been cancelled. |
| 378 | QUIC_STREAM_CANCELLED, |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 379 | // Sending a RST to allow for proper flow control accounting. |
| 380 | QUIC_RST_FLOW_CONTROL_ACCOUNTING, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 381 | |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 382 | // No error. Used as bound while iterating. |
| 383 | QUIC_STREAM_LAST_ERROR, |
| 384 | }; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 385 | |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 386 | // Because receiving an unknown QuicRstStreamErrorCode results in connection |
| 387 | // teardown, we use this to make sure any errors predating a given version are |
| 388 | // downgraded to the most appropriate existing error. |
| 389 | NET_EXPORT_PRIVATE QuicRstStreamErrorCode AdjustErrorForVersion( |
| 390 | QuicRstStreamErrorCode error_code, |
| 391 | QuicVersion version); |
| 392 | |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 393 | // These values must remain stable as they are uploaded to UMA histograms. |
| 394 | // To add a new error code, use the current value of QUIC_LAST_ERROR and |
| 395 | // increment QUIC_LAST_ERROR. |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 396 | enum QuicErrorCode { |
| 397 | QUIC_NO_ERROR = 0, |
| 398 | |
| 399 | // Connection has reached an invalid state. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 400 | QUIC_INTERNAL_ERROR = 1, |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 401 | // There were data frames after the a fin or reset. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 402 | QUIC_STREAM_DATA_AFTER_TERMINATION = 2, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 403 | // Control frame is malformed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 404 | QUIC_INVALID_PACKET_HEADER = 3, |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 405 | // Frame data is malformed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 406 | QUIC_INVALID_FRAME_DATA = 4, |
| 407 | // The packet contained no payload. |
| 408 | QUIC_MISSING_PAYLOAD = 48, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 409 | // FEC data is malformed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 410 | QUIC_INVALID_FEC_DATA = 5, |
| 411 | // STREAM frame data is malformed. |
| 412 | QUIC_INVALID_STREAM_DATA = 46, |
[email protected] | 42a3eba | 2014-04-30 10:52:55 | [diff] [blame] | 413 | // STREAM frame data is not encrypted. |
| 414 | QUIC_UNENCRYPTED_STREAM_DATA = 61, |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 415 | // RST_STREAM frame data is malformed. |
| 416 | QUIC_INVALID_RST_STREAM_DATA = 6, |
| 417 | // CONNECTION_CLOSE frame data is malformed. |
| 418 | QUIC_INVALID_CONNECTION_CLOSE_DATA = 7, |
| 419 | // GOAWAY frame data is malformed. |
| 420 | QUIC_INVALID_GOAWAY_DATA = 8, |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 421 | // WINDOW_UPDATE frame data is malformed. |
| 422 | QUIC_INVALID_WINDOW_UPDATE_DATA = 57, |
| 423 | // BLOCKED frame data is malformed. |
| 424 | QUIC_INVALID_BLOCKED_DATA = 58, |
[email protected] | 93dd91f | 2014-02-27 00:09:03 | [diff] [blame] | 425 | // STOP_WAITING frame data is malformed. |
| 426 | QUIC_INVALID_STOP_WAITING_DATA = 60, |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 427 | // ACK frame data is malformed. |
| 428 | QUIC_INVALID_ACK_DATA = 9, |
| 429 | // CONGESTION_FEEDBACK frame data is malformed. |
| 430 | QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47, |
[email protected] | 14e8106c | 2013-03-14 16:25:33 | [diff] [blame] | 431 | // Version negotiation packet is malformed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 432 | QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10, |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 433 | // Public RST packet is malformed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 434 | QUIC_INVALID_PUBLIC_RST_PACKET = 11, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 435 | // There was an error decrypting. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 436 | QUIC_DECRYPTION_FAILURE = 12, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 437 | // There was an error encrypting. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 438 | QUIC_ENCRYPTION_FAILURE = 13, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 439 | // The packet exceeded kMaxPacketSize. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 440 | QUIC_PACKET_TOO_LARGE = 14, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 441 | // Data was sent for a stream which did not exist. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 442 | QUIC_PACKET_FOR_NONEXISTENT_STREAM = 15, |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 443 | // The peer is going away. May be a client or server. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 444 | QUIC_PEER_GOING_AWAY = 16, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 445 | // A stream ID was invalid. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 446 | QUIC_INVALID_STREAM_ID = 17, |
[email protected] | 24e5bc5 | 2013-09-18 15:36:58 | [diff] [blame] | 447 | // A priority was invalid. |
| 448 | QUIC_INVALID_PRIORITY = 49, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 449 | // Too many streams already open. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 450 | QUIC_TOO_MANY_OPEN_STREAMS = 18, |
[email protected] | 9693157b | 2014-08-08 11:13:49 | [diff] [blame] | 451 | // The peer must send a FIN/RST for each stream, and has not been doing so. |
| 452 | QUIC_TOO_MANY_UNFINISHED_STREAMS = 66, |
[email protected] | 86a318d | 2013-01-23 21:16:04 | [diff] [blame] | 453 | // Received public reset for this connection. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 454 | QUIC_PUBLIC_RESET = 19, |
[email protected] | c244c5a1 | 2013-05-07 20:55:04 | [diff] [blame] | 455 | // Invalid protocol version. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 456 | QUIC_INVALID_VERSION = 20, |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 457 | |
| 458 | // deprecated: QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED = 21 |
| 459 | |
[email protected] | c244c5a1 | 2013-05-07 20:55:04 | [diff] [blame] | 460 | // The Header ID for a stream was too far from the previous. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 461 | QUIC_INVALID_HEADER_ID = 22, |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 462 | // Negotiable parameter received during handshake had invalid value. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 463 | QUIC_INVALID_NEGOTIATED_VALUE = 23, |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 464 | // There was an error decompressing data. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 465 | QUIC_DECOMPRESSION_FAILURE = 24, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 466 | // We hit our prenegotiated (or default) timeout |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 467 | QUIC_CONNECTION_TIMED_OUT = 25, |
[email protected] | 89995165 | 2013-05-16 12:52:39 | [diff] [blame] | 468 | // There was an error encountered migrating addresses |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 469 | QUIC_ERROR_MIGRATING_ADDRESS = 26, |
[email protected] | 1505a51 | 2013-09-04 22:59:35 | [diff] [blame] | 470 | // There was an error while writing to the socket. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 471 | QUIC_PACKET_WRITE_ERROR = 27, |
[email protected] | 1505a51 | 2013-09-04 22:59:35 | [diff] [blame] | 472 | // There was an error while reading from the socket. |
| 473 | QUIC_PACKET_READ_ERROR = 51, |
[email protected] | 24e5bc5 | 2013-09-18 15:36:58 | [diff] [blame] | 474 | // We received a STREAM_FRAME with no data and no fin flag set. |
| 475 | QUIC_INVALID_STREAM_FRAME = 50, |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 476 | // We received invalid data on the headers stream. |
| 477 | QUIC_INVALID_HEADERS_STREAM_DATA = 56, |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 478 | // The peer received too much data, violating flow control. |
| 479 | QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA = 59, |
| 480 | // The peer sent too much data, violating flow control. |
| 481 | QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63, |
| 482 | // The peer received an invalid flow control window. |
| 483 | QUIC_FLOW_CONTROL_INVALID_WINDOW = 64, |
[email protected] | 71c84e59 | 2014-05-28 23:39:29 | [diff] [blame] | 484 | // The connection has been IP pooled into an existing connection. |
| 485 | QUIC_CONNECTION_IP_POOLED = 62, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 486 | |
| 487 | // Crypto errors. |
| 488 | |
[email protected] | 1354bf6 | 2013-05-23 23:17:18 | [diff] [blame] | 489 | // Hanshake failed. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 490 | QUIC_HANDSHAKE_FAILED = 28, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 491 | // Handshake message contained out of order tags. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 492 | QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29, |
[email protected] | 701bc89 | 2013-01-17 04:51:54 | [diff] [blame] | 493 | // Handshake message contained too many entries. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 494 | QUIC_CRYPTO_TOO_MANY_ENTRIES = 30, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 495 | // Handshake message contained an invalid value length. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 496 | QUIC_CRYPTO_INVALID_VALUE_LENGTH = 31, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 497 | // A crypto message was received after the handshake was complete. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 498 | QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE = 32, |
[email protected] | d3d15bf | 2013-01-30 02:51:54 | [diff] [blame] | 499 | // A crypto message was received with an illegal message tag. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 500 | QUIC_INVALID_CRYPTO_MESSAGE_TYPE = 33, |
[email protected] | d3d15bf | 2013-01-30 02:51:54 | [diff] [blame] | 501 | // A crypto message was received with an illegal parameter. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 502 | QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER = 34, |
[email protected] | 752fbe5 | 2013-10-14 08:35:32 | [diff] [blame] | 503 | // An invalid channel id signature was supplied. |
| 504 | QUIC_INVALID_CHANNEL_ID_SIGNATURE = 52, |
[email protected] | d3d15bf | 2013-01-30 02:51:54 | [diff] [blame] | 505 | // A crypto message was received with a mandatory parameter missing. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 506 | QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND = 35, |
[email protected] | d3d15bf | 2013-01-30 02:51:54 | [diff] [blame] | 507 | // A crypto message was received with a parameter that has no overlap |
| 508 | // with the local parameter. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 509 | QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP = 36, |
[email protected] | ed3fc15d | 2013-03-08 18:37:44 | [diff] [blame] | 510 | // A crypto message was received that contained a parameter with too few |
| 511 | // values. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 512 | QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND = 37, |
[email protected] | ccc66e8a | 2013-03-26 08:26:14 | [diff] [blame] | 513 | // An internal error occured in crypto processing. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 514 | QUIC_CRYPTO_INTERNAL_ERROR = 38, |
[email protected] | ccc66e8a | 2013-03-26 08:26:14 | [diff] [blame] | 515 | // A crypto handshake message specified an unsupported version. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 516 | QUIC_CRYPTO_VERSION_NOT_SUPPORTED = 39, |
[email protected] | ccc66e8a | 2013-03-26 08:26:14 | [diff] [blame] | 517 | // There was no intersection between the crypto primitives supported by the |
| 518 | // peer and ourselves. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 519 | QUIC_CRYPTO_NO_SUPPORT = 40, |
[email protected] | ef95114d | 2013-04-17 17:57:01 | [diff] [blame] | 520 | // The server rejected our client hello messages too many times. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 521 | QUIC_CRYPTO_TOO_MANY_REJECTS = 41, |
[email protected] | a57e027 | 2013-04-26 07:31:47 | [diff] [blame] | 522 | // The client rejected the server's certificate chain or signature. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 523 | QUIC_PROOF_INVALID = 42, |
[email protected] | 8ba8121 | 2013-05-03 13:11:48 | [diff] [blame] | 524 | // A crypto message was received with a duplicate tag. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 525 | QUIC_CRYPTO_DUPLICATE_TAG = 43, |
[email protected] | 2532de1 | 2013-05-09 12:29:33 | [diff] [blame] | 526 | // A crypto message was received with the wrong encryption level (i.e. it |
| 527 | // should have been encrypted but was not.) |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 528 | QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT = 44, |
[email protected] | 2532de1 | 2013-05-09 12:29:33 | [diff] [blame] | 529 | // The server config for a server has expired. |
[email protected] | 8926404 | 2013-08-21 07:35:24 | [diff] [blame] | 530 | QUIC_CRYPTO_SERVER_CONFIG_EXPIRED = 45, |
[email protected] | 752fbe5 | 2013-10-14 08:35:32 | [diff] [blame] | 531 | // We failed to setup the symmetric keys for a connection. |
| 532 | QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53, |
[email protected] | 691f45a98 | 2013-11-19 10:52:04 | [diff] [blame] | 533 | // A handshake message arrived, but we are still validating the |
| 534 | // previous handshake message. |
| 535 | QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54, |
[email protected] | ccb3421 | 2014-07-18 09:27:50 | [diff] [blame] | 536 | // A server config update arrived before the handshake is complete. |
| 537 | QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65, |
[email protected] | d89f186 | 2013-11-26 21:21:27 | [diff] [blame] | 538 | // This connection involved a version negotiation which appears to have been |
| 539 | // tampered with. |
| 540 | QUIC_VERSION_NEGOTIATION_MISMATCH = 55, |
[email protected] | ccc66e8a | 2013-03-26 08:26:14 | [diff] [blame] | 541 | |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 542 | // No error. Used as bound while iterating. |
[email protected] | 9693157b | 2014-08-08 11:13:49 | [diff] [blame] | 543 | QUIC_LAST_ERROR = 67, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 544 | }; |
| 545 | |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 546 | struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { |
[email protected] | 14e8106c | 2013-03-14 16:25:33 | [diff] [blame] | 547 | QuicPacketPublicHeader(); |
| 548 | explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other); |
| 549 | ~QuicPacketPublicHeader(); |
| 550 | |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 551 | // Universal header. All QuicPacket headers will have a connection_id and |
| 552 | // public flags. |
| 553 | QuicConnectionId connection_id; |
| 554 | QuicConnectionIdLength connection_id_length; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 555 | bool reset_flag; |
| 556 | bool version_flag; |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 557 | QuicSequenceNumberLength sequence_number_length; |
[email protected] | 4887809 | 2013-07-26 14:51:56 | [diff] [blame] | 558 | QuicVersionVector versions; |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 559 | }; |
| 560 | |
| 561 | // Header for Data or FEC packets. |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 562 | struct NET_EXPORT_PRIVATE QuicPacketHeader { |
| 563 | QuicPacketHeader(); |
| 564 | explicit QuicPacketHeader(const QuicPacketPublicHeader& header); |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 565 | |
| 566 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 567 | std::ostream& os, const QuicPacketHeader& s); |
| 568 | |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 569 | QuicPacketPublicHeader public_header; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 570 | bool fec_flag; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 571 | bool entropy_flag; |
| 572 | QuicPacketEntropyHash entropy_hash; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 573 | QuicPacketSequenceNumber packet_sequence_number; |
[email protected] | b06431078 | 2013-05-30 21:12:17 | [diff] [blame] | 574 | InFecGroup is_in_fec_group; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 575 | QuicFecGroupNumber fec_group; |
| 576 | }; |
| 577 | |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 578 | struct NET_EXPORT_PRIVATE QuicPublicResetPacket { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 579 | QuicPublicResetPacket(); |
| 580 | explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header); |
| 581 | |
[email protected] | 86a318d | 2013-01-23 21:16:04 | [diff] [blame] | 582 | QuicPacketPublicHeader public_header; |
[email protected] | 86a318d | 2013-01-23 21:16:04 | [diff] [blame] | 583 | QuicPublicResetNonceProof nonce_proof; |
[email protected] | 300ccd5 | 2014-01-25 08:00:19 | [diff] [blame] | 584 | QuicPacketSequenceNumber rejected_sequence_number; |
[email protected] | 79d13dcb | 2014-02-05 07:23:13 | [diff] [blame] | 585 | IPEndPoint client_address; |
[email protected] | 86a318d | 2013-01-23 21:16:04 | [diff] [blame] | 586 | }; |
| 587 | |
[email protected] | 14e8106c | 2013-03-14 16:25:33 | [diff] [blame] | 588 | enum QuicVersionNegotiationState { |
| 589 | START_NEGOTIATION = 0, |
[email protected] | ec64011 | 2013-08-09 03:56:18 | [diff] [blame] | 590 | // Server-side this implies we've sent a version negotiation packet and are |
| 591 | // waiting on the client to select a compatible version. Client-side this |
| 592 | // implies we've gotten a version negotiation packet, are retransmitting the |
| 593 | // initial packets with a supported version and are waiting for our first |
| 594 | // packet from the server. |
| 595 | NEGOTIATION_IN_PROGRESS, |
| 596 | // This indicates this endpoint has received a packet from the peer with a |
| 597 | // version this endpoint supports. Version negotiation is complete, and the |
| 598 | // version number will no longer be sent with future packets. |
[email protected] | 14e8106c | 2013-03-14 16:25:33 | [diff] [blame] | 599 | NEGOTIATED_VERSION |
| 600 | }; |
| 601 | |
| 602 | typedef QuicPacketPublicHeader QuicVersionNegotiationPacket; |
| 603 | |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 604 | // A padding frame contains no payload. |
| 605 | struct NET_EXPORT_PRIVATE QuicPaddingFrame { |
| 606 | }; |
| 607 | |
[email protected] | d8c52211 | 2014-04-23 09:23:25 | [diff] [blame] | 608 | // A ping frame contains no payload, though it is retransmittable, |
| 609 | // and ACK'd just like other normal frames. |
| 610 | struct NET_EXPORT_PRIVATE QuicPingFrame { |
| 611 | }; |
| 612 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 613 | struct NET_EXPORT_PRIVATE QuicStreamFrame { |
| 614 | QuicStreamFrame(); |
[email protected] | 5dafdb6 | 2013-11-14 01:24:26 | [diff] [blame] | 615 | QuicStreamFrame(const QuicStreamFrame& frame); |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 616 | QuicStreamFrame(QuicStreamId stream_id, |
[email protected] | a506124 | 2012-10-23 23:29:37 | [diff] [blame] | 617 | bool fin, |
[email protected] | 701bc89 | 2013-01-17 04:51:54 | [diff] [blame] | 618 | QuicStreamOffset offset, |
[email protected] | 5dafdb6 | 2013-11-14 01:24:26 | [diff] [blame] | 619 | IOVector data); |
| 620 | |
[email protected] | c5e1aca | 2014-01-30 04:03:04 | [diff] [blame] | 621 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 622 | std::ostream& os, const QuicStreamFrame& s); |
| 623 | |
[email protected] | 5dafdb6 | 2013-11-14 01:24:26 | [diff] [blame] | 624 | // Returns a copy of the IOVector |data| as a heap-allocated string. |
| 625 | // Caller must take ownership of the returned string. |
| 626 | std::string* GetDataAsString() const; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 627 | |
| 628 | QuicStreamId stream_id; |
| 629 | bool fin; |
[email protected] | 701bc89 | 2013-01-17 04:51:54 | [diff] [blame] | 630 | QuicStreamOffset offset; // Location of this data in the stream. |
[email protected] | 5dafdb6 | 2013-11-14 01:24:26 | [diff] [blame] | 631 | IOVector data; |
[email protected] | 97cf302 | 2013-09-05 14:30:16 | [diff] [blame] | 632 | |
| 633 | // If this is set, then when this packet is ACKed the AckNotifier will be |
| 634 | // informed. |
| 635 | QuicAckNotifier* notifier; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 636 | }; |
| 637 | |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 638 | // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing |
| 639 | // is finalized. |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 640 | typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet; |
[email protected] | 3c5f4a73 | 2013-01-12 16:45:34 | [diff] [blame] | 641 | // TODO(pwestin): Add a way to enforce the max size of this map. |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 642 | typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap; |
[email protected] | 044ac2b | 2012-11-13 21:41:06 | [diff] [blame] | 643 | |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 644 | struct NET_EXPORT_PRIVATE QuicStopWaitingFrame { |
| 645 | QuicStopWaitingFrame(); |
| 646 | ~QuicStopWaitingFrame(); |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 647 | |
[email protected] | 26f3f8e | 2012-12-13 21:07:19 | [diff] [blame] | 648 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 649 | std::ostream& os, const QuicStopWaitingFrame& s); |
| 650 | // Entropy hash of all packets up to, but not including, the least unacked |
| 651 | // packet. |
| 652 | QuicPacketEntropyHash entropy_hash; |
| 653 | // The lowest packet we've sent which is unacked, and we expect an ack for. |
| 654 | QuicPacketSequenceNumber least_unacked; |
| 655 | }; |
| 656 | |
| 657 | struct NET_EXPORT_PRIVATE QuicAckFrame { |
| 658 | QuicAckFrame(); |
| 659 | ~QuicAckFrame(); |
| 660 | |
| 661 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 662 | std::ostream& os, const QuicAckFrame& s); |
[email protected] | a674b4c | 2012-12-05 03:44:30 | [diff] [blame] | 663 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 664 | // Entropy hash of all packets up to largest observed not including missing |
| 665 | // packets. |
| 666 | QuicPacketEntropyHash entropy_hash; |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 667 | |
[email protected] | 48697d8a | 2013-01-15 19:42:24 | [diff] [blame] | 668 | // The highest packet sequence number we've observed from the peer. |
| 669 | // |
| 670 | // In general, this should be the largest packet number we've received. In |
| 671 | // the case of truncated acks, we may have to advertise a lower "upper bound" |
| 672 | // than largest received, to avoid implicitly acking missing packets that |
| 673 | // don't fit in the missing packet list due to size limitations. In this |
| 674 | // case, largest_observed may be a packet which is also in the missing packets |
| 675 | // list. |
| 676 | QuicPacketSequenceNumber largest_observed; |
[email protected] | a674b4c | 2012-12-05 03:44:30 | [diff] [blame] | 677 | |
[email protected] | 14e8106c | 2013-03-14 16:25:33 | [diff] [blame] | 678 | // Time elapsed since largest_observed was received until this Ack frame was |
| 679 | // sent. |
| 680 | QuicTime::Delta delta_time_largest_observed; |
| 681 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 682 | // TODO(satyamshekhar): Can be optimized using an interval set like data |
| 683 | // structure. |
[email protected] | e537f74 | 2012-12-07 15:33:53 | [diff] [blame] | 684 | // The set of packets which we're expecting and have not received. |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 685 | SequenceNumberSet missing_packets; |
[email protected] | 8e01c06 | 2013-10-31 07:35:31 | [diff] [blame] | 686 | |
| 687 | // Whether the ack had to be truncated when sent. |
| 688 | bool is_truncated; |
[email protected] | bdf2d43 | 2014-02-09 10:45:41 | [diff] [blame] | 689 | |
| 690 | // Packets which have been revived via FEC. |
| 691 | // All of these must also be in missing_packets. |
| 692 | SequenceNumberSet revived_packets; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 693 | }; |
| 694 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 695 | // True if the sequence number is greater than largest_observed or is listed |
| 696 | // as missing. |
| 697 | // Always returns false for sequence numbers less than least_unacked. |
| 698 | bool NET_EXPORT_PRIVATE IsAwaitingPacket( |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 699 | const QuicAckFrame& ack_frame, |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 700 | QuicPacketSequenceNumber sequence_number); |
| 701 | |
| 702 | // Inserts missing packets between [lower, higher). |
| 703 | void NET_EXPORT_PRIVATE InsertMissingPacketsBetween( |
[email protected] | 310d37b | 2014-08-02 06:15:37 | [diff] [blame] | 704 | QuicAckFrame* ack_frame, |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 705 | QuicPacketSequenceNumber lower, |
| 706 | QuicPacketSequenceNumber higher); |
| 707 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 708 | // Defines for all types of congestion feedback that will be negotiated in QUIC, |
[email protected] | f62262b | 2013-07-05 20:57:30 | [diff] [blame] | 709 | // kTCP MUST be supported by all QUIC implementations to guarantee 100% |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 710 | // compatibility. |
| 711 | enum CongestionFeedbackType { |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 712 | kTCP, // Used to mimic TCP. |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 713 | kTimestamp, // Use additional inter arrival timestamp information. |
[email protected] | a692ad9d | 2014-07-18 21:35:24 | [diff] [blame] | 714 | }; |
| 715 | |
| 716 | // Defines for all types of congestion control algorithms that can be used in |
| 717 | // QUIC. Note that this is separate from the congestion feedback type - |
| 718 | // some congestion control algorithms may use the same feedback type |
| 719 | // (Reno and Cubic are the classic example for that). |
| 720 | enum CongestionControlType { |
| 721 | kCubic, |
| 722 | kReno, |
[email protected] | a692ad9d | 2014-07-18 21:35:24 | [diff] [blame] | 723 | kBBR, |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 724 | }; |
| 725 | |
[email protected] | c5cc9bd | 2014-03-31 23:17:14 | [diff] [blame] | 726 | enum LossDetectionType { |
| 727 | kNack, // Used to mimic TCP's loss detection. |
| 728 | kTime, // Time based loss detection. |
| 729 | }; |
| 730 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 731 | struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTCP { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 732 | CongestionFeedbackMessageTCP(); |
| 733 | |
[email protected] | fee17f7 | 2013-02-03 07:47:41 | [diff] [blame] | 734 | QuicByteCount receive_window; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 735 | }; |
| 736 | |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 737 | struct NET_EXPORT_PRIVATE CongestionFeedbackMessageTimestamp { |
| 738 | CongestionFeedbackMessageTimestamp(); |
| 739 | ~CongestionFeedbackMessageTimestamp(); |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 740 | |
[email protected] | 7884ecad | 2012-12-14 22:55:15 | [diff] [blame] | 741 | // The set of received packets since the last feedback was sent, along with |
| 742 | // their arrival times. |
| 743 | TimeMap received_packet_times; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 744 | }; |
| 745 | |
[email protected] | 26f3f8e | 2012-12-13 21:07:19 | [diff] [blame] | 746 | struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame { |
[email protected] | 7884ecad | 2012-12-14 22:55:15 | [diff] [blame] | 747 | QuicCongestionFeedbackFrame(); |
| 748 | ~QuicCongestionFeedbackFrame(); |
| 749 | |
[email protected] | 26f3f8e | 2012-12-13 21:07:19 | [diff] [blame] | 750 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 751 | std::ostream& os, const QuicCongestionFeedbackFrame& c); |
| 752 | |
[email protected] | 7884ecad | 2012-12-14 22:55:15 | [diff] [blame] | 753 | CongestionFeedbackType type; |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 754 | // This should really be a union, but since the timestamp struct |
[email protected] | 7884ecad | 2012-12-14 22:55:15 | [diff] [blame] | 755 | // is non-trivial, C++ prohibits it. |
| 756 | CongestionFeedbackMessageTCP tcp; |
[email protected] | a97b318 | 2014-08-08 08:10:18 | [diff] [blame] | 757 | CongestionFeedbackMessageTimestamp timestamp; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 758 | }; |
| 759 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 760 | struct NET_EXPORT_PRIVATE QuicRstStreamFrame { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 761 | QuicRstStreamFrame(); |
| 762 | QuicRstStreamFrame(QuicStreamId stream_id, |
| 763 | QuicRstStreamErrorCode error_code, |
| 764 | QuicStreamOffset bytes_written); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 765 | |
[email protected] | c5e1aca | 2014-01-30 04:03:04 | [diff] [blame] | 766 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 767 | std::ostream& os, const QuicRstStreamFrame& r); |
| 768 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 769 | QuicStreamId stream_id; |
[email protected] | 74bda14 | 2013-03-31 02:49:11 | [diff] [blame] | 770 | QuicRstStreamErrorCode error_code; |
[email protected] | 431bb4fd | 2012-10-19 17:46:09 | [diff] [blame] | 771 | std::string error_details; |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 772 | |
| 773 | // Used to update flow control windows. On termination of a stream, both |
| 774 | // endpoints must inform the peer of the number of bytes they have sent on |
| 775 | // that stream. This can be done through normal termination (data packet with |
| 776 | // FIN) or through a RST. |
| 777 | QuicStreamOffset byte_offset; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 778 | }; |
| 779 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 780 | struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 781 | QuicConnectionCloseFrame(); |
| 782 | |
[email protected] | c5e1aca | 2014-01-30 04:03:04 | [diff] [blame] | 783 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 784 | std::ostream& os, const QuicConnectionCloseFrame& c); |
| 785 | |
[email protected] | 431bb4fd | 2012-10-19 17:46:09 | [diff] [blame] | 786 | QuicErrorCode error_code; |
[email protected] | 431bb4fd | 2012-10-19 17:46:09 | [diff] [blame] | 787 | std::string error_details; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 788 | }; |
| 789 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 790 | struct NET_EXPORT_PRIVATE QuicGoAwayFrame { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 791 | QuicGoAwayFrame(); |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 792 | QuicGoAwayFrame(QuicErrorCode error_code, |
| 793 | QuicStreamId last_good_stream_id, |
| 794 | const std::string& reason); |
| 795 | |
[email protected] | c5e1aca | 2014-01-30 04:03:04 | [diff] [blame] | 796 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 797 | std::ostream& os, const QuicGoAwayFrame& g); |
| 798 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 799 | QuicErrorCode error_code; |
| 800 | QuicStreamId last_good_stream_id; |
| 801 | std::string reason_phrase; |
| 802 | }; |
| 803 | |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 804 | // Flow control updates per-stream and at the connection levoel. |
| 805 | // Based on SPDY's WINDOW_UPDATE frame, but uses an absolute byte offset rather |
| 806 | // than a window delta. |
| 807 | // TODO(rjshade): A possible future optimization is to make stream_id and |
| 808 | // byte_offset variable length, similar to stream frames. |
| 809 | struct NET_EXPORT_PRIVATE QuicWindowUpdateFrame { |
| 810 | QuicWindowUpdateFrame() {} |
| 811 | QuicWindowUpdateFrame(QuicStreamId stream_id, QuicStreamOffset byte_offset); |
| 812 | |
| 813 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 814 | std::ostream& os, const QuicWindowUpdateFrame& w); |
| 815 | |
| 816 | // The stream this frame applies to. 0 is a special case meaning the overall |
| 817 | // connection rather than a specific stream. |
| 818 | QuicStreamId stream_id; |
| 819 | |
| 820 | // Byte offset in the stream or connection. The receiver of this frame must |
| 821 | // not send data which would result in this offset being exceeded. |
| 822 | QuicStreamOffset byte_offset; |
| 823 | }; |
| 824 | |
| 825 | // The BLOCKED frame is used to indicate to the remote endpoint that this |
| 826 | // endpoint believes itself to be flow-control blocked but otherwise ready to |
| 827 | // send data. The BLOCKED frame is purely advisory and optional. |
| 828 | // Based on SPDY's BLOCKED frame (undocumented as of 2014-01-28). |
| 829 | struct NET_EXPORT_PRIVATE QuicBlockedFrame { |
| 830 | QuicBlockedFrame() {} |
| 831 | explicit QuicBlockedFrame(QuicStreamId stream_id); |
| 832 | |
| 833 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 834 | std::ostream& os, const QuicBlockedFrame& b); |
| 835 | |
| 836 | // The stream this frame applies to. 0 is a special case meaning the overall |
| 837 | // connection rather than a specific stream. |
| 838 | QuicStreamId stream_id; |
| 839 | }; |
| 840 | |
[email protected] | 8ba8121 | 2013-05-03 13:11:48 | [diff] [blame] | 841 | // EncryptionLevel enumerates the stages of encryption that a QUIC connection |
| 842 | // progresses through. When retransmitting a packet, the encryption level needs |
| 843 | // to be specified so that it is retransmitted at a level which the peer can |
| 844 | // understand. |
| 845 | enum EncryptionLevel { |
| 846 | ENCRYPTION_NONE = 0, |
| 847 | ENCRYPTION_INITIAL = 1, |
| 848 | ENCRYPTION_FORWARD_SECURE = 2, |
| 849 | |
| 850 | NUM_ENCRYPTION_LEVELS, |
| 851 | }; |
| 852 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 853 | struct NET_EXPORT_PRIVATE QuicFrame { |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 854 | QuicFrame(); |
| 855 | explicit QuicFrame(QuicPaddingFrame* padding_frame); |
| 856 | explicit QuicFrame(QuicStreamFrame* stream_frame); |
| 857 | explicit QuicFrame(QuicAckFrame* frame); |
| 858 | explicit QuicFrame(QuicCongestionFeedbackFrame* frame); |
| 859 | explicit QuicFrame(QuicRstStreamFrame* frame); |
| 860 | explicit QuicFrame(QuicConnectionCloseFrame* frame); |
[email protected] | 93dd91f | 2014-02-27 00:09:03 | [diff] [blame] | 861 | explicit QuicFrame(QuicStopWaitingFrame* frame); |
[email protected] | d8c52211 | 2014-04-23 09:23:25 | [diff] [blame] | 862 | explicit QuicFrame(QuicPingFrame* frame); |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 863 | explicit QuicFrame(QuicGoAwayFrame* frame); |
| 864 | explicit QuicFrame(QuicWindowUpdateFrame* frame); |
| 865 | explicit QuicFrame(QuicBlockedFrame* frame); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 866 | |
[email protected] | c5e1aca | 2014-01-30 04:03:04 | [diff] [blame] | 867 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 868 | std::ostream& os, const QuicFrame& frame); |
| 869 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 870 | QuicFrameType type; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 871 | union { |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 872 | QuicPaddingFrame* padding_frame; |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 873 | QuicStreamFrame* stream_frame; |
| 874 | QuicAckFrame* ack_frame; |
[email protected] | 26f3f8e | 2012-12-13 21:07:19 | [diff] [blame] | 875 | QuicCongestionFeedbackFrame* congestion_feedback_frame; |
[email protected] | 93dd91f | 2014-02-27 00:09:03 | [diff] [blame] | 876 | QuicStopWaitingFrame* stop_waiting_frame; |
[email protected] | d8c52211 | 2014-04-23 09:23:25 | [diff] [blame] | 877 | QuicPingFrame* ping_frame; |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 878 | QuicRstStreamFrame* rst_stream_frame; |
| 879 | QuicConnectionCloseFrame* connection_close_frame; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 880 | QuicGoAwayFrame* goaway_frame; |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 881 | QuicWindowUpdateFrame* window_update_frame; |
| 882 | QuicBlockedFrame* blocked_frame; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 883 | }; |
| 884 | }; |
| 885 | |
[email protected] | be24ab2 | 2012-10-22 03:01:52 | [diff] [blame] | 886 | typedef std::vector<QuicFrame> QuicFrames; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 887 | |
| 888 | struct NET_EXPORT_PRIVATE QuicFecData { |
| 889 | QuicFecData(); |
[email protected] | a506124 | 2012-10-23 23:29:37 | [diff] [blame] | 890 | |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 891 | // The FEC group number is also the sequence number of the first |
| 892 | // FEC protected packet. The last protected packet's sequence number will |
| 893 | // be one less than the sequence number of the FEC packet. |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 894 | QuicFecGroupNumber fec_group; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 895 | base::StringPiece redundancy; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 896 | }; |
| 897 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 898 | class NET_EXPORT_PRIVATE QuicData { |
| 899 | public: |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 900 | QuicData(const char* buffer, size_t length); |
| 901 | QuicData(char* buffer, size_t length, bool owns_buffer); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 902 | virtual ~QuicData(); |
| 903 | |
| 904 | base::StringPiece AsStringPiece() const { |
| 905 | return base::StringPiece(data(), length()); |
| 906 | } |
| 907 | |
| 908 | const char* data() const { return buffer_; } |
| 909 | size_t length() const { return length_; } |
| 910 | |
| 911 | private: |
| 912 | const char* buffer_; |
| 913 | size_t length_; |
| 914 | bool owns_buffer_; |
| 915 | |
| 916 | DISALLOW_COPY_AND_ASSIGN(QuicData); |
| 917 | }; |
| 918 | |
| 919 | class NET_EXPORT_PRIVATE QuicPacket : public QuicData { |
| 920 | public: |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 921 | static QuicPacket* NewDataPacket( |
| 922 | char* buffer, |
| 923 | size_t length, |
| 924 | bool owns_buffer, |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 925 | QuicConnectionIdLength connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 926 | bool includes_version, |
| 927 | QuicSequenceNumberLength sequence_number_length) { |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 928 | return new QuicPacket(buffer, length, owns_buffer, connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 929 | includes_version, sequence_number_length, false); |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 930 | } |
| 931 | |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 932 | static QuicPacket* NewFecPacket( |
| 933 | char* buffer, |
| 934 | size_t length, |
| 935 | bool owns_buffer, |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 936 | QuicConnectionIdLength connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 937 | bool includes_version, |
| 938 | QuicSequenceNumberLength sequence_number_length) { |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 939 | return new QuicPacket(buffer, length, owns_buffer, connection_id_length, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 940 | includes_version, sequence_number_length, true); |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 941 | } |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 942 | |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 943 | base::StringPiece FecProtectedData() const; |
| 944 | base::StringPiece AssociatedData() const; |
| 945 | base::StringPiece BeforePlaintext() const; |
| 946 | base::StringPiece Plaintext() const; |
[email protected] | 082b65b | 2012-11-10 19:11:31 | [diff] [blame] | 947 | |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 948 | bool is_fec_packet() const { return is_fec_packet_; } |
[email protected] | 082b65b | 2012-11-10 19:11:31 | [diff] [blame] | 949 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 950 | char* mutable_data() { return buffer_; } |
| 951 | |
| 952 | private: |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 953 | QuicPacket(char* buffer, |
| 954 | size_t length, |
| 955 | bool owns_buffer, |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 956 | QuicConnectionIdLength connection_id_length, |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 957 | bool includes_version, |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 958 | QuicSequenceNumberLength sequence_number_length, |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 959 | bool is_fec_packet); |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 960 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 961 | char* buffer_; |
[email protected] | c995c57 | 2013-01-18 05:43:20 | [diff] [blame] | 962 | const bool is_fec_packet_; |
[email protected] | 3aa9ca7 | 2014-02-27 19:39:43 | [diff] [blame] | 963 | const QuicConnectionIdLength connection_id_length_; |
[email protected] | 5351cc4b | 2013-03-03 07:22:41 | [diff] [blame] | 964 | const bool includes_version_; |
[email protected] | 25c31dc | 2013-06-05 17:56:04 | [diff] [blame] | 965 | const QuicSequenceNumberLength sequence_number_length_; |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 966 | |
[email protected] | 2e740db | 2012-10-20 19:35:19 | [diff] [blame] | 967 | DISALLOW_COPY_AND_ASSIGN(QuicPacket); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 968 | }; |
| 969 | |
| 970 | class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData { |
| 971 | public: |
[email protected] | 6ae6e34 | 2014-02-06 02:21:42 | [diff] [blame] | 972 | QuicEncryptedPacket(const char* buffer, size_t length); |
| 973 | QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 974 | |
[email protected] | ec86d546 | 2013-11-17 16:04:49 | [diff] [blame] | 975 | // Clones the packet into a new packet which owns the buffer. |
| 976 | QuicEncryptedPacket* Clone() const; |
| 977 | |
[email protected] | c1b32c6 | 2013-01-20 02:49:10 | [diff] [blame] | 978 | // By default, gtest prints the raw bytes of an object. The bool data |
| 979 | // member (in the base class QuicData) causes this object to have padding |
| 980 | // bytes, which causes the default gtest object printer to read |
| 981 | // uninitialize memory. So we need to teach gtest how to print this object. |
| 982 | NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
| 983 | std::ostream& os, const QuicEncryptedPacket& s); |
| 984 | |
[email protected] | 2e740db | 2012-10-20 19:35:19 | [diff] [blame] | 985 | private: |
| 986 | DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket); |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 987 | }; |
| 988 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 989 | class NET_EXPORT_PRIVATE RetransmittableFrames { |
| 990 | public: |
| 991 | RetransmittableFrames(); |
| 992 | ~RetransmittableFrames(); |
| 993 | |
| 994 | // Allocates a local copy of the referenced StringPiece has QuicStreamFrame |
| 995 | // use it. |
| 996 | // Takes ownership of |stream_frame|. |
| 997 | const QuicFrame& AddStreamFrame(QuicStreamFrame* stream_frame); |
| 998 | // Takes ownership of the frame inside |frame|. |
| 999 | const QuicFrame& AddNonStreamFrame(const QuicFrame& frame); |
| 1000 | const QuicFrames& frames() const { return frames_; } |
| 1001 | |
[email protected] | 2115d33ba | 2014-01-02 21:53:52 | [diff] [blame] | 1002 | IsHandshake HasCryptoHandshake() const; |
| 1003 | |
[email protected] | 8ba8121 | 2013-05-03 13:11:48 | [diff] [blame] | 1004 | void set_encryption_level(EncryptionLevel level); |
| 1005 | EncryptionLevel encryption_level() const { |
| 1006 | return encryption_level_; |
| 1007 | } |
| 1008 | |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1009 | private: |
| 1010 | QuicFrames frames_; |
[email protected] | 8ba8121 | 2013-05-03 13:11:48 | [diff] [blame] | 1011 | EncryptionLevel encryption_level_; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1012 | // Data referenced by the StringPiece of a QuicStreamFrame. |
| 1013 | std::vector<std::string*> stream_data_; |
| 1014 | |
| 1015 | DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames); |
| 1016 | }; |
| 1017 | |
| 1018 | struct NET_EXPORT_PRIVATE SerializedPacket { |
| 1019 | SerializedPacket(QuicPacketSequenceNumber sequence_number, |
[email protected] | ea825e0 | 2013-08-21 18:12:45 | [diff] [blame] | 1020 | QuicSequenceNumberLength sequence_number_length, |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1021 | QuicPacket* packet, |
| 1022 | QuicPacketEntropyHash entropy_hash, |
[email protected] | 97cf302 | 2013-09-05 14:30:16 | [diff] [blame] | 1023 | RetransmittableFrames* retransmittable_frames); |
| 1024 | ~SerializedPacket(); |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1025 | |
| 1026 | QuicPacketSequenceNumber sequence_number; |
[email protected] | ea825e0 | 2013-08-21 18:12:45 | [diff] [blame] | 1027 | QuicSequenceNumberLength sequence_number_length; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1028 | QuicPacket* packet; |
| 1029 | QuicPacketEntropyHash entropy_hash; |
| 1030 | RetransmittableFrames* retransmittable_frames; |
[email protected] | 97cf302 | 2013-09-05 14:30:16 | [diff] [blame] | 1031 | |
| 1032 | // If set, these will be called when this packet is ACKed by the peer. |
| 1033 | std::set<QuicAckNotifier*> notifiers; |
[email protected] | 9db44391 | 2013-02-25 05:27:03 | [diff] [blame] | 1034 | }; |
| 1035 | |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 1036 | struct NET_EXPORT_PRIVATE TransmissionInfo { |
| 1037 | // Used by STL when assigning into a map. |
| 1038 | TransmissionInfo(); |
| 1039 | |
| 1040 | // Constructs a Transmission with a new all_tranmissions set |
| 1041 | // containing |sequence_number|. |
| 1042 | TransmissionInfo(RetransmittableFrames* retransmittable_frames, |
| 1043 | QuicPacketSequenceNumber sequence_number, |
| 1044 | QuicSequenceNumberLength sequence_number_length); |
| 1045 | |
| 1046 | // Constructs a Transmission with the specified |all_tranmissions| set |
| 1047 | // and inserts |sequence_number| into it. |
| 1048 | TransmissionInfo(RetransmittableFrames* retransmittable_frames, |
| 1049 | QuicPacketSequenceNumber sequence_number, |
| 1050 | QuicSequenceNumberLength sequence_number_length, |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 1051 | TransmissionType transmission_type, |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 1052 | SequenceNumberSet* all_transmissions); |
| 1053 | |
| 1054 | RetransmittableFrames* retransmittable_frames; |
| 1055 | QuicSequenceNumberLength sequence_number_length; |
| 1056 | // Zero when the packet is serialized, non-zero once it's sent. |
| 1057 | QuicTime sent_time; |
| 1058 | // Zero when the packet is serialized, non-zero once it's sent. |
| 1059 | QuicByteCount bytes_sent; |
| 1060 | size_t nack_count; |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 1061 | // Reason why this packet was transmitted. |
| 1062 | TransmissionType transmission_type; |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 1063 | // Stores the sequence numbers of all transmissions of this packet. |
| 1064 | // Can never be null. |
| 1065 | SequenceNumberSet* all_transmissions; |
[email protected] | aa7e4ef | 2014-05-28 03:53:15 | [diff] [blame] | 1066 | // In flight packets have not been abandoned or lost. |
| 1067 | bool in_flight; |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 1068 | }; |
| 1069 | |
[email protected] | 8b37a09 | 2012-10-18 21:53:49 | [diff] [blame] | 1070 | } // namespace net |
| 1071 | |
| 1072 | #endif // NET_QUIC_QUIC_PROTOCOL_H_ |