blob: 7330d8ef98f2a17b10df38ac81bfa048785454b1 [file] [log] [blame]
[email protected]8b37a092012-10-18 21:53:491// 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]e537f742012-12-07 15:33:538#include <stddef.h>
tfarina3723da22015-06-03 21:39:309#include <stdint.h>
[email protected]8b37a092012-10-18 21:53:4910#include <limits>
rtenneti4b06ae72014-08-26 03:43:4311#include <list>
[email protected]a674b4c2012-12-05 03:44:3012#include <map>
[email protected]5640d0a2012-10-22 18:17:0213#include <ostream>
[email protected]e537f742012-12-07 15:33:5314#include <set>
15#include <string>
[email protected]8b37a092012-10-18 21:53:4916#include <utility>
17#include <vector>
18
19#include "base/basictypes.h"
[email protected]14c1c232013-06-11 17:52:4420#include "base/containers/hash_tables.h"
[email protected]8b37a092012-10-18 21:53:4921#include "base/logging.h"
[email protected]d069c11a2013-04-13 00:01:5522#include "base/strings/string_piece.h"
[email protected]165e0752012-11-16 07:49:4423#include "net/base/int128.h"
rtennetic14c8ab2015-06-18 05:47:4024#include "net/base/iovec.h"
[email protected]79d13dcb2014-02-05 07:23:1325#include "net/base/ip_endpoint.h"
[email protected]8b37a092012-10-18 21:53:4926#include "net/base/net_export.h"
[email protected]fee17f72013-02-03 07:47:4127#include "net/quic/quic_bandwidth.h"
[email protected]2a960e02012-11-11 14:48:1028#include "net/quic/quic_time.h"
rtennetic14c8ab2015-06-18 05:47:4029#include "net/quic/quic_types.h"
[email protected]8b37a092012-10-18 21:53:4930
31namespace net {
32
[email protected]97cf3022013-09-05 14:30:1633class QuicAckNotifier;
[email protected]8b37a092012-10-18 21:53:4934class QuicPacket;
[email protected]b064310782013-05-30 21:12:1735struct QuicPacketHeader;
[email protected]8b37a092012-10-18 21:53:4936
[email protected]3aa9ca72014-02-27 19:39:4337typedef uint64 QuicConnectionId;
[email protected]8b37a092012-10-18 21:53:4938typedef uint32 QuicStreamId;
39typedef uint64 QuicStreamOffset;
40typedef uint64 QuicPacketSequenceNumber;
[email protected]c995c572013-01-18 05:43:2041typedef QuicPacketSequenceNumber QuicFecGroupNumber;
[email protected]86a318d2013-01-23 21:16:0442typedef uint64 QuicPublicResetNonceProof;
[email protected]9db443912013-02-25 05:27:0343typedef uint8 QuicPacketEntropyHash;
[email protected]c244c5a12013-05-07 20:55:0444typedef uint32 QuicHeaderId;
[email protected]2532de12013-05-09 12:29:3345// QuicTag is the type of a tag in the wire protocol.
46typedef uint32 QuicTag;
47typedef std::vector<QuicTag> QuicTagVector;
[email protected]79d13dcb2014-02-05 07:23:1348typedef std::map<QuicTag, std::string> QuicTagValueMap;
[email protected]497bfb22014-01-08 01:28:0349// TODO(rtenneti): Didn't use SpdyPriority because SpdyPriority is uint8 and
50// QuicPriority is uint32. Use SpdyPriority when we change the QUIC_VERSION.
[email protected]8edeb8d2013-08-28 06:11:4351typedef uint32 QuicPriority;
[email protected]cff7b7b2013-01-11 08:49:0752
rtennetibb2780c2015-07-22 19:16:0853// Default initial maximum size in bytes of a QUIC packet.
[email protected]310d37b2014-08-02 06:15:3754const QuicByteCount kDefaultMaxPacketSize = 1350;
rtenneti16a20772015-02-17 18:58:4855// Default initial maximum size in bytes of a QUIC packet for servers.
56const QuicByteCount kDefaultServerMaxPacketSize = 1000;
[email protected]8e01c062013-10-31 07:35:3157// The maximum packet size of any QUIC packet, based on ethernet's max size,
[email protected]41fb6372013-12-10 05:26:4058// minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an
59// additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
60// max packet size is 1500 bytes, 1500 - 48 = 1452.
61const QuicByteCount kMaxPacketSize = 1452;
rtenneti9e0fb502015-03-08 06:07:1662// Default maximum packet size used in the Linux TCP implementation.
63// Used in QUIC for congestion window computations in bytes.
[email protected]ce7bb1412014-05-17 15:51:3364const QuicByteCount kDefaultTCPMSS = 1460;
[email protected]8e01c062013-10-31 07:35:3165
rtenneti3fe4ebbc2014-11-16 16:43:4766// We match SPDY's use of 32 when secure (since we'd compete with SPDY).
67const QuicPacketCount kInitialCongestionWindowSecure = 32;
68// Be conservative, and just use double a typical TCP ICWND for HTTP.
69const QuicPacketCount kInitialCongestionWindowInsecure = 20;
[email protected]8e01c062013-10-31 07:35:3170
rtenneti7652bf32015-01-05 18:51:0771// Minimum size of initial flow control window, for both stream and session.
72const uint32 kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB
[email protected]9bb57c72014-03-31 20:36:0473
rtennetifb3fa6c2015-03-16 23:04:5574// Minimum size of the CWND, in packets, when doing bandwidth resumption.
rtenneti8d2a808d2014-11-26 01:10:0975const QuicPacketCount kMinCongestionWindowForBandwidthResumption = 10;
76
rtenneti581b6ae82015-07-20 20:48:0177// Maximum size of the CWND, in packets.
78const QuicPacketCount kMaxCongestionWindow = 200;
rtenneti69e64aa2015-06-26 04:25:3079
80// Maximum number of tracked packets.
81const QuicPacketCount kMaxTrackedPackets = 5000;
[email protected]0ac0c5b2013-11-20 05:55:5882
rtenneti23186682014-10-30 01:49:3383// Default size of the socket receive buffer in bytes.
[email protected]648f81142014-08-15 21:38:4684const QuicByteCount kDefaultSocketReceiveBuffer = 256 * 1024;
rtenneti23186682014-10-30 01:49:3385// Minimum size of the socket receive buffer in bytes.
86// Smaller values are ignored.
87const QuicByteCount kMinSocketReceiveBuffer = 16 * 1024;
[email protected]a97b3182014-08-08 08:10:1888
rtenneti95293802015-03-27 18:59:2389// Fraction of the receive buffer that can be used for encrypted bytes.
90// Allows a 5% overhead for IP and UDP framing, as well as ack only packets.
91static const float kUsableRecieveBufferFraction = 0.95f;
rtenneti581b6ae82015-07-20 20:48:0192// Fraction of the receive buffer that can be used, based on conservative
93// estimates and testing on Linux.
94// An alternative to kUsableRecieveBufferFraction.
95static const float kConservativeReceiveBufferFraction = 0.6f;
rtenneti95293802015-03-27 18:59:2396
rtennetifc97ab62014-11-11 22:17:4997// Don't allow a client to suggest an RTT shorter than 10ms.
98const uint32 kMinInitialRoundTripTimeUs = 10 * kNumMicrosPerMilli;
99
[email protected]8e01c062013-10-31 07:35:31100// Don't allow a client to suggest an RTT longer than 15 seconds.
[email protected]2d43c40122014-04-21 14:51:27101const uint32 kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond;
[email protected]8b37a092012-10-18 21:53:49102
103// Maximum number of open streams per connection.
104const size_t kDefaultMaxStreamsPerConnection = 100;
105
[email protected]af806e62013-05-22 14:47:50106// Number of bytes reserved for public flags in the packet header.
107const size_t kPublicFlagsSize = 1;
[email protected]5351cc4b2013-03-03 07:22:41108// Number of bytes reserved for version number in the packet header.
109const size_t kQuicVersionSize = 4;
[email protected]c995c572013-01-18 05:43:20110// Number of bytes reserved for private flags in the packet header.
111const size_t kPrivateFlagsSize = 1;
112// Number of bytes reserved for FEC group in the packet header.
113const size_t kFecGroupSize = 1;
[email protected]5351cc4b2013-03-03 07:22:41114
115// Signifies that the QuicPacket will contain version of the protocol.
116const bool kIncludeVersion = true;
[email protected]c995c572013-01-18 05:43:20117
[email protected]5351cc4b2013-03-03 07:22:41118// Index of the first byte in a QUIC packet which is used in hash calculation.
119const size_t kStartOfHashData = 0;
[email protected]8b37a092012-10-18 21:53:49120
[email protected]8b37a092012-10-18 21:53:49121// Reserved ID for the crypto stream.
[email protected]8b37a092012-10-18 21:53:49122const QuicStreamId kCryptoStreamId = 1;
123
[email protected]4d640792013-12-18 22:21:08124// Reserved ID for the headers stream.
125const QuicStreamId kHeadersStreamId = 3;
126
[email protected]648f81142014-08-15 21:38:46127// Maximum delayed ack time, in ms.
pkastingacec86f2014-10-14 23:08:55128const int64 kMaxDelayedAckTimeMs = 25;
[email protected]648f81142014-08-15 21:38:46129
rtennetib5512bb2014-09-29 19:17:15130// The timeout before the handshake succeeds.
131const int64 kInitialIdleTimeoutSecs = 5;
132// The default idle timeout.
133const int64 kDefaultIdleTimeoutSecs = 30;
rtenneti31e9fd62014-09-16 05:22:15134// The maximum idle timeout that can be negotiated.
135const int64 kMaximumIdleTimeoutSecs = 60 * 10; // 10 minutes.
136// The default timeout for a connection until the crypto handshake succeeds.
rtennetib5512bb2014-09-29 19:17:15137const int64 kMaxTimeForCryptoHandshakeSecs = 10; // 10 secs.
[email protected]8b37a092012-10-18 21:53:49138
rtenneti93bce7ece2014-10-13 22:38:41139// Default limit on the number of undecryptable packets the connection buffers
140// before the CHLO/SHLO arrive.
141const size_t kDefaultMaxUndecryptablePackets = 10;
142
[email protected]525948df2014-04-21 06:26:58143// Default ping timeout.
144const int64 kPingTimeoutSecs = 15; // 15 secs.
145
[email protected]ca4e0d92014-08-22 16:33:22146// Minimum number of RTTs between Server Config Updates (SCUP) sent to client.
147const int kMinIntervalBetweenServerConfigUpdatesRTTs = 10;
148
149// Minimum time between Server Config Updates (SCUP) sent to client.
150const int kMinIntervalBetweenServerConfigUpdatesMs = 1000;
151
rtenneti33da8ab2014-11-04 04:17:00152// Minimum number of packets between Server Config Updates (SCUP).
153const int kMinPacketsBetweenServerConfigUpdates = 100;
154
rtennetib5512bb2014-09-29 19:17:15155// The number of open streams that a server will accept is set to be slightly
156// larger than the negotiated limit. Immediately closing the connection if the
157// client opens slightly too many streams is not ideal: the client may have sent
158// a FIN that was lost, and simultaneously opened a new stream. The number of
159// streams a server accepts is a fixed increment over the negotiated limit, or a
160// percentage increase, whichever is larger.
rtenneti31e9fd62014-09-16 05:22:15161const float kMaxStreamsMultiplier = 1.1f;
rtennetib5512bb2014-09-29 19:17:15162const int kMaxStreamsMinimumIncrement = 10;
rtenneti31e9fd62014-09-16 05:22:15163
[email protected]b007e632013-10-28 08:39:25164// We define an unsigned 16-bit floating point value, inspired by IEEE floats
165// (http://en.wikipedia.org/wiki/Half_precision_floating-point_format),
166// with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden
167// bit) and denormals, but without signs, transfinites or fractions. Wire format
168// 16 bits (little-endian byte order) are split into exponent (high 5) and
169// mantissa (low 11) and decoded as:
170// uint64 value;
171// if (exponent == 0) value = mantissa;
172// else value = (mantissa | 1 << 11) << (exponent - 1)
173const int kUFloat16ExponentBits = 5;
174const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30
175const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11
176const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12
177const uint64 kUFloat16MaxValue = // 0x3FFC0000000
tfarina3723da22015-06-03 21:39:30178 ((UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) <<
[email protected]b007e632013-10-28 08:39:25179 kUFloat16MaxExponent;
180
[email protected]c67a82cb2013-09-24 02:53:21181enum TransmissionType {
[email protected]2532de12013-05-09 12:29:33182 NOT_RETRANSMISSION,
[email protected]b9475b582014-03-20 20:04:33183 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION,
184 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts.
rtenneti31e9fd62014-09-16 05:22:15185 ALL_UNACKED_RETRANSMISSION, // Retransmits all unacked packets.
186 ALL_INITIAL_RETRANSMISSION, // Retransmits all initially encrypted packets.
[email protected]b9475b582014-03-20 20:04:33187 LOSS_RETRANSMISSION, // Retransmits due to loss detection.
188 RTO_RETRANSMISSION, // Retransmits due to retransmit time out.
189 TLP_RETRANSMISSION, // Tail loss probes.
190 LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION,
[email protected]74bda142013-03-31 02:49:11191};
192
193enum HasRetransmittableData {
[email protected]2532de12013-05-09 12:29:33194 NO_RETRANSMITTABLE_DATA,
195 HAS_RETRANSMITTABLE_DATA,
[email protected]74bda142013-03-31 02:49:11196};
197
[email protected]575cce62013-08-03 02:06:43198enum IsHandshake {
199 NOT_HANDSHAKE,
200 IS_HANDSHAKE
201};
202
rtenneti6f48aa92015-03-16 02:18:48203enum class Perspective { IS_SERVER, IS_CLIENT };
204
205NET_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
206 const Perspective& s);
207
[email protected]bbb10072014-06-13 07:41:59208// Indicates FEC protection level for data being written.
209enum FecProtection {
210 MUST_FEC_PROTECT, // Callee must FEC protect this data.
[email protected]a5b98172014-06-18 07:01:59211 MAY_FEC_PROTECT // Callee does not have to but may FEC protect this data.
212};
213
[email protected]bc356fe2014-06-19 11:14:14214// Indicates FEC policy.
[email protected]a5b98172014-06-18 07:01:59215enum FecPolicy {
216 FEC_PROTECT_ALWAYS, // All data in the stream should be FEC protected.
217 FEC_PROTECT_OPTIONAL // Data in the stream does not need FEC protection.
[email protected]bbb10072014-06-13 07:41:59218};
219
rtennetia4228ea2015-06-04 02:31:44220// Indicates FEC policy about when to send FEC packet.
221enum FecSendPolicy {
222 // Send FEC packet when FEC group is full or when FEC alarm goes off.
223 FEC_ANY_TRIGGER,
224 // Send FEC packet only when FEC alarm goes off.
225 FEC_ALARM_TRIGGER
226};
227
[email protected]be24ab22012-10-22 03:01:52228enum QuicFrameType {
[email protected]6ae6e342014-02-06 02:21:42229 // Regular frame types. The values set here cannot change without the
230 // introduction of a new QUIC version.
[email protected]c995c572013-01-18 05:43:20231 PADDING_FRAME = 0,
[email protected]6ae6e342014-02-06 02:21:42232 RST_STREAM_FRAME = 1,
233 CONNECTION_CLOSE_FRAME = 2,
234 GOAWAY_FRAME = 3,
235 WINDOW_UPDATE_FRAME = 4,
236 BLOCKED_FRAME = 5,
[email protected]93dd91f2014-02-27 00:09:03237 STOP_WAITING_FRAME = 6,
[email protected]d8c522112014-04-23 09:23:25238 PING_FRAME = 7,
[email protected]6ae6e342014-02-06 02:21:42239
rtennetif4bdb542015-01-21 14:33:05240 // STREAM and ACK frames are special frames. They are encoded differently on
241 // the wire and their values do not need to be stable.
[email protected]97cf3022013-09-05 14:30:16242 STREAM_FRAME,
243 ACK_FRAME,
rtenneti69e64aa2015-06-26 04:25:30244 // The path MTU discovery frame is encoded as a PING frame on the wire.
245 MTU_DISCOVERY_FRAME,
[email protected]be24ab22012-10-22 03:01:52246 NUM_FRAME_TYPES
[email protected]8b37a092012-10-18 21:53:49247};
248
[email protected]3aa9ca72014-02-27 19:39:43249enum QuicConnectionIdLength {
250 PACKET_0BYTE_CONNECTION_ID = 0,
251 PACKET_1BYTE_CONNECTION_ID = 1,
252 PACKET_4BYTE_CONNECTION_ID = 4,
253 PACKET_8BYTE_CONNECTION_ID = 8
[email protected]b064310782013-05-30 21:12:17254};
255
256enum InFecGroup {
257 NOT_IN_FEC_GROUP,
258 IN_FEC_GROUP,
259};
260
[email protected]25c31dc2013-06-05 17:56:04261enum QuicSequenceNumberLength {
262 PACKET_1BYTE_SEQUENCE_NUMBER = 1,
263 PACKET_2BYTE_SEQUENCE_NUMBER = 2,
264 PACKET_4BYTE_SEQUENCE_NUMBER = 4,
265 PACKET_6BYTE_SEQUENCE_NUMBER = 6
266};
267
[email protected]8e01c062013-10-31 07:35:31268// Used to indicate a QuicSequenceNumberLength using two flag bits.
269enum QuicSequenceNumberLengthFlags {
270 PACKET_FLAGS_1BYTE_SEQUENCE = 0, // 00
271 PACKET_FLAGS_2BYTE_SEQUENCE = 1, // 01
272 PACKET_FLAGS_4BYTE_SEQUENCE = 1 << 1, // 10
273 PACKET_FLAGS_6BYTE_SEQUENCE = 1 << 1 | 1, // 11
274};
275
[email protected]f62262b2013-07-05 20:57:30276// The public flags are specified in one byte.
[email protected]c995c572013-01-18 05:43:20277enum QuicPacketPublicFlags {
278 PACKET_PUBLIC_FLAGS_NONE = 0,
[email protected]f62262b2013-07-05 20:57:30279
280 // Bit 0: Does the packet header contains version info?
281 PACKET_PUBLIC_FLAGS_VERSION = 1 << 0,
282
283 // Bit 1: Is this packet a public reset packet?
284 PACKET_PUBLIC_FLAGS_RST = 1 << 1,
285
[email protected]3aa9ca72014-02-27 19:39:43286 // Bits 2 and 3 specify the length of the ConnectionId as follows:
[email protected]f62262b2013-07-05 20:57:30287 // ----00--: 0 bytes
288 // ----01--: 1 byte
289 // ----10--: 4 bytes
290 // ----11--: 8 bytes
[email protected]3aa9ca72014-02-27 19:39:43291 PACKET_PUBLIC_FLAGS_0BYTE_CONNECTION_ID = 0,
292 PACKET_PUBLIC_FLAGS_1BYTE_CONNECTION_ID = 1 << 2,
293 PACKET_PUBLIC_FLAGS_4BYTE_CONNECTION_ID = 1 << 3,
294 PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID = 1 << 3 | 1 << 2,
[email protected]f62262b2013-07-05 20:57:30295
296 // Bits 4 and 5 describe the packet sequence number length as follows:
297 // --00----: 1 byte
298 // --01----: 2 bytes
299 // --10----: 4 bytes
300 // --11----: 6 bytes
[email protected]8e01c062013-10-31 07:35:31301 PACKET_PUBLIC_FLAGS_1BYTE_SEQUENCE = PACKET_FLAGS_1BYTE_SEQUENCE << 4,
302 PACKET_PUBLIC_FLAGS_2BYTE_SEQUENCE = PACKET_FLAGS_2BYTE_SEQUENCE << 4,
303 PACKET_PUBLIC_FLAGS_4BYTE_SEQUENCE = PACKET_FLAGS_4BYTE_SEQUENCE << 4,
304 PACKET_PUBLIC_FLAGS_6BYTE_SEQUENCE = PACKET_FLAGS_6BYTE_SEQUENCE << 4,
[email protected]f62262b2013-07-05 20:57:30305
306 // All bits set (bits 6 and 7 are not currently used): 00111111
307 PACKET_PUBLIC_FLAGS_MAX = (1 << 6) - 1
[email protected]c995c572013-01-18 05:43:20308};
[email protected]8b37a092012-10-18 21:53:49309
[email protected]f62262b2013-07-05 20:57:30310// The private flags are specified in one byte.
[email protected]c995c572013-01-18 05:43:20311enum QuicPacketPrivateFlags {
312 PACKET_PRIVATE_FLAGS_NONE = 0,
[email protected]f62262b2013-07-05 20:57:30313
314 // Bit 0: Does this packet contain an entropy bit?
[email protected]b064310782013-05-30 21:12:17315 PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 0,
[email protected]f62262b2013-07-05 20:57:30316
317 // Bit 1: Payload is part of an FEC group?
318 PACKET_PRIVATE_FLAGS_FEC_GROUP = 1 << 1,
319
320 // Bit 2: Payload is FEC as opposed to frames?
321 PACKET_PRIVATE_FLAGS_FEC = 1 << 2,
322
323 // All bits set (bits 3-7 are not currently used): 00000111
324 PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1
[email protected]c995c572013-01-18 05:43:20325};
326
[email protected]48878092013-07-26 14:51:56327// The available versions of QUIC. Guaranteed that the integer value of the enum
328// will match the version number.
329// When adding a new version to this enum you should add it to
[email protected]8bbfaeb72013-08-09 06:38:26330// kSupportedQuicVersions (if appropriate), and also add a new case to the
331// helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and
332// QuicVersionToString.
[email protected]48878092013-07-26 14:51:56333enum QuicVersion {
334 // Special case to indicate unknown/unsupported QUIC version.
335 QUIC_VERSION_UNSUPPORTED = 0,
336
rtenneti501f0a92015-01-17 01:55:40337 QUIC_VERSION_24 = 24, // SPDY/4 header compression.
rchc0815442015-04-18 13:29:46338 QUIC_VERSION_25 = 25, // SPDY/4 header keys, and removal of error_details
339 // from QuicRstStreamFrame
[email protected]48878092013-07-26 14:51:56340};
341
342// This vector contains QUIC versions which we currently support.
343// This should be ordered such that the highest supported version is the first
344// element, with subsequent elements in descending order (versions can be
345// skipped as necessary).
[email protected]31ae854842013-11-27 00:05:46346//
[email protected]310d37b2014-08-02 06:15:37347// IMPORTANT: if you are adding to this list, follow the instructions at
[email protected]31ae854842013-11-27 00:05:46348// http://sites/quic/adding-and-removing-versions
rchc0815442015-04-18 13:29:46349static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_25,
rtennetie0ee6eb2015-05-01 00:55:09350 QUIC_VERSION_24};
[email protected]48878092013-07-26 14:51:56351
352typedef std::vector<QuicVersion> QuicVersionVector;
353
[email protected]b007e632013-10-28 08:39:25354// Returns a vector of QUIC versions in kSupportedQuicVersions.
355NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions();
[email protected]ea2ab47b2013-08-13 00:44:11356
[email protected]48878092013-07-26 14:51:56357// QuicTag is written to and read from the wire, but we prefer to use
358// the more readable QuicVersion at other levels.
359// Helper function which translates from a QuicVersion to a QuicTag. Returns 0
360// if QuicVersion is unsupported.
361NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version);
362
363// Returns appropriate QuicVersion from a QuicTag.
364// Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood.
365NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag);
366
367// Helper function which translates from a QuicVersion to a string.
368// Returns strings corresponding to enum names (e.g. QUIC_VERSION_6).
369NET_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version);
370
371// Returns comma separated list of string representations of QuicVersion enum
[email protected]b007e632013-10-28 08:39:25372// values in the supplied |versions| vector.
373NET_EXPORT_PRIVATE std::string QuicVersionVectorToString(
374 const QuicVersionVector& versions);
[email protected]48878092013-07-26 14:51:56375
376// Version and Crypto tags are written to the wire with a big-endian
377// representation of the name of the tag. For example
378// the client hello tag (CHLO) will be written as the
379// following 4 bytes: 'C' 'H' 'L' 'O'. Since it is
380// stored in memory as a little endian uint32, we need
381// to reverse the order of the bytes.
382
383// MakeQuicTag returns a value given the four bytes. For example:
384// MakeQuicTag('C', 'H', 'L', 'O');
385NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d);
386
[email protected]9cda5fd2014-06-03 10:20:28387// Returns true if the tag vector contains the specified tag.
[email protected]cc1aa272014-06-30 19:48:22388NET_EXPORT_PRIVATE bool ContainsQuicTag(const QuicTagVector& tag_vector,
389 QuicTag tag);
[email protected]9cda5fd2014-06-03 10:20:28390
[email protected]b064310782013-05-30 21:12:17391// Size in bytes of the data or fec packet header.
[email protected]79d13dcb2014-02-05 07:23:13392NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header);
[email protected]b064310782013-05-30 21:12:17393
[email protected]25c31dc2013-06-05 17:56:04394NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(
[email protected]3aa9ca72014-02-27 19:39:43395 QuicConnectionIdLength connection_id_length,
[email protected]25c31dc2013-06-05 17:56:04396 bool include_version,
397 QuicSequenceNumberLength sequence_number_length,
398 InFecGroup is_in_fec_group);
[email protected]b064310782013-05-30 21:12:17399
[email protected]b064310782013-05-30 21:12:17400// Index of the first byte in a QUIC packet of FEC protected data.
[email protected]25c31dc2013-06-05 17:56:04401NET_EXPORT_PRIVATE size_t GetStartOfFecProtectedData(
[email protected]3aa9ca72014-02-27 19:39:43402 QuicConnectionIdLength connection_id_length,
[email protected]25c31dc2013-06-05 17:56:04403 bool include_version,
404 QuicSequenceNumberLength sequence_number_length);
[email protected]b064310782013-05-30 21:12:17405// Index of the first byte in a QUIC packet of encrypted data.
[email protected]25c31dc2013-06-05 17:56:04406NET_EXPORT_PRIVATE size_t GetStartOfEncryptedData(
[email protected]3aa9ca72014-02-27 19:39:43407 QuicConnectionIdLength connection_id_length,
[email protected]25c31dc2013-06-05 17:56:04408 bool include_version,
409 QuicSequenceNumberLength sequence_number_length);
[email protected]b064310782013-05-30 21:12:17410
[email protected]74bda142013-03-31 02:49:11411enum QuicRstStreamErrorCode {
412 QUIC_STREAM_NO_ERROR = 0,
[email protected]8b37a092012-10-18 21:53:49413
[email protected]24e5bc52013-09-18 15:36:58414 // There was some error which halted stream processing.
415 QUIC_ERROR_PROCESSING_STREAM,
[email protected]8b37a092012-10-18 21:53:49416 // We got two fin or reset offsets which did not match.
417 QUIC_MULTIPLE_TERMINATION_OFFSETS,
418 // We got bad payload and can not respond to it at the protocol level.
419 QUIC_BAD_APPLICATION_PAYLOAD,
[email protected]74bda142013-03-31 02:49:11420 // Stream closed due to connection error. No reset frame is sent when this
421 // happens.
422 QUIC_STREAM_CONNECTION_ERROR,
423 // GoAway frame sent. No more stream can be created.
424 QUIC_STREAM_PEER_GOING_AWAY,
[email protected]06ff5152013-08-29 01:03:05425 // The stream has been cancelled.
426 QUIC_STREAM_CANCELLED,
rtenneti4a5df262014-11-07 00:43:58427 // Closing stream locally, sending a RST to allow for proper flow control
428 // accounting. Sent in response to a RST from the peer.
429 QUIC_RST_ACKNOWLEDGEMENT,
[email protected]8b37a092012-10-18 21:53:49430
[email protected]74bda142013-03-31 02:49:11431 // No error. Used as bound while iterating.
432 QUIC_STREAM_LAST_ERROR,
433};
[email protected]8b37a092012-10-18 21:53:49434
[email protected]51cc1342014-04-18 23:44:37435// Because receiving an unknown QuicRstStreamErrorCode results in connection
436// teardown, we use this to make sure any errors predating a given version are
437// downgraded to the most appropriate existing error.
438NET_EXPORT_PRIVATE QuicRstStreamErrorCode AdjustErrorForVersion(
439 QuicRstStreamErrorCode error_code,
440 QuicVersion version);
441
[email protected]89264042013-08-21 07:35:24442// These values must remain stable as they are uploaded to UMA histograms.
443// To add a new error code, use the current value of QUIC_LAST_ERROR and
444// increment QUIC_LAST_ERROR.
[email protected]74bda142013-03-31 02:49:11445enum QuicErrorCode {
446 QUIC_NO_ERROR = 0,
447
448 // Connection has reached an invalid state.
[email protected]89264042013-08-21 07:35:24449 QUIC_INTERNAL_ERROR = 1,
[email protected]74bda142013-03-31 02:49:11450 // There were data frames after the a fin or reset.
[email protected]89264042013-08-21 07:35:24451 QUIC_STREAM_DATA_AFTER_TERMINATION = 2,
[email protected]8b37a092012-10-18 21:53:49452 // Control frame is malformed.
[email protected]89264042013-08-21 07:35:24453 QUIC_INVALID_PACKET_HEADER = 3,
[email protected]be24ab22012-10-22 03:01:52454 // Frame data is malformed.
[email protected]89264042013-08-21 07:35:24455 QUIC_INVALID_FRAME_DATA = 4,
456 // The packet contained no payload.
457 QUIC_MISSING_PAYLOAD = 48,
[email protected]8b37a092012-10-18 21:53:49458 // FEC data is malformed.
[email protected]89264042013-08-21 07:35:24459 QUIC_INVALID_FEC_DATA = 5,
460 // STREAM frame data is malformed.
461 QUIC_INVALID_STREAM_DATA = 46,
[email protected]42a3eba2014-04-30 10:52:55462 // STREAM frame data is not encrypted.
463 QUIC_UNENCRYPTED_STREAM_DATA = 61,
[email protected]89264042013-08-21 07:35:24464 // RST_STREAM frame data is malformed.
465 QUIC_INVALID_RST_STREAM_DATA = 6,
466 // CONNECTION_CLOSE frame data is malformed.
467 QUIC_INVALID_CONNECTION_CLOSE_DATA = 7,
468 // GOAWAY frame data is malformed.
469 QUIC_INVALID_GOAWAY_DATA = 8,
[email protected]6ae6e342014-02-06 02:21:42470 // WINDOW_UPDATE frame data is malformed.
471 QUIC_INVALID_WINDOW_UPDATE_DATA = 57,
472 // BLOCKED frame data is malformed.
473 QUIC_INVALID_BLOCKED_DATA = 58,
[email protected]93dd91f2014-02-27 00:09:03474 // STOP_WAITING frame data is malformed.
475 QUIC_INVALID_STOP_WAITING_DATA = 60,
[email protected]89264042013-08-21 07:35:24476 // ACK frame data is malformed.
477 QUIC_INVALID_ACK_DATA = 9,
rtennetif4bdb542015-01-21 14:33:05478
479 // deprecated: QUIC_INVALID_CONGESTION_FEEDBACK_DATA = 47,
480
[email protected]14e8106c2013-03-14 16:25:33481 // Version negotiation packet is malformed.
[email protected]89264042013-08-21 07:35:24482 QUIC_INVALID_VERSION_NEGOTIATION_PACKET = 10,
[email protected]899951652013-05-16 12:52:39483 // Public RST packet is malformed.
[email protected]89264042013-08-21 07:35:24484 QUIC_INVALID_PUBLIC_RST_PACKET = 11,
[email protected]8b37a092012-10-18 21:53:49485 // There was an error decrypting.
[email protected]89264042013-08-21 07:35:24486 QUIC_DECRYPTION_FAILURE = 12,
[email protected]8b37a092012-10-18 21:53:49487 // There was an error encrypting.
[email protected]89264042013-08-21 07:35:24488 QUIC_ENCRYPTION_FAILURE = 13,
[email protected]8b37a092012-10-18 21:53:49489 // The packet exceeded kMaxPacketSize.
[email protected]89264042013-08-21 07:35:24490 QUIC_PACKET_TOO_LARGE = 14,
[email protected]8b37a092012-10-18 21:53:49491 // Data was sent for a stream which did not exist.
[email protected]89264042013-08-21 07:35:24492 QUIC_PACKET_FOR_NONEXISTENT_STREAM = 15,
[email protected]9db443912013-02-25 05:27:03493 // The peer is going away. May be a client or server.
[email protected]89264042013-08-21 07:35:24494 QUIC_PEER_GOING_AWAY = 16,
[email protected]8b37a092012-10-18 21:53:49495 // A stream ID was invalid.
[email protected]89264042013-08-21 07:35:24496 QUIC_INVALID_STREAM_ID = 17,
[email protected]24e5bc52013-09-18 15:36:58497 // A priority was invalid.
498 QUIC_INVALID_PRIORITY = 49,
[email protected]8b37a092012-10-18 21:53:49499 // Too many streams already open.
[email protected]89264042013-08-21 07:35:24500 QUIC_TOO_MANY_OPEN_STREAMS = 18,
[email protected]9693157b2014-08-08 11:13:49501 // The peer must send a FIN/RST for each stream, and has not been doing so.
502 QUIC_TOO_MANY_UNFINISHED_STREAMS = 66,
[email protected]86a318d2013-01-23 21:16:04503 // Received public reset for this connection.
[email protected]89264042013-08-21 07:35:24504 QUIC_PUBLIC_RESET = 19,
[email protected]c244c5a12013-05-07 20:55:04505 // Invalid protocol version.
[email protected]89264042013-08-21 07:35:24506 QUIC_INVALID_VERSION = 20,
[email protected]92bf17c2014-03-03 21:14:03507
508 // deprecated: QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED = 21
509
[email protected]c244c5a12013-05-07 20:55:04510 // The Header ID for a stream was too far from the previous.
[email protected]89264042013-08-21 07:35:24511 QUIC_INVALID_HEADER_ID = 22,
[email protected]899951652013-05-16 12:52:39512 // Negotiable parameter received during handshake had invalid value.
[email protected]89264042013-08-21 07:35:24513 QUIC_INVALID_NEGOTIATED_VALUE = 23,
[email protected]899951652013-05-16 12:52:39514 // There was an error decompressing data.
[email protected]89264042013-08-21 07:35:24515 QUIC_DECOMPRESSION_FAILURE = 24,
[email protected]8b37a092012-10-18 21:53:49516 // We hit our prenegotiated (or default) timeout
[email protected]89264042013-08-21 07:35:24517 QUIC_CONNECTION_TIMED_OUT = 25,
rtenneti31e9fd62014-09-16 05:22:15518 // We hit our overall connection timeout
519 QUIC_CONNECTION_OVERALL_TIMED_OUT = 67,
[email protected]899951652013-05-16 12:52:39520 // There was an error encountered migrating addresses
[email protected]89264042013-08-21 07:35:24521 QUIC_ERROR_MIGRATING_ADDRESS = 26,
[email protected]1505a512013-09-04 22:59:35522 // There was an error while writing to the socket.
[email protected]89264042013-08-21 07:35:24523 QUIC_PACKET_WRITE_ERROR = 27,
[email protected]1505a512013-09-04 22:59:35524 // There was an error while reading from the socket.
525 QUIC_PACKET_READ_ERROR = 51,
[email protected]24e5bc52013-09-18 15:36:58526 // We received a STREAM_FRAME with no data and no fin flag set.
527 QUIC_INVALID_STREAM_FRAME = 50,
[email protected]4d640792013-12-18 22:21:08528 // We received invalid data on the headers stream.
529 QUIC_INVALID_HEADERS_STREAM_DATA = 56,
[email protected]730b35d72014-06-05 03:23:22530 // The peer received too much data, violating flow control.
531 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA = 59,
532 // The peer sent too much data, violating flow control.
533 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA = 63,
534 // The peer received an invalid flow control window.
535 QUIC_FLOW_CONTROL_INVALID_WINDOW = 64,
[email protected]71c84e592014-05-28 23:39:29536 // The connection has been IP pooled into an existing connection.
537 QUIC_CONNECTION_IP_POOLED = 62,
rtenneti23186682014-10-30 01:49:33538 // The connection has too many outstanding sent packets.
539 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS = 68,
540 // The connection has too many outstanding received packets.
541 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS = 69,
rtenneti14abd312015-02-06 21:56:01542 // The quic connection job to load server config is cancelled.
543 QUIC_CONNECTION_CANCELLED = 70,
rtenneti85dcfac22015-03-27 20:22:19544 // Disabled QUIC because of high packet loss rate.
545 QUIC_BAD_PACKET_LOSS_RATE = 71,
ckrasic1e53b642015-07-08 22:39:35546 // Disabled QUIC because of too many PUBLIC_RESETs post handshake.
547 QUIC_PUBLIC_RESETS_POST_HANDSHAKE = 73,
548 // Disabled QUIC because of too many timeouts with streams open.
549 QUIC_TIMEOUTS_WITH_OPEN_STREAMS = 74,
rtenneti8811fdb2015-07-22 00:17:07550 // Closed because we failed to serialize a packet.
551 QUIC_FAILED_TO_SERIALIZE_PACKET = 75,
[email protected]8b37a092012-10-18 21:53:49552
553 // Crypto errors.
554
[email protected]1354bf62013-05-23 23:17:18555 // Hanshake failed.
[email protected]89264042013-08-21 07:35:24556 QUIC_HANDSHAKE_FAILED = 28,
[email protected]8b37a092012-10-18 21:53:49557 // Handshake message contained out of order tags.
[email protected]89264042013-08-21 07:35:24558 QUIC_CRYPTO_TAGS_OUT_OF_ORDER = 29,
[email protected]701bc892013-01-17 04:51:54559 // Handshake message contained too many entries.
[email protected]89264042013-08-21 07:35:24560 QUIC_CRYPTO_TOO_MANY_ENTRIES = 30,
[email protected]8b37a092012-10-18 21:53:49561 // Handshake message contained an invalid value length.
[email protected]89264042013-08-21 07:35:24562 QUIC_CRYPTO_INVALID_VALUE_LENGTH = 31,
[email protected]8b37a092012-10-18 21:53:49563 // A crypto message was received after the handshake was complete.
[email protected]89264042013-08-21 07:35:24564 QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE = 32,
[email protected]d3d15bf2013-01-30 02:51:54565 // A crypto message was received with an illegal message tag.
[email protected]89264042013-08-21 07:35:24566 QUIC_INVALID_CRYPTO_MESSAGE_TYPE = 33,
[email protected]d3d15bf2013-01-30 02:51:54567 // A crypto message was received with an illegal parameter.
[email protected]89264042013-08-21 07:35:24568 QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER = 34,
[email protected]752fbe52013-10-14 08:35:32569 // An invalid channel id signature was supplied.
570 QUIC_INVALID_CHANNEL_ID_SIGNATURE = 52,
[email protected]d3d15bf2013-01-30 02:51:54571 // A crypto message was received with a mandatory parameter missing.
[email protected]89264042013-08-21 07:35:24572 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND = 35,
[email protected]d3d15bf2013-01-30 02:51:54573 // A crypto message was received with a parameter that has no overlap
574 // with the local parameter.
[email protected]89264042013-08-21 07:35:24575 QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP = 36,
[email protected]ed3fc15d2013-03-08 18:37:44576 // A crypto message was received that contained a parameter with too few
577 // values.
[email protected]89264042013-08-21 07:35:24578 QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND = 37,
[email protected]ccc66e8a2013-03-26 08:26:14579 // An internal error occured in crypto processing.
[email protected]89264042013-08-21 07:35:24580 QUIC_CRYPTO_INTERNAL_ERROR = 38,
[email protected]ccc66e8a2013-03-26 08:26:14581 // A crypto handshake message specified an unsupported version.
[email protected]89264042013-08-21 07:35:24582 QUIC_CRYPTO_VERSION_NOT_SUPPORTED = 39,
rtennetie0ee6eb2015-05-01 00:55:09583 // A crypto handshake message resulted in a stateless reject.
584 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT = 72,
[email protected]ccc66e8a2013-03-26 08:26:14585 // There was no intersection between the crypto primitives supported by the
586 // peer and ourselves.
[email protected]89264042013-08-21 07:35:24587 QUIC_CRYPTO_NO_SUPPORT = 40,
[email protected]ef95114d2013-04-17 17:57:01588 // The server rejected our client hello messages too many times.
[email protected]89264042013-08-21 07:35:24589 QUIC_CRYPTO_TOO_MANY_REJECTS = 41,
[email protected]a57e0272013-04-26 07:31:47590 // The client rejected the server's certificate chain or signature.
[email protected]89264042013-08-21 07:35:24591 QUIC_PROOF_INVALID = 42,
[email protected]8ba81212013-05-03 13:11:48592 // A crypto message was received with a duplicate tag.
[email protected]89264042013-08-21 07:35:24593 QUIC_CRYPTO_DUPLICATE_TAG = 43,
[email protected]2532de12013-05-09 12:29:33594 // A crypto message was received with the wrong encryption level (i.e. it
595 // should have been encrypted but was not.)
[email protected]89264042013-08-21 07:35:24596 QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT = 44,
[email protected]2532de12013-05-09 12:29:33597 // The server config for a server has expired.
[email protected]89264042013-08-21 07:35:24598 QUIC_CRYPTO_SERVER_CONFIG_EXPIRED = 45,
[email protected]752fbe52013-10-14 08:35:32599 // We failed to setup the symmetric keys for a connection.
600 QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED = 53,
[email protected]691f45a982013-11-19 10:52:04601 // A handshake message arrived, but we are still validating the
602 // previous handshake message.
603 QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO = 54,
[email protected]ccb34212014-07-18 09:27:50604 // A server config update arrived before the handshake is complete.
605 QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE = 65,
[email protected]d89f1862013-11-26 21:21:27606 // This connection involved a version negotiation which appears to have been
607 // tampered with.
608 QUIC_VERSION_NEGOTIATION_MISMATCH = 55,
[email protected]ccc66e8a2013-03-26 08:26:14609
[email protected]74bda142013-03-31 02:49:11610 // No error. Used as bound while iterating.
rtenneti8811fdb2015-07-22 00:17:07611 QUIC_LAST_ERROR = 76,
[email protected]8b37a092012-10-18 21:53:49612};
613
[email protected]c995c572013-01-18 05:43:20614struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
[email protected]14e8106c2013-03-14 16:25:33615 QuicPacketPublicHeader();
616 explicit QuicPacketPublicHeader(const QuicPacketPublicHeader& other);
617 ~QuicPacketPublicHeader();
618
[email protected]3aa9ca72014-02-27 19:39:43619 // Universal header. All QuicPacket headers will have a connection_id and
620 // public flags.
621 QuicConnectionId connection_id;
622 QuicConnectionIdLength connection_id_length;
[email protected]9db443912013-02-25 05:27:03623 bool reset_flag;
624 bool version_flag;
[email protected]25c31dc2013-06-05 17:56:04625 QuicSequenceNumberLength sequence_number_length;
[email protected]48878092013-07-26 14:51:56626 QuicVersionVector versions;
[email protected]c995c572013-01-18 05:43:20627};
628
rtenneti9e0fb502015-03-08 06:07:16629// An integer which cannot be a packet sequence number.
630const QuicPacketSequenceNumber kInvalidPacketSequenceNumber = 0;
631
[email protected]c995c572013-01-18 05:43:20632// Header for Data or FEC packets.
[email protected]74bda142013-03-31 02:49:11633struct NET_EXPORT_PRIVATE QuicPacketHeader {
634 QuicPacketHeader();
635 explicit QuicPacketHeader(const QuicPacketPublicHeader& header);
[email protected]9db443912013-02-25 05:27:03636
637 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
638 std::ostream& os, const QuicPacketHeader& s);
639
[email protected]c995c572013-01-18 05:43:20640 QuicPacketPublicHeader public_header;
rtennetid39bd762015-06-12 01:05:52641 QuicPacketSequenceNumber packet_sequence_number;
[email protected]9db443912013-02-25 05:27:03642 bool fec_flag;
[email protected]9db443912013-02-25 05:27:03643 bool entropy_flag;
644 QuicPacketEntropyHash entropy_hash;
[email protected]b064310782013-05-30 21:12:17645 InFecGroup is_in_fec_group;
[email protected]8b37a092012-10-18 21:53:49646 QuicFecGroupNumber fec_group;
647};
648
[email protected]74bda142013-03-31 02:49:11649struct NET_EXPORT_PRIVATE QuicPublicResetPacket {
[email protected]6ae6e342014-02-06 02:21:42650 QuicPublicResetPacket();
651 explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header);
652
[email protected]86a318d2013-01-23 21:16:04653 QuicPacketPublicHeader public_header;
[email protected]86a318d2013-01-23 21:16:04654 QuicPublicResetNonceProof nonce_proof;
[email protected]300ccd52014-01-25 08:00:19655 QuicPacketSequenceNumber rejected_sequence_number;
[email protected]79d13dcb2014-02-05 07:23:13656 IPEndPoint client_address;
[email protected]86a318d2013-01-23 21:16:04657};
658
[email protected]14e8106c2013-03-14 16:25:33659enum QuicVersionNegotiationState {
660 START_NEGOTIATION = 0,
[email protected]ec640112013-08-09 03:56:18661 // Server-side this implies we've sent a version negotiation packet and are
662 // waiting on the client to select a compatible version. Client-side this
663 // implies we've gotten a version negotiation packet, are retransmitting the
664 // initial packets with a supported version and are waiting for our first
665 // packet from the server.
666 NEGOTIATION_IN_PROGRESS,
667 // This indicates this endpoint has received a packet from the peer with a
668 // version this endpoint supports. Version negotiation is complete, and the
669 // version number will no longer be sent with future packets.
[email protected]14e8106c2013-03-14 16:25:33670 NEGOTIATED_VERSION
671};
672
673typedef QuicPacketPublicHeader QuicVersionNegotiationPacket;
674
[email protected]c995c572013-01-18 05:43:20675// A padding frame contains no payload.
676struct NET_EXPORT_PRIVATE QuicPaddingFrame {
677};
678
[email protected]d8c522112014-04-23 09:23:25679// A ping frame contains no payload, though it is retransmittable,
680// and ACK'd just like other normal frames.
681struct NET_EXPORT_PRIVATE QuicPingFrame {
682};
683
rtenneti69e64aa2015-06-26 04:25:30684// A path MTU discovery frame contains no payload and is serialized as a ping
685// frame.
686struct NET_EXPORT_PRIVATE QuicMtuDiscoveryFrame {};
687
[email protected]be24ab22012-10-22 03:01:52688struct NET_EXPORT_PRIVATE QuicStreamFrame {
689 QuicStreamFrame();
[email protected]5dafdb62013-11-14 01:24:26690 QuicStreamFrame(const QuicStreamFrame& frame);
[email protected]be24ab22012-10-22 03:01:52691 QuicStreamFrame(QuicStreamId stream_id,
[email protected]a5061242012-10-23 23:29:37692 bool fin,
[email protected]701bc892013-01-17 04:51:54693 QuicStreamOffset offset,
rtennetia4228ea2015-06-04 02:31:44694 base::StringPiece data);
[email protected]5dafdb62013-11-14 01:24:26695
[email protected]c5e1aca2014-01-30 04:03:04696 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
697 std::ostream& os, const QuicStreamFrame& s);
698
[email protected]8b37a092012-10-18 21:53:49699 QuicStreamId stream_id;
700 bool fin;
[email protected]701bc892013-01-17 04:51:54701 QuicStreamOffset offset; // Location of this data in the stream.
rtennetia4228ea2015-06-04 02:31:44702 base::StringPiece data;
[email protected]8b37a092012-10-18 21:53:49703};
704
[email protected]e537f742012-12-07 15:33:53705// TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing
706// is finalized.
[email protected]9db443912013-02-25 05:27:03707typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet;
rtennetidd4bf8f2014-09-03 00:45:16708typedef std::list<QuicPacketSequenceNumber> SequenceNumberList;
rtenneti4b06ae72014-08-26 03:43:43709
mostynbdc40b80612014-09-10 03:45:42710typedef std::list<
711 std::pair<QuicPacketSequenceNumber, QuicTime> > PacketTimeList;
[email protected]044ac2b2012-11-13 21:41:06712
[email protected]310d37b2014-08-02 06:15:37713struct NET_EXPORT_PRIVATE QuicStopWaitingFrame {
714 QuicStopWaitingFrame();
715 ~QuicStopWaitingFrame();
[email protected]6ae6e342014-02-06 02:21:42716
[email protected]26f3f8e2012-12-13 21:07:19717 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
[email protected]310d37b2014-08-02 06:15:37718 std::ostream& os, const QuicStopWaitingFrame& s);
719 // Entropy hash of all packets up to, but not including, the least unacked
720 // packet.
721 QuicPacketEntropyHash entropy_hash;
722 // The lowest packet we've sent which is unacked, and we expect an ack for.
723 QuicPacketSequenceNumber least_unacked;
724};
725
726struct NET_EXPORT_PRIVATE QuicAckFrame {
727 QuicAckFrame();
728 ~QuicAckFrame();
729
730 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
731 std::ostream& os, const QuicAckFrame& s);
[email protected]a674b4c2012-12-05 03:44:30732
[email protected]9db443912013-02-25 05:27:03733 // Entropy hash of all packets up to largest observed not including missing
734 // packets.
735 QuicPacketEntropyHash entropy_hash;
[email protected]e537f742012-12-07 15:33:53736
[email protected]48697d8a2013-01-15 19:42:24737 // The highest packet sequence number we've observed from the peer.
738 //
739 // In general, this should be the largest packet number we've received. In
740 // the case of truncated acks, we may have to advertise a lower "upper bound"
741 // than largest received, to avoid implicitly acking missing packets that
742 // don't fit in the missing packet list due to size limitations. In this
743 // case, largest_observed may be a packet which is also in the missing packets
744 // list.
745 QuicPacketSequenceNumber largest_observed;
[email protected]a674b4c2012-12-05 03:44:30746
[email protected]14e8106c2013-03-14 16:25:33747 // Time elapsed since largest_observed was received until this Ack frame was
748 // sent.
749 QuicTime::Delta delta_time_largest_observed;
750
[email protected]9db443912013-02-25 05:27:03751 // TODO(satyamshekhar): Can be optimized using an interval set like data
752 // structure.
[email protected]e537f742012-12-07 15:33:53753 // The set of packets which we're expecting and have not received.
[email protected]9db443912013-02-25 05:27:03754 SequenceNumberSet missing_packets;
[email protected]8e01c062013-10-31 07:35:31755
756 // Whether the ack had to be truncated when sent.
757 bool is_truncated;
[email protected]bdf2d432014-02-09 10:45:41758
759 // Packets which have been revived via FEC.
760 // All of these must also be in missing_packets.
761 SequenceNumberSet revived_packets;
rtenneti4b06ae72014-08-26 03:43:43762
763 // List of <sequence_number, time> for when packets arrived.
764 PacketTimeList received_packet_times;
[email protected]8b37a092012-10-18 21:53:49765};
766
[email protected]9db443912013-02-25 05:27:03767// True if the sequence number is greater than largest_observed or is listed
768// as missing.
769// Always returns false for sequence numbers less than least_unacked.
770bool NET_EXPORT_PRIVATE IsAwaitingPacket(
[email protected]310d37b2014-08-02 06:15:37771 const QuicAckFrame& ack_frame,
[email protected]9db443912013-02-25 05:27:03772 QuicPacketSequenceNumber sequence_number);
773
774// Inserts missing packets between [lower, higher).
775void NET_EXPORT_PRIVATE InsertMissingPacketsBetween(
[email protected]310d37b2014-08-02 06:15:37776 QuicAckFrame* ack_frame,
[email protected]9db443912013-02-25 05:27:03777 QuicPacketSequenceNumber lower,
778 QuicPacketSequenceNumber higher);
779
[email protected]a692ad9d2014-07-18 21:35:24780// Defines for all types of congestion control algorithms that can be used in
781// QUIC. Note that this is separate from the congestion feedback type -
782// some congestion control algorithms may use the same feedback type
783// (Reno and Cubic are the classic example for that).
784enum CongestionControlType {
785 kCubic,
rtennetifb3fa6c2015-03-16 23:04:55786 kCubicBytes,
[email protected]a692ad9d2014-07-18 21:35:24787 kReno,
rtennetifb3fa6c2015-03-16 23:04:55788 kRenoBytes,
[email protected]a692ad9d2014-07-18 21:35:24789 kBBR,
[email protected]8b37a092012-10-18 21:53:49790};
791
[email protected]c5cc9bd2014-03-31 23:17:14792enum LossDetectionType {
793 kNack, // Used to mimic TCP's loss detection.
794 kTime, // Time based loss detection.
795};
796
[email protected]be24ab22012-10-22 03:01:52797struct NET_EXPORT_PRIVATE QuicRstStreamFrame {
[email protected]6ae6e342014-02-06 02:21:42798 QuicRstStreamFrame();
799 QuicRstStreamFrame(QuicStreamId stream_id,
800 QuicRstStreamErrorCode error_code,
801 QuicStreamOffset bytes_written);
[email protected]8b37a092012-10-18 21:53:49802
[email protected]c5e1aca2014-01-30 04:03:04803 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
804 std::ostream& os, const QuicRstStreamFrame& r);
805
[email protected]8b37a092012-10-18 21:53:49806 QuicStreamId stream_id;
[email protected]74bda142013-03-31 02:49:11807 QuicRstStreamErrorCode error_code;
rchc0815442015-04-18 13:29:46808 // Only used in versions <= QUIC_VERSION_24.
[email protected]431bb4fd2012-10-19 17:46:09809 std::string error_details;
[email protected]6ae6e342014-02-06 02:21:42810
811 // Used to update flow control windows. On termination of a stream, both
812 // endpoints must inform the peer of the number of bytes they have sent on
813 // that stream. This can be done through normal termination (data packet with
814 // FIN) or through a RST.
815 QuicStreamOffset byte_offset;
[email protected]8b37a092012-10-18 21:53:49816};
817
[email protected]be24ab22012-10-22 03:01:52818struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame {
[email protected]6ae6e342014-02-06 02:21:42819 QuicConnectionCloseFrame();
820
[email protected]c5e1aca2014-01-30 04:03:04821 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
822 std::ostream& os, const QuicConnectionCloseFrame& c);
823
[email protected]431bb4fd2012-10-19 17:46:09824 QuicErrorCode error_code;
[email protected]431bb4fd2012-10-19 17:46:09825 std::string error_details;
[email protected]8b37a092012-10-18 21:53:49826};
827
[email protected]9db443912013-02-25 05:27:03828struct NET_EXPORT_PRIVATE QuicGoAwayFrame {
[email protected]6ae6e342014-02-06 02:21:42829 QuicGoAwayFrame();
[email protected]9db443912013-02-25 05:27:03830 QuicGoAwayFrame(QuicErrorCode error_code,
831 QuicStreamId last_good_stream_id,
832 const std::string& reason);
833
[email protected]c5e1aca2014-01-30 04:03:04834 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
835 std::ostream& os, const QuicGoAwayFrame& g);
836
[email protected]9db443912013-02-25 05:27:03837 QuicErrorCode error_code;
838 QuicStreamId last_good_stream_id;
839 std::string reason_phrase;
840};
841
[email protected]6ae6e342014-02-06 02:21:42842// Flow control updates per-stream and at the connection levoel.
843// Based on SPDY's WINDOW_UPDATE frame, but uses an absolute byte offset rather
844// than a window delta.
845// TODO(rjshade): A possible future optimization is to make stream_id and
846// byte_offset variable length, similar to stream frames.
847struct NET_EXPORT_PRIVATE QuicWindowUpdateFrame {
848 QuicWindowUpdateFrame() {}
849 QuicWindowUpdateFrame(QuicStreamId stream_id, QuicStreamOffset byte_offset);
850
851 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
852 std::ostream& os, const QuicWindowUpdateFrame& w);
853
854 // The stream this frame applies to. 0 is a special case meaning the overall
855 // connection rather than a specific stream.
856 QuicStreamId stream_id;
857
858 // Byte offset in the stream or connection. The receiver of this frame must
859 // not send data which would result in this offset being exceeded.
860 QuicStreamOffset byte_offset;
861};
862
863// The BLOCKED frame is used to indicate to the remote endpoint that this
864// endpoint believes itself to be flow-control blocked but otherwise ready to
865// send data. The BLOCKED frame is purely advisory and optional.
866// Based on SPDY's BLOCKED frame (undocumented as of 2014-01-28).
867struct NET_EXPORT_PRIVATE QuicBlockedFrame {
868 QuicBlockedFrame() {}
869 explicit QuicBlockedFrame(QuicStreamId stream_id);
870
871 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
872 std::ostream& os, const QuicBlockedFrame& b);
873
874 // The stream this frame applies to. 0 is a special case meaning the overall
875 // connection rather than a specific stream.
876 QuicStreamId stream_id;
877};
878
[email protected]8ba81212013-05-03 13:11:48879// EncryptionLevel enumerates the stages of encryption that a QUIC connection
880// progresses through. When retransmitting a packet, the encryption level needs
881// to be specified so that it is retransmitted at a level which the peer can
882// understand.
883enum EncryptionLevel {
884 ENCRYPTION_NONE = 0,
885 ENCRYPTION_INITIAL = 1,
886 ENCRYPTION_FORWARD_SECURE = 2,
887
888 NUM_ENCRYPTION_LEVELS,
889};
890
[email protected]be24ab22012-10-22 03:01:52891struct NET_EXPORT_PRIVATE QuicFrame {
[email protected]6ae6e342014-02-06 02:21:42892 QuicFrame();
893 explicit QuicFrame(QuicPaddingFrame* padding_frame);
894 explicit QuicFrame(QuicStreamFrame* stream_frame);
895 explicit QuicFrame(QuicAckFrame* frame);
rtenneti69e64aa2015-06-26 04:25:30896 explicit QuicFrame(QuicMtuDiscoveryFrame* frame);
rtenneti4b06ae72014-08-26 03:43:43897
[email protected]6ae6e342014-02-06 02:21:42898 explicit QuicFrame(QuicRstStreamFrame* frame);
899 explicit QuicFrame(QuicConnectionCloseFrame* frame);
[email protected]93dd91f2014-02-27 00:09:03900 explicit QuicFrame(QuicStopWaitingFrame* frame);
[email protected]d8c522112014-04-23 09:23:25901 explicit QuicFrame(QuicPingFrame* frame);
[email protected]6ae6e342014-02-06 02:21:42902 explicit QuicFrame(QuicGoAwayFrame* frame);
903 explicit QuicFrame(QuicWindowUpdateFrame* frame);
904 explicit QuicFrame(QuicBlockedFrame* frame);
[email protected]8b37a092012-10-18 21:53:49905
[email protected]c5e1aca2014-01-30 04:03:04906 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
907 std::ostream& os, const QuicFrame& frame);
908
[email protected]be24ab22012-10-22 03:01:52909 QuicFrameType type;
[email protected]8b37a092012-10-18 21:53:49910 union {
[email protected]c995c572013-01-18 05:43:20911 QuicPaddingFrame* padding_frame;
[email protected]be24ab22012-10-22 03:01:52912 QuicStreamFrame* stream_frame;
913 QuicAckFrame* ack_frame;
rtenneti69e64aa2015-06-26 04:25:30914 QuicMtuDiscoveryFrame* mtu_discovery_frame;
rtenneti4b06ae72014-08-26 03:43:43915
[email protected]93dd91f2014-02-27 00:09:03916 QuicStopWaitingFrame* stop_waiting_frame;
rtenneti4b06ae72014-08-26 03:43:43917
[email protected]d8c522112014-04-23 09:23:25918 QuicPingFrame* ping_frame;
[email protected]be24ab22012-10-22 03:01:52919 QuicRstStreamFrame* rst_stream_frame;
920 QuicConnectionCloseFrame* connection_close_frame;
[email protected]9db443912013-02-25 05:27:03921 QuicGoAwayFrame* goaway_frame;
[email protected]6ae6e342014-02-06 02:21:42922 QuicWindowUpdateFrame* window_update_frame;
923 QuicBlockedFrame* blocked_frame;
[email protected]8b37a092012-10-18 21:53:49924 };
925};
926
[email protected]be24ab22012-10-22 03:01:52927typedef std::vector<QuicFrame> QuicFrames;
[email protected]8b37a092012-10-18 21:53:49928
929struct NET_EXPORT_PRIVATE QuicFecData {
930 QuicFecData();
[email protected]a5061242012-10-23 23:29:37931
[email protected]c995c572013-01-18 05:43:20932 // The FEC group number is also the sequence number of the first
933 // FEC protected packet. The last protected packet's sequence number will
934 // be one less than the sequence number of the FEC packet.
[email protected]8b37a092012-10-18 21:53:49935 QuicFecGroupNumber fec_group;
[email protected]8b37a092012-10-18 21:53:49936 base::StringPiece redundancy;
[email protected]8b37a092012-10-18 21:53:49937};
938
[email protected]8b37a092012-10-18 21:53:49939class NET_EXPORT_PRIVATE QuicData {
940 public:
[email protected]6ae6e342014-02-06 02:21:42941 QuicData(const char* buffer, size_t length);
942 QuicData(char* buffer, size_t length, bool owns_buffer);
[email protected]8b37a092012-10-18 21:53:49943 virtual ~QuicData();
944
945 base::StringPiece AsStringPiece() const {
946 return base::StringPiece(data(), length());
947 }
948
949 const char* data() const { return buffer_; }
950 size_t length() const { return length_; }
rtennetie0ee6eb2015-05-01 00:55:09951 bool owns_buffer() const { return owns_buffer_; }
[email protected]8b37a092012-10-18 21:53:49952
953 private:
954 const char* buffer_;
955 size_t length_;
956 bool owns_buffer_;
957
958 DISALLOW_COPY_AND_ASSIGN(QuicData);
959};
960
961class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
962 public:
rtennetica5ac272015-02-07 12:35:12963 QuicPacket(char* buffer,
964 size_t length,
965 bool owns_buffer,
966 QuicConnectionIdLength connection_id_length,
967 bool includes_version,
968 QuicSequenceNumberLength sequence_number_length);
[email protected]8b37a092012-10-18 21:53:49969
[email protected]5351cc4b2013-03-03 07:22:41970 base::StringPiece FecProtectedData() const;
971 base::StringPiece AssociatedData() const;
972 base::StringPiece BeforePlaintext() const;
973 base::StringPiece Plaintext() const;
[email protected]082b65b2012-11-10 19:11:31974
[email protected]8b37a092012-10-18 21:53:49975 char* mutable_data() { return buffer_; }
976
977 private:
978 char* buffer_;
[email protected]3aa9ca72014-02-27 19:39:43979 const QuicConnectionIdLength connection_id_length_;
[email protected]5351cc4b2013-03-03 07:22:41980 const bool includes_version_;
[email protected]25c31dc2013-06-05 17:56:04981 const QuicSequenceNumberLength sequence_number_length_;
[email protected]8b37a092012-10-18 21:53:49982
[email protected]2e740db2012-10-20 19:35:19983 DISALLOW_COPY_AND_ASSIGN(QuicPacket);
[email protected]8b37a092012-10-18 21:53:49984};
985
986class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData {
987 public:
[email protected]6ae6e342014-02-06 02:21:42988 QuicEncryptedPacket(const char* buffer, size_t length);
989 QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer);
[email protected]8b37a092012-10-18 21:53:49990
[email protected]ec86d5462013-11-17 16:04:49991 // Clones the packet into a new packet which owns the buffer.
992 QuicEncryptedPacket* Clone() const;
993
[email protected]c1b32c62013-01-20 02:49:10994 // By default, gtest prints the raw bytes of an object. The bool data
995 // member (in the base class QuicData) causes this object to have padding
996 // bytes, which causes the default gtest object printer to read
997 // uninitialize memory. So we need to teach gtest how to print this object.
998 NET_EXPORT_PRIVATE friend std::ostream& operator<<(
999 std::ostream& os, const QuicEncryptedPacket& s);
1000
[email protected]2e740db2012-10-20 19:35:191001 private:
1002 DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket);
[email protected]8b37a092012-10-18 21:53:491003};
1004
[email protected]9db443912013-02-25 05:27:031005class NET_EXPORT_PRIVATE RetransmittableFrames {
1006 public:
rtennetidc8e5a22015-02-25 01:38:521007 explicit RetransmittableFrames(EncryptionLevel level);
[email protected]9db443912013-02-25 05:27:031008 ~RetransmittableFrames();
1009
[email protected]9db443912013-02-25 05:27:031010 // Takes ownership of the frame inside |frame|.
rtennetia4228ea2015-06-04 02:31:441011 const QuicFrame& AddFrame(const QuicFrame& frame);
1012 // Takes ownership of the frame inside |frame| and |buffer|.
1013 const QuicFrame& AddFrame(const QuicFrame& frame, char* buffer);
rtenneti73e25c12015-03-16 06:12:431014 // Removes all stream frames associated with |stream_id|.
1015 void RemoveFramesForStream(QuicStreamId stream_id);
1016
[email protected]9db443912013-02-25 05:27:031017 const QuicFrames& frames() const { return frames_; }
1018
[email protected]672631c2014-08-16 06:11:451019 IsHandshake HasCryptoHandshake() const {
1020 return has_crypto_handshake_;
1021 }
[email protected]2115d33ba2014-01-02 21:53:521022
[email protected]8ba81212013-05-03 13:11:481023 EncryptionLevel encryption_level() const {
1024 return encryption_level_;
1025 }
1026
rtennetid7d78b02015-06-17 16:54:341027 bool needs_padding() const { return needs_padding_; }
1028
1029 void set_needs_padding(bool needs_padding) { needs_padding_ = needs_padding; }
1030
[email protected]9db443912013-02-25 05:27:031031 private:
1032 QuicFrames frames_;
rtennetidc8e5a22015-02-25 01:38:521033 const EncryptionLevel encryption_level_;
[email protected]672631c2014-08-16 06:11:451034 IsHandshake has_crypto_handshake_;
rtennetid7d78b02015-06-17 16:54:341035 bool needs_padding_;
rtennetic14c8ab2015-06-18 05:47:401036 // Data referenced by the StringPiece of a QuicStreamFrame.
rtennetia4228ea2015-06-04 02:31:441037 std::vector<const char*> stream_data_;
[email protected]9db443912013-02-25 05:27:031038
1039 DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames);
1040};
1041
1042struct NET_EXPORT_PRIVATE SerializedPacket {
1043 SerializedPacket(QuicPacketSequenceNumber sequence_number,
[email protected]ea825e02013-08-21 18:12:451044 QuicSequenceNumberLength sequence_number_length,
rtennetib6ac61a52015-02-11 20:20:521045 QuicEncryptedPacket* packet,
[email protected]9db443912013-02-25 05:27:031046 QuicPacketEntropyHash entropy_hash,
rtenneti9bd5d4b2015-08-21 05:44:521047 RetransmittableFrames* retransmittable_frames,
1048 bool has_ack,
1049 bool has_stop_waiting);
[email protected]97cf3022013-09-05 14:30:161050 ~SerializedPacket();
[email protected]9db443912013-02-25 05:27:031051
rtennetid39bd762015-06-12 01:05:521052 QuicEncryptedPacket* packet;
1053 RetransmittableFrames* retransmittable_frames;
[email protected]9db443912013-02-25 05:27:031054 QuicPacketSequenceNumber sequence_number;
[email protected]ea825e02013-08-21 18:12:451055 QuicSequenceNumberLength sequence_number_length;
[email protected]9db443912013-02-25 05:27:031056 QuicPacketEntropyHash entropy_hash;
rtennetica5ac272015-02-07 12:35:121057 bool is_fec_packet;
rtenneti9bd5d4b2015-08-21 05:44:521058 bool has_ack;
1059 bool has_stop_waiting;
[email protected]97cf3022013-09-05 14:30:161060
rtenneti6b1c5b12015-01-13 20:08:351061 // Optional notifiers which will be informed when this packet has been ACKed.
rtenneticf54a52c2015-01-26 17:01:541062 std::list<QuicAckNotifier*> notifiers;
[email protected]9db443912013-02-25 05:27:031063};
1064
[email protected]77b5d50b2014-05-07 22:48:481065struct NET_EXPORT_PRIVATE TransmissionInfo {
1066 // Used by STL when assigning into a map.
1067 TransmissionInfo();
1068
1069 // Constructs a Transmission with a new all_tranmissions set
1070 // containing |sequence_number|.
1071 TransmissionInfo(RetransmittableFrames* retransmittable_frames,
[email protected]77b5d50b2014-05-07 22:48:481072 QuicSequenceNumberLength sequence_number_length,
[email protected]730b35d72014-06-05 03:23:221073 TransmissionType transmission_type,
rtenneti3183ac42015-02-28 03:39:411074 QuicTime sent_time,
1075 QuicByteCount bytes_sent,
1076 bool is_fec_packet);
[email protected]77b5d50b2014-05-07 22:48:481077
1078 RetransmittableFrames* retransmittable_frames;
1079 QuicSequenceNumberLength sequence_number_length;
[email protected]77b5d50b2014-05-07 22:48:481080 QuicTime sent_time;
[email protected]77b5d50b2014-05-07 22:48:481081 QuicByteCount bytes_sent;
pkastinga9f22d4e2014-12-01 22:43:461082 QuicPacketCount nack_count;
[email protected]730b35d72014-06-05 03:23:221083 // Reason why this packet was transmitted.
1084 TransmissionType transmission_type;
[email protected]77b5d50b2014-05-07 22:48:481085 // Stores the sequence numbers of all transmissions of this packet.
rtennetibe635732014-10-02 22:51:421086 // Must always be nullptr or have multiple elements.
rtennetidd4bf8f2014-09-03 00:45:161087 SequenceNumberList* all_transmissions;
[email protected]aa7e4ef2014-05-28 03:53:151088 // In flight packets have not been abandoned or lost.
1089 bool in_flight;
rtenneti31e9fd62014-09-16 05:22:151090 // True if the packet can never be acked, so it can be removed.
1091 bool is_unackable;
rtenneti85d89712014-11-20 03:32:241092 // True if the packet is an FEC packet.
1093 bool is_fec_packet;
[email protected]77b5d50b2014-05-07 22:48:481094};
1095
rtennetic14c8ab2015-06-18 05:47:401096// Convenience wrapper to wrap an iovec array and the total length, which must
1097// be less than or equal to the actual total length of the iovecs.
1098struct NET_EXPORT_PRIVATE QuicIOVector {
1099 QuicIOVector(const struct iovec* iov, int iov_count, size_t total_length)
1100 : iov(iov), iov_count(iov_count), total_length(total_length) {}
1101
1102 const struct iovec* iov;
1103 const int iov_count;
1104 const size_t total_length;
1105};
1106
[email protected]8b37a092012-10-18 21:53:491107} // namespace net
1108
1109#endif // NET_QUIC_QUIC_PROTOCOL_H_