idnits 2.17.1 draft-ietf-quic-transport-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'SHOULD not' in this paragraph: To limit ACK blocks to those that have not yet been received by the sender, the receiver SHOULD track which ACK frames have been acknowledged by its peer. Once an ACK frame has been acknowledged, the packets it acknowledges SHOULD not be acknowledged again. To handle cases where the receiver is only sending ACK frames, and hence will not receive acknowledgments for its packets, it MAY send a PING frame at most once per RTT to explicitly request acknowledgment. -- The document date (March 13, 2017) is 2598 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '4' on line 372 -- Looks like a reference, but probably isn't: '1' on line 2933 == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-19 -- Possible downref: Non-RFC (?) normative reference: ref. 'QUIC-RECOVERY' -- Possible downref: Non-RFC (?) normative reference: ref. 'QUIC-TLS' ** Obsolete normative reference: RFC 1981 (Obsoleted by RFC 8201) ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) -- Obsolete informational reference (is this intentional?): RFC 6824 (Obsoleted by RFC 8684) -- Obsolete informational reference (is this intentional?): RFC 7540 (Obsoleted by RFC 9113) Summary: 3 errors (**), 0 flaws (~~), 4 warnings (==), 8 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 QUIC J. Iyengar, Ed. 3 Internet-Draft Google 4 Intended status: Standards Track M. Thomson, Ed. 5 Expires: September 14, 2017 Mozilla 6 March 13, 2017 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-02 11 Abstract 13 This document defines the core of the QUIC transport protocol. This 14 document describes connection establishment, packet format, 15 multiplexing and reliability. Accompanying documents describe the 16 cryptographic handshake and loss detection. 18 Note to Readers 20 Discussion of this draft takes place on the QUIC working group 21 mailing list (quic@ietf.org), which is archived at 22 https://mailarchive.ietf.org/arch/search/?email_list=quic . 24 Working Group information can be found at https://github.com/quicwg ; 25 source code and issues list for this draft can be found at 26 https://github.com/quicwg/base-drafts/labels/transport . 28 Status of This Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at http://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on September 14, 2017. 45 Copyright Notice 47 Copyright (c) 2017 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents 52 (http://trustee.ietf.org/license-info) in effect on the date of 53 publication of this document. Please review these documents 54 carefully, as they describe your rights and restrictions with respect 55 to this document. Code Components extracted from this document must 56 include Simplified BSD License text as described in Section 4.e of 57 the Trust Legal Provisions and are provided without warranty as 58 described in the Simplified BSD License. 60 Table of Contents 62 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 63 2. Conventions and Definitions . . . . . . . . . . . . . . . . . 4 64 2.1. Notational Conventions . . . . . . . . . . . . . . . . . 5 65 3. A QUIC Overview . . . . . . . . . . . . . . . . . . . . . . . 5 66 3.1. Low-Latency Connection Establishment . . . . . . . . . . 6 67 3.2. Stream Multiplexing . . . . . . . . . . . . . . . . . . . 6 68 3.3. Rich Signaling for Congestion Control and Loss Recovery . 6 69 3.4. Stream and Connection Flow Control . . . . . . . . . . . 6 70 3.5. Authenticated and Encrypted Header and Payload . . . . . 7 71 3.6. Connection Migration and Resilience to NAT Rebinding . . 7 72 3.7. Version Negotiation . . . . . . . . . . . . . . . . . . . 8 73 4. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 8 74 5. Packet Types and Formats . . . . . . . . . . . . . . . . . . 8 75 5.1. Long Header . . . . . . . . . . . . . . . . . . . . . . . 9 76 5.2. Short Header . . . . . . . . . . . . . . . . . . . . . . 11 77 5.3. Version Negotiation Packet . . . . . . . . . . . . . . . 12 78 5.4. Cleartext Packets . . . . . . . . . . . . . . . . . . . . 13 79 5.5. Encrypted Packets . . . . . . . . . . . . . . . . . . . . 14 80 5.6. Public Reset Packet . . . . . . . . . . . . . . . . . . . 15 81 5.6.1. Public Reset Proof . . . . . . . . . . . . . . . . . 15 82 5.7. Connection ID . . . . . . . . . . . . . . . . . . . . . . 16 83 5.8. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 16 84 5.8.1. Initial Packet Number . . . . . . . . . . . . . . . . 17 85 5.9. Handling Packets from Different Versions . . . . . . . . 17 86 6. Frames and Frame Types . . . . . . . . . . . . . . . . . . . 18 87 7. Life of a Connection . . . . . . . . . . . . . . . . . . . . 19 88 7.1. Version Negotiation . . . . . . . . . . . . . . . . . . . 19 89 7.1.1. Using Reserved Versions . . . . . . . . . . . . . . . 20 90 7.2. Cryptographic and Transport Handshake . . . . . . . . . . 21 91 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 22 92 7.3.1. Transport Parameter Definitions . . . . . . . . . . . 24 93 7.3.2. Values of Transport Parameters for 0-RTT . . . . . . 24 94 7.3.3. New Transport Parameters . . . . . . . . . . . . . . 25 95 7.3.4. Version Negotiation Validation . . . . . . . . . . . 25 96 7.4. Proof of Source Address Ownership . . . . . . . . . . . . 27 97 7.4.1. Client Address Validation Procedure . . . . . . . . . 27 98 7.4.2. Address Validation on Session Resumption . . . . . . 28 99 7.4.3. Address Validation Token Integrity . . . . . . . . . 29 100 7.5. Connection Migration . . . . . . . . . . . . . . . . . . 29 101 7.6. Connection Termination . . . . . . . . . . . . . . . . . 30 102 8. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 31 103 8.1. STREAM Frame . . . . . . . . . . . . . . . . . . . . . . 31 104 8.2. ACK Frame . . . . . . . . . . . . . . . . . . . . . . . . 32 105 8.2.1. ACK Block Section . . . . . . . . . . . . . . . . . . 34 106 8.2.2. Timestamp Section . . . . . . . . . . . . . . . . . . 35 107 8.2.3. ACK Frames and Packet Protection . . . . . . . . . . 37 108 8.3. WINDOW_UPDATE Frame . . . . . . . . . . . . . . . . . . . 38 109 8.4. BLOCKED Frame . . . . . . . . . . . . . . . . . . . . . . 39 110 8.5. RST_STREAM Frame . . . . . . . . . . . . . . . . . . . . 39 111 8.6. PADDING Frame . . . . . . . . . . . . . . . . . . . . . . 40 112 8.7. PING frame . . . . . . . . . . . . . . . . . . . . . . . 40 113 8.8. CONNECTION_CLOSE frame . . . . . . . . . . . . . . . . . 40 114 8.9. GOAWAY Frame . . . . . . . . . . . . . . . . . . . . . . 41 115 9. Packetization and Reliability . . . . . . . . . . . . . . . . 42 116 9.1. Special Considerations for PMTU Discovery . . . . . . . . 44 117 10. Streams: QUIC's Data Structuring Abstraction . . . . . . . . 45 118 10.1. Life of a Stream . . . . . . . . . . . . . . . . . . . . 45 119 10.1.1. idle . . . . . . . . . . . . . . . . . . . . . . . . 47 120 10.1.2. open . . . . . . . . . . . . . . . . . . . . . . . . 47 121 10.1.3. half-closed (local) . . . . . . . . . . . . . . . . 48 122 10.1.4. half-closed (remote) . . . . . . . . . . . . . . . . 48 123 10.1.5. closed . . . . . . . . . . . . . . . . . . . . . . . 48 124 10.2. Stream Identifiers . . . . . . . . . . . . . . . . . . . 50 125 10.3. Stream Concurrency . . . . . . . . . . . . . . . . . . . 50 126 10.4. Sending and Receiving Data . . . . . . . . . . . . . . . 51 127 10.5. Stream Prioritization . . . . . . . . . . . . . . . . . 51 128 11. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 52 129 11.1. Edge Cases and Other Considerations . . . . . . . . . . 54 130 11.1.1. Mid-stream RST_STREAM . . . . . . . . . . . . . . . 54 131 11.1.2. Response to a RST_STREAM . . . . . . . . . . . . . . 54 132 11.1.3. Offset Increment . . . . . . . . . . . . . . . . . . 54 133 11.1.4. BLOCKED frames . . . . . . . . . . . . . . . . . . . 55 134 12. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 55 135 12.1. Connection Errors . . . . . . . . . . . . . . . . . . . 55 136 12.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 56 137 12.3. Error Codes . . . . . . . . . . . . . . . . . . . . . . 56 138 13. Security and Privacy Considerations . . . . . . . . . . . . . 60 139 13.1. Spoofed ACK Attack . . . . . . . . . . . . . . . . . . . 60 140 14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 61 141 14.1. QUIC Transport Parameter Registry . . . . . . . . . . . 61 142 15. References . . . . . . . . . . . . . . . . . . . . . . . . . 62 143 15.1. Normative References . . . . . . . . . . . . . . . . . . 62 144 15.2. Informative References . . . . . . . . . . . . . . . . . 63 145 15.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 64 146 Appendix A. Contributors . . . . . . . . . . . . . . . . . . . . 64 147 Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 64 148 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 64 149 C.1. Since draft-ietf-quic-transport-01: . . . . . . . . . . . 64 150 C.2. Since draft-ietf-quic-transport-00: . . . . . . . . . . . 66 151 C.3. Since draft-hamilton-quic-transport-protocol-01: . . . . 67 152 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 67 154 1. Introduction 156 QUIC is a multiplexed and secure transport protocol that runs on top 157 of UDP. QUIC aims to provide a flexible set of features that allow 158 it to be a general-purpose transport for multiple applications. 160 QUIC implements techniques learned from experience with TCP, SCTP and 161 other transport protocols. Using UDP as the substrate, QUIC seeks to 162 be compatible with legacy clients and middleboxes. QUIC 163 authenticates all of its headers and encrypts most of the data it 164 exchanges, including its signaling. This allows the protocol to 165 evolve without incurring a dependency on upgrades to middleboxes. 167 This document describes the core QUIC protocol, including the 168 conceptual design, wire format, and mechanisms of the QUIC protocol 169 for connection establishment, stream multiplexing, stream and 170 connection-level flow control, and data reliability. 172 Accompanying documents describe QUIC's loss detection and congestion 173 control [QUIC-RECOVERY], and the use of TLS 1.3 for key negotiation 174 [QUIC-TLS]. 176 2. Conventions and Definitions 178 The words "MUST", "MUST NOT", "SHOULD", and "MAY" are used in this 179 document. It's not shouting; when they are capitalized, they have 180 the special meaning defined in [RFC2119]. 182 Definitions of terms that are used in this document: 184 Client: The endpoint initiating a QUIC connection. 186 Server: The endpoint accepting incoming QUIC connections. 188 Endpoint: The client or server end of a connection. 190 Stream: A logical, bi-directional channel of ordered bytes within a 191 QUIC connection. 193 Connection: A conversation between two QUIC endpoints with a single 194 encryption context that multiplexes streams within it. 196 Connection ID: The identifier for a QUIC connection. 198 QUIC packet: A well-formed UDP payload that can be parsed by a QUIC 199 receiver. QUIC packet size in this document refers to the UDP 200 payload size. 202 2.1. Notational Conventions 204 Packet and frame diagrams use the format described in [RFC2360] 205 Section 3.1, with the following additional conventions: 207 [x] Indicates that x is optional 209 {x} Indicates that x is encrypted 211 x (A) Indicates that x is A bits long 213 x (A/B/C) ... Indicates that x is one of A, B, or C bits long 215 x (*) ... Indicates that x is variable-length 217 3. A QUIC Overview 219 This section briefly describes QUIC's key mechanisms and benefits. 220 Key strengths of QUIC include: 222 o Low-latency connection establishment 224 o Multiplexing without head-of-line blocking 226 o Authenticated and encrypted header and payload 228 o Rich signaling for congestion control and loss recovery 230 o Stream and connection flow control 232 o Connection migration and resilience to NAT rebinding 234 o Version negotiation 236 3.1. Low-Latency Connection Establishment 238 QUIC relies on a combined cryptographic and transport handshake for 239 setting up a secure transport connection. QUIC connections are 240 expected to commonly use 0-RTT handshakes, meaning that for most QUIC 241 connections, data can be sent immediately following the client 242 handshake packet, without waiting for a reply from the server. QUIC 243 provides a dedicated stream (Stream ID 1) to be used for performing 244 the cryptographic handshake and QUIC options negotiation. The format 245 of the QUIC options and parameters used during negotiation are 246 described in this document, but the handshake protocol that runs on 247 Stream ID 1 is described in the accompanying cryptographic handshake 248 draft [QUIC-TLS]. 250 3.2. Stream Multiplexing 252 When application messages are transported over TCP, independent 253 application messages can suffer from head-of-line blocking. When an 254 application multiplexes many streams atop TCP's single-bytestream 255 abstraction, a loss of a TCP segment results in blocking of all 256 subsequent segments until a retransmission arrives, irrespective of 257 the application streams that are encapsulated in subsequent segments. 258 QUIC ensures that lost packets carrying data for an individual stream 259 only impact that specific stream. Data received on other streams can 260 continue to be reassembled and delivered to the application. 262 3.3. Rich Signaling for Congestion Control and Loss Recovery 264 QUIC's packet framing and acknowledgments carry rich information that 265 help both congestion control and loss recovery in fundamental ways. 266 Each QUIC packet carries a new packet number, including those 267 carrying retransmitted data. This obviates the need for a separate 268 mechanism to distinguish acknowledgments for retransmissions from 269 those for original transmissions, avoiding TCP's retransmission 270 ambiguity problem. QUIC acknowledgments also explicitly encode the 271 delay between the receipt of a packet and its acknowledgment being 272 sent, and together with the monotonically-increasing packet numbers, 273 this allows for precise network roundtrip-time (RTT) calculation. 274 QUIC's ACK frames support up to 256 ACK blocks, so QUIC is more 275 resilient to reordering than TCP with SACK support, as well as able 276 to keep more bytes on the wire when there is reordering or loss. 278 3.4. Stream and Connection Flow Control 280 QUIC implements stream- and connection-level flow control, closely 281 following HTTP/2's flow control mechanisms. At a high level, a QUIC 282 receiver advertises the absolute byte offset within each stream up to 283 which the receiver is willing to receive data. As data is sent, 284 received, and delivered on a particular stream, the receiver sends 285 WINDOW_UPDATE frames that increase the advertised offset limit for 286 that stream, allowing the peer to send more data on that stream. In 287 addition to this stream-level flow control, QUIC implements 288 connection-level flow control to limit the aggregate buffer that a 289 QUIC receiver is willing to allocate to all streams on a connection. 290 Connection-level flow control works in the same way as stream-level 291 flow control, but the bytes delivered and highest received offset are 292 all aggregates across all streams. 294 3.5. Authenticated and Encrypted Header and Payload 296 TCP headers appear in plaintext on the wire and are not 297 authenticated, causing a plethora of injection and header 298 manipulation issues for TCP, such as receive-window manipulation and 299 sequence-number overwriting. While some of these are mechanisms used 300 by middleboxes to improve TCP performance, others are active attacks. 301 Even "performance-enhancing" middleboxes that routinely interpose on 302 the transport state machine end up limiting the evolvability of the 303 transport protocol, as has been observed in the design of MPTCP 304 [RFC6824] and in its subsequent deployability issues. 306 Generally, QUIC packets are always authenticated and the payload is 307 typically fully encrypted. The parts of the packet header which are 308 not encrypted are still authenticated by the receiver, so as to 309 thwart any packet injection or manipulation by third parties. Some 310 early handshake packets, such as the Version Negotiation packet, are 311 not encrypted, but information sent in these unencrypted handshake 312 packets is later verified as part of cryptographic processing. 314 PUBLIC_RESET packets that reset a connection are currently not 315 authenticated. 317 3.6. Connection Migration and Resilience to NAT Rebinding 319 QUIC connections are identified by a 64-bit Connection ID, randomly 320 generated by the client. QUIC's consistent connection ID allows 321 connections to survive changes to the client's IP and port, such as 322 those caused by NAT rebindings or by the client changing network 323 connectivity to a new address. QUIC provides automatic cryptographic 324 verification of a rebound client, since the client continues to use 325 the same session key for encrypting and decrypting packets. The 326 consistent connection ID can be used to allow migration of the 327 connection to a new server IP address as well, since the Connection 328 ID remains consistent across changes in the client's and the server's 329 network addresses. 331 3.7. Version Negotiation 333 QUIC version negotiation allows for multiple versions of the protocol 334 to be deployed and used concurrently. Version negotiation is 335 described in Section 7.1. 337 4. Versions 339 QUIC versions are identified using a 32-bit value. 341 The version 0x00000000 is reserved to represent an invalid version. 342 This version of the specification is identified by the number 343 0x00000001. 345 Versions with the most significant 16 bits of the version number 346 cleared are reserved for use in future IETF consensus documents. 348 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 349 forcing version negotiation to be exercised. That is, any version 350 number where the low four bits of all octets is 1010 (in binary). A 351 client or server MAY advertise support for any of these reserved 352 versions. 354 Reserved version numbers will probably never represent a real 355 protocol; a client MAY use one of these version numbers with the 356 expectation that the server will initiate version negotiation; a 357 server MAY advertise support for one of these versions and can expect 358 that clients ignore the value. 360 [[RFC editor: please remove the remainder of this section before 361 publication.]] 363 The version number for the final version of this specification 364 (0x00000001), is reserved for the version of the protocol that is 365 published as an RFC. 367 Version numbers used to identify IETF drafts are created by adding 368 the draft number to 0xff000000. For example, draft-ietf-quic- 369 transport-13 would be identified as 0xff00000D. 371 Implementors are encouraged to register version numbers of QUIC that 372 they are using for private experimentation on the github wiki [4]. 374 5. Packet Types and Formats 376 We first describe QUIC's packet types and their formats, since some 377 are referenced in subsequent mechanisms. 379 All numeric values are encoded in network byte order (that is, big- 380 endian) and all field sizes are in bits. When discussing individual 381 bits of fields, the least significant bit is referred to as bit 0. 382 Hexadecimal notation is used for describing the value of fields. 384 Any QUIC packet has either a long or a short header, as indicated by 385 the Header Form bit. Long headers are expected to be used early in 386 the connection before version negotiation and establishment of 1-RTT 387 keys, and for public resets. Short headers are minimal version- 388 specific headers, which can be used after version negotiation and 389 1-RTT keys are established. 391 5.1. Long Header 393 0 1 2 3 394 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 395 +-+-+-+-+-+-+-+-+ 396 |1| Type (7) | 397 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 398 | | 399 + Connection ID (64) + 400 | | 401 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 402 | Packet Number (32) | 403 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 404 | Version (32) | 405 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 406 | Payload (*) ... 407 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 409 Figure 1: Long Header Format 411 Long headers are used for packets that are sent prior to the 412 completion of version negotiation and establishment of 1-RTT keys. 413 Once both conditions are met, a sender SHOULD switch to sending 414 short-form headers. While inefficient, long headers MAY be used for 415 packets encrypted with 1-RTT keys. The long form allows for special 416 packets, such as the Version Negotiation and the Public Reset packets 417 to be represented in this uniform fixed-length packet format. A long 418 header contains the following fields: 420 Header Form: The most significant bit (0x80) of the first octet is 421 set to 1 for long headers and 0 for short headers. 423 Long Packet Type: The remaining seven bits of first octet of a long 424 packet is the packet type. This field can indicate one of 128 425 packet types. The types specified for this version are listed in 426 Table 1. 428 Connection ID: Octets 1 through 8 contain the connection ID. 429 Section 5.7 describes the use of this field in more detail. 431 Packet Number: Octets 9 to 12 contain the packet number. {{packet- 432 numbers} describes the use of packet numbers. 434 Version: Octets 13 to 16 contain the selected protocol version. 435 This field indicates which version of QUIC is in use and 436 determines how the rest of the protocol fields are interpreted. 438 Payload: Octets from 17 onwards (the rest of QUIC packet) are the 439 payload of the packet. 441 The following packet types are defined: 443 +------+-------------------------------+-------------+ 444 | Type | Name | Section | 445 +------+-------------------------------+-------------+ 446 | 01 | Version Negotiation | Section 5.3 | 447 | | | | 448 | 02 | Client Cleartext | Section 5.4 | 449 | | | | 450 | 03 | Non-Final Server Cleartext | Section 5.4 | 451 | | | | 452 | 04 | Final Server Cleartext | Section 5.4 | 453 | | | | 454 | 05 | 0-RTT Encrypted | Section 5.5 | 455 | | | | 456 | 06 | 1-RTT Encrypted (key phase 0) | Section 5.5 | 457 | | | | 458 | 07 | 1-RTT Encrypted (key phase 1) | Section 5.5 | 459 | | | | 460 | 08 | Public Reset | Section 5.6 | 461 +------+-------------------------------+-------------+ 463 Table 1: Long Header Packet Types 465 The header form, packet type, connection ID, packet number and 466 version fields of a long header packet are version-independent. The 467 types of packets defined in Table 1 are version-specific. See 468 Section 5.9 for details on how packets from different versions of 469 QUIC are interpreted. 471 (TODO: Should the list of packet types be version-independent?) 473 The interpretation of the fields and the payload are specific to a 474 version and packet type. Type-specific semantics for this version 475 are described in Section 5.3, Section 5.6, Section 5.4, and 476 Section 5.5. 478 5.2. Short Header 480 0 1 2 3 481 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 482 +-+-+-+-+-+-+-+-+ 483 |0|C|K| Type (5)| 484 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 485 | | 486 + [Connection ID (64)] + 487 | | 488 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 489 | Packet Number (8/16/32) ... 490 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 491 | Encrypted Payload (*) ... 492 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 494 Figure 2: Short Header Format 496 The short header can be used after the version and 1-RTT keys are 497 negotiated. This header form has the following fields: 499 Header Form: The most significant bit (0x80) of the first octet of a 500 packet is the header form. This bit is set to 0 for the short 501 header. 503 Connection ID Flag: The second bit (0x40) of the first octet 504 indicates whether the Connection ID field is present. If set to 505 1, then the Connection ID field is present; if set to 0, the 506 Connection ID field is omitted. 508 Key Phase Bit: The third bit (0x20) of the first octet indicates the 509 key phase, which allows a recipient of a packet to identify the 510 packet protection keys that are used to protect the packet. See 511 [QUIC-TLS] for details. 513 Short Packet Type: The remaining 5 bits of the first octet include 514 one of 32 packet types. Table 2 lists the types that are defined 515 for short packets. 517 Connection ID: If the Connection ID Flag is set, a connection ID 518 occupies octets 1 through 8 of the packet. See Section 5.7 for 519 more details. 521 Packet Number: The length of the packet number field depends on the 522 packet type. This field can be 1, 2 or 4 octets long depending on 523 the short packet type. 525 Encrypted Payload: Packets with a short header always include a 526 1-RTT protected payload. 528 The packet type in a short header currently determines only the size 529 of the packet number field. Additional types can be used to signal 530 the presence of other fields. 532 +------+--------------------+ 533 | Type | Packet Number Size | 534 +------+--------------------+ 535 | 01 | 1 octet | 536 | | | 537 | 02 | 2 octets | 538 | | | 539 | 03 | 4 octets | 540 +------+--------------------+ 542 Table 2: Short Header Packet Types 544 The header form, connection ID flag and connection ID of a short 545 header packet are version-independent. The remaining fields are 546 specific to the selected QUIC version. See Section 5.9 for details 547 on how packets from different versions of QUIC are interpreted. 549 5.3. Version Negotiation Packet 551 A Version Negotiation packet is sent only by servers and is a 552 response to a client packet of an unsupported version. It uses a 553 long header and contains: 555 o Octet 0: 0x81 557 o Octets 1-8: Connection ID (echoed) 559 o Octets 9-12: Packet Number (echoed) 561 o Octets 13-16: Version (echoed) 563 o Octets 17+: Payload 565 The payload of the Version Negotiation packet is a list of 32-bit 566 versions which the server supports, as shown below. 568 0 1 2 3 569 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 570 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 571 | Supported Version 1 (32) ... 572 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 573 | [Supported Version 2 (32)] ... 574 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 575 ... 576 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 577 | [Supported Version N (32)] ... 578 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 580 Figure 3: Version Negotiation Packet 582 See Section 7.1 for a description of the version negotiation process. 584 5.4. Cleartext Packets 586 Cleartext packets are sent during the handshake prior to key 587 negotiation. A Client Cleartext packet contains: 589 o Octet 0: 0x82 591 o Octets 1-8: Connection ID (initial) 593 o Octets 9-12: Packet number 595 o Octets 13-16: Version 597 o Octets 17+: Payload 599 Non-Final Server Cleartext packets contain: 601 o Octet 0: 0x83 603 o Octets 1-8: Connection ID (echoed) 605 o Octets 9-12: Packet Number 607 o Octets 13-16: Version 609 o Octets 17+: Payload 611 Final Server Cleartext packets contains: 613 o Octet 0: 0x84 615 o Octets 1-8: Connection ID (final) 616 o Octets 9-12: Packet Number 618 o Octets 13-16: Version 620 o Octets 17+: Payload 622 The client MUST choose a random 64-bit value and use it as the 623 initial Connection ID in all packets until the server replies with 624 the final Connection ID. The server echoes the client's Connection 625 ID in Non-Final Server Cleartext packets. The first Final Server 626 Cleartext and all subsequent packets MUST use the final Connection 627 ID, as described in Section 5.7. 629 The payload of a Cleartext packet consists of a sequence of frames, 630 as described in Section 6. 632 (TODO: Add hash before frames.) 634 5.5. Encrypted Packets 636 Packets encrypted with either 0-RTT or 1-RTT keys may be sent with 637 long headers. Different packet types explicitly indicate the 638 encryption level for ease of decryption. These packets contain: 640 o Octet 0: 0x85, 0x86 or 0x87 642 o Octets 1-8: Connection ID (initial or final) 644 o Octets 9-12: Packet Number 646 o Octets 13-16: Version 648 o Octets 17+: Encrypted Payload 650 A first octet of 0x85 indicates a 0-RTT packet. After the 1-RTT keys 651 are established, key phases are used by the QUIC packet protection to 652 identify the correct packet protection keys. The initial key phase 653 is 0. See [QUIC-TLS] for more details. 655 The encrypted payload is both authenticated and encrypted using 656 packet protection keys. [QUIC-TLS] describes packet protection in 657 detail. After decryption, the plaintext consists of a sequence of 658 frames, as described in Section 6. 660 5.6. Public Reset Packet 662 A Public Reset packet is only sent by servers and is used to abruptly 663 terminate communications. Public Reset is provided as an option of 664 last resort for a server that does not have access to the state of a 665 connection. This is intended for use by a server that has lost state 666 (for example, through a crash or outage). A server that wishes to 667 communicate a fatal connection error MUST use a CONNECTION_CLOSE 668 frame if it has sufficient state to do so. 670 A Public Reset packet contains: 672 o Octet 0: 0x88 674 o Octets 1-8: Echoed data (octets 1-8 of received packet) 676 o Octets 9-12: Echoed data (octets 9-12 of received packet) 678 o Octets 13-16: Version 680 o Octets 17+: Public Reset Proof 682 For a client that sends a connection ID on every packet, the 683 Connection ID field is simply an echo of the initial Connection ID, 684 and the Packet Number field includes an echo of the client's packet 685 number (and, depending on the client's packet number length, 0, 2, or 686 3 additional octets from the client's packet). 688 A Public Reset packet sent by a server indicates that it does not 689 have the state necessary to continue with a connection. In this 690 case, the server will include the fields that prove that it 691 originally participated in the connection (see Section 5.6.1 for 692 details). 694 Upon receipt of a Public Reset packet that contains a valid proof, a 695 client MUST tear down state associated with the connection. The 696 client MUST then cease sending packets on the connection and SHOULD 697 discard any subsequent packets that arrive. A Public Reset that does 698 not contain a valid proof MUST be ignored. 700 5.6.1. Public Reset Proof 702 TODO: Details to be added. 704 5.7. Connection ID 706 QUIC connections are identified by their 64-bit Connection ID. All 707 long headers contain a Connection ID. Short headers indicate the 708 presence of a Connection ID using the CONNECTION_ID flag. When 709 present, the Connection ID is in the same location in all packet 710 headers, making it straightforward for middleboxes, such as load 711 balancers, to locate and use it. 713 When a connection is initiated, the client MUST choose a random value 714 and use it as the initial Connection ID until the final value is 715 available. The initial Connection ID is a suggestion to the server. 716 The server echoes this value in all packets until the handshake is 717 successful (see [QUIC-TLS]). On a successful handshake, the server 718 MUST select the final Connection ID for the connection and use it in 719 Final Server Cleartext packets. This final Connection ID MAY be the 720 one proposed by the client or MAY be a new server-selected value. 721 All subsequent packets from the server MUST contain this value. On 722 handshake completion, the client MUST switch to using the final 723 Connection ID for all subsequent packets. 725 Thus, all Client Cleartext packets, 0-RTT Encrypted packets, and Non- 726 Final Server Cleartext packets MUST use the client's randomly- 727 generated initial Connection ID. Final Server Cleartext packets, 728 1-RTT Encrypted packets, and all short-header packets MUST use the 729 final Connection ID. 731 5.8. Packet Numbers 733 The packet number is a 64-bit unsigned number and is used as part of 734 a cryptographic nonce for packet encryption. Each endpoint maintains 735 a separate packet number for sending and receiving. The packet 736 number for sending MUST increase by at least one after sending any 737 packet. 739 A QUIC endpoint MUST NOT reuse a packet number within the same 740 connection (that is, under the same cryptographic keys). If the 741 packet number for sending reaches 2^64 - 1, the sender MUST close the 742 connection by sending a CONNECTION_CLOSE frame with the error code 743 QUIC_SEQUENCE_NUMBER_LIMIT_REACHED (connection termination is 744 described in Section 7.6.) 746 To reduce the number of bits required to represent the packet number 747 over the wire, only the least significant bits of the packet number 748 are transmitted over the wire, up to 32 bits. The actual packet 749 number for each packet is reconstructed at the receiver based on the 750 largest packet number received on a successfully authenticated 751 packet. 753 A packet number is decoded by finding the packet number value that is 754 closest to the next expected packet. The next expected packet is the 755 highest received packet number plus one. For example, if the highest 756 successfully authenticated packet had a packet number of 0xaa82f30e, 757 then a packet containing a 16-bit value of 0x1f94 will be decoded as 758 0xaa831f94. 760 The sender MUST use a packet number size able to represent more than 761 twice as large a range than the difference between the largest 762 acknowledged packet and packet number being sent. A peer receiving 763 the packet will then correctly decode the packet number, unless the 764 packet is delayed in transit such that it arrives after many higher- 765 numbered packets have been received. An endpoint MAY use a larger 766 packet number size to safeguard against such reordering. 768 As a result, the size of the packet number encoding is at least one 769 more than the base 2 logarithm of the number of contiguous 770 unacknowledged packet numbers, including the new packet. 772 For example, if an endpoint has received an acknowledgment for packet 773 0x6afa2f, sending a packet with a number of 0x6b4264 requires a 774 16-bit or larger packet number encoding; whereas a 32-bit packet 775 number is needed to send a packet with a number of 0x6bc107. 777 5.8.1. Initial Packet Number 779 The initial value for packet number MUST be a 31-bit random number. 780 That is, the value is selected from an uniform random distribution 781 between 0 and 2^31-1. [RFC4086] provides guidance on the generation 782 of random values. 784 The first set of packets sent by an endpoint MUST include the low 785 32-bits of the packet number. Once any packet has been acknowledged, 786 subsequent packets can use a shorter packet number encoding. 788 5.9. Handling Packets from Different Versions 790 Between different versions the following things are guaranteed to 791 remain constant: 793 o the location of the header form flag, 795 o the location of the Connection ID flag in short headers, 797 o the location and size of the Connection ID field in both header 798 forms, 800 o the location and size of the Version field in long headers, and 801 o the location and size of the Packet Number field in long headers. 803 Implementations MUST assume that an unsupported version uses an 804 unknown packet format. All other fields MUST be ignored when 805 processing a packet that contains an unsupported version. 807 6. Frames and Frame Types 809 The payload of cleartext packets and the plaintext after decryption 810 of encrypted payloads consists of a sequence of frames, as shown in 811 Figure 4. 813 0 1 2 3 814 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 815 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 816 | Frame 1 (*) ... 817 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 818 | Frame 2 (*) ... 819 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 820 ... 821 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 822 | Frame N (*) ... 823 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 825 Figure 4: Contents of Encrypted Payload 827 Encrypted payloads MUST contain at least one frame, and MAY contain 828 multiple frames and multiple frame types. 830 Frames MUST fit within a single QUIC packet and MUST NOT span a QUIC 831 packet boundary. Each frame begins with a Frame Type byte, 832 indicating its type, followed by additional type-dependent fields: 834 0 1 2 3 835 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 836 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 837 | Type (8) | Type-Dependent Fields (*) ... 838 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 840 Figure 5: Generic Frame Layout 842 Frame types are listed in Table 3. Note that the Frame Type byte in 843 STREAM and ACK frames is used to carry other frame-specific flags. 844 For all other frames, the Frame Type byte simply identifies the 845 frame. These frames are explained in more detail as they are 846 referenced later in the document. 848 +------------------+------------------+-------------+ 849 | Type-field value | Frame type | Definition | 850 +------------------+------------------+-------------+ 851 | 0x00 | PADDING | Section 8.6 | 852 | | | | 853 | 0x01 | RST_STREAM | Section 8.5 | 854 | | | | 855 | 0x02 | CONNECTION_CLOSE | Section 8.8 | 856 | | | | 857 | 0x03 | GOAWAY | Section 8.9 | 858 | | | | 859 | 0x04 | WINDOW_UPDATE | Section 8.3 | 860 | | | | 861 | 0x05 | BLOCKED | Section 8.4 | 862 | | | | 863 | 0x07 | PING | Section 8.7 | 864 | | | | 865 | 0x40 - 0x7f | ACK | Section 8.2 | 866 | | | | 867 | 0x80 - 0xff | STREAM | Section 8.1 | 868 +------------------+------------------+-------------+ 870 Table 3: Frame Types 872 7. Life of a Connection 874 A QUIC connection is a single conversation between two QUIC 875 endpoints. QUIC's connection establishment intertwines version 876 negotiation with the cryptographic and transport handshakes to reduce 877 connection establishment latency, as described in Section 7.2. Once 878 established, a connection may migrate to a different IP or port at 879 either endpoint, due to NAT rebinding or mobility, as described in 880 Section 7.5. Finally a connection may be terminated by either 881 endpoint, as described in Section 7.6. 883 7.1. Version Negotiation 885 QUIC's connection establishment begins with version negotiation, 886 since all communication between the endpoints, including packet and 887 frame formats, relies on the two endpoints agreeing on a version. 889 A QUIC connection begins with a client sending a handshake packet. 890 The details of the handshake mechanisms are described in Section 7.2, 891 but all of the initial packets sent from the client to the server 892 MUST use the long header format and MUST specify the version of the 893 protocol being used. 895 When the server receives a packet from a client with the long header 896 format, it compares the client's version to the versions it supports. 898 If the version selected by the client is not acceptable to the 899 server, the server discards the incoming packet and responds with a 900 Version Negotiation packet (Section 5.3). This includes a list of 901 versions that the server will accept. A server MUST send a Version 902 Negotiation packet for every packet that it receives with an 903 unacceptable version. 905 If the packet contains a version that is acceptable to the server, 906 the server proceeds with the handshake (Section 7.2). This commits 907 the server to the version that the client selected. 909 When the client receives a Version Negotiation packet from the 910 server, it should select an acceptable protocol version. If the 911 server lists an acceptable version, the client selects that version 912 and reattempts to create a connection using that version. Though the 913 contents of a packet might not change in response to version 914 negotiation, a client MUST increase the packet number it uses on 915 every packet it sends. Packets MUST continue to use long headers and 916 MUST include the new negotiated protocol version. 918 The client MUST use the long header format and include its selected 919 version on all packets until it has 1-RTT keys and it has received a 920 packet from the server which is not a Version Negotiation packet. 922 A client MUST NOT change the version it uses unless it is in response 923 to a Version Negotiation packet from the server. Once a client 924 receives a packet from the server which is not a Version Negotiation 925 packet, it MUST ignore Version Negotiation packets on the same 926 connection. 928 Version negotiation uses unprotected data. The result of the 929 negotiation MUST be revalidated as part of the cryptographic 930 handshake (see Section 7.3.4). 932 7.1.1. Using Reserved Versions 934 For a server to use a new version in the future, clients must 935 correctly handle unsupported versions. To help ensure this, a server 936 SHOULD include a reserved version (see Section 4) while generating a 937 Version Negotiation packet. 939 The design of version negotiation permits a server to avoid 940 maintaining state for packets that it rejects in this fashion. 941 However, when the server generates a Version Negotiation packet, it 942 cannot randomly generate a reserved version number. This is because 943 the server is required to include the same value in its transport 944 parameters (see Section 7.3.4). To avoid the selected version number 945 changing during connection establishment, the reserved version SHOULD 946 be generated as a function of values that will be available to the 947 server when later generating its handshake packets. 949 A pseudorandom function that takes client address information (IP and 950 port) and the client selected version as input would ensure that 951 there is sufficient variability in the values that a server uses. 953 A client MAY send a packet using a reserved version number. This can 954 be used to solicit a list of supported versions from a server. 956 7.2. Cryptographic and Transport Handshake 958 QUIC relies on a combined cryptographic and transport handshake to 959 minimize connection establishment latency. QUIC allocates stream 1 960 for the cryptographic handshake. This version of QUIC uses TLS 1.3 961 [QUIC-TLS]. 963 QUIC provides this stream with reliable, ordered delivery of data. 964 In return, the cryptographic handshake provides QUIC with: 966 o authenticated key exchange, where 968 * a server is always authenticated, 970 * a client is optionally authenticated, 972 * every connection produces distinct and unrelated keys, 974 * keying material is usable for packet protection for both 0-RTT 975 and 1-RTT packets, and 977 * 1-RTT keys have forward secrecy 979 o authenticated values for the transport parameters of the peer (see 980 Section 7.3) 982 o authenticated confirmation of version negotiation (see 983 Section 7.3.4) 985 o authenticated negotiation of an application protocol (TLS uses 986 ALPN [RFC7301] for this purpose) 988 o for the server, the ability to carry data that provides assurance 989 that the client can receive packets that are addressed with the 990 transport address that is claimed by the client (see Section 7.4) 992 The initial cryptographic handshake message MUST be sent in a single 993 packet. Any second attempt that is triggered by address validation 994 MUST also be sent within a single packet. This avoids having to 995 reassemble a message from multiple packets. Reassembling messages 996 requires that a server maintain state prior to establishing a 997 connection, exposing the server to a denial of service risk. 999 The first client packet of the cryptographic handshake protocol MUST 1000 fit within a 1280 octet QUIC packet. This includes overheads that 1001 reduce the space available to the cryptographic handshake protocol. 1003 Details of how TLS is integrated with QUIC is provided in more detail 1004 in [QUIC-TLS]. 1006 7.3. Transport Parameters 1008 During connection establishment, both endpoints make authenticated 1009 declarations of their transport parameters. These declarations are 1010 made unilaterally by each endpoint. Endpoints are required to comply 1011 with the restrictions implied by these parameters; the description of 1012 each parameter includes rules for its handling. 1014 The format of the transport parameters is the TransportParameters 1015 struct from Figure 6. This is described using the presentation 1016 language from Section 3 of [I-D.ietf-tls-tls13]. 1018 uint32 QuicVersion; 1020 enum { 1021 stream_fc_offset(0), 1022 connection_fc_offset(1), 1023 concurrent_streams(2), 1024 idle_timeout(3), 1025 truncate_connection_id(4), 1026 (65535) 1027 } TransportParameterId; 1029 struct { 1030 TransportParameterId parameter; 1031 opaque value<0..2^16-1>; 1032 } TransportParameter; 1034 struct { 1035 select (Handshake.msg_type) { 1036 case client_hello: 1037 QuicVersion negotiated_version; 1038 QuicVersion initial_version; 1040 case encrypted_extensions: 1041 QuicVersion supported_versions<2..2^8-4>; 1042 }; 1043 TransportParameter parameters<30..2^16-1>; 1044 } TransportParameters; 1046 Figure 6: Definition of TransportParameters 1048 The "extension_data" field of the quic_transport_parameters extension 1049 defined in [QUIC-TLS] contains a TransportParameters value. TLS 1050 encoding rules are therefore used to encode the transport parameters. 1052 QUIC encodes transport parameters into a sequence of octets, which 1053 are then included in the cryptographic handshake. Once the handshake 1054 completes, the transport parameters declared by the peer are 1055 available. Each endpoint validates the value provided by its peer. 1056 In particular, version negotiation MUST be validated (see 1057 Section 7.3.4) before the connection establishment is considered 1058 properly complete. 1060 Definitions for each of the defined transport parameters are included 1061 in Section 7.3.1. 1063 7.3.1. Transport Parameter Definitions 1065 An endpoint MUST include the following parameters in its encoded 1066 TransportParameters: 1068 stream_fc_offset (0x0000): The initial stream level flow control 1069 offset parameter is encoded as an unsigned 32-bit integer in units 1070 of octets. The sender of this parameter indicates that the flow 1071 control offset for all stream data sent toward it is this value. 1073 connection_fc_offset (0x0001): The connection level flow control 1074 offset parameter contains the initial connection flow control 1075 window encoded as an unsigned 32-bit integer in units of 1024 1076 octets. That is, the value here is multiplied by 1024 to 1077 determine the actual flow control offset. The sender of this 1078 parameter sets the byte offset for connection level flow control 1079 to this value. This is equivalent to sending a WINDOW_UPDATE 1080 (Section 8.3) for the connection immediately after completing the 1081 handshake. 1083 concurrent_streams (0x0002): The maximum number of concurrent 1084 streams parameter is encoded as an unsigned 32-bit integer. 1086 idle_timeout (0x0003): The idle timeout is a value in seconds that 1087 is encoded as an unsigned 16-bit integer. The maximum value is 1088 600 seconds (10 minutes). 1090 An endpoint MAY use the following transport parameters: 1092 truncate_connection_id (0x0004): The truncated connection identifier 1093 parameter indicates that packets sent to the peer can omit the 1094 connection ID. This can be used by an endpoint where the 5-tuple 1095 is sufficient to identify a connection. This parameter is zero 1096 length. Omitting the parameter indicates that the endpoint relies 1097 on the connection ID being present in every packet. 1099 7.3.2. Values of Transport Parameters for 0-RTT 1101 Transport parameters from the server SHOULD be remembered by the 1102 client for use with 0-RTT data. A client that doesn't remember 1103 values from a previous connection can instead assume the following 1104 values: stream_fc_offset (65535), connection_fc_offset (65535), 1105 concurrent_streams (10), idle_timeout (600), truncate_connection_id 1106 (absent). 1108 If assumed values change as a result of completing the handshake, the 1109 client is expected to respect the new values. This introduces some 1110 potential problems, particularly with respect to transport parameters 1111 that establish limits: 1113 o A client might exceed a newly declared connection or stream flow 1114 control limit with 0-RTT data. If this occurs, the client ceases 1115 transmission as though the flow control limit was reached. Once 1116 WINDOW_UPDATE frames indicating an increase to the affected flow 1117 control offsets is received, the client can recommence sending. 1119 o Similarly, a client might exceed the concurrent stream limit 1120 declared by the server. A client MUST reset any streams that 1121 exceed this limit. A server SHOULD reset any streams it cannot 1122 handle with a code that allows the client to retry any application 1123 action bound to those streams. 1125 A server MAY close a connection if remembered or assumed 0-RTT 1126 transport parameters cannot be supported, using an error code that is 1127 appropriate to the specific condition. For example, a 1128 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA might be used to indicate 1129 that exceeding flow control limits caused the error. A client that 1130 has a connection closed due to an error condition SHOULD NOT attempt 1131 0-RTT when attempting to create a new connection. 1133 7.3.3. New Transport Parameters 1135 New transport parameters can be used to negotiate new protocol 1136 behavior. An endpoint MUST ignore transport parameters that it does 1137 not support. Absence of a transport parameter therefore disables any 1138 optional protocol feature that is negotiated using the parameter. 1140 The definition of a transport parameter SHOULD include a default 1141 value that a client can use when establishing a new connection. If 1142 no default is specified, the value can be assumed to be absent when 1143 attempting 0-RTT. 1145 New transport parameters can be registered according to the rules in 1146 Section 14.1. 1148 7.3.4. Version Negotiation Validation 1150 The transport parameters include three fields that encode version 1151 information. These retroactively authenticate the version 1152 negotiation (see Section 7.1) that is performed prior to the 1153 cryptographic handshake. 1155 The cryptographic handshake provides integrity protection for the 1156 negotiated version as part of the transport parameters (see 1157 Section 7.3). As a result, modification of version negotiation 1158 packets by an attacker can be detected. 1160 The client includes two fields in the transport parameters: 1162 o The negotiated_version is the version that was finally selected 1163 for use. This MUST be identical to the value that is on the 1164 packet that carries the ClientHello. A server that receives a 1165 negotiated_version that does not match the version of QUIC that is 1166 in use MUST terminate the connection with a 1167 QUIC_VERSION_NEGOTIATION_MISMATCH error code. 1169 o The initial_version is the version that the client initially 1170 attempted to use. If the server did not send a version 1171 negotiation packet Section 5.3, this will be identical to the 1172 negotiated_version. 1174 A server that processes all packets in a stateful fashion can 1175 remember how version negotiation was performed and validate the 1176 initial_version value. 1178 A server that does not maintain state for every packet it receives 1179 (i.e., a stateless server) uses a different process. If the initial 1180 and negotiated versions are the same, a stateless server can accept 1181 the value. 1183 If the initial version is different from the negotiated_version, a 1184 stateless server MUST check that it would have sent a version 1185 negotiation packet if it had received a packet with the indicated 1186 initial_version. If a server would have accepted the version 1187 included in the initial_version and the value differs from the value 1188 of negotiated_version, the server MUST terminate the connection with 1189 a QUIC_VERSION_NEGOTIATION_MISMATCH error. 1191 The server includes a list of versions that it would send in any 1192 version negotiation packet (Section 5.3) in supported_versions. This 1193 value is set even if it did not send a version negotiation packet. 1195 The client can validate that the negotiated_version is included in 1196 the supported_versions list and - if version negotiation was 1197 performed - that it would have selected the negotiated version. A 1198 client MUST terminate the connection with a 1199 QUIC_VERSION_NEGOTIATION_MISMATCH error code if the 1200 negotiated_version value is not included in the supported_versions 1201 list. A client MUST terminate with a 1202 QUIC_VERSION_NEGOTIATION_MISMATCH error code if version negotiation 1203 occurred but it would have selected a different version based on the 1204 value of the supported_versions list. 1206 7.4. Proof of Source Address Ownership 1208 Transport protocols commonly spend a round trip checking that a 1209 client owns the transport address (IP and port) that it claims. 1210 Verifying that a client can receive packets sent to its claimed 1211 transport address protects against spoofing of this information by 1212 malicious clients. 1214 This technique is used primarily to avoid QUIC from being used for 1215 traffic amplification attack. In such an attack, a packet is sent to 1216 a server with spoofed source address information that identifies a 1217 victim. If a server generates more or larger packets in response to 1218 that packet, the attacker can use the server to send more data toward 1219 the victim than it would be able to send on its own. 1221 Several methods are used in QUIC to mitigate this attack. Firstly, 1222 the initial handshake packet from a client is padded to at least 1280 1223 octets. This allows a server to send a similar amount of data 1224 without risking causing an amplication attack toward an unproven 1225 remote address. 1227 A server eventually confirms that a client has received its messages 1228 when the cryptographic handshake successfully completes. This might 1229 be insufficient, either because the server wishes to avoid the 1230 computational cost of completing the handshake, or it might be that 1231 the size of the packets that are sent during the handshake is too 1232 large. This is especially important for 0-RTT, where the server 1233 might wish to provide application data traffic - such as a response 1234 to a request - in response to the data carried in the early data from 1235 the client. 1237 To send additional data prior to completing the cryptographic 1238 handshake, the server then needs to validate that the client owns the 1239 address that it claims. 1241 Source address validation is therefore performed during the 1242 establishment of a connection. TLS provides the tools that support 1243 the feature, but basic validation is performed by the core transport 1244 protocol. 1246 7.4.1. Client Address Validation Procedure 1248 QUIC uses token-based address validation. Any time the server wishes 1249 to validate a client address, it provides the client with a token. 1250 As long as the token cannot be easily guessed (see Section 7.4.3), if 1251 the client is able to return that token, it proves to the server that 1252 it received the token. 1254 During the processing of the cryptographic handshake messages from a 1255 client, TLS will request that QUIC make a decision about whether to 1256 proceed based on the information it has. TLS will provide QUIC with 1257 any token that was provided by the client. For an initial packet, 1258 QUIC can decide to abort the connection, allow it to proceed, or 1259 request address validation. 1261 If QUIC decides to request address validation, it provides the 1262 cryptographic handshake with a token. The contents of this token are 1263 consumed by the server that generates the token, so there is no need 1264 for a single well-defined format. A token could include information 1265 about the claimed client address (IP and port), a timestamp, and any 1266 other supplementary information the server will need to validate the 1267 token in the future. 1269 The cryptographic handshake is responsible for enacting validation by 1270 sending the address validation token to the client. A legitimate 1271 client will include a copy of the token when it attempts to continue 1272 the handshake. The cryptographic handshake extracts the token then 1273 asks QUIC a second time whether the token is acceptable. In 1274 response, QUIC can either abort the connection or permit it to 1275 proceed. 1277 A connection MAY be accepted without address validation - or with 1278 only limited validation - but a server SHOULD limit the data it sends 1279 toward an unvalidated address. Successful completion of the 1280 cryptographic handshake implicitly provides proof that the client has 1281 received packets from the server. 1283 7.4.2. Address Validation on Session Resumption 1285 A server MAY provide clients with an address validation token during 1286 one connection that can be used on a subsequent connection. Address 1287 validation is especially important with 0-RTT because a server 1288 potentially sends a significant amount of data to a client in 1289 response to 0-RTT data. 1291 A different type of token is needed when resuming. Unlike the token 1292 that is created during a handshake, there might be some time between 1293 when the token is created and when the token is subsequently used. 1294 Thus, a resumption token SHOULD include an expiration time. It is 1295 also unlikely that the client port number is the same on two 1296 different connections; validating the port is therefore unlikely to 1297 be successful. 1299 This token can be provided to the cryptographic handshake immediately 1300 after establishing a connection. QUIC might also generate an updated 1301 token if significant time passes or the client address changes for 1302 any reason (see Section 7.5). The cryptographic handshake is 1303 responsible for providing the client with the token. In TLS the 1304 token is included in the ticket that is used for resumption and 1305 0-RTT, which is carried in a NewSessionTicket message. 1307 7.4.3. Address Validation Token Integrity 1309 An address validation token MUST be difficult to guess. Including a 1310 large enough random value in the token would be sufficient, but this 1311 depends on the server remembering the value it sends to clients. 1313 A token-based scheme allows the server to offload any state 1314 associated with validation to the client. For this design to work, 1315 the token MUST be covered by integrity protection against 1316 modification or falsification by clients. Without integrity 1317 protection, malicious clients could generate or guess values for 1318 tokens that would be accepted by the server. Only the server 1319 requires access to the integrity protection key for tokens. 1321 In TLS the address validation token is often bundled with the 1322 information that TLS requires, such as the resumption secret. In 1323 this case, adding integrity protection can be delegated to the 1324 cryptographic handshake protocol, avoiding redundant protection. If 1325 integrity protection is delegated to the cryptographic handshake, an 1326 integrity failure will result in immediate cryptographic handshake 1327 failure. If integrity protection is performed by QUIC, QUIC MUST 1328 abort the connection if the integrity check fails with a 1329 QUIC_ADDRESS_VALIDATION_FAILURE error code. 1331 7.5. Connection Migration 1333 QUIC connections are identified by their 64-bit Connection ID. 1334 QUIC's consistent connection ID allows connections to survive changes 1335 to the client's IP and/or port, such as those caused by client or 1336 server migrating to a new network. QUIC also provides automatic 1337 cryptographic verification of a client which has changed its IP 1338 address because the client continues to use the same session key for 1339 encrypting and decrypting packets. 1341 DISCUSS: Simultaneous migration. Is this reasonable? 1343 TODO: Perhaps move mitigation techniques from Security Considerations 1344 here. 1346 7.6. Connection Termination 1348 Connections should remain open until they become idle for a pre- 1349 negotiated period of time. A QUIC connection, once established, can 1350 be terminated in one of three ways: 1352 1. Explicit Shutdown: An endpoint sends a CONNECTION_CLOSE frame to 1353 initiate a connection termination. An endpoint may send a GOAWAY 1354 frame to the peer prior to a CONNECTION_CLOSE to indicate that 1355 the connection will soon be terminated. A GOAWAY frame signals 1356 to the peer that any active streams will continue to be 1357 processed, but the sender of the GOAWAY will not initiate any 1358 additional streams and will not accept any new incoming streams. 1359 On termination of the active streams, a CONNECTION_CLOSE may be 1360 sent. If an endpoint sends a CONNECTION_CLOSE frame while 1361 unterminated streams are active (no FIN bit or RST_STREAM frames 1362 have been sent or received for one or more streams), then the 1363 peer must assume that the streams were incomplete and were 1364 abnormally terminated. 1366 2. Implicit Shutdown: The default idle timeout for a QUIC connection 1367 is 30 seconds, and is a required parameter in connection 1368 negotiation. The maximum is 10 minutes. If there is no network 1369 activity for the duration of the idle timeout, the connection is 1370 closed. By default a CONNECTION_CLOSE frame will be sent. A 1371 silent close option can be enabled when it is expensive to send 1372 an explicit close, such as mobile networks that must wake up the 1373 radio. 1375 3. Abrupt Shutdown: An endpoint may send a Public Reset packet at 1376 any time during the connection to abruptly terminate an active 1377 connection. A Public Reset packet SHOULD only be used as a final 1378 recourse. Commonly, a public reset is expected to be sent when a 1379 packet on an established connection is received by an endpoint 1380 that is unable decrypt the packet. For instance, if a server 1381 reboots mid-connection and loses any cryptographic state 1382 associated with open connections, and then receives a packet on 1383 an open connection, it should send a Public Reset packet in 1384 return. (TODO: articulate rules around when a public reset 1385 should be sent.) 1387 TODO: Connections that are terminated are added to a TIME_WAIT list 1388 at the server, so as to absorb any straggler packets in the network. 1389 Discuss TIME_WAIT list. 1391 8. Frame Types and Formats 1393 As described in Section 6, Regular packets contain one or more 1394 frames. We now describe the various QUIC frame types that can be 1395 present in a Regular packet. The use of these frames and various 1396 frame header bits are described in subsequent sections. 1398 8.1. STREAM Frame 1400 STREAM frames implicitly create a stream and carry stream data. The 1401 type byte for a STREAM frame contains embedded flags, and is 1402 formatted as "1FDOOOSS". These bits are parsed as follows: 1404 o The leftmost bit must be set to 1, indicating that this is a 1405 STREAM frame. 1407 o "F" is the FIN bit, which is used for stream termination. 1409 o The "D" bit indicates whether a Data Length field is present in 1410 the STREAM header. When set to 0, this field indicates that the 1411 Stream Data field extends to the end of the packet. When set to 1412 1, this field indicates that Data Length field contains the length 1413 (in bytes) of the Stream Data field. The option to omit the 1414 length should only be used when the packet is a "full-sized" 1415 packet, to avoid the risk of corruption via padding. 1417 o The "OOO" bits encode the length of the Offset header field as 0, 1418 16, 24, 32, 40, 48, 56, or 64 bits long. 1420 o The "SS" bits encode the length of the Stream ID header field as 1421 8, 16, 24, or 32 bits. (DISCUSS: Consider making this 8, 16, 32, 1422 64.) 1424 A STREAM frame is shown below. 1426 0 1 2 3 1427 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1428 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1429 | [Data Length (16)] | 1430 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1431 | Stream ID (8/16/24/32) ... 1432 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1433 | Offset (0/16/24/32/40/48/56/64) ... 1434 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1435 | Stream Data (*) ... 1436 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1438 Figure 7: STREAM Frame Format 1440 The STREAM frame contains the following fields: 1442 Data Length: An optional 16-bit unsigned number specifying the 1443 length of the Stream Data field in this STREAM frame. This field 1444 is present when the "D" bit is set to 1. 1446 Stream ID: A variable-sized unsigned ID unique to this stream. 1448 Offset: A variable-sized unsigned number specifying the byte offset 1449 in the stream for the data in this STREAM frame. The first byte 1450 in the stream has an offset of 0. The largest offset delivered on 1451 a stream - the sum of the re-constructed offset and data length - 1452 MUST be less than 2^64. 1454 Stream Data: The bytes from the designated stream to be delivered. 1456 A STREAM frame MUST have either non-zero data length or the FIN bit 1457 set. 1459 Stream multiplexing is achieved by interleaving STREAM frames from 1460 multiple streams into one or more QUIC packets. A single QUIC packet 1461 MAY bundle STREAM frames from multiple streams. 1463 Implementation note: One of the benefits of QUIC is avoidance of 1464 head-of-line blocking across multiple streams. When a packet loss 1465 occurs, only streams with data in that packet are blocked waiting for 1466 a retransmission to be received, while other streams can continue 1467 making progress. Note that when data from multiple streams is 1468 bundled into a single QUIC packet, loss of that packet blocks all 1469 those streams from making progress. An implementation is therefore 1470 advised to bundle as few streams as necessary in outgoing packets 1471 without losing transmission efficiency to underfilled packets. 1473 8.2. ACK Frame 1475 Receivers send ACK frames to inform senders which packets they have 1476 received and processed, as well as which packets are considered 1477 missing. The ACK frame contains between 1 and 256 ACK blocks. ACK 1478 blocks are ranges of acknowledged packets. 1480 To limit ACK blocks to those that have not yet been received by the 1481 sender, the receiver SHOULD track which ACK frames have been 1482 acknowledged by its peer. Once an ACK frame has been acknowledged, 1483 the packets it acknowledges SHOULD not be acknowledged again. To 1484 handle cases where the receiver is only sending ACK frames, and hence 1485 will not receive acknowledgments for its packets, it MAY send a PING 1486 frame at most once per RTT to explicitly request acknowledgment. 1488 To limit receiver state or the size of ACK frames, a receiver MAY 1489 limit the number of ACK blocks it sends. A receiver can do this even 1490 without receiving acknowledgment of its ACK frames, with the 1491 knowledge this could cause the sender to unnecessarily retransmit 1492 some data. 1494 Unlike TCP SACKs, QUIC ACK blocks are cumulative and therefore 1495 irrevocable. Once a packet has been acknowledged, even if it does 1496 not appear in a future ACK frame, it is assumed to be acknowledged. 1498 QUIC ACK frames contain a timestamp section with up to 255 1499 timestamps. Timestamps enable better congestion control, but are not 1500 required for correct loss recovery, and old timestamps are less 1501 valuable, so it is not guaranteed every timestamp will be received by 1502 the sender. A receiver SHOULD send a timestamp exactly once for each 1503 received packet containing retransmittable frames. A receiver MAY 1504 send timestamps for non-retransmittable packets. 1506 A sender MAY intentionally skip packet numbers to introduce entropy 1507 into the connection, to avoid opportunistic acknowledgement attacks. 1508 The sender MUST close the connection if an unsent packet number is 1509 acknowledged. The format of the ACK frame is efficient at expressing 1510 blocks of missing packets; skipping packet numbers between 1 and 255 1511 effectively provides up to 8 bits of efficient entropy on demand, 1512 which should be adequate protection against most opportunistic 1513 acknowledgement attacks. 1515 The type byte for a ACK frame contains embedded flags, and is 1516 formatted as "01NULLMM". These bits are parsed as follows: 1518 o The first two bits must be set to 01 indicating that this is an 1519 ACK frame. 1521 o The "N" bit indicates whether the frame has more than 1 range of 1522 acknowledged packets (i.e., whether the ACK Block Section contains 1523 a Num Blocks field). 1525 o The "U" bit is unused and MUST be set to zero. 1527 o The two "LL" bits encode the length of the Largest Acknowledged 1528 field as 1, 2, 4, or 6 bytes long. 1530 o The two "MM" bits encode the length of the ACK Block Length fields 1531 as 1, 2, 4, or 6 bytes long. 1533 An ACK frame is shown below. 1535 0 1 2 3 1536 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1537 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1538 |[Num Blocks(8)]| NumTS (8) | 1539 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1540 | Largest Acknowledged (8/16/32/48) ... 1541 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1542 | ACK Delay (16) | 1543 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1544 | ACK Block Section (*) ... 1545 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1546 | Timestamp Section (*) ... 1547 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1549 Figure 8: ACK Frame Format 1551 The fields in the ACK frame are as follows: 1553 Num Blocks (opt): An optional 8-bit unsigned value specifying the 1554 number of additional ACK blocks (besides the required First ACK 1555 Block) in this ACK frame. Only present if the 'N' flag bit is 1. 1557 Num Timestamps: An unsigned 8-bit number specifying the total number 1558 of pairs in the Timestamp Section. 1560 Largest Acknowledged: A variable-sized unsigned value representing 1561 the largest packet number the peer is acknowledging in this packet 1562 (typically the largest that the peer has seen thus far.) 1564 ACK Delay: The time from when the largest acknowledged packet, as 1565 indicated in the Largest Acknowledged field, was received by this 1566 peer to when this ACK was sent. 1568 ACK Block Section: Contains one or more blocks of packet numbers 1569 which have been successfully received, see Section 8.2.1. 1571 Timestamp Section: Contains zero or more timestamps reporting 1572 transit delay of received packets. See Section 8.2.2. 1574 8.2.1. ACK Block Section 1576 The ACK Block Section contains between one and 256 blocks of packet 1577 numbers which have been successfully received. If the Num Blocks 1578 field is absent, only the First ACK Block length is present in this 1579 section. Otherwise, the Num Blocks field indicates how many 1580 additional blocks follow the First ACK Block Length field. 1582 0 1 2 3 1583 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1584 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1585 | First ACK Block Length (8/16/32/48) ... 1586 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1587 | [Gap 1 (8)] | [ACK Block 1 Length (8/16/32/48)] ... 1588 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1589 | [Gap 2 (8)] | [ACK Block 2 Length (8/16/32/48)] ... 1590 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1591 ... 1592 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1593 | [Gap N (8)] | [ACK Block N Length (8/16/32/48)] ... 1594 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1596 Figure 9: ACK Block Section 1598 The fields in the ACK Block Section are: 1600 First ACK Block Length: An unsigned packet number delta that 1601 indicates the number of contiguous additional packets being 1602 acknowledged starting at the Largest Acknowledged. 1604 Gap To Next Block (opt, repeated): An unsigned number specifying the 1605 number of contiguous missing packets from the end of the previous 1606 ACK block to the start of the next. Repeated "Num Blocks" times. 1608 ACK Block Length (opt, repeated): An unsigned packet number delta 1609 that indicates the number of contiguous packets being acknowledged 1610 starting after the end of the previous gap. Repeated "Num Blocks" 1611 times. 1613 8.2.2. Timestamp Section 1615 The Timestamp Section contains between zero and 255 measurements of 1616 packet receive times relative to the beginning of the connection. 1618 0 1 2 3 1619 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1620 +-+-+-+-+-+-+-+-+ 1621 | [Delta LA (8)]| 1622 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1623 | [First Timestamp (32)] | 1624 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1625 |[Delta LA 1(8)]| [Time Since Previous 1 (16)] | 1626 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1627 |[Delta LA 2(8)]| [Time Since Previous 2 (16)] | 1628 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1629 ... 1630 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1631 |[Delta LA N(8)]| [Time Since Previous N (16)] | 1632 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1634 Figure 10: Timestamp Section 1636 The fields in the Timestamp Section are: 1638 Delta Largest Acknowledged (opt): An optional 8-bit unsigned packet 1639 number delta specifying the delta between the largest acknowledged 1640 and the first packet whose timestamp is being reported. In other 1641 words, this first packet number may be computed as (Largest 1642 Acknowledged - Delta Largest Acknowledged.) 1644 First Timestamp (opt): An optional 32-bit unsigned value specifying 1645 the time delta in microseconds, from the beginning of the 1646 connection to the arrival of the packet indicated by Delta Largest 1647 Acknowledged. 1649 Delta Largest Acked 1..N (opt, repeated): This field has the same 1650 semantics and format as "Delta Largest Acknowledged". Repeated 1651 "Num Timestamps - 1" times. 1653 Time Since Previous Timestamp 1..N(opt, repeated): An optional 1654 16-bit unsigned value specifying time delta from the previous 1655 reported timestamp. It is encoded in the same format as the ACK 1656 Delay. Repeated "Num Timestamps - 1" times. 1658 The timestamp section lists packet receipt timestamps ordered by 1659 timestamp. 1661 8.2.2.1. Time Format 1663 DISCUSS_AND_REPLACE: Perhaps make this format simpler. 1665 The time format used in the ACK frame above is a 16-bit unsigned 1666 float with 11 explicit bits of mantissa and 5 bits of explicit 1667 exponent, specifying time in microseconds. The bit format is loosely 1668 modeled after IEEE 754. For example, 1 microsecond is represented as 1669 0x1, which has an exponent of zero, presented in the 5 high order 1670 bits, and mantissa of 1, presented in the 11 low order bits. When 1671 the explicit exponent is greater than zero, an implicit high-order 1672 12th bit of 1 is assumed in the mantissa. For example, a floating 1673 value of 0x800 has an explicit exponent of 1, as well as an explicit 1674 mantissa of 0, but then has an effective mantissa of 4096 (12th bit 1675 is assumed to be 1). Additionally, the actual exponent is one-less 1676 than the explicit exponent, and the value represents 4096 1677 microseconds. Any values larger than the representable range are 1678 clamped to 0xFFFF. 1680 8.2.3. ACK Frames and Packet Protection 1682 ACK frames that acknowledge protected packets MUST be carried in a 1683 packet that has an equivalent or greater level of packet protection. 1685 Packets that are protected with 1-RTT keys MUST be acknowledged in 1686 packets that are also protected with 1-RTT keys. 1688 A packet that is not protected and claims to acknowledge a packet 1689 number that was sent with packet protection is not valid. An 1690 unprotected packet that carries acknowledgments for protected packets 1691 MUST be discarded in its entirety. 1693 Packets that a client sends with 0-RTT packet protection MUST be 1694 acknowledged by the server in packets protected by 1-RTT keys. This 1695 can mean that the client is unable to use these acknowledgments if 1696 the server cryptographic handshake messages are delayed or lost. 1697 Note that the same limitation applies to other data sent by the 1698 server protected by the 1-RTT keys. 1700 Unprotected packets, such as those that carry the initial 1701 cryptographic handshake messages, MAY be acknowledged in unprotected 1702 packets. Unprotected packets are vulnerable to falsification or 1703 modification. Unprotected packets can be acknowledged along with 1704 protected packets in a protected packet. 1706 An endpoint SHOULD acknowledge packets containing cryptographic 1707 handshake messages in the next unprotected packet that it sends, 1708 unless it is able to acknowledge those packets in later packets 1709 protected by 1-RTT keys. At the completion of the cryptographic 1710 handshake, both peers send unprotected packets containing 1711 cryptographic handshake messages followed by packets protected by 1712 1-RTT keys. An endpoint SHOULD acknowledge the unprotected packets 1713 that complete the cryptographic handshake in a protected packet, 1714 because its peer is guaranteed to have access to 1-RTT packet 1715 protection keys. 1717 For instance, a server acknowledges a TLS ClientHello in the packet 1718 that carries the TLS ServerHello; similarly, a client can acknowledge 1719 a TLS HelloRetryRequest in the packet containing a second TLS 1720 ClientHello. The complete set of server handshake messages (TLS 1721 ServerHello through to Finished) might be acknowledged by a client in 1722 protected packets, because it is certain that the server is able to 1723 decipher the packet. 1725 8.3. WINDOW_UPDATE Frame 1727 The WINDOW_UPDATE frame (type=0x04) informs the peer of an increase 1728 in an endpoint's flow control receive window for either a single 1729 stream, or the entire connection as a whole. 1731 The frame is as follows: 1733 0 1 2 3 1734 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1735 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1736 | Stream ID (32) | 1737 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1738 | | 1739 + Flow Control Offset (64) + 1740 | | 1741 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1743 The fields in the WINDOW_UPDATE frame are as follows: 1745 Stream ID: ID of the stream whose flow control windows is being 1746 updated, or 0 to specify the connection-level flow control window. 1748 Flow Control Offset: A 64-bit unsigned integer indicating the flow 1749 control offset for the given stream (for a stream ID other than 0) 1750 or the entire connection. 1752 The flow control offset is expressed in units of octets for 1753 individual streams (for stream identifiers other than 0). 1755 The connection-level flow control offset is expressed in units of 1756 1024 octets (for a stream identifier of 0). That is, the connection- 1757 level flow control offset is determined by multiplying the encoded 1758 value by 1024. 1760 An endpoint accounts for the maximum offset of data that is sent or 1761 received on a stream. Loss or reordering can mean that the maximum 1762 offset is greater than the total size of data received on a stream. 1763 Similarly, receiving STREAM frames might not increase the maximum 1764 offset on a stream. A STREAM frame with a FIN bit set or RST_STREAM 1765 causes the final offset for a stream to be fixed. 1767 The maximum data offset on a stream MUST NOT exceed the stream flow 1768 control offset advertised by the receiver. The sum of the maximum 1769 data offsets of all streams (including closed streams) MUST NOT 1770 exceed the connection flow control offset advertised by the receiver. 1771 An endpoint MUST terminate a connection with a 1772 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA error if it receives more 1773 data than the largest flow control offset that it has sent, unless 1774 this is a result of a change in the initial offsets (see 1775 Section 7.3.2). 1777 8.4. BLOCKED Frame 1779 A sender sends a BLOCKED frame (type=0x05) when it is ready to send 1780 data (and has data to send), but is currently flow control blocked. 1781 BLOCKED frames are purely informational frames, but extremely useful 1782 for debugging purposes. A receiver of a BLOCKED frame should simply 1783 discard it (after possibly printing a helpful log message). The 1784 frame is as follows: 1786 0 1 2 3 1787 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1788 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1789 | Stream ID (32) | 1790 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1792 The BLOCKED frame contains a single field: 1794 Stream ID: A 32-bit unsigned number indicating the stream which is 1795 flow control blocked. A non-zero Stream ID field specifies the 1796 stream that is flow control blocked. When zero, the Stream ID 1797 field indicates that the connection is flow control blocked. 1799 8.5. RST_STREAM Frame 1801 An endpoint may use a RST_STREAM frame (type=0x01) to abruptly 1802 terminate a stream. The frame is as follows: 1804 0 1 2 3 1805 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1806 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1807 | Error Code (32) | 1808 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1809 | Stream ID (32) | 1810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1811 | | 1812 + Final Offset (64) + 1813 | | 1814 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1816 The fields are: 1818 Error code: A 32-bit error code which indicates why the stream is 1819 being closed. 1821 Stream ID: The 32-bit Stream ID of the stream being terminated. 1823 Final offset: A 64-bit unsigned integer indicating the absolute byte 1824 offset of the end of data written on this stream by the RST_STREAM 1825 sender. 1827 8.6. PADDING Frame 1829 The PADDING frame (type=0x00) has no semantic value. PADDING frames 1830 can be used to increase the size of a packet. Padding can be used to 1831 increase an initial client packet to the minimum required size, or to 1832 provide protection against traffic analysis for protected packets. 1834 A PADDING frame has no content. That is, a PADDING frame consists of 1835 the single octet that identifies the frame as a PADDING frame. 1837 8.7. PING frame 1839 Endpoints can use PING frames (type=0x07) to verify that their peers 1840 are still alive or to check reachability to the peer. The PING frame 1841 contains no additional fields. The receiver of a PING frame simply 1842 needs to acknowledge the packet containing this frame. The PING 1843 frame SHOULD be used to keep a connection alive when a stream is 1844 open. The default is to send a PING frame after 15 seconds of 1845 quiescence. A PING frame has no additional fields. 1847 8.8. CONNECTION_CLOSE frame 1849 An endpoint sends a CONNECTION_CLOSE frame (type=0x02) to notify its 1850 peer that the connection is being closed. If there are open streams 1851 that haven't been explicitly closed, they are implicitly closed when 1852 the connection is closed. (Ideally, a GOAWAY frame would be sent 1853 with enough time that all streams are torn down.) The frame is as 1854 follows: 1856 0 1 2 3 1857 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1858 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1859 | Error Code (32) | 1860 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1861 | Reason Phrase Length (16) | [Reason Phrase (*)] ... 1862 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1864 The fields of a CONNECTION_CLOSE frame are as follows: 1866 Error Code: A 32-bit error code which indicates the reason for 1867 closing this connection. 1869 Reason Phrase Length: A 16-bit unsigned number specifying the length 1870 of the reason phrase. This may be zero if the sender chooses to 1871 not give details beyond the Error Code. 1873 Reason Phrase: An optional human-readable explanation for why the 1874 connection was closed. 1876 8.9. GOAWAY Frame 1878 An endpoint uses a GOAWAY frame (type=0x03) to initiate a graceful 1879 shutdown of a connection. The endpoints will continue to use any 1880 active streams, but the sender of the GOAWAY will not initiate or 1881 accept any additional streams beyond those indicated. The GOAWAY 1882 frame is as follows: 1884 0 1 2 3 1885 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1886 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1887 | Largest Client Stream ID (32) | 1888 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1889 | Largest Server Stream ID (32) | 1890 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1892 The fields of a GOAWAY frame are: 1894 Largest Client Stream ID: The highest-numbered, client-initiated 1895 stream on which the endpoint sending the GOAWAY frame either sent 1896 data, or received and delivered data. All higher-numbered, 1897 client-initiated streams (that is, odd-numbered streams) are 1898 implicitly reset by sending or receiving the GOAWAY frame. 1900 Largest Server Stream ID: The highest-numbered, server-initiated 1901 stream on which the endpoint sending the GOAWAY frame either sent 1902 data, or received and delivered data. All higher-numbered, 1903 server-initiated streams (that is, even-numbered streams) are 1904 implicitly reset by sending or receiving the GOAWAY frame. 1906 A GOAWAY frame indicates that any application layer actions on 1907 streams with higher numbers than those indicated can be safely 1908 retried because no data was exchanged. An endpoint MUST set the 1909 value of the Largest Client or Server Stream ID to be at least as 1910 high as the highest-numbered stream on which it either sent data or 1911 received and delivered data to the application protocol that uses 1912 QUIC. 1914 An endpoint MAY choose a larger stream identifier if it wishes to 1915 allow for a number of streams to be created. This is especially 1916 valuable for peer-initiated streams where packets creating new 1917 streams could be in transit; using a larger stream number allows 1918 those streams to complete. 1920 In addition to initiating a graceful shutdown of a connection, GOAWAY 1921 MAY be sent immediately prior to sending a CONNECTION_CLOSE frame 1922 that is sent as a result of detecting a fatal error. Higher-numbered 1923 streams than those indicated in the GOAWAY frame can then be retried. 1925 9. Packetization and Reliability 1927 The Path Maximum Transmission Unit (PTMU) is the maximum size of the 1928 entire IP header, UDP header, and UDP payload. The UDP payload 1929 includes the QUIC public header, encrypted payload, and any 1930 authentication fields. 1932 All QUIC packets SHOULD be sized to fit within the estimated PMTU to 1933 avoid IP fragmentation or packet drops. To optimize bandwidth 1934 efficiency, endpoints SHOULD use Packetization Layer PMTU Discovery 1935 ([RFC4821]) and MAY use PMTU Discovery ([RFC1191], [RFC1981]) for 1936 detecting the PMTU, setting the PMTU appropriately, and storing the 1937 result of previous PMTU determinations. 1939 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 1940 packets larger than 1280 octets. Assuming the minimum IP header 1941 size, this results in a UDP payload length of 1232 octets for IPv6 1942 and 1252 octets for IPv4. 1944 QUIC endpoints that implement any kind of PMTU discovery SHOULD 1945 maintain an estimate for each combination of local and remote IP 1946 addresses (as each pairing could have a different maximum MTU in the 1947 path). 1949 QUIC depends on the network path supporting a MTU of at least 1280 1950 octets. This is the IPv6 minimum and therefore also supported by 1951 most modern IPv4 networks. An endpoint MUST NOT reduce their MTU 1952 below this number, even if it receives signals that indicate a 1953 smaller limit might exist. 1955 Clients MUST ensure that the first packet in a connection, and any 1956 retransmissions of those octets, has a total size (including IP and 1957 UDP headers) of at least 1280 bytes. This might require inclusion of 1958 PADDING frames. It is RECOMMENDED that a packet be padded to exactly 1959 1280 octets unless the client has a reasonable assurance that the 1960 PMTU is larger. Sending a packet of this size ensures that the 1961 network path supports an MTU of this size and helps mitigate 1962 amplification attacks caused by server responses toward an unverified 1963 client address. 1965 Servers MUST reject the first plaintext packet received from a client 1966 if it its total size is less than 1280 octets, to mitigate 1967 amplification attacks. 1969 If a QUIC endpoint determines that the PMTU between any pair of local 1970 and remote IP addresses has fallen below 1280 octets, it MUST 1971 immediately cease sending QUIC packets between those IP addresses. 1972 This may result in abrupt termination of the connection if all pairs 1973 are affected. In this case, an endpoint SHOULD send a Public Reset 1974 packet to indicate the failure. The application SHOULD attempt to 1975 use TLS over TCP instead. 1977 A sender bundles one or more frames in a Regular QUIC packet (see 1978 Section 6). 1980 A sender SHOULD minimize per-packet bandwidth and computational costs 1981 by bundling as many frames as possible within a QUIC packet. A 1982 sender MAY wait for a short period of time to bundle multiple frames 1983 before sending a packet that is not maximally packed, to avoid 1984 sending out large numbers of small packets. An implementation may 1985 use heuristics about expected application sending behavior to 1986 determine whether and for how long to wait. This waiting period is 1987 an implementation decision, and an implementation should be careful 1988 to delay conservatively, since any delay is likely to increase 1989 application-visible latency. 1991 Regular QUIC packets are "containers" of frames; a packet is never 1992 retransmitted whole. How an endpoint handles the loss of the frame 1993 depends on the type of the frame. Some frames are simply 1994 retransmitted, some have their contents moved to new frames, and 1995 others are never retransmitted. 1997 When a packet is detected as lost, the sender re-sends any frames as 1998 necessary: 2000 o All application data sent in STREAM frames MUST be retransmitted, 2001 unless the endpoint has sent a RST_STREAM for that stream. When 2002 an endpoint sends a RST_STREAM frame, data outstanding on that 2003 stream SHOULD NOT be retransmitted, since subsequent data on this 2004 stream is expected to not be delivered by the receiver. 2006 o ACK and PADDING frames MUST NOT be retransmitted. ACK frames are 2007 cumulative, so new frames containing updated information will be 2008 sent as described in Section 8.2. 2010 o All other frames MUST be retransmitted. 2012 Upon detecting losses, a sender MUST take appropriate congestion 2013 control action. The details of loss detection and congestion control 2014 are described in [QUIC-RECOVERY]. 2016 A packet MUST NOT be acknowledged until packet protection has been 2017 successfully removed and all frames contained in the packet have been 2018 processed. For STREAM frames, this means the data has been queued 2019 (but not necessarily delivered to the application). This also means 2020 that any stream state transitions triggered by STREAM or RST_STREAM 2021 frames have occurred. Once the packet has been fully processed, a 2022 receiver acknowledges receipt by sending one or more ACK frames 2023 containing the packet number of the received packet. 2025 To avoid creating an indefinite feedback loop, an endpoint MUST NOT 2026 generate an ACK frame in response to a packet containing only ACK or 2027 PADDING frames. 2029 Strategies and implications of the frequency of generating 2030 acknowledgments are discussed in more detail in [QUIC-RECOVERY]. 2032 9.1. Special Considerations for PMTU Discovery 2034 Traditional ICMP-based path MTU discovery in IPv4 ([RFC1191] is 2035 potentially vulnerable to off-path attacks that successfully guess 2036 the IP/port 4-tuple and reduce the MTU to a bandwidth-inefficient 2037 value. TCP connections mitigate this risk by using the (at minimum) 2038 8 bytes of transport header echoed in the ICMP message to validate 2039 the TCP sequence number as valid for the current connection. 2040 However, as QUIC operates over UDP, in IPv4 the echoed information 2041 could consist only of the IP and UDP headers, which usually has 2042 insufficient entropy to mitigate off-path attacks. 2044 As a result, endpoints that implement PMTUD in IPv4 SHOULD take steps 2045 to mitigate this risk. For instance, an application could: 2047 o Set the IPv4 Don't Fragment (DF) bit on a small proportion of 2048 packets, so that most invalid ICMP messages arrive when there are 2049 no DF packets outstanding, and can therefore be identified as 2050 spurious. 2052 o Store additional information from the IP or UDP headers from DF 2053 packets (for example, the IP ID or UDP checksum) to further 2054 authenticate incoming Datagram Too Big messages. 2056 o Any reduction in PMTU due to a report contained in an ICMP packet 2057 is provisional until QUIC's loss detection algorithm determines 2058 that the packet is actually lost. 2060 10. Streams: QUIC's Data Structuring Abstraction 2062 Streams in QUIC provide a lightweight, ordered, and bidirectional 2063 byte-stream abstraction modeled closely on HTTP/2 streams [RFC7540]. 2065 Streams can be created either by the client or the server, can 2066 concurrently send data interleaved with other streams, and can be 2067 cancelled. 2069 Data that is received on a stream is delivered in order within that 2070 stream, but there is no particular delivery order across streams. 2071 Transmit ordering among streams is left to the implementation. 2073 The creation and destruction of streams are expected to have minimal 2074 bandwidth and computational cost. A single STREAM frame may create, 2075 carry data for, and terminate a stream, or a stream may last the 2076 entire duration of a connection. 2078 Streams are individually flow controlled, allowing an endpoint to 2079 limit memory commitment and to apply back pressure. 2081 An alternative view of QUIC streams is as an elastic "message" 2082 abstraction, similar to the way ephemeral streams are used in SST 2083 [SST], which may be a more appealing description for some 2084 applications. 2086 10.1. Life of a Stream 2088 The semantics of QUIC streams is based on HTTP/2 streams, and the 2089 lifecycle of a QUIC stream therefore closely follows that of an 2090 HTTP/2 stream [RFC7540], with some differences to accommodate the 2091 possibility of out-of-order delivery due to the use of multiple 2092 streams in QUIC. The lifecycle of a QUIC stream is shown in the 2093 following figure and described below. 2095 +--------+ 2096 | | 2097 | idle | 2098 | | 2099 +--------+ 2100 | 2101 | send data/ 2102 | recv data/ 2103 | recv higher stream 2104 | 2105 v 2106 +--------+ 2107 recv FIN | | send FIN 2108 ,---------| open |-----------. 2109 / | | \ 2110 v +--------+ v 2111 +----------+ | +----------+ 2112 | half | | | half | 2113 | closed | | send RST/ | closed | 2114 | (remote) | | recv RST | (local) | 2115 +----------+ | +----------+ 2116 | | | 2117 | send FIN/ | recv FIN/ | 2118 | send RST/ v send RST/ | 2119 | recv RST +--------+ recv RST | 2120 `------------->| |<---------------' 2121 | closed | 2122 | | 2123 +--------+ 2125 send: endpoint sends this frame 2126 recv: endpoint receives this frame 2128 data: application data in a STREAM frame 2129 FIN: FIN flag in a STREAM frame 2130 RST: RST_STREAM frame 2132 Figure 11: Lifecycle of a stream 2134 Note that this diagram shows stream state transitions and the frames 2135 and flags that affect those transitions only. For the purpose of 2136 state transitions, the FIN flag is processed as a separate event to 2137 the frame that bears it; a STREAM frame with the FIN flag set can 2138 cause two state transitions. When the FIN flag is sent on an empty 2139 STREAM frame, the offset in the STREAM frame MUST be one greater than 2140 the last data byte sent on this stream. 2142 The recipient of a frame which changes stream state will have a 2143 delayed view of the state of a stream while the frame is in transit. 2144 Endpoints do not coordinate the creation of streams; they are created 2145 unilaterally by either endpoint. The negative consequences of a 2146 mismatch in states are limited to the "closed" state after sending 2147 RST_STREAM, where frames might be received for some time after 2148 closing. Endpoints can use acknowledgments to understand the peer's 2149 subjective view of stream state at any given time. 2151 Streams have the following states: 2153 10.1.1. idle 2155 All streams start in the "idle" state. 2157 The following transitions are valid from this state: 2159 Sending or receiving a STREAM frame causes the stream to become 2160 "open". The stream identifier is selected as described in 2161 Section 10.2. The same STREAM frame can also cause a stream to 2162 immediately become "half-closed". 2164 Receiving a STREAM frame on a peer-initiated stream (that is, a 2165 packet sent by a server on an even-numbered stream or a client packet 2166 on an odd-numbered stream) also causes all lower-numbered "idle" 2167 streams in the same direction to become "open". This could occur if 2168 a peer begins sending on streams in a different order to their 2169 creation, or it could happen if packets are lost or reordered in 2170 transit. 2172 Receiving any frame other than STREAM or RST_STREAM on a stream in 2173 this state MUST be treated as a connection error (Section 12) of type 2174 YYYY. 2176 10.1.2. open 2178 A stream in the "open" state may be used by both peers to send frames 2179 of any type. In this state, a sending peer must observe the flow- 2180 control limit advertised by its receiving peer (Section 11). 2182 From this state, either endpoint can send a frame with the FIN flag 2183 set, which causes the stream to transition into one of the "half- 2184 closed" states. An endpoint sending an FIN flag causes the stream 2185 state to become "half-closed (local)". An endpoint receiving a FIN 2186 flag causes the stream state to become "half-closed (remote)" once 2187 all preceding data has arrived. The receiving endpoint MUST NOT 2188 consider the stream state to have changed until all data has arrived. 2190 Either endpoint can send a RST_STREAM frame from this state, causing 2191 it to transition immediately to "closed". 2193 10.1.3. half-closed (local) 2195 A stream that is in the "half-closed (local)" state MUST NOT be used 2196 for sending STREAM frames; WINDOW_UPDATE and RST_STREAM MAY be sent 2197 in this state. 2199 A stream transitions from this state to "closed" when a STREAM frame 2200 that contains a FIN flag is received and all prior data has arrived, 2201 or when either peer sends a RST_STREAM frame. 2203 An endpoint that closes a stream MUST NOT send data beyond the final 2204 offset that it has chosen, see Section 10.1.5 for details. 2206 An endpoint can receive any type of frame in this state. Providing 2207 flow-control credit using WINDOW_UPDATE frames is necessary to 2208 continue receiving flow-controlled frames. In this state, a receiver 2209 MAY ignore WINDOW_UPDATE frames for this stream, which might arrive 2210 for a short period after a frame bearing the FIN flag is sent. 2212 10.1.4. half-closed (remote) 2214 A stream that is "half-closed (remote)" is no longer being used by 2215 the peer to send any data. In this state, a sender is no longer 2216 obligated to maintain a receiver stream-level flow-control window. 2218 A stream that is in the "half-closed (remote)" state will have a 2219 final offset for received data, see Section 10.1.5 for details. 2221 A stream in this state can be used by the endpoint to send frames of 2222 any type. In this state, the endpoint continues to observe 2223 advertised stream-level and connection-level flow-control limits 2224 (Section 11). 2226 A stream can transition from this state to "closed" by sending a 2227 frame that contains a FIN flag or when either peer sends a RST_STREAM 2228 frame. 2230 10.1.5. closed 2232 The "closed" state is the terminal state. 2234 An endpoint will learn the final offset of the data it receives on a 2235 stream when it enters the "half-closed (remote)" or "closed" state. 2236 The final offset is carried explicitly in the RST_STREAM frame; 2237 otherwise, the final offset is the offset of the end of the data 2238 carried in STREAM frame marked with a FIN flag. 2240 An endpoint MUST NOT send data on a stream at or beyond the final 2241 offset. 2243 Once a final offset for a stream is known, it cannot change. If a 2244 RST_STREAM or STREAM frame causes the final offset to change for a 2245 stream, an endpoint SHOULD respond with a 2246 QUIC_STREAM_DATA_AFTER_TERMINATION error (see Section 12). A 2247 receiver SHOULD treat receipt of data at or beyond the final offset 2248 as a QUIC_STREAM_DATA_AFTER_TERMINATION error. Generating these 2249 errors is not mandatory, but only because requiring that an endpoint 2250 generate these errors also means that the endpoint needs to maintain 2251 the final offset state for closed streams, which could mean a 2252 significant state commitment. 2254 An endpoint that receives a RST_STREAM frame (and which has not sent 2255 a FIN or a RST_STREAM) MUST immediately respond with a RST_STREAM 2256 frame, and MUST NOT send any more data on the stream. This endpoint 2257 may continue receiving frames for the stream on which a RST_STREAM is 2258 received. 2260 If this state is reached as a result of sending a RST_STREAM frame, 2261 the peer that receives the RST_STREAM frame might have already sent - 2262 or enqueued for sending - frames on the stream that cannot be 2263 withdrawn. An endpoint MUST ignore frames that it receives on closed 2264 streams after it has sent a RST_STREAM frame. An endpoint MAY choose 2265 to limit the period over which it ignores frames and treat frames 2266 that arrive after this time as being in error. 2268 STREAM frames received after sending RST_STREAM are counted toward 2269 the connection and stream flow-control windows. Even though these 2270 frames might be ignored, because they are sent before their sender 2271 receives the RST_STREAM, the sender will consider the frames to count 2272 against its flow-control windows. 2274 In the absence of more specific guidance elsewhere in this document, 2275 implementations SHOULD treat the receipt of a frame that is not 2276 expressly permitted in the description of a state as a connection 2277 error (Section 12). Frames of unknown types are ignored. 2279 (TODO: QUIC_STREAM_NO_ERROR is a special case. Write it up.) 2281 10.2. Stream Identifiers 2283 Streams are identified by an unsigned 32-bit integer, referred to as 2284 the StreamID. To avoid StreamID collision, clients MUST initiate 2285 streams usinge odd-numbered StreamIDs; streams initiated by the 2286 server MUST use even-numbered StreamIDs. 2288 A StreamID of zero (0x0) is reserved and used for connection-level 2289 flow control frames (Section 11); the StreamID of zero cannot be used 2290 to establish a new stream. 2292 StreamID 1 (0x1) is reserved for the cryptographic handshake. 2293 StreamID 1 MUST NOT be used for application data, and MUST be the 2294 first client-initiated stream. 2296 A QUIC endpoint cannot reuse a StreamID on a given connection. 2297 Streams MUST be created in sequential order. Open streams can be 2298 used in any order. Streams that are used out of order result in 2299 lower-numbered streams in the same direction being counted as open. 2301 All streams, including stream 1, count toward this limit. Thus, a 2302 concurrent stream limit of 0 will cause a connection to be unusable. 2303 Application protocols that use QUIC might require a certain minimum 2304 number of streams to function correctly. If a peer advertises an 2305 concurrent stream limit (concurrent_streams) that is too small for 2306 the selected application protocol to function, an endpoint MUST 2307 terminate the connection with an error of type 2308 QUIC_TOO_MANY_OPEN_STREAMS (Section 12). 2310 10.3. Stream Concurrency 2312 An endpoint limits the number of concurrently active incoming streams 2313 by setting the concurrent stream limit (see Section 7.3.1) in the 2314 transport parameters. The maximum concurrent streams setting is 2315 specific to each endpoint and applies only to the peer that receives 2316 the setting. That is, clients specify the maximum number of 2317 concurrent streams the server can initiate, and servers specify the 2318 maximum number of concurrent streams the client can initiate. 2320 Streams that are in the "open" state or in either of the "half- 2321 closed" states count toward the maximum number of streams that an 2322 endpoint is permitted to open. Streams in any of these three states 2323 count toward the limit advertised in the concurrent stream limit. 2325 A recently closed stream MUST also be considered to count toward this 2326 limit until packets containing all frames required to close the 2327 stream have been acknowledged. For a stream which closed cleanly, 2328 this means all STREAM frames have been acknowledged; for a stream 2329 which closed abruptly, this means the RST_STREAM frame has been 2330 acknowledged. 2332 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 2333 that receives a STREAM frame that causes its advertised concurrent 2334 stream limit to be exceeded MUST treat this as a stream error of type 2335 QUIC_TOO_MANY_OPEN_STREAMS (Section 12). 2337 10.4. Sending and Receiving Data 2339 Once a stream is created, endpoints may use the stream to send and 2340 receive data. Each endpoint may send a series of STREAM frames 2341 encapsulating data on a stream until the stream is terminated in that 2342 direction. Streams are an ordered byte-stream abstraction, and they 2343 have no other structure within them. STREAM frame boundaries are not 2344 expected to be preserved in retransmissions from the sender or during 2345 delivery to the application at the receiver. 2347 When new data is to be sent on a stream, a sender MUST set the 2348 encapsulating STREAM frame's offset field to the stream offset of the 2349 first byte of this new data. The first byte of data that is sent on 2350 a stream has the stream offset 0. The largest offset delivered on a 2351 stream MUST be less than 2^64. A receiver MUST ensure that received 2352 stream data is delivered to the application as an ordered byte- 2353 stream. Data received out of order MUST be buffered for later 2354 delivery, as long as it is not in violation of the receiver's flow 2355 control limits. 2357 The cryptographic handshake stream, Stream 1, MUST NOT be subject to 2358 congestion control or connection-level flow control, but MUST be 2359 subject to stream-level flow control. An endpoint MUST NOT send data 2360 on any other stream without consulting the congestion controller and 2361 the flow controller. 2363 Flow control is described in detail in Section 11, and congestion 2364 control is described in the companion document [QUIC-RECOVERY]. 2366 10.5. Stream Prioritization 2368 Stream multiplexing has a significant effect on application 2369 performance if resources allocated to streams are correctly 2370 prioritized. Experience with other multiplexed protocols, such as 2371 HTTP/2 [RFC7540], shows that effective prioritization strategies have 2372 a significant positive impact on performance. 2374 QUIC does not provide frames for exchanging priotization information. 2375 Instead it relies on receiving priority information from the 2376 application that uses QUIC. Protocols that use QUIC are able to 2377 define any prioritization scheme that suits their application 2378 semantics. A protocol might define explicit messages for signaling 2379 priority, such as those defined in HTTP/2; it could define rules that 2380 allow an endpoint to determine priority based on context; or it could 2381 leave the determination to the application. 2383 A QUIC implementation SHOULD provide ways in which an application can 2384 indicate the relative priority of streams. When deciding which 2385 streams to dedicate resources to, QUIC SHOULD use the information 2386 provided by the application. Failure to account for priority of 2387 streams can result in suboptimal performance. 2389 Stream priority is most relevant when deciding which stream data will 2390 be transmitted. Often, there will be limits on what can be 2391 transmitted as a result of connection flow control or the current 2392 congestion controller state. 2394 Giving preference to the transmission of its own management frames 2395 ensures that the protocol functions efficiently. That is, 2396 prioritizing frames other than STREAM frames ensures that loss 2397 recovery, congestion control, and flow control operate effectively. 2399 Stream 1 MUST be prioritized over other streams prior to the 2400 completion of the cryptographic handshake. This includes the 2401 retransmission of the second flight of client handshake messages, 2402 that is, the TLS Finished and any client authentication messages. 2404 STREAM frames that are determined to be lost SHOULD be retransmitted 2405 before sending new data, unless application priorities indicate 2406 otherwise. Retransmitting lost STREAM frames can fill in gaps, which 2407 allows the peer to consume already received data and free up flow 2408 control window. 2410 11. Flow Control 2412 It is necessary to limit the amount of data that a sender may have 2413 outstanding at any time, so as to prevent a fast sender from 2414 overwhelming a slow receiver, or to prevent a malicious sender from 2415 consuming significant resources at a receiver. This section 2416 describes QUIC's flow-control mechanisms. 2418 QUIC employs a credit-based flow-control scheme similar to HTTP/2's 2419 flow control [RFC7540]. A receiver advertises the number of octets 2420 it is prepared to receive on a given stream and for the entire 2421 connection. This leads to two levels of flow control in QUIC: (i) 2422 Connection flow control, which prevents senders from exceeding a 2423 receiver's buffer capacity for the connection, and (ii) Stream flow 2424 control, which prevents a single stream from consuming the entire 2425 receive buffer for a connection. 2427 A receiver sends WINDOW_UPDATE frames to the sender to advertise 2428 additional credit by sending the absolute byte offset in the stream 2429 or in the connection which it is willing to receive. 2431 The initial flow control credit is 65536 bytes for both the stream 2432 and connection flow controllers. 2434 A receiver MAY advertise a larger offset at any point in the 2435 connection by sending a WINDOW_UPDATE frame. A receiver MUST NOT 2436 renege on an advertisement; that is, once a receiver advertises an 2437 offset via a WINDOW_UPDATE frame, it MUST NOT subsequently advertise 2438 a smaller offset. A sender may receive WINDOW_UPDATE frames out of 2439 order; a sender MUST therefore ignore any WINDOW_UPDATE that does not 2440 move the window forward. 2442 A receiver MUST close the connection with a 2443 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA error (Section 12) if the 2444 peer violates the advertised stream or connection flow control 2445 windows. 2447 A sender MUST send BLOCKED frames to indicate it has data to write 2448 but is blocked by lack of connection or stream flow control credit. 2449 BLOCKED frames are expected to be sent infrequently in common cases, 2450 but they are considered useful for debugging and monitoring purposes. 2452 A receiver advertises credit for a stream by sending a WINDOW_UPDATE 2453 frame with the StreamID set appropriately. A receiver may use the 2454 current offset of data consumed to determine the flow control offset 2455 to be advertised. A receiver MAY send copies of a WINDOW_UPDATE 2456 frame in multiple packets in order to make sure that the sender 2457 receives it before running out of flow control credit, even if one of 2458 the packets is lost. 2460 Connection flow control is a limit to the total bytes of stream data 2461 sent in STREAM frames on all streams contributing to connection flow 2462 control. A receiver advertises credit for a connection by sending a 2463 WINDOW_UPDATE frame with the StreamID set to zero (0x00). A receiver 2464 maintains a cumulative sum of bytes received on all streams 2465 contributing to connection-level flow control, to check for flow 2466 control violations. A receiver may maintain a cumulative sum of 2467 bytes consumed on all contributing streams to determine the 2468 connection-level flow control offset to be advertised. 2470 11.1. Edge Cases and Other Considerations 2472 There are some edge cases which must be considered when dealing with 2473 stream and connection level flow control. Given enough time, both 2474 endpoints must agree on flow control state. If one end believes it 2475 can send more than the other end is willing to receive, the 2476 connection will be torn down when too much data arrives. Conversely 2477 if a sender believes it is blocked, while endpoint B expects more 2478 data can be received, then the connection can be in a deadlock, with 2479 the sender waiting for a WINDOW_UPDATE which will never come. 2481 11.1.1. Mid-stream RST_STREAM 2483 On receipt of a RST_STREAM frame, an endpoint will tear down state 2484 for the matching stream and ignore further data arriving on that 2485 stream. This could result in the endpoints getting out of sync, 2486 since the RST_STREAM frame may have arrived out of order and there 2487 may be further bytes in flight. The data sender would have counted 2488 the data against its connection level flow control budget, but a 2489 receiver that has not received these bytes would not know to include 2490 them as well. The receiver must learn the number of bytes that were 2491 sent on the stream to make the same adjustment in its connection flow 2492 controller. 2494 To avoid this de-synchronization, a RST_STREAM sender MUST include 2495 the final byte offset sent on the stream in the RST_STREAM frame. On 2496 receiving a RST_STREAM frame, a receiver definitively knows how many 2497 bytes were sent on that stream before the RST_STREAM frame, and the 2498 receiver MUST use the final offset to account for all bytes sent on 2499 the stream in its connection level flow controller. 2501 11.1.2. Response to a RST_STREAM 2503 Since streams are bidirectional, a sender of a RST_STREAM needs to 2504 know how many bytes the peer has sent on the stream. If an endpoint 2505 receives a RST_STREAM frame and has sent neither a FIN nor a 2506 RST_STREAM, it MUST send a RST_STREAM in response, bearing the offset 2507 of the last byte sent on this stream as the final offset. 2509 11.1.3. Offset Increment 2511 This document leaves when and how many bytes to advertise in a 2512 WINDOW_UPDATE to the implementation, but offers a few considerations. 2513 WINDOW_UPDATE frames constitute overhead, and therefore, sending a 2514 WINDOW_UPDATE with small offset increments is undesirable. At the 2515 same time, sending WINDOW_UPDATES with large offset increments 2516 requires the sender to commit to that amount of buffer. 2518 Implementations must find the correct tradeoff between these sides to 2519 determine how large an offset increment to send in a WINDOW_UPDATE. 2521 A receiver MAY use an autotuning mechanism to tune the size of the 2522 offset increment to advertise based on a roundtrip time estimate and 2523 the rate at which the receiving application consumes data, similar to 2524 common TCP implementations. 2526 11.1.4. BLOCKED frames 2528 If a sender does not receive a WINDOW_UPDATE frame when it has run 2529 out of flow control credit, the sender will be blocked and MUST send 2530 a BLOCKED frame. A BLOCKED frame is expected to be useful for 2531 debugging at the receiver. A receiver SHOULD NOT wait for a BLOCKED 2532 frame before sending a WINDOW_UPDATE, since doing so will cause at 2533 least one roundtrip of quiescence. For smooth operation of the 2534 congestion controller, it is generally considered best to not let the 2535 sender go into quiescence if avoidable. To avoid blocking a sender, 2536 and to reasonably account for the possibiity of loss, a receiver 2537 should send a WINDOW_UPDATE frame at least two roundtrips before it 2538 expects the sender to get blocked. 2540 12. Error Handling 2542 An endpoint that detects an error SHOULD signal the existence of that 2543 error to its peer. Errors can affect an entire connection (see 2544 Section 12.1), or a single stream (see Section 12.2). 2546 The most appropriate error code (Section 12.3) SHOULD be included in 2547 the frame that signals the error. Where this specification 2548 identifies error conditions, it also identifies the error code that 2549 is used. 2551 Public Reset is not suitable for any error that can be signaled with 2552 a CONNECTION_CLOSE or RST_STREAM frame. Public Reset MUST NOT be 2553 sent by an endpoint that has the state necessary to send a frame on 2554 the connection. 2556 12.1. Connection Errors 2558 Errors that result in the connection being unusable, such as an 2559 obvious violation of protocol semantics or corruption of state that 2560 affects an entire connection, MUST be signaled using a 2561 CONNECTION_CLOSE frame (Section 8.8). An endpoint MAY close the 2562 connection in this manner, even if the error only affects a single 2563 stream. 2565 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 2566 endpoint SHOULD be prepared to retransmit a packet containing a 2567 CONNECTION_CLOSE frame if it receives more packets on a terminated 2568 connection. Limiting the number of retransmissions and the time over 2569 which this final packet is sent limits the effort expended on 2570 terminated connections. 2572 An endpoint that chooses not to retransmit packets containing 2573 CONNECTION_CLOSE risks a peer missing the first such packet. The 2574 only mechanism available to an endpoint that continues to receive 2575 data for a terminated connection is to send a Public Reset packet. 2577 12.2. Stream Errors 2579 If the error affects a single stream, but otherwise leaves the 2580 connection in a recoverable state, the endpoint can sent a RST_STREAM 2581 frame (Section 8.5) with an appropriate error code to terminate just 2582 the affected stream. 2584 Stream 1 is critical to the functioning of the entire connection. If 2585 stream 1 is closed with either a RST_STREAM or STREAM frame bearing 2586 the FIN flag, an endpoint MUST generate a connection error of type 2587 QUIC_CLOSED_CRITICAL_STREAM. 2589 Some application protocols make other streams critical to that 2590 protocol. An application protocol does not need to inform the 2591 transport that a stream is critical; it can instead generate 2592 appropriate errors in response to being notified that the critical 2593 stream is closed. 2595 An endpoint MAY send a RST_STREAM frame in the same packet as a 2596 CONNECTION_CLOSE frame. 2598 12.3. Error Codes 2600 Error codes are 32 bits long, with the first two bits indicating the 2601 source of the error code: 2603 0x00000000-0x3FFFFFFF: Application-specific error codes. Defined by 2604 each application-layer protocol. 2606 0x40000000-0x7FFFFFFF: Reserved for host-local error codes. These 2607 codes MUST NOT be sent to a peer, but MAY be used in API return 2608 codes and logs. 2610 0x80000000-0xBFFFFFFF: QUIC transport error codes, including packet 2611 protection errors. Applicable to all uses of QUIC. 2613 0xC0000000-0xFFFFFFFF: Cryptographic error codes. Defined by the 2614 cryptographic handshake protocol in use. 2616 This section lists the defined QUIC transport error codes that may be 2617 used in a CONNECTION_CLOSE or RST_STREAM frame. Error codes share a 2618 common code space. Some error codes apply only to either streams or 2619 the entire connection and have no defined semantics in the other 2620 context. 2622 QUIC_INTERNAL_ERROR (0x80000001): Connection has reached an invalid 2623 state. 2625 QUIC_STREAM_DATA_AFTER_TERMINATION (0x80000002): There were data 2626 frames after the a fin or reset. 2628 QUIC_INVALID_PACKET_HEADER (0x80000003): Control frame is malformed. 2630 QUIC_INVALID_FRAME_DATA (0x80000004): Frame data is malformed. 2632 QUIC_MULTIPLE_TERMINATION_OFFSETS (0x80000005): Multiple final 2633 offset values were received on the same stream 2635 QUIC_STREAM_CANCELLED (0x80000006): The stream was cancelled 2637 QUIC_CLOSED_CRITICAL_STREAM (0x80000007): A stream that is critical 2638 to the protocol was closed. 2640 QUIC_MISSING_PAYLOAD (0x80000030): The packet contained no payload. 2642 QUIC_INVALID_STREAM_DATA (0x8000002E): STREAM frame data is 2643 malformed. 2645 QUIC_UNENCRYPTED_STREAM_DATA (0x8000003D): Received STREAM frame 2646 data is not encrypted. 2648 QUIC_MAYBE_CORRUPTED_MEMORY (0x80000059): Received a frame which is 2649 likely the result of memory corruption. 2651 QUIC_INVALID_RST_STREAM_DATA (0x80000006): RST_STREAM frame data is 2652 malformed. 2654 QUIC_INVALID_CONNECTION_CLOSE_DATA (0x80000007): CONNECTION_CLOSE 2655 frame data is malformed. 2657 QUIC_INVALID_GOAWAY_DATA (0x80000008): GOAWAY frame data is 2658 malformed. 2660 QUIC_INVALID_WINDOW_UPDATE_DATA (0x80000039): WINDOW_UPDATE frame 2661 data is malformed. 2663 QUIC_INVALID_BLOCKED_DATA (0x8000003A): BLOCKED frame data is 2664 malformed. 2666 QUIC_INVALID_PATH_CLOSE_DATA (0x8000004E): PATH_CLOSE frame data is 2667 malformed. 2669 QUIC_INVALID_ACK_DATA (0x80000009): ACK frame data is malformed. 2671 QUIC_INVALID_VERSION_NEGOTIATION_PACKET (0x8000000A): Version 2672 negotiation packet is malformed. 2674 QUIC_INVALID_PUBLIC_RST_PACKET (0x8000000b): Public RST packet is 2675 malformed. 2677 QUIC_DECRYPTION_FAILURE (0x8000000c): There was an error decrypting. 2679 QUIC_ENCRYPTION_FAILURE (0x8000000d): There was an error encrypting. 2681 QUIC_PACKET_TOO_LARGE (0x8000000e): The packet exceeded 2682 kMaxPacketSize. 2684 QUIC_PEER_GOING_AWAY (0x80000010): The peer is going away. May be a 2685 client or server. 2687 QUIC_INVALID_STREAM_ID (0x80000011): A stream ID was invalid. 2689 QUIC_INVALID_PRIORITY (0x80000031): A priority was invalid. 2691 QUIC_TOO_MANY_OPEN_STREAMS (0x80000012): Too many streams already 2692 open. 2694 QUIC_TOO_MANY_AVAILABLE_STREAMS (0x8000004c): The peer created too 2695 many available streams. 2697 QUIC_PUBLIC_RESET (0x80000013): Received public reset for this 2698 connection. 2700 QUIC_INVALID_VERSION (0x80000014): Invalid protocol version. 2702 QUIC_INVALID_HEADER_ID (0x80000016): The Header ID for a stream was 2703 too far from the previous. 2705 QUIC_INVALID_NEGOTIATED_VALUE (0x80000017): Negotiable parameter 2706 received during handshake had invalid value. 2708 QUIC_DECOMPRESSION_FAILURE (0x80000018): There was an error 2709 decompressing data. 2711 QUIC_NETWORK_IDLE_TIMEOUT (0x80000019): The connection timed out due 2712 to no network activity. 2714 QUIC_HANDSHAKE_TIMEOUT (0x80000043): The connection timed out 2715 waiting for the handshake to complete. 2717 QUIC_ERROR_MIGRATING_ADDRESS (0x8000001a): There was an error 2718 encountered migrating addresses. 2720 QUIC_ERROR_MIGRATING_PORT (0x80000056): There was an error 2721 encountered migrating port only. 2723 QUIC_EMPTY_STREAM_FRAME_NO_FIN (0x80000032): We received a 2724 STREAM_FRAME with no data and no fin flag set. 2726 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA (0x8000003b): The peer 2727 received too much data, violating flow control. 2729 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA (0x8000003f): The peer sent too 2730 much data, violating flow control. 2732 QUIC_FLOW_CONTROL_INVALID_WINDOW (0x80000040): The peer received an 2733 invalid flow control window. 2735 QUIC_CONNECTION_IP_POOLED (0x8000003e): The connection has been IP 2736 pooled into an existing connection. 2738 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS (0x80000044): The connection 2739 has too many outstanding sent packets. 2741 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS (0x80000045): The 2742 connection has too many outstanding received packets. 2744 QUIC_CONNECTION_CANCELLED (0x80000046): The QUIC connection has been 2745 cancelled. 2747 QUIC_BAD_PACKET_LOSS_RATE (0x80000047): Disabled QUIC because of 2748 high packet loss rate. 2750 QUIC_PUBLIC_RESETS_POST_HANDSHAKE (0x80000049): Disabled QUIC 2751 because of too many PUBLIC_RESETs post handshake. 2753 QUIC_TIMEOUTS_WITH_OPEN_STREAMS (0x8000004a): Disabled QUIC because 2754 of too many timeouts with streams open. 2756 QUIC_TOO_MANY_RTOS (0x80000055): QUIC timed out after too many RTOs. 2758 QUIC_ENCRYPTION_LEVEL_INCORRECT (0x8000002c): A packet was received 2759 with the wrong encryption level (i.e. it should have been 2760 encrypted but was not.) 2762 QUIC_VERSION_NEGOTIATION_MISMATCH (0x80000037): This connection 2763 involved a version negotiation which appears to have been tampered 2764 with. 2766 QUIC_IP_ADDRESS_CHANGED (0x80000050): IP address changed causing 2767 connection close. 2769 QUIC_ADDRESS_VALIDATION_FAILURE (0x80000051): Client address 2770 validation failed. 2772 QUIC_TOO_MANY_FRAME_GAPS (0x8000005d): Stream frames arrived too 2773 discontiguously so that stream sequencer buffer maintains too many 2774 gaps. 2776 QUIC_TOO_MANY_SESSIONS_ON_SERVER (0x80000060): Connection closed 2777 because server hit max number of sessions allowed. 2779 13. Security and Privacy Considerations 2781 13.1. Spoofed ACK Attack 2783 An attacker receives an STK from the server and then releases the IP 2784 address on which it received the STK. The attacker may, in the 2785 future, spoof this same address (which now presumably addresses a 2786 different endpoint), and initiate a 0-RTT connection with a server on 2787 the victim's behalf. The attacker then spoofs ACK frames to the 2788 server which cause the server to potentially drown the victim in 2789 data. 2791 There are two possible mitigations to this attack. The simplest one 2792 is that a server can unilaterally create a gap in packet-number 2793 space. In the non-attack scenario, the client will send an ACK frame 2794 with the larger value for largest acknowledged. In the attack 2795 scenario, the attacker could acknowledge a packet in the gap. If the 2796 server sees an acknowledgment for a packet that was never sent, the 2797 connection can be aborted. 2799 The second mitigation is that the server can require that 2800 acknowledgments for sent packets match the encryption level of the 2801 sent packet. This mitigation is useful if the connection has an 2802 ephemeral forward-secure key that is generated and used for every new 2803 connection. If a packet sent is encrypted with a forward-secure key, 2804 then any acknowledgments that are received for them MUST also be 2805 forward-secure encrypted. Since the attacker will not have the 2806 forward secure key, the attacker will not be able to generate 2807 forward-secure encrypted packets with ACK frames. 2809 14. IANA Considerations 2811 14.1. QUIC Transport Parameter Registry 2813 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 2814 under a "QUIC Protocol" heading. 2816 The "QUIC Transport Parameters" registry governs a 16-bit space. 2817 This space is split into two spaces that are governed by different 2818 policies. Values with the first byte in the range 0x00 to 0xfe (in 2819 hexadecimal) are assigned via the Specification Required policy 2820 [RFC5226]. Values with the first byte 0xff are reserved for Private 2821 Use [RFC5226]. 2823 Registrations MUST include the following fields: 2825 Value: The numeric value of the assignment (registrations will be 2826 between 0x0000 and 0xfeff). 2828 Parameter Name: A short mnemonic for the parameter. 2830 Specification: A reference to a publicly available specification for 2831 the value. 2833 The nominated expert(s) verify that a specification exists and is 2834 readily accessible. The expert(s) are encouraged to be biased 2835 towards approving registrations unless they are abusive, frivolous, 2836 or actively harmful (not merely aesthetically displeasing, or 2837 architecturally dubious). 2839 The initial contents of this registry are shown in Table 4. 2841 +--------+------------------------+---------------+ 2842 | Value | Parameter Name | Specification | 2843 +--------+------------------------+---------------+ 2844 | 0x0000 | stream_fc_offset | Section 7.3.1 | 2845 | | | | 2846 | 0x0001 | connection_fc_offset | Section 7.3.1 | 2847 | | | | 2848 | 0x0002 | concurrent_streams | Section 7.3.1 | 2849 | | | | 2850 | 0x0003 | idle_timeout | Section 7.3.1 | 2851 | | | | 2852 | 0x0004 | truncate_connection_id | Section 7.3.1 | 2853 +--------+------------------------+---------------+ 2855 Table 4: Initial QUIC Transport Parameters Entries 2857 15. References 2859 15.1. Normative References 2861 [I-D.ietf-tls-tls13] 2862 Rescorla, E., "The Transport Layer Security (TLS) Protocol 2863 Version 1.3", draft-ietf-tls-tls13-19 (work in progress), 2864 March 2017. 2866 [QUIC-RECOVERY] 2867 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 2868 and Congestion Control". 2870 [QUIC-TLS] 2871 Thomson, M., Ed. and S. Turner, Ed., "Using Transport 2872 Layer Security (TLS) to Secure QUIC". 2874 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 2875 DOI 10.17487/RFC1191, November 1990, 2876 . 2878 [RFC1981] McCann, J., Deering, S., and J. Mogul, "Path MTU Discovery 2879 for IP version 6", RFC 1981, DOI 10.17487/RFC1981, August 2880 1996, . 2882 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2883 Requirement Levels", BCP 14, RFC 2119, 2884 DOI 10.17487/RFC2119, March 1997, 2885 . 2887 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 2888 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 2889 . 2891 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 2892 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 2893 DOI 10.17487/RFC5226, May 2008, 2894 . 2896 15.2. Informative References 2898 [EARLY-DESIGN] 2899 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 2900 December 2013, . 2902 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 2903 RFC 2360, DOI 10.17487/RFC2360, June 1998, 2904 . 2906 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 2907 "Randomness Requirements for Security", BCP 106, RFC 4086, 2908 DOI 10.17487/RFC4086, June 2005, 2909 . 2911 [RFC6824] Ford, A., Raiciu, C., Handley, M., and O. Bonaventure, 2912 "TCP Extensions for Multipath Operation with Multiple 2913 Addresses", RFC 6824, DOI 10.17487/RFC6824, January 2013, 2914 . 2916 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 2917 "Transport Layer Security (TLS) Application-Layer Protocol 2918 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 2919 July 2014, . 2921 [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 2922 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 2923 DOI 10.17487/RFC7540, May 2015, 2924 . 2926 [SST] Ford, B., "Structured Streams: A New Transport 2927 Abstraction", DOI 10.1145/1282427.1282421, ACM 2928 SIGCOMM Computer Communication Review Volume 37 Issue 4, 2929 October 2007. 2931 15.3. URIs 2933 [1] https://github.com/quicwg/base-drafts/wiki/QUIC-Versions 2935 Appendix A. Contributors 2937 The original authors of this specification were Ryan Hamilton, Jana 2938 Iyengar, Ian Swett, and Alyssa Wilk. 2940 The original design and rationale behind this protocol draw 2941 significantly from work by Jim Roskind [EARLY-DESIGN]. In 2942 alphabetical order, the contributors to the pre-IETF QUIC project at 2943 Google are: Britt Cyr, Jeremy Dorfman, Ryan Hamilton, Jana Iyengar, 2944 Fedor Kouranov, Charles Krasic, Jo Kulik, Adam Langley, Jim Roskind, 2945 Robbie Shade, Satyam Shekhar, Cherie Shi, Ian Swett, Raman Tenneti, 2946 Victor Vasiliev, Antonio Vicente, Patrik Westin, Alyssa Wilk, Dale 2947 Worley, Fan Yang, Dan Zhang, Daniel Ziegler. 2949 Appendix B. Acknowledgments 2951 Special thanks are due to the following for helping shape pre-IETF 2952 QUIC and its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, 2953 Alistair Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. 2955 This document has benefited immensely from various private 2956 discussions and public ones on the quic@ietf.org and proto- 2957 quic@chromium.org mailing lists. Our thanks to all. 2959 Appendix C. Change Log 2961 *RFC Editor's Note:* Please remove this section prior to 2962 publication of a final version of this document. 2964 Issue and pull request numbers are listed with a leading octothorp. 2966 C.1. Since draft-ietf-quic-transport-01: 2968 o Defined short and long packet headers (#40, #148, #361) 2970 o Defined a versioning scheme and stable fields (#51, #361) 2972 o Define reserved version values for "greasing" negotiation (#112, 2973 #278) 2975 o The initial packet number is randomized (#35, #283) 2977 o Narrow the packet number encoding range requirement (#67, #286, 2978 #299, #323, #356) 2980 o Defined client address validation (#52, #118, #120, #275) 2982 o Define transport parameters as a TLS extension (#122) 2984 o SCUP and COPT parameters are no longer valid (#116, #117) 2986 o Transport parameters for 0-RTT are either remembered from before, 2987 or assume default values (#126) 2989 o The server chooses connection IDs in its final flight (#119, #349, 2990 #361) 2992 o The server echoes the Connection ID and packet number fields when 2993 sending a Version Negotiation packet (#133, #295, #244) 2995 o Definied a minimum packet size for the initial handshake packet 2996 from the client (#69, #136, #139, #164) 2998 o Path MTU Discovery (#64, #106) 3000 o The initial handshake packet from the client needs to fit in a 3001 single packet (#338) 3003 o Forbid acknowledgment of packets containing only ACK and PADDING 3004 (#291) 3006 o Require that frames are processed when packets are acknowledged 3007 (#381, #341) 3009 o Removed the STOP_WAITING frame (#66) 3011 o Don't require retransmission of old timestamps for lost ACK frames 3012 (#308) 3014 o Clarified that frames are not retransmitted, but the information 3015 in them can be (#157, #298) 3017 o Error handling definitions (#335) 3019 o Split error codes into four sections (#74) 3021 o Forbid the use of Public Reset where CONNECTION_CLOSE is possible 3022 (#289) 3024 o Define packet protection rules (#336) 3025 o Require that stream be entirely delivered or reset, including 3026 acknowledgment of all STREAM frames or the RST_STREAM, before it 3027 closes (#381) 3029 o Remove stream reservation from state machine (#174, #280) 3031 o Only stream 0 does not contributing to connection-level flow 3032 control (#204) 3034 o Stream 1 counts towards the maximum concurrent stream limit (#201, 3035 #282) 3037 o Remove connection-level flow control exclusion for some streams 3038 (except 1) (#246) 3040 o RST_STREAM affects connection-level flow control (#162, #163) 3042 o Flow control accounting uses the maximum data offset on each 3043 stream, rather than bytes received (#378) 3045 o Moved length-determining fields to the start of STREAM and ACK 3046 (#168, #277) 3048 o Added the ability to pad between frames (#158, #276) 3050 o Remove error code and reason phrase from GOAWAY (#352, #355) 3052 o GOAWAY includes a final stream number for both directions (#347) 3054 o Error codes for RST_STREAM and CONNECTION_CLOSE are now at a 3055 consistent offset (#249) 3057 o Defined priority as the responsibility of the application protocol 3058 (#104, #303) 3060 C.2. Since draft-ietf-quic-transport-00: 3062 o Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 3064 o Defined versioning 3066 o Reworked description of packet and frame layout 3068 o Error code space is divided into regions for each component 3070 o Use big endian for all numeric values 3072 C.3. Since draft-hamilton-quic-transport-protocol-01: 3074 o Adopted as base for draft-ietf-quic-tls. 3076 o Updated authors/editors list. 3078 o Added IANA Considerations section. 3080 o Moved Contributors and Acknowledgments to appendices. 3082 Authors' Addresses 3084 Jana Iyengar (editor) 3085 Google 3087 Email: jri@google.com 3089 Martin Thomson (editor) 3090 Mozilla 3092 Email: martin.thomson@gmail.com