idnits 2.17.00 (12 Aug 2021) /tmp/idnits54168/draft-ietf-quic-transport-23.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 (September 12, 2019) is 982 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 1892 == Missing Reference: 'CH' is mentioned on line 1888, but not defined == Missing Reference: 'SH' is mentioned on line 1890, but not defined == Missing Reference: 'EE' is mentioned on line 1891, but not defined == Missing Reference: 'CERT' is mentioned on line 1891, but not defined == Missing Reference: 'CV' is mentioned on line 1891, but not defined == Missing Reference: 'FIN' is mentioned on line 1891, but not defined -- Looks like a reference, but probably isn't: '1' on line 1890 -- Looks like a reference, but probably isn't: '4' on line 4898 -- Looks like a reference, but probably isn't: '16' on line 4903 == Outdated reference: draft-ietf-tsvwg-datagram-plpmtud has been published as RFC 8899 == Outdated reference: draft-ietf-quic-recovery has been published as RFC 9002 == Outdated reference: draft-ietf-quic-tls has been published as RFC 9001 == Outdated reference: draft-ietf-quic-invariants has been published as RFC 8999 == Outdated reference: A later version (-16) exists of draft-ietf-quic-manageability-05 Summary: 0 errors (**), 0 flaws (~~), 14 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 QUIC J. Iyengar, Ed. 3 Internet-Draft Fastly 4 Intended status: Standards Track M. Thomson, Ed. 5 Expires: March 15, 2020 Mozilla 6 September 12, 2019 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-23 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 March 15, 2020. 44 Copyright Notice 46 Copyright (c) 2019 IETF Trust and the persons identified as the 47 document authors. All rights reserved. 49 This document is subject to BCP 78 and the IETF Trust's Legal 50 Provisions Relating to IETF Documents 51 (https://trustee.ietf.org/license-info) in effect on the date of 52 publication of this document. Please review these documents 53 carefully, as they describe your rights and restrictions with respect 54 to this document. Code Components extracted from this document must 55 include Simplified BSD License text as described in Section 4.e of 56 the Trust Legal Provisions and are provided without warranty as 57 described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 62 1.1. Document Structure . . . . . . . . . . . . . . . . . . . 6 63 1.2. Terms and Definitions . . . . . . . . . . . . . . . . . . 8 64 1.3. Notational Conventions . . . . . . . . . . . . . . . . . 8 65 2. Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 2.1. Stream Types and Identifiers . . . . . . . . . . . . . . 9 67 2.2. Sending and Receiving Data . . . . . . . . . . . . . . . 10 68 2.3. Stream Prioritization . . . . . . . . . . . . . . . . . . 11 69 2.4. Required Operations on Streams . . . . . . . . . . . . . 11 70 3. Stream States . . . . . . . . . . . . . . . . . . . . . . . . 12 71 3.1. Sending Stream States . . . . . . . . . . . . . . . . . . 12 72 3.2. Receiving Stream States . . . . . . . . . . . . . . . . . 14 73 3.3. Permitted Frame Types . . . . . . . . . . . . . . . . . . 17 74 3.4. Bidirectional Stream States . . . . . . . . . . . . . . . 17 75 3.5. Solicited State Transitions . . . . . . . . . . . . . . . 19 76 4. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 20 77 4.1. Data Flow Control . . . . . . . . . . . . . . . . . . . . 20 78 4.2. Flow Credit Increments . . . . . . . . . . . . . . . . . 21 79 4.3. Handling Stream Cancellation . . . . . . . . . . . . . . 22 80 4.4. Stream Final Size . . . . . . . . . . . . . . . . . . . . 23 81 4.5. Controlling Concurrency . . . . . . . . . . . . . . . . . 23 82 5. Connections . . . . . . . . . . . . . . . . . . . . . . . . . 24 83 5.1. Connection ID . . . . . . . . . . . . . . . . . . . . . . 24 84 5.1.1. Issuing Connection IDs . . . . . . . . . . . . . . . 25 85 5.1.2. Consuming and Retiring Connection IDs . . . . . . . . 26 86 5.2. Matching Packets to Connections . . . . . . . . . . . . . 27 87 5.2.1. Client Packet Handling . . . . . . . . . . . . . . . 28 88 5.2.2. Server Packet Handling . . . . . . . . . . . . . . . 28 89 5.3. Life of a QUIC Connection . . . . . . . . . . . . . . . . 29 90 5.4. Required Operations on Connections . . . . . . . . . . . 29 91 6. Version Negotiation . . . . . . . . . . . . . . . . . . . . . 30 92 6.1. Sending Version Negotiation Packets . . . . . . . . . . . 30 93 6.2. Handling Version Negotiation Packets . . . . . . . . . . 31 94 6.2.1. Version Negotiation Between Draft Versions . . . . . 31 95 6.3. Using Reserved Versions . . . . . . . . . . . . . . . . . 31 96 7. Cryptographic and Transport Handshake . . . . . . . . . . . . 32 97 7.1. Example Handshake Flows . . . . . . . . . . . . . . . . . 33 98 7.2. Negotiating Connection IDs . . . . . . . . . . . . . . . 34 99 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 36 100 7.3.1. Values of Transport Parameters for 0-RTT . . . . . . 36 101 7.3.2. New Transport Parameters . . . . . . . . . . . . . . 38 102 7.4. Cryptographic Message Buffering . . . . . . . . . . . . . 38 103 8. Address Validation . . . . . . . . . . . . . . . . . . . . . 38 104 8.1. Address Validation During Connection Establishment . . . 39 105 8.1.1. Address Validation using Retry Packets . . . . . . . 40 106 8.1.2. Address Validation for Future Connections . . . . . . 40 107 8.1.3. Address Validation Token Integrity . . . . . . . . . 43 108 8.2. Path Validation . . . . . . . . . . . . . . . . . . . . . 43 109 8.3. Initiating Path Validation . . . . . . . . . . . . . . . 44 110 8.4. Path Validation Responses . . . . . . . . . . . . . . . . 44 111 8.5. Successful Path Validation . . . . . . . . . . . . . . . 44 112 8.6. Failed Path Validation . . . . . . . . . . . . . . . . . 45 113 9. Connection Migration . . . . . . . . . . . . . . . . . . . . 45 114 9.1. Probing a New Path . . . . . . . . . . . . . . . . . . . 46 115 9.2. Initiating Connection Migration . . . . . . . . . . . . . 47 116 9.3. Responding to Connection Migration . . . . . . . . . . . 47 117 9.3.1. Peer Address Spoofing . . . . . . . . . . . . . . . . 48 118 9.3.2. On-Path Address Spoofing . . . . . . . . . . . . . . 48 119 9.3.3. Off-Path Packet Forwarding . . . . . . . . . . . . . 49 120 9.4. Loss Detection and Congestion Control . . . . . . . . . . 50 121 9.5. Privacy Implications of Connection Migration . . . . . . 51 122 9.6. Server's Preferred Address . . . . . . . . . . . . . . . 52 123 9.6.1. Communicating a Preferred Address . . . . . . . . . . 52 124 9.6.2. Responding to Connection Migration . . . . . . . . . 52 125 9.6.3. Interaction of Client Migration and Preferred Address 53 126 9.7. Use of IPv6 Flow-Label and Migration . . . . . . . . . . 53 127 10. Connection Termination . . . . . . . . . . . . . . . . . . . 54 128 10.1. Closing and Draining Connection States . . . . . . . . . 54 129 10.2. Idle Timeout . . . . . . . . . . . . . . . . . . . . . . 55 130 10.3. Immediate Close . . . . . . . . . . . . . . . . . . . . 56 131 10.4. Stateless Reset . . . . . . . . . . . . . . . . . . . . 57 132 10.4.1. Detecting a Stateless Reset . . . . . . . . . . . . 60 133 10.4.2. Calculating a Stateless Reset Token . . . . . . . . 61 134 10.4.3. Looping . . . . . . . . . . . . . . . . . . . . . . 62 135 11. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 62 136 11.1. Connection Errors . . . . . . . . . . . . . . . . . . . 63 137 11.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 64 138 12. Packets and Frames . . . . . . . . . . . . . . . . . . . . . 64 139 12.1. Protected Packets . . . . . . . . . . . . . . . . . . . 64 140 12.2. Coalescing Packets . . . . . . . . . . . . . . . . . . . 65 141 12.3. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 66 142 12.4. Frames and Frame Types . . . . . . . . . . . . . . . . . 67 143 13. Packetization and Reliability . . . . . . . . . . . . . . . . 70 144 13.1. Packet Processing . . . . . . . . . . . . . . . . . . . 71 145 13.2. Generating Acknowledgements . . . . . . . . . . . . . . 71 146 13.2.1. Sending ACK Frames . . . . . . . . . . . . . . . . . 71 147 13.2.2. Managing ACK Ranges . . . . . . . . . . . . . . . . 73 148 13.2.3. Receiver Tracking of ACK Frames . . . . . . . . . . 73 149 13.2.4. Limiting ACK Ranges . . . . . . . . . . . . . . . . 73 150 13.2.5. Measuring and Reporting Host Delay . . . . . . . . . 74 151 13.2.6. ACK Frames and Packet Protection . . . . . . . . . . 74 152 13.3. Retransmission of Information . . . . . . . . . . . . . 75 153 13.4. Explicit Congestion Notification . . . . . . . . . . . . 77 154 13.4.1. ECN Counts . . . . . . . . . . . . . . . . . . . . . 77 155 13.4.2. ECN Validation . . . . . . . . . . . . . . . . . . . 78 156 14. Packet Size . . . . . . . . . . . . . . . . . . . . . . . . . 80 157 14.1. Path Maximum Transmission Unit (PMTU) . . . . . . . . . 81 158 14.2. ICMP Packet Too Big Messages . . . . . . . . . . . . . . 82 159 14.3. Datagram Packetization Layer PMTU Discovery . . . . . . 83 160 14.3.1. PMTU Probes Containing Source Connection ID . . . . 83 161 15. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 83 162 16. Variable-Length Integer Encoding . . . . . . . . . . . . . . 84 163 17. Packet Formats . . . . . . . . . . . . . . . . . . . . . . . 85 164 17.1. Packet Number Encoding and Decoding . . . . . . . . . . 85 165 17.2. Long Header Packets . . . . . . . . . . . . . . . . . . 86 166 17.2.1. Version Negotiation Packet . . . . . . . . . . . . . 89 167 17.2.2. Initial Packet . . . . . . . . . . . . . . . . . . . 91 168 17.2.3. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . 93 169 17.2.4. Handshake Packet . . . . . . . . . . . . . . . . . . 95 170 17.2.5. Retry Packet . . . . . . . . . . . . . . . . . . . . 96 171 17.3. Short Header Packets . . . . . . . . . . . . . . . . . . 98 172 17.3.1. Latency Spin Bit . . . . . . . . . . . . . . . . . . 100 173 18. Transport Parameter Encoding . . . . . . . . . . . . . . . . 101 174 18.1. Reserved Transport Parameters . . . . . . . . . . . . . 102 175 18.2. Transport Parameter Definitions . . . . . . . . . . . . 102 176 19. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 106 177 19.1. PADDING Frame . . . . . . . . . . . . . . . . . . . . . 106 178 19.2. PING Frame . . . . . . . . . . . . . . . . . . . . . . . 106 179 19.3. ACK Frames . . . . . . . . . . . . . . . . . . . . . . . 106 180 19.3.1. ACK Ranges . . . . . . . . . . . . . . . . . . . . . 108 181 19.3.2. ECN Counts . . . . . . . . . . . . . . . . . . . . . 110 182 19.4. RESET_STREAM Frame . . . . . . . . . . . . . . . . . . . 111 183 19.5. STOP_SENDING Frame . . . . . . . . . . . . . . . . . . . 111 184 19.6. CRYPTO Frame . . . . . . . . . . . . . . . . . . . . . . 112 185 19.7. NEW_TOKEN Frame . . . . . . . . . . . . . . . . . . . . 113 186 19.8. STREAM Frames . . . . . . . . . . . . . . . . . . . . . 114 187 19.9. MAX_DATA Frame . . . . . . . . . . . . . . . . . . . . . 115 188 19.10. MAX_STREAM_DATA Frame . . . . . . . . . . . . . . . . . 116 189 19.11. MAX_STREAMS Frames . . . . . . . . . . . . . . . . . . . 117 190 19.12. DATA_BLOCKED Frame . . . . . . . . . . . . . . . . . . . 118 191 19.13. STREAM_DATA_BLOCKED Frame . . . . . . . . . . . . . . . 118 192 19.14. STREAMS_BLOCKED Frames . . . . . . . . . . . . . . . . . 119 193 19.15. NEW_CONNECTION_ID Frame . . . . . . . . . . . . . . . . 119 194 19.16. RETIRE_CONNECTION_ID Frame . . . . . . . . . . . . . . . 121 195 19.17. PATH_CHALLENGE Frame . . . . . . . . . . . . . . . . . . 122 196 19.18. PATH_RESPONSE Frame . . . . . . . . . . . . . . . . . . 123 197 19.19. CONNECTION_CLOSE Frames . . . . . . . . . . . . . . . . 123 198 19.20. Extension Frames . . . . . . . . . . . . . . . . . . . . 124 199 20. Transport Error Codes . . . . . . . . . . . . . . . . . . . . 124 200 20.1. Application Protocol Error Codes . . . . . . . . . . . . 126 201 21. Security Considerations . . . . . . . . . . . . . . . . . . . 126 202 21.1. Handshake Denial of Service . . . . . . . . . . . . . . 126 203 21.2. Amplification Attack . . . . . . . . . . . . . . . . . . 127 204 21.3. Optimistic ACK Attack . . . . . . . . . . . . . . . . . 127 205 21.4. Slowloris Attacks . . . . . . . . . . . . . . . . . . . 128 206 21.5. Stream Fragmentation and Reassembly Attacks . . . . . . 128 207 21.6. Stream Commitment Attack . . . . . . . . . . . . . . . . 128 208 21.7. Peer Denial of Service . . . . . . . . . . . . . . . . . 129 209 21.8. Explicit Congestion Notification Attacks . . . . . . . . 129 210 21.9. Stateless Reset Oracle . . . . . . . . . . . . . . . . . 130 211 21.10. Version Downgrade . . . . . . . . . . . . . . . . . . . 130 212 21.11. Targeted Attacks by Routing . . . . . . . . . . . . . . 130 213 22. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 131 214 22.1. QUIC Transport Parameter Registry . . . . . . . . . . . 131 215 22.2. QUIC Frame Type Registry . . . . . . . . . . . . . . . . 132 216 22.3. QUIC Transport Error Codes Registry . . . . . . . . . . 133 217 23. References . . . . . . . . . . . . . . . . . . . . . . . . . 135 218 23.1. Normative References . . . . . . . . . . . . . . . . . . 136 219 23.2. Informative References . . . . . . . . . . . . . . . . . 137 220 Appendix A. Sample Packet Number Decoding Algorithm . . . . . . 139 221 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 140 222 B.1. Since draft-ietf-quic-transport-22 . . . . . . . . . . . 140 223 B.2. Since draft-ietf-quic-transport-21 . . . . . . . . . . . 141 224 B.3. Since draft-ietf-quic-transport-20 . . . . . . . . . . . 141 225 B.4. Since draft-ietf-quic-transport-19 . . . . . . . . . . . 142 226 B.5. Since draft-ietf-quic-transport-18 . . . . . . . . . . . 142 227 B.6. Since draft-ietf-quic-transport-17 . . . . . . . . . . . 143 228 B.7. Since draft-ietf-quic-transport-16 . . . . . . . . . . . 144 229 B.8. Since draft-ietf-quic-transport-15 . . . . . . . . . . . 145 230 B.9. Since draft-ietf-quic-transport-14 . . . . . . . . . . . 145 231 B.10. Since draft-ietf-quic-transport-13 . . . . . . . . . . . 145 232 B.11. Since draft-ietf-quic-transport-12 . . . . . . . . . . . 146 233 B.12. Since draft-ietf-quic-transport-11 . . . . . . . . . . . 147 234 B.13. Since draft-ietf-quic-transport-10 . . . . . . . . . . . 147 235 B.14. Since draft-ietf-quic-transport-09 . . . . . . . . . . . 148 236 B.15. Since draft-ietf-quic-transport-08 . . . . . . . . . . . 148 237 B.16. Since draft-ietf-quic-transport-07 . . . . . . . . . . . 149 238 B.17. Since draft-ietf-quic-transport-06 . . . . . . . . . . . 150 239 B.18. Since draft-ietf-quic-transport-05 . . . . . . . . . . . 150 240 B.19. Since draft-ietf-quic-transport-04 . . . . . . . . . . . 151 241 B.20. Since draft-ietf-quic-transport-03 . . . . . . . . . . . 151 242 B.21. Since draft-ietf-quic-transport-02 . . . . . . . . . . . 152 243 B.22. Since draft-ietf-quic-transport-01 . . . . . . . . . . . 153 244 B.23. Since draft-ietf-quic-transport-00 . . . . . . . . . . . 155 245 B.24. Since draft-hamilton-quic-transport-protocol-01 . . . . . 155 246 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 155 247 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 155 248 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 156 250 1. Introduction 252 QUIC is a multiplexed and secure general-purpose transport protocol 253 that provides: 255 o Stream multiplexing 257 o Stream and connection-level flow control 259 o Low-latency connection establishment 261 o Connection migration and resilience to NAT rebinding 263 o Authenticated and encrypted header and payload 265 QUIC uses UDP as a substrate to avoid requiring changes to legacy 266 client operating systems and middleboxes. QUIC authenticates all of 267 its headers and encrypts most of the data it exchanges, including its 268 signaling, to avoid incurring a dependency on middleboxes. 270 1.1. Document Structure 272 This document describes the core QUIC protocol and is structured as 273 follows. 275 o Streams are the basic service abstraction that QUIC provides. 277 * Section 2 describes core concepts related to streams, 279 * Section 3 provides a reference model for stream states, and 281 * Section 4 outlines the operation of flow control. 283 o Connections are the context in which QUIC endpoints communicate. 285 * Section 5 describes core concepts related to connections, 287 * Section 6 describes version negotiation, 288 * Section 7 details the process for establishing connections, 290 * Section 8 specifies critical denial of service mitigation 291 mechanisms, 293 * Section 9 describes how endpoints migrate a connection to a new 294 network path, 296 * Section 10 lists the options for terminating an open 297 connection, and 299 * Section 11 provides general guidance for error handling. 301 o Packets and frames are the basic unit used by QUIC to communicate. 303 * Section 12 describes concepts related to packets and frames, 305 * Section 13 defines models for the transmission, retransmission, 306 and acknowledgement of data, and 308 * Section 14 specifies rules for managing the size of packets. 310 o Finally, encoding details of QUIC protocol elements are described 311 in: 313 * Section 15 (Versions), 315 * Section 16 (Integer Encoding), 317 * Section 17 (Packet Headers), 319 * Section 18 (Transport Parameters), 321 * Section 19 (Frames), and 323 * Section 20 (Errors). 325 Accompanying documents describe QUIC's loss detection and congestion 326 control [QUIC-RECOVERY], and the use of TLS for key negotiation 327 [QUIC-TLS]. 329 This document defines QUIC version 1, which conforms to the protocol 330 invariants in [QUIC-INVARIANTS]. 332 1.2. Terms and Definitions 334 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 335 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 336 "OPTIONAL" in this document are to be interpreted as described in BCP 337 14 [RFC2119] [RFC8174] when, and only when, they appear in all 338 capitals, as shown here. 340 Commonly used terms in the document are described below. 342 QUIC: The transport protocol described by this document. QUIC is a 343 name, not an acronym. 345 QUIC packet: A complete processable unit of QUIC that can be 346 encapsulated in a UDP datagram. Multiple QUIC packets can be 347 encapsulated in a single UDP datagram. 349 Endpoint: An entity that can participate in a QUIC connection by 350 generating, receiving, and processing QUIC packets. There are 351 only two types of endpoint in QUIC: client and server. 353 Client: The endpoint initiating a QUIC connection. 355 Server: The endpoint accepting incoming QUIC connections. 357 Connection ID: An opaque identifier that is used to identify a QUIC 358 connection at an endpoint. Each endpoint sets a value for its 359 peer to include in packets sent towards the endpoint. 361 Stream: A unidirectional or bidirectional channel of ordered bytes 362 within a QUIC connection. A QUIC connection can carry multiple 363 simultaneous streams. 365 Application: An entity that uses QUIC to send and receive data. 367 1.3. Notational Conventions 369 Packet and frame diagrams in this document use the format described 370 in Section 3.1 of [RFC2360], with the following additional 371 conventions: 373 [x]: Indicates that x is optional 375 x (A): Indicates that x is A bits long 377 x (A/B/C) ...: Indicates that x is one of A, B, or C bits long 378 x (i) ...: Indicates that x uses the variable-length encoding in 379 Section 16 381 x (*) ...: Indicates that x is variable-length 383 2. Streams 385 Streams in QUIC provide a lightweight, ordered byte-stream 386 abstraction to an application. Streams can be unidirectional or 387 bidirectional. An alternative view of QUIC unidirectional streams is 388 a "message" abstraction of practically unlimited length. 390 Streams can be created by sending data. Other processes associated 391 with stream management - ending, cancelling, and managing flow 392 control - are all designed to impose minimal overheads. For 393 instance, a single STREAM frame (Section 19.8) can open, carry data 394 for, and close a stream. Streams can also be long-lived and can last 395 the entire duration of a connection. 397 Streams can be created by either endpoint, can concurrently send data 398 interleaved with other streams, and can be cancelled. QUIC does not 399 provide any means of ensuring ordering between bytes on different 400 streams. 402 QUIC allows for an arbitrary number of streams to operate 403 concurrently and for an arbitrary amount of data to be sent on any 404 stream, subject to flow control constraints (see Section 4) and 405 stream limits. 407 2.1. Stream Types and Identifiers 409 Streams can be unidirectional or bidirectional. Unidirectional 410 streams carry data in one direction: from the initiator of the stream 411 to its peer. Bidirectional streams allow for data to be sent in both 412 directions. 414 Streams are identified within a connection by a numeric value, 415 referred to as the stream ID. A stream ID is a 62-bit integer (0 to 416 2^62-1) that is unique for all streams on a connection. Stream IDs 417 are encoded as variable-length integers (see Section 16). A QUIC 418 endpoint MUST NOT reuse a stream ID within a connection. 420 The least significant bit (0x1) of the stream ID identifies the 421 initiator of the stream. Client-initiated streams have even-numbered 422 stream IDs (with the bit set to 0), and server-initiated streams have 423 odd-numbered stream IDs (with the bit set to 1). 425 The second least significant bit (0x2) of the stream ID distinguishes 426 between bidirectional streams (with the bit set to 0) and 427 unidirectional streams (with the bit set to 1). 429 The least significant two bits from a stream ID therefore identify a 430 stream as one of four types, as summarized in Table 1. 432 +------+----------------------------------+ 433 | Bits | Stream Type | 434 +------+----------------------------------+ 435 | 0x0 | Client-Initiated, Bidirectional | 436 | | | 437 | 0x1 | Server-Initiated, Bidirectional | 438 | | | 439 | 0x2 | Client-Initiated, Unidirectional | 440 | | | 441 | 0x3 | Server-Initiated, Unidirectional | 442 +------+----------------------------------+ 444 Table 1: Stream ID Types 446 Within each type, streams are created with numerically increasing 447 stream IDs. A stream ID that is used out of order results in all 448 streams of that type with lower-numbered stream IDs also being 449 opened. 451 The first bidirectional stream opened by the client has a stream ID 452 of 0. 454 2.2. Sending and Receiving Data 456 STREAM frames (Section 19.8) encapsulate data sent by an application. 457 An endpoint uses the Stream ID and Offset fields in STREAM frames to 458 place data in order. 460 Endpoints MUST be able to deliver stream data to an application as an 461 ordered byte-stream. Delivering an ordered byte-stream requires that 462 an endpoint buffer any data that is received out of order, up to the 463 advertised flow control limit. 465 QUIC makes no specific allowances for delivery of stream data out of 466 order. However, implementations MAY choose to offer the ability to 467 deliver data out of order to a receiving application. 469 An endpoint could receive data for a stream at the same stream offset 470 multiple times. Data that has already been received can be 471 discarded. The data at a given offset MUST NOT change if it is sent 472 multiple times; an endpoint MAY treat receipt of different data at 473 the same offset within a stream as a connection error of type 474 PROTOCOL_VIOLATION. 476 Streams are an ordered byte-stream abstraction with no other 477 structure visible to QUIC. STREAM frame boundaries are not expected 478 to be preserved when data is transmitted, retransmitted after packet 479 loss, or delivered to the application at a receiver. 481 An endpoint MUST NOT send data on any stream without ensuring that it 482 is within the flow control limits set by its peer. Flow control is 483 described in detail in Section 4. 485 2.3. Stream Prioritization 487 Stream multiplexing can have a significant effect on application 488 performance if resources allocated to streams are correctly 489 prioritized. 491 QUIC does not provide a mechanism for exchanging prioritization 492 information. Instead, it relies on receiving priority information 493 from the application that uses QUIC. 495 A QUIC implementation SHOULD provide ways in which an application can 496 indicate the relative priority of streams. When deciding which 497 streams to dedicate resources to, the implementation SHOULD use the 498 information provided by the application. 500 2.4. Required Operations on Streams 502 There are certain operations which an application MUST be able to 503 perform when interacting with QUIC streams. This document does not 504 specify an API, but any implementation of this version of QUIC MUST 505 expose the ability to perform the operations described in this 506 section on a QUIC stream. 508 On the sending part of a stream, application protocols need to be 509 able to: 511 o write data, understanding when stream flow control credit 512 (Section 4.1) has successfully been reserved to send the written 513 data 515 o end the stream (clean termination), resulting in a STREAM frame 516 (Section 19.8) with the FIN bit set; and 518 o reset the stream (abrupt termination), resulting in a RESET_STREAM 519 frame (Section 19.4), even if the stream was already ended. 521 On the receiving part of a stream, application protocols need to be 522 able to: 524 o read data 526 o abort reading of the stream and request closure, possibly 527 resulting in a STOP_SENDING frame (Section 19.5) 529 Applications also need to be informed of state changes on streams, 530 including when the peer has opened or reset a stream, when a peer 531 aborts reading on a stream, when new data is available, and when data 532 can or cannot be written to the stream due to flow control. 534 3. Stream States 536 This section describes streams in terms of their send or receive 537 components. Two state machines are described: one for the streams on 538 which an endpoint transmits data (Section 3.1), and another for 539 streams on which an endpoint receives data (Section 3.2). 541 Unidirectional streams use the applicable state machine directly. 542 Bidirectional streams use both state machines. For the most part, 543 the use of these state machines is the same whether the stream is 544 unidirectional or bidirectional. The conditions for opening a stream 545 are slightly more complex for a bidirectional stream because the 546 opening of either send or receive sides causes the stream to open in 547 both directions. 549 An endpoint MUST open streams of the same type in increasing order of 550 stream ID. 552 Note: These states are largely informative. This document uses 553 stream states to describe rules for when and how different types 554 of frames can be sent and the reactions that are expected when 555 different types of frames are received. Though these state 556 machines are intended to be useful in implementing QUIC, these 557 states aren't intended to constrain implementations. An 558 implementation can define a different state machine as long as its 559 behavior is consistent with an implementation that implements 560 these states. 562 3.1. Sending Stream States 564 Figure 1 shows the states for the part of a stream that sends data to 565 a peer. 567 o 568 | Create Stream (Sending) 569 | Peer Creates Bidirectional Stream 570 v 571 +-------+ 572 | Ready | Send RESET_STREAM 573 | |-----------------------. 574 +-------+ | 575 | | 576 | Send STREAM / | 577 | STREAM_DATA_BLOCKED | 578 | | 579 | Peer Creates | 580 | Bidirectional Stream | 581 v | 582 +-------+ | 583 | Send | Send RESET_STREAM | 584 | |---------------------->| 585 +-------+ | 586 | | 587 | Send STREAM + FIN | 588 v v 589 +-------+ +-------+ 590 | Data | Send RESET_STREAM | Reset | 591 | Sent |------------------>| Sent | 592 +-------+ +-------+ 593 | | 594 | Recv All ACKs | Recv ACK 595 v v 596 +-------+ +-------+ 597 | Data | | Reset | 598 | Recvd | | Recvd | 599 +-------+ +-------+ 601 Figure 1: States for Sending Parts of Streams 603 The sending part of stream that the endpoint initiates (types 0 and 2 604 for clients, 1 and 3 for servers) is opened by the application. The 605 "Ready" state represents a newly created stream that is able to 606 accept data from the application. Stream data might be buffered in 607 this state in preparation for sending. 609 Sending the first STREAM or STREAM_DATA_BLOCKED frame causes a 610 sending part of a stream to enter the "Send" state. An 611 implementation might choose to defer allocating a stream ID to a 612 stream until it sends the first STREAM frame and enters this state, 613 which can allow for better stream prioritization. 615 The sending part of a bidirectional stream initiated by a peer (type 616 0 for a server, type 1 for a client) enters the "Ready" state then 617 immediately transitions to the "Send" state if the receiving part 618 enters the "Recv" state (Section 3.2). 620 In the "Send" state, an endpoint transmits - and retransmits as 621 necessary - stream data in STREAM frames. The endpoint respects the 622 flow control limits set by its peer, and continues to accept and 623 process MAX_STREAM_DATA frames. An endpoint in the "Send" state 624 generates STREAM_DATA_BLOCKED frames if it is blocked from sending by 625 stream or connection flow control limits Section 4.1. 627 After the application indicates that all stream data has been sent 628 and a STREAM frame containing the FIN bit is sent, the sending part 629 of the stream enters the "Data Sent" state. From this state, the 630 endpoint only retransmits stream data as necessary. The endpoint 631 does not need to check flow control limits or send 632 STREAM_DATA_BLOCKED frames for a stream in this state. 633 MAX_STREAM_DATA frames might be received until the peer receives the 634 final stream offset. The endpoint can safely ignore any 635 MAX_STREAM_DATA frames it receives from its peer for a stream in this 636 state. 638 Once all stream data has been successfully acknowledged, the sending 639 part of the stream enters the "Data Recvd" state, which is a terminal 640 state. 642 From any of the "Ready", "Send", or "Data Sent" states, an 643 application can signal that it wishes to abandon transmission of 644 stream data. Alternatively, an endpoint might receive a STOP_SENDING 645 frame from its peer. In either case, the endpoint sends a 646 RESET_STREAM frame, which causes the stream to enter the "Reset Sent" 647 state. 649 An endpoint MAY send a RESET_STREAM as the first frame that mentions 650 a stream; this causes the sending part of that stream to open and 651 then immediately transition to the "Reset Sent" state. 653 Once a packet containing a RESET_STREAM has been acknowledged, the 654 sending part of the stream enters the "Reset Recvd" state, which is a 655 terminal state. 657 3.2. Receiving Stream States 659 Figure 2 shows the states for the part of a stream that receives data 660 from a peer. The states for a receiving part of a stream mirror only 661 some of the states of the sending part of the stream at the peer. 662 The receiving part of a stream does not track states on the sending 663 part that cannot be observed, such as the "Ready" state. Instead, 664 the receiving part of a stream tracks the delivery of data to the 665 application, some of which cannot be observed by the sender. 667 o 668 | Recv STREAM / STREAM_DATA_BLOCKED / RESET_STREAM 669 | Create Bidirectional Stream (Sending) 670 | Recv MAX_STREAM_DATA / STOP_SENDING (Bidirectional) 671 | Create Higher-Numbered Stream 672 v 673 +-------+ 674 | Recv | Recv RESET_STREAM 675 | |-----------------------. 676 +-------+ | 677 | | 678 | Recv STREAM + FIN | 679 v | 680 +-------+ | 681 | Size | Recv RESET_STREAM | 682 | Known |---------------------->| 683 +-------+ | 684 | | 685 | Recv All Data | 686 v v 687 +-------+ Recv RESET_STREAM +-------+ 688 | Data |--- (optional) --->| Reset | 689 | Recvd | Recv All Data | Recvd | 690 +-------+<-- (optional) ----+-------+ 691 | | 692 | App Read All Data | App Read RST 693 v v 694 +-------+ +-------+ 695 | Data | | Reset | 696 | Read | | Read | 697 +-------+ +-------+ 699 Figure 2: States for Receiving Parts of Streams 701 The receiving part of a stream initiated by a peer (types 1 and 3 for 702 a client, or 0 and 2 for a server) is created when the first STREAM, 703 STREAM_DATA_BLOCKED, or RESET_STREAM is received for that stream. 704 For bidirectional streams initiated by a peer, receipt of a 705 MAX_STREAM_DATA or STOP_SENDING frame for the sending part of the 706 stream also creates the receiving part. The initial state for the 707 receiving part of stream is "Recv". 709 The receiving part of a stream enters the "Recv" state when the 710 sending part of a bidirectional stream initiated by the endpoint 711 (type 0 for a client, type 1 for a server) enters the "Ready" state. 713 An endpoint opens a bidirectional stream when a MAX_STREAM_DATA or 714 STOP_SENDING frame is received from the peer for that stream. 715 Receiving a MAX_STREAM_DATA frame for an unopened stream indicates 716 that the remote peer has opened the stream and is providing flow 717 control credit. Receiving a STOP_SENDING frame for an unopened 718 stream indicates that the remote peer no longer wishes to receive 719 data on this stream. Either frame might arrive before a STREAM or 720 STREAM_DATA_BLOCKED frame if packets are lost or reordered. 722 Before a stream is created, all streams of the same type with lower- 723 numbered stream IDs MUST be created. This ensures that the creation 724 order for streams is consistent on both endpoints. 726 In the "Recv" state, the endpoint receives STREAM and 727 STREAM_DATA_BLOCKED frames. Incoming data is buffered and can be 728 reassembled into the correct order for delivery to the application. 729 As data is consumed by the application and buffer space becomes 730 available, the endpoint sends MAX_STREAM_DATA frames to allow the 731 peer to send more data. 733 When a STREAM frame with a FIN bit is received, the final size of the 734 stream is known (see Section 4.4). The receiving part of the stream 735 then enters the "Size Known" state. In this state, the endpoint no 736 longer needs to send MAX_STREAM_DATA frames, it only receives any 737 retransmissions of stream data. 739 Once all data for the stream has been received, the receiving part 740 enters the "Data Recvd" state. This might happen as a result of 741 receiving the same STREAM frame that causes the transition to "Size 742 Known". After all data has been received, any STREAM or 743 STREAM_DATA_BLOCKED frames for the stream can be discarded. 745 The "Data Recvd" state persists until stream data has been delivered 746 to the application. Once stream data has been delivered, the stream 747 enters the "Data Read" state, which is a terminal state. 749 Receiving a RESET_STREAM frame in the "Recv" or "Size Known" states 750 causes the stream to enter the "Reset Recvd" state. This might cause 751 the delivery of stream data to the application to be interrupted. 753 It is possible that all stream data is received when a RESET_STREAM 754 is received (that is, from the "Data Recvd" state). Similarly, it is 755 possible for remaining stream data to arrive after receiving a 756 RESET_STREAM frame (the "Reset Recvd" state). An implementation is 757 free to manage this situation as it chooses. 759 Sending RESET_STREAM means that an endpoint cannot guarantee delivery 760 of stream data; however there is no requirement that stream data not 761 be delivered if a RESET_STREAM is received. An implementation MAY 762 interrupt delivery of stream data, discard any data that was not 763 consumed, and signal the receipt of the RESET_STREAM. A RESET_STREAM 764 signal might be suppressed or withheld if stream data is completely 765 received and is buffered to be read by the application. If the 766 RESET_STREAM is suppressed, the receiving part of the stream remains 767 in "Data Recvd". 769 Once the application receives the signal indicating that the stream 770 was reset, the receiving part of the stream transitions to the "Reset 771 Read" state, which is a terminal state. 773 3.3. Permitted Frame Types 775 The sender of a stream sends just three frame types that affect the 776 state of a stream at either sender or receiver: STREAM 777 (Section 19.8), STREAM_DATA_BLOCKED (Section 19.13), and RESET_STREAM 778 (Section 19.4). 780 A sender MUST NOT send any of these frames from a terminal state 781 ("Data Recvd" or "Reset Recvd"). A sender MUST NOT send STREAM or 782 STREAM_DATA_BLOCKED after sending a RESET_STREAM; that is, in the 783 terminal states and in the "Reset Sent" state. A receiver could 784 receive any of these three frames in any state, due to the 785 possibility of delayed delivery of packets carrying them. 787 The receiver of a stream sends MAX_STREAM_DATA (Section 19.10) and 788 STOP_SENDING frames (Section 19.5). 790 The receiver only sends MAX_STREAM_DATA in the "Recv" state. A 791 receiver can send STOP_SENDING in any state where it has not received 792 a RESET_STREAM frame; that is states other than "Reset Recvd" or 793 "Reset Read". However there is little value in sending a 794 STOP_SENDING frame in the "Data Recvd" state, since all stream data 795 has been received. A sender could receive either of these two frames 796 in any state as a result of delayed delivery of packets. 798 3.4. Bidirectional Stream States 800 A bidirectional stream is composed of sending and receiving parts. 801 Implementations may represent states of the bidirectional stream as 802 composites of sending and receiving stream states. The simplest 803 model presents the stream as "open" when either sending or receiving 804 parts are in a non-terminal state and "closed" when both sending and 805 receiving streams are in terminal states. 807 Table 2 shows a more complex mapping of bidirectional stream states 808 that loosely correspond to the stream states in HTTP/2 [HTTP2]. This 809 shows that multiple states on sending or receiving parts of streams 810 are mapped to the same composite state. Note that this is just one 811 possibility for such a mapping; this mapping requires that data is 812 acknowledged before the transition to a "closed" or "half-closed" 813 state. 815 +-----------------------+---------------------+---------------------+ 816 | Sending Part | Receiving Part | Composite State | 817 +-----------------------+---------------------+---------------------+ 818 | No Stream/Ready | No Stream/Recv *1 | idle | 819 | | | | 820 | Ready/Send/Data Sent | Recv/Size Known | open | 821 | | | | 822 | Ready/Send/Data Sent | Data Recvd/Data | half-closed | 823 | | Read | (remote) | 824 | | | | 825 | Ready/Send/Data Sent | Reset Recvd/Reset | half-closed | 826 | | Read | (remote) | 827 | | | | 828 | Data Recvd | Recv/Size Known | half-closed (local) | 829 | | | | 830 | Reset Sent/Reset | Recv/Size Known | half-closed (local) | 831 | Recvd | | | 832 | | | | 833 | Reset Sent/Reset | Data Recvd/Data | closed | 834 | Recvd | Read | | 835 | | | | 836 | Reset Sent/Reset | Reset Recvd/Reset | closed | 837 | Recvd | Read | | 838 | | | | 839 | Data Recvd | Data Recvd/Data | closed | 840 | | Read | | 841 | | | | 842 | Data Recvd | Reset Recvd/Reset | closed | 843 | | Read | | 844 +-----------------------+---------------------+---------------------+ 846 Table 2: Possible Mapping of Stream States to HTTP/2 848 Note (*1): A stream is considered "idle" if it has not yet been 849 created, or if the receiving part of the stream is in the "Recv" 850 state without yet having received any frames. 852 3.5. Solicited State Transitions 854 If an application is no longer interested in the data it is receiving 855 on a stream, it can abort reading the stream and specify an 856 application error code. 858 If the stream is in the "Recv" or "Size Known" states, the transport 859 SHOULD signal this by sending a STOP_SENDING frame to prompt closure 860 of the stream in the opposite direction. This typically indicates 861 that the receiving application is no longer reading data it receives 862 from the stream, but it is not a guarantee that incoming data will be 863 ignored. 865 STREAM frames received after sending STOP_SENDING are still counted 866 toward connection and stream flow control, even though these frames 867 can be discarded upon receipt. 869 A STOP_SENDING frame requests that the receiving endpoint send a 870 RESET_STREAM frame. An endpoint that receives a STOP_SENDING frame 871 MUST send a RESET_STREAM frame if the stream is in the Ready or Send 872 state. If the stream is in the Data Sent state and any outstanding 873 data is declared lost, an endpoint SHOULD send a RESET_STREAM frame 874 in lieu of a retransmission. 876 An endpoint SHOULD copy the error code from the STOP_SENDING frame to 877 the RESET_STREAM frame it sends, but MAY use any application error 878 code. The endpoint that sends a STOP_SENDING frame MAY ignore the 879 error code carried in any RESET_STREAM frame it receives. 881 If the STOP_SENDING frame is received on a stream that is already in 882 the "Data Sent" state, an endpoint that wishes to cease 883 retransmission of previously-sent STREAM frames on that stream MUST 884 first send a RESET_STREAM frame. 886 STOP_SENDING SHOULD only be sent for a stream that has not been reset 887 by the peer. STOP_SENDING is most useful for streams in the "Recv" 888 or "Size Known" states. 890 An endpoint is expected to send another STOP_SENDING frame if a 891 packet containing a previous STOP_SENDING is lost. However, once 892 either all stream data or a RESET_STREAM frame has been received for 893 the stream - that is, the stream is in any state other than "Recv" or 894 "Size Known" - sending a STOP_SENDING frame is unnecessary. 896 An endpoint that wishes to terminate both directions of a 897 bidirectional stream can terminate one direction by sending a 898 RESET_STREAM, and it can encourage prompt termination in the opposite 899 direction by sending a STOP_SENDING frame. 901 4. Flow Control 903 It is necessary to limit the amount of data that a receiver could 904 buffer, to prevent a fast sender from overwhelming a slow receiver, 905 or to prevent a malicious sender from consuming a large amount of 906 memory at a receiver. To enable a receiver to limit memory 907 commitment to a connection and to apply back pressure on the sender, 908 streams are flow controlled both individually and as an aggregate. A 909 QUIC receiver controls the maximum amount of data the sender can send 910 on a stream at any time, as described in Section 4.1 and Section 4.2 912 Similarly, to limit concurrency within a connection, a QUIC endpoint 913 controls the maximum cumulative number of streams that its peer can 914 initiate, as described in Section 4.5. 916 Data sent in CRYPTO frames is not flow controlled in the same way as 917 stream data. QUIC relies on the cryptographic protocol 918 implementation to avoid excessive buffering of data; see [QUIC-TLS]. 919 The implementation SHOULD provide an interface to QUIC to tell it 920 about its buffering limits so that there is not excessive buffering 921 at multiple layers. 923 4.1. Data Flow Control 925 QUIC employs a credit-based flow-control scheme similar to that in 926 HTTP/2 [HTTP2], where a receiver advertises the number of bytes it is 927 prepared to receive on a given stream and for the entire connection. 928 This leads to two levels of data flow control in QUIC: 930 o Stream flow control, which prevents a single stream from consuming 931 the entire receive buffer for a connection by limiting the amount 932 of data that can be sent on any stream. 934 o Connection flow control, which prevents senders from exceeding a 935 receiver's buffer capacity for the connection, by limiting the 936 total bytes of stream data sent in STREAM frames on all streams. 938 A receiver sets initial credits for all streams by sending transport 939 parameters during the handshake (Section 7.3). A receiver sends 940 MAX_STREAM_DATA (Section 19.10) or MAX_DATA (Section 19.9) frames to 941 the sender to advertise additional credit. 943 A receiver advertises credit for a stream by sending a 944 MAX_STREAM_DATA frame with the Stream ID field set appropriately. A 945 MAX_STREAM_DATA frame indicates the maximum absolute byte offset of a 946 stream. A receiver could use the current offset of data consumed to 947 determine the flow control offset to be advertised. A receiver MAY 948 send MAX_STREAM_DATA frames in multiple packets in order to make sure 949 that the sender receives an update before running out of flow control 950 credit, even if one of the packets is lost. 952 A receiver advertises credit for a connection by sending a MAX_DATA 953 frame, which indicates the maximum of the sum of the absolute byte 954 offsets of all streams. A receiver maintains a cumulative sum of 955 bytes received on all streams, which is used to check for flow 956 control violations. A receiver might use a sum of bytes consumed on 957 all streams to determine the maximum data limit to be advertised. 959 A receiver can advertise a larger offset by sending MAX_STREAM_DATA 960 or MAX_DATA frames. Once a receiver advertises an offset, it MAY 961 advertise a smaller offset, but this has no effect. 963 A receiver MUST close the connection with a FLOW_CONTROL_ERROR error 964 (Section 11) if the sender violates the advertised connection or 965 stream data limits. 967 A sender MUST ignore any MAX_STREAM_DATA or MAX_DATA frames that do 968 not increase flow control limits. 970 If a sender runs out of flow control credit, it will be unable to 971 send new data and is considered blocked. A sender SHOULD send a 972 STREAM_DATA_BLOCKED or DATA_BLOCKED frame to indicate it has data to 973 write but is blocked by flow control limits. These frames are 974 expected to be sent infrequently in common cases, but they are 975 considered useful for debugging and monitoring purposes. 977 A sender SHOULD NOT send multiple STREAM_DATA_BLOCKED or DATA_BLOCKED 978 frames for the same data limit, unless the original frame is 979 determined to be lost. Another STREAM_DATA_BLOCKED or DATA_BLOCKED 980 frame can be sent after the data limit is increased. 982 4.2. Flow Credit Increments 984 This document leaves when and how many bytes to advertise in a 985 MAX_STREAM_DATA or MAX_DATA frame to implementations, but offers a 986 few considerations. These frames contribute to connection overhead. 987 Therefore frequently sending frames with small changes is 988 undesirable. At the same time, larger increments to limits are 989 necessary to avoid blocking if updates are less frequent, requiring 990 larger resource commitments at the receiver. Thus there is a trade- 991 off between resource commitment and overhead when determining how 992 large a limit is advertised. 994 A receiver can use an autotuning mechanism to tune the frequency and 995 amount of advertised additional credit based on a round-trip time 996 estimate and the rate at which the receiving application consumes 997 data, similar to common TCP implementations. As an optimization, 998 sending frames related to flow control only when there are other 999 frames to send or when a peer is blocked ensures that flow control 1000 doesn't cause extra packets to be sent. 1002 If a sender runs out of flow control credit, it will be unable to 1003 send new data and is considered blocked. It is generally considered 1004 best to not let the sender become blocked. To avoid blocking a 1005 sender, and to reasonably account for the possibility of loss, a 1006 receiver should send a MAX_DATA or MAX_STREAM_DATA frame at least two 1007 round trips before it expects the sender to get blocked. 1009 A receiver MUST NOT wait for a STREAM_DATA_BLOCKED or DATA_BLOCKED 1010 frame before sending MAX_STREAM_DATA or MAX_DATA, since doing so will 1011 mean that a sender will be blocked for at least an entire round trip, 1012 and potentially for longer if the peer chooses to not send 1013 STREAM_DATA_BLOCKED or DATA_BLOCKED frames. 1015 4.3. Handling Stream Cancellation 1017 Endpoints need to eventually agree on the amount of flow control 1018 credit that has been consumed, to avoid either exceeding flow control 1019 limits or deadlocking. 1021 On receipt of a RESET_STREAM frame, an endpoint will tear down state 1022 for the matching stream and ignore further data arriving on that 1023 stream. Without the offset included in RESET_STREAM, the two 1024 endpoints could disagree on the number of bytes that count towards 1025 connection flow control. 1027 To remedy this issue, a RESET_STREAM frame (Section 19.4) includes 1028 the final size of data sent on the stream. On receiving a 1029 RESET_STREAM frame, a receiver definitively knows how many bytes were 1030 sent on that stream before the RESET_STREAM frame, and the receiver 1031 MUST use the final size of the stream to account for all bytes sent 1032 on the stream in its connection level flow controller. 1034 RESET_STREAM terminates one direction of a stream abruptly. For a 1035 bidirectional stream, RESET_STREAM has no effect on data flow in the 1036 opposite direction. Both endpoints MUST maintain flow control state 1037 for the stream in the unterminated direction until that direction 1038 enters a terminal state, or until one of the endpoints sends 1039 CONNECTION_CLOSE. 1041 4.4. Stream Final Size 1043 The final size is the amount of flow control credit that is consumed 1044 by a stream. Assuming that every contiguous byte on the stream was 1045 sent once, the final size is the number of bytes sent. More 1046 generally, this is one higher than the offset of the byte with the 1047 largest offset sent on the stream, or zero if no bytes were sent. 1049 For a stream that is reset, the final size is carried explicitly in a 1050 RESET_STREAM frame. Otherwise, the final size is the offset plus the 1051 length of a STREAM frame marked with a FIN flag, or 0 in the case of 1052 incoming unidirectional streams. 1054 An endpoint will know the final size for a stream when the receiving 1055 part of the stream enters the "Size Known" or "Reset Recvd" state 1056 (Section 3). 1058 An endpoint MUST NOT send data on a stream at or beyond the final 1059 size. 1061 Once a final size for a stream is known, it cannot change. If a 1062 RESET_STREAM or STREAM frame is received indicating a change in the 1063 final size for the stream, an endpoint SHOULD respond with a 1064 FINAL_SIZE_ERROR error (see Section 11). A receiver SHOULD treat 1065 receipt of data at or beyond the final size as a FINAL_SIZE_ERROR 1066 error, even after a stream is closed. Generating these errors is not 1067 mandatory, but only because requiring that an endpoint generate these 1068 errors also means that the endpoint needs to maintain the final size 1069 state for closed streams, which could mean a significant state 1070 commitment. 1072 4.5. Controlling Concurrency 1074 An endpoint limits the cumulative number of incoming streams a peer 1075 can open. Only streams with a stream ID less than (max_stream * 4 + 1076 initial_stream_id_for_type) can be opened (see Table 5). Initial 1077 limits are set in the transport parameters (see Section 18.2) and 1078 subsequently limits are advertised using MAX_STREAMS frames 1079 (Section 19.11). Separate limits apply to unidirectional and 1080 bidirectional streams. 1082 If a max_streams transport parameter or MAX_STREAMS frame is received 1083 with a value greater than 2^60, this would allow a maximum stream ID 1084 that cannot be expressed as a variable-length integer (see 1085 Section 16). If either is received, the connection MUST be closed 1086 immediately with a connection error of type STREAM_LIMIT_ERROR (see 1087 Section 10.3). 1089 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 1090 that receives a frame with a stream ID exceeding the limit it has 1091 sent MUST treat this as a connection error of type STREAM_LIMIT_ERROR 1092 (Section 11). 1094 Once a receiver advertises a stream limit using the MAX_STREAMS 1095 frame, advertising a smaller limit has no effect. A receiver MUST 1096 ignore any MAX_STREAMS frame that does not increase the stream limit. 1098 As with stream and connection flow control, this document leaves when 1099 and how many streams to advertise to a peer via MAX_STREAMS to 1100 implementations. Implementations might choose to increase limits as 1101 streams close to keep the number of streams available to peers 1102 roughly consistent. 1104 An endpoint that is unable to open a new stream due to the peer's 1105 limits SHOULD send a STREAMS_BLOCKED frame (Section 19.14). This 1106 signal is considered useful for debugging. An endpoint MUST NOT wait 1107 to receive this signal before advertising additional credit, since 1108 doing so will mean that the peer will be blocked for at least an 1109 entire round trip, and potentially for longer if the peer chooses to 1110 not send STREAMS_BLOCKED frames. 1112 5. Connections 1114 QUIC's connection establishment combines version negotiation with the 1115 cryptographic and transport handshakes to reduce connection 1116 establishment latency, as described in Section 7. Once established, 1117 a connection may migrate to a different IP or port at either endpoint 1118 as described in Section 9. Finally, a connection may be terminated 1119 by either endpoint, as described in Section 10. 1121 5.1. Connection ID 1123 Each connection possesses a set of connection identifiers, or 1124 connection IDs, each of which can identify the connection. 1125 Connection IDs are independently selected by endpoints; each endpoint 1126 selects the connection IDs that its peer uses. 1128 The primary function of a connection ID is to ensure that changes in 1129 addressing at lower protocol layers (UDP, IP) don't cause packets for 1130 a QUIC connection to be delivered to the wrong endpoint. Each 1131 endpoint selects connection IDs using an implementation-specific (and 1132 perhaps deployment-specific) method which will allow packets with 1133 that connection ID to be routed back to the endpoint and identified 1134 by the endpoint upon receipt. 1136 Connection IDs MUST NOT contain any information that can be used by 1137 an external observer (that is, one that does not cooperate with the 1138 issuer) to correlate them with other connection IDs for the same 1139 connection. As a trivial example, this means the same connection ID 1140 MUST NOT be issued more than once on the same connection. 1142 Packets with long headers include Source Connection ID and 1143 Destination Connection ID fields. These fields are used to set the 1144 connection IDs for new connections; see Section 7.2 for details. 1146 Packets with short headers (Section 17.3) only include the 1147 Destination Connection ID and omit the explicit length. The length 1148 of the Destination Connection ID field is expected to be known to 1149 endpoints. Endpoints using a load balancer that routes based on 1150 connection ID could agree with the load balancer on a fixed length 1151 for connection IDs, or agree on an encoding scheme. A fixed portion 1152 could encode an explicit length, which allows the entire connection 1153 ID to vary in length and still be used by the load balancer. 1155 A Version Negotiation (Section 17.2.1) packet echoes the connection 1156 IDs selected by the client, both to ensure correct routing toward the 1157 client and to allow the client to validate that the packet is in 1158 response to an Initial packet. 1160 A zero-length connection ID MAY be used when the connection ID is not 1161 needed for routing and the address/port tuple of packets is 1162 sufficient to identify a connection. An endpoint whose peer has 1163 selected a zero-length connection ID MUST continue to use a zero- 1164 length connection ID for the lifetime of the connection and MUST NOT 1165 send packets from any other local address. 1167 When an endpoint has requested a non-zero-length connection ID, it 1168 needs to ensure that the peer has a supply of connection IDs from 1169 which to choose for packets sent to the endpoint. These connection 1170 IDs are supplied by the endpoint using the NEW_CONNECTION_ID frame 1171 (Section 19.15). 1173 5.1.1. Issuing Connection IDs 1175 Each Connection ID has an associated sequence number to assist in 1176 deduplicating messages. The initial connection ID issued by an 1177 endpoint is sent in the Source Connection ID field of the long packet 1178 header (Section 17.2) during the handshake. The sequence number of 1179 the initial connection ID is 0. If the preferred_address transport 1180 parameter is sent, the sequence number of the supplied connection ID 1181 is 1. 1183 Additional connection IDs are communicated to the peer using 1184 NEW_CONNECTION_ID frames (Section 19.15). The sequence number on 1185 each newly-issued connection ID MUST increase by 1. The connection 1186 ID randomly selected by the client in the Initial packet and any 1187 connection ID provided by a Retry packet are not assigned sequence 1188 numbers unless a server opts to retain them as its initial connection 1189 ID. 1191 When an endpoint issues a connection ID, it MUST accept packets that 1192 carry this connection ID for the duration of the connection or until 1193 its peer invalidates the connection ID via a RETIRE_CONNECTION_ID 1194 frame (Section 19.16). 1196 An endpoint SHOULD ensure that its peer has a sufficient number of 1197 available and unused connection IDs. Endpoints store received 1198 connection IDs for future use and advertise the number of connection 1199 IDs they are willing to store with the active_connection_id_limit 1200 transport parameter. An endpoint SHOULD NOT provide more connection 1201 IDs than the peer's limit. 1203 An endpoint SHOULD supply a new connection ID when it receives a 1204 packet with a previously unused connection ID or when the peer 1205 retires one, unless providing the new connection ID would exceed the 1206 peer's limit. An endpoint MAY limit the frequency or the total 1207 number of connection IDs issued for each connection to avoid the risk 1208 of running out of connection IDs; see Section 10.4.2. 1210 An endpoint that initiates migration and requires non-zero-length 1211 connection IDs SHOULD ensure that the pool of connection IDs 1212 available to its peer allows the peer to use a new connection ID on 1213 migration, as the peer will close the connection if the pool is 1214 exhausted. 1216 5.1.2. Consuming and Retiring Connection IDs 1218 An endpoint can change the connection ID it uses for a peer to 1219 another available one at any time during the connection. An endpoint 1220 consumes connection IDs in response to a migrating peer; see 1221 Section 9.5 for more. 1223 An endpoint maintains a set of connection IDs received from its peer, 1224 any of which it can use when sending packets. When the endpoint 1225 wishes to remove a connection ID from use, it sends a 1226 RETIRE_CONNECTION_ID frame to its peer. Sending a 1227 RETIRE_CONNECTION_ID frame indicates that the connection ID will not 1228 be used again and requests that the peer replace it with a new 1229 connection ID using a NEW_CONNECTION_ID frame. 1231 As discussed in Section 9.5, each connection ID MUST be used on 1232 packets sent from only one local address. An endpoint that migrates 1233 away from a local address SHOULD retire all connection IDs used on 1234 that address once it no longer plans to use that address. 1236 An endpoint can request that its peer retire connection IDs by 1237 sending a NEW_CONNECTION_ID frame with an increased Retire Prior To 1238 field. Upon receipt, the peer SHOULD retire the corresponding 1239 connection IDs and send the corresponding RETIRE_CONNECTION_ID frames 1240 in a timely manner. Failing to do so can cause packets to be 1241 delayed, lost, or cause the original endpoint to send a stateless 1242 reset in response to a connection ID it can no longer route 1243 correctly. 1245 An endpoint MAY discard a connection ID for which retirement has been 1246 requested once an interval of no less than 3 PTO has elapsed since an 1247 acknowledgement is received for the NEW_CONNECTION_ID frame 1248 requesting that retirement. Subsequent incoming packets using that 1249 connection ID could elicit a response with the corresponding 1250 stateless reset token. 1252 5.2. Matching Packets to Connections 1254 Incoming packets are classified on receipt. Packets can either be 1255 associated with an existing connection, or - for servers - 1256 potentially create a new connection. 1258 Hosts try to associate a packet with an existing connection. If the 1259 packet has a Destination Connection ID corresponding to an existing 1260 connection, QUIC processes that packet accordingly. Note that more 1261 than one connection ID can be associated with a connection; see 1262 Section 5.1. 1264 If the Destination Connection ID is zero length and the packet 1265 matches the address/port tuple of a connection where the host did not 1266 require connection IDs, QUIC processes the packet as part of that 1267 connection. Endpoints SHOULD either reject connection attempts that 1268 use the same addresses as existing connections, or use a non-zero- 1269 length Destination Connection ID so that packets can be correctly 1270 attributed to connections. 1272 Endpoints can send a Stateless Reset (Section 10.4) for any packets 1273 that cannot be attributed to an existing connection. A stateless 1274 reset allows a peer to more quickly identify when a connection 1275 becomes unusable. 1277 Packets that are matched to an existing connection are discarded if 1278 the packets are inconsistent with the state of that connection. For 1279 example, packets are discarded if they indicate a different protocol 1280 version than that of the connection, or if the removal of packet 1281 protection is unsuccessful once the expected keys are available. 1283 Invalid packets without packet protection, such as Initial, Retry, or 1284 Version Negotiation, MAY be discarded. An endpoint MUST generate a 1285 connection error if it commits changes to state before discovering an 1286 error. 1288 5.2.1. Client Packet Handling 1290 Valid packets sent to clients always include a Destination Connection 1291 ID that matches a value the client selects. Clients that choose to 1292 receive zero-length connection IDs can use the address/port tuple to 1293 identify a connection. Packets that don't match an existing 1294 connection are discarded. 1296 Due to packet reordering or loss, a client might receive packets for 1297 a connection that are encrypted with a key it has not yet computed. 1298 The client MAY drop these packets, or MAY buffer them in anticipation 1299 of later packets that allow it to compute the key. 1301 If a client receives a packet that has an unsupported version, it 1302 MUST discard that packet. 1304 5.2.2. Server Packet Handling 1306 If a server receives a packet that has an unsupported version, but 1307 the packet is sufficiently large to initiate a new connection for any 1308 version supported by the server, it SHOULD send a Version Negotiation 1309 packet as described in Section 6.1. Servers MAY rate control these 1310 packets to avoid storms of Version Negotiation packets. Otherwise, 1311 servers MUST drop packets that specify unsupported versions. 1313 The first packet for an unsupported version can use different 1314 semantics and encodings for any version-specific field. In 1315 particular, different packet protection keys might be used for 1316 different versions. Servers that do not support a particular version 1317 are unlikely to be able to decrypt the payload of the packet. 1318 Servers SHOULD NOT attempt to decode or decrypt a packet from an 1319 unknown version, but instead send a Version Negotiation packet, 1320 provided that the packet is sufficiently long. 1322 Packets with a supported version, or no version field, are matched to 1323 a connection using the connection ID or - for packets with zero- 1324 length connection IDs - the address tuple. If the packet doesn't 1325 match an existing connection, the server continues below. 1327 If the packet is an Initial packet fully conforming with the 1328 specification, the server proceeds with the handshake (Section 7). 1329 This commits the server to the version that the client selected. 1331 If a server isn't currently accepting any new connections, it SHOULD 1332 send an Initial packet containing a CONNECTION_CLOSE frame with error 1333 code SERVER_BUSY. 1335 If the packet is a 0-RTT packet, the server MAY buffer a limited 1336 number of these packets in anticipation of a late-arriving Initial 1337 packet. Clients are not able to send Handshake packets prior to 1338 receiving a server response, so servers SHOULD ignore any such 1339 packets. 1341 Servers MUST drop incoming packets under all other circumstances. 1343 5.3. Life of a QUIC Connection 1345 TBD. 1347 5.4. Required Operations on Connections 1349 There are certain operations which an application MUST be able to 1350 perform when interacting with the QUIC transport. This document does 1351 not specify an API, but any implementation of this version of QUIC 1352 MUST expose the ability to perform the operations described in this 1353 section on a QUIC connection. 1355 When implementing the client role, applications need to be able to: 1357 o open a connection, which begins the exchange described in 1358 Section 7; 1360 o enable 0-RTT; and 1362 o be informed when 0-RTT has been accepted or rejected by a server. 1364 When implementing the server role, applications need to be able to: 1366 o listen for incoming connections, which prepares for the exchange 1367 described in Section 7; 1369 o if Early Data is supported, embed application-controlled data in 1370 the TLS resumption ticket sent to the client; and 1372 o if Early Data is supported, retrieve application-controlled data 1373 from the client's resumption ticket and enable rejecting Early 1374 Data based on that information. 1376 In either role, applications need to be able to: 1378 o configure minimum values for the initial number of permitted 1379 streams of each type, as communicated in the transport parameters 1380 (Section 7.3); 1382 o control resource allocation of various types, including flow 1383 control and the number of permitted streams of each type; 1385 o identify whether the handshake has completed successfully or is 1386 still ongoing 1388 o keep a connection from silently closing, either by generating PING 1389 frames (Section 19.2) or by requesting that the transport send 1390 additional frames before the idle timeout expires (Section 10.2); 1391 and 1393 o immediately close (Section 10.3) the connection. 1395 6. Version Negotiation 1397 Version negotiation ensures that client and server agree to a QUIC 1398 version that is mutually supported. A server sends a Version 1399 Negotiation packet in response to each packet that might initiate a 1400 new connection; see Section 5.2 for details. 1402 The size of the first packet sent by a client will determine whether 1403 a server sends a Version Negotiation packet. Clients that support 1404 multiple QUIC versions SHOULD pad the first packet they send to the 1405 largest of the minimum packet sizes across all versions they support. 1406 This ensures that the server responds if there is a mutually 1407 supported version. 1409 6.1. Sending Version Negotiation Packets 1411 If the version selected by the client is not acceptable to the 1412 server, the server responds with a Version Negotiation packet (see 1413 Section 17.2.1). This includes a list of versions that the server 1414 will accept. An endpoint MUST NOT send a Version Negotiation packet 1415 in response to receiving a Version Negotiation packet. 1417 This system allows a server to process packets with unsupported 1418 versions without retaining state. Though either the Initial packet 1419 or the Version Negotiation packet that is sent in response could be 1420 lost, the client will send new packets until it successfully receives 1421 a response or it abandons the connection attempt. As a result, the 1422 client discards all state for the connection and does not send any 1423 more packets on the connection. 1425 A server MAY limit the number of Version Negotiation packets it 1426 sends. For instance, a server that is able to recognize packets as 1427 0-RTT might choose not to send Version Negotiation packets in 1428 response to 0-RTT packets with the expectation that it will 1429 eventually receive an Initial packet. 1431 6.2. Handling Version Negotiation Packets 1433 When a client receives a Version Negotiation packet, it MUST abandon 1434 the current connection attempt. Version Negotiation packets are 1435 designed to allow future versions of QUIC to negotiate the version in 1436 use between endpoints. Future versions of QUIC might change how 1437 implementations that support multiple versions of QUIC react to 1438 Version Negotiation packets when attempting to establish a connection 1439 using this version. How to perform version negotiation is left as 1440 future work defined by future versions of QUIC. In particular, that 1441 future work will need to ensure robustness against version downgrade 1442 attacks Section 21.10. 1444 6.2.1. Version Negotiation Between Draft Versions 1446 [[RFC editor: please remove this section before publication.]] 1448 When a draft implementation receives a Version Negotiation packet, it 1449 MAY use it to attempt a new connection with one of the versions 1450 listed in the packet, instead of abandoning the current connection 1451 attempt Section 6.2. 1453 The client MUST check that the Destination and Source Connection ID 1454 fields match the Source and Destination Connection ID fields in a 1455 packet that the client sent. If this check fails, the packet MUST be 1456 discarded. 1458 Once the Version Negotiation packet is determined to be valid, the 1459 client then selects an acceptable protocol version from the list 1460 provided by the server. The client then attempts to create a new 1461 connection using that version. The new connection MUST use a new 1462 random Destination Connection ID different from the one it had 1463 previously sent. 1465 Note that this mechanism does not protect against downgrade attacks 1466 and MUST NOT be used outside of draft implementations. 1468 6.3. Using Reserved Versions 1470 For a server to use a new version in the future, clients need to 1471 correctly handle unsupported versions. To help ensure this, a server 1472 SHOULD include a version that is reserved for forcing version 1473 negotiation (0x?a?a?a?a as defined in Section 15) when generating a 1474 Version Negotiation packet. 1476 The design of version negotiation permits a server to avoid 1477 maintaining state for packets that it rejects in this fashion. 1479 A client MAY send a packet using a version that is reserved for 1480 forcing version negotiation. This can be used to solicit a list of 1481 supported versions from a server. 1483 7. Cryptographic and Transport Handshake 1485 QUIC relies on a combined cryptographic and transport handshake to 1486 minimize connection establishment latency. QUIC uses the CRYPTO 1487 frame Section 19.6 to transmit the cryptographic handshake. Version 1488 0x00000001 of QUIC uses TLS as described in [QUIC-TLS]; a different 1489 QUIC version number could indicate that a different cryptographic 1490 handshake protocol is in use. 1492 QUIC provides reliable, ordered delivery of the cryptographic 1493 handshake data. QUIC packet protection is used to encrypt as much of 1494 the handshake protocol as possible. The cryptographic handshake MUST 1495 provide the following properties: 1497 o authenticated key exchange, where 1499 * a server is always authenticated, 1501 * a client is optionally authenticated, 1503 * every connection produces distinct and unrelated keys, 1505 * keying material is usable for packet protection for both 0-RTT 1506 and 1-RTT packets, and 1508 * 1-RTT keys have forward secrecy 1510 o authenticated values for transport parameters of both endpoints, 1511 and confidentiality protection for server transport parameters 1512 (see Section 7.3) 1514 o authenticated negotiation of an application protocol (TLS uses 1515 ALPN [RFC7301] for this purpose) 1517 The first CRYPTO frame from a client MUST be sent in a single packet. 1518 Any second attempt that is triggered by address validation (see 1519 Section 8.1) MUST also be sent within a single packet. This avoids 1520 having to reassemble a message from multiple packets. 1522 The first client packet of the cryptographic handshake protocol MUST 1523 fit within a 1232 byte QUIC packet payload. This includes overheads 1524 that reduce the space available to the cryptographic handshake 1525 protocol. 1527 An endpoint can verify support for Explicit Congestion Notification 1528 (ECN) in the first packets it sends, as described in Section 13.4.2. 1530 The CRYPTO frame can be sent in different packet number spaces. The 1531 sequence numbers used by CRYPTO frames to ensure ordered delivery of 1532 cryptographic handshake data start from zero in each packet number 1533 space. 1535 Endpoints MUST explicitly negotiate an application protocol. This 1536 avoids situations where there is a disagreement about the protocol 1537 that is in use. 1539 7.1. Example Handshake Flows 1541 Details of how TLS is integrated with QUIC are provided in 1542 [QUIC-TLS], but some examples are provided here. An extension of 1543 this exchange to support client address validation is shown in 1544 Section 8.1.1. 1546 Once any address validation exchanges are complete, the cryptographic 1547 handshake is used to agree on cryptographic keys. The cryptographic 1548 handshake is carried in Initial (Section 17.2.2) and Handshake 1549 (Section 17.2.4) packets. 1551 Figure 3 provides an overview of the 1-RTT handshake. Each line 1552 shows a QUIC packet with the packet type and packet number shown 1553 first, followed by the frames that are typically contained in those 1554 packets. So, for instance the first packet is of type Initial, with 1555 packet number 0, and contains a CRYPTO frame carrying the 1556 ClientHello. 1558 Note that multiple QUIC packets - even of different encryption levels 1559 - may be coalesced into a single UDP datagram (see Section 12.2), and 1560 so this handshake may consist of as few as 4 UDP datagrams, or any 1561 number more. For instance, the server's first flight contains 1562 packets from the Initial encryption level (obfuscation), the 1563 Handshake level, and "0.5-RTT data" from the server at the 1-RTT 1564 encryption level. 1566 Client Server 1568 Initial[0]: CRYPTO[CH] -> 1570 Initial[0]: CRYPTO[SH] ACK[0] 1571 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1572 <- 1-RTT[0]: STREAM[1, "..."] 1574 Initial[1]: ACK[0] 1575 Handshake[0]: CRYPTO[FIN], ACK[0] 1576 1-RTT[0]: STREAM[0, "..."], ACK[0] -> 1578 1-RTT[1]: STREAM[3, "..."], ACK[0] 1579 <- Handshake[1]: ACK[0] 1581 Figure 3: Example 1-RTT Handshake 1583 Figure 4 shows an example of a connection with a 0-RTT handshake and 1584 a single packet of 0-RTT data. Note that as described in 1585 Section 12.3, the server acknowledges 0-RTT data at the 1-RTT 1586 encryption level, and the client sends 1-RTT packets in the same 1587 packet number space. 1589 Client Server 1591 Initial[0]: CRYPTO[CH] 1592 0-RTT[0]: STREAM[0, "..."] -> 1594 Initial[0]: CRYPTO[SH] ACK[0] 1595 Handshake[0] CRYPTO[EE, FIN] 1596 <- 1-RTT[0]: STREAM[1, "..."] ACK[0] 1598 Initial[1]: ACK[0] 1599 Handshake[0]: CRYPTO[FIN], ACK[0] 1600 1-RTT[1]: STREAM[0, "..."] ACK[0] -> 1602 1-RTT[1]: STREAM[3, "..."], ACK[1] 1603 <- Handshake[1]: ACK[0] 1605 Figure 4: Example 0-RTT Handshake 1607 7.2. Negotiating Connection IDs 1609 A connection ID is used to ensure consistent routing of packets, as 1610 described in Section 5.1. The long header contains two connection 1611 IDs: the Destination Connection ID is chosen by the recipient of the 1612 packet and is used to provide consistent routing; the Source 1613 Connection ID is used to set the Destination Connection ID used by 1614 the peer. 1616 During the handshake, packets with the long header (Section 17.2) are 1617 used to establish the connection ID that each endpoint uses. Each 1618 endpoint uses the Source Connection ID field to specify the 1619 connection ID that is used in the Destination Connection ID field of 1620 packets being sent to them. Upon receiving a packet, each endpoint 1621 sets the Destination Connection ID it sends to match the value of the 1622 Source Connection ID that they receive. 1624 When an Initial packet is sent by a client that has not previously 1625 received an Initial or Retry packet from the server, it populates the 1626 Destination Connection ID field with an unpredictable value. This 1627 MUST be at least 8 bytes in length. Until a packet is received from 1628 the server, the client MUST use the same value unless it abandons the 1629 connection attempt and starts a new one. The initial Destination 1630 Connection ID is used to determine packet protection keys for Initial 1631 packets. 1633 The client populates the Source Connection ID field with a value of 1634 its choosing and sets the SCID Len field to indicate the length. 1636 The first flight of 0-RTT packets use the same Destination and Source 1637 Connection ID values as the client's first Initial. 1639 Upon first receiving an Initial or Retry packet from the server, the 1640 client uses the Source Connection ID supplied by the server as the 1641 Destination Connection ID for subsequent packets, including any 1642 subsequent 0-RTT packets. That means that a client might change the 1643 Destination Connection ID twice during connection establishment, once 1644 in response to a Retry and once in response to the first Initial 1645 packet from the server. Once a client has received an Initial packet 1646 from the server, it MUST discard any packet it receives with a 1647 different Source Connection ID. 1649 A client MUST only change the value it sends in the Destination 1650 Connection ID in response to the first packet of each type it 1651 receives from the server (Retry or Initial); a server MUST set its 1652 value based on the Initial packet. Any additional changes are not 1653 permitted; if subsequent packets of those types include a different 1654 Source Connection ID, they MUST be discarded. This avoids problems 1655 that might arise from stateless processing of multiple Initial 1656 packets producing different connection IDs. 1658 The connection ID can change over the lifetime of a connection, 1659 especially in response to connection migration (Section 9); see 1660 Section 5.1.1 for details. 1662 7.3. Transport Parameters 1664 During connection establishment, both endpoints make authenticated 1665 declarations of their transport parameters. These declarations are 1666 made unilaterally by each endpoint. Endpoints are required to comply 1667 with the restrictions implied by these parameters; the description of 1668 each parameter includes rules for its handling. 1670 The encoding of the transport parameters is detailed in Section 18. 1672 QUIC includes the encoded transport parameters in the cryptographic 1673 handshake. Once the handshake completes, the transport parameters 1674 declared by the peer are available. Each endpoint validates the 1675 value provided by its peer. 1677 Definitions for each of the defined transport parameters are included 1678 in Section 18.2. 1680 An endpoint MUST treat receipt of a transport parameter with an 1681 invalid value as a connection error of type 1682 TRANSPORT_PARAMETER_ERROR. 1684 An endpoint MUST NOT send a parameter more than once in a given 1685 transport parameters extension. An endpoint SHOULD treat receipt of 1686 duplicate transport parameters as a connection error of type 1687 TRANSPORT_PARAMETER_ERROR. 1689 A server MUST include the original_connection_id transport parameter 1690 (Section 18.2) if it sent a Retry packet to enable validation of the 1691 Retry, as described in Section 17.2.5. 1693 7.3.1. Values of Transport Parameters for 0-RTT 1695 Both endpoints store the value of the server transport parameters 1696 from a connection and apply them to any 0-RTT packets that are sent 1697 in subsequent connections to that peer, except for transport 1698 parameters that are explicitly excluded. Remembered transport 1699 parameters apply to the new connection until the handshake completes 1700 and the client starts sending 1-RTT packets. Once the handshake 1701 completes, the client uses the transport parameters established in 1702 the handshake. 1704 The definition of new transport parameters (Section 7.3.2) MUST 1705 specify whether they MUST, MAY, or MUST NOT be stored for 0-RTT. A 1706 client need not store a transport parameter it cannot process. 1708 A client MUST NOT use remembered values for the following parameters: 1709 original_connection_id, preferred_address, stateless_reset_token, 1710 ack_delay_exponent and active_connection_id_limit. The client MUST 1711 use the server's new values in the handshake instead, and absent new 1712 values from the server, the default value. 1714 A client that attempts to send 0-RTT data MUST remember all other 1715 transport parameters used by the server. The server can remember 1716 these transport parameters, or store an integrity-protected copy of 1717 the values in the ticket and recover the information when accepting 1718 0-RTT data. A server uses the transport parameters in determining 1719 whether to accept 0-RTT data. 1721 If 0-RTT data is accepted by the server, the server MUST NOT reduce 1722 any limits or alter any values that might be violated by the client 1723 with its 0-RTT data. In particular, a server that accepts 0-RTT data 1724 MUST NOT set values for the following parameters (Section 18.2) that 1725 are smaller than the remembered value of the parameters. 1727 o initial_max_data 1729 o initial_max_stream_data_bidi_local 1731 o initial_max_stream_data_bidi_remote 1733 o initial_max_stream_data_uni 1735 o initial_max_streams_bidi 1737 o initial_max_streams_uni 1739 Omitting or setting a zero value for certain transport parameters can 1740 result in 0-RTT data being enabled, but not usable. The applicable 1741 subset of transport parameters that permit sending of application 1742 data SHOULD be set to non-zero values for 0-RTT. This includes 1743 initial_max_data and either initial_max_streams_bidi and 1744 initial_max_stream_data_bidi_remote, or initial_max_streams_uni and 1745 initial_max_stream_data_uni. 1747 A server MUST either reject 0-RTT data or abort a handshake if the 1748 implied values for transport parameters cannot be supported. 1750 When sending frames in 0-RTT packets, a client MUST only use 1751 remembered transport parameters; importantly, it MUST NOT use updated 1752 values that it learns from the server's updated transport parameters 1753 or from frames received in 1-RTT packets. Updated values of 1754 transport parameters from the handshake apply only to 1-RTT packets. 1755 For instance, flow control limits from remembered transport 1756 parameters apply to all 0-RTT packets even if those values are 1757 increased by the handshake or by frames sent in 1-RTT packets. A 1758 server MAY treat use of updated transport parameters in 0-RTT as a 1759 connection error of type PROTOCOL_VIOLATION. 1761 7.3.2. New Transport Parameters 1763 New transport parameters can be used to negotiate new protocol 1764 behavior. An endpoint MUST ignore transport parameters that it does 1765 not support. Absence of a transport parameter therefore disables any 1766 optional protocol feature that is negotiated using the parameter. As 1767 described in Section 18.1, some identifiers are reserved in order to 1768 exercise this requirement. 1770 New transport parameters can be registered according to the rules in 1771 Section 22.1. 1773 7.4. Cryptographic Message Buffering 1775 Implementations need to maintain a buffer of CRYPTO data received out 1776 of order. Because there is no flow control of CRYPTO frames, an 1777 endpoint could potentially force its peer to buffer an unbounded 1778 amount of data. 1780 Implementations MUST support buffering at least 4096 bytes of data 1781 received in CRYPTO frames out of order. Endpoints MAY choose to 1782 allow more data to be buffered during the handshake. A larger limit 1783 during the handshake could allow for larger keys or credentials to be 1784 exchanged. An endpoint's buffer size does not need to remain 1785 constant during the life of the connection. 1787 Being unable to buffer CRYPTO frames during the handshake can lead to 1788 a connection failure. If an endpoint's buffer is exceeded during the 1789 handshake, it can expand its buffer temporarily to complete the 1790 handshake. If an endpoint does not expand its buffer, it MUST close 1791 the connection with a CRYPTO_BUFFER_EXCEEDED error code. 1793 Once the handshake completes, if an endpoint is unable to buffer all 1794 data in a CRYPTO frame, it MAY discard that CRYPTO frame and all 1795 CRYPTO frames received in the future, or it MAY close the connection 1796 with a CRYPTO_BUFFER_EXCEEDED error code. Packets containing 1797 discarded CRYPTO frames MUST be acknowledged because the packet has 1798 been received and processed by the transport even though the CRYPTO 1799 frame was discarded. 1801 8. Address Validation 1803 Address validation is used by QUIC to avoid being used for a traffic 1804 amplification attack. In such an attack, a packet is sent to a 1805 server with spoofed source address information that identifies a 1806 victim. If a server generates more or larger packets in response to 1807 that packet, the attacker can use the server to send more data toward 1808 the victim than it would be able to send on its own. 1810 The primary defense against amplification attack is verifying that an 1811 endpoint is able to receive packets at the transport address that it 1812 claims. Address validation is performed both during connection 1813 establishment (see Section 8.1) and during connection migration (see 1814 Section 8.2). 1816 8.1. Address Validation During Connection Establishment 1818 Connection establishment implicitly provides address validation for 1819 both endpoints. In particular, receipt of a packet protected with 1820 Handshake keys confirms that the client received the Initial packet 1821 from the server. Once the server has successfully processed a 1822 Handshake packet from the client, it can consider the client address 1823 to have been validated. 1825 Prior to validating the client address, servers MUST NOT send more 1826 than three times as many bytes as the number of bytes they have 1827 received. This limits the magnitude of any amplification attack that 1828 can be mounted using spoofed source addresses. In determining this 1829 limit, servers only count the size of successfully processed packets. 1831 Clients MUST ensure that UDP datagrams containing only Initial 1832 packets are sized to at least 1200 bytes, adding padding to packets 1833 in the datagram as necessary. Sending padded datagrams ensures that 1834 the server is not overly constrained by the amplification 1835 restriction. 1837 Packet loss, in particular loss of a Handshake packet from the 1838 server, can cause a situation in which the server cannot send when 1839 the client has no data to send and the anti-amplification limit is 1840 reached. In order to avoid this causing a handshake deadlock, 1841 clients SHOULD send a packet upon a crypto retransmission timeout, as 1842 described in [QUIC-RECOVERY]. If the client has no data to 1843 retransmit and does not have Handshake keys, it SHOULD send an 1844 Initial packet in a UDP datagram of at least 1200 bytes. If the 1845 client has Handshake keys, it SHOULD send a Handshake packet. 1847 A server might wish to validate the client address before starting 1848 the cryptographic handshake. QUIC uses a token in the Initial packet 1849 to provide address validation prior to completing the handshake. 1850 This token is delivered to the client during connection establishment 1851 with a Retry packet (see Section 8.1.1) or in a previous connection 1852 using the NEW_TOKEN frame (see Section 8.1.2). 1854 In addition to sending limits imposed prior to address validation, 1855 servers are also constrained in what they can send by the limits set 1856 by the congestion controller. Clients are only constrained by the 1857 congestion controller. 1859 8.1.1. Address Validation using Retry Packets 1861 Upon receiving the client's Initial packet, the server can request 1862 address validation by sending a Retry packet (Section 17.2.5) 1863 containing a token. This token MUST be repeated by the client in all 1864 Initial packets it sends for that connection after it receives the 1865 Retry packet. In response to processing an Initial containing a 1866 token, a server can either abort the connection or permit it to 1867 proceed. 1869 As long as it is not possible for an attacker to generate a valid 1870 token for its own address (see Section 8.1.3) and the client is able 1871 to return that token, it proves to the server that it received the 1872 token. 1874 A server can also use a Retry packet to defer the state and 1875 processing costs of connection establishment. By giving the client a 1876 different connection ID to use, a server can cause the connection to 1877 be routed to a server instance with more resources available for new 1878 connections. 1880 A flow showing the use of a Retry packet is shown in Figure 5. 1882 Client Server 1884 Initial[0]: CRYPTO[CH] -> 1886 <- Retry+Token 1888 Initial+Token[1]: CRYPTO[CH] -> 1890 Initial[0]: CRYPTO[SH] ACK[1] 1891 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1892 <- 1-RTT[0]: STREAM[1, "..."] 1894 Figure 5: Example Handshake with Retry 1896 8.1.2. Address Validation for Future Connections 1898 A server MAY provide clients with an address validation token during 1899 one connection that can be used on a subsequent connection. Address 1900 validation is especially important with 0-RTT because a server 1901 potentially sends a significant amount of data to a client in 1902 response to 0-RTT data. 1904 The server uses the NEW_TOKEN frame Section 19.7 to provide the 1905 client with an address validation token that can be used to validate 1906 future connections. The client includes this token in Initial 1907 packets to provide address validation in a future connection. The 1908 client MUST include the token in all Initial packets it sends, unless 1909 a Retry replaces the token with a newer one. The client MUST NOT use 1910 the token provided in a Retry for future connections. Servers MAY 1911 discard any Initial packet that does not carry the expected token. 1913 A token SHOULD be constructed in a way that allows the server to 1914 distinguish it from tokens that are sent in Retry packets as they are 1915 carried in the same field. 1917 The token MUST NOT include information that would allow it to be 1918 linked by an on-path observer to the connection on which it was 1919 issued. For example, it cannot include the connection ID or 1920 addressing information unless the values are encrypted. 1922 Unlike the token that is created for a Retry packet, there might be 1923 some time between when the token is created and when the token is 1924 subsequently used. Thus, a token SHOULD have an expiration time, 1925 which could be either an explicit expiration time or an issued 1926 timestamp that can be used to dynamically calculate the expiration 1927 time. A server can store the expiration time or include it in an 1928 encrypted form in the token. 1930 It is unlikely that the client port number is the same on two 1931 different connections; validating the port is therefore unlikely to 1932 be successful. 1934 If the client has a token received in a NEW_TOKEN frame on a previous 1935 connection to what it believes to be the same server, it SHOULD 1936 include that value in the Token field of its Initial packet. 1937 Including a token might allow the server to validate the client 1938 address without an additional round trip. 1940 A token allows a server to correlate activity between the connection 1941 where the token was issued and any connection where it is used. 1942 Clients that want to break continuity of identity with a server MAY 1943 discard tokens provided using the NEW_TOKEN frame. A token obtained 1944 in a Retry packet MUST be used immediately during the connection 1945 attempt and cannot be used in subsequent connection attempts. 1947 A client SHOULD NOT reuse a token in different connections. Reusing 1948 a token allows connections to be linked by entities on the network 1949 path; see Section 9.5. A client MUST NOT reuse a token if it 1950 believes that its point of network attachment has changed since the 1951 token was last used; that is, if there is a change in its local IP 1952 address or network interface. A client needs to start the connection 1953 process over if there is any change in its local address prior to 1954 completing the handshake. 1956 Clients might receive multiple tokens on a single connection. Aside 1957 from preventing linkability, any token can be used in any connection 1958 attempt. Servers can send additional tokens to either enable address 1959 validation for multiple connection attempts or to replace older 1960 tokens that might become invalid. For a client, this ambiguity means 1961 that sending the most recent unused token is most likely to be 1962 effective. Though saving and using older tokens has no negative 1963 consequences, clients can regard older tokens as being less likely be 1964 useful to the server for address validation. 1966 When a server receives an Initial packet with an address validation 1967 token, it MUST attempt to validate the token, unless it has already 1968 completed address validation. If the token is invalid then the 1969 server SHOULD proceed as if the client did not have a validated 1970 address, including potentially sending a Retry. If the validation 1971 succeeds, the server SHOULD then allow the handshake to proceed. 1973 Note: The rationale for treating the client as unvalidated rather 1974 than discarding the packet is that the client might have received 1975 the token in a previous connection using the NEW_TOKEN frame, and 1976 if the server has lost state, it might be unable to validate the 1977 token at all, leading to connection failure if the packet is 1978 discarded. A server SHOULD encode tokens provided with NEW_TOKEN 1979 frames and Retry packets differently, and validate the latter more 1980 strictly. 1982 In a stateless design, a server can use encrypted and authenticated 1983 tokens to pass information to clients that the server can later 1984 recover and use to validate a client address. Tokens are not 1985 integrated into the cryptographic handshake and so they are not 1986 authenticated. For instance, a client might be able to reuse a 1987 token. To avoid attacks that exploit this property, a server can 1988 limit its use of tokens to only the information needed to validate 1989 client addresses. 1991 Attackers could replay tokens to use servers as amplifiers in DDoS 1992 attacks. To protect against such attacks, servers SHOULD ensure that 1993 tokens sent in Retry packets are only accepted for a short time. 1994 Tokens that are provided in NEW_TOKEN frames (see Section 19.7) need 1995 to be valid for longer, but SHOULD NOT be accepted multiple times in 1996 a short period. Servers are encouraged to allow tokens to be used 1997 only once, if possible. 1999 8.1.3. Address Validation Token Integrity 2001 An address validation token MUST be difficult to guess. Including a 2002 large enough random value in the token would be sufficient, but this 2003 depends on the server remembering the value it sends to clients. 2005 A token-based scheme allows the server to offload any state 2006 associated with validation to the client. For this design to work, 2007 the token MUST be covered by integrity protection against 2008 modification or falsification by clients. Without integrity 2009 protection, malicious clients could generate or guess values for 2010 tokens that would be accepted by the server. Only the server 2011 requires access to the integrity protection key for tokens. 2013 There is no need for a single well-defined format for the token 2014 because the server that generates the token also consumes it. A 2015 token could include information about the claimed client address (IP 2016 and port), a timestamp, and any other supplementary information the 2017 server will need to validate the token in the future. 2019 8.2. Path Validation 2021 Path validation is used during connection migration (see Section 9 2022 and Section 9.6) by the migrating endpoint to verify reachability of 2023 a peer from a new local address. In path validation, endpoints test 2024 reachability between a specific local address and a specific peer 2025 address, where an address is the two-tuple of IP address and port. 2027 Path validation tests that packets (PATH_CHALLENGE) can be both sent 2028 to and received (PATH_RESPONSE) from a peer on the path. 2029 Importantly, it validates that the packets received from the 2030 migrating endpoint do not carry a spoofed source address. 2032 Path validation can be used at any time by either endpoint. For 2033 instance, an endpoint might check that a peer is still in possession 2034 of its address after a period of quiescence. 2036 Path validation is not designed as a NAT traversal mechanism. Though 2037 the mechanism described here might be effective for the creation of 2038 NAT bindings that support NAT traversal, the expectation is that one 2039 or other peer is able to receive packets without first having sent a 2040 packet on that path. Effective NAT traversal needs additional 2041 synchronization mechanisms that are not provided here. 2043 An endpoint MAY bundle PATH_CHALLENGE and PATH_RESPONSE frames that 2044 are used for path validation with other frames. In particular, an 2045 endpoint may pad a packet carrying a PATH_CHALLENGE for PMTU 2046 discovery, or an endpoint may bundle a PATH_RESPONSE with its own 2047 PATH_CHALLENGE. 2049 When probing a new path, an endpoint might want to ensure that its 2050 peer has an unused connection ID available for responses. The 2051 endpoint can send NEW_CONNECTION_ID and PATH_CHALLENGE frames in the 2052 same packet. This ensures that an unused connection ID will be 2053 available to the peer when sending a response. 2055 8.3. Initiating Path Validation 2057 To initiate path validation, an endpoint sends a PATH_CHALLENGE frame 2058 containing a random payload on the path to be validated. 2060 An endpoint MAY send multiple PATH_CHALLENGE frames to guard against 2061 packet loss, however an endpoint SHOULD NOT send multiple 2062 PATH_CHALLENGE frames in a single packet. An endpoint SHOULD NOT 2063 send a PATH_CHALLENGE more frequently than it would an Initial 2064 packet, ensuring that connection migration is no more load on a new 2065 path than establishing a new connection. 2067 The endpoint MUST use unpredictable data in every PATH_CHALLENGE 2068 frame so that it can associate the peer's response with the 2069 corresponding PATH_CHALLENGE. 2071 8.4. Path Validation Responses 2073 On receiving a PATH_CHALLENGE frame, an endpoint MUST respond 2074 immediately by echoing the data contained in the PATH_CHALLENGE frame 2075 in a PATH_RESPONSE frame. 2077 An endpoint MUST NOT send more than one PATH_RESPONSE frame in 2078 response to one PATH_CHALLENGE frame (see Section 13.3). The peer is 2079 expected to send more PATH_CHALLENGE frames as necessary to evoke 2080 additional PATH_RESPONSE frames. 2082 8.5. Successful Path Validation 2084 A new address is considered valid when a PATH_RESPONSE frame is 2085 received that contains the data that was sent in a previous 2086 PATH_CHALLENGE. Receipt of an acknowledgment for a packet containing 2087 a PATH_CHALLENGE frame is not adequate validation, since the 2088 acknowledgment can be spoofed by a malicious peer. 2090 Note that receipt on a different local address does not result in 2091 path validation failure, as it might be a result of a forwarded 2092 packet (see Section 9.3.3) or misrouting. It is possible that a 2093 valid PATH_RESPONSE might be received in the future. 2095 8.6. Failed Path Validation 2097 Path validation only fails when the endpoint attempting to validate 2098 the path abandons its attempt to validate the path. 2100 Endpoints SHOULD abandon path validation based on a timer. When 2101 setting this timer, implementations are cautioned that the new path 2102 could have a longer round-trip time than the original. A value of 2103 three times the larger of the current Probe Timeout (PTO) or the 2104 initial timeout (that is, 2*kInitialRtt) as defined in 2105 [QUIC-RECOVERY] is RECOMMENDED. That is: 2107 validation_timeout = max(3*PTO, 6*kInitialRtt) 2109 Note that the endpoint might receive packets containing other frames 2110 on the new path, but a PATH_RESPONSE frame with appropriate data is 2111 required for path validation to succeed. 2113 When an endpoint abandons path validation, it determines that the 2114 path is unusable. This does not necessarily imply a failure of the 2115 connection - endpoints can continue sending packets over other paths 2116 as appropriate. If no paths are available, an endpoint can wait for 2117 a new path to become available or close the connection. 2119 A path validation might be abandoned for other reasons besides 2120 failure. Primarily, this happens if a connection migration to a new 2121 path is initiated while a path validation on the old path is in 2122 progress. 2124 9. Connection Migration 2126 The use of a connection ID allows connections to survive changes to 2127 endpoint addresses (IP address and port), such as those caused by an 2128 endpoint migrating to a new network. This section describes the 2129 process by which an endpoint migrates to a new address. 2131 The design of QUIC relies on endpoints retaining a stable address for 2132 the duration of the handshake. An endpoint MUST NOT initiate 2133 connection migration before the handshake is confirmed, as defined in 2134 section 4.1.2 of [QUIC-TLS]. 2136 An endpoint also MUST NOT send packets from a different local 2137 address, actively initiating migration, if the peer sent the 2138 "disable_active_migration" transport parameter during the handshake. 2139 An endpoint which has sent this transport parameter, but detects that 2140 a peer has nonetheless migrated to a different network MUST either 2141 drop the incoming packets on that path without generating a stateless 2142 reset or proceed with path validation and allow the peer to migrate. 2143 Generating a stateless reset or closing the connection would allow 2144 third parties in the network to cause connections to close by 2145 spoofing or otherwise manipulating observed traffic. 2147 Not all changes of peer address are intentional, or active, 2148 migrations. The peer could experience NAT rebinding: a change of 2149 address due to a middlebox, usually a NAT, allocating a new outgoing 2150 port or even a new outgoing IP address for a flow. An endpoint MUST 2151 perform path validation (Section 8.2) if it detects any change to a 2152 peer's address, unless it has previously validated that address. 2154 When an endpoint has no validated path on which to send packets, it 2155 MAY discard connection state. An endpoint capable of connection 2156 migration MAY wait for a new path to become available before 2157 discarding connection state. 2159 This document limits migration of connections to new client 2160 addresses, except as described in Section 9.6. Clients are 2161 responsible for initiating all migrations. Servers do not send non- 2162 probing packets (see Section 9.1) toward a client address until they 2163 see a non-probing packet from that address. If a client receives 2164 packets from an unknown server address, the client MUST discard these 2165 packets. 2167 9.1. Probing a New Path 2169 An endpoint MAY probe for peer reachability from a new local address 2170 using path validation Section 8.2 prior to migrating the connection 2171 to the new local address. Failure of path validation simply means 2172 that the new path is not usable for this connection. Failure to 2173 validate a path does not cause the connection to end unless there are 2174 no valid alternative paths available. 2176 An endpoint uses a new connection ID for probes sent from a new local 2177 address, see Section 9.5 for further discussion. An endpoint that 2178 uses a new local address needs to ensure that at least one new 2179 connection ID is available at the peer. That can be achieved by 2180 including a NEW_CONNECTION_ID frame in the probe. 2182 Receiving a PATH_CHALLENGE frame from a peer indicates that the peer 2183 is probing for reachability on a path. An endpoint sends a 2184 PATH_RESPONSE in response as per Section 8.2. 2186 PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames 2187 are "probing frames", and all other frames are "non-probing frames". 2188 A packet containing only probing frames is a "probing packet", and a 2189 packet containing any other frame is a "non-probing packet". 2191 9.2. Initiating Connection Migration 2193 An endpoint can migrate a connection to a new local address by 2194 sending packets containing non-probing frames from that address. 2196 Each endpoint validates its peer's address during connection 2197 establishment. Therefore, a migrating endpoint can send to its peer 2198 knowing that the peer is willing to receive at the peer's current 2199 address. Thus an endpoint can migrate to a new local address without 2200 first validating the peer's address. 2202 When migrating, the new path might not support the endpoint's current 2203 sending rate. Therefore, the endpoint resets its congestion 2204 controller, as described in Section 9.4. 2206 The new path might not have the same ECN capability. Therefore, the 2207 endpoint verifies ECN capability as described in Section 13.4. 2209 Receiving acknowledgments for data sent on the new path serves as 2210 proof of the peer's reachability from the new address. Note that 2211 since acknowledgments may be received on any path, return 2212 reachability on the new path is not established. To establish return 2213 reachability on the new path, an endpoint MAY concurrently initiate 2214 path validation Section 8.2 on the new path. 2216 9.3. Responding to Connection Migration 2218 Receiving a packet from a new peer address containing a non-probing 2219 frame indicates that the peer has migrated to that address. 2221 In response to such a packet, an endpoint MUST start sending 2222 subsequent packets to the new peer address and MUST initiate path 2223 validation (Section 8.2) to verify the peer's ownership of the 2224 unvalidated address. 2226 An endpoint MAY send data to an unvalidated peer address, but it MUST 2227 protect against potential attacks as described in Section 9.3.1 and 2228 Section 9.3.2. An endpoint MAY skip validation of a peer address if 2229 that address has been seen recently. 2231 An endpoint only changes the address that it sends packets to in 2232 response to the highest-numbered non-probing packet. This ensures 2233 that an endpoint does not send packets to an old peer address in the 2234 case that it receives reordered packets. 2236 After changing the address to which it sends non-probing packets, an 2237 endpoint could abandon any path validation for other addresses. 2239 Receiving a packet from a new peer address might be the result of a 2240 NAT rebinding at the peer. 2242 After verifying a new client address, the server SHOULD send new 2243 address validation tokens (Section 8) to the client. 2245 9.3.1. Peer Address Spoofing 2247 It is possible that a peer is spoofing its source address to cause an 2248 endpoint to send excessive amounts of data to an unwilling host. If 2249 the endpoint sends significantly more data than the spoofing peer, 2250 connection migration might be used to amplify the volume of data that 2251 an attacker can generate toward a victim. 2253 As described in Section 9.3, an endpoint is required to validate a 2254 peer's new address to confirm the peer's possession of the new 2255 address. Until a peer's address is deemed valid, an endpoint MUST 2256 limit the rate at which it sends data to this address. The endpoint 2257 MUST NOT send more than a minimum congestion window's worth of data 2258 per estimated round-trip time (kMinimumWindow, as defined in 2259 [QUIC-RECOVERY]). In the absence of this limit, an endpoint risks 2260 being used for a denial of service attack against an unsuspecting 2261 victim. Note that since the endpoint will not have any round-trip 2262 time measurements to this address, the estimate SHOULD be the default 2263 initial value (see [QUIC-RECOVERY]). 2265 If an endpoint skips validation of a peer address as described in 2266 Section 9.3, it does not need to limit its sending rate. 2268 9.3.2. On-Path Address Spoofing 2270 An on-path attacker could cause a spurious connection migration by 2271 copying and forwarding a packet with a spoofed address such that it 2272 arrives before the original packet. The packet with the spoofed 2273 address will be seen to come from a migrating connection, and the 2274 original packet will be seen as a duplicate and dropped. After a 2275 spurious migration, validation of the source address will fail 2276 because the entity at the source address does not have the necessary 2277 cryptographic keys to read or respond to the PATH_CHALLENGE frame 2278 that is sent to it even if it wanted to. 2280 To protect the connection from failing due to such a spurious 2281 migration, an endpoint MUST revert to using the last validated peer 2282 address when validation of a new peer address fails. 2284 If an endpoint has no state about the last validated peer address, it 2285 MUST close the connection silently by discarding all connection 2286 state. This results in new packets on the connection being handled 2287 generically. For instance, an endpoint MAY send a stateless reset in 2288 response to any further incoming packets. 2290 Note that receipt of packets with higher packet numbers from the 2291 legitimate peer address will trigger another connection migration. 2292 This will cause the validation of the address of the spurious 2293 migration to be abandoned. 2295 9.3.3. Off-Path Packet Forwarding 2297 An off-path attacker that can observe packets might forward copies of 2298 genuine packets to endpoints. If the copied packet arrives before 2299 the genuine packet, this will appear as a NAT rebinding. Any genuine 2300 packet will be discarded as a duplicate. If the attacker is able to 2301 continue forwarding packets, it might be able to cause migration to a 2302 path via the attacker. This places the attacker on path, giving it 2303 the ability to observe or drop all subsequent packets. 2305 Unlike the attack described in Section 9.3.2, the attacker can ensure 2306 that the new path is successfully validated. 2308 This style of attack relies on the attacker using a path that is 2309 approximately as fast as the direct path between endpoints. The 2310 attack is more reliable if relatively few packets are sent or if 2311 packet loss coincides with the attempted attack. 2313 A non-probing packet received on the original path that increases the 2314 maximum received packet number will cause the endpoint to move back 2315 to that path. Eliciting packets on this path increases the 2316 likelihood that the attack is unsuccessful. Therefore, mitigation of 2317 this attack relies on triggering the exchange of packets. 2319 In response to an apparent migration, endpoints MUST validate the 2320 previously active path using a PATH_CHALLENGE frame. This induces 2321 the sending of new packets on that path. If the path is no longer 2322 viable, the validation attempt will time out and fail; if the path is 2323 viable, but no longer desired, the validation will succeed, but only 2324 results in probing packets being sent on the path. 2326 An endpoint that receives a PATH_CHALLENGE on an active path SHOULD 2327 send a non-probing packet in response. If the non-probing packet 2328 arrives before any copy made by an attacker, this results in the 2329 connection being migrated back to the original path. Any subsequent 2330 migration to another path restarts this entire process. 2332 This defense is imperfect, but this is not considered a serious 2333 problem. If the path via the attack is reliably faster than the 2334 original path despite multiple attempts to use that original path, it 2335 is not possible to distinguish between attack and an improvement in 2336 routing. 2338 An endpoint could also use heuristics to improve detection of this 2339 style of attack. For instance, NAT rebinding is improbable if 2340 packets were recently received on the old path, similarly rebinding 2341 is rare on IPv6 paths. Endpoints can also look for duplicated 2342 packets. Conversely, a change in connection ID is more likely to 2343 indicate an intentional migration rather than an attack. 2345 9.4. Loss Detection and Congestion Control 2347 The capacity available on the new path might not be the same as the 2348 old path. Packets sent on the old path SHOULD NOT contribute to 2349 congestion control or RTT estimation for the new path. 2351 On confirming a peer's ownership of its new address, an endpoint MUST 2352 immediately reset the congestion controller and round-trip time 2353 estimator for the new path to initial values (see Sections A.3 and 2354 B.3 in [QUIC-RECOVERY]) unless it has knowledge that a previous send 2355 rate or round-trip time estimate is valid for the new path. For 2356 instance, an endpoint might infer that a change in only the client's 2357 port number is indicative of a NAT rebinding, meaning that the new 2358 path is likely to have similar bandwidth and round-trip time. 2359 However, this determination will be imperfect. If the determination 2360 is incorrect, the congestion controller and the RTT estimator are 2361 expected to adapt to the new path. Generally, implementations are 2362 advised to be cautious when using previous values on a new path. 2364 There may be apparent reordering at the receiver when an endpoint 2365 sends data and probes from/to multiple addresses during the migration 2366 period, since the two resulting paths may have different round-trip 2367 times. A receiver of packets on multiple paths will still send ACK 2368 frames covering all received packets. 2370 While multiple paths might be used during connection migration, a 2371 single congestion control context and a single loss recovery context 2372 (as described in [QUIC-RECOVERY]) may be adequate. For instance, an 2373 endpoint might delay switching to a new congestion control context 2374 until it is confirmed that an old path is no longer needed (such as 2375 the case in Section 9.3.3). 2377 A sender can make exceptions for probe packets so that their loss 2378 detection is independent and does not unduly cause the congestion 2379 controller to reduce its sending rate. An endpoint might set a 2380 separate timer when a PATH_CHALLENGE is sent, which is cancelled when 2381 the corresponding PATH_RESPONSE is received. If the timer fires 2382 before the PATH_RESPONSE is received, the endpoint might send a new 2383 PATH_CHALLENGE, and restart the timer for a longer period of time. 2385 9.5. Privacy Implications of Connection Migration 2387 Using a stable connection ID on multiple network paths allows a 2388 passive observer to correlate activity between those paths. An 2389 endpoint that moves between networks might not wish to have their 2390 activity correlated by any entity other than their peer, so different 2391 connection IDs are used when sending from different local addresses, 2392 as discussed in Section 5.1. For this to be effective endpoints need 2393 to ensure that connections IDs they provide cannot be linked by any 2394 other entity. 2396 At any time, endpoints MAY change the Destination Connection ID they 2397 send to a value that has not been used on another path. 2399 An endpoint MUST use a new connection ID if it initiates connection 2400 migration. Using a new connection ID eliminates the use of the 2401 connection ID for linking activity from the same connection on 2402 different networks. Header protection ensures that packet numbers 2403 cannot be used to correlate activity. This does not prevent other 2404 properties of packets, such as timing and size, from being used to 2405 correlate activity. 2407 Unintentional changes in path without a change in connection ID are 2408 possible. For example, after a period of network inactivity, NAT 2409 rebinding might cause packets to be sent on a new path when the 2410 client resumes sending. 2412 A client might wish to reduce linkability by employing a new 2413 connection ID and source UDP port when sending traffic after a period 2414 of inactivity. Changing the UDP port from which it sends packets at 2415 the same time might cause the packet to appear as a connection 2416 migration. This ensures that the mechanisms that support migration 2417 are exercised even for clients that don't experience NAT rebindings 2418 or genuine migrations. Changing port number can cause a peer to 2419 reset its congestion state (see Section 9.4), so the port SHOULD only 2420 be changed infrequently. 2422 An endpoint that exhausts available connection IDs cannot migrate. 2423 To ensure that migration is possible and packets sent on different 2424 paths cannot be correlated, endpoints SHOULD provide new connection 2425 IDs before peers migrate. 2427 9.6. Server's Preferred Address 2429 QUIC allows servers to accept connections on one IP address and 2430 attempt to transfer these connections to a more preferred address 2431 shortly after the handshake. This is particularly useful when 2432 clients initially connect to an address shared by multiple servers 2433 but would prefer to use a unicast address to ensure connection 2434 stability. This section describes the protocol for migrating a 2435 connection to a preferred server address. 2437 Migrating a connection to a new server address mid-connection is left 2438 for future work. If a client receives packets from a new server 2439 address not indicated by the preferred_address transport parameter, 2440 the client SHOULD discard these packets. 2442 9.6.1. Communicating a Preferred Address 2444 A server conveys a preferred address by including the 2445 preferred_address transport parameter in the TLS handshake. 2447 Servers MAY communicate a preferred address of each address family 2448 (IPv4 and IPv6) to allow clients to pick the one most suited to their 2449 network attachment. 2451 Once the handshake is finished, the client SHOULD select one of the 2452 two server's preferred addresses and initiate path validation (see 2453 Section 8.2) of that address using the connection ID provided in the 2454 preferred_address transport parameter. 2456 If path validation succeeds, the client SHOULD immediately begin 2457 sending all future packets to the new server address using the new 2458 connection ID and discontinue use of the old server address. If path 2459 validation fails, the client MUST continue sending all future packets 2460 to the server's original IP address. 2462 9.6.2. Responding to Connection Migration 2464 A server might receive a packet addressed to its preferred IP address 2465 at any time after it accepts a connection. If this packet contains a 2466 PATH_CHALLENGE frame, the server sends a PATH_RESPONSE frame as per 2467 Section 8.2. The server MUST send other non-probing frames from its 2468 original address until it receives a non-probing packet from the 2469 client at its preferred address and until the server has validated 2470 the new path. 2472 The server MUST probe on the path toward the client from its 2473 preferred address. This helps to guard against spurious migration 2474 initiated by an attacker. 2476 Once the server has completed its path validation and has received a 2477 non-probing packet with a new largest packet number on its preferred 2478 address, the server begins sending non-probing packets to the client 2479 exclusively from its preferred IP address. It SHOULD drop packets 2480 for this connection received on the old IP address, but MAY continue 2481 to process delayed packets. 2483 9.6.3. Interaction of Client Migration and Preferred Address 2485 A client might need to perform a connection migration before it has 2486 migrated to the server's preferred address. In this case, the client 2487 SHOULD perform path validation to both the original and preferred 2488 server address from the client's new address concurrently. 2490 If path validation of the server's preferred address succeeds, the 2491 client MUST abandon validation of the original address and migrate to 2492 using the server's preferred address. If path validation of the 2493 server's preferred address fails but validation of the server's 2494 original address succeeds, the client MAY migrate to its new address 2495 and continue sending to the server's original address. 2497 If the connection to the server's preferred address is not from the 2498 same client address, the server MUST protect against potential 2499 attacks as described in Section 9.3.1 and Section 9.3.2. In addition 2500 to intentional simultaneous migration, this might also occur because 2501 the client's access network used a different NAT binding for the 2502 server's preferred address. 2504 Servers SHOULD initiate path validation to the client's new address 2505 upon receiving a probe packet from a different address. Servers MUST 2506 NOT send more than a minimum congestion window's worth of non-probing 2507 packets to the new address before path validation is complete. 2509 A client that migrates to a new address SHOULD use a preferred 2510 address from the same address family for the server. 2512 9.7. Use of IPv6 Flow-Label and Migration 2514 Endpoints that send data using IPv6 SHOULD apply an IPv6 flow label 2515 in compliance with [RFC6437], unless the local API does not allow 2516 setting IPv6 flow labels. 2518 The IPv6 flow label SHOULD be a pseudo-random function of the source 2519 and destination addresses, source and destination UDP ports, and the 2520 destination CID. The flow label generation MUST be designed to 2521 minimize the chances of linkability with a previously used flow 2522 label, as this would enable correlating activity on multiple paths 2523 (see Section 9.5). 2525 A possible implementation is to compute the flow label as a 2526 cryptographic hash function of the source and destination addresses, 2527 source and destination UDP ports, destination CID, and a local 2528 secret. 2530 10. Connection Termination 2532 An established QUIC connection can be terminated in one of three 2533 ways: 2535 o idle timeout (Section 10.2) 2537 o immediate close (Section 10.3) 2539 o stateless reset (Section 10.4) 2541 An endpoint MAY discard connection state if it does not have a 2542 validated path on which it can send packets (see Section 8.2). 2544 10.1. Closing and Draining Connection States 2546 The closing and draining connection states exist to ensure that 2547 connections close cleanly and that delayed or reordered packets are 2548 properly discarded. These states SHOULD persist for at least three 2549 times the current Probe Timeout (PTO) interval as defined in 2550 [QUIC-RECOVERY]. 2552 An endpoint enters a closing period after initiating an immediate 2553 close (Section 10.3). While closing, an endpoint MUST NOT send 2554 packets unless they contain a CONNECTION_CLOSE frame (see 2555 Section 10.3 for details). An endpoint retains only enough 2556 information to generate a packet containing a CONNECTION_CLOSE frame 2557 and to identify packets as belonging to the connection. The 2558 endpoint's selected connection ID and the QUIC version are sufficient 2559 information to identify packets for a closing connection; an endpoint 2560 can discard all other connection state. An endpoint MAY retain 2561 packet protection keys for incoming packets to allow it to read and 2562 process a CONNECTION_CLOSE frame. 2564 The draining state is entered once an endpoint receives a signal that 2565 its peer is closing or draining. While otherwise identical to the 2566 closing state, an endpoint in the draining state MUST NOT send any 2567 packets. Retaining packet protection keys is unnecessary once a 2568 connection is in the draining state. 2570 An endpoint MAY transition from the closing period to the draining 2571 period if it receives a CONNECTION_CLOSE frame or stateless reset, 2572 both of which indicate that the peer is also closing or draining. 2573 The draining period SHOULD end when the closing period would have 2574 ended. In other words, the endpoint can use the same end time, but 2575 cease retransmission of the closing packet. 2577 Disposing of connection state prior to the end of the closing or 2578 draining period could cause delayed or reordered packets to generate 2579 an unnecessary stateless reset. Endpoints that have some alternative 2580 means to ensure that late-arriving packets on the connection do not 2581 induce a response, such as those that are able to close the UDP 2582 socket, MAY use an abbreviated draining period which can allow for 2583 faster resource recovery. Servers that retain an open socket for 2584 accepting new connections SHOULD NOT exit the closing or draining 2585 period early. 2587 Once the closing or draining period has ended, an endpoint SHOULD 2588 discard all connection state. This results in new packets on the 2589 connection being handled generically. For instance, an endpoint MAY 2590 send a stateless reset in response to any further incoming packets. 2592 The draining and closing periods do not apply when a stateless reset 2593 (Section 10.4) is sent. 2595 An endpoint is not expected to handle key updates when it is closing 2596 or draining. A key update might prevent the endpoint from moving 2597 from the closing state to draining, but it otherwise has no impact. 2599 While in the closing period, an endpoint could receive packets from a 2600 new source address, indicating a connection migration (Section 9). 2601 An endpoint in the closing state MUST strictly limit the number of 2602 packets it sends to this new address until the address is validated 2603 (see Section 8.2). A server in the closing state MAY instead choose 2604 to discard packets received from a new source address. 2606 10.2. Idle Timeout 2608 If the idle timeout is enabled, a connection is silently closed and 2609 the state is discarded when it remains idle for longer than both the 2610 advertised idle timeout (see Section 18.2) and three times the 2611 current Probe Timeout (PTO). 2613 Each endpoint advertises its own idle timeout to its peer. An 2614 endpoint restarts any timer it maintains when a packet from its peer 2615 is received and processed successfully. The timer is also restarted 2616 when sending a packet containing frames other than ACK or PADDING (an 2617 ACK-eliciting packet; see [QUIC-RECOVERY]), but only if no other ACK- 2618 eliciting packets have been sent since last receiving a packet. 2619 Restarting when sending packets ensures that connections do not 2620 prematurely time out when initiating new activity. 2622 The value for an idle timeout can be asymmetric. The value 2623 advertised by an endpoint is only used to determine whether the 2624 connection is live at that endpoint. An endpoint that sends packets 2625 near the end of the idle timeout period of a peer risks having those 2626 packets discarded if its peer enters the draining state before the 2627 packets arrive. If a peer could timeout within a Probe Timeout (PTO; 2628 see Section 6.3 of [QUIC-RECOVERY]), it is advisable to test for 2629 liveness before sending any data that cannot be retried safely. Note 2630 that it is likely that only applications or application protocols 2631 will know what information can be retried. 2633 10.3. Immediate Close 2635 An endpoint sends a CONNECTION_CLOSE frame (Section 19.19) to 2636 terminate the connection immediately. A CONNECTION_CLOSE frame 2637 causes all streams to immediately become closed; open streams can be 2638 assumed to be implicitly reset. 2640 After sending a CONNECTION_CLOSE frame, endpoints immediately enter 2641 the closing state. During the closing period, an endpoint that sends 2642 a CONNECTION_CLOSE frame SHOULD respond to any packet that it 2643 receives with another packet containing a CONNECTION_CLOSE frame. To 2644 minimize the state that an endpoint maintains for a closing 2645 connection, endpoints MAY send the exact same packet. However, 2646 endpoints SHOULD limit the number of packets they generate containing 2647 a CONNECTION_CLOSE frame. For instance, an endpoint could 2648 progressively increase the number of packets that it receives before 2649 sending additional packets or increase the time between packets. 2651 Note: Allowing retransmission of a closing packet contradicts other 2652 advice in this document that recommends the creation of new packet 2653 numbers for every packet. Sending new packet numbers is primarily 2654 of advantage to loss recovery and congestion control, which are 2655 not expected to be relevant for a closed connection. 2656 Retransmitting the final packet requires less state. 2658 New packets from unverified addresses could be used to create an 2659 amplification attack (see Section 8). To avoid this, endpoints MUST 2660 either limit transmission of CONNECTION_CLOSE frames to validated 2661 addresses or drop packets without response if the response would be 2662 more than three times larger than the received packet. 2664 After receiving a CONNECTION_CLOSE frame, endpoints enter the 2665 draining state. An endpoint that receives a CONNECTION_CLOSE frame 2666 MAY send a single packet containing a CONNECTION_CLOSE frame before 2667 entering the draining state, using a CONNECTION_CLOSE frame and a 2668 NO_ERROR code if appropriate. An endpoint MUST NOT send further 2669 packets, which could result in a constant exchange of 2670 CONNECTION_CLOSE frames until the closing period on either peer 2671 ended. 2673 An immediate close can be used after an application protocol has 2674 arranged to close a connection. This might be after the application 2675 protocols negotiates a graceful shutdown. The application protocol 2676 exchanges whatever messages that are needed to cause both endpoints 2677 to agree to close the connection, after which the application 2678 requests that the connection be closed. The application protocol can 2679 use a CONNECTION_CLOSE frame with an appropriate error code to signal 2680 closure. 2682 When sending CONNECTION_CLOSE, the goal is to ensure that the peer 2683 will process the frame. Generally, this means sending the frame in a 2684 packet with the highest level of packet protection to avoid the 2685 packet being discarded. However, during the handshake, it is 2686 possible that more advanced packet protection keys are not available 2687 to the peer, so the frame MAY be replicated in a packet that uses a 2688 lower packet protection level. 2690 After the handshake is confirmed, an endpoint MUST send any 2691 CONNECTION_CLOSE frames in a 1-RTT packet. Prior to handshake 2692 confirmation, the peer might not have 1-RTT keys, so the endpoint 2693 SHOULD send CONNECTION_CLOSE frames in a Handshake packet. If the 2694 endpoint does not have Handshake keys, it SHOULD send 2695 CONNECTION_CLOSE frames in an Initial packet. 2697 A client will always know whether the server has Handshake keys (see 2698 Section 17.2.2.1), but it is possible that a server does not know 2699 whether the client has Handshake keys. Under these circumstances, a 2700 server SHOULD send a CONNECTION_CLOSE frame in both Handshake and 2701 Initial packets to ensure that at least one of them is processable by 2702 the client. These packets can be coalesced into a single UDP 2703 datagram (see Section 12.2). 2705 10.4. Stateless Reset 2707 A stateless reset is provided as an option of last resort for an 2708 endpoint that does not have access to the state of a connection. A 2709 crash or outage might result in peers continuing to send data to an 2710 endpoint that is unable to properly continue the connection. An 2711 endpoint MAY send a stateless reset in response to receiving a packet 2712 that it cannot associate with an active connection. 2714 A stateless reset is not appropriate for signaling error conditions. 2715 An endpoint that wishes to communicate a fatal connection error MUST 2716 use a CONNECTION_CLOSE frame if it has sufficient state to do so. 2718 To support this process, a token is sent by endpoints. The token is 2719 carried in the NEW_CONNECTION_ID frame sent by either peer, and 2720 servers can specify the stateless_reset_token transport parameter 2721 during the handshake (clients cannot because their transport 2722 parameters don't have confidentiality protection). This value is 2723 protected by encryption, so only client and server know this value. 2724 Tokens are invalidated when their associated connection ID is retired 2725 via a RETIRE_CONNECTION_ID frame (Section 19.16). 2727 An endpoint that receives packets that it cannot process sends a 2728 packet in the following layout: 2730 0 1 2 3 2731 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 2732 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2733 |0|1| Unpredictable Bits (38 ..) ... 2734 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2735 | | 2736 + + 2737 | | 2738 + Stateless Reset Token (128) + 2739 | | 2740 + + 2741 | | 2742 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2744 Figure 6: Stateless Reset Packet 2746 This design ensures that a stateless reset packet is - to the extent 2747 possible - indistinguishable from a regular packet with a short 2748 header. 2750 A stateless reset uses an entire UDP datagram, starting with the 2751 first two bits of the packet header. The remainder of the first byte 2752 and an arbitrary number of bytes following it that are set to 2753 unpredictable values. The last 16 bytes of the datagram contain a 2754 Stateless Reset Token. 2756 To entities other than its intended recipient, a stateless reset will 2757 appear to be a packet with a short header. For the stateless reset 2758 to appear as a valid QUIC packet, the Unpredictable Bits field needs 2759 to include at least 38 bits of data (or 5 bytes, less the two fixed 2760 bits). 2762 A minimum size of 21 bytes does not guarantee that a stateless reset 2763 is difficult to distinguish from other packets if the recipient 2764 requires the use of a connection ID. To prevent a resulting 2765 stateless reset from being trivially distinguishable from a valid 2766 packet, all packets sent by an endpoint SHOULD be padded to at least 2767 22 bytes longer than the minimum connection ID that the endpoint 2768 might use. An endpoint that sends a stateless reset in response to 2769 packet that is 43 bytes or less in length SHOULD send a stateless 2770 reset that is one byte shorter than the packet it responds to. 2772 These values assume that the Stateless Reset Token is the same as the 2773 minimum expansion of the packet protection AEAD. Additional 2774 unpredictable bytes are necessary if the endpoint could have 2775 negotiated a packet protection scheme with a larger minimum 2776 expansion. 2778 An endpoint MUST NOT send a stateless reset that is three times or 2779 more larger than the packet it receives to avoid being used for 2780 amplification. Section 10.4.3 describes additional limits on 2781 stateless reset size. 2783 Endpoints MUST discard packets that are too small to be valid QUIC 2784 packets. With the set of AEAD functions defined in [QUIC-TLS], 2785 packets that are smaller than 21 bytes are never valid. 2787 Endpoints MUST send stateless reset packets formatted as a packet 2788 with a short header. However, endpoints MUST treat any packet ending 2789 in a valid stateless reset token as a stateless reset, as other QUIC 2790 versions might allow the use of a long header. 2792 An endpoint MAY send a stateless reset in response to a packet with a 2793 long header. Sending a stateless reset is not effective prior to the 2794 stateless reset token being available to a peer. In this QUIC 2795 version, packets with a long header are only used during connection 2796 establishment. Because the stateless reset token is not available 2797 until connection establishment is complete or near completion, 2798 ignoring an unknown packet with a long header might be as effective 2799 as sending a stateless reset. 2801 An endpoint cannot determine the Source Connection ID from a packet 2802 with a short header, therefore it cannot set the Destination 2803 Connection ID in the stateless reset packet. The Destination 2804 Connection ID will therefore differ from the value used in previous 2805 packets. A random Destination Connection ID makes the connection ID 2806 appear to be the result of moving to a new connection ID that was 2807 provided using a NEW_CONNECTION_ID frame (Section 19.15). 2809 Using a randomized connection ID results in two problems: 2811 o The packet might not reach the peer. If the Destination 2812 Connection ID is critical for routing toward the peer, then this 2813 packet could be incorrectly routed. This might also trigger 2814 another Stateless Reset in response; see Section 10.4.3. A 2815 Stateless Reset that is not correctly routed is an ineffective 2816 error detection and recovery mechanism. In this case, endpoints 2817 will need to rely on other methods - such as timers - to detect 2818 that the connection has failed. 2820 o The randomly generated connection ID can be used by entities other 2821 than the peer to identify this as a potential stateless reset. An 2822 endpoint that occasionally uses different connection IDs might 2823 introduce some uncertainty about this. 2825 This stateless reset design is specific to QUIC version 1. An 2826 endpoint that supports multiple versions of QUIC needs to generate a 2827 stateless reset that will be accepted by peers that support any 2828 version that the endpoint might support (or might have supported 2829 prior to losing state). Designers of new versions of QUIC need to be 2830 aware of this and either reuse this design, or use a portion of the 2831 packet other than the last 16 bytes for carrying data. 2833 10.4.1. Detecting a Stateless Reset 2835 An endpoint detects a potential stateless reset when an incoming 2836 packet either cannot be associated with a connection, cannot be 2837 decrypted, or is marked as a duplicate packet. The endpoint MUST 2838 then compare the last 16 bytes of the packet with all Stateless Reset 2839 Tokens that are associated with connection IDs that the endpoint 2840 recently used to send packets from the IP address and port on which 2841 the datagram is received. This includes Stateless Reset Tokens from 2842 NEW_CONNECTION_ID frames and the server's transport parameters. An 2843 endpoint MUST NOT check for any Stateless Reset Tokens associated 2844 with connection IDs it has not used or for connection IDs that have 2845 been retired. 2847 If the last 16 bytes of the packet values are identical to a 2848 Stateless Reset Token, the endpoint MUST enter the draining period 2849 and not send any further packets on this connection. If the 2850 comparison fails, the packet can be discarded. 2852 10.4.2. Calculating a Stateless Reset Token 2854 The stateless reset token MUST be difficult to guess. In order to 2855 create a Stateless Reset Token, an endpoint could randomly generate 2856 [RFC4086] a secret for every connection that it creates. However, 2857 this presents a coordination problem when there are multiple 2858 instances in a cluster or a storage problem for an endpoint that 2859 might lose state. Stateless reset specifically exists to handle the 2860 case where state is lost, so this approach is suboptimal. 2862 A single static key can be used across all connections to the same 2863 endpoint by generating the proof using a second iteration of a 2864 preimage-resistant function that takes a static key and the 2865 connection ID chosen by the endpoint (see Section 5.1) as input. An 2866 endpoint could use HMAC [RFC2104] (for example, HMAC(static_key, 2867 connection_id)) or HKDF [RFC5869] (for example, using the static key 2868 as input keying material, with the connection ID as salt). The 2869 output of this function is truncated to 16 bytes to produce the 2870 Stateless Reset Token for that connection. 2872 An endpoint that loses state can use the same method to generate a 2873 valid Stateless Reset Token. The connection ID comes from the packet 2874 that the endpoint receives. 2876 This design relies on the peer always sending a connection ID in its 2877 packets so that the endpoint can use the connection ID from a packet 2878 to reset the connection. An endpoint that uses this design MUST 2879 either use the same connection ID length for all connections or 2880 encode the length of the connection ID such that it can be recovered 2881 without state. In addition, it cannot provide a zero-length 2882 connection ID. 2884 Revealing the Stateless Reset Token allows any entity to terminate 2885 the connection, so a value can only be used once. This method for 2886 choosing the Stateless Reset Token means that the combination of 2887 connection ID and static key MUST NOT be used for another connection. 2888 A denial of service attack is possible if the same connection ID is 2889 used by instances that share a static key, or if an attacker can 2890 cause a packet to be routed to an instance that has no state but the 2891 same static key; see Section 21.9. A connection ID from a connection 2892 that is reset by revealing the Stateless Reset Token MUST NOT be 2893 reused for new connections at nodes that share a static key. 2895 The same Stateless Reset Token MAY be used for multiple connection 2896 IDs on the same connection. However, reuse of a Stateless Reset 2897 Token might expose an endpoint to denial of service if associated 2898 connection IDs are forgotten while the associated token is still 2899 active at a peer. An endpoint MUST ensure that packets with 2900 Destination Connection ID field values that correspond to a reused 2901 Stateless Reset Token are attributed to the same connection as long 2902 as the Stateless Reset Token is still usable, even when the 2903 connection ID has been retired. Otherwise, an attacker might be able 2904 to send a packet with a retired connection ID and cause the endpoint 2905 to produce a Stateless Reset that it can use to disrupt the 2906 connection, just as with the attacks in Section 21.9. 2908 Note that Stateless Reset packets do not have any cryptographic 2909 protection. 2911 10.4.3. Looping 2913 The design of a Stateless Reset is such that without knowing the 2914 stateless reset token it is indistinguishable from a valid packet. 2915 For instance, if a server sends a Stateless Reset to another server 2916 it might receive another Stateless Reset in response, which could 2917 lead to an infinite exchange. 2919 An endpoint MUST ensure that every Stateless Reset that it sends is 2920 smaller than the packet which triggered it, unless it maintains state 2921 sufficient to prevent looping. In the event of a loop, this results 2922 in packets eventually being too small to trigger a response. 2924 An endpoint can remember the number of Stateless Reset packets that 2925 it has sent and stop generating new Stateless Reset packets once a 2926 limit is reached. Using separate limits for different remote 2927 addresses will ensure that Stateless Reset packets can be used to 2928 close connections when other peers or connections have exhausted 2929 limits. 2931 Reducing the size of a Stateless Reset below 41 bytes means that the 2932 packet could reveal to an observer that it is a Stateless Reset, 2933 depending upon the length of the peer's connection IDs. Conversely, 2934 refusing to send a Stateless Reset in response to a small packet 2935 might result in Stateless Reset not being useful in detecting cases 2936 of broken connections where only very small packets are sent; such 2937 failures might only be detected by other means, such as timers. 2939 11. Error Handling 2941 An endpoint that detects an error SHOULD signal the existence of that 2942 error to its peer. Both transport-level and application-level errors 2943 can affect an entire connection (see Section 11.1), while only 2944 application-level errors can be isolated to a single stream (see 2945 Section 11.2). 2947 The most appropriate error code (Section 20) SHOULD be included in 2948 the frame that signals the error. Where this specification 2949 identifies error conditions, it also identifies the error code that 2950 is used; though these are worded as requirements, different 2951 implementation strategies might lead to different errors being 2952 reported. In particular, an endpoint MAY use any applicable error 2953 code when it detects an error condition; a generic error code (such 2954 as PROTOCOL_VIOLATION or INTERNAL_ERROR) can always be used in place 2955 of specific error codes. 2957 A stateless reset (Section 10.4) is not suitable for any error that 2958 can be signaled with a CONNECTION_CLOSE or RESET_STREAM frame. A 2959 stateless reset MUST NOT be used by an endpoint that has the state 2960 necessary to send a frame on the connection. 2962 11.1. Connection Errors 2964 Errors that result in the connection being unusable, such as an 2965 obvious violation of protocol semantics or corruption of state that 2966 affects an entire connection, MUST be signaled using a 2967 CONNECTION_CLOSE frame (Section 19.19). An endpoint MAY close the 2968 connection in this manner even if the error only affects a single 2969 stream. 2971 Application protocols can signal application-specific protocol errors 2972 using the application-specific variant of the CONNECTION_CLOSE frame. 2973 Errors that are specific to the transport, including all those 2974 described in this document, are carried in the QUIC-specific variant 2975 of the CONNECTION_CLOSE frame. 2977 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 2978 endpoint SHOULD be prepared to retransmit a packet containing a 2979 CONNECTION_CLOSE frame if it receives more packets on a terminated 2980 connection. Limiting the number of retransmissions and the time over 2981 which this final packet is sent limits the effort expended on 2982 terminated connections. 2984 An endpoint that chooses not to retransmit packets containing a 2985 CONNECTION_CLOSE frame risks a peer missing the first such packet. 2986 The only mechanism available to an endpoint that continues to receive 2987 data for a terminated connection is to use the stateless reset 2988 process (Section 10.4). 2990 An endpoint that receives an invalid CONNECTION_CLOSE frame MUST NOT 2991 signal the existence of the error to its peer. 2993 11.2. Stream Errors 2995 If an application-level error affects a single stream, but otherwise 2996 leaves the connection in a recoverable state, the endpoint can send a 2997 RESET_STREAM frame (Section 19.4) with an appropriate error code to 2998 terminate just the affected stream. 3000 RESET_STREAM MUST be instigated by the protocol using QUIC. 3001 RESET_STREAM carries an application error code. Only the application 3002 protocol is able to cause a stream to be terminated. A local 3003 instance of the application protocol uses a direct API call and a 3004 remote instance uses the STOP_SENDING frame, which triggers an 3005 automatic RESET_STREAM. 3007 Resetting a stream without knowledge of the application protocol 3008 could cause the protocol to enter an unrecoverable state. 3009 Application protocols might require certain streams to be reliably 3010 delivered in order to guarantee consistent state between endpoints. 3011 Application protocols SHOULD define rules for handling streams that 3012 are prematurely cancelled by either endpoint. 3014 12. Packets and Frames 3016 QUIC endpoints communicate by exchanging packets. Packets have 3017 confidentiality and integrity protection (see Section 12.1) and are 3018 carried in UDP datagrams (see Section 12.2). 3020 This version of QUIC uses the long packet header (see Section 17.2) 3021 during connection establishment. Packets with the long header are 3022 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), Handshake 3023 (Section 17.2.4), and Retry (Section 17.2.5). Version negotiation 3024 uses a version-independent packet with a long header (see 3025 Section 17.2.1). 3027 Packets with the short header (Section 17.3) are designed for minimal 3028 overhead and are used after a connection is established and 1-RTT 3029 keys are available. 3031 12.1. Protected Packets 3033 All QUIC packets except Version Negotiation and Retry packets use 3034 authenticated encryption with additional data (AEAD) [RFC5116] to 3035 provide confidentiality and integrity protection. Details of packet 3036 protection are found in [QUIC-TLS]; this section includes an overview 3037 of the process. 3039 Initial packets are protected using keys that are statically derived. 3040 This packet protection is not effective confidentiality protection. 3042 Initial protection only exists to ensure that the sender of the 3043 packet is on the network path. Any entity that receives the Initial 3044 packet from a client can recover the keys necessary to remove packet 3045 protection or to generate packets that will be successfully 3046 authenticated. 3048 All other packets are protected with keys derived from the 3049 cryptographic handshake. The type of the packet from the long header 3050 or key phase from the short header are used to identify which 3051 encryption level - and therefore the keys - that are used. Packets 3052 protected with 0-RTT and 1-RTT keys are expected to have 3053 confidentiality and data origin authentication; the cryptographic 3054 handshake ensures that only the communicating endpoints receive the 3055 corresponding keys. 3057 The packet number field contains a packet number, which has 3058 additional confidentiality protection that is applied after packet 3059 protection is applied (see [QUIC-TLS] for details). The underlying 3060 packet number increases with each packet sent in a given packet 3061 number space; see Section 12.3 for details. 3063 12.2. Coalescing Packets 3065 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), and Handshake 3066 (Section 17.2.4) packets contain a Length field, which determines the 3067 end of the packet. The length includes both the Packet Number and 3068 Payload fields, both of which are confidentiality protected and 3069 initially of unknown length. The length of the Payload field is 3070 learned once header protection is removed. 3072 Using the Length field, a sender can coalesce multiple QUIC packets 3073 into one UDP datagram. This can reduce the number of UDP datagrams 3074 needed to complete the cryptographic handshake and start sending 3075 data. This can also be used to construct PMTU probes (see 3076 Section 14.3.1). Receivers MUST be able to process coalesced 3077 packets. 3079 Coalescing packets in order of increasing encryption levels (Initial, 3080 0-RTT, Handshake, 1-RTT) makes it more likely the receiver will be 3081 able to process all the packets in a single pass. A packet with a 3082 short header does not include a length, so it can only be the last 3083 packet included in a UDP datagram. An endpoint SHOULD NOT coalesce 3084 multiple packets at the same encryption level. 3086 Senders MUST NOT coalesce QUIC packets for different connections into 3087 a single UDP datagram. Receivers SHOULD ignore any subsequent 3088 packets with a different Destination Connection ID than the first 3089 packet in the datagram. 3091 Every QUIC packet that is coalesced into a single UDP datagram is 3092 separate and complete. Though the values of some fields in the 3093 packet header might be redundant, no fields are omitted. The 3094 receiver of coalesced QUIC packets MUST individually process each 3095 QUIC packet and separately acknowledge them, as if they were received 3096 as the payload of different UDP datagrams. For example, if 3097 decryption fails (because the keys are not available or any other 3098 reason), the receiver MAY either discard or buffer the packet for 3099 later processing and MUST attempt to process the remaining packets. 3101 Retry packets (Section 17.2.5), Version Negotiation packets 3102 (Section 17.2.1), and packets with a short header (Section 17.3) do 3103 not contain a Length field and so cannot be followed by other packets 3104 in the same UDP datagram. Note also that there is no situation where 3105 a Retry or Version Negotiation packet is coalesced with another 3106 packet. 3108 12.3. Packet Numbers 3110 The packet number is an integer in the range 0 to 2^62-1. This 3111 number is used in determining the cryptographic nonce for packet 3112 protection. Each endpoint maintains a separate packet number for 3113 sending and receiving. 3115 Packet numbers are limited to this range because they need to be 3116 representable in whole in the Largest Acknowledged field of an ACK 3117 frame (Section 19.3). When present in a long or short header 3118 however, packet numbers are reduced and encoded in 1 to 4 bytes (see 3119 Section 17.1). 3121 Version Negotiation (Section 17.2.1) and Retry (Section 17.2.5) 3122 packets do not include a packet number. 3124 Packet numbers are divided into 3 spaces in QUIC: 3126 o Initial space: All Initial packets (Section 17.2.2) are in this 3127 space. 3129 o Handshake space: All Handshake packets (Section 17.2.4) are in 3130 this space. 3132 o Application data space: All 0-RTT and 1-RTT encrypted packets 3133 (Section 12.1) are in this space. 3135 As described in [QUIC-TLS], each packet type uses different 3136 protection keys. 3138 Conceptually, a packet number space is the context in which a packet 3139 can be processed and acknowledged. Initial packets can only be sent 3140 with Initial packet protection keys and acknowledged in packets which 3141 are also Initial packets. Similarly, Handshake packets are sent at 3142 the Handshake encryption level and can only be acknowledged in 3143 Handshake packets. 3145 This enforces cryptographic separation between the data sent in the 3146 different packet sequence number spaces. Packet numbers in each 3147 space start at packet number 0. Subsequent packets sent in the same 3148 packet number space MUST increase the packet number by at least one. 3150 0-RTT and 1-RTT data exist in the same packet number space to make 3151 loss recovery algorithms easier to implement between the two packet 3152 types. 3154 A QUIC endpoint MUST NOT reuse a packet number within the same packet 3155 number space in one connection. If the packet number for sending 3156 reaches 2^62 - 1, the sender MUST close the connection without 3157 sending a CONNECTION_CLOSE frame or any further packets; an endpoint 3158 MAY send a Stateless Reset (Section 10.4) in response to further 3159 packets that it receives. 3161 A receiver MUST discard a newly unprotected packet unless it is 3162 certain that it has not processed another packet with the same packet 3163 number from the same packet number space. Duplicate suppression MUST 3164 happen after removing packet protection for the reasons described in 3165 Section 9.3 of [QUIC-TLS]. An efficient algorithm for duplicate 3166 suppression can be found in Section 3.4.3 of [RFC4303]. 3168 Packet number encoding at a sender and decoding at a receiver are 3169 described in Section 17.1. 3171 12.4. Frames and Frame Types 3173 The payload of QUIC packets, after removing packet protection, 3174 consists of a sequence of complete frames, as shown in Figure 7. 3175 Version Negotiation, Stateless Reset, and Retry packets do not 3176 contain frames. 3178 0 1 2 3 3179 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 3180 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3181 | Frame 1 (*) ... 3182 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3183 | Frame 2 (*) ... 3184 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3185 ... 3186 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3187 | Frame N (*) ... 3188 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3190 Figure 7: QUIC Payload 3192 The payload of a packet that contains frames MUST contain at least 3193 one frame, and MAY contain multiple frames and multiple frame types. 3194 Frames always fit within a single QUIC packet and cannot span 3195 multiple packets. 3197 Each frame begins with a Frame Type, indicating its type, followed by 3198 additional type-dependent fields: 3200 0 1 2 3 3201 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 3202 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3203 | Frame Type (i) ... 3204 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3205 | Type-Dependent Fields (*) ... 3206 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3208 Figure 8: Generic Frame Layout 3210 The frame types defined in this specification are listed in Table 3. 3211 The Frame Type in ACK, STREAM, MAX_STREAMS, STREAMS_BLOCKED, and 3212 CONNECTION_CLOSE frames is used to carry other frame-specific flags. 3213 For all other frames, the Frame Type field simply identifies the 3214 frame. These frames are explained in more detail in Section 19. 3216 +-------------+----------------------+---------------+ 3217 | Type Value | Frame Type Name | Definition | 3218 +-------------+----------------------+---------------+ 3219 | 0x00 | PADDING | Section 19.1 | 3220 | | | | 3221 | 0x01 | PING | Section 19.2 | 3222 | | | | 3223 | 0x02 - 0x03 | ACK | Section 19.3 | 3224 | | | | 3225 | 0x04 | RESET_STREAM | Section 19.4 | 3226 | | | | 3227 | 0x05 | STOP_SENDING | Section 19.5 | 3228 | | | | 3229 | 0x06 | CRYPTO | Section 19.6 | 3230 | | | | 3231 | 0x07 | NEW_TOKEN | Section 19.7 | 3232 | | | | 3233 | 0x08 - 0x0f | STREAM | Section 19.8 | 3234 | | | | 3235 | 0x10 | MAX_DATA | Section 19.9 | 3236 | | | | 3237 | 0x11 | MAX_STREAM_DATA | Section 19.10 | 3238 | | | | 3239 | 0x12 - 0x13 | MAX_STREAMS | Section 19.11 | 3240 | | | | 3241 | 0x14 | DATA_BLOCKED | Section 19.12 | 3242 | | | | 3243 | 0x15 | STREAM_DATA_BLOCKED | Section 19.13 | 3244 | | | | 3245 | 0x16 - 0x17 | STREAMS_BLOCKED | Section 19.14 | 3246 | | | | 3247 | 0x18 | NEW_CONNECTION_ID | Section 19.15 | 3248 | | | | 3249 | 0x19 | RETIRE_CONNECTION_ID | Section 19.16 | 3250 | | | | 3251 | 0x1a | PATH_CHALLENGE | Section 19.17 | 3252 | | | | 3253 | 0x1b | PATH_RESPONSE | Section 19.18 | 3254 | | | | 3255 | 0x1c - 0x1d | CONNECTION_CLOSE | Section 19.19 | 3256 +-------------+----------------------+---------------+ 3258 Table 3: Frame Types 3260 An endpoint MUST treat the receipt of a frame of unknown type as a 3261 connection error of type FRAME_ENCODING_ERROR. 3263 All QUIC frames are idempotent in this version of QUIC. That is, a 3264 valid frame does not cause undesirable side effects or errors when 3265 received more than once. 3267 The Frame Type field uses a variable length integer encoding (see 3268 Section 16) with one exception. To ensure simple and efficient 3269 implementations of frame parsing, a frame type MUST use the shortest 3270 possible encoding. Though a two-, four- or eight-byte encoding of 3271 the frame types defined in this document is possible, the Frame Type 3272 field for these frames is encoded on a single byte. For instance, 3273 though 0x4001 is a legitimate two-byte encoding for a variable-length 3274 integer with a value of 1, PING frames are always encoded as a single 3275 byte with the value 0x01. An endpoint MAY treat the receipt of a 3276 frame type that uses a longer encoding than necessary as a connection 3277 error of type PROTOCOL_VIOLATION. 3279 13. Packetization and Reliability 3281 A sender bundles one or more frames in a QUIC packet (see 3282 Section 12.4). 3284 A sender can minimize per-packet bandwidth and computational costs by 3285 bundling as many frames as possible within a QUIC packet. A sender 3286 MAY wait for a short period of time to bundle multiple frames before 3287 sending a packet that is not maximally packed, to avoid sending out 3288 large numbers of small packets. An implementation MAY use knowledge 3289 about application sending behavior or heuristics to determine whether 3290 and for how long to wait. This waiting period is an implementation 3291 decision, and an implementation should be careful to delay 3292 conservatively, since any delay is likely to increase application- 3293 visible latency. 3295 Stream multiplexing is achieved by interleaving STREAM frames from 3296 multiple streams into one or more QUIC packets. A single QUIC packet 3297 can include multiple STREAM frames from one or more streams. 3299 One of the benefits of QUIC is avoidance of head-of-line blocking 3300 across multiple streams. When a packet loss occurs, only streams 3301 with data in that packet are blocked waiting for a retransmission to 3302 be received, while other streams can continue making progress. Note 3303 that when data from multiple streams is bundled into a single QUIC 3304 packet, loss of that packet blocks all those streams from making 3305 progress. Implementations are advised to bundle as few streams as 3306 necessary in outgoing packets without losing transmission efficiency 3307 to underfilled packets. 3309 13.1. Packet Processing 3311 A packet MUST NOT be acknowledged until packet protection has been 3312 successfully removed and all frames contained in the packet have been 3313 processed. For STREAM frames, this means the data has been enqueued 3314 in preparation to be received by the application protocol, but it 3315 does not require that data is delivered and consumed. 3317 Once the packet has been fully processed, a receiver acknowledges 3318 receipt by sending one or more ACK frames containing the packet 3319 number of the received packet. 3321 13.2. Generating Acknowledgements 3323 Endpoints acknowledge all packets they receive and process. However, 3324 only ack-eliciting packets (see [QUIC-RECOVERY]) trigger the sending 3325 of an ACK frame. Packets that are not ack-eliciting are only 3326 acknowledged when an ACK frame is sent for other reasons. 3328 When sending a packet for any reason, an endpoint should attempt to 3329 bundle an ACK frame if one has not been sent recently. Doing so 3330 helps with timely loss detection at the peer. 3332 In general, frequent feedback from a receiver improves loss and 3333 congestion response, but this has to be balanced against excessive 3334 load generated by a receiver that sends an ACK frame in response to 3335 every ack-eliciting packet. The guidance offered below seeks to 3336 strike this balance. 3338 13.2.1. Sending ACK Frames 3340 An ACK frame SHOULD be generated for at least every second ack- 3341 eliciting packet. This recommendation is in keeping with standard 3342 practice for TCP [RFC5681]. 3344 A receiver's delayed acknowledgment timer SHOULD NOT exceed the 3345 current RTT estimate or the value it indicates in the "max_ack_delay" 3346 transport parameter. This ensures an acknowledgment is sent at least 3347 once per RTT when packets needing acknowledgement are received. The 3348 sender can use the receiver's "max_ack_delay" value in determining 3349 timeouts for timer-based retransmission. 3351 In order to assist loss detection at the sender, an endpoint SHOULD 3352 send an ACK frame immediately on receiving an ack-eliciting packet 3353 that is out of order. The endpoint MAY continue sending ACK frames 3354 immediately on each subsequently received packet, but the endpoint 3355 SHOULD return to acknowledging every other packet after a period of 3356 1/8 x RTT, unless more ACK-eliciting packets are received out of 3357 order. If every subsequent ACK-eliciting packet arrives out of 3358 order, then an ACK frame SHOULD be sent immediately for every 3359 received ACK-eliciting packet. 3361 Similarly, packets marked with the ECN Congestion Experienced (CE) 3362 codepoint in the IP header SHOULD be acknowledged immediately, to 3363 reduce the peer's response time to congestion events. 3365 As an optimization, a receiver MAY process multiple packets before 3366 sending any ACK frames in response. In this case the receiver can 3367 determine whether an immediate or delayed acknowledgement should be 3368 generated after processing incoming packets. 3370 Acknowledgements of packets carrying CRYPTO frames SHOULD be 3371 minimally delayed, to complete the handshake with minimal latency. 3372 Delaying them by a small amount, such as the local timer granularity, 3373 allows the endpoint to bundle any data sent in response with the ACK 3374 frame. ACK frames SHOULD be sent immediately when the crypto stack 3375 indicates all data for that packet number space has been received. 3377 Packets containing PADDING frames are considered to be in flight for 3378 congestion control purposes [QUIC-RECOVERY]. Sending only PADDING 3379 frames might cause the sender to become limited by the congestion 3380 controller (as described in [QUIC-RECOVERY]) with no acknowledgments 3381 forthcoming from the receiver. Therefore, a sender SHOULD ensure 3382 that other frames are sent in addition to PADDING frames to elicit 3383 acknowledgments from the receiver. 3385 An endpoint that is only sending ACK frames will not receive 3386 acknowledgments from its peer unless those acknowledgements are 3387 included in packets with ACK-eliciting frames. An endpoint SHOULD 3388 bundle ACK frames with other frames when there are new ACK-eliciting 3389 packets to acknowledge. When only non-ACK-eliciting packets need to 3390 be acknowledged, an endpoint MAY wait until an ACK-eliciting packet 3391 has been received to bundle an ACK frame with outgoing frames. 3393 The algorithms in [QUIC-RECOVERY] are resilient to receivers that do 3394 not follow guidance offered above. However, an implementor should 3395 only deviate from these requirements after careful consideration of 3396 the performance implications of doing so. 3398 Packets containing only ACK frames are not congestion controlled, so 3399 there are limits on how frequently they can be sent. An endpoint 3400 MUST NOT send more than one ACK-frame-only packet in response to 3401 receiving an ACK-eliciting packet (one containing frames other than 3402 ACK and/or PADDING). An endpoint MUST NOT send a packet containing 3403 only an ACK frame in response to a non-ACK-eliciting packet (one 3404 containing only ACK and/or PADDING frames), even if there are packet 3405 gaps which precede the received packet. Limiting ACK frames avoids 3406 an infinite feedback loop of acknowledgements, which could prevent 3407 the connection from ever becoming idle. However, the endpoint 3408 acknowledges non-ACK-eliciting packets when it sends an ACK frame. 3410 An endpoint SHOULD treat receipt of an acknowledgment for a packet it 3411 did not send as a connection error of type PROTOCOL_VIOLATION, if it 3412 is able to detect the condition. 3414 13.2.2. Managing ACK Ranges 3416 When an ACK frame is sent, one or more ranges of acknowledged packets 3417 are included. Including older packets reduces the chance of spurious 3418 retransmits caused by losing previously sent ACK frames, at the cost 3419 of larger ACK frames. 3421 ACK frames SHOULD always acknowledge the most recently received 3422 packets, and the more out-of-order the packets are, the more 3423 important it is to send an updated ACK frame quickly, to prevent the 3424 peer from declaring a packet as lost and spuriously retransmitting 3425 the frames it contains. 3427 Section 13.2.3 and Section 13.2.4 describe an exemplary approach for 3428 determining what packets to acknowledge in each ACK frame. 3430 13.2.3. Receiver Tracking of ACK Frames 3432 When a packet containing an ACK frame is sent, the largest 3433 acknowledged in that frame may be saved. When a packet containing an 3434 ACK frame is acknowledged, the receiver can stop acknowledging 3435 packets less than or equal to the largest acknowledged in the sent 3436 ACK frame. 3438 In cases without ACK frame loss, this algorithm allows for a minimum 3439 of 1 RTT of reordering. In cases with ACK frame loss and reordering, 3440 this approach does not guarantee that every acknowledgement is seen 3441 by the sender before it is no longer included in the ACK frame. 3442 Packets could be received out of order and all subsequent ACK frames 3443 containing them could be lost. In this case, the loss recovery 3444 algorithm could cause spurious retransmits, but the sender will 3445 continue making forward progress. 3447 13.2.4. Limiting ACK Ranges 3449 To limit ACK Ranges (see Section 19.3.1) to those that have not yet 3450 been received by the sender, the receiver SHOULD track which ACK 3451 frames have been acknowledged by its peer. The receiver SHOULD 3452 exclude already acknowledged packets from future ACK frames whenever 3453 these packets would unnecessarily contribute to the ACK frame size. 3454 When the receiver is only sending non-ACK-eliciting packets, it can 3455 bundle a PING or other small ACK-eliciting frame with a fraction of 3456 them, such as once per round trip, to enable dropping unnecessary ACK 3457 ranges and any state for previously sent packets. The receiver MUST 3458 NOT bundle an ACK-eliciting frame, such as a PING, with all packets 3459 that would otherwise be non-ACK-eliciting, in order to avoid an 3460 infinite feedback loop of acknowledgements. 3462 To limit receiver state or the size of ACK frames, a receiver MAY 3463 limit the number of ACK Ranges it sends. A receiver can do this even 3464 without receiving acknowledgment of its ACK frames, with the 3465 knowledge this could cause the sender to unnecessarily retransmit 3466 some data. Standard QUIC algorithms ([QUIC-RECOVERY]) declare 3467 packets lost after sufficiently newer packets are acknowledged. 3468 Therefore, the receiver SHOULD repeatedly acknowledge newly received 3469 packets in preference to packets received in the past. 3471 13.2.5. Measuring and Reporting Host Delay 3473 An endpoint measures the delays intentionally introduced between when 3474 an ACK-eliciting packet is received and the corresponding 3475 acknowledgment is sent. The endpoint encodes this delay for the 3476 largest acknowledged packet in the Ack Delay field of an ACK frame 3477 (see Section 19.3). This allows the receiver of the ACK to adjust 3478 for any intentional delays, which is important for getting a better 3479 estimate of the path RTT when acknowledgments are delayed. A packet 3480 might be held in the OS kernel or elsewhere on the host before being 3481 processed. An endpoint MUST NOT include delays that is does not 3482 control when populating the Ack Delay field in an ACK frame. 3484 An endpoint MUST NOT excessively delay acknowledgements of ack- 3485 eliciting packets. An endpoint commits to a maximum delay using the 3486 max_ack_delay transport parameter; see Section 18.2. max_ack_delay 3487 declares an explicit contract: an endpoint promises to never delay 3488 acknowledgments of an ack-eliciting packet by more than the indicated 3489 value. If it does, any excess accrues to the RTT estimate and could 3490 result in delayed retransmissions from the peer. For Initial and 3491 Handshake packets, a max_ack_delay of 0 is used. 3493 13.2.6. ACK Frames and Packet Protection 3495 ACK frames MUST only be carried in a packet that has the same packet 3496 number space as the packet being ACKed (see Section 12.1). For 3497 instance, packets that are protected with 1-RTT keys MUST be 3498 acknowledged in packets that are also protected with 1-RTT keys. 3500 Packets that a client sends with 0-RTT packet protection MUST be 3501 acknowledged by the server in packets protected by 1-RTT keys. This 3502 can mean that the client is unable to use these acknowledgments if 3503 the server cryptographic handshake messages are delayed or lost. 3504 Note that the same limitation applies to other data sent by the 3505 server protected by the 1-RTT keys. 3507 13.3. Retransmission of Information 3509 QUIC packets that are determined to be lost are not retransmitted 3510 whole. The same applies to the frames that are contained within lost 3511 packets. Instead, the information that might be carried in frames is 3512 sent again in new frames as needed. 3514 New frames and packets are used to carry information that is 3515 determined to have been lost. In general, information is sent again 3516 when a packet containing that information is determined to be lost 3517 and sending ceases when a packet containing that information is 3518 acknowledged. 3520 o Data sent in CRYPTO frames is retransmitted according to the rules 3521 in [QUIC-RECOVERY], until all data has been acknowledged. Data in 3522 CRYPTO frames for Initial and Handshake packets is discarded when 3523 keys for the corresponding encryption level are discarded. 3525 o Application data sent in STREAM frames is retransmitted in new 3526 STREAM frames unless the endpoint has sent a RESET_STREAM for that 3527 stream. Once an endpoint sends a RESET_STREAM frame, no further 3528 STREAM frames are needed. 3530 o The most recent set of acknowledgments are sent in ACK frames. An 3531 ACK frame SHOULD contain all unacknowledged acknowledgments, as 3532 described in Section 13.2.1. 3534 o Cancellation of stream transmission, as carried in a RESET_STREAM 3535 frame, is sent until acknowledged or until all stream data is 3536 acknowledged by the peer (that is, either the "Reset Recvd" or 3537 "Data Recvd" state is reached on the sending part of the stream). 3538 The content of a RESET_STREAM frame MUST NOT change when it is 3539 sent again. 3541 o Similarly, a request to cancel stream transmission, as encoded in 3542 a STOP_SENDING frame, is sent until the receiving part of the 3543 stream enters either a "Data Recvd" or "Reset Recvd" state; see 3544 Section 3.5. 3546 o Connection close signals, including packets that contain 3547 CONNECTION_CLOSE frames, are not sent again when packet loss is 3548 detected, but as described in Section 10. 3550 o The current connection maximum data is sent in MAX_DATA frames. 3551 An updated value is sent in a MAX_DATA frame if the packet 3552 containing the most recently sent MAX_DATA frame is declared lost, 3553 or when the endpoint decides to update the limit. Care is 3554 necessary to avoid sending this frame too often as the limit can 3555 increase frequently and cause an unnecessarily large number of 3556 MAX_DATA frames to be sent. 3558 o The current maximum stream data offset is sent in MAX_STREAM_DATA 3559 frames. Like MAX_DATA, an updated value is sent when the packet 3560 containing the most recent MAX_STREAM_DATA frame for a stream is 3561 lost or when the limit is updated, with care taken to prevent the 3562 frame from being sent too often. An endpoint SHOULD stop sending 3563 MAX_STREAM_DATA frames when the receiving part of the stream 3564 enters a "Size Known" state. 3566 o The limit on streams of a given type is sent in MAX_STREAMS 3567 frames. Like MAX_DATA, an updated value is sent when a packet 3568 containing the most recent MAX_STREAMS for a stream type frame is 3569 declared lost or when the limit is updated, with care taken to 3570 prevent the frame from being sent too often. 3572 o Blocked signals are carried in DATA_BLOCKED, STREAM_DATA_BLOCKED, 3573 and STREAMS_BLOCKED frames. DATA_BLOCKED frames have connection 3574 scope, STREAM_DATA_BLOCKED frames have stream scope, and 3575 STREAMS_BLOCKED frames are scoped to a specific stream type. New 3576 frames are sent if packets containing the most recent frame for a 3577 scope is lost, but only while the endpoint is blocked on the 3578 corresponding limit. These frames always include the limit that 3579 is causing blocking at the time that they are transmitted. 3581 o A liveness or path validation check using PATH_CHALLENGE frames is 3582 sent periodically until a matching PATH_RESPONSE frame is received 3583 or until there is no remaining need for liveness or path 3584 validation checking. PATH_CHALLENGE frames include a different 3585 payload each time they are sent. 3587 o Responses to path validation using PATH_RESPONSE frames are sent 3588 just once. The peer is expected to send more PATH_CHALLENGE 3589 frames as necessary to evoke additional PATH_RESPONSE frames. 3591 o New connection IDs are sent in NEW_CONNECTION_ID frames and 3592 retransmitted if the packet containing them is lost. 3593 Retransmissions of this frame carry the same sequence number 3594 value. Likewise, retired connection IDs are sent in 3595 RETIRE_CONNECTION_ID frames and retransmitted if the packet 3596 containing them is lost. 3598 o NEW_TOKEN frames are retransmitted if the packet containing them 3599 is lost. No special support is made for detecting reordered and 3600 duplicated NEW_TOKEN frames other than a direct comparison of the 3601 frame contents. 3603 o PING and PADDING frames contain no information, so lost PING or 3604 PADDING frames do not require repair. 3606 Endpoints SHOULD prioritize retransmission of data over sending new 3607 data, unless priorities specified by the application indicate 3608 otherwise (see Section 2.3). 3610 Even though a sender is encouraged to assemble frames containing up- 3611 to-date information every time it sends a packet, it is not forbidden 3612 to retransmit copies of frames from lost packets. A receiver MUST 3613 accept packets containing an outdated frame, such as a MAX_DATA frame 3614 carrying a smaller maximum data than one found in an older packet. 3616 Upon detecting losses, a sender MUST take appropriate congestion 3617 control action. The details of loss detection and congestion control 3618 are described in [QUIC-RECOVERY]. 3620 13.4. Explicit Congestion Notification 3622 QUIC endpoints can use Explicit Congestion Notification (ECN) 3623 [RFC3168] to detect and respond to network congestion. ECN allows a 3624 network node to indicate congestion in the network by setting a 3625 codepoint in the IP header of a packet instead of dropping it. 3626 Endpoints react to congestion by reducing their sending rate in 3627 response, as described in [QUIC-RECOVERY]. 3629 To use ECN, QUIC endpoints first determine whether a path supports 3630 ECN marking and the peer is able to access the ECN codepoint in the 3631 IP header. A network path does not support ECN if ECN marked packets 3632 get dropped or ECN markings are rewritten on the path. An endpoint 3633 validates the use of ECN on the path, both during connection 3634 establishment and when migrating to a new path (Section 9). 3636 13.4.1. ECN Counts 3638 On receiving a QUIC packet with an ECT or CE codepoint, an ECN- 3639 enabled endpoint that can access the ECN codepoints from the 3640 enclosing IP packet increases the corresponding ECT(0), ECT(1), or CE 3641 count, and includes these counts in subsequent ACK frames (see 3642 Section 13.2 and Section 19.3). Note that this requires being able 3643 to read the ECN codepoints from the enclosing IP packet, which is not 3644 possible on all platforms. 3646 A packet detected by a receiver as a duplicate does not affect the 3647 receiver's local ECN codepoint counts; see (Section 21.8) for 3648 relevant security concerns. 3650 If an endpoint receives a QUIC packet without an ECT or CE codepoint 3651 in the IP packet header, it responds per Section 13.2 with an ACK 3652 frame without increasing any ECN counts. If an endpoint does not 3653 implement ECN support or does not have access to received ECN 3654 codepoints, it does not increase ECN counts. 3656 Coalesced packets (see Section 12.2) mean that several packets can 3657 share the same IP header. The ECN counter for the ECN codepoint 3658 received in the associated IP header are incremented once for each 3659 QUIC packet, not per enclosing IP packet or UDP datagram. 3661 Each packet number space maintains separate acknowledgement state and 3662 separate ECN counts. For example, if one each of an Initial, 0-RTT, 3663 Handshake, and 1-RTT QUIC packet are coalesced, the corresponding 3664 counts for the Initial and Handshake packet number space will be 3665 incremented by one and the counts for the 1-RTT packet number space 3666 will be increased by two. 3668 13.4.2. ECN Validation 3670 It is possible for faulty network devices to corrupt or erroneously 3671 drop packets with ECN markings. To provide robust connectivity in 3672 the presence of such devices, each endpoint independently validates 3673 ECN counts and disables ECN if errors are detected. 3675 Endpoints validate ECN for packets sent on each network path 3676 independently. An endpoint thus validates ECN on new connection 3677 establishment, when switching to a new server preferred address, and 3678 on active connection migration to a new path. 3680 Even if an endpoint does not use ECN markings on packets it 3681 transmits, the endpoint MUST provide feedback about ECN markings 3682 received from the peer if they are accessible. Failing to report ECN 3683 counts will cause the peer to disable ECN marking. 3685 13.4.2.1. Sending ECN Markings 3687 To start ECN validation, an endpoint SHOULD do the following when 3688 sending packets on a new path to a peer: 3690 o Set the ECT(0) codepoint in the IP header of early outgoing 3691 packets sent on a new path to the peer [RFC8311]. 3693 o If all packets that were sent with the ECT(0) codepoint are 3694 eventually deemed lost [QUIC-RECOVERY], validation is deemed to 3695 have failed. 3697 To reduce the chances of misinterpreting congestive loss as packets 3698 dropped by a faulty network element, an endpoint could set the ECT(0) 3699 codepoint in the first ten outgoing packets on a path, or for a 3700 period of three RTTs, whichever occurs first. 3702 Implementations MAY experiment with and use other strategies for use 3703 of ECN. Other methods of probing paths for ECN support are possible, 3704 as are different marking strategies. Implementations can also use 3705 the ECT(1) codepoint, as specified in [RFC8311]. 3707 13.4.2.2. Receiving ACK Frames 3709 An endpoint that sets ECT(0) or ECT(1) codepoints on packets it 3710 transmits MUST use the following steps on receiving an ACK frame to 3711 validate ECN. 3713 o If this ACK frame newly acknowledges a packet that the endpoint 3714 sent with either ECT(0) or ECT(1) codepoints set, and if no ECN 3715 feedback is present in the ACK frame, validation fails. This step 3716 protects against both a network element that zeroes out ECN bits 3717 and a peer that is unable to access ECN markings, since the peer 3718 could respond without ECN feedback in these cases. 3720 o For validation to succeed, the total increase in ECT(0), ECT(1), 3721 and CE counts MUST be no smaller than the total number of QUIC 3722 packets sent with an ECT codepoint that are newly acknowledged in 3723 this ACK frame. This step detects any network remarking from 3724 ECT(0), ECT(1), or CE codepoints to Not-ECT. 3726 o Any increase in either ECT(0) or ECT(1) counts, plus any increase 3727 in the CE count, MUST be no smaller than the number of packets 3728 sent with the corresponding ECT codepoint that are newly 3729 acknowledged in this ACK frame. This step detects any erroneous 3730 network remarking from ECT(0) to ECT(1) (or vice versa). 3732 Processing ECN counts out of order can result in validation failure. 3733 An endpoint SHOULD NOT perform this validation if this ACK frame does 3734 not advance the largest packet number acknowledged in this 3735 connection. 3737 An endpoint could miss acknowledgements for a packet when ACK frames 3738 are lost. It is therefore possible for the total increase in ECT(0), 3739 ECT(1), and CE counts to be greater than the number of packets 3740 acknowledged in an ACK frame. When this happens, and if validation 3741 succeeds, the local reference counts MUST be increased to match the 3742 counts in the ACK frame. 3744 13.4.2.3. Validation Outcomes 3746 If validation fails, then the endpoint stops sending ECN markings in 3747 subsequent IP packets with the expectation that either the network 3748 path or the peer does not support ECN. 3750 Upon successful validation, an endpoint can continue to set ECT 3751 codepoints in subsequent packets with the expectation that the path 3752 is ECN-capable. Network routing and path elements can change mid- 3753 connection however; an endpoint MUST disable ECN if validation fails 3754 at any point in the connection. 3756 Even if validation fails, an endpoint MAY revalidate ECN on the same 3757 path at any later time in the connection. 3759 14. Packet Size 3761 The QUIC packet size includes the QUIC header and protected payload, 3762 but not the UDP or IP header. 3764 Clients MUST ensure they send the first Initial packet in a single IP 3765 packet. Similarly, the first Initial packet sent after receiving a 3766 Retry packet MUST be sent in a single IP packet. 3768 The payload of a UDP datagram carrying the first Initial packet MUST 3769 be expanded to at least 1200 bytes, by adding PADDING frames to the 3770 Initial packet and/or by coalescing the Initial packet (see 3771 Section 12.2). Sending a UDP datagram of this size ensures that the 3772 network path supports a reasonable Maximum Transmission Unit (MTU), 3773 and helps reduce the amplitude of amplification attacks caused by 3774 server responses toward an unverified client address; see Section 8. 3776 The datagram containing the first Initial packet from a client MAY 3777 exceed 1200 bytes if the client believes that the Path Maximum 3778 Transmission Unit (PMTU) supports the size that it chooses. 3780 A server MAY send a CONNECTION_CLOSE frame with error code 3781 PROTOCOL_VIOLATION in response to the first Initial packet it 3782 receives from a client if the UDP datagram is smaller than 1200 3783 bytes. It MUST NOT send any other frame type in response, or 3784 otherwise behave as if any part of the offending packet was processed 3785 as valid. 3787 The server MUST also limit the number of bytes it sends before 3788 validating the address of the client; see Section 8. 3790 14.1. Path Maximum Transmission Unit (PMTU) 3792 The PMTU is the maximum size of the entire IP packet including the IP 3793 header, UDP header, and UDP payload. The UDP payload includes the 3794 QUIC packet header, protected payload, and any authentication fields. 3795 The PMTU can depend upon the current path characteristics. 3796 Therefore, the current largest UDP payload an implementation will 3797 send is referred to as the QUIC maximum packet size. 3799 QUIC depends on a PMTU of at least 1280 bytes. This is the IPv6 3800 minimum size [RFC8200] and is also supported by most modern IPv4 3801 networks. All QUIC packets (except for PMTU probe packets) SHOULD be 3802 sized to fit within the maximum packet size to avoid the packet being 3803 fragmented or dropped [RFC8085]. 3805 An endpoint SHOULD use Datagram Packetization Layer PMTU Discovery 3806 ([DPLPMTUD]) or implement Path MTU Discovery (PMTUD) [RFC1191] 3807 [RFC8201] to determine whether the path to a destination will support 3808 a desired message size without fragmentation. 3810 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 3811 packets larger than 1280 bytes. Assuming the minimum IP header size, 3812 this results in a QUIC maximum packet size of 1232 bytes for IPv6 and 3813 1252 bytes for IPv4. A QUIC implementation MAY be more conservative 3814 in computing the QUIC maximum packet size to allow for unknown tunnel 3815 overheads or IP header options/extensions. 3817 Each pair of local and remote addresses could have a different PMTU. 3818 QUIC implementations that implement any kind of PMTU discovery 3819 therefore SHOULD maintain a maximum packet size for each combination 3820 of local and remote IP addresses. 3822 If a QUIC endpoint determines that the PMTU between any pair of local 3823 and remote IP addresses has fallen below the size needed to support 3824 the smallest allowed maximum packet size, it MUST immediately cease 3825 sending QUIC packets, except for PMTU probe packets, on the affected 3826 path. An endpoint MAY terminate the connection if an alternative 3827 path cannot be found. 3829 14.2. ICMP Packet Too Big Messages 3831 PMTU discovery [RFC1191] [RFC8201] relies on reception of ICMP 3832 messages (e.g., IPv6 Packet Too Big messages) that indicate when a 3833 packet is dropped because it is larger than the local router MTU. 3834 DPLPMTUD can also optionally use these messages. This use of ICMP 3835 messages is potentially vulnerable to off-path attacks that 3836 successfully guess the addresses used on the path and reduce the PMTU 3837 to a bandwidth-inefficient value. 3839 An endpoint MUST ignore an ICMP message that claims the PMTU has 3840 decreased below 1280 bytes. 3842 The requirements for generating ICMP ([RFC1812], [RFC4443]) state 3843 that the quoted packet should contain as much of the original packet 3844 as possible without exceeding the minimum MTU for the IP version. 3845 The size of the quoted packet can actually be smaller, or the 3846 information unintelligible, as described in Section 1.1 of 3847 [DPLPMTUD]. 3849 QUIC endpoints SHOULD validate ICMP messages to protect from off-path 3850 injection as specified in [RFC8201] and Section 5.2 of [RFC8085]. 3851 This validation SHOULD use the quoted packet supplied in the payload 3852 of an ICMP message to associate the message with a corresponding 3853 transport connection [DPLPMTUD]. 3855 ICMP message validation MUST include matching IP addresses and UDP 3856 ports [RFC8085] and, when possible, connection IDs to an active QUIC 3857 session. 3859 Further validation can also be provided: 3861 o An IPv4 endpoint could set the Don't Fragment (DF) bit on a small 3862 proportion of packets, so that most invalid ICMP messages arrive 3863 when there are no DF packets outstanding, and can therefore be 3864 identified as spurious. 3866 o An endpoint could store additional information from the IP or UDP 3867 headers to use for validation (for example, the IP ID or UDP 3868 checksum). 3870 The endpoint SHOULD ignore all ICMP messages that fail validation. 3872 An endpoint MUST NOT increase PMTU based on ICMP messages. Any 3873 reduction in the QUIC maximum packet size MAY be provisional until 3874 QUIC's loss detection algorithm determines that the quoted packet has 3875 actually been lost. 3877 14.3. Datagram Packetization Layer PMTU Discovery 3879 Section 6.4 of [DPLPMTUD] provides considerations for implementing 3880 Datagram Packetization Layer PMTUD (DPLPMTUD) with QUIC. 3882 When implementing the algorithm in Section 5.3 of [DPLPMTUD], the 3883 initial value of BASE_PMTU SHOULD be consistent with the minimum QUIC 3884 packet size (1232 bytes for IPv6 and 1252 bytes for IPv4). 3886 PING and PADDING frames can be used to generate PMTU probe packets. 3887 These frames might not be retransmitted if a probe packet containing 3888 them is lost. However, these frames do consume congestion window, 3889 which could delay the transmission of subsequent application data. 3891 A PING frame can be included in a PMTU probe to ensure that a valid 3892 probe is acknowledged. 3894 The considerations for processing ICMP messages in the previous 3895 section also apply if these messages are used by DPLPMTUD. 3897 14.3.1. PMTU Probes Containing Source Connection ID 3899 Endpoints that rely on the destination connection ID for routing QUIC 3900 packets are likely to require that the connection ID be included in 3901 PMTU probe packets to route any resulting ICMP messages 3902 (Section 14.2) back to the correct endpoint. However, only long 3903 header packets (Section 17.2) contain source connection IDs, and long 3904 header packets are not decrypted or acknowledged by the peer once the 3905 handshake is complete. One way to construct a PMTU probe is to 3906 coalesce (see Section 12.2) a Handshake packet (Section 17.2.4) with 3907 a short header packet in a single UDP datagram. If the UDP datagram 3908 reaches the endpoint, the Handshake packet will be ignored, but the 3909 short header packet will be acknowledged. If the UDP datagram 3910 elicits an ICMP message, that message will likely contain the source 3911 connection ID within the quoted portion of the UDP datagram. 3913 15. Versions 3915 QUIC versions are identified using a 32-bit unsigned number. 3917 The version 0x00000000 is reserved to represent version negotiation. 3918 This version of the specification is identified by the number 3919 0x00000001. 3921 Other versions of QUIC might have different properties to this 3922 version. The properties of QUIC that are guaranteed to be consistent 3923 across all versions of the protocol are described in 3924 [QUIC-INVARIANTS]. 3926 Version 0x00000001 of QUIC uses TLS as a cryptographic handshake 3927 protocol, as described in [QUIC-TLS]. 3929 Versions with the most significant 16 bits of the version number 3930 cleared are reserved for use in future IETF consensus documents. 3932 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 3933 forcing version negotiation to be exercised. That is, any version 3934 number where the low four bits of all bytes is 1010 (in binary). A 3935 client or server MAY advertise support for any of these reserved 3936 versions. 3938 Reserved version numbers will probably never represent a real 3939 protocol; a client MAY use one of these version numbers with the 3940 expectation that the server will initiate version negotiation; a 3941 server MAY advertise support for one of these versions and can expect 3942 that clients ignore the value. 3944 [[RFC editor: please remove the remainder of this section before 3945 publication.]] 3947 The version number for the final version of this specification 3948 (0x00000001), is reserved for the version of the protocol that is 3949 published as an RFC. 3951 Version numbers used to identify IETF drafts are created by adding 3952 the draft number to 0xff000000. For example, draft-ietf-quic- 3953 transport-13 would be identified as 0xff00000D. 3955 Implementors are encouraged to register version numbers of QUIC that 3956 they are using for private experimentation on the GitHub wiki at 3957 . 3959 16. Variable-Length Integer Encoding 3961 QUIC packets and frames commonly use a variable-length encoding for 3962 non-negative integer values. This encoding ensures that smaller 3963 integer values need fewer bytes to encode. 3965 The QUIC variable-length integer encoding reserves the two most 3966 significant bits of the first byte to encode the base 2 logarithm of 3967 the integer encoding length in bytes. The integer value is encoded 3968 on the remaining bits, in network byte order. 3970 This means that integers are encoded on 1, 2, 4, or 8 bytes and can 3971 encode 6, 14, 30, or 62 bit values respectively. Table 4 summarizes 3972 the encoding properties. 3974 +------+--------+-------------+-----------------------+ 3975 | 2Bit | Length | Usable Bits | Range | 3976 +------+--------+-------------+-----------------------+ 3977 | 00 | 1 | 6 | 0-63 | 3978 | | | | | 3979 | 01 | 2 | 14 | 0-16383 | 3980 | | | | | 3981 | 10 | 4 | 30 | 0-1073741823 | 3982 | | | | | 3983 | 11 | 8 | 62 | 0-4611686018427387903 | 3984 +------+--------+-------------+-----------------------+ 3986 Table 4: Summary of Integer Encodings 3988 For example, the eight byte sequence c2 19 7c 5e ff 14 e8 8c (in 3989 hexadecimal) decodes to the decimal value 151288809941952652; the 3990 four byte sequence 9d 7f 3e 7d decodes to 494878333; the two byte 3991 sequence 7b bd decodes to 15293; and the single byte 25 decodes to 37 3992 (as does the two byte sequence 40 25). 3994 Error codes (Section 20) and versions (Section 15) are described 3995 using integers, but do not use this encoding. 3997 17. Packet Formats 3999 All numeric values are encoded in network byte order (that is, big- 4000 endian) and all field sizes are in bits. Hexadecimal notation is 4001 used for describing the value of fields. 4003 17.1. Packet Number Encoding and Decoding 4005 Packet numbers are integers in the range 0 to 2^62-1 (Section 12.3). 4006 When present in long or short packet headers, they are encoded in 1 4007 to 4 bytes. The number of bits required to represent the packet 4008 number is reduced by including the least significant bits of the 4009 packet number. 4011 The encoded packet number is protected as described in Section 5.4 of 4012 [QUIC-TLS]. 4014 The sender MUST use a packet number size able to represent more than 4015 twice as large a range than the difference between the largest 4016 acknowledged packet and packet number being sent. A peer receiving 4017 the packet will then correctly decode the packet number, unless the 4018 packet is delayed in transit such that it arrives after many higher- 4019 numbered packets have been received. An endpoint SHOULD use a large 4020 enough packet number encoding to allow the packet number to be 4021 recovered even if the packet arrives after packets that are sent 4022 afterwards. 4024 As a result, the size of the packet number encoding is at least one 4025 bit more than the base-2 logarithm of the number of contiguous 4026 unacknowledged packet numbers, including the new packet. 4028 For example, if an endpoint has received an acknowledgment for packet 4029 0xabe8bc, sending a packet with a number of 0xac5c02 requires a 4030 packet number encoding with 16 bits or more; whereas the 24-bit 4031 packet number encoding is needed to send a packet with a number of 4032 0xace8fe. 4034 At a receiver, protection of the packet number is removed prior to 4035 recovering the full packet number. The full packet number is then 4036 reconstructed based on the number of significant bits present, the 4037 value of those bits, and the largest packet number received on a 4038 successfully authenticated packet. Recovering the full packet number 4039 is necessary to successfully remove packet protection. 4041 Once header protection is removed, the packet number is decoded by 4042 finding the packet number value that is closest to the next expected 4043 packet. The next expected packet is the highest received packet 4044 number plus one. For example, if the highest successfully 4045 authenticated packet had a packet number of 0xa82f30ea, then a packet 4046 containing a 16-bit value of 0x9b32 will be decoded as 0xa82f9b32. 4047 Example pseudo-code for packet number decoding can be found in 4048 Appendix A. 4050 17.2. Long Header Packets 4052 0 1 2 3 4053 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 4054 +-+-+-+-+-+-+-+-+ 4055 |1|1|T T|X X X X| 4056 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4057 | Version (32) | 4058 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4059 | DCID Len (8) | 4060 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4061 | Destination Connection ID (0..160) ... 4062 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4063 | SCID Len (8) | 4064 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4065 | Source Connection ID (0..160) ... 4066 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4068 Figure 9: Long Header Packet Format 4070 Long headers are used for packets that are sent prior to the 4071 establishment of 1-RTT keys. Once both conditions are met, a sender 4072 switches to sending packets using the short header (Section 17.3). 4073 The long form allows for special packets - such as the Version 4074 Negotiation packet - to be represented in this uniform fixed-length 4075 packet format. Packets that use the long header contain the 4076 following fields: 4078 Header Form: The most significant bit (0x80) of byte 0 (the first 4079 byte) is set to 1 for long headers. 4081 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4082 containing a zero value for this bit are not valid packets in this 4083 version and MUST be discarded. 4085 Long Packet Type (T): The next two bits (those with a mask of 0x30) 4086 of byte 0 contain a packet type. Packet types are listed in 4087 Table 5. 4089 Type-Specific Bits (X): The lower four bits (those with a mask of 4090 0x0f) of byte 0 are type-specific. 4092 Version: The QUIC Version is a 32-bit field that follows the first 4093 byte. This field indicates which version of QUIC is in use and 4094 determines how the rest of the protocol fields are interpreted. 4096 DCID Len: The byte following the version contains the length in 4097 bytes of the Destination Connection ID field that follows it. 4098 This length is encoded as an 8-bit unsigned integer. In QUIC 4099 version 1, this value MUST NOT exceed 20. Endpoints that receive 4100 a version 1 long header with a value larger than 20 MUST drop the 4101 packet. Servers SHOULD be able to read longer connection IDs from 4102 other QUIC versions in order to properly form a version 4103 negotiation packet. 4105 Destination Connection ID: The Destination Connection ID field 4106 follows the DCID Len and is between 0 and 20 bytes in length. 4107 Section 7.2 describes the use of this field in more detail. 4109 SCID Len: The byte following the Destination Connection ID contains 4110 the length in bytes of the Source Connection ID field that follows 4111 it. This length is encoded as a 8-bit unsigned integer. In QUIC 4112 version 1, this value MUST NOT exceed 20 bytes. Endpoints that 4113 receive a version 1 long header with a value larger than 20 MUST 4114 drop the packet. Servers SHOULD be able to read longer connection 4115 IDs from other QUIC versions in order to properly form a version 4116 negotiation packet. 4118 Source Connection ID: The Source Connection ID field follows the 4119 SCID Len and is between 0 and 20 bytes in length. Section 7.2 4120 describes the use of this field in more detail. 4122 In this version of QUIC, the following packet types with the long 4123 header are defined: 4125 +------+-----------+----------------+ 4126 | Type | Name | Section | 4127 +------+-----------+----------------+ 4128 | 0x0 | Initial | Section 17.2.2 | 4129 | | | | 4130 | 0x1 | 0-RTT | Section 17.2.3 | 4131 | | | | 4132 | 0x2 | Handshake | Section 17.2.4 | 4133 | | | | 4134 | 0x3 | Retry | Section 17.2.5 | 4135 +------+-----------+----------------+ 4137 Table 5: Long Header Packet Types 4139 The header form bit, connection ID lengths byte, Destination and 4140 Source Connection ID fields, and Version fields of a long header 4141 packet are version-independent. The other fields in the first byte 4142 are version-specific. See [QUIC-INVARIANTS] for details on how 4143 packets from different versions of QUIC are interpreted. 4145 The interpretation of the fields and the payload are specific to a 4146 version and packet type. While type-specific semantics for this 4147 version are described in the following sections, several long-header 4148 packets in this version of QUIC contain these additional fields: 4150 Reserved Bits (R): Two bits (those with a mask of 0x0c) of byte 0 4151 are reserved across multiple packet types. These bits are 4152 protected using header protection (see Section 5.4 of [QUIC-TLS]). 4153 The value included prior to protection MUST be set to 0. An 4154 endpoint MUST treat receipt of a packet that has a non-zero value 4155 for these bits, after removing both packet and header protection, 4156 as a connection error of type PROTOCOL_VIOLATION. Discarding such 4157 a packet after only removing header protection can expose the 4158 endpoint to attacks (see Section 9.3 of [QUIC-TLS]). 4160 Packet Number Length (P): In packet types which contain a Packet 4161 Number field, the least significant two bits (those with a mask of 4162 0x03) of byte 0 contain the length of the packet number, encoded 4163 as an unsigned, two-bit integer that is one less than the length 4164 of the packet number field in bytes. That is, the length of the 4165 packet number field is the value of this field, plus one. These 4166 bits are protected using header protection (see Section 5.4 of 4167 [QUIC-TLS]). 4169 Length: The length of the remainder of the packet (that is, the 4170 Packet Number and Payload fields) in bytes, encoded as a variable- 4171 length integer (Section 16). 4173 Packet Number: The packet number field is 1 to 4 bytes long. The 4174 packet number has confidentiality protection separate from packet 4175 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4176 of the packet number field is encoded in the Packet Number Length 4177 bits of byte 0 (see above). 4179 17.2.1. Version Negotiation Packet 4181 A Version Negotiation packet is inherently not version-specific. 4182 Upon receipt by a client, it will be identified as a Version 4183 Negotiation packet based on the Version field having a value of 0. 4185 The Version Negotiation packet is a response to a client packet that 4186 contains a version that is not supported by the server, and is only 4187 sent by servers. 4189 The layout of a Version Negotiation packet is: 4191 0 1 2 3 4192 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 4193 +-+-+-+-+-+-+-+-+ 4194 |1| Unused (7) | 4195 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4196 | Version (32) | 4197 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4198 | DCID Len (8) | 4199 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4200 | Destination Connection ID (0..2040) ... 4201 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4202 | SCID Len (8) | 4203 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4204 | Source Connection ID (0..2040) ... 4205 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4206 | Supported Version 1 (32) ... 4207 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4208 | [Supported Version 2 (32)] ... 4209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4210 ... 4211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4212 | [Supported Version N (32)] ... 4213 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4215 Figure 10: Version Negotiation Packet 4217 The value in the Unused field is selected randomly by the server. 4218 Clients MUST ignore the value of this field. Servers SHOULD set the 4219 most significant bit of this field (0x40) to 1 so that Version 4220 Negotiation packets appear to have the Fixed Bit field. 4222 The Version field of a Version Negotiation packet MUST be set to 4223 0x00000000. 4225 The server MUST include the value from the Source Connection ID field 4226 of the packet it receives in the Destination Connection ID field. 4227 The value for Source Connection ID MUST be copied from the 4228 Destination Connection ID of the received packet, which is initially 4229 randomly selected by a client. Echoing both connection IDs gives 4230 clients some assurance that the server received the packet and that 4231 the Version Negotiation packet was not generated by an off-path 4232 attacker. 4234 As future versions of QUIC may support Connection IDs larger than the 4235 version 1 limit, Version Negotiation packets could carry Connection 4236 IDs that are longer than 20 bytes. 4238 The remainder of the Version Negotiation packet is a list of 32-bit 4239 versions which the server supports. 4241 A Version Negotiation packet cannot be explicitly acknowledged in an 4242 ACK frame by a client. Receiving another Initial packet implicitly 4243 acknowledges a Version Negotiation packet. 4245 The Version Negotiation packet does not include the Packet Number and 4246 Length fields present in other packets that use the long header form. 4247 Consequently, a Version Negotiation packet consumes an entire UDP 4248 datagram. 4250 A server MUST NOT send more than one Version Negotiation packet in 4251 response to a single UDP datagram. 4253 See Section 6 for a description of the version negotiation process. 4255 17.2.2. Initial Packet 4257 An Initial packet uses long headers with a type value of 0x0. It 4258 carries the first CRYPTO frames sent by the client and server to 4259 perform key exchange, and carries ACKs in either direction. 4261 +-+-+-+-+-+-+-+-+ 4262 |1|1| 0 |R R|P P| 4263 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4264 | Version (32) | 4265 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4266 | DCID Len (8) | 4267 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4268 | Destination Connection ID (0..160) ... 4269 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4270 | SCID Len (8) | 4271 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4272 | Source Connection ID (0..160) ... 4273 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4274 | Token Length (i) ... 4275 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4276 | Token (*) ... 4277 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4278 | Length (i) ... 4279 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4280 | Packet Number (8/16/24/32) ... 4281 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4282 | Payload (*) ... 4283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4285 Figure 11: Initial Packet 4287 The Initial packet contains a long header as well as the Length and 4288 Packet Number fields. The first byte contains the Reserved and 4289 Packet Number Length bits. Between the SCID and Length fields, there 4290 are two additional field specific to the Initial packet. 4292 Token Length: A variable-length integer specifying the length of the 4293 Token field, in bytes. This value is zero if no token is present. 4294 Initial packets sent by the server MUST set the Token Length field 4295 to zero; clients that receive an Initial packet with a non-zero 4296 Token Length field MUST either discard the packet or generate a 4297 connection error of type PROTOCOL_VIOLATION. 4299 Token: The value of the token that was previously provided in a 4300 Retry packet or NEW_TOKEN frame. 4302 Payload: The payload of the packet. 4304 In order to prevent tampering by version-unaware middleboxes, Initial 4305 packets are protected with connection- and version-specific keys 4306 (Initial keys) as described in [QUIC-TLS]. This protection does not 4307 provide confidentiality or integrity against on-path attackers, but 4308 provides some level of protection against off-path attackers. 4310 The client and server use the Initial packet type for any packet that 4311 contains an initial cryptographic handshake message. This includes 4312 all cases where a new packet containing the initial cryptographic 4313 message needs to be created, such as the packets sent after receiving 4314 a Retry packet (Section 17.2.5). 4316 A server sends its first Initial packet in response to a client 4317 Initial. A server may send multiple Initial packets. The 4318 cryptographic key exchange could require multiple round trips or 4319 retransmissions of this data. 4321 The payload of an Initial packet includes a CRYPTO frame (or frames) 4322 containing a cryptographic handshake message, ACK frames, or both. 4323 PADDING and CONNECTION_CLOSE frames are also permitted. An endpoint 4324 that receives an Initial packet containing other frames can either 4325 discard the packet as spurious or treat it as a connection error. 4327 The first packet sent by a client always includes a CRYPTO frame that 4328 contains the entirety of the first cryptographic handshake message. 4329 This packet, and the cryptographic handshake message, MUST fit in a 4330 single UDP datagram (see Section 7). The first CRYPTO frame sent 4331 always begins at an offset of 0 (see Section 7). 4333 Note that if the server sends a HelloRetryRequest, the client will 4334 send a second Initial packet. This Initial packet will continue the 4335 cryptographic handshake and will contain a CRYPTO frame with an 4336 offset matching the size of the CRYPTO frame sent in the first 4337 Initial packet. Cryptographic handshake messages subsequent to the 4338 first do not need to fit within a single UDP datagram. 4340 17.2.2.1. Abandoning Initial Packets 4342 A client stops both sending and processing Initial packets when it 4343 sends its first Handshake packet. A server stops sending and 4344 processing Initial packets when it receives its first Handshake 4345 packet. Though packets might still be in flight or awaiting 4346 acknowledgment, no further Initial packets need to be exchanged 4347 beyond this point. Initial packet protection keys are discarded (see 4348 Section 4.9.1 of [QUIC-TLS]) along with any loss recovery and 4349 congestion control state (see Section 6.5 of [QUIC-RECOVERY]). 4351 Any data in CRYPTO frames is discarded - and no longer retransmitted 4352 - when Initial keys are discarded. 4354 17.2.3. 0-RTT 4356 A 0-RTT packet uses long headers with a type value of 0x1, followed 4357 by the Length and Packet Number fields. The first byte contains the 4358 Reserved and Packet Number Length bits. It is used to carry "early" 4359 data from the client to the server as part of the first flight, prior 4360 to handshake completion. As part of the TLS handshake, the server 4361 can accept or reject this early data. 4363 See Section 2.3 of [TLS13] for a discussion of 0-RTT data and its 4364 limitations. 4366 +-+-+-+-+-+-+-+-+ 4367 |1|1| 1 |R R|P P| 4368 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4369 | Version (32) | 4370 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4371 | DCID Len (8) | 4372 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4373 | Destination Connection ID (0..160) ... 4374 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4375 | SCID Len (8) | 4376 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4377 | Source Connection ID (0..160) ... 4378 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4379 | Length (i) ... 4380 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4381 | Packet Number (8/16/24/32) ... 4382 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4383 | Payload (*) ... 4384 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4386 0-RTT Packet 4388 Packet numbers for 0-RTT protected packets use the same space as 4389 1-RTT protected packets. 4391 After a client receives a Retry packet, 0-RTT packets are likely to 4392 have been lost or discarded by the server. A client SHOULD attempt 4393 to resend data in 0-RTT packets after it sends a new Initial packet. 4395 A client MUST NOT reset the packet number it uses for 0-RTT packets, 4396 since the keys used to protect 0-RTT packets will not change as a 4397 result of responding to a Retry packet. Sending packets with the 4398 same packet number in that case is likely to compromise the packet 4399 protection for all 0-RTT packets because the same key and nonce could 4400 be used to protect different content. 4402 A client only receives acknowledgments for its 0-RTT packets once the 4403 handshake is complete. Consequently, a server might expect 0-RTT 4404 packets to start with a packet number of 0. Therefore, in 4405 determining the length of the packet number encoding for 0-RTT 4406 packets, a client MUST assume that all packets up to the current 4407 packet number are in flight, starting from a packet number of 0. 4408 Thus, 0-RTT packets could need to use a longer packet number 4409 encoding. 4411 A client MUST NOT send 0-RTT packets once it starts processing 1-RTT 4412 packets from the server. This means that 0-RTT packets cannot 4413 contain any response to frames from 1-RTT packets. For instance, a 4414 client cannot send an ACK frame in a 0-RTT packet, because that can 4415 only acknowledge a 1-RTT packet. An acknowledgment for a 1-RTT 4416 packet MUST be carried in a 1-RTT packet. 4418 A server SHOULD treat a violation of remembered limits as a 4419 connection error of an appropriate type (for instance, a 4420 FLOW_CONTROL_ERROR for exceeding stream data limits). 4422 17.2.4. Handshake Packet 4424 A Handshake packet uses long headers with a type value of 0x2, 4425 followed by the Length and Packet Number fields. The first byte 4426 contains the Reserved and Packet Number Length bits. It is used to 4427 carry acknowledgments and cryptographic handshake messages from the 4428 server and client. 4430 +-+-+-+-+-+-+-+-+ 4431 |1|1| 2 |R R|P P| 4432 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4433 | Version (32) | 4434 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4435 | DCID Len (8) | 4436 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4437 | Destination Connection ID (0..160) ... 4438 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4439 | SCID Len (8) | 4440 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4441 | Source Connection ID (0..160) ... 4442 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4443 | Length (i) ... 4444 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4445 | Packet Number (8/16/24/32) ... 4446 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4447 | Payload (*) ... 4448 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4450 Figure 12: Handshake Protected Packet 4452 Once a client has received a Handshake packet from a server, it uses 4453 Handshake packets to send subsequent cryptographic handshake messages 4454 and acknowledgments to the server. 4456 The Destination Connection ID field in a Handshake packet contains a 4457 connection ID that is chosen by the recipient of the packet; the 4458 Source Connection ID includes the connection ID that the sender of 4459 the packet wishes to use (see Section 7.2). 4461 Handshake packets are their own packet number space, and thus the 4462 first Handshake packet sent by a server contains a packet number of 4463 0. 4465 The payload of this packet contains CRYPTO frames and could contain 4466 PADDING, or ACK frames. Handshake packets MAY contain 4467 CONNECTION_CLOSE frames. Endpoints MUST treat receipt of Handshake 4468 packets with other frames as a connection error. 4470 Like Initial packets (see Section 17.2.2.1), data in CRYPTO frames at 4471 the Handshake encryption level is discarded - and no longer 4472 retransmitted - when Handshake protection keys are discarded. 4474 17.2.5. Retry Packet 4476 A Retry packet uses a long packet header with a type value of 0x3. 4477 It carries an address validation token created by the server. It is 4478 used by a server that wishes to perform a retry (see Section 8.1). 4480 0 1 2 3 4481 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 4482 +-+-+-+-+-+-+-+-+ 4483 |1|1| 3 | Unused| 4484 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4485 | Version (32) | 4486 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4487 | DCID Len (8) | 4488 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4489 | Destination Connection ID (0..160) ... 4490 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4491 | SCID Len (8) | 4492 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4493 | Source Connection ID (0..160) ... 4494 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4495 | ODCID Len (8) | 4496 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4497 | Original Destination Connection ID (0..160) ... 4498 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4499 | Retry Token (*) ... 4500 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4502 Figure 13: Retry Packet 4504 A Retry packet (shown in Figure 13) does not contain any protected 4505 fields. The value in the Unused field is selected randomly by the 4506 server. In addition to the long header, it contains these additional 4507 fields: 4509 ODCID Len: The ODCID Len contains the length in bytes of the 4510 Original Destination Connection ID field that follows it. This 4511 length is encoded as a 8-bit unsigned integer. In QUIC version 1, 4512 this value MUST NOT exceed 20 bytes. Clients that receive a 4513 version 1 Retry Packet with a value larger than 20 MUST drop the 4514 packet. 4516 Original Destination Connection ID: The Original Destination 4517 Connection ID contains the value of the Destination Connection ID 4518 from the Initial packet that this Retry is in response to. The 4519 length of this field is given in ODCID Len. 4521 Retry Token: An opaque token that the server can use to validate the 4522 client's address. 4524 The server populates the Destination Connection ID with the 4525 connection ID that the client included in the Source Connection ID of 4526 the Initial packet. 4528 The server includes a connection ID of its choice in the Source 4529 Connection ID field. This value MUST not be equal to the Destination 4530 Connection ID field of the packet sent by the client. The client 4531 MUST use this connection ID in the Destination Connection ID of 4532 subsequent packets that it sends. 4534 A server MAY send Retry packets in response to Initial and 0-RTT 4535 packets. A server can either discard or buffer 0-RTT packets that it 4536 receives. A server can send multiple Retry packets as it receives 4537 Initial or 0-RTT packets. A server MUST NOT send more than one Retry 4538 packet in response to a single UDP datagram. 4540 A client MUST accept and process at most one Retry packet for each 4541 connection attempt. After the client has received and processed an 4542 Initial or Retry packet from the server, it MUST discard any 4543 subsequent Retry packets that it receives. 4545 Clients MUST discard Retry packets that contain an Original 4546 Destination Connection ID field that does not match the Destination 4547 Connection ID from its Initial packet. This prevents an off-path 4548 attacker from injecting a Retry packet. 4550 The client responds to a Retry packet with an Initial packet that 4551 includes the provided Retry Token to continue connection 4552 establishment. 4554 A client sets the Destination Connection ID field of this Initial 4555 packet to the value from the Source Connection ID in the Retry 4556 packet. Changing Destination Connection ID also results in a change 4557 to the keys used to protect the Initial packet. It also sets the 4558 Token field to the token provided in the Retry. The client MUST NOT 4559 change the Source Connection ID because the server could include the 4560 connection ID as part of its token validation logic (see 4561 Section 8.1.3). 4563 The next Initial packet from the client uses the connection ID and 4564 token values from the Retry packet (see Section 7.2). Aside from 4565 this, the Initial packet sent by the client is subject to the same 4566 restrictions as the first Initial packet. A client MUST use the same 4567 cryptographic handshake message it includes in this packet. A server 4568 MAY treat a packet that contains a different cryptographic handshake 4569 message as a connection error or discard it. 4571 A client MAY attempt 0-RTT after receiving a Retry packet by sending 4572 0-RTT packets to the connection ID provided by the server. A client 4573 MUST NOT change the cryptographic handshake message it sends in 4574 response to receiving a Retry. 4576 A client MUST NOT reset the packet number for any packet number space 4577 after processing a Retry packet; Section 17.2.3 contains more 4578 information on this. 4580 A server acknowledges the use of a Retry packet for a connection 4581 using the original_connection_id transport parameter (see 4582 Section 18.2). If the server sends a Retry packet, it MUST include 4583 the value of the Original Destination Connection ID field of the 4584 Retry packet (that is, the Destination Connection ID field from the 4585 client's first Initial packet) in the transport parameter. 4587 If the client received and processed a Retry packet, it MUST validate 4588 that the original_connection_id transport parameter is present and 4589 correct; otherwise, it MUST validate that the transport parameter is 4590 absent. A client MUST treat a failed validation as a connection 4591 error of type TRANSPORT_PARAMETER_ERROR. 4593 A Retry packet does not include a packet number and cannot be 4594 explicitly acknowledged by a client. 4596 17.3. Short Header Packets 4598 This version of QUIC defines a single packet type which uses the 4599 short packet header. 4601 0 1 2 3 4602 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 4603 +-+-+-+-+-+-+-+-+ 4604 |0|1|S|R|R|K|P P| 4605 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4606 | Destination Connection ID (0..160) ... 4607 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4608 | Packet Number (8/16/24/32) ... 4609 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4610 | Protected Payload (*) ... 4611 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4613 Figure 14: Short Header Packet Format 4615 The short header can be used after the version and 1-RTT keys are 4616 negotiated. Packets that use the short header contain the following 4617 fields: 4619 Header Form: The most significant bit (0x80) of byte 0 is set to 0 4620 for the short header. 4622 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4623 containing a zero value for this bit are not valid packets in this 4624 version and MUST be discarded. 4626 Spin Bit (S): The third most significant bit (0x20) of byte 0 is the 4627 latency spin bit, set as described in Section 17.3.1. 4629 Reserved Bits (R): The next two bits (those with a mask of 0x18) of 4630 byte 0 are reserved. These bits are protected using header 4631 protection (see Section 5.4 of [QUIC-TLS]). The value included 4632 prior to protection MUST be set to 0. An endpoint MUST treat 4633 receipt of a packet that has a non-zero value for these bits, 4634 after removing both packet and header protection, as a connection 4635 error of type PROTOCOL_VIOLATION. Discarding such a packet after 4636 only removing header protection can expose the endpoint to attacks 4637 (see Section 9.3 of [QUIC-TLS]). 4639 Key Phase (K): The next bit (0x04) of byte 0 indicates the key 4640 phase, which allows a recipient of a packet to identify the packet 4641 protection keys that are used to protect the packet. See 4642 [QUIC-TLS] for details. This bit is protected using header 4643 protection (see Section 5.4 of [QUIC-TLS]). 4645 Packet Number Length (P): The least significant two bits (those with 4646 a mask of 0x03) of byte 0 contain the length of the packet number, 4647 encoded as an unsigned, two-bit integer that is one less than the 4648 length of the packet number field in bytes. That is, the length 4649 of the packet number field is the value of this field, plus one. 4650 These bits are protected using header protection (see Section 5.4 4651 of [QUIC-TLS]). 4653 Destination Connection ID: The Destination Connection ID is a 4654 connection ID that is chosen by the intended recipient of the 4655 packet. See Section 5.1 for more details. 4657 Packet Number: The packet number field is 1 to 4 bytes long. The 4658 packet number has confidentiality protection separate from packet 4659 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4660 of the packet number field is encoded in Packet Number Length 4661 field. See Section 17.1 for details. 4663 Protected Payload: Packets with a short header always include a 4664 1-RTT protected payload. 4666 The header form bit and the connection ID field of a short header 4667 packet are version-independent. The remaining fields are specific to 4668 the selected QUIC version. See [QUIC-INVARIANTS] for details on how 4669 packets from different versions of QUIC are interpreted. 4671 17.3.1. Latency Spin Bit 4673 The latency spin bit enables passive latency monitoring from 4674 observation points on the network path throughout the duration of a 4675 connection. The spin bit is only present in the short packet header, 4676 since it is possible to measure the initial RTT of a connection by 4677 observing the handshake. Therefore, the spin bit is available after 4678 version negotiation and connection establishment are completed. On- 4679 path measurement and use of the latency spin bit is further discussed 4680 in [QUIC-MANAGEABILITY]. 4682 The spin bit is an OPTIONAL feature of QUIC. A QUIC stack that 4683 chooses to support the spin bit MUST implement it as specified in 4684 this section. 4686 Each endpoint unilaterally decides if the spin bit is enabled or 4687 disabled for a connection. Implementations MUST allow administrators 4688 of clients and servers to disable the spin bit either globally or on 4689 a per-connection basis. Even when the spin bit is not disabled by 4690 the administrator, implementations MUST disable the spin bit for a 4691 given connection with a certain likelihood. The random selection 4692 process SHOULD be designed such that on average the spin bit is 4693 disabled for at least one eighth of network paths. The selection 4694 process performed at the beginning of the connection SHOULD be 4695 applied for all paths used by the connection. 4697 When the spin bit is disabled, endpoints MAY set the spin bit to any 4698 value, and MUST ignore any incoming value. It is RECOMMENDED that 4699 endpoints set the spin bit to a random value either chosen 4700 independently for each packet or chosen independently for each 4701 connection ID. 4703 If the spin bit is enabled for the connection, the endpoint maintains 4704 a spin value and sets the spin bit in the short header to the 4705 currently stored value when a packet with a short header is sent out. 4706 The spin value is initialized to 0 in the endpoint at connection 4707 start. Each endpoint also remembers the highest packet number seen 4708 from its peer on the connection. 4710 When a server receives a short header packet that increments the 4711 highest packet number seen by the server from the client, it sets the 4712 spin value to be equal to the spin bit in the received packet. 4714 When a client receives a short header packet that increments the 4715 highest packet number seen by the client from the server, it sets the 4716 spin value to the inverse of the spin bit in the received packet. 4718 An endpoint resets its spin value to zero when sending the first 4719 packet of a given connection with a new connection ID. This reduces 4720 the risk that transient spin bit state can be used to link flows 4721 across connection migration or ID change. 4723 With this mechanism, the server reflects the spin value received, 4724 while the client 'spins' it after one RTT. On-path observers can 4725 measure the time between two spin bit toggle events to estimate the 4726 end-to-end RTT of a connection. 4728 18. Transport Parameter Encoding 4730 The format of the transport parameters is the TransportParameters 4731 struct from Figure 15. This is described using the presentation 4732 language from Section 3 of [TLS13]. 4734 enum { 4735 original_connection_id(0), 4736 idle_timeout(1), 4737 stateless_reset_token(2), 4738 max_packet_size(3), 4739 initial_max_data(4), 4740 initial_max_stream_data_bidi_local(5), 4741 initial_max_stream_data_bidi_remote(6), 4742 initial_max_stream_data_uni(7), 4743 initial_max_streams_bidi(8), 4744 initial_max_streams_uni(9), 4745 ack_delay_exponent(10), 4746 max_ack_delay(11), 4747 disable_active_migration(12), 4748 preferred_address(13), 4749 active_connection_id_limit(14), 4750 (65535) 4751 } TransportParameterId; 4753 struct { 4754 TransportParameterId parameter; 4755 opaque value<0..2^16-1>; 4756 } TransportParameter; 4758 TransportParameter TransportParameters<0..2^16-1>; 4760 Figure 15: Definition of TransportParameters 4762 The "extension_data" field of the quic_transport_parameters extension 4763 defined in [QUIC-TLS] contains a TransportParameters value. TLS 4764 encoding rules are therefore used to describe the encoding of 4765 transport parameters. 4767 QUIC encodes transport parameters into a sequence of bytes, which are 4768 then included in the cryptographic handshake. 4770 18.1. Reserved Transport Parameters 4772 Transport parameters with an identifier of the form "31 * N + 27" for 4773 integer values of N are reserved to exercise the requirement that 4774 unknown transport parameters be ignored. These transport parameters 4775 have no semantics, and may carry arbitrary values. 4777 18.2. Transport Parameter Definitions 4779 This section details the transport parameters defined in this 4780 document. 4782 Many transport parameters listed here have integer values. Those 4783 transport parameters that are identified as integers use a variable- 4784 length integer encoding (see Section 16) and have a default value of 4785 0 if the transport parameter is absent, unless otherwise stated. 4787 The following transport parameters are defined: 4789 original_connection_id (0x0000): The value of the Destination 4790 Connection ID field from the first Initial packet sent by the 4791 client. This transport parameter is only sent by a server. A 4792 server MUST include the original_connection_id transport parameter 4793 if it sent a Retry packet. 4795 idle_timeout (0x0001): The idle timeout is a value in milliseconds 4796 that is encoded as an integer; see (Section 10.2). If this 4797 parameter is absent or zero then the idle timeout is disabled. 4799 stateless_reset_token (0x0002): A stateless reset token is used in 4800 verifying a stateless reset; see Section 10.4. This parameter is 4801 a sequence of 16 bytes. This transport parameter MUST NOT be sent 4802 by a client, but MAY be sent by a server. A server that does not 4803 send this transport parameter cannot use stateless reset 4804 (Section 10.4) for the connection ID negotiated during the 4805 handshake. 4807 max_packet_size (0x0003): The maximum packet size parameter is an 4808 integer value that limits the size of packets that the endpoint is 4809 willing to receive. This indicates that packets larger than this 4810 limit will be dropped. The default for this parameter is the 4811 maximum permitted UDP payload of 65527. Values below 1200 are 4812 invalid. This limit only applies to protected packets 4813 (Section 12.1). 4815 initial_max_data (0x0004): The initial maximum data parameter is an 4816 integer value that contains the initial value for the maximum 4817 amount of data that can be sent on the connection. This is 4818 equivalent to sending a MAX_DATA (Section 19.9) for the connection 4819 immediately after completing the handshake. 4821 initial_max_stream_data_bidi_local (0x0005): This parameter is an 4822 integer value specifying the initial flow control limit for 4823 locally-initiated bidirectional streams. This limit applies to 4824 newly created bidirectional streams opened by the endpoint that 4825 sends the transport parameter. In client transport parameters, 4826 this applies to streams with an identifier with the least 4827 significant two bits set to 0x0; in server transport parameters, 4828 this applies to streams with the least significant two bits set to 4829 0x1. 4831 initial_max_stream_data_bidi_remote (0x0006): This parameter is an 4832 integer value specifying the initial flow control limit for peer- 4833 initiated bidirectional streams. This limit applies to newly 4834 created bidirectional streams opened by the endpoint that receives 4835 the transport parameter. In client transport parameters, this 4836 applies to streams with an identifier with the least significant 4837 two bits set to 0x1; in server transport parameters, this applies 4838 to streams with the least significant two bits set to 0x0. 4840 initial_max_stream_data_uni (0x0007): This parameter is an integer 4841 value specifying the initial flow control limit for unidirectional 4842 streams. This limit applies to newly created unidirectional 4843 streams opened by the endpoint that receives the transport 4844 parameter. In client transport parameters, this applies to 4845 streams with an identifier with the least significant two bits set 4846 to 0x3; in server transport parameters, this applies to streams 4847 with the least significant two bits set to 0x2. 4849 initial_max_streams_bidi (0x0008): The initial maximum bidirectional 4850 streams parameter is an integer value that contains the initial 4851 maximum number of bidirectional streams the peer may initiate. If 4852 this parameter is absent or zero, the peer cannot open 4853 bidirectional streams until a MAX_STREAMS frame is sent. Setting 4854 this parameter is equivalent to sending a MAX_STREAMS 4855 (Section 19.11) of the corresponding type with the same value. 4857 initial_max_streams_uni (0x0009): The initial maximum unidirectional 4858 streams parameter is an integer value that contains the initial 4859 maximum number of unidirectional streams the peer may initiate. 4860 If this parameter is absent or zero, the peer cannot open 4861 unidirectional streams until a MAX_STREAMS frame is sent. Setting 4862 this parameter is equivalent to sending a MAX_STREAMS 4863 (Section 19.11) of the corresponding type with the same value. 4865 ack_delay_exponent (0x000a): The ACK delay exponent is an integer 4866 value indicating an exponent used to decode the ACK Delay field in 4867 the ACK frame (Section 19.3). If this value is absent, a default 4868 value of 3 is assumed (indicating a multiplier of 8). Values 4869 above 20 are invalid. 4871 max_ack_delay (0x000b): The maximum ACK delay is an integer value 4872 indicating the maximum amount of time in milliseconds by which the 4873 endpoint will delay sending acknowledgments. This value SHOULD 4874 include the receiver's expected delays in alarms firing. For 4875 example, if a receiver sets a timer for 5ms and alarms commonly 4876 fire up to 1ms late, then it should send a max_ack_delay of 6ms. 4877 If this value is absent, a default of 25 milliseconds is assumed. 4878 Values of 2^14 or greater are invalid. 4880 disable_active_migration (0x000c): The disable active migration 4881 transport parameter is included if the endpoint does not support 4882 active connection migration (Section 9). Peers of an endpoint 4883 that sets this transport parameter MUST NOT send any packets, 4884 including probing packets (Section 9.1), from a local address or 4885 port other than that used to perform the handshake. This 4886 parameter is a zero-length value. 4888 preferred_address (0x000d): The server's preferred address is used 4889 to effect a change in server address at the end of the handshake, 4890 as described in Section 9.6. The format of this transport 4891 parameter is the PreferredAddress struct shown in Figure 16. This 4892 transport parameter is only sent by a server. Servers MAY choose 4893 to only send a preferred address of one address family by sending 4894 an all-zero address and port (0.0.0.0:0 or ::.0) for the other 4895 family. IP addresses are encoded in network byte order. 4897 struct { 4898 opaque ipv4Address[4]; 4899 uint16 ipv4Port; 4900 opaque ipv6Address[16]; 4901 uint16 ipv6Port; 4902 opaque connectionId<0..20>; 4903 opaque statelessResetToken[16]; 4904 } PreferredAddress; 4906 Figure 16: Preferred Address format 4908 active_connection_id_limit (0x000e): The maximum number of 4909 connection IDs from the peer that an endpoint is willing to store. 4910 This value includes only connection IDs sent in NEW_CONNECTION_ID 4911 frames. If this parameter is absent, a default of 0 is assumed. 4913 If present, transport parameters that set initial flow control limits 4914 (initial_max_stream_data_bidi_local, 4915 initial_max_stream_data_bidi_remote, and initial_max_stream_data_uni) 4916 are equivalent to sending a MAX_STREAM_DATA frame (Section 19.10) on 4917 every stream of the corresponding type immediately after opening. If 4918 the transport parameter is absent, streams of that type start with a 4919 flow control limit of 0. 4921 A client MUST NOT include an original connection ID, a stateless 4922 reset token, or a preferred address. A server MUST treat receipt of 4923 any of these transport parameters as a connection error of type 4924 TRANSPORT_PARAMETER_ERROR. 4926 19. Frame Types and Formats 4928 As described in Section 12.4, packets contain one or more frames. 4929 This section describes the format and semantics of the core QUIC 4930 frame types. 4932 19.1. PADDING Frame 4934 The PADDING frame (type=0x00) has no semantic value. PADDING frames 4935 can be used to increase the size of a packet. Padding can be used to 4936 increase an initial client packet to the minimum required size, or to 4937 provide protection against traffic analysis for protected packets. 4939 A PADDING frame has no content. That is, a PADDING frame consists of 4940 the single byte that identifies the frame as a PADDING frame. 4942 19.2. PING Frame 4944 Endpoints can use PING frames (type=0x01) to verify that their peers 4945 are still alive or to check reachability to the peer. The PING frame 4946 contains no additional fields. 4948 The receiver of a PING frame simply needs to acknowledge the packet 4949 containing this frame. 4951 The PING frame can be used to keep a connection alive when an 4952 application or application protocol wishes to prevent the connection 4953 from timing out. An application protocol SHOULD provide guidance 4954 about the conditions under which generating a PING is recommended. 4955 This guidance SHOULD indicate whether it is the client or the server 4956 that is expected to send the PING. Having both endpoints send PING 4957 frames without coordination can produce an excessive number of 4958 packets and poor performance. 4960 A connection will time out if no packets are sent or received for a 4961 period longer than the time specified in the idle_timeout transport 4962 parameter (see Section 10). However, state in middleboxes might time 4963 out earlier than that. Though REQ-5 in [RFC4787] recommends a 2 4964 minute timeout interval, experience shows that sending packets every 4965 15 to 30 seconds is necessary to prevent the majority of middleboxes 4966 from losing state for UDP flows. 4968 19.3. ACK Frames 4970 Receivers send ACK frames (types 0x02 and 0x03) to inform senders of 4971 packets they have received and processed. The ACK frame contains one 4972 or more ACK Ranges. ACK Ranges identify acknowledged packets. If 4973 the frame type is 0x03, ACK frames also contain the sum of QUIC 4974 packets with associated ECN marks received on the connection up until 4975 this point. QUIC implementations MUST properly handle both types 4976 and, if they have enabled ECN for packets they send, they SHOULD use 4977 the information in the ECN section to manage their congestion state. 4979 QUIC acknowledgements are irrevocable. Once acknowledged, a packet 4980 remains acknowledged, even if it does not appear in a future ACK 4981 frame. This is unlike TCP SACKs ([RFC2018]). 4983 It is expected that a sender will reuse the same packet number across 4984 different packet number spaces. ACK frames only acknowledge the 4985 packet numbers that were transmitted by the sender in the same packet 4986 number space of the packet that the ACK was received in. 4988 Version Negotiation and Retry packets cannot be acknowledged because 4989 they do not contain a packet number. Rather than relying on ACK 4990 frames, these packets are implicitly acknowledged by the next Initial 4991 packet sent by the client. 4993 An ACK frame is as follows: 4995 0 1 2 3 4996 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 4997 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4998 | Largest Acknowledged (i) ... 4999 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5000 | ACK Delay (i) ... 5001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5002 | ACK Range Count (i) ... 5003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5004 | First ACK Range (i) ... 5005 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5006 | ACK Ranges (*) ... 5007 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5008 | [ECN Counts] ... 5009 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5011 Figure 17: ACK Frame Format 5013 ACK frames contain the following fields: 5015 Largest Acknowledged: A variable-length integer representing the 5016 largest packet number the peer is acknowledging; this is usually 5017 the largest packet number that the peer has received prior to 5018 generating the ACK frame. Unlike the packet number in the QUIC 5019 long or short header, the value in an ACK frame is not truncated. 5021 ACK Delay: A variable-length integer representing the time delta in 5022 microseconds between when this ACK was sent and when the largest 5023 acknowledged packet, as indicated in the Largest Acknowledged 5024 field, was received by this peer. The value of the ACK Delay 5025 field is scaled by multiplying the encoded value by 2 to the power 5026 of the value of the "ack_delay_exponent" transport parameter set 5027 by the sender of the ACK frame (see Section 18.2). Scaling in 5028 this fashion allows for a larger range of values with a shorter 5029 encoding at the cost of lower resolution. Because the receiver 5030 doesn't use the ACK Delay for Initial and Handshake packets, a 5031 sender SHOULD send a value of 0. 5033 ACK Range Count: A variable-length integer specifying the number of 5034 Gap and ACK Range fields in the frame. 5036 First ACK Range: A variable-length integer indicating the number of 5037 contiguous packets preceding the Largest Acknowledged that are 5038 being acknowledged. The First ACK Range is encoded as an ACK 5039 Range (see Section 19.3.1) starting from the Largest Acknowledged. 5040 That is, the smallest packet acknowledged in the range is 5041 determined by subtracting the First ACK Range value from the 5042 Largest Acknowledged. 5044 ACK Ranges: Contains additional ranges of packets which are 5045 alternately not acknowledged (Gap) and acknowledged (ACK Range); 5046 see Section 19.3.1. 5048 ECN Counts: The three ECN Counts; see Section 19.3.2. 5050 19.3.1. ACK Ranges 5052 The ACK Ranges field consists of alternating Gap and ACK Range values 5053 in descending packet number order. The number of Gap and ACK Range 5054 values is determined by the ACK Range Count field; one of each value 5055 is present for each value in the ACK Range Count field. 5057 ACK Ranges are structured as follows: 5059 0 1 2 3 5060 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 5061 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5062 | [Gap (i)] ... 5063 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5064 | [ACK Range (i)] ... 5065 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5066 | [Gap (i)] ... 5067 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5068 | [ACK Range (i)] ... 5069 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5070 ... 5071 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5072 | [Gap (i)] ... 5073 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5074 | [ACK Range (i)] ... 5075 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5077 Figure 18: ACK Ranges 5079 The fields that form the ACK Ranges are: 5081 Gap (repeated): A variable-length integer indicating the number of 5082 contiguous unacknowledged packets preceding the packet number one 5083 lower than the smallest in the preceding ACK Range. 5085 ACK Range (repeated): A variable-length integer indicating the 5086 number of contiguous acknowledged packets preceding the largest 5087 packet number, as determined by the preceding Gap. 5089 Gap and ACK Range value use a relative integer encoding for 5090 efficiency. Though each encoded value is positive, the values are 5091 subtracted, so that each ACK Range describes progressively lower- 5092 numbered packets. 5094 Each ACK Range acknowledges a contiguous range of packets by 5095 indicating the number of acknowledged packets that precede the 5096 largest packet number in that range. A value of zero indicates that 5097 only the largest packet number is acknowledged. Larger ACK Range 5098 values indicate a larger range, with corresponding lower values for 5099 the smallest packet number in the range. Thus, given a largest 5100 packet number for the range, the smallest value is determined by the 5101 formula: 5103 smallest = largest - ack_range 5105 An ACK Range acknowledges all packets between the smallest packet 5106 number and the largest, inclusive. 5108 The largest value for an ACK Range is determined by cumulatively 5109 subtracting the size of all preceding ACK Ranges and Gaps. 5111 Each Gap indicates a range of packets that are not being 5112 acknowledged. The number of packets in the gap is one higher than 5113 the encoded value of the Gap field. 5115 The value of the Gap field establishes the largest packet number 5116 value for the subsequent ACK Range using the following formula: 5118 largest = previous_smallest - gap - 2 5120 If any computed packet number is negative, an endpoint MUST generate 5121 a connection error of type FRAME_ENCODING_ERROR indicating an error 5122 in an ACK frame. 5124 19.3.2. ECN Counts 5126 The ACK frame uses the least significant bit (that is, type 0x03) to 5127 indicate ECN feedback and report receipt of QUIC packets with 5128 associated ECN codepoints of ECT(0), ECT(1), or CE in the packet's IP 5129 header. ECN Counts are only present when the ACK frame type is 0x03. 5131 ECN Counts are only parsed when the ACK frame type is 0x03. There 5132 are 3 ECN counts, as follows: 5134 0 1 2 3 5135 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 5136 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5137 | ECT(0) Count (i) ... 5138 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5139 | ECT(1) Count (i) ... 5140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5141 | ECN-CE Count (i) ... 5142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5144 The three ECN Counts are: 5146 ECT(0) Count: A variable-length integer representing the total 5147 number of packets received with the ECT(0) codepoint in the packet 5148 number space of the ACK frame. 5150 ECT(1) Count: A variable-length integer representing the total 5151 number of packets received with the ECT(1) codepoint in the packet 5152 number space of the ACK frame. 5154 CE Count: A variable-length integer representing the total number of 5155 packets received with the CE codepoint in the packet number space 5156 of the ACK frame. 5158 ECN counts are maintained separately for each packet number space. 5160 19.4. RESET_STREAM Frame 5162 An endpoint uses a RESET_STREAM frame (type=0x04) to abruptly 5163 terminate the sending part of a stream. 5165 After sending a RESET_STREAM, an endpoint ceases transmission and 5166 retransmission of STREAM frames on the identified stream. A receiver 5167 of RESET_STREAM can discard any data that it already received on that 5168 stream. 5170 An endpoint that receives a RESET_STREAM frame for a send-only stream 5171 MUST terminate the connection with error STREAM_STATE_ERROR. 5173 The RESET_STREAM frame is as follows: 5175 0 1 2 3 5176 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 5177 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5178 | Stream ID (i) ... 5179 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5180 | Application Error Code (i) ... 5181 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5182 | Final Size (i) ... 5183 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5185 RESET_STREAM frames contain the following fields: 5187 Stream ID: A variable-length integer encoding of the Stream ID of 5188 the stream being terminated. 5190 Application Protocol Error Code: A variable-length integer 5191 containing the application protocol error code (see Section 20.1) 5192 which indicates why the stream is being closed. 5194 Final Size: A variable-length integer indicating the final size of 5195 the stream by the RESET_STREAM sender, in unit of bytes. 5197 19.5. STOP_SENDING Frame 5199 An endpoint uses a STOP_SENDING frame (type=0x05) to communicate that 5200 incoming data is being discarded on receipt at application request. 5201 STOP_SENDING requests that a peer cease transmission on a stream. 5203 A STOP_SENDING frame can be sent for streams in the Recv or Size 5204 Known states (see Section 3.1). Receiving a STOP_SENDING frame for a 5205 locally-initiated stream that has not yet been created MUST be 5206 treated as a connection error of type STREAM_STATE_ERROR. An 5207 endpoint that receives a STOP_SENDING frame for a receive-only stream 5208 MUST terminate the connection with error STREAM_STATE_ERROR. 5210 The STOP_SENDING frame is as follows: 5212 0 1 2 3 5213 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 5214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5215 | Stream ID (i) ... 5216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5217 | Application Error Code (i) ... 5218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5220 STOP_SENDING frames contain the following fields: 5222 Stream ID: A variable-length integer carrying the Stream ID of the 5223 stream being ignored. 5225 Application Error Code: A variable-length integer containing the 5226 application-specified reason the sender is ignoring the stream 5227 (see Section 20.1). 5229 19.6. CRYPTO Frame 5231 The CRYPTO frame (type=0x06) is used to transmit cryptographic 5232 handshake messages. It can be sent in all packet types except 0-RTT. 5233 The CRYPTO frame offers the cryptographic protocol an in-order stream 5234 of bytes. CRYPTO frames are functionally identical to STREAM frames, 5235 except that they do not bear a stream identifier; they are not flow 5236 controlled; and they do not carry markers for optional offset, 5237 optional length, and the end of the stream. 5239 The CRYPTO frame is as follows: 5241 0 1 2 3 5242 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 5243 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5244 | Offset (i) ... 5245 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5246 | Length (i) ... 5247 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5248 | Crypto Data (*) ... 5249 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5251 Figure 19: CRYPTO Frame Format 5253 CRYPTO frames contain the following fields: 5255 Offset: A variable-length integer specifying the byte offset in the 5256 stream for the data in this CRYPTO frame. 5258 Length: A variable-length integer specifying the length of the 5259 Crypto Data field in this CRYPTO frame. 5261 Crypto Data: The cryptographic message data. 5263 There is a separate flow of cryptographic handshake data in each 5264 encryption level, each of which starts at an offset of 0. This 5265 implies that each encryption level is treated as a separate CRYPTO 5266 stream of data. 5268 Unlike STREAM frames, which include a Stream ID indicating to which 5269 stream the data belongs, the CRYPTO frame carries data for a single 5270 stream per encryption level. The stream does not have an explicit 5271 end, so CRYPTO frames do not have a FIN bit. 5273 19.7. NEW_TOKEN Frame 5275 A server sends a NEW_TOKEN frame (type=0x07) to provide the client 5276 with a token to send in the header of an Initial packet for a future 5277 connection. 5279 The NEW_TOKEN frame is as follows: 5281 0 1 2 3 5282 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 5283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5284 | Token Length (i) ... 5285 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5286 | Token (*) ... 5287 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5288 NEW_TOKEN frames contain the following fields: 5290 Token Length: A variable-length integer specifying the length of the 5291 token in bytes. 5293 Token: An opaque blob that the client may use with a future Initial 5294 packet. 5296 An endpoint might receive multiple NEW_TOKEN frames that contain the 5297 same token value. Endpoints are responsible for discarding duplicate 5298 values, which might be used to link connection attempts; see 5299 Section 8.1.2. 5301 Clients MUST NOT send NEW_TOKEN frames. Servers MUST treat receipt 5302 of a NEW_TOKEN frame as a connection error of type 5303 PROTOCOL_VIOLATION. 5305 19.8. STREAM Frames 5307 STREAM frames implicitly create a stream and carry stream data. The 5308 STREAM frame takes the form 0b00001XXX (or the set of values from 5309 0x08 to 0x0f). The value of the three low-order bits of the frame 5310 type determines the fields that are present in the frame. 5312 o The OFF bit (0x04) in the frame type is set to indicate that there 5313 is an Offset field present. When set to 1, the Offset field is 5314 present. When set to 0, the Offset field is absent and the Stream 5315 Data starts at an offset of 0 (that is, the frame contains the 5316 first bytes of the stream, or the end of a stream that includes no 5317 data). 5319 o The LEN bit (0x02) in the frame type is set to indicate that there 5320 is a Length field present. If this bit is set to 0, the Length 5321 field is absent and the Stream Data field extends to the end of 5322 the packet. If this bit is set to 1, the Length field is present. 5324 o The FIN bit (0x01) of the frame type is set only on frames that 5325 contain the final size of the stream. Setting this bit indicates 5326 that the frame marks the end of the stream. 5328 An endpoint that receives a STREAM frame for a send-only stream MUST 5329 terminate the connection with error STREAM_STATE_ERROR. 5331 The STREAM frames are as follows: 5333 0 1 2 3 5334 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 5335 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5336 | Stream ID (i) ... 5337 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5338 | [Offset (i)] ... 5339 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5340 | [Length (i)] ... 5341 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5342 | Stream Data (*) ... 5343 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5345 Figure 20: STREAM Frame Format 5347 STREAM frames contain the following fields: 5349 Stream ID: A variable-length integer indicating the stream ID of the 5350 stream (see Section 2.1). 5352 Offset: A variable-length integer specifying the byte offset in the 5353 stream for the data in this STREAM frame. This field is present 5354 when the OFF bit is set to 1. When the Offset field is absent, 5355 the offset is 0. 5357 Length: A variable-length integer specifying the length of the 5358 Stream Data field in this STREAM frame. This field is present 5359 when the LEN bit is set to 1. When the LEN bit is set to 0, the 5360 Stream Data field consumes all the remaining bytes in the packet. 5362 Stream Data: The bytes from the designated stream to be delivered. 5364 When a Stream Data field has a length of 0, the offset in the STREAM 5365 frame is the offset of the next byte that would be sent. 5367 The first byte in the stream has an offset of 0. The largest offset 5368 delivered on a stream - the sum of the offset and data length - 5369 cannot exceed 2^62-1, as it is not possible to provide flow control 5370 credit for that data. Receipt of a frame that exceeds this limit 5371 will be treated as a connection error of type FLOW_CONTROL_ERROR. 5373 19.9. MAX_DATA Frame 5375 The MAX_DATA frame (type=0x10) is used in flow control to inform the 5376 peer of the maximum amount of data that can be sent on the connection 5377 as a whole. 5379 The MAX_DATA frame is as follows: 5381 0 1 2 3 5382 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 5383 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5384 | Maximum Data (i) ... 5385 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5387 MAX_DATA frames contain the following fields: 5389 Maximum Data: A variable-length integer indicating the maximum 5390 amount of data that can be sent on the entire connection, in units 5391 of bytes. 5393 All data sent in STREAM frames counts toward this limit. The sum of 5394 the largest received offsets on all streams - including streams in 5395 terminal states - MUST NOT exceed the value advertised by a receiver. 5396 An endpoint MUST terminate a connection with a FLOW_CONTROL_ERROR 5397 error if it receives more data than the maximum data value that it 5398 has sent, unless this is a result of a change in the initial limits 5399 (see Section 7.3.1). 5401 19.10. MAX_STREAM_DATA Frame 5403 The MAX_STREAM_DATA frame (type=0x11) is used in flow control to 5404 inform a peer of the maximum amount of data that can be sent on a 5405 stream. 5407 A MAX_STREAM_DATA frame can be sent for streams in the Recv state 5408 (see Section 3.1). Receiving a MAX_STREAM_DATA frame for a locally- 5409 initiated stream that has not yet been created MUST be treated as a 5410 connection error of type STREAM_STATE_ERROR. An endpoint that 5411 receives a MAX_STREAM_DATA frame for a receive-only stream MUST 5412 terminate the connection with error STREAM_STATE_ERROR. 5414 The MAX_STREAM_DATA frame is as follows: 5416 0 1 2 3 5417 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 5418 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5419 | Stream ID (i) ... 5420 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5421 | Maximum Stream Data (i) ... 5422 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5424 MAX_STREAM_DATA frames contain the following fields: 5426 Stream ID: The stream ID of the stream that is affected encoded as a 5427 variable-length integer. 5429 Maximum Stream Data: A variable-length integer indicating the 5430 maximum amount of data that can be sent on the identified stream, 5431 in units of bytes. 5433 When counting data toward this limit, an endpoint accounts for the 5434 largest received offset of data that is sent or received on the 5435 stream. Loss or reordering can mean that the largest received offset 5436 on a stream can be greater than the total size of data received on 5437 that stream. Receiving STREAM frames might not increase the largest 5438 received offset. 5440 The data sent on a stream MUST NOT exceed the largest maximum stream 5441 data value advertised by the receiver. An endpoint MUST terminate a 5442 connection with a FLOW_CONTROL_ERROR error if it receives more data 5443 than the largest maximum stream data that it has sent for the 5444 affected stream, unless this is a result of a change in the initial 5445 limits (see Section 7.3.1). 5447 19.11. MAX_STREAMS Frames 5449 The MAX_STREAMS frames (type=0x12 and 0x13) inform the peer of the 5450 cumulative number of streams of a given type it is permitted to open. 5451 A MAX_STREAMS frame with a type of 0x12 applies to bidirectional 5452 streams, and a MAX_STREAMS frame with a type of 0x13 applies to 5453 unidirectional streams. 5455 The MAX_STREAMS frames are as follows: 5457 0 1 2 3 5458 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 5459 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5460 | Maximum Streams (i) ... 5461 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5463 MAX_STREAMS frames contain the following fields: 5465 Maximum Streams: A count of the cumulative number of streams of the 5466 corresponding type that can be opened over the lifetime of the 5467 connection. 5469 Loss or reordering can cause a MAX_STREAMS frame to be received which 5470 states a lower stream limit than an endpoint has previously received. 5471 MAX_STREAMS frames which do not increase the stream limit MUST be 5472 ignored. 5474 An endpoint MUST NOT open more streams than permitted by the current 5475 stream limit set by its peer. For instance, a server that receives a 5476 unidirectional stream limit of 3 is permitted to open stream 3, 7, 5477 and 11, but not stream 15. An endpoint MUST terminate a connection 5478 with a STREAM_LIMIT_ERROR error if a peer opens more streams than was 5479 permitted. 5481 Note that these frames (and the corresponding transport parameters) 5482 do not describe the number of streams that can be opened 5483 concurrently. The limit includes streams that have been closed as 5484 well as those that are open. 5486 19.12. DATA_BLOCKED Frame 5488 A sender SHOULD send a DATA_BLOCKED frame (type=0x14) when it wishes 5489 to send data, but is unable to due to connection-level flow control 5490 (see Section 4). DATA_BLOCKED frames can be used as input to tuning 5491 of flow control algorithms (see Section 4.2). 5493 The DATA_BLOCKED frame is as follows: 5495 0 1 2 3 5496 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 5497 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5498 | Data Limit (i) ... 5499 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5501 DATA_BLOCKED frames contain the following fields: 5503 Data Limit: A variable-length integer indicating the connection- 5504 level limit at which blocking occurred. 5506 19.13. STREAM_DATA_BLOCKED Frame 5508 A sender SHOULD send a STREAM_DATA_BLOCKED frame (type=0x15) when it 5509 wishes to send data, but is unable to due to stream-level flow 5510 control. This frame is analogous to DATA_BLOCKED (Section 19.12). 5512 An endpoint that receives a STREAM_DATA_BLOCKED frame for a send-only 5513 stream MUST terminate the connection with error STREAM_STATE_ERROR. 5515 The STREAM_DATA_BLOCKED frame is as follows: 5517 0 1 2 3 5518 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 5519 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5520 | Stream ID (i) ... 5521 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5522 | Stream Data Limit (i) ... 5523 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5524 STREAM_DATA_BLOCKED frames contain the following fields: 5526 Stream ID: A variable-length integer indicating the stream which is 5527 flow control blocked. 5529 Stream Data Limit: A variable-length integer indicating the offset 5530 of the stream at which the blocking occurred. 5532 19.14. STREAMS_BLOCKED Frames 5534 A sender SHOULD send a STREAMS_BLOCKED frame (type=0x16 or 0x17) when 5535 it wishes to open a stream, but is unable to due to the maximum 5536 stream limit set by its peer (see Section 19.11). A STREAMS_BLOCKED 5537 frame of type 0x16 is used to indicate reaching the bidirectional 5538 stream limit, and a STREAMS_BLOCKED frame of type 0x17 indicates 5539 reaching the unidirectional stream limit. 5541 A STREAMS_BLOCKED frame does not open the stream, but informs the 5542 peer that a new stream was needed and the stream limit prevented the 5543 creation of the stream. 5545 The STREAMS_BLOCKED frames are as follows: 5547 0 1 2 3 5548 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 5549 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5550 | Stream Limit (i) ... 5551 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5553 STREAMS_BLOCKED frames contain the following fields: 5555 Stream Limit: A variable-length integer indicating the stream limit 5556 at the time the frame was sent. 5558 19.15. NEW_CONNECTION_ID Frame 5560 An endpoint sends a NEW_CONNECTION_ID frame (type=0x18) to provide 5561 its peer with alternative connection IDs that can be used to break 5562 linkability when migrating connections (see Section 9.5). 5564 The NEW_CONNECTION_ID frame is as follows: 5566 0 1 2 3 5567 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 5568 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5569 | Sequence Number (i) ... 5570 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5571 | Retire Prior To (i) ... 5572 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5573 | Length (8) | | 5574 +-+-+-+-+-+-+-+-+ Connection ID (8..160) + 5575 | ... 5576 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5577 | | 5578 + + 5579 | | 5580 + Stateless Reset Token (128) + 5581 | | 5582 + + 5583 | | 5584 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5586 NEW_CONNECTION_ID frames contain the following fields: 5588 Sequence Number: The sequence number assigned to the connection ID 5589 by the sender. See Section 5.1.1. 5591 Retire Prior To: A variable-length integer indicating which 5592 connection IDs should be retired. See Section 5.1.2. 5594 Length: An 8-bit unsigned integer containing the length of the 5595 connection ID. Values less than 1 and greater than 20 are invalid 5596 and MUST be treated as a connection error of type 5597 PROTOCOL_VIOLATION. 5599 Connection ID: A connection ID of the specified length. 5601 Stateless Reset Token: A 128-bit value that will be used for a 5602 stateless reset when the associated connection ID is used (see 5603 Section 10.4). 5605 An endpoint MUST NOT send this frame if it currently requires that 5606 its peer send packets with a zero-length Destination Connection ID. 5607 Changing the length of a connection ID to or from zero-length makes 5608 it difficult to identify when the value of the connection ID changed. 5609 An endpoint that is sending packets with a zero-length Destination 5610 Connection ID MUST treat receipt of a NEW_CONNECTION_ID frame as a 5611 connection error of type PROTOCOL_VIOLATION. 5613 Transmission errors, timeouts and retransmissions might cause the 5614 same NEW_CONNECTION_ID frame to be received multiple times. Receipt 5615 of the same frame multiple times MUST NOT be treated as a connection 5616 error. A receiver can use the sequence number supplied in the 5617 NEW_CONNECTION_ID frame to identify new connection IDs from old ones. 5619 If an endpoint receives a NEW_CONNECTION_ID frame that repeats a 5620 previously issued connection ID with a different Stateless Reset 5621 Token or a different sequence number, or if a sequence number is used 5622 for different connection IDs, the endpoint MAY treat that receipt as 5623 a connection error of type PROTOCOL_VIOLATION. 5625 The Retire Prior To field is a request for the peer to retire all 5626 connection IDs with a sequence number less than the specified value. 5627 This includes the initial and preferred_address transport parameter 5628 connection IDs. The peer SHOULD retire the corresponding connection 5629 IDs and send the corresponding RETIRE_CONNECTION_ID frames in a 5630 timely manner. 5632 The Retire Prior To field MUST be less than or equal to the Sequence 5633 Number field. Receiving a value greater than the Sequence Number 5634 MUST be treated as a connection error of type PROTOCOL_VIOLATION. 5636 Once a sender indicates a Retire Prior To value, smaller values sent 5637 in subsequent NEW_CONNECTION_ID frames have no effect. A receiver 5638 MUST ignore any Retire Prior To fields that do not increase the 5639 largest received Retire Prior To value. 5641 19.16. RETIRE_CONNECTION_ID Frame 5643 An endpoint sends a RETIRE_CONNECTION_ID frame (type=0x19) to 5644 indicate that it will no longer use a connection ID that was issued 5645 by its peer. This may include the connection ID provided during the 5646 handshake. Sending a RETIRE_CONNECTION_ID frame also serves as a 5647 request to the peer to send additional connection IDs for future use 5648 (see Section 5.1). New connection IDs can be delivered to a peer 5649 using the NEW_CONNECTION_ID frame (Section 19.15). 5651 Retiring a connection ID invalidates the stateless reset token 5652 associated with that connection ID. 5654 The RETIRE_CONNECTION_ID frame is as follows: 5656 0 1 2 3 5657 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 5658 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5659 | Sequence Number (i) ... 5660 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5661 RETIRE_CONNECTION_ID frames contain the following fields: 5663 Sequence Number: The sequence number of the connection ID being 5664 retired. See Section 5.1.2. 5666 Receipt of a RETIRE_CONNECTION_ID frame containing a sequence number 5667 greater than any previously sent to the peer MAY be treated as a 5668 connection error of type PROTOCOL_VIOLATION. 5670 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST 5671 NOT refer to the Destination Connection ID field of the packet in 5672 which the frame is contained. The peer MAY treat this as a 5673 connection error of type PROTOCOL_VIOLATION. 5675 An endpoint cannot send this frame if it was provided with a zero- 5676 length connection ID by its peer. An endpoint that provides a zero- 5677 length connection ID MUST treat receipt of a RETIRE_CONNECTION_ID 5678 frame as a connection error of type PROTOCOL_VIOLATION. 5680 19.17. PATH_CHALLENGE Frame 5682 Endpoints can use PATH_CHALLENGE frames (type=0x1a) to check 5683 reachability to the peer and for path validation during connection 5684 migration. 5686 The PATH_CHALLENGE frames are as follows: 5688 0 1 2 3 5689 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 5690 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5691 | | 5692 + Data (64) + 5693 | | 5694 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5696 PATH_CHALLENGE frames contain the following fields: 5698 Data: This 8-byte field contains arbitrary data. 5700 A PATH_CHALLENGE frame containing 8 bytes that are hard to guess is 5701 sufficient to ensure that it is easier to receive the packet than it 5702 is to guess the value correctly. 5704 The recipient of this frame MUST generate a PATH_RESPONSE frame 5705 (Section 19.18) containing the same Data. 5707 19.18. PATH_RESPONSE Frame 5709 The PATH_RESPONSE frame (type=0x1b) is sent in response to a 5710 PATH_CHALLENGE frame. Its format is identical to the PATH_CHALLENGE 5711 frame (Section 19.17). 5713 If the content of a PATH_RESPONSE frame does not match the content of 5714 a PATH_CHALLENGE frame previously sent by the endpoint, the endpoint 5715 MAY generate a connection error of type PROTOCOL_VIOLATION. 5717 19.19. CONNECTION_CLOSE Frames 5719 An endpoint sends a CONNECTION_CLOSE frame (type=0x1c or 0x1d) to 5720 notify its peer that the connection is being closed. The 5721 CONNECTION_CLOSE with a frame type of 0x1c is used to signal errors 5722 at only the QUIC layer, or the absence of errors (with the NO_ERROR 5723 code). The CONNECTION_CLOSE frame with a type of 0x1d is used to 5724 signal an error with the application that uses QUIC. 5726 If there are open streams that haven't been explicitly closed, they 5727 are implicitly closed when the connection is closed. 5729 The CONNECTION_CLOSE frames are as follows: 5731 0 1 2 3 5732 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 5733 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5734 | Error Code (i) ... 5735 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5736 | [ Frame Type (i) ] ... 5737 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5738 | Reason Phrase Length (i) ... 5739 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5740 | Reason Phrase (*) ... 5741 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5743 CONNECTION_CLOSE frames contain the following fields: 5745 Error Code: A variable length integer error code which indicates the 5746 reason for closing this connection. A CONNECTION_CLOSE frame of 5747 type 0x1c uses codes from the space defined in Section 20. A 5748 CONNECTION_CLOSE frame of type 0x1d uses codes from the 5749 application protocol error code space; see Section 20.1 5751 Frame Type: A variable-length integer encoding the type of frame 5752 that triggered the error. A value of 0 (equivalent to the mention 5753 of the PADDING frame) is used when the frame type is unknown. The 5754 application-specific variant of CONNECTION_CLOSE (type 0x1d) does 5755 not include this field. 5757 Reason Phrase Length: A variable-length integer specifying the 5758 length of the reason phrase in bytes. Because a CONNECTION_CLOSE 5759 frame cannot be split between packets, any limits on packet size 5760 will also limit the space available for a reason phrase. 5762 Reason Phrase: A human-readable explanation for why the connection 5763 was closed. This can be zero length if the sender chooses to not 5764 give details beyond the Error Code. This SHOULD be a UTF-8 5765 encoded string [RFC3629]. 5767 19.20. Extension Frames 5769 QUIC frames do not use a self-describing encoding. An endpoint 5770 therefore needs to understand the syntax of all frames before it can 5771 successfully process a packet. This allows for efficient encoding of 5772 frames, but it means that an endpoint cannot send a frame of a type 5773 that is unknown to its peer. 5775 An extension to QUIC that wishes to use a new type of frame MUST 5776 first ensure that a peer is able to understand the frame. An 5777 endpoint can use a transport parameter to signal its willingness to 5778 receive one or more extension frame types with the one transport 5779 parameter. 5781 Extension frames MUST be congestion controlled and MUST cause an ACK 5782 frame to be sent. The exception is extension frames that replace or 5783 supplement the ACK frame. Extension frames are not included in flow 5784 control unless specified in the extension. 5786 An IANA registry is used to manage the assignment of frame types; see 5787 Section 22.2. 5789 20. Transport Error Codes 5791 QUIC error codes are 62-bit unsigned integers. 5793 This section lists the defined QUIC transport error codes that may be 5794 used in a CONNECTION_CLOSE frame. These errors apply to the entire 5795 connection. 5797 NO_ERROR (0x0): An endpoint uses this with CONNECTION_CLOSE to 5798 signal that the connection is being closed abruptly in the absence 5799 of any error. 5801 INTERNAL_ERROR (0x1): The endpoint encountered an internal error and 5802 cannot continue with the connection. 5804 SERVER_BUSY (0x2): The server is currently busy and does not accept 5805 any new connections. 5807 FLOW_CONTROL_ERROR (0x3): An endpoint received more data than it 5808 permitted in its advertised data limits (see Section 4). 5810 STREAM_LIMIT_ERROR (0x4): An endpoint received a frame for a stream 5811 identifier that exceeded its advertised stream limit for the 5812 corresponding stream type. 5814 STREAM_STATE_ERROR (0x5): An endpoint received a frame for a stream 5815 that was not in a state that permitted that frame (see Section 3). 5817 FINAL_SIZE_ERROR (0x6): An endpoint received a STREAM frame 5818 containing data that exceeded the previously established final 5819 size. Or an endpoint received a STREAM frame or a RESET_STREAM 5820 frame containing a final size that was lower than the size of 5821 stream data that was already received. Or an endpoint received a 5822 STREAM frame or a RESET_STREAM frame containing a different final 5823 size to the one already established. 5825 FRAME_ENCODING_ERROR (0x7): An endpoint received a frame that was 5826 badly formatted. For instance, a frame of an unknown type, or an 5827 ACK frame that has more acknowledgment ranges than the remainder 5828 of the packet could carry. 5830 TRANSPORT_PARAMETER_ERROR (0x8): An endpoint received transport 5831 parameters that were badly formatted, included an invalid value, 5832 was absent even though it is mandatory, was present though it is 5833 forbidden, or is otherwise in error. 5835 PROTOCOL_VIOLATION (0xA): An endpoint detected an error with 5836 protocol compliance that was not covered by more specific error 5837 codes. 5839 CRYPTO_BUFFER_EXCEEDED (0xD): An endpoint has received more data in 5840 CRYPTO frames than it can buffer. 5842 CRYPTO_ERROR (0x1XX): The cryptographic handshake failed. A range 5843 of 256 values is reserved for carrying error codes specific to the 5844 cryptographic handshake that is used. Codes for errors occurring 5845 when TLS is used for the crypto handshake are described in 5846 Section 4.8 of [QUIC-TLS]. 5848 See Section 22.3 for details of registering new error codes. 5850 In defining these error codes, several principles are applied. Error 5851 conditions that might require specific action on the part of a 5852 recipient are given unique codes. Errors that represent common 5853 conditions are given specific codes. Absent either of these 5854 conditions, error codes are used to identify a general function of 5855 the stack, like flow control or transport parameter handling. 5856 Finally, generic errors are provided for conditions where 5857 implementations are unable or unwilling to use more specific codes. 5859 20.1. Application Protocol Error Codes 5861 Application protocol error codes are 62-bit unsigned integers, but 5862 the management of application error codes is left to application 5863 protocols. Application protocol error codes are used for the 5864 RESET_STREAM frame (Section 19.4), the STOP_SENDING frame 5865 (Section 19.5), and the CONNECTION_CLOSE frame with a type of 0x1d 5866 (Section 19.19). 5868 21. Security Considerations 5870 21.1. Handshake Denial of Service 5872 As an encrypted and authenticated transport QUIC provides a range of 5873 protections against denial of service. Once the cryptographic 5874 handshake is complete, QUIC endpoints discard most packets that are 5875 not authenticated, greatly limiting the ability of an attacker to 5876 interfere with existing connections. 5878 Once a connection is established QUIC endpoints might accept some 5879 unauthenticated ICMP packets (see Section 14.2), but the use of these 5880 packets is extremely limited. The only other type of packet that an 5881 endpoint might accept is a stateless reset (Section 10.4) which 5882 relies on the token being kept secret until it is used. 5884 During the creation of a connection, QUIC only provides protection 5885 against attack from off the network path. All QUIC packets contain 5886 proof that the recipient saw a preceding packet from its peer. 5888 The first mechanism used is the source and destination connection 5889 IDs, which are required to match those set by a peer. Except for an 5890 Initial and stateless reset packets, an endpoint only accepts packets 5891 that include a destination connection that matches a connection ID 5892 the endpoint previously chose. This is the only protection offered 5893 for Version Negotiation packets. 5895 The destination connection ID in an Initial packet is selected by a 5896 client to be unpredictable, which serves an additional purpose. The 5897 packets that carry the cryptographic handshake are protected with a 5898 key that is derived from this connection ID and salt specific to the 5899 QUIC version. This allows endpoints to use the same process for 5900 authenticating packets that they receive as they use after the 5901 cryptographic handshake completes. Packets that cannot be 5902 authenticated are discarded. Protecting packets in this fashion 5903 provides a strong assurance that the sender of the packet saw the 5904 Initial packet and understood it. 5906 These protections are not intended to be effective against an 5907 attacker that is able to receive QUIC packets prior to the connection 5908 being established. Such an attacker can potentially send packets 5909 that will be accepted by QUIC endpoints. This version of QUIC 5910 attempts to detect this sort of attack, but it expects that endpoints 5911 will fail to establish a connection rather than recovering. For the 5912 most part, the cryptographic handshake protocol [QUIC-TLS] is 5913 responsible for detecting tampering during the handshake. 5915 Endpoints are permitted to use other methods to detect and attempt to 5916 recover from interference with the handshake. Invalid packets may be 5917 identified and discarded using other methods, but no specific method 5918 is mandated in this document. 5920 21.2. Amplification Attack 5922 An attacker might be able to receive an address validation token 5923 (Section 8) from a server and then release the IP address it used to 5924 acquire that token. At a later time, the attacker may initiate a 5925 0-RTT connection with a server by spoofing this same address, which 5926 might now address a different (victim) endpoint. The attacker can 5927 thus potentially cause the server to send an initial congestion 5928 window's worth of data towards the victim. 5930 Servers SHOULD provide mitigations for this attack by limiting the 5931 usage and lifetime of address validation tokens (see Section 8.1.2). 5933 21.3. Optimistic ACK Attack 5935 An endpoint that acknowledges packets it has not received might cause 5936 a congestion controller to permit sending at rates beyond what the 5937 network supports. An endpoint MAY skip packet numbers when sending 5938 packets to detect this behavior. An endpoint can then immediately 5939 close the connection with a connection error of type 5940 PROTOCOL_VIOLATION (see Section 10.3). 5942 21.4. Slowloris Attacks 5944 The attacks commonly known as Slowloris [SLOWLORIS] try to keep many 5945 connections to the target endpoint open and hold them open as long as 5946 possible. These attacks can be executed against a QUIC endpoint by 5947 generating the minimum amount of activity necessary to avoid being 5948 closed for inactivity. This might involve sending small amounts of 5949 data, gradually opening flow control windows in order to control the 5950 sender rate, or manufacturing ACK frames that simulate a high loss 5951 rate. 5953 QUIC deployments SHOULD provide mitigations for the Slowloris 5954 attacks, such as increasing the maximum number of clients the server 5955 will allow, limiting the number of connections a single IP address is 5956 allowed to make, imposing restrictions on the minimum transfer speed 5957 a connection is allowed to have, and restricting the length of time 5958 an endpoint is allowed to stay connected. 5960 21.5. Stream Fragmentation and Reassembly Attacks 5962 An adversarial sender might intentionally send fragments of stream 5963 data in order to cause disproportionate receive buffer memory 5964 commitment and/or creation of a large and inefficient data structure. 5966 An adversarial receiver might intentionally not acknowledge packets 5967 containing stream data in order to force the sender to store the 5968 unacknowledged stream data for retransmission. 5970 The attack on receivers is mitigated if flow control windows 5971 correspond to available memory. However, some receivers will over- 5972 commit memory and advertise flow control offsets in the aggregate 5973 that exceed actual available memory. The over-commitment strategy 5974 can lead to better performance when endpoints are well behaved, but 5975 renders endpoints vulnerable to the stream fragmentation attack. 5977 QUIC deployments SHOULD provide mitigations against stream 5978 fragmentation attacks. Mitigations could consist of avoiding over- 5979 committing memory, limiting the size of tracking data structures, 5980 delaying reassembly of STREAM frames, implementing heuristics based 5981 on the age and duration of reassembly holes, or some combination. 5983 21.6. Stream Commitment Attack 5985 An adversarial endpoint can open lots of streams, exhausting state on 5986 an endpoint. The adversarial endpoint could repeat the process on a 5987 large number of connections, in a manner similar to SYN flooding 5988 attacks in TCP. 5990 Normally, clients will open streams sequentially, as explained in 5991 Section 2.1. However, when several streams are initiated at short 5992 intervals, loss or reordering may cause STREAM frames that open 5993 streams to be received out of sequence. On receiving a higher- 5994 numbered stream ID, a receiver is required to open all intervening 5995 streams of the same type (see Section 3.2). Thus, on a new 5996 connection, opening stream 4000000 opens 1 million and 1 client- 5997 initiated bidirectional streams. 5999 The number of active streams is limited by the 6000 initial_max_streams_bidi and initial_max_streams_uni transport 6001 parameters, as explained in Section 4.5. If chosen judiciously, 6002 these limits mitigate the effect of the stream commitment attack. 6003 However, setting the limit too low could affect performance when 6004 applications expect to open large number of streams. 6006 21.7. Peer Denial of Service 6008 QUIC and TLS both contain messages that have legitimate uses in some 6009 contexts, but that can be abused to cause a peer to expend processing 6010 resources without having any observable impact on the state of the 6011 connection. 6013 Messages can also be used to change and revert state in small or 6014 inconsequential ways, such as by sending small increments to flow 6015 control limits. 6017 If processing costs are disproportionately large in comparison to 6018 bandwidth consumption or effect on state, then this could allow a 6019 malicious peer to exhaust processing capacity. 6021 While there are legitimate uses for all messages, implementations 6022 SHOULD track cost of processing relative to progress and treat 6023 excessive quantities of any non-productive packets as indicative of 6024 an attack. Endpoints MAY respond to this condition with a connection 6025 error, or by dropping packets. 6027 21.8. Explicit Congestion Notification Attacks 6029 An on-path attacker could manipulate the value of ECN codepoints in 6030 the IP header to influence the sender's rate. [RFC3168] discusses 6031 manipulations and their effects in more detail. 6033 An on-the-side attacker can duplicate and send packets with modified 6034 ECN codepoints to affect the sender's rate. If duplicate packets are 6035 discarded by a receiver, an off-path attacker will need to race the 6036 duplicate packet against the original to be successful in this 6037 attack. Therefore, QUIC endpoints ignore the ECN codepoint field on 6038 an IP packet unless at least one QUIC packet in that IP packet is 6039 successfully processed; see Section 13.4. 6041 21.9. Stateless Reset Oracle 6043 Stateless resets create a possible denial of service attack analogous 6044 to a TCP reset injection. This attack is possible if an attacker is 6045 able to cause a stateless reset token to be generated for a 6046 connection with a selected connection ID. An attacker that can cause 6047 this token to be generated can reset an active connection with the 6048 same connection ID. 6050 If a packet can be routed to different instances that share a static 6051 key, for example by changing an IP address or port, then an attacker 6052 can cause the server to send a stateless reset. To defend against 6053 this style of denial service, endpoints that share a static key for 6054 stateless reset (see Section 10.4.2) MUST be arranged so that packets 6055 with a given connection ID always arrive at an instance that has 6056 connection state, unless that connection is no longer active. 6058 In the case of a cluster that uses dynamic load balancing, it's 6059 possible that a change in load balancer configuration could happen 6060 while an active instance retains connection state; even if an 6061 instance retains connection state, the change in routing and 6062 resulting stateless reset will result in the connection being 6063 terminated. If there is no chance in the packet being routed to the 6064 correct instance, it is better to send a stateless reset than wait 6065 for connections to time out. However, this is acceptable only if the 6066 routing cannot be influenced by an attacker. 6068 21.10. Version Downgrade 6070 This document defines QUIC Version Negotiation packets Section 6, 6071 which can be used to negotiate the QUIC version used between two 6072 endpoints. However, this document does not specify how this 6073 negotiation will be performed between this version and subsequent 6074 future versions. In particular, Version Negotiation packets do not 6075 contain any mechanism to prevent version downgrade attacks. Future 6076 versions of QUIC that use Version Negotiation packets MUST define a 6077 mechanism that is robust against version downgrade attacks. 6079 21.11. Targeted Attacks by Routing 6081 Deployments should limit the ability of an attacker to target a new 6082 connection to a particular server instance. This means that client- 6083 controlled fields, such as the initial Destination Connection ID used 6084 on Initial and 0-RTT packets SHOULD NOT be used by themselves to make 6085 routing decisions. Ideally, routing decisions are made independently 6086 of client-selected values; a Source Connection ID can be selected to 6087 route later packets to the same server. 6089 22. IANA Considerations 6091 22.1. QUIC Transport Parameter Registry 6093 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 6094 under a "QUIC Protocol" heading. 6096 The "QUIC Transport Parameters" registry governs a 16-bit space. 6097 This space is split into two spaces that are governed by different 6098 policies. Values with the first byte in the range 0x00 to 0xfe (in 6099 hexadecimal) are assigned via the Specification Required policy 6100 [RFC8126]. Values with the first byte 0xff are reserved for Private 6101 Use [RFC8126]. 6103 Registrations MUST include the following fields: 6105 Value: The numeric value of the assignment (registrations will be 6106 between 0x0000 and 0xfeff). 6108 Parameter Name: A short mnemonic for the parameter. 6110 Specification: A reference to a publicly available specification for 6111 the value. 6113 The nominated expert(s) verify that a specification exists and is 6114 readily accessible. Expert(s) are encouraged to be biased towards 6115 approving registrations unless they are abusive, frivolous, or 6116 actively harmful (not merely aesthetically displeasing, or 6117 architecturally dubious). 6119 The initial contents of this registry are shown in Table 6. 6121 +--------+-------------------------------------+---------------+ 6122 | Value | Parameter Name | Specification | 6123 +--------+-------------------------------------+---------------+ 6124 | 0x0000 | original_connection_id | Section 18.2 | 6125 | | | | 6126 | 0x0001 | idle_timeout | Section 18.2 | 6127 | | | | 6128 | 0x0002 | stateless_reset_token | Section 18.2 | 6129 | | | | 6130 | 0x0003 | max_packet_size | Section 18.2 | 6131 | | | | 6132 | 0x0004 | initial_max_data | Section 18.2 | 6133 | | | | 6134 | 0x0005 | initial_max_stream_data_bidi_local | Section 18.2 | 6135 | | | | 6136 | 0x0006 | initial_max_stream_data_bidi_remote | Section 18.2 | 6137 | | | | 6138 | 0x0007 | initial_max_stream_data_uni | Section 18.2 | 6139 | | | | 6140 | 0x0008 | initial_max_streams_bidi | Section 18.2 | 6141 | | | | 6142 | 0x0009 | initial_max_streams_uni | Section 18.2 | 6143 | | | | 6144 | 0x000a | ack_delay_exponent | Section 18.2 | 6145 | | | | 6146 | 0x000b | max_ack_delay | Section 18.2 | 6147 | | | | 6148 | 0x000c | disable_active_migration | Section 18.2 | 6149 | | | | 6150 | 0x000d | preferred_address | Section 18.2 | 6151 | | | | 6152 | 0x000e | active_connection_id_limit | Section 18.2 | 6153 +--------+-------------------------------------+---------------+ 6155 Table 6: Initial QUIC Transport Parameters Entries 6157 Additionally, each value of the format "31 * N + 27" for integer 6158 values of N (that is, "27", "58", "89", ...) MUST NOT be assigned by 6159 IANA. 6161 22.2. QUIC Frame Type Registry 6163 IANA [SHALL add/has added] a registry for "QUIC Frame Types" under a 6164 "QUIC Protocol" heading. 6166 The "QUIC Frame Types" registry governs a 62-bit space. This space 6167 is split into three spaces that are governed by different policies. 6168 Values between 0x00 and 0x3f (in hexadecimal) are assigned via the 6169 Standards Action or IESG Review policies [RFC8126]. Values from 0x40 6170 to 0x3fff operate on the Specification Required policy [RFC8126]. 6171 All other values are assigned to Private Use [RFC8126]. 6173 Registrations MUST include the following fields: 6175 Value: The numeric value of the assignment (registrations will be 6176 between 0x00 and 0x3fff). A range of values MAY be assigned. 6178 Frame Name: A short mnemonic for the frame type. 6180 Specification: A reference to a publicly available specification for 6181 the value. 6183 The nominated expert(s) verify that a specification exists and is 6184 readily accessible. Specifications for new registrations need to 6185 describe the means by which an endpoint might determine that it can 6186 send the identified type of frame. An accompanying transport 6187 parameter registration (see Section 22.1) is expected for most 6188 registrations. The specification needs to describe the format and 6189 assigned semantics of any fields in the frame. 6191 Expert(s) are encouraged to be biased towards approving registrations 6192 unless they are abusive, frivolous, or actively harmful (not merely 6193 aesthetically displeasing, or architecturally dubious). 6195 The initial contents of this registry are tabulated in Table 3. 6197 22.3. QUIC Transport Error Codes Registry 6199 IANA [SHALL add/has added] a registry for "QUIC Transport Error 6200 Codes" under a "QUIC Protocol" heading. 6202 The "QUIC Transport Error Codes" registry governs a 62-bit space. 6203 This space is split into three spaces that are governed by different 6204 policies. Values between 0x00 and 0x3f (in hexadecimal) are assigned 6205 via the Standards Action or IESG Review policies [RFC8126]. Values 6206 from 0x40 to 0x3fff operate on the Specification Required policy 6207 [RFC8126]. All other values are assigned to Private Use [RFC8126]. 6209 Registrations MUST include the following fields: 6211 Value: The numeric value of the assignment (registrations will be 6212 between 0x0000 and 0x3fff). 6214 Code: A short mnemonic for the parameter. 6216 Description: A brief description of the error code semantics, which 6217 MAY be a summary if a specification reference is provided. 6219 Specification: A reference to a publicly available specification for 6220 the value. 6222 The nominated expert(s) verify that a specification exists and is 6223 readily accessible. Expert(s) are encouraged to be biased towards 6224 approving registrations unless they are abusive, frivolous, or 6225 actively harmful (not merely aesthetically displeasing, or 6226 architecturally dubious). 6228 The initial contents of this registry are shown in Table 7. 6230 +------+---------------------------+----------------+---------------+ 6231 | Valu | Error | Description | Specification | 6232 | e | | | | 6233 +------+---------------------------+----------------+---------------+ 6234 | 0x0 | NO_ERROR | No error | Section 20 | 6235 | | | | | 6236 | 0x1 | INTERNAL_ERROR | Implementation | Section 20 | 6237 | | | error | | 6238 | | | | | 6239 | 0x2 | SERVER_BUSY | Server | Section 20 | 6240 | | | currently busy | | 6241 | | | | | 6242 | 0x3 | FLOW_CONTROL_ERROR | Flow control | Section 20 | 6243 | | | error | | 6244 | | | | | 6245 | 0x4 | STREAM_LIMIT_ERROR | Too many | Section 20 | 6246 | | | streams opened | | 6247 | | | | | 6248 | 0x5 | STREAM_STATE_ERROR | Frame received | Section 20 | 6249 | | | in invalid | | 6250 | | | stream state | | 6251 | | | | | 6252 | 0x6 | FINAL_SIZE_ERROR | Change to | Section 20 | 6253 | | | final size | | 6254 | | | | | 6255 | 0x7 | FRAME_ENCODING_ERROR | Frame encoding | Section 20 | 6256 | | | error | | 6257 | | | | | 6258 | 0x8 | TRANSPORT_PARAMETER_ERROR | Error in | Section 20 | 6259 | | | transport | | 6260 | | | parameters | | 6261 | | | | | 6262 | 0xA | PROTOCOL_VIOLATION | Generic | Section 20 | 6263 | | | protocol | | 6264 | | | violation | | 6265 | | | | | 6266 | 0xD | CRYPTO_BUFFER_EXCEEDED | CRYPTO data | Section 20 | 6267 | | | buffer | | 6268 | | | overflowed | | 6269 +------+---------------------------+----------------+---------------+ 6271 Table 7: Initial QUIC Transport Error Codes Entries 6273 23. References 6274 23.1. Normative References 6276 [DPLPMTUD] 6277 Fairhurst, G., Jones, T., Tuexen, M., Ruengeler, I., and 6278 T. Voelker, "Packetization Layer Path MTU Discovery for 6279 Datagram Transports", draft-ietf-tsvwg-datagram-plpmtud-08 6280 (work in progress), June 2019. 6282 [QUIC-RECOVERY] 6283 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 6284 and Congestion Control", draft-ietf-quic-recovery-23 (work 6285 in progress), September 2019. 6287 [QUIC-TLS] 6288 Thomson, M., Ed. and S. Turner, Ed., "Using Transport 6289 Layer Security (TLS) to Secure QUIC", draft-ietf-quic- 6290 tls-23 (work in progress), September 2019. 6292 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 6293 DOI 10.17487/RFC1191, November 1990, 6294 . 6296 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6297 Requirement Levels", BCP 14, RFC 2119, 6298 DOI 10.17487/RFC2119, March 1997, 6299 . 6301 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 6302 of Explicit Congestion Notification (ECN) to IP", 6303 RFC 3168, DOI 10.17487/RFC3168, September 2001, 6304 . 6306 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 6307 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 6308 2003, . 6310 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 6311 "Randomness Requirements for Security", BCP 106, RFC 4086, 6312 DOI 10.17487/RFC4086, June 2005, 6313 . 6315 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 6316 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 6317 . 6319 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 6320 "IPv6 Flow Label Specification", RFC 6437, 6321 DOI 10.17487/RFC6437, November 2011, 6322 . 6324 [RFC8085] Eggert, L., Fairhurst, G., and G. Shepherd, "UDP Usage 6325 Guidelines", BCP 145, RFC 8085, DOI 10.17487/RFC8085, 6326 March 2017, . 6328 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 6329 Writing an IANA Considerations Section in RFCs", BCP 26, 6330 RFC 8126, DOI 10.17487/RFC8126, June 2017, 6331 . 6333 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 6334 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 6335 May 2017, . 6337 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 6338 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 6339 DOI 10.17487/RFC8201, July 2017, 6340 . 6342 [RFC8311] Black, D., "Relaxing Restrictions on Explicit Congestion 6343 Notification (ECN) Experimentation", RFC 8311, 6344 DOI 10.17487/RFC8311, January 2018, 6345 . 6347 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 6348 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 6349 . 6351 23.2. Informative References 6353 [EARLY-DESIGN] 6354 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 6355 December 2013, . 6357 [HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 6358 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 6359 DOI 10.17487/RFC7540, May 2015, 6360 . 6362 [QUIC-INVARIANTS] 6363 Thomson, M., "Version-Independent Properties of QUIC", 6364 draft-ietf-quic-invariants-07 (work in progress), 6365 September 2019. 6367 [QUIC-MANAGEABILITY] 6368 Kuehlewind, M. and B. Trammell, "Manageability of the QUIC 6369 Transport Protocol", draft-ietf-quic-manageability-05 6370 (work in progress), July 2019. 6372 [RFC1812] Baker, F., Ed., "Requirements for IP Version 4 Routers", 6373 RFC 1812, DOI 10.17487/RFC1812, June 1995, 6374 . 6376 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 6377 Selective Acknowledgment Options", RFC 2018, 6378 DOI 10.17487/RFC2018, October 1996, 6379 . 6381 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 6382 Hashing for Message Authentication", RFC 2104, 6383 DOI 10.17487/RFC2104, February 1997, 6384 . 6386 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 6387 RFC 2360, DOI 10.17487/RFC2360, June 1998, 6388 . 6390 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 6391 RFC 4303, DOI 10.17487/RFC4303, December 2005, 6392 . 6394 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 6395 Control Message Protocol (ICMPv6) for the Internet 6396 Protocol Version 6 (IPv6) Specification", STD 89, 6397 RFC 4443, DOI 10.17487/RFC4443, March 2006, 6398 . 6400 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 6401 Translation (NAT) Behavioral Requirements for Unicast 6402 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 6403 2007, . 6405 [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 6406 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 6407 . 6409 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 6410 Key Derivation Function (HKDF)", RFC 5869, 6411 DOI 10.17487/RFC5869, May 2010, 6412 . 6414 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 6415 "Transport Layer Security (TLS) Application-Layer Protocol 6416 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 6417 July 2014, . 6419 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 6420 (IPv6) Specification", STD 86, RFC 8200, 6421 DOI 10.17487/RFC8200, July 2017, 6422 . 6424 [SLOWLORIS] 6425 RSnake Hansen, R., "Welcome to Slowloris...", June 2009, 6426 . 6429 Appendix A. Sample Packet Number Decoding Algorithm 6431 The following pseudo-code shows how an implementation can decode 6432 packet numbers after header protection has been removed. 6434 DecodePacketNumber(largest_pn, truncated_pn, pn_nbits): 6435 expected_pn = largest_pn + 1 6436 pn_win = 1 << pn_nbits 6437 pn_hwin = pn_win / 2 6438 pn_mask = pn_win - 1 6439 // The incoming packet number should be greater than 6440 // expected_pn - pn_hwin and less than or equal to 6441 // expected_pn + pn_hwin 6442 // 6443 // This means we can't just strip the trailing bits from 6444 // expected_pn and add the truncated_pn because that might 6445 // yield a value outside the window. 6446 // 6447 // The following code calculates a candidate value and 6448 // makes sure it's within the packet number window. 6449 candidate_pn = (expected_pn & ~pn_mask) | truncated_pn 6450 if candidate_pn <= expected_pn - pn_hwin: 6451 return candidate_pn + pn_win 6452 // Note the extra check for underflow when candidate_pn 6453 // is near zero. 6454 if candidate_pn > expected_pn + pn_hwin and 6455 candidate_pn > pn_win: 6456 return candidate_pn - pn_win 6457 return candidate_pn 6459 Appendix B. Change Log 6461 *RFC Editor's Note:* Please remove this section prior to 6462 publication of a final version of this document. 6464 Issue and pull request numbers are listed with a leading octothorp. 6466 B.1. Since draft-ietf-quic-transport-22 6468 o Rules for preventing correlation by connection ID tightened 6469 (#2084, #2929) 6471 o Clarified use of CONNECTION_CLOSE in Handshake packets (#2151, 6472 #2541, #2688) 6474 o Discourage regressions of largest acknowledged in ACK (#2205, 6475 #2752) 6477 o Improved robusness of validation process for ECN counts (#2534, 6478 #2752) 6480 o Require endpoints to ignore spurious migration attempts (#2342, 6481 #2893) 6483 o Transport parameter for disabling migration clarified to allow NAT 6484 rebinding (#2389, #2893) 6486 o Document principles for defining new error codes (#2388, #2880) 6488 o Reserve transport parameters for greasing (#2550, #2873) 6490 o A maximum ACK delay of 0 is used for handshake packet number 6491 spaces (#2646, #2638) 6493 o Improved rules for use of congestion control state on new paths 6494 (#2685, #2918) 6496 o Removed recommendation to coordinate spin for multiple connections 6497 that share a path (#2763, #2882) 6499 o Allow smaller stateless resets and recommend a smaller minimum on 6500 packets that might trigger a stateless reset (#2770, #2869, #2927) 6502 o Provide guidance around the interface to QUIC as used by 6503 application protocols (#2805, #2857) 6505 o Frames other than STREAM can cause STREAM_LIMIT_ERROR (#2825, 6506 #2826) 6508 o Tighter rules about processing of rejected 0-RTT packets (#2829, 6509 #2840, #2841) 6511 o Explanation of the effect of Retry on 0-RTT packets (#2842, #2852) 6513 o Cryptographic handshake needs to provide server transport 6514 parameter encryption (#2920, #2921) 6516 o Moved ACK generation guidance from recovery draft to transport 6517 draft (#1860, #2916). 6519 B.2. Since draft-ietf-quic-transport-21 6521 o Connection ID lengths are now one octet, but limited in version 1 6522 to 20 octets of length (#2736, #2749) 6524 B.3. Since draft-ietf-quic-transport-20 6526 o Error codes are encoded as variable-length integers (#2672, #2680) 6528 o NEW_CONNECTION_ID includes a request to retire old connection IDs 6529 (#2645, #2769) 6531 o Tighter rules for generating and explicitly eliciting ACK frames 6532 (#2546, #2794) 6534 o Recommend having only one packet per encryption level in a 6535 datagram (#2308, #2747) 6537 o More normative language about use of stateless reset (#2471, 6538 #2574) 6540 o Allow reuse of stateless reset tokens (#2732, #2733) 6542 o Allow, but not require, enforcing non-duplicate transport 6543 parameters (#2689, #2691) 6545 o Added an active_connection_id_limit transport parameter (#1994, 6546 #1998) 6548 o max_ack_delay transport parameter defaults to 0 (#2638, #2646) 6550 o When sending 0-RTT, only remembered transport parameters apply 6551 (#2458, #2360, #2466, #2461) 6553 o Define handshake completion and confirmation; define clearer rules 6554 when it encryption keys should be discarded (#2214, #2267, #2673) 6556 o Prohibit path migration prior to handshake confirmation (#2309, 6557 #2370) 6559 o PATH_RESPONSE no longer needs to be received on the validated path 6560 (#2582, #2580, #2579, #2637) 6562 o PATH_RESPONSE frames are not stored and retransmitted (#2724, 6563 #2729) 6565 o Document hack for enabling routing of ICMP when doing PMTU probing 6566 (#1243, #2402) 6568 B.4. Since draft-ietf-quic-transport-19 6570 o Refine discussion of 0-RTT transport parameters (#2467, #2464) 6572 o Fewer transport parameters need to be remembered for 0-RTT (#2624, 6573 #2467) 6575 o Spin bit text incorporated (#2564) 6577 o Close the connection when maximum stream ID in MAX_STREAMS exceeds 6578 2^62 - 1 (#2499, #2487) 6580 o New connection ID required for intentional migration (#2414, 6581 #2413) 6583 o Connection ID issuance can be rate-limited (#2436, #2428) 6585 o The "QUIC bit" is ignored in Version Negotiation (#2400, #2561) 6587 o Initial packets from clients need to be padded to 1200 unless a 6588 Handshake packet is sent as well (#2522, #2523) 6590 o CRYPTO frames can be discarded if too much data is buffered 6591 (#1834, #2524) 6593 o Stateless reset uses a short header packet (#2599, #2600) 6595 B.5. Since draft-ietf-quic-transport-18 6597 o Removed version negotiation; version negotiation, including 6598 authentication of the result, will be addressed in the next 6599 version of QUIC (#1773, #2313) 6601 o Added discussion of the use of IPv6 flow labels (#2348, #2399) 6602 o A connection ID can't be retired in a packet that uses that 6603 connection ID (#2101, #2420) 6605 o Idle timeout transport parameter is in milliseconds (from seconds) 6606 (#2453, #2454) 6608 o Endpoints are required to use new connection IDs when they use new 6609 network paths (#2413, #2414) 6611 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 6613 B.6. Since draft-ietf-quic-transport-17 6615 o Stream-related errors now use STREAM_STATE_ERROR (#2305) 6617 o Endpoints discard initial keys as soon as handshake keys are 6618 available (#1951, #2045) 6620 o Expanded conditions for ignoring ICMP packet too big messages 6621 (#2108, #2161) 6623 o Remove rate control from PATH_CHALLENGE/PATH_RESPONSE (#2129, 6624 #2241) 6626 o Endpoints are permitted to discard malformed initial packets 6627 (#2141) 6629 o Clarified ECN implementation and usage requirements (#2156, #2201) 6631 o Disable ECN count verification for packets that arrive out of 6632 order (#2198, #2215) 6634 o Use Probe Timeout (PTO) instead of RTO (#2206, #2238) 6636 o Loosen constraints on retransmission of ACK ranges (#2199, #2245) 6638 o Limit Retry and Version Negotiation to once per datagram (#2259, 6639 #2303) 6641 o Set a maximum value for max_ack_delay transport parameter (#2282, 6642 #2301) 6644 o Allow server preferred address for both IPv4 and IPv6 (#2122, 6645 #2296) 6647 o Corrected requirements for migration to a preferred address 6648 (#2146, #2349) 6650 o ACK of non-existent packet is illegal (#2298, #2302) 6652 B.7. Since draft-ietf-quic-transport-16 6654 o Stream limits are defined as counts, not maximums (#1850, #1906) 6656 o Require amplification attack defense after closing (#1905, #1911) 6658 o Remove reservation of application error code 0 for STOPPING 6659 (#1804, #1922) 6661 o Renumbered frames (#1945) 6663 o Renumbered transport parameters (#1946) 6665 o Numeric transport parameters are expressed as varints (#1608, 6666 #1947, #1955) 6668 o Reorder the NEW_CONNECTION_ID frame (#1952, #1963) 6670 o Rework the first byte (#2006) 6672 * Fix the 0x40 bit 6674 * Change type values for long header 6676 * Add spin bit to short header (#631, #1988) 6678 * Encrypt the remainder of the first byte (#1322) 6680 * Move packet number length to first byte 6682 * Move ODCIL to first byte of retry packets 6684 * Simplify packet number protection (#1575) 6686 o Allow STOP_SENDING to open a remote bidirectional stream (#1797, 6687 #2013) 6689 o Added mitigation for off-path migration attacks (#1278, #1749, 6690 #2033) 6692 o Don't let the PMTU to drop below 1280 (#2063, #2069) 6694 o Require peers to replace retired connection IDs (#2085) 6696 o Servers are required to ignore Version Negotiation packets (#2088) 6697 o Tokens are repeated in all Initial packets (#2089) 6699 o Clarified how PING frames are sent after loss (#2094) 6701 o Initial keys are discarded once Handshake are available (#1951, 6702 #2045) 6704 o ICMP PTB validation clarifications (#2161, #2109, #2108) 6706 B.8. Since draft-ietf-quic-transport-15 6708 Substantial editorial reorganization; no technical changes. 6710 B.9. Since draft-ietf-quic-transport-14 6712 o Merge ACK and ACK_ECN (#1778, #1801) 6714 o Explicitly communicate max_ack_delay (#981, #1781) 6716 o Validate original connection ID after Retry packets (#1710, #1486, 6717 #1793) 6719 o Idle timeout is optional and has no specified maximum (#1765) 6721 o Update connection ID handling; add RETIRE_CONNECTION_ID type 6722 (#1464, #1468, #1483, #1484, #1486, #1495, #1729, #1742, #1799, 6723 #1821) 6725 o Include a Token in all Initial packets (#1649, #1794) 6727 o Prevent handshake deadlock (#1764, #1824) 6729 B.10. Since draft-ietf-quic-transport-13 6731 o Streams open when higher-numbered streams of the same type open 6732 (#1342, #1549) 6734 o Split initial stream flow control limit into 3 transport 6735 parameters (#1016, #1542) 6737 o All flow control transport parameters are optional (#1610) 6739 o Removed UNSOLICITED_PATH_RESPONSE error code (#1265, #1539) 6741 o Permit stateless reset in response to any packet (#1348, #1553) 6743 o Recommended defense against stateless reset spoofing (#1386, 6744 #1554) 6746 o Prevent infinite stateless reset exchanges (#1443, #1627) 6748 o Forbid processing of the same packet number twice (#1405, #1624) 6750 o Added a packet number decoding example (#1493) 6752 o More precisely define idle timeout (#1429, #1614, #1652) 6754 o Corrected format of Retry packet and prevented looping (#1492, 6755 #1451, #1448, #1498) 6757 o Permit 0-RTT after receiving Version Negotiation or Retry (#1507, 6758 #1514, #1621) 6760 o Permit Retry in response to 0-RTT (#1547, #1552) 6762 o Looser verification of ECN counters to account for ACK loss 6763 (#1555, #1481, #1565) 6765 o Remove frame type field from APPLICATION_CLOSE (#1508, #1528) 6767 B.11. Since draft-ietf-quic-transport-12 6769 o Changes to integration of the TLS handshake (#829, #1018, #1094, 6770 #1165, #1190, #1233, #1242, #1252, #1450, #1458) 6772 * The cryptographic handshake uses CRYPTO frames, not stream 0 6774 * QUIC packet protection is used in place of TLS record 6775 protection 6777 * Separate QUIC packet number spaces are used for the handshake 6779 * Changed Retry to be independent of the cryptographic handshake 6781 * Added NEW_TOKEN frame and Token fields to Initial packet 6783 * Limit the use of HelloRetryRequest to address TLS needs (like 6784 key shares) 6786 o Enable server to transition connections to a preferred address 6787 (#560, #1251, #1373) 6789 o Added ECN feedback mechanisms and handling; new ACK_ECN frame 6790 (#804, #805, #1372) 6792 o Changed rules and recommendations for use of new connection IDs 6793 (#1258, #1264, #1276, #1280, #1419, #1452, #1453, #1465) 6795 o Added a transport parameter to disable intentional connection 6796 migration (#1271, #1447) 6798 o Packets from different connection ID can't be coalesced (#1287, 6799 #1423) 6801 o Fixed sampling method for packet number encryption; the length 6802 field in long headers includes the packet number field in addition 6803 to the packet payload (#1387, #1389) 6805 o Stateless Reset is now symmetric and subject to size constraints 6806 (#466, #1346) 6808 o Added frame type extension mechanism (#58, #1473) 6810 B.12. Since draft-ietf-quic-transport-11 6812 o Enable server to transition connections to a preferred address 6813 (#560, #1251) 6815 o Packet numbers are encrypted (#1174, #1043, #1048, #1034, #850, 6816 #990, #734, #1317, #1267, #1079) 6818 o Packet numbers use a variable-length encoding (#989, #1334) 6820 o STREAM frames can now be empty (#1350) 6822 B.13. Since draft-ietf-quic-transport-10 6824 o Swap payload length and packed number fields in long header 6825 (#1294) 6827 o Clarified that CONNECTION_CLOSE is allowed in Handshake packet 6828 (#1274) 6830 o Spin bit reserved (#1283) 6832 o Coalescing multiple QUIC packets in a UDP datagram (#1262, #1285) 6834 o A more complete connection migration (#1249) 6836 o Refine opportunistic ACK defense text (#305, #1030, #1185) 6838 o A Stateless Reset Token isn't mandatory (#818, #1191) 6840 o Removed implicit stream opening (#896, #1193) 6841 o An empty STREAM frame can be used to open a stream without sending 6842 data (#901, #1194) 6844 o Define stream counts in transport parameters rather than a maximum 6845 stream ID (#1023, #1065) 6847 o STOP_SENDING is now prohibited before streams are used (#1050) 6849 o Recommend including ACK in Retry packets and allow PADDING (#1067, 6850 #882) 6852 o Endpoints now become closing after an idle timeout (#1178, #1179) 6854 o Remove implication that Version Negotiation is sent when a packet 6855 of the wrong version is received (#1197) 6857 B.14. Since draft-ietf-quic-transport-09 6859 o Added PATH_CHALLENGE and PATH_RESPONSE frames to replace PING with 6860 Data and PONG frame. Changed ACK frame type from 0x0e to 0x0d. 6861 (#1091, #725, #1086) 6863 o A server can now only send 3 packets without validating the client 6864 address (#38, #1090) 6866 o Delivery order of stream data is no longer strongly specified 6867 (#252, #1070) 6869 o Rework of packet handling and version negotiation (#1038) 6871 o Stream 0 is now exempt from flow control until the handshake 6872 completes (#1074, #725, #825, #1082) 6874 o Improved retransmission rules for all frame types: information is 6875 retransmitted, not packets or frames (#463, #765, #1095, #1053) 6877 o Added an error code for server busy signals (#1137) 6879 o Endpoints now set the connection ID that their peer uses. 6880 Connection IDs are variable length. Removed the 6881 omit_connection_id transport parameter and the corresponding short 6882 header flag. (#1089, #1052, #1146, #821, #745, #821, #1166, #1151) 6884 B.15. Since draft-ietf-quic-transport-08 6886 o Clarified requirements for BLOCKED usage (#65, #924) 6887 o BLOCKED frame now includes reason for blocking (#452, #924, #927, 6888 #928) 6890 o GAP limitation in ACK Frame (#613) 6892 o Improved PMTUD description (#614, #1036) 6894 o Clarified stream state machine (#634, #662, #743, #894) 6896 o Reserved versions don't need to be generated deterministically 6897 (#831, #931) 6899 o You don't always need the draining period (#871) 6901 o Stateless reset clarified as version-specific (#930, #986) 6903 o initial_max_stream_id_x transport parameters are optional (#970, 6904 #971) 6906 o Ack Delay assumes a default value during the handshake (#1007, 6907 #1009) 6909 o Removed transport parameters from NewSessionTicket (#1015) 6911 B.16. Since draft-ietf-quic-transport-07 6913 o The long header now has version before packet number (#926, #939) 6915 o Rename and consolidate packet types (#846, #822, #847) 6917 o Packet types are assigned new codepoints and the Connection ID 6918 Flag is inverted (#426, #956) 6920 o Removed type for Version Negotiation and use Version 0 (#963, 6921 #968) 6923 o Streams are split into unidirectional and bidirectional (#643, 6924 #656, #720, #872, #175, #885) 6926 * Stream limits now have separate uni- and bi-directional 6927 transport parameters (#909, #958) 6929 * Stream limit transport parameters are now optional and default 6930 to 0 (#970, #971) 6932 o The stream state machine has been split into read and write (#634, 6933 #894) 6935 o Employ variable-length integer encodings throughout (#595) 6937 o Improvements to connection close 6939 * Added distinct closing and draining states (#899, #871) 6941 * Draining period can terminate early (#869, #870) 6943 * Clarifications about stateless reset (#889, #890) 6945 o Address validation for connection migration (#161, #732, #878) 6947 o Clearly defined retransmission rules for BLOCKED (#452, #65, #924) 6949 o negotiated_version is sent in server transport parameters (#710, 6950 #959) 6952 o Increased the range over which packet numbers are randomized 6953 (#864, #850, #964) 6955 B.17. Since draft-ietf-quic-transport-06 6957 o Replaced FNV-1a with AES-GCM for all "Cleartext" packets (#554) 6959 o Split error code space between application and transport (#485) 6961 o Stateless reset token moved to end (#820) 6963 o 1-RTT-protected long header types removed (#848) 6965 o No acknowledgments during draining period (#852) 6967 o Remove "application close" as a separate close type (#854) 6969 o Remove timestamps from the ACK frame (#841) 6971 o Require transport parameters to only appear once (#792) 6973 B.18. Since draft-ietf-quic-transport-05 6975 o Stateless token is server-only (#726) 6977 o Refactor section on connection termination (#733, #748, #328, 6978 #177) 6980 o Limit size of Version Negotiation packet (#585) 6982 o Clarify when and what to ack (#736) 6983 o Renamed STREAM_ID_NEEDED to STREAM_ID_BLOCKED 6985 o Clarify Keep-alive requirements (#729) 6987 B.19. Since draft-ietf-quic-transport-04 6989 o Introduce STOP_SENDING frame, RESET_STREAM only resets in one 6990 direction (#165) 6992 o Removed GOAWAY; application protocols are responsible for graceful 6993 shutdown (#696) 6995 o Reduced the number of error codes (#96, #177, #184, #211) 6997 o Version validation fields can't move or change (#121) 6999 o Removed versions from the transport parameters in a 7000 NewSessionTicket message (#547) 7002 o Clarify the meaning of "bytes in flight" (#550) 7004 o Public reset is now stateless reset and not visible to the path 7005 (#215) 7007 o Reordered bits and fields in STREAM frame (#620) 7009 o Clarifications to the stream state machine (#572, #571) 7011 o Increased the maximum length of the Largest Acknowledged field in 7012 ACK frames to 64 bits (#629) 7014 o truncate_connection_id is renamed to omit_connection_id (#659) 7016 o CONNECTION_CLOSE terminates the connection like TCP RST (#330, 7017 #328) 7019 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 7021 B.20. Since draft-ietf-quic-transport-03 7023 o Change STREAM and RESET_STREAM layout 7025 o Add MAX_STREAM_ID settings 7027 B.21. Since draft-ietf-quic-transport-02 7029 o The size of the initial packet payload has a fixed minimum (#267, 7030 #472) 7032 o Define when Version Negotiation packets are ignored (#284, #294, 7033 #241, #143, #474) 7035 o The 64-bit FNV-1a algorithm is used for integrity protection of 7036 unprotected packets (#167, #480, #481, #517) 7038 o Rework initial packet types to change how the connection ID is 7039 chosen (#482, #442, #493) 7041 o No timestamps are forbidden in unprotected packets (#542, #429) 7043 o Cryptographic handshake is now on stream 0 (#456) 7045 o Remove congestion control exemption for cryptographic handshake 7046 (#248, #476) 7048 o Version 1 of QUIC uses TLS; a new version is needed to use a 7049 different handshake protocol (#516) 7051 o STREAM frames have a reduced number of offset lengths (#543, #430) 7053 o Split some frames into separate connection- and stream- level 7054 frames (#443) 7056 * WINDOW_UPDATE split into MAX_DATA and MAX_STREAM_DATA (#450) 7058 * BLOCKED split to match WINDOW_UPDATE split (#454) 7060 * Define STREAM_ID_NEEDED frame (#455) 7062 o A NEW_CONNECTION_ID frame supports connection migration without 7063 linkability (#232, #491, #496) 7065 o Transport parameters for 0-RTT are retained from a previous 7066 connection (#405, #513, #512) 7068 * A client in 0-RTT no longer required to reset excess streams 7069 (#425, #479) 7071 o Expanded security considerations (#440, #444, #445, #448) 7073 B.22. Since draft-ietf-quic-transport-01 7075 o Defined short and long packet headers (#40, #148, #361) 7077 o Defined a versioning scheme and stable fields (#51, #361) 7079 o Define reserved version values for "greasing" negotiation (#112, 7080 #278) 7082 o The initial packet number is randomized (#35, #283) 7084 o Narrow the packet number encoding range requirement (#67, #286, 7085 #299, #323, #356) 7087 o Defined client address validation (#52, #118, #120, #275) 7089 o Define transport parameters as a TLS extension (#49, #122) 7091 o SCUP and COPT parameters are no longer valid (#116, #117) 7093 o Transport parameters for 0-RTT are either remembered from before, 7094 or assume default values (#126) 7096 o The server chooses connection IDs in its final flight (#119, #349, 7097 #361) 7099 o The server echoes the Connection ID and packet number fields when 7100 sending a Version Negotiation packet (#133, #295, #244) 7102 o Defined a minimum packet size for the initial handshake packet 7103 from the client (#69, #136, #139, #164) 7105 o Path MTU Discovery (#64, #106) 7107 o The initial handshake packet from the client needs to fit in a 7108 single packet (#338) 7110 o Forbid acknowledgment of packets containing only ACK and PADDING 7111 (#291) 7113 o Require that frames are processed when packets are acknowledged 7114 (#381, #341) 7116 o Removed the STOP_WAITING frame (#66) 7118 o Don't require retransmission of old timestamps for lost ACK frames 7119 (#308) 7121 o Clarified that frames are not retransmitted, but the information 7122 in them can be (#157, #298) 7124 o Error handling definitions (#335) 7126 o Split error codes into four sections (#74) 7128 o Forbid the use of Public Reset where CONNECTION_CLOSE is possible 7129 (#289) 7131 o Define packet protection rules (#336) 7133 o Require that stream be entirely delivered or reset, including 7134 acknowledgment of all STREAM frames or the RESET_STREAM, before it 7135 closes (#381) 7137 o Remove stream reservation from state machine (#174, #280) 7139 o Only stream 1 does not contribute to connection-level flow control 7140 (#204) 7142 o Stream 1 counts towards the maximum concurrent stream limit (#201, 7143 #282) 7145 o Remove connection-level flow control exclusion for some streams 7146 (except 1) (#246) 7148 o RESET_STREAM affects connection-level flow control (#162, #163) 7150 o Flow control accounting uses the maximum data offset on each 7151 stream, rather than bytes received (#378) 7153 o Moved length-determining fields to the start of STREAM and ACK 7154 (#168, #277) 7156 o Added the ability to pad between frames (#158, #276) 7158 o Remove error code and reason phrase from GOAWAY (#352, #355) 7160 o GOAWAY includes a final stream number for both directions (#347) 7162 o Error codes for RESET_STREAM and CONNECTION_CLOSE are now at a 7163 consistent offset (#249) 7165 o Defined priority as the responsibility of the application protocol 7166 (#104, #303) 7168 B.23. Since draft-ietf-quic-transport-00 7170 o Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 7172 o Defined versioning 7174 o Reworked description of packet and frame layout 7176 o Error code space is divided into regions for each component 7178 o Use big endian for all numeric values 7180 B.24. Since draft-hamilton-quic-transport-protocol-01 7182 o Adopted as base for draft-ietf-quic-tls 7184 o Updated authors/editors list 7186 o Added IANA Considerations section 7188 o Moved Contributors and Acknowledgments to appendices 7190 Acknowledgments 7192 Special thanks are due to the following for helping shape pre-IETF 7193 QUIC and its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, 7194 Alistair Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. 7196 This document has benefited immensely from various private 7197 discussions and public ones on the quic@ietf.org and proto- 7198 quic@chromium.org mailing lists. Our thanks to all. 7200 Contributors 7202 The original authors of this specification were Ryan Hamilton, Jana 7203 Iyengar, Ian Swett, and Alyssa Wilk. 7205 The original design and rationale behind this protocol draw 7206 significantly from work by Jim Roskind [EARLY-DESIGN]. In 7207 alphabetical order, the contributors to the pre-IETF QUIC project at 7208 Google are: Britt Cyr, Jeremy Dorfman, Ryan Hamilton, Jana Iyengar, 7209 Fedor Kouranov, Charles Krasic, Jo Kulik, Adam Langley, Jim Roskind, 7210 Robbie Shade, Satyam Shekhar, Cherie Shi, Ian Swett, Raman Tenneti, 7211 Victor Vasiliev, Antonio Vicente, Patrik Westin, Alyssa Wilk, Dale 7212 Worley, Fan Yang, Dan Zhang, Daniel Ziegler. 7214 Authors' Addresses 7216 Jana Iyengar (editor) 7217 Fastly 7219 Email: jri.ietf@gmail.com 7221 Martin Thomson (editor) 7222 Mozilla 7224 Email: mt@lowentropy.net