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