idnits 2.17.1 draft-ietf-quic-transport-21.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 : ---------------------------------------------------------------------------- No issues found here. 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 'MUST not' in this paragraph: The server includes a connection ID of its choice in the Source Connection ID field. This value MUST not be equal to the Destination Connection ID field of the packet sent by the client. The client MUST use this connection ID in the Destination Connection ID of subsequent packets that it sends. -- The document date (July 08, 2019) is 1753 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: '0' on line 1793 == Missing Reference: 'CH' is mentioned on line 1789, but not defined == Missing Reference: 'SH' is mentioned on line 1791, but not defined == Missing Reference: 'EE' is mentioned on line 1792, but not defined == Missing Reference: 'CERT' is mentioned on line 1792, but not defined == Missing Reference: 'CV' is mentioned on line 1792, but not defined == Missing Reference: 'FIN' is mentioned on line 1792, but not defined -- Looks like a reference, but probably isn't: '1' on line 1791 -- Looks like a reference, but probably isn't: '4' on line 4619 -- Looks like a reference, but probably isn't: '16' on line 4624 == Outdated reference: A later version (-22) exists of draft-ietf-tsvwg-datagram-plpmtud-08 == Outdated reference: A later version (-34) exists of draft-ietf-quic-recovery-21 == Outdated reference: A later version (-34) exists of draft-ietf-quic-tls-21 -- Obsolete informational reference (is this intentional?): RFC 7540 (ref. 'HTTP2') (Obsoleted by RFC 9113) == Outdated reference: A later version (-13) exists of draft-ietf-quic-invariants-05 == Outdated reference: A later version (-18) exists of draft-ietf-quic-manageability-05 Summary: 0 errors (**), 0 flaws (~~), 14 warnings (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 QUIC J. Iyengar, Ed. 3 Internet-Draft Fastly 4 Intended status: Standards Track M. Thomson, Ed. 5 Expires: January 9, 2020 Mozilla 6 July 08, 2019 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-21 11 Abstract 13 This document defines the core of the QUIC transport protocol. 14 Accompanying documents describe QUIC's loss detection and congestion 15 control and the use of TLS for key negotiation. 17 Note to Readers 19 Discussion of this draft takes place on the QUIC working group 20 mailing list (quic@ietf.org), which is archived at 21 . 23 Working Group information can be found at ; source code and issues list for this draft can be found at 25 . 27 Status of This Memo 29 This Internet-Draft is submitted in full conformance with the 30 provisions of BCP 78 and BCP 79. 32 Internet-Drafts are working documents of the Internet Engineering 33 Task Force (IETF). Note that other groups may also distribute 34 working documents as Internet-Drafts. The list of current Internet- 35 Drafts is at https://datatracker.ietf.org/drafts/current/. 37 Internet-Drafts are draft documents valid for a maximum of six months 38 and may be updated, replaced, or obsoleted by other documents at any 39 time. It is inappropriate to use Internet-Drafts as reference 40 material or to cite them other than as "work in progress." 42 This Internet-Draft will expire on January 9, 2020. 44 Copyright Notice 46 Copyright (c) 2019 IETF Trust and the persons identified as the 47 document authors. All rights reserved. 49 This document is subject to BCP 78 and the IETF Trust's Legal 50 Provisions Relating to IETF Documents 51 (https://trustee.ietf.org/license-info) in effect on the date of 52 publication of this document. Please review these documents 53 carefully, as they describe your rights and restrictions with respect 54 to this document. Code Components extracted from this document must 55 include Simplified BSD License text as described in Section 4.e of 56 the Trust Legal Provisions and are provided without warranty as 57 described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 62 1.1. Document Structure . . . . . . . . . . . . . . . . . . . 6 63 1.2. Terms and Definitions . . . . . . . . . . . . . . . . . . 7 64 1.3. Notational Conventions . . . . . . . . . . . . . . . . . 8 65 2. Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 66 2.1. Stream Types and Identifiers . . . . . . . . . . . . . . 9 67 2.2. Sending and Receiving Data . . . . . . . . . . . . . . . 10 68 2.3. Stream Prioritization . . . . . . . . . . . . . . . . . . 11 69 3. Stream States . . . . . . . . . . . . . . . . . . . . . . . . 11 70 3.1. Sending Stream States . . . . . . . . . . . . . . . . . . 12 71 3.2. Receiving Stream States . . . . . . . . . . . . . . . . . 14 72 3.3. Permitted Frame Types . . . . . . . . . . . . . . . . . . 16 73 3.4. Bidirectional Stream States . . . . . . . . . . . . . . . 17 74 3.5. Solicited State Transitions . . . . . . . . . . . . . . . 18 75 4. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 19 76 4.1. Data Flow Control . . . . . . . . . . . . . . . . . . . . 20 77 4.2. Flow Credit Increments . . . . . . . . . . . . . . . . . 21 78 4.3. Handling Stream Cancellation . . . . . . . . . . . . . . 22 79 4.4. Stream Final Size . . . . . . . . . . . . . . . . . . . . 22 80 4.5. Controlling Concurrency . . . . . . . . . . . . . . . . . 23 81 5. Connections . . . . . . . . . . . . . . . . . . . . . . . . . 24 82 5.1. Connection ID . . . . . . . . . . . . . . . . . . . . . . 24 83 5.1.1. Issuing Connection IDs . . . . . . . . . . . . . . . 25 84 5.1.2. Consuming and Retiring Connection IDs . . . . . . . . 26 85 5.2. Matching Packets to Connections . . . . . . . . . . . . . 27 86 5.2.1. Client Packet Handling . . . . . . . . . . . . . . . 27 87 5.2.2. Server Packet Handling . . . . . . . . . . . . . . . 28 88 5.3. Life of a QUIC Connection . . . . . . . . . . . . . . . . 29 89 6. Version Negotiation . . . . . . . . . . . . . . . . . . . . . 29 90 6.1. Sending Version Negotiation Packets . . . . . . . . . . . 29 91 6.2. Handling Version Negotiation Packets . . . . . . . . . . 29 92 6.2.1. Version Negotiation Between Draft Versions . . . . . 30 93 6.3. Using Reserved Versions . . . . . . . . . . . . . . . . . 30 94 7. Cryptographic and Transport Handshake . . . . . . . . . . . . 31 95 7.1. Example Handshake Flows . . . . . . . . . . . . . . . . . 32 96 7.2. Negotiating Connection IDs . . . . . . . . . . . . . . . 33 97 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 35 98 7.3.1. Values of Transport Parameters for 0-RTT . . . . . . 35 99 7.3.2. New Transport Parameters . . . . . . . . . . . . . . 37 100 7.4. Cryptographic Message Buffering . . . . . . . . . . . . . 37 101 8. Address Validation . . . . . . . . . . . . . . . . . . . . . 37 102 8.1. Address Validation During Connection Establishment . . . 38 103 8.1.1. Address Validation using Retry Packets . . . . . . . 39 104 8.1.2. Address Validation for Future Connections . . . . . . 39 105 8.1.3. Address Validation Token Integrity . . . . . . . . . 41 106 8.2. Path Validation . . . . . . . . . . . . . . . . . . . . . 42 107 8.3. Initiating Path Validation . . . . . . . . . . . . . . . 43 108 8.4. Path Validation Responses . . . . . . . . . . . . . . . . 43 109 8.5. Successful Path Validation . . . . . . . . . . . . . . . 43 110 8.6. Failed Path Validation . . . . . . . . . . . . . . . . . 43 111 9. Connection Migration . . . . . . . . . . . . . . . . . . . . 44 112 9.1. Probing a New Path . . . . . . . . . . . . . . . . . . . 45 113 9.2. Initiating Connection Migration . . . . . . . . . . . . . 45 114 9.3. Responding to Connection Migration . . . . . . . . . . . 46 115 9.3.1. Peer Address Spoofing . . . . . . . . . . . . . . . . 47 116 9.3.2. On-Path Address Spoofing . . . . . . . . . . . . . . 47 117 9.3.3. Off-Path Packet Forwarding . . . . . . . . . . . . . 48 118 9.4. Loss Detection and Congestion Control . . . . . . . . . . 49 119 9.5. Privacy Implications of Connection Migration . . . . . . 50 120 9.6. Server's Preferred Address . . . . . . . . . . . . . . . 50 121 9.6.1. Communicating a Preferred Address . . . . . . . . . . 51 122 9.6.2. Responding to Connection Migration . . . . . . . . . 51 123 9.6.3. Interaction of Client Migration and Preferred Address 52 124 9.7. Use of IPv6 Flow-Label and Migration . . . . . . . . . . 52 125 10. Connection Termination . . . . . . . . . . . . . . . . . . . 53 126 10.1. Closing and Draining Connection States . . . . . . . . . 53 127 10.2. Idle Timeout . . . . . . . . . . . . . . . . . . . . . . 54 128 10.3. Immediate Close . . . . . . . . . . . . . . . . . . . . 55 129 10.4. Stateless Reset . . . . . . . . . . . . . . . . . . . . 56 130 10.4.1. Detecting a Stateless Reset . . . . . . . . . . . . 59 131 10.4.2. Calculating a Stateless Reset Token . . . . . . . . 59 132 10.4.3. Looping . . . . . . . . . . . . . . . . . . . . . . 60 133 11. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 61 134 11.1. Connection Errors . . . . . . . . . . . . . . . . . . . 61 135 11.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 62 136 12. Packets and Frames . . . . . . . . . . . . . . . . . . . . . 62 137 12.1. Protected Packets . . . . . . . . . . . . . . . . . . . 63 138 12.2. Coalescing Packets . . . . . . . . . . . . . . . . . . . 63 139 12.3. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 64 140 12.4. Frames and Frame Types . . . . . . . . . . . . . . . . . 66 141 13. Packetization and Reliability . . . . . . . . . . . . . . . . 68 142 13.1. Packet Processing and Acknowledgment . . . . . . . . . . 69 143 13.1.1. Sending ACK Frames . . . . . . . . . . . . . . . . . 69 144 13.1.2. Limiting ACK Ranges . . . . . . . . . . . . . . . . 70 145 13.1.3. ACK Frames and Packet Protection . . . . . . . . . . 70 146 13.2. Retransmission of Information . . . . . . . . . . . . . 71 147 13.3. Explicit Congestion Notification . . . . . . . . . . . . 73 148 13.3.1. ECN Counts . . . . . . . . . . . . . . . . . . . . . 73 149 13.3.2. ECN Verification . . . . . . . . . . . . . . . . . . 74 150 14. Packet Size . . . . . . . . . . . . . . . . . . . . . . . . . 75 151 14.1. Path Maximum Transmission Unit (PMTU) . . . . . . . . . 76 152 14.2. ICMP Packet Too Big Messages . . . . . . . . . . . . . . 77 153 14.3. Datagram Packetization Layer PMTU Discovery . . . . . . 78 154 14.3.1. PMTU Probes Containing Source Connection ID . . . . 78 155 15. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 79 156 16. Variable-Length Integer Encoding . . . . . . . . . . . . . . 80 157 17. Packet Formats . . . . . . . . . . . . . . . . . . . . . . . 80 158 17.1. Packet Number Encoding and Decoding . . . . . . . . . . 81 159 17.2. Long Header Packets . . . . . . . . . . . . . . . . . . 82 160 17.2.1. Version Negotiation Packet . . . . . . . . . . . . . 84 161 17.2.2. Initial Packet . . . . . . . . . . . . . . . . . . . 86 162 17.2.3. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . 88 163 17.2.4. Handshake Packet . . . . . . . . . . . . . . . . . . 89 164 17.2.5. Retry Packet . . . . . . . . . . . . . . . . . . . . 90 165 17.3. Short Header Packets . . . . . . . . . . . . . . . . . . 93 166 17.3.1. Latency Spin Bit . . . . . . . . . . . . . . . . . . 94 167 18. Transport Parameter Encoding . . . . . . . . . . . . . . . . 96 168 18.1. Transport Parameter Definitions . . . . . . . . . . . . 97 169 19. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 100 170 19.1. PADDING Frame . . . . . . . . . . . . . . . . . . . . . 100 171 19.2. PING Frame . . . . . . . . . . . . . . . . . . . . . . . 100 172 19.3. ACK Frames . . . . . . . . . . . . . . . . . . . . . . . 101 173 19.3.1. ACK Ranges . . . . . . . . . . . . . . . . . . . . . 102 174 19.3.2. ECN Counts . . . . . . . . . . . . . . . . . . . . . 104 175 19.4. RESET_STREAM Frame . . . . . . . . . . . . . . . . . . . 105 176 19.5. STOP_SENDING Frame . . . . . . . . . . . . . . . . . . . 105 177 19.6. CRYPTO Frame . . . . . . . . . . . . . . . . . . . . . . 106 178 19.7. NEW_TOKEN Frame . . . . . . . . . . . . . . . . . . . . 107 179 19.8. STREAM Frames . . . . . . . . . . . . . . . . . . . . . 107 180 19.9. MAX_DATA Frame . . . . . . . . . . . . . . . . . . . . . 109 181 19.10. MAX_STREAM_DATA Frame . . . . . . . . . . . . . . . . . 109 182 19.11. MAX_STREAMS Frames . . . . . . . . . . . . . . . . . . . 110 183 19.12. DATA_BLOCKED Frame . . . . . . . . . . . . . . . . . . . 111 184 19.13. STREAM_DATA_BLOCKED Frame . . . . . . . . . . . . . . . 112 185 19.14. STREAMS_BLOCKED Frames . . . . . . . . . . . . . . . . . 112 186 19.15. NEW_CONNECTION_ID Frame . . . . . . . . . . . . . . . . 113 187 19.16. RETIRE_CONNECTION_ID Frame . . . . . . . . . . . . . . . 115 188 19.17. PATH_CHALLENGE Frame . . . . . . . . . . . . . . . . . . 115 189 19.18. PATH_RESPONSE Frame . . . . . . . . . . . . . . . . . . 116 190 19.19. CONNECTION_CLOSE Frames . . . . . . . . . . . . . . . . 116 191 19.20. Extension Frames . . . . . . . . . . . . . . . . . . . . 117 192 20. Transport Error Codes . . . . . . . . . . . . . . . . . . . . 118 193 20.1. Application Protocol Error Codes . . . . . . . . . . . . 119 194 21. Security Considerations . . . . . . . . . . . . . . . . . . . 119 195 21.1. Handshake Denial of Service . . . . . . . . . . . . . . 119 196 21.2. Amplification Attack . . . . . . . . . . . . . . . . . . 120 197 21.3. Optimistic ACK Attack . . . . . . . . . . . . . . . . . 121 198 21.4. Slowloris Attacks . . . . . . . . . . . . . . . . . . . 121 199 21.5. Stream Fragmentation and Reassembly Attacks . . . . . . 121 200 21.6. Stream Commitment Attack . . . . . . . . . . . . . . . . 122 201 21.7. Explicit Congestion Notification Attacks . . . . . . . . 122 202 21.8. Stateless Reset Oracle . . . . . . . . . . . . . . . . . 123 203 21.9. Version Downgrade . . . . . . . . . . . . . . . . . . . 123 204 21.10. Targeted Attacks by Routing . . . . . . . . . . . . . . 123 205 22. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 124 206 22.1. QUIC Transport Parameter Registry . . . . . . . . . . . 124 207 22.2. QUIC Frame Type Registry . . . . . . . . . . . . . . . . 125 208 22.3. QUIC Transport Error Codes Registry . . . . . . . . . . 126 209 23. References . . . . . . . . . . . . . . . . . . . . . . . . . 128 210 23.1. Normative References . . . . . . . . . . . . . . . . . . 129 211 23.2. Informative References . . . . . . . . . . . . . . . . . 130 212 Appendix A. Sample Packet Number Decoding Algorithm . . . . . . 132 213 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 132 214 B.1. Since draft-ietf-quic-transport-20 . . . . . . . . . . . 133 215 B.2. Since draft-ietf-quic-transport-19 . . . . . . . . . . . 134 216 B.3. Since draft-ietf-quic-transport-18 . . . . . . . . . . . 134 217 B.4. Since draft-ietf-quic-transport-17 . . . . . . . . . . . 135 218 B.5. Since draft-ietf-quic-transport-16 . . . . . . . . . . . 135 219 B.6. Since draft-ietf-quic-transport-15 . . . . . . . . . . . 137 220 B.7. Since draft-ietf-quic-transport-14 . . . . . . . . . . . 137 221 B.8. Since draft-ietf-quic-transport-13 . . . . . . . . . . . 137 222 B.9. Since draft-ietf-quic-transport-12 . . . . . . . . . . . 138 223 B.10. Since draft-ietf-quic-transport-11 . . . . . . . . . . . 139 224 B.11. Since draft-ietf-quic-transport-10 . . . . . . . . . . . 139 225 B.12. Since draft-ietf-quic-transport-09 . . . . . . . . . . . 140 226 B.13. Since draft-ietf-quic-transport-08 . . . . . . . . . . . 140 227 B.14. Since draft-ietf-quic-transport-07 . . . . . . . . . . . 141 228 B.15. Since draft-ietf-quic-transport-06 . . . . . . . . . . . 142 229 B.16. Since draft-ietf-quic-transport-05 . . . . . . . . . . . 142 230 B.17. Since draft-ietf-quic-transport-04 . . . . . . . . . . . 142 231 B.18. Since draft-ietf-quic-transport-03 . . . . . . . . . . . 143 232 B.19. Since draft-ietf-quic-transport-02 . . . . . . . . . . . 143 233 B.20. Since draft-ietf-quic-transport-01 . . . . . . . . . . . 144 234 B.21. Since draft-ietf-quic-transport-00 . . . . . . . . . . . 146 235 B.22. Since draft-hamilton-quic-transport-protocol-01 . . . . . 146 236 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 147 237 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 147 238 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 147 240 1. Introduction 242 QUIC is a multiplexed and secure general-purpose transport protocol 243 that provides: 245 o Stream multiplexing 247 o Stream and connection-level flow control 249 o Low-latency connection establishment 251 o Connection migration and resilience to NAT rebinding 253 o Authenticated and encrypted header and payload 255 QUIC uses UDP as a substrate to avoid requiring changes to legacy 256 client operating systems and middleboxes. QUIC authenticates all of 257 its headers and encrypts most of the data it exchanges, including its 258 signaling, to avoid incurring a dependency on middleboxes. 260 1.1. Document Structure 262 This document describes the core QUIC protocol and is structured as 263 follows. 265 o Streams are the basic service abstraction that QUIC provides. 267 * Section 2 describes core concepts related to streams, 269 * Section 3 provides a reference model for stream states, and 271 * Section 4 outlines the operation of flow control. 273 o Connections are the context in which QUIC endpoints communicate. 275 * Section 5 describes core concepts related to connections, 277 * Section 6 describes version negotiation, 279 * Section 7 details the process for establishing connections, 281 * Section 8 specifies critical denial of service mitigation 282 mechanisms, 284 * Section 9 describes how endpoints migrate a connection to a new 285 network path, 287 * Section 10 lists the options for terminating an open 288 connection, and 290 * Section 11 provides general guidance for error handling. 292 o Packets and frames are the basic unit used by QUIC to communicate. 294 * Section 12 describes concepts related to packets and frames, 296 * Section 13 defines models for the transmission, retransmission, 297 and acknowledgement of data, and 299 * Section 14 specifies rules for managing the size of packets. 301 o Finally, encoding details of QUIC protocol elements are described 302 in: 304 * Section 15 (Versions), 306 * Section 16 (Integer Encoding), 308 * Section 17 (Packet Headers), 310 * Section 18 (Transport Parameters), 312 * Section 19 (Frames), and 314 * Section 20 (Errors). 316 Accompanying documents describe QUIC's loss detection and congestion 317 control [QUIC-RECOVERY], and the use of TLS for key negotiation 318 [QUIC-TLS]. 320 This document defines QUIC version 1, which conforms to the protocol 321 invariants in [QUIC-INVARIANTS]. 323 1.2. Terms and Definitions 325 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 326 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 327 "OPTIONAL" in this document are to be interpreted as described in BCP 328 14 [RFC2119] [RFC8174] when, and only when, they appear in all 329 capitals, as shown here. 331 Commonly used terms in the document are described below. 333 QUIC: The transport protocol described by this document. QUIC is a 334 name, not an acronym. 336 QUIC packet: A complete processable unit of QUIC that can be 337 encapsulated in a UDP datagram. Multiple QUIC packets can be 338 encapsulated in a single UDP datagram. 340 Endpoint: An entity that can participate in a QUIC connection by 341 generating, receiving, and processing QUIC packets. There are 342 only two types of endpoint in QUIC: client and server. 344 Client: The endpoint initiating a QUIC connection. 346 Server: The endpoint accepting incoming QUIC connections. 348 Connection ID: An opaque identifier that is used to identify a QUIC 349 connection at an endpoint. Each endpoint sets a value for its 350 peer to include in packets sent towards the endpoint. 352 Stream: A unidirectional or bidirectional channel of ordered bytes 353 within a QUIC connection. A QUIC connection can carry multiple 354 simultaneous streams. 356 Application: An entity that uses QUIC to send and receive data. 358 1.3. Notational Conventions 360 Packet and frame diagrams in this document use the format described 361 in Section 3.1 of [RFC2360], with the following additional 362 conventions: 364 [x]: Indicates that x is optional 366 x (A): Indicates that x is A bits long 368 x (A/B/C) ...: Indicates that x is one of A, B, or C bits long 370 x (i) ...: Indicates that x uses the variable-length encoding in 371 Section 16 373 x (*) ...: Indicates that x is variable-length 375 2. Streams 377 Streams in QUIC provide a lightweight, ordered byte-stream 378 abstraction to an application. Streams can be unidirectional or 379 bidirecational. An alternative view of QUIC unidirectional streams 380 is a "message" abstraction of practically unlimited length. 382 Streams can be created by sending data. Other processes associated 383 with stream management - ending, cancelling, and managing flow 384 control - are all designed to impose minimal overheads. For 385 instance, a single STREAM frame (Section 19.8) can open, carry data 386 for, and close a stream. Streams can also be long-lived and can last 387 the entire duration of a connection. 389 Streams can be created by either endpoint, can concurrently send data 390 interleaved with other streams, and can be cancelled. QUIC does not 391 provide any means of ensuring ordering between bytes on different 392 streams. 394 QUIC allows for an arbitrary number of streams to operate 395 concurrently and for an arbitrary amount of data to be sent on any 396 stream, subject to flow control constraints (see Section 4) and 397 stream limits. 399 2.1. Stream Types and Identifiers 401 Streams can be unidirectional or bidirectional. Unidirectional 402 streams carry data in one direction: from the initiator of the stream 403 to its peer. Bidirectional streams allow for data to be sent in both 404 directions. 406 Streams are identified within a connection by a numeric value, 407 referred to as the stream ID. A stream ID is a 62-bit integer (0 to 408 2^62-1) that is unique for all streams on a connection. Stream IDs 409 are encoded as variable-length integers (see Section 16). A QUIC 410 endpoint MUST NOT reuse a stream ID within a connection. 412 The least significant bit (0x1) of the stream ID identifies the 413 initiator of the stream. Client-initiated streams have even-numbered 414 stream IDs (with the bit set to 0), and server-initiated streams have 415 odd-numbered stream IDs (with the bit set to 1). 417 The second least significant bit (0x2) of the stream ID distinguishes 418 between bidirectional streams (with the bit set to 0) and 419 unidirectional streams (with the bit set to 1). 421 The least significant two bits from a stream ID therefore identify a 422 stream as one of four types, as summarized in Table 1. 424 +------+----------------------------------+ 425 | Bits | Stream Type | 426 +------+----------------------------------+ 427 | 0x0 | Client-Initiated, Bidirectional | 428 | | | 429 | 0x1 | Server-Initiated, Bidirectional | 430 | | | 431 | 0x2 | Client-Initiated, Unidirectional | 432 | | | 433 | 0x3 | Server-Initiated, Unidirectional | 434 +------+----------------------------------+ 436 Table 1: Stream ID Types 438 Within each type, streams are created with numerically increasing 439 stream IDs. A stream ID that is used out of order results in all 440 streams of that type with lower-numbered stream IDs also being 441 opened. 443 The first bidirectional stream opened by the client has a stream ID 444 of 0. 446 2.2. Sending and Receiving Data 448 STREAM frames (Section 19.8) encapsulate data sent by an application. 449 An endpoint uses the Stream ID and Offset fields in STREAM frames to 450 place data in order. 452 Endpoints MUST be able to deliver stream data to an application as an 453 ordered byte-stream. Delivering an ordered byte-stream requires that 454 an endpoint buffer any data that is received out of order, up to the 455 advertised flow control limit. 457 QUIC makes no specific allowances for delivery of stream data out of 458 order. However, implementations MAY choose to offer the ability to 459 deliver data out of order to a receiving application. 461 An endpoint could receive data for a stream at the same stream offset 462 multiple times. Data that has already been received can be 463 discarded. The data at a given offset MUST NOT change if it is sent 464 multiple times; an endpoint MAY treat receipt of different data at 465 the same offset within a stream as a connection error of type 466 PROTOCOL_VIOLATION. 468 Streams are an ordered byte-stream abstraction with no other 469 structure visible to QUIC. STREAM frame boundaries are not expected 470 to be preserved when data is transmitted, retransmitted after packet 471 loss, or delivered to the application at a receiver. 473 An endpoint MUST NOT send data on any stream without ensuring that it 474 is within the flow control limits set by its peer. Flow control is 475 described in detail in Section 4. 477 2.3. Stream Prioritization 479 Stream multiplexing can have a significant effect on application 480 performance if resources allocated to streams are correctly 481 prioritized. 483 QUIC does not provide a mechanism for exchanging prioritization 484 information. Instead, it relies on receiving priority information 485 from the application that uses QUIC. 487 A QUIC implementation SHOULD provide ways in which an application can 488 indicate the relative priority of streams. When deciding which 489 streams to dedicate resources to, the implementation SHOULD use the 490 information provided by the application. 492 3. Stream States 494 This section describes streams in terms of their send or receive 495 components. Two state machines are described: one for the streams on 496 which an endpoint transmits data (Section 3.1), and another for 497 streams on which an endpoint receives data (Section 3.2). 499 Unidirectional streams use the applicable state machine directly. 500 Bidirectional streams use both state machines. For the most part, 501 the use of these state machines is the same whether the stream is 502 unidirectional or bidirectional. The conditions for opening a stream 503 are slightly more complex for a bidirectional stream because the 504 opening of either send or receive sides causes the stream to open in 505 both directions. 507 An endpoint MUST open streams of the same type in increasing order of 508 stream ID. 510 Note: These states are largely informative. This document uses 511 stream states to describe rules for when and how different types 512 of frames can be sent and the reactions that are expected when 513 different types of frames are received. Though these state 514 machines are intended to be useful in implementing QUIC, these 515 states aren't intended to constrain implementations. An 516 implementation can define a different state machine as long as its 517 behavior is consistent with an implementation that implements 518 these states. 520 3.1. Sending Stream States 522 Figure 1 shows the states for the part of a stream that sends data to 523 a peer. 525 o 526 | Create Stream (Sending) 527 | Peer Creates Bidirectional Stream 528 v 529 +-------+ 530 | Ready | Send RESET_STREAM 531 | |-----------------------. 532 +-------+ | 533 | | 534 | Send STREAM / | 535 | STREAM_DATA_BLOCKED | 536 | | 537 | Peer Creates | 538 | Bidirectional Stream | 539 v | 540 +-------+ | 541 | Send | Send RESET_STREAM | 542 | |---------------------->| 543 +-------+ | 544 | | 545 | Send STREAM + FIN | 546 v v 547 +-------+ +-------+ 548 | Data | Send RESET_STREAM | Reset | 549 | Sent |------------------>| Sent | 550 +-------+ +-------+ 551 | | 552 | Recv All ACKs | Recv ACK 553 v v 554 +-------+ +-------+ 555 | Data | | Reset | 556 | Recvd | | Recvd | 557 +-------+ +-------+ 559 Figure 1: States for Sending Parts of Streams 561 The sending part of stream that the endpoint initiates (types 0 and 2 562 for clients, 1 and 3 for servers) is opened by the application. The 563 "Ready" state represents a newly created stream that is able to 564 accept data from the application. Stream data might be buffered in 565 this state in preparation for sending. 567 Sending the first STREAM or STREAM_DATA_BLOCKED frame causes a 568 sending part of a stream to enter the "Send" state. An 569 implementation might choose to defer allocating a stream ID to a 570 stream until it sends the first STREAM frame and enters this state, 571 which can allow for better stream prioritization. 573 The sending part of a bidirectional stream initiated by a peer (type 574 0 for a server, type 1 for a client) enters the "Ready" state then 575 immediately transitions to the "Send" state if the receiving part 576 enters the "Recv" state (Section 3.2). 578 In the "Send" state, an endpoint transmits - and retransmits as 579 necessary - stream data in STREAM frames. The endpoint respects the 580 flow control limits set by its peer, and continues to accept and 581 process MAX_STREAM_DATA frames. An endpoint in the "Send" state 582 generates STREAM_DATA_BLOCKED frames if it is blocked from sending by 583 stream or connection flow control limits Section 4.1. 585 After the application indicates that all stream data has been sent 586 and a STREAM frame containing the FIN bit is sent, the sending part 587 of the stream enters the "Data Sent" state. From this state, the 588 endpoint only retransmits stream data as necessary. The endpoint 589 does not need to check flow control limits or send 590 STREAM_DATA_BLOCKED frames for a stream in this state. 591 MAX_STREAM_DATA frames might be received until the peer receives the 592 final stream offset. The endpoint can safely ignore any 593 MAX_STREAM_DATA frames it receives from its peer for a stream in this 594 state. 596 Once all stream data has been successfully acknowledged, the sending 597 part of the stream enters the "Data Recvd" state, which is a terminal 598 state. 600 From any of the "Ready", "Send", or "Data Sent" states, an 601 application can signal that it wishes to abandon transmission of 602 stream data. Alternatively, an endpoint might receive a STOP_SENDING 603 frame from its peer. In either case, the endpoint sends a 604 RESET_STREAM frame, which causes the stream to enter the "Reset Sent" 605 state. 607 An endpoint MAY send a RESET_STREAM as the first frame that mentions 608 a stream; this causes the sending part of that stream to open and 609 then immediately transition to the "Reset Sent" state. 611 Once a packet containing a RESET_STREAM has been acknowledged, the 612 sending part of the stream enters the "Reset Recvd" state, which is a 613 terminal state. 615 3.2. Receiving Stream States 617 Figure 2 shows the states for the part of a stream that receives data 618 from a peer. The states for a receiving part of a stream mirror only 619 some of the states of the sending part of the stream at the peer. 620 The receiving part of a stream does not track states on the sending 621 part that cannot be observed, such as the "Ready" state. Instead, 622 the receiving part of a stream tracks the delivery of data to the 623 application, some of which cannot be observed by the sender. 625 o 626 | Recv STREAM / STREAM_DATA_BLOCKED / RESET_STREAM 627 | Create Bidirectional Stream (Sending) 628 | Recv MAX_STREAM_DATA / STOP_SENDING (Bidirectional) 629 | Create Higher-Numbered Stream 630 v 631 +-------+ 632 | Recv | Recv RESET_STREAM 633 | |-----------------------. 634 +-------+ | 635 | | 636 | Recv STREAM + FIN | 637 v | 638 +-------+ | 639 | Size | Recv RESET_STREAM | 640 | Known |---------------------->| 641 +-------+ | 642 | | 643 | Recv All Data | 644 v v 645 +-------+ Recv RESET_STREAM +-------+ 646 | Data |--- (optional) --->| Reset | 647 | Recvd | Recv All Data | Recvd | 648 +-------+<-- (optional) ----+-------+ 649 | | 650 | App Read All Data | App Read RST 651 v v 652 +-------+ +-------+ 653 | Data | | Reset | 654 | Read | | Read | 655 +-------+ +-------+ 657 Figure 2: States for Receiving Parts of Streams 659 The receiving part of a stream initiated by a peer (types 1 and 3 for 660 a client, or 0 and 2 for a server) is created when the first STREAM, 661 STREAM_DATA_BLOCKED, or RESET_STREAM is received for that stream. 662 For bidirectional streams initiated by a peer, receipt of a 663 MAX_STREAM_DATA or STOP_SENDING frame for the sending part of the 664 stream also creates the receiving part. The initial state for the 665 receiving part of stream is "Recv". 667 The receiving part of a stream enters the "Recv" state when the 668 sending part of a bidirectional stream initiated by the endpoint 669 (type 0 for a client, type 1 for a server) enters the "Ready" state. 671 An endpoint opens a bidirectional stream when a MAX_STREAM_DATA or 672 STOP_SENDING frame is received from the peer for that stream. 673 Receiving a MAX_STREAM_DATA frame for an unopened stream indicates 674 that the remote peer has opened the stream and is providing flow 675 control credit. Receiving a STOP_SENDING frame for an unopened 676 stream indicates that the remote peer no longer wishes to receive 677 data on this stream. Either frame might arrive before a STREAM or 678 STREAM_DATA_BLOCKED frame if packets are lost or reordered. 680 Before a stream is created, all streams of the same type with lower- 681 numbered stream IDs MUST be created. This ensures that the creation 682 order for streams is consistent on both endpoints. 684 In the "Recv" state, the endpoint receives STREAM and 685 STREAM_DATA_BLOCKED frames. Incoming data is buffered and can be 686 reassembled into the correct order for delivery to the application. 687 As data is consumed by the application and buffer space becomes 688 available, the endpoint sends MAX_STREAM_DATA frames to allow the 689 peer to send more data. 691 When a STREAM frame with a FIN bit is received, the final size of the 692 stream is known (see Section 4.4). The receiving part of the stream 693 then enters the "Size Known" state. In this state, the endpoint no 694 longer needs to send MAX_STREAM_DATA frames, it only receives any 695 retransmissions of stream data. 697 Once all data for the stream has been received, the receiving part 698 enters the "Data Recvd" state. This might happen as a result of 699 receiving the same STREAM frame that causes the transition to "Size 700 Known". After all data has been received, any STREAM or 701 STREAM_DATA_BLOCKED frames for the stream can be discarded. 703 The "Data Recvd" state persists until stream data has been delivered 704 to the application. Once stream data has been delivered, the stream 705 enters the "Data Read" state, which is a terminal state. 707 Receiving a RESET_STREAM frame in the "Recv" or "Size Known" states 708 causes the stream to enter the "Reset Recvd" state. This might cause 709 the delivery of stream data to the application to be interrupted. 711 It is possible that all stream data is received when a RESET_STREAM 712 is received (that is, from the "Data Recvd" state). Similarly, it is 713 possible for remaining stream data to arrive after receiving a 714 RESET_STREAM frame (the "Reset Recvd" state). An implementation is 715 free to manage this situation as it chooses. 717 Sending RESET_STREAM means that an endpoint cannot guarantee delivery 718 of stream data; however there is no requirement that stream data not 719 be delivered if a RESET_STREAM is received. An implementation MAY 720 interrupt delivery of stream data, discard any data that was not 721 consumed, and signal the receipt of the RESET_STREAM. A RESET_STREAM 722 signal might be suppressed or withheld if stream data is completely 723 received and is buffered to be read by the application. If the 724 RESET_STREAM is suppressed, the receiving part of the stream remains 725 in "Data Recvd". 727 Once the application receives the signal indicating that the stream 728 was reset, the receiving part of the stream transitions to the "Reset 729 Read" state, which is a terminal state. 731 3.3. Permitted Frame Types 733 The sender of a stream sends just three frame types that affect the 734 state of a stream at either sender or receiver: STREAM 735 (Section 19.8), STREAM_DATA_BLOCKED (Section 19.13), and RESET_STREAM 736 (Section 19.4). 738 A sender MUST NOT send any of these frames from a terminal state 739 ("Data Recvd" or "Reset Recvd"). A sender MUST NOT send STREAM or 740 STREAM_DATA_BLOCKED after sending a RESET_STREAM; that is, in the 741 terminal states and in the "Reset Sent" state. A receiver could 742 receive any of these three frames in any state, due to the 743 possibility of delayed delivery of packets carrying them. 745 The receiver of a stream sends MAX_STREAM_DATA (Section 19.10) and 746 STOP_SENDING frames (Section 19.5). 748 The receiver only sends MAX_STREAM_DATA in the "Recv" state. A 749 receiver can send STOP_SENDING in any state where it has not received 750 a RESET_STREAM frame; that is states other than "Reset Recvd" or 751 "Reset Read". However there is little value in sending a 752 STOP_SENDING frame in the "Data Recvd" state, since all stream data 753 has been received. A sender could receive either of these two frames 754 in any state as a result of delayed delivery of packets. 756 3.4. Bidirectional Stream States 758 A bidirectional stream is composed of sending and receiving parts. 759 Implementations may represent states of the bidirectional stream as 760 composites of sending and receiving stream states. The simplest 761 model presents the stream as "open" when either sending or receiving 762 parts are in a non-terminal state and "closed" when both sending and 763 receiving streams are in terminal states. 765 Table 2 shows a more complex mapping of bidirectional stream states 766 that loosely correspond to the stream states in HTTP/2 [HTTP2]. This 767 shows that multiple states on sending or receiving parts of streams 768 are mapped to the same composite state. Note that this is just one 769 possibility for such a mapping; this mapping requires that data is 770 acknowledged before the transition to a "closed" or "half-closed" 771 state. 773 +-----------------------+---------------------+---------------------+ 774 | Sending Part | Receiving Part | Composite State | 775 +-----------------------+---------------------+---------------------+ 776 | No Stream/Ready | No Stream/Recv *1 | idle | 777 | | | | 778 | Ready/Send/Data Sent | Recv/Size Known | open | 779 | | | | 780 | Ready/Send/Data Sent | Data Recvd/Data | half-closed | 781 | | Read | (remote) | 782 | | | | 783 | Ready/Send/Data Sent | Reset Recvd/Reset | half-closed | 784 | | Read | (remote) | 785 | | | | 786 | Data Recvd | Recv/Size Known | half-closed (local) | 787 | | | | 788 | Reset Sent/Reset | Recv/Size Known | half-closed (local) | 789 | Recvd | | | 790 | | | | 791 | Reset Sent/Reset | Data Recvd/Data | closed | 792 | Recvd | Read | | 793 | | | | 794 | Reset Sent/Reset | Reset Recvd/Reset | closed | 795 | Recvd | Read | | 796 | | | | 797 | Data Recvd | Data Recvd/Data | closed | 798 | | Read | | 799 | | | | 800 | Data Recvd | Reset Recvd/Reset | closed | 801 | | Read | | 802 +-----------------------+---------------------+---------------------+ 804 Table 2: Possible Mapping of Stream States to HTTP/2 806 Note (*1): A stream is considered "idle" if it has not yet been 807 created, or if the receiving part of the stream is in the "Recv" 808 state without yet having received any frames. 810 3.5. Solicited State Transitions 812 If an endpoint is no longer interested in the data it is receiving on 813 a stream, it MAY send a STOP_SENDING frame identifying that stream to 814 prompt closure of the stream in the opposite direction. This 815 typically indicates that the receiving application is no longer 816 reading data it receives from the stream, but it is not a guarantee 817 that incoming data will be ignored. 819 STREAM frames received after sending STOP_SENDING are still counted 820 toward connection and stream flow control, even though these frames 821 can be discarded upon receipt. 823 A STOP_SENDING frame requests that the receiving endpoint send a 824 RESET_STREAM frame. An endpoint that receives a STOP_SENDING frame 825 MUST send a RESET_STREAM frame if the stream is in the Ready or Send 826 state. If the stream is in the Data Sent state and any outstanding 827 data is declared lost, an endpoint SHOULD send a RESET_STREAM frame 828 in lieu of a retransmission. 830 An endpoint SHOULD copy the error code from the STOP_SENDING frame to 831 the RESET_STREAM frame it sends, but MAY use any application error 832 code. The endpoint that sends a STOP_SENDING frame MAY ignore the 833 error code carried in any RESET_STREAM frame it receives. 835 If the STOP_SENDING frame is received on a stream that is already in 836 the "Data Sent" state, an endpoint that wishes to cease 837 retransmission of previously-sent STREAM frames on that stream MUST 838 first send a RESET_STREAM frame. 840 STOP_SENDING SHOULD only be sent for a stream that has not been reset 841 by the peer. STOP_SENDING is most useful for streams in the "Recv" 842 or "Size Known" states. 844 An endpoint is expected to send another STOP_SENDING frame if a 845 packet containing a previous STOP_SENDING is lost. However, once 846 either all stream data or a RESET_STREAM frame has been received for 847 the stream - that is, the stream is in any state other than "Recv" or 848 "Size Known" - sending a STOP_SENDING frame is unnecessary. 850 An endpoint that wishes to terminate both directions of a 851 bidirectional stream can terminate one direction by sending a 852 RESET_STREAM, and it can encourage prompt termination in the opposite 853 direction by sending a STOP_SENDING frame. 855 4. Flow Control 857 It is necessary to limit the amount of data that a receiver could 858 buffer, to prevent a fast sender from overwhelming a slow receiver, 859 or to prevent a malicious sender from consuming a large amount of 860 memory at a receiver. To enable a receiver to limit memory 861 commitment to a connection and to apply back pressure on the sender, 862 streams are flow controlled both individually and as an aggregate. A 863 QUIC receiver controls the maximum amount of data the sender can send 864 on a stream at any time, as described in Section 4.1 and Section 4.2 865 Similarly, to limit concurrency within a connection, a QUIC endpoint 866 controls the maximum cumulative number of streams that its peer can 867 initiate, as described in Section 4.5. 869 Data sent in CRYPTO frames is not flow controlled in the same way as 870 stream data. QUIC relies on the cryptographic protocol 871 implementation to avoid excessive buffering of data; see [QUIC-TLS]. 872 The implementation SHOULD provide an interface to QUIC to tell it 873 about its buffering limits so that there is not excessive buffering 874 at multiple layers. 876 4.1. Data Flow Control 878 QUIC employs a credit-based flow-control scheme similar to that in 879 HTTP/2 [HTTP2], where a receiver advertises the number of bytes it is 880 prepared to receive on a given stream and for the entire connection. 881 This leads to two levels of data flow control in QUIC: 883 o Stream flow control, which prevents a single stream from consuming 884 the entire receive buffer for a connection by limiting the amount 885 of data that can be sent on any stream. 887 o Connection flow control, which prevents senders from exceeding a 888 receiver's buffer capacity for the connection, by limiting the 889 total bytes of stream data sent in STREAM frames on all streams. 891 A receiver sets initial credits for all streams by sending transport 892 parameters during the handshake (Section 7.3). A receiver sends 893 MAX_STREAM_DATA (Section 19.10) or MAX_DATA (Section 19.9) frames to 894 the sender to advertise additional credit. 896 A receiver advertises credit for a stream by sending a 897 MAX_STREAM_DATA frame with the Stream ID field set appropriately. A 898 MAX_STREAM_DATA frame indicates the maximum absolute byte offset of a 899 stream. A receiver could use the current offset of data consumed to 900 determine the flow control offset to be advertised. A receiver MAY 901 send MAX_STREAM_DATA frames in multiple packets in order to make sure 902 that the sender receives an update before running out of flow control 903 credit, even if one of the packets is lost. 905 A receiver advertises credit for a connection by sending a MAX_DATA 906 frame, which indicates the maximum of the sum of the absolute byte 907 offsets of all streams. A receiver maintains a cumulative sum of 908 bytes received on all streams, which is used to check for flow 909 control violations. A receiver might use a sum of bytes consumed on 910 all streams to determine the maximum data limit to be advertised. 912 A receiver can advertise a larger offset by sending MAX_STREAM_DATA 913 or MAX_DATA frames. Once a receiver advertises an offset, it MAY 914 advertise a smaller offset, but this has no effect. 916 A receiver MUST close the connection with a FLOW_CONTROL_ERROR error 917 (Section 11) if the sender violates the advertised connection or 918 stream data limits. 920 A sender MUST ignore any MAX_STREAM_DATA or MAX_DATA frames that do 921 not increase flow control limits. 923 If a sender runs out of flow control credit, it will be unable to 924 send new data and is considered blocked. A sender SHOULD send a 925 STREAM_DATA_BLOCKED or DATA_BLOCKED frame to indicate it has data to 926 write but is blocked by flow control limits. These frames are 927 expected to be sent infrequently in common cases, but they are 928 considered useful for debugging and monitoring purposes. 930 A sender SHOULD NOT send multiple STREAM_DATA_BLOCKED or DATA_BLOCKED 931 frames for the same data limit, unless the original frame is 932 determined to be lost. Another STREAM_DATA_BLOCKED or DATA_BLOCKED 933 frame can be sent after the data limit is increased. 935 4.2. Flow Credit Increments 937 This document leaves when and how many bytes to advertise in a 938 MAX_STREAM_DATA or MAX_DATA frame to implementations, but offers a 939 few considerations. These frames contribute to connection overhead. 940 Therefore frequently sending frames with small changes is 941 undesirable. At the same time, larger increments to limits are 942 necessary to avoid blocking if updates are less frequent, requiring 943 larger resource commitments at the receiver. Thus there is a trade- 944 off between resource commitment and overhead when determining how 945 large a limit is advertised. 947 A receiver can use an autotuning mechanism to tune the frequency and 948 amount of advertised additional credit based on a round-trip time 949 estimate and the rate at which the receiving application consumes 950 data, similar to common TCP implementations. As an optimization, 951 sending frames related to flow control only when there are other 952 frames to send or when a peer is blocked ensures that flow control 953 doesn't cause extra packets to be sent. 955 If a sender runs out of flow control credit, it will be unable to 956 send new data and is considered blocked. It is generally considered 957 best to not let the sender become blocked. To avoid blocking a 958 sender, and to reasonably account for the possibility of loss, a 959 receiver should send a MAX_DATA or MAX_STREAM_DATA frame at least two 960 round trips before it expects the sender to get blocked. 962 A receiver MUST NOT wait for a STREAM_DATA_BLOCKED or DATA_BLOCKED 963 frame before sending MAX_STREAM_DATA or MAX_DATA, since doing so will 964 mean that a sender will be blocked for at least an entire round trip, 965 and potentially for longer if the peer chooses to not send 966 STREAM_DATA_BLOCKED or DATA_BLOCKED frames. 968 4.3. Handling Stream Cancellation 970 Endpoints need to eventually agree on the amount of flow control 971 credit that has been consumed, to avoid either exceeding flow control 972 limits or deadlocking. 974 On receipt of a RESET_STREAM frame, an endpoint will tear down state 975 for the matching stream and ignore further data arriving on that 976 stream. Without the offset included in RESET_STREAM, the two 977 endpoints could disagree on the number of bytes that count towards 978 connection flow control. 980 To remedy this issue, a RESET_STREAM frame (Section 19.4) includes 981 the final size of data sent on the stream. On receiving a 982 RESET_STREAM frame, a receiver definitively knows how many bytes were 983 sent on that stream before the RESET_STREAM frame, and the receiver 984 MUST use the final size of the stream to account for all bytes sent 985 on the stream in its connection level flow controller. 987 RESET_STREAM terminates one direction of a stream abruptly. For a 988 bidirectional stream, RESET_STREAM has no effect on data flow in the 989 opposite direction. Both endpoints MUST maintain flow control state 990 for the stream in the unterminated direction until that direction 991 enters a terminal state, or until one of the endpoints sends 992 CONNECTION_CLOSE. 994 4.4. Stream Final Size 996 The final size is the amount of flow control credit that is consumed 997 by a stream. Assuming that every contiguous byte on the stream was 998 sent once, the final size is the number of bytes sent. More 999 generally, this is one higher than the offset of the byte with the 1000 largest offset sent on the stream, or zero if no bytes were sent. 1002 For a stream that is reset, the final size is carried explicitly in a 1003 RESET_STREAM frame. Otherwise, the final size is the offset plus the 1004 length of a STREAM frame marked with a FIN flag, or 0 in the case of 1005 incoming unidirectional streams. 1007 An endpoint will know the final size for a stream when the receiving 1008 part of the stream enters the "Size Known" or "Reset Recvd" state 1009 (Section 3). 1011 An endpoint MUST NOT send data on a stream at or beyond the final 1012 size. 1014 Once a final size for a stream is known, it cannot change. If a 1015 RESET_STREAM or STREAM frame is received indicating a change in the 1016 final size for the stream, an endpoint SHOULD respond with a 1017 FINAL_SIZE_ERROR error (see Section 11). A receiver SHOULD treat 1018 receipt of data at or beyond the final size as a FINAL_SIZE_ERROR 1019 error, even after a stream is closed. Generating these errors is not 1020 mandatory, but only because requiring that an endpoint generate these 1021 errors also means that the endpoint needs to maintain the final size 1022 state for closed streams, which could mean a significant state 1023 commitment. 1025 4.5. Controlling Concurrency 1027 An endpoint limits the cumulative number of incoming streams a peer 1028 can open. Only streams with a stream ID less than (max_stream * 4 + 1029 initial_stream_id_for_type) can be opened (see Table 5). Initial 1030 limits are set in the transport parameters (see Section 18.1) and 1031 subsequently limits are advertised using MAX_STREAMS frames 1032 (Section 19.11). Separate limits apply to unidirectional and 1033 bidirectional streams. 1035 If a max_streams transport parameter or MAX_STREAMS frame is received 1036 with a value greater than 2^60, this would allow a maximum stream ID 1037 that cannot be expressed as a variable-length integer (see 1038 Section 16). If either is received, the connection MUST be closed 1039 immediately with a connection error of type STREAM_LIMIT_ERROR (see 1040 Section 10.3). 1042 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 1043 that receives a frame with a stream ID exceeding the limit it has 1044 sent MUST treat this as a connection error of type STREAM_LIMIT_ERROR 1045 (Section 11). 1047 Once a receiver advertises a stream limit using the MAX_STREAMS 1048 frame, advertising a smaller limit has no effect. A receiver MUST 1049 ignore any MAX_STREAMS frame that does not increase the stream limit. 1051 As with stream and connection flow control, this document leaves when 1052 and how many streams to advertise to a peer via MAX_STREAMS to 1053 implementations. Implementations might choose to increase limits as 1054 streams close to keep the number of streams available to peers 1055 roughly consistent. 1057 An endpoint that is unable to open a new stream due to the peer's 1058 limits SHOULD send a STREAMS_BLOCKED frame (Section 19.14). This 1059 signal is considered useful for debugging. An endpoint MUST NOT wait 1060 to receive this signal before advertising additional credit, since 1061 doing so will mean that the peer will be blocked for at least an 1062 entire round trip, and potentially for longer if the peer chooses to 1063 not send STREAMS_BLOCKED frames. 1065 5. Connections 1067 QUIC's connection establishment combines version negotiation with the 1068 cryptographic and transport handshakes to reduce connection 1069 establishment latency, as described in Section 7. Once established, 1070 a connection may migrate to a different IP or port at either endpoint 1071 as described in Section 9. Finally, a connection may be terminated 1072 by either endpoint, as described in Section 10. 1074 5.1. Connection ID 1076 Each connection possesses a set of connection identifiers, or 1077 connection IDs, each of which can identify the connection. 1078 Connection IDs are independently selected by endpoints; each endpoint 1079 selects the connection IDs that its peer uses. 1081 The primary function of a connection ID is to ensure that changes in 1082 addressing at lower protocol layers (UDP, IP) don't cause packets for 1083 a QUIC connection to be delivered to the wrong endpoint. Each 1084 endpoint selects connection IDs using an implementation-specific (and 1085 perhaps deployment-specific) method which will allow packets with 1086 that connection ID to be routed back to the endpoint and identified 1087 by the endpoint upon receipt. 1089 Connection IDs MUST NOT contain any information that can be used by 1090 an external observer to correlate them with other connection IDs for 1091 the same connection. As a trivial example, this means the same 1092 connection ID MUST NOT be issued more than once on the same 1093 connection. 1095 Packets with long headers include Source Connection ID and 1096 Destination Connection ID fields. These fields are used to set the 1097 connection IDs for new connections; see Section 7.2 for details. 1099 Packets with short headers (Section 17.3) only include the 1100 Destination Connection ID and omit the explicit length. The length 1101 of the Destination Connection ID field is expected to be known to 1102 endpoints. Endpoints using a load balancer that routes based on 1103 connection ID could agree with the load balancer on a fixed length 1104 for connection IDs, or agree on an encoding scheme. A fixed portion 1105 could encode an explicit length, which allows the entire connection 1106 ID to vary in length and still be used by the load balancer. 1108 A Version Negotiation (Section 17.2.1) packet echoes the connection 1109 IDs selected by the client, both to ensure correct routing toward the 1110 client and to allow the client to validate that the packet is in 1111 response to an Initial packet. 1113 A zero-length connection ID MAY be used when the connection ID is not 1114 needed for routing and the address/port tuple of packets is 1115 sufficient to identify a connection. An endpoint whose peer has 1116 selected a zero-length connection ID MUST continue to use a zero- 1117 length connection ID for the lifetime of the connection and MUST NOT 1118 send packets from any other local address. 1120 When an endpoint has requested a non-zero-length connection ID, it 1121 needs to ensure that the peer has a supply of connection IDs from 1122 which to choose for packets sent to the endpoint. These connection 1123 IDs are supplied by the endpoint using the NEW_CONNECTION_ID frame 1124 (Section 19.15). 1126 5.1.1. Issuing Connection IDs 1128 Each Connection ID has an associated sequence number to assist in 1129 deduplicating messages. The initial connection ID issued by an 1130 endpoint is sent in the Source Connection ID field of the long packet 1131 header (Section 17.2) during the handshake. The sequence number of 1132 the initial connection ID is 0. If the preferred_address transport 1133 parameter is sent, the sequence number of the supplied connection ID 1134 is 1. 1136 Additional connection IDs are communicated to the peer using 1137 NEW_CONNECTION_ID frames (Section 19.15). The sequence number on 1138 each newly-issued connection ID MUST increase by 1. The connection 1139 ID randomly selected by the client in the Initial packet and any 1140 connection ID provided by a Retry packet are not assigned sequence 1141 numbers unless a server opts to retain them as its initial connection 1142 ID. 1144 When an endpoint issues a connection ID, it MUST accept packets that 1145 carry this connection ID for the duration of the connection or until 1146 its peer invalidates the connection ID via a RETIRE_CONNECTION_ID 1147 frame (Section 19.16). 1149 An endpoint SHOULD ensure that its peer has a sufficient number of 1150 available and unused connection IDs. Endpoints store received 1151 connection IDs for future use and advertise the number of connection 1152 IDs they are willing to store with the active_connection_id_limit 1153 transport parameter. An endpoint SHOULD NOT provide more connection 1154 IDs than the peer's limit. 1156 An endpoint SHOULD supply a new connection ID when it receives a 1157 packet with a previously unused connection ID or when the peer 1158 retires one, unless providing the new connection ID would exceed the 1159 peer's limit. An endpoint MAY limit the frequency or the total 1160 number of connection IDs issued for each connection to avoid the risk 1161 of running out of connection IDs; see Section 10.4.2. 1163 An endpoint that initiates migration and requires non-zero-length 1164 connection IDs SHOULD ensure that the pool of connection IDs 1165 available to its peer allows the peer to use a new connection ID on 1166 migration, as the peer will close the connection if the pool is 1167 exhausted. 1169 5.1.2. Consuming and Retiring Connection IDs 1171 An endpoint can change the connection ID it uses for a peer to 1172 another available one at any time during the connection. An endpoint 1173 consumes connection IDs in response to a migrating peer; see 1174 Section 9.5 for more. 1176 An endpoint maintains a set of connection IDs received from its peer, 1177 any of which it can use when sending packets. When the endpoint 1178 wishes to remove a connection ID from use, it sends a 1179 RETIRE_CONNECTION_ID frame to its peer. Sending a 1180 RETIRE_CONNECTION_ID frame indicates that the connection ID will not 1181 be used again and requests that the peer replace it with a new 1182 connection ID using a NEW_CONNECTION_ID frame. 1184 As discussed in Section 9.5, each connection ID MUST be used on 1185 packets sent from only one local address. An endpoint that migrates 1186 away from a local address SHOULD retire all connection IDs used on 1187 that address once it no longer plans to use that address. 1189 An endpoint can request that its peer retire connection IDs by 1190 sending a NEW_CONNECTION_ID frame with an increased Retire Prior To 1191 field. Upon receipt, the peer SHOULD retire the corresponding 1192 connection IDs and send the corresponding RETIRE_CONNECTION_ID frames 1193 in a timely manner. Failing to do so can cause packets to be 1194 delayed, lost, or cause the original endpoint to send a stateless 1195 reset in response to a connection ID it can no longer route 1196 correctly. 1198 An endpoint MAY discard a connection ID for which retirement has been 1199 requested once an interval of no less than 3 PTO has elapsed since an 1200 acknowledgement is received for the NEW_CONNECTION_ID frame 1201 requesting that retirement. Subsequent incoming packets using that 1202 connection ID could elicit a response with the corresponding 1203 stateless reset token. 1205 5.2. Matching Packets to Connections 1207 Incoming packets are classified on receipt. Packets can either be 1208 associated with an existing connection, or - for servers - 1209 potentially create a new connection. 1211 Hosts try to associate a packet with an existing connection. If the 1212 packet has a Destination Connection ID corresponding to an existing 1213 connection, QUIC processes that packet accordingly. Note that more 1214 than one connection ID can be associated with a connection; see 1215 Section 5.1. 1217 If the Destination Connection ID is zero length and the packet 1218 matches the address/port tuple of a connection where the host did not 1219 require connection IDs, QUIC processes the packet as part of that 1220 connection. Endpoints SHOULD either reject connection attempts that 1221 use the same addresses as existing connections, or use a non-zero- 1222 length Destination Connection ID so that packets can be correctly 1223 attributed to connections. 1225 Endpoints can send a Stateless Reset (Section 10.4) for any packets 1226 that cannot be attributed to an existing connection. A stateless 1227 reset allows a peer to more quickly identify when a connection 1228 becomes unusable. 1230 Packets that are matched to an existing connection are discarded if 1231 the packets are inconsistent with the state of that connection. For 1232 example, packets are discarded if they indicate a different protocol 1233 version than that of the connection, or if the removal of packet 1234 protection is unsuccessful once the expected keys are available. 1236 Invalid packets without packet protection, such as Initial, Retry, or 1237 Version Negotiation, MAY be discarded. An endpoint MUST generate a 1238 connection error if it commits changes to state before discovering an 1239 error. 1241 5.2.1. Client Packet Handling 1243 Valid packets sent to clients always include a Destination Connection 1244 ID that matches a value the client selects. Clients that choose to 1245 receive zero-length connection IDs can use the address/port tuple to 1246 identify a connection. Packets that don't match an existing 1247 connection are discarded. 1249 Due to packet reordering or loss, a client might receive packets for 1250 a connection that are encrypted with a key it has not yet computed. 1251 The client MAY drop these packets, or MAY buffer them in anticipation 1252 of later packets that allow it to compute the key. 1254 If a client receives a packet that has an unsupported version, it 1255 MUST discard that packet. 1257 5.2.2. Server Packet Handling 1259 If a server receives a packet that has an unsupported version, but 1260 the packet is sufficiently large to initiate a new connection for any 1261 version supported by the server, it SHOULD send a Version Negotiation 1262 packet as described in Section 6.1. Servers MAY rate control these 1263 packets to avoid storms of Version Negotiation packets. Otherwise, 1264 servers MUST drop packets that specify unsupported versions. 1266 The first packet for an unsupported version can use different 1267 semantics and encodings for any version-specific field. In 1268 particular, different packet protection keys might be used for 1269 different versions. Servers that do not support a particular version 1270 are unlikely to be able to decrypt the payload of the packet. 1271 Servers SHOULD NOT attempt to decode or decrypt a packet from an 1272 unknown version, but instead send a Version Negotiation packet, 1273 provided that the packet is sufficiently long. 1275 Packets with a supported version, or no version field, are matched to 1276 a connection using the connection ID or - for packets with zero- 1277 length connection IDs - the address tuple. If the packet doesn't 1278 match an existing connection, the server continues below. 1280 If the packet is an Initial packet fully conforming with the 1281 specification, the server proceeds with the handshake (Section 7). 1282 This commits the server to the version that the client selected. 1284 If a server isn't currently accepting any new connections, it SHOULD 1285 send an Initial packet containing a CONNECTION_CLOSE frame with error 1286 code SERVER_BUSY. 1288 If the packet is a 0-RTT packet, the server MAY buffer a limited 1289 number of these packets in anticipation of a late-arriving Initial 1290 packet. Clients are not able to send Handshake packets prior to 1291 receiving a server response, so servers SHOULD ignore any such 1292 packets. 1294 Servers MUST drop incoming packets under all other circumstances. 1296 5.3. Life of a QUIC Connection 1298 TBD. 1300 6. Version Negotiation 1302 Version negotiation ensures that client and server agree to a QUIC 1303 version that is mutually supported. A server sends a Version 1304 Negotiation packet in response to each packet that might initiate a 1305 new connection; see Section 5.2 for details. 1307 The size of the first packet sent by a client will determine whether 1308 a server sends a Version Negotiation packet. Clients that support 1309 multiple QUIC versions SHOULD pad the first packet they send to the 1310 largest of the minimum packet sizes across all versions they support. 1311 This ensures that the server responds if there is a mutually 1312 supported version. 1314 6.1. Sending Version Negotiation Packets 1316 If the version selected by the client is not acceptable to the 1317 server, the server responds with a Version Negotiation packet (see 1318 Section 17.2.1). This includes a list of versions that the server 1319 will accept. An endpoint MUST NOT send a Version Negotiation packet 1320 in response to receiving a Version Negotiation packet. 1322 This system allows a server to process packets with unsupported 1323 versions without retaining state. Though either the Initial packet 1324 or the Version Negotiation packet that is sent in response could be 1325 lost, the client will send new packets until it successfully receives 1326 a response or it abandons the connection attempt. As a result, the 1327 client discards all state for the connection and does not send any 1328 more packets on the connection. 1330 A server MAY limit the number of Version Negotiation packets it 1331 sends. For instance, a server that is able to recognize packets as 1332 0-RTT might choose not to send Version Negotiation packets in 1333 response to 0-RTT packets with the expectation that it will 1334 eventually receive an Initial packet. 1336 6.2. Handling Version Negotiation Packets 1338 When a client receives a Version Negotiation packet, it MUST abandon 1339 the current connection attempt. Version Negotiation packets are 1340 designed to allow future versions of QUIC to negotiate the version in 1341 use between endpoints. Future versions of QUIC might change how 1342 implementations that support multiple versions of QUIC react to 1343 Version Negotiation packets when attempting to establish a connection 1344 using this version. How to perform version negotiation is left as 1345 future work defined by future versions of QUIC. In particular, that 1346 future work will need to ensure robustness against version downgrade 1347 attacks Section 21.9. 1349 6.2.1. Version Negotiation Between Draft Versions 1351 [[RFC editor: please remove this section before publication.]] 1353 When a draft implementation receives a Version Negotiation packet, it 1354 MAY use it to attempt a new connection with one of the versions 1355 listed in the packet, instead of abandoning the current connection 1356 attempt Section 6.2. 1358 The client MUST check that the Destination and Source Connection ID 1359 fields match the Source and Destination Connection ID fields in a 1360 packet that the client sent. If this check fails, the packet MUST be 1361 discarded. 1363 Once the Version Negotiation packet is determined to be valid, the 1364 client then selects an acceptable protocol version from the list 1365 provided by the server. The client then attempts to create a new 1366 connection using that version. The new connection MUST use a new 1367 random Destination Connection ID different from the one it had 1368 previously sent. 1370 Note that this mechanism does not protect against downgrade attacks 1371 and MUST NOT be used outside of draft implementations. 1373 6.3. Using Reserved Versions 1375 For a server to use a new version in the future, clients need to 1376 correctly handle unsupported versions. To help ensure this, a server 1377 SHOULD include a version that is reserved for forcing version 1378 negotiation (0x?a?a?a?a as defined in Section 15) when generating a 1379 Version Negotiation packet. 1381 The design of version negotiation permits a server to avoid 1382 maintaining state for packets that it rejects in this fashion. 1384 A client MAY send a packet using a version that is reserved for 1385 forcing version negotiation. This can be used to solicit a list of 1386 supported versions from a server. 1388 7. Cryptographic and Transport Handshake 1390 QUIC relies on a combined cryptographic and transport handshake to 1391 minimize connection establishment latency. QUIC uses the CRYPTO 1392 frame Section 19.6 to transmit the cryptographic handshake. Version 1393 0x00000001 of QUIC uses TLS as described in [QUIC-TLS]; a different 1394 QUIC version number could indicate that a different cryptographic 1395 handshake protocol is in use. 1397 QUIC provides reliable, ordered delivery of the cryptographic 1398 handshake data. QUIC packet protection is used to encrypt as much of 1399 the handshake protocol as possible. The cryptographic handshake MUST 1400 provide the following properties: 1402 o authenticated key exchange, where 1404 * a server is always authenticated, 1406 * a client is optionally authenticated, 1408 * every connection produces distinct and unrelated keys, 1410 * keying material is usable for packet protection for both 0-RTT 1411 and 1-RTT packets, and 1413 * 1-RTT keys have forward secrecy 1415 o authenticated values for the transport parameters of the peer (see 1416 Section 7.3) 1418 o authenticated negotiation of an application protocol (TLS uses 1419 ALPN [RFC7301] for this purpose) 1421 The first CRYPTO frame from a client MUST be sent in a single packet. 1422 Any second attempt that is triggered by address validation (see 1423 Section 8.1) MUST also be sent within a single packet. This avoids 1424 having to reassemble a message from multiple packets. 1426 The first client packet of the cryptographic handshake protocol MUST 1427 fit within a 1232 byte QUIC packet payload. This includes overheads 1428 that reduce the space available to the cryptographic handshake 1429 protocol. 1431 An endpoint can verify support for Explicit Congestion Notification 1432 (ECN) in the first packets it sends, as described in Section 13.3.2. 1434 The CRYPTO frame can be sent in different packet number spaces. The 1435 sequence numbers used by CRYPTO frames to ensure ordered delivery of 1436 cryptographic handshake data start from zero in each packet number 1437 space. 1439 Endpoints MUST explicitly negotiate an application protocol. This 1440 avoids situations where there is a disagreement about the protocol 1441 that is in use. 1443 7.1. Example Handshake Flows 1445 Details of how TLS is integrated with QUIC are provided in 1446 [QUIC-TLS], but some examples are provided here. An extension of 1447 this exchange to support client address validation is shown in 1448 Section 8.1.1. 1450 Once any address validation exchanges are complete, the cryptographic 1451 handshake is used to agree on cryptographic keys. The cryptographic 1452 handshake is carried in Initial (Section 17.2.2) and Handshake 1453 (Section 17.2.4) packets. 1455 Figure 3 provides an overview of the 1-RTT handshake. Each line 1456 shows a QUIC packet with the packet type and packet number shown 1457 first, followed by the frames that are typically contained in those 1458 packets. So, for instance the first packet is of type Initial, with 1459 packet number 0, and contains a CRYPTO frame carrying the 1460 ClientHello. 1462 Note that multiple QUIC packets - even of different encryption levels 1463 - may be coalesced into a single UDP datagram (see Section 12.2), and 1464 so this handshake may consist of as few as 4 UDP datagrams, or any 1465 number more. For instance, the server's first flight contains 1466 packets from the Initial encryption level (obfuscation), the 1467 Handshake level, and "0.5-RTT data" from the server at the 1-RTT 1468 encryption level. 1470 Client Server 1472 Initial[0]: CRYPTO[CH] -> 1474 Initial[0]: CRYPTO[SH] ACK[0] 1475 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1476 <- 1-RTT[0]: STREAM[1, "..."] 1478 Initial[1]: ACK[0] 1479 Handshake[0]: CRYPTO[FIN], ACK[0] 1480 1-RTT[0]: STREAM[0, "..."], ACK[0] -> 1482 1-RTT[1]: STREAM[3, "..."], ACK[0] 1483 <- Handshake[1]: ACK[0] 1485 Figure 3: Example 1-RTT Handshake 1487 Figure 4 shows an example of a connection with a 0-RTT handshake and 1488 a single packet of 0-RTT data. Note that as described in 1489 Section 12.3, the server acknowledges 0-RTT data at the 1-RTT 1490 encryption level, and the client sends 1-RTT packets in the same 1491 packet number space. 1493 Client Server 1495 Initial[0]: CRYPTO[CH] 1496 0-RTT[0]: STREAM[0, "..."] -> 1498 Initial[0]: CRYPTO[SH] ACK[0] 1499 Handshake[0] CRYPTO[EE, FIN] 1500 <- 1-RTT[0]: STREAM[1, "..."] ACK[0] 1502 Initial[1]: ACK[0] 1503 Handshake[0]: CRYPTO[FIN], ACK[0] 1504 1-RTT[1]: STREAM[0, "..."] ACK[0] -> 1506 1-RTT[1]: STREAM[3, "..."], ACK[1] 1507 <- Handshake[1]: ACK[0] 1509 Figure 4: Example 0-RTT Handshake 1511 7.2. Negotiating Connection IDs 1513 A connection ID is used to ensure consistent routing of packets, as 1514 described in Section 5.1. The long header contains two connection 1515 IDs: the Destination Connection ID is chosen by the recipient of the 1516 packet and is used to provide consistent routing; the Source 1517 Connection ID is used to set the Destination Connection ID used by 1518 the peer. 1520 During the handshake, packets with the long header (Section 17.2) are 1521 used to establish the connection ID that each endpoint uses. Each 1522 endpoint uses the Source Connection ID field to specify the 1523 connection ID that is used in the Destination Connection ID field of 1524 packets being sent to them. Upon receiving a packet, each endpoint 1525 sets the Destination Connection ID it sends to match the value of the 1526 Source Connection ID that they receive. 1528 When an Initial packet is sent by a client that has not previously 1529 received an Initial or Retry packet from the server, it populates the 1530 Destination Connection ID field with an unpredictable value. This 1531 MUST be at least 8 bytes in length. Until a packet is received from 1532 the server, the client MUST use the same value unless it abandons the 1533 connection attempt and starts a new one. The initial Destination 1534 Connection ID is used to determine packet protection keys for Initial 1535 packets. 1537 The client populates the Source Connection ID field with a value of 1538 its choosing and sets the SCIL field to indicate the length. The 1539 first flight of 0-RTT packets use the same Destination and Source 1540 Connection ID values as the client's first Initial. 1542 Upon first receiving an Initial or Retry packet from the server, the 1543 client uses the Source Connection ID supplied by the server as the 1544 Destination Connection ID for subsequent packets, including any 1545 subsequent 0-RTT packets. That means that a client might change the 1546 Destination Connection ID twice during connection establishment, once 1547 in response to a Retry and once in response to the first Initial 1548 packet from the server. Once a client has received an Initial packet 1549 from the server, it MUST discard any packet it receives with a 1550 different Source Connection ID. 1552 A client MUST only change the value it sends in the Destination 1553 Connection ID in response to the first packet of each type it 1554 receives from the server (Retry or Initial); a server MUST set its 1555 value based on the Initial packet. Any additional changes are not 1556 permitted; if subsequent packets of those types include a different 1557 Source Connection ID, they MUST be discarded. This avoids problems 1558 that might arise from stateless processing of multiple Initial 1559 packets producing different connection IDs. 1561 The connection ID can change over the lifetime of a connection, 1562 especially in response to connection migration (Section 9); see 1563 Section 5.1.1 for details. 1565 7.3. Transport Parameters 1567 During connection establishment, both endpoints make authenticated 1568 declarations of their transport parameters. These declarations are 1569 made unilaterally by each endpoint. Endpoints are required to comply 1570 with the restrictions implied by these parameters; the description of 1571 each parameter includes rules for its handling. 1573 The encoding of the transport parameters is detailed in Section 18. 1575 QUIC includes the encoded transport parameters in the cryptographic 1576 handshake. Once the handshake completes, the transport parameters 1577 declared by the peer are available. Each endpoint validates the 1578 value provided by its peer. 1580 Definitions for each of the defined transport parameters are included 1581 in Section 18.1. 1583 An endpoint MUST treat receipt of a transport parameter with an 1584 invalid value as a connection error of type 1585 TRANSPORT_PARAMETER_ERROR. 1587 An endpoint MUST NOT send a parameter more than once in a given 1588 transport parameters extension. An endpoint SHOULD treat receipt of 1589 duplicate transport parameters as a connection error of type 1590 TRANSPORT_PARAMETER_ERROR. 1592 A server MUST include the original_connection_id transport parameter 1593 (Section 18.1) if it sent a Retry packet to enable validation of the 1594 Retry, as described in Section 17.2.5. 1596 7.3.1. Values of Transport Parameters for 0-RTT 1598 Both endpoints store the value of the server transport parameters 1599 from a connection and apply them to any 0-RTT packets that are sent 1600 in subsequent connections to that peer, except for transport 1601 parameters that are explicitly excluded. Remembered transport 1602 parameters apply to the new connection until the handshake completes 1603 and the client starts sending 1-RTT packets. Once the handshake 1604 completes, the client uses the transport parameters established in 1605 the handshake. 1607 The definition of new transport parameters (Section 7.3.2) MUST 1608 specify whether they MUST, MAY, or MUST NOT be stored for 0-RTT. A 1609 client need not store a transport parameter it cannot process. 1611 A client MUST NOT use remembered values for the following parameters: 1612 original_connection_id, preferred_address, stateless_reset_token, 1613 ack_delay_exponent and active_connection_id_limit. The client MUST 1614 use the server's new values in the handshake instead, and absent new 1615 values from the server, the default value. 1617 A client that attempts to send 0-RTT data MUST remember all other 1618 transport parameters used by the server. The server can remember 1619 these transport parameters, or store an integrity-protected copy of 1620 the values in the ticket and recover the information when accepting 1621 0-RTT data. A server uses the transport parameters in determining 1622 whether to accept 0-RTT data. 1624 If 0-RTT data is accepted by the server, the server MUST NOT reduce 1625 any limits or alter any values that might be violated by the client 1626 with its 0-RTT data. In particular, a server that accepts 0-RTT data 1627 MUST NOT set values for the following parameters (Section 18.1) that 1628 are smaller than the remembered value of the parameters. 1630 o initial_max_data 1632 o initial_max_stream_data_bidi_local 1634 o initial_max_stream_data_bidi_remote 1636 o initial_max_stream_data_uni 1638 o initial_max_streams_bidi 1640 o initial_max_streams_uni 1642 Omitting or setting a zero value for certain transport parameters can 1643 result in 0-RTT data being enabled, but not usable. The applicable 1644 subset of transport parameters that permit sending of application 1645 data SHOULD be set to non-zero values for 0-RTT. This includes 1646 initial_max_data and either initial_max_streams_bidi and 1647 initial_max_stream_data_bidi_remote, or initial_max_streams_uni and 1648 initial_max_stream_data_uni. 1650 A server MUST either reject 0-RTT data or abort a handshake if the 1651 implied values for transport parameters cannot be supported. 1653 When sending frames in 0-RTT packets, a client MUST only use 1654 remembered transport parameters; importantly, it MUST NOT use updated 1655 values that it learns from the server's updated transport parameters 1656 or from frames received in 1-RTT packets. Updated values of 1657 transport parameters from the handshake apply only to 1-RTT packets. 1658 For instance, flow control limits from remembered transport 1659 parameters apply to all 0-RTT packets even if those values are 1660 increased by the handshake or by frames sent in 1-RTT packets. A 1661 server MAY treat use of updated transport parameters in 0-RTT as a 1662 connection error of type PROTOCOL_VIOLATION. 1664 7.3.2. New Transport Parameters 1666 New transport parameters can be used to negotiate new protocol 1667 behavior. An endpoint MUST ignore transport parameters that it does 1668 not support. Absence of a transport parameter therefore disables any 1669 optional protocol feature that is negotiated using the parameter. 1671 New transport parameters can be registered according to the rules in 1672 Section 22.1. 1674 7.4. Cryptographic Message Buffering 1676 Implementations need to maintain a buffer of CRYPTO data received out 1677 of order. Because there is no flow control of CRYPTO frames, an 1678 endpoint could potentially force its peer to buffer an unbounded 1679 amount of data. 1681 Implementations MUST support buffering at least 4096 bytes of data 1682 received in CRYPTO frames out of order. Endpoints MAY choose to 1683 allow more data to be buffered during the handshake. A larger limit 1684 during the handshake could allow for larger keys or credentials to be 1685 exchanged. An endpoint's buffer size does not need to remain 1686 constant during the life of the connection. 1688 Being unable to buffer CRYPTO frames during the handshake can lead to 1689 a connection failure. If an endpoint's buffer is exceeded during the 1690 handshake, it can expand its buffer temporarily to complete the 1691 handshake. If an endpoint does not expand its buffer, it MUST close 1692 the connection with a CRYPTO_BUFFER_EXCEEDED error code. 1694 Once the handshake completes, if an endpoint is unable to buffer all 1695 data in a CRYPTO frame, it MAY discard that CRYPTO frame and all 1696 CRYPTO frames received in the future, or it MAY close the connection 1697 with a CRYPTO_BUFFER_EXCEEDED error code. Packets containing 1698 discarded CRYPTO frames MUST be acknowledged because the packet has 1699 been received and processed by the transport even though the CRYPTO 1700 frame was discarded. 1702 8. Address Validation 1704 Address validation is used by QUIC to avoid being used for a traffic 1705 amplification attack. In such an attack, a packet is sent to a 1706 server with spoofed source address information that identifies a 1707 victim. If a server generates more or larger packets in response to 1708 that packet, the attacker can use the server to send more data toward 1709 the victim than it would be able to send on its own. 1711 The primary defense against amplification attack is verifying that an 1712 endpoint is able to receive packets at the transport address that it 1713 claims. Address validation is performed both during connection 1714 establishment (see Section 8.1) and during connection migration (see 1715 Section 8.2). 1717 8.1. Address Validation During Connection Establishment 1719 Connection establishment implicitly provides address validation for 1720 both endpoints. In particular, receipt of a packet protected with 1721 Handshake keys confirms that the client received the Initial packet 1722 from the server. Once the server has successfully processed a 1723 Handshake packet from the client, it can consider the client address 1724 to have been validated. 1726 Prior to validating the client address, servers MUST NOT send more 1727 than three times as many bytes as the number of bytes they have 1728 received. This limits the magnitude of any amplification attack that 1729 can be mounted using spoofed source addresses. In determining this 1730 limit, servers only count the size of successfully processed packets. 1732 Clients MUST ensure that UDP datagrams containing only Initial 1733 packets are sized to at least 1200 bytes, adding padding to packets 1734 in the datagram as necessary. Sending padded datagrams ensures that 1735 the server is not overly constrained by the amplification 1736 restriction. 1738 Packet loss, in particular loss of a Handshake packet from the 1739 server, can cause a situation in which the server cannot send when 1740 the client has no data to send and the anti-amplification limit is 1741 reached. In order to avoid this causing a handshake deadlock, 1742 clients SHOULD send a packet upon a crypto retransmission timeout, as 1743 described in [QUIC-RECOVERY]. If the client has no data to 1744 retransmit and does not have Handshake keys, it SHOULD send an 1745 Initial packet in a UDP datagram of at least 1200 bytes. If the 1746 client has Handshake keys, it SHOULD send a Handshake packet. 1748 A server might wish to validate the client address before starting 1749 the cryptographic handshake. QUIC uses a token in the Initial packet 1750 to provide address validation prior to completing the handshake. 1751 This token is delivered to the client during connection establishment 1752 with a Retry packet (see Section 8.1.1) or in a previous connection 1753 using the NEW_TOKEN frame (see Section 8.1.2). 1755 In addition to sending limits imposed prior to address validation, 1756 servers are also constrained in what they can send by the limits set 1757 by the congestion controller. Clients are only constrained by the 1758 congestion controller. 1760 8.1.1. Address Validation using Retry Packets 1762 Upon receiving the client's Initial packet, the server can request 1763 address validation by sending a Retry packet (Section 17.2.5) 1764 containing a token. This token MUST be repeated by the client in all 1765 Initial packets it sends for that connection after it receives the 1766 Retry packet. In response to processing an Initial containing a 1767 token, a server can either abort the connection or permit it to 1768 proceed. 1770 As long as it is not possible for an attacker to generate a valid 1771 token for its own address (see Section 8.1.3) and the client is able 1772 to return that token, it proves to the server that it received the 1773 token. 1775 A server can also use a Retry packet to defer the state and 1776 processing costs of connection establishment. By giving the client a 1777 different connection ID to use, a server can cause the connection to 1778 be routed to a server instance with more resources available for new 1779 connections. 1781 A flow showing the use of a Retry packet is shown in Figure 5. 1783 Client Server 1785 Initial[0]: CRYPTO[CH] -> 1787 <- Retry+Token 1789 Initial+Token[1]: CRYPTO[CH] -> 1791 Initial[0]: CRYPTO[SH] ACK[1] 1792 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1793 <- 1-RTT[0]: STREAM[1, "..."] 1795 Figure 5: Example Handshake with Retry 1797 8.1.2. Address Validation for Future Connections 1799 A server MAY provide clients with an address validation token during 1800 one connection that can be used on a subsequent connection. Address 1801 validation is especially important with 0-RTT because a server 1802 potentially sends a significant amount of data to a client in 1803 response to 0-RTT data. 1805 The server uses the NEW_TOKEN frame Section 19.7 to provide the 1806 client with an address validation token that can be used to validate 1807 future connections. The client includes this token in Initial 1808 packets to provide address validation in a future connection. The 1809 client MUST include the token in all Initial packets it sends, unless 1810 a Retry replaces the token with a newer one. The client MUST NOT use 1811 the token provided in a Retry for future connections. Servers MAY 1812 discard any Initial packet that does not carry the expected token. 1814 A token SHOULD be constructed for the server to easily distinguish it 1815 from tokens that are sent in Retry packets as they are carried in the 1816 same field. 1818 The token MUST NOT include information that would allow it to be 1819 linked by an on-path observer to the connection on which it was 1820 issued. For example, it cannot include the connection ID or 1821 addressing information unless the values are encrypted. 1823 Unlike the token that is created for a Retry packet, there might be 1824 some time between when the token is created and when the token is 1825 subsequently used. Thus, a token SHOULD have an expiration time, 1826 which could be either an explicit expiration time or an issued 1827 timestamp that can be used to dynamically calculate the expiration 1828 time. A server can store the expiration time or include it in an 1829 encrypted form in the token. 1831 It is unlikely that the client port number is the same on two 1832 different connections; validating the port is therefore unlikely to 1833 be successful. 1835 If the client has a token received in a NEW_TOKEN frame on a previous 1836 connection to what it believes to be the same server, it SHOULD 1837 include that value in the Token field of its Initial packet. 1838 Including a token might allow the server to validate the client 1839 address without an additional round trip. 1841 A token allows a server to correlate activity between the connection 1842 where the token was issued and any connection where it is used. 1843 Clients that want to break continuity of identity with a server MAY 1844 discard tokens provided using the NEW_TOKEN frame. A token obtained 1845 in a Retry packet MUST be used immediately during the connection 1846 attempt and cannot be used in subsequent connection attempts. 1848 A client SHOULD NOT reuse a token in different connections. Reusing 1849 a token allows connections to be linked by entities on the network 1850 path (see Section 9.5). A client MUST NOT reuse a token if it 1851 believes that its point of network attachment has changed since the 1852 token was last used; that is, if there is a change in its local IP 1853 address or network interface. A client needs to start the connection 1854 process over if it migrates prior to completing the handshake. 1856 When a server receives an Initial packet with an address validation 1857 token, it MUST attempt to validate the token, unless it has already 1858 completed address validation. If the token is invalid then the 1859 server SHOULD proceed as if the client did not have a validated 1860 address, including potentially sending a Retry. If the validation 1861 succeeds, the server SHOULD then allow the handshake to proceed. 1863 Note: The rationale for treating the client as unvalidated rather 1864 than discarding the packet is that the client might have received 1865 the token in a previous connection using the NEW_TOKEN frame, and 1866 if the server has lost state, it might be unable to validate the 1867 token at all, leading to connection failure if the packet is 1868 discarded. A server SHOULD encode tokens provided with NEW_TOKEN 1869 frames and Retry packets differently, and validate the latter more 1870 strictly. 1872 In a stateless design, a server can use encrypted and authenticated 1873 tokens to pass information to clients that the server can later 1874 recover and use to validate a client address. Tokens are not 1875 integrated into the cryptographic handshake and so they are not 1876 authenticated. For instance, a client might be able to reuse a 1877 token. To avoid attacks that exploit this property, a server can 1878 limit its use of tokens to only the information needed to validate 1879 client addresses. 1881 Attackers could replay tokens to use servers as amplifiers in DDoS 1882 attacks. To protect against such attacks, servers SHOULD ensure that 1883 tokens sent in Retry packets are only accepted for a short time. 1884 Tokens that are provided in NEW_TOKEN frames (see Section 19.7) need 1885 to be valid for longer, but SHOULD NOT be accepted multiple times in 1886 a short period. Servers are encouraged to allow tokens to be used 1887 only once, if possible. 1889 8.1.3. Address Validation Token Integrity 1891 An address validation token MUST be difficult to guess. Including a 1892 large enough random value in the token would be sufficient, but this 1893 depends on the server remembering the value it sends to clients. 1895 A token-based scheme allows the server to offload any state 1896 associated with validation to the client. For this design to work, 1897 the token MUST be covered by integrity protection against 1898 modification or falsification by clients. Without integrity 1899 protection, malicious clients could generate or guess values for 1900 tokens that would be accepted by the server. Only the server 1901 requires access to the integrity protection key for tokens. 1903 There is no need for a single well-defined format for the token 1904 because the server that generates the token also consumes it. A 1905 token could include information about the claimed client address (IP 1906 and port), a timestamp, and any other supplementary information the 1907 server will need to validate the token in the future. 1909 8.2. Path Validation 1911 Path validation is used during connection migration (see Section 9 1912 and Section 9.6) by the migrating endpoint to verify reachability of 1913 a peer from a new local address. In path validation, endpoints test 1914 reachability between a specific local address and a specific peer 1915 address, where an address is the two-tuple of IP address and port. 1917 Path validation tests that packets (PATH_CHALLENGE) can be both sent 1918 to and received (PATH_RESPONSE) from a peer on the path. 1919 Importantly, it validates that the packets received from the 1920 migrating endpoint do not carry a spoofed source address. 1922 Path validation can be used at any time by either endpoint. For 1923 instance, an endpoint might check that a peer is still in possession 1924 of its address after a period of quiescence. 1926 Path validation is not designed as a NAT traversal mechanism. Though 1927 the mechanism described here might be effective for the creation of 1928 NAT bindings that support NAT traversal, the expectation is that one 1929 or other peer is able to receive packets without first having sent a 1930 packet on that path. Effective NAT traversal needs additional 1931 synchronization mechanisms that are not provided here. 1933 An endpoint MAY bundle PATH_CHALLENGE and PATH_RESPONSE frames that 1934 are used for path validation with other frames. In particular, an 1935 endpoint may pad a packet carrying a PATH_CHALLENGE for PMTU 1936 discovery, or an endpoint may bundle a PATH_RESPONSE with its own 1937 PATH_CHALLENGE. 1939 When probing a new path, an endpoint might want to ensure that its 1940 peer has an unused connection ID available for responses. The 1941 endpoint can send NEW_CONNECTION_ID and PATH_CHALLENGE frames in the 1942 same packet. This ensures that an unused connection ID will be 1943 available to the peer when sending a response. 1945 8.3. Initiating Path Validation 1947 To initiate path validation, an endpoint sends a PATH_CHALLENGE frame 1948 containing a random payload on the path to be validated. 1950 An endpoint MAY send multiple PATH_CHALLENGE frames to guard against 1951 packet loss, however an endpoint SHOULD NOT send multiple 1952 PATH_CHALLENGE frames in a single packet. An endpoint SHOULD NOT 1953 send a PATH_CHALLENGE more frequently than it would an Initial 1954 packet, ensuring that connection migration is no more load on a new 1955 path than establishing a new connection. 1957 The endpoint MUST use unpredictable data in every PATH_CHALLENGE 1958 frame so that it can associate the peer's response with the 1959 corresponding PATH_CHALLENGE. 1961 8.4. Path Validation Responses 1963 On receiving a PATH_CHALLENGE frame, an endpoint MUST respond 1964 immediately by echoing the data contained in the PATH_CHALLENGE frame 1965 in a PATH_RESPONSE frame. 1967 An endpoint MUST NOT send more than one PATH_RESPONSE frame in 1968 response to one PATH_CHALLENGE frame (see Section 13.2). The peer is 1969 expected to send more PATH_CHALLENGE frames as necessary to evoke 1970 additional PATH_RESPONSE frames. 1972 8.5. Successful Path Validation 1974 A new address is considered valid when a PATH_RESPONSE frame is 1975 received that contains the data that was sent in a previous 1976 PATH_CHALLENGE. Receipt of an acknowledgment for a packet containing 1977 a PATH_CHALLENGE frame is not adequate validation, since the 1978 acknowledgment can be spoofed by a malicious peer. 1980 Note that receipt on a different local address does not result in 1981 path validation failure, as it might be a result of a forwarded 1982 packet (see Section 9.3.3) or misrouting. It is possible that a 1983 valid PATH_RESPONSE might be received in the future. 1985 8.6. Failed Path Validation 1987 Path validation only fails when the endpoint attempting to validate 1988 the path abandons its attempt to validate the path. 1990 Endpoints SHOULD abandon path validation based on a timer. When 1991 setting this timer, implementations are cautioned that the new path 1992 could have a longer round-trip time than the original. A value of 1993 three times the larger of the current Probe Timeout (PTO) or the 1994 initial timeout (that is, 2*kInitialRtt) as defined in 1995 [QUIC-RECOVERY] is RECOMMENDED. That is: 1997 validation_timeout = max(3*PTO, 6*kInitialRtt) 1999 Note that the endpoint might receive packets containing other frames 2000 on the new path, but a PATH_RESPONSE frame with appropriate data is 2001 required for path validation to succeed. 2003 When an endpoint abandons path validation, it determines that the 2004 path is unusable. This does not necessarily imply a failure of the 2005 connection - endpoints can continue sending packets over other paths 2006 as appropriate. If no paths are available, an endpoint can wait for 2007 a new path to become available or close the connection. 2009 A path validation might be abandoned for other reasons besides 2010 failure. Primarily, this happens if a connection migration to a new 2011 path is initiated while a path validation on the old path is in 2012 progress. 2014 9. Connection Migration 2016 The use of a connection ID allows connections to survive changes to 2017 endpoint addresses (IP address and port), such as those caused by an 2018 endpoint migrating to a new network. This section describes the 2019 process by which an endpoint migrates to a new address. 2021 The design of QUIC relies on endpoints retaining a stable address for 2022 the duration of the handshake. An endpoint MUST NOT initiate 2023 connection migration before the handshake is confirmed, as defined in 2024 section 4.1.2 of [QUIC-TLS]. 2026 An endpoint also MUST NOT initiate connection migration if the peer 2027 sent the "disable_migration" transport parameter during the 2028 handshake. An endpoint which has sent this transport parameter, but 2029 detects that a peer has nonetheless migrated to a different network 2030 MAY treat this as a connection error of type INVALID_MIGRATION. 2031 Similarly, an endpoint MUST NOT initiate migration if its peer 2032 supplies a zero-length connection ID as packets without a Destination 2033 Connection ID cannot be attributed to a connection based on address 2034 tuple. 2036 Not all changes of peer address are intentional migrations. The peer 2037 could experience NAT rebinding: a change of address due to a 2038 middlebox, usually a NAT, allocating a new outgoing port or even a 2039 new outgoing IP address for a flow. An endpoint MUST perform path 2040 validation (Section 8.2) if it detects any change to a peer's 2041 address, unless it has previously validated that address. 2043 When an endpoint has no validated path on which to send packets, it 2044 MAY discard connection state. An endpoint capable of connection 2045 migration MAY wait for a new path to become available before 2046 discarding connection state. 2048 This document limits migration of connections to new client 2049 addresses, except as described in Section 9.6. Clients are 2050 responsible for initiating all migrations. Servers do not send non- 2051 probing packets (see Section 9.1) toward a client address until they 2052 see a non-probing packet from that address. If a client receives 2053 packets from an unknown server address, the client MUST discard these 2054 packets. 2056 9.1. Probing a New Path 2058 An endpoint MAY probe for peer reachability from a new local address 2059 using path validation Section 8.2 prior to migrating the connection 2060 to the new local address. Failure of path validation simply means 2061 that the new path is not usable for this connection. Failure to 2062 validate a path does not cause the connection to end unless there are 2063 no valid alternative paths available. 2065 An endpoint uses a new connection ID for probes sent from a new local 2066 address, see Section 9.5 for further discussion. An endpoint that 2067 uses a new local address needs to ensure that at least one new 2068 connection ID is available at the peer. That can be achieved by 2069 including a NEW_CONNECTION_ID frame in the probe. 2071 Receiving a PATH_CHALLENGE frame from a peer indicates that the peer 2072 is probing for reachability on a path. An endpoint sends a 2073 PATH_RESPONSE in response as per Section 8.2. 2075 PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames 2076 are "probing frames", and all other frames are "non-probing frames". 2077 A packet containing only probing frames is a "probing packet", and a 2078 packet containing any other frame is a "non-probing packet". 2080 9.2. Initiating Connection Migration 2082 An endpoint can migrate a connection to a new local address by 2083 sending packets containing non-probing frames from that address. 2085 Each endpoint validates its peer's address during connection 2086 establishment. Therefore, a migrating endpoint can send to its peer 2087 knowing that the peer is willing to receive at the peer's current 2088 address. Thus an endpoint can migrate to a new local address without 2089 first validating the peer's address. 2091 When migrating, the new path might not support the endpoint's current 2092 sending rate. Therefore, the endpoint resets its congestion 2093 controller, as described in Section 9.4. 2095 The new path might not have the same ECN capability. Therefore, the 2096 endpoint verifies ECN capability as described in Section 13.3. 2098 Receiving acknowledgments for data sent on the new path serves as 2099 proof of the peer's reachability from the new address. Note that 2100 since acknowledgments may be received on any path, return 2101 reachability on the new path is not established. To establish return 2102 reachability on the new path, an endpoint MAY concurrently initiate 2103 path validation Section 8.2 on the new path. 2105 9.3. Responding to Connection Migration 2107 Receiving a packet from a new peer address containing a non-probing 2108 frame indicates that the peer has migrated to that address. 2110 In response to such a packet, an endpoint MUST start sending 2111 subsequent packets to the new peer address and MUST initiate path 2112 validation (Section 8.2) to verify the peer's ownership of the 2113 unvalidated address. 2115 An endpoint MAY send data to an unvalidated peer address, but it MUST 2116 protect against potential attacks as described in Section 9.3.1 and 2117 Section 9.3.2. An endpoint MAY skip validation of a peer address if 2118 that address has been seen recently. 2120 An endpoint only changes the address that it sends packets to in 2121 response to the highest-numbered non-probing packet. This ensures 2122 that an endpoint does not send packets to an old peer address in the 2123 case that it receives reordered packets. 2125 After changing the address to which it sends non-probing packets, an 2126 endpoint could abandon any path validation for other addresses. 2128 Receiving a packet from a new peer address might be the result of a 2129 NAT rebinding at the peer. 2131 After verifying a new client address, the server SHOULD send new 2132 address validation tokens (Section 8) to the client. 2134 9.3.1. Peer Address Spoofing 2136 It is possible that a peer is spoofing its source address to cause an 2137 endpoint to send excessive amounts of data to an unwilling host. If 2138 the endpoint sends significantly more data than the spoofing peer, 2139 connection migration might be used to amplify the volume of data that 2140 an attacker can generate toward a victim. 2142 As described in Section 9.3, an endpoint is required to validate a 2143 peer's new address to confirm the peer's possession of the new 2144 address. Until a peer's address is deemed valid, an endpoint MUST 2145 limit the rate at which it sends data to this address. The endpoint 2146 MUST NOT send more than a minimum congestion window's worth of data 2147 per estimated round-trip time (kMinimumWindow, as defined in 2148 [QUIC-RECOVERY]). In the absence of this limit, an endpoint risks 2149 being used for a denial of service attack against an unsuspecting 2150 victim. Note that since the endpoint will not have any round-trip 2151 time measurements to this address, the estimate SHOULD be the default 2152 initial value (see [QUIC-RECOVERY]). 2154 If an endpoint skips validation of a peer address as described in 2155 Section 9.3, it does not need to limit its sending rate. 2157 9.3.2. On-Path Address Spoofing 2159 An on-path attacker could cause a spurious connection migration by 2160 copying and forwarding a packet with a spoofed address such that it 2161 arrives before the original packet. The packet with the spoofed 2162 address will be seen to come from a migrating connection, and the 2163 original packet will be seen as a duplicate and dropped. After a 2164 spurious migration, validation of the source address will fail 2165 because the entity at the source address does not have the necessary 2166 cryptographic keys to read or respond to the PATH_CHALLENGE frame 2167 that is sent to it even if it wanted to. 2169 To protect the connection from failing due to such a spurious 2170 migration, an endpoint MUST revert to using the last validated peer 2171 address when validation of a new peer address fails. 2173 If an endpoint has no state about the last validated peer address, it 2174 MUST close the connection silently by discarding all connection 2175 state. This results in new packets on the connection being handled 2176 generically. For instance, an endpoint MAY send a stateless reset in 2177 response to any further incoming packets. 2179 Note that receipt of packets with higher packet numbers from the 2180 legitimate peer address will trigger another connection migration. 2182 This will cause the validation of the address of the spurious 2183 migration to be abandoned. 2185 9.3.3. Off-Path Packet Forwarding 2187 An off-path attacker that can observe packets might forward copies of 2188 genuine packets to endpoints. If the copied packet arrives before 2189 the genuine packet, this will appear as a NAT rebinding. Any genuine 2190 packet will be discarded as a duplicate. If the attacker is able to 2191 continue forwarding packets, it might be able to cause migration to a 2192 path via the attacker. This places the attacker on path, giving it 2193 the ability to observe or drop all subsequent packets. 2195 Unlike the attack described in Section 9.3.2, the attacker can ensure 2196 that the new path is successfully validated. 2198 This style of attack relies on the attacker using a path that is 2199 approximately as fast as the direct path between endpoints. The 2200 attack is more reliable if relatively few packets are sent or if 2201 packet loss coincides with the attempted attack. 2203 A non-probing packet received on the original path that increases the 2204 maximum received packet number will cause the endpoint to move back 2205 to that path. Eliciting packets on this path increases the 2206 likelihood that the attack is unsuccessful. Therefore, mitigation of 2207 this attack relies on triggering the exchange of packets. 2209 In response to an apparent migration, endpoints MUST validate the 2210 previously active path using a PATH_CHALLENGE frame. This induces 2211 the sending of new packets on that path. If the path is no longer 2212 viable, the validation attempt will time out and fail; if the path is 2213 viable, but no longer desired, the validation will succeed, but only 2214 results in probing packets being sent on the path. 2216 An endpoint that receives a PATH_CHALLENGE on an active path SHOULD 2217 send a non-probing packet in response. If the non-probing packet 2218 arrives before any copy made by an attacker, this results in the 2219 connection being migrated back to the original path. Any subsequent 2220 migration to another path restarts this entire process. 2222 This defense is imperfect, but this is not considered a serious 2223 problem. If the path via the attack is reliably faster than the 2224 original path despite multiple attempts to use that original path, it 2225 is not possible to distinguish between attack and an improvement in 2226 routing. 2228 An endpoint could also use heuristics to improve detection of this 2229 style of attack. For instance, NAT rebinding is improbable if 2230 packets were recently received on the old path, similarly rebinding 2231 is rare on IPv6 paths. Endpoints can also look for duplicated 2232 packets. Conversely, a change in connection ID is more likely to 2233 indicate an intentional migration rather than an attack. 2235 9.4. Loss Detection and Congestion Control 2237 The capacity available on the new path might not be the same as the 2238 old path. Packets sent on the old path SHOULD NOT contribute to 2239 congestion control or RTT estimation for the new path. 2241 On confirming a peer's ownership of its new address, an endpoint 2242 SHOULD immediately reset the congestion controller and round-trip 2243 time estimator for the new path. 2245 An endpoint MUST NOT return to the send rate used for the previous 2246 path unless it is reasonably sure that the previous send rate is 2247 valid for the new path. For instance, a change in the client's port 2248 number is likely indicative of a rebinding in a middlebox and not a 2249 complete change in path. This determination likely depends on 2250 heuristics, which could be imperfect; if the new path capacity is 2251 significantly reduced, ultimately this relies on the congestion 2252 controller responding to congestion signals and reducing send rates 2253 appropriately. 2255 There may be apparent reordering at the receiver when an endpoint 2256 sends data and probes from/to multiple addresses during the migration 2257 period, since the two resulting paths may have different round-trip 2258 times. A receiver of packets on multiple paths will still send ACK 2259 frames covering all received packets. 2261 While multiple paths might be used during connection migration, a 2262 single congestion control context and a single loss recovery context 2263 (as described in [QUIC-RECOVERY]) may be adequate. For instance, an 2264 endpoint might delay switching to a new congestion control context 2265 until it is confirmed that an old path is no longer needed (such as 2266 the case in Section 9.3.3). 2268 A sender can make exceptions for probe packets so that their loss 2269 detection is independent and does not unduly cause the congestion 2270 controller to reduce its sending rate. An endpoint might set a 2271 separate timer when a PATH_CHALLENGE is sent, which is cancelled when 2272 the corresponding PATH_RESPONSE is received. If the timer fires 2273 before the PATH_RESPONSE is received, the endpoint might send a new 2274 PATH_CHALLENGE, and restart the timer for a longer period of time. 2276 9.5. Privacy Implications of Connection Migration 2278 Using a stable connection ID on multiple network paths allows a 2279 passive observer to correlate activity between those paths. An 2280 endpoint that moves between networks might not wish to have their 2281 activity correlated by any entity other than their peer, so different 2282 connection IDs are used when sending from different local addresses, 2283 as discussed in Section 5.1. For this to be effective endpoints need 2284 to ensure that connections IDs they provide cannot be linked by any 2285 other entity. 2287 At any time, endpoints MAY change the Destination Connection ID they 2288 send to a value that has not been used on another path. 2290 An endpoint MUST use a new connection ID if it initiates connection 2291 migration. Using a new connection ID eliminates the use of the 2292 connection ID for linking activity from the same connection on 2293 different networks. Header protection ensures that packet numbers 2294 cannot be used to correlate activity. This does not prevent other 2295 properties of packets, such as timing and size, from being used to 2296 correlate activity. 2298 Unintentional changes in path without a change in connection ID are 2299 possible. For example, after a period of network inactivity, NAT 2300 rebinding might cause packets to be sent on a new path when the 2301 client resumes sending. 2303 A client might wish to reduce linkability by employing a new 2304 connection ID and source UDP port when sending traffic after a period 2305 of inactivity. Changing the UDP port from which it sends packets at 2306 the same time might cause the packet to appear as a connection 2307 migration. This ensures that the mechanisms that support migration 2308 are exercised even for clients that don't experience NAT rebindings 2309 or genuine migrations. Changing port number can cause a peer to 2310 reset its congestion state (see Section 9.4), so the port SHOULD only 2311 be changed infrequently. 2313 An endpoint that exhausts available connection IDs cannot migrate. 2314 To ensure that migration is possible and packets sent on different 2315 paths cannot be correlated, endpoints SHOULD provide new connection 2316 IDs before peers migrate. 2318 9.6. Server's Preferred Address 2320 QUIC allows servers to accept connections on one IP address and 2321 attempt to transfer these connections to a more preferred address 2322 shortly after the handshake. This is particularly useful when 2323 clients initially connect to an address shared by multiple servers 2324 but would prefer to use a unicast address to ensure connection 2325 stability. This section describes the protocol for migrating a 2326 connection to a preferred server address. 2328 Migrating a connection to a new server address mid-connection is left 2329 for future work. If a client receives packets from a new server 2330 address not indicated by the preferred_address transport parameter, 2331 the client SHOULD discard these packets. 2333 9.6.1. Communicating a Preferred Address 2335 A server conveys a preferred address by including the 2336 preferred_address transport parameter in the TLS handshake. 2338 Servers MAY communicate a preferred address of each address family 2339 (IPv4 and IPv6) to allow clients to pick the one most suited to their 2340 network attachment. 2342 Once the handshake is finished, the client SHOULD select one of the 2343 two server's preferred addresses and initiate path validation (see 2344 Section 8.2) of that address using the connection ID provided in the 2345 preferred_address transport parameter. 2347 If path validation succeeds, the client SHOULD immediately begin 2348 sending all future packets to the new server address using the new 2349 connection ID and discontinue use of the old server address. If path 2350 validation fails, the client MUST continue sending all future packets 2351 to the server's original IP address. 2353 9.6.2. Responding to Connection Migration 2355 A server might receive a packet addressed to its preferred IP address 2356 at any time after it accepts a connection. If this packet contains a 2357 PATH_CHALLENGE frame, the server sends a PATH_RESPONSE frame as per 2358 Section 8.2. The server MUST send other non-probing frames from its 2359 original address until it receives a non-probing packet from the 2360 client at its preferred address and until the server has validated 2361 the new path. 2363 The server MUST probe on the path toward the client from its 2364 preferred address. This helps to guard against spurious migration 2365 initiated by an attacker. 2367 Once the server has completed its path validation and has received a 2368 non-probing packet with a new largest packet number on its preferred 2369 address, the server begins sending non-probing packets to the client 2370 exclusively from its preferred IP address. It SHOULD drop packets 2371 for this connection received on the old IP address, but MAY continue 2372 to process delayed packets. 2374 9.6.3. Interaction of Client Migration and Preferred Address 2376 A client might need to perform a connection migration before it has 2377 migrated to the server's preferred address. In this case, the client 2378 SHOULD perform path validation to both the original and preferred 2379 server address from the client's new address concurrently. 2381 If path validation of the server's preferred address succeeds, the 2382 client MUST abandon validation of the original address and migrate to 2383 using the server's preferred address. If path validation of the 2384 server's preferred address fails but validation of the server's 2385 original address succeeds, the client MAY migrate to its new address 2386 and continue sending to the server's original address. 2388 If the connection to the server's preferred address is not from the 2389 same client address, the server MUST protect against potential 2390 attacks as described in Section 9.3.1 and Section 9.3.2. In addition 2391 to intentional simultaneous migration, this might also occur because 2392 the client's access network used a different NAT binding for the 2393 server's preferred address. 2395 Servers SHOULD initiate path validation to the client's new address 2396 upon receiving a probe packet from a different address. Servers MUST 2397 NOT send more than a minimum congestion window's worth of non-probing 2398 packets to the new address before path validation is complete. 2400 A client that migrates to a new address SHOULD use a preferred 2401 address from the same address family for the server. 2403 9.7. Use of IPv6 Flow-Label and Migration 2405 Endpoints that send data using IPv6 SHOULD apply an IPv6 flow label 2406 in compliance with [RFC6437], unless the local API does not allow 2407 setting IPv6 flow labels. 2409 The IPv6 flow label SHOULD be a pseudo-random function of the source 2410 and destination addresses, source and destination UDP ports, and the 2411 destination CID. The flow label generation MUST be designed to 2412 minimize the chances of linkability with a previously used flow 2413 label, as this would enable correlating activity on multiple paths 2414 (see Section 9.5). 2416 A possible implementation is to compute the flow label as a 2417 cryptographic hash function of the source and destination addresses, 2418 source and destination UDP ports, destination CID, and a local 2419 secret. 2421 10. Connection Termination 2423 An established QUIC connection can be terminated in one of three 2424 ways: 2426 o idle timeout (Section 10.2) 2428 o immediate close (Section 10.3) 2430 o stateless reset (Section 10.4) 2432 An endpoint MAY discard connection state if it does not have a 2433 validated path on which it can send packets (see Section 8.2). 2435 10.1. Closing and Draining Connection States 2437 The closing and draining connection states exist to ensure that 2438 connections close cleanly and that delayed or reordered packets are 2439 properly discarded. These states SHOULD persist for at least three 2440 times the current Probe Timeout (PTO) interval as defined in 2441 [QUIC-RECOVERY]. 2443 An endpoint enters a closing period after initiating an immediate 2444 close (Section 10.3). While closing, an endpoint MUST NOT send 2445 packets unless they contain a CONNECTION_CLOSE frame (see 2446 Section 10.3 for details). An endpoint retains only enough 2447 information to generate a packet containing a CONNECTION_CLOSE frame 2448 and to identify packets as belonging to the connection. The 2449 endpoint's selected connection ID and the QUIC version are sufficient 2450 information to identify packets for a closing connection; an endpoint 2451 can discard all other connection state. An endpoint MAY retain 2452 packet protection keys for incoming packets to allow it to read and 2453 process a CONNECTION_CLOSE frame. 2455 The draining state is entered once an endpoint receives a signal that 2456 its peer is closing or draining. While otherwise identical to the 2457 closing state, an endpoint in the draining state MUST NOT send any 2458 packets. Retaining packet protection keys is unnecessary once a 2459 connection is in the draining state. 2461 An endpoint MAY transition from the closing period to the draining 2462 period if it receives a CONNECTION_CLOSE frame or stateless reset, 2463 both of which indicate that the peer is also closing or draining. 2464 The draining period SHOULD end when the closing period would have 2465 ended. In other words, the endpoint can use the same end time, but 2466 cease retransmission of the closing packet. 2468 Disposing of connection state prior to the end of the closing or 2469 draining period could cause delayed or reordered packets to generate 2470 an unnecessary stateless reset. Endpoints that have some alternative 2471 means to ensure that late-arriving packets on the connection do not 2472 induce a response, such as those that are able to close the UDP 2473 socket, MAY use an abbreviated draining period which can allow for 2474 faster resource recovery. Servers that retain an open socket for 2475 accepting new connections SHOULD NOT exit the closing or draining 2476 period early. 2478 Once the closing or draining period has ended, an endpoint SHOULD 2479 discard all connection state. This results in new packets on the 2480 connection being handled generically. For instance, an endpoint MAY 2481 send a stateless reset in response to any further incoming packets. 2483 The draining and closing periods do not apply when a stateless reset 2484 (Section 10.4) is sent. 2486 An endpoint is not expected to handle key updates when it is closing 2487 or draining. A key update might prevent the endpoint from moving 2488 from the closing state to draining, but it otherwise has no impact. 2490 While in the closing period, an endpoint could receive packets from a 2491 new source address, indicating a connection migration (Section 9). 2492 An endpoint in the closing state MUST strictly limit the number of 2493 packets it sends to this new address until the address is validated 2494 (see Section 8.2). A server in the closing state MAY instead choose 2495 to discard packets received from a new source address. 2497 10.2. Idle Timeout 2499 If the idle timeout is enabled, a connection is silently closed and 2500 the state is discarded when it remains idle for longer than both the 2501 advertised idle timeout (see Section 18.1) and three times the 2502 current Probe Timeout (PTO). 2504 Each endpoint advertises its own idle timeout to its peer. An 2505 endpoint restarts any timer it maintains when a packet from its peer 2506 is received and processed successfully. The timer is also restarted 2507 when sending a packet containing frames other than ACK or PADDING (an 2508 ACK-eliciting packet; see [QUIC-RECOVERY]), but only if no other ACK- 2509 eliciting packets have been sent since last receiving a packet. 2510 Restarting when sending packets ensures that connections do not 2511 prematurely time out when initiating new activity. 2513 The value for an idle timeout can be asymmetric. The value 2514 advertised by an endpoint is only used to determine whether the 2515 connection is live at that endpoint. An endpoint that sends packets 2516 near the end of the idle timeout period of a peer risks having those 2517 packets discarded if its peer enters the draining state before the 2518 packets arrive. If a peer could timeout within a Probe Timeout (PTO; 2519 see Section 6.3 of [QUIC-RECOVERY]), it is advisable to test for 2520 liveness before sending any data that cannot be retried safely. Note 2521 that it is likely that only applications or application protocols 2522 will know what information can be retried. 2524 10.3. Immediate Close 2526 An endpoint sends a CONNECTION_CLOSE frame (Section 19.19) to 2527 terminate the connection immediately. A CONNECTION_CLOSE frame 2528 causes all streams to immediately become closed; open streams can be 2529 assumed to be implicitly reset. 2531 After sending a CONNECTION_CLOSE frame, endpoints immediately enter 2532 the closing state. During the closing period, an endpoint that sends 2533 a CONNECTION_CLOSE frame SHOULD respond to any packet that it 2534 receives with another packet containing a CONNECTION_CLOSE frame. To 2535 minimize the state that an endpoint maintains for a closing 2536 connection, endpoints MAY send the exact same packet. However, 2537 endpoints SHOULD limit the number of packets they generate containing 2538 a CONNECTION_CLOSE frame. For instance, an endpoint could 2539 progressively increase the number of packets that it receives before 2540 sending additional packets or increase the time between packets. 2542 Note: Allowing retransmission of a closing packet contradicts other 2543 advice in this document that recommends the creation of new packet 2544 numbers for every packet. Sending new packet numbers is primarily 2545 of advantage to loss recovery and congestion control, which are 2546 not expected to be relevant for a closed connection. 2547 Retransmitting the final packet requires less state. 2549 New packets from unverified addresses could be used to create an 2550 amplification attack (see Section 8). To avoid this, endpoints MUST 2551 either limit transmission of CONNECTION_CLOSE frames to validated 2552 addresses or drop packets without response if the response would be 2553 more than three times larger than the received packet. 2555 After receiving a CONNECTION_CLOSE frame, endpoints enter the 2556 draining state. An endpoint that receives a CONNECTION_CLOSE frame 2557 MAY send a single packet containing a CONNECTION_CLOSE frame before 2558 entering the draining state, using a CONNECTION_CLOSE frame and a 2559 NO_ERROR code if appropriate. An endpoint MUST NOT send further 2560 packets, which could result in a constant exchange of 2561 CONNECTION_CLOSE frames until the closing period on either peer 2562 ended. 2564 An immediate close can be used after an application protocol has 2565 arranged to close a connection. This might be after the application 2566 protocols negotiates a graceful shutdown. The application protocol 2567 exchanges whatever messages that are needed to cause both endpoints 2568 to agree to close the connection, after which the application 2569 requests that the connection be closed. The application protocol can 2570 use a CONNECTION_CLOSE frame with an appropriate error code to signal 2571 closure. 2573 When sending CONNECTION_CLOSE, the goal is to ensure that the peer 2574 will process the frame. Generally, this means sending the frame in a 2575 packet with the highest level of packet protection to avoid the 2576 packet being discarded. However, during the handshake, it is 2577 possible that more advanced packet protection keys are not available 2578 to the peer, so the frame MAY be replicated in a packet that uses a 2579 lower packet protection level. 2581 After the handshake is confirmed, an endpoint MUST send any 2582 CONNECTION_CLOSE frames in a 1-RTT packet. Prior to handshake 2583 confirmation, the peer might not have 1-RTT keys, so the endpoint 2584 SHOULD send CONNECTION_CLOSE frames in a Handshake packet. If the 2585 endpoint does not have Handshake keys, it SHOULD send 2586 CONNECTION_CLOSE frames in an Initial packet. 2588 A client will always know whether the server has Handshake keys (see 2589 Section 17.2.2.1), but it is possible that a server does not know 2590 whether the client has Handshake keys. Under these circumstances, a 2591 server SHOULD send a CONNECTION_CLOSE frame in both Handshake and 2592 Initial packets to ensure that at least one of them is processable by 2593 the client. These packets can be coalesced into a single UDP 2594 datagram (see Section 12.2). 2596 10.4. Stateless Reset 2598 A stateless reset is provided as an option of last resort for an 2599 endpoint that does not have access to the state of a connection. A 2600 crash or outage might result in peers continuing to send data to an 2601 endpoint that is unable to properly continue the connection. An 2602 endpoint MAY send a stateless reset in response to receiving a packet 2603 that it cannot associate with an active connection. 2605 A stateless reset is not appropriate for signaling error conditions. 2606 An endpoint that wishes to communicate a fatal connection error MUST 2607 use a CONNECTION_CLOSE frame if it has sufficient state to do so. 2609 To support this process, a token is sent by endpoints. The token is 2610 carried in the NEW_CONNECTION_ID frame sent by either peer, and 2611 servers can specify the stateless_reset_token transport parameter 2612 during the handshake (clients cannot because their transport 2613 parameters don't have confidentiality protection). This value is 2614 protected by encryption, so only client and server know this value. 2615 Tokens are invalidated when their associated connection ID is retired 2616 via a RETIRE_CONNECTION_ID frame (Section 19.16). 2618 An endpoint that receives packets that it cannot process sends a 2619 packet in the following layout: 2621 0 1 2 3 2622 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 2623 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2624 |0|1| Unpredictable Bits (182..) ... 2625 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2626 | | 2627 + + 2628 | | 2629 + Stateless Reset Token (128) + 2630 | | 2631 + + 2632 | | 2633 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2635 Figure 6: Stateless Reset Packet 2637 This design ensures that a stateless reset packet is - to the extent 2638 possible - indistinguishable from a regular packet with a short 2639 header. 2641 A stateless reset uses an entire UDP datagram, starting with the 2642 first two bits of the packet header. The remainder of the first byte 2643 and an arbitrary number of bytes following it that are set to 2644 unpredictable values. The last 16 bytes of the datagram contain a 2645 Stateless Reset Token. 2647 To entities other than its intended recipient, a stateless reset will 2648 appear to be a packet with a short header. For the packet to appear 2649 as valid, the Unpredictable Bits field needs to include at least 182 2650 bits of data (or 23 bytes, less the two fixed bits). This is 2651 intended to allow for a Destination Connection ID of the maximum 2652 length permitted, with a minimal packet number, and payload. The 2653 Stateless Reset Token corresponds to the minimum expansion of the 2654 packet protection AEAD. More unpredictable bytes might be necessary 2655 if the endpoint could have negotiated a packet protection scheme with 2656 a larger minimum AEAD expansion. 2658 An endpoint SHOULD NOT send a stateless reset that is significantly 2659 larger than the packet it receives. Endpoints MUST discard packets 2660 that are too small to be valid QUIC packets. With the set of AEAD 2661 functions defined in [QUIC-TLS], packets that are smaller than 21 2662 bytes are never valid. 2664 Endpoints MUST send stateless reset packets formatted as a packet 2665 with a short header. However, endpoints MUST treat any packet ending 2666 in a valid stateless reset token as a stateless reset, as other QUIC 2667 versions might allow the use of a long header. 2669 An endpoint MAY send a stateless reset in response to a packet with a 2670 long header. Sending a stateless reset is not effective prior to the 2671 stateless reset token being available to a peer. In this QUIC 2672 version, packets with a long header are only used during connection 2673 establishment. Because the stateless reset token is not available 2674 until connection establishment is complete or near completion, 2675 ignoring an unknown packet with a long header might be as effective 2676 as sending a stateless reset. 2678 An endpoint cannot determine the Source Connection ID from a packet 2679 with a short header, therefore it cannot set the Destination 2680 Connection ID in the stateless reset packet. The Destination 2681 Connection ID will therefore differ from the value used in previous 2682 packets. A random Destination Connection ID makes the connection ID 2683 appear to be the result of moving to a new connection ID that was 2684 provided using a NEW_CONNECTION_ID frame (Section 19.15). 2686 Using a randomized connection ID results in two problems: 2688 o The packet might not reach the peer. If the Destination 2689 Connection ID is critical for routing toward the peer, then this 2690 packet could be incorrectly routed. This might also trigger 2691 another Stateless Reset in response; see Section 10.4.3. A 2692 Stateless Reset that is not correctly routed is an ineffective 2693 error detection and recovery mechanism. In this case, endpoints 2694 will need to rely on other methods - such as timers - to detect 2695 that the connection has failed. 2697 o The randomly generated connection ID can be used by entities other 2698 than the peer to identify this as a potential stateless reset. An 2699 endpoint that occasionally uses different connection IDs might 2700 introduce some uncertainty about this. 2702 Finally, the last 16 bytes of the packet are set to the value of the 2703 Stateless Reset Token. 2705 This stateless reset design is specific to QUIC version 1. An 2706 endpoint that supports multiple versions of QUIC needs to generate a 2707 stateless reset that will be accepted by peers that support any 2708 version that the endpoint might support (or might have supported 2709 prior to losing state). Designers of new versions of QUIC need to be 2710 aware of this and either reuse this design, or use a portion of the 2711 packet other than the last 16 bytes for carrying data. 2713 10.4.1. Detecting a Stateless Reset 2715 An endpoint detects a potential stateless reset when an incoming 2716 packet either cannot be associated with a connection, cannot be 2717 decrypted, or is marked as a duplicate packet. The endpoint MUST 2718 then compare the last 16 bytes of the packet with all Stateless Reset 2719 Tokens that are associated with connection IDs that the endpoint 2720 recently used to send packets from the IP address and port on which 2721 the datagram is received. This includes Stateless Reset Tokens from 2722 NEW_CONNECTION_ID frames and the server's transport parameters. An 2723 endpoint MUST NOT check for any Stateless Reset Tokens associated 2724 with connection IDs it has not used or for connection IDs that have 2725 been retired. 2727 If the last 16 bytes of the packet values are identical to a 2728 Stateless Reset Token, the endpoint MUST enter the draining period 2729 and not send any further packets on this connection. If the 2730 comparison fails, the packet can be discarded. 2732 10.4.2. Calculating a Stateless Reset Token 2734 The stateless reset token MUST be difficult to guess. In order to 2735 create a Stateless Reset Token, an endpoint could randomly generate 2736 [RFC4086] a secret for every connection that it creates. However, 2737 this presents a coordination problem when there are multiple 2738 instances in a cluster or a storage problem for an endpoint that 2739 might lose state. Stateless reset specifically exists to handle the 2740 case where state is lost, so this approach is suboptimal. 2742 A single static key can be used across all connections to the same 2743 endpoint by generating the proof using a second iteration of a 2744 preimage-resistant function that takes a static key and the 2745 connection ID chosen by the endpoint (see Section 5.1) as input. An 2746 endpoint could use HMAC [RFC2104] (for example, HMAC(static_key, 2747 connection_id)) or HKDF [RFC5869] (for example, using the static key 2748 as input keying material, with the connection ID as salt). The 2749 output of this function is truncated to 16 bytes to produce the 2750 Stateless Reset Token for that connection. 2752 An endpoint that loses state can use the same method to generate a 2753 valid Stateless Reset Token. The connection ID comes from the packet 2754 that the endpoint receives. 2756 This design relies on the peer always sending a connection ID in its 2757 packets so that the endpoint can use the connection ID from a packet 2758 to reset the connection. An endpoint that uses this design MUST 2759 either use the same connection ID length for all connections or 2760 encode the length of the connection ID such that it can be recovered 2761 without state. In addition, it cannot provide a zero-length 2762 connection ID. 2764 Revealing the Stateless Reset Token allows any entity to terminate 2765 the connection, so a value can only be used once. This method for 2766 choosing the Stateless Reset Token means that the combination of 2767 connection ID and static key MUST NOT be used for another connection. 2768 A denial of service attack is possible if the same connection ID is 2769 used by instances that share a static key, or if an attacker can 2770 cause a packet to be routed to an instance that has no state but the 2771 same static key; see Section 21.8. A connection ID from a connection 2772 that is reset by revealing the Stateless Reset Token MUST NOT be 2773 reused for new connections at nodes that share a static key. 2775 The same Stateless Reset Token MAY be used for multiple connection 2776 IDs on the same connection. However, reuse of a Stateless Reset 2777 Token might expose an endpoint to denial of service if associated 2778 connection IDs are forgotten while the associated token is still 2779 active at a peer. An endpoint MUST ensure that packets with 2780 Destination Connection ID field values that correspond to a reused 2781 Stateless Reset Token are attributed to the same connection as long 2782 as the Stateless Reset Token is still usable, even when the 2783 connection ID has been retired. Otherwise, an attacker might be able 2784 to send a packet with a retired connection ID and cause the endpoint 2785 to produce a Stateless Reset that it can use to disrupt the 2786 connection, just as with the attacks in Section 21.8. 2788 Note that Stateless Reset packets do not have any cryptographic 2789 protection. 2791 10.4.3. Looping 2793 The design of a Stateless Reset is such that without knowing the 2794 stateless reset token it is indistinguishable from a valid packet. 2795 For instance, if a server sends a Stateless Reset to another server 2796 it might receive another Stateless Reset in response, which could 2797 lead to an infinite exchange. 2799 An endpoint MUST ensure that every Stateless Reset that it sends is 2800 smaller than the packet which triggered it, unless it maintains state 2801 sufficient to prevent looping. In the event of a loop, this results 2802 in packets eventually being too small to trigger a response. 2804 An endpoint can remember the number of Stateless Reset packets that 2805 it has sent and stop generating new Stateless Reset packets once a 2806 limit is reached. Using separate limits for different remote 2807 addresses will ensure that Stateless Reset packets can be used to 2808 close connections when other peers or connections have exhausted 2809 limits. 2811 Reducing the size of a Stateless Reset below the recommended minimum 2812 size of 39 bytes could mean that the packet could reveal to an 2813 observer that it is a Stateless Reset. Conversely, refusing to send 2814 a Stateless Reset in response to a small packet might result in 2815 Stateless Reset not being useful in detecting cases of broken 2816 connections where only very small packets are sent; such failures 2817 might only be detected by other means, such as timers. 2819 An endpoint can increase the odds that a packet will trigger a 2820 Stateless Reset if it cannot be processed by padding it to at least 2821 40 bytes. 2823 11. Error Handling 2825 An endpoint that detects an error SHOULD signal the existence of that 2826 error to its peer. Both transport-level and application-level errors 2827 can affect an entire connection (see Section 11.1), while only 2828 application-level errors can be isolated to a single stream (see 2829 Section 11.2). 2831 The most appropriate error code (Section 20) SHOULD be included in 2832 the frame that signals the error. Where this specification 2833 identifies error conditions, it also identifies the error code that 2834 is used. 2836 A stateless reset (Section 10.4) is not suitable for any error that 2837 can be signaled with a CONNECTION_CLOSE or RESET_STREAM frame. A 2838 stateless reset MUST NOT be used by an endpoint that has the state 2839 necessary to send a frame on the connection. 2841 11.1. Connection Errors 2843 Errors that result in the connection being unusable, such as an 2844 obvious violation of protocol semantics or corruption of state that 2845 affects an entire connection, MUST be signaled using a 2846 CONNECTION_CLOSE frame (Section 19.19). An endpoint MAY close the 2847 connection in this manner even if the error only affects a single 2848 stream. 2850 Application protocols can signal application-specific protocol errors 2851 using the application-specific variant of the CONNECTION_CLOSE frame. 2852 Errors that are specific to the transport, including all those 2853 described in this document, are carried in the QUIC-specific variant 2854 of the CONNECTION_CLOSE frame. 2856 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 2857 endpoint SHOULD be prepared to retransmit a packet containing a 2858 CONNECTION_CLOSE frame if it receives more packets on a terminated 2859 connection. Limiting the number of retransmissions and the time over 2860 which this final packet is sent limits the effort expended on 2861 terminated connections. 2863 An endpoint that chooses not to retransmit packets containing a 2864 CONNECTION_CLOSE frame risks a peer missing the first such packet. 2865 The only mechanism available to an endpoint that continues to receive 2866 data for a terminated connection is to use the stateless reset 2867 process (Section 10.4). 2869 An endpoint that receives an invalid CONNECTION_CLOSE frame MUST NOT 2870 signal the existence of the error to its peer. 2872 11.2. Stream Errors 2874 If an application-level error affects a single stream, but otherwise 2875 leaves the connection in a recoverable state, the endpoint can send a 2876 RESET_STREAM frame (Section 19.4) with an appropriate error code to 2877 terminate just the affected stream. 2879 RESET_STREAM MUST be instigated by the protocol using QUIC, either 2880 directly or through the receipt of a STOP_SENDING frame from a peer. 2881 RESET_STREAM carries an application error code. Resetting a stream 2882 without knowledge of the application protocol could cause the 2883 protocol to enter an unrecoverable state. Application protocols 2884 might require certain streams to be reliably delivered in order to 2885 guarantee consistent state between endpoints. 2887 12. Packets and Frames 2889 QUIC endpoints communicate by exchanging packets. Packets have 2890 confidentiality and integrity protection (see Section 12.1) and are 2891 carried in UDP datagrams (see Section 12.2). 2893 This version of QUIC uses the long packet header (see Section 17.2) 2894 during connection establishment. Packets with the long header are 2895 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), Handshake 2896 (Section 17.2.4), and Retry (Section 17.2.5). Version negotiation 2897 uses a version-independent packet with a long header (see 2898 Section 17.2.1). 2900 Packets with the short header (Section 17.3) are designed for minimal 2901 overhead and are used after a connection is established and 1-RTT 2902 keys are available. 2904 12.1. Protected Packets 2906 All QUIC packets except Version Negotiation and Retry packets use 2907 authenticated encryption with additional data (AEAD) [RFC5116] to 2908 provide confidentiality and integrity protection. Details of packet 2909 protection are found in [QUIC-TLS]; this section includes an overview 2910 of the process. 2912 Initial packets are protected using keys that are statically derived. 2913 This packet protection is not effective confidentiality protection. 2914 Initial protection only exists to ensure that the sender of the 2915 packet is on the network path. Any entity that receives the Initial 2916 packet from a client can recover the keys necessary to remove packet 2917 protection or to generate packets that will be successfully 2918 authenticated. 2920 All other packets are protected with keys derived from the 2921 cryptographic handshake. The type of the packet from the long header 2922 or key phase from the short header are used to identify which 2923 encryption level - and therefore the keys - that are used. Packets 2924 protected with 0-RTT and 1-RTT keys are expected to have 2925 confidentiality and data origin authentication; the cryptographic 2926 handshake ensures that only the communicating endpoints receive the 2927 corresponding keys. 2929 The packet number field contains a packet number, which has 2930 additional confidentiality protection that is applied after packet 2931 protection is applied (see [QUIC-TLS] for details). The underlying 2932 packet number increases with each packet sent in a given packet 2933 number space; see Section 12.3 for details. 2935 12.2. Coalescing Packets 2937 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), and Handshake 2938 (Section 17.2.4) packets contain a Length field, which determines the 2939 end of the packet. The length includes both the Packet Number and 2940 Payload fields, both of which are confidentiality protected and 2941 initially of unknown length. The length of the Payload field is 2942 learned once header protection is removed. 2944 Using the Length field, a sender can coalesce multiple QUIC packets 2945 into one UDP datagram. This can reduce the number of UDP datagrams 2946 needed to complete the cryptographic handshake and start sending 2947 data. This can also be used to construct PMTU probes (see 2948 Section 14.3.1). Receivers MUST be able to process coalesced 2949 packets. 2951 Coalescing packets in order of increasing encryption levels (Initial, 2952 0-RTT, Handshake, 1-RTT) makes it more likely the receiver will be 2953 able to process all the packets in a single pass. A packet with a 2954 short header does not include a length, so it can only be the last 2955 packet included in a UDP datagram. An endpoint SHOULD NOT coalesce 2956 multiple packets at the same encryption level. 2958 Senders MUST NOT coalesce QUIC packets for different connections into 2959 a single UDP datagram. Receivers SHOULD ignore any subsequent 2960 packets with a different Destination Connection ID than the first 2961 packet in the datagram. 2963 Every QUIC packet that is coalesced into a single UDP datagram is 2964 separate and complete. Though the values of some fields in the 2965 packet header might be redundant, no fields are omitted. The 2966 receiver of coalesced QUIC packets MUST individually process each 2967 QUIC packet and separately acknowledge them, as if they were received 2968 as the payload of different UDP datagrams. For example, if 2969 decryption fails (because the keys are not available or any other 2970 reason), the receiver MAY either discard or buffer the packet for 2971 later processing and MUST attempt to process the remaining packets. 2973 Retry packets (Section 17.2.5), Version Negotiation packets 2974 (Section 17.2.1), and packets with a short header (Section 17.3) do 2975 not contain a Length field and so cannot be followed by other packets 2976 in the same UDP datagram. 2978 12.3. Packet Numbers 2980 The packet number is an integer in the range 0 to 2^62-1. This 2981 number is used in determining the cryptographic nonce for packet 2982 protection. Each endpoint maintains a separate packet number for 2983 sending and receiving. 2985 Packet numbers are limited to this range because they need to be 2986 representable in whole in the Largest Acknowledged field of an ACK 2987 frame (Section 19.3). When present in a long or short header 2988 however, packet numbers are reduced and encoded in 1 to 4 bytes (see 2989 Section 17.1). 2991 Version Negotiation (Section 17.2.1) and Retry (Section 17.2.5) 2992 packets do not include a packet number. 2994 Packet numbers are divided into 3 spaces in QUIC: 2996 o Initial space: All Initial packets (Section 17.2.2) are in this 2997 space. 2999 o Handshake space: All Handshake packets (Section 17.2.4) are in 3000 this space. 3002 o Application data space: All 0-RTT and 1-RTT encrypted packets 3003 (Section 12.1) are in this space. 3005 As described in [QUIC-TLS], each packet type uses different 3006 protection keys. 3008 Conceptually, a packet number space is the context in which a packet 3009 can be processed and acknowledged. Initial packets can only be sent 3010 with Initial packet protection keys and acknowledged in packets which 3011 are also Initial packets. Similarly, Handshake packets are sent at 3012 the Handshake encryption level and can only be acknowledged in 3013 Handshake packets. 3015 This enforces cryptographic separation between the data sent in the 3016 different packet sequence number spaces. Packet numbers in each 3017 space start at packet number 0. Subsequent packets sent in the same 3018 packet number space MUST increase the packet number by at least one. 3020 0-RTT and 1-RTT data exist in the same packet number space to make 3021 loss recovery algorithms easier to implement between the two packet 3022 types. 3024 A QUIC endpoint MUST NOT reuse a packet number within the same packet 3025 number space in one connection. If the packet number for sending 3026 reaches 2^62 - 1, the sender MUST close the connection without 3027 sending a CONNECTION_CLOSE frame or any further packets; an endpoint 3028 MAY send a Stateless Reset (Section 10.4) in response to further 3029 packets that it receives. 3031 A receiver MUST discard a newly unprotected packet unless it is 3032 certain that it has not processed another packet with the same packet 3033 number from the same packet number space. Duplicate suppression MUST 3034 happen after removing packet protection for the reasons described in 3035 Section 9.3 of [QUIC-TLS]. An efficient algorithm for duplicate 3036 suppression can be found in Section 3.4.3 of [RFC4303]. 3038 Packet number encoding at a sender and decoding at a receiver are 3039 described in Section 17.1. 3041 12.4. Frames and Frame Types 3043 The payload of QUIC packets, after removing packet protection, 3044 consists of a sequence of complete frames, as shown in Figure 7. 3045 Version Negotiation, Stateless Reset, and Retry packets do not 3046 contain frames. 3048 0 1 2 3 3049 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 3050 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3051 | Frame 1 (*) ... 3052 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3053 | Frame 2 (*) ... 3054 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3055 ... 3056 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3057 | Frame N (*) ... 3058 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3060 Figure 7: QUIC Payload 3062 The payload of a packet that contains frames MUST contain at least 3063 one frame, and MAY contain multiple frames and multiple frame types. 3064 Frames always fit within a single QUIC packet and cannot span 3065 multiple packets. 3067 Each frame begins with a Frame Type, indicating its type, followed by 3068 additional type-dependent fields: 3070 0 1 2 3 3071 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 3072 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3073 | Frame Type (i) ... 3074 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3075 | Type-Dependent Fields (*) ... 3076 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3078 Figure 8: Generic Frame Layout 3080 The frame types defined in this specification are listed in Table 3. 3081 The Frame Type in ACK, STREAM, MAX_STREAMS, STREAMS_BLOCKED, and 3082 CONNECTION_CLOSE frames is used to carry other frame-specific flags. 3083 For all other frames, the Frame Type field simply identifies the 3084 frame. These frames are explained in more detail in Section 19. 3086 +-------------+----------------------+---------------+ 3087 | Type Value | Frame Type Name | Definition | 3088 +-------------+----------------------+---------------+ 3089 | 0x00 | PADDING | Section 19.1 | 3090 | | | | 3091 | 0x01 | PING | Section 19.2 | 3092 | | | | 3093 | 0x02 - 0x03 | ACK | Section 19.3 | 3094 | | | | 3095 | 0x04 | RESET_STREAM | Section 19.4 | 3096 | | | | 3097 | 0x05 | STOP_SENDING | Section 19.5 | 3098 | | | | 3099 | 0x06 | CRYPTO | Section 19.6 | 3100 | | | | 3101 | 0x07 | NEW_TOKEN | Section 19.7 | 3102 | | | | 3103 | 0x08 - 0x0f | STREAM | Section 19.8 | 3104 | | | | 3105 | 0x10 | MAX_DATA | Section 19.9 | 3106 | | | | 3107 | 0x11 | MAX_STREAM_DATA | Section 19.10 | 3108 | | | | 3109 | 0x12 - 0x13 | MAX_STREAMS | Section 19.11 | 3110 | | | | 3111 | 0x14 | DATA_BLOCKED | Section 19.12 | 3112 | | | | 3113 | 0x15 | STREAM_DATA_BLOCKED | Section 19.13 | 3114 | | | | 3115 | 0x16 - 0x17 | STREAMS_BLOCKED | Section 19.14 | 3116 | | | | 3117 | 0x18 | NEW_CONNECTION_ID | Section 19.15 | 3118 | | | | 3119 | 0x19 | RETIRE_CONNECTION_ID | Section 19.16 | 3120 | | | | 3121 | 0x1a | PATH_CHALLENGE | Section 19.17 | 3122 | | | | 3123 | 0x1b | PATH_RESPONSE | Section 19.18 | 3124 | | | | 3125 | 0x1c - 0x1d | CONNECTION_CLOSE | Section 19.19 | 3126 +-------------+----------------------+---------------+ 3128 Table 3: Frame Types 3130 An endpoint MUST treat the receipt of a frame of unknown type as a 3131 connection error of type FRAME_ENCODING_ERROR. 3133 All QUIC frames are idempotent in this version of QUIC. That is, a 3134 valid frame does not cause undesirable side effects or errors when 3135 received more than once. 3137 The Frame Type field uses a variable length integer encoding (see 3138 Section 16) with one exception. To ensure simple and efficient 3139 implementations of frame parsing, a frame type MUST use the shortest 3140 possible encoding. Though a two-, four- or eight-byte encoding of 3141 the frame types defined in this document is possible, the Frame Type 3142 field for these frames is encoded on a single byte. For instance, 3143 though 0x4001 is a legitimate two-byte encoding for a variable-length 3144 integer with a value of 1, PING frames are always encoded as a single 3145 byte with the value 0x01. An endpoint MAY treat the receipt of a 3146 frame type that uses a longer encoding than necessary as a connection 3147 error of type PROTOCOL_VIOLATION. 3149 13. Packetization and Reliability 3151 A sender bundles one or more frames in a QUIC packet (see 3152 Section 12.4). 3154 A sender can minimize per-packet bandwidth and computational costs by 3155 bundling as many frames as possible within a QUIC packet. A sender 3156 MAY wait for a short period of time to bundle multiple frames before 3157 sending a packet that is not maximally packed, to avoid sending out 3158 large numbers of small packets. An implementation MAY use knowledge 3159 about application sending behavior or heuristics to determine whether 3160 and for how long to wait. This waiting period is an implementation 3161 decision, and an implementation should be careful to delay 3162 conservatively, since any delay is likely to increase application- 3163 visible latency. 3165 Stream multiplexing is achieved by interleaving STREAM frames from 3166 multiple streams into one or more QUIC packets. A single QUIC packet 3167 can include multiple STREAM frames from one or more streams. 3169 One of the benefits of QUIC is avoidance of head-of-line blocking 3170 across multiple streams. When a packet loss occurs, only streams 3171 with data in that packet are blocked waiting for a retransmission to 3172 be received, while other streams can continue making progress. Note 3173 that when data from multiple streams is bundled into a single QUIC 3174 packet, loss of that packet blocks all those streams from making 3175 progress. Implementations are advised to bundle as few streams as 3176 necessary in outgoing packets without losing transmission efficiency 3177 to underfilled packets. 3179 13.1. Packet Processing and Acknowledgment 3181 A packet MUST NOT be acknowledged until packet protection has been 3182 successfully removed and all frames contained in the packet have been 3183 processed. For STREAM frames, this means the data has been enqueued 3184 in preparation to be received by the application protocol, but it 3185 does not require that data is delivered and consumed. 3187 Once the packet has been fully processed, a receiver acknowledges 3188 receipt by sending one or more ACK frames containing the packet 3189 number of the received packet. 3191 13.1.1. Sending ACK Frames 3193 An endpoint sends ACK frames to acknowledge packets it has received 3194 and processed. 3196 Packets containing only ACK frames are not congestion controlled, so 3197 there are limits on how frequently they can be sent. An endpoint 3198 MUST NOT send more than one ACK-frame-only packet in response to 3199 receiving an ACK-eliciting packet (one containing frames other than 3200 ACK and/or PADDING). An endpoint MUST NOT send a packet containing 3201 only an ACK frame in response to a non-ACK-eliciting packet (one 3202 containing only ACK and/or PADDING frames), even if there are packet 3203 gaps which precede the received packet. Limiting ACK frames avoids 3204 an infinite feedback loop of acknowledgements, which could prevent 3205 the connection from ever becoming idle. However, the endpoint 3206 acknowledges non-ACK-eliciting packets when it sends an ACK frame. 3208 Packets containing PADDING frames are considered to be in flight for 3209 congestion control purposes [QUIC-RECOVERY]. Sending only PADDING 3210 frames might cause the sender to become limited by the congestion 3211 controller (as described in [QUIC-RECOVERY]) with no acknowledgments 3212 forthcoming from the receiver. Therefore, a sender SHOULD ensure 3213 that other frames are sent in addition to PADDING frames to elicit 3214 acknowledgments from the receiver. 3216 An endpoint that is only sending ACK frames will not receive 3217 acknowledgments from its peer unless those acknowledgements are 3218 included in packets with ACK-eliciting frames. An endpoint SHOULD 3219 bundle ACK frames with other frames when there are new ACK-eliciting 3220 packets to acknowledge. When only non-ACK-eliciting packets need to 3221 be acknowledged, an endpoint MAY wait until an ACK-eliciting packet 3222 has been received to bundle an ACK frame with outgoing frames. 3224 An endpoint SHOULD treat receipt of an acknowledgment for a packet it 3225 did not send as a connection error of type PROTOCOL_VIOLATION, if it 3226 is able to detect the condition. 3228 The receiver's delayed acknowledgment timer SHOULD NOT exceed the 3229 current RTT estimate or the value it indicates in the "max_ack_delay" 3230 transport parameter. This ensures an acknowledgment is sent at least 3231 once per RTT when packets needing acknowledgement are received. The 3232 sender can use the receiver's "max_ack_delay" value in determining 3233 timeouts for timer-based retransmission. 3235 Strategies and implications of the frequency of generating 3236 acknowledgments are discussed in more detail in [QUIC-RECOVERY]. 3238 13.1.2. Limiting ACK Ranges 3240 To limit ACK Ranges (see Section 19.3.1) to those that have not yet 3241 been received by the sender, the receiver SHOULD track which ACK 3242 frames have been acknowledged by its peer. The receiver SHOULD 3243 exclude already acknowledged packets from future ACK frames whenever 3244 these packets would unnecessarily contribute to the ACK frame size. 3245 When the receiver is only sending non-ACK-eliciting packets, it can 3246 bundle a PING or other small ACK-eliciting frame with a fraction of 3247 them, such as once per round trip, to enable dropping unnecessary ACK 3248 ranges and any state for previously sent packets. The receiver MUST 3249 NOT bundle an ACK-elicing frame, such as a PING, with all packets 3250 that would otherwise be non-ACK-eliciting, in order to avoid an 3251 infinite feedback loop of acknowledgements. 3253 To limit receiver state or the size of ACK frames, a receiver MAY 3254 limit the number of ACK Ranges it sends. A receiver can do this even 3255 without receiving acknowledgment of its ACK frames, with the 3256 knowledge this could cause the sender to unnecessarily retransmit 3257 some data. Standard QUIC algorithms ([QUIC-RECOVERY]) declare 3258 packets lost after sufficiently newer packets are acknowledged. 3259 Therefore, the receiver SHOULD repeatedly acknowledge newly received 3260 packets in preference to packets received in the past. 3262 13.1.3. ACK Frames and Packet Protection 3264 ACK frames MUST only be carried in a packet that has the same packet 3265 number space as the packet being ACKed (see Section 12.1). For 3266 instance, packets that are protected with 1-RTT keys MUST be 3267 acknowledged in packets that are also protected with 1-RTT keys. 3269 Packets that a client sends with 0-RTT packet protection MUST be 3270 acknowledged by the server in packets protected by 1-RTT keys. This 3271 can mean that the client is unable to use these acknowledgments if 3272 the server cryptographic handshake messages are delayed or lost. 3273 Note that the same limitation applies to other data sent by the 3274 server protected by the 1-RTT keys. 3276 Endpoints SHOULD send acknowledgments for packets containing CRYPTO 3277 frames with a reduced delay; see Section 6.2 of [QUIC-RECOVERY]. 3279 13.2. Retransmission of Information 3281 QUIC packets that are determined to be lost are not retransmitted 3282 whole. The same applies to the frames that are contained within lost 3283 packets. Instead, the information that might be carried in frames is 3284 sent again in new frames as needed. 3286 New frames and packets are used to carry information that is 3287 determined to have been lost. In general, information is sent again 3288 when a packet containing that information is determined to be lost 3289 and sending ceases when a packet containing that information is 3290 acknowledged. 3292 o Data sent in CRYPTO frames is retransmitted according to the rules 3293 in [QUIC-RECOVERY], until all data has been acknowledged. Data in 3294 CRYPTO frames for Initial and Handshake packets is discarded when 3295 keys for the corresponding encryption level are discarded. 3297 o Application data sent in STREAM frames is retransmitted in new 3298 STREAM frames unless the endpoint has sent a RESET_STREAM for that 3299 stream. Once an endpoint sends a RESET_STREAM frame, no further 3300 STREAM frames are needed. 3302 o The most recent set of acknowledgments are sent in ACK frames. An 3303 ACK frame SHOULD contain all unacknowledged acknowledgments, as 3304 described in Section 13.1.1. 3306 o Cancellation of stream transmission, as carried in a RESET_STREAM 3307 frame, is sent until acknowledged or until all stream data is 3308 acknowledged by the peer (that is, either the "Reset Recvd" or 3309 "Data Recvd" state is reached on the sending part of the stream). 3310 The content of a RESET_STREAM frame MUST NOT change when it is 3311 sent again. 3313 o Similarly, a request to cancel stream transmission, as encoded in 3314 a STOP_SENDING frame, is sent until the receiving part of the 3315 stream enters either a "Data Recvd" or "Reset Recvd" state; see 3316 Section 3.5. 3318 o Connection close signals, including packets that contain 3319 CONNECTION_CLOSE frames, are not sent again when packet loss is 3320 detected, but as described in Section 10. 3322 o The current connection maximum data is sent in MAX_DATA frames. 3323 An updated value is sent in a MAX_DATA frame if the packet 3324 containing the most recently sent MAX_DATA frame is declared lost, 3325 or when the endpoint decides to update the limit. Care is 3326 necessary to avoid sending this frame too often as the limit can 3327 increase frequently and cause an unnecessarily large number of 3328 MAX_DATA frames to be sent. 3330 o The current maximum stream data offset is sent in MAX_STREAM_DATA 3331 frames. Like MAX_DATA, an updated value is sent when the packet 3332 containing the most recent MAX_STREAM_DATA frame for a stream is 3333 lost or when the limit is updated, with care taken to prevent the 3334 frame from being sent too often. An endpoint SHOULD stop sending 3335 MAX_STREAM_DATA frames when the receiving part of the stream 3336 enters a "Size Known" state. 3338 o The limit on streams of a given type is sent in MAX_STREAMS 3339 frames. Like MAX_DATA, an updated value is sent when a packet 3340 containing the most recent MAX_STREAMS for a stream type frame is 3341 declared lost or when the limit is updated, with care taken to 3342 prevent the frame from being sent too often. 3344 o Blocked signals are carried in DATA_BLOCKED, STREAM_DATA_BLOCKED, 3345 and STREAMS_BLOCKED frames. DATA_BLOCKED frames have connection 3346 scope, STREAM_DATA_BLOCKED frames have stream scope, and 3347 STREAMS_BLOCKED frames are scoped to a specific stream type. New 3348 frames are sent if packets containing the most recent frame for a 3349 scope is lost, but only while the endpoint is blocked on the 3350 corresponding limit. These frames always include the limit that 3351 is causing blocking at the time that they are transmitted. 3353 o A liveness or path validation check using PATH_CHALLENGE frames is 3354 sent periodically until a matching PATH_RESPONSE frame is received 3355 or until there is no remaining need for liveness or path 3356 validation checking. PATH_CHALLENGE frames include a different 3357 payload each time they are sent. 3359 o Responses to path validation using PATH_RESPONSE frames are sent 3360 just once. The peer is expected to send more PATH_CHALLENGE 3361 frames as necessary to evoke additional PATH_RESPONSE frames. 3363 o New connection IDs are sent in NEW_CONNECTION_ID frames and 3364 retransmitted if the packet containing them is lost. 3365 Retransmissions of this frame carry the same sequence number 3366 value. Likewise, retired connection IDs are sent in 3367 RETIRE_CONNECTION_ID frames and retransmitted if the packet 3368 containing them is lost. 3370 o PING and PADDING frames contain no information, so lost PING or 3371 PADDING frames do not require repair. 3373 Endpoints SHOULD prioritize retransmission of data over sending new 3374 data, unless priorities specified by the application indicate 3375 otherwise (see Section 2.3). 3377 Even though a sender is encouraged to assemble frames containing up- 3378 to-date information every time it sends a packet, it is not forbidden 3379 to retransmit copies of frames from lost packets. A receiver MUST 3380 accept packets containing an outdated frame, such as a MAX_DATA frame 3381 carrying a smaller maximum data than one found in an older packet. 3383 Upon detecting losses, a sender MUST take appropriate congestion 3384 control action. The details of loss detection and congestion control 3385 are described in [QUIC-RECOVERY]. 3387 13.3. Explicit Congestion Notification 3389 QUIC endpoints can use Explicit Congestion Notification (ECN) 3390 [RFC3168] to detect and respond to network congestion. ECN allows a 3391 network node to indicate congestion in the network by setting a 3392 codepoint in the IP header of a packet instead of dropping it. 3393 Endpoints react to congestion by reducing their sending rate in 3394 response, as described in [QUIC-RECOVERY]. 3396 To use ECN, QUIC endpoints first determine whether a path supports 3397 ECN marking and the peer is able to access the ECN codepoint in the 3398 IP header. A network path does not support ECN if ECN marked packets 3399 get dropped or ECN markings are rewritten on the path. An endpoint 3400 verifies the path, both during connection establishment and when 3401 migrating to a new path (see Section 9). 3403 13.3.1. ECN Counts 3405 On receiving a QUIC packet with an ECT or CE codepoint, an ECN- 3406 enabled endpoint that can access the ECN codepoints from the 3407 enclosing IP packet increases the corresponding ECT(0), ECT(1), or CE 3408 count, and includes these counts in subsequent ACK frames (see 3409 Section 13.1 and Section 19.3). Note that this requires being able 3410 to read the ECN codepoints from the enclosing IP packet, which is not 3411 possible on all platforms. 3413 A packet detected by a receiver as a duplicate does not affect the 3414 receiver's local ECN codepoint counts; see (Section 21.7) for 3415 relevant security concerns. 3417 If an endpoint receives a QUIC packet without an ECT or CE codepoint 3418 in the IP packet header, it responds per Section 13.1 with an ACK 3419 frame without increasing any ECN counts. If an endpoint does not 3420 implement ECN support or does not have access to received ECN 3421 codepoints, it does not increase ECN counts. 3423 Coalesced packets (see Section 12.2) mean that several packets can 3424 share the same IP header. The ECN counter for the ECN codepoint 3425 received in the associated IP header are incremented once for each 3426 QUIC packet, not per enclosing IP packet or UDP datagram. 3428 Each packet number space maintains separate acknowledgement state and 3429 separate ECN counts. For example, if one each of an Initial, 0-RTT, 3430 Handshake, and 1-RTT QUIC packet are coalesced, the corresponding 3431 counts for the Initial and Handshake packet number space will be 3432 incremented by one and the counts for the 1-RTT packet number space 3433 will be increased by two. 3435 13.3.2. ECN Verification 3437 Each endpoint independently verifies and enables use of ECN by 3438 setting the IP header ECN codepoint to ECN Capable Transport (ECT) 3439 for the path from it to the other peer. Even if not setting ECN 3440 codepoints on packets it transmits, the endpoint SHOULD provide 3441 feedback about ECN markings received (if accessible). 3443 To verify both that a path supports ECN and the peer can provide ECN 3444 feedback, an endpoint sets the ECT(0) codepoint in the IP header of 3445 all outgoing packets [RFC8311]. 3447 If an ECT codepoint set in the IP header is not corrupted by a 3448 network device, then a received packet contains either the codepoint 3449 sent by the peer or the Congestion Experienced (CE) codepoint set by 3450 a network device that is experiencing congestion. 3452 If a QUIC packet sent with an ECT codepoint is newly acknowledged by 3453 the peer in an ACK frame without ECN feedback, the endpoint stops 3454 setting ECT codepoints in subsequent IP packets, with the expectation 3455 that either the network path or the peer no longer supports ECN. 3457 Network devices that corrupt or apply non-standard ECN markings might 3458 result in reduced throughput or other undesirable side-effects. To 3459 reduce this risk, an endpoint uses the following steps to verify the 3460 counts it receives in an ACK frame. 3462 o The total increase in ECT(0), ECT(1), and CE counts MUST be no 3463 smaller than the total number of QUIC packets sent with an ECT 3464 codepoint that are newly acknowledged in this ACK frame. This 3465 step detects any network remarking from ECT(0), ECT(1), or CE 3466 codepoints to Not-ECT. 3468 o Any increase in either ECT(0) or ECT(1) counts, plus any increase 3469 in the CE count, MUST be no smaller than the number of packets 3470 sent with the corresponding ECT codepoint that are newly 3471 acknowledged in this ACK frame. This step detects any erroneous 3472 network remarking from ECT(0) to ECT(1) (or vice versa). 3474 An endpoint could miss acknowledgements for a packet when ACK frames 3475 are lost. It is therefore possible for the total increase in ECT(0), 3476 ECT(1), and CE counts to be greater than the number of packets 3477 acknowledged in an ACK frame. When this happens, and if verification 3478 succeeds, the local reference counts MUST be increased to match the 3479 counts in the ACK frame. 3481 Processing counts out of order can result in verification failure. 3482 An endpoint SHOULD NOT perform this verification if the ACK frame is 3483 received in a packet with packet number lower than a previously 3484 received ACK frame. Verifying based on ACK frames that arrive out of 3485 order can result in disabling ECN unnecessarily. 3487 Upon successful verification, an endpoint continues to set ECT 3488 codepoints in subsequent packets with the expectation that the path 3489 is ECN-capable. 3491 If verification fails, then the endpoint ceases setting ECT 3492 codepoints in subsequent IP packets with the expectation that either 3493 the network path or the peer does not support ECN. 3495 If an endpoint sets ECT codepoints on outgoing IP packets and 3496 encounters a retransmission timeout due to the absence of 3497 acknowledgments from the peer (see [QUIC-RECOVERY]), or if an 3498 endpoint has reason to believe that an element on the network path 3499 might be corrupting ECN codepoints, the endpoint MAY cease setting 3500 ECT codepoints in subsequent packets. Doing so allows the connection 3501 to be resilient to network elements that corrupt ECN codepoints in 3502 the IP header or drop packets with ECT or CE codepoints in the IP 3503 header. 3505 14. Packet Size 3507 The QUIC packet size includes the QUIC header and protected payload, 3508 but not the UDP or IP header. 3510 Clients MUST ensure they send the first Initial packet in a single IP 3511 packet. Similarly, the first Initial packet sent after receiving a 3512 Retry packet MUST be sent in a single IP packet. 3514 The payload of a UDP datagram carrying the first Initial packet MUST 3515 be expanded to at least 1200 bytes, by adding PADDING frames to the 3516 Initial packet and/or by coalescing the Initial packet (see 3517 Section 12.2). Sending a UDP datagram of this size ensures that the 3518 network path supports a reasonable Maximum Transmission Unit (MTU), 3519 and helps reduce the amplitude of amplification attacks caused by 3520 server responses toward an unverified client address; see Section 8. 3522 The datagram containing the first Initial packet from a client MAY 3523 exceed 1200 bytes if the client believes that the Path Maximum 3524 Transmission Unit (PMTU) supports the size that it chooses. 3526 A server MAY send a CONNECTION_CLOSE frame with error code 3527 PROTOCOL_VIOLATION in response to the first Initial packet it 3528 receives from a client if the UDP datagram is smaller than 1200 3529 bytes. It MUST NOT send any other frame type in response, or 3530 otherwise behave as if any part of the offending packet was processed 3531 as valid. 3533 The server MUST also limit the number of bytes it sends before 3534 validating the address of the client; see Section 8. 3536 14.1. Path Maximum Transmission Unit (PMTU) 3538 The PMTU is the maximum size of the entire IP packet including the IP 3539 header, UDP header, and UDP payload. The UDP payload includes the 3540 QUIC packet header, protected payload, and any authentication fields. 3541 The PMTU can depend upon the current path characteristics. 3542 Therefore, the current largest UDP payload an implementation will 3543 send is referred to as the QUIC maximum packet size. 3545 QUIC depends on a PMTU of at least 1280 bytes. This is the IPv6 3546 minimum size [RFC8200] and is also supported by most modern IPv4 3547 networks. All QUIC packets (except for PMTU probe packets) SHOULD be 3548 sized to fit within the maximum packet size to avoid the packet being 3549 fragmented or dropped [RFC8085]. 3551 An endpoint SHOULD use Datagram Packetization Layer PMTU Discovery 3552 ([DPLPMTUD]) or implement Path MTU Discovery (PMTUD) [RFC1191] 3553 [RFC8201] to determine whether the path to a destination will support 3554 a desired message size without fragmentation. 3556 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 3557 packets larger than 1280 bytes. Assuming the minimum IP header size, 3558 this results in a QUIC maximum packet size of 1232 bytes for IPv6 and 3559 1252 bytes for IPv4. A QUIC implementation MAY be more conservative 3560 in computing the QUIC maximum packet size to allow for unknown tunnel 3561 overheads or IP header options/extensions. 3563 Each pair of local and remote addresses could have a different PMTU. 3564 QUIC implementations that implement any kind of PMTU discovery 3565 therefore SHOULD maintain a maximum packet size for each combination 3566 of local and remote IP addresses. 3568 If a QUIC endpoint determines that the PMTU between any pair of local 3569 and remote IP addresses has fallen below the size needed to support 3570 the smallest allowed maximum packet size, it MUST immediately cease 3571 sending QUIC packets, except for PMTU probe packets, on the affected 3572 path. An endpoint MAY terminate the connection if an alternative 3573 path cannot be found. 3575 14.2. ICMP Packet Too Big Messages 3577 PMTU discovery [RFC1191] [RFC8201] relies on reception of ICMP 3578 messages (e.g., IPv6 Packet Too Big messages) that indicate when a 3579 packet is dropped because it is larger than the local router MTU. 3580 DPLPMTUD can also optionally use these messages. This use of ICMP 3581 messages is potentially vulnerable to off-path attacks that 3582 successfully guess the addresses used on the path and reduce the PMTU 3583 to a bandwidth-inefficient value. 3585 An endpoint MUST ignore an ICMP message that claims the PMTU has 3586 decreased below 1280 bytes. 3588 The requirements for generating ICMP ([RFC1812], [RFC4443]) state 3589 that the quoted packet should contain as much of the original packet 3590 as possible without exceeding the minimum MTU for the IP version. 3591 The size of the quoted packet can actually be smaller, or the 3592 information unintelligible, as described in Section 1.1 of 3593 [DPLPMTUD]. 3595 QUIC endpoints SHOULD validate ICMP messages to protect from off-path 3596 injection as specified in [RFC8201] and Section 5.2 of [RFC8085]. 3597 This validation SHOULD use the quoted packet supplied in the payload 3598 of an ICMP message to associate the message with a corresponding 3599 transport connection [DPLPMTUD]. 3601 ICMP message validation MUST include matching IP addresses and UDP 3602 ports [RFC8085] and, when possible, connection IDs to an active QUIC 3603 session. 3605 Further validation can also be provided: 3607 o An IPv4 endpoint could set the Don't Fragment (DF) bit on a small 3608 proportion of packets, so that most invalid ICMP messages arrive 3609 when there are no DF packets outstanding, and can therefore be 3610 identified as spurious. 3612 o An endpoint could store additional information from the IP or UDP 3613 headers to use for validation (for example, the IP ID or UDP 3614 checksum). 3616 The endpoint SHOULD ignore all ICMP messages that fail validation. 3618 An endpoint MUST NOT increase PMTU based on ICMP messages. Any 3619 reduction in the QUIC maximum packet size MAY be provisional until 3620 QUIC's loss detection algorithm determines that the quoted packet has 3621 actually been lost. 3623 14.3. Datagram Packetization Layer PMTU Discovery 3625 Section 6.4 of [DPLPMTUD] provides considerations for implementing 3626 Datagram Packetization Layer PMTUD (DPLPMTUD) with QUIC. 3628 When implementing the algorithm in Section 5.3 of [DPLPMTUD], the 3629 initial value of BASE_PMTU SHOULD be consistent with the minimum QUIC 3630 packet size (1232 bytes for IPv6 and 1252 bytes for IPv4). 3632 PING and PADDING frames can be used to generate PMTU probe packets. 3633 These frames might not be retransmitted if a probe packet containing 3634 them is lost. However, these frames do consume congestion window, 3635 which could delay the transmission of subsequent application data. 3637 A PING frame can be included in a PMTU probe to ensure that a valid 3638 probe is acknowledged. 3640 The considerations for processing ICMP messages in the previous 3641 section also apply if these messages are used by DPLPMTUD. 3643 14.3.1. PMTU Probes Containing Source Connection ID 3645 Endpoints that rely on the destination connection ID for routing QUIC 3646 packets are likely to require that the connection ID be included in 3647 PMTU probe packets to route any resulting ICMP messages 3648 (Section 14.2) back to the correct endpoint. However, only long 3649 header packets (Section 17.2) contain source connection IDs, and long 3650 header packets are not decrypted or acknowledged by the peer once the 3651 handshake is complete. One way to construct a PMTU probe is to 3652 coalesce (see Section 12.2) a Handshake packet (Section 17.2.4) with 3653 a short header packet in a single UDP datagram. If the UDP datagram 3654 reaches the endpoint, the Handshake packet will be ignored, but the 3655 short header packet will be acknowledged. If the UDP datagram 3656 elicits an ICMP message, that message will likely contain the source 3657 connection ID within the quoted portion of the UDP datagram. 3659 15. Versions 3661 QUIC versions are identified using a 32-bit unsigned number. 3663 The version 0x00000000 is reserved to represent version negotiation. 3664 This version of the specification is identified by the number 3665 0x00000001. 3667 Other versions of QUIC might have different properties to this 3668 version. The properties of QUIC that are guaranteed to be consistent 3669 across all versions of the protocol are described in 3670 [QUIC-INVARIANTS]. 3672 Version 0x00000001 of QUIC uses TLS as a cryptographic handshake 3673 protocol, as described in [QUIC-TLS]. 3675 Versions with the most significant 16 bits of the version number 3676 cleared are reserved for use in future IETF consensus documents. 3678 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 3679 forcing version negotiation to be exercised. That is, any version 3680 number where the low four bits of all bytes is 1010 (in binary). A 3681 client or server MAY advertise support for any of these reserved 3682 versions. 3684 Reserved version numbers will probably never represent a real 3685 protocol; a client MAY use one of these version numbers with the 3686 expectation that the server will initiate version negotiation; a 3687 server MAY advertise support for one of these versions and can expect 3688 that clients ignore the value. 3690 [[RFC editor: please remove the remainder of this section before 3691 publication.]] 3693 The version number for the final version of this specification 3694 (0x00000001), is reserved for the version of the protocol that is 3695 published as an RFC. 3697 Version numbers used to identify IETF drafts are created by adding 3698 the draft number to 0xff000000. For example, draft-ietf-quic- 3699 transport-13 would be identified as 0xff00000D. 3701 Implementors are encouraged to register version numbers of QUIC that 3702 they are using for private experimentation on the GitHub wiki at 3703 . 3705 16. Variable-Length Integer Encoding 3707 QUIC packets and frames commonly use a variable-length encoding for 3708 non-negative integer values. This encoding ensures that smaller 3709 integer values need fewer bytes to encode. 3711 The QUIC variable-length integer encoding reserves the two most 3712 significant bits of the first byte to encode the base 2 logarithm of 3713 the integer encoding length in bytes. The integer value is encoded 3714 on the remaining bits, in network byte order. 3716 This means that integers are encoded on 1, 2, 4, or 8 bytes and can 3717 encode 6, 14, 30, or 62 bit values respectively. Table 4 summarizes 3718 the encoding properties. 3720 +------+--------+-------------+-----------------------+ 3721 | 2Bit | Length | Usable Bits | Range | 3722 +------+--------+-------------+-----------------------+ 3723 | 00 | 1 | 6 | 0-63 | 3724 | | | | | 3725 | 01 | 2 | 14 | 0-16383 | 3726 | | | | | 3727 | 10 | 4 | 30 | 0-1073741823 | 3728 | | | | | 3729 | 11 | 8 | 62 | 0-4611686018427387903 | 3730 +------+--------+-------------+-----------------------+ 3732 Table 4: Summary of Integer Encodings 3734 For example, the eight byte sequence c2 19 7c 5e ff 14 e8 8c (in 3735 hexadecimal) decodes to the decimal value 151288809941952652; the 3736 four byte sequence 9d 7f 3e 7d decodes to 494878333; the two byte 3737 sequence 7b bd decodes to 15293; and the single byte 25 decodes to 37 3738 (as does the two byte sequence 40 25). 3740 Error codes (Section 20) and versions (Section 15) are described 3741 using integers, but do not use this encoding. 3743 17. Packet Formats 3745 All numeric values are encoded in network byte order (that is, big- 3746 endian) and all field sizes are in bits. Hexadecimal notation is 3747 used for describing the value of fields. 3749 17.1. Packet Number Encoding and Decoding 3751 Packet numbers are integers in the range 0 to 2^62-1 (Section 12.3). 3752 When present in long or short packet headers, they are encoded in 1 3753 to 4 bytes. The number of bits required to represent the packet 3754 number is reduced by including the least significant bits of the 3755 packet number. 3757 The encoded packet number is protected as described in Section 5.4 of 3758 [QUIC-TLS]. 3760 The sender MUST use a packet number size able to represent more than 3761 twice as large a range than the difference between the largest 3762 acknowledged packet and packet number being sent. A peer receiving 3763 the packet will then correctly decode the packet number, unless the 3764 packet is delayed in transit such that it arrives after many higher- 3765 numbered packets have been received. An endpoint SHOULD use a large 3766 enough packet number encoding to allow the packet number to be 3767 recovered even if the packet arrives after packets that are sent 3768 afterwards. 3770 As a result, the size of the packet number encoding is at least one 3771 bit more than the base-2 logarithm of the number of contiguous 3772 unacknowledged packet numbers, including the new packet. 3774 For example, if an endpoint has received an acknowledgment for packet 3775 0xabe8bc, sending a packet with a number of 0xac5c02 requires a 3776 packet number encoding with 16 bits or more; whereas the 24-bit 3777 packet number encoding is needed to send a packet with a number of 3778 0xace8fe. 3780 At a receiver, protection of the packet number is removed prior to 3781 recovering the full packet number. The full packet number is then 3782 reconstructed based on the number of significant bits present, the 3783 value of those bits, and the largest packet number received on a 3784 successfully authenticated packet. Recovering the full packet number 3785 is necessary to successfully remove packet protection. 3787 Once header protection is removed, the packet number is decoded by 3788 finding the packet number value that is closest to the next expected 3789 packet. The next expected packet is the highest received packet 3790 number plus one. For example, if the highest successfully 3791 authenticated packet had a packet number of 0xa82f30ea, then a packet 3792 containing a 16-bit value of 0x9b32 will be decoded as 0xa82f9b32. 3793 Example pseudo-code for packet number decoding can be found in 3794 Appendix A. 3796 17.2. Long Header Packets 3798 0 1 2 3 3799 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 3800 +-+-+-+-+-+-+-+-+ 3801 |1|1|T T|X X X X| 3802 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3803 | Version (32) | 3804 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3805 |DCIL(4)|SCIL(4)| 3806 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3807 | Destination Connection ID (0/32..144) ... 3808 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3809 | Source Connection ID (0/32..144) ... 3810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3812 Figure 9: Long Header Packet Format 3814 Long headers are used for packets that are sent prior to the 3815 establishment of 1-RTT keys. Once both conditions are met, a sender 3816 switches to sending packets using the short header (Section 17.3). 3817 The long form allows for special packets - such as the Version 3818 Negotiation packet - to be represented in this uniform fixed-length 3819 packet format. Packets that use the long header contain the 3820 following fields: 3822 Header Form: The most significant bit (0x80) of byte 0 (the first 3823 byte) is set to 1 for long headers. 3825 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 3826 containing a zero value for this bit are not valid packets in this 3827 version and MUST be discarded. 3829 Long Packet Type (T): The next two bits (those with a mask of 0x30) 3830 of byte 0 contain a packet type. Packet types are listed in 3831 Table 5. 3833 Type-Specific Bits (X): The lower four bits (those with a mask of 3834 0x0f) of byte 0 are type-specific. 3836 Version: The QUIC Version is a 32-bit field that follows the first 3837 byte. This field indicates which version of QUIC is in use and 3838 determines how the rest of the protocol fields are interpreted. 3840 DCIL and SCIL: The byte following the version contains the lengths 3841 of the two connection ID fields that follow it. These lengths are 3842 encoded as two 4-bit unsigned integers. The Destination 3843 Connection ID Length (DCIL) field occupies the 4 high bits of the 3844 byte and the Source Connection ID Length (SCIL) field occupies the 3845 4 low bits of the byte. An encoded length of 0 indicates that the 3846 connection ID is also 0 bytes in length. Non-zero encoded lengths 3847 are increased by 3 to get the full length of the connection ID, 3848 producing a length between 4 and 18 bytes inclusive. For example, 3849 a byte with the value 0x50 describes an 8-byte Destination 3850 Connection ID and a zero-length Source Connection ID. 3852 Destination Connection ID: The Destination Connection ID field 3853 follows the connection ID lengths and is either 0 bytes in length 3854 or between 4 and 18 bytes. Section 7.2 describes the use of this 3855 field in more detail. 3857 Source Connection ID: The Source Connection ID field follows the 3858 Destination Connection ID and is either 0 bytes in length or 3859 between 4 and 18 bytes. Section 7.2 describes the use of this 3860 field in more detail. 3862 In this version of QUIC, the following packet types with the long 3863 header are defined: 3865 +------+-----------+----------------+ 3866 | Type | Name | Section | 3867 +------+-----------+----------------+ 3868 | 0x0 | Initial | Section 17.2.2 | 3869 | | | | 3870 | 0x1 | 0-RTT | Section 17.2.3 | 3871 | | | | 3872 | 0x2 | Handshake | Section 17.2.4 | 3873 | | | | 3874 | 0x3 | Retry | Section 17.2.5 | 3875 +------+-----------+----------------+ 3877 Table 5: Long Header Packet Types 3879 The header form bit, connection ID lengths byte, Destination and 3880 Source Connection ID fields, and Version fields of a long header 3881 packet are version-independent. The other fields in the first byte 3882 are version-specific. See [QUIC-INVARIANTS] for details on how 3883 packets from different versions of QUIC are interpreted. 3885 The interpretation of the fields and the payload are specific to a 3886 version and packet type. While type-specific semantics for this 3887 version are described in the following sections, several long-header 3888 packets in this version of QUIC contain these additional fields: 3890 Reserved Bits (R): Two bits (those with a mask of 0x0c) of byte 0 3891 are reserved across multiple packet types. These bits are 3892 protected using header protection (see Section 5.4 of [QUIC-TLS]). 3893 The value included prior to protection MUST be set to 0. An 3894 endpoint MUST treat receipt of a packet that has a non-zero value 3895 for these bits, after removing both packet and header protection, 3896 as a connection error of type PROTOCOL_VIOLATION. Discarding such 3897 a packet after only removing header protection can expose the 3898 endpoint to attacks (see Section 9.3 of [QUIC-TLS]). 3900 Packet Number Length (P): In packet types which contain a Packet 3901 Number field, the least significant two bits (those with a mask of 3902 0x03) of byte 0 contain the length of the packet number, encoded 3903 as an unsigned, two-bit integer that is one less than the length 3904 of the packet number field in bytes. That is, the length of the 3905 packet number field is the value of this field, plus one. These 3906 bits are protected using header protection (see Section 5.4 of 3907 [QUIC-TLS]). 3909 Length: The length of the remainder of the packet (that is, the 3910 Packet Number and Payload fields) in bytes, encoded as a variable- 3911 length integer (Section 16). 3913 Packet Number: The packet number field is 1 to 4 bytes long. The 3914 packet number has confidentiality protection separate from packet 3915 protection, as described in Section 5.4 of [QUIC-TLS]. The length 3916 of the packet number field is encoded in the Packet Number Length 3917 bits of byte 0 (see above). 3919 17.2.1. Version Negotiation Packet 3921 A Version Negotiation packet is inherently not version-specific. 3922 Upon receipt by a client, it will be identified as a Version 3923 Negotiation packet based on the Version field having a value of 0. 3925 The Version Negotiation packet is a response to a client packet that 3926 contains a version that is not supported by the server, and is only 3927 sent by servers. 3929 The layout of a Version Negotiation packet is: 3931 0 1 2 3 3932 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 3933 +-+-+-+-+-+-+-+-+ 3934 |1| Unused (7) | 3935 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3936 | Version (32) | 3937 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3938 |DCIL(4)|SCIL(4)| 3939 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3940 | Destination Connection ID (0/32..144) ... 3941 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3942 | Source Connection ID (0/32..144) ... 3943 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3944 | Supported Version 1 (32) ... 3945 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3946 | [Supported Version 2 (32)] ... 3947 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3948 ... 3949 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3950 | [Supported Version N (32)] ... 3951 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3953 Figure 10: Version Negotiation Packet 3955 The value in the Unused field is selected randomly by the server. 3956 Clients MUST ignore the value of this field. Servers SHOULD set the 3957 most significant bit of this field (0x40) to 1 so that Version 3958 Negotiation packets appear to have the Fixed Bit field. 3960 The Version field of a Version Negotiation packet MUST be set to 3961 0x00000000. 3963 The server MUST include the value from the Source Connection ID field 3964 of the packet it receives in the Destination Connection ID field. 3965 The value for Source Connection ID MUST be copied from the 3966 Destination Connection ID of the received packet, which is initially 3967 randomly selected by a client. Echoing both connection IDs gives 3968 clients some assurance that the server received the packet and that 3969 the Version Negotiation packet was not generated by an off-path 3970 attacker. 3972 The remainder of the Version Negotiation packet is a list of 32-bit 3973 versions which the server supports. 3975 A Version Negotiation packet cannot be explicitly acknowledged in an 3976 ACK frame by a client. Receiving another Initial packet implicitly 3977 acknowledges a Version Negotiation packet. 3979 The Version Negotiation packet does not include the Packet Number and 3980 Length fields present in other packets that use the long header form. 3981 Consequently, a Version Negotiation packet consumes an entire UDP 3982 datagram. 3984 A server MUST NOT send more than one Version Negotiation packet in 3985 response to a single UDP datagram. 3987 See Section 6 for a description of the version negotiation process. 3989 17.2.2. Initial Packet 3991 An Initial packet uses long headers with a type value of 0x0. It 3992 carries the first CRYPTO frames sent by the client and server to 3993 perform key exchange, and carries ACKs in either direction. 3995 +-+-+-+-+-+-+-+-+ 3996 |1|1| 0 |R R|P P| 3997 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3998 | Version (32) | 3999 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4000 |DCIL(4)|SCIL(4)| 4001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4002 | Destination Connection ID (0/32..144) ... 4003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4004 | Source Connection ID (0/32..144) ... 4005 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4006 | Token Length (i) ... 4007 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4008 | Token (*) ... 4009 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4010 | Length (i) ... 4011 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4012 | Packet Number (8/16/24/32) ... 4013 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4014 | Payload (*) ... 4015 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4017 Figure 11: Initial Packet 4019 The Initial packet contains a long header as well as the Length and 4020 Packet Number fields. The first byte contains the Reserved and 4021 Packet Number Length bits. Between the SCID and Length fields, there 4022 are two additional field specific to the Initial packet. 4024 Token Length: A variable-length integer specifying the length of the 4025 Token field, in bytes. This value is zero if no token is present. 4026 Initial packets sent by the server MUST set the Token Length field 4027 to zero; clients that receive an Initial packet with a non-zero 4028 Token Length field MUST either discard the packet or generate a 4029 connection error of type PROTOCOL_VIOLATION. 4031 Token: The value of the token that was previously provided in a 4032 Retry packet or NEW_TOKEN frame. 4034 Payload: The payload of the packet. 4036 In order to prevent tampering by version-unaware middleboxes, Initial 4037 packets are protected with connection- and version-specific keys 4038 (Initial keys) as described in [QUIC-TLS]. This protection does not 4039 provide confidentiality or integrity against on-path attackers, but 4040 provides some level of protection against off-path attackers. 4042 The client and server use the Initial packet type for any packet that 4043 contains an initial cryptographic handshake message. This includes 4044 all cases where a new packet containing the initial cryptographic 4045 message needs to be created, such as the packets sent after receiving 4046 a Retry packet (Section 17.2.5). 4048 A server sends its first Initial packet in response to a client 4049 Initial. A server may send multiple Initial packets. The 4050 cryptographic key exchange could require multiple round trips or 4051 retransmissions of this data. 4053 The payload of an Initial packet includes a CRYPTO frame (or frames) 4054 containing a cryptographic handshake message, ACK frames, or both. 4055 PADDING and CONNECTION_CLOSE frames are also permitted. An endpoint 4056 that receives an Initial packet containing other frames can either 4057 discard the packet as spurious or treat it as a connection error. 4059 The first packet sent by a client always includes a CRYPTO frame that 4060 contains the entirety of the first cryptographic handshake message. 4061 This packet, and the cryptographic handshake message, MUST fit in a 4062 single UDP datagram (see Section 7). The first CRYPTO frame sent 4063 always begins at an offset of 0 (see Section 7). 4065 Note that if the server sends a HelloRetryRequest, the client will 4066 send a second Initial packet. This Initial packet will continue the 4067 cryptographic handshake and will contain a CRYPTO frame with an 4068 offset matching the size of the CRYPTO frame sent in the first 4069 Initial packet. Cryptographic handshake messages subsequent to the 4070 first do not need to fit within a single UDP datagram. 4072 17.2.2.1. Abandoning Initial Packets 4074 A client stops both sending and processing Initial packets when it 4075 sends its first Handshake packet. A server stops sending and 4076 processing Initial packets when it receives its first Handshake 4077 packet. Though packets might still be in flight or awaiting 4078 acknowledgment, no further Initial packets need to be exchanged 4079 beyond this point. Initial packet protection keys are discarded (see 4080 Section 4.9.1 of [QUIC-TLS]) along with any loss recovery and 4081 congestion control state (see Section 6.5 of [QUIC-RECOVERY]). 4083 Any data in CRYPTO frames is discarded - and no longer retransmitted 4084 - when Initial keys are discarded. 4086 17.2.3. 0-RTT 4088 A 0-RTT packet uses long headers with a type value of 0x1, followed 4089 by the Length and Packet Number fields. The first byte contains the 4090 Reserved and Packet Number Length bits. It is used to carry "early" 4091 data from the client to the server as part of the first flight, prior 4092 to handshake completion. As part of the TLS handshake, the server 4093 can accept or reject this early data. 4095 See Section 2.3 of [TLS13] for a discussion of 0-RTT data and its 4096 limitations. 4098 +-+-+-+-+-+-+-+-+ 4099 |1|1| 1 |R R|P P| 4100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4101 | Version (32) | 4102 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4103 |DCIL(4)|SCIL(4)| 4104 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4105 | Destination Connection ID (0/32..144) ... 4106 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4107 | Source Connection ID (0/32..144) ... 4108 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4109 | Length (i) ... 4110 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4111 | Packet Number (8/16/24/32) ... 4112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4113 | Payload (*) ... 4114 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4116 0-RTT Packet 4118 Packet numbers for 0-RTT protected packets use the same space as 4119 1-RTT protected packets. 4121 After a client receives a Retry packet, 0-RTT packets are likely to 4122 have been lost or discarded by the server. A client MAY attempt to 4123 resend data in 0-RTT packets after it sends a new Initial packet. 4125 A client MUST NOT reset the packet number it uses for 0-RTT packets, 4126 since the keys used to protect 0-RTT packets will not change as a 4127 result of responding to a Retry packet. Sending packets with the 4128 same packet number in that case is likely to compromise the packet 4129 protection for all 0-RTT packets because the same key and nonce could 4130 be used to protect different content. 4132 A client only receives acknowledgments for its 0-RTT packets once the 4133 handshake is complete. Consequently, a server might expect 0-RTT 4134 packets to start with a packet number of 0. Therefore, in 4135 determining the length of the packet number encoding for 0-RTT 4136 packets, a client MUST assume that all packets up to the current 4137 packet number are in flight, starting from a packet number of 0. 4138 Thus, 0-RTT packets could need to use a longer packet number 4139 encoding. 4141 A client MUST NOT send 0-RTT packets once it starts processing 1-RTT 4142 packets from the server. This means that 0-RTT packets cannot 4143 contain any response to frames from 1-RTT packets. For instance, a 4144 client cannot send an ACK frame in a 0-RTT packet, because that can 4145 only acknowledge a 1-RTT packet. An acknowledgment for a 1-RTT 4146 packet MUST be carried in a 1-RTT packet. 4148 A server SHOULD treat a violation of remembered limits as a 4149 connection error of an appropriate type (for instance, a 4150 FLOW_CONTROL_ERROR for exceeding stream data limits). 4152 17.2.4. Handshake Packet 4154 A Handshake packet uses long headers with a type value of 0x2, 4155 followed by the Length and Packet Number fields. The first byte 4156 contains the Reserved and Packet Number Length bits. It is used to 4157 carry acknowledgments and cryptographic handshake messages from the 4158 server and client. 4160 +-+-+-+-+-+-+-+-+ 4161 |1|1| 2 |R R|P P| 4162 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4163 | Version (32) | 4164 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4165 |DCIL(4)|SCIL(4)| 4166 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4167 | Destination Connection ID (0/32..144) ... 4168 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4169 | Source Connection ID (0/32..144) ... 4170 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4171 | Length (i) ... 4172 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4173 | Packet Number (8/16/24/32) ... 4174 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4175 | Payload (*) ... 4176 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4178 Figure 12: Handshake Protected Packet 4180 Once a client has received a Handshake packet from a server, it uses 4181 Handshake packets to send subsequent cryptographic handshake messages 4182 and acknowledgments to the server. 4184 The Destination Connection ID field in a Handshake packet contains a 4185 connection ID that is chosen by the recipient of the packet; the 4186 Source Connection ID includes the connection ID that the sender of 4187 the packet wishes to use (see Section 7.2). 4189 Handshake packets are their own packet number space, and thus the 4190 first Handshake packet sent by a server contains a packet number of 4191 0. 4193 The payload of this packet contains CRYPTO frames and could contain 4194 PADDING, or ACK frames. Handshake packets MAY contain 4195 CONNECTION_CLOSE frames. Endpoints MUST treat receipt of Handshake 4196 packets with other frames as a connection error. 4198 Like Initial packets (see Section 17.2.2.1), data in CRYPTO frames at 4199 the Handshake encryption level is discarded - and no longer 4200 retransmitted - when Handshake protection keys are discarded. 4202 17.2.5. Retry Packet 4204 A Retry packet uses a long packet header with a type value of 0x3. 4205 It carries an address validation token created by the server. It is 4206 used by a server that wishes to perform a retry (see Section 8.1). 4208 0 1 2 3 4209 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 4210 +-+-+-+-+-+-+-+-+ 4211 |1|1| 3 | ODCIL | 4212 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4213 | Version (32) | 4214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4215 |DCIL(4)|SCIL(4)| 4216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4217 | Destination Connection ID (0/32..144) ... 4218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4219 | Source Connection ID (0/32..144) ... 4220 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4221 | Original Destination Connection ID (0/32..144) ... 4222 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4223 | Retry Token (*) ... 4224 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4226 Figure 13: Retry Packet 4228 A Retry packet (shown in Figure 13) does not contain any protected 4229 fields. In addition to the long header, it contains these additional 4230 fields: 4232 ODCIL: The four least-significant bits of the first byte of a Retry 4233 packet are not protected as they are for other packets with the 4234 long header, because Retry packets don't contain a protected 4235 payload. These bits instead encode the length of the Original 4236 Destination Connection ID field. The length uses the same 4237 encoding as the DCIL and SCIL fields. 4239 Original Destination Connection ID: The Original Destination 4240 Connection ID contains the value of the Destination Connection ID 4241 from the Initial packet that this Retry is in response to. The 4242 length of this field is given in ODCIL. 4244 Retry Token: An opaque token that the server can use to validate the 4245 client's address. 4247 The server populates the Destination Connection ID with the 4248 connection ID that the client included in the Source Connection ID of 4249 the Initial packet. 4251 The server includes a connection ID of its choice in the Source 4252 Connection ID field. This value MUST not be equal to the Destination 4253 Connection ID field of the packet sent by the client. The client 4254 MUST use this connection ID in the Destination Connection ID of 4255 subsequent packets that it sends. 4257 A server MAY send Retry packets in response to Initial and 0-RTT 4258 packets. A server can either discard or buffer 0-RTT packets that it 4259 receives. A server can send multiple Retry packets as it receives 4260 Initial or 0-RTT packets. A server MUST NOT send more than one Retry 4261 packet in response to a single UDP datagram. 4263 A client MUST accept and process at most one Retry packet for each 4264 connection attempt. After the client has received and processed an 4265 Initial or Retry packet from the server, it MUST discard any 4266 subsequent Retry packets that it receives. 4268 Clients MUST discard Retry packets that contain an Original 4269 Destination Connection ID field that does not match the Destination 4270 Connection ID from its Initial packet. This prevents an off-path 4271 attacker from injecting a Retry packet. 4273 The client responds to a Retry packet with an Initial packet that 4274 includes the provided Retry Token to continue connection 4275 establishment. 4277 A client sets the Destination Connection ID field of this Initial 4278 packet to the value from the Source Connection ID in the Retry 4279 packet. Changing Destination Connection ID also results in a change 4280 to the keys used to protect the Initial packet. It also sets the 4281 Token field to the token provided in the Retry. The client MUST NOT 4282 change the Source Connection ID because the server could include the 4283 connection ID as part of its token validation logic (see 4284 Section 8.1.3). 4286 The next Initial packet from the client uses the connection ID and 4287 token values from the Retry packet (see Section 7.2). Aside from 4288 this, the Initial packet sent by the client is subject to the same 4289 restrictions as the first Initial packet. A client MUST use the same 4290 cryptographic handshake message it includes in this packet. A server 4291 MAY treat a packet that contains a different cryptographic handshake 4292 message as a connection error or discard it. 4294 A client MAY attempt 0-RTT after receiving a Retry packet by sending 4295 0-RTT packets to the connection ID provided by the server. A client 4296 MUST NOT change the cryptographic handshake message it sends in 4297 response to receiving a Retry. 4299 A client MUST NOT reset the packet number for any packet number space 4300 after processing a Retry packet; Section 17.2.3 contains more 4301 information on this. 4303 A server acknowledges the use of a Retry packet for a connection 4304 using the original_connection_id transport parameter (see 4305 Section 18.1). If the server sends a Retry packet, it MUST include 4306 the value of the Original Destination Connection ID field of the 4307 Retry packet (that is, the Destination Connection ID field from the 4308 client's first Initial packet) in the transport parameter. 4310 If the client received and processed a Retry packet, it MUST validate 4311 that the original_connection_id transport parameter is present and 4312 correct; otherwise, it MUST validate that the transport parameter is 4313 absent. A client MUST treat a failed validation as a connection 4314 error of type TRANSPORT_PARAMETER_ERROR. 4316 A Retry packet does not include a packet number and cannot be 4317 explicitly acknowledged by a client. 4319 17.3. Short Header Packets 4321 This version of QUIC defines a single packet type which uses the 4322 short packet header. 4324 0 1 2 3 4325 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 4326 +-+-+-+-+-+-+-+-+ 4327 |0|1|S|R|R|K|P P| 4328 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4329 | Destination Connection ID (0..144) ... 4330 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4331 | Packet Number (8/16/24/32) ... 4332 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4333 | Protected Payload (*) ... 4334 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4336 Figure 14: Short Header Packet Format 4338 The short header can be used after the version and 1-RTT keys are 4339 negotiated. Packets that use the short header contain the following 4340 fields: 4342 Header Form: The most significant bit (0x80) of byte 0 is set to 0 4343 for the short header. 4345 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4346 containing a zero value for this bit are not valid packets in this 4347 version and MUST be discarded. 4349 Spin Bit (S): The third most significant bit (0x20) of byte 0 is the 4350 latency spin bit, set as described in Section 17.3.1. 4352 Reserved Bits (R): The next two bits (those with a mask of 0x18) of 4353 byte 0 are reserved. These bits are protected using header 4354 protection (see Section 5.4 of [QUIC-TLS]). The value included 4355 prior to protection MUST be set to 0. An endpoint MUST treat 4356 receipt of a packet that has a non-zero value for these bits, 4357 after removing both packet and header protection, as a connection 4358 error of type PROTOCOL_VIOLATION. Discarding such a packet after 4359 only removing header protection can expose the endpoint to attacks 4360 (see Section 9.3 of [QUIC-TLS]). 4362 Key Phase (K): The next bit (0x04) of byte 0 indicates the key 4363 phase, which allows a recipient of a packet to identify the packet 4364 protection keys that are used to protect the packet. See 4365 [QUIC-TLS] for details. This bit is protected using header 4366 protection (see Section 5.4 of [QUIC-TLS]). 4368 Packet Number Length (P): The least significant two bits (those with 4369 a mask of 0x03) of byte 0 contain the length of the packet number, 4370 encoded as an unsigned, two-bit integer that is one less than the 4371 length of the packet number field in bytes. That is, the length 4372 of the packet number field is the value of this field, plus one. 4373 These bits are protected using header protection (see Section 5.4 4374 of [QUIC-TLS]). 4376 Destination Connection ID: The Destination Connection ID is a 4377 connection ID that is chosen by the intended recipient of the 4378 packet. See Section 5.1 for more details. 4380 Packet Number: The packet number field is 1 to 4 bytes long. The 4381 packet number has confidentiality protection separate from packet 4382 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4383 of the packet number field is encoded in Packet Number Length 4384 field. See Section 17.1 for details. 4386 Protected Payload: Packets with a short header always include a 4387 1-RTT protected payload. 4389 The header form bit and the connection ID field of a short header 4390 packet are version-independent. The remaining fields are specific to 4391 the selected QUIC version. See [QUIC-INVARIANTS] for details on how 4392 packets from different versions of QUIC are interpreted. 4394 17.3.1. Latency Spin Bit 4396 The latency spin bit enables passive latency monitoring from 4397 observation points on the network path throughout the duration of a 4398 connection. The spin bit is only present in the short packet header, 4399 since it is possible to measure the initial RTT of a connection by 4400 observing the handshake. Therefore, the spin bit is available after 4401 version negotiation and connection establishment are completed. On- 4402 path measurement and use of the latency spin bit is further discussed 4403 in [QUIC-MANAGEABILITY]. 4405 The spin bit is an OPTIONAL feature of QUIC. A QUIC stack that 4406 chooses to support the spin bit MUST implement it as specified in 4407 this section. 4409 Each endpoint unilaterally decides if the spin bit is enabled or 4410 disabled for a connection. Implementations MUST allow administrators 4411 of clients and servers to disable the spin bit either globally or on 4412 a per-connection basis. Even when the spin bit is not disabled by 4413 the administrator, implementations MUST disable the spin bit for a 4414 given connection with a certain likelihood. The random selection 4415 process SHOULD be designed such that on average the spin bit is 4416 disabled for at least one eighth of network paths. The selection 4417 process performed at the beginning of the connection SHOULD be 4418 applied for all paths used by the connection. 4420 In case multiple connections share the same network path, as 4421 determined by having the same source and destination IP address and 4422 UDP ports, endpoints should try to co-ordinate across all connections 4423 to ensure a clear signal to any on-path measurement points. 4425 When the spin bit is disabled, endpoints MAY set the spin bit to any 4426 value, and MUST ignore any incoming value. It is RECOMMENDED that 4427 endpoints set the spin bit to a random value either chosen 4428 independently for each packet or chosen independently for each 4429 connection ID. 4431 If the spin bit is enabled for the connection, the endpoint maintains 4432 a spin value and sets the spin bit in the short header to the 4433 currently stored value when a packet with a short header is sent out. 4434 The spin value is initialized to 0 in the endpoint at connection 4435 start. Each endpoint also remembers the highest packet number seen 4436 from its peer on the connection. 4438 When a server receives a short header packet that increments the 4439 highest packet number seen by the server from the client, it sets the 4440 spin value to be equal to the spin bit in the received packet. 4442 When a client receives a short header packet that increments the 4443 highest packet number seen by the client from the server, it sets the 4444 spin value to the inverse of the spin bit in the received packet. 4446 An endpoint resets its spin value to zero when sending the first 4447 packet of a given connection with a new connection ID. This reduces 4448 the risk that transient spin bit state can be used to link flows 4449 across connection migration or ID change. 4451 With this mechanism, the server reflects the spin value received, 4452 while the client 'spins' it after one RTT. On-path observers can 4453 measure the time between two spin bit toggle events to estimate the 4454 end-to-end RTT of a connection. 4456 18. Transport Parameter Encoding 4458 The format of the transport parameters is the TransportParameters 4459 struct from Figure 15. This is described using the presentation 4460 language from Section 3 of [TLS13]. 4462 enum { 4463 original_connection_id(0), 4464 idle_timeout(1), 4465 stateless_reset_token(2), 4466 max_packet_size(3), 4467 initial_max_data(4), 4468 initial_max_stream_data_bidi_local(5), 4469 initial_max_stream_data_bidi_remote(6), 4470 initial_max_stream_data_uni(7), 4471 initial_max_streams_bidi(8), 4472 initial_max_streams_uni(9), 4473 ack_delay_exponent(10), 4474 max_ack_delay(11), 4475 disable_migration(12), 4476 preferred_address(13), 4477 active_connection_id_limit(14), 4478 (65535) 4479 } TransportParameterId; 4481 struct { 4482 TransportParameterId parameter; 4483 opaque value<0..2^16-1>; 4484 } TransportParameter; 4486 TransportParameter TransportParameters<0..2^16-1>; 4488 Figure 15: Definition of TransportParameters 4490 The "extension_data" field of the quic_transport_parameters extension 4491 defined in [QUIC-TLS] contains a TransportParameters value. TLS 4492 encoding rules are therefore used to describe the encoding of 4493 transport parameters. 4495 QUIC encodes transport parameters into a sequence of bytes, which are 4496 then included in the cryptographic handshake. 4498 18.1. Transport Parameter Definitions 4500 This section details the transport parameters defined in this 4501 document. 4503 Many transport parameters listed here have integer values. Those 4504 transport parameters that are identified as integers use a variable- 4505 length integer encoding (see Section 16) and have a default value of 4506 0 if the transport parameter is absent, unless otherwise stated. 4508 The following transport parameters are defined: 4510 original_connection_id (0x0000): The value of the Destination 4511 Connection ID field from the first Initial packet sent by the 4512 client. This transport parameter is only sent by a server. A 4513 server MUST include the original_connection_id transport parameter 4514 if it sent a Retry packet. 4516 idle_timeout (0x0001): The idle timeout is a value in milliseconds 4517 that is encoded as an integer; see (Section 10.2). If this 4518 parameter is absent or zero then the idle timeout is disabled. 4520 stateless_reset_token (0x0002): A stateless reset token is used in 4521 verifying a stateless reset; see Section 10.4. This parameter is 4522 a sequence of 16 bytes. This transport parameter MUST NOT be sent 4523 by a client, but MAY be sent by a server. A server that does not 4524 send this transport parameter cannot use stateless reset 4525 (Section 10.4) for the connection ID negotiated during the 4526 handshake. 4528 max_packet_size (0x0003): The maximum packet size parameter is an 4529 integer value that limits the size of packets that the endpoint is 4530 willing to receive. This indicates that packets larger than this 4531 limit will be dropped. The default for this parameter is the 4532 maximum permitted UDP payload of 65527. Values below 1200 are 4533 invalid. This limit only applies to protected packets 4534 (Section 12.1). 4536 initial_max_data (0x0004): The initial maximum data parameter is an 4537 integer value that contains the initial value for the maximum 4538 amount of data that can be sent on the connection. This is 4539 equivalent to sending a MAX_DATA (Section 19.9) for the connection 4540 immediately after completing the handshake. 4542 initial_max_stream_data_bidi_local (0x0005): This parameter is an 4543 integer value specifying the initial flow control limit for 4544 locally-initiated bidirectional streams. This limit applies to 4545 newly created bidirectional streams opened by the endpoint that 4546 sends the transport parameter. In client transport parameters, 4547 this applies to streams with an identifier with the least 4548 significant two bits set to 0x0; in server transport parameters, 4549 this applies to streams with the least significant two bits set to 4550 0x1. 4552 initial_max_stream_data_bidi_remote (0x0006): This parameter is an 4553 integer value specifying the initial flow control limit for peer- 4554 initiated bidirectional streams. This limit applies to newly 4555 created bidirectional streams opened by the endpoint that receives 4556 the transport parameter. In client transport parameters, this 4557 applies to streams with an identifier with the least significant 4558 two bits set to 0x1; in server transport parameters, this applies 4559 to streams with the least significant two bits set to 0x0. 4561 initial_max_stream_data_uni (0x0007): This parameter is an integer 4562 value specifying the initial flow control limit for unidirectional 4563 streams. This limit applies to newly created unidirectional 4564 streams opened by the endpoint that receives the transport 4565 parameter. In client transport parameters, this applies to 4566 streams with an identifier with the least significant two bits set 4567 to 0x3; in server transport parameters, this applies to streams 4568 with the least significant two bits set to 0x2. 4570 initial_max_streams_bidi (0x0008): The initial maximum bidirectional 4571 streams parameter is an integer value that contains the initial 4572 maximum number of bidirectional streams the peer may initiate. If 4573 this parameter is absent or zero, the peer cannot open 4574 bidirectional streams until a MAX_STREAMS frame is sent. Setting 4575 this parameter is equivalent to sending a MAX_STREAMS 4576 (Section 19.11) of the corresponding type with the same value. 4578 initial_max_streams_uni (0x0009): The initial maximum unidirectional 4579 streams parameter is an integer value that contains the initial 4580 maximum number of unidirectional streams the peer may initiate. 4581 If this parameter is absent or zero, the peer cannot open 4582 unidirectional streams until a MAX_STREAMS frame is sent. Setting 4583 this parameter is equivalent to sending a MAX_STREAMS 4584 (Section 19.11) of the corresponding type with the same value. 4586 ack_delay_exponent (0x000a): The ACK delay exponent is an integer 4587 value indicating an exponent used to decode the ACK Delay field in 4588 the ACK frame (Section 19.3). If this value is absent, a default 4589 value of 3 is assumed (indicating a multiplier of 8). Values 4590 above 20 are invalid. 4592 max_ack_delay (0x000b): The maximum ACK delay is an integer value 4593 indicating the maximum amount of time in milliseconds by which the 4594 endpoint will delay sending acknowledgments. This value SHOULD 4595 include the receiver's expected delays in alarms firing. For 4596 example, if a receiver sets a timer for 5ms and alarms commonly 4597 fire up to 1ms late, then it should send a max_ack_delay of 6ms. 4598 If this value is absent, a default of 25 milliseconds is assumed. 4599 Values of 2^14 or greater are invalid. 4601 disable_migration (0x000c): The disable migration transport 4602 parameter is included if the endpoint does not support connection 4603 migration (Section 9). Peers of an endpoint that sets this 4604 transport parameter MUST NOT send any packets, including probing 4605 packets (Section 9.1), from a local address or port other than 4606 that used to perform the handshake. This parameter is a zero- 4607 length value. 4609 preferred_address (0x000d): The server's preferred address is used 4610 to effect a change in server address at the end of the handshake, 4611 as described in Section 9.6. The format of this transport 4612 parameter is the PreferredAddress struct shown in Figure 16. This 4613 transport parameter is only sent by a server. Servers MAY choose 4614 to only send a preferred address of one address family by sending 4615 an all-zero address and port (0.0.0.0:0 or ::.0) for the other 4616 family. 4618 struct { 4619 opaque ipv4Address[4]; 4620 uint16 ipv4Port; 4621 opaque ipv6Address[16]; 4622 uint16 ipv6Port; 4623 opaque connectionId<0..18>; 4624 opaque statelessResetToken[16]; 4625 } PreferredAddress; 4627 Figure 16: Preferred Address format 4629 active_connection_id_limit (0x000e): The maximum number of 4630 connection IDs from the peer that an endpoint is willing to store. 4631 This value includes only connection IDs sent in NEW_CONNECTION_ID 4632 frames. If this parameter is absent, a default of 0 is assumed. 4634 If present, transport parameters that set initial flow control limits 4635 (initial_max_stream_data_bidi_local, 4636 initial_max_stream_data_bidi_remote, and initial_max_stream_data_uni) 4637 are equivalent to sending a MAX_STREAM_DATA frame (Section 19.10) on 4638 every stream of the corresponding type immediately after opening. If 4639 the transport parameter is absent, streams of that type start with a 4640 flow control limit of 0. 4642 A client MUST NOT include an original connection ID, a stateless 4643 reset token, or a preferred address. A server MUST treat receipt of 4644 any of these transport parameters as a connection error of type 4645 TRANSPORT_PARAMETER_ERROR. 4647 19. Frame Types and Formats 4649 As described in Section 12.4, packets contain one or more frames. 4650 This section describes the format and semantics of the core QUIC 4651 frame types. 4653 19.1. PADDING Frame 4655 The PADDING frame (type=0x00) has no semantic value. PADDING frames 4656 can be used to increase the size of a packet. Padding can be used to 4657 increase an initial client packet to the minimum required size, or to 4658 provide protection against traffic analysis for protected packets. 4660 A PADDING frame has no content. That is, a PADDING frame consists of 4661 the single byte that identifies the frame as a PADDING frame. 4663 19.2. PING Frame 4665 Endpoints can use PING frames (type=0x01) to verify that their peers 4666 are still alive or to check reachability to the peer. The PING frame 4667 contains no additional fields. 4669 The receiver of a PING frame simply needs to acknowledge the packet 4670 containing this frame. 4672 The PING frame can be used to keep a connection alive when an 4673 application or application protocol wishes to prevent the connection 4674 from timing out. An application protocol SHOULD provide guidance 4675 about the conditions under which generating a PING is recommended. 4676 This guidance SHOULD indicate whether it is the client or the server 4677 that is expected to send the PING. Having both endpoints send PING 4678 frames without coordination can produce an excessive number of 4679 packets and poor performance. 4681 A connection will time out if no packets are sent or received for a 4682 period longer than the time specified in the idle_timeout transport 4683 parameter (see Section 10). However, state in middleboxes might time 4684 out earlier than that. Though REQ-5 in [RFC4787] recommends a 2 4685 minute timeout interval, experience shows that sending packets every 4686 15 to 30 seconds is necessary to prevent the majority of middleboxes 4687 from losing state for UDP flows. 4689 19.3. ACK Frames 4691 Receivers send ACK frames (types 0x02 and 0x03) to inform senders of 4692 packets they have received and processed. The ACK frame contains one 4693 or more ACK Ranges. ACK Ranges identify acknowledged packets. If 4694 the frame type is 0x03, ACK frames also contain the sum of QUIC 4695 packets with associated ECN marks received on the connection up until 4696 this point. QUIC implementations MUST properly handle both types 4697 and, if they have enabled ECN for packets they send, they SHOULD use 4698 the information in the ECN section to manage their congestion state. 4700 QUIC acknowledgements are irrevocable. Once acknowledged, a packet 4701 remains acknowledged, even if it does not appear in a future ACK 4702 frame. This is unlike TCP SACKs ([RFC2018]). 4704 It is expected that a sender will reuse the same packet number across 4705 different packet number spaces. ACK frames only acknowledge the 4706 packet numbers that were transmitted by the sender in the same packet 4707 number space of the packet that the ACK was received in. 4709 Version Negotiation and Retry packets cannot be acknowledged because 4710 they do not contain a packet number. Rather than relying on ACK 4711 frames, these packets are implicitly acknowledged by the next Initial 4712 packet sent by the client. 4714 An ACK frame is as follows: 4716 0 1 2 3 4717 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 4718 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4719 | Largest Acknowledged (i) ... 4720 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4721 | ACK Delay (i) ... 4722 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4723 | ACK Range Count (i) ... 4724 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4725 | First ACK Range (i) ... 4726 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4727 | ACK Ranges (*) ... 4728 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4729 | [ECN Counts] ... 4730 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4732 Figure 17: ACK Frame Format 4734 ACK frames contain the following fields: 4736 Largest Acknowledged: A variable-length integer representing the 4737 largest packet number the peer is acknowledging; this is usually 4738 the largest packet number that the peer has received prior to 4739 generating the ACK frame. Unlike the packet number in the QUIC 4740 long or short header, the value in an ACK frame is not truncated. 4742 ACK Delay: A variable-length integer representing the time delta in 4743 microseconds between when this ACK was sent and when the largest 4744 acknowledged packet, as indicated in the Largest Acknowledged 4745 field, was received by this peer. The value of the ACK Delay 4746 field is scaled by multiplying the encoded value by 2 to the power 4747 of the value of the "ack_delay_exponent" transport parameter set 4748 by the sender of the ACK frame (see Section 18.1). Scaling in 4749 this fashion allows for a larger range of values with a shorter 4750 encoding at the cost of lower resolution. Because the receiver 4751 doesn't use the ACK Delay for Initial and Handshake packets, a 4752 sender SHOULD send a value of 0. 4754 ACK Range Count: A variable-length integer specifying the number of 4755 Gap and ACK Range fields in the frame. 4757 First ACK Range: A variable-length integer indicating the number of 4758 contiguous packets preceding the Largest Acknowledged that are 4759 being acknowledged. The First ACK Range is encoded as an ACK 4760 Range (see Section 19.3.1) starting from the Largest Acknowledged. 4761 That is, the smallest packet acknowledged in the range is 4762 determined by subtracting the First ACK Range value from the 4763 Largest Acknowledged. 4765 ACK Ranges: Contains additional ranges of packets which are 4766 alternately not acknowledged (Gap) and acknowledged (ACK Range); 4767 see Section 19.3.1. 4769 ECN Counts: The three ECN Counts; see Section 19.3.2. 4771 19.3.1. ACK Ranges 4773 The ACK Ranges field consists of alternating Gap and ACK Range values 4774 in descending packet number order. The number of Gap and ACK Range 4775 values is determined by the ACK Range Count field; one of each value 4776 is present for each value in the ACK Range Count field. 4778 ACK Ranges are structured as follows: 4780 0 1 2 3 4781 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 4782 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4783 | [Gap (i)] ... 4784 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4785 | [ACK Range (i)] ... 4786 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4787 | [Gap (i)] ... 4788 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4789 | [ACK Range (i)] ... 4790 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4791 ... 4792 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4793 | [Gap (i)] ... 4794 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4795 | [ACK Range (i)] ... 4796 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4798 Figure 18: ACK Ranges 4800 The fields that form the ACK Ranges are: 4802 Gap (repeated): A variable-length integer indicating the number of 4803 contiguous unacknowledged packets preceding the packet number one 4804 lower than the smallest in the preceding ACK Range. 4806 ACK Range (repeated): A variable-length integer indicating the 4807 number of contiguous acknowledged packets preceding the largest 4808 packet number, as determined by the preceding Gap. 4810 Gap and ACK Range value use a relative integer encoding for 4811 efficiency. Though each encoded value is positive, the values are 4812 subtracted, so that each ACK Range describes progressively lower- 4813 numbered packets. 4815 Each ACK Range acknowledges a contiguous range of packets by 4816 indicating the number of acknowledged packets that precede the 4817 largest packet number in that range. A value of zero indicates that 4818 only the largest packet number is acknowledged. Larger ACK Range 4819 values indicate a larger range, with corresponding lower values for 4820 the smallest packet number in the range. Thus, given a largest 4821 packet number for the range, the smallest value is determined by the 4822 formula: 4824 smallest = largest - ack_range 4826 An ACK Range acknowledges all packets between the smallest packet 4827 number and the largest, inclusive. 4829 The largest value for an ACK Range is determined by cumulatively 4830 subtracting the size of all preceding ACK Ranges and Gaps. 4832 Each Gap indicates a range of packets that are not being 4833 acknowledged. The number of packets in the gap is one higher than 4834 the encoded value of the Gap field. 4836 The value of the Gap field establishes the largest packet number 4837 value for the subsequent ACK Range using the following formula: 4839 largest = previous_smallest - gap - 2 4841 If any computed packet number is negative, an endpoint MUST generate 4842 a connection error of type FRAME_ENCODING_ERROR indicating an error 4843 in an ACK frame. 4845 19.3.2. ECN Counts 4847 The ACK frame uses the least significant bit (that is, type 0x03) to 4848 indicate ECN feedback and report receipt of QUIC packets with 4849 associated ECN codepoints of ECT(0), ECT(1), or CE in the packet's IP 4850 header. ECN Counts are only present when the ACK frame type is 0x03. 4852 ECN Counts are only parsed when the ACK frame type is 0x03. There 4853 are 3 ECN counts, as follows: 4855 0 1 2 3 4856 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 4857 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4858 | ECT(0) Count (i) ... 4859 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4860 | ECT(1) Count (i) ... 4861 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4862 | ECN-CE Count (i) ... 4863 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4865 The three ECN Counts are: 4867 ECT(0) Count: A variable-length integer representing the total 4868 number of packets received with the ECT(0) codepoint. 4870 ECT(1) Count: A variable-length integer representing the total 4871 number of packets received with the ECT(1) codepoint. 4873 CE Count: A variable-length integer representing the total number of 4874 packets received with the CE codepoint. 4876 ECN counts are maintained separately for each packet number space. 4878 19.4. RESET_STREAM Frame 4880 An endpoint uses a RESET_STREAM frame (type=0x04) to abruptly 4881 terminate the sending part of a stream. 4883 After sending a RESET_STREAM, an endpoint ceases transmission and 4884 retransmission of STREAM frames on the identified stream. A receiver 4885 of RESET_STREAM can discard any data that it already received on that 4886 stream. 4888 An endpoint that receives a RESET_STREAM frame for a send-only stream 4889 MUST terminate the connection with error STREAM_STATE_ERROR. 4891 The RESET_STREAM frame is as follows: 4893 0 1 2 3 4894 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 4895 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4896 | Stream ID (i) ... 4897 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4898 | Application Error Code (i) ... 4899 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4900 | Final Size (i) ... 4901 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4903 RESET_STREAM frames contain the following fields: 4905 Stream ID: A variable-length integer encoding of the Stream ID of 4906 the stream being terminated. 4908 Application Protocol Error Code: A variable-length integer 4909 containing the application protocol error code (see Section 20.1) 4910 which indicates why the stream is being closed. 4912 Final Size: A variable-length integer indicating the final size of 4913 the stream by the RESET_STREAM sender, in unit of bytes. 4915 19.5. STOP_SENDING Frame 4917 An endpoint uses a STOP_SENDING frame (type=0x05) to communicate that 4918 incoming data is being discarded on receipt at application request. 4919 STOP_SENDING requests that a peer cease transmission on a stream. 4921 A STOP_SENDING frame can be sent for streams in the Recv or Size 4922 Known states (see Section 3.1). Receiving a STOP_SENDING frame for a 4923 locally-initiated stream that has not yet been created MUST be 4924 treated as a connection error of type STREAM_STATE_ERROR. An 4925 endpoint that receives a STOP_SENDING frame for a receive-only stream 4926 MUST terminate the connection with error STREAM_STATE_ERROR. 4928 The STOP_SENDING frame is as follows: 4930 0 1 2 3 4931 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 4932 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4933 | Stream ID (i) ... 4934 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4935 | Application Error Code (i) ... 4936 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4938 STOP_SENDING frames contain the following fields: 4940 Stream ID: A variable-length integer carrying the Stream ID of the 4941 stream being ignored. 4943 Application Error Code: A variable-length integer containing the 4944 application-specified reason the sender is ignoring the stream 4945 (see Section 20.1). 4947 19.6. CRYPTO Frame 4949 The CRYPTO frame (type=0x06) is used to transmit cryptographic 4950 handshake messages. It can be sent in all packet types. The CRYPTO 4951 frame offers the cryptographic protocol an in-order stream of bytes. 4952 CRYPTO frames are functionally identical to STREAM frames, except 4953 that they do not bear a stream identifier; they are not flow 4954 controlled; and they do not carry markers for optional offset, 4955 optional length, and the end of the stream. 4957 The CRYPTO frame is as follows: 4959 0 1 2 3 4960 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 4961 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4962 | Offset (i) ... 4963 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4964 | Length (i) ... 4965 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4966 | Crypto Data (*) ... 4967 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4969 Figure 19: CRYPTO Frame Format 4971 CRYPTO frames contain the following fields: 4973 Offset: A variable-length integer specifying the byte offset in the 4974 stream for the data in this CRYPTO frame. 4976 Length: A variable-length integer specifying the length of the 4977 Crypto Data field in this CRYPTO frame. 4979 Crypto Data: The cryptographic message data. 4981 There is a separate flow of cryptographic handshake data in each 4982 encryption level, each of which starts at an offset of 0. This 4983 implies that each encryption level is treated as a separate CRYPTO 4984 stream of data. 4986 Unlike STREAM frames, which include a Stream ID indicating to which 4987 stream the data belongs, the CRYPTO frame carries data for a single 4988 stream per encryption level. The stream does not have an explicit 4989 end, so CRYPTO frames do not have a FIN bit. 4991 19.7. NEW_TOKEN Frame 4993 A server sends a NEW_TOKEN frame (type=0x07) to provide the client 4994 with a token to send in the header of an Initial packet for a future 4995 connection. 4997 The NEW_TOKEN frame is as follows: 4999 0 1 2 3 5000 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 5001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5002 | Token Length (i) ... 5003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5004 | Token (*) ... 5005 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5007 NEW_TOKEN frames contain the following fields: 5009 Token Length: A variable-length integer specifying the length of the 5010 token in bytes. 5012 Token: An opaque blob that the client may use with a future Initial 5013 packet. 5015 19.8. STREAM Frames 5017 STREAM frames implicitly create a stream and carry stream data. The 5018 STREAM frame takes the form 0b00001XXX (or the set of values from 5019 0x08 to 0x0f). The value of the three low-order bits of the frame 5020 type determines the fields that are present in the frame. 5022 o The OFF bit (0x04) in the frame type is set to indicate that there 5023 is an Offset field present. When set to 1, the Offset field is 5024 present. When set to 0, the Offset field is absent and the Stream 5025 Data starts at an offset of 0 (that is, the frame contains the 5026 first bytes of the stream, or the end of a stream that includes no 5027 data). 5029 o The LEN bit (0x02) in the frame type is set to indicate that there 5030 is a Length field present. If this bit is set to 0, the Length 5031 field is absent and the Stream Data field extends to the end of 5032 the packet. If this bit is set to 1, the Length field is present. 5034 o The FIN bit (0x01) of the frame type is set only on frames that 5035 contain the final size of the stream. Setting this bit indicates 5036 that the frame marks the end of the stream. 5038 An endpoint that receives a STREAM frame for a send-only stream MUST 5039 terminate the connection with error STREAM_STATE_ERROR. 5041 The STREAM frames are as follows: 5043 0 1 2 3 5044 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 5045 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5046 | Stream ID (i) ... 5047 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5048 | [Offset (i)] ... 5049 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5050 | [Length (i)] ... 5051 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5052 | Stream Data (*) ... 5053 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5055 Figure 20: STREAM Frame Format 5057 STREAM frames contain the following fields: 5059 Stream ID: A variable-length integer indicating the stream ID of the 5060 stream (see Section 2.1). 5062 Offset: A variable-length integer specifying the byte offset in the 5063 stream for the data in this STREAM frame. This field is present 5064 when the OFF bit is set to 1. When the Offset field is absent, 5065 the offset is 0. 5067 Length: A variable-length integer specifying the length of the 5068 Stream Data field in this STREAM frame. This field is present 5069 when the LEN bit is set to 1. When the LEN bit is set to 0, the 5070 Stream Data field consumes all the remaining bytes in the packet. 5072 Stream Data: The bytes from the designated stream to be delivered. 5074 When a Stream Data field has a length of 0, the offset in the STREAM 5075 frame is the offset of the next byte that would be sent. 5077 The first byte in the stream has an offset of 0. The largest offset 5078 delivered on a stream - the sum of the offset and data length - 5079 cannot exceed 2^62-1, as it is not possible to provide flow control 5080 credit for that data. Receipt of a frame that exceeds this limit 5081 will be treated as a connection error of type FLOW_CONTROL_ERROR. 5083 19.9. MAX_DATA Frame 5085 The MAX_DATA frame (type=0x10) is used in flow control to inform the 5086 peer of the maximum amount of data that can be sent on the connection 5087 as a whole. 5089 The MAX_DATA frame is as follows: 5091 0 1 2 3 5092 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 5093 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5094 | Maximum Data (i) ... 5095 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5097 MAX_DATA frames contain the following fields: 5099 Maximum Data: A variable-length integer indicating the maximum 5100 amount of data that can be sent on the entire connection, in units 5101 of bytes. 5103 All data sent in STREAM frames counts toward this limit. The sum of 5104 the largest received offsets on all streams - including streams in 5105 terminal states - MUST NOT exceed the value advertised by a receiver. 5106 An endpoint MUST terminate a connection with a FLOW_CONTROL_ERROR 5107 error if it receives more data than the maximum data value that it 5108 has sent, unless this is a result of a change in the initial limits 5109 (see Section 7.3.1). 5111 19.10. MAX_STREAM_DATA Frame 5113 The MAX_STREAM_DATA frame (type=0x11) is used in flow control to 5114 inform a peer of the maximum amount of data that can be sent on a 5115 stream. 5117 A MAX_STREAM_DATA frame can be sent for streams in the Recv state 5118 (see Section 3.1). Receiving a MAX_STREAM_DATA frame for a locally- 5119 initiated stream that has not yet been created MUST be treated as a 5120 connection error of type STREAM_STATE_ERROR. An endpoint that 5121 receives a MAX_STREAM_DATA frame for a receive-only stream MUST 5122 terminate the connection with error STREAM_STATE_ERROR. 5124 The MAX_STREAM_DATA frame is as follows: 5126 0 1 2 3 5127 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 5128 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5129 | Stream ID (i) ... 5130 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5131 | Maximum Stream Data (i) ... 5132 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5134 MAX_STREAM_DATA frames contain the following fields: 5136 Stream ID: The stream ID of the stream that is affected encoded as a 5137 variable-length integer. 5139 Maximum Stream Data: A variable-length integer indicating the 5140 maximum amount of data that can be sent on the identified stream, 5141 in units of bytes. 5143 When counting data toward this limit, an endpoint accounts for the 5144 largest received offset of data that is sent or received on the 5145 stream. Loss or reordering can mean that the largest received offset 5146 on a stream can be greater than the total size of data received on 5147 that stream. Receiving STREAM frames might not increase the largest 5148 received offset. 5150 The data sent on a stream MUST NOT exceed the largest maximum stream 5151 data value advertised by the receiver. An endpoint MUST terminate a 5152 connection with a FLOW_CONTROL_ERROR error if it receives more data 5153 than the largest maximum stream data that it has sent for the 5154 affected stream, unless this is a result of a change in the initial 5155 limits (see Section 7.3.1). 5157 19.11. MAX_STREAMS Frames 5159 The MAX_STREAMS frames (type=0x12 and 0x13) inform the peer of the 5160 cumulative number of streams of a given type it is permitted to open. 5161 A MAX_STREAMS frame with a type of 0x12 applies to bidirectional 5162 streams, and a MAX_STREAMS frame with a type of 0x13 applies to 5163 unidirectional streams. 5165 The MAX_STREAMS frames are as follows: 5167 0 1 2 3 5168 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 5169 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5170 | Maximum Streams (i) ... 5171 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5173 MAX_STREAMS frames contain the following fields: 5175 Maximum Streams: A count of the cumulative number of streams of the 5176 corresponding type that can be opened over the lifetime of the 5177 connection. 5179 Loss or reordering can cause a MAX_STREAMS frame to be received which 5180 states a lower stream limit than an endpoint has previously received. 5181 MAX_STREAMS frames which do not increase the stream limit MUST be 5182 ignored. 5184 An endpoint MUST NOT open more streams than permitted by the current 5185 stream limit set by its peer. For instance, a server that receives a 5186 unidirectional stream limit of 3 is permitted to open stream 3, 7, 5187 and 11, but not stream 15. An endpoint MUST terminate a connection 5188 with a STREAM_LIMIT_ERROR error if a peer opens more streams than was 5189 permitted. 5191 Note that these frames (and the corresponding transport parameters) 5192 do not describe the number of streams that can be opened 5193 concurrently. The limit includes streams that have been closed as 5194 well as those that are open. 5196 19.12. DATA_BLOCKED Frame 5198 A sender SHOULD send a DATA_BLOCKED frame (type=0x14) when it wishes 5199 to send data, but is unable to due to connection-level flow control 5200 (see Section 4). DATA_BLOCKED frames can be used as input to tuning 5201 of flow control algorithms (see Section 4.2). 5203 The DATA_BLOCKED frame is as follows: 5205 0 1 2 3 5206 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 5207 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5208 | Data Limit (i) ... 5209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5211 DATA_BLOCKED frames contain the following fields: 5213 Data Limit: A variable-length integer indicating the connection- 5214 level limit at which blocking occurred. 5216 19.13. STREAM_DATA_BLOCKED Frame 5218 A sender SHOULD send a STREAM_DATA_BLOCKED frame (type=0x15) when it 5219 wishes to send data, but is unable to due to stream-level flow 5220 control. This frame is analogous to DATA_BLOCKED (Section 19.12). 5222 An endpoint that receives a STREAM_DATA_BLOCKED frame for a send-only 5223 stream MUST terminate the connection with error STREAM_STATE_ERROR. 5225 The STREAM_DATA_BLOCKED frame is as follows: 5227 0 1 2 3 5228 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 5229 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5230 | Stream ID (i) ... 5231 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5232 | Stream Data Limit (i) ... 5233 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5235 STREAM_DATA_BLOCKED frames contain the following fields: 5237 Stream ID: A variable-length integer indicating the stream which is 5238 flow control blocked. 5240 Stream Data Limit: A variable-length integer indicating the offset 5241 of the stream at which the blocking occurred. 5243 19.14. STREAMS_BLOCKED Frames 5245 A sender SHOULD send a STREAMS_BLOCKED frame (type=0x16 or 0x17) when 5246 it wishes to open a stream, but is unable to due to the maximum 5247 stream limit set by its peer (see Section 19.11). A STREAMS_BLOCKED 5248 frame of type 0x16 is used to indicate reaching the bidirectional 5249 stream limit, and a STREAMS_BLOCKED frame of type 0x17 indicates 5250 reaching the unidirectional stream limit. 5252 A STREAMS_BLOCKED frame does not open the stream, but informs the 5253 peer that a new stream was needed and the stream limit prevented the 5254 creation of the stream. 5256 The STREAMS_BLOCKED frames are as follows: 5258 0 1 2 3 5259 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 5260 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5261 | Stream Limit (i) ... 5262 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5264 STREAMS_BLOCKED frames contain the following fields: 5266 Stream Limit: A variable-length integer indicating the stream limit 5267 at the time the frame was sent. 5269 19.15. NEW_CONNECTION_ID Frame 5271 An endpoint sends a NEW_CONNECTION_ID frame (type=0x18) to provide 5272 its peer with alternative connection IDs that can be used to break 5273 linkability when migrating connections (see Section 9.5). 5275 The NEW_CONNECTION_ID frame is as follows: 5277 0 1 2 3 5278 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 5279 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5280 | Sequence Number (i) ... 5281 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5282 | Retire Prior To (i) ... 5283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5284 | Length (8) | | 5285 +-+-+-+-+-+-+-+-+ Connection ID (32..144) + 5286 | ... 5287 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5288 | | 5289 + + 5290 | | 5291 + Stateless Reset Token (128) + 5292 | | 5293 + + 5294 | | 5295 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5297 NEW_CONNECTION_ID frames contain the following fields: 5299 Sequence Number: The sequence number assigned to the connection ID 5300 by the sender. See Section 5.1.1. 5302 Retire Prior To: A variable-length integer indicating which 5303 connection IDs should be retired. See Section 5.1.2. 5305 Length: An 8-bit unsigned integer containing the length of the 5306 connection ID. Values less than 4 and greater than 18 are invalid 5307 and MUST be treated as a connection error of type 5308 PROTOCOL_VIOLATION. 5310 Connection ID: A connection ID of the specified length. 5312 Stateless Reset Token: A 128-bit value that will be used for a 5313 stateless reset when the associated connection ID is used (see 5314 Section 10.4). 5316 An endpoint MUST NOT send this frame if it currently requires that 5317 its peer send packets with a zero-length Destination Connection ID. 5318 Changing the length of a connection ID to or from zero-length makes 5319 it difficult to identify when the value of the connection ID changed. 5320 An endpoint that is sending packets with a zero-length Destination 5321 Connection ID MUST treat receipt of a NEW_CONNECTION_ID frame as a 5322 connection error of type PROTOCOL_VIOLATION. 5324 Transmission errors, timeouts and retransmissions might cause the 5325 same NEW_CONNECTION_ID frame to be received multiple times. Receipt 5326 of the same frame multiple times MUST NOT be treated as a connection 5327 error. A receiver can use the sequence number supplied in the 5328 NEW_CONNECTION_ID frame to identify new connection IDs from old ones. 5330 If an endpoint receives a NEW_CONNECTION_ID frame that repeats a 5331 previously issued connection ID with a different Stateless Reset 5332 Token or a different sequence number, or if a sequence number is used 5333 for different connection IDs, the endpoint MAY treat that receipt as 5334 a connection error of type PROTOCOL_VIOLATION. 5336 The Retire Prior To field is a request for the peer to retire all 5337 connection IDs with a sequence number less than the specified value. 5338 This includes the initial and preferred_address transport parameter 5339 connection IDs. The peer SHOULD retire the corresponding connection 5340 IDs and send the corresponding RETIRE_CONNECTION_ID frames in a 5341 timely manner. 5343 The Retire Prior To field MUST be less than or equal to the Sequence 5344 Number field. Receiving a value greater than the Sequence Number 5345 MUST be treated as a connection error of type PROTOCOL_VIOLATION. 5347 Once a sender indicates a Retire Prior To value, smaller values sent 5348 in subsequent NEW_CONNECTION_ID frames have no effect. A receiver 5349 MUST ignore any Retire Prior To fields that do not increase the 5350 largest received Retire Prior To value. 5352 19.16. RETIRE_CONNECTION_ID Frame 5354 An endpoint sends a RETIRE_CONNECTION_ID frame (type=0x19) to 5355 indicate that it will no longer use a connection ID that was issued 5356 by its peer. This may include the connection ID provided during the 5357 handshake. Sending a RETIRE_CONNECTION_ID frame also serves as a 5358 request to the peer to send additional connection IDs for future use 5359 (see Section 5.1). New connection IDs can be delivered to a peer 5360 using the NEW_CONNECTION_ID frame (Section 19.15). 5362 Retiring a connection ID invalidates the stateless reset token 5363 associated with that connection ID. 5365 The RETIRE_CONNECTION_ID frame is as follows: 5367 0 1 2 3 5368 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 5369 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5370 | Sequence Number (i) ... 5371 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5373 RETIRE_CONNECTION_ID frames contain the following fields: 5375 Sequence Number: The sequence number of the connection ID being 5376 retired. See Section 5.1.2. 5378 Receipt of a RETIRE_CONNECTION_ID frame containing a sequence number 5379 greater than any previously sent to the peer MAY be treated as a 5380 connection error of type PROTOCOL_VIOLATION. 5382 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST 5383 NOT refer to the Destination Connection ID field of the packet in 5384 which the frame is contained. The peer MAY treat this as a 5385 connection error of type PROTOCOL_VIOLATION. 5387 An endpoint cannot send this frame if it was provided with a zero- 5388 length connection ID by its peer. An endpoint that provides a zero- 5389 length connection ID MUST treat receipt of a RETIRE_CONNECTION_ID 5390 frame as a connection error of type PROTOCOL_VIOLATION. 5392 19.17. PATH_CHALLENGE Frame 5394 Endpoints can use PATH_CHALLENGE frames (type=0x1a) to check 5395 reachability to the peer and for path validation during connection 5396 migration. 5398 The PATH_CHALLENGE frames are as follows: 5400 0 1 2 3 5401 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 5402 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5403 | | 5404 + Data (64) + 5405 | | 5406 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5408 PATH_CHALLENGE frames contain the following fields: 5410 Data: This 8-byte field contains arbitrary data. 5412 A PATH_CHALLENGE frame containing 8 bytes that are hard to guess is 5413 sufficient to ensure that it is easier to receive the packet than it 5414 is to guess the value correctly. 5416 The recipient of this frame MUST generate a PATH_RESPONSE frame 5417 (Section 19.18) containing the same Data. 5419 19.18. PATH_RESPONSE Frame 5421 The PATH_RESPONSE frame (type=0x1b) is sent in response to a 5422 PATH_CHALLENGE frame. Its format is identical to the PATH_CHALLENGE 5423 frame (Section 19.17). 5425 If the content of a PATH_RESPONSE frame does not match the content of 5426 a PATH_CHALLENGE frame previously sent by the endpoint, the endpoint 5427 MAY generate a connection error of type PROTOCOL_VIOLATION. 5429 19.19. CONNECTION_CLOSE Frames 5431 An endpoint sends a CONNECTION_CLOSE frame (type=0x1c or 0x1d) to 5432 notify its peer that the connection is being closed. The 5433 CONNECTION_CLOSE with a frame type of 0x1c is used to signal errors 5434 at only the QUIC layer, or the absence of errors (with the NO_ERROR 5435 code). The CONNECTION_CLOSE frame with a type of 0x1d is used to 5436 signal an error with the application that uses QUIC. 5438 If there are open streams that haven't been explicitly closed, they 5439 are implicitly closed when the connection is closed. 5441 The CONNECTION_CLOSE frames are as follows: 5443 0 1 2 3 5444 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 5445 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5446 | Error Code (i) ... 5447 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5448 | [ Frame Type (i) ] ... 5449 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5450 | Reason Phrase Length (i) ... 5451 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5452 | Reason Phrase (*) ... 5453 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5455 CONNECTION_CLOSE frames contain the following fields: 5457 Error Code: A variable length integer error code which indicates the 5458 reason for closing this connection. A CONNECTION_CLOSE frame of 5459 type 0x1c uses codes from the space defined in Section 20. A 5460 CONNECTION_CLOSE frame of type 0x1d uses codes from the 5461 application protocol error code space; see Section 20.1 5463 Frame Type: A variable-length integer encoding the type of frame 5464 that triggered the error. A value of 0 (equivalent to the mention 5465 of the PADDING frame) is used when the frame type is unknown. The 5466 application-specific variant of CONNECTION_CLOSE (type 0x1d) does 5467 not include this field. 5469 Reason Phrase Length: A variable-length integer specifying the 5470 length of the reason phrase in bytes. Because a CONNECTION_CLOSE 5471 frame cannot be split between packets, any limits on packet size 5472 will also limit the space available for a reason phrase. 5474 Reason Phrase: A human-readable explanation for why the connection 5475 was closed. This can be zero length if the sender chooses to not 5476 give details beyond the Error Code. This SHOULD be a UTF-8 5477 encoded string [RFC3629]. 5479 19.20. Extension Frames 5481 QUIC frames do not use a self-describing encoding. An endpoint 5482 therefore needs to understand the syntax of all frames before it can 5483 successfully process a packet. This allows for efficient encoding of 5484 frames, but it means that an endpoint cannot send a frame of a type 5485 that is unknown to its peer. 5487 An extension to QUIC that wishes to use a new type of frame MUST 5488 first ensure that a peer is able to understand the frame. An 5489 endpoint can use a transport parameter to signal its willingness to 5490 receive one or more extension frame types with the one transport 5491 parameter. 5493 Extension frames MUST be congestion controlled and MUST cause an ACK 5494 frame to be sent. The exception is extension frames that replace or 5495 supplement the ACK frame. Extension frames are not included in flow 5496 control unless specified in the extension. 5498 An IANA registry is used to manage the assignment of frame types; see 5499 Section 22.2. 5501 20. Transport Error Codes 5503 QUIC error codes are 62-bit unsigned integers. 5505 This section lists the defined QUIC transport error codes that may be 5506 used in a CONNECTION_CLOSE frame. These errors apply to the entire 5507 connection. 5509 NO_ERROR (0x0): An endpoint uses this with CONNECTION_CLOSE to 5510 signal that the connection is being closed abruptly in the absence 5511 of any error. 5513 INTERNAL_ERROR (0x1): The endpoint encountered an internal error and 5514 cannot continue with the connection. 5516 SERVER_BUSY (0x2): The server is currently busy and does not accept 5517 any new connections. 5519 FLOW_CONTROL_ERROR (0x3): An endpoint received more data than it 5520 permitted in its advertised data limits (see Section 4). 5522 STREAM_LIMIT_ERROR (0x4): An endpoint received a frame for a stream 5523 identifier that exceeded its advertised stream limit for the 5524 corresponding stream type. 5526 STREAM_STATE_ERROR (0x5): An endpoint received a frame for a stream 5527 that was not in a state that permitted that frame (see Section 3). 5529 FINAL_SIZE_ERROR (0x6): An endpoint received a STREAM frame 5530 containing data that exceeded the previously established final 5531 size. Or an endpoint received a STREAM frame or a RESET_STREAM 5532 frame containing a final size that was lower than the size of 5533 stream data that was already received. Or an endpoint received a 5534 STREAM frame or a RESET_STREAM frame containing a different final 5535 size to the one already established. 5537 FRAME_ENCODING_ERROR (0x7): An endpoint received a frame that was 5538 badly formatted. For instance, a frame of an unknown type, or an 5539 ACK frame that has more acknowledgment ranges than the remainder 5540 of the packet could carry. 5542 TRANSPORT_PARAMETER_ERROR (0x8): An endpoint received transport 5543 parameters that were badly formatted, included an invalid value, 5544 was absent even though it is mandatory, was present though it is 5545 forbidden, or is otherwise in error. 5547 PROTOCOL_VIOLATION (0xA): An endpoint detected an error with 5548 protocol compliance that was not covered by more specific error 5549 codes. 5551 INVALID_MIGRATION (0xC): A peer has migrated to a different network 5552 when the endpoint had disabled migration. 5554 CRYPTO_BUFFER_EXCEEDED (0xD): An endpoint has received more data in 5555 CRYPTO frames than it can buffer. 5557 CRYPTO_ERROR (0x1XX): The cryptographic handshake failed. A range 5558 of 256 values is reserved for carrying error codes specific to the 5559 cryptographic handshake that is used. Codes for errors occurring 5560 when TLS is used for the crypto handshake are described in 5561 Section 4.8 of [QUIC-TLS]. 5563 See Section 22.3 for details of registering new error codes. 5565 20.1. Application Protocol Error Codes 5567 Application protocol error codes are 62-bit unsigned integers, but 5568 the management of application error codes is left to application 5569 protocols. Application protocol error codes are used for the 5570 RESET_STREAM frame (Section 19.4), the STOP_SENDING frame 5571 (Section 19.5), and the CONNECTION_CLOSE frame with a type of 0x1d 5572 (Section 19.19). 5574 21. Security Considerations 5576 21.1. Handshake Denial of Service 5578 As an encrypted and authenticated transport QUIC provides a range of 5579 protections against denial of service. Once the cryptographic 5580 handshake is complete, QUIC endpoints discard most packets that are 5581 not authenticated, greatly limiting the ability of an attacker to 5582 interfere with existing connections. 5584 Once a connection is established QUIC endpoints might accept some 5585 unauthenticated ICMP packets (see Section 14.2), but the use of these 5586 packets is extremely limited. The only other type of packet that an 5587 endpoint might accept is a stateless reset (Section 10.4) which 5588 relies on the token being kept secret until it is used. 5590 During the creation of a connection, QUIC only provides protection 5591 against attack from off the network path. All QUIC packets contain 5592 proof that the recipient saw a preceding packet from its peer. 5594 The first mechanism used is the source and destination connection 5595 IDs, which are required to match those set by a peer. Except for an 5596 Initial and stateless reset packets, an endpoint only accepts packets 5597 that include a destination connection that matches a connection ID 5598 the endpoint previously chose. This is the only protection offered 5599 for Version Negotiation packets. 5601 The destination connection ID in an Initial packet is selected by a 5602 client to be unpredictable, which serves an additional purpose. The 5603 packets that carry the cryptographic handshake are protected with a 5604 key that is derived from this connection ID and salt specific to the 5605 QUIC version. This allows endpoints to use the same process for 5606 authenticating packets that they receive as they use after the 5607 cryptographic handshake completes. Packets that cannot be 5608 authenticated are discarded. Protecting packets in this fashion 5609 provides a strong assurance that the sender of the packet saw the 5610 Initial packet and understood it. 5612 These protections are not intended to be effective against an 5613 attacker that is able to receive QUIC packets prior to the connection 5614 being established. Such an attacker can potentially send packets 5615 that will be accepted by QUIC endpoints. This version of QUIC 5616 attempts to detect this sort of attack, but it expects that endpoints 5617 will fail to establish a connection rather than recovering. For the 5618 most part, the cryptographic handshake protocol [QUIC-TLS] is 5619 responsible for detecting tampering during the handshake. 5621 Endpoints are permitted to use other methods to detect and attempt to 5622 recover from interference with the handshake. Invalid packets may be 5623 identified and discarded using other methods, but no specific method 5624 is mandated in this document. 5626 21.2. Amplification Attack 5628 An attacker might be able to receive an address validation token 5629 (Section 8) from a server and then release the IP address it used to 5630 acquire that token. At a later time, the attacker may initiate a 5631 0-RTT connection with a server by spoofing this same address, which 5632 might now address a different (victim) endpoint. The attacker can 5633 thus potentially cause the server to send an initial congestion 5634 window's worth of data towards the victim. 5636 Servers SHOULD provide mitigations for this attack by limiting the 5637 usage and lifetime of address validation tokens (see Section 8.1.2). 5639 21.3. Optimistic ACK Attack 5641 An endpoint that acknowledges packets it has not received might cause 5642 a congestion controller to permit sending at rates beyond what the 5643 network supports. An endpoint MAY skip packet numbers when sending 5644 packets to detect this behavior. An endpoint can then immediately 5645 close the connection with a connection error of type 5646 PROTOCOL_VIOLATION (see Section 10.3). 5648 21.4. Slowloris Attacks 5650 The attacks commonly known as Slowloris [SLOWLORIS] try to keep many 5651 connections to the target endpoint open and hold them open as long as 5652 possible. These attacks can be executed against a QUIC endpoint by 5653 generating the minimum amount of activity necessary to avoid being 5654 closed for inactivity. This might involve sending small amounts of 5655 data, gradually opening flow control windows in order to control the 5656 sender rate, or manufacturing ACK frames that simulate a high loss 5657 rate. 5659 QUIC deployments SHOULD provide mitigations for the Slowloris 5660 attacks, such as increasing the maximum number of clients the server 5661 will allow, limiting the number of connections a single IP address is 5662 allowed to make, imposing restrictions on the minimum transfer speed 5663 a connection is allowed to have, and restricting the length of time 5664 an endpoint is allowed to stay connected. 5666 21.5. Stream Fragmentation and Reassembly Attacks 5668 An adversarial sender might intentionally send fragments of stream 5669 data in order to cause disproportionate receive buffer memory 5670 commitment and/or creation of a large and inefficient data structure. 5672 An adversarial receiver might intentionally not acknowledge packets 5673 containing stream data in order to force the sender to store the 5674 unacknowledged stream data for retransmission. 5676 The attack on receivers is mitigated if flow control windows 5677 correspond to available memory. However, some receivers will over- 5678 commit memory and advertise flow control offsets in the aggregate 5679 that exceed actual available memory. The over-commitment strategy 5680 can lead to better performance when endpoints are well behaved, but 5681 renders endpoints vulnerable to the stream fragmentation attack. 5683 QUIC deployments SHOULD provide mitigations against stream 5684 fragmentation attacks. Mitigations could consist of avoiding over- 5685 committing memory, limiting the size of tracking data structures, 5686 delaying reassembly of STREAM frames, implementing heuristics based 5687 on the age and duration of reassembly holes, or some combination. 5689 21.6. Stream Commitment Attack 5691 An adversarial endpoint can open lots of streams, exhausting state on 5692 an endpoint. The adversarial endpoint could repeat the process on a 5693 large number of connections, in a manner similar to SYN flooding 5694 attacks in TCP. 5696 Normally, clients will open streams sequentially, as explained in 5697 Section 2.1. However, when several streams are initiated at short 5698 intervals, transmission error may cause STREAM DATA frames opening 5699 streams to be received out of sequence. A receiver is obligated to 5700 open intervening streams if a higher-numbered stream ID is received. 5701 Thus, on a new connection, opening stream 2000001 opens 1 million 5702 streams, as required by the specification. 5704 The number of active streams is limited by the 5705 initial_max_streams_bidi and initial_max_streams_uni transport 5706 parameters, as explained in Section 4.5. If chosen judiciously, 5707 these limits mitigate the effect of the stream commitment attack. 5708 However, setting the limit too low could affect performance when 5709 applications expect to open large number of streams. 5711 21.7. Explicit Congestion Notification Attacks 5713 An on-path attacker could manipulate the value of ECN codepoints in 5714 the IP header to influence the sender's rate. [RFC3168] discusses 5715 manipulations and their effects in more detail. 5717 An on-the-side attacker can duplicate and send packets with modified 5718 ECN codepoints to affect the sender's rate. If duplicate packets are 5719 discarded by a receiver, an off-path attacker will need to race the 5720 duplicate packet against the original to be successful in this 5721 attack. Therefore, QUIC endpoints ignore the ECN codepoint field on 5722 an IP packet unless at least one QUIC packet in that IP packet is 5723 successfully processed; see Section 13.3. 5725 21.8. Stateless Reset Oracle 5727 Stateless resets create a possible denial of service attack analogous 5728 to a TCP reset injection. This attack is possible if an attacker is 5729 able to cause a stateless reset token to be generated for a 5730 connection with a selected connection ID. An attacker that can cause 5731 this token to be generated can reset an active connection with the 5732 same connection ID. 5734 If a packet can be routed to different instances that share a static 5735 key, for example by changing an IP address or port, then an attacker 5736 can cause the server to send a stateless reset. To defend against 5737 this style of denial service, endpoints that share a static key for 5738 stateless reset (see Section 10.4.2) MUST be arranged so that packets 5739 with a given connection ID always arrive at an instance that has 5740 connection state, unless that connection is no longer active. 5742 In the case of a cluster that uses dynamic load balancing, it's 5743 possible that a change in load balancer configuration could happen 5744 while an active instance retains connection state; even if an 5745 instance retains connection state, the change in routing and 5746 resulting stateless reset will result in the connection being 5747 terminated. If there is no chance in the packet being routed to the 5748 correct instance, it is better to send a stateless reset than wait 5749 for connections to time out. However, this is acceptable only if the 5750 routing cannot be influenced by an attacker. 5752 21.9. Version Downgrade 5754 This document defines QUIC Version Negotiation packets Section 6, 5755 which can be used to negotiate the QUIC version used between two 5756 endpoints. However, this document does not specify how this 5757 negotiation will be performed between this version and subsequent 5758 future versions. In particular, Version Negotiation packets do not 5759 contain any mechanism to prevent version downgrade attacks. Future 5760 versions of QUIC that use Version Negotiation packets MUST define a 5761 mechanism that is robust against version downgrade attacks. 5763 21.10. Targeted Attacks by Routing 5765 Deployments should limit the ability of an attacker to target a new 5766 connection to a particular server instance. This means that client- 5767 controlled fields, such as the initial Destination Connection ID used 5768 on Initial and 0-RTT packets SHOULD NOT be used by themselves to make 5769 routing decisions. Ideally, routing decisions are made independently 5770 of client-selected values; a Source Connection ID can be selected to 5771 route later packets to the same server. 5773 22. IANA Considerations 5775 22.1. QUIC Transport Parameter Registry 5777 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 5778 under a "QUIC Protocol" heading. 5780 The "QUIC Transport Parameters" registry governs a 16-bit space. 5781 This space is split into two spaces that are governed by different 5782 policies. Values with the first byte in the range 0x00 to 0xfe (in 5783 hexadecimal) are assigned via the Specification Required policy 5784 [RFC8126]. Values with the first byte 0xff are reserved for Private 5785 Use [RFC8126]. 5787 Registrations MUST include the following fields: 5789 Value: The numeric value of the assignment (registrations will be 5790 between 0x0000 and 0xfeff). 5792 Parameter Name: A short mnemonic for the parameter. 5794 Specification: A reference to a publicly available specification for 5795 the value. 5797 The nominated expert(s) verify that a specification exists and is 5798 readily accessible. Expert(s) are encouraged to be biased towards 5799 approving registrations unless they are abusive, frivolous, or 5800 actively harmful (not merely aesthetically displeasing, or 5801 architecturally dubious). 5803 The initial contents of this registry are shown in Table 6. 5805 +--------+-------------------------------------+---------------+ 5806 | Value | Parameter Name | Specification | 5807 +--------+-------------------------------------+---------------+ 5808 | 0x0000 | original_connection_id | Section 18.1 | 5809 | | | | 5810 | 0x0001 | idle_timeout | Section 18.1 | 5811 | | | | 5812 | 0x0002 | stateless_reset_token | Section 18.1 | 5813 | | | | 5814 | 0x0003 | max_packet_size | Section 18.1 | 5815 | | | | 5816 | 0x0004 | initial_max_data | Section 18.1 | 5817 | | | | 5818 | 0x0005 | initial_max_stream_data_bidi_local | Section 18.1 | 5819 | | | | 5820 | 0x0006 | initial_max_stream_data_bidi_remote | Section 18.1 | 5821 | | | | 5822 | 0x0007 | initial_max_stream_data_uni | Section 18.1 | 5823 | | | | 5824 | 0x0008 | initial_max_streams_bidi | Section 18.1 | 5825 | | | | 5826 | 0x0009 | initial_max_streams_uni | Section 18.1 | 5827 | | | | 5828 | 0x000a | ack_delay_exponent | Section 18.1 | 5829 | | | | 5830 | 0x000b | max_ack_delay | Section 18.1 | 5831 | | | | 5832 | 0x000c | disable_migration | Section 18.1 | 5833 | | | | 5834 | 0x000d | preferred_address | Section 18.1 | 5835 | | | | 5836 | 0x000e | active_connection_id_limit | Section 18.1 | 5837 +--------+-------------------------------------+---------------+ 5839 Table 6: Initial QUIC Transport Parameters Entries 5841 22.2. QUIC Frame Type Registry 5843 IANA [SHALL add/has added] a registry for "QUIC Frame Types" under a 5844 "QUIC Protocol" heading. 5846 The "QUIC Frame Types" registry governs a 62-bit space. This space 5847 is split into three spaces that are governed by different policies. 5848 Values between 0x00 and 0x3f (in hexadecimal) are assigned via the 5849 Standards Action or IESG Review policies [RFC8126]. Values from 0x40 5850 to 0x3fff operate on the Specification Required policy [RFC8126]. 5851 All other values are assigned to Private Use [RFC8126]. 5853 Registrations MUST include the following fields: 5855 Value: The numeric value of the assignment (registrations will be 5856 between 0x00 and 0x3fff). A range of values MAY be assigned. 5858 Frame Name: A short mnemonic for the frame type. 5860 Specification: A reference to a publicly available specification for 5861 the value. 5863 The nominated expert(s) verify that a specification exists and is 5864 readily accessible. Specifications for new registrations need to 5865 describe the means by which an endpoint might determine that it can 5866 send the identified type of frame. An accompanying transport 5867 parameter registration (see Section 22.1) is expected for most 5868 registrations. The specification needs to describe the format and 5869 assigned semantics of any fields in the frame. 5871 Expert(s) are encouraged to be biased towards approving registrations 5872 unless they are abusive, frivolous, or actively harmful (not merely 5873 aesthetically displeasing, or architecturally dubious). 5875 The initial contents of this registry are tabulated in Table 3. 5877 22.3. QUIC Transport Error Codes Registry 5879 IANA [SHALL add/has added] a registry for "QUIC Transport Error 5880 Codes" under a "QUIC Protocol" heading. 5882 The "QUIC Transport Error Codes" registry governs a 62-bit space. 5883 This space is split into three spaces that are governed by different 5884 policies. Values between 0x00 and 0x3f (in hexadecimal) are assigned 5885 via the Standards Action or IESG Review policies [RFC8126]. Values 5886 from 0x40 to 0x3fff operate on the Specification Required policy 5887 [RFC8126]. All other values are assigned to Private Use [RFC8126]. 5889 Registrations MUST include the following fields: 5891 Value: The numeric value of the assignment (registrations will be 5892 between 0x0000 and 0x3fff). 5894 Code: A short mnemonic for the parameter. 5896 Description: A brief description of the error code semantics, which 5897 MAY be a summary if a specification reference is provided. 5899 Specification: A reference to a publicly available specification for 5900 the value. 5902 The nominated expert(s) verify that a specification exists and is 5903 readily accessible. Expert(s) are encouraged to be biased towards 5904 approving registrations unless they are abusive, frivolous, or 5905 actively harmful (not merely aesthetically displeasing, or 5906 architecturally dubious). 5908 The initial contents of this registry are shown in Table 7. 5910 +------+---------------------------+----------------+---------------+ 5911 | Valu | Error | Description | Specification | 5912 | e | | | | 5913 +------+---------------------------+----------------+---------------+ 5914 | 0x0 | NO_ERROR | No error | Section 20 | 5915 | | | | | 5916 | 0x1 | INTERNAL_ERROR | Implementation | Section 20 | 5917 | | | error | | 5918 | | | | | 5919 | 0x2 | SERVER_BUSY | Server | Section 20 | 5920 | | | currently busy | | 5921 | | | | | 5922 | 0x3 | FLOW_CONTROL_ERROR | Flow control | Section 20 | 5923 | | | error | | 5924 | | | | | 5925 | 0x4 | STREAM_LIMIT_ERROR | Too many | Section 20 | 5926 | | | streams opened | | 5927 | | | | | 5928 | 0x5 | STREAM_STATE_ERROR | Frame received | Section 20 | 5929 | | | in invalid | | 5930 | | | stream state | | 5931 | | | | | 5932 | 0x6 | FINAL_SIZE_ERROR | Change to | Section 20 | 5933 | | | final size | | 5934 | | | | | 5935 | 0x7 | FRAME_ENCODING_ERROR | Frame encoding | Section 20 | 5936 | | | error | | 5937 | | | | | 5938 | 0x8 | TRANSPORT_PARAMETER_ERROR | Error in | Section 20 | 5939 | | | transport | | 5940 | | | parameters | | 5941 | | | | | 5942 | 0xA | PROTOCOL_VIOLATION | Generic | Section 20 | 5943 | | | protocol | | 5944 | | | violation | | 5945 | | | | | 5946 | 0xC | INVALID_MIGRATION | Violated | Section 20 | 5947 | | | disabled | | 5948 | | | migration | | 5949 +------+---------------------------+----------------+---------------+ 5951 Table 7: Initial QUIC Transport Error Codes Entries 5953 23. References 5954 23.1. Normative References 5956 [DPLPMTUD] 5957 Fairhurst, G., Jones, T., Tuexen, M., Ruengeler, I., and 5958 T. Voelker, "Packetization Layer Path MTU Discovery for 5959 Datagram Transports", draft-ietf-tsvwg-datagram-plpmtud-08 5960 (work in progress), June 2019. 5962 [QUIC-RECOVERY] 5963 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 5964 and Congestion Control", draft-ietf-quic-recovery-21 (work 5965 in progress), July 2019. 5967 [QUIC-TLS] 5968 Thomson, M., Ed. and S. Turner, Ed., "Using Transport 5969 Layer Security (TLS) to Secure QUIC", draft-ietf-quic- 5970 tls-21 (work in progress), July 2019. 5972 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 5973 DOI 10.17487/RFC1191, November 1990, 5974 . 5976 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5977 Requirement Levels", BCP 14, RFC 2119, 5978 DOI 10.17487/RFC2119, March 1997, 5979 . 5981 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 5982 of Explicit Congestion Notification (ECN) to IP", 5983 RFC 3168, DOI 10.17487/RFC3168, September 2001, 5984 . 5986 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5987 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 5988 2003, . 5990 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 5991 "Randomness Requirements for Security", BCP 106, RFC 4086, 5992 DOI 10.17487/RFC4086, June 2005, 5993 . 5995 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 5996 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 5997 . 5999 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 6000 "IPv6 Flow Label Specification", RFC 6437, 6001 DOI 10.17487/RFC6437, November 2011, 6002 . 6004 [RFC8085] Eggert, L., Fairhurst, G., and G. Shepherd, "UDP Usage 6005 Guidelines", BCP 145, RFC 8085, DOI 10.17487/RFC8085, 6006 March 2017, . 6008 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 6009 Writing an IANA Considerations Section in RFCs", BCP 26, 6010 RFC 8126, DOI 10.17487/RFC8126, June 2017, 6011 . 6013 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6014 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6015 May 2017, . 6017 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 6018 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 6019 DOI 10.17487/RFC8201, July 2017, 6020 . 6022 [RFC8311] Black, D., "Relaxing Restrictions on Explicit Congestion 6023 Notification (ECN) Experimentation", RFC 8311, 6024 DOI 10.17487/RFC8311, January 2018, 6025 . 6027 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 6028 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 6029 . 6031 23.2. Informative References 6033 [EARLY-DESIGN] 6034 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 6035 December 2013, . 6037 [HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 6038 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 6039 DOI 10.17487/RFC7540, May 2015, 6040 . 6042 [QUIC-INVARIANTS] 6043 Thomson, M., "Version-Independent Properties of QUIC", 6044 draft-ietf-quic-invariants-05 (work in progress), July 6045 2019. 6047 [QUIC-MANAGEABILITY] 6048 Kuehlewind, M. and B. Trammell, "Manageability of the QUIC 6049 Transport Protocol", draft-ietf-quic-manageability-05 6050 (work in progress), July 2019. 6052 [RFC1812] Baker, F., Ed., "Requirements for IP Version 4 Routers", 6053 RFC 1812, DOI 10.17487/RFC1812, June 1995, 6054 . 6056 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 6057 Selective Acknowledgment Options", RFC 2018, 6058 DOI 10.17487/RFC2018, October 1996, 6059 . 6061 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 6062 Hashing for Message Authentication", RFC 2104, 6063 DOI 10.17487/RFC2104, February 1997, 6064 . 6066 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 6067 RFC 2360, DOI 10.17487/RFC2360, June 1998, 6068 . 6070 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 6071 RFC 4303, DOI 10.17487/RFC4303, December 2005, 6072 . 6074 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 6075 Control Message Protocol (ICMPv6) for the Internet 6076 Protocol Version 6 (IPv6) Specification", STD 89, 6077 RFC 4443, DOI 10.17487/RFC4443, March 2006, 6078 . 6080 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 6081 Translation (NAT) Behavioral Requirements for Unicast 6082 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 6083 2007, . 6085 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 6086 Key Derivation Function (HKDF)", RFC 5869, 6087 DOI 10.17487/RFC5869, May 2010, 6088 . 6090 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 6091 "Transport Layer Security (TLS) Application-Layer Protocol 6092 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 6093 July 2014, . 6095 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 6096 (IPv6) Specification", STD 86, RFC 8200, 6097 DOI 10.17487/RFC8200, July 2017, 6098 . 6100 [SLOWLORIS] 6101 RSnake Hansen, R., "Welcome to Slowloris...", June 2009, 6102 . 6105 Appendix A. Sample Packet Number Decoding Algorithm 6107 The following pseudo-code shows how an implementation can decode 6108 packet numbers after header protection has been removed. 6110 DecodePacketNumber(largest_pn, truncated_pn, pn_nbits): 6111 expected_pn = largest_pn + 1 6112 pn_win = 1 << pn_nbits 6113 pn_hwin = pn_win / 2 6114 pn_mask = pn_win - 1 6115 // The incoming packet number should be greater than 6116 // expected_pn - pn_hwin and less than or equal to 6117 // expected_pn + pn_hwin 6118 // 6119 // This means we can't just strip the trailing bits from 6120 // expected_pn and add the truncated_pn because that might 6121 // yield a value outside the window. 6122 // 6123 // The following code calculates a candidate value and 6124 // makes sure it's within the packet number window. 6125 candidate_pn = (expected_pn & ~pn_mask) | truncated_pn 6126 if candidate_pn <= expected_pn - pn_hwin: 6127 return candidate_pn + pn_win 6128 // Note the extra check for underflow when candidate_pn 6129 // is near zero. 6130 if candidate_pn > expected_pn + pn_hwin and 6131 candidate_pn > pn_win: 6132 return candidate_pn - pn_win 6133 return candidate_pn 6135 Appendix B. Change Log 6137 *RFC Editor's Note:* Please remove this section prior to 6138 publication of a final version of this document. 6140 Issue and pull request numbers are listed with a leading octothorp. 6142 B.1. Since draft-ietf-quic-transport-20 6144 o Connection ID lengths are now one octet, but limited in version 1 6145 to 20 octets of length (#2736, #2749) 6147 o Error codes are encoded as variable-length integers (#2672, #2680) 6149 o NEW_CONNECTION_ID includes a request to retire old connection IDs 6150 (#2645, #2769) 6152 o Tighter rules for generating and explicitly eliciting ACK frames 6153 (#2546, #2794) 6155 o Recommend having only one packet per encryption level in a 6156 datagram (#2308, #2747) 6158 o More normative language about use of stateless reset (#2471, 6159 #2574) 6161 o Allow reuse of stateless reset tokens (#2732, #2733) 6163 o Allow, but not require, enforcing non-duplicate transport 6164 parameters (#2689, #2691) 6166 o Added a active_connection_id_limit transport parameter (#1994, 6167 #1998) 6169 o max_ack_delay transport parameter defaults to 0 (#2638, #2646) 6171 o When sending 0-RTT, only remembered transport parameters apply 6172 (#2458, #2360, #2466, #2461) 6174 o Define handshake completion and confirmation; define clearer rules 6175 when it encryption keys should be discarded (#2214, #2267, #2673) 6177 o Prohibit path migration prior to handshake confirmation (#2309, 6178 #2370) 6180 o PATH_RESPONSE no longer needs to be received on the validated path 6181 (#2582, #2580, #2579, #2637) 6183 o PATH_RESPONSE frames are not stored and retransmitted (#2724, 6184 #2729) 6186 o Document hack for enabling routing of ICMP when doing PMTU probing 6187 (#1243, #2402) 6189 B.2. Since draft-ietf-quic-transport-19 6191 o Refine discussion of 0-RTT transport parameters (#2467, #2464) 6193 o Fewer transport parameters need to be remembered for 0-RTT (#2624, 6194 #2467) 6196 o Spin bit text incorporated (#2564) 6198 o Close the connection when maximum stream ID in MAX_STREAMS exceeds 6199 2^62 - 1 (#2499, #2487) 6201 o New connection ID required for intentional migration (#2414, 6202 #2413) 6204 o Connection ID issuance can be rate-limited (#2436, #2428) 6206 o The "QUIC bit" is ignored in Version Negotiation (#2400, #2561) 6208 o Initial packets from clients need to be padded to 1200 unless a 6209 Handshake packet is sent as well (#2522, #2523) 6211 o CRYPTO frames can be discarded if too much data is buffered 6212 (#1834, #2524) 6214 o Stateless reset uses a short header packet (#2599, #2600) 6216 B.3. Since draft-ietf-quic-transport-18 6218 o Removed version negotiation; version negotiation, including 6219 authentication of the result, will be addressed in the next 6220 version of QUIC (#1773, #2313) 6222 o Added discussion of the use of IPv6 flow labels (#2348, #2399) 6224 o A connection ID can't be retired in a packet that uses that 6225 connection ID (#2101, #2420) 6227 o Idle timeout transport parameter is in milliseconds (from seconds) 6228 (#2453, #2454) 6230 o Endpoints are required to use new connection IDs when they use new 6231 network paths (#2413, #2414) 6233 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 6235 B.4. Since draft-ietf-quic-transport-17 6237 o Stream-related errors now use STREAM_STATE_ERROR (#2305) 6239 o Endpoints discard initial keys as soon as handshake keys are 6240 available (#1951, #2045) 6242 o Expanded conditions for ignoring ICMP packet too big messages 6243 (#2108, #2161) 6245 o Remove rate control from PATH_CHALLENGE/PATH_RESPONSE (#2129, 6246 #2241) 6248 o Endpoints are permitted to discard malformed initial packets 6249 (#2141) 6251 o Clarified ECN implementation and usage requirements (#2156, #2201) 6253 o Disable ECN count verification for packets that arrive out of 6254 order (#2198, #2215) 6256 o Use Probe Timeout (PTO) instead of RTO (#2206, #2238) 6258 o Loosen constraints on retransmission of ACK ranges (#2199, #2245) 6260 o Limit Retry and Version Negotiation to once per datagram (#2259, 6261 #2303) 6263 o Set a maximum value for max_ack_delay transport parameter (#2282, 6264 #2301) 6266 o Allow server preferred address for both IPv4 and IPv6 (#2122, 6267 #2296) 6269 o Corrected requirements for migration to a preferred address 6270 (#2146, #2349) 6272 o ACK of non-existent packet is illegal (#2298, #2302) 6274 B.5. Since draft-ietf-quic-transport-16 6276 o Stream limits are defined as counts, not maximums (#1850, #1906) 6278 o Require amplification attack defense after closing (#1905, #1911) 6280 o Remove reservation of application error code 0 for STOPPING 6281 (#1804, #1922) 6283 o Renumbered frames (#1945) 6285 o Renumbered transport parameters (#1946) 6287 o Numeric transport parameters are expressed as varints (#1608, 6288 #1947, #1955) 6290 o Reorder the NEW_CONNECTION_ID frame (#1952, #1963) 6292 o Rework the first byte (#2006) 6294 * Fix the 0x40 bit 6296 * Change type values for long header 6298 * Add spin bit to short header (#631, #1988) 6300 * Encrypt the remainder of the first byte (#1322) 6302 * Move packet number length to first byte 6304 * Move ODCIL to first byte of retry packets 6306 * Simplify packet number protection (#1575) 6308 o Allow STOP_SENDING to open a remote bidirectional stream (#1797, 6309 #2013) 6311 o Added mitigation for off-path migration attacks (#1278, #1749, 6312 #2033) 6314 o Don't let the PMTU to drop below 1280 (#2063, #2069) 6316 o Require peers to replace retired connection IDs (#2085) 6318 o Servers are required to ignore Version Negotiation packets (#2088) 6320 o Tokens are repeated in all Initial packets (#2089) 6322 o Clarified how PING frames are sent after loss (#2094) 6324 o Initial keys are discarded once Handshake are available (#1951, 6325 #2045) 6327 o ICMP PTB validation clarifications (#2161, #2109, #2108) 6329 B.6. Since draft-ietf-quic-transport-15 6331 Substantial editorial reorganization; no technical changes. 6333 B.7. Since draft-ietf-quic-transport-14 6335 o Merge ACK and ACK_ECN (#1778, #1801) 6337 o Explicitly communicate max_ack_delay (#981, #1781) 6339 o Validate original connection ID after Retry packets (#1710, #1486, 6340 #1793) 6342 o Idle timeout is optional and has no specified maximum (#1765) 6344 o Update connection ID handling; add RETIRE_CONNECTION_ID type 6345 (#1464, #1468, #1483, #1484, #1486, #1495, #1729, #1742, #1799, 6346 #1821) 6348 o Include a Token in all Initial packets (#1649, #1794) 6350 o Prevent handshake deadlock (#1764, #1824) 6352 B.8. Since draft-ietf-quic-transport-13 6354 o Streams open when higher-numbered streams of the same type open 6355 (#1342, #1549) 6357 o Split initial stream flow control limit into 3 transport 6358 parameters (#1016, #1542) 6360 o All flow control transport parameters are optional (#1610) 6362 o Removed UNSOLICITED_PATH_RESPONSE error code (#1265, #1539) 6364 o Permit stateless reset in response to any packet (#1348, #1553) 6366 o Recommended defense against stateless reset spoofing (#1386, 6367 #1554) 6369 o Prevent infinite stateless reset exchanges (#1443, #1627) 6371 o Forbid processing of the same packet number twice (#1405, #1624) 6373 o Added a packet number decoding example (#1493) 6375 o More precisely define idle timeout (#1429, #1614, #1652) 6376 o Corrected format of Retry packet and prevented looping (#1492, 6377 #1451, #1448, #1498) 6379 o Permit 0-RTT after receiving Version Negotiation or Retry (#1507, 6380 #1514, #1621) 6382 o Permit Retry in response to 0-RTT (#1547, #1552) 6384 o Looser verification of ECN counters to account for ACK loss 6385 (#1555, #1481, #1565) 6387 o Remove frame type field from APPLICATION_CLOSE (#1508, #1528) 6389 B.9. Since draft-ietf-quic-transport-12 6391 o Changes to integration of the TLS handshake (#829, #1018, #1094, 6392 #1165, #1190, #1233, #1242, #1252, #1450, #1458) 6394 * The cryptographic handshake uses CRYPTO frames, not stream 0 6396 * QUIC packet protection is used in place of TLS record 6397 protection 6399 * Separate QUIC packet number spaces are used for the handshake 6401 * Changed Retry to be independent of the cryptographic handshake 6403 * Added NEW_TOKEN frame and Token fields to Initial packet 6405 * Limit the use of HelloRetryRequest to address TLS needs (like 6406 key shares) 6408 o Enable server to transition connections to a preferred address 6409 (#560, #1251, #1373) 6411 o Added ECN feedback mechanisms and handling; new ACK_ECN frame 6412 (#804, #805, #1372) 6414 o Changed rules and recommendations for use of new connection IDs 6415 (#1258, #1264, #1276, #1280, #1419, #1452, #1453, #1465) 6417 o Added a transport parameter to disable intentional connection 6418 migration (#1271, #1447) 6420 o Packets from different connection ID can't be coalesced (#1287, 6421 #1423) 6423 o Fixed sampling method for packet number encryption; the length 6424 field in long headers includes the packet number field in addition 6425 to the packet payload (#1387, #1389) 6427 o Stateless Reset is now symmetric and subject to size constraints 6428 (#466, #1346) 6430 o Added frame type extension mechanism (#58, #1473) 6432 B.10. Since draft-ietf-quic-transport-11 6434 o Enable server to transition connections to a preferred address 6435 (#560, #1251) 6437 o Packet numbers are encrypted (#1174, #1043, #1048, #1034, #850, 6438 #990, #734, #1317, #1267, #1079) 6440 o Packet numbers use a variable-length encoding (#989, #1334) 6442 o STREAM frames can now be empty (#1350) 6444 B.11. Since draft-ietf-quic-transport-10 6446 o Swap payload length and packed number fields in long header 6447 (#1294) 6449 o Clarified that CONNECTION_CLOSE is allowed in Handshake packet 6450 (#1274) 6452 o Spin bit reserved (#1283) 6454 o Coalescing multiple QUIC packets in a UDP datagram (#1262, #1285) 6456 o A more complete connection migration (#1249) 6458 o Refine opportunistic ACK defense text (#305, #1030, #1185) 6460 o A Stateless Reset Token isn't mandatory (#818, #1191) 6462 o Removed implicit stream opening (#896, #1193) 6464 o An empty STREAM frame can be used to open a stream without sending 6465 data (#901, #1194) 6467 o Define stream counts in transport parameters rather than a maximum 6468 stream ID (#1023, #1065) 6470 o STOP_SENDING is now prohibited before streams are used (#1050) 6471 o Recommend including ACK in Retry packets and allow PADDING (#1067, 6472 #882) 6474 o Endpoints now become closing after an idle timeout (#1178, #1179) 6476 o Remove implication that Version Negotiation is sent when a packet 6477 of the wrong version is received (#1197) 6479 B.12. Since draft-ietf-quic-transport-09 6481 o Added PATH_CHALLENGE and PATH_RESPONSE frames to replace PING with 6482 Data and PONG frame. Changed ACK frame type from 0x0e to 0x0d. 6483 (#1091, #725, #1086) 6485 o A server can now only send 3 packets without validating the client 6486 address (#38, #1090) 6488 o Delivery order of stream data is no longer strongly specified 6489 (#252, #1070) 6491 o Rework of packet handling and version negotiation (#1038) 6493 o Stream 0 is now exempt from flow control until the handshake 6494 completes (#1074, #725, #825, #1082) 6496 o Improved retransmission rules for all frame types: information is 6497 retransmitted, not packets or frames (#463, #765, #1095, #1053) 6499 o Added an error code for server busy signals (#1137) 6501 o Endpoints now set the connection ID that their peer uses. 6502 Connection IDs are variable length. Removed the 6503 omit_connection_id transport parameter and the corresponding short 6504 header flag. (#1089, #1052, #1146, #821, #745, #821, #1166, #1151) 6506 B.13. Since draft-ietf-quic-transport-08 6508 o Clarified requirements for BLOCKED usage (#65, #924) 6510 o BLOCKED frame now includes reason for blocking (#452, #924, #927, 6511 #928) 6513 o GAP limitation in ACK Frame (#613) 6515 o Improved PMTUD description (#614, #1036) 6517 o Clarified stream state machine (#634, #662, #743, #894) 6518 o Reserved versions don't need to be generated deterministically 6519 (#831, #931) 6521 o You don't always need the draining period (#871) 6523 o Stateless reset clarified as version-specific (#930, #986) 6525 o initial_max_stream_id_x transport parameters are optional (#970, 6526 #971) 6528 o Ack Delay assumes a default value during the handshake (#1007, 6529 #1009) 6531 o Removed transport parameters from NewSessionTicket (#1015) 6533 B.14. Since draft-ietf-quic-transport-07 6535 o The long header now has version before packet number (#926, #939) 6537 o Rename and consolidate packet types (#846, #822, #847) 6539 o Packet types are assigned new codepoints and the Connection ID 6540 Flag is inverted (#426, #956) 6542 o Removed type for Version Negotiation and use Version 0 (#963, 6543 #968) 6545 o Streams are split into unidirectional and bidirectional (#643, 6546 #656, #720, #872, #175, #885) 6548 * Stream limits now have separate uni- and bi-directional 6549 transport parameters (#909, #958) 6551 * Stream limit transport parameters are now optional and default 6552 to 0 (#970, #971) 6554 o The stream state machine has been split into read and write (#634, 6555 #894) 6557 o Employ variable-length integer encodings throughout (#595) 6559 o Improvements to connection close 6561 * Added distinct closing and draining states (#899, #871) 6563 * Draining period can terminate early (#869, #870) 6565 * Clarifications about stateless reset (#889, #890) 6567 o Address validation for connection migration (#161, #732, #878) 6569 o Clearly defined retransmission rules for BLOCKED (#452, #65, #924) 6571 o negotiated_version is sent in server transport parameters (#710, 6572 #959) 6574 o Increased the range over which packet numbers are randomized 6575 (#864, #850, #964) 6577 B.15. Since draft-ietf-quic-transport-06 6579 o Replaced FNV-1a with AES-GCM for all "Cleartext" packets (#554) 6581 o Split error code space between application and transport (#485) 6583 o Stateless reset token moved to end (#820) 6585 o 1-RTT-protected long header types removed (#848) 6587 o No acknowledgments during draining period (#852) 6589 o Remove "application close" as a separate close type (#854) 6591 o Remove timestamps from the ACK frame (#841) 6593 o Require transport parameters to only appear once (#792) 6595 B.16. Since draft-ietf-quic-transport-05 6597 o Stateless token is server-only (#726) 6599 o Refactor section on connection termination (#733, #748, #328, 6600 #177) 6602 o Limit size of Version Negotiation packet (#585) 6604 o Clarify when and what to ack (#736) 6606 o Renamed STREAM_ID_NEEDED to STREAM_ID_BLOCKED 6608 o Clarify Keep-alive requirements (#729) 6610 B.17. Since draft-ietf-quic-transport-04 6612 o Introduce STOP_SENDING frame, RESET_STREAM only resets in one 6613 direction (#165) 6615 o Removed GOAWAY; application protocols are responsible for graceful 6616 shutdown (#696) 6618 o Reduced the number of error codes (#96, #177, #184, #211) 6620 o Version validation fields can't move or change (#121) 6622 o Removed versions from the transport parameters in a 6623 NewSessionTicket message (#547) 6625 o Clarify the meaning of "bytes in flight" (#550) 6627 o Public reset is now stateless reset and not visible to the path 6628 (#215) 6630 o Reordered bits and fields in STREAM frame (#620) 6632 o Clarifications to the stream state machine (#572, #571) 6634 o Increased the maximum length of the Largest Acknowledged field in 6635 ACK frames to 64 bits (#629) 6637 o truncate_connection_id is renamed to omit_connection_id (#659) 6639 o CONNECTION_CLOSE terminates the connection like TCP RST (#330, 6640 #328) 6642 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 6644 B.18. Since draft-ietf-quic-transport-03 6646 o Change STREAM and RESET_STREAM layout 6648 o Add MAX_STREAM_ID settings 6650 B.19. Since draft-ietf-quic-transport-02 6652 o The size of the initial packet payload has a fixed minimum (#267, 6653 #472) 6655 o Define when Version Negotiation packets are ignored (#284, #294, 6656 #241, #143, #474) 6658 o The 64-bit FNV-1a algorithm is used for integrity protection of 6659 unprotected packets (#167, #480, #481, #517) 6661 o Rework initial packet types to change how the connection ID is 6662 chosen (#482, #442, #493) 6664 o No timestamps are forbidden in unprotected packets (#542, #429) 6666 o Cryptographic handshake is now on stream 0 (#456) 6668 o Remove congestion control exemption for cryptographic handshake 6669 (#248, #476) 6671 o Version 1 of QUIC uses TLS; a new version is needed to use a 6672 different handshake protocol (#516) 6674 o STREAM frames have a reduced number of offset lengths (#543, #430) 6676 o Split some frames into separate connection- and stream- level 6677 frames (#443) 6679 * WINDOW_UPDATE split into MAX_DATA and MAX_STREAM_DATA (#450) 6681 * BLOCKED split to match WINDOW_UPDATE split (#454) 6683 * Define STREAM_ID_NEEDED frame (#455) 6685 o A NEW_CONNECTION_ID frame supports connection migration without 6686 linkability (#232, #491, #496) 6688 o Transport parameters for 0-RTT are retained from a previous 6689 connection (#405, #513, #512) 6691 * A client in 0-RTT no longer required to reset excess streams 6692 (#425, #479) 6694 o Expanded security considerations (#440, #444, #445, #448) 6696 B.20. Since draft-ietf-quic-transport-01 6698 o Defined short and long packet headers (#40, #148, #361) 6700 o Defined a versioning scheme and stable fields (#51, #361) 6702 o Define reserved version values for "greasing" negotiation (#112, 6703 #278) 6705 o The initial packet number is randomized (#35, #283) 6707 o Narrow the packet number encoding range requirement (#67, #286, 6708 #299, #323, #356) 6710 o Defined client address validation (#52, #118, #120, #275) 6711 o Define transport parameters as a TLS extension (#49, #122) 6713 o SCUP and COPT parameters are no longer valid (#116, #117) 6715 o Transport parameters for 0-RTT are either remembered from before, 6716 or assume default values (#126) 6718 o The server chooses connection IDs in its final flight (#119, #349, 6719 #361) 6721 o The server echoes the Connection ID and packet number fields when 6722 sending a Version Negotiation packet (#133, #295, #244) 6724 o Defined a minimum packet size for the initial handshake packet 6725 from the client (#69, #136, #139, #164) 6727 o Path MTU Discovery (#64, #106) 6729 o The initial handshake packet from the client needs to fit in a 6730 single packet (#338) 6732 o Forbid acknowledgment of packets containing only ACK and PADDING 6733 (#291) 6735 o Require that frames are processed when packets are acknowledged 6736 (#381, #341) 6738 o Removed the STOP_WAITING frame (#66) 6740 o Don't require retransmission of old timestamps for lost ACK frames 6741 (#308) 6743 o Clarified that frames are not retransmitted, but the information 6744 in them can be (#157, #298) 6746 o Error handling definitions (#335) 6748 o Split error codes into four sections (#74) 6750 o Forbid the use of Public Reset where CONNECTION_CLOSE is possible 6751 (#289) 6753 o Define packet protection rules (#336) 6755 o Require that stream be entirely delivered or reset, including 6756 acknowledgment of all STREAM frames or the RESET_STREAM, before it 6757 closes (#381) 6759 o Remove stream reservation from state machine (#174, #280) 6761 o Only stream 1 does not contribute to connection-level flow control 6762 (#204) 6764 o Stream 1 counts towards the maximum concurrent stream limit (#201, 6765 #282) 6767 o Remove connection-level flow control exclusion for some streams 6768 (except 1) (#246) 6770 o RESET_STREAM affects connection-level flow control (#162, #163) 6772 o Flow control accounting uses the maximum data offset on each 6773 stream, rather than bytes received (#378) 6775 o Moved length-determining fields to the start of STREAM and ACK 6776 (#168, #277) 6778 o Added the ability to pad between frames (#158, #276) 6780 o Remove error code and reason phrase from GOAWAY (#352, #355) 6782 o GOAWAY includes a final stream number for both directions (#347) 6784 o Error codes for RESET_STREAM and CONNECTION_CLOSE are now at a 6785 consistent offset (#249) 6787 o Defined priority as the responsibility of the application protocol 6788 (#104, #303) 6790 B.21. Since draft-ietf-quic-transport-00 6792 o Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 6794 o Defined versioning 6796 o Reworked description of packet and frame layout 6798 o Error code space is divided into regions for each component 6800 o Use big endian for all numeric values 6802 B.22. Since draft-hamilton-quic-transport-protocol-01 6804 o Adopted as base for draft-ietf-quic-tls 6806 o Updated authors/editors list 6807 o Added IANA Considerations section 6809 o Moved Contributors and Acknowledgments to appendices 6811 Acknowledgments 6813 Special thanks are due to the following for helping shape pre-IETF 6814 QUIC and its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, 6815 Alistair Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. 6817 This document has benefited immensely from various private 6818 discussions and public ones on the quic@ietf.org and proto- 6819 quic@chromium.org mailing lists. Our thanks to all. 6821 Contributors 6823 The original authors of this specification were Ryan Hamilton, Jana 6824 Iyengar, Ian Swett, and Alyssa Wilk. 6826 The original design and rationale behind this protocol draw 6827 significantly from work by Jim Roskind [EARLY-DESIGN]. In 6828 alphabetical order, the contributors to the pre-IETF QUIC project at 6829 Google are: Britt Cyr, Jeremy Dorfman, Ryan Hamilton, Jana Iyengar, 6830 Fedor Kouranov, Charles Krasic, Jo Kulik, Adam Langley, Jim Roskind, 6831 Robbie Shade, Satyam Shekhar, Cherie Shi, Ian Swett, Raman Tenneti, 6832 Victor Vasiliev, Antonio Vicente, Patrik Westin, Alyssa Wilk, Dale 6833 Worley, Fan Yang, Dan Zhang, Daniel Ziegler. 6835 Authors' Addresses 6837 Jana Iyengar (editor) 6838 Fastly 6840 Email: jri.ietf@gmail.com 6842 Martin Thomson (editor) 6843 Mozilla 6845 Email: mt@lowentropy.net