idnits 2.17.1 draft-ietf-quic-transport-04.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. == 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 'MUST not' in this paragraph: QUIC ACK frames contain a timestamp section with up to 255 timestamps. Timestamps enable better congestion control, but are not required for correct loss recovery, and old timestamps are less valuable, so it is not guaranteed every timestamp will be received by the sender. A receiver SHOULD send a timestamp exactly once for each received packet containing retransmittable frames. A receiver MAY send timestamps for non-retransmittable packets. A receiver MUST not send timestamps in unprotected packets. -- The document date (June 13, 2017) is 2509 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 391 -- Looks like a reference, but probably isn't: '1' on line 3325 == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-20 ** 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 (~~), 5 warnings (==), 6 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: December 15, 2017 Mozilla 6 June 13, 2017 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-04 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 December 15, 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 . . . . . . . . . . . . . . . . . 5 64 2.1. Notational Conventions . . . . . . . . . . . . . . . . . 5 65 3. A QUIC Overview . . . . . . . . . . . . . . . . . . . . . . . 6 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 . 7 69 3.4. Stream and Connection Flow Control . . . . . . . . . . . 7 70 3.5. Authenticated and Encrypted Header and Payload . . . . . 7 71 3.6. Connection Migration and Resilience to NAT Rebinding . . 8 72 3.7. Version Negotiation . . . . . . . . . . . . . . . . . . . 8 73 4. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 8 74 5. Packet Types and Formats . . . . . . . . . . . . . . . . . . 9 75 5.1. Long Header . . . . . . . . . . . . . . . . . . . . . . . 9 76 5.2. Short Header . . . . . . . . . . . . . . . . . . . . . . 11 77 5.3. Version Negotiation Packet . . . . . . . . . . . . . . . 13 78 5.4. Cleartext Packets . . . . . . . . . . . . . . . . . . . . 14 79 5.4.1. Client Initial Packet . . . . . . . . . . . . . . . . 14 80 5.4.2. Server Stateless Retry Packet . . . . . . . . . . . . 15 81 5.4.3. Server Cleartext Packet . . . . . . . . . . . . . . . 15 82 5.4.4. Client Cleartext Packet . . . . . . . . . . . . . . . 16 83 5.5. Protected Packets . . . . . . . . . . . . . . . . . . . . 16 84 5.6. Public Reset Packet . . . . . . . . . . . . . . . . . . . 17 85 5.6.1. Public Reset Proof . . . . . . . . . . . . . . . . . 18 86 5.7. Connection ID . . . . . . . . . . . . . . . . . . . . . . 18 87 5.8. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 18 88 5.8.1. Initial Packet Number . . . . . . . . . . . . . . . . 19 89 5.9. Handling Packets from Different Versions . . . . . . . . 20 90 6. Frames and Frame Types . . . . . . . . . . . . . . . . . . . 20 91 7. Life of a Connection . . . . . . . . . . . . . . . . . . . . 22 92 7.1. Version Negotiation . . . . . . . . . . . . . . . . . . . 23 93 7.1.1. Using Reserved Versions . . . . . . . . . . . . . . . 24 94 7.2. Cryptographic and Transport Handshake . . . . . . . . . . 24 95 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 25 96 7.3.1. Transport Parameter Definitions . . . . . . . . . . . 27 97 7.3.2. Values of Transport Parameters for 0-RTT . . . . . . 28 98 7.3.3. New Transport Parameters . . . . . . . . . . . . . . 28 99 7.3.4. Version Negotiation Validation . . . . . . . . . . . 28 100 7.4. Stateless Retries . . . . . . . . . . . . . . . . . . . . 30 101 7.5. Proof of Source Address Ownership . . . . . . . . . . . . 30 102 7.5.1. Client Address Validation Procedure . . . . . . . . . 31 103 7.5.2. Address Validation on Session Resumption . . . . . . 32 104 7.5.3. Address Validation Token Integrity . . . . . . . . . 32 105 7.6. Connection Migration . . . . . . . . . . . . . . . . . . 33 106 7.6.1. Privacy Implications of Connection Migration . . . . 33 107 7.6.2. Address Validation for Migrated Connections . . . . . 34 108 7.7. Connection Termination . . . . . . . . . . . . . . . . . 34 109 8. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 35 110 8.1. STREAM Frame . . . . . . . . . . . . . . . . . . . . . . 35 111 8.2. ACK Frame . . . . . . . . . . . . . . . . . . . . . . . . 37 112 8.2.1. ACK Block Section . . . . . . . . . . . . . . . . . . 39 113 8.2.2. Timestamp Section . . . . . . . . . . . . . . . . . . 40 114 8.2.3. ACK Frames and Packet Protection . . . . . . . . . . 41 115 8.3. MAX_DATA Frame . . . . . . . . . . . . . . . . . . . . . 42 116 8.4. MAX_STREAM_DATA Frame . . . . . . . . . . . . . . . . . . 43 117 8.5. MAX_STREAM_ID Frame . . . . . . . . . . . . . . . . . . . 44 118 8.6. BLOCKED Frame . . . . . . . . . . . . . . . . . . . . . . 44 119 8.7. STREAM_BLOCKED Frame . . . . . . . . . . . . . . . . . . 44 120 8.8. STREAM_ID_NEEDED Frame . . . . . . . . . . . . . . . . . 45 121 8.9. RST_STREAM Frame . . . . . . . . . . . . . . . . . . . . 45 122 8.10. PADDING Frame . . . . . . . . . . . . . . . . . . . . . . 46 123 8.11. PING frame . . . . . . . . . . . . . . . . . . . . . . . 46 124 8.12. NEW_CONNECTION_ID Frame . . . . . . . . . . . . . . . . . 46 125 8.13. CONNECTION_CLOSE frame . . . . . . . . . . . . . . . . . 47 126 8.14. GOAWAY Frame . . . . . . . . . . . . . . . . . . . . . . 48 127 9. Packetization and Reliability . . . . . . . . . . . . . . . . 49 128 9.1. Special Considerations for PMTU Discovery . . . . . . . . 51 129 10. Streams: QUIC's Data Structuring Abstraction . . . . . . . . 51 130 10.1. Stream Identifiers . . . . . . . . . . . . . . . . . . . 52 131 10.2. Life of a Stream . . . . . . . . . . . . . . . . . . . . 52 132 10.2.1. idle . . . . . . . . . . . . . . . . . . . . . . . . 54 133 10.2.2. open . . . . . . . . . . . . . . . . . . . . . . . . 54 134 10.2.3. half-closed (local) . . . . . . . . . . . . . . . . 55 135 10.2.4. half-closed (remote) . . . . . . . . . . . . . . . . 55 136 10.2.5. closed . . . . . . . . . . . . . . . . . . . . . . . 56 137 10.3. Stream Concurrency . . . . . . . . . . . . . . . . . . . 56 138 10.4. Sending and Receiving Data . . . . . . . . . . . . . . . 57 139 10.5. Stream Prioritization . . . . . . . . . . . . . . . . . 57 140 11. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 58 141 11.1. Edge Cases and Other Considerations . . . . . . . . . . 59 142 11.1.1. Response to a RST_STREAM . . . . . . . . . . . . . . 60 143 11.1.2. Data Limit Increments . . . . . . . . . . . . . . . 60 144 11.2. Stream Limit Increment . . . . . . . . . . . . . . . . . 61 145 11.2.1. Blocking on Flow Control . . . . . . . . . . . . . . 61 146 11.3. Stream Final Offset . . . . . . . . . . . . . . . . . . 61 147 12. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 62 148 12.1. Connection Errors . . . . . . . . . . . . . . . . . . . 62 149 12.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 63 150 12.3. Error Codes . . . . . . . . . . . . . . . . . . . . . . 63 151 13. Security and Privacy Considerations . . . . . . . . . . . . . 67 152 13.1. Spoofed ACK Attack . . . . . . . . . . . . . . . . . . . 67 153 13.2. Slowloris Attacks . . . . . . . . . . . . . . . . . . . 68 154 13.3. Stream Fragmentation and Reassembly Attacks . . . . . . 68 155 13.4. Stream Commitment Attack . . . . . . . . . . . . . . . . 68 156 14. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 69 157 14.1. QUIC Transport Parameter Registry . . . . . . . . . . . 69 158 15. References . . . . . . . . . . . . . . . . . . . . . . . . . 70 159 15.1. Normative References . . . . . . . . . . . . . . . . . . 70 160 15.2. Informative References . . . . . . . . . . . . . . . . . 71 161 15.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 72 162 Appendix A. Contributors . . . . . . . . . . . . . . . . . . . . 72 163 Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 72 164 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 72 165 C.1. Since draft-ietf-quic-transport-02 . . . . . . . . . . . 73 166 C.2. Since draft-ietf-quic-transport-01 . . . . . . . . . . . 74 167 C.3. Since draft-ietf-quic-transport-00 . . . . . . . . . . . 76 168 C.4. Since draft-hamilton-quic-transport-protocol-01 . . . . . 76 169 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 76 171 1. Introduction 173 QUIC is a multiplexed and secure transport protocol that runs on top 174 of UDP. QUIC aims to provide a flexible set of features that allow 175 it to be a general-purpose transport for multiple applications. 177 QUIC implements techniques learned from experience with TCP, SCTP and 178 other transport protocols. Using UDP as the substrate, QUIC seeks to 179 be compatible with legacy clients and middleboxes. QUIC 180 authenticates all of its headers and encrypts most of the data it 181 exchanges, including its signaling. This allows the protocol to 182 evolve without incurring a dependency on upgrades to middleboxes. 183 This document describes the core QUIC protocol, including the 184 conceptual design, wire format, and mechanisms of the QUIC protocol 185 for connection establishment, stream multiplexing, stream and 186 connection-level flow control, and data reliability. 188 Accompanying documents describe QUIC's loss detection and congestion 189 control [QUIC-RECOVERY], and the use of TLS 1.3 for key negotiation 190 [QUIC-TLS]. 192 2. Conventions and Definitions 194 The words "MUST", "MUST NOT", "SHOULD", and "MAY" are used in this 195 document. It's not shouting; when they are capitalized, they have 196 the special meaning defined in [RFC2119]. 198 Definitions of terms that are used in this document: 200 Client: The endpoint initiating a QUIC connection. 202 Server: The endpoint accepting incoming QUIC connections. 204 Endpoint: The client or server end of a connection. 206 Stream: A logical, bi-directional channel of ordered bytes within a 207 QUIC connection. 209 Connection: A conversation between two QUIC endpoints with a single 210 encryption context that multiplexes streams within it. 212 Connection ID: The identifier for a QUIC connection. 214 QUIC packet: A well-formed UDP payload that can be parsed by a QUIC 215 receiver. QUIC packet size in this document refers to the UDP 216 payload size. 218 2.1. Notational Conventions 220 Packet and frame diagrams use the format described in [RFC2360] 221 Section 3.1, with the following additional conventions: 223 [x] Indicates that x is optional 225 {x} Indicates that x is encrypted 227 x (A) Indicates that x is A bits long 229 x (A/B/C) ... Indicates that x is one of A, B, or C bits long 231 x (*) ... Indicates that x is variable-length 233 3. A QUIC Overview 235 This section briefly describes QUIC's key mechanisms and benefits. 236 Key strengths of QUIC include: 238 o Low-latency connection establishment 240 o Multiplexing without head-of-line blocking 242 o Authenticated and encrypted header and payload 244 o Rich signaling for congestion control and loss recovery 246 o Stream and connection flow control 248 o Connection migration and resilience to NAT rebinding 250 o Version negotiation 252 3.1. Low-Latency Connection Establishment 254 QUIC relies on a combined cryptographic and transport handshake for 255 setting up a secure transport connection. QUIC connections are 256 expected to commonly use 0-RTT handshakes, meaning that for most QUIC 257 connections, data can be sent immediately following the client 258 handshake packet, without waiting for a reply from the server. QUIC 259 provides a dedicated stream (Stream ID 0) to be used for performing 260 the cryptographic handshake and QUIC options negotiation. The format 261 of the QUIC options and parameters used during negotiation are 262 described in this document, but the handshake protocol that runs on 263 Stream ID 0 is described in the accompanying cryptographic handshake 264 draft [QUIC-TLS]. 266 3.2. Stream Multiplexing 268 When application messages are transported over TCP, independent 269 application messages can suffer from head-of-line blocking. When an 270 application multiplexes many streams atop TCP's single-bytestream 271 abstraction, a loss of a TCP segment results in blocking of all 272 subsequent segments until a retransmission arrives, irrespective of 273 the application streams that are encapsulated in subsequent segments. 274 QUIC ensures that lost packets carrying data for an individual stream 275 only impact that specific stream. Data received on other streams can 276 continue to be reassembled and delivered to the application. 278 3.3. Rich Signaling for Congestion Control and Loss Recovery 280 QUIC's packet framing and acknowledgments carry rich information that 281 help both congestion control and loss recovery in fundamental ways. 282 Each QUIC packet carries a new packet number, including those 283 carrying retransmitted data. This obviates the need for a separate 284 mechanism to distinguish acknowledgments for retransmissions from 285 those for original transmissions, avoiding TCP's retransmission 286 ambiguity problem. QUIC acknowledgments also explicitly encode the 287 delay between the receipt of a packet and its acknowledgment being 288 sent, and together with the monotonically-increasing packet numbers, 289 this allows for precise network roundtrip-time (RTT) calculation. 290 QUIC's ACK frames support up to 256 ACK blocks, so QUIC is more 291 resilient to reordering than TCP with SACK support, as well as able 292 to keep more bytes on the wire when there is reordering or loss. 294 3.4. Stream and Connection Flow Control 296 QUIC implements stream- and connection-level flow control. At a high 297 level, a QUIC receiver advertises the maximum amount of data that it 298 is willing to receive on each stream. As data is sent, received, and 299 delivered on a particular stream, the receiver sends MAX_STREAM_DATA 300 frames that increase the advertised limit for that stream, allowing 301 the peer to send more data on that stream. 303 In addition to this stream-level flow control, QUIC implements 304 connection-level flow control to limit the aggregate buffer that a 305 QUIC receiver is willing to allocate to all streams on a connection. 306 Connection-level flow control works in the same way as stream-level 307 flow control, but the bytes delivered and the limits are aggregated 308 across all streams. 310 3.5. Authenticated and Encrypted Header and Payload 312 TCP headers appear in plaintext on the wire and are not 313 authenticated, causing a plethora of injection and header 314 manipulation issues for TCP, such as receive-window manipulation and 315 sequence-number overwriting. While some of these are mechanisms used 316 by middleboxes to improve TCP performance, others are active attacks. 317 Even "performance-enhancing" middleboxes that routinely interpose on 318 the transport state machine end up limiting the evolvability of the 319 transport protocol, as has been observed in the design of MPTCP 320 [RFC6824] and in its subsequent deployability issues. 322 Generally, QUIC packets are always authenticated and the payload is 323 typically fully encrypted. The parts of the packet header which are 324 not encrypted are still authenticated by the receiver, so as to 325 thwart any packet injection or manipulation by third parties. Some 326 early handshake packets, such as the Version Negotiation packet, are 327 not encrypted, but information sent in these unencrypted handshake 328 packets is later verified as part of cryptographic processing. 330 PUBLIC_RESET packets that reset a connection are currently not 331 authenticated. 333 3.6. Connection Migration and Resilience to NAT Rebinding 335 QUIC connections are identified by a 64-bit Connection ID, randomly 336 generated by the client. QUIC's consistent connection ID allows 337 connections to survive changes to the client's IP and port, such as 338 those caused by NAT rebindings or by the client changing network 339 connectivity to a new address. QUIC provides automatic cryptographic 340 verification of a rebound client, since the client continues to use 341 the same session key for encrypting and decrypting packets. The 342 consistent connection ID can be used to allow migration of the 343 connection to a new server IP address as well, since the Connection 344 ID remains consistent across changes in the client's and the server's 345 network addresses. 347 3.7. Version Negotiation 349 QUIC version negotiation allows for multiple versions of the protocol 350 to be deployed and used concurrently. Version negotiation is 351 described in Section 7.1. 353 4. Versions 355 QUIC versions are identified using a 32-bit value. 357 The version 0x00000000 is reserved to represent an invalid version. 358 This version of the specification is identified by the number 359 0x00000001. 361 Version 0x00000001 of QUIC uses TLS as a cryptographic handshake 362 protocol, as described in [QUIC-TLS]. 364 Versions with the most significant 16 bits of the version number 365 cleared are reserved for use in future IETF consensus documents. 367 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 368 forcing version negotiation to be exercised. That is, any version 369 number where the low four bits of all octets is 1010 (in binary). A 370 client or server MAY advertise support for any of these reserved 371 versions. 373 Reserved version numbers will probably never represent a real 374 protocol; a client MAY use one of these version numbers with the 375 expectation that the server will initiate version negotiation; a 376 server MAY advertise support for one of these versions and can expect 377 that clients ignore the value. 379 [[RFC editor: please remove the remainder of this section before 380 publication.]] 382 The version number for the final version of this specification 383 (0x00000001), is reserved for the version of the protocol that is 384 published as an RFC. 386 Version numbers used to identify IETF drafts are created by adding 387 the draft number to 0xff000000. For example, draft-ietf-quic- 388 transport-13 would be identified as 0xff00000D. 390 Implementors are encouraged to register version numbers of QUIC that 391 they are using for private experimentation on the github wiki [4]. 393 5. Packet Types and Formats 395 We first describe QUIC's packet types and their formats, since some 396 are referenced in subsequent mechanisms. 398 All numeric values are encoded in network byte order (that is, big- 399 endian) and all field sizes are in bits. When discussing individual 400 bits of fields, the least significant bit is referred to as bit 0. 401 Hexadecimal notation is used for describing the value of fields. 403 Any QUIC packet has either a long or a short header, as indicated by 404 the Header Form bit. Long headers are expected to be used early in 405 the connection before version negotiation and establishment of 1-RTT 406 keys, and for public resets. Short headers are minimal version- 407 specific headers, which can be used after version negotiation and 408 1-RTT keys are established. 410 5.1. Long Header 411 0 1 2 3 412 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 413 +-+-+-+-+-+-+-+-+ 414 |1| Type (7) | 415 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 416 | | 417 + Connection ID (64) + 418 | | 419 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 420 | Packet Number (32) | 421 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 422 | Version (32) | 423 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 424 | Payload (*) ... 425 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 427 Figure 1: Long Header Format 429 Long headers are used for packets that are sent prior to the 430 completion of version negotiation and establishment of 1-RTT keys. 431 Once both conditions are met, a sender SHOULD switch to sending 432 short-form headers. While inefficient, long headers MAY be used for 433 packets encrypted with 1-RTT keys. The long form allows for special 434 packets, such as the Version Negotiation and the Public Reset packets 435 to be represented in this uniform fixed-length packet format. A long 436 header contains the following fields: 438 Header Form: The most significant bit (0x80) of the first octet is 439 set to 1 for long headers and 0 for short headers. 441 Long Packet Type: The remaining seven bits of first octet of a long 442 packet is the packet type. This field can indicate one of 128 443 packet types. The types specified for this version are listed in 444 Table 1. 446 Connection ID: Octets 1 through 8 contain the connection ID. 447 Section 5.7 describes the use of this field in more detail. 449 Packet Number: Octets 9 to 12 contain the packet number. 450 Section 5.8 describes the use of packet numbers. 452 Version: Octets 13 to 16 contain the selected protocol version. 453 This field indicates which version of QUIC is in use and 454 determines how the rest of the protocol fields are interpreted. 456 Payload: Octets from 17 onwards (the rest of QUIC packet) are the 457 payload of the packet. 459 The following packet types are defined: 461 +------+-------------------------------+---------------+ 462 | Type | Name | Section | 463 +------+-------------------------------+---------------+ 464 | 01 | Version Negotiation | Section 5.3 | 465 | | | | 466 | 02 | Client Initial | Section 5.4.1 | 467 | | | | 468 | 03 | Server Stateless Retry | Section 5.4.2 | 469 | | | | 470 | 04 | Server Cleartext | Section 5.4.3 | 471 | | | | 472 | 05 | Client Cleartext | Section 5.4.4 | 473 | | | | 474 | 06 | 0-RTT Protected | Section 5.5 | 475 | | | | 476 | 07 | 1-RTT Protected (key phase 0) | Section 5.5 | 477 | | | | 478 | 08 | 1-RTT Protected (key phase 1) | Section 5.5 | 479 | | | | 480 | 09 | Public Reset | Section 5.6 | 481 +------+-------------------------------+---------------+ 483 Table 1: Long Header Packet Types 485 The header form, packet type, connection ID, packet number and 486 version fields of a long header packet are version-independent. The 487 types of packets defined in Table 1 are version-specific. See 488 Section 5.9 for details on how packets from different versions of 489 QUIC are interpreted. 491 (TODO: Should the list of packet types be version-independent?) 493 The interpretation of the fields and the payload are specific to a 494 version and packet type. Type-specific semantics for this version 495 are described in the following sections. 497 5.2. Short Header 498 0 1 2 3 499 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 500 +-+-+-+-+-+-+-+-+ 501 |0|C|K| Type (5)| 502 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 503 | | 504 + [Connection ID (64)] + 505 | | 506 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 507 | Packet Number (8/16/32) ... 508 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 509 | Protected Payload (*) ... 510 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 512 Figure 2: Short Header Format 514 The short header can be used after the version and 1-RTT keys are 515 negotiated. This header form has the following fields: 517 Header Form: The most significant bit (0x80) of the first octet of a 518 packet is the header form. This bit is set to 0 for the short 519 header. 521 Connection ID Flag: The second bit (0x40) of the first octet 522 indicates whether the Connection ID field is present. If set to 523 1, then the Connection ID field is present; if set to 0, the 524 Connection ID field is omitted. 526 Key Phase Bit: The third bit (0x20) of the first octet indicates the 527 key phase, which allows a recipient of a packet to identify the 528 packet protection keys that are used to protect the packet. See 529 [QUIC-TLS] for details. 531 Short Packet Type: The remaining 5 bits of the first octet include 532 one of 32 packet types. Table 2 lists the types that are defined 533 for short packets. 535 Connection ID: If the Connection ID Flag is set, a connection ID 536 occupies octets 1 through 8 of the packet. See Section 5.7 for 537 more details. 539 Packet Number: The length of the packet number field depends on the 540 packet type. This field can be 1, 2 or 4 octets long depending on 541 the short packet type. 543 Protected Payload: Packets with a short header always include a 544 1-RTT protected payload. 546 The packet type in a short header currently determines only the size 547 of the packet number field. Additional types can be used to signal 548 the presence of other fields. 550 +------+--------------------+ 551 | Type | Packet Number Size | 552 +------+--------------------+ 553 | 01 | 1 octet | 554 | | | 555 | 02 | 2 octets | 556 | | | 557 | 03 | 4 octets | 558 +------+--------------------+ 560 Table 2: Short Header Packet Types 562 The header form, connection ID flag and connection ID of a short 563 header packet are version-independent. The remaining fields are 564 specific to the selected QUIC version. See Section 5.9 for details 565 on how packets from different versions of QUIC are interpreted. 567 5.3. Version Negotiation Packet 569 A Version Negotiation packet has long headers with a type value of 570 0x01 and is sent only by servers. The Version Negotiation packet is 571 a response to a client packet that contains a version that is not 572 supported by the server. 574 The packet number, connection ID and version fields echo 575 corresponding values from the triggering client packet. This allows 576 clients some assurance that the server received the packet and that 577 the Version Negotiation packet was not carried in a packet with a 578 spoofed source address. 580 The payload of the Version Negotiation packet is a list of 32-bit 581 versions which the server supports, as shown below. 583 0 1 2 3 584 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 585 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 586 | Supported Version 1 (32) ... 587 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 588 | [Supported Version 2 (32)] ... 589 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 590 ... 591 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 592 | [Supported Version N (32)] ... 593 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 595 Figure 3: Version Negotiation Packet 597 See Section 7.1 for a description of the version negotiation process. 599 5.4. Cleartext Packets 601 Cleartext packets are sent during the handshake prior to key 602 negotiation. 604 All cleartext packets contain the current QUIC version in the version 605 field. 607 The payload of cleartext packets also includes an integrity check, 608 which is described in [QUIC-TLS]. 610 5.4.1. Client Initial Packet 612 The Client Initial packet uses long headers with a type value of 613 0x02. It carries the first cryptographic handshake message sent by 614 the client. 616 The client populates the connection ID field with randomly selected 617 values, unless it has received a packet from the server. If the 618 client has received a packet from the server, the connection ID field 619 uses the value provided by the server. 621 The packet number used for Client Initial packets is initialized with 622 a random value each time the new contents are created for the packet. 623 Retransmissions of the packet contents increment the packet number by 624 one, see (Section 5.8). 626 The payload of a Client Initial packet consists of a STREAM frame (or 627 frames) for stream 0 containing a cryptographic handshake message, 628 plus any PADDING frames necessary to ensure that the packet is at 629 least the minimum PMTU size (see Section 9). The stream in this 630 packet always starts at an offset of 0 (see Section 7.4) and the 631 complete cyptographic handshake message MUST fit in a single packet 632 (see Section 7.2). 634 The client uses the Client Initial Packet type for any packet that 635 contains an initial cryptographic handshake message. This includes 636 all cases where a new packet containing the initial cryptographic 637 message needs to be created, this includes the packets sent after 638 receiving a Version Negotiation (Section 5.3) or Server Stateless 639 Retry packet (Section 5.4.2). 641 5.4.2. Server Stateless Retry Packet 643 A Server Stateless Retry packet uses long headers with a type value 644 of 0x03. It carries cryptographic handshake messages and 645 acknowledgments. It is used by a server that wishes to perform a 646 stateless retry (see Section 7.4). 648 The packet number and connection ID fields echo the corresponding 649 fields from the triggering client packet. This allows a client to 650 verify that the server received its packet. 652 After receiving a Server Stateless Retry packet, the client uses a 653 new Client Initial packet containing the next cryptographic handshake 654 message. The client retains the state of its cryptographic 655 handshake, but discards all transport state. In effect, the next 656 cryptographic handshake message is sent on a new connection. The new 657 Client Initial packet is sent in a packet with a newly randomized 658 packet number and starting at a stream offset of 0. 660 Continuing the cryptographic handshake is necessary to ensure that an 661 attacker cannot force a downgrade of any cryptographic parameters. 662 In addition to continuing the cryptographic handshake, the client 663 MUST remember the results of any version negotiation that occurred 664 (see Section 7.1). The client MAY also retain any observed RTT or 665 congestion state that it has accumulated for the flow, but other 666 transport state MUST be discarded. 668 The payload of the Server Stateless Retry packet contains STREAM 669 frames and could contain PADDING and ACK frames. A server can only 670 send a single Server Stateless Retry packet in response to each 671 Client Initial packet that is receives. 673 5.4.3. Server Cleartext Packet 675 A Server Cleartext packet uses long headers with a type value of 676 0x04. It is used to carry acknowledgments and cryptographic 677 handshake messages from the server. 679 The connection ID field in a Server Cleartext packet contains a 680 connection ID that is chosen by the server (see Section 5.7). 682 The first Server Cleartext packet contains a randomized packet 683 number. This value is increased for each subsequent packet sent by 684 the server as described in Section 5.8. 686 The payload of this packet contains STREAM frames and could contain 687 PADDING and ACK frames. 689 5.4.4. Client Cleartext Packet 691 A Client Cleartext packet uses long headers with a type value of 692 0x05, and is sent when the client has received a Server Cleartext 693 packet from the server. 695 The connection ID field in a Client Cleartext packet contains a 696 server-selected connection ID, see Section 5.7. 698 The Client Cleartext packet includes a packet number that is one 699 higher than the last Client Initial, 0-RTT Protected or Client 700 Cleartext packet that was sent. The packet number is incremented for 701 each subsequent packet, see Section 5.8. 703 The payload of this packet contains STREAM frames and could contain 704 PADDING and ACK frames. 706 5.5. Protected Packets 708 Packets that are protected with 0-RTT keys are sent with long 709 headers. Packets that are protected with 1-RTT keys MAY be sent with 710 long headers. The different packet types explicitly indicate the 711 encryption level and therefore the keys that are used to remove 712 packet protection. 714 Packets protected with 0-RTT keys use a type value of 0x06. The 715 connection ID field for a 0-RTT packet is selected by the client. 717 The client can send 0-RTT packets after having received a packet from 718 the server if that packet does not complete the handshake. Even if 719 the client receives a different connection ID from the server, it 720 MUST NOT update the connection ID it uses for 0-RTT packets. This 721 enables consistent routing for all 0-RTT packets. 723 Packets protected with 1-RTT keys that use long headers use a type 724 value of 0x07 for key phase 0 and 0x08 for key phase 1; see 725 [QUIC-TLS] for more details on the use of key phases. The connection 726 ID field for these packet types MUST contain the value selected by 727 the server, see Section 5.7. 729 The version field for protected packets is the current QUIC version. 731 The packet number field contains a packet number, which increases 732 with each packet sent, see Section 5.8 for details. 734 The payload is protected using authenticated encryption. [QUIC-TLS] 735 describes packet protection in detail. After decryption, the 736 plaintext consists of a sequence of frames, as described in 737 Section 6. 739 5.6. Public Reset Packet 741 A Public Reset packet is only sent by servers and is used to abruptly 742 terminate communications. Public Reset is provided as an option of 743 last resort for a server that does not have access to the state of a 744 connection. This is intended for use by a server that has lost state 745 (for example, through a crash or outage). A server that wishes to 746 communicate a fatal connection error MUST use a CONNECTION_CLOSE 747 frame if it has sufficient state to do so. 749 A Public Reset packet uses long headers with a type value of 0x09. 751 The connection ID and packet number of fields together contain octets 752 1 through 12 from the packet that triggered the reset. For a client 753 that sends a connection ID on every packet, the Connection ID field 754 is simply an echo of the client's Connection ID, and the Packet 755 Number field includes an echo of the client's packet number. 756 Depending on the client's packet number length it might also include 757 0, 2, or 3 additional octets from the protected payload of the client 758 packet. 760 The version field contains the current QUIC version. 762 A Public Reset packet sent by a server indicates that it does not 763 have the state necessary to continue with a connection. In this 764 case, the server will include the fields that prove that it 765 originally participated in the connection (see Section 5.6.1 for 766 details). 768 Upon receipt of a Public Reset packet that contains a valid proof, a 769 client MUST tear down state associated with the connection. The 770 client MUST then cease sending packets on the connection and SHOULD 771 discard any subsequent packets that arrive. A Public Reset that does 772 not contain a valid proof MUST be ignored. 774 5.6.1. Public Reset Proof 776 TODO: Details to be added. 778 5.7. Connection ID 780 QUIC connections are identified by their 64-bit Connection ID. All 781 long headers contain a Connection ID. Short headers indicate the 782 presence of a Connection ID using the CONNECTION_ID flag. When 783 present, the Connection ID is in the same location in all packet 784 headers, making it straightforward for middleboxes, such as load 785 balancers, to locate and use it. 787 The client MUST choose a random connection ID and use it in Client 788 Initial packets (Section 5.4.1) and 0-RTT packets (Section 5.5). If 789 the client has received any packet from the server, it uses the 790 connection ID it received from the server for all packets other than 791 0-RTT packets. 793 When the server receives a Client Initial packet and decides to 794 proceed with the handshake, it chooses a new value for the connection 795 ID and sends that in a Server Cleartext packet. The server MAY 796 choose to use the value that the client initially selects. 798 Once the client receives the connection ID that the server has 799 chosen, it uses this for all subsequent packets that it sends, except 800 for any 0-RTT packets, which all have the same connection ID. 802 5.8. Packet Numbers 804 The packet number is a 64-bit unsigned number and is used as part of 805 a cryptographic nonce for packet encryption. Each endpoint maintains 806 a separate packet number for sending and receiving. The packet 807 number for sending MUST increase by at least one after sending any 808 packet, unless otherwise specified (see Section 5.8.1). 810 A QUIC endpoint MUST NOT reuse a packet number within the same 811 connection (that is, under the same cryptographic keys). If the 812 packet number for sending reaches 2^64 - 1, the sender MUST close the 813 connection by sending a CONNECTION_CLOSE frame with the error code 814 QUIC_SEQUENCE_NUMBER_LIMIT_REACHED (connection termination is 815 described in Section 7.7.) 817 To reduce the number of bits required to represent the packet number 818 over the wire, only the least significant bits of the packet number 819 are transmitted over the wire, up to 32 bits. The actual packet 820 number for each packet is reconstructed at the receiver based on the 821 largest packet number received on a successfully authenticated 822 packet. 824 A packet number is decoded by finding the packet number value that is 825 closest to the next expected packet. The next expected packet is the 826 highest received packet number plus one. For example, if the highest 827 successfully authenticated packet had a packet number of 0xaa82f30e, 828 then a packet containing a 16-bit value of 0x1f94 will be decoded as 829 0xaa831f94. 831 The sender MUST use a packet number size able to represent more than 832 twice as large a range than the difference between the largest 833 acknowledged packet and packet number being sent. A peer receiving 834 the packet will then correctly decode the packet number, unless the 835 packet is delayed in transit such that it arrives after many higher- 836 numbered packets have been received. An endpoint MAY use a larger 837 packet number size to safeguard against such reordering. 839 As a result, the size of the packet number encoding is at least one 840 more than the base 2 logarithm of the number of contiguous 841 unacknowledged packet numbers, including the new packet. 843 For example, if an endpoint has received an acknowledgment for packet 844 0x6afa2f, sending a packet with a number of 0x6b4264 requires a 845 16-bit or larger packet number encoding; whereas a 32-bit packet 846 number is needed to send a packet with a number of 0x6bc107. 848 Version Negotiation (Section 5.3), Server Stateless Retry 849 (Section 5.4.2), and Public Reset (Section 5.6) packets have special 850 rules for populating the packet number field. 852 5.8.1. Initial Packet Number 854 The initial value for packet number MUST be selected from an uniform 855 random distribution between 0 and 2^31-1. That is, the lower 31 bits 856 of the packet number are randomized. [RFC4086] provides guidance on 857 the generation of random values. 859 The first set of packets sent by an endpoint MUST include the low 860 32-bits of the packet number. Once any packet has been acknowledged, 861 subsequent packets can use a shorter packet number encoding. 863 A client that receives a Version Negotiation (Section 5.3) or Server 864 Stateless Retry packet (Section 5.4.2) MUST generate a new initial 865 packet number. This ensures that the first transmission attempt for 866 a Client Initial packet (Section 5.4.1) always contains a randomized 867 packet number, but packets that contain retransmissions increment the 868 packet number. 870 A client MUST NOT generate a new initial packet number if it discards 871 the server packet. This might happen if the information the client 872 retransmits its Client Initial packet. 874 5.9. Handling Packets from Different Versions 876 Between different versions the following things are guaranteed to 877 remain constant: 879 o the location of the header form flag, 881 o the location of the Connection ID flag in short headers, 883 o the location and size of the Connection ID field in both header 884 forms, 886 o the location and size of the Version field in long headers, and 888 o the location and size of the Packet Number field in long headers. 890 Implementations MUST assume that an unsupported version uses an 891 unknown packet format. All other fields MUST be ignored when 892 processing a packet that contains an unsupported version. 894 6. Frames and Frame Types 896 The payload of cleartext packets and the plaintext after decryption 897 of protected payloads consists of a sequence of frames, as shown in 898 Figure 4. 900 0 1 2 3 901 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 902 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 903 | Frame 1 (*) ... 904 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 905 | Frame 2 (*) ... 906 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 907 ... 908 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 909 | Frame N (*) ... 910 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 912 Figure 4: Contents of Protected Payload 914 Protected payloads MUST contain at least one frame, and MAY contain 915 multiple frames and multiple frame types. 917 Frames MUST fit within a single QUIC packet and MUST NOT span a QUIC 918 packet boundary. Each frame begins with a Frame Type byte, 919 indicating its type, followed by additional type-dependent fields: 921 0 1 2 3 922 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 923 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 924 | Type (8) | Type-Dependent Fields (*) ... 925 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 927 Figure 5: Generic Frame Layout 929 Frame types are listed in Table 3. Note that the Frame Type byte in 930 STREAM and ACK frames is used to carry other frame-specific flags. 931 For all other frames, the Frame Type byte simply identifies the 932 frame. These frames are explained in more detail as they are 933 referenced later in the document. 935 +-------------+-------------------+--------------+ 936 | Type Value | Frame Type Name | Definition | 937 +-------------+-------------------+--------------+ 938 | 0x00 | PADDING | Section 8.10 | 939 | | | | 940 | 0x01 | RST_STREAM | Section 8.9 | 941 | | | | 942 | 0x02 | CONNECTION_CLOSE | Section 8.13 | 943 | | | | 944 | 0x03 | GOAWAY | Section 8.14 | 945 | | | | 946 | 0x04 | MAX_DATA | Section 8.3 | 947 | | | | 948 | 0x05 | MAX_STREAM_DATA | Section 8.4 | 949 | | | | 950 | 0x06 | MAX_STREAM_ID | Section 8.5 | 951 | | | | 952 | 0x07 | PING | Section 8.11 | 953 | | | | 954 | 0x08 | BLOCKED | Section 8.6 | 955 | | | | 956 | 0x09 | STREAM_BLOCKED | Section 8.7 | 957 | | | | 958 | 0x0a | STREAM_ID_NEEDED | Section 8.8 | 959 | | | | 960 | 0x0b | NEW_CONNECTION_ID | Section 8.12 | 961 | | | | 962 | 0xa0 - 0xbf | ACK | Section 8.2 | 963 | | | | 964 | 0xc0 - 0xff | STREAM | Section 8.1 | 965 +-------------+-------------------+--------------+ 967 Table 3: Frame Types 969 7. Life of a Connection 971 A QUIC connection is a single conversation between two QUIC 972 endpoints. QUIC's connection establishment intertwines version 973 negotiation with the cryptographic and transport handshakes to reduce 974 connection establishment latency, as described in Section 7.2. Once 975 established, a connection may migrate to a different IP or port at 976 either endpoint, due to NAT rebinding or mobility, as described in 977 Section 7.6. Finally a connection may be terminated by either 978 endpoint, as described in Section 7.7. 980 7.1. Version Negotiation 982 QUIC's connection establishment begins with version negotiation, 983 since all communication between the endpoints, including packet and 984 frame formats, relies on the two endpoints agreeing on a version. 986 A QUIC connection begins with a client sending a handshake packet. 987 The details of the handshake mechanisms are described in Section 7.2, 988 but all of the initial packets sent from the client to the server 989 MUST use the long header format and MUST specify the version of the 990 protocol being used. 992 When the server receives a packet from a client with the long header 993 format, it compares the client's version to the versions it supports. 995 If the version selected by the client is not acceptable to the 996 server, the server discards the incoming packet and responds with a 997 Version Negotiation packet (Section 5.3). This includes a list of 998 versions that the server will accept. 1000 A server sends a Version Negotiation packet for every packet that it 1001 receives with an unacceptable version. This allows a server to 1002 process packets with unsupported versions without retaining state. 1003 Though either the initial client packet or the version negotiation 1004 packet that is sent in response could be lost, the client will send 1005 new packets until it successfully receives a response. 1007 If the packet contains a version that is acceptable to the server, 1008 the server proceeds with the handshake (Section 7.2). This commits 1009 the server to the version that the client selected. 1011 When the client receives a Version Negotiation packet from the 1012 server, it should select an acceptable protocol version. If the 1013 server lists an acceptable version, the client selects that version 1014 and reattempts to create a connection using that version. Though the 1015 contents of a packet might not change in response to version 1016 negotiation, a client MUST increase the packet number it uses on 1017 every packet it sends. Packets MUST continue to use long headers and 1018 MUST include the new negotiated protocol version. 1020 The client MUST use the long header format and include its selected 1021 version on all packets until it has 1-RTT keys and it has received a 1022 packet from the server which is not a Version Negotiation packet. 1024 A client MUST NOT change the version it uses unless it is in response 1025 to a Version Negotiation packet from the server. Once a client 1026 receives a packet from the server which is not a Version Negotiation 1027 packet, it MUST ignore other Version Negotiation packets on the same 1028 connection. Similarly, a client MUST ignore a Version Negotiation 1029 packet if it has already received and acted on a Version Negotiation 1030 packet. 1032 A client MUST ignore a Version Negotiation packet that lists the 1033 client's chosen version. 1035 Version negotiation uses unprotected data. The result of the 1036 negotiation MUST be revalidated as part of the cryptographic 1037 handshake (see Section 7.3.4). 1039 7.1.1. Using Reserved Versions 1041 For a server to use a new version in the future, clients must 1042 correctly handle unsupported versions. To help ensure this, a server 1043 SHOULD include a reserved version (see Section 4) while generating a 1044 Version Negotiation packet. 1046 The design of version negotiation permits a server to avoid 1047 maintaining state for packets that it rejects in this fashion. 1048 However, when the server generates a Version Negotiation packet, it 1049 cannot randomly generate a reserved version number. This is because 1050 the server is required to include the same value in its transport 1051 parameters (see Section 7.3.4). To avoid the selected version number 1052 changing during connection establishment, the reserved version SHOULD 1053 be generated as a function of values that will be available to the 1054 server when later generating its handshake packets. 1056 A pseudorandom function that takes client address information (IP and 1057 port) and the client selected version as input would ensure that 1058 there is sufficient variability in the values that a server uses. 1060 A client MAY send a packet using a reserved version number. This can 1061 be used to solicit a list of supported versions from a server. 1063 7.2. Cryptographic and Transport Handshake 1065 QUIC relies on a combined cryptographic and transport handshake to 1066 minimize connection establishment latency. QUIC allocates stream 0 1067 for the cryptographic handshake. Version 0x00000001 of QUIC uses TLS 1068 1.3 as described in [QUIC-TLS]; a different QUIC version number could 1069 indicate that a different cryptographic handshake protocol is in use. 1071 QUIC provides this stream with reliable, ordered delivery of data. 1072 In return, the cryptographic handshake provides QUIC with: 1074 o authenticated key exchange, where 1075 * a server is always authenticated, 1077 * a client is optionally authenticated, 1079 * every connection produces distinct and unrelated keys, 1081 * keying material is usable for packet protection for both 0-RTT 1082 and 1-RTT packets, and 1084 * 1-RTT keys have forward secrecy 1086 o authenticated values for the transport parameters of the peer (see 1087 Section 7.3) 1089 o authenticated confirmation of version negotiation (see 1090 Section 7.3.4) 1092 o authenticated negotiation of an application protocol (TLS uses 1093 ALPN [RFC7301] for this purpose) 1095 o for the server, the ability to carry data that provides assurance 1096 that the client can receive packets that are addressed with the 1097 transport address that is claimed by the client (see Section 7.5) 1099 The initial cryptographic handshake message MUST be sent in a single 1100 packet. Any second attempt that is triggered by address validation 1101 MUST also be sent within a single packet. This avoids having to 1102 reassemble a message from multiple packets. Reassembling messages 1103 requires that a server maintain state prior to establishing a 1104 connection, exposing the server to a denial of service risk. 1106 The first client packet of the cryptographic handshake protocol MUST 1107 fit within a 1232 octet QUIC packet payload. This includes overheads 1108 that reduce the space available to the cryptographic handshake 1109 protocol. 1111 Details of how TLS is integrated with QUIC is provided in more detail 1112 in [QUIC-TLS]. 1114 7.3. Transport Parameters 1116 During connection establishment, both endpoints make authenticated 1117 declarations of their transport parameters. These declarations are 1118 made unilaterally by each endpoint. Endpoints are required to comply 1119 with the restrictions implied by these parameters; the description of 1120 each parameter includes rules for its handling. 1122 The format of the transport parameters is the TransportParameters 1123 struct from Figure 6. This is described using the presentation 1124 language from Section 3 of [I-D.ietf-tls-tls13]. 1126 uint32 QuicVersion; 1128 enum { 1129 initial_max_stream_data(0), 1130 initial_max_data(1), 1131 initial_max_stream_id(2), 1132 idle_timeout(3), 1133 truncate_connection_id(4), 1134 max_packet_size(5), 1135 (65535) 1136 } TransportParameterId; 1138 struct { 1139 TransportParameterId parameter; 1140 opaque value<0..2^16-1>; 1141 } TransportParameter; 1143 struct { 1144 select (Handshake.msg_type) { 1145 case client_hello: 1146 QuicVersion negotiated_version; 1147 QuicVersion initial_version; 1149 case encrypted_extensions: 1150 QuicVersion supported_versions<2..2^8-4>; 1151 }; 1152 TransportParameter parameters<30..2^16-1>; 1153 } TransportParameters; 1155 Figure 6: Definition of TransportParameters 1157 The "extension_data" field of the quic_transport_parameters extension 1158 defined in [QUIC-TLS] contains a TransportParameters value. TLS 1159 encoding rules are therefore used to encode the transport parameters. 1161 QUIC encodes transport parameters into a sequence of octets, which 1162 are then included in the cryptographic handshake. Once the handshake 1163 completes, the transport parameters declared by the peer are 1164 available. Each endpoint validates the value provided by its peer. 1165 In particular, version negotiation MUST be validated (see 1166 Section 7.3.4) before the connection establishment is considered 1167 properly complete. 1169 Definitions for each of the defined transport parameters are included 1170 in Section 7.3.1. 1172 7.3.1. Transport Parameter Definitions 1174 An endpoint MUST include the following parameters in its encoded 1175 TransportParameters: 1177 initial_max_stream_data (0x0000): The initial stream maximum data 1178 parameter contains the initial value for the maximum data that can 1179 be sent on any newly created stream. This parameter is encoded as 1180 an unsigned 32-bit integer in units of octets. This is equivalent 1181 to an implicit MAX_STREAM_DATA frame (Section 8.4) being sent on 1182 all streams immediately after opening. 1184 initial_max_data (0x0001): The initial maximum data parameter 1185 contains the initial value for the maximum amount of data that can 1186 be sent on the connection. This parameter is encoded as an 1187 unsigned 32-bit integer in units of 1024 octets. That is, the 1188 value here is multiplied by 1024 to determine the actual maximum 1189 value. This is equivalent to sending a MAX_DATA (Section 8.3) for 1190 the connection immediately after completing the handshake. 1192 initial_max_stream_id (0x0002): The initial maximum stream ID 1193 parameter contains the initial maximum stream number the peer may 1194 initiate, encoded as an unsigned 32-bit integer. This is 1195 equivalent to sending a MAX_STREAM_ID (Section 8.5) immediately 1196 after completing the handshake. 1198 idle_timeout (0x0003): The idle timeout is a value in seconds that 1199 is encoded as an unsigned 16-bit integer. The maximum value is 1200 600 seconds (10 minutes). 1202 An endpoint MAY use the following transport parameters: 1204 truncate_connection_id (0x0004): The truncated connection identifier 1205 parameter indicates that packets sent to the peer can omit the 1206 connection ID. This can be used by an endpoint where the 5-tuple 1207 is sufficient to identify a connection. This parameter is zero 1208 length. Omitting the parameter indicates that the endpoint relies 1209 on the connection ID being present in every packet. 1211 max_packet_size (0x0005): The maximum packet size parameter places a 1212 limit on the size of packets that the endpoint is willing to 1213 receive, encoded as an unsigned 16-bit integer. This indicates 1214 that packets larger than this limit will be dropped. The default 1215 for this parameter is the maximum permitted UDP payload of 65527. 1217 Values below 1252 are invalid. This limit only applies to 1218 protected packets (Section 5.5). 1220 7.3.2. Values of Transport Parameters for 0-RTT 1222 Transport parameters from the server MUST be remembered by the client 1223 for use with 0-RTT data. If the TLS NewSessionTicket message 1224 includes the quic_transport_parameters extension, then those values 1225 are used for the server values when establishing a new connection 1226 using that ticket. Otherwise, the transport parameters that the 1227 server advertises during connection establishment are used. 1229 A server can remember the transport parameters that it advertised, or 1230 store an integrity-protected copy of the values in the ticket and 1231 recover the information when accepting 0-RTT data. A server uses the 1232 transport parameters in determining whether to accept 0-RTT data. 1234 A server MAY accept 0-RTT and subsequently provide different values 1235 for transport parameters for use in the new connection. If 0-RTT 1236 data is accepted by the server, the server MUST NOT reduce any limits 1237 or alter any values that might be violated by the client with its 1238 0-RTT data. In particular, a server that accepts 0-RTT data MUST NOT 1239 set values for initial_max_data or initial_max_stream_data that are 1240 smaller than the remembered value of those parameters. Similarly, a 1241 server MUST NOT reduce the value of initial_max_stream_id. 1243 A server MUST reject 0-RTT data or even abort a handshake if the 1244 implied values for transport parameters cannot be supported. 1246 7.3.3. New Transport Parameters 1248 New transport parameters can be used to negotiate new protocol 1249 behavior. An endpoint MUST ignore transport parameters that it does 1250 not support. Absence of a transport parameter therefore disables any 1251 optional protocol feature that is negotiated using the parameter. 1253 New transport parameters can be registered according to the rules in 1254 Section 14.1. 1256 7.3.4. Version Negotiation Validation 1258 The transport parameters include three fields that encode version 1259 information. These retroactively authenticate the version 1260 negotiation (see Section 7.1) that is performed prior to the 1261 cryptographic handshake. 1263 The cryptographic handshake provides integrity protection for the 1264 negotiated version as part of the transport parameters (see 1265 Section 7.3). As a result, modification of version negotiation 1266 packets by an attacker can be detected. 1268 The client includes two fields in the transport parameters: 1270 o The negotiated_version is the version that was finally selected 1271 for use. This MUST be identical to the value that is on the 1272 packet that carries the ClientHello. A server that receives a 1273 negotiated_version that does not match the version of QUIC that is 1274 in use MUST terminate the connection with a 1275 QUIC_VERSION_NEGOTIATION_MISMATCH error code. 1277 o The initial_version is the version that the client initially 1278 attempted to use. If the server did not send a version 1279 negotiation packet Section 5.3, this will be identical to the 1280 negotiated_version. 1282 A server that processes all packets in a stateful fashion can 1283 remember how version negotiation was performed and validate the 1284 initial_version value. 1286 A server that does not maintain state for every packet it receives 1287 (i.e., a stateless server) uses a different process. If the initial 1288 and negotiated versions are the same, a stateless server can accept 1289 the value. 1291 If the initial version is different from the negotiated_version, a 1292 stateless server MUST check that it would have sent a version 1293 negotiation packet if it had received a packet with the indicated 1294 initial_version. If a server would have accepted the version 1295 included in the initial_version and the value differs from the value 1296 of negotiated_version, the server MUST terminate the connection with 1297 a QUIC_VERSION_NEGOTIATION_MISMATCH error. 1299 The server includes a list of versions that it would send in any 1300 version negotiation packet (Section 5.3) in supported_versions. This 1301 value is set even if it did not send a version negotiation packet. 1303 The client can validate that the negotiated_version is included in 1304 the supported_versions list and - if version negotiation was 1305 performed - that it would have selected the negotiated version. A 1306 client MUST terminate the connection with a 1307 QUIC_VERSION_NEGOTIATION_MISMATCH error code if the 1308 negotiated_version value is not included in the supported_versions 1309 list. A client MUST terminate with a 1310 QUIC_VERSION_NEGOTIATION_MISMATCH error code if version negotiation 1311 occurred but it would have selected a different version based on the 1312 value of the supported_versions list. 1314 7.4. Stateless Retries 1316 A server can process an initial cryptographic handshake messages from 1317 a client without committing any state. This allows a server to 1318 perform address validation (Section 7.5, or to defer connection 1319 establishment costs. 1321 A server that generates a response to an initial packet without 1322 retaining connection state MUST use the Server Stateless Retry packet 1323 (Section 5.4.2). This packet causes a client to reset its transport 1324 state and to continue the connection attempt with new connection 1325 state while maintaining the state of the cryptographic handshake. 1327 A server MUST NOT send multiple Server Stateless Retry packets in 1328 response to a client handshake packet. Thus, any cryptographic 1329 handshake message that is sent MUST fit within a single packet. 1331 In TLS, the Server Stateless Retry packet type is used to carry the 1332 HelloRetryRequest message. 1334 7.5. Proof of Source Address Ownership 1336 Transport protocols commonly spend a round trip checking that a 1337 client owns the transport address (IP and port) that it claims. 1338 Verifying that a client can receive packets sent to its claimed 1339 transport address protects against spoofing of this information by 1340 malicious clients. 1342 This technique is used primarily to avoid QUIC from being used for 1343 traffic amplification attack. In such an attack, a packet is sent to 1344 a server with spoofed source address information that identifies a 1345 victim. If a server generates more or larger packets in response to 1346 that packet, the attacker can use the server to send more data toward 1347 the victim than it would be able to send on its own. 1349 Several methods are used in QUIC to mitigate this attack. Firstly, 1350 the initial handshake packet is padded to at least 1280 octets. This 1351 allows a server to send a similar amount of data without risking 1352 causing an amplification attack toward an unproven remote address. 1354 A server eventually confirms that a client has received its messages 1355 when the cryptographic handshake successfully completes. This might 1356 be insufficient, either because the server wishes to avoid the 1357 computational cost of completing the handshake, or it might be that 1358 the size of the packets that are sent during the handshake is too 1359 large. This is especially important for 0-RTT, where the server 1360 might wish to provide application data traffic - such as a response 1361 to a request - in response to the data carried in the early data from 1362 the client. 1364 To send additional data prior to completing the cryptographic 1365 handshake, the server then needs to validate that the client owns the 1366 address that it claims. 1368 Source address validation is therefore performed during the 1369 establishment of a connection. TLS provides the tools that support 1370 the feature, but basic validation is performed by the core transport 1371 protocol. 1373 7.5.1. Client Address Validation Procedure 1375 QUIC uses token-based address validation. Any time the server wishes 1376 to validate a client address, it provides the client with a token. 1377 As long as the token cannot be easily guessed (see Section 7.5.3), if 1378 the client is able to return that token, it proves to the server that 1379 it received the token. 1381 During the processing of the cryptographic handshake messages from a 1382 client, TLS will request that QUIC make a decision about whether to 1383 proceed based on the information it has. TLS will provide QUIC with 1384 any token that was provided by the client. For an initial packet, 1385 QUIC can decide to abort the connection, allow it to proceed, or 1386 request address validation. 1388 If QUIC decides to request address validation, it provides the 1389 cryptographic handshake with a token. The contents of this token are 1390 consumed by the server that generates the token, so there is no need 1391 for a single well-defined format. A token could include information 1392 about the claimed client address (IP and port), a timestamp, and any 1393 other supplementary information the server will need to validate the 1394 token in the future. 1396 The cryptographic handshake is responsible for enacting validation by 1397 sending the address validation token to the client. A legitimate 1398 client will include a copy of the token when it attempts to continue 1399 the handshake. The cryptographic handshake extracts the token then 1400 asks QUIC a second time whether the token is acceptable. In 1401 response, QUIC can either abort the connection or permit it to 1402 proceed. 1404 A connection MAY be accepted without address validation - or with 1405 only limited validation - but a server SHOULD limit the data it sends 1406 toward an unvalidated address. Successful completion of the 1407 cryptographic handshake implicitly provides proof that the client has 1408 received packets from the server. 1410 7.5.2. Address Validation on Session Resumption 1412 A server MAY provide clients with an address validation token during 1413 one connection that can be used on a subsequent connection. Address 1414 validation is especially important with 0-RTT because a server 1415 potentially sends a significant amount of data to a client in 1416 response to 0-RTT data. 1418 A different type of token is needed when resuming. Unlike the token 1419 that is created during a handshake, there might be some time between 1420 when the token is created and when the token is subsequently used. 1421 Thus, a resumption token SHOULD include an expiration time. It is 1422 also unlikely that the client port number is the same on two 1423 different connections; validating the port is therefore unlikely to 1424 be successful. 1426 This token can be provided to the cryptographic handshake immediately 1427 after establishing a connection. QUIC might also generate an updated 1428 token if significant time passes or the client address changes for 1429 any reason (see Section 7.6). The cryptographic handshake is 1430 responsible for providing the client with the token. In TLS the 1431 token is included in the ticket that is used for resumption and 1432 0-RTT, which is carried in a NewSessionTicket message. 1434 7.5.3. Address Validation Token Integrity 1436 An address validation token MUST be difficult to guess. Including a 1437 large enough random value in the token would be sufficient, but this 1438 depends on the server remembering the value it sends to clients. 1440 A token-based scheme allows the server to offload any state 1441 associated with validation to the client. For this design to work, 1442 the token MUST be covered by integrity protection against 1443 modification or falsification by clients. Without integrity 1444 protection, malicious clients could generate or guess values for 1445 tokens that would be accepted by the server. Only the server 1446 requires access to the integrity protection key for tokens. 1448 In TLS the address validation token is often bundled with the 1449 information that TLS requires, such as the resumption secret. In 1450 this case, adding integrity protection can be delegated to the 1451 cryptographic handshake protocol, avoiding redundant protection. If 1452 integrity protection is delegated to the cryptographic handshake, an 1453 integrity failure will result in immediate cryptographic handshake 1454 failure. If integrity protection is performed by QUIC, QUIC MUST 1455 abort the connection if the integrity check fails with a 1456 QUIC_ADDRESS_VALIDATION_FAILURE error code. 1458 7.6. Connection Migration 1460 QUIC connections are identified by their 64-bit Connection ID. 1461 QUIC's consistent connection ID allows connections to survive changes 1462 to the client's IP and/or port, such as those caused by client or 1463 server migrating to a new network. Connection migration allows a 1464 client to retain any shared state with a connection when they move 1465 networks. This includes state that can be hard to recover such as 1466 outstanding requests, which might otherwise be lost with no easy way 1467 to retry them. 1469 7.6.1. Privacy Implications of Connection Migration 1471 Using a stable connection ID on multiple network paths allows a 1472 passive observer to correlate activity between those paths. A client 1473 that moves between networks might not wish to have their activity 1474 correlated by any entity other than a server. The NEW_CONNECTION_ID 1475 message can be sent by a server to provide an unlinkable connection 1476 ID for use in case the client wishes to explicitly break linkability 1477 between two points of network attachment. 1479 A client which wishes to break linkability upon changing networks 1480 MUST use the NEW_CONNECTION_ID as well as incrementing the packet 1481 sequence number by an externally unpredictable value computed as 1482 described in Section 7.6.1.1. Packet number gaps are cumulative. A 1483 client might skip connection IDs, but it MUST ensure that it applies 1484 the associated packet number gaps in addition to the packet number 1485 gap associated with the connection ID that it does use. 1487 A client might need to send packets on multiple networks without 1488 receiving any response from the server. To ensure that the client is 1489 not linkable across each of these changes, a new connection ID and 1490 packet number gap are needed for each network. To support this, a 1491 server sends multiple NEW_CONNECTION_ID messages. Each 1492 NEW_CONNECTION_ID is marked with a sequence number. Connection IDs 1493 MUST be used in the order in which they are numbered. 1495 A server that receives a packet that is marked with a new connection 1496 ID recovers the packet number by adding the cumulative packet number 1497 gap to its expected packet number. A server SHOULD discard packets 1498 that contain a smaller gap than it advertised. 1500 For instance, a server might provide a packet number gap of 7 1501 associated with a new connection ID. If the server received packet 1502 10 using the previous connection ID, it should expect packets on the 1503 new connection ID to start at 18. A packet with the new connection 1504 ID and a packet number of 17 is discarded as being in error. 1506 7.6.1.1. Packet Number Gap 1508 In order to avoid linkage, the packet number gap MUST be externally 1509 indistinguishable from random. The packet number gap for a 1510 connection ID with sequence number is computed by encoding the 1511 sequence number as a 32-bit integer in big-endian format, and then 1512 computing: 1514 Gap = HKDF-Expand-Label(packet_number_secret, 1515 "QUIC packet sequence gap", sequence, 4) 1517 The output of HKDF-Expand-Label is interpreted as a big-endian 1518 number. "packet_number_secret" is derived from the TLS key exchange, 1519 as described in [QUIC-TLS] Section 5.6. 1521 7.6.2. Address Validation for Migrated Connections 1523 TODO: see issue #161 1525 7.7. Connection Termination 1527 Connections should remain open until they become idle for a pre- 1528 negotiated period of time. A QUIC connection, once established, can 1529 be terminated in one of three ways: 1531 1. Explicit Shutdown: An endpoint sends a CONNECTION_CLOSE frame to 1532 initiate a connection termination. An endpoint may send a GOAWAY 1533 frame to the peer prior to a CONNECTION_CLOSE to indicate that 1534 the connection will soon be terminated. A GOAWAY frame signals 1535 to the peer that any active streams will continue to be 1536 processed, but the sender of the GOAWAY will not initiate any 1537 additional streams and will not accept any new incoming streams. 1538 On termination of the active streams, a CONNECTION_CLOSE may be 1539 sent. If an endpoint sends a CONNECTION_CLOSE frame while 1540 unterminated streams are active (no FIN bit or RST_STREAM frames 1541 have been sent or received for one or more streams), then the 1542 peer must assume that the streams were incomplete and were 1543 abnormally terminated. 1545 2. Implicit Shutdown: The default idle timeout is a required 1546 parameter in connection negotiation. The maximum is 10 minutes. 1547 If there is no network activity for the duration of the idle 1548 timeout, the connection is closed. By default a CONNECTION_CLOSE 1549 frame will be sent. A silent close option can be enabled when it 1550 is expensive to send an explicit close, such as mobile networks 1551 that must wake up the radio. 1553 3. Abrupt Shutdown: An endpoint may send a Public Reset packet at 1554 any time during the connection to abruptly terminate an active 1555 connection. A Public Reset packet SHOULD only be used as a final 1556 recourse. Commonly, a public reset is expected to be sent when a 1557 packet on an established connection is received by an endpoint 1558 that is unable decrypt the packet. For instance, if a server 1559 reboots mid-connection and loses any cryptographic state 1560 associated with open connections, and then receives a packet on 1561 an open connection, it should send a Public Reset packet in 1562 return. (TODO: articulate rules around when a public reset 1563 should be sent.) 1565 TODO: Connections that are terminated are added to a TIME_WAIT list 1566 at the server, so as to absorb any straggler packets in the network. 1567 Discuss TIME_WAIT list. 1569 8. Frame Types and Formats 1571 As described in Section 6, Regular packets contain one or more 1572 frames. We now describe the various QUIC frame types that can be 1573 present in a Regular packet. The use of these frames and various 1574 frame header bits are described in subsequent sections. 1576 8.1. STREAM Frame 1578 STREAM frames implicitly create a stream and carry stream data. The 1579 type byte for a STREAM frame contains embedded flags, and is 1580 formatted as "11FSSOOD". These bits are parsed as follows: 1582 o The first two bits must be set to 11, indicating that this is a 1583 STREAM frame. 1585 o "F" is the FIN bit, which is used for stream termination. 1587 o The "SS" bits encode the length of the Stream ID header field. 1588 The values 00, 01, 02, and 03 indicate lengths of 8, 16, 24, and 1589 32 bits long respectively. 1591 o The "OO" bits encode the length of the Offset header field. The 1592 values 00, 01, 02, and 03 indicate lengths of 0, 16, 32, and 64 1593 bits long respectively. 1595 o The "D" bit indicates whether a Data Length field is present in 1596 the STREAM header. When set to 0, this field indicates that the 1597 Stream Data field extends to the end of the packet. When set to 1598 1, this field indicates that Data Length field contains the length 1599 (in bytes) of the Stream Data field. The option to omit the 1600 length should only be used when the packet is a "full-sized" 1601 packet, to avoid the risk of corruption via padding. 1603 A STREAM frame is shown below. 1605 0 1 2 3 1606 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 1607 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1608 | Stream ID (8/16/24/32) ... 1609 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1610 | Offset (0/16/32/64) ... 1611 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1612 | [Data Length (16)] | Stream Data (*) ... 1613 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1615 Figure 7: STREAM Frame Format 1617 The STREAM frame contains the following fields: 1619 Stream ID: The stream ID of the stream (see Section 10.1). 1621 Offset: A variable-sized unsigned number specifying the byte offset 1622 in the stream for the data in this STREAM frame. When the offset 1623 length is 0, the offset is 0. The first byte in the stream has an 1624 offset of 0. The largest offset delivered on a stream - the sum 1625 of the re-constructed offset and data length - MUST be less than 1626 2^64. 1628 Stream Data: The bytes from the designated stream to be delivered. 1630 Data Length: An optional 16-bit unsigned number specifying the 1631 length of the Stream Data field in this STREAM frame. This field 1632 is present when the "D" bit is set to 1. 1634 A STREAM frame MUST have either non-zero data length or the FIN bit 1635 set. When the FIN flag is sent on an empty STREAM frame, the offset 1636 in the STREAM frame MUST be one greater than the last data byte sent 1637 on this stream. 1639 Stream multiplexing is achieved by interleaving STREAM frames from 1640 multiple streams into one or more QUIC packets. A single QUIC packet 1641 can include multiple STREAM frames from one or more streams. 1643 Implementation note: One of the benefits of QUIC is avoidance of 1644 head-of-line blocking across multiple streams. When a packet loss 1645 occurs, only streams with data in that packet are blocked waiting for 1646 a retransmission to be received, while other streams can continue 1647 making progress. Note that when data from multiple streams is 1648 bundled into a single QUIC packet, loss of that packet blocks all 1649 those streams from making progress. An implementation is therefore 1650 advised to bundle as few streams as necessary in outgoing packets 1651 without losing transmission efficiency to underfilled packets. 1653 8.2. ACK Frame 1655 Receivers send ACK frames to inform senders which packets they have 1656 received and processed, as well as which packets are considered 1657 missing. The ACK frame contains between 1 and 256 ACK blocks. ACK 1658 blocks are ranges of acknowledged packets. 1660 To limit ACK blocks to those that have not yet been received by the 1661 sender, the receiver SHOULD track which ACK frames have been 1662 acknowledged by its peer. Once an ACK frame has been acknowledged, 1663 the packets it acknowledges SHOULD not be acknowledged again. 1665 A receiver that is only sending ACK frames will not receive 1666 acknowledgments for its packets. Sending an occasional MAX_DATA or 1667 MAX_STREAM_DATA frame as data is received will ensure that 1668 acknowledgements are generated by a peer. Otherwise, an endpoint MAY 1669 send a PING frame once per RTT to solicit an acknowledgment. 1671 To limit receiver state or the size of ACK frames, a receiver MAY 1672 limit the number of ACK blocks it sends. A receiver can do this even 1673 without receiving acknowledgment of its ACK frames, with the 1674 knowledge this could cause the sender to unnecessarily retransmit 1675 some data. When this is necessary, the receiver SHOULD acknowledge 1676 newly received packets and stop acknowledging packets received in the 1677 past. 1679 Unlike TCP SACKs, QUIC ACK blocks are cumulative and therefore 1680 irrevocable. Once a packet has been acknowledged, even if it does 1681 not appear in a future ACK frame, it is assumed to be acknowledged. 1683 QUIC ACK frames contain a timestamp section with up to 255 1684 timestamps. Timestamps enable better congestion control, but are not 1685 required for correct loss recovery, and old timestamps are less 1686 valuable, so it is not guaranteed every timestamp will be received by 1687 the sender. A receiver SHOULD send a timestamp exactly once for each 1688 received packet containing retransmittable frames. A receiver MAY 1689 send timestamps for non-retransmittable packets. A receiver MUST not 1690 send timestamps in unprotected packets. 1692 A sender MAY intentionally skip packet numbers to introduce entropy 1693 into the connection, to avoid opportunistic acknowledgement attacks. 1694 The sender SHOULD close the connection if an unsent packet number is 1695 acknowledged. The format of the ACK frame is efficient at expressing 1696 blocks of missing packets; skipping packet numbers between 1 and 255 1697 effectively provides up to 8 bits of efficient entropy on demand, 1698 which should be adequate protection against most opportunistic 1699 acknowledgement attacks. 1701 The type byte for a ACK frame contains embedded flags, and is 1702 formatted as "101NLLMM". These bits are parsed as follows: 1704 o The first three bits must be set to 101 indicating that this is an 1705 ACK frame. 1707 o The "N" bit indicates whether the frame has more than 1 range of 1708 acknowledged packets (i.e., whether the ACK Block Section contains 1709 a Num Blocks field). 1711 o The two "LL" bits encode the length of the Largest Acknowledged 1712 field. The values 00, 01, 02, and 03 indicate lengths of 8, 16, 1713 32, and 48 bits respectively. 1715 o The two "MM" bits encode the length of the ACK Block Length 1716 fields. The values 00, 01, 02, and 03 indicate lengths of 8, 16, 1717 32, and 48 bits respectively. 1719 An ACK frame is shown below. 1721 0 1 2 3 1722 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 1723 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1724 |[Num Blocks(8)]| NumTS (8) | 1725 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1726 | Largest Acknowledged (8/16/32/48) ... 1727 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1728 | ACK Delay (16) | 1729 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1730 | ACK Block Section (*) ... 1731 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1732 | Timestamp Section (*) ... 1733 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1735 Figure 8: ACK Frame Format 1737 The fields in the ACK frame are as follows: 1739 Num Blocks (opt): An optional 8-bit unsigned value specifying the 1740 number of additional ACK blocks (besides the required First ACK 1741 Block) in this ACK frame. Only present if the 'N' flag bit is 1. 1743 Num Timestamps: An unsigned 8-bit number specifying the total number 1744 of pairs in the Timestamp Section. 1746 Largest Acknowledged: A variable-sized unsigned value representing 1747 the largest packet number the peer is acknowledging in this packet 1748 (typically the largest that the peer has seen thus far.) 1750 ACK Delay: The time from when the largest acknowledged packet, as 1751 indicated in the Largest Acknowledged field, was received by this 1752 peer to when this ACK was sent. 1754 ACK Block Section: Contains one or more blocks of packet numbers 1755 which have been successfully received, see Section 8.2.1. 1757 Timestamp Section: Contains zero or more timestamps reporting 1758 transit delay of received packets. See Section 8.2.2. 1760 8.2.1. ACK Block Section 1762 The ACK Block Section contains between one and 256 blocks of packet 1763 numbers which have been successfully received. If the Num Blocks 1764 field is absent, only the First ACK Block length is present in this 1765 section. Otherwise, the Num Blocks field indicates how many 1766 additional blocks follow the First ACK Block Length field. 1768 0 1 2 3 1769 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 1770 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1771 | First ACK Block Length (8/16/32/48) ... 1772 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1773 | [Gap 1 (8)] | [ACK Block 1 Length (8/16/32/48)] ... 1774 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1775 | [Gap 2 (8)] | [ACK Block 2 Length (8/16/32/48)] ... 1776 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1777 ... 1778 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1779 | [Gap N (8)] | [ACK Block N Length (8/16/32/48)] ... 1780 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1782 Figure 9: ACK Block Section 1784 The fields in the ACK Block Section are: 1786 First ACK Block Length: An unsigned packet number delta that 1787 indicates the number of contiguous additional packets being 1788 acknowledged starting at the Largest Acknowledged. 1790 Gap To Next Block (opt, repeated): An unsigned number specifying the 1791 number of contiguous missing packets from the end of the previous 1792 ACK block to the start of the next. Repeated "Num Blocks" times. 1794 ACK Block Length (opt, repeated): An unsigned packet number delta 1795 that indicates the number of contiguous packets being acknowledged 1796 starting after the end of the previous gap. Repeated "Num Blocks" 1797 times. 1799 8.2.2. Timestamp Section 1801 The Timestamp Section contains between zero and 255 measurements of 1802 packet receive times relative to the beginning of the connection. 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 | [Delta LA (8)]| 1808 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1809 | [First Timestamp (32)] | 1810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1811 |[Delta LA 1(8)]| [Time Since Previous 1 (16)] | 1812 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1813 |[Delta LA 2(8)]| [Time Since Previous 2 (16)] | 1814 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1815 ... 1816 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1817 |[Delta LA N(8)]| [Time Since Previous N (16)] | 1818 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1820 Figure 10: Timestamp Section 1822 The fields in the Timestamp Section are: 1824 Delta Largest Acknowledged (opt): An optional 8-bit unsigned packet 1825 number delta specifying the delta between the largest acknowledged 1826 and the first packet whose timestamp is being reported. In other 1827 words, this first packet number may be computed as (Largest 1828 Acknowledged - Delta Largest Acknowledged.) 1830 First Timestamp (opt): An optional 32-bit unsigned value specifying 1831 the time delta in microseconds, from the beginning of the 1832 connection to the arrival of the packet indicated by Delta Largest 1833 Acknowledged. 1835 Delta Largest Acked 1..N (opt, repeated): This field has the same 1836 semantics and format as "Delta Largest Acknowledged". Repeated 1837 "Num Timestamps - 1" times. 1839 Time Since Previous Timestamp 1..N(opt, repeated): An optional 1840 16-bit unsigned value specifying time delta from the previous 1841 reported timestamp. It is encoded in the same format as the ACK 1842 Delay. Repeated "Num Timestamps - 1" times. 1844 The timestamp section lists packet receipt timestamps ordered by 1845 timestamp. 1847 8.2.2.1. Time Format 1849 DISCUSS_AND_REPLACE: Perhaps make this format simpler. 1851 The time format used in the ACK frame above is a 16-bit unsigned 1852 float with 11 explicit bits of mantissa and 5 bits of explicit 1853 exponent, specifying time in microseconds. The bit format is loosely 1854 modeled after IEEE 754. For example, 1 microsecond is represented as 1855 0x1, which has an exponent of zero, presented in the 5 high order 1856 bits, and mantissa of 1, presented in the 11 low order bits. When 1857 the explicit exponent is greater than zero, an implicit high-order 1858 12th bit of 1 is assumed in the mantissa. For example, a floating 1859 value of 0x800 has an explicit exponent of 1, as well as an explicit 1860 mantissa of 0, but then has an effective mantissa of 4096 (12th bit 1861 is assumed to be 1). Additionally, the actual exponent is one-less 1862 than the explicit exponent, and the value represents 4096 1863 microseconds. Any values larger than the representable range are 1864 clamped to 0xFFFF. 1866 8.2.3. ACK Frames and Packet Protection 1868 ACK frames that acknowledge protected packets MUST be carried in a 1869 packet that has an equivalent or greater level of packet protection. 1871 Packets that are protected with 1-RTT keys MUST be acknowledged in 1872 packets that are also protected with 1-RTT keys. 1874 A packet that is not protected and claims to acknowledge a packet 1875 number that was sent with packet protection is not valid. An 1876 unprotected packet that carries acknowledgments for protected packets 1877 MUST be discarded in its entirety. 1879 Packets that a client sends with 0-RTT packet protection MUST be 1880 acknowledged by the server in packets protected by 1-RTT keys. This 1881 can mean that the client is unable to use these acknowledgments if 1882 the server cryptographic handshake messages are delayed or lost. 1883 Note that the same limitation applies to other data sent by the 1884 server protected by the 1-RTT keys. 1886 Unprotected packets, such as those that carry the initial 1887 cryptographic handshake messages, MAY be acknowledged in unprotected 1888 packets. Unprotected packets are vulnerable to falsification or 1889 modification. Unprotected packets can be acknowledged along with 1890 protected packets in a protected packet. 1892 An endpoint SHOULD acknowledge packets containing cryptographic 1893 handshake messages in the next unprotected packet that it sends, 1894 unless it is able to acknowledge those packets in later packets 1895 protected by 1-RTT keys. At the completion of the cryptographic 1896 handshake, both peers send unprotected packets containing 1897 cryptographic handshake messages followed by packets protected by 1898 1-RTT keys. An endpoint SHOULD acknowledge the unprotected packets 1899 that complete the cryptographic handshake in a protected packet, 1900 because its peer is guaranteed to have access to 1-RTT packet 1901 protection keys. 1903 For instance, a server acknowledges a TLS ClientHello in the packet 1904 that carries the TLS ServerHello; similarly, a client can acknowledge 1905 a TLS HelloRetryRequest in the packet containing a second TLS 1906 ClientHello. The complete set of server handshake messages (TLS 1907 ServerHello through to Finished) might be acknowledged by a client in 1908 protected packets, because it is certain that the server is able to 1909 decipher the packet. 1911 8.3. MAX_DATA Frame 1913 The MAX_DATA frame (type=0x04) is used in flow control to inform the 1914 peer of the maximum amount of data that can be sent on the connection 1915 as a whole. 1917 The frame is as follows: 1919 0 1 2 3 1920 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 1921 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1922 | | 1923 + Maximum Data (64) + 1924 | | 1925 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1927 The fields in the MAX_DATA frame are as follows: 1929 Maximum Data: A 64-bit unsigned integer indicating the maximum 1930 amount of data that can be sent on the entire connection, in units 1931 of 1024 octets. That is, the updated connection-level data limit 1932 is determined by multiplying the encoded value by 1024. 1934 All data sent in STREAM frames counts toward this limit, with the 1935 exception of data on stream 0. The sum of the largest received 1936 offsets on all streams - including closed streams, but excluding 1937 stream 0 - MUST NOT exceed the value advertised by a receiver. An 1938 endpoint MUST terminate a connection with a 1939 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA error if it receives more 1940 data than the maximum data value that it has sent, unless this is a 1941 result of a change in the initial limits (see Section 7.3.2). 1943 8.4. MAX_STREAM_DATA Frame 1945 The MAX_STREAM_DATA frame (type=0x05) is used in flow control to 1946 inform a peer of the maximum amount of data that can be sent on a 1947 stream. 1949 The frame is as follows: 1951 0 1 2 3 1952 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 1953 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1954 | Stream ID (32) | 1955 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1956 | | 1957 + Maximum Stream Data (64) + 1958 | | 1959 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1961 The fields in the MAX_STREAM_DATA frame are as follows: 1963 Stream ID: The stream ID of the stream that is affected. 1965 Maximum Stream Data: A 64-bit unsigned integer indicating the 1966 maximum amount of data that can be sent on the identified stream, 1967 in units of octets. 1969 When counting data toward this limit, an endpoint accounts for the 1970 largest received offset of data that is sent or received on the 1971 stream. Loss or reordering can mean that the largest received offset 1972 on a stream can be greater than the total size of data received on 1973 that stream. Receiving STREAM frames might not increase the largest 1974 received offset. 1976 The data sent on a stream MUST NOT exceed the largest maximum stream 1977 data value advertised by the receiver. An endpoint MUST terminate a 1978 connection with a QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA error if 1979 it receives more data than the largest maximum stream data that it 1980 has sent for the affected stream, unless this is a result of a change 1981 in the initial limits (see Section 7.3.2). 1983 8.5. MAX_STREAM_ID Frame 1985 The MAX_STREAM_ID frame (type=0x06) informs the peer of the maximum 1986 stream ID that they are permitted to open. 1988 The frame is as follows: 1990 0 1 2 3 1991 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 1992 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1993 | Maximum Stream ID (32) | 1994 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1996 The fields in the MAX_STREAM_ID frame are as follows: 1998 Maximum Stream ID: ID of the maximum peer-initiated stream ID for 1999 the connection. 2001 Loss or reordering can mean that a MAX_STREAM_ID frame can be 2002 received which states a lower stream limit than the client has 2003 previously received. MAX_STREAM_ID frames which do not increase the 2004 maximum stream ID MUST be ignored. 2006 A peer MUST NOT initiate a stream with a higher stream ID than the 2007 greatest maximum stream ID it has received. An endpoint MUST 2008 terminate a connection with a QUIC_TOO_MANY_OPEN_STREAMS error if a 2009 peer initiates a stream with a higher stream ID than it has sent, 2010 unless this is a result of a change in the initial limits (see 2011 Section 7.3.2). 2013 8.6. BLOCKED Frame 2015 A sender sends a BLOCKED frame (type=0x08) when it wishes to send 2016 data, but is unable to due to connection-level flow control (see 2017 Section 11.2.1). BLOCKED frames can be used as input to tuning of 2018 flow control algorithms (see Section 11.1.2). 2020 The BLOCKED frame does not contain a payload. 2022 8.7. STREAM_BLOCKED Frame 2024 A sender sends a STREAM_BLOCKED frame (type=0x09) when it wishes to 2025 send data, but is unable to due to stream-level flow control. This 2026 frame is analogous to BLOCKED (Section 8.6). 2028 The STREAM_BLOCKED frame is as follows: 2030 0 1 2 3 2031 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 2032 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2033 | Stream ID (32) | 2034 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2036 The STREAM_BLOCKED frame contains a single field: 2038 Stream ID: A 32-bit unsigned number indicating the stream which is 2039 flow control blocked. 2041 An endpoint MAY send a STREAM_BLOCKED frame for a stream that exceeds 2042 the maximum stream ID set by its peer (see Section 8.5). This does 2043 not open the stream, but informs the peer that a new stream was 2044 needed, but the stream limit prevented the creation of the stream. 2046 8.8. STREAM_ID_NEEDED Frame 2048 A sender sends a STREAM_ID_NEEDED frame (type=0x0a) when it wishes to 2049 open a stream, but is unable to due to the maximum stream ID limit. 2051 The STREAM_ID_NEEDED frame does not contain a payload. 2053 8.9. RST_STREAM Frame 2055 An endpoint may use a RST_STREAM frame (type=0x01) to abruptly 2056 terminate a stream. 2058 After sending a RST_STREAM, an endpoint ceases transmission of STREAM 2059 frames on the identified stream. A receiver of RST_STREAM can 2060 discard any data that it already received on that stream. An 2061 endpoint sends a RST_STREAM in response to a RST_STREAM unless the 2062 stream is already closed. 2064 The RST_STREAM frame is as follows: 2066 0 1 2 3 2067 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 2068 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2069 | Stream ID (32) | 2070 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2071 | Error Code (32) | 2072 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2073 | | 2074 + Final Offset (64) + 2075 | | 2076 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2077 The fields are: 2079 Error code: A 32-bit error code which indicates why the stream is 2080 being closed. 2082 Stream ID: The 32-bit Stream ID of the stream being terminated. 2084 Final offset: A 64-bit unsigned integer indicating the absolute byte 2085 offset of the end of data written on this stream by the RST_STREAM 2086 sender. 2088 8.10. PADDING Frame 2090 The PADDING frame (type=0x00) has no semantic value. PADDING frames 2091 can be used to increase the size of a packet. Padding can be used to 2092 increase an initial client packet to the minimum required size, or to 2093 provide protection against traffic analysis for protected packets. 2095 A PADDING frame has no content. That is, a PADDING frame consists of 2096 the single octet that identifies the frame as a PADDING frame. 2098 8.11. PING frame 2100 Endpoints can use PING frames (type=0x07) to verify that their peers 2101 are still alive or to check reachability to the peer. The PING frame 2102 contains no additional fields. The receiver of a PING frame simply 2103 needs to acknowledge the packet containing this frame. The PING 2104 frame SHOULD be used to keep a connection alive when a stream is 2105 open. The default is to send a PING frame after 15 seconds of 2106 quiescence. A PING frame has no additional fields. 2108 8.12. NEW_CONNECTION_ID Frame 2110 A server sends a NEW_CONNECTION_ID to provide the client with 2111 alternative connection IDs that can be used to break linkability when 2112 migrating connections (see Section 7.6.1). 2114 The NEW_CONNECTION_ID is as follows: 2116 0 1 2 3 2117 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 2118 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2119 | Sequence (16) | 2120 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2121 | | 2122 + Connection ID (64) + 2123 | | 2124 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2125 The fields are: 2127 Sequence: A 16-bit sequence number. This value starts at 0 and 2128 increases by 1 for each connection ID that is provided by the 2129 server. The sequence value can wrap; the value 65535 is followed 2130 by 0. When wrapping the sequence field, the server MUST ensure 2131 that a value with the same sequence has been received and 2132 acknowledged by the client. The connection ID that is assigned 2133 during the handshake is assumed to have a sequence of 65535. 2135 Connection ID: A 64-bit connection ID. 2137 8.13. CONNECTION_CLOSE frame 2139 An endpoint sends a CONNECTION_CLOSE frame (type=0x02) to notify its 2140 peer that the connection is being closed. If there are open streams 2141 that haven't been explicitly closed, they are implicitly closed when 2142 the connection is closed. (Ideally, a GOAWAY frame would be sent 2143 with enough time that all streams are torn down.) The frame is as 2144 follows: 2146 0 1 2 3 2147 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 2148 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2149 | Error Code (32) | 2150 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2151 | Reason Phrase Length (16) | [Reason Phrase (*)] ... 2152 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2154 The fields of a CONNECTION_CLOSE frame are as follows: 2156 Error Code: A 32-bit error code which indicates the reason for 2157 closing this connection. 2159 Reason Phrase Length: A 16-bit unsigned number specifying the length 2160 of the reason phrase. Note that a CONNECTION_CLOSE frame cannot 2161 be split between packets, so in practice any limits on packet size 2162 will also limit the space available for a reason phrase. 2164 Reason Phrase: A human-readable explanation for why the connection 2165 was closed. This can be zero length if the sender chooses to not 2166 give details beyond the Error Code. This SHOULD be a UTF-8 2167 encoded string [RFC3629]. 2169 8.14. GOAWAY Frame 2171 An endpoint uses a GOAWAY frame (type=0x03) to initiate a graceful 2172 shutdown of a connection. The endpoints will continue to use any 2173 active streams, but the sender of the GOAWAY will not initiate or 2174 accept any additional streams beyond those indicated. The GOAWAY 2175 frame is as follows: 2177 0 1 2 3 2178 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 2179 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2180 | Largest Client Stream ID (32) | 2181 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2182 | Largest Server Stream ID (32) | 2183 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2185 The fields of a GOAWAY frame are: 2187 Largest Client Stream ID: The highest-numbered, client-initiated 2188 stream on which the endpoint sending the GOAWAY frame either sent 2189 data, or received and delivered data. All higher-numbered, 2190 client-initiated streams (that is, odd-numbered streams) are 2191 implicitly reset by sending or receiving the GOAWAY frame. 2193 Largest Server Stream ID: The highest-numbered, server-initiated 2194 stream on which the endpoint sending the GOAWAY frame either sent 2195 data, or received and delivered data. All higher-numbered, 2196 server-initiated streams (that is, even-numbered streams) are 2197 implicitly reset by sending or receiving the GOAWAY frame. 2199 A GOAWAY frame indicates that any application layer actions on 2200 streams with higher numbers than those indicated can be safely 2201 retried because no data was exchanged. An endpoint MUST set the 2202 value of the Largest Client or Server Stream ID to be at least as 2203 high as the highest-numbered stream on which it either sent data or 2204 received and delivered data to the application protocol that uses 2205 QUIC. 2207 An endpoint MAY choose a larger stream identifier if it wishes to 2208 allow for a number of streams to be created. This is especially 2209 valuable for peer-initiated streams where packets creating new 2210 streams could be in transit; using a larger stream number allows 2211 those streams to complete. 2213 In addition to initiating a graceful shutdown of a connection, GOAWAY 2214 MAY be sent immediately prior to sending a CONNECTION_CLOSE frame 2215 that is sent as a result of detecting a fatal error. Higher-numbered 2216 streams than those indicated in the GOAWAY frame can then be retried. 2218 9. Packetization and Reliability 2220 The Path Maximum Transmission Unit (PMTU) is the maximum size of the 2221 entire IP header, UDP header, and UDP payload. The UDP payload 2222 includes the QUIC public header, protected payload, and any 2223 authentication fields. 2225 All QUIC packets SHOULD be sized to fit within the estimated PMTU to 2226 avoid IP fragmentation or packet drops. To optimize bandwidth 2227 efficiency, endpoints SHOULD use Packetization Layer PMTU Discovery 2228 ([RFC4821]) and MAY use PMTU Discovery ([RFC1191], [RFC1981]) for 2229 detecting the PMTU, setting the PMTU appropriately, and storing the 2230 result of previous PMTU determinations. 2232 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 2233 packets larger than 1280 octets. Assuming the minimum IP header 2234 size, this results in a QUIC packet size of 1232 octets for IPv6 and 2235 1252 octets for IPv4. 2237 QUIC endpoints that implement any kind of PMTU discovery SHOULD 2238 maintain an estimate for each combination of local and remote IP 2239 addresses (as each pairing could have a different maximum MTU in the 2240 path). 2242 QUIC depends on the network path supporting a MTU of at least 1280 2243 octets. This is the IPv6 minimum and therefore also supported by 2244 most modern IPv4 networks. An endpoint MUST NOT reduce their MTU 2245 below this number, even if it receives signals that indicate a 2246 smaller limit might exist. 2248 Clients MUST ensure that the first packet in a connection, and any 2249 retransmissions of those octets, has a QUIC packet size of least 1232 2250 octets for an IPv6 packet and 1252 octets for an IPv4 packet. In the 2251 absence of extensions to the IP header, padding to exactly these 2252 values will result in an IP packet that is 1280 octets. 2254 The initial client packet SHOULD be padded to exactly these values 2255 unless the client has a reasonable assurance that the PMTU is larger. 2256 Sending a packet of this size ensures that the network path supports 2257 an MTU of this size and helps reduce the amplitude of amplification 2258 attacks caused by server responses toward an unverified client 2259 address. 2261 Servers MUST ignore an initial plaintext packet from a client if its 2262 total size is less than 1232 octets for IPv6 or 1252 octets for IPv4. 2264 If a QUIC endpoint determines that the PMTU between any pair of local 2265 and remote IP addresses has fallen below 1280 octets, it MUST 2266 immediately cease sending QUIC packets on the affected path. This 2267 could result in termination of the connection if an alternative path 2268 cannot be found. 2270 A sender bundles one or more frames in a Regular QUIC packet (see 2271 Section 6). 2273 A sender SHOULD minimize per-packet bandwidth and computational costs 2274 by bundling as many frames as possible within a QUIC packet. A 2275 sender MAY wait for a short period of time to bundle multiple frames 2276 before sending a packet that is not maximally packed, to avoid 2277 sending out large numbers of small packets. An implementation may 2278 use heuristics about expected application sending behavior to 2279 determine whether and for how long to wait. This waiting period is 2280 an implementation decision, and an implementation should be careful 2281 to delay conservatively, since any delay is likely to increase 2282 application-visible latency. 2284 Regular QUIC packets are "containers" of frames; a packet is never 2285 retransmitted whole. How an endpoint handles the loss of the frame 2286 depends on the type of the frame. Some frames are simply 2287 retransmitted, some have their contents moved to new frames, and 2288 others are never retransmitted. 2290 When a packet is detected as lost, the sender re-sends any frames as 2291 necessary: 2293 o All application data sent in STREAM frames MUST be retransmitted, 2294 unless the endpoint has sent a RST_STREAM for that stream. When 2295 an endpoint sends a RST_STREAM frame, data outstanding on that 2296 stream SHOULD NOT be retransmitted, since subsequent data on this 2297 stream is expected to not be delivered by the receiver. 2299 o ACK and PADDING frames MUST NOT be retransmitted. ACK frames are 2300 cumulative, so new frames containing updated information will be 2301 sent as described in Section 8.2. 2303 o All other frames MUST be retransmitted. 2305 Upon detecting losses, a sender MUST take appropriate congestion 2306 control action. The details of loss detection and congestion control 2307 are described in [QUIC-RECOVERY]. 2309 A packet MUST NOT be acknowledged until packet protection has been 2310 successfully removed and all frames contained in the packet have been 2311 processed. For STREAM frames, this means the data has been queued 2312 (but not necessarily delivered to the application). This also means 2313 that any stream state transitions triggered by STREAM or RST_STREAM 2314 frames have occurred. Once the packet has been fully processed, a 2315 receiver acknowledges receipt by sending one or more ACK frames 2316 containing the packet number of the received packet. 2318 To avoid creating an indefinite feedback loop, an endpoint MUST NOT 2319 generate an ACK frame in response to a packet containing only ACK or 2320 PADDING frames. 2322 Strategies and implications of the frequency of generating 2323 acknowledgments are discussed in more detail in [QUIC-RECOVERY]. 2325 9.1. Special Considerations for PMTU Discovery 2327 Traditional ICMP-based path MTU discovery in IPv4 [RFC1191] is 2328 potentially vulnerable to off-path attacks that successfully guess 2329 the IP/port 4-tuple and reduce the MTU to a bandwidth-inefficient 2330 value. TCP connections mitigate this risk by using the (at minimum) 2331 8 bytes of transport header echoed in the ICMP message to validate 2332 the TCP sequence number as valid for the current connection. 2333 However, as QUIC operates over UDP, in IPv4 the echoed information 2334 could consist only of the IP and UDP headers, which usually has 2335 insufficient entropy to mitigate off-path attacks. 2337 As a result, endpoints that implement PMTUD in IPv4 SHOULD take steps 2338 to mitigate this risk. For instance, an application could: 2340 o Set the IPv4 Don't Fragment (DF) bit on a small proportion of 2341 packets, so that most invalid ICMP messages arrive when there are 2342 no DF packets outstanding, and can therefore be identified as 2343 spurious. 2345 o Store additional information from the IP or UDP headers from DF 2346 packets (for example, the IP ID or UDP checksum) to further 2347 authenticate incoming Datagram Too Big messages. 2349 o Any reduction in PMTU due to a report contained in an ICMP packet 2350 is provisional until QUIC's loss detection algorithm determines 2351 that the packet is actually lost. 2353 10. Streams: QUIC's Data Structuring Abstraction 2355 Streams in QUIC provide a lightweight, ordered, and bidirectional 2356 byte-stream abstraction modeled closely on HTTP/2 streams [RFC7540]. 2358 Streams can be created either by the client or the server, can 2359 concurrently send data interleaved with other streams, and can be 2360 cancelled. 2362 Data that is received on a stream is delivered in order within that 2363 stream, but there is no particular delivery order across streams. 2364 Transmit ordering among streams is left to the implementation. 2366 The creation and destruction of streams are expected to have minimal 2367 bandwidth and computational cost. A single STREAM frame may create, 2368 carry data for, and terminate a stream, or a stream may last the 2369 entire duration of a connection. 2371 Streams are individually flow controlled, allowing an endpoint to 2372 limit memory commitment and to apply back pressure. The creation of 2373 streams is also flow controlled, with each peer declaring the maximum 2374 stream ID it is willing to accept at a given time. 2376 An alternative view of QUIC streams is as an elastic "message" 2377 abstraction, similar to the way ephemeral streams are used in SST 2378 [SST], which may be a more appealing description for some 2379 applications. 2381 10.1. Stream Identifiers 2383 Streams are identified by an unsigned 32-bit integer, referred to as 2384 the Stream ID. To avoid Stream ID collision, clients initiate 2385 streams using odd-numbered Stream IDs; streams initiated by the 2386 server use even-numbered Stream IDs. 2388 Stream ID 0 (0x0) is reserved for the cryptographic handshake. 2389 Stream 0 MUST NOT be used for application data, and is the first 2390 client-initiated stream. 2392 A QUIC endpoint cannot reuse a Stream ID. Streams MUST be created in 2393 sequential order. Open streams can be used in any order. Streams 2394 that are used out of order result in lower-numbered streams in the 2395 same direction being counted as open. 2397 Stream IDs are usually encoded as a 32-bit integer, though the STREAM 2398 frame (Section 8.1) permits a shorter encoding when the leading bits 2399 of the stream ID are zero. 2401 10.2. Life of a Stream 2403 The semantics of QUIC streams is based on HTTP/2 streams, and the 2404 lifecycle of a QUIC stream therefore closely follows that of an 2405 HTTP/2 stream [RFC7540], with some differences to accommodate the 2406 possibility of out-of-order delivery due to the use of multiple 2407 streams in QUIC. The lifecycle of a QUIC stream is shown in the 2408 following figure and described below. 2410 +--------+ 2411 | | 2412 | idle | 2413 | | 2414 +--------+ 2415 | 2416 send/recv STREAM/RST 2417 recv MSD/SB 2418 | 2419 v 2420 recv FIN/ +--------+ send FIN/ 2421 recv RST | | send RST 2422 ,---------| open |-----------. 2423 / | | \ 2424 v +--------+ v 2425 +----------+ +----------+ 2426 | half | | half | 2427 | closed | | closed | 2428 | (remote) | | (local) | 2429 +----------+ +----------+ 2430 | | 2431 | send FIN/ +--------+ recv FIN/ | 2432 \ send RST | | recv RST / 2433 `----------->| closed |<-------------' 2434 | | 2435 +--------+ 2437 send: endpoint sends this frame 2438 recv: endpoint receives this frame 2440 STREAM: a STREAM frame 2441 FIN: FIN flag in a STREAM frame 2442 RST: RST_STREAM frame 2443 MSD: MAX_STREAM_DATA frame 2444 SB: STREAM_BLOCKED frame 2446 Figure 11: Lifecycle of a stream 2448 Note that this diagram shows stream state transitions and the frames 2449 and flags that affect those transitions only. It is possible for a 2450 single frame to cause two transitions: receiving a RST_STREAM frame, 2451 or a STREAM frame with the FIN flag cause the stream state to move 2452 from "idle" to "open" and then immediately to one of the "half- 2453 closed" states. 2455 The recipient of a frame that changes stream state will have a 2456 delayed view of the state of a stream while the frame is in transit. 2457 Endpoints do not coordinate the creation of streams; they are created 2458 unilaterally by either endpoint. Endpoints can use acknowledgments 2459 to understand the peer's subjective view of stream state at any given 2460 time. 2462 In the absence of more specific guidance elsewhere in this document, 2463 implementations SHOULD treat the receipt of a frame that is not 2464 expressly permitted in the description of a state as a connection 2465 error (see Section 12). 2467 10.2.1. idle 2469 All streams start in the "idle" state. 2471 The following transitions are valid from this state: 2473 Sending or receiving a STREAM or RST_STREAM frame causes the 2474 identified stream to become "open". The stream identifier for a new 2475 stream is selected as described in Section 10.1. A RST_STREAM frame, 2476 or a STREAM frame with the FIN flag set also causes a stream to 2477 become "half-closed". 2479 An endpoint might receive MAX_STREAM_DATA or STREAM_BLOCKED frames on 2480 peer-initiated streams that are "idle" if there is loss or reordering 2481 of packets. Receiving these frames also causes the stream to become 2482 "open". 2484 An endpoint MUST NOT send a STREAM or RST_STREAM frame for a stream 2485 ID that is higher than the peers advertised maximum stream ID (see 2486 Section 8.5). 2488 10.2.2. open 2490 A stream in the "open" state may be used by both peers to send frames 2491 of any type. In this state, endpoints can send MAX_STREAM_DATA and 2492 MUST observe the value advertised by its receiving peer (see 2493 Section 11). 2495 Opening a stream causes all lower-numbered streams in the same 2496 direction to become open. Thus, opening an odd-numbered stream 2497 causes all "idle", odd-numbered streams with a lower identifier to 2498 become open and the same applies to even numbered streams. Endpoints 2499 open streams in increasing numeric order, but loss or reordering can 2500 cause packets that open streams to arrive out of order. 2502 From the "open" state, either endpoint can send a frame with the FIN 2503 flag set, which causes the stream to transition into one of the 2504 "half-closed" states. This flag can be set on the frame that opens 2505 the stream, which causes the stream to immediately become "half- 2506 closed". Once an endpoint has completed sending all stream data and 2507 a STREAM frame with a FIN flag, the stream state becomes "half-closed 2508 (local)". When an endpoint receives all stream data a FIN flag the 2509 stream state becomes "half-closed (remote)". An endpoint MUST NOT 2510 consider the stream state to have changed until all data has been 2511 sent, received or discarded. 2513 A RST_STREAM frame on an "open" stream causes the stream to become 2514 "half-closed". A stream that becomes "open" as a result of sending 2515 or receiving RST_STREAM immediately becomes "half-closed". Sending a 2516 RST_STREAM frame causes the stream to become "half-closed (local)"; 2517 receiving RST_STREAM causes the stream to become "half-closed 2518 (remote)". 2520 Any frame type that mentions a stream ID can be sent in this state. 2522 10.2.3. half-closed (local) 2524 A stream that is in the "half-closed (local)" state MUST NOT be used 2525 for sending on new STREAM frames. Retransmission of data that has 2526 already been sent on STREAM frames is permitted. An endpoint MAY 2527 also send MAX_STREAM_DATA and RST_STREAM in this state. 2529 An endpoint that closes a stream MUST NOT send data beyond the final 2530 offset that it has chosen, see Section 10.2.5 for details. 2532 A stream transitions from this state to "closed" when a STREAM frame 2533 that contains a FIN flag is received and all prior data has arrived, 2534 or when a RST_STREAM frame is received. 2536 An endpoint can receive any frame that mentions a stream ID in this 2537 state. Providing flow-control credit using MAX_STREAM_DATA frames is 2538 necessary to continue receiving flow-controlled frames. In this 2539 state, a receiver MAY ignore MAX_STREAM_DATA frames for this stream, 2540 which might arrive for a short period after a frame bearing the FIN 2541 flag is sent. 2543 10.2.4. half-closed (remote) 2545 A stream is "half-closed (remote)" when the stream is no longer being 2546 used by the peer to send any data. An endpoint will have either 2547 received all data that a peer has sent or will have received a 2548 RST_STREAM frame and discarded any received data. 2550 Once all data has been either received or discarded, a sender is no 2551 longer obligated to update the maximum received data for the 2552 connection. 2554 An endpoint that receives a RST_STREAM frame (and which has not sent 2555 a FIN or a RST_STREAM) MUST immediately respond with a RST_STREAM 2556 frame, and MUST NOT send any more data on the stream. 2558 Due to reordering, an endpoint could continue receiving frames for 2559 the stream even after the stream is closed for sending. Frames 2560 received after a peer closes a stream SHOULD be discarded. An 2561 endpoint MAY choose to limit the period over which it ignores frames 2562 and treat frames that arrive after this time as being in error. 2564 An endpoint will know the final offset of the data it receives on a 2565 stream when it reaches the "half-closed (remote)" state, see 2566 Section 11.3 for details. 2568 A stream in this state can be used by the endpoint to send any frame 2569 that mentions a stream ID. In this state, the endpoint MUST observe 2570 advertised stream and connection data limits (see Section 11). 2572 A stream transitions from this state to "closed" by completing 2573 transmission of all data. This includes sending all data carried in 2574 STREAM frames up including the terminal STREAM frame that contains a 2575 FIN flag. 2577 A stream becomes "closed" when the endpoint sends and receives 2578 acknowledgment of a RST_STREAM frame. 2580 10.2.5. closed 2582 The "closed" state is the terminal state for a stream. 2584 Once a stream reaches this state, no frames can be sent that mention 2585 the stream. Reordering might cause frames to be received after 2586 closing, see Section 10.2.4. 2588 10.3. Stream Concurrency 2590 An endpoint limits the number of concurrently active incoming streams 2591 by adjusting the maximum stream ID. An initial value is set in the 2592 transport parameters (see Section 7.3.1) and is subsequently 2593 increased by MAX_STREAM_ID frames (see Section 8.5). 2595 The maximum stream ID is specific to each endpoint and applies only 2596 to the peer that receives the setting. That is, clients specify the 2597 maximum stream ID the server can initiate, and servers specify the 2598 maximum stream ID the client can initiate. Each endpoint may respond 2599 on streams initiated by the other peer, regardless of whether it is 2600 permitted to initiated new streams. 2602 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 2603 that receives a STREAM frame with an ID greater than the limit it has 2604 sent MUST treat this as a stream error of type 2605 QUIC_TOO_MANY_OPEN_STREAMS (Section 12), unless this is a result of a 2606 change in the initial offsets (see Section 7.3.2). 2608 A receiver MUST NOT renege on an advertisement; that is, once a 2609 receiver advertises a stream ID via a MAX_STREAM_ID frame, it MUST 2610 NOT subsequently advertise a smaller maximum ID. A sender may 2611 receive MAX_STREAM_ID frames out of order; a sender MUST therefore 2612 ignore any MAX_STREAM_ID that does not increase the maximum. 2614 10.4. Sending and Receiving Data 2616 Once a stream is created, endpoints may use the stream to send and 2617 receive data. Each endpoint may send a series of STREAM frames 2618 encapsulating data on a stream until the stream is terminated in that 2619 direction. Streams are an ordered byte-stream abstraction, and they 2620 have no other structure within them. STREAM frame boundaries are not 2621 expected to be preserved in retransmissions from the sender or during 2622 delivery to the application at the receiver. 2624 When new data is to be sent on a stream, a sender MUST set the 2625 encapsulating STREAM frame's offset field to the stream offset of the 2626 first byte of this new data. The first byte of data that is sent on 2627 a stream has the stream offset 0. The largest offset delivered on a 2628 stream MUST be less than 2^64. A receiver MUST ensure that received 2629 stream data is delivered to the application as an ordered byte- 2630 stream. Data received out of order MUST be buffered for later 2631 delivery, as long as it is not in violation of the receiver's flow 2632 control limits. 2634 An endpoint MUST NOT send data on any stream without ensuring that it 2635 is within the data limits set by its peer. The cryptographic 2636 handshake stream, Stream 0, is exempt from the connection-level data 2637 limits established by MAX_DATA. Stream 0 is still subject to stream- 2638 level data limits and MAX_STREAM_DATA. 2640 Flow control is described in detail in Section 11, and congestion 2641 control is described in the companion document [QUIC-RECOVERY]. 2643 10.5. Stream Prioritization 2645 Stream multiplexing has a significant effect on application 2646 performance if resources allocated to streams are correctly 2647 prioritized. Experience with other multiplexed protocols, such as 2648 HTTP/2 [RFC7540], shows that effective prioritization strategies have 2649 a significant positive impact on performance. 2651 QUIC does not provide frames for exchanging prioritization 2652 information. Instead it relies on receiving priority information 2653 from the application that uses QUIC. Protocols that use QUIC are 2654 able to define any prioritization scheme that suits their application 2655 semantics. A protocol might define explicit messages for signaling 2656 priority, such as those defined in HTTP/2; it could define rules that 2657 allow an endpoint to determine priority based on context; or it could 2658 leave the determination to the application. 2660 A QUIC implementation SHOULD provide ways in which an application can 2661 indicate the relative priority of streams. When deciding which 2662 streams to dedicate resources to, QUIC SHOULD use the information 2663 provided by the application. Failure to account for priority of 2664 streams can result in suboptimal performance. 2666 Stream priority is most relevant when deciding which stream data will 2667 be transmitted. Often, there will be limits on what can be 2668 transmitted as a result of connection flow control or the current 2669 congestion controller state. 2671 Giving preference to the transmission of its own management frames 2672 ensures that the protocol functions efficiently. That is, 2673 prioritizing frames other than STREAM frames ensures that loss 2674 recovery, congestion control, and flow control operate effectively. 2676 Stream 0 MUST be prioritized over other streams prior to the 2677 completion of the cryptographic handshake. This includes the 2678 retransmission of the second flight of client handshake messages, 2679 that is, the TLS Finished and any client authentication messages. 2681 STREAM frames that are determined to be lost SHOULD be retransmitted 2682 before sending new data, unless application priorities indicate 2683 otherwise. Retransmitting lost STREAM frames can fill in gaps, which 2684 allows the peer to consume already received data and free up flow 2685 control window. 2687 11. Flow Control 2689 It is necessary to limit the amount of data that a sender may have 2690 outstanding at any time, so as to prevent a fast sender from 2691 overwhelming a slow receiver, or to prevent a malicious sender from 2692 consuming significant resources at a receiver. This section 2693 describes QUIC's flow-control mechanisms. 2695 QUIC employs a credit-based flow-control scheme similar to HTTP/2's 2696 flow control [RFC7540]. A receiver advertises the number of octets 2697 it is prepared to receive on a given stream and for the entire 2698 connection. This leads to two levels of flow control in QUIC: (i) 2699 Connection flow control, which prevents senders from exceeding a 2700 receiver's buffer capacity for the connection, and (ii) Stream flow 2701 control, which prevents a single stream from consuming the entire 2702 receive buffer for a connection. 2704 A receiver sends MAX_DATA or MAX_STREAM_DATA frames to the sender to 2705 advertise additional credit by sending the absolute byte offset in 2706 the connection or stream which it is willing to receive. 2708 A receiver MAY advertise a larger offset at any point by sending 2709 MAX_DATA or MAX_STREAM_DATA frames. A receiver MUST NOT renege on an 2710 advertisement; that is, once a receiver advertises an offset, it MUST 2711 NOT subsequently advertise a smaller offset. A sender could receive 2712 MAX_DATA or MAX_STREAM_DATA frames out of order; a sender MUST 2713 therefore ignore any flow control offset that does not move the 2714 window forward. 2716 A receiver MUST close the connection with a 2717 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA error (Section 12) if the 2718 peer violates the advertised connection or stream data limits. 2720 A sender MUST send BLOCKED frames to indicate it has data to write 2721 but is blocked by lack of connection or stream flow control credit. 2722 BLOCKED frames are expected to be sent infrequently in common cases, 2723 but they are considered useful for debugging and monitoring purposes. 2725 A receiver advertises credit for a stream by sending a 2726 MAX_STREAM_DATA frame with the Stream ID set appropriately. A 2727 receiver could use the current offset of data consumed to determine 2728 the flow control offset to be advertised. A receiver MAY send 2729 MAX_STREAM_DATA frames in multiple packets in order to make sure that 2730 the sender receives an update before running out of flow control 2731 credit, even if one of the packets is lost. 2733 Connection flow control is a limit to the total bytes of stream data 2734 sent in STREAM frames on all streams. A receiver advertises credit 2735 for a connection by sending a MAX_DATA frame. A receiver maintains a 2736 cumulative sum of bytes received on all streams, which are used to 2737 check for flow control violations. A receiver might use a sum of 2738 bytes consumed on all contributing streams to determine the maximum 2739 data limit to be advertised. 2741 11.1. Edge Cases and Other Considerations 2743 There are some edge cases which must be considered when dealing with 2744 stream and connection level flow control. Given enough time, both 2745 endpoints must agree on flow control state. If one end believes it 2746 can send more than the other end is willing to receive, the 2747 connection will be torn down when too much data arrives. 2749 Conversely if a sender believes it is blocked, while endpoint B 2750 expects more data can be received, then the connection can be in a 2751 deadlock, with the sender waiting for a MAX_DATA or MAX_STREAM_DATA 2752 frame which will never come. 2754 On receipt of a RST_STREAM frame, an endpoint will tear down state 2755 for the matching stream and ignore further data arriving on that 2756 stream. This could result in the endpoints getting out of sync, 2757 since the RST_STREAM frame may have arrived out of order and there 2758 may be further bytes in flight. The data sender would have counted 2759 the data against its connection level flow control budget, but a 2760 receiver that has not received these bytes would not know to include 2761 them as well. The receiver must learn the number of bytes that were 2762 sent on the stream to make the same adjustment in its connection flow 2763 controller. 2765 To avoid this de-synchronization, a RST_STREAM sender MUST include 2766 the final byte offset sent on the stream in the RST_STREAM frame. On 2767 receiving a RST_STREAM frame, a receiver definitively knows how many 2768 bytes were sent on that stream before the RST_STREAM frame, and the 2769 receiver MUST use the final offset to account for all bytes sent on 2770 the stream in its connection level flow controller. 2772 11.1.1. Response to a RST_STREAM 2774 Since streams are bidirectional, a sender of a RST_STREAM needs to 2775 know how many bytes the peer has sent on the stream. If an endpoint 2776 receives a RST_STREAM frame and has sent neither a FIN nor a 2777 RST_STREAM, it MUST send a RST_STREAM in response, bearing the offset 2778 of the last byte sent on this stream as the final offset. 2780 11.1.2. Data Limit Increments 2782 This document leaves when and how many bytes to advertise in a 2783 MAX_DATA or MAX_STREAM_DATA to implementations, but offers a few 2784 considerations. These frames contribute to connection overhead. 2785 Therefore frequently sending frames with small changes is 2786 undesirable. At the same time, infrequent updates require larger 2787 increments to limits if blocking is to be avoided. Thus, larger 2788 updates require a receiver to commit to larger resource commitments. 2789 Thus there is a tradeoff between resource commitment and overhead 2790 when determining how large a limit is advertised. 2792 A receiver MAY use an autotuning mechanism to tune the frequency and 2793 amount that it increases data limits based on a roundtrip time 2794 estimate and the rate at which the receiving application consumes 2795 data, similar to common TCP implementations. 2797 11.2. Stream Limit Increment 2799 As with flow control, this document leaves when and how many streams 2800 to make available to a peer via MAX_STREAM_ID to implementations, but 2801 offers a few considerations. MAX_STREAM_ID frames constitute minimal 2802 overhead, while withholding MAX_STREAM_ID frames can prevent the peer 2803 from using the available parallelism. 2805 Implementations will likely want to increase the maximum stream ID as 2806 peer-initiated streams close. A receiver MAY also advance the 2807 maximum stream ID based on current activity, system conditions, and 2808 other environmental factors. 2810 11.2.1. Blocking on Flow Control 2812 If a sender does not receive a MAX_DATA or MAX_STREAM_DATA frame when 2813 it has run out of flow control credit, the sender will be blocked and 2814 MUST send a BLOCKED or STREAM_BLOCKED frame. These frames are 2815 expected to be useful for debugging at the receiver; they do not 2816 require any other action. A receiver SHOULD NOT wait for a BLOCKED 2817 or STREAM_BLOCKED frame before sending MAX_DATA or MAX_STREAM_DATA, 2818 since doing so will mean that a sender is unable to send for an 2819 entire round trip. 2821 For smooth operation of the congestion controller, it is generally 2822 considered best to not let the sender go into quiescence if 2823 avoidable. To avoid blocking a sender, and to reasonably account for 2824 the possibiity of loss, a receiver should send a MAX_DATA or 2825 MAX_STREAM_DATA frame at least two roundtrips before it expects the 2826 sender to get blocked. 2828 A sender sends a single BLOCKED or STREAM_BLOCKED frame only once 2829 when it reaches a data limit. A sender MUST NOT send multiple 2830 BLOCKED or STREAM_BLOCKED frames for the same data limit, unless the 2831 original frame is determined to be lost. Another BLOCKED or 2832 STREAM_BLOCKED frame can be sent after the data limit is increased. 2834 11.3. Stream Final Offset 2836 The final offset is the count of the number of octets that are 2837 transmitted on a stream. For a stream that is reset, the final 2838 offset is carried explicitly in the RST_STREAM frame. Otherwise, the 2839 final offset is the offset of the end of the data carried in STREAM 2840 frame marked with a FIN flag. 2842 An endpoint will know the final offset for a stream when the stream 2843 enters the "half-closed (remote)" state. However, if there is 2844 reordering or loss, an endpoint might learn the final offset prior to 2845 entering this state if it is carried on a STREAM frame. 2847 An endpoint MUST NOT send data on a stream at or beyond the final 2848 offset. 2850 Once a final offset for a stream is known, it cannot change. If a 2851 RST_STREAM or STREAM frame causes the final offset to change for a 2852 stream, an endpoint SHOULD respond with a 2853 QUIC_STREAM_DATA_AFTER_TERMINATION error (see Section 12). A 2854 receiver SHOULD treat receipt of data at or beyond the final offset 2855 as a QUIC_STREAM_DATA_AFTER_TERMINATION error, even after a stream is 2856 closed. Generating these errors is not mandatory, but only because 2857 requiring that an endpoint generate these errors also means that the 2858 endpoint needs to maintain the final offset state for closed streams, 2859 which could mean a significant state commitment. 2861 12. Error Handling 2863 An endpoint that detects an error SHOULD signal the existence of that 2864 error to its peer. Errors can affect an entire connection (see 2865 Section 12.1), or a single stream (see Section 12.2). 2867 The most appropriate error code (Section 12.3) SHOULD be included in 2868 the frame that signals the error. Where this specification 2869 identifies error conditions, it also identifies the error code that 2870 is used. 2872 Public Reset is not suitable for any error that can be signaled with 2873 a CONNECTION_CLOSE or RST_STREAM frame. Public Reset MUST NOT be 2874 sent by an endpoint that has the state necessary to send a frame on 2875 the connection. 2877 12.1. Connection Errors 2879 Errors that result in the connection being unusable, such as an 2880 obvious violation of protocol semantics or corruption of state that 2881 affects an entire connection, MUST be signaled using a 2882 CONNECTION_CLOSE frame (Section 8.13). An endpoint MAY close the 2883 connection in this manner, even if the error only affects a single 2884 stream. 2886 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 2887 endpoint SHOULD be prepared to retransmit a packet containing a 2888 CONNECTION_CLOSE frame if it receives more packets on a terminated 2889 connection. Limiting the number of retransmissions and the time over 2890 which this final packet is sent limits the effort expended on 2891 terminated connections. 2893 An endpoint that chooses not to retransmit packets containing 2894 CONNECTION_CLOSE risks a peer missing the first such packet. The 2895 only mechanism available to an endpoint that continues to receive 2896 data for a terminated connection is to send a Public Reset packet. 2898 12.2. Stream Errors 2900 If the error affects a single stream, but otherwise leaves the 2901 connection in a recoverable state, the endpoint can send a RST_STREAM 2902 frame (Section 8.9) with an appropriate error code to terminate just 2903 the affected stream. 2905 Stream 0 is critical to the functioning of the entire connection. If 2906 stream 0 is closed with either a RST_STREAM or STREAM frame bearing 2907 the FIN flag, an endpoint MUST generate a connection error of type 2908 QUIC_CLOSED_CRITICAL_STREAM. 2910 Some application protocols make other streams critical to that 2911 protocol. An application protocol does not need to inform the 2912 transport that a stream is critical; it can instead generate 2913 appropriate errors in response to being notified that the critical 2914 stream is closed. 2916 An endpoint MAY send a RST_STREAM frame in the same packet as a 2917 CONNECTION_CLOSE frame. 2919 12.3. Error Codes 2921 Error codes are 32 bits long, with the first two bits indicating the 2922 source of the error code: 2924 0x00000000-0x3FFFFFFF: Application-specific error codes. Defined by 2925 each application-layer protocol. 2927 0x40000000-0x7FFFFFFF: Reserved for host-local error codes. These 2928 codes MUST NOT be sent to a peer, but MAY be used in API return 2929 codes and logs. 2931 0x80000000-0xBFFFFFFF: QUIC transport error codes, including packet 2932 protection errors. Applicable to all uses of QUIC. 2934 0xC0000000-0xFFFFFFFF: Cryptographic error codes. Defined by the 2935 cryptographic handshake protocol in use. 2937 This section lists the defined QUIC transport error codes that may be 2938 used in a CONNECTION_CLOSE or RST_STREAM frame. Error codes share a 2939 common code space. Some error codes apply only to either streams or 2940 the entire connection and have no defined semantics in the other 2941 context. 2943 QUIC_INTERNAL_ERROR (0x80000001): Connection has reached an invalid 2944 state. 2946 QUIC_STREAM_DATA_AFTER_TERMINATION (0x80000002): There were data 2947 frames after the a fin or reset. 2949 QUIC_INVALID_PACKET_HEADER (0x80000003): Control frame is malformed. 2951 QUIC_INVALID_FRAME_DATA (0x80000004): Frame data is malformed. 2953 QUIC_MULTIPLE_TERMINATION_OFFSETS (0x80000005): Multiple final 2954 offset values were received on the same stream 2956 QUIC_STREAM_CANCELLED (0x80000006): The stream was cancelled 2958 QUIC_CLOSED_CRITICAL_STREAM (0x80000007): A stream that is critical 2959 to the protocol was closed. 2961 QUIC_MISSING_PAYLOAD (0x80000030): The packet contained no payload. 2963 QUIC_INVALID_STREAM_DATA (0x8000002E): STREAM frame data is 2964 malformed. 2966 QUIC_UNENCRYPTED_STREAM_DATA (0x8000003D): Received STREAM frame 2967 data is not encrypted. 2969 QUIC_MAYBE_CORRUPTED_MEMORY (0x80000059): Received a frame which is 2970 likely the result of memory corruption. 2972 QUIC_INVALID_RST_STREAM_DATA (0x80000006): RST_STREAM frame data is 2973 malformed. 2975 QUIC_INVALID_CONNECTION_CLOSE_DATA (0x80000007): CONNECTION_CLOSE 2976 frame data is malformed. 2978 QUIC_INVALID_GOAWAY_DATA (0x80000008): GOAWAY frame data is 2979 malformed. 2981 QUIC_INVALID_WINDOW_UPDATE_DATA (0x80000039): WINDOW_UPDATE frame 2982 data is malformed. 2984 QUIC_INVALID_BLOCKED_DATA (0x8000003A): BLOCKED frame data is 2985 malformed. 2987 QUIC_INVALID_PATH_CLOSE_DATA (0x8000004E): PATH_CLOSE frame data is 2988 malformed. 2990 QUIC_INVALID_ACK_DATA (0x80000009): ACK frame data is malformed. 2992 QUIC_INVALID_VERSION_NEGOTIATION_PACKET (0x8000000A): Version 2993 negotiation packet is malformed. 2995 QUIC_INVALID_PUBLIC_RST_PACKET (0x8000000b): Public RST packet is 2996 malformed. 2998 QUIC_DECRYPTION_FAILURE (0x8000000c): There was an error decrypting. 3000 QUIC_ENCRYPTION_FAILURE (0x8000000d): There was an error encrypting. 3002 QUIC_PACKET_TOO_LARGE (0x8000000e): The packet exceeded 3003 kMaxPacketSize. 3005 QUIC_PEER_GOING_AWAY (0x80000010): The peer is going away. May be a 3006 client or server. 3008 QUIC_INVALID_STREAM_ID (0x80000011): A stream ID was invalid. 3010 QUIC_INVALID_PRIORITY (0x80000031): A priority was invalid. 3012 QUIC_TOO_MANY_OPEN_STREAMS (0x80000012): Too many streams already 3013 open. 3015 QUIC_TOO_MANY_AVAILABLE_STREAMS (0x8000004c): The peer created too 3016 many available streams. 3018 QUIC_PUBLIC_RESET (0x80000013): Received public reset for this 3019 connection. 3021 QUIC_INVALID_VERSION (0x80000014): Invalid protocol version. 3023 QUIC_INVALID_HEADER_ID (0x80000016): The Header ID for a stream was 3024 too far from the previous. 3026 QUIC_INVALID_NEGOTIATED_VALUE (0x80000017): Negotiable parameter 3027 received during handshake had invalid value. 3029 QUIC_DECOMPRESSION_FAILURE (0x80000018): There was an error 3030 decompressing data. 3032 QUIC_NETWORK_IDLE_TIMEOUT (0x80000019): The connection timed out due 3033 to no network activity. 3035 QUIC_HANDSHAKE_TIMEOUT (0x80000043): The connection timed out 3036 waiting for the handshake to complete. 3038 QUIC_ERROR_MIGRATING_ADDRESS (0x8000001a): There was an error 3039 encountered migrating addresses. 3041 QUIC_ERROR_MIGRATING_PORT (0x80000056): There was an error 3042 encountered migrating port only. 3044 QUIC_EMPTY_STREAM_FRAME_NO_FIN (0x80000032): We received a 3045 STREAM_FRAME with no data and no fin flag set. 3047 QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA (0x8000003b): The peer 3048 received too much data, violating flow control. 3050 QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA (0x8000003f): The peer sent too 3051 much data, violating flow control. 3053 QUIC_FLOW_CONTROL_INVALID_WINDOW (0x80000040): The peer received an 3054 invalid flow control window. 3056 QUIC_CONNECTION_IP_POOLED (0x8000003e): The connection has been IP 3057 pooled into an existing connection. 3059 QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS (0x80000044): The connection 3060 has too many outstanding sent packets. 3062 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS (0x80000045): The 3063 connection has too many outstanding received packets. 3065 QUIC_CONNECTION_CANCELLED (0x80000046): The QUIC connection has been 3066 cancelled. 3068 QUIC_BAD_PACKET_LOSS_RATE (0x80000047): Disabled QUIC because of 3069 high packet loss rate. 3071 QUIC_PUBLIC_RESETS_POST_HANDSHAKE (0x80000049): Disabled QUIC 3072 because of too many PUBLIC_RESETs post handshake. 3074 QUIC_TIMEOUTS_WITH_OPEN_STREAMS (0x8000004a): Disabled QUIC because 3075 of too many timeouts with streams open. 3077 QUIC_TOO_MANY_RTOS (0x80000055): QUIC timed out after too many RTOs. 3079 QUIC_ENCRYPTION_LEVEL_INCORRECT (0x8000002c): A packet was received 3080 with the wrong encryption level (i.e. it should have been 3081 encrypted but was not.) 3083 QUIC_VERSION_NEGOTIATION_MISMATCH (0x80000037): This connection 3084 involved a version negotiation which appears to have been tampered 3085 with. 3087 QUIC_IP_ADDRESS_CHANGED (0x80000050): IP address changed causing 3088 connection close. 3090 QUIC_ADDRESS_VALIDATION_FAILURE (0x80000051): Client address 3091 validation failed. 3093 QUIC_TOO_MANY_FRAME_GAPS (0x8000005d): Stream frames arrived too 3094 discontiguously so that stream sequencer buffer maintains too many 3095 gaps. 3097 QUIC_TOO_MANY_SESSIONS_ON_SERVER (0x80000060): Connection closed 3098 because server hit max number of sessions allowed. 3100 13. Security and Privacy Considerations 3102 13.1. Spoofed ACK Attack 3104 An attacker receives an STK from the server and then releases the IP 3105 address on which it received the STK. The attacker may, in the 3106 future, spoof this same address (which now presumably addresses a 3107 different endpoint), and initiate a 0-RTT connection with a server on 3108 the victim's behalf. The attacker then spoofs ACK frames to the 3109 server which cause the server to potentially drown the victim in 3110 data. 3112 There are two possible mitigations to this attack. The simplest one 3113 is that a server can unilaterally create a gap in packet-number 3114 space. In the non-attack scenario, the client will send an ACK frame 3115 with the larger value for largest acknowledged. In the attack 3116 scenario, the attacker could acknowledge a packet in the gap. If the 3117 server sees an acknowledgment for a packet that was never sent, the 3118 connection can be aborted. 3120 The second mitigation is that the server can require that 3121 acknowledgments for sent packets match the encryption level of the 3122 sent packet. This mitigation is useful if the connection has an 3123 ephemeral forward-secure key that is generated and used for every new 3124 connection. If a packet sent is protected with a forward-secure key, 3125 then any acknowledgments that are received for them MUST also be 3126 forward-secure protected. Since the attacker will not have the 3127 forward secure key, the attacker will not be able to generate 3128 forward-secure protected packets with ACK frames. 3130 13.2. Slowloris Attacks 3132 The attacks commonly known as Slowloris [SLOWLORIS] try to keep many 3133 connections to the target endpoint open and hold them open as long as 3134 possible. These attacks can be executed against a QUIC endpoint by 3135 generating the minimum amount of activity necessary to avoid being 3136 closed for inactivity. This might involve sending small amounts of 3137 data, gradually opening flow control windows in order to control the 3138 sender rate, or manufacturing ACK frames that simulate a high loss 3139 rate. 3141 QUIC deployments SHOULD provide mitigations for the Slowloris 3142 attacks, such as increasing the maximum number of clients the server 3143 will allow, limiting the number of connections a single IP address is 3144 allowed to make, imposing restrictions on the minimum transfer speed 3145 a connection is allowed to have, and restricting the length of time 3146 an endpoint is allowed to stay connected. 3148 13.3. Stream Fragmentation and Reassembly Attacks 3150 An adversarial endpoint might intentionally fragment the data on 3151 stream buffers in order to cause disproportionate memory commitment. 3152 An adversarial endpoint could open a stream and send some STREAM 3153 frames containing arbitrary fragments of the stream content. 3155 The attack is mitigated if flow control windows correspond to 3156 available memory. However, some receivers will over-commit memory 3157 and advertise flow control offsets in the aggregate that exceed 3158 actual available memory. The over-commitment strategy can lead to 3159 better performance when endpoints are well behaved, but renders 3160 endpoints vulnerable to the stream fragmentation attack. 3162 QUIC deployments SHOULD provide mitigations against the stream 3163 fragmentation attack. Mitigations could consist of avoiding over- 3164 committing memory, delaying reassembly of STREAM frames, implementing 3165 heuristics based on the age and duration of reassembly holes, or some 3166 combination. 3168 13.4. Stream Commitment Attack 3170 An adversarial endpoint can open lots of streams, exhausting state on 3171 an endpoint. The adversarial endpoint could repeat the process on a 3172 large number of connections, in a manner similar to SYN flooding 3173 attacks in TCP. 3175 Normally, clients will open streams sequentially, as explained in 3176 Section 10.1. However, when several streams are initiated at short 3177 intervals, transmission error may cause STREAM DATA frames opening 3178 streams to be received out of sequence. A receiver is obligated to 3179 open intervening streams if a higher-numbered stream ID is received. 3180 Thus, on a new connection, opening stream 2000001 opens 1 million 3181 streams, as required by the specification. 3183 The number of active streams is limited by the concurrent stream 3184 limit transport parameter, as explained in Section 10.3. If chosen 3185 judisciously, this limit mitigates the effect of the stream 3186 commitment attack. However, setting the limit too low could affect 3187 performance when applications expect to open large number of streams. 3189 14. IANA Considerations 3191 14.1. QUIC Transport Parameter Registry 3193 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 3194 under a "QUIC Protocol" heading. 3196 The "QUIC Transport Parameters" registry governs a 16-bit space. 3197 This space is split into two spaces that are governed by different 3198 policies. Values with the first byte in the range 0x00 to 0xfe (in 3199 hexadecimal) are assigned via the Specification Required policy 3200 [RFC5226]. Values with the first byte 0xff are reserved for Private 3201 Use [RFC5226]. 3203 Registrations MUST include the following fields: 3205 Value: The numeric value of the assignment (registrations will be 3206 between 0x0000 and 0xfeff). 3208 Parameter Name: A short mnemonic for the parameter. 3210 Specification: A reference to a publicly available specification for 3211 the value. 3213 The nominated expert(s) verify that a specification exists and is 3214 readily accessible. The expert(s) are encouraged to be biased 3215 towards approving registrations unless they are abusive, frivolous, 3216 or actively harmful (not merely aesthetically displeasing, or 3217 architecturally dubious). 3219 The initial contents of this registry are shown in Table 4. 3221 +--------+-------------------------+---------------+ 3222 | Value | Parameter Name | Specification | 3223 +--------+-------------------------+---------------+ 3224 | 0x0000 | initial_max_stream_data | Section 7.3.1 | 3225 | | | | 3226 | 0x0001 | initial_max_data | Section 7.3.1 | 3227 | | | | 3228 | 0x0002 | initial_max_stream_id | Section 7.3.1 | 3229 | | | | 3230 | 0x0003 | idle_timeout | Section 7.3.1 | 3231 | | | | 3232 | 0x0004 | truncate_connection_id | Section 7.3.1 | 3233 | | | | 3234 | 0x0005 | max_packet_size | Section 7.3.1 | 3235 +--------+-------------------------+---------------+ 3237 Table 4: Initial QUIC Transport Parameters Entries 3239 15. References 3241 15.1. Normative References 3243 [I-D.ietf-tls-tls13] 3244 Rescorla, E., "The Transport Layer Security (TLS) Protocol 3245 Version 1.3", draft-ietf-tls-tls13-20 (work in progress), 3246 April 2017. 3248 [QUIC-RECOVERY] 3249 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 3250 and Congestion Control", draft-ietf-quic-recovery (work in 3251 progress), June 2017. 3253 [QUIC-TLS] 3254 Thomson, M., Ed. and S. Turner, Ed., "Using Transport 3255 Layer Security (TLS) to Secure QUIC", draft-ietf-quic-tls 3256 (work in progress), June 2017. 3258 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 3259 DOI 10.17487/RFC1191, November 1990, 3260 . 3262 [RFC1981] McCann, J., Deering, S., and J. Mogul, "Path MTU Discovery 3263 for IP version 6", RFC 1981, DOI 10.17487/RFC1981, August 3264 1996, . 3266 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 3267 Requirement Levels", BCP 14, RFC 2119, 3268 DOI 10.17487/RFC2119, March 1997, 3269 . 3271 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 3272 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 3273 2003, . 3275 [RFC4821] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 3276 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 3277 . 3279 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 3280 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 3281 DOI 10.17487/RFC5226, May 2008, 3282 . 3284 15.2. Informative References 3286 [EARLY-DESIGN] 3287 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 3288 December 2013, . 3290 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 3291 RFC 2360, DOI 10.17487/RFC2360, June 1998, 3292 . 3294 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 3295 "Randomness Requirements for Security", BCP 106, RFC 4086, 3296 DOI 10.17487/RFC4086, June 2005, 3297 . 3299 [RFC6824] Ford, A., Raiciu, C., Handley, M., and O. Bonaventure, 3300 "TCP Extensions for Multipath Operation with Multiple 3301 Addresses", RFC 6824, DOI 10.17487/RFC6824, January 2013, 3302 . 3304 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 3305 "Transport Layer Security (TLS) Application-Layer Protocol 3306 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 3307 July 2014, . 3309 [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 3310 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 3311 DOI 10.17487/RFC7540, May 2015, 3312 . 3314 [SLOWLORIS] 3315 RSnake Hansen, R., "Welcome to Slowloris...", June 2009, 3316 . 3319 [SST] Ford, B., "Structured streams", ACM SIGCOMM Computer 3320 Communication Review Vol. 37, pp. 361, 3321 DOI 10.1145/1282427.1282421, October 2007. 3323 15.3. URIs 3325 [1] https://github.com/quicwg/base-drafts/wiki/QUIC-Versions 3327 Appendix A. Contributors 3329 The original authors of this specification were Ryan Hamilton, Jana 3330 Iyengar, Ian Swett, and Alyssa Wilk. 3332 The original design and rationale behind this protocol draw 3333 significantly from work by Jim Roskind [EARLY-DESIGN]. In 3334 alphabetical order, the contributors to the pre-IETF QUIC project at 3335 Google are: Britt Cyr, Jeremy Dorfman, Ryan Hamilton, Jana Iyengar, 3336 Fedor Kouranov, Charles Krasic, Jo Kulik, Adam Langley, Jim Roskind, 3337 Robbie Shade, Satyam Shekhar, Cherie Shi, Ian Swett, Raman Tenneti, 3338 Victor Vasiliev, Antonio Vicente, Patrik Westin, Alyssa Wilk, Dale 3339 Worley, Fan Yang, Dan Zhang, Daniel Ziegler. 3341 Appendix B. Acknowledgments 3343 Special thanks are due to the following for helping shape pre-IETF 3344 QUIC and its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, 3345 Alistair Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. 3347 This document has benefited immensely from various private 3348 discussions and public ones on the quic@ietf.org and proto- 3349 quic@chromium.org mailing lists. Our thanks to all. 3351 Appendix C. Change Log 3353 *RFC Editor's Note:* Please remove this section prior to 3354 publication of a final version of this document. 3356 Issue and pull request numbers are listed with a leading octothorp. 3358 C.1. Since draft-ietf-quic-transport-02 3360 o The size of the initial packet payload has a fixed minimum (#267, 3361 #472) 3363 o Define when Version Negotiation packets are ignored (#284, #294, 3364 #241, #143, #474) 3366 o The 64-bit FNV-1a algorithm is used for integrity protection of 3367 unprotected packets (#167, #480, #481, #517) 3369 o Rework initial packet types to change how the connection ID is 3370 chosen (#482, #442, #493) 3372 o No timestamps are forbidden in unprotected packets (#542, #429) 3374 o Cryptographic handshake is now on stream 0 (#456) 3376 o Remove congestion control exemption for cryptographic handshake 3377 (#248, #476) 3379 o Version 1 of QUIC uses TLS; a new version is needed to use a 3380 different handshake protocol (#516) 3382 o STREAM frames have a reduced number of offset lengths (#543, #430) 3384 o Split some frames into separate connection- and stream- level 3385 frames (#443) 3387 * WINDOW_UPDATE split into MAX_DATA and MAX_STREAM_DATA (#450) 3389 * BLOCKED split to match WINDOW_UPDATE split (#454) 3391 * Define STREAM_ID_NEEDED frame (#455) 3393 o A NEW_CONNECTION_ID frame supports connection migration without 3394 linkability (#232, #491, #496) 3396 o Transport parameters for 0-RTT are retained from a previous 3397 connection (#512) 3399 * A client in 0-RTT no longer required to reset excess streams 3400 (#425, #479) 3402 o Expanded security considerations (#440, #444, #445, #448) 3404 C.2. Since draft-ietf-quic-transport-01 3406 o Defined short and long packet headers (#40, #148, #361) 3408 o Defined a versioning scheme and stable fields (#51, #361) 3410 o Define reserved version values for "greasing" negotiation (#112, 3411 #278) 3413 o The initial packet number is randomized (#35, #283) 3415 o Narrow the packet number encoding range requirement (#67, #286, 3416 #299, #323, #356) 3418 o Defined client address validation (#52, #118, #120, #275) 3420 o Define transport parameters as a TLS extension (#49, #122) 3422 o SCUP and COPT parameters are no longer valid (#116, #117) 3424 o Transport parameters for 0-RTT are either remembered from before, 3425 or assume default values (#126) 3427 o The server chooses connection IDs in its final flight (#119, #349, 3428 #361) 3430 o The server echoes the Connection ID and packet number fields when 3431 sending a Version Negotiation packet (#133, #295, #244) 3433 o Defined a minimum packet size for the initial handshake packet 3434 from the client (#69, #136, #139, #164) 3436 o Path MTU Discovery (#64, #106) 3438 o The initial handshake packet from the client needs to fit in a 3439 single packet (#338) 3441 o Forbid acknowledgment of packets containing only ACK and PADDING 3442 (#291) 3444 o Require that frames are processed when packets are acknowledged 3445 (#381, #341) 3447 o Removed the STOP_WAITING frame (#66) 3449 o Don't require retransmission of old timestamps for lost ACK frames 3450 (#308) 3452 o Clarified that frames are not retransmitted, but the information 3453 in them can be (#157, #298) 3455 o Error handling definitions (#335) 3457 o Split error codes into four sections (#74) 3459 o Forbid the use of Public Reset where CONNECTION_CLOSE is possible 3460 (#289) 3462 o Define packet protection rules (#336) 3464 o Require that stream be entirely delivered or reset, including 3465 acknowledgment of all STREAM frames or the RST_STREAM, before it 3466 closes (#381) 3468 o Remove stream reservation from state machine (#174, #280) 3470 o Only stream 1 does not contribute to connection-level flow control 3471 (#204) 3473 o Stream 1 counts towards the maximum concurrent stream limit (#201, 3474 #282) 3476 o Remove connection-level flow control exclusion for some streams 3477 (except 1) (#246) 3479 o RST_STREAM affects connection-level flow control (#162, #163) 3481 o Flow control accounting uses the maximum data offset on each 3482 stream, rather than bytes received (#378) 3484 o Moved length-determining fields to the start of STREAM and ACK 3485 (#168, #277) 3487 o Added the ability to pad between frames (#158, #276) 3489 o Remove error code and reason phrase from GOAWAY (#352, #355) 3491 o GOAWAY includes a final stream number for both directions (#347) 3493 o Error codes for RST_STREAM and CONNECTION_CLOSE are now at a 3494 consistent offset (#249) 3496 o Defined priority as the responsibility of the application protocol 3497 (#104, #303) 3499 C.3. Since draft-ietf-quic-transport-00 3501 o Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 3503 o Defined versioning 3505 o Reworked description of packet and frame layout 3507 o Error code space is divided into regions for each component 3509 o Use big endian for all numeric values 3511 C.4. Since draft-hamilton-quic-transport-protocol-01 3513 o Adopted as base for draft-ietf-quic-tls 3515 o Updated authors/editors list 3517 o Added IANA Considerations section 3519 o Moved Contributors and Acknowledgments to appendices 3521 Authors' Addresses 3523 Jana Iyengar (editor) 3524 Google 3526 Email: jri@google.com 3528 Martin Thomson (editor) 3529 Mozilla 3531 Email: martin.thomson@gmail.com