idnits 2.17.1 draft-ietf-quic-transport-20.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 (April 23, 2019) is 1829 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 1776 == Missing Reference: 'CH' is mentioned on line 1772, but not defined == Missing Reference: 'SH' is mentioned on line 1774, but not defined == Missing Reference: 'EE' is mentioned on line 1775, but not defined == Missing Reference: 'CERT' is mentioned on line 1775, but not defined == Missing Reference: 'CV' is mentioned on line 1775, but not defined == Missing Reference: 'FIN' is mentioned on line 1775, but not defined -- Looks like a reference, but probably isn't: '1' on line 1774 -- Looks like a reference, but probably isn't: '4' on line 4532 -- Looks like a reference, but probably isn't: '16' on line 4537 == Outdated reference: A later version (-22) exists of draft-ietf-tsvwg-datagram-plpmtud-07 == Outdated reference: A later version (-34) exists of draft-ietf-quic-recovery-20 == Outdated reference: A later version (-34) exists of draft-ietf-quic-tls-20 -- 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-04 == Outdated reference: A later version (-18) exists of draft-ietf-quic-manageability-03 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: October 25, 2019 Mozilla 6 April 23, 2019 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-20 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 October 25, 2019. 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 . . . . . . . . . . . . . . . . . . . . . . . . 5 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 . . . . . . . . . . . . . . . . . . 10 69 3. Stream States . . . . . . . . . . . . . . . . . . . . . . . . 11 70 3.1. Sending Stream States . . . . . . . . . . . . . . . . . . 11 71 3.2. Receiving Stream States . . . . . . . . . . . . . . . . . 13 72 3.3. Permitted Frame Types . . . . . . . . . . . . . . . . . . 16 73 3.4. Bidirectional Stream States . . . . . . . . . . . . . . . 16 74 3.5. Solicited State Transitions . . . . . . . . . . . . . . . 18 75 4. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 19 76 4.1. Data Flow Control . . . . . . . . . . . . . . . . . . . . 19 77 4.2. Flow Credit Increments . . . . . . . . . . . . . . . . . 20 78 4.3. Handling Stream Cancellation . . . . . . . . . . . . . . 21 79 4.4. Stream Final Size . . . . . . . . . . . . . . . . . . . . 22 80 4.5. Controlling Concurrency . . . . . . . . . . . . . . . . . 22 81 5. Connections . . . . . . . . . . . . . . . . . . . . . . . . . 23 82 5.1. Connection ID . . . . . . . . . . . . . . . . . . . . . . 23 83 5.1.1. Issuing Connection IDs . . . . . . . . . . . . . . . 24 84 5.1.2. Consuming and Retiring Connection IDs . . . . . . . . 25 85 5.2. Matching Packets to Connections . . . . . . . . . . . . . 26 86 5.2.1. Client Packet Handling . . . . . . . . . . . . . . . 27 87 5.2.2. Server Packet Handling . . . . . . . . . . . . . . . 27 88 5.3. Life of a QUIC Connection . . . . . . . . . . . . . . . . 28 89 6. Version Negotiation . . . . . . . . . . . . . . . . . . . . . 28 90 6.1. Sending Version Negotiation Packets . . . . . . . . . . . 28 91 6.2. Handling Version Negotiation Packets . . . . . . . . . . 29 92 6.2.1. Version Negotiation Between Draft Versions . . . . . 29 93 6.3. Using Reserved Versions . . . . . . . . . . . . . . . . . 29 94 7. Cryptographic and Transport Handshake . . . . . . . . . . . . 30 95 7.1. Example Handshake Flows . . . . . . . . . . . . . . . . . 31 96 7.2. Negotiating Connection IDs . . . . . . . . . . . . . . . 32 97 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 34 98 7.3.1. Values of Transport Parameters for 0-RTT . . . . . . 34 99 7.3.2. New Transport Parameters . . . . . . . . . . . . . . 35 100 7.4. Cryptographic Message Buffering . . . . . . . . . . . . . 36 101 8. Address Validation . . . . . . . . . . . . . . . . . . . . . 36 102 8.1. Address Validation During Connection Establishment . . . 37 103 8.1.1. Address Validation using Retry Packets . . . . . . . 37 104 8.1.2. Address Validation for Future Connections . . . . . . 38 105 8.1.3. Address Validation Token Integrity . . . . . . . . . 40 106 8.2. Path Validation . . . . . . . . . . . . . . . . . . . . . 40 107 8.3. Initiating Path Validation . . . . . . . . . . . . . . . 41 108 8.4. Path Validation Responses . . . . . . . . . . . . . . . . 42 109 8.5. Successful Path Validation . . . . . . . . . . . . . . . 42 110 8.6. Failed Path Validation . . . . . . . . . . . . . . . . . 42 111 9. Connection Migration . . . . . . . . . . . . . . . . . . . . 43 112 9.1. Probing a New Path . . . . . . . . . . . . . . . . . . . 44 113 9.2. Initiating Connection Migration . . . . . . . . . . . . . 44 114 9.3. Responding to Connection Migration . . . . . . . . . . . 45 115 9.3.1. Peer Address Spoofing . . . . . . . . . . . . . . . . 45 116 9.3.2. On-Path Address Spoofing . . . . . . . . . . . . . . 46 117 9.3.3. Off-Path Packet Forwarding . . . . . . . . . . . . . 47 118 9.4. Loss Detection and Congestion Control . . . . . . . . . . 48 119 9.5. Privacy Implications of Connection Migration . . . . . . 49 120 9.6. Server's Preferred Address . . . . . . . . . . . . . . . 49 121 9.6.1. Communicating A Preferred Address . . . . . . . . . . 50 122 9.6.2. Responding to Connection Migration . . . . . . . . . 50 123 9.6.3. Interaction of Client Migration and Preferred Address 51 124 9.7. Use of IPv6 Flow-Label and Migration . . . . . . . . . . 51 125 10. Connection Termination . . . . . . . . . . . . . . . . . . . 52 126 10.1. Closing and Draining Connection States . . . . . . . . . 52 127 10.2. Idle Timeout . . . . . . . . . . . . . . . . . . . . . . 53 128 10.3. Immediate Close . . . . . . . . . . . . . . . . . . . . 54 129 10.4. Stateless Reset . . . . . . . . . . . . . . . . . . . . 55 130 10.4.1. Detecting a Stateless Reset . . . . . . . . . . . . 58 131 10.4.2. Calculating a Stateless Reset Token . . . . . . . . 58 132 10.4.3. Looping . . . . . . . . . . . . . . . . . . . . . . 59 133 11. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 60 134 11.1. Connection Errors . . . . . . . . . . . . . . . . . . . 60 135 11.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 61 136 12. Packets and Frames . . . . . . . . . . . . . . . . . . . . . 61 137 12.1. Protected Packets . . . . . . . . . . . . . . . . . . . 61 138 12.2. Coalescing Packets . . . . . . . . . . . . . . . . . . . 62 139 12.3. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 63 140 12.4. Frames and Frame Types . . . . . . . . . . . . . . . . . 64 141 13. Packetization and Reliability . . . . . . . . . . . . . . . . 67 142 13.1. Packet Processing and Acknowledgment . . . . . . . . . . 68 143 13.1.1. Sending ACK Frames . . . . . . . . . . . . . . . . . 68 144 13.1.2. ACK Frames and Packet Protection . . . . . . . . . . 69 146 13.2. Retransmission of Information . . . . . . . . . . . . . 69 147 13.3. Explicit Congestion Notification . . . . . . . . . . . . 72 148 13.3.1. ECN Counts . . . . . . . . . . . . . . . . . . . . . 72 149 13.3.2. ECN Verification . . . . . . . . . . . . . . . . . . 73 150 14. Packet Size . . . . . . . . . . . . . . . . . . . . . . . . . 74 151 14.1. Path Maximum Transmission Unit (PMTU) . . . . . . . . . 75 152 14.2. ICMP Packet Too Big Messages . . . . . . . . . . . . . . 76 153 14.3. Datagram Packetization Layer PMTU Discovery . . . . . . 77 154 15. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 77 155 16. Variable-Length Integer Encoding . . . . . . . . . . . . . . 78 156 17. Packet Formats . . . . . . . . . . . . . . . . . . . . . . . 79 157 17.1. Packet Number Encoding and Decoding . . . . . . . . . . 79 158 17.2. Long Header Packets . . . . . . . . . . . . . . . . . . 80 159 17.2.1. Version Negotiation Packet . . . . . . . . . . . . . 83 160 17.2.2. Initial Packet . . . . . . . . . . . . . . . . . . . 84 161 17.2.3. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . 87 162 17.2.4. Handshake Packet . . . . . . . . . . . . . . . . . . 88 163 17.2.5. Retry Packet . . . . . . . . . . . . . . . . . . . . 89 164 17.3. Short Header Packets . . . . . . . . . . . . . . . . . . 91 165 17.3.1. Latency Spin Bit . . . . . . . . . . . . . . . . . . 93 166 18. Transport Parameter Encoding . . . . . . . . . . . . . . . . 94 167 18.1. Transport Parameter Definitions . . . . . . . . . . . . 95 168 19. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 98 169 19.1. PADDING Frame . . . . . . . . . . . . . . . . . . . . . 98 170 19.2. PING Frame . . . . . . . . . . . . . . . . . . . . . . . 99 171 19.3. ACK Frames . . . . . . . . . . . . . . . . . . . . . . . 99 172 19.3.1. ACK Ranges . . . . . . . . . . . . . . . . . . . . . 101 173 19.3.2. ECN Counts . . . . . . . . . . . . . . . . . . . . . 102 174 19.4. RESET_STREAM Frame . . . . . . . . . . . . . . . . . . . 103 175 19.5. STOP_SENDING Frame . . . . . . . . . . . . . . . . . . . 104 176 19.6. CRYPTO Frame . . . . . . . . . . . . . . . . . . . . . . 104 177 19.7. NEW_TOKEN Frame . . . . . . . . . . . . . . . . . . . . 105 178 19.8. STREAM Frames . . . . . . . . . . . . . . . . . . . . . 106 179 19.9. MAX_DATA Frame . . . . . . . . . . . . . . . . . . . . . 107 180 19.10. MAX_STREAM_DATA Frame . . . . . . . . . . . . . . . . . 108 181 19.11. MAX_STREAMS Frames . . . . . . . . . . . . . . . . . . . 109 182 19.12. DATA_BLOCKED Frame . . . . . . . . . . . . . . . . . . . 110 183 19.13. STREAM_DATA_BLOCKED Frame . . . . . . . . . . . . . . . 110 184 19.14. STREAMS_BLOCKED Frames . . . . . . . . . . . . . . . . . 111 185 19.15. NEW_CONNECTION_ID Frame . . . . . . . . . . . . . . . . 111 186 19.16. RETIRE_CONNECTION_ID Frame . . . . . . . . . . . . . . . 113 187 19.17. PATH_CHALLENGE Frame . . . . . . . . . . . . . . . . . . 114 188 19.18. PATH_RESPONSE Frame . . . . . . . . . . . . . . . . . . 114 189 19.19. CONNECTION_CLOSE Frames . . . . . . . . . . . . . . . . 114 190 19.20. Extension Frames . . . . . . . . . . . . . . . . . . . . 115 191 20. Transport Error Codes . . . . . . . . . . . . . . . . . . . . 116 192 20.1. Application Protocol Error Codes . . . . . . . . . . . . 117 193 21. Security Considerations . . . . . . . . . . . . . . . . . . . 117 194 21.1. Handshake Denial of Service . . . . . . . . . . . . . . 117 195 21.2. Amplification Attack . . . . . . . . . . . . . . . . . . 118 196 21.3. Optimistic ACK Attack . . . . . . . . . . . . . . . . . 119 197 21.4. Slowloris Attacks . . . . . . . . . . . . . . . . . . . 119 198 21.5. Stream Fragmentation and Reassembly Attacks . . . . . . 119 199 21.6. Stream Commitment Attack . . . . . . . . . . . . . . . . 120 200 21.7. Explicit Congestion Notification Attacks . . . . . . . . 120 201 21.8. Stateless Reset Oracle . . . . . . . . . . . . . . . . . 121 202 21.9. Version Downgrade . . . . . . . . . . . . . . . . . . . 121 203 22. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 121 204 22.1. QUIC Transport Parameter Registry . . . . . . . . . . . 121 205 22.2. QUIC Frame Type Registry . . . . . . . . . . . . . . . . 123 206 22.3. QUIC Transport Error Codes Registry . . . . . . . . . . 124 207 23. References . . . . . . . . . . . . . . . . . . . . . . . . . 126 208 23.1. Normative References . . . . . . . . . . . . . . . . . . 126 209 23.2. Informative References . . . . . . . . . . . . . . . . . 127 210 Appendix A. Sample Packet Number Decoding Algorithm . . . . . . 129 211 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 129 212 B.1. Since draft-ietf-quic-transport-19 . . . . . . . . . . . 130 213 B.2. Since draft-ietf-quic-transport-18 . . . . . . . . . . . 130 214 B.3. Since draft-ietf-quic-transport-17 . . . . . . . . . . . 131 215 B.4. Since draft-ietf-quic-transport-16 . . . . . . . . . . . 131 216 B.5. Since draft-ietf-quic-transport-15 . . . . . . . . . . . 133 217 B.6. Since draft-ietf-quic-transport-14 . . . . . . . . . . . 133 218 B.7. Since draft-ietf-quic-transport-13 . . . . . . . . . . . 133 219 B.8. Since draft-ietf-quic-transport-12 . . . . . . . . . . . 134 220 B.9. Since draft-ietf-quic-transport-11 . . . . . . . . . . . 135 221 B.10. Since draft-ietf-quic-transport-10 . . . . . . . . . . . 135 222 B.11. Since draft-ietf-quic-transport-09 . . . . . . . . . . . 136 223 B.12. Since draft-ietf-quic-transport-08 . . . . . . . . . . . 136 224 B.13. Since draft-ietf-quic-transport-07 . . . . . . . . . . . 137 225 B.14. Since draft-ietf-quic-transport-06 . . . . . . . . . . . 138 226 B.15. Since draft-ietf-quic-transport-05 . . . . . . . . . . . 138 227 B.16. Since draft-ietf-quic-transport-04 . . . . . . . . . . . 138 228 B.17. Since draft-ietf-quic-transport-03 . . . . . . . . . . . 139 229 B.18. Since draft-ietf-quic-transport-02 . . . . . . . . . . . 139 230 B.19. Since draft-ietf-quic-transport-01 . . . . . . . . . . . 140 231 B.20. Since draft-ietf-quic-transport-00 . . . . . . . . . . . 142 232 B.21. Since draft-hamilton-quic-transport-protocol-01 . . . . . 142 233 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 143 234 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 143 235 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 143 237 1. Introduction 239 QUIC is a multiplexed and secure general-purpose transport protocol 240 that provides: 242 o Stream multiplexing 244 o Stream and connection-level flow control 246 o Low-latency connection establishment 248 o Connection migration and resilience to NAT rebinding 250 o Authenticated and encrypted header and payload 252 QUIC uses UDP as a substrate to avoid requiring changes to legacy 253 client operating systems and middleboxes. QUIC authenticates all of 254 its headers and encrypts most of the data it exchanges, including its 255 signaling, to avoid incurring a dependency on middleboxes. 257 1.1. Document Structure 259 This document describes the core QUIC protocol and is structured as 260 follows. 262 o Streams are the basic service abstraction that QUIC provides. 264 * Section 2 describes core concepts related to streams, 266 * Section 3 provides a reference model for stream states, and 268 * Section 4 outlines the operation of flow control. 270 o Connections are the context in which QUIC endpoints communicate. 272 * Section 5 describes core concepts related to connections, 274 * Section 6 describes version negotiation, 276 * Section 7 details the process for establishing connections, 278 * Section 8 specifies critical denial of service mitigation 279 mechanisms, 281 * Section 9 describes how endpoints migrate a connection to a new 282 network path, 284 * Section 10 lists the options for terminating an open 285 connection, and 287 * Section 11 provides general guidance for error handling. 289 o Packets and frames are the basic unit used by QUIC to communicate. 291 * Section 12 describes concepts related to packets and frames, 293 * Section 13 defines models for the transmission, retransmission, 294 and acknowledgement of data, and 296 * Section 14 specifies rules for managing the size of packets. 298 o Finally, encoding details of QUIC protocol elements are described 299 in: 301 * Section 15 (Versions), 303 * Section 16 (Integer Encoding), 305 * Section 17 (Packet Headers), 307 * Section 18 (Transport Parameters), 309 * Section 19 (Frames), and 311 * Section 20 (Errors). 313 Accompanying documents describe QUIC's loss detection and congestion 314 control [QUIC-RECOVERY], and the use of TLS for key negotiation 315 [QUIC-TLS]. 317 This document defines QUIC version 1, which conforms to the protocol 318 invariants in [QUIC-INVARIANTS]. 320 1.2. Terms and Definitions 322 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 323 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 324 "OPTIONAL" in this document are to be interpreted as described in BCP 325 14 [RFC2119] [RFC8174] when, and only when, they appear in all 326 capitals, as shown here. 328 Commonly used terms in the document are described below. 330 QUIC: The transport protocol described by this document. QUIC is a 331 name, not an acronym. 333 QUIC packet: The smallest unit of QUIC that can be encapsulated in a 334 UDP datagram. Multiple QUIC packets can be encapsulated in a 335 single UDP datagram. 337 Endpoint: An entity that can participate in a QUIC connection by 338 generating, receiving, and processing QUIC packets. There are 339 only two types of endpoint in QUIC: client and server. 341 Client: The endpoint initiating a QUIC connection. 343 Server: The endpoint accepting incoming QUIC connections. 345 Connection ID: An opaque identifier that is used to identify a QUIC 346 connection at an endpoint. Each endpoint sets a value for its 347 peer to include in packets sent towards the endpoint. 349 Stream: A unidirectional or bidirectional channel of ordered bytes 350 within a QUIC connection. A QUIC connection can carry multiple 351 simultaneous streams. 353 Application: An entity that uses QUIC to send and receive data. 355 1.3. Notational Conventions 357 Packet and frame diagrams in this document use the format described 358 in Section 3.1 of [RFC2360], with the following additional 359 conventions: 361 [x]: Indicates that x is optional 363 x (A): Indicates that x is A bits long 365 x (A/B/C) ...: Indicates that x is one of A, B, or C bits long 367 x (i) ...: Indicates that x uses the variable-length encoding in 368 Section 16 370 x (*) ...: Indicates that x is variable-length 372 2. Streams 374 Streams in QUIC provide a lightweight, ordered byte-stream 375 abstraction to an application. An alternative view of QUIC streams 376 is as an elastic "message" abstraction. 378 Streams can be created by sending data. Other processes associated 379 with stream management - ending, cancelling, and managing flow 380 control - are all designed to impose minimal overheads. For 381 instance, a single STREAM frame (Section 19.8) can open, carry data 382 for, and close a stream. Streams can also be long-lived and can last 383 the entire duration of a connection. 385 Streams can be created by either endpoint, can concurrently send data 386 interleaved with other streams, and can be cancelled. QUIC does not 387 provide any means of ensuring ordering between bytes on different 388 streams. 390 QUIC allows for an arbitrary number of streams to operate 391 concurrently and for an arbitrary amount of data to be sent on any 392 stream, subject to flow control constraints (see Section 4) and 393 stream limits. 395 2.1. Stream Types and Identifiers 397 Streams can be unidirectional or bidirectional. Unidirectional 398 streams carry data in one direction: from the initiator of the stream 399 to its peer. Bidirectional streams allow for data to be sent in both 400 directions. 402 Streams are identified within a connection by a numeric value, 403 referred to as the stream ID. Stream IDs are unique to a stream. A 404 QUIC endpoint MUST NOT reuse a stream ID within a connection. Stream 405 IDs are encoded as variable-length integers (see Section 16). 407 The least significant bit (0x1) of the stream ID identifies the 408 initiator of the stream. Client-initiated streams have even-numbered 409 stream IDs (with the bit set to 0), and server-initiated streams have 410 odd-numbered stream IDs (with the bit set to 1). 412 The second least significant bit (0x2) of the stream ID distinguishes 413 between bidirectional streams (with the bit set to 0) and 414 unidirectional streams (with the bit set to 1). 416 The least significant two bits from a stream ID therefore identify a 417 stream as one of four types, as summarized in Table 1. 419 +------+----------------------------------+ 420 | Bits | Stream Type | 421 +------+----------------------------------+ 422 | 0x0 | Client-Initiated, Bidirectional | 423 | | | 424 | 0x1 | Server-Initiated, Bidirectional | 425 | | | 426 | 0x2 | Client-Initiated, Unidirectional | 427 | | | 428 | 0x3 | Server-Initiated, Unidirectional | 429 +------+----------------------------------+ 431 Table 1: Stream ID Types 433 Within each type, streams are created with numerically increasing 434 stream IDs. A stream ID that is used out of order results in all 435 streams of that type with lower-numbered stream IDs also being 436 opened. 438 The first bidirectional stream opened by the client has a stream ID 439 of 0. 441 2.2. Sending and Receiving Data 443 STREAM frames (Section 19.8) encapsulate data sent by an application. 444 An endpoint uses the Stream ID and Offset fields in STREAM frames to 445 place data in order. 447 Endpoints MUST be able to deliver stream data to an application as an 448 ordered byte-stream. Delivering an ordered byte-stream requires that 449 an endpoint buffer any data that is received out of order, up to the 450 advertised flow control limit. 452 QUIC makes no specific allowances for delivery of stream data out of 453 order. However, implementations MAY choose to offer the ability to 454 deliver data out of order to a receiving application. 456 An endpoint could receive data for a stream at the same stream offset 457 multiple times. Data that has already been received can be 458 discarded. The data at a given offset MUST NOT change if it is sent 459 multiple times; an endpoint MAY treat receipt of different data at 460 the same offset within a stream as a connection error of type 461 PROTOCOL_VIOLATION. 463 Streams are an ordered byte-stream abstraction with no other 464 structure that is visible to QUIC. STREAM frame boundaries are not 465 expected to be preserved when data is transmitted, when data is 466 retransmitted after packet loss, or when data is delivered to the 467 application at a receiver. 469 An endpoint MUST NOT send data on any stream without ensuring that it 470 is within the flow control limits set by its peer. Flow control is 471 described in detail in Section 4. 473 2.3. Stream Prioritization 475 Stream multiplexing can have a significant effect on application 476 performance if resources allocated to streams are correctly 477 prioritized. 479 QUIC does not provide frames for exchanging prioritization 480 information. Instead it relies on receiving priority information 481 from the application that uses QUIC. 483 A QUIC implementation SHOULD provide ways in which an application can 484 indicate the relative priority of streams. When deciding which 485 streams to dedicate resources to, the implementation SHOULD use the 486 information provided by the application. 488 3. Stream States 490 This section describes streams in terms of their send or receive 491 components. Two state machines are described: one for the streams on 492 which an endpoint transmits data (Section 3.1), and another for 493 streams on which an endpoint receives data (Section 3.2). 495 Unidirectional streams use the applicable state machine directly. 496 Bidirectional streams use both state machines. For the most part, 497 the use of these state machines is the same whether the stream is 498 unidirectional or bidirectional. The conditions for opening a stream 499 are slightly more complex for a bidirectional stream because the 500 opening of either send or receive sides causes the stream to open in 501 both directions. 503 An endpoint MUST open streams of the same type in increasing order of 504 stream ID. 506 Note: These states are largely informative. This document uses 507 stream states to describe rules for when and how different types 508 of frames can be sent and the reactions that are expected when 509 different types of frames are received. Though these state 510 machines are intended to be useful in implementing QUIC, these 511 states aren't intended to constrain implementations. An 512 implementation can define a different state machine as long as its 513 behavior is consistent with an implementation that implements 514 these states. 516 3.1. Sending Stream States 518 Figure 1 shows the states for the part of a stream that sends data to 519 a peer. 521 o 522 | Create Stream (Sending) 523 | Peer Creates Bidirectional Stream 524 v 525 +-------+ 526 | Ready | Send RESET_STREAM 527 | |-----------------------. 528 +-------+ | 529 | | 530 | Send STREAM / | 531 | STREAM_DATA_BLOCKED | 532 | | 533 | Peer Creates | 534 | Bidirectional Stream | 535 v | 536 +-------+ | 537 | Send | Send RESET_STREAM | 538 | |---------------------->| 539 +-------+ | 540 | | 541 | Send STREAM + FIN | 542 v v 543 +-------+ +-------+ 544 | Data | Send RESET_STREAM | Reset | 545 | Sent |------------------>| Sent | 546 +-------+ +-------+ 547 | | 548 | Recv All ACKs | Recv ACK 549 v v 550 +-------+ +-------+ 551 | Data | | Reset | 552 | Recvd | | Recvd | 553 +-------+ +-------+ 555 Figure 1: States for Sending Parts of Streams 557 The sending part of stream that the endpoint initiates (types 0 and 2 558 for clients, 1 and 3 for servers) is opened by the application. The 559 "Ready" state represents a newly created stream that is able to 560 accept data from the application. Stream data might be buffered in 561 this state in preparation for sending. 563 Sending the first STREAM or STREAM_DATA_BLOCKED frame causes a 564 sending part of a stream to enter the "Send" state. An 565 implementation might choose to defer allocating a stream ID to a 566 stream until it sends the first frame and enters this state, which 567 can allow for better stream prioritization. 569 The sending part of a bidirectional stream initiated by a peer (type 570 0 for a server, type 1 for a client) enters the "Ready" state then 571 immediately transitions to the "Send" state if the receiving part 572 enters the "Recv" state (Section 3.2). 574 In the "Send" state, an endpoint transmits - and retransmits as 575 necessary - stream data in STREAM frames. The endpoint respects the 576 flow control limits set by its peer, and continues to accept and 577 process MAX_STREAM_DATA frames. An endpoint in the "Send" state 578 generates STREAM_DATA_BLOCKED frames if it is blocked from sending by 579 stream or connection flow control limits Section 4.1. 581 After the application indicates that all stream data has been sent 582 and a STREAM frame containing the FIN bit is sent, the sending part 583 of the stream enters the "Data Sent" state. From this state, the 584 endpoint only retransmits stream data as necessary. The endpoint 585 does not need to check flow control limits or send 586 STREAM_DATA_BLOCKED frames for a stream in this state. 587 MAX_STREAM_DATA frames might be received until the peer receives the 588 final stream offset. The endpoint can safely ignore any 589 MAX_STREAM_DATA frames it receives from its peer for a stream in this 590 state. 592 Once all stream data has been successfully acknowledged, the sending 593 part of the stream enters the "Data Recvd" state, which is a terminal 594 state. 596 From any of the "Ready", "Send", or "Data Sent" states, an 597 application can signal that it wishes to abandon transmission of 598 stream data. Alternatively, an endpoint might receive a STOP_SENDING 599 frame from its peer. In either case, the endpoint sends a 600 RESET_STREAM frame, which causes the stream to enter the "Reset Sent" 601 state. 603 An endpoint MAY send a RESET_STREAM as the first frame that mentions 604 a stream; this causes the sending part of that stream to open and 605 then immediately transition to the "Reset Sent" state. 607 Once a packet containing a RESET_STREAM has been acknowledged, the 608 sending part of the stream enters the "Reset Recvd" state, which is a 609 terminal state. 611 3.2. Receiving Stream States 613 Figure 2 shows the states for the part of a stream that receives data 614 from a peer. The states for a receiving part of a stream mirror only 615 some of the states of the sending part of the stream at the peer. 616 The receiving part of a stream does not track states on the sending 617 part that cannot be observed, such as the "Ready" state. Instead, 618 the receiving part of a stream tracks the delivery of data to the 619 application, some of which cannot be observed by the sender. 621 o 622 | Recv STREAM / STREAM_DATA_BLOCKED / RESET_STREAM 623 | Create Bidirectional Stream (Sending) 624 | Recv MAX_STREAM_DATA / STOP_SENDING (Bidirectional) 625 | Create Higher-Numbered Stream 626 v 627 +-------+ 628 | Recv | Recv RESET_STREAM 629 | |-----------------------. 630 +-------+ | 631 | | 632 | Recv STREAM + FIN | 633 v | 634 +-------+ | 635 | Size | Recv RESET_STREAM | 636 | Known |---------------------->| 637 +-------+ | 638 | | 639 | Recv All Data | 640 v v 641 +-------+ Recv RESET_STREAM +-------+ 642 | Data |--- (optional) --->| Reset | 643 | Recvd | Recv All Data | Recvd | 644 +-------+<-- (optional) ----+-------+ 645 | | 646 | App Read All Data | App Read RST 647 v v 648 +-------+ +-------+ 649 | Data | | Reset | 650 | Read | | Read | 651 +-------+ +-------+ 653 Figure 2: States for Receiving Parts of Streams 655 The receiving part of a stream initiated by a peer (types 1 and 3 for 656 a client, or 0 and 2 for a server) is created when the first STREAM, 657 STREAM_DATA_BLOCKED, or RESET_STREAM is received for that stream. 658 For bidirectional streams initiated by a peer, receipt of a 659 MAX_STREAM_DATA or STOP_SENDING frame for the sending part of the 660 stream also creates the receiving part. The initial state for the 661 receiving part of stream is "Recv". 663 The receiving part of a stream enters the "Recv" state when the 664 sending part of a bidirectional stream initiated by the endpoint 665 (type 0 for a client, type 1 for a server) enters the "Ready" state. 667 An endpoint opens a bidirectional stream when a MAX_STREAM_DATA or 668 STOP_SENDING frame is received from the peer for that stream. 669 Receiving a MAX_STREAM_DATA frame for an unopened stream indicates 670 that the remote peer has opened the stream and is providing flow 671 control credit. Receiving a STOP_SENDING frame for an unopened 672 stream indicates that the remote peer no longer wishes to receive 673 data on this stream. Either frame might arrive before a STREAM or 674 STREAM_DATA_BLOCKED frame if packets are lost or reordered. 676 Before creating a stream, all streams of the same type with lower- 677 numbered stream IDs MUST be created. This ensures that the creation 678 order for streams is consistent on both endpoints. 680 In the "Recv" state, the endpoint receives STREAM and 681 STREAM_DATA_BLOCKED frames. Incoming data is buffered and can be 682 reassembled into the correct order for delivery to the application. 683 As data is consumed by the application and buffer space becomes 684 available, the endpoint sends MAX_STREAM_DATA frames to allow the 685 peer to send more data. 687 When a STREAM frame with a FIN bit is received, the final size of the 688 stream is known (see Section 4.4). The receiving part of the stream 689 then enters the "Size Known" state. In this state, the endpoint no 690 longer needs to send MAX_STREAM_DATA frames, it only receives any 691 retransmissions of stream data. 693 Once all data for the stream has been received, the receiving part 694 enters the "Data Recvd" state. This might happen as a result of 695 receiving the same STREAM frame that causes the transition to "Size 696 Known". In this state, the endpoint has all stream data. Any STREAM 697 or STREAM_DATA_BLOCKED frames it receives for the stream can be 698 discarded. 700 The "Data Recvd" state persists until stream data has been delivered 701 to the application. Once stream data has been delivered, the stream 702 enters the "Data Read" state, which is a terminal state. 704 Receiving a RESET_STREAM frame in the "Recv" or "Size Known" states 705 causes the stream to enter the "Reset Recvd" state. This might cause 706 the delivery of stream data to the application to be interrupted. 708 It is possible that all stream data is received when a RESET_STREAM 709 is received (that is, from the "Data Recvd" state). Similarly, it is 710 possible for remaining stream data to arrive after receiving a 711 RESET_STREAM frame (the "Reset Recvd" state). An implementation is 712 free to manage this situation as it chooses. 714 Sending RESET_STREAM means that an endpoint cannot guarantee delivery 715 of stream data; however there is no requirement that stream data not 716 be delivered if a RESET_STREAM is received. An implementation MAY 717 interrupt delivery of stream data, discard any data that was not 718 consumed, and signal the receipt of the RESET_STREAM. A RESET_STREAM 719 signal might be suppressed or withheld if stream data is completely 720 received and is buffered to be read by the application. If the 721 RESET_STREAM is suppressed, the receiving part of the stream remains 722 in "Data Recvd". 724 Once the application has been delivered the signal indicating that 725 the stream was reset, the receiving part of the stream transitions to 726 the "Reset Read" state, which is a terminal state. 728 3.3. Permitted Frame Types 730 The sender of a stream sends just three frame types that affect the 731 state of a stream at either sender or receiver: STREAM 732 (Section 19.8), STREAM_DATA_BLOCKED (Section 19.13), and RESET_STREAM 733 (Section 19.4). 735 A sender MUST NOT send any of these frames from a terminal state 736 ("Data Recvd" or "Reset Recvd"). A sender MUST NOT send STREAM or 737 STREAM_DATA_BLOCKED after sending a RESET_STREAM; that is, in the 738 terminal states and in the "Reset Sent" state. A receiver could 739 receive any of these three frames in any state, due to the 740 possibility of delayed delivery of packets carrying them. 742 The receiver of a stream sends MAX_STREAM_DATA (Section 19.10) and 743 STOP_SENDING frames (Section 19.5). 745 The receiver only sends MAX_STREAM_DATA in the "Recv" state. A 746 receiver can send STOP_SENDING in any state where it has not received 747 a RESET_STREAM frame; that is states other than "Reset Recvd" or 748 "Reset Read". However there is little value in sending a 749 STOP_SENDING frame in the "Data Recvd" state, since all stream data 750 has been received. A sender could receive either of these two frames 751 in any state as a result of delayed delivery of packets. 753 3.4. Bidirectional Stream States 755 A bidirectional stream is composed of sending and receiving parts. 756 Implementations may represent states of the bidirectional stream as 757 composites of sending and receiving stream states. The simplest 758 model presents the stream as "open" when either sending or receiving 759 parts are in a non-terminal state and "closed" when both sending and 760 receiving streams are in terminal states. 762 Table 2 shows a more complex mapping of bidirectional stream states 763 that loosely correspond to the stream states in HTTP/2 [HTTP2]. This 764 shows that multiple states on sending or receiving parts of streams 765 are mapped to the same composite state. Note that this is just one 766 possibility for such a mapping; this mapping requires that data is 767 acknowledged before the transition to a "closed" or "half-closed" 768 state. 770 +-----------------------+---------------------+---------------------+ 771 | Sending Part | Receiving Part | Composite State | 772 +-----------------------+---------------------+---------------------+ 773 | No Stream/Ready | No Stream/Recv *1 | idle | 774 | | | | 775 | Ready/Send/Data Sent | Recv/Size Known | open | 776 | | | | 777 | Ready/Send/Data Sent | Data Recvd/Data | half-closed | 778 | | Read | (remote) | 779 | | | | 780 | Ready/Send/Data Sent | Reset Recvd/Reset | half-closed | 781 | | Read | (remote) | 782 | | | | 783 | Data Recvd | Recv/Size Known | half-closed (local) | 784 | | | | 785 | Reset Sent/Reset | Recv/Size Known | half-closed (local) | 786 | Recvd | | | 787 | | | | 788 | Reset Sent/Reset | Data Recvd/Data | closed | 789 | Recvd | Read | | 790 | | | | 791 | Reset Sent/Reset | Reset Recvd/Reset | closed | 792 | Recvd | Read | | 793 | | | | 794 | Data Recvd | Data Recvd/Data | closed | 795 | | Read | | 796 | | | | 797 | Data Recvd | Reset Recvd/Reset | closed | 798 | | Read | | 799 +-----------------------+---------------------+---------------------+ 801 Table 2: Possible Mapping of Stream States to HTTP/2 803 Note (*1): A stream is considered "idle" if it has not yet been 804 created, or if the receiving part of the stream is in the "Recv" 805 state without yet having received any frames. 807 3.5. Solicited State Transitions 809 If an endpoint is no longer interested in the data it is receiving on 810 a stream, it MAY send a STOP_SENDING frame identifying that stream to 811 prompt closure of the stream in the opposite direction. This 812 typically indicates that the receiving application is no longer 813 reading data it receives from the stream, but it is not a guarantee 814 that incoming data will be ignored. 816 STREAM frames received after sending STOP_SENDING are still counted 817 toward connection and stream flow control, even though these frames 818 will be discarded upon receipt. 820 A STOP_SENDING frame requests that the receiving endpoint send a 821 RESET_STREAM frame. An endpoint that receives a STOP_SENDING frame 822 MUST send a RESET_STREAM frame if the stream is in the Ready or Send 823 state. If the stream is in the Data Sent state and any outstanding 824 data is declared lost, an endpoint SHOULD send a RESET_STREAM frame 825 in lieu of a retransmission. 827 An endpoint SHOULD copy the error code from the STOP_SENDING frame to 828 the RESET_STREAM frame it sends, but MAY use any application error 829 code. The endpoint that sends a STOP_SENDING frame MAY ignore the 830 error code carried in any RESET_STREAM frame it receives. 832 If the STOP_SENDING frame is received on a stream that is already in 833 the "Data Sent" state, an endpoint that wishes to cease 834 retransmission of previously-sent STREAM frames on that stream MUST 835 first send a RESET_STREAM frame. 837 STOP_SENDING SHOULD only be sent for a stream that has not been reset 838 by the peer. STOP_SENDING is most useful for streams in the "Recv" 839 or "Size Known" states. 841 An endpoint is expected to send another STOP_SENDING frame if a 842 packet containing a previous STOP_SENDING is lost. However, once 843 either all stream data or a RESET_STREAM frame has been received for 844 the stream - that is, the stream is in any state other than "Recv" or 845 "Size Known" - sending a STOP_SENDING frame is unnecessary. 847 An endpoint that wishes to terminate both directions of a 848 bidirectional stream can terminate one direction by sending a 849 RESET_STREAM, and it can encourage prompt termination in the opposite 850 direction by sending a STOP_SENDING frame. 852 4. Flow Control 854 It is necessary to limit the amount of data that a receiver could 855 buffer, to prevent a fast sender from overwhelming a slow receiver, 856 or to prevent a malicious sender from consuming a large amount of 857 memory at a receiver. To enable a receiver to limit memory 858 commitment to a connection and to apply back pressure on the sender, 859 streams are flow controlled both individually and as an aggregate. A 860 QUIC receiver controls the maximum amount of data the sender can send 861 on a stream at any time, as described in Section 4.1 and Section 4.2 863 Similarly, to limit concurrency within a connection, a QUIC endpoint 864 controls the maximum cumulative number of streams that its peer can 865 initiate, as described in Section 4.5. 867 Data sent in CRYPTO frames is not flow controlled in the same way as 868 stream data. QUIC relies on the cryptographic protocol 869 implementation to avoid excessive buffering of data, see [QUIC-TLS]. 870 The implementation SHOULD provide an interface to QUIC to tell it 871 about its buffering limits so that there is not excessive buffering 872 at multiple layers. 874 4.1. Data Flow Control 876 QUIC employs a credit-based flow-control scheme similar to that in 877 HTTP/2 [HTTP2], where a receiver advertises the number of bytes it is 878 prepared to receive on a given stream and for the entire connection. 879 This leads to two levels of data flow control in QUIC: 881 o Stream flow control, which prevents a single stream from consuming 882 the entire receive buffer for a connection by limiting the amount 883 of data that can be sent on any stream. 885 o Connection flow control, which prevents senders from exceeding a 886 receiver's buffer capacity for the connection, by limiting the 887 total bytes of stream data sent in STREAM frames on all streams. 889 A receiver sets initial credits for all streams by sending transport 890 parameters during the handshake (Section 7.3). A receiver sends 891 MAX_STREAM_DATA (Section 19.10) or MAX_DATA (Section 19.9) frames to 892 the sender to advertise additional credit. 894 A receiver advertises credit for a stream by sending a 895 MAX_STREAM_DATA frame with the Stream ID field set appropriately. A 896 MAX_STREAM_DATA frame indicates the maximum absolute byte offset of a 897 stream. A receiver could use the current offset of data consumed to 898 determine the flow control offset to be advertised. A receiver MAY 899 send MAX_STREAM_DATA frames in multiple packets in order to make sure 900 that the sender receives an update before running out of flow control 901 credit, even if one of the packets is lost. 903 A receiver advertises credit for a connection by sending a MAX_DATA 904 frame, which indicates the maximum of the sum of the absolute byte 905 offsets of all streams. A receiver maintains a cumulative sum of 906 bytes received on all streams, which is used to check for flow 907 control violations. A receiver might use a sum of bytes consumed on 908 all streams to determine the maximum data limit to be advertised. 910 A receiver can advertise a larger offset by sending MAX_STREAM_DATA 911 or MAX_DATA frames at any time during the connection. A receiver 912 cannot renege on an advertisement however. That is, once a receiver 913 advertises an offset, it MAY advertise a smaller offset, but this has 914 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 925 STREAM_DATA_BLOCKED or DATA_BLOCKED frames 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 sends a single STREAM_DATA_BLOCKED or DATA_BLOCKED frame 931 only once when it reaches a data limit. A sender SHOULD NOT send 932 multiple STREAM_DATA_BLOCKED or DATA_BLOCKED frames for the same data 933 limit, unless the original frame is determined to be lost. Another 934 STREAM_DATA_BLOCKED or DATA_BLOCKED frame can be sent after the data 935 limit is increased. 937 4.2. Flow Credit Increments 939 This document leaves when and how many bytes to advertise in a 940 MAX_STREAM_DATA or MAX_DATA frame to implementations, but offers a 941 few considerations. These frames contribute to connection overhead. 942 Therefore frequently sending frames with small changes is 943 undesirable. At the same time, larger increments to limits are 944 necessary to avoid blocking if updates are less frequent, requiring 945 larger resource commitments at the receiver. Thus there is a trade- 946 off between resource commitment and overhead when determining how 947 large a limit is advertised. 949 A receiver can use an autotuning mechanism to tune the frequency and 950 amount of advertised additional credit based on a round-trip time 951 estimate and the rate at which the receiving application consumes 952 data, similar to common TCP implementations. As an optimization, 953 sending frames related to flow control only when there are other 954 frames to send or when a peer is blocked ensures that flow control 955 doesn't cause extra packets to be sent. 957 If a sender runs out of flow control credit, it will be unable to 958 send new data and is considered blocked. It is generally considered 959 best to not let the sender become blocked. To avoid blocking a 960 sender, and to reasonably account for the possibility of loss, a 961 receiver should send a MAX_DATA or MAX_STREAM_DATA frame at least two 962 round trips before it expects the sender to get blocked. 964 A receiver MUST NOT wait for a STREAM_DATA_BLOCKED or DATA_BLOCKED 965 frame before sending MAX_STREAM_DATA or MAX_DATA, since doing so will 966 mean that a sender will be blocked for at least an entire round trip, 967 and potentially for longer if the peer chooses to not send 968 STREAM_DATA_BLOCKED or DATA_BLOCKED frames. 970 4.3. Handling Stream Cancellation 972 Endpoints need to eventually agree on the amount of flow control 973 credit that has been consumed, to avoid either exceeding flow control 974 limits or deadlocking. 976 On receipt of a RESET_STREAM frame, an endpoint will tear down state 977 for the matching stream and ignore further data arriving on that 978 stream. If a RESET_STREAM frame is reordered with stream data for 979 the same stream, the receiver's estimate of the number of bytes 980 received on that stream can be lower than the sender's estimate of 981 the number sent. As a result, the two endpoints could disagree on 982 the number of bytes that count towards connection flow control. 984 To remedy this issue, a RESET_STREAM frame (Section 19.4) includes 985 the final size of data sent on the stream. On receiving a 986 RESET_STREAM frame, a receiver definitively knows how many bytes were 987 sent on that stream before the RESET_STREAM frame, and the receiver 988 MUST use the final size of the stream to account for all bytes sent 989 on the stream in its connection level flow controller. 991 RESET_STREAM terminates one direction of a stream abruptly. For a 992 bidirectional stream, RESET_STREAM has no effect on data flow in the 993 opposite direction. Both endpoints MUST maintain flow control state 994 for the stream in the unterminated direction until that direction 995 enters a terminal state, or until one of the endpoints sends 996 CONNECTION_CLOSE. 998 4.4. Stream Final Size 1000 The final size is the amount of flow control credit that is consumed 1001 by a stream. Assuming that every contiguous byte on the stream was 1002 sent once, the final size is the number of bytes sent. More 1003 generally, this is one higher than the offset of the byte with the 1004 largest offset sent on the stream, or zero if no bytes were sent. 1006 For a stream that is reset, the final size is carried explicitly in a 1007 RESET_STREAM frame. Otherwise, the final size is the offset plus the 1008 length of a STREAM frame marked with a FIN flag, or 0 in the case of 1009 incoming unidirectional streams. 1011 An endpoint will know the final size for a stream when the receiving 1012 part of the stream enters the "Size Known" or "Reset Recvd" state 1013 (Section 3). 1015 An endpoint MUST NOT send data on a stream at or beyond the final 1016 size. 1018 Once a final size for a stream is known, it cannot change. If a 1019 RESET_STREAM or STREAM frame is received indicating a change in the 1020 final size for the stream, an endpoint SHOULD respond with a 1021 FINAL_SIZE_ERROR error (see Section 11). A receiver SHOULD treat 1022 receipt of data at or beyond the final size as a FINAL_SIZE_ERROR 1023 error, even after a stream is closed. Generating these errors is not 1024 mandatory, but only because requiring that an endpoint generate these 1025 errors also means that the endpoint needs to maintain the final size 1026 state for closed streams, which could mean a significant state 1027 commitment. 1029 4.5. Controlling Concurrency 1031 An endpoint limits the cumulative number of incoming streams a peer 1032 can open. Only streams with a stream ID less than (max_stream * 4 + 1033 initial_stream_id_for_type) can be opened (see Table 5). Initial 1034 limits are set in the transport parameters (see Section 18.1) and 1035 subsequently limits are advertised using MAX_STREAMS frames 1036 (Section 19.11). Separate limits apply to unidirectional and 1037 bidirectional streams. 1039 If a max_streams transport parameter or MAX_STREAMS frame is received 1040 with a value greater than 2^60, this would allow a maximum stream ID 1041 that cannot be expressed as a variable-length integer (see 1042 Section 16). If either is received, the connection MUST be closed 1043 immediately with a connection error of type STREAM_LIMIT_ERROR (see 1044 Section 10.3). 1046 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 1047 that receives a STREAM frame with a stream ID exceeding the limit it 1048 has sent MUST treat this as a stream error of type STREAM_LIMIT_ERROR 1049 (Section 11). 1051 A receiver cannot renege on an advertisement. That is, once a 1052 receiver advertises a stream limit using the MAX_STREAMS frame, 1053 advertising a smaller limit has no effect. A receiver MUST ignore 1054 any MAX_STREAMS frame that does not increase the stream limit. 1056 As with stream and connection flow control, this document leaves when 1057 and how many streams to advertise to a peer via MAX_STREAMS to 1058 implementations. Implementations might choose to increase limits as 1059 streams close to keep the number of streams available to peers 1060 roughly consistent. 1062 An endpoint that is unable to open a new stream due to the peer's 1063 limits SHOULD send a STREAMS_BLOCKED frame (Section 19.14). This 1064 signal is considered useful for debugging. An endpoint MUST NOT wait 1065 to receive this signal before advertising additional credit, since 1066 doing so will mean that the peer will be blocked for at least an 1067 entire round trip, and potentially for longer if the peer chooses to 1068 not send STREAMS_BLOCKED frames. 1070 5. Connections 1072 QUIC's connection establishment combines version negotiation with the 1073 cryptographic and transport handshakes to reduce connection 1074 establishment latency, as described in Section 7. Once established, 1075 a connection may migrate to a different IP or port at either endpoint 1076 as described in Section 9. Finally, a connection may be terminated 1077 by either endpoint, as described in Section 10. 1079 5.1. Connection ID 1081 Each connection possesses a set of connection identifiers, or 1082 connection IDs, each of which can identify the connection. 1083 Connection IDs are independently selected by endpoints; each endpoint 1084 selects the connection IDs that its peer uses. 1086 The primary function of a connection ID is to ensure that changes in 1087 addressing at lower protocol layers (UDP, IP) don't cause packets for 1088 a QUIC connection to be delivered to the wrong endpoint. Each 1089 endpoint selects connection IDs using an implementation-specific (and 1090 perhaps deployment-specific) method which will allow packets with 1091 that connection ID to be routed back to the endpoint and identified 1092 by the endpoint upon receipt. 1094 Connection IDs MUST NOT contain any information that can be used by 1095 an external observer to correlate them with other connection IDs for 1096 the same connection. As a trivial example, this means the same 1097 connection ID MUST NOT be issued more than once on the same 1098 connection. 1100 Packets with long headers include Source Connection ID and 1101 Destination Connection ID fields. These fields are used to set the 1102 connection IDs for new connections, see Section 7.2 for details. 1104 Packets with short headers (Section 17.3) only include the 1105 Destination Connection ID and omit the explicit length. The length 1106 of the Destination Connection ID field is expected to be known to 1107 endpoints. Endpoints using a load balancer that routes based on 1108 connection ID could agree with the load balancer on a fixed length 1109 for connection IDs, or agree on an encoding scheme. A fixed portion 1110 could encode an explicit length, which allows the entire connection 1111 ID to vary in length and still be used by the load balancer. 1113 A Version Negotiation (Section 17.2.1) packet echoes the connection 1114 IDs selected by the client, both to ensure correct routing toward the 1115 client and to allow the client to validate that the packet is in 1116 response to an Initial packet. 1118 A zero-length connection ID MAY be used when the connection ID is not 1119 needed for routing and the address/port tuple of packets is 1120 sufficient to identify a connection. An endpoint whose peer has 1121 selected a zero-length connection ID MUST continue to use a zero- 1122 length connection ID for the lifetime of the connection and MUST NOT 1123 send packets from any other local address. 1125 When an endpoint has requested a non-zero-length connection ID, it 1126 needs to ensure that the peer has a supply of connection IDs from 1127 which to choose for packets sent to the endpoint. These connection 1128 IDs are supplied by the endpoint using the NEW_CONNECTION_ID frame 1129 (Section 19.15). 1131 5.1.1. Issuing Connection IDs 1133 Each Connection ID has an associated sequence number to assist in 1134 deduplicating messages. The initial connection ID issued by an 1135 endpoint is sent in the Source Connection ID field of the long packet 1136 header (Section 17.2) during the handshake. The sequence number of 1137 the initial connection ID is 0. If the preferred_address transport 1138 parameter is sent, the sequence number of the supplied connection ID 1139 is 1. 1141 Additional connection IDs are communicated to the peer using 1142 NEW_CONNECTION_ID frames (Section 19.15). The sequence number on 1143 each newly-issued connection ID MUST increase by 1. The connection 1144 ID randomly selected by the client in the Initial packet and any 1145 connection ID provided by a Retry packet are not assigned sequence 1146 numbers unless a server opts to retain them as its initial connection 1147 ID. 1149 When an endpoint issues a connection ID, it MUST accept packets that 1150 carry this connection ID for the duration of the connection or until 1151 its peer invalidates the connection ID via a RETIRE_CONNECTION_ID 1152 frame (Section 19.16). 1154 Endpoints store received connection IDs for future use. An endpoint 1155 that receives excessive connection IDs MAY discard those it cannot 1156 store without sending a RETIRE_CONNECTION_ID frame. An endpoint that 1157 issues connection IDs cannot expect its peer to store and use all 1158 issued connection IDs. 1160 An endpoint SHOULD ensure that its peer has a sufficient number of 1161 available and unused connection IDs. While each endpoint 1162 independently chooses how many connection IDs to issue, endpoints 1163 SHOULD provide and maintain at least eight connection IDs. The 1164 endpoint SHOULD do this by supplying a new connection ID when a 1165 connection ID is retired by its peer or when the endpoint receives a 1166 packet with a previously unused connection ID. However, it MAY limit 1167 the frequency or the total number of connection IDs issued for each 1168 connection to avoid the risk of running out of connection IDs (see 1169 Section 10.4.2). 1171 An endpoint that initiates migration and requires non-zero-length 1172 connection IDs SHOULD ensure that the pool of connection IDs 1173 available to its peer allows the peer to use a new connection ID on 1174 migration, as the peer will close the connection if the pool is 1175 exhausted. 1177 5.1.2. Consuming and Retiring Connection IDs 1179 An endpoint can change the connection ID it uses for a peer to 1180 another available one at any time during the connection. An endpoint 1181 consumes connection IDs in response to a migrating peer, see 1182 Section 9.5 for more. 1184 An endpoint maintains a set of connection IDs received from its peer, 1185 any of which it can use when sending packets. When the endpoint 1186 wishes to remove a connection ID from use, it sends a 1187 RETIRE_CONNECTION_ID frame to its peer. Sending a 1188 RETIRE_CONNECTION_ID frame indicates that the connection ID won't be 1189 used again and requests that the peer replace it with a new 1190 connection ID using a NEW_CONNECTION_ID frame. 1192 As discussed in Section 9.5, each connection ID MUST be used on 1193 packets sent from only one local address. An endpoint that migrates 1194 away from a local address SHOULD retire all connection IDs used on 1195 that address once it no longer plans to use that address. 1197 5.2. Matching Packets to Connections 1199 Incoming packets are classified on receipt. Packets can either be 1200 associated with an existing connection, or - for servers - 1201 potentially create a new connection. 1203 Hosts try to associate a packet with an existing connection. If the 1204 packet has a Destination Connection ID corresponding to an existing 1205 connection, QUIC processes that packet accordingly. Note that more 1206 than one connection ID can be associated with a connection; see 1207 Section 5.1. 1209 If the Destination Connection ID is zero length and the packet 1210 matches the address/port tuple of a connection where the host did not 1211 require connection IDs, QUIC processes the packet as part of that 1212 connection. Endpoints SHOULD either reject connection attempts that 1213 use the same addresses as existing connections, or use a non-zero- 1214 length Destination Connection ID so that packets can be correctly 1215 attributed to connections. 1217 Endpoints can send a Stateless Reset (Section 10.4) for any packets 1218 that cannot be attributed to an existing connection. A stateless 1219 reset allows a peer to more quickly identify when a connection 1220 becomes unusable. 1222 Packets that are matched to an existing connection are discarded if 1223 the packets are inconsistent with the state of that connection. For 1224 example, packets are discarded if they indicate a different protocol 1225 version than that of the connection, or if the removal of packet 1226 protection is unsuccessful once the expected keys are available. 1228 Invalid packets without packet protection, such as Initial, Retry, or 1229 Version Negotiation, MAY be discarded. An endpoint MUST generate a 1230 connection error if it commits changes to state before discovering an 1231 error. 1233 5.2.1. Client Packet Handling 1235 Valid packets sent to clients always include a Destination Connection 1236 ID that matches a value the client selects. Clients that choose to 1237 receive zero-length connection IDs can use the address/port tuple to 1238 identify a connection. Packets that don't match an existing 1239 connection are discarded. 1241 Due to packet reordering or loss, clients might receive packets for a 1242 connection that are encrypted with a key it has not yet computed. 1243 Clients MAY drop these packets, or MAY buffer them in anticipation of 1244 later packets that allow it to compute the key. 1246 If a client receives a packet that has an unsupported version, it 1247 MUST discard that packet. 1249 5.2.2. Server Packet Handling 1251 If a server receives a packet that has an unsupported version, but 1252 the packet is sufficiently large to initiate a new connection for any 1253 version supported by the server, it SHOULD send a Version Negotiation 1254 packet as described in Section 6.1. Servers MAY rate control these 1255 packets to avoid storms of Version Negotiation packets. 1257 The first packet for an unsupported version can use different 1258 semantics and encodings for any version-specific field. In 1259 particular, different packet protection keys might be used for 1260 different versions. Servers that do not support a particular version 1261 are unlikely to be able to decrypt the payload of the packet. 1262 Servers SHOULD NOT attempt to decode or decrypt a packet from an 1263 unknown version, but instead send a Version Negotiation packet, 1264 provided that the packet is sufficiently long. 1266 Servers MUST drop other packets that contain unsupported versions. 1268 Packets with a supported version, or no version field, are matched to 1269 a connection using the connection ID or - for packets with zero- 1270 length connection IDs - the address tuple. If the packet doesn't 1271 match an existing connection, the server continues below. 1273 If the packet is an Initial packet fully conforming with the 1274 specification, the server proceeds with the handshake (Section 7). 1275 This commits the server to the version that the client selected. 1277 If a server isn't currently accepting any new connections, it SHOULD 1278 send an Initial packet containing a CONNECTION_CLOSE frame with error 1279 code SERVER_BUSY. 1281 If the packet is a 0-RTT packet, the server MAY buffer a limited 1282 number of these packets in anticipation of a late-arriving Initial 1283 Packet. Clients are forbidden from sending Handshake packets prior 1284 to receiving a server response, so servers SHOULD ignore any such 1285 packets. 1287 Servers MUST drop incoming packets under all other circumstances. 1289 5.3. Life of a QUIC Connection 1291 TBD. 1293 6. Version Negotiation 1295 Version negotiation ensures that client and server agree to a QUIC 1296 version that is mutually supported. A server sends a Version 1297 Negotiation packet in response to each packet that might initiate a 1298 new connection, see Section 5.2 for details. 1300 The size of the first packet sent by a client will determine whether 1301 a server sends a Version Negotiation packet. Clients that support 1302 multiple QUIC versions SHOULD pad the first packet they send to the 1303 largest of the minimum packet sizes across all versions they support. 1304 This ensures that the server responds if there is a mutually 1305 supported version. 1307 6.1. Sending Version Negotiation Packets 1309 If the version selected by the client is not acceptable to the 1310 server, the server responds with a Version Negotiation packet (see 1311 Section 17.2.1). This includes a list of versions that the server 1312 will accept. An endpoint MUST NOT send a Version Negotiation packet 1313 in response to receiving a Version Negotiation packet. 1315 This system allows a server to process packets with unsupported 1316 versions without retaining state. Though either the Initial packet 1317 or the Version Negotiation packet that is sent in response could be 1318 lost, the client will send new packets until it successfully receives 1319 a response or it abandons the connection attempt. 1321 A server MAY limit the number of Version Negotiation packets it 1322 sends. For instance, a server that is able to recognize packets as 1323 0-RTT might choose not to send Version Negotiation packets in 1324 response to 0-RTT packets with the expectation that it will 1325 eventually receive an Initial packet. 1327 6.2. Handling Version Negotiation Packets 1329 When a client receives a Version Negotiation packet, it MUST abandon 1330 the current connection attempt. Version Negotiation packets are 1331 designed to allow future versions of QUIC to negotiate the version in 1332 use between endpoints. Future versions of QUIC might change how 1333 implementations that support multiple versions of QUIC react to 1334 Version Negotiation packets when attempting to establish a connection 1335 using this version. How to perform version negotiation is left as 1336 future work defined by future versions of QUIC. In particular, that 1337 future work will need to ensure robustness against version downgrade 1338 attacks Section 21.9. 1340 6.2.1. Version Negotiation Between Draft Versions 1342 [[RFC editor: please remove this section before publication.]] 1344 When a draft implementation receives a Version Negotiation packet, it 1345 MAY use it to attempt a new connection with one of the versions 1346 listed in the packet, instead of abandoning the current connection 1347 attempt Section 6.2. 1349 The client MUST check that the Destination and Source Connection ID 1350 fields match the Source and Destination Connection ID fields in a 1351 packet that the client sent. If this check fails, the packet MUST be 1352 discarded. 1354 Once the Version Negotiation packet is determined to be valid, the 1355 client then selects an acceptable protocol version from the list 1356 provided by the server. The client then attempts to create a new 1357 connection using that version. The new connection MUST use a new 1358 random Destination Connection ID different from the one it had 1359 previously sent. 1361 Note that this mechanism does not protect against downgrade attacks 1362 and MUST NOT be used outside of draft implementations. 1364 6.3. Using Reserved Versions 1366 For a server to use a new version in the future, clients need to 1367 correctly handle unsupported versions. To help ensure this, a server 1368 SHOULD include a version that is reserved for forcing version 1369 negotiation (0x?a?a?a?a as defined in Section 15) when generating a 1370 Version Negotiation packet. 1372 The design of version negotiation permits a server to avoid 1373 maintaining state for packets that it rejects in this fashion. 1375 A client MAY send a packet using a version that is reserved for 1376 forcing version negotiation. This can be used to solicit a list of 1377 supported versions from a server. 1379 7. Cryptographic and Transport Handshake 1381 QUIC relies on a combined cryptographic and transport handshake to 1382 minimize connection establishment latency. QUIC uses the CRYPTO 1383 frame Section 19.6 to transmit the cryptographic handshake. Version 1384 0x00000001 of QUIC uses TLS as described in [QUIC-TLS]; a different 1385 QUIC version number could indicate that a different cryptographic 1386 handshake protocol is in use. 1388 QUIC provides reliable, ordered delivery of the cryptographic 1389 handshake data. QUIC packet protection is used to encrypt as much of 1390 the handshake protocol as possible. The cryptographic handshake MUST 1391 provide the following properties: 1393 o authenticated key exchange, where 1395 * a server is always authenticated, 1397 * a client is optionally authenticated, 1399 * every connection produces distinct and unrelated keys, 1401 * keying material is usable for packet protection for both 0-RTT 1402 and 1-RTT packets, and 1404 * 1-RTT keys have forward secrecy 1406 o authenticated values for the transport parameters of the peer (see 1407 Section 7.3) 1409 o authenticated negotiation of an application protocol (TLS uses 1410 ALPN [RFC7301] for this purpose) 1412 The first CRYPTO frame from a client MUST be sent in a single packet. 1413 Any second attempt that is triggered by address validation (see 1414 Section 8.1) MUST also be sent within a single packet. This avoids 1415 having to reassemble a message from multiple packets. 1417 The first client packet of the cryptographic handshake protocol MUST 1418 fit within a 1232 byte QUIC packet payload. This includes overheads 1419 that reduce the space available to the cryptographic handshake 1420 protocol. 1422 An endpoint can verify support for Explicit Congestion Notification 1423 (ECN) in the first packets it sends, as described in Section 13.3.2. 1425 The CRYPTO frame can be sent in different packet number spaces. The 1426 sequence numbers used by CRYPTO frames to ensure ordered delivery of 1427 cryptographic handshake data start from zero in each packet number 1428 space. 1430 Endpoints MUST explicitly negotiate an application protocol. This 1431 avoids situations where there is a disagreement about the protocol 1432 that is in use. 1434 7.1. Example Handshake Flows 1436 Details of how TLS is integrated with QUIC are provided in 1437 [QUIC-TLS], but some examples are provided here. An extension of 1438 this exchange to support client address validation is shown in 1439 Section 8.1.1. 1441 Once any address validation exchanges are complete, the cryptographic 1442 handshake is used to agree on cryptographic keys. The cryptographic 1443 handshake is carried in Initial (Section 17.2.2) and Handshake 1444 (Section 17.2.4) packets. 1446 Figure 3 provides an overview of the 1-RTT handshake. Each line 1447 shows a QUIC packet with the packet type and packet number shown 1448 first, followed by the frames that are typically contained in those 1449 packets. So, for instance the first packet is of type Initial, with 1450 packet number 0, and contains a CRYPTO frame carrying the 1451 ClientHello. 1453 Note that multiple QUIC packets - even of different encryption levels 1454 - may be coalesced into a single UDP datagram (see Section 12.2), and 1455 so this handshake may consist of as few as 4 UDP datagrams, or any 1456 number more. For instance, the server's first flight contains 1457 packets from the Initial encryption level (obfuscation), the 1458 Handshake level, and "0.5-RTT data" from the server at the 1-RTT 1459 encryption level. 1461 Client Server 1463 Initial[0]: CRYPTO[CH] -> 1465 Initial[0]: CRYPTO[SH] ACK[0] 1466 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1467 <- 1-RTT[0]: STREAM[1, "..."] 1469 Initial[1]: ACK[0] 1470 Handshake[0]: CRYPTO[FIN], ACK[0] 1471 1-RTT[0]: STREAM[0, "..."], ACK[0] -> 1473 1-RTT[1]: STREAM[3, "..."], ACK[0] 1474 <- Handshake[1]: ACK[0] 1476 Figure 3: Example 1-RTT Handshake 1478 Figure 4 shows an example of a connection with a 0-RTT handshake and 1479 a single packet of 0-RTT data. Note that as described in 1480 Section 12.3, the server acknowledges 0-RTT data at the 1-RTT 1481 encryption level, and the client sends 1-RTT packets in the same 1482 packet number space. 1484 Client Server 1486 Initial[0]: CRYPTO[CH] 1487 0-RTT[0]: STREAM[0, "..."] -> 1489 Initial[0]: CRYPTO[SH] ACK[0] 1490 Handshake[0] CRYPTO[EE, FIN] 1491 <- 1-RTT[0]: STREAM[1, "..."] ACK[0] 1493 Initial[1]: ACK[0] 1494 Handshake[0]: CRYPTO[FIN], ACK[0] 1495 1-RTT[1]: STREAM[0, "..."] ACK[0] -> 1497 1-RTT[1]: STREAM[3, "..."], ACK[1] 1498 <- Handshake[1]: ACK[0] 1500 Figure 4: Example 0-RTT Handshake 1502 7.2. Negotiating Connection IDs 1504 A connection ID is used to ensure consistent routing of packets, as 1505 described in Section 5.1. The long header contains two connection 1506 IDs: the Destination Connection ID is chosen by the recipient of the 1507 packet and is used to provide consistent routing; the Source 1508 Connection ID is used to set the Destination Connection ID used by 1509 the peer. 1511 During the handshake, packets with the long header (Section 17.2) are 1512 used to establish the connection ID that each endpoint uses. Each 1513 endpoint uses the Source Connection ID field to specify the 1514 connection ID that is used in the Destination Connection ID field of 1515 packets being sent to them. Upon receiving a packet, each endpoint 1516 sets the Destination Connection ID it sends to match the value of the 1517 Source Connection ID that they receive. 1519 When an Initial packet is sent by a client which has not previously 1520 received a Retry packet from the server, it populates the Destination 1521 Connection ID field with an unpredictable value. This MUST be at 1522 least 8 bytes in length. Until a packet is received from the server, 1523 the client MUST use the same value unless it abandons the connection 1524 attempt and starts a new one. The initial Destination Connection ID 1525 is used to determine packet protection keys for Initial packets. 1527 The client populates the Source Connection ID field with a value of 1528 its choosing and sets the SCIL field to indicate the length. 1530 The first flight of 0-RTT packets use the same Destination and Source 1531 Connection ID values as the client's first Initial. 1533 The Destination Connection ID field in the server's Initial packet 1534 contains a connection ID that is chosen by the recipient of the 1535 packet (i.e., the client); the Source Connection ID includes the 1536 connection ID that the sender of the packet wishes to use (see 1537 Section 5.1). The server MUST use consistent Source Connection IDs 1538 during the handshake. 1540 On first receiving an Initial or Retry packet from the server, the 1541 client uses the Source Connection ID supplied by the server as the 1542 Destination Connection ID for subsequent packets, including any 1543 subsequent 0-RTT packets. That means that a client might change the 1544 Destination Connection ID twice during connection establishment, once 1545 in response to a Retry and once in response to the first Initial 1546 packet from the server. Once a client has received an Initial packet 1547 from the server, it MUST discard any packet it receives with a 1548 different Source Connection ID. 1550 A client MUST only change the value it sends in the Destination 1551 Connection ID in response to the first packet of each type it 1552 receives from the server (Retry or Initial); a server MUST set its 1553 value based on the Initial packet. Any additional changes are not 1554 permitted; if subsequent packets of those types include a different 1555 Source Connection ID, they MUST be discarded. This avoids problems 1556 that might arise from stateless processing of multiple Initial 1557 packets producing different connection IDs. 1559 The connection ID can change over the lifetime of a connection, 1560 especially in response to connection migration (Section 9), see 1561 Section 5.1.1 for details. 1563 7.3. Transport Parameters 1565 During connection establishment, both endpoints make authenticated 1566 declarations of their transport parameters. These declarations are 1567 made unilaterally by each endpoint. Endpoints are required to comply 1568 with the restrictions implied by these parameters; the description of 1569 each parameter includes rules for its handling. 1571 The encoding of the transport parameters is detailed in Section 18. 1573 QUIC includes the encoded transport parameters in the cryptographic 1574 handshake. Once the handshake completes, the transport parameters 1575 declared by the peer are available. Each endpoint validates the 1576 value provided by its peer. 1578 Definitions for each of the defined transport parameters are included 1579 in Section 18.1. An endpoint MUST treat receipt of a transport 1580 parameter with an invalid value as a connection error of type 1581 TRANSPORT_PARAMETER_ERROR. Any given parameter MUST appear at most 1582 once in a given transport parameters extension. An endpoint MUST 1583 treat receipt of duplicate transport parameters as a connection error 1584 of type TRANSPORT_PARAMETER_ERROR. 1586 A server MUST include the original_connection_id transport parameter 1587 (Section 18.1) if it sent a Retry packet to enable validation of the 1588 Retry, as described in Section 17.2.5. 1590 7.3.1. Values of Transport Parameters for 0-RTT 1592 Both endpoints store the value of the server transport parameters 1593 from a connection and apply them to any 0-RTT packets that are sent 1594 in subsequent connections to that peer, except for transport 1595 parameters that are explicitly excluded. Remembered transport 1596 parameters apply to the new connection until the handshake completes 1597 and the client starts sending 1-RTT packets. Once the handshake 1598 completes, the client uses the transport parameters established in 1599 the handshake. 1601 The definition of new transport parameters (Section 7.3.2) MUST 1602 specify whether they MUST, MAY, or MUST NOT be stored for 0-RTT. A 1603 client need not store a transport parameter it cannot process. 1605 A client MUST NOT use remembered values for the following parameters: 1606 original_connection_id, preferred_address, stateless_reset_token, and 1607 ack_delay_exponent. The client MUST use the server's new values in 1608 the handshake instead, and absent new values from the server, the 1609 default value. 1611 A client that attempts to send 0-RTT data MUST remember all other 1612 transport parameters used by the server. The server can remember 1613 these transport parameters, or store an integrity-protected copy of 1614 the values in the ticket and recover the information when accepting 1615 0-RTT data. A server uses the transport parameters in determining 1616 whether to accept 0-RTT data. 1618 If 0-RTT data is accepted by the server, the server MUST NOT reduce 1619 any limits or alter any values that might be violated by the client 1620 with its 0-RTT data. In particular, a server that accepts 0-RTT data 1621 MUST NOT set values for the following parameters (Section 18.1) that 1622 are smaller than the remembered value of the parameters. 1624 o initial_max_data 1626 o initial_max_stream_data_bidi_local 1628 o initial_max_stream_data_bidi_remote 1630 o initial_max_stream_data_uni 1632 o initial_max_streams_bidi 1634 o initial_max_streams_uni 1636 Omitting or setting a zero value for certain transport parameters can 1637 result in 0-RTT data being enabled, but not usable. The applicable 1638 subset of transport parameters that permit sending of application 1639 data SHOULD be set to non-zero values for 0-RTT. This includes 1640 initial_max_data and either initial_max_streams_bidi and 1641 initial_max_stream_data_bidi_remote, or initial_max_streams_uni and 1642 initial_max_stream_data_uni. 1644 A server MUST either reject 0-RTT data or abort a handshake if the 1645 implied values for transport parameters cannot be supported. 1647 7.3.2. New Transport Parameters 1649 New transport parameters can be used to negotiate new protocol 1650 behavior. An endpoint MUST ignore transport parameters that it does 1651 not support. Absence of a transport parameter therefore disables any 1652 optional protocol feature that is negotiated using the parameter. 1654 New transport parameters can be registered according to the rules in 1655 Section 22.1. 1657 7.4. Cryptographic Message Buffering 1659 Implementations need to maintain a buffer of CRYPTO data received out 1660 of order. Because there is no flow control of CRYPTO frames, an 1661 endpoint could potentially force its peer to buffer an unbounded 1662 amount of data. 1664 Implementations MUST support buffering at least 4096 bytes of data 1665 received in CRYPTO frames out of order. Endpoints MAY choose to 1666 allow more data to be buffered during the handshake. A larger limit 1667 during the handshake could allow for larger keys or credentials to be 1668 exchanged. An endpoint's buffer size does not need to remain 1669 constant during the life of the connection. 1671 Being unable to buffer CRYPTO frames during the handshake can lead to 1672 a connection failure. If an endpoint's buffer is exceeded during the 1673 handshake, it can expand its buffer temporarily to complete the 1674 handshake. If an endpoint does not expand its buffer, it MUST close 1675 the connection with a CRYPTO_BUFFER_EXCEEDED error code. 1677 Once the handshake completes, if an endpoint is unable to buffer all 1678 data in a CRYPTO frame, it MAY discard that CRYPTO frame and all 1679 CRYPTO frames received in the future, or it MAY close the connection 1680 with an CRYPTO_BUFFER_EXCEEDED error code. Packets containing 1681 discarded CRYPTO frames MUST be acknowledged because the packet has 1682 been received and processed by the transport even though the CRYPTO 1683 frame was discarded. 1685 8. Address Validation 1687 Address validation is used by QUIC to avoid being used for a traffic 1688 amplification attack. In such an attack, a packet is sent to a 1689 server with spoofed source address information that identifies a 1690 victim. If a server generates more or larger packets in response to 1691 that packet, the attacker can use the server to send more data toward 1692 the victim than it would be able to send on its own. 1694 The primary defense against amplification attack is verifying that an 1695 endpoint is able to receive packets at the transport address that it 1696 claims. Address validation is performed both during connection 1697 establishment (see Section 8.1) and during connection migration (see 1698 Section 8.2). 1700 8.1. Address Validation During Connection Establishment 1702 Connection establishment implicitly provides address validation for 1703 both endpoints. In particular, receipt of a packet protected with 1704 Handshake keys confirms that the client received the Initial packet 1705 from the server. Once the server has successfully processed a 1706 Handshake packet from the client, it can consider the client address 1707 to have been validated. 1709 Prior to validating the client address, servers MUST NOT send more 1710 than three times as many bytes as the number of bytes they have 1711 received. This limits the magnitude of any amplification attack that 1712 can be mounted using spoofed source addresses. In determining this 1713 limit, servers only count the size of successfully processed packets. 1715 Clients MUST ensure that UDP datagrams containing only Initial 1716 packets are sized to at least 1200 bytes, adding padding to packets 1717 in the datagram as necessary. Sending padded datagrams ensures that 1718 the server is not overly constrained by the amplification 1719 restriction. 1721 Packet loss, in particular loss of a Handshake packet from the 1722 server, can cause a situation in which the server cannot send when 1723 the client has no data to send and the anti-amplification limit is 1724 reached. In order to avoid this causing a handshake deadlock, 1725 clients SHOULD send a packet upon a crypto retransmission timeout, as 1726 described in [QUIC-RECOVERY]. If the client has no data to 1727 retransmit and does not have Handshake keys, it SHOULD send an 1728 Initial packet in a UDP datagram of at least 1200 bytes. If the 1729 client has Handshake keys, it SHOULD send a Handshake packet. 1731 A server might wish to validate the client address before starting 1732 the cryptographic handshake. QUIC uses a token in the Initial packet 1733 to provide address validation prior to completing the handshake. 1734 This token is delivered to the client during connection establishment 1735 with a Retry packet (see Section 8.1.1) or in a previous connection 1736 using the NEW_TOKEN frame (see Section 8.1.2). 1738 In addition to sending limits imposed prior to address validation, 1739 servers are also constrained in what they can send by the limits set 1740 by the congestion controller. Clients are only constrained by the 1741 congestion controller. 1743 8.1.1. Address Validation using Retry Packets 1745 Upon receiving the client's Initial packet, the server can request 1746 address validation by sending a Retry packet (Section 17.2.5) 1747 containing a token. This token MUST be repeated by the client in all 1748 Initial packets it sends for that connection after it receives the 1749 Retry packet. In response to processing an Initial containing a 1750 token, a server can either abort the connection or permit it to 1751 proceed. 1753 As long as it is not possible for an attacker to generate a valid 1754 token for its own address (see Section 8.1.3) and the client is able 1755 to return that token, it proves to the server that it received the 1756 token. 1758 A server can also use a Retry packet to defer the state and 1759 processing costs of connection establishment. By giving the client a 1760 different connection ID to use, a server can cause the connection to 1761 be routed to a server instance with more resources available for new 1762 connections. 1764 A flow showing the use of a Retry packet is shown in Figure 5. 1766 Client Server 1768 Initial[0]: CRYPTO[CH] -> 1770 <- Retry+Token 1772 Initial+Token[1]: CRYPTO[CH] -> 1774 Initial[0]: CRYPTO[SH] ACK[1] 1775 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1776 <- 1-RTT[0]: STREAM[1, "..."] 1778 Figure 5: Example Handshake with Retry 1780 8.1.2. Address Validation for Future Connections 1782 A server MAY provide clients with an address validation token during 1783 one connection that can be used on a subsequent connection. Address 1784 validation is especially important with 0-RTT because a server 1785 potentially sends a significant amount of data to a client in 1786 response to 0-RTT data. 1788 The server uses the NEW_TOKEN frame Section 19.7 to provide the 1789 client with an address validation token that can be used to validate 1790 future connections. The client includes this token in Initial 1791 packets to provide address validation in a future connection. The 1792 client MUST include the token in all Initial packets it sends, unless 1793 a Retry or NEW_TOKEN frame replaces the token with a newer one. The 1794 client MUST NOT use the token provided in a Retry for future 1795 connections. Servers MAY discard any Initial packet that does not 1796 carry the expected token. 1798 Unlike the token that is created for a Retry packet, there might be 1799 some time between when the token is created and when the token is 1800 subsequently used. Thus, a token SHOULD include an expiration time. 1801 The server MAY include either an explicit expiration time or an 1802 issued timestamp and dynamically calculate the expiration time. It 1803 is also unlikely that the client port number is the same on two 1804 different connections; validating the port is therefore unlikely to 1805 be successful. 1807 A token SHOULD be constructed for the server to easily distinguish it 1808 from tokens that are sent in Retry packets as they are carried in the 1809 same field. 1811 If the client has a token received in a NEW_TOKEN frame on a previous 1812 connection to what it believes to be the same server, it SHOULD 1813 include that value in the Token field of its Initial packet. 1814 Including a token might allow the server to validate the client 1815 address without an additional round trip. 1817 A token allows a server to correlate activity between the connection 1818 where the token was issued and any connection where it is used. 1819 Clients that want to break continuity of identity with a server MAY 1820 discard tokens provided using the NEW_TOKEN frame. A token obtained 1821 in a Retry packet MUST be used immediately during the connection 1822 attempt and cannot be used in subsequent connection attempts. 1824 A client SHOULD NOT reuse a token in different connections. Reusing 1825 a token allows connections to be linked by entities on the network 1826 path (see Section 9.5). A client MUST NOT reuse a token if it 1827 believes that its point of network attachment has changed since the 1828 token was last used; that is, if there is a change in its local IP 1829 address or network interface. A client needs to start the connection 1830 process over if it migrates prior to completing the handshake. 1832 When a server receives an Initial packet with an address validation 1833 token, it MUST attempt to validate the token, unless it has already 1834 completed address validation. If the token is invalid then the 1835 server SHOULD proceed as if the client did not have a validated 1836 address, including potentially sending a Retry. If the validation 1837 succeeds, the server SHOULD then allow the handshake to proceed. 1839 Note: The rationale for treating the client as unvalidated rather 1840 than discarding the packet is that the client might have received 1841 the token in a previous connection using the NEW_TOKEN frame, and 1842 if the server has lost state, it might be unable to validate the 1843 token at all, leading to connection failure if the packet is 1844 discarded. A server SHOULD encode tokens provided with NEW_TOKEN 1845 frames and Retry packets differently, and validate the latter more 1846 strictly. 1848 In a stateless design, a server can use encrypted and authenticated 1849 tokens to pass information to clients that the server can later 1850 recover and use to validate a client address. Tokens are not 1851 integrated into the cryptographic handshake and so they are not 1852 authenticated. For instance, a client might be able to reuse a 1853 token. To avoid attacks that exploit this property, a server can 1854 limit its use of tokens to only the information needed to validate 1855 client addresses. 1857 Attackers could replay tokens to use servers as amplifiers in DDoS 1858 attacks. To protect against such attacks, servers SHOULD ensure that 1859 tokens sent in Retry packets are only accepted for a short time. 1860 Tokens that are provided in NEW_TOKEN frames (see Section 19.7) need 1861 to be valid for longer, but SHOULD NOT be accepted multiple times in 1862 a short period. Servers are encouraged to allow tokens to be used 1863 only once, if possible. 1865 8.1.3. Address Validation Token Integrity 1867 An address validation token MUST be difficult to guess. Including a 1868 large enough random value in the token would be sufficient, but this 1869 depends on the server remembering the value it sends to clients. 1871 A token-based scheme allows the server to offload any state 1872 associated with validation to the client. For this design to work, 1873 the token MUST be covered by integrity protection against 1874 modification or falsification by clients. Without integrity 1875 protection, malicious clients could generate or guess values for 1876 tokens that would be accepted by the server. Only the server 1877 requires access to the integrity protection key for tokens. 1879 There is no need for a single well-defined format for the token 1880 because the server that generates the token also consumes it. A 1881 token could include information about the claimed client address (IP 1882 and port), a timestamp, and any other supplementary information the 1883 server will need to validate the token in the future. 1885 8.2. Path Validation 1887 Path validation is used during connection migration (see Section 9 1888 and Section 9.6) by the migrating endpoint to verify reachability of 1889 a peer from a new local address. In path validation, endpoints test 1890 reachability between a specific local address and a specific peer 1891 address, where an address is the two-tuple of IP address and port. 1893 Path validation tests that packets (PATH_CHALLENGE) can be both sent 1894 to and received (PATH_RESPONSE) from a peer on the path. 1895 Importantly, it validates that the packets received from the 1896 migrating endpoint do not carry a spoofed source address. 1898 Path validation can be used at any time by either endpoint. For 1899 instance, an endpoint might check that a peer is still in possession 1900 of its address after a period of quiescence. 1902 Path validation is not designed as a NAT traversal mechanism. Though 1903 the mechanism described here might be effective for the creation of 1904 NAT bindings that support NAT traversal, the expectation is that one 1905 or other peer is able to receive packets without first having sent a 1906 packet on that path. Effective NAT traversal needs additional 1907 synchronization mechanisms that are not provided here. 1909 An endpoint MAY bundle PATH_CHALLENGE and PATH_RESPONSE frames that 1910 are used for path validation with other frames. In particular, an 1911 endpoint may pad a packet carrying a PATH_CHALLENGE for PMTU 1912 discovery, or an endpoint may bundle a PATH_RESPONSE with its own 1913 PATH_CHALLENGE. 1915 When probing a new path, an endpoint might want to ensure that its 1916 peer has an unused connection ID available for responses. The 1917 endpoint can send NEW_CONNECTION_ID and PATH_CHALLENGE frames in the 1918 same packet. This ensures that an unused connection ID will be 1919 available to the peer when sending a response. 1921 8.3. Initiating Path Validation 1923 To initiate path validation, an endpoint sends a PATH_CHALLENGE frame 1924 containing a random payload on the path to be validated. 1926 An endpoint MAY send multiple PATH_CHALLENGE frames to guard against 1927 packet loss. An endpoint SHOULD NOT send a PATH_CHALLENGE more 1928 frequently than it would an Initial packet, ensuring that connection 1929 migration is no more load on a new path than establishing a new 1930 connection. 1932 The endpoint MUST use unpredictable data in every PATH_CHALLENGE 1933 frame so that it can associate the peer's response with the 1934 corresponding PATH_CHALLENGE. 1936 8.4. Path Validation Responses 1938 On receiving a PATH_CHALLENGE frame, an endpoint MUST respond 1939 immediately by echoing the data contained in the PATH_CHALLENGE frame 1940 in a PATH_RESPONSE frame. 1942 To ensure that packets can be both sent to and received from the 1943 peer, the PATH_RESPONSE MUST be sent on the same path as the 1944 triggering PATH_CHALLENGE. That is, from the same local address on 1945 which the PATH_CHALLENGE was received, to the same remote address 1946 from which the PATH_CHALLENGE was received. 1948 8.5. Successful Path Validation 1950 A new address is considered valid when a PATH_RESPONSE frame is 1951 received that meets the following criteria: 1953 o It contains the data that was sent in a previous PATH_CHALLENGE. 1954 Receipt of an acknowledgment for a packet containing a 1955 PATH_CHALLENGE frame is not adequate validation, since the 1956 acknowledgment can be spoofed by a malicious peer. 1958 o It was sent from the same remote address to which the 1959 corresponding PATH_CHALLENGE was sent. If a PATH_RESPONSE frame 1960 is received from a different remote address than the one to which 1961 the PATH_CHALLENGE was sent, path validation is considered to have 1962 failed, even if the data matches that sent in the PATH_CHALLENGE. 1964 o It was received on the same local address from which the 1965 corresponding PATH_CHALLENGE was sent. 1967 Note that receipt on a different local address does not result in 1968 path validation failure, as it might be a result of a forwarded 1969 packet (see Section 9.3.3) or misrouting. It is possible that a 1970 valid PATH_RESPONSE might be received in the future. 1972 8.6. Failed Path Validation 1974 Path validation only fails when the endpoint attempting to validate 1975 the path abandons its attempt to validate the path. 1977 Endpoints SHOULD abandon path validation based on a timer. When 1978 setting this timer, implementations are cautioned that the new path 1979 could have a longer round-trip time than the original. A value of 1980 three times the larger of the current Probe Timeout (PTO) or the 1981 initial timeout (that is, 2*kInitialRtt) as defined in 1982 [QUIC-RECOVERY] is RECOMMENDED. That is: 1984 validation_timeout = max(3*PTO, 6*kInitialRtt) 1986 Note that the endpoint might receive packets containing other frames 1987 on the new path, but a PATH_RESPONSE frame with appropriate data is 1988 required for path validation to succeed. 1990 When an endpoint abandons path validation, it determines that the 1991 path is unusable. This does not necessarily imply a failure of the 1992 connection - endpoints can continue sending packets over other paths 1993 as appropriate. If no paths are available, an endpoint can wait for 1994 a new path to become available or close the connection. 1996 A path validation might be abandoned for other reasons besides 1997 failure. Primarily, this happens if a connection migration to a new 1998 path is initiated while a path validation on the old path is in 1999 progress. 2001 9. Connection Migration 2003 The use of a connection ID allows connections to survive changes to 2004 endpoint addresses (that is, IP address and/or port), such as those 2005 caused by an endpoint migrating to a new network. This section 2006 describes the process by which an endpoint migrates to a new address. 2008 An endpoint MUST NOT initiate connection migration before the 2009 handshake is finished and the endpoint has 1-RTT keys. The design of 2010 QUIC relies on endpoints retaining a stable address for the duration 2011 of the handshake. 2013 An endpoint also MUST NOT initiate connection migration if the peer 2014 sent the "disable_migration" transport parameter during the 2015 handshake. An endpoint which has sent this transport parameter, but 2016 detects that a peer has nonetheless migrated to a different network 2017 MAY treat this as a connection error of type INVALID_MIGRATION. 2018 Similarly, an endpoint MUST NOT initiate migration if its peer 2019 supplies a zero-length connection ID as packets without a Destination 2020 Connection ID cannot be attributed to a connection based on address 2021 tuple. 2023 Not all changes of peer address are intentional migrations. The peer 2024 could experience NAT rebinding: a change of address due to a 2025 middlebox, usually a NAT, allocating a new outgoing port or even a 2026 new outgoing IP address for a flow. NAT rebinding is not connection 2027 migration as defined in this section, though an endpoint SHOULD 2028 perform path validation (Section 8.2) if it detects a change in the 2029 IP address of its peer. 2031 When an endpoint has no validated path on which to send packets, it 2032 MAY discard connection state. An endpoint capable of connection 2033 migration MAY wait for a new path to become available before 2034 discarding connection state. 2036 This document limits migration of connections to new client 2037 addresses, except as described in Section 9.6. Clients are 2038 responsible for initiating all migrations. Servers do not send non- 2039 probing packets (see Section 9.1) toward a client address until they 2040 see a non-probing packet from that address. If a client receives 2041 packets from an unknown server address, the client MUST discard these 2042 packets. 2044 9.1. Probing a New Path 2046 An endpoint MAY probe for peer reachability from a new local address 2047 using path validation Section 8.2 prior to migrating the connection 2048 to the new local address. Failure of path validation simply means 2049 that the new path is not usable for this connection. Failure to 2050 validate a path does not cause the connection to end unless there are 2051 no valid alternative paths available. 2053 An endpoint uses a new connection ID for probes sent from a new local 2054 address, see Section 9.5 for further discussion. An endpoint that 2055 uses a new local address needs to ensure that at least one new 2056 connection ID is available at the peer. That can be achieved by 2057 including a NEW_CONNECTION_ID frame in the probe. 2059 Receiving a PATH_CHALLENGE frame from a peer indicates that the peer 2060 is probing for reachability on a path. An endpoint sends a 2061 PATH_RESPONSE in response as per Section 8.2. 2063 PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames 2064 are "probing frames", and all other frames are "non-probing frames". 2065 A packet containing only probing frames is a "probing packet", and a 2066 packet containing any other frame is a "non-probing packet". 2068 9.2. Initiating Connection Migration 2070 An endpoint can migrate a connection to a new local address by 2071 sending packets containing non-probing frames from that address. 2073 Each endpoint validates its peer's address during connection 2074 establishment. Therefore, a migrating endpoint can send to its peer 2075 knowing that the peer is willing to receive at the peer's current 2076 address. Thus an endpoint can migrate to a new local address without 2077 first validating the peer's address. 2079 When migrating, the new path might not support the endpoint's current 2080 sending rate. Therefore, the endpoint resets its congestion 2081 controller, as described in Section 9.4. 2083 The new path might not have the same ECN capability. Therefore, the 2084 endpoint verifies ECN capability as described in Section 13.3. 2086 Receiving acknowledgments for data sent on the new path serves as 2087 proof of the peer's reachability from the new address. Note that 2088 since acknowledgments may be received on any path, return 2089 reachability on the new path is not established. To establish return 2090 reachability on the new path, an endpoint MAY concurrently initiate 2091 path validation Section 8.2 on the new path. 2093 9.3. Responding to Connection Migration 2095 Receiving a packet from a new peer address containing a non-probing 2096 frame indicates that the peer has migrated to that address. 2098 In response to such a packet, an endpoint MUST start sending 2099 subsequent packets to the new peer address and MUST initiate path 2100 validation (Section 8.2) to verify the peer's ownership of the 2101 unvalidated address. 2103 An endpoint MAY send data to an unvalidated peer address, but it MUST 2104 protect against potential attacks as described in Section 9.3.1 and 2105 Section 9.3.2. An endpoint MAY skip validation of a peer address if 2106 that address has been seen recently. 2108 An endpoint only changes the address that it sends packets to in 2109 response to the highest-numbered non-probing packet. This ensures 2110 that an endpoint does not send packets to an old peer address in the 2111 case that it receives reordered packets. 2113 After changing the address to which it sends non-probing packets, an 2114 endpoint could abandon any path validation for other addresses. 2116 Receiving a packet from a new peer address might be the result of a 2117 NAT rebinding at the peer. 2119 After verifying a new client address, the server SHOULD send new 2120 address validation tokens (Section 8) to the client. 2122 9.3.1. Peer Address Spoofing 2124 It is possible that a peer is spoofing its source address to cause an 2125 endpoint to send excessive amounts of data to an unwilling host. If 2126 the endpoint sends significantly more data than the spoofing peer, 2127 connection migration might be used to amplify the volume of data that 2128 an attacker can generate toward a victim. 2130 As described in Section 9.3, an endpoint is required to validate a 2131 peer's new address to confirm the peer's possession of the new 2132 address. Until a peer's address is deemed valid, an endpoint MUST 2133 limit the rate at which it sends data to this address. The endpoint 2134 MUST NOT send more than a minimum congestion window's worth of data 2135 per estimated round-trip time (kMinimumWindow, as defined in 2136 [QUIC-RECOVERY]). In the absence of this limit, an endpoint risks 2137 being used for a denial of service attack against an unsuspecting 2138 victim. Note that since the endpoint will not have any round-trip 2139 time measurements to this address, the estimate SHOULD be the default 2140 initial value (see [QUIC-RECOVERY]). 2142 If an endpoint skips validation of a peer address as described in 2143 Section 9.3, it does not need to limit its sending rate. 2145 9.3.2. On-Path Address Spoofing 2147 An on-path attacker could cause a spurious connection migration by 2148 copying and forwarding a packet with a spoofed address such that it 2149 arrives before the original packet. The packet with the spoofed 2150 address will be seen to come from a migrating connection, and the 2151 original packet will be seen as a duplicate and dropped. After a 2152 spurious migration, validation of the source address will fail 2153 because the entity at the source address does not have the necessary 2154 cryptographic keys to read or respond to the PATH_CHALLENGE frame 2155 that is sent to it even if it wanted to. 2157 To protect the connection from failing due to such a spurious 2158 migration, an endpoint MUST revert to using the last validated peer 2159 address when validation of a new peer address fails. 2161 If an endpoint has no state about the last validated peer address, it 2162 MUST close the connection silently by discarding all connection 2163 state. This results in new packets on the connection being handled 2164 generically. For instance, an endpoint MAY send a stateless reset in 2165 response to any further incoming packets. 2167 Note that receipt of packets with higher packet numbers from the 2168 legitimate peer address will trigger another connection migration. 2169 This will cause the validation of the address of the spurious 2170 migration to be abandoned. 2172 9.3.3. Off-Path Packet Forwarding 2174 An off-path attacker that can observe packets might forward copies of 2175 genuine packets to endpoints. If the copied packet arrives before 2176 the genuine packet, this will appear as a NAT rebinding. Any genuine 2177 packet will be discarded as a duplicate. If the attacker is able to 2178 continue forwarding packets, it might be able to cause migration to a 2179 path via the attacker. This places the attacker on path, giving it 2180 the ability to observe or drop all subsequent packets. 2182 Unlike the attack described in Section 9.3.2, the attacker can ensure 2183 that the new path is successfully validated. 2185 This style of attack relies on the attacker using a path that is 2186 approximately as fast as the direct path between endpoints. The 2187 attack is more reliable if relatively few packets are sent or if 2188 packet loss coincides with the attempted attack. 2190 A non-probing packet received on the original path that increases the 2191 maximum received packet number will cause the endpoint to move back 2192 to that path. Eliciting packets on this path increases the 2193 likelihood that the attack is unsuccessful. Therefore, mitigation of 2194 this attack relies on triggering the exchange of packets. 2196 In response to an apparent migration, endpoints MUST validate the 2197 previously active path using a PATH_CHALLENGE frame. This induces 2198 the sending of new packets on that path. If the path is no longer 2199 viable, the validation attempt will time out and fail; if the path is 2200 viable, but no longer desired, the validation will succeed, but only 2201 results in probing packets being sent on the path. 2203 An endpoint that receives a PATH_CHALLENGE on an active path SHOULD 2204 send a non-probing packet in response. If the non-probing packet 2205 arrives before any copy made by an attacker, this results in the 2206 connection being migrated back to the original path. Any subsequent 2207 migration to another path restarts this entire process. 2209 This defense is imperfect, but this is not considered a serious 2210 problem. If the path via the attack is reliably faster than the 2211 original path despite multiple attempts to use that original path, it 2212 is not possible to distinguish between attack and an improvement in 2213 routing. 2215 An endpoint could also use heuristics to improve detection of this 2216 style of attack. For instance, NAT rebinding is improbable if 2217 packets were recently received on the old path, similarly rebinding 2218 is rare on IPv6 paths. Endpoints can also look for duplicated 2219 packets. Conversely, a change in connection ID is more likely to 2220 indicate an intentional migration rather than an attack. 2222 9.4. Loss Detection and Congestion Control 2224 The capacity available on the new path might not be the same as the 2225 old path. Packets sent on the old path SHOULD NOT contribute to 2226 congestion control or RTT estimation for the new path. 2228 On confirming a peer's ownership of its new address, an endpoint 2229 SHOULD immediately reset the congestion controller and round-trip 2230 time estimator for the new path. 2232 An endpoint MUST NOT return to the send rate used for the previous 2233 path unless it is reasonably sure that the previous send rate is 2234 valid for the new path. For instance, a change in the client's port 2235 number is likely indicative of a rebinding in a middlebox and not a 2236 complete change in path. This determination likely depends on 2237 heuristics, which could be imperfect; if the new path capacity is 2238 significantly reduced, ultimately this relies on the congestion 2239 controller responding to congestion signals and reducing send rates 2240 appropriately. 2242 There may be apparent reordering at the receiver when an endpoint 2243 sends data and probes from/to multiple addresses during the migration 2244 period, since the two resulting paths may have different round-trip 2245 times. A receiver of packets on multiple paths will still send ACK 2246 frames covering all received packets. 2248 While multiple paths might be used during connection migration, a 2249 single congestion control context and a single loss recovery context 2250 (as described in [QUIC-RECOVERY]) may be adequate. For instance, an 2251 endpoint might delay switching to a new congestion control context 2252 until it is confirmed that an old path is no longer needed (such as 2253 the case in Section 9.3.3). 2255 A sender can make exceptions for probe packets so that their loss 2256 detection is independent and does not unduly cause the congestion 2257 controller to reduce its sending rate. An endpoint might set a 2258 separate timer when a PATH_CHALLENGE is sent, which is cancelled when 2259 the corresponding PATH_RESPONSE is received. If the timer fires 2260 before the PATH_RESPONSE is received, the endpoint might send a new 2261 PATH_CHALLENGE, and restart the timer for a longer period of time. 2263 9.5. Privacy Implications of Connection Migration 2265 Using a stable connection ID on multiple network paths allows a 2266 passive observer to correlate activity between those paths. An 2267 endpoint that moves between networks might not wish to have their 2268 activity correlated by any entity other than their peer, so different 2269 connection IDs are used when sending from different local addresses, 2270 as discussed in Section 5.1. For this to be effective endpoints need 2271 to ensure that connections IDs they provide cannot be linked by any 2272 other entity. 2274 At any time, endpoints MAY change the Destination Connection ID they 2275 send to a value that has not been used on another path. 2277 An endpoint MUST use a new connection ID if it initiates connection 2278 migration. Using a new connection ID eliminates the use of the 2279 connection ID for linking activity from the same connection on 2280 different networks. Header protection ensures that packet numbers 2281 cannot be used to correlate activity. This does not prevent other 2282 properties of packets, such as timing and size, from being used to 2283 correlate activity. 2285 Unintentional changes in path without a change in connection ID are 2286 possible. For example, after a period of network inactivity, NAT 2287 rebinding might cause packets to be sent on a new path when the 2288 client resumes sending. 2290 A client might wish to reduce linkability by employing a new 2291 connection ID and source UDP port when sending traffic after a period 2292 of inactivity. Changing the UDP port from which it sends packets at 2293 the same time might cause the packet to appear as a connection 2294 migration. This ensures that the mechanisms that support migration 2295 are exercised even for clients that don't experience NAT rebindings 2296 or genuine migrations. Changing port number can cause a peer to 2297 reset its congestion state (see Section 9.4), so the port SHOULD only 2298 be changed infrequently. 2300 An endpoint that exhausts available connection IDs cannot migrate. 2301 To ensure that migration is possible and packets sent on different 2302 paths cannot be correlated, endpoints SHOULD provide new connection 2303 IDs before peers migrate. 2305 9.6. Server's Preferred Address 2307 QUIC allows servers to accept connections on one IP address and 2308 attempt to transfer these connections to a more preferred address 2309 shortly after the handshake. This is particularly useful when 2310 clients initially connect to an address shared by multiple servers 2311 but would prefer to use a unicast address to ensure connection 2312 stability. This section describes the protocol for migrating a 2313 connection to a preferred server address. 2315 Migrating a connection to a new server address mid-connection is left 2316 for future work. If a client receives packets from a new server 2317 address not indicated by the preferred_address transport parameter, 2318 the client SHOULD discard these packets. 2320 9.6.1. Communicating A Preferred Address 2322 A server conveys a preferred address by including the 2323 preferred_address transport parameter in the TLS handshake. 2325 Servers MAY communicate a preferred address of each address family 2326 (IPv4 and IPv6) to allow clients to pick the one most suited to their 2327 network attachment. 2329 Once the handshake is finished, the client SHOULD select one of the 2330 two server's preferred addresses and initiate path validation (see 2331 Section 8.2) of that address using the connection ID provided in the 2332 preferred_address transport parameter. 2334 If path validation succeeds, the client SHOULD immediately begin 2335 sending all future packets to the new server address using the new 2336 connection ID and discontinue use of the old server address. If path 2337 validation fails, the client MUST continue sending all future packets 2338 to the server's original IP address. 2340 9.6.2. Responding to Connection Migration 2342 A server might receive a packet addressed to its preferred IP address 2343 at any time after it accepts a connection. If this packet contains a 2344 PATH_CHALLENGE frame, the server sends a PATH_RESPONSE frame as per 2345 Section 8.2. The server MUST send other non-probing frames from its 2346 original address until it receives a non-probing packet from the 2347 client at its preferred address and until the server has validated 2348 the new path. 2350 The server MUST probe on the path toward the client from its 2351 preferred address. This helps to guard against spurious migration 2352 initiated by an attacker. 2354 Once the server has completed its path validation and has received a 2355 non-probing packet with a new largest packet number on its preferred 2356 address, the server begins sending non-probing packets to the client 2357 exclusively from its preferred IP address. It SHOULD drop packets 2358 for this connection received on the old IP address, but MAY continue 2359 to process delayed packets. 2361 9.6.3. Interaction of Client Migration and Preferred Address 2363 A client might need to perform a connection migration before it has 2364 migrated to the server's preferred address. In this case, the client 2365 SHOULD perform path validation to both the original and preferred 2366 server address from the client's new address concurrently. 2368 If path validation of the server's preferred address succeeds, the 2369 client MUST abandon validation of the original address and migrate to 2370 using the server's preferred address. If path validation of the 2371 server's preferred address fails but validation of the server's 2372 original address succeeds, the client MAY migrate to its new address 2373 and continue sending to the server's original address. 2375 If the connection to the server's preferred address is not from the 2376 same client address, the server MUST protect against potential 2377 attacks as described in Section 9.3.1 and Section 9.3.2. In addition 2378 to intentional simultaneous migration, this might also occur because 2379 the client's access network used a different NAT binding for the 2380 server's preferred address. 2382 Servers SHOULD initiate path validation to the client's new address 2383 upon receiving a probe packet from a different address. Servers MUST 2384 NOT send more than a minimum congestion window's worth of non-probing 2385 packets to the new address before path validation is complete. 2387 A client that migrates to a new address SHOULD use a preferred 2388 address from the same address family for the server. 2390 9.7. Use of IPv6 Flow-Label and Migration 2392 Endpoints that send data using IPv6 SHOULD apply an IPv6 flow label 2393 in compliance with [RFC6437], unless the local API does not allow 2394 setting IPv6 flow labels. 2396 The IPv6 flow label SHOULD be a pseudo-random function of the source 2397 and destination addresses, source and destination UDP ports, and the 2398 destination CID. The flow label generation MUST be designed to 2399 minimize the chances of linkability with a previously used flow 2400 label, as this would enable correlating activity on multiple paths 2401 (see Section 9.5). 2403 A possible implementation is to compute the flow label as a 2404 cryptographic hash function of the source and destination addresses, 2405 source and destination UDP ports, destination CID, and a local 2406 secret. 2408 10. Connection Termination 2410 An established QUIC connection can be terminated in one of three 2411 ways: 2413 o idle timeout (Section 10.2) 2415 o immediate close (Section 10.3) 2417 o stateless reset (Section 10.4) 2419 An endpoint MAY discard connection state if it does not have a 2420 validated path on which it can send packets (see Section 8.2). 2422 10.1. Closing and Draining Connection States 2424 The closing and draining connection states exist to ensure that 2425 connections close cleanly and that delayed or reordered packets are 2426 properly discarded. These states SHOULD persist for at least three 2427 times the current Probe Timeout (PTO) interval as defined in 2428 [QUIC-RECOVERY]. 2430 An endpoint enters a closing period after initiating an immediate 2431 close (Section 10.3). While closing, an endpoint MUST NOT send 2432 packets unless they contain a CONNECTION_CLOSE frame (see 2433 Section 10.3 for details). An endpoint retains only enough 2434 information to generate a packet containing a CONNECTION_CLOSE frame 2435 and to identify packets as belonging to the connection. The 2436 endpoint's selected connection ID and the QUIC version are sufficient 2437 information to identify packets for a closing connection; an endpoint 2438 can discard all other connection state. An endpoint MAY retain 2439 packet protection keys for incoming packets to allow it to read and 2440 process a CONNECTION_CLOSE frame. 2442 The draining state is entered once an endpoint receives a signal that 2443 its peer is closing or draining. While otherwise identical to the 2444 closing state, an endpoint in the draining state MUST NOT send any 2445 packets. Retaining packet protection keys is unnecessary once a 2446 connection is in the draining state. 2448 An endpoint MAY transition from the closing period to the draining 2449 period if it receives a CONNECTION_CLOSE frame or stateless reset, 2450 both of which indicate that the peer is also closing or draining. 2451 The draining period SHOULD end when the closing period would have 2452 ended. In other words, the endpoint can use the same end time, but 2453 cease retransmission of the closing packet. 2455 Disposing of connection state prior to the end of the closing or 2456 draining period could cause delayed or reordered packets to be 2457 handled poorly. Endpoints that have some alternative means to ensure 2458 that late-arriving packets on the connection do not create QUIC 2459 state, such as those that are able to close the UDP socket, MAY use 2460 an abbreviated draining period which can allow for faster resource 2461 recovery. Servers that retain an open socket for accepting new 2462 connections SHOULD NOT exit the closing or draining period early. 2464 Once the closing or draining period has ended, an endpoint SHOULD 2465 discard all connection state. This results in new packets on the 2466 connection being handled generically. For instance, an endpoint MAY 2467 send a stateless reset in response to any further incoming packets. 2469 The draining and closing periods do not apply when a stateless reset 2470 (Section 10.4) is sent. 2472 An endpoint is not expected to handle key updates when it is closing 2473 or draining. A key update might prevent the endpoint from moving 2474 from the closing state to draining, but it otherwise has no impact. 2476 While in the closing period, an endpoint could receive packets from a 2477 new source address, indicating a connection migration (Section 9). 2478 An endpoint in the closing state MUST strictly limit the number of 2479 packets it sends to this new address until the address is validated 2480 (see Section 8.2). A server in the closing state MAY instead choose 2481 to discard packets received from a new source address. 2483 10.2. Idle Timeout 2485 If the idle timeout is enabled, a connection is silently closed and 2486 the state is discarded when it remains idle for longer than both the 2487 advertised idle timeout (see Section 18.1) and three times the 2488 current Probe Timeout (PTO). 2490 Each endpoint advertises its own idle timeout to its peer. An 2491 endpoint restarts any timer it maintains when a packet from its peer 2492 is received and processed successfully. The timer is also restarted 2493 when sending a packet containing frames other than ACK or PADDING (an 2494 ACK-eliciting packet, see [QUIC-RECOVERY]), but only if no other ACK- 2495 eliciting packets have been sent since last receiving a packet. 2496 Restarting when sending packets ensures that connections do not 2497 prematurely time out when initiating new activity. 2499 The value for an idle timeout can be asymmetric. The value 2500 advertised by an endpoint is only used to determine whether the 2501 connection is live at that endpoint. An endpoint that sends packets 2502 near the end of the idle timeout period of a peer risks having those 2503 packets discarded if its peer enters the draining state before the 2504 packets arrive. If a peer could timeout within an Probe Timeout 2505 (PTO, see Section 6.2.2 of [QUIC-RECOVERY]), it is advisable to test 2506 for liveness before sending any data that cannot be retried safely. 2507 Note that it is likely that only applications or application 2508 protocols will know what information can be retried. 2510 10.3. Immediate Close 2512 An endpoint sends a CONNECTION_CLOSE frame (Section 19.19) to 2513 terminate the connection immediately. A CONNECTION_CLOSE frame 2514 causes all streams to immediately become closed; open streams can be 2515 assumed to be implicitly reset. 2517 After sending a CONNECTION_CLOSE frame, endpoints immediately enter 2518 the closing state. During the closing period, an endpoint that sends 2519 a CONNECTION_CLOSE frame SHOULD respond to any packet that it 2520 receives with another packet containing a CONNECTION_CLOSE frame. To 2521 minimize the state that an endpoint maintains for a closing 2522 connection, endpoints MAY send the exact same packet. However, 2523 endpoints SHOULD limit the number of packets they generate containing 2524 a CONNECTION_CLOSE frame. For instance, an endpoint could 2525 progressively increase the number of packets that it receives before 2526 sending additional packets or increase the time between packets. 2528 Note: Allowing retransmission of a closing packet contradicts other 2529 advice in this document that recommends the creation of new packet 2530 numbers for every packet. Sending new packet numbers is primarily 2531 of advantage to loss recovery and congestion control, which are 2532 not expected to be relevant for a closed connection. 2533 Retransmitting the final packet requires less state. 2535 New packets from unverified addresses could be used to create an 2536 amplification attack (see Section 8). To avoid this, endpoints MUST 2537 either limit transmission of CONNECTION_CLOSE frames to validated 2538 addresses or drop packets without response if the response would be 2539 more than three times larger than the received packet. 2541 After receiving a CONNECTION_CLOSE frame, endpoints enter the 2542 draining state. An endpoint that receives a CONNECTION_CLOSE frame 2543 MAY send a single packet containing a CONNECTION_CLOSE frame before 2544 entering the draining state, using a CONNECTION_CLOSE frame and a 2545 NO_ERROR code if appropriate. An endpoint MUST NOT send further 2546 packets, which could result in a constant exchange of 2547 CONNECTION_CLOSE frames until the closing period on either peer 2548 ended. 2550 An immediate close can be used after an application protocol has 2551 arranged to close a connection. This might be after the application 2552 protocols negotiates a graceful shutdown. The application protocol 2553 exchanges whatever messages that are needed to cause both endpoints 2554 to agree to close the connection, after which the application 2555 requests that the connection be closed. The application protocol can 2556 use an CONNECTION_CLOSE frame with an appropriate error code to 2557 signal closure. 2559 If the connection has been successfully established, endpoints MUST 2560 send any CONNECTION_CLOSE frames in a 1-RTT packet. Prior to 2561 connection establishment a peer might not have 1-RTT keys, so 2562 endpoints SHOULD send CONNECTION_CLOSE frames in a Handshake packet. 2563 If the endpoint does not have Handshake keys, or it is not certain 2564 that the peer has Handshake keys, it MAY send CONNECTION_CLOSE frames 2565 in an Initial packet. If multiple packets are sent, they can be 2566 coalesced (see Section 12.2) to facilitate retransmission. 2568 10.4. Stateless Reset 2570 A stateless reset is provided as an option of last resort for an 2571 endpoint that does not have access to the state of a connection. A 2572 crash or outage might result in peers continuing to send data to an 2573 endpoint that is unable to properly continue the connection. A 2574 stateless reset is not appropriate for signaling error conditions. 2575 An endpoint that wishes to communicate a fatal connection error MUST 2576 use a CONNECTION_CLOSE frame if it has sufficient state to do so. 2578 To support this process, a token is sent by endpoints. The token is 2579 carried in the NEW_CONNECTION_ID frame sent by either peer, and 2580 servers can specify the stateless_reset_token transport parameter 2581 during the handshake (clients cannot because their transport 2582 parameters don't have confidentiality protection). This value is 2583 protected by encryption, so only client and server know this value. 2584 Tokens are invalidated when their associated connection ID is retired 2585 via a RETIRE_CONNECTION_ID frame (Section 19.16). 2587 An endpoint that receives packets that it cannot process sends a 2588 packet in the following layout: 2590 0 1 2 3 2591 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 2592 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2593 |0|1| Unpredictable Bits (182..) ... 2594 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2595 | | 2596 + + 2597 | | 2598 + Stateless Reset Token (128) + 2599 | | 2600 + + 2601 | | 2602 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2604 Figure 6: Stateless Reset Packet 2606 This design ensures that a stateless reset packet is - to the extent 2607 possible - indistinguishable from a regular packet with a short 2608 header. 2610 A stateless reset uses an entire UDP datagram, starting with the 2611 first two bits of the packet header. The remainder of the first byte 2612 and an arbitrary number of bytes following it that are set to 2613 unpredictable values. The last 16 bytes of the datagram contain a 2614 Stateless Reset Token. 2616 To entities other than its intended recipient, a stateless reset will 2617 be appear to be a packet with a short header. For the packet to 2618 appear as valid, the Unpredictable Bits field needs to include at 2619 least 182 bits of data (or 23 bytes, less the two fixed bits). This 2620 is intended to allow for a Destination Connection ID of the maximum 2621 length permitted, with a minimal packet number, and payload. The 2622 Stateless Reset Token corresponds to the minimum expansion of the 2623 packet protection AEAD. More unpredictable bytes might be necessary 2624 if the endpoint could have negotiated a packet protection scheme with 2625 a larger minimum AEAD expansion. 2627 An endpoint SHOULD NOT send a stateless reset that is significantly 2628 larger than the packet it receives. Endpoints MUST discard packets 2629 that are too small to be valid QUIC packets. With the set of AEAD 2630 functions defined in [QUIC-TLS], packets that are smaller than 21 2631 bytes are never valid. 2633 Endpoints MUST send stateless reset packets formatted as a packet 2634 with a short header. However, endpoints MUST treat any packet ending 2635 in a valid stateless reset token as a stateless reset, as other QUIC 2636 versions might allow the use of a long header. 2638 An endpoint MAY send a stateless reset in response to a packet with a 2639 long header. Sending a stateless reset is not effective prior to the 2640 stateless reset token being available to a peer. In this QUIC 2641 version, packets with a long header are only used during connection 2642 establishment. Because the stateless reset token is not available 2643 until connection establishment is complete or near completion, 2644 ignoring an unknown packet with a long header might be as effective 2645 than sending a stateless reset. 2647 An endpoint cannot determine the Source Connection ID from a packet 2648 with a short header, therefore it cannot set the Destination 2649 Connection ID in the stateless reset packet. The Destination 2650 Connection ID will therefore differ from the value used in previous 2651 packets. A random Destination Connection ID makes the connection ID 2652 appear to be the result of moving to a new connection ID that was 2653 provided using a NEW_CONNECTION_ID frame (Section 19.15). 2655 Using a randomized connection ID results in two problems: 2657 o The packet might not reach the peer. If the Destination 2658 Connection ID is critical for routing toward the peer, then this 2659 packet could be incorrectly routed. This might also trigger 2660 another Stateless Reset in response, see Section 10.4.3. A 2661 Stateless Reset that is not correctly routed is an ineffective 2662 error detection and recovery mechanism. In this case, endpoints 2663 will need to rely on other methods - such as timers - to detect 2664 that the connection has failed. 2666 o The randomly generated connection ID can be used by entities other 2667 than the peer to identify this as a potential stateless reset. An 2668 endpoint that occasionally uses different connection IDs might 2669 introduce some uncertainty about this. 2671 Finally, the last 16 bytes of the packet are set to the value of the 2672 Stateless Reset Token. 2674 This stateless reset design is specific to QUIC version 1. An 2675 endpoint that supports multiple versions of QUIC needs to generate a 2676 stateless reset that will be accepted by peers that support any 2677 version that the endpoint might support (or might have supported 2678 prior to losing state). Designers of new versions of QUIC need to be 2679 aware of this and either reuse this design, or use a portion of the 2680 packet other than the last 16 bytes for carrying data. 2682 10.4.1. Detecting a Stateless Reset 2684 An endpoint detects a potential stateless reset when an incoming 2685 packet either cannot be associated with a connection, cannot be 2686 decrypted, or is marked as a duplicate packet. The endpoint MUST 2687 then compare the last 16 bytes of the packet with all Stateless Reset 2688 Tokens that are associated with connection IDs that are currently in 2689 use. This includes Stateless Reset Tokens from NEW_CONNECTION_ID 2690 frames and the server's transport parameters. An endpoint MUST NOT 2691 check for any Stateless Reset Tokens associated with connection IDs 2692 it has not used or for connection IDs that have been retired. 2694 If the last 16 bytes of the packet values are identical to a 2695 Stateless Reset Token, the endpoint MUST enter the draining period 2696 and not send any further packets on this connection. If the 2697 comparison fails, the packet can be discarded. 2699 10.4.2. Calculating a Stateless Reset Token 2701 The stateless reset token MUST be difficult to guess. In order to 2702 create a Stateless Reset Token, an endpoint could randomly generate 2703 [RFC4086] a secret for every connection that it creates. However, 2704 this presents a coordination problem when there are multiple 2705 instances in a cluster or a storage problem for an endpoint that 2706 might lose state. Stateless reset specifically exists to handle the 2707 case where state is lost, so this approach is suboptimal. 2709 A single static key can be used across all connections to the same 2710 endpoint by generating the proof using a second iteration of a 2711 preimage-resistant function that takes a static key and the 2712 connection ID chosen by the endpoint (see Section 5.1) as input. An 2713 endpoint could use HMAC [RFC2104] (for example, HMAC(static_key, 2714 connection_id)) or HKDF [RFC5869] (for example, using the static key 2715 as input keying material, with the connection ID as salt). The 2716 output of this function is truncated to 16 bytes to produce the 2717 Stateless Reset Token for that connection. 2719 An endpoint that loses state can use the same method to generate a 2720 valid Stateless Reset Token. The connection ID comes from the packet 2721 that the endpoint receives. 2723 This design relies on the peer always sending a connection ID in its 2724 packets so that the endpoint can use the connection ID from a packet 2725 to reset the connection. An endpoint that uses this design MUST 2726 either use the same connection ID length for all connections or 2727 encode the length of the connection ID such that it can be recovered 2728 without state. In addition, it cannot provide a zero-length 2729 connection ID. 2731 Revealing the Stateless Reset Token allows any entity to terminate 2732 the connection, so a value can only be used once. This method for 2733 choosing the Stateless Reset Token means that the combination of 2734 connection ID and static key MUST NOT be used for another connection. 2735 A denial of service attack is possible if the same connection ID is 2736 used by instances that share a static key, or if an attacker can 2737 cause a packet to be routed to an instance that has no state but the 2738 same static key (see Section 21.8). A connection ID from a 2739 connection that is reset by revealing the Stateless Reset Token MUST 2740 NOT be reused for new connections at nodes that share a static key. 2742 Note that Stateless Reset packets do not have any cryptographic 2743 protection. 2745 10.4.3. Looping 2747 The design of a Stateless Reset is such that without knowing the 2748 stateless reset token it is indistinguishable from a valid packet. 2749 For instance, if a server sends a Stateless Reset to another server 2750 it might receive another Stateless Reset in response, which could 2751 lead to an infinite exchange. 2753 An endpoint MUST ensure that every Stateless Reset that it sends is 2754 smaller than the packet which triggered it, unless it maintains state 2755 sufficient to prevent looping. In the event of a loop, this results 2756 in packets eventually being too small to trigger a response. 2758 An endpoint can remember the number of Stateless Reset packets that 2759 it has sent and stop generating new Stateless Reset packets once a 2760 limit is reached. Using separate limits for different remote 2761 addresses will ensure that Stateless Reset packets can be used to 2762 close connections when other peers or connections have exhausted 2763 limits. 2765 Reducing the size of a Stateless Reset below the recommended minimum 2766 size of 39 bytes could mean that the packet could reveal to an 2767 observer that it is a Stateless Reset. Conversely, refusing to send 2768 a Stateless Reset in response to a small packet might result in 2769 Stateless Reset not being useful in detecting cases of broken 2770 connections where only very small packets are sent; such failures 2771 might only be detected by other means, such as timers. 2773 An endpoint can increase the odds that a packet will trigger a 2774 Stateless Reset if it cannot be processed by padding it to at least 2775 40 bytes. 2777 11. Error Handling 2779 An endpoint that detects an error SHOULD signal the existence of that 2780 error to its peer. Both transport-level and application-level errors 2781 can affect an entire connection (see Section 11.1), while only 2782 application-level errors can be isolated to a single stream (see 2783 Section 11.2). 2785 The most appropriate error code (Section 20) SHOULD be included in 2786 the frame that signals the error. Where this specification 2787 identifies error conditions, it also identifies the error code that 2788 is used. 2790 A stateless reset (Section 10.4) is not suitable for any error that 2791 can be signaled with a CONNECTION_CLOSE or RESET_STREAM frame. A 2792 stateless reset MUST NOT be used by an endpoint that has the state 2793 necessary to send a frame on the connection. 2795 11.1. Connection Errors 2797 Errors that result in the connection being unusable, such as an 2798 obvious violation of protocol semantics or corruption of state that 2799 affects an entire connection, MUST be signaled using a 2800 CONNECTION_CLOSE frame (Section 19.19). An endpoint MAY close the 2801 connection in this manner even if the error only affects a single 2802 stream. 2804 Application protocols can signal application-specific protocol errors 2805 using the application-specific variant of the CONNECTION_CLOSE frame. 2806 Errors that are specific to the transport, including all those 2807 described in this document, are carried the QUIC-specific variant of 2808 the CONNECTION_CLOSE frame. 2810 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 2811 endpoint SHOULD be prepared to retransmit a packet containing a 2812 CONNECTION_CLOSE frame if it receives more packets on a terminated 2813 connection. Limiting the number of retransmissions and the time over 2814 which this final packet is sent limits the effort expended on 2815 terminated connections. 2817 An endpoint that chooses not to retransmit packets containing a 2818 CONNECTION_CLOSE frame risks a peer missing the first such packet. 2819 The only mechanism available to an endpoint that continues to receive 2820 data for a terminated connection is to use the stateless reset 2821 process (Section 10.4). 2823 An endpoint that receives an invalid CONNECTION_CLOSE frame MUST NOT 2824 signal the existence of the error to its peer. 2826 11.2. Stream Errors 2828 If an application-level error affects a single stream, but otherwise 2829 leaves the connection in a recoverable state, the endpoint can send a 2830 RESET_STREAM frame (Section 19.4) with an appropriate error code to 2831 terminate just the affected stream. 2833 RESET_STREAM MUST be instigated by the protocol using QUIC, either 2834 directly or through the receipt of a STOP_SENDING frame from a peer. 2835 RESET_STREAM carries an application error code. Resetting a stream 2836 without knowledge of the application protocol could cause the 2837 protocol to enter an unrecoverable state. Application protocols 2838 might require certain streams to be reliably delivered in order to 2839 guarantee consistent state between endpoints. 2841 12. Packets and Frames 2843 QUIC endpoints communicate by exchanging packets. Packets have 2844 confidentiality and integrity protection (see Section 12.1) and are 2845 carried in UDP datagrams (see Section 12.2). 2847 This version of QUIC uses the long packet header (see Section 17.2) 2848 during connection establishment. Packets with the long header are 2849 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), Handshake 2850 (Section 17.2.4), and Retry (Section 17.2.5). Version negotiation 2851 uses a version-independent packet with a long header (see 2852 Section 17.2.1). 2854 Packets with the short header (Section 17.3) are designed for minimal 2855 overhead and are used after a connection is established and 1-RTT 2856 keys are available. 2858 12.1. Protected Packets 2860 All QUIC packets except Version Negotiation and Retry packets use 2861 authenticated encryption with additional data (AEAD) [RFC5116] to 2862 provide confidentiality and integrity protection. Details of packet 2863 protection are found in [QUIC-TLS]; this section includes an overview 2864 of the process. 2866 Initial packets are protected using keys that are statically derived. 2867 This packet protection is not effective confidentiality protection. 2868 Initial protection only exists to ensure that the sender of the 2869 packet is on the network path. Any entity that receives the Initial 2870 packet from a client can recover the keys necessary to remove packet 2871 protection or to generate packets that will be successfully 2872 authenticated. 2874 All other packets are protected with keys derived from the 2875 cryptographic handshake. The type of the packet from the long header 2876 or key phase from the short header are used to identify which 2877 encryption level - and therefore the keys - that are used. Packets 2878 protected with 0-RTT and 1-RTT keys are expected to have 2879 confidentiality and data origin authentication; the cryptographic 2880 handshake ensures that only the communicating endpoints receive the 2881 corresponding keys. 2883 The packet number field contains a packet number, which has 2884 additional confidentiality protection that is applied after packet 2885 protection is applied (see [QUIC-TLS] for details). The underlying 2886 packet number increases with each packet sent in a given packet 2887 number space, see Section 12.3 for details. 2889 12.2. Coalescing Packets 2891 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), and Handshake 2892 (Section 17.2.4) packets contain a Length field, which determines the 2893 end of the packet. The length includes both the Packet Number and 2894 Payload fields, both of which are confidentiality protected and 2895 initially of unknown length. The length of the Payload field is 2896 learned once header protection is removed. 2898 Using the Length field, a sender can coalesce multiple QUIC packets 2899 into one UDP datagram. This can reduce the number of UDP datagrams 2900 needed to complete the cryptographic handshake and starting sending 2901 data. Receivers MUST be able to process coalesced packets. 2903 Coalescing packets in order of increasing encryption levels (Initial, 2904 0-RTT, Handshake, 1-RTT) makes it more likely the receiver will be 2905 able to process all the packets in a single pass. A packet with a 2906 short header does not include a length, so it can only be the last 2907 packet included in a UDP datagram. 2909 Senders MUST NOT coalesce QUIC packets for different connections into 2910 a single UDP datagram. Receivers SHOULD ignore any subsequent 2911 packets with a different Destination Connection ID than the first 2912 packet in the datagram. 2914 Every QUIC packet that is coalesced into a single UDP datagram is 2915 separate and complete. Though the values of some fields in the 2916 packet header might be redundant, no fields are omitted. The 2917 receiver of coalesced QUIC packets MUST individually process each 2918 QUIC packet and separately acknowledge them, as if they were received 2919 as the payload of different UDP datagrams. For example, if 2920 decryption fails (because the keys are not available or any other 2921 reason), the receiver MAY either discard or buffer the packet for 2922 later processing and MUST attempt to process the remaining packets. 2924 Retry packets (Section 17.2.5), Version Negotiation packets 2925 (Section 17.2.1), and packets with a short header (Section 17.3) do 2926 not contain a Length field and so cannot be followed by other packets 2927 in the same UDP datagram. 2929 12.3. Packet Numbers 2931 The packet number is an integer in the range 0 to 2^62-1. This 2932 number is used in determining the cryptographic nonce for packet 2933 protection. Each endpoint maintains a separate packet number for 2934 sending and receiving. 2936 Packet numbers are limited to this range because they need to be 2937 representable in whole in the Largest Acknowledged field of an ACK 2938 frame (Section 19.3). When present in a long or short header 2939 however, packet numbers are reduced and encoded in 1 to 4 bytes (see 2940 Section 17.1). 2942 Version Negotiation (Section 17.2.1) and Retry (Section 17.2.5) 2943 packets do not include a packet number. 2945 Packet numbers are divided into 3 spaces in QUIC: 2947 o Initial space: All Initial packets (Section 17.2.2) are in this 2948 space. 2950 o Handshake space: All Handshake packets (Section 17.2.4) are in 2951 this space. 2953 o Application data space: All 0-RTT and 1-RTT encrypted packets 2954 (Section 12.1) are in this space. 2956 As described in [QUIC-TLS], each packet type uses different 2957 protection keys. 2959 Conceptually, a packet number space is the context in which a packet 2960 can be processed and acknowledged. Initial packets can only be sent 2961 with Initial packet protection keys and acknowledged in packets which 2962 are also Initial packets. Similarly, Handshake packets are sent at 2963 the Handshake encryption level and can only be acknowledged in 2964 Handshake packets. 2966 This enforces cryptographic separation between the data sent in the 2967 different packet sequence number spaces. Packet numbers in each 2968 space start at packet number 0. Subsequent packets sent in the same 2969 packet number space MUST increase the packet number by at least one. 2971 0-RTT and 1-RTT data exist in the same packet number space to make 2972 loss recovery algorithms easier to implement between the two packet 2973 types. 2975 A QUIC endpoint MUST NOT reuse a packet number within the same packet 2976 number space in one connection. If the packet number for sending 2977 reaches 2^62 - 1, the sender MUST close the connection without 2978 sending a CONNECTION_CLOSE frame or any further packets; an endpoint 2979 MAY send a Stateless Reset (Section 10.4) in response to further 2980 packets that it receives. 2982 A receiver MUST discard a newly unprotected packet unless it is 2983 certain that it has not processed another packet with the same packet 2984 number from the same packet number space. Duplicate suppression MUST 2985 happen after removing packet protection for the reasons described in 2986 Section 9.3 of [QUIC-TLS]. An efficient algorithm for duplicate 2987 suppression can be found in Section 3.4.3 of [RFC4303]. 2989 Packet number encoding at a sender and decoding at a receiver are 2990 described in Section 17.1. 2992 12.4. Frames and Frame Types 2994 The payload of QUIC packets, after removing packet protection, 2995 consists of a sequence of complete frames, as shown in Figure 7. 2996 Version Negotiation, Stateless Reset, and Retry packets do not 2997 contain frames. 2999 0 1 2 3 3000 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 3001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3002 | Frame 1 (*) ... 3003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3004 | Frame 2 (*) ... 3005 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3006 ... 3007 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3008 | Frame N (*) ... 3009 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3011 Figure 7: QUIC Payload 3013 The payload of a packet that contains frames MUST contain at least 3014 one frame, and MAY contain multiple frames and multiple frame types. 3016 Frames always fit within a single QUIC packet and cannot span 3017 multiple packets. 3019 Each frame begins with a Frame Type, indicating its type, followed by 3020 additional type-dependent fields: 3022 0 1 2 3 3023 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 3024 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3025 | Frame Type (i) ... 3026 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3027 | Type-Dependent Fields (*) ... 3028 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3030 Figure 8: Generic Frame Layout 3032 The frame types defined in this specification are listed in Table 3. 3033 The Frame Type in ACK, STREAM, MAX_STREAMS, STREAMS_BLOCKED, and 3034 CONNECTION_CLOSE frames is used to carry other frame-specific flags. 3035 For all other frames, the Frame Type field simply identifies the 3036 frame. These frames are explained in more detail in Section 19. 3038 +-------------+----------------------+---------------+ 3039 | Type Value | Frame Type Name | Definition | 3040 +-------------+----------------------+---------------+ 3041 | 0x00 | PADDING | Section 19.1 | 3042 | | | | 3043 | 0x01 | PING | Section 19.2 | 3044 | | | | 3045 | 0x02 - 0x03 | ACK | Section 19.3 | 3046 | | | | 3047 | 0x04 | RESET_STREAM | Section 19.4 | 3048 | | | | 3049 | 0x05 | STOP_SENDING | Section 19.5 | 3050 | | | | 3051 | 0x06 | CRYPTO | Section 19.6 | 3052 | | | | 3053 | 0x07 | NEW_TOKEN | Section 19.7 | 3054 | | | | 3055 | 0x08 - 0x0f | STREAM | Section 19.8 | 3056 | | | | 3057 | 0x10 | MAX_DATA | Section 19.9 | 3058 | | | | 3059 | 0x11 | MAX_STREAM_DATA | Section 19.10 | 3060 | | | | 3061 | 0x12 - 0x13 | MAX_STREAMS | Section 19.11 | 3062 | | | | 3063 | 0x14 | DATA_BLOCKED | Section 19.12 | 3064 | | | | 3065 | 0x15 | STREAM_DATA_BLOCKED | Section 19.13 | 3066 | | | | 3067 | 0x16 - 0x17 | STREAMS_BLOCKED | Section 19.14 | 3068 | | | | 3069 | 0x18 | NEW_CONNECTION_ID | Section 19.15 | 3070 | | | | 3071 | 0x19 | RETIRE_CONNECTION_ID | Section 19.16 | 3072 | | | | 3073 | 0x1a | PATH_CHALLENGE | Section 19.17 | 3074 | | | | 3075 | 0x1b | PATH_RESPONSE | Section 19.18 | 3076 | | | | 3077 | 0x1c - 0x1d | CONNECTION_CLOSE | Section 19.19 | 3078 +-------------+----------------------+---------------+ 3080 Table 3: Frame Types 3082 An endpoint MUST treat the receipt of a frame of unknown type as a 3083 connection error of type FRAME_ENCODING_ERROR. 3085 All QUIC frames are idempotent in this version of QUIC. That is, a 3086 valid frame does not cause undesirable side effects or errors when 3087 received more than once. 3089 The Frame Type field uses a variable length integer encoding (see 3090 Section 16) with one exception. To ensure simple and efficient 3091 implementations of frame parsing, a frame type MUST use the shortest 3092 possible encoding. Though a two-, four- or eight-byte encoding of 3093 the frame types defined in this document is possible, the Frame Type 3094 field for these frames is encoded on a single byte. For instance, 3095 though 0x4001 is a legitimate two-byte encoding for a variable-length 3096 integer with a value of 1, PING frames are always encoded as a single 3097 byte with the value 0x01. An endpoint MAY treat the receipt of a 3098 frame type that uses a longer encoding than necessary as a connection 3099 error of type PROTOCOL_VIOLATION. 3101 13. Packetization and Reliability 3103 A sender bundles one or more frames in a QUIC packet (see 3104 Section 12.4). 3106 A sender can minimize per-packet bandwidth and computational costs by 3107 bundling as many frames as possible within a QUIC packet. A sender 3108 MAY wait for a short period of time to bundle multiple frames before 3109 sending a packet that is not maximally packed, to avoid sending out 3110 large numbers of small packets. An implementation MAY use knowledge 3111 about application sending behavior or heuristics to determine whether 3112 and for how long to wait. This waiting period is an implementation 3113 decision, and an implementation should be careful to delay 3114 conservatively, since any delay is likely to increase application- 3115 visible latency. 3117 Stream multiplexing is achieved by interleaving STREAM frames from 3118 multiple streams into one or more QUIC packets. A single QUIC packet 3119 can include multiple STREAM frames from one or more streams. 3121 One of the benefits of QUIC is avoidance of head-of-line blocking 3122 across multiple streams. When a packet loss occurs, only streams 3123 with data in that packet are blocked waiting for a retransmission to 3124 be received, while other streams can continue making progress. Note 3125 that when data from multiple streams is bundled into a single QUIC 3126 packet, loss of that packet blocks all those streams from making 3127 progress. Implementations are advised to bundle as few streams as 3128 necessary in outgoing packets without losing transmission efficiency 3129 to underfilled packets. 3131 13.1. Packet Processing and Acknowledgment 3133 A packet MUST NOT be acknowledged until packet protection has been 3134 successfully removed and all frames contained in the packet have been 3135 processed. For STREAM frames, this means the data has been enqueued 3136 in preparation to be received by the application protocol, but it 3137 does not require that data is delivered and consumed. 3139 Once the packet has been fully processed, a receiver acknowledges 3140 receipt by sending one or more ACK frames containing the packet 3141 number of the received packet. 3143 13.1.1. Sending ACK Frames 3145 An endpoint MUST NOT send more than one packet containing only an ACK 3146 frame per received packet that contains frames other than ACK and 3147 PADDING frames. An endpoint MUST NOT send a packet containing only 3148 an ACK frame in response to a packet containing only ACK or PADDING 3149 frames, even if there are packet gaps which precede the received 3150 packet. This prevents an indefinite feedback loop of ACKs. The 3151 endpoint MUST however acknowledge packets containing only ACK or 3152 PADDING frames when sending ACK frames in response to other packets. 3154 Packets containing PADDING frames are considered to be in flight for 3155 congestion control purposes [QUIC-RECOVERY]. Sending only PADDING 3156 frames might cause the sender to become limited by the congestion 3157 controller (as described in [QUIC-RECOVERY]) with no acknowledgments 3158 forthcoming from the receiver. Therefore, a sender SHOULD ensure 3159 that other frames are sent in addition to PADDING frames to elicit 3160 acknowledgments from the receiver. 3162 The receiver's delayed acknowledgment timer SHOULD NOT exceed the 3163 current RTT estimate or the value it indicates in the "max_ack_delay" 3164 transport parameter. This ensures an acknowledgment is sent at least 3165 once per RTT when packets needing acknowledgement are received. The 3166 sender can use the receiver's "max_ack_delay" value in determining 3167 timeouts for timer-based retransmission. 3169 Strategies and implications of the frequency of generating 3170 acknowledgments are discussed in more detail in [QUIC-RECOVERY]. 3172 To limit ACK Ranges (see Section 19.3.1) to those that have not yet 3173 been received by the sender, the receiver SHOULD track which ACK 3174 frames have been acknowledged by its peer. The receiver SHOULD 3175 exclude already acknowledged packets from future ACK frames whenever 3176 these packets would unnecessarily contribute to the ACK frame size. 3178 Because ACK frames are not sent in response to ACK-only packets, a 3179 receiver that is only sending ACK frames will only receive 3180 acknowledgements for its packets if the sender includes them in 3181 packets with non-ACK frames. A sender SHOULD bundle ACK frames with 3182 other frames when possible. 3184 To limit receiver state or the size of ACK frames, a receiver MAY 3185 limit the number of ACK Ranges it sends. A receiver can do this even 3186 without receiving acknowledgment of its ACK frames, with the 3187 knowledge this could cause the sender to unnecessarily retransmit 3188 some data. Standard QUIC [QUIC-RECOVERY] algorithms declare packets 3189 lost after sufficiently newer packets are acknowledged. Therefore, 3190 the receiver SHOULD repeatedly acknowledge newly received packets in 3191 preference to packets received in the past. 3193 An endpoint SHOULD treat receipt of an acknowledgment for a packet it 3194 did not send as a connection error of type PROTOCOL_VIOLATION, if it 3195 is able to detect the condition. 3197 13.1.2. ACK Frames and Packet Protection 3199 ACK frames MUST only be carried in a packet that has the same packet 3200 number space as the packet being ACKed (see Section 12.1). For 3201 instance, packets that are protected with 1-RTT keys MUST be 3202 acknowledged in packets that are also protected with 1-RTT keys. 3204 Packets that a client sends with 0-RTT packet protection MUST be 3205 acknowledged by the server in packets protected by 1-RTT keys. This 3206 can mean that the client is unable to use these acknowledgments if 3207 the server cryptographic handshake messages are delayed or lost. 3208 Note that the same limitation applies to other data sent by the 3209 server protected by the 1-RTT keys. 3211 Endpoints SHOULD send acknowledgments for packets containing CRYPTO 3212 frames with a reduced delay; see Section 6.2.1 of [QUIC-RECOVERY]. 3214 13.2. Retransmission of Information 3216 QUIC packets that are determined to be lost are not retransmitted 3217 whole. The same applies to the frames that are contained within lost 3218 packets. Instead, the information that might be carried in frames is 3219 sent again in new frames as needed. 3221 New frames and packets are used to carry information that is 3222 determined to have been lost. In general, information is sent again 3223 when a packet containing that information is determined to be lost 3224 and sending ceases when a packet containing that information is 3225 acknowledged. 3227 o Data sent in CRYPTO frames is retransmitted according to the rules 3228 in [QUIC-RECOVERY], until all data has been acknowledged. Data in 3229 CRYPTO frames for Initial and Handshake packets is discarded when 3230 keys for the corresponding encryption level are discarded. 3232 o Application data sent in STREAM frames is retransmitted in new 3233 STREAM frames unless the endpoint has sent a RESET_STREAM for that 3234 stream. Once an endpoint sends a RESET_STREAM frame, no further 3235 STREAM frames are needed. 3237 o The most recent set of acknowledgments are sent in ACK frames. An 3238 ACK frame SHOULD contain all unacknowledged acknowledgments, as 3239 described in Section 13.1.1. 3241 o Cancellation of stream transmission, as carried in a RESET_STREAM 3242 frame, is sent until acknowledged or until all stream data is 3243 acknowledged by the peer (that is, either the "Reset Recvd" or 3244 "Data Recvd" state is reached on the sending part of the stream). 3245 The content of a RESET_STREAM frame MUST NOT change when it is 3246 sent again. 3248 o Similarly, a request to cancel stream transmission, as encoded in 3249 a STOP_SENDING frame, is sent until the receiving part of the 3250 stream enters either a "Data Recvd" or "Reset Recvd" state, see 3251 Section 3.5. 3253 o Connection close signals, including packets that contain 3254 CONNECTION_CLOSE frames, are not sent again when packet loss is 3255 detected, but as described in Section 10. 3257 o The current connection maximum data is sent in MAX_DATA frames. 3258 An updated value is sent in a MAX_DATA frame if the packet 3259 containing the most recently sent MAX_DATA frame is declared lost, 3260 or when the endpoint decides to update the limit. Care is 3261 necessary to avoid sending this frame too often as the limit can 3262 increase frequently and cause an unnecessarily large number of 3263 MAX_DATA frames to be sent. 3265 o The current maximum stream data offset is sent in MAX_STREAM_DATA 3266 frames. Like MAX_DATA, an updated value is sent when the packet 3267 containing the most recent MAX_STREAM_DATA frame for a stream is 3268 lost or when the limit is updated, with care taken to prevent the 3269 frame from being sent too often. An endpoint SHOULD stop sending 3270 MAX_STREAM_DATA frames when the receiving part of the stream 3271 enters a "Size Known" state. 3273 o The limit on streams of a given type is sent in MAX_STREAMS 3274 frames. Like MAX_DATA, an updated value is sent when a packet 3275 containing the most recent MAX_STREAMS for a stream type frame is 3276 declared lost or when the limit is updated, with care taken to 3277 prevent the frame from being sent too often. 3279 o Blocked signals are carried in DATA_BLOCKED, STREAM_DATA_BLOCKED, 3280 and STREAMS_BLOCKED frames. DATA_BLOCKED frames have connection 3281 scope, STREAM_DATA_BLOCKED frames have stream scope, and 3282 STREAMS_BLOCKED frames are scoped to a specific stream type. New 3283 frames are sent if packets containing the most recent frame for a 3284 scope is lost, but only while the endpoint is blocked on the 3285 corresponding limit. These frames always include the limit that 3286 is causing blocking at the time that they are transmitted. 3288 o A liveness or path validation check using PATH_CHALLENGE frames is 3289 sent periodically until a matching PATH_RESPONSE frame is received 3290 or until there is no remaining need for liveness or path 3291 validation checking. PATH_CHALLENGE frames include a different 3292 payload each time they are sent. 3294 o Responses to path validation using PATH_RESPONSE frames are sent 3295 just once. A new PATH_CHALLENGE frame will be sent if another 3296 PATH_RESPONSE frame is needed. 3298 o New connection IDs are sent in NEW_CONNECTION_ID frames and 3299 retransmitted if the packet containing them is lost. 3300 Retransmissions of this frame carry the same sequence number 3301 value. Likewise, retired connection IDs are sent in 3302 RETIRE_CONNECTION_ID frames and retransmitted if the packet 3303 containing them is lost. 3305 o PING and PADDING frames contain no information, so lost PING or 3306 PADDING frames do not require repair. 3308 Endpoints SHOULD prioritize retransmission of data over sending new 3309 data, unless priorities specified by the application indicate 3310 otherwise (see Section 2.3). 3312 Even though a sender is encouraged to assemble frames containing up- 3313 to-date information every time it sends a packet, it is not forbidden 3314 to retransmit copies of frames from lost packets. A receiver MUST 3315 accept packets containing an outdated frame, such as a MAX_DATA frame 3316 carrying a smaller maximum data than one found in an older packet. 3318 Upon detecting losses, a sender MUST take appropriate congestion 3319 control action. The details of loss detection and congestion control 3320 are described in [QUIC-RECOVERY]. 3322 13.3. Explicit Congestion Notification 3324 QUIC endpoints can use Explicit Congestion Notification (ECN) 3325 [RFC3168] to detect and respond to network congestion. ECN allows a 3326 network node to indicate congestion in the network by setting a 3327 codepoint in the IP header of a packet instead of dropping it. 3328 Endpoints react to congestion by reducing their sending rate in 3329 response, as described in [QUIC-RECOVERY]. 3331 To use ECN, QUIC endpoints first determine whether a path supports 3332 ECN marking and the peer is able to access the ECN codepoint in the 3333 IP header. A network path does not support ECN if ECN marked packets 3334 get dropped or ECN markings are rewritten on the path. An endpoint 3335 verifies the path, both during connection establishment and when 3336 migrating to a new path (see Section 9). 3338 13.3.1. ECN Counts 3340 On receiving a QUIC packet with an ECT or CE codepoint, an ECN- 3341 enabled endpoint that can access the ECN codepoints from the 3342 enclosing IP packet increases the corresponding ECT(0), ECT(1), or CE 3343 count, and includes these counts in subsequent ACK frames (see 3344 Section 13.1 and Section 19.3). Note that this requires being able 3345 to read the ECN codepoints from the enclosing IP packet, which is not 3346 possible on all platforms. 3348 A packet detected by a receiver as a duplicate does not affect the 3349 receiver's local ECN codepoint counts; see (Section 21.7) for 3350 relevant security concerns. 3352 If an endpoint receives a QUIC packet without an ECT or CE codepoint 3353 in the IP packet header, it responds per Section 13.1 with an ACK 3354 frame without increasing any ECN counts. If an endpoint does not 3355 implement ECN support or does not have access to received ECN 3356 codepoints, it does not increase ECN counts. 3358 Coalesced packets (see Section 12.2) mean that several packets can 3359 share the same IP header. The ECN counter for the ECN codepoint 3360 received in the associated IP header are incremented once for each 3361 QUIC packet, not per enclosing IP packet or UDP datagram. 3363 Each packet number space maintains separate acknowledgement state and 3364 separate ECN counts. For example, if one each of an Initial, 0-RTT, 3365 Handshake, and 1-RTT QUIC packet are coalesced, the corresponding 3366 counts for the Initial and Handshake packet number space will be 3367 incremented by one and the counts for the 1-RTT packet number space 3368 will be increased by two. 3370 13.3.2. ECN Verification 3372 Each endpoint independently verifies and enables use of ECN by 3373 setting the IP header ECN codepoint to ECN Capable Transport (ECT) 3374 for the path from it to the other peer. Even if not setting ECN 3375 codepoints on packets it transmits, the endpoint SHOULD provide 3376 feedback about ECN markings received (if accessible). 3378 To verify both that a path supports ECN and the peer can provide ECN 3379 feedback, an endpoint sets the ECT(0) codepoint in the IP header of 3380 all outgoing packets [RFC8311]. 3382 If an ECT codepoint set in the IP header is not corrupted by a 3383 network device, then a received packet contains either the codepoint 3384 sent by the peer or the Congestion Experienced (CE) codepoint set by 3385 a network device that is experiencing congestion. 3387 If a QUIC packet sent with an ECT codepoint is newly acknowledged by 3388 the peer in an ACK frame without ECN feedback, the endpoint stops 3389 setting ECT codepoints in subsequent IP packets, with the expectation 3390 that either the network path or the peer no longer supports ECN. 3392 Network devices that corrupt or apply non-standard ECN markings might 3393 result in reduced throughput or other undesirable side-effects. To 3394 reduce this risk, an endpoint uses the following steps to verify the 3395 counts it receives in an ACK frame. 3397 o The total increase in ECT(0), ECT(1), and CE counts MUST be no 3398 smaller than the total number of QUIC packets sent with an ECT 3399 codepoint that are newly acknowledged in this ACK frame. This 3400 step detects any network remarking from ECT(0), ECT(1), or CE 3401 codepoints to Not-ECT. 3403 o Any increase in either ECT(0) or ECT(1) counts, plus any increase 3404 in the CE count, MUST be no smaller than the number of packets 3405 sent with the corresponding ECT codepoint that are newly 3406 acknowledged in this ACK frame. This step detects any erroneous 3407 network remarking from ECT(0) to ECT(1) (or vice versa). 3409 An endpoint could miss acknowledgements for a packet when ACK frames 3410 are lost. It is therefore possible for the total increase in ECT(0), 3411 ECT(1), and CE counts to be greater than the number of packets 3412 acknowledged in an ACK frame. When this happens, and if verification 3413 succeeds, the local reference counts MUST be increased to match the 3414 counts in the ACK frame. 3416 Processing counts out of order can result in verification failure. 3417 An endpoint SHOULD NOT perform this verification if the ACK frame is 3418 received in a packet with packet number lower than a previously 3419 received ACK frame. Verifying based on ACK frames that arrive out of 3420 order can result in disabling ECN unnecessarily. 3422 Upon successful verification, an endpoint continues to set ECT 3423 codepoints in subsequent packets with the expectation that the path 3424 is ECN-capable. 3426 If verification fails, then the endpoint ceases setting ECT 3427 codepoints in subsequent IP packets with the expectation that either 3428 the network path or the peer does not support ECN. 3430 If an endpoint sets ECT codepoints on outgoing IP packets and 3431 encounters a retransmission timeout due to the absence of 3432 acknowledgments from the peer (see [QUIC-RECOVERY]), or if an 3433 endpoint has reason to believe that an element on the network path 3434 might be corrupting ECN codepoints, the endpoint MAY cease setting 3435 ECT codepoints in subsequent packets. Doing so allows the connection 3436 to be resilient to network elements that corrupt ECN codepoints in 3437 the IP header or drop packets with ECT or CE codepoints in the IP 3438 header. 3440 14. Packet Size 3442 The QUIC packet size includes the QUIC header and protected payload, 3443 but not the UDP or IP header. 3445 Clients MUST ensure they send the first Initial packet in a single IP 3446 packet. Similarly, the first Initial packet sent after receiving a 3447 Retry packet MUST be sent in a single IP packet. 3449 The payload of a UDP datagram carrying the first Initial packet MUST 3450 be expanded to at least 1200 bytes, by adding PADDING frames to the 3451 Initial packet and/or by combining the Initial packet with a 0-RTT 3452 packet (see Section 12.2). Sending a UDP datagram of this size 3453 ensures that the network path supports a reasonable Maximum 3454 Transmission Unit (MTU), and helps reduce the amplitude of 3455 amplification attacks caused by server responses toward an unverified 3456 client address, see Section 8. 3458 The datagram containing the first Initial packet from a client MAY 3459 exceed 1200 bytes if the client believes that the Path Maximum 3460 Transmission Unit (PMTU) supports the size that it chooses. 3462 A server MAY send a CONNECTION_CLOSE frame with error code 3463 PROTOCOL_VIOLATION in response to the first Initial packet it 3464 receives from a client if the UDP datagram is smaller than 1200 3465 bytes. It MUST NOT send any other frame type in response, or 3466 otherwise behave as if any part of the offending packet was processed 3467 as valid. 3469 The server MUST also limit the number of bytes it sends before 3470 validating the address of the client, see Section 8. 3472 14.1. Path Maximum Transmission Unit (PMTU) 3474 The PMTU is the maximum size of the entire IP packet including the IP 3475 header, UDP header, and UDP payload. The UDP payload includes the 3476 QUIC packet header, protected payload, and any authentication fields. 3477 The PMTU can depend upon the current path characteristics. 3478 Therefore, the current largest UDP payload an implementation will 3479 send is referred to as the QUIC maximum packet size. 3481 QUIC depends on a PMTU of at least 1280 bytes. This is the IPv6 3482 minimum size [RFC8200] and is also supported by most modern IPv4 3483 networks. All QUIC packets (except for PMTU probe packets) SHOULD be 3484 sized to fit within the maximum packet size to avoid the packet being 3485 fragmented or dropped [RFC8085]. 3487 An endpoint SHOULD use Datagram Packetization Layer PMTU Discovery 3488 ([DPLPMTUD]) or implement Path MTU Discovery (PMTUD) [RFC1191] 3489 [RFC8201] to determine whether the path to a destination will support 3490 a desired message size without fragmentation. 3492 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 3493 packets larger than 1280 bytes. Assuming the minimum IP header size, 3494 this results in a QUIC maximum packet size of 1232 bytes for IPv6 and 3495 1252 bytes for IPv4. A QUIC implementation MAY be more conservative 3496 in computing the QUIC maximum packet size to allow for unknown tunnel 3497 overheads or IP header options/extensions. 3499 Each pair of local and remote addresses could have a different PMTU. 3500 QUIC implementations that implement any kind of PMTU discovery 3501 therefore SHOULD maintain a maximum packet size for each combination 3502 of local and remote IP addresses. 3504 If a QUIC endpoint determines that the PMTU between any pair of local 3505 and remote IP addresses has fallen below the size needed to support 3506 the smallest allowed maximum packet size, it MUST immediately cease 3507 sending QUIC packets, except for PMTU probe packets, on the affected 3508 path. An endpoint MAY terminate the connection if an alternative 3509 path cannot be found. 3511 14.2. ICMP Packet Too Big Messages 3513 PMTU discovery [RFC1191] [RFC8201] relies on reception of ICMP 3514 messages (e.g., IPv6 Packet Too Big messages) that indicate when a 3515 packet is dropped because it is larger than the local router MTU. 3516 DPLPMTUD can also optionally use these messages. This use of ICMP 3517 messages is potentially vulnerable to off-path attacks that 3518 successfully guess the addresses used on the path and reduce the PMTU 3519 to a bandwidth-inefficient value. 3521 An endpoint MUST ignore an ICMP message that claims the PMTU has 3522 decreased below 1280 bytes. 3524 The requirements for generating ICMP ([RFC1812], [RFC4443]) state 3525 that the quoted packet should contain as much of the original packet 3526 as possible without exceeding the minimum MTU for the IP version. 3527 The size of the quoted packet can actually be smaller, or the 3528 information unintelligible, as described in Section 1.1 of 3529 [DPLPMTUD]. 3531 QUIC endpoints SHOULD validate ICMP messages to protect from off-path 3532 injection as specified in [RFC8201] and Section 5.2 of [RFC8085]. 3533 This validation SHOULD use the quoted packet supplied in the payload 3534 of an ICMP message to associate the message with a corresponding 3535 transport connection [DPLPMTUD]. 3537 ICMP message validation MUST include matching IP addresses and UDP 3538 ports [RFC8085] and, when possible, connection IDs to an active QUIC 3539 session. 3541 Further validation can also be provided: 3543 o An IPv4 endpoint could set the Don't Fragment (DF) bit on a small 3544 proportion of packets, so that most invalid ICMP messages arrive 3545 when there are no DF packets outstanding, and can therefore be 3546 identified as spurious. 3548 o An endpoint could store additional information from the IP or UDP 3549 headers to use for validation (for example, the IP ID or UDP 3550 checksum). 3552 The endpoint SHOULD ignore all ICMP messages that fail validation. 3554 An endpoint MUST NOT increase PMTU based on ICMP messages. Any 3555 reduction in the QUIC maximum packet size MAY be provisional until 3556 QUIC's loss detection algorithm determines that the quoted packet has 3557 actually been lost. 3559 14.3. Datagram Packetization Layer PMTU Discovery 3561 Section 6.4 of [DPLPMTUD] provides considerations for implementing 3562 Datagram Packetization Layer PMTUD (DPLPMTUD) with QUIC. 3564 When implementing the algorithm in Section 5.3 of [DPLPMTUD], the 3565 initial value of BASE_PMTU SHOULD be consistent with the minimum QUIC 3566 packet size (1232 bytes for IPv6 and 1252 bytes for IPv4). 3568 PING and PADDING frames can be used to generate PMTU probe packets. 3569 These frames might not be retransmitted if a probe packet containing 3570 them is lost. However, these frames do consume congestion window, 3571 which could delay the transmission of subsequent application data. 3573 A PING frame can be included in a PMTU probe to ensure that a valid 3574 probe is acknowledged. 3576 The considerations for processing ICMP messages in the previous 3577 section also apply if these messages are used by DPLPMTUD. 3579 15. Versions 3581 QUIC versions are identified using a 32-bit unsigned number. 3583 The version 0x00000000 is reserved to represent version negotiation. 3584 This version of the specification is identified by the number 3585 0x00000001. 3587 Other versions of QUIC might have different properties to this 3588 version. The properties of QUIC that are guaranteed to be consistent 3589 across all versions of the protocol are described in 3590 [QUIC-INVARIANTS]. 3592 Version 0x00000001 of QUIC uses TLS as a cryptographic handshake 3593 protocol, as described in [QUIC-TLS]. 3595 Versions with the most significant 16 bits of the version number 3596 cleared are reserved for use in future IETF consensus documents. 3598 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 3599 forcing version negotiation to be exercised. That is, any version 3600 number where the low four bits of all bytes is 1010 (in binary). A 3601 client or server MAY advertise support for any of these reserved 3602 versions. 3604 Reserved version numbers will probably never represent a real 3605 protocol; a client MAY use one of these version numbers with the 3606 expectation that the server will initiate version negotiation; a 3607 server MAY advertise support for one of these versions and can expect 3608 that clients ignore the value. 3610 [[RFC editor: please remove the remainder of this section before 3611 publication.]] 3613 The version number for the final version of this specification 3614 (0x00000001), is reserved for the version of the protocol that is 3615 published as an RFC. 3617 Version numbers used to identify IETF drafts are created by adding 3618 the draft number to 0xff000000. For example, draft-ietf-quic- 3619 transport-13 would be identified as 0xff00000D. 3621 Implementors are encouraged to register version numbers of QUIC that 3622 they are using for private experimentation on the GitHub wiki at 3623 . 3625 16. Variable-Length Integer Encoding 3627 QUIC packets and frames commonly use a variable-length encoding for 3628 non-negative integer values. This encoding ensures that smaller 3629 integer values need fewer bytes to encode. 3631 The QUIC variable-length integer encoding reserves the two most 3632 significant bits of the first byte to encode the base 2 logarithm of 3633 the integer encoding length in bytes. The integer value is encoded 3634 on the remaining bits, in network byte order. 3636 This means that integers are encoded on 1, 2, 4, or 8 bytes and can 3637 encode 6, 14, 30, or 62 bit values respectively. Table 4 summarizes 3638 the encoding properties. 3640 +------+--------+-------------+-----------------------+ 3641 | 2Bit | Length | Usable Bits | Range | 3642 +------+--------+-------------+-----------------------+ 3643 | 00 | 1 | 6 | 0-63 | 3644 | | | | | 3645 | 01 | 2 | 14 | 0-16383 | 3646 | | | | | 3647 | 10 | 4 | 30 | 0-1073741823 | 3648 | | | | | 3649 | 11 | 8 | 62 | 0-4611686018427387903 | 3650 +------+--------+-------------+-----------------------+ 3652 Table 4: Summary of Integer Encodings 3654 For example, the eight byte sequence c2 19 7c 5e ff 14 e8 8c (in 3655 hexadecimal) decodes to the decimal value 151288809941952652; the 3656 four byte sequence 9d 7f 3e 7d decodes to 494878333; the two byte 3657 sequence 7b bd decodes to 15293; and the single byte 25 decodes to 37 3658 (as does the two byte sequence 40 25). 3660 Error codes (Section 20) and versions (Section 15) are described 3661 using integers, but do not use this encoding. 3663 17. Packet Formats 3665 All numeric values are encoded in network byte order (that is, big- 3666 endian) and all field sizes are in bits. Hexadecimal notation is 3667 used for describing the value of fields. 3669 17.1. Packet Number Encoding and Decoding 3671 Packet numbers are integers in the range 0 to 2^62-1 (Section 12.3). 3672 When present in long or short packet headers, they are encoded in 1 3673 to 4 bytes. The number of bits required to represent the packet 3674 number is reduced by including the least significant bits of the 3675 packet number. 3677 The encoded packet number is protected as described in Section 5.4 of 3678 [QUIC-TLS]. 3680 The sender MUST use a packet number size able to represent more than 3681 twice as large a range than the difference between the largest 3682 acknowledged packet and packet number being sent. A peer receiving 3683 the packet will then correctly decode the packet number, unless the 3684 packet is delayed in transit such that it arrives after many higher- 3685 numbered packets have been received. An endpoint SHOULD use a large 3686 enough packet number encoding to allow the packet number to be 3687 recovered even if the packet arrives after packets that are sent 3688 afterwards. 3690 As a result, the size of the packet number encoding is at least one 3691 bit more than the base-2 logarithm of the number of contiguous 3692 unacknowledged packet numbers, including the new packet. 3694 For example, if an endpoint has received an acknowledgment for packet 3695 0xabe8bc, sending a packet with a number of 0xac5c02 requires a 3696 packet number encoding with 16 bits or more; whereas the 24-bit 3697 packet number encoding is needed to send a packet with a number of 3698 0xace8fe. 3700 At a receiver, protection of the packet number is removed prior to 3701 recovering the full packet number. The full packet number is then 3702 reconstructed based on the number of significant bits present, the 3703 value of those bits, and the largest packet number received on a 3704 successfully authenticated packet. Recovering the full packet number 3705 is necessary to successfully remove packet protection. 3707 Once header protection is removed, the packet number is decoded by 3708 finding the packet number value that is closest to the next expected 3709 packet. The next expected packet is the highest received packet 3710 number plus one. For example, if the highest successfully 3711 authenticated packet had a packet number of 0xa82f30ea, then a packet 3712 containing a 16-bit value of 0x9b32 will be decoded as 0xa82f9b32. 3713 Example pseudo-code for packet number decoding can be found in 3714 Appendix A. 3716 17.2. Long Header Packets 3718 0 1 2 3 3719 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 3720 +-+-+-+-+-+-+-+-+ 3721 |1|1|T T|X X X X| 3722 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3723 | Version (32) | 3724 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3725 |DCIL(4)|SCIL(4)| 3726 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3727 | Destination Connection ID (0/32..144) ... 3728 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3729 | Source Connection ID (0/32..144) ... 3730 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3732 Figure 9: Long Header Packet Format 3734 Long headers are used for packets that are sent prior to the 3735 establishment of 1-RTT keys. Once both conditions are met, a sender 3736 switches to sending packets using the short header (Section 17.3). 3737 The long form allows for special packets - such as the Version 3738 Negotiation packet - to be represented in this uniform fixed-length 3739 packet format. Packets that use the long header contain the 3740 following fields: 3742 Header Form: The most significant bit (0x80) of byte 0 (the first 3743 byte) is set to 1 for long headers. 3745 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 3746 containing a zero value for this bit are not valid packets in this 3747 version and MUST be discarded. 3749 Long Packet Type (T): The next two bits (those with a mask of 0x30) 3750 of byte 0 contain a packet type. Packet types are listed in 3751 Table 5. 3753 Type-Specific Bits (X): The lower four bits (those with a mask of 3754 0x0f) of byte 0 are type-specific. 3756 Version: The QUIC Version is a 32-bit field that follows the first 3757 byte. This field indicates which version of QUIC is in use and 3758 determines how the rest of the protocol fields are interpreted. 3760 DCIL and SCIL: The byte following the version contains the lengths 3761 of the two connection ID fields that follow it. These lengths are 3762 encoded as two 4-bit unsigned integers. The Destination 3763 Connection ID Length (DCIL) field occupies the 4 high bits of the 3764 byte and the Source Connection ID Length (SCIL) field occupies the 3765 4 low bits of the byte. An encoded length of 0 indicates that the 3766 connection ID is also 0 bytes in length. Non-zero encoded lengths 3767 are increased by 3 to get the full length of the connection ID, 3768 producing a length between 4 and 18 bytes inclusive. For example, 3769 an byte with the value 0x50 describes an 8-byte Destination 3770 Connection ID and a zero-length Source Connection ID. 3772 Destination Connection ID: The Destination Connection ID field 3773 follows the connection ID lengths and is either 0 bytes in length 3774 or between 4 and 18 bytes. Section 7.2 describes the use of this 3775 field in more detail. 3777 Source Connection ID: The Source Connection ID field follows the 3778 Destination Connection ID and is either 0 bytes in length or 3779 between 4 and 18 bytes. Section 7.2 describes the use of this 3780 field in more detail. 3782 In this version of QUIC, the following packet types with the long 3783 header are defined: 3785 +------+-----------+----------------+ 3786 | Type | Name | Section | 3787 +------+-----------+----------------+ 3788 | 0x0 | Initial | Section 17.2.2 | 3789 | | | | 3790 | 0x1 | 0-RTT | Section 17.2.3 | 3791 | | | | 3792 | 0x2 | Handshake | Section 17.2.4 | 3793 | | | | 3794 | 0x3 | Retry | Section 17.2.5 | 3795 +------+-----------+----------------+ 3797 Table 5: Long Header Packet Types 3799 The header form bit, connection ID lengths byte, Destination and 3800 Source Connection ID fields, and Version fields of a long header 3801 packet are version-independent. The other fields in the first byte 3802 are version-specific. See [QUIC-INVARIANTS] for details on how 3803 packets from different versions of QUIC are interpreted. 3805 The interpretation of the fields and the payload are specific to a 3806 version and packet type. While type-specific semantics for this 3807 version are described in the following sections, several long-header 3808 packets in this version of QUIC contain these additional fields: 3810 Reserved Bits (R): Two bits (those with a mask of 0x0c) of byte 0 3811 are reserved across multiple packet types. These bits are 3812 protected using header protection (see Section 5.4 of [QUIC-TLS]). 3813 The value included prior to protection MUST be set to 0. An 3814 endpoint MUST treat receipt of a packet that has a non-zero value 3815 for these bits, after removing both packet and header protection, 3816 as a connection error of type PROTOCOL_VIOLATION. Discarding such 3817 a packet after only removing header protection can expose the 3818 endpoint to attacks (see Section 9.3 of [QUIC-TLS]). 3820 Packet Number Length (P): In packet types which contain a Packet 3821 Number field, the least significant two bits (those with a mask of 3822 0x03) of byte 0 contain the length of the packet number, encoded 3823 as an unsigned, two-bit integer that is one less than the length 3824 of the packet number field in bytes. That is, the length of the 3825 packet number field is the value of this field, plus one. These 3826 bits are protected using header protection (see Section 5.4 of 3827 [QUIC-TLS]). 3829 Length: The length of the remainder of the packet (that is, the 3830 Packet Number and Payload fields) in bytes, encoded as a variable- 3831 length integer (Section 16). 3833 Packet Number: The packet number field is 1 to 4 bytes long. The 3834 packet number has confidentiality protection separate from packet 3835 protection, as described in Section 5.4 of [QUIC-TLS]. The length 3836 of the packet number field is encoded in the Packet Number Length 3837 bits of byte 0 (see above). 3839 17.2.1. Version Negotiation Packet 3841 A Version Negotiation packet is inherently not version-specific. 3842 Upon receipt by a client, it will be identified as a Version 3843 Negotiation packet based on the Version field having a value of 0. 3845 The Version Negotiation packet is a response to a client packet that 3846 contains a version that is not supported by the server, and is only 3847 sent by servers. 3849 The layout of a Version Negotiation packet is: 3851 0 1 2 3 3852 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 3853 +-+-+-+-+-+-+-+-+ 3854 |1| Unused (7) | 3855 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3856 | Version (32) | 3857 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3858 |DCIL(4)|SCIL(4)| 3859 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3860 | Destination Connection ID (0/32..144) ... 3861 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3862 | Source Connection ID (0/32..144) ... 3863 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3864 | Supported Version 1 (32) ... 3865 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3866 | [Supported Version 2 (32)] ... 3867 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3868 ... 3869 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3870 | [Supported Version N (32)] ... 3871 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3873 Figure 10: Version Negotiation Packet 3875 The value in the Unused field is selected randomly by the server. 3876 Clients MUST ignore the value of this field. Servers SHOULD set the 3877 most significant bit of this field (0x40) to 1 so that Version 3878 Negotiation packets appear to have the Fixed Bit field. 3880 The Version field of a Version Negotiation packet MUST be set to 3881 0x00000000. 3883 The server MUST include the value from the Source Connection ID field 3884 of the packet it receives in the Destination Connection ID field. 3885 The value for Source Connection ID MUST be copied from the 3886 Destination Connection ID of the received packet, which is initially 3887 randomly selected by a client. Echoing both connection IDs gives 3888 clients some assurance that the server received the packet and that 3889 the Version Negotiation packet was not generated by an off-path 3890 attacker. 3892 The remainder of the Version Negotiation packet is a list of 32-bit 3893 versions which the server supports. 3895 A Version Negotiation packet cannot be explicitly acknowledged in an 3896 ACK frame by a client. Receiving another Initial packet implicitly 3897 acknowledges a Version Negotiation packet. 3899 The Version Negotiation packet does not include the Packet Number and 3900 Length fields present in other packets that use the long header form. 3901 Consequently, a Version Negotiation packet consumes an entire UDP 3902 datagram. 3904 A server MUST NOT send more than one Version Negotiation packet in 3905 response to a single UDP datagram. 3907 See Section 6 for a description of the version negotiation process. 3909 17.2.2. Initial Packet 3911 An Initial packet uses long headers with a type value of 0x0. It 3912 carries the first CRYPTO frames sent by the client and server to 3913 perform key exchange, and carries ACKs in either direction. 3915 +-+-+-+-+-+-+-+-+ 3916 |1|1| 0 |R R|P P| 3917 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3918 | Version (32) | 3919 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3920 |DCIL(4)|SCIL(4)| 3921 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3922 | Destination Connection ID (0/32..144) ... 3923 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3924 | Source Connection ID (0/32..144) ... 3925 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3926 | Token Length (i) ... 3927 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3928 | Token (*) ... 3929 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3930 | Length (i) ... 3931 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3932 | Packet Number (8/16/24/32) ... 3933 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3934 | Payload (*) ... 3935 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3937 Figure 11: Initial Packet 3939 The Initial packet contains a long header as well as the Length and 3940 Packet Number fields. The first byte contains the Reserved and 3941 Packet Number Length bits. Between the SCID and Length fields, there 3942 are two additional field specific to the Initial packet. 3944 Token Length: A variable-length integer specifying the length of the 3945 Token field, in bytes. This value is zero if no token is present. 3946 Initial packets sent by the server MUST set the Token Length field 3947 to zero; clients that receive an Initial packet with a non-zero 3948 Token Length field MUST either discard the packet or generate a 3949 connection error of type PROTOCOL_VIOLATION. 3951 Token: The value of the token that was previously provided in a 3952 Retry packet or NEW_TOKEN frame. 3954 Payload: The payload of the packet. 3956 In order to prevent tampering by version-unaware middleboxes, Initial 3957 packets are protected with connection- and version-specific keys 3958 (Initial keys) as described in [QUIC-TLS]. This protection does not 3959 provide confidentiality or integrity against on-path attackers, but 3960 provides some level of protection against off-path attackers. 3962 The client and server use the Initial packet type for any packet that 3963 contains an initial cryptographic handshake message. This includes 3964 all cases where a new packet containing the initial cryptographic 3965 message needs to be created, such as the packets sent after receiving 3966 a Retry packet (Section 17.2.5). 3968 A server sends its first Initial packet in response to a client 3969 Initial. A server may send multiple Initial packets. The 3970 cryptographic key exchange could require multiple round trips or 3971 retransmissions of this data. 3973 The payload of an Initial packet includes a CRYPTO frame (or frames) 3974 containing a cryptographic handshake message, ACK frames, or both. 3975 PADDING and CONNECTION_CLOSE frames are also permitted. An endpoint 3976 that receives an Initial packet containing other frames can either 3977 discard the packet as spurious or treat it as a connection error. 3979 The first packet sent by a client always includes a CRYPTO frame that 3980 contains the entirety of the first cryptographic handshake message. 3981 This packet, and the cryptographic handshake message, MUST fit in a 3982 single UDP datagram (see Section 7). The first CRYPTO frame sent 3983 always begins at an offset of 0 (see Section 7). 3985 Note that if the server sends a HelloRetryRequest, the client will 3986 send a second Initial packet. This Initial packet will continue the 3987 cryptographic handshake and will contain a CRYPTO frame with an 3988 offset matching the size of the CRYPTO frame sent in the first 3989 Initial packet. Cryptographic handshake messages subsequent to the 3990 first do not need to fit within a single UDP datagram. 3992 17.2.2.1. Abandoning Initial Packets 3994 A client stops both sending and processing Initial packets when it 3995 sends its first Handshake packet. A server stops sending and 3996 processing Initial packets when it receives its first Handshake 3997 packet. Though packets might still be in flight or awaiting 3998 acknowledgment, no further Initial packets need to be exchanged 3999 beyond this point. Initial packet protection keys are discarded (see 4000 Section 4.10 of [QUIC-TLS]) along with any loss recovery and 4001 congestion control state (see Sections 5.3.1.2 and 6.9 of 4002 [QUIC-RECOVERY]). 4004 Any data in CRYPTO frames is discarded - and no longer retransmitted 4005 - when Initial keys are discarded. 4007 17.2.3. 0-RTT 4009 A 0-RTT packet uses long headers with a type value of 0x1, followed 4010 by the Length and Packet Number fields. The first byte contains the 4011 Reserved and Packet Number Length bits. It is used to carry "early" 4012 data from the client to the server as part of the first flight, prior 4013 to handshake completion. As part of the TLS handshake, the server 4014 can accept or reject this early data. 4016 See Section 2.3 of [TLS13] for a discussion of 0-RTT data and its 4017 limitations. 4019 +-+-+-+-+-+-+-+-+ 4020 |1|1| 1 |R R|P P| 4021 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4022 | Version (32) | 4023 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4024 |DCIL(4)|SCIL(4)| 4025 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4026 | Destination Connection ID (0/32..144) ... 4027 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4028 | Source Connection ID (0/32..144) ... 4029 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4030 | Length (i) ... 4031 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4032 | Packet Number (8/16/24/32) ... 4033 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4034 | Payload (*) ... 4035 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4037 0-RTT Packet 4039 Packet numbers for 0-RTT protected packets use the same space as 4040 1-RTT protected packets. 4042 After a client receives a Retry packet, 0-RTT packets are likely to 4043 have been lost or discarded by the server. A client MAY attempt to 4044 resend data in 0-RTT packets after it sends a new Initial packet. 4046 A client MUST NOT reset the packet number it uses for 0-RTT packets. 4047 The keys used to protect 0-RTT packets will not change as a result of 4048 responding to a Retry packet unless the client also regenerates the 4049 cryptographic handshake message. Sending packets with the same 4050 packet number in that case is likely to compromise the packet 4051 protection for all 0-RTT packets because the same key and nonce could 4052 be used to protect different content. 4054 Receiving a Retry packet, especially a Retry that changes the 4055 connection ID used for subsequent packets, indicates a strong 4056 possibility that 0-RTT packets could be lost. A client only receives 4057 acknowledgments for its 0-RTT packets once the handshake is complete. 4058 Consequently, a server might expect 0-RTT packets to start with a 4059 packet number of 0. Therefore, in determining the length of the 4060 packet number encoding for 0-RTT packets, a client MUST assume that 4061 all packets up to the current packet number are in flight, starting 4062 from a packet number of 0. Thus, 0-RTT packets could need to use a 4063 longer packet number encoding. 4065 A client SHOULD instead generate a fresh cryptographic handshake 4066 message and start packet numbers from 0. This ensures that new 0-RTT 4067 packets will not use the same keys, avoiding any risk of key and 4068 nonce reuse; this also prevents 0-RTT packets from previous handshake 4069 attempts from being accepted as part of the connection. 4071 17.2.4. Handshake Packet 4073 A Handshake packet uses long headers with a type value of 0x2, 4074 followed by the Length and Packet Number fields. The first byte 4075 contains the Reserved and Packet Number Length bits. It is used to 4076 carry acknowledgments and cryptographic handshake messages from the 4077 server and client. 4079 +-+-+-+-+-+-+-+-+ 4080 |1|1| 2 |R R|P P| 4081 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4082 | Version (32) | 4083 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4084 |DCIL(4)|SCIL(4)| 4085 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4086 | Destination Connection ID (0/32..144) ... 4087 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4088 | Source Connection ID (0/32..144) ... 4089 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4090 | Length (i) ... 4091 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4092 | Packet Number (8/16/24/32) ... 4093 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4094 | Payload (*) ... 4095 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4097 Figure 12: Handshake Protected Packet 4099 Once a client has received a Handshake packet from a server, it uses 4100 Handshake packets to send subsequent cryptographic handshake messages 4101 and acknowledgments to the server. 4103 The Destination Connection ID field in a Handshake packet contains a 4104 connection ID that is chosen by the recipient of the packet; the 4105 Source Connection ID includes the connection ID that the sender of 4106 the packet wishes to use (see Section 7.2). 4108 Handshake packets are their own packet number space, and thus the 4109 first Handshake packet sent by a server contains a packet number of 4110 0. 4112 The payload of this packet contains CRYPTO frames and could contain 4113 PADDING, or ACK frames. Handshake packets MAY contain 4114 CONNECTION_CLOSE frames. Endpoints MUST treat receipt of Handshake 4115 packets with other frames as a connection error. 4117 Like Initial packets (see Section 17.2.2.1), data in CRYPTO frames at 4118 the Handshake encryption level is discarded - and no longer 4119 retransmitted - when Handshake protection keys are discarded. 4121 17.2.5. Retry Packet 4123 A Retry packet uses a long packet header with a type value of 0x3. 4124 It carries an address validation token created by the server. It is 4125 used by a server that wishes to perform a stateless retry (see 4126 Section 8.1). 4128 0 1 2 3 4129 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 4130 +-+-+-+-+-+-+-+-+ 4131 |1|1| 3 | ODCIL | 4132 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4133 | Version (32) | 4134 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4135 |DCIL(4)|SCIL(4)| 4136 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4137 | Destination Connection ID (0/32..144) ... 4138 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4139 | Source Connection ID (0/32..144) ... 4140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4141 | Original Destination Connection ID (0/32..144) ... 4142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4143 | Retry Token (*) ... 4144 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4146 Figure 13: Retry Packet 4148 A Retry packet (shown in Figure 13) does not contain any protected 4149 fields. In addition to the long header, it contains these additional 4150 fields: 4152 ODCIL: The four least-significant bits of the first byte of a Retry 4153 packet are not protected as they are for other packets with the 4154 long header, because Retry packets don't contain a protected 4155 payload. These bits instead encode the length of the Original 4156 Destination Connection ID field. The length uses the same 4157 encoding as the DCIL and SCIL fields. 4159 Original Destination Connection ID: The Original Destination 4160 Connection ID contains the value of the Destination Connection ID 4161 from the Initial packet that this Retry is in response to. The 4162 length of this field is given in ODCIL. 4164 Retry Token: An opaque token that the server can use to validate the 4165 client's address. 4167 The server populates the Destination Connection ID with the 4168 connection ID that the client included in the Source Connection ID of 4169 the Initial packet. 4171 The server includes a connection ID of its choice in the Source 4172 Connection ID field. This value MUST not be equal to the Destination 4173 Connection ID field of the packet sent by the client. The client 4174 MUST use this connection ID in the Destination Connection ID of 4175 subsequent packets that it sends. 4177 A server MAY send Retry packets in response to Initial and 0-RTT 4178 packets. A server can either discard or buffer 0-RTT packets that it 4179 receives. A server can send multiple Retry packets as it receives 4180 Initial or 0-RTT packets. A server MUST NOT send more than one Retry 4181 packet in response to a single UDP datagram. 4183 A client MUST accept and process at most one Retry packet for each 4184 connection attempt. After the client has received and processed an 4185 Initial or Retry packet from the server, it MUST discard any 4186 subsequent Retry packets that it receives. 4188 Clients MUST discard Retry packets that contain an Original 4189 Destination Connection ID field that does not match the Destination 4190 Connection ID from its Initial packet. This prevents an off-path 4191 attacker from injecting a Retry packet. 4193 The client responds to a Retry packet with an Initial packet that 4194 includes the provided Retry Token to continue connection 4195 establishment. 4197 A client sets the Destination Connection ID field of this Initial 4198 packet to the value from the Source Connection ID in the Retry 4199 packet. Changing Destination Connection ID also results in a change 4200 to the keys used to protect the Initial packet. It also sets the 4201 Token field to the token provided in the Retry. The client MUST NOT 4202 change the Source Connection ID because the server could include the 4203 connection ID as part of its token validation logic (see 4204 Section 8.1.3). 4206 The next Initial packet from the client uses the connection ID and 4207 token values from the Retry packet (see Section 7.2). Aside from 4208 this, the Initial packet sent by the client is subject to the same 4209 restrictions as the first Initial packet. A client can either reuse 4210 the cryptographic handshake message or construct a new one at its 4211 discretion. 4213 A client MAY attempt 0-RTT after receiving a Retry packet by sending 4214 0-RTT packets to the connection ID provided by the server. A client 4215 that sends additional 0-RTT packets without constructing a new 4216 cryptographic handshake message MUST NOT reset the packet number to 0 4217 after a Retry packet, see Section 17.2.3. 4219 A server acknowledges the use of a Retry packet for a connection 4220 using the original_connection_id transport parameter (see 4221 Section 18.1). If the server sends a Retry packet, it MUST include 4222 the value of the Original Destination Connection ID field of the 4223 Retry packet (that is, the Destination Connection ID field from the 4224 client's first Initial packet) in the transport parameter. 4226 If the client received and processed a Retry packet, it MUST validate 4227 that the original_connection_id transport parameter is present and 4228 correct; otherwise, it MUST validate that the transport parameter is 4229 absent. A client MUST treat a failed validation as a connection 4230 error of type TRANSPORT_PARAMETER_ERROR. 4232 A Retry packet does not include a packet number and cannot be 4233 explicitly acknowledged by a client. 4235 17.3. Short Header Packets 4237 This version of QUIC defines a single packet type which uses the 4238 short packet header. 4240 0 1 2 3 4241 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 4242 +-+-+-+-+-+-+-+-+ 4243 |0|1|S|R|R|K|P P| 4244 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4245 | Destination Connection ID (0..144) ... 4246 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4247 | Packet Number (8/16/24/32) ... 4248 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4249 | Protected Payload (*) ... 4250 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4252 Figure 14: Short Header Packet Format 4254 The short header can be used after the version and 1-RTT keys are 4255 negotiated. Packets that use the short header contain the following 4256 fields: 4258 Header Form: The most significant bit (0x80) of byte 0 is set to 0 4259 for the short header. 4261 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4262 containing a zero value for this bit are not valid packets in this 4263 version and MUST be discarded. 4265 Spin Bit (S): The third most significant bit (0x20) of byte 0 is the 4266 latency spin bit, set as described in Section 17.3.1. 4268 Reserved Bits (R): The next two bits (those with a mask of 0x18) of 4269 byte 0 are reserved. These bits are protected using header 4270 protection (see Section 5.4 of [QUIC-TLS]). The value included 4271 prior to protection MUST be set to 0. An endpoint MUST treat 4272 receipt of a packet that has a non-zero value for these bits, 4273 after removing both packet and header protection, as a connection 4274 error of type PROTOCOL_VIOLATION. Discarding such a packet after 4275 only removing header protection can expose the endpoint to attacks 4276 (see Section 9.3 of [QUIC-TLS]). 4278 Key Phase (K): The next bit (0x04) of byte 0 indicates the key 4279 phase, which allows a recipient of a packet to identify the packet 4280 protection keys that are used to protect the packet. See 4281 [QUIC-TLS] for details. This bit is protected using header 4282 protection (see Section 5.4 of [QUIC-TLS]). 4284 Packet Number Length (P): The least significant two bits (those with 4285 a mask of 0x03) of byte 0 contain the length of the packet number, 4286 encoded as an unsigned, two-bit integer that is one less than the 4287 length of the packet number field in bytes. That is, the length 4288 of the packet number field is the value of this field, plus one. 4289 These bits are protected using header protection (see Section 5.4 4290 of [QUIC-TLS]). 4292 Destination Connection ID: The Destination Connection ID is a 4293 connection ID that is chosen by the intended recipient of the 4294 packet. See Section 5.1 for more details. 4296 Packet Number: The packet number field is 1 to 4 bytes long. The 4297 packet number has confidentiality protection separate from packet 4298 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4299 of the packet number field is encoded in Packet Number Length 4300 field. See Section 17.1 for details. 4302 Protected Payload: Packets with a short header always include a 4303 1-RTT protected payload. 4305 The header form bit and the connection ID field of a short header 4306 packet are version-independent. The remaining fields are specific to 4307 the selected QUIC version. See [QUIC-INVARIANTS] for details on how 4308 packets from different versions of QUIC are interpreted. 4310 17.3.1. Latency Spin Bit 4312 The latency spin bit enables passive latency monitoring from 4313 observation points on the network path throughout the duration of a 4314 connection. The spin bit is only present in the short packet header, 4315 since it is possible to measure the initial RTT of a connection by 4316 observing the handshake. Therefore, the spin bit is available after 4317 version negotiation and connection establishment are completed. On- 4318 path measurement and use of the latency spin bit is further discussed 4319 in [QUIC-MANAGEABILITY]. 4321 The spin bit is an OPTIONAL feature of QUIC. A QUIC stack that 4322 chooses to support the spin bit MUST implement it as specified in 4323 this section. 4325 Each endpoint unilaterally decides if the spin bit is enabled or 4326 disabled for a connection. Implementations MUST allow administrators 4327 of clients and servers to disable the spin bit either globally or on 4328 a per-connection basis. Even when the spin bit is not disabled by 4329 the administrator, implementations MUST disable the spin bit for a 4330 given connection with a certain likelihood. The random selection 4331 process SHOULD be designed such that on average the spin bit is 4332 disabled for at least one eighth of connections. The selection 4333 process performed at the beginning of the connection SHOULD be 4334 applied for all paths used by the connection. 4336 In case multiple connections share the same five-tuple, that is, have 4337 the same source and destination IP address and UDP ports, endpoints 4338 should try to co-ordinate across all connections to ensure a clear 4339 signal to any on-path measurement points. 4341 When the spin bit is disabled, endpoints MAY set the spin bit to any 4342 value, and MUST ignore any incoming value. It is RECOMMENDED that 4343 endpoints set the spin bit to a random value either chosen 4344 independently for each packet or chosen independently for each 4345 connection ID. 4347 If the spin bit is enabled for the connection, the endpoint maintains 4348 a spin value and sets the spin bit in the short header to the 4349 currently stored value when a packet with a short header is sent out. 4350 The spin value is initialized to 0 in the endpoint at connection 4351 start. Each endpoint also remembers the highest packet number seen 4352 from its peer on the connection. 4354 When a server receives a short header packet that increments the 4355 highest packet number seen by the server from the client, it sets the 4356 spin value to be equal to the spin bit in the received packet. 4358 When a client receives a short header packet that increments the 4359 highest packet number seen by the client from the server, it sets the 4360 spin value to the inverse of the spin bit in the received packet. 4362 An endpoint resets its spin value to zero when sending the first 4363 packet of a given connection with a new connection ID. This reduces 4364 the risk that transient spin bit state can be used to link flows 4365 across connection migration or ID change. 4367 With this mechanism, the server reflects the spin value received, 4368 while the client 'spins' it after one RTT. On-path observers can 4369 measure the time between two spin bit toggle events to estimate the 4370 end-to-end RTT of a connection. 4372 18. Transport Parameter Encoding 4374 The format of the transport parameters is the TransportParameters 4375 struct from Figure 15. This is described using the presentation 4376 language from Section 3 of [TLS13]. 4378 enum { 4379 original_connection_id(0), 4380 idle_timeout(1), 4381 stateless_reset_token(2), 4382 max_packet_size(3), 4383 initial_max_data(4), 4384 initial_max_stream_data_bidi_local(5), 4385 initial_max_stream_data_bidi_remote(6), 4386 initial_max_stream_data_uni(7), 4387 initial_max_streams_bidi(8), 4388 initial_max_streams_uni(9), 4389 ack_delay_exponent(10), 4390 max_ack_delay(11), 4391 disable_migration(12), 4392 preferred_address(13), 4393 (65535) 4394 } TransportParameterId; 4396 struct { 4397 TransportParameterId parameter; 4398 opaque value<0..2^16-1>; 4399 } TransportParameter; 4401 TransportParameter TransportParameters<0..2^16-1>; 4403 Figure 15: Definition of TransportParameters 4405 The "extension_data" field of the quic_transport_parameters extension 4406 defined in [QUIC-TLS] contains a TransportParameters value. TLS 4407 encoding rules are therefore used to describe the encoding of 4408 transport parameters. 4410 QUIC encodes transport parameters into a sequence of bytes, which are 4411 then included in the cryptographic handshake. 4413 18.1. Transport Parameter Definitions 4415 This section details the transport parameters defined in this 4416 document. 4418 Many transport parameters listed here have integer values. Those 4419 transport parameters that are identified as integers use a variable- 4420 length integer encoding (see Section 16) and have a default value of 4421 0 if the transport parameter is absent, unless otherwise stated. 4423 The following transport parameters are defined: 4425 original_connection_id (0x0000): The value of the Destination 4426 Connection ID field from the first Initial packet sent by the 4427 client. This transport parameter is only sent by a server. A 4428 server MUST include the original_connection_id transport parameter 4429 if it sent a Retry packet. 4431 idle_timeout (0x0001): The idle timeout is a value in milliseconds 4432 that is encoded as an integer, see (Section 10.2). If this 4433 parameter is absent or zero then the idle timeout is disabled. 4435 stateless_reset_token (0x0002): A stateless reset token is used in 4436 verifying a stateless reset, see Section 10.4. This parameter is 4437 a sequence of 16 bytes. This transport parameter is only sent by 4438 a server. 4440 max_packet_size (0x0003): The maximum packet size parameter is an 4441 integer value that limits the size of packets that the endpoint is 4442 willing to receive. This indicates that packets larger than this 4443 limit will be dropped. The default for this parameter is the 4444 maximum permitted UDP payload of 65527. Values below 1200 are 4445 invalid. This limit only applies to protected packets 4446 (Section 12.1). 4448 initial_max_data (0x0004): The initial maximum data parameter is an 4449 integer value that contains the initial value for the maximum 4450 amount of data that can be sent on the connection. This is 4451 equivalent to sending a MAX_DATA (Section 19.9) for the connection 4452 immediately after completing the handshake. 4454 initial_max_stream_data_bidi_local (0x0005): This parameter is an 4455 integer value specifying the initial flow control limit for 4456 locally-initiated bidirectional streams. This limit applies to 4457 newly created bidirectional streams opened by the endpoint that 4458 sends the transport parameter. In client transport parameters, 4459 this applies to streams with an identifier with the least 4460 significant two bits set to 0x0; in server transport parameters, 4461 this applies to streams with the least significant two bits set to 4462 0x1. 4464 initial_max_stream_data_bidi_remote (0x0006): This parameter is an 4465 integer value specifying the initial flow control limit for peer- 4466 initiated bidirectional streams. This limit applies to newly 4467 created bidirectional streams opened by the endpoint that receives 4468 the transport parameter. In client transport parameters, this 4469 applies to streams with an identifier with the least significant 4470 two bits set to 0x1; in server transport parameters, this applies 4471 to streams with the least significant two bits set to 0x0. 4473 initial_max_stream_data_uni (0x0007): This parameter is an integer 4474 value specifying the initial flow control limit for unidirectional 4475 streams. This limit applies to newly created unidirectional 4476 streams opened by the endpoint that receives the transport 4477 parameter. In client transport parameters, this applies to 4478 streams with an identifier with the least significant two bits set 4479 to 0x3; in server transport parameters, this applies to streams 4480 with the least significant two bits set to 0x2. 4482 initial_max_streams_bidi (0x0008): The initial maximum bidirectional 4483 streams parameter is an integer value that contains the initial 4484 maximum number of bidirectional streams the peer may initiate. If 4485 this parameter is absent or zero, the peer cannot open 4486 bidirectional streams until a MAX_STREAMS frame is sent. Setting 4487 this parameter is equivalent to sending a MAX_STREAMS 4488 (Section 19.11) of the corresponding type with the same value. 4490 initial_max_streams_uni (0x0009): The initial maximum unidirectional 4491 streams parameter is an integer value that contains the initial 4492 maximum number of unidirectional streams the peer may initiate. 4493 If this parameter is absent or zero, the peer cannot open 4494 unidirectional streams until a MAX_STREAMS frame is sent. Setting 4495 this parameter is equivalent to sending a MAX_STREAMS 4496 (Section 19.11) of the corresponding type with the same value. 4498 ack_delay_exponent (0x000a): The ACK delay exponent is an integer 4499 value indicating an exponent used to decode the ACK Delay field in 4500 the ACK frame (Section 19.3). If this value is absent, a default 4501 value of 3 is assumed (indicating a multiplier of 8). The default 4502 value is also used for ACK frames that are sent in Initial and 4503 Handshake packets. Values above 20 are invalid. 4505 max_ack_delay (0x000b): The maximum ACK delay is an integer value 4506 indicating the maximum amount of time in milliseconds by which the 4507 endpoint will delay sending acknowledgments. This value SHOULD 4508 include the receiver's expected delays in alarms firing. For 4509 example, if a receiver sets a timer for 5ms and alarms commonly 4510 fire up to 1ms late, then it should send a max_ack_delay of 6ms. 4511 If this value is absent, a default of 25 milliseconds is assumed. 4512 Values of 2^14 or greater are invalid. 4514 disable_migration (0x000c): The disable migration transport 4515 parameter is included if the endpoint does not support connection 4516 migration (Section 9). Peers of an endpoint that sets this 4517 transport parameter MUST NOT send any packets, including probing 4518 packets (Section 9.1), from a local address or port other than 4519 that used to perform the handshake. This parameter is a zero- 4520 length value. 4522 preferred_address (0x000d): The server's preferred address is used 4523 to effect a change in server address at the end of the handshake, 4524 as described in Section 9.6. The format of this transport 4525 parameter is the PreferredAddress struct shown in Figure 16. This 4526 transport parameter is only sent by a server. Servers MAY choose 4527 to only send a preferred address of one address family by sending 4528 an all-zero address and port (0.0.0.0:0 or ::.0) for the other 4529 family. 4531 struct { 4532 opaque ipv4Address[4]; 4533 uint16 ipv4Port; 4534 opaque ipv6Address[16]; 4535 uint16 ipv6Port; 4536 opaque connectionId<0..18>; 4537 opaque statelessResetToken[16]; 4538 } PreferredAddress; 4540 Figure 16: Preferred Address format 4542 If present, transport parameters that set initial flow control limits 4543 (initial_max_stream_data_bidi_local, 4544 initial_max_stream_data_bidi_remote, and initial_max_stream_data_uni) 4545 are equivalent to sending a MAX_STREAM_DATA frame (Section 19.10) on 4546 every stream of the corresponding type immediately after opening. If 4547 the transport parameter is absent, streams of that type start with a 4548 flow control limit of 0. 4550 A client MUST NOT include an original connection ID, a stateless 4551 reset token, or a preferred address. A server MUST treat receipt of 4552 any of these transport parameters as a connection error of type 4553 TRANSPORT_PARAMETER_ERROR. 4555 19. Frame Types and Formats 4557 As described in Section 12.4, packets contain one or more frames. 4558 This section describes the format and semantics of the core QUIC 4559 frame types. 4561 19.1. PADDING Frame 4563 The PADDING frame (type=0x00) has no semantic value. PADDING frames 4564 can be used to increase the size of a packet. Padding can be used to 4565 increase an initial client packet to the minimum required size, or to 4566 provide protection against traffic analysis for protected packets. 4568 A PADDING frame has no content. That is, a PADDING frame consists of 4569 the single byte that identifies the frame as a PADDING frame. 4571 19.2. PING Frame 4573 Endpoints can use PING frames (type=0x01) to verify that their peers 4574 are still alive or to check reachability to the peer. The PING frame 4575 contains no additional fields. 4577 The receiver of a PING frame simply needs to acknowledge the packet 4578 containing this frame. 4580 The PING frame can be used to keep a connection alive when an 4581 application or application protocol wishes to prevent the connection 4582 from timing out. An application protocol SHOULD provide guidance 4583 about the conditions under which generating a PING is recommended. 4584 This guidance SHOULD indicate whether it is the client or the server 4585 that is expected to send the PING. Having both endpoints send PING 4586 frames without coordination can produce an excessive number of 4587 packets and poor performance. 4589 A connection will time out if no packets are sent or received for a 4590 period longer than the time specified in the idle_timeout transport 4591 parameter (see Section 10). However, state in middleboxes might time 4592 out earlier than that. Though REQ-5 in [RFC4787] recommends a 2 4593 minute timeout interval, experience shows that sending packets every 4594 15 to 30 seconds is necessary to prevent the majority of middleboxes 4595 from losing state for UDP flows. 4597 19.3. ACK Frames 4599 Receivers send ACK frames (types 0x02 and 0x03) to inform senders of 4600 packets they have received and processed. The ACK frame contains one 4601 or more ACK Ranges. ACK Ranges identify acknowledged packets. If 4602 the frame type is 0x03, ACK frames also contain the sum of QUIC 4603 packets with associated ECN marks received on the connection up until 4604 this point. QUIC implementations MUST properly handle both types 4605 and, if they have enabled ECN for packets they send, they SHOULD use 4606 the information in the ECN section to manage their congestion state. 4608 QUIC acknowledgements are irrevocable. Once acknowledged, a packet 4609 remains acknowledged, even if it does not appear in a future ACK 4610 frame. This is unlike TCP SACKs ([RFC2018]). 4612 It is expected that a sender will reuse the same packet number across 4613 different packet number spaces. ACK frames only acknowledge the 4614 packet numbers that were transmitted by the sender in the same packet 4615 number space of the packet that the ACK was received in. 4617 Version Negotiation and Retry packets cannot be acknowledged because 4618 they do not contain a packet number. Rather than relying on ACK 4619 frames, these packets are implicitly acknowledged by the next Initial 4620 packet sent by the client. 4622 An ACK frame is as follows: 4624 0 1 2 3 4625 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 4626 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4627 | Largest Acknowledged (i) ... 4628 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4629 | ACK Delay (i) ... 4630 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4631 | ACK Range Count (i) ... 4632 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4633 | First ACK Range (i) ... 4634 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4635 | ACK Ranges (*) ... 4636 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4637 | [ECN Counts] ... 4638 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4640 Figure 17: ACK Frame Format 4642 ACK frames contain the following fields: 4644 Largest Acknowledged: A variable-length integer representing the 4645 largest packet number the peer is acknowledging; this is usually 4646 the largest packet number that the peer has received prior to 4647 generating the ACK frame. Unlike the packet number in the QUIC 4648 long or short header, the value in an ACK frame is not truncated. 4650 ACK Delay: A variable-length integer representing the time delta in 4651 microseconds between when this ACK was sent and when the largest 4652 acknowledged packet, as indicated in the Largest Acknowledged 4653 field, was received by this peer. The value of the ACK Delay 4654 field is scaled by multiplying the encoded value by 2 to the power 4655 of the value of the "ack_delay_exponent" transport parameter set 4656 by the sender of the ACK frame. The "ack_delay_exponent" defaults 4657 to 3, or a multiplier of 8 (see Section 18.1). Scaling in this 4658 fashion allows for a larger range of values with a shorter 4659 encoding at the cost of lower resolution. 4661 ACK Range Count: A variable-length integer specifying the number of 4662 Gap and ACK Range fields in the frame. 4664 First ACK Range: A variable-length integer indicating the number of 4665 contiguous packets preceding the Largest Acknowledged that are 4666 being acknowledged. The First ACK Range is encoded as an ACK 4667 Range (see Section 19.3.1) starting from the Largest Acknowledged. 4668 That is, the smallest packet acknowledged in the range is 4669 determined by subtracting the First ACK Range value from the 4670 Largest Acknowledged. 4672 ACK Ranges: Contains additional ranges of packets which are 4673 alternately not acknowledged (Gap) and acknowledged (ACK Range), 4674 see Section 19.3.1. 4676 ECN Counts: The three ECN Counts, see Section 19.3.2. 4678 19.3.1. ACK Ranges 4680 The ACK Ranges field consists of alternating Gap and ACK Range values 4681 in descending packet number order. The number of Gap and ACK Range 4682 values is determined by the ACK Range Count field; one of each value 4683 is present for each value in the ACK Range Count field. 4685 ACK Ranges are structured as follows: 4687 0 1 2 3 4688 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 4689 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4690 | [Gap (i)] ... 4691 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4692 | [ACK Range (i)] ... 4693 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4694 | [Gap (i)] ... 4695 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4696 | [ACK Range (i)] ... 4697 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4698 ... 4699 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4700 | [Gap (i)] ... 4701 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4702 | [ACK Range (i)] ... 4703 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4705 Figure 18: ACK Ranges 4707 The fields that form the ACK Ranges are: 4709 Gap (repeated): A variable-length integer indicating the number of 4710 contiguous unacknowledged packets preceding the packet number one 4711 lower than the smallest in the preceding ACK Range. 4713 ACK Range (repeated): A variable-length integer indicating the 4714 number of contiguous acknowledged packets preceding the largest 4715 packet number, as determined by the preceding Gap. 4717 Gap and ACK Range value use a relative integer encoding for 4718 efficiency. Though each encoded value is positive, the values are 4719 subtracted, so that each ACK Range describes progressively lower- 4720 numbered packets. 4722 Each ACK Range acknowledges a contiguous range of packets by 4723 indicating the number of acknowledged packets that precede the 4724 largest packet number in that range. A value of zero indicates that 4725 only the largest packet number is acknowledged. Larger ACK Range 4726 values indicate a larger range, with corresponding lower values for 4727 the smallest packet number in the range. Thus, given a largest 4728 packet number for the range, the smallest value is determined by the 4729 formula: 4731 smallest = largest - ack_range 4733 An ACK Range acknowledges all packets between the smallest packet 4734 number and the largest, inclusive. 4736 The largest value for an ACK Range is determined by cumulatively 4737 subtracting the size of all preceding ACK Ranges and Gaps. 4739 Each Gap indicates a range of packets that are not being 4740 acknowledged. The number of packets in the gap is one higher than 4741 the encoded value of the Gap field. 4743 The value of the Gap field establishes the largest packet number 4744 value for the subsequent ACK Range using the following formula: 4746 largest = previous_smallest - gap - 2 4748 If any computed packet number is negative, an endpoint MUST generate 4749 a connection error of type FRAME_ENCODING_ERROR indicating an error 4750 in an ACK frame. 4752 19.3.2. ECN Counts 4754 The ACK frame uses the least significant bit (that is, type 0x03) to 4755 indicate ECN feedback and report receipt of QUIC packets with 4756 associated ECN codepoints of ECT(0), ECT(1), or CE in the packet's IP 4757 header. ECN Counts are only present when the ACK frame type is 0x03. 4759 ECN Counts are only parsed when the ACK frame type is 0x03. There 4760 are 3 ECN counts, as follows: 4762 0 1 2 3 4763 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 4764 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4765 | ECT(0) Count (i) ... 4766 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4767 | ECT(1) Count (i) ... 4768 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4769 | ECN-CE Count (i) ... 4770 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4772 The three ECN Counts are: 4774 ECT(0) Count: A variable-length integer representing the total 4775 number of packets received with the ECT(0) codepoint. 4777 ECT(1) Count: A variable-length integer representing the total 4778 number of packets received with the ECT(1) codepoint. 4780 CE Count: A variable-length integer representing the total number of 4781 packets received with the CE codepoint. 4783 ECN counts are maintained separately for each packet number space. 4785 19.4. RESET_STREAM Frame 4787 An endpoint uses a RESET_STREAM frame (type=0x04) to abruptly 4788 terminate the sending part of a stream. 4790 After sending a RESET_STREAM, an endpoint ceases transmission and 4791 retransmission of STREAM frames on the identified stream. A receiver 4792 of RESET_STREAM can discard any data that it already received on that 4793 stream. 4795 An endpoint that receives a RESET_STREAM frame for a send-only stream 4796 MUST terminate the connection with error STREAM_STATE_ERROR. 4798 The RESET_STREAM frame is as follows: 4800 0 1 2 3 4801 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 4802 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4803 | Stream ID (i) ... 4804 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4805 | Application Error Code (16) | 4806 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4807 | Final Size (i) ... 4808 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4809 RESET_STREAM frames contain the following fields: 4811 Stream ID: A variable-length integer encoding of the Stream ID of 4812 the stream being terminated. 4814 Application Protocol Error Code: A 16-bit application protocol error 4815 code (see Section 20.1) which indicates why the stream is being 4816 closed. 4818 Final Size: A variable-length integer indicating the final size of 4819 the stream by the RESET_STREAM sender, in unit of bytes. 4821 19.5. STOP_SENDING Frame 4823 An endpoint uses a STOP_SENDING frame (type=0x05) to communicate that 4824 incoming data is being discarded on receipt at application request. 4825 STOP_SENDING requests that a peer cease transmission on a stream. 4827 A STOP_SENDING frame can be sent for streams in the Recv or Size 4828 Known states (see Section 3.1). Receiving a STOP_SENDING frame for a 4829 locally-initiated stream that has not yet been created MUST be 4830 treated as a connection error of type STREAM_STATE_ERROR. An 4831 endpoint that receives a STOP_SENDING frame for a receive-only stream 4832 MUST terminate the connection with error STREAM_STATE_ERROR. 4834 The STOP_SENDING frame is as follows: 4836 0 1 2 3 4837 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 4838 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4839 | Stream ID (i) ... 4840 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4841 | Application Error Code (16) | 4842 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4844 STOP_SENDING frames contain the following fields: 4846 Stream ID: A variable-length integer carrying the Stream ID of the 4847 stream being ignored. 4849 Application Error Code: A 16-bit, application-specified reason the 4850 sender is ignoring the stream (see Section 20.1). 4852 19.6. CRYPTO Frame 4854 The CRYPTO frame (type=0x06) is used to transmit cryptographic 4855 handshake messages. It can be sent in all packet types. The CRYPTO 4856 frame offers the cryptographic protocol an in-order stream of bytes. 4858 CRYPTO frames are functionally identical to STREAM frames, except 4859 that they do not bear a stream identifier; they are not flow 4860 controlled; and they do not carry markers for optional offset, 4861 optional length, and the end of the stream. 4863 The CRYPTO frame is as follows: 4865 0 1 2 3 4866 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 4867 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4868 | Offset (i) ... 4869 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4870 | Length (i) ... 4871 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4872 | Crypto Data (*) ... 4873 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4875 Figure 19: CRYPTO Frame Format 4877 CRYPTO frames contain the following fields: 4879 Offset: A variable-length integer specifying the byte offset in the 4880 stream for the data in this CRYPTO frame. 4882 Length: A variable-length integer specifying the length of the 4883 Crypto Data field in this CRYPTO frame. 4885 Crypto Data: The cryptographic message data. 4887 There is a separate flow of cryptographic handshake data in each 4888 encryption level, each of which starts at an offset of 0. This 4889 implies that each encryption level is treated as a separate CRYPTO 4890 stream of data. 4892 Unlike STREAM frames, which include a Stream ID indicating to which 4893 stream the data belongs, the CRYPTO frame carries data for a single 4894 stream per encryption level. The stream does not have an explicit 4895 end, so CRYPTO frames do not have a FIN bit. 4897 19.7. NEW_TOKEN Frame 4899 A server sends a NEW_TOKEN frame (type=0x07) to provide the client 4900 with a token to send in the header of an Initial packet for a future 4901 connection. 4903 The NEW_TOKEN frame is as follows: 4905 0 1 2 3 4906 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 4907 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4908 | Token Length (i) ... 4909 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4910 | Token (*) ... 4911 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4913 NEW_TOKEN frames contain the following fields: 4915 Token Length: A variable-length integer specifying the length of the 4916 token in bytes. 4918 Token: An opaque blob that the client may use with a future Initial 4919 packet. 4921 19.8. STREAM Frames 4923 STREAM frames implicitly create a stream and carry stream data. The 4924 STREAM frame takes the form 0b00001XXX (or the set of values from 4925 0x08 to 0x0f). The value of the three low-order bits of the frame 4926 type determine the fields that are present in the frame. 4928 o The OFF bit (0x04) in the frame type is set to indicate that there 4929 is an Offset field present. When set to 1, the Offset field is 4930 present. When set to 0, the Offset field is absent and the Stream 4931 Data starts at an offset of 0 (that is, the frame contains the 4932 first bytes of the stream, or the end of a stream that includes no 4933 data). 4935 o The LEN bit (0x02) in the frame type is set to indicate that there 4936 is a Length field present. If this bit is set to 0, the Length 4937 field is absent and the Stream Data field extends to the end of 4938 the packet. If this bit is set to 1, the Length field is present. 4940 o The FIN bit (0x01) of the frame type is set only on frames that 4941 contain the final size of the stream. Setting this bit indicates 4942 that the frame marks the end of the stream. 4944 An endpoint that receives a STREAM frame for a send-only stream MUST 4945 terminate the connection with error STREAM_STATE_ERROR. 4947 The STREAM frames are as follows: 4949 0 1 2 3 4950 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 4951 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4952 | Stream ID (i) ... 4953 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4954 | [Offset (i)] ... 4955 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4956 | [Length (i)] ... 4957 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4958 | Stream Data (*) ... 4959 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4961 Figure 20: STREAM Frame Format 4963 STREAM frames contain the following fields: 4965 Stream ID: A variable-length integer indicating the stream ID of the 4966 stream (see Section 2.1). 4968 Offset: A variable-length integer specifying the byte offset in the 4969 stream for the data in this STREAM frame. This field is present 4970 when the OFF bit is set to 1. When the Offset field is absent, 4971 the offset is 0. 4973 Length: A variable-length integer specifying the length of the 4974 Stream Data field in this STREAM frame. This field is present 4975 when the LEN bit is set to 1. When the LEN bit is set to 0, the 4976 Stream Data field consumes all the remaining bytes in the packet. 4978 Stream Data: The bytes from the designated stream to be delivered. 4980 When a Stream Data field has a length of 0, the offset in the STREAM 4981 frame is the offset of the next byte that would be sent. 4983 The first byte in the stream has an offset of 0. The largest offset 4984 delivered on a stream - the sum of the offset and data length - 4985 cannot exceed 2^62-1, as it is not possible to provide flow control 4986 credit for that data. Receipt of a frame that exceeds this limit 4987 will be treated as a connection error of type FLOW_CONTROL_ERROR. 4989 19.9. MAX_DATA Frame 4991 The MAX_DATA frame (type=0x10) is used in flow control to inform the 4992 peer of the maximum amount of data that can be sent on the connection 4993 as a whole. 4995 The MAX_DATA frame is as follows: 4997 0 1 2 3 4998 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 4999 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5000 | Maximum Data (i) ... 5001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5003 MAX_DATA frames contain the following fields: 5005 Maximum Data: A variable-length integer indicating the maximum 5006 amount of data that can be sent on the entire connection, in units 5007 of bytes. 5009 All data sent in STREAM frames counts toward this limit. The sum of 5010 the largest received offsets on all streams - including streams in 5011 terminal states - MUST NOT exceed the value advertised by a receiver. 5012 An endpoint MUST terminate a connection with a FLOW_CONTROL_ERROR 5013 error if it receives more data than the maximum data value that it 5014 has sent, unless this is a result of a change in the initial limits 5015 (see Section 7.3.1). 5017 19.10. MAX_STREAM_DATA Frame 5019 The MAX_STREAM_DATA frame (type=0x11) is used in flow control to 5020 inform a peer of the maximum amount of data that can be sent on a 5021 stream. 5023 A MAX_STREAM_DATA frame can be sent for streams in the Recv state 5024 (see Section 3.1). Receiving a MAX_STREAM_DATA frame for a locally- 5025 initiated stream that has not yet been created MUST be treated as a 5026 connection error of type STREAM_STATE_ERROR. An endpoint that 5027 receives a MAX_STREAM_DATA frame for a receive-only stream MUST 5028 terminate the connection with error STREAM_STATE_ERROR. 5030 The MAX_STREAM_DATA frame is as follows: 5032 0 1 2 3 5033 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 5034 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5035 | Stream ID (i) ... 5036 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5037 | Maximum Stream Data (i) ... 5038 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5040 MAX_STREAM_DATA frames contain the following fields: 5042 Stream ID: The stream ID of the stream that is affected encoded as a 5043 variable-length integer. 5045 Maximum Stream Data: A variable-length integer indicating the 5046 maximum amount of data that can be sent on the identified stream, 5047 in units of bytes. 5049 When counting data toward this limit, an endpoint accounts for the 5050 largest received offset of data that is sent or received on the 5051 stream. Loss or reordering can mean that the largest received offset 5052 on a stream can be greater than the total size of data received on 5053 that stream. Receiving STREAM frames might not increase the largest 5054 received offset. 5056 The data sent on a stream MUST NOT exceed the largest maximum stream 5057 data value advertised by the receiver. An endpoint MUST terminate a 5058 connection with a FLOW_CONTROL_ERROR error if it receives more data 5059 than the largest maximum stream data that it has sent for the 5060 affected stream, unless this is a result of a change in the initial 5061 limits (see Section 7.3.1). 5063 19.11. MAX_STREAMS Frames 5065 The MAX_STREAMS frames (type=0x12 and 0x13) inform the peer of the 5066 cumulative number of streams of a given type it is permitted to open. 5067 A MAX_STREAMS frame with a type of 0x12 applies to bidirectional 5068 streams, and a MAX_STREAMS frame with a type of 0x13 applies to 5069 unidirectional streams. 5071 The MAX_STREAMS frames are as follows: 5073 0 1 2 3 5074 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 5075 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5076 | Maximum Streams (i) ... 5077 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5079 MAX_STREAMS frames contain the following fields: 5081 Maximum Streams: A count of the cumulative number of streams of the 5082 corresponding type that can be opened over the lifetime of the 5083 connection. 5085 Loss or reordering can cause a MAX_STREAMS frame to be received which 5086 states a lower stream limit than an endpoint has previously received. 5087 MAX_STREAMS frames which do not increase the stream limit MUST be 5088 ignored. 5090 An endpoint MUST NOT open more streams than permitted by the current 5091 stream limit set by its peer. For instance, a server that receives a 5092 unidirectional stream limit of 3 is permitted to open stream 3, 7, 5093 and 11, but not stream 15. An endpoint MUST terminate a connection 5094 with a STREAM_LIMIT_ERROR error if a peer opens more streams than was 5095 permitted. 5097 Note that these frames (and the corresponding transport parameters) 5098 do not describe the number of streams that can be opened 5099 concurrently. The limit includes streams that have been closed as 5100 well as those that are open. 5102 19.12. DATA_BLOCKED Frame 5104 A sender SHOULD send a DATA_BLOCKED frame (type=0x14) when it wishes 5105 to send data, but is unable to due to connection-level flow control 5106 (see Section 4). DATA_BLOCKED frames can be used as input to tuning 5107 of flow control algorithms (see Section 4.2). 5109 The DATA_BLOCKED frame is as follows: 5111 0 1 2 3 5112 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 5113 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5114 | Data Limit (i) ... 5115 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5117 DATA_BLOCKED frames contain the following fields: 5119 Data Limit: A variable-length integer indicating the connection- 5120 level limit at which blocking occurred. 5122 19.13. STREAM_DATA_BLOCKED Frame 5124 A sender SHOULD send a STREAM_DATA_BLOCKED frame (type=0x15) when it 5125 wishes to send data, but is unable to due to stream-level flow 5126 control. This frame is analogous to DATA_BLOCKED (Section 19.12). 5128 An endpoint that receives a STREAM_DATA_BLOCKED frame for a send-only 5129 stream MUST terminate the connection with error STREAM_STATE_ERROR. 5131 The STREAM_DATA_BLOCKED frame is as follows: 5133 0 1 2 3 5134 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 5135 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5136 | Stream ID (i) ... 5137 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5138 | Stream Data Limit (i) ... 5139 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5140 STREAM_DATA_BLOCKED frames contain the following fields: 5142 Stream ID: A variable-length integer indicating the stream which is 5143 flow control blocked. 5145 Stream Data Limit: A variable-length integer indicating the offset 5146 of the stream at which the blocking occurred. 5148 19.14. STREAMS_BLOCKED Frames 5150 A sender SHOULD send a STREAMS_BLOCKED frame (type=0x16 or 0x17) when 5151 it wishes to open a stream, but is unable to due to the maximum 5152 stream limit set by its peer (see Section 19.11). A STREAMS_BLOCKED 5153 frame of type 0x16 is used to indicate reaching the bidirectional 5154 stream limit, and a STREAMS_BLOCKED frame of type 0x17 indicates 5155 reaching the unidirectional stream limit. 5157 A STREAMS_BLOCKED frame does not open the stream, but informs the 5158 peer that a new stream was needed and the stream limit prevented the 5159 creation of the stream. 5161 The STREAMS_BLOCKED frames are as follows: 5163 0 1 2 3 5164 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 5165 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5166 | Stream Limit (i) ... 5167 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5169 STREAMS_BLOCKED frames contain the following fields: 5171 Stream Limit: A variable-length integer indicating the stream limit 5172 at the time the frame was sent. 5174 19.15. NEW_CONNECTION_ID Frame 5176 An endpoint sends a NEW_CONNECTION_ID frame (type=0x18) to provide 5177 its peer with alternative connection IDs that can be used to break 5178 linkability when migrating connections (see Section 9.5). 5180 The NEW_CONNECTION_ID frame is as follows: 5182 0 1 2 3 5183 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 5184 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5185 | Sequence Number (i) ... 5186 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5187 | Length (8) | | 5188 +-+-+-+-+-+-+-+-+ Connection ID (32..144) + 5189 | ... 5190 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5191 | | 5192 + + 5193 | | 5194 + Stateless Reset Token (128) + 5195 | | 5196 + + 5197 | | 5198 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5200 NEW_CONNECTION_ID frames contain the following fields: 5202 Sequence Number: The sequence number assigned to the connection ID 5203 by the sender. See Section 5.1.1. 5205 Length: An 8-bit unsigned integer containing the length of the 5206 connection ID. Values less than 4 and greater than 18 are invalid 5207 and MUST be treated as a connection error of type 5208 PROTOCOL_VIOLATION. 5210 Connection ID: A connection ID of the specified length. 5212 Stateless Reset Token: A 128-bit value that will be used for a 5213 stateless reset when the associated connection ID is used (see 5214 Section 10.4). 5216 An endpoint MUST NOT send this frame if it currently requires that 5217 its peer send packets with a zero-length Destination Connection ID. 5218 Changing the length of a connection ID to or from zero-length makes 5219 it difficult to identify when the value of the connection ID changed. 5220 An endpoint that is sending packets with a zero-length Destination 5221 Connection ID MUST treat receipt of a NEW_CONNECTION_ID frame as a 5222 connection error of type PROTOCOL_VIOLATION. 5224 Transmission errors, timeouts and retransmissions might cause the 5225 same NEW_CONNECTION_ID frame to be received multiple times. Receipt 5226 of the same frame multiple times MUST NOT be treated as a connection 5227 error. A receiver can use the sequence number supplied in the 5228 NEW_CONNECTION_ID frame to identify new connection IDs from old ones. 5230 If an endpoint receives a NEW_CONNECTION_ID frame that repeats a 5231 previously issued connection ID with a different Stateless Reset 5232 Token or a different sequence number, or if a sequence number is used 5233 for different connection IDs, the endpoint MAY treat that receipt as 5234 a connection error of type PROTOCOL_VIOLATION. 5236 19.16. RETIRE_CONNECTION_ID Frame 5238 An endpoint sends a RETIRE_CONNECTION_ID frame (type=0x19) to 5239 indicate that it will no longer use a connection ID that was issued 5240 by its peer. This may include the connection ID provided during the 5241 handshake. Sending a RETIRE_CONNECTION_ID frame also serves as a 5242 request to the peer to send additional connection IDs for future use 5243 (see Section 5.1). New connection IDs can be delivered to a peer 5244 using the NEW_CONNECTION_ID frame (Section 19.15). 5246 Retiring a connection ID invalidates the stateless reset token 5247 associated with that connection ID. 5249 The RETIRE_CONNECTION_ID frame is as follows: 5251 0 1 2 3 5252 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 5253 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5254 | Sequence Number (i) ... 5255 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5257 RETIRE_CONNECTION_ID frames contain the following fields: 5259 Sequence Number: The sequence number of the connection ID being 5260 retired. See Section 5.1.2. 5262 Receipt of a RETIRE_CONNECTION_ID frame containing a sequence number 5263 greater than any previously sent to the peer MAY be treated as a 5264 connection error of type PROTOCOL_VIOLATION. 5266 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST 5267 NOT refer to the Destination Connection ID field of the packet in 5268 which the frame is contained. The peer MAY treat this as a 5269 connection error of type PROTOCOL_VIOLATION. 5271 An endpoint cannot send this frame if it was provided with a zero- 5272 length connection ID by its peer. An endpoint that provides a zero- 5273 length connection ID MUST treat receipt of a RETIRE_CONNECTION_ID 5274 frame as a connection error of type PROTOCOL_VIOLATION. 5276 19.17. PATH_CHALLENGE Frame 5278 Endpoints can use PATH_CHALLENGE frames (type=0x1a) to check 5279 reachability to the peer and for path validation during connection 5280 migration. 5282 The PATH_CHALLENGE frames are as follows: 5284 0 1 2 3 5285 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 5286 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5287 | | 5288 + Data (64) + 5289 | | 5290 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5292 PATH_CHALLENGE frames contain the following fields: 5294 Data: This 8-byte field contains arbitrary data. 5296 A PATH_CHALLENGE frame containing 8 bytes that are hard to guess is 5297 sufficient to ensure that it is easier to receive the packet than it 5298 is to guess the value correctly. 5300 The recipient of this frame MUST generate a PATH_RESPONSE frame 5301 (Section 19.18) containing the same Data. 5303 19.18. PATH_RESPONSE Frame 5305 The PATH_RESPONSE frame (type=0x1b) is sent in response to a 5306 PATH_CHALLENGE frame. Its format is identical to the PATH_CHALLENGE 5307 frame (Section 19.17). 5309 If the content of a PATH_RESPONSE frame does not match the content of 5310 a PATH_CHALLENGE frame previously sent by the endpoint, the endpoint 5311 MAY generate a connection error of type PROTOCOL_VIOLATION. 5313 19.19. CONNECTION_CLOSE Frames 5315 An endpoint sends a CONNECTION_CLOSE frame (type=0x1c or 0x1d) to 5316 notify its peer that the connection is being closed. The 5317 CONNECTION_CLOSE with a frame type of 0x1c is used to signal errors 5318 at only the QUIC layer, or the absence of errors (with the NO_ERROR 5319 code). The CONNECTION_CLOSE frame with a type of 0x1d is used to 5320 signal an error with the application that uses QUIC. 5322 If there are open streams that haven't been explicitly closed, they 5323 are implicitly closed when the connection is closed. 5325 The CONNECTION_CLOSE frames are as follows: 5327 0 1 2 3 5328 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 5329 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5330 | Error Code (16) | [ Frame Type (i) ] ... 5331 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5332 | Reason Phrase Length (i) ... 5333 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5334 | Reason Phrase (*) ... 5335 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5337 CONNECTION_CLOSE frames contain the following fields: 5339 Error Code: A 16-bit error code which indicates the reason for 5340 closing this connection. A CONNECTION_CLOSE frame of type 0x1c 5341 uses codes from the space defined in Section 20. A 5342 CONNECTION_CLOSE frame of type 0x1d uses codes from the 5343 application protocol error code space, see Section 20.1 5345 Frame Type: A variable-length integer encoding the type of frame 5346 that triggered the error. A value of 0 (equivalent to the mention 5347 of the PADDING frame) is used when the frame type is unknown. The 5348 application-specific variant of CONNECTION_CLOSE (type 0x1d) does 5349 not include this field. 5351 Reason Phrase Length: A variable-length integer specifying the 5352 length of the reason phrase in bytes. Because a CONNECTION_CLOSE 5353 frame cannot be split between packets, any limits on packet size 5354 will also limit the space available for a reason phrase. 5356 Reason Phrase: A human-readable explanation for why the connection 5357 was closed. This can be zero length if the sender chooses to not 5358 give details beyond the Error Code. This SHOULD be a UTF-8 5359 encoded string [RFC3629]. 5361 19.20. Extension Frames 5363 QUIC frames do not use a self-describing encoding. An endpoint 5364 therefore needs to understand the syntax of all frames before it can 5365 successfully process a packet. This allows for efficient encoding of 5366 frames, but it means that an endpoint cannot send a frame of a type 5367 that is unknown to its peer. 5369 An extension to QUIC that wishes to use a new type of frame MUST 5370 first ensure that a peer is able to understand the frame. An 5371 endpoint can use a transport parameter to signal its willingness to 5372 receive one or more extension frame types with the one transport 5373 parameter. 5375 Extension frames MUST be congestion controlled and MUST cause an ACK 5376 frame to be sent. The exception is extension frames that replace or 5377 supplement the ACK frame. Extension frames are not included in flow 5378 control unless specified in the extension. 5380 An IANA registry is used to manage the assignment of frame types, see 5381 Section 22.2. 5383 20. Transport Error Codes 5385 QUIC error codes are 16-bit unsigned integers. 5387 This section lists the defined QUIC transport error codes that may be 5388 used in a CONNECTION_CLOSE frame. These errors apply to the entire 5389 connection. 5391 NO_ERROR (0x0): An endpoint uses this with CONNECTION_CLOSE to 5392 signal that the connection is being closed abruptly in the absence 5393 of any error. 5395 INTERNAL_ERROR (0x1): The endpoint encountered an internal error and 5396 cannot continue with the connection. 5398 SERVER_BUSY (0x2): The server is currently busy and does not accept 5399 any new connections. 5401 FLOW_CONTROL_ERROR (0x3): An endpoint received more data than it 5402 permitted in its advertised data limits (see Section 4). 5404 STREAM_LIMIT_ERROR (0x4): An endpoint received a frame for a stream 5405 identifier that exceeded its advertised stream limit for the 5406 corresponding stream type. 5408 STREAM_STATE_ERROR (0x5): An endpoint received a frame for a stream 5409 that was not in a state that permitted that frame (see Section 3). 5411 FINAL_SIZE_ERROR (0x6): An endpoint received a STREAM frame 5412 containing data that exceeded the previously established final 5413 size. Or an endpoint received a STREAM frame or a RESET_STREAM 5414 frame containing a final size that was lower than the size of 5415 stream data that was already received. Or an endpoint received a 5416 STREAM frame or a RESET_STREAM frame containing a different final 5417 size to the one already established. 5419 FRAME_ENCODING_ERROR (0x7): An endpoint received a frame that was 5420 badly formatted. For instance, a frame of an unknown type, or an 5421 ACK frame that has more acknowledgment ranges than the remainder 5422 of the packet could carry. 5424 TRANSPORT_PARAMETER_ERROR (0x8): An endpoint received transport 5425 parameters that were badly formatted, included an invalid value, 5426 was absent even though it is mandatory, was present though it is 5427 forbidden, or is otherwise in error. 5429 PROTOCOL_VIOLATION (0xA): An endpoint detected an error with 5430 protocol compliance that was not covered by more specific error 5431 codes. 5433 INVALID_MIGRATION (0xC): A peer has migrated to a different network 5434 when the endpoint had disabled migration. 5436 CRYPTO_BUFFER_EXCEEDED (0xD): An endpoint has received more data in 5437 CRYPTO frames than it can buffer. 5439 CRYPTO_ERROR (0x1XX): The cryptographic handshake failed. A range 5440 of 256 values is reserved for carrying error codes specific to the 5441 cryptographic handshake that is used. Codes for errors occurring 5442 when TLS is used for the crypto handshake are described in 5443 Section 4.8 of [QUIC-TLS]. 5445 See Section 22.3 for details of registering new error codes. 5447 20.1. Application Protocol Error Codes 5449 Application protocol error codes are 16-bit unsigned integers, but 5450 the management of application error codes are left to application 5451 protocols. Application protocol error codes are used for the 5452 RESET_STREAM frame (Section 19.4), the STOP_SENDING frame 5453 (Section 19.5), and the CONNECTION_CLOSE frame with a type of 0x1d 5454 (Section 19.19). 5456 21. Security Considerations 5458 21.1. Handshake Denial of Service 5460 As an encrypted and authenticated transport QUIC provides a range of 5461 protections against denial of service. Once the cryptographic 5462 handshake is complete, QUIC endpoints discard most packets that are 5463 not authenticated, greatly limiting the ability of an attacker to 5464 interfere with existing connections. 5466 Once a connection is established QUIC endpoints might accept some 5467 unauthenticated ICMP packets (see Section 14.2), but the use of these 5468 packets is extremely limited. The only other type of packet that an 5469 endpoint might accept is a stateless reset (Section 10.4) which 5470 relies on the token being kept secret until it is used. 5472 During the creation of a connection, QUIC only provides protection 5473 against attack from off the network path. All QUIC packets contain 5474 proof that the recipient saw a preceding packet from its peer. 5476 The first mechanism used is the source and destination connection 5477 IDs, which are required to match those set by a peer. Except for an 5478 Initial and stateless reset packets, an endpoint only accepts packets 5479 that include a destination connection that matches a connection ID 5480 the endpoint previously chose. This is the only protection offered 5481 for Version Negotiation packets. 5483 The destination connection ID in an Initial packet is selected by a 5484 client to be unpredictable, which serves an additional purpose. The 5485 packets that carry the cryptographic handshake are protected with a 5486 key that is derived from this connection ID and salt specific to the 5487 QUIC version. This allows endpoints to use the same process for 5488 authenticating packets that they receive as they use after the 5489 cryptographic handshake completes. Packets that cannot be 5490 authenticated are discarded. Protecting packets in this fashion 5491 provides a strong assurance that the sender of the packet saw the 5492 Initial packet and understood it. 5494 These protections are not intended to be effective against an 5495 attacker that is able to receive QUIC packets prior to the connection 5496 being established. Such an attacker can potentially send packets 5497 that will be accepted by QUIC endpoints. This version of QUIC 5498 attempts to detect this sort of attack, but it expects that endpoints 5499 will fail to establish a connection rather than recovering. For the 5500 most part, the cryptographic handshake protocol [QUIC-TLS] is 5501 responsible for detecting tampering during the handshake. 5503 Endpoints are permitted to use other methods to detect and attempt to 5504 recover from interference with the handshake. Invalid packets may be 5505 identified and discarded using other methods, but no specific method 5506 is mandated in this document. 5508 21.2. Amplification Attack 5510 An attacker might be able to receive an address validation token 5511 (Section 8) from a server and then release the IP address it used to 5512 acquire that token. At a later time, the attacker may initiate a 5513 0-RTT connection with a server by spoofing this same address, which 5514 might now address a different (victim) endpoint. The attacker can 5515 thus potentially cause the server to send an initial congestion 5516 window's worth of data towards the victim. 5518 Servers SHOULD provide mitigations for this attack by limiting the 5519 usage and lifetime of address validation tokens (see Section 8.1.2). 5521 21.3. Optimistic ACK Attack 5523 An endpoint that acknowledges packets it has not received might cause 5524 a congestion controller to permit sending at rates beyond what the 5525 network supports. An endpoint MAY skip packet numbers when sending 5526 packets to detect this behavior. An endpoint can then immediately 5527 close the connection with a connection error of type 5528 PROTOCOL_VIOLATION (see Section 10.3). 5530 21.4. Slowloris Attacks 5532 The attacks commonly known as Slowloris [SLOWLORIS] try to keep many 5533 connections to the target endpoint open and hold them open as long as 5534 possible. These attacks can be executed against a QUIC endpoint by 5535 generating the minimum amount of activity necessary to avoid being 5536 closed for inactivity. This might involve sending small amounts of 5537 data, gradually opening flow control windows in order to control the 5538 sender rate, or manufacturing ACK frames that simulate a high loss 5539 rate. 5541 QUIC deployments SHOULD provide mitigations for the Slowloris 5542 attacks, such as increasing the maximum number of clients the server 5543 will allow, limiting the number of connections a single IP address is 5544 allowed to make, imposing restrictions on the minimum transfer speed 5545 a connection is allowed to have, and restricting the length of time 5546 an endpoint is allowed to stay connected. 5548 21.5. Stream Fragmentation and Reassembly Attacks 5550 An adversarial sender might intentionally send fragments of stream 5551 data in order to cause disproportionate receive buffer memory 5552 commitment and/or creation of a large and inefficient data structure. 5554 An adversarial receiver might intentionally not acknowledge packets 5555 containing stream data in order to force the sender to store the 5556 unacknowledged stream data for retransmission. 5558 The attack on receivers is mitigated if flow control windows 5559 correspond to available memory. However, some receivers will over- 5560 commit memory and advertise flow control offsets in the aggregate 5561 that exceed actual available memory. The over-commitment strategy 5562 can lead to better performance when endpoints are well behaved, but 5563 renders endpoints vulnerable to the stream fragmentation attack. 5565 QUIC deployments SHOULD provide mitigations against stream 5566 fragmentation attacks. Mitigations could consist of avoiding over- 5567 committing memory, limiting the size of tracking data structures, 5568 delaying reassembly of STREAM frames, implementing heuristics based 5569 on the age and duration of reassembly holes, or some combination. 5571 21.6. Stream Commitment Attack 5573 An adversarial endpoint can open lots of streams, exhausting state on 5574 an endpoint. The adversarial endpoint could repeat the process on a 5575 large number of connections, in a manner similar to SYN flooding 5576 attacks in TCP. 5578 Normally, clients will open streams sequentially, as explained in 5579 Section 2.1. However, when several streams are initiated at short 5580 intervals, transmission error may cause STREAM DATA frames opening 5581 streams to be received out of sequence. A receiver is obligated to 5582 open intervening streams if a higher-numbered stream ID is received. 5583 Thus, on a new connection, opening stream 2000001 opens 1 million 5584 streams, as required by the specification. 5586 The number of active streams is limited by the 5587 initial_max_streams_bidi and initial_max_streams_uni transport 5588 parameters, as explained in Section 4.5. If chosen judiciously, 5589 these limits mitigate the effect of the stream commitment attack. 5590 However, setting the limit too low could affect performance when 5591 applications expect to open large number of streams. 5593 21.7. Explicit Congestion Notification Attacks 5595 An on-path attacker could manipulate the value of ECN codepoints in 5596 the IP header to influence the sender's rate. [RFC3168] discusses 5597 manipulations and their effects in more detail. 5599 An on-the-side attacker can duplicate and send packets with modified 5600 ECN codepoints to affect the sender's rate. If duplicate packets are 5601 discarded by a receiver, an off-path attacker will need to race the 5602 duplicate packet against the original to be successful in this 5603 attack. Therefore, QUIC receivers ignore ECN codepoints set in 5604 duplicate packets (see Section 13.3). 5606 21.8. Stateless Reset Oracle 5608 Stateless resets create a possible denial of service attack analogous 5609 to a TCP reset injection. This attack is possible if an attacker is 5610 able to cause a stateless reset token to be generated for a 5611 connection with a selected connection ID. An attacker that can cause 5612 this token to be generated can reset an active connection with the 5613 same connection ID. 5615 If a packet can be routed to different instances that share a static 5616 key, for example by changing an IP address or port, then an attacker 5617 can cause the server to send a stateless reset. To defend against 5618 this style of denial service, endpoints that share a static key for 5619 stateless reset (see Section 10.4.2) MUST be arranged so that packets 5620 with a given connection ID always arrive at an instance that has 5621 connection state, unless that connection is no longer active. 5623 In the case of a cluster that uses dynamic load balancing, it's 5624 possible that a change in load balancer configuration could happen 5625 while an active instance retains connection state; even if an 5626 instance retains connection state, the change in routing and 5627 resulting stateless reset will result in the connection being 5628 terminated. If there is no chance in the packet being routed to the 5629 correct instance, it is better to send a stateless reset than wait 5630 for connections to time out. However, this is acceptable only if the 5631 routing cannot be influenced by an attacker. 5633 21.9. Version Downgrade 5635 This document defines QUIC Version Negotiation packets Section 6, 5636 which can be used to negotiate the QUIC version used between two 5637 endpoints. However, this document does not specify how this 5638 negotiation will be performed between this version and subsequent 5639 future versions. In particular, Version Negotiation packets do not 5640 contain any mechanism to prevent version downgrade attacks. Future 5641 versions of QUIC that use Version Negotiation packets MUST define a 5642 mechanism that is robust against version downgrade attacks. 5644 22. IANA Considerations 5646 22.1. QUIC Transport Parameter Registry 5648 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 5649 under a "QUIC Protocol" heading. 5651 The "QUIC Transport Parameters" registry governs a 16-bit space. 5652 This space is split into two spaces that are governed by different 5653 policies. Values with the first byte in the range 0x00 to 0xfe (in 5654 hexadecimal) are assigned via the Specification Required policy 5655 [RFC8126]. Values with the first byte 0xff are reserved for Private 5656 Use [RFC8126]. 5658 Registrations MUST include the following fields: 5660 Value: The numeric value of the assignment (registrations will be 5661 between 0x0000 and 0xfeff). 5663 Parameter Name: A short mnemonic for the parameter. 5665 Specification: A reference to a publicly available specification for 5666 the value. 5668 The nominated expert(s) verify that a specification exists and is 5669 readily accessible. Expert(s) are encouraged to be biased towards 5670 approving registrations unless they are abusive, frivolous, or 5671 actively harmful (not merely aesthetically displeasing, or 5672 architecturally dubious). 5674 The initial contents of this registry are shown in Table 6. 5676 +--------+-------------------------------------+---------------+ 5677 | Value | Parameter Name | Specification | 5678 +--------+-------------------------------------+---------------+ 5679 | 0x0000 | original_connection_id | Section 18.1 | 5680 | | | | 5681 | 0x0001 | idle_timeout | Section 18.1 | 5682 | | | | 5683 | 0x0002 | stateless_reset_token | Section 18.1 | 5684 | | | | 5685 | 0x0003 | max_packet_size | Section 18.1 | 5686 | | | | 5687 | 0x0004 | initial_max_data | Section 18.1 | 5688 | | | | 5689 | 0x0005 | initial_max_stream_data_bidi_local | Section 18.1 | 5690 | | | | 5691 | 0x0006 | initial_max_stream_data_bidi_remote | Section 18.1 | 5692 | | | | 5693 | 0x0007 | initial_max_stream_data_uni | Section 18.1 | 5694 | | | | 5695 | 0x0008 | initial_max_streams_bidi | Section 18.1 | 5696 | | | | 5697 | 0x0009 | initial_max_streams_uni | Section 18.1 | 5698 | | | | 5699 | 0x000a | ack_delay_exponent | Section 18.1 | 5700 | | | | 5701 | 0x000b | max_ack_delay | Section 18.1 | 5702 | | | | 5703 | 0x000c | disable_migration | Section 18.1 | 5704 | | | | 5705 | 0x000d | preferred_address | Section 18.1 | 5706 +--------+-------------------------------------+---------------+ 5708 Table 6: Initial QUIC Transport Parameters Entries 5710 22.2. QUIC Frame Type Registry 5712 IANA [SHALL add/has added] a registry for "QUIC Frame Types" under a 5713 "QUIC Protocol" heading. 5715 The "QUIC Frame Types" registry governs a 62-bit space. This space 5716 is split into three spaces that are governed by different policies. 5717 Values between 0x00 and 0x3f (in hexadecimal) are assigned via the 5718 Standards Action or IESG Review policies [RFC8126]. Values from 0x40 5719 to 0x3fff operate on the Specification Required policy [RFC8126]. 5720 All other values are assigned to Private Use [RFC8126]. 5722 Registrations MUST include the following fields: 5724 Value: The numeric value of the assignment (registrations will be 5725 between 0x00 and 0x3fff). A range of values MAY be assigned. 5727 Frame Name: A short mnemonic for the frame type. 5729 Specification: A reference to a publicly available specification for 5730 the value. 5732 The nominated expert(s) verify that a specification exists and is 5733 readily accessible. Specifications for new registrations need to 5734 describe the means by which an endpoint might determine that it can 5735 send the identified type of frame. An accompanying transport 5736 parameter registration (see Section 22.1) is expected for most 5737 registrations. The specification needs to describe the format and 5738 assigned semantics of any fields in the frame. 5740 Expert(s) are encouraged to be biased towards approving registrations 5741 unless they are abusive, frivolous, or actively harmful (not merely 5742 aesthetically displeasing, or architecturally dubious). 5744 The initial contents of this registry are tabulated in Table 3. 5746 22.3. QUIC Transport Error Codes Registry 5748 IANA [SHALL add/has added] a registry for "QUIC Transport Error 5749 Codes" under a "QUIC Protocol" heading. 5751 The "QUIC Transport Error Codes" registry governs a 16-bit space. 5752 This space is split into two spaces that are governed by different 5753 policies. Values with the first byte in the range 0x00 to 0xfe (in 5754 hexadecimal) are assigned via the Specification Required policy 5755 [RFC8126]. Values with the first byte 0xff are reserved for Private 5756 Use [RFC8126]. 5758 Registrations MUST include the following fields: 5760 Value: The numeric value of the assignment (registrations will be 5761 between 0x0000 and 0xfeff). 5763 Code: A short mnemonic for the parameter. 5765 Description: A brief description of the error code semantics, which 5766 MAY be a summary if a specification reference is provided. 5768 Specification: A reference to a publicly available specification for 5769 the value. 5771 The initial contents of this registry are shown in Table 7. Values 5772 from 0xFF00 to 0xFFFF are reserved for Private Use [RFC8126]. 5774 +------+---------------------------+----------------+---------------+ 5775 | Valu | Error | Description | Specification | 5776 | e | | | | 5777 +------+---------------------------+----------------+---------------+ 5778 | 0x0 | NO_ERROR | No error | Section 20 | 5779 | | | | | 5780 | 0x1 | INTERNAL_ERROR | Implementation | Section 20 | 5781 | | | error | | 5782 | | | | | 5783 | 0x2 | SERVER_BUSY | Server | Section 20 | 5784 | | | currently busy | | 5785 | | | | | 5786 | 0x3 | FLOW_CONTROL_ERROR | Flow control | Section 20 | 5787 | | | error | | 5788 | | | | | 5789 | 0x4 | STREAM_LIMIT_ERROR | Too many | Section 20 | 5790 | | | streams opened | | 5791 | | | | | 5792 | 0x5 | STREAM_STATE_ERROR | Frame received | Section 20 | 5793 | | | in invalid | | 5794 | | | stream state | | 5795 | | | | | 5796 | 0x6 | FINAL_SIZE_ERROR | Change to | Section 20 | 5797 | | | final size | | 5798 | | | | | 5799 | 0x7 | FRAME_ENCODING_ERROR | Frame encoding | Section 20 | 5800 | | | error | | 5801 | | | | | 5802 | 0x8 | TRANSPORT_PARAMETER_ERROR | Error in | Section 20 | 5803 | | | transport | | 5804 | | | parameters | | 5805 | | | | | 5806 | 0xA | PROTOCOL_VIOLATION | Generic | Section 20 | 5807 | | | protocol | | 5808 | | | violation | | 5809 | | | | | 5810 | 0xC | INVALID_MIGRATION | Violated | Section 20 | 5811 | | | disabled | | 5812 | | | migration | | 5813 +------+---------------------------+----------------+---------------+ 5815 Table 7: Initial QUIC Transport Error Codes Entries 5817 23. References 5819 23.1. Normative References 5821 [DPLPMTUD] 5822 Fairhurst, G., Jones, T., Tuexen, M., Ruengeler, I., and 5823 T. Voelker, "Packetization Layer Path MTU Discovery for 5824 Datagram Transports", draft-ietf-tsvwg-datagram-plpmtud-07 5825 (work in progress), February 2019. 5827 [QUIC-RECOVERY] 5828 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 5829 and Congestion Control", draft-ietf-quic-recovery-20 (work 5830 in progress), April 2019. 5832 [QUIC-TLS] 5833 Thomson, M., Ed. and S. Turner, Ed., "Using Transport 5834 Layer Security (TLS) to Secure QUIC", draft-ietf-quic- 5835 tls-20 (work in progress), April 2019. 5837 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 5838 DOI 10.17487/RFC1191, November 1990, 5839 . 5841 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 5842 Requirement Levels", BCP 14, RFC 2119, 5843 DOI 10.17487/RFC2119, March 1997, 5844 . 5846 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 5847 of Explicit Congestion Notification (ECN) to IP", 5848 RFC 3168, DOI 10.17487/RFC3168, September 2001, 5849 . 5851 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 5852 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 5853 2003, . 5855 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 5856 "Randomness Requirements for Security", BCP 106, RFC 4086, 5857 DOI 10.17487/RFC4086, June 2005, 5858 . 5860 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 5861 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 5862 . 5864 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 5865 "IPv6 Flow Label Specification", RFC 6437, 5866 DOI 10.17487/RFC6437, November 2011, 5867 . 5869 [RFC8085] Eggert, L., Fairhurst, G., and G. Shepherd, "UDP Usage 5870 Guidelines", BCP 145, RFC 8085, DOI 10.17487/RFC8085, 5871 March 2017, . 5873 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 5874 Writing an IANA Considerations Section in RFCs", BCP 26, 5875 RFC 8126, DOI 10.17487/RFC8126, June 2017, 5876 . 5878 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 5879 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 5880 May 2017, . 5882 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 5883 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 5884 DOI 10.17487/RFC8201, July 2017, 5885 . 5887 [RFC8311] Black, D., "Relaxing Restrictions on Explicit Congestion 5888 Notification (ECN) Experimentation", RFC 8311, 5889 DOI 10.17487/RFC8311, January 2018, 5890 . 5892 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 5893 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 5894 . 5896 23.2. Informative References 5898 [EARLY-DESIGN] 5899 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 5900 December 2013, . 5902 [HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 5903 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 5904 DOI 10.17487/RFC7540, May 2015, 5905 . 5907 [QUIC-INVARIANTS] 5908 Thomson, M., "Version-Independent Properties of QUIC", 5909 draft-ietf-quic-invariants-04 (work in progress), April 5910 2019. 5912 [QUIC-MANAGEABILITY] 5913 Kuehlewind, M. and B. Trammell, "Manageability of the QUIC 5914 Transport Protocol", draft-ietf-quic-manageability-03 5915 (work in progress), October 2018. 5917 [RFC1812] Baker, F., Ed., "Requirements for IP Version 4 Routers", 5918 RFC 1812, DOI 10.17487/RFC1812, June 1995, 5919 . 5921 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 5922 Selective Acknowledgment Options", RFC 2018, 5923 DOI 10.17487/RFC2018, October 1996, 5924 . 5926 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 5927 Hashing for Message Authentication", RFC 2104, 5928 DOI 10.17487/RFC2104, February 1997, 5929 . 5931 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 5932 RFC 2360, DOI 10.17487/RFC2360, June 1998, 5933 . 5935 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 5936 RFC 4303, DOI 10.17487/RFC4303, December 2005, 5937 . 5939 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 5940 Control Message Protocol (ICMPv6) for the Internet 5941 Protocol Version 6 (IPv6) Specification", STD 89, 5942 RFC 4443, DOI 10.17487/RFC4443, March 2006, 5943 . 5945 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 5946 Translation (NAT) Behavioral Requirements for Unicast 5947 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 5948 2007, . 5950 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 5951 Key Derivation Function (HKDF)", RFC 5869, 5952 DOI 10.17487/RFC5869, May 2010, 5953 . 5955 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 5956 "Transport Layer Security (TLS) Application-Layer Protocol 5957 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 5958 July 2014, . 5960 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 5961 (IPv6) Specification", STD 86, RFC 8200, 5962 DOI 10.17487/RFC8200, July 2017, 5963 . 5965 [SLOWLORIS] 5966 RSnake Hansen, R., "Welcome to Slowloris...", June 2009, 5967 . 5970 Appendix A. Sample Packet Number Decoding Algorithm 5972 The following pseudo-code shows how an implementation can decode 5973 packet numbers after header protection has been removed. 5975 DecodePacketNumber(largest_pn, truncated_pn, pn_nbits): 5976 expected_pn = largest_pn + 1 5977 pn_win = 1 << pn_nbits 5978 pn_hwin = pn_win / 2 5979 pn_mask = pn_win - 1 5980 // The incoming packet number should be greater than 5981 // expected_pn - pn_hwin and less than or equal to 5982 // expected_pn + pn_hwin 5983 // 5984 // This means we can't just strip the trailing bits from 5985 // expected_pn and add the truncated_pn because that might 5986 // yield a value outside the window. 5987 // 5988 // The following code calculates a candidate value and 5989 // makes sure it's within the packet number window. 5990 candidate_pn = (expected_pn & ~pn_mask) | truncated_pn 5991 if candidate_pn <= expected_pn - pn_hwin: 5992 return candidate_pn + pn_win 5993 // Note the extra check for underflow when candidate_pn 5994 // is near zero. 5995 if candidate_pn > expected_pn + pn_hwin and 5996 candidate_pn > pn_win: 5997 return candidate_pn - pn_win 5998 return candidate_pn 6000 Appendix B. Change Log 6002 *RFC Editor's Note:* Please remove this section prior to 6003 publication of a final version of this document. 6005 Issue and pull request numbers are listed with a leading octothorp. 6007 B.1. Since draft-ietf-quic-transport-19 6009 o Refine discussion of 0-RTT transport parameters (#2467, #2464) 6011 o Fewer transport parameters need to be remembered for 0-RTT (#2624, 6012 #2467) 6014 o Spin bit text incorporated (#2564) 6016 o Close the connection when maximum stream ID in MAX_STREAMS exceeds 6017 2^62 - 1 (#2499, #2487) 6019 o New connection ID required for intentional migration (#2414, 6020 #2413) 6022 o Connection ID issuance can be rate-limited (#2436, #2428) 6024 o The "QUIC bit" is ignored in Version Negotiation (#2400, #2561) 6026 o Initial packets from clients need to be padded to 1200 unless a 6027 Handshake packet is sent as well (#2522, #2523) 6029 o CRYPTO frames can be discarded if too much data is buffered 6030 (#1834, #2524) 6032 o Stateless reset uses a short header packet (#2599, #2600) 6034 B.2. Since draft-ietf-quic-transport-18 6036 o Removed version negotation; version negotiation, including 6037 authentication of the result, will be addressed in the next 6038 version of QUIC (#1773, #2313) 6040 o Added discussion of the use of IPv6 flow labels (#2348, #2399) 6042 o A connection ID can't be retired in a packet that uses that 6043 connection ID (#2101, #2420) 6045 o Idle timeout transport parameter is in milliseconds (from seconds) 6046 (#2453, #2454) 6048 o Endpoints are required to use new connnection IDs when they use 6049 new network paths (#2413, #2414) 6051 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 6053 B.3. Since draft-ietf-quic-transport-17 6055 o Stream-related errors now use STREAM_STATE_ERROR (#2305) 6057 o Endpoints discard initial keys as soon as handshake keys are 6058 available (#1951, #2045) 6060 o Expanded conditions for ignoring ICMP packet too big messages 6061 (#2108, #2161) 6063 o Remove rate control from PATH_CHALLENGE/PATH_RESPONSE (#2129, 6064 #2241) 6066 o Endpoints are permitted to discard malformed initial packets 6067 (#2141) 6069 o Clarified ECN implementation and usage requirements (#2156, #2201) 6071 o Disable ECN count verification for packets that arrive out of 6072 order (#2198, #2215) 6074 o Use Probe Timeout (PTO) instead of RTO (#2206, #2238) 6076 o Loosen constraints on retransmission of ACK ranges (#2199, #2245) 6078 o Limit Retry and Version Negotiation to once per datagram (#2259, 6079 #2303) 6081 o Set a maximum value for max_ack_delay transport parameter (#2282, 6082 #2301) 6084 o Allow server preferred address for both IPv4 and IPv6 (#2122, 6085 #2296) 6087 o Corrected requirements for migration to a preferred address 6088 (#2146, #2349) 6090 o ACK of non-existent packet is illegal (#2298, #2302) 6092 B.4. Since draft-ietf-quic-transport-16 6094 o Stream limits are defined as counts, not maximums (#1850, #1906) 6096 o Require amplification attack defense after closing (#1905, #1911) 6098 o Remove reservation of application error code 0 for STOPPING 6099 (#1804, #1922) 6101 o Renumbered frames (#1945) 6103 o Renumbered transport parameters (#1946) 6105 o Numeric transport parameters are expressed as varints (#1608, 6106 #1947, #1955) 6108 o Reorder the NEW_CONNECTION_ID frame (#1952, #1963) 6110 o Rework the first byte (#2006) 6112 * Fix the 0x40 bit 6114 * Change type values for long header 6116 * Add spin bit to short header (#631, #1988) 6118 * Encrypt the remainder of the first byte (#1322) 6120 * Move packet number length to first byte 6122 * Move ODCIL to first byte of retry packets 6124 * Simplify packet number protection (#1575) 6126 o Allow STOP_SENDING to open a remote bidirectional stream (#1797, 6127 #2013) 6129 o Added mitigation for off-path migration attacks (#1278, #1749, 6130 #2033) 6132 o Don't let the PMTU to drop below 1280 (#2063, #2069) 6134 o Require peers to replace retired connection IDs (#2085) 6136 o Servers are required to ignore Version Negotiation packets (#2088) 6138 o Tokens are repeated in all Initial packets (#2089) 6140 o Clarified how PING frames are sent after loss (#2094) 6142 o Initial keys are discarded once Handshake are available (#1951, 6143 #2045) 6145 o ICMP PTB validation clarifications (#2161, #2109, #2108) 6147 B.5. Since draft-ietf-quic-transport-15 6149 Substantial editorial reorganization; no technical changes. 6151 B.6. Since draft-ietf-quic-transport-14 6153 o Merge ACK and ACK_ECN (#1778, #1801) 6155 o Explicitly communicate max_ack_delay (#981, #1781) 6157 o Validate original connection ID after Retry packets (#1710, #1486, 6158 #1793) 6160 o Idle timeout is optional and has no specified maximum (#1765) 6162 o Update connection ID handling; add RETIRE_CONNECTION_ID type 6163 (#1464, #1468, #1483, #1484, #1486, #1495, #1729, #1742, #1799, 6164 #1821) 6166 o Include a Token in all Initial packets (#1649, #1794) 6168 o Prevent handshake deadlock (#1764, #1824) 6170 B.7. Since draft-ietf-quic-transport-13 6172 o Streams open when higher-numbered streams of the same type open 6173 (#1342, #1549) 6175 o Split initial stream flow control limit into 3 transport 6176 parameters (#1016, #1542) 6178 o All flow control transport parameters are optional (#1610) 6180 o Removed UNSOLICITED_PATH_RESPONSE error code (#1265, #1539) 6182 o Permit stateless reset in response to any packet (#1348, #1553) 6184 o Recommended defense against stateless reset spoofing (#1386, 6185 #1554) 6187 o Prevent infinite stateless reset exchanges (#1443, #1627) 6189 o Forbid processing of the same packet number twice (#1405, #1624) 6191 o Added a packet number decoding example (#1493) 6193 o More precisely define idle timeout (#1429, #1614, #1652) 6194 o Corrected format of Retry packet and prevented looping (#1492, 6195 #1451, #1448, #1498) 6197 o Permit 0-RTT after receiving Version Negotiation or Retry (#1507, 6198 #1514, #1621) 6200 o Permit Retry in response to 0-RTT (#1547, #1552) 6202 o Looser verification of ECN counters to account for ACK loss 6203 (#1555, #1481, #1565) 6205 o Remove frame type field from APPLICATION_CLOSE (#1508, #1528) 6207 B.8. Since draft-ietf-quic-transport-12 6209 o Changes to integration of the TLS handshake (#829, #1018, #1094, 6210 #1165, #1190, #1233, #1242, #1252, #1450, #1458) 6212 * The cryptographic handshake uses CRYPTO frames, not stream 0 6214 * QUIC packet protection is used in place of TLS record 6215 protection 6217 * Separate QUIC packet number spaces are used for the handshake 6219 * Changed Retry to be independent of the cryptographic handshake 6221 * Added NEW_TOKEN frame and Token fields to Initial packet 6223 * Limit the use of HelloRetryRequest to address TLS needs (like 6224 key shares) 6226 o Enable server to transition connections to a preferred address 6227 (#560, #1251, #1373) 6229 o Added ECN feedback mechanisms and handling; new ACK_ECN frame 6230 (#804, #805, #1372) 6232 o Changed rules and recommendations for use of new connection IDs 6233 (#1258, #1264, #1276, #1280, #1419, #1452, #1453, #1465) 6235 o Added a transport parameter to disable intentional connection 6236 migration (#1271, #1447) 6238 o Packets from different connection ID can't be coalesced (#1287, 6239 #1423) 6241 o Fixed sampling method for packet number encryption; the length 6242 field in long headers includes the packet number field in addition 6243 to the packet payload (#1387, #1389) 6245 o Stateless Reset is now symmetric and subject to size constraints 6246 (#466, #1346) 6248 o Added frame type extension mechanism (#58, #1473) 6250 B.9. Since draft-ietf-quic-transport-11 6252 o Enable server to transition connections to a preferred address 6253 (#560, #1251) 6255 o Packet numbers are encrypted (#1174, #1043, #1048, #1034, #850, 6256 #990, #734, #1317, #1267, #1079) 6258 o Packet numbers use a variable-length encoding (#989, #1334) 6260 o STREAM frames can now be empty (#1350) 6262 B.10. Since draft-ietf-quic-transport-10 6264 o Swap payload length and packed number fields in long header 6265 (#1294) 6267 o Clarified that CONNECTION_CLOSE is allowed in Handshake packet 6268 (#1274) 6270 o Spin bit reserved (#1283) 6272 o Coalescing multiple QUIC packets in a UDP datagram (#1262, #1285) 6274 o A more complete connection migration (#1249) 6276 o Refine opportunistic ACK defense text (#305, #1030, #1185) 6278 o A Stateless Reset Token isn't mandatory (#818, #1191) 6280 o Removed implicit stream opening (#896, #1193) 6282 o An empty STREAM frame can be used to open a stream without sending 6283 data (#901, #1194) 6285 o Define stream counts in transport parameters rather than a maximum 6286 stream ID (#1023, #1065) 6288 o STOP_SENDING is now prohibited before streams are used (#1050) 6289 o Recommend including ACK in Retry packets and allow PADDING (#1067, 6290 #882) 6292 o Endpoints now become closing after an idle timeout (#1178, #1179) 6294 o Remove implication that Version Negotiation is sent when a packet 6295 of the wrong version is received (#1197) 6297 B.11. Since draft-ietf-quic-transport-09 6299 o Added PATH_CHALLENGE and PATH_RESPONSE frames to replace PING with 6300 Data and PONG frame. Changed ACK frame type from 0x0e to 0x0d. 6301 (#1091, #725, #1086) 6303 o A server can now only send 3 packets without validating the client 6304 address (#38, #1090) 6306 o Delivery order of stream data is no longer strongly specified 6307 (#252, #1070) 6309 o Rework of packet handling and version negotiation (#1038) 6311 o Stream 0 is now exempt from flow control until the handshake 6312 completes (#1074, #725, #825, #1082) 6314 o Improved retransmission rules for all frame types: information is 6315 retransmitted, not packets or frames (#463, #765, #1095, #1053) 6317 o Added an error code for server busy signals (#1137) 6319 o Endpoints now set the connection ID that their peer uses. 6320 Connection IDs are variable length. Removed the 6321 omit_connection_id transport parameter and the corresponding short 6322 header flag. (#1089, #1052, #1146, #821, #745, #821, #1166, #1151) 6324 B.12. Since draft-ietf-quic-transport-08 6326 o Clarified requirements for BLOCKED usage (#65, #924) 6328 o BLOCKED frame now includes reason for blocking (#452, #924, #927, 6329 #928) 6331 o GAP limitation in ACK Frame (#613) 6333 o Improved PMTUD description (#614, #1036) 6335 o Clarified stream state machine (#634, #662, #743, #894) 6336 o Reserved versions don't need to be generated deterministically 6337 (#831, #931) 6339 o You don't always need the draining period (#871) 6341 o Stateless reset clarified as version-specific (#930, #986) 6343 o initial_max_stream_id_x transport parameters are optional (#970, 6344 #971) 6346 o Ack Delay assumes a default value during the handshake (#1007, 6347 #1009) 6349 o Removed transport parameters from NewSessionTicket (#1015) 6351 B.13. Since draft-ietf-quic-transport-07 6353 o The long header now has version before packet number (#926, #939) 6355 o Rename and consolidate packet types (#846, #822, #847) 6357 o Packet types are assigned new codepoints and the Connection ID 6358 Flag is inverted (#426, #956) 6360 o Removed type for Version Negotiation and use Version 0 (#963, 6361 #968) 6363 o Streams are split into unidirectional and bidirectional (#643, 6364 #656, #720, #872, #175, #885) 6366 * Stream limits now have separate uni- and bi-directional 6367 transport parameters (#909, #958) 6369 * Stream limit transport parameters are now optional and default 6370 to 0 (#970, #971) 6372 o The stream state machine has been split into read and write (#634, 6373 #894) 6375 o Employ variable-length integer encodings throughout (#595) 6377 o Improvements to connection close 6379 * Added distinct closing and draining states (#899, #871) 6381 * Draining period can terminate early (#869, #870) 6383 * Clarifications about stateless reset (#889, #890) 6385 o Address validation for connection migration (#161, #732, #878) 6387 o Clearly defined retransmission rules for BLOCKED (#452, #65, #924) 6389 o negotiated_version is sent in server transport parameters (#710, 6390 #959) 6392 o Increased the range over which packet numbers are randomized 6393 (#864, #850, #964) 6395 B.14. Since draft-ietf-quic-transport-06 6397 o Replaced FNV-1a with AES-GCM for all "Cleartext" packets (#554) 6399 o Split error code space between application and transport (#485) 6401 o Stateless reset token moved to end (#820) 6403 o 1-RTT-protected long header types removed (#848) 6405 o No acknowledgments during draining period (#852) 6407 o Remove "application close" as a separate close type (#854) 6409 o Remove timestamps from the ACK frame (#841) 6411 o Require transport parameters to only appear once (#792) 6413 B.15. Since draft-ietf-quic-transport-05 6415 o Stateless token is server-only (#726) 6417 o Refactor section on connection termination (#733, #748, #328, 6418 #177) 6420 o Limit size of Version Negotiation packet (#585) 6422 o Clarify when and what to ack (#736) 6424 o Renamed STREAM_ID_NEEDED to STREAM_ID_BLOCKED 6426 o Clarify Keep-alive requirements (#729) 6428 B.16. Since draft-ietf-quic-transport-04 6430 o Introduce STOP_SENDING frame, RESET_STREAM only resets in one 6431 direction (#165) 6433 o Removed GOAWAY; application protocols are responsible for graceful 6434 shutdown (#696) 6436 o Reduced the number of error codes (#96, #177, #184, #211) 6438 o Version validation fields can't move or change (#121) 6440 o Removed versions from the transport parameters in a 6441 NewSessionTicket message (#547) 6443 o Clarify the meaning of "bytes in flight" (#550) 6445 o Public reset is now stateless reset and not visible to the path 6446 (#215) 6448 o Reordered bits and fields in STREAM frame (#620) 6450 o Clarifications to the stream state machine (#572, #571) 6452 o Increased the maximum length of the Largest Acknowledged field in 6453 ACK frames to 64 bits (#629) 6455 o truncate_connection_id is renamed to omit_connection_id (#659) 6457 o CONNECTION_CLOSE terminates the connection like TCP RST (#330, 6458 #328) 6460 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 6462 B.17. Since draft-ietf-quic-transport-03 6464 o Change STREAM and RESET_STREAM layout 6466 o Add MAX_STREAM_ID settings 6468 B.18. Since draft-ietf-quic-transport-02 6470 o The size of the initial packet payload has a fixed minimum (#267, 6471 #472) 6473 o Define when Version Negotiation packets are ignored (#284, #294, 6474 #241, #143, #474) 6476 o The 64-bit FNV-1a algorithm is used for integrity protection of 6477 unprotected packets (#167, #480, #481, #517) 6479 o Rework initial packet types to change how the connection ID is 6480 chosen (#482, #442, #493) 6482 o No timestamps are forbidden in unprotected packets (#542, #429) 6484 o Cryptographic handshake is now on stream 0 (#456) 6486 o Remove congestion control exemption for cryptographic handshake 6487 (#248, #476) 6489 o Version 1 of QUIC uses TLS; a new version is needed to use a 6490 different handshake protocol (#516) 6492 o STREAM frames have a reduced number of offset lengths (#543, #430) 6494 o Split some frames into separate connection- and stream- level 6495 frames (#443) 6497 * WINDOW_UPDATE split into MAX_DATA and MAX_STREAM_DATA (#450) 6499 * BLOCKED split to match WINDOW_UPDATE split (#454) 6501 * Define STREAM_ID_NEEDED frame (#455) 6503 o A NEW_CONNECTION_ID frame supports connection migration without 6504 linkability (#232, #491, #496) 6506 o Transport parameters for 0-RTT are retained from a previous 6507 connection (#405, #513, #512) 6509 * A client in 0-RTT no longer required to reset excess streams 6510 (#425, #479) 6512 o Expanded security considerations (#440, #444, #445, #448) 6514 B.19. Since draft-ietf-quic-transport-01 6516 o Defined short and long packet headers (#40, #148, #361) 6518 o Defined a versioning scheme and stable fields (#51, #361) 6520 o Define reserved version values for "greasing" negotiation (#112, 6521 #278) 6523 o The initial packet number is randomized (#35, #283) 6525 o Narrow the packet number encoding range requirement (#67, #286, 6526 #299, #323, #356) 6528 o Defined client address validation (#52, #118, #120, #275) 6529 o Define transport parameters as a TLS extension (#49, #122) 6531 o SCUP and COPT parameters are no longer valid (#116, #117) 6533 o Transport parameters for 0-RTT are either remembered from before, 6534 or assume default values (#126) 6536 o The server chooses connection IDs in its final flight (#119, #349, 6537 #361) 6539 o The server echoes the Connection ID and packet number fields when 6540 sending a Version Negotiation packet (#133, #295, #244) 6542 o Defined a minimum packet size for the initial handshake packet 6543 from the client (#69, #136, #139, #164) 6545 o Path MTU Discovery (#64, #106) 6547 o The initial handshake packet from the client needs to fit in a 6548 single packet (#338) 6550 o Forbid acknowledgment of packets containing only ACK and PADDING 6551 (#291) 6553 o Require that frames are processed when packets are acknowledged 6554 (#381, #341) 6556 o Removed the STOP_WAITING frame (#66) 6558 o Don't require retransmission of old timestamps for lost ACK frames 6559 (#308) 6561 o Clarified that frames are not retransmitted, but the information 6562 in them can be (#157, #298) 6564 o Error handling definitions (#335) 6566 o Split error codes into four sections (#74) 6568 o Forbid the use of Public Reset where CONNECTION_CLOSE is possible 6569 (#289) 6571 o Define packet protection rules (#336) 6573 o Require that stream be entirely delivered or reset, including 6574 acknowledgment of all STREAM frames or the RESET_STREAM, before it 6575 closes (#381) 6577 o Remove stream reservation from state machine (#174, #280) 6579 o Only stream 1 does not contribute to connection-level flow control 6580 (#204) 6582 o Stream 1 counts towards the maximum concurrent stream limit (#201, 6583 #282) 6585 o Remove connection-level flow control exclusion for some streams 6586 (except 1) (#246) 6588 o RESET_STREAM affects connection-level flow control (#162, #163) 6590 o Flow control accounting uses the maximum data offset on each 6591 stream, rather than bytes received (#378) 6593 o Moved length-determining fields to the start of STREAM and ACK 6594 (#168, #277) 6596 o Added the ability to pad between frames (#158, #276) 6598 o Remove error code and reason phrase from GOAWAY (#352, #355) 6600 o GOAWAY includes a final stream number for both directions (#347) 6602 o Error codes for RESET_STREAM and CONNECTION_CLOSE are now at a 6603 consistent offset (#249) 6605 o Defined priority as the responsibility of the application protocol 6606 (#104, #303) 6608 B.20. Since draft-ietf-quic-transport-00 6610 o Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 6612 o Defined versioning 6614 o Reworked description of packet and frame layout 6616 o Error code space is divided into regions for each component 6618 o Use big endian for all numeric values 6620 B.21. Since draft-hamilton-quic-transport-protocol-01 6622 o Adopted as base for draft-ietf-quic-tls 6624 o Updated authors/editors list 6625 o Added IANA Considerations section 6627 o Moved Contributors and Acknowledgments to appendices 6629 Acknowledgments 6631 Special thanks are due to the following for helping shape pre-IETF 6632 QUIC and its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, 6633 Alistair Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. 6635 This document has benefited immensely from various private 6636 discussions and public ones on the quic@ietf.org and proto- 6637 quic@chromium.org mailing lists. Our thanks to all. 6639 Contributors 6641 The original authors of this specification were Ryan Hamilton, Jana 6642 Iyengar, Ian Swett, and Alyssa Wilk. 6644 The original design and rationale behind this protocol draw 6645 significantly from work by Jim Roskind [EARLY-DESIGN]. In 6646 alphabetical order, the contributors to the pre-IETF QUIC project at 6647 Google are: Britt Cyr, Jeremy Dorfman, Ryan Hamilton, Jana Iyengar, 6648 Fedor Kouranov, Charles Krasic, Jo Kulik, Adam Langley, Jim Roskind, 6649 Robbie Shade, Satyam Shekhar, Cherie Shi, Ian Swett, Raman Tenneti, 6650 Victor Vasiliev, Antonio Vicente, Patrik Westin, Alyssa Wilk, Dale 6651 Worley, Fan Yang, Dan Zhang, Daniel Ziegler. 6653 Authors' Addresses 6655 Jana Iyengar (editor) 6656 Fastly 6658 Email: jri.ietf@gmail.com 6660 Martin Thomson (editor) 6661 Mozilla 6663 Email: mt@lowentropy.net