idnits 2.17.1 draft-ietf-quic-transport-25.txt: -(8035): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding 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: ---------------------------------------------------------------------------- == There are 2 instances of lines with non-ascii characters in the document. 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. A client MUST discard a Retry packet that contains a Source Connection ID field that is identical to the Destination Connection ID field of its Initial packet. The client MUST use the value from the Source Connection ID field of the Retry packet in the Destination Connection ID field of subsequent packets that it sends. -- The document date (22 January 2020) is 1556 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 1971 == Missing Reference: 'CH' is mentioned on line 1967, but not defined == Missing Reference: 'SH' is mentioned on line 1969, but not defined == Missing Reference: 'EE' is mentioned on line 1970, but not defined == Missing Reference: 'CERT' is mentioned on line 1970, but not defined == Missing Reference: 'CV' is mentioned on line 1970, but not defined == Missing Reference: 'FIN' is mentioned on line 1970, but not defined -- Looks like a reference, but probably isn't: '1' on line 1969 == Outdated reference: A later version (-22) exists of draft-ietf-tsvwg-datagram-plpmtud-08 == Outdated reference: A later version (-34) exists of draft-ietf-quic-recovery-25 == Outdated reference: A later version (-34) exists of draft-ietf-quic-tls-25 -- Obsolete informational reference (is this intentional?): RFC 7540 (ref. 'HTTP2') (Obsoleted by RFC 9113) == Outdated reference: A later version (-13) exists of draft-ietf-quic-invariants-07 == Outdated reference: A later version (-18) exists of draft-ietf-quic-manageability-05 Summary: 0 errors (**), 0 flaws (~~), 15 warnings (==), 5 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: 25 July 2020 Mozilla 6 22 January 2020 8 QUIC: A UDP-Based Multiplexed and Secure Transport 9 draft-ietf-quic-transport-25 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 25 July 2020. 44 Copyright Notice 46 Copyright (c) 2020 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 (https://trustee.ietf.org/ 51 license-info) in effect on the date of publication of this document. 52 Please review these documents carefully, as they describe your rights 53 and restrictions with respect to this document. Code Components 54 extracted from this document must include Simplified BSD License text 55 as described in Section 4.e of the Trust Legal Provisions and are 56 provided without warranty as described in the Simplified BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6 61 1.1. Document Structure . . . . . . . . . . . . . . . . . . . 6 62 1.2. Terms and Definitions . . . . . . . . . . . . . . . . . . 8 63 1.3. Notational Conventions . . . . . . . . . . . . . . . . . 9 64 2. Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 65 2.1. Stream Types and Identifiers . . . . . . . . . . . . . . 10 66 2.2. Sending and Receiving Data . . . . . . . . . . . . . . . 11 67 2.3. Stream Prioritization . . . . . . . . . . . . . . . . . . 11 68 2.4. Required Operations on Streams . . . . . . . . . . . . . 12 69 3. Stream States . . . . . . . . . . . . . . . . . . . . . . . . 12 70 3.1. Sending Stream States . . . . . . . . . . . . . . . . . . 13 71 3.2. Receiving Stream States . . . . . . . . . . . . . . . . . 16 72 3.3. Permitted Frame Types . . . . . . . . . . . . . . . . . . 18 73 3.4. Bidirectional Stream States . . . . . . . . . . . . . . . 19 74 3.5. Solicited State Transitions . . . . . . . . . . . . . . . 20 75 4. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 22 76 4.1. Data Flow Control . . . . . . . . . . . . . . . . . . . . 22 77 4.2. Flow Credit Increments . . . . . . . . . . . . . . . . . 23 78 4.3. Handling Stream Cancellation . . . . . . . . . . . . . . 24 79 4.4. Stream Final Size . . . . . . . . . . . . . . . . . . . . 25 80 4.5. Controlling Concurrency . . . . . . . . . . . . . . . . . 25 81 5. Connections . . . . . . . . . . . . . . . . . . . . . . . . . 26 82 5.1. Connection ID . . . . . . . . . . . . . . . . . . . . . . 26 83 5.1.1. Issuing Connection IDs . . . . . . . . . . . . . . . 27 84 5.1.2. Consuming and Retiring Connection IDs . . . . . . . . 28 85 5.2. Matching Packets to Connections . . . . . . . . . . . . . 29 86 5.2.1. Client Packet Handling . . . . . . . . . . . . . . . 30 87 5.2.2. Server Packet Handling . . . . . . . . . . . . . . . 30 88 5.3. Life of a QUIC Connection . . . . . . . . . . . . . . . . 31 89 5.4. Required Operations on Connections . . . . . . . . . . . 32 90 6. Version Negotiation . . . . . . . . . . . . . . . . . . . . . 33 91 6.1. Sending Version Negotiation Packets . . . . . . . . . . . 33 92 6.2. Handling Version Negotiation Packets . . . . . . . . . . 34 93 6.2.1. Version Negotiation Between Draft Versions . . . . . 34 94 6.3. Using Reserved Versions . . . . . . . . . . . . . . . . . 34 95 7. Cryptographic and Transport Handshake . . . . . . . . . . . . 35 96 7.1. Example Handshake Flows . . . . . . . . . . . . . . . . . 36 97 7.2. Negotiating Connection IDs . . . . . . . . . . . . . . . 37 98 7.3. Transport Parameters . . . . . . . . . . . . . . . . . . 38 99 7.3.1. Values of Transport Parameters for 0-RTT . . . . . . 39 100 7.3.2. New Transport Parameters . . . . . . . . . . . . . . 40 101 7.4. Cryptographic Message Buffering . . . . . . . . . . . . . 41 102 8. Address Validation . . . . . . . . . . . . . . . . . . . . . 41 103 8.1. Address Validation During Connection Establishment . . . 42 104 8.1.1. Token Construction . . . . . . . . . . . . . . . . . 43 105 8.1.2. Address Validation using Retry Packets . . . . . . . 43 106 8.1.3. Address Validation for Future Connections . . . . . . 44 107 8.1.4. Address Validation Token Integrity . . . . . . . . . 46 108 8.2. Path Validation . . . . . . . . . . . . . . . . . . . . . 47 109 8.3. Initiating Path Validation . . . . . . . . . . . . . . . 47 110 8.4. Path Validation Responses . . . . . . . . . . . . . . . . 48 111 8.5. Successful Path Validation . . . . . . . . . . . . . . . 48 112 8.6. Failed Path Validation . . . . . . . . . . . . . . . . . 48 113 9. Connection Migration . . . . . . . . . . . . . . . . . . . . 49 114 9.1. Probing a New Path . . . . . . . . . . . . . . . . . . . 50 115 9.2. Initiating Connection Migration . . . . . . . . . . . . . 50 116 9.3. Responding to Connection Migration . . . . . . . . . . . 51 117 9.3.1. Peer Address Spoofing . . . . . . . . . . . . . . . . 52 118 9.3.2. On-Path Address Spoofing . . . . . . . . . . . . . . 52 119 9.3.3. Off-Path Packet Forwarding . . . . . . . . . . . . . 53 120 9.4. Loss Detection and Congestion Control . . . . . . . . . . 54 121 9.5. Privacy Implications of Connection Migration . . . . . . 55 122 9.6. Server's Preferred Address . . . . . . . . . . . . . . . 56 123 9.6.1. Communicating a Preferred Address . . . . . . . . . . 56 124 9.6.2. Responding to Connection Migration . . . . . . . . . 57 125 9.6.3. Interaction of Client Migration and Preferred 126 Address . . . . . . . . . . . . . . . . . . . . . . . 57 127 9.7. Use of IPv6 Flow-Label and Migration . . . . . . . . . . 58 128 10. Connection Termination . . . . . . . . . . . . . . . . . . . 58 129 10.1. Closing and Draining Connection States . . . . . . . . . 58 130 10.2. Idle Timeout . . . . . . . . . . . . . . . . . . . . . . 60 131 10.3. Immediate Close . . . . . . . . . . . . . . . . . . . . 60 132 10.4. Stateless Reset . . . . . . . . . . . . . . . . . . . . 62 133 10.4.1. Detecting a Stateless Reset . . . . . . . . . . . . 65 134 10.4.2. Calculating a Stateless Reset Token . . . . . . . . 66 135 10.4.3. Looping . . . . . . . . . . . . . . . . . . . . . . 67 136 11. Error Handling . . . . . . . . . . . . . . . . . . . . . . . 67 137 11.1. Connection Errors . . . . . . . . . . . . . . . . . . . 68 138 11.2. Stream Errors . . . . . . . . . . . . . . . . . . . . . 68 139 12. Packets and Frames . . . . . . . . . . . . . . . . . . . . . 69 140 12.1. Protected Packets . . . . . . . . . . . . . . . . . . . 69 141 12.2. Coalescing Packets . . . . . . . . . . . . . . . . . . . 70 142 12.3. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 71 143 12.4. Frames and Frame Types . . . . . . . . . . . . . . . . . 72 144 13. Packetization and Reliability . . . . . . . . . . . . . . . . 75 145 13.1. Packet Processing . . . . . . . . . . . . . . . . . . . 76 146 13.2. Generating Acknowledgements . . . . . . . . . . . . . . 76 147 13.2.1. Sending ACK Frames . . . . . . . . . . . . . . . . . 77 148 13.2.2. Managing ACK Ranges . . . . . . . . . . . . . . . . 78 149 13.2.3. Receiver Tracking of ACK Frames . . . . . . . . . . 79 150 13.2.4. Limiting ACK Ranges . . . . . . . . . . . . . . . . 79 151 13.2.5. Measuring and Reporting Host Delay . . . . . . . . . 79 152 13.2.6. ACK Frames and Packet Protection . . . . . . . . . . 80 153 13.3. Retransmission of Information . . . . . . . . . . . . . 80 154 13.4. Explicit Congestion Notification . . . . . . . . . . . . 83 155 13.4.1. ECN Counts . . . . . . . . . . . . . . . . . . . . . 83 156 13.4.2. ECN Validation . . . . . . . . . . . . . . . . . . . 84 157 14. Packet Size . . . . . . . . . . . . . . . . . . . . . . . . . 85 158 14.1. Path Maximum Transmission Unit (PMTU) . . . . . . . . . 86 159 14.2. ICMP Packet Too Big Messages . . . . . . . . . . . . . . 87 160 14.3. Datagram Packetization Layer PMTU Discovery . . . . . . 88 161 14.3.1. PMTU Probes Containing Source Connection ID . . . . 88 162 15. Versions . . . . . . . . . . . . . . . . . . . . . . . . . . 89 163 16. Variable-Length Integer Encoding . . . . . . . . . . . . . . 90 164 17. Packet Formats . . . . . . . . . . . . . . . . . . . . . . . 90 165 17.1. Packet Number Encoding and Decoding . . . . . . . . . . 91 166 17.2. Long Header Packets . . . . . . . . . . . . . . . . . . 92 167 17.2.1. Version Negotiation Packet . . . . . . . . . . . . . 94 168 17.2.2. Initial Packet . . . . . . . . . . . . . . . . . . . 96 169 17.2.3. 0-RTT . . . . . . . . . . . . . . . . . . . . . . . 98 170 17.2.4. Handshake Packet . . . . . . . . . . . . . . . . . . 100 171 17.2.5. Retry Packet . . . . . . . . . . . . . . . . . . . . 101 172 17.3. Short Header Packets . . . . . . . . . . . . . . . . . . 103 173 17.3.1. Latency Spin Bit . . . . . . . . . . . . . . . . . . 105 174 18. Transport Parameter Encoding . . . . . . . . . . . . . . . . 106 175 18.1. Reserved Transport Parameters . . . . . . . . . . . . . 107 176 18.2. Transport Parameter Definitions . . . . . . . . . . . . 107 177 19. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 112 178 19.1. PADDING Frame . . . . . . . . . . . . . . . . . . . . . 112 179 19.2. PING Frame . . . . . . . . . . . . . . . . . . . . . . . 112 180 19.3. ACK Frames . . . . . . . . . . . . . . . . . . . . . . . 113 181 19.3.1. ACK Ranges . . . . . . . . . . . . . . . . . . . . . 114 182 19.3.2. ECN Counts . . . . . . . . . . . . . . . . . . . . . 116 183 19.4. RESET_STREAM Frame . . . . . . . . . . . . . . . . . . . 117 184 19.5. STOP_SENDING Frame . . . . . . . . . . . . . . . . . . . 118 185 19.6. CRYPTO Frame . . . . . . . . . . . . . . . . . . . . . . 118 186 19.7. NEW_TOKEN Frame . . . . . . . . . . . . . . . . . . . . 119 187 19.8. STREAM Frames . . . . . . . . . . . . . . . . . . . . . 120 188 19.9. MAX_DATA Frame . . . . . . . . . . . . . . . . . . . . . 122 189 19.10. MAX_STREAM_DATA Frame . . . . . . . . . . . . . . . . . 122 190 19.11. MAX_STREAMS Frames . . . . . . . . . . . . . . . . . . . 123 191 19.12. DATA_BLOCKED Frame . . . . . . . . . . . . . . . . . . . 124 192 19.13. STREAM_DATA_BLOCKED Frame . . . . . . . . . . . . . . . 125 193 19.14. STREAMS_BLOCKED Frames . . . . . . . . . . . . . . . . . 125 194 19.15. NEW_CONNECTION_ID Frame . . . . . . . . . . . . . . . . 126 195 19.16. RETIRE_CONNECTION_ID Frame . . . . . . . . . . . . . . . 128 196 19.17. PATH_CHALLENGE Frame . . . . . . . . . . . . . . . . . . 129 197 19.18. PATH_RESPONSE Frame . . . . . . . . . . . . . . . . . . 129 198 19.19. CONNECTION_CLOSE Frames . . . . . . . . . . . . . . . . 129 199 19.20. HANDSHAKE_DONE frame . . . . . . . . . . . . . . . . . . 131 200 19.21. Extension Frames . . . . . . . . . . . . . . . . . . . . 131 201 20. Transport Error Codes . . . . . . . . . . . . . . . . . . . . 131 202 20.1. Application Protocol Error Codes . . . . . . . . . . . . 133 203 21. Security Considerations . . . . . . . . . . . . . . . . . . . 133 204 21.1. Handshake Denial of Service . . . . . . . . . . . . . . 133 205 21.2. Amplification Attack . . . . . . . . . . . . . . . . . . 134 206 21.3. Optimistic ACK Attack . . . . . . . . . . . . . . . . . 135 207 21.4. Slowloris Attacks . . . . . . . . . . . . . . . . . . . 135 208 21.5. Stream Fragmentation and Reassembly Attacks . . . . . . 135 209 21.6. Stream Commitment Attack . . . . . . . . . . . . . . . . 136 210 21.7. Peer Denial of Service . . . . . . . . . . . . . . . . . 136 211 21.8. Explicit Congestion Notification Attacks . . . . . . . . 137 212 21.9. Stateless Reset Oracle . . . . . . . . . . . . . . . . . 137 213 21.10. Version Downgrade . . . . . . . . . . . . . . . . . . . 137 214 21.11. Targeted Attacks by Routing . . . . . . . . . . . . . . 138 215 21.12. Overview of Security Properties . . . . . . . . . . . . 138 216 21.12.1. Handshake . . . . . . . . . . . . . . . . . . . . . 138 217 21.12.2. Protected Packets . . . . . . . . . . . . . . . . . 140 218 21.12.3. Connection Migration . . . . . . . . . . . . . . . 141 219 22. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 145 220 22.1. Registration Policies for QUIC Registries . . . . . . . 145 221 22.1.1. Provisional Registrations . . . . . . . . . . . . . 145 222 22.1.2. Selecting Codepoints . . . . . . . . . . . . . . . . 146 223 22.1.3. Reclaiming Provisional Codepoints . . . . . . . . . 146 224 22.1.4. Permanent Registrations . . . . . . . . . . . . . . 147 225 22.2. QUIC Transport Parameter Registry . . . . . . . . . . . 148 226 22.3. QUIC Frame Type Registry . . . . . . . . . . . . . . . . 149 227 22.4. QUIC Transport Error Codes Registry . . . . . . . . . . 150 228 23. References . . . . . . . . . . . . . . . . . . . . . . . . . 152 229 23.1. Normative References . . . . . . . . . . . . . . . . . . 152 230 23.2. Informative References . . . . . . . . . . . . . . . . . 153 231 Appendix A. Sample Packet Number Decoding Algorithm . . . . . . 155 232 Appendix B. Sample ECN Validation Algorithm . . . . . . . . . . 156 233 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 157 234 C.1. Since draft-ietf-quic-transport-24 . . . . . . . . . . . 157 235 C.2. Since draft-ietf-quic-transport-23 . . . . . . . . . . . 158 236 C.3. Since draft-ietf-quic-transport-22 . . . . . . . . . . . 159 237 C.4. Since draft-ietf-quic-transport-21 . . . . . . . . . . . 160 238 C.5. Since draft-ietf-quic-transport-20 . . . . . . . . . . . 160 239 C.6. Since draft-ietf-quic-transport-19 . . . . . . . . . . . 161 240 C.7. Since draft-ietf-quic-transport-18 . . . . . . . . . . . 162 241 C.8. Since draft-ietf-quic-transport-17 . . . . . . . . . . . 162 242 C.9. Since draft-ietf-quic-transport-16 . . . . . . . . . . . 163 243 C.10. Since draft-ietf-quic-transport-15 . . . . . . . . . . . 164 244 C.11. Since draft-ietf-quic-transport-14 . . . . . . . . . . . 164 245 C.12. Since draft-ietf-quic-transport-13 . . . . . . . . . . . 164 246 C.13. Since draft-ietf-quic-transport-12 . . . . . . . . . . . 165 247 C.14. Since draft-ietf-quic-transport-11 . . . . . . . . . . . 166 248 C.15. Since draft-ietf-quic-transport-10 . . . . . . . . . . . 166 249 C.16. Since draft-ietf-quic-transport-09 . . . . . . . . . . . 167 250 C.17. Since draft-ietf-quic-transport-08 . . . . . . . . . . . 168 251 C.18. Since draft-ietf-quic-transport-07 . . . . . . . . . . . 168 252 C.19. Since draft-ietf-quic-transport-06 . . . . . . . . . . . 169 253 C.20. Since draft-ietf-quic-transport-05 . . . . . . . . . . . 170 254 C.21. Since draft-ietf-quic-transport-04 . . . . . . . . . . . 170 255 C.22. Since draft-ietf-quic-transport-03 . . . . . . . . . . . 171 256 C.23. Since draft-ietf-quic-transport-02 . . . . . . . . . . . 171 257 C.24. Since draft-ietf-quic-transport-01 . . . . . . . . . . . 172 258 C.25. Since draft-ietf-quic-transport-00 . . . . . . . . . . . 174 259 C.26. Since draft-hamilton-quic-transport-protocol-01 . . . . . 174 260 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 174 261 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 174 263 1. Introduction 265 QUIC is a multiplexed and secure general-purpose transport protocol 266 that provides: 268 * Stream multiplexing 270 * Stream and connection-level flow control 272 * Low-latency connection establishment 274 * Connection migration and resilience to NAT rebinding 276 * Authenticated and encrypted header and payload 278 QUIC uses UDP as a substrate to avoid requiring changes to legacy 279 client operating systems and middleboxes. QUIC authenticates all of 280 its headers and encrypts most of the data it exchanges, including its 281 signaling, to avoid incurring a dependency on middleboxes. 283 1.1. Document Structure 285 This document describes the core QUIC protocol and is structured as 286 follows: 288 * Streams are the basic service abstraction that QUIC provides. 290 - Section 2 describes core concepts related to streams, 292 - Section 3 provides a reference model for stream states, and 294 - Section 4 outlines the operation of flow control. 296 * Connections are the context in which QUIC endpoints communicate. 298 - Section 5 describes core concepts related to connections, 300 - Section 6 describes version negotiation, 302 - Section 7 details the process for establishing connections, 304 - Section 8 specifies critical denial of service mitigation 305 mechanisms, 307 - Section 9 describes how endpoints migrate a connection to a new 308 network path, 310 - Section 10 lists the options for terminating an open 311 connection, and 313 - Section 11 provides general guidance for error handling. 315 * Packets and frames are the basic unit used by QUIC to communicate. 317 - Section 12 describes concepts related to packets and frames, 319 - Section 13 defines models for the transmission, retransmission, 320 and acknowledgement of data, and 322 - Section 14 specifies rules for managing the size of packets. 324 * Finally, encoding details of QUIC protocol elements are described 325 in: 327 - Section 15 (Versions), 329 - Section 16 (Integer Encoding), 331 - Section 17 (Packet Headers), 333 - Section 18 (Transport Parameters), 335 - Section 19 (Frames), and 337 - Section 20 (Errors). 339 Accompanying documents describe QUIC's loss detection and congestion 340 control [QUIC-RECOVERY], and the use of TLS for key negotiation 341 [QUIC-TLS]. 343 This document defines QUIC version 1, which conforms to the protocol 344 invariants in [QUIC-INVARIANTS]. 346 1.2. Terms and Definitions 348 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 349 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 350 "OPTIONAL" in this document are to be interpreted as described in BCP 351 14 [RFC2119] [RFC8174] when, and only when, they appear in all 352 capitals, as shown here. 354 Commonly used terms in the document are described below. 356 QUIC: The transport protocol described by this document. QUIC is a 357 name, not an acronym. 359 QUIC packet: A complete processable unit of QUIC that can be 360 encapsulated in a UDP datagram. Multiple QUIC packets can be 361 encapsulated in a single UDP datagram. 363 Ack-eliciting Packet: A QUIC packet that contains frames other than 364 ACK, PADDING, and CONNECTION_CLOSE. These cause a recipient to 365 send an acknowledgment (see Section 13.2.1). 367 Out-of-order packet: A packet that does not increase the largest 368 received packet number for its packet number space by exactly one. 369 A packet can arrive out of order if it is delayed or if earlier 370 packets are lost or delayed. 372 Endpoint: An entity that can participate in a QUIC connection by 373 generating, receiving, and processing QUIC packets. There are 374 only two types of endpoint in QUIC: client and server. 376 Client: The endpoint initiating a QUIC connection. 378 Server: The endpoint accepting incoming QUIC connections. 380 Address: When used without qualification, the tuple of IP version, 381 IP address, UDP protocol, and UDP port number that represents one 382 end of a network path. 384 Connection ID: An opaque identifier that is used to identify a QUIC 385 connection at an endpoint. Each endpoint sets a value for its 386 peer to include in packets sent towards the endpoint. 388 Stream: A unidirectional or bidirectional channel of ordered bytes 389 within a QUIC connection. A QUIC connection can carry multiple 390 simultaneous streams. 392 Application: An entity that uses QUIC to send and receive data. 394 1.3. Notational Conventions 396 Packet and frame diagrams in this document use the format described 397 in Section 3.1 of [RFC2360], with the following additional 398 conventions: 400 [x]: Indicates that x is optional 402 x (A): Indicates that x is A bits long 404 x (A/B/C) ...: Indicates that x is one of A, B, or C bits long 406 x (i) ...: Indicates that x uses the variable-length encoding in 407 Section 16 409 x (*) ...: Indicates that x is variable-length 411 2. Streams 413 Streams in QUIC provide a lightweight, ordered byte-stream 414 abstraction to an application. Streams can be unidirectional or 415 bidirectional. An alternative view of QUIC unidirectional streams is 416 a "message" abstraction of practically unlimited length. 418 Streams can be created by sending data. Other processes associated 419 with stream management - ending, cancelling, and managing flow 420 control - are all designed to impose minimal overheads. For 421 instance, a single STREAM frame (Section 19.8) can open, carry data 422 for, and close a stream. Streams can also be long-lived and can last 423 the entire duration of a connection. 425 Streams can be created by either endpoint, can concurrently send data 426 interleaved with other streams, and can be cancelled. QUIC does not 427 provide any means of ensuring ordering between bytes on different 428 streams. 430 QUIC allows for an arbitrary number of streams to operate 431 concurrently and for an arbitrary amount of data to be sent on any 432 stream, subject to flow control constraints (see Section 4) and 433 stream limits. 435 2.1. Stream Types and Identifiers 437 Streams can be unidirectional or bidirectional. Unidirectional 438 streams carry data in one direction: from the initiator of the stream 439 to its peer. Bidirectional streams allow for data to be sent in both 440 directions. 442 Streams are identified within a connection by a numeric value, 443 referred to as the stream ID. A stream ID is a 62-bit integer (0 to 444 2^62-1) that is unique for all streams on a connection. Stream IDs 445 are encoded as variable-length integers (see Section 16). A QUIC 446 endpoint MUST NOT reuse a stream ID within a connection. 448 The least significant bit (0x1) of the stream ID identifies the 449 initiator of the stream. Client-initiated streams have even-numbered 450 stream IDs (with the bit set to 0), and server-initiated streams have 451 odd-numbered stream IDs (with the bit set to 1). 453 The second least significant bit (0x2) of the stream ID distinguishes 454 between bidirectional streams (with the bit set to 0) and 455 unidirectional streams (with the bit set to 1). 457 The least significant two bits from a stream ID therefore identify a 458 stream as one of four types, as summarized in Table 1. 460 +------+----------------------------------+ 461 | Bits | Stream Type | 462 +======+==================================+ 463 | 0x0 | Client-Initiated, Bidirectional | 464 +------+----------------------------------+ 465 | 0x1 | Server-Initiated, Bidirectional | 466 +------+----------------------------------+ 467 | 0x2 | Client-Initiated, Unidirectional | 468 +------+----------------------------------+ 469 | 0x3 | Server-Initiated, Unidirectional | 470 +------+----------------------------------+ 472 Table 1: Stream ID Types 474 Within each type, streams are created with numerically increasing 475 stream IDs. A stream ID that is used out of order results in all 476 streams of that type with lower-numbered stream IDs also being 477 opened. 479 The first bidirectional stream opened by the client has a stream ID 480 of 0. 482 2.2. Sending and Receiving Data 484 STREAM frames (Section 19.8) encapsulate data sent by an application. 485 An endpoint uses the Stream ID and Offset fields in STREAM frames to 486 place data in order. 488 Endpoints MUST be able to deliver stream data to an application as an 489 ordered byte-stream. Delivering an ordered byte-stream requires that 490 an endpoint buffer any data that is received out of order, up to the 491 advertised flow control limit. 493 QUIC makes no specific allowances for delivery of stream data out of 494 order. However, implementations MAY choose to offer the ability to 495 deliver data out of order to a receiving application. 497 An endpoint could receive data for a stream at the same stream offset 498 multiple times. Data that has already been received can be 499 discarded. The data at a given offset MUST NOT change if it is sent 500 multiple times; an endpoint MAY treat receipt of different data at 501 the same offset within a stream as a connection error of type 502 PROTOCOL_VIOLATION. 504 Streams are an ordered byte-stream abstraction with no other 505 structure visible to QUIC. STREAM frame boundaries are not expected 506 to be preserved when data is transmitted, retransmitted after packet 507 loss, or delivered to the application at a receiver. 509 An endpoint MUST NOT send data on any stream without ensuring that it 510 is within the flow control limits set by its peer. Flow control is 511 described in detail in Section 4. 513 2.3. Stream Prioritization 515 Stream multiplexing can have a significant effect on application 516 performance if resources allocated to streams are correctly 517 prioritized. 519 QUIC does not provide a mechanism for exchanging prioritization 520 information. Instead, it relies on receiving priority information 521 from the application that uses QUIC. 523 A QUIC implementation SHOULD provide ways in which an application can 524 indicate the relative priority of streams. When deciding which 525 streams to dedicate resources to, the implementation SHOULD use the 526 information provided by the application. 528 2.4. Required Operations on Streams 530 There are certain operations which an application MUST be able to 531 perform when interacting with QUIC streams. This document does not 532 specify an API, but any implementation of this version of QUIC MUST 533 expose the ability to perform the operations described in this 534 section on a QUIC stream. 536 On the sending part of a stream, application protocols need to be 537 able to: 539 * write data, understanding when stream flow control credit 540 (Section 4.1) has successfully been reserved to send the written 541 data; 543 * end the stream (clean termination), resulting in a STREAM frame 544 (Section 19.8) with the FIN bit set; and 546 * reset the stream (abrupt termination), resulting in a RESET_STREAM 547 frame (Section 19.4), if the stream was not already in a terminal 548 state. 550 On the receiving part of a stream, application protocols need to be 551 able to: 553 * read data; and 555 * abort reading of the stream and request closure, possibly 556 resulting in a STOP_SENDING frame (Section 19.5). 558 Applications also need to be informed of state changes on streams, 559 including when the peer has opened or reset a stream, when a peer 560 aborts reading on a stream, when new data is available, and when data 561 can or cannot be written to the stream due to flow control. 563 3. Stream States 565 This section describes streams in terms of their send or receive 566 components. Two state machines are described: one for the streams on 567 which an endpoint transmits data (Section 3.1), and another for 568 streams on which an endpoint receives data (Section 3.2). 570 Unidirectional streams use the applicable state machine directly. 571 Bidirectional streams use both state machines. For the most part, 572 the use of these state machines is the same whether the stream is 573 unidirectional or bidirectional. The conditions for opening a stream 574 are slightly more complex for a bidirectional stream because the 575 opening of either send or receive sides causes the stream to open in 576 both directions. 578 An endpoint MUST open streams of the same type in increasing order of 579 stream ID. 581 Note: These states are largely informative. This document uses 582 stream states to describe rules for when and how different types 583 of frames can be sent and the reactions that are expected when 584 different types of frames are received. Though these state 585 machines are intended to be useful in implementing QUIC, these 586 states aren't intended to constrain implementations. An 587 implementation can define a different state machine as long as its 588 behavior is consistent with an implementation that implements 589 these states. 591 3.1. Sending Stream States 593 Figure 1 shows the states for the part of a stream that sends data to 594 a peer. 596 o 597 | Create Stream (Sending) 598 | Peer Creates Bidirectional Stream 599 v 600 +-------+ 601 | Ready | Send RESET_STREAM 602 | |-----------------------. 603 +-------+ | 604 | | 605 | Send STREAM / | 606 | STREAM_DATA_BLOCKED | 607 | | 608 | Peer Creates | 609 | Bidirectional Stream | 610 v | 611 +-------+ | 612 | Send | Send RESET_STREAM | 613 | |---------------------->| 614 +-------+ | 615 | | 616 | Send STREAM + FIN | 617 v v 618 +-------+ +-------+ 619 | Data | Send RESET_STREAM | Reset | 620 | Sent |------------------>| Sent | 621 +-------+ +-------+ 622 | | 623 | Recv All ACKs | Recv ACK 624 v v 625 +-------+ +-------+ 626 | Data | | Reset | 627 | Recvd | | Recvd | 628 +-------+ +-------+ 630 Figure 1: States for Sending Parts of Streams 632 The sending part of stream that the endpoint initiates (types 0 and 2 633 for clients, 1 and 3 for servers) is opened by the application. The 634 "Ready" state represents a newly created stream that is able to 635 accept data from the application. Stream data might be buffered in 636 this state in preparation for sending. 638 Sending the first STREAM or STREAM_DATA_BLOCKED frame causes a 639 sending part of a stream to enter the "Send" state. An 640 implementation might choose to defer allocating a stream ID to a 641 stream until it sends the first STREAM frame and enters this state, 642 which can allow for better stream prioritization. 644 The sending part of a bidirectional stream initiated by a peer (type 645 0 for a server, type 1 for a client) enters the "Ready" state then 646 immediately transitions to the "Send" state if the receiving part 647 enters the "Recv" state (Section 3.2). 649 In the "Send" state, an endpoint transmits - and retransmits as 650 necessary - stream data in STREAM frames. The endpoint respects the 651 flow control limits set by its peer, and continues to accept and 652 process MAX_STREAM_DATA frames. An endpoint in the "Send" state 653 generates STREAM_DATA_BLOCKED frames if it is blocked from sending by 654 stream or connection flow control limits Section 4.1. 656 After the application indicates that all stream data has been sent 657 and a STREAM frame containing the FIN bit is sent, the sending part 658 of the stream enters the "Data Sent" state. From this state, the 659 endpoint only retransmits stream data as necessary. The endpoint 660 does not need to check flow control limits or send 661 STREAM_DATA_BLOCKED frames for a stream in this state. 662 MAX_STREAM_DATA frames might be received until the peer receives the 663 final stream offset. The endpoint can safely ignore any 664 MAX_STREAM_DATA frames it receives from its peer for a stream in this 665 state. 667 Once all stream data has been successfully acknowledged, the sending 668 part of the stream enters the "Data Recvd" state, which is a terminal 669 state. 671 From any of the "Ready", "Send", or "Data Sent" states, an 672 application can signal that it wishes to abandon transmission of 673 stream data. Alternatively, an endpoint might receive a STOP_SENDING 674 frame from its peer. In either case, the endpoint sends a 675 RESET_STREAM frame, which causes the stream to enter the "Reset Sent" 676 state. 678 An endpoint MAY send a RESET_STREAM as the first frame that mentions 679 a stream; this causes the sending part of that stream to open and 680 then immediately transition to the "Reset Sent" state. 682 Once a packet containing a RESET_STREAM has been acknowledged, the 683 sending part of the stream enters the "Reset Recvd" state, which is a 684 terminal state. 686 3.2. Receiving Stream States 688 Figure 2 shows the states for the part of a stream that receives data 689 from a peer. The states for a receiving part of a stream mirror only 690 some of the states of the sending part of the stream at the peer. 691 The receiving part of a stream does not track states on the sending 692 part that cannot be observed, such as the "Ready" state. Instead, 693 the receiving part of a stream tracks the delivery of data to the 694 application, some of which cannot be observed by the sender. 696 o 697 | Recv STREAM / STREAM_DATA_BLOCKED / RESET_STREAM 698 | Create Bidirectional Stream (Sending) 699 | Recv MAX_STREAM_DATA / STOP_SENDING (Bidirectional) 700 | Create Higher-Numbered Stream 701 v 702 +-------+ 703 | Recv | Recv RESET_STREAM 704 | |-----------------------. 705 +-------+ | 706 | | 707 | Recv STREAM + FIN | 708 v | 709 +-------+ | 710 | Size | Recv RESET_STREAM | 711 | Known |---------------------->| 712 +-------+ | 713 | | 714 | Recv All Data | 715 v v 716 +-------+ Recv RESET_STREAM +-------+ 717 | Data |--- (optional) --->| Reset | 718 | Recvd | Recv All Data | Recvd | 719 +-------+<-- (optional) ----+-------+ 720 | | 721 | App Read All Data | App Read RST 722 v v 723 +-------+ +-------+ 724 | Data | | Reset | 725 | Read | | Read | 726 +-------+ +-------+ 728 Figure 2: States for Receiving Parts of Streams 730 The receiving part of a stream initiated by a peer (types 1 and 3 for 731 a client, or 0 and 2 for a server) is created when the first STREAM, 732 STREAM_DATA_BLOCKED, or RESET_STREAM is received for that stream. 733 For bidirectional streams initiated by a peer, receipt of a 734 MAX_STREAM_DATA or STOP_SENDING frame for the sending part of the 735 stream also creates the receiving part. The initial state for the 736 receiving part of stream is "Recv". 738 The receiving part of a stream enters the "Recv" state when the 739 sending part of a bidirectional stream initiated by the endpoint 740 (type 0 for a client, type 1 for a server) enters the "Ready" state. 742 An endpoint opens a bidirectional stream when a MAX_STREAM_DATA or 743 STOP_SENDING frame is received from the peer for that stream. 744 Receiving a MAX_STREAM_DATA frame for an unopened stream indicates 745 that the remote peer has opened the stream and is providing flow 746 control credit. Receiving a STOP_SENDING frame for an unopened 747 stream indicates that the remote peer no longer wishes to receive 748 data on this stream. Either frame might arrive before a STREAM or 749 STREAM_DATA_BLOCKED frame if packets are lost or reordered. 751 Before a stream is created, all streams of the same type with lower- 752 numbered stream IDs MUST be created. This ensures that the creation 753 order for streams is consistent on both endpoints. 755 In the "Recv" state, the endpoint receives STREAM and 756 STREAM_DATA_BLOCKED frames. Incoming data is buffered and can be 757 reassembled into the correct order for delivery to the application. 758 As data is consumed by the application and buffer space becomes 759 available, the endpoint sends MAX_STREAM_DATA frames to allow the 760 peer to send more data. 762 When a STREAM frame with a FIN bit is received, the final size of the 763 stream is known (see Section 4.4). The receiving part of the stream 764 then enters the "Size Known" state. In this state, the endpoint no 765 longer needs to send MAX_STREAM_DATA frames, it only receives any 766 retransmissions of stream data. 768 Once all data for the stream has been received, the receiving part 769 enters the "Data Recvd" state. This might happen as a result of 770 receiving the same STREAM frame that causes the transition to "Size 771 Known". After all data has been received, any STREAM or 772 STREAM_DATA_BLOCKED frames for the stream can be discarded. 774 The "Data Recvd" state persists until stream data has been delivered 775 to the application. Once stream data has been delivered, the stream 776 enters the "Data Read" state, which is a terminal state. 778 Receiving a RESET_STREAM frame in the "Recv" or "Size Known" states 779 causes the stream to enter the "Reset Recvd" state. This might cause 780 the delivery of stream data to the application to be interrupted. 782 It is possible that all stream data is received when a RESET_STREAM 783 is received (that is, from the "Data Recvd" state). Similarly, it is 784 possible for remaining stream data to arrive after receiving a 785 RESET_STREAM frame (the "Reset Recvd" state). An implementation is 786 free to manage this situation as it chooses. 788 Sending RESET_STREAM means that an endpoint cannot guarantee delivery 789 of stream data; however there is no requirement that stream data not 790 be delivered if a RESET_STREAM is received. An implementation MAY 791 interrupt delivery of stream data, discard any data that was not 792 consumed, and signal the receipt of the RESET_STREAM. A RESET_STREAM 793 signal might be suppressed or withheld if stream data is completely 794 received and is buffered to be read by the application. If the 795 RESET_STREAM is suppressed, the receiving part of the stream remains 796 in "Data Recvd". 798 Once the application receives the signal indicating that the stream 799 was reset, the receiving part of the stream transitions to the "Reset 800 Read" state, which is a terminal state. 802 3.3. Permitted Frame Types 804 The sender of a stream sends just three frame types that affect the 805 state of a stream at either sender or receiver: STREAM 806 (Section 19.8), STREAM_DATA_BLOCKED (Section 19.13), and RESET_STREAM 807 (Section 19.4). 809 A sender MUST NOT send any of these frames from a terminal state 810 ("Data Recvd" or "Reset Recvd"). A sender MUST NOT send STREAM or 811 STREAM_DATA_BLOCKED after sending a RESET_STREAM; that is, in the 812 terminal states and in the "Reset Sent" state. A receiver could 813 receive any of these three frames in any state, due to the 814 possibility of delayed delivery of packets carrying them. 816 The receiver of a stream sends MAX_STREAM_DATA (Section 19.10) and 817 STOP_SENDING frames (Section 19.5). 819 The receiver only sends MAX_STREAM_DATA in the "Recv" state. A 820 receiver can send STOP_SENDING in any state where it has not received 821 a RESET_STREAM frame; that is states other than "Reset Recvd" or 822 "Reset Read". However there is little value in sending a 823 STOP_SENDING frame in the "Data Recvd" state, since all stream data 824 has been received. A sender could receive either of these two frames 825 in any state as a result of delayed delivery of packets. 827 3.4. Bidirectional Stream States 829 A bidirectional stream is composed of sending and receiving parts. 830 Implementations may represent states of the bidirectional stream as 831 composites of sending and receiving stream states. The simplest 832 model presents the stream as "open" when either sending or receiving 833 parts are in a non-terminal state and "closed" when both sending and 834 receiving streams are in terminal states. 836 Table 2 shows a more complex mapping of bidirectional stream states 837 that loosely correspond to the stream states in HTTP/2 [HTTP2]. This 838 shows that multiple states on sending or receiving parts of streams 839 are mapped to the same composite state. Note that this is just one 840 possibility for such a mapping; this mapping requires that data is 841 acknowledged before the transition to a "closed" or "half-closed" 842 state. 844 +----------------------+----------------------+-----------------+ 845 | Sending Part | Receiving Part | Composite State | 846 +======================+======================+=================+ 847 | No Stream/Ready | No Stream/Recv *1 | idle | 848 +----------------------+----------------------+-----------------+ 849 | Ready/Send/Data Sent | Recv/Size Known | open | 850 +----------------------+----------------------+-----------------+ 851 | Ready/Send/Data Sent | Data Recvd/Data Read | half-closed | 852 | | | (remote) | 853 +----------------------+----------------------+-----------------+ 854 | Ready/Send/Data Sent | Reset Recvd/Reset | half-closed | 855 | | Read | (remote) | 856 +----------------------+----------------------+-----------------+ 857 | Data Recvd | Recv/Size Known | half-closed | 858 | | | (local) | 859 +----------------------+----------------------+-----------------+ 860 | Reset Sent/Reset | Recv/Size Known | half-closed | 861 | Recvd | | (local) | 862 +----------------------+----------------------+-----------------+ 863 | Reset Sent/Reset | Data Recvd/Data Read | closed | 864 | Recvd | | | 865 +----------------------+----------------------+-----------------+ 866 | Reset Sent/Reset | Reset Recvd/Reset | closed | 867 | Recvd | Read | | 868 +----------------------+----------------------+-----------------+ 869 | Data Recvd | Data Recvd/Data Read | closed | 870 +----------------------+----------------------+-----------------+ 871 | Data Recvd | Reset Recvd/Reset | closed | 872 | | Read | | 873 +----------------------+----------------------+-----------------+ 875 Table 2: Possible Mapping of Stream States to HTTP/2 877 Note (*1): A stream is considered "idle" if it has not yet been 878 created, or if the receiving part of the stream is in the "Recv" 879 state without yet having received any frames. 881 3.5. Solicited State Transitions 883 If an application is no longer interested in the data it is receiving 884 on a stream, it can abort reading the stream and specify an 885 application error code. 887 If the stream is in the "Recv" or "Size Known" states, the transport 888 SHOULD signal this by sending a STOP_SENDING frame to prompt closure 889 of the stream in the opposite direction. This typically indicates 890 that the receiving application is no longer reading data it receives 891 from the stream, but it is not a guarantee that incoming data will be 892 ignored. 894 STREAM frames received after sending STOP_SENDING are still counted 895 toward connection and stream flow control, even though these frames 896 can be discarded upon receipt. 898 A STOP_SENDING frame requests that the receiving endpoint send a 899 RESET_STREAM frame. An endpoint that receives a STOP_SENDING frame 900 MUST send a RESET_STREAM frame if the stream is in the Ready or Send 901 state. If the stream is in the Data Sent state and any outstanding 902 data is declared lost, an endpoint SHOULD send a RESET_STREAM frame 903 in lieu of a retransmission. 905 An endpoint SHOULD copy the error code from the STOP_SENDING frame to 906 the RESET_STREAM frame it sends, but MAY use any application error 907 code. The endpoint that sends a STOP_SENDING frame MAY ignore the 908 error code carried in any RESET_STREAM frame it receives. 910 If the STOP_SENDING frame is received on a stream that is already in 911 the "Data Sent" state, an endpoint that wishes to cease 912 retransmission of previously-sent STREAM frames on that stream MUST 913 first send a RESET_STREAM frame. 915 STOP_SENDING SHOULD only be sent for a stream that has not been reset 916 by the peer. STOP_SENDING is most useful for streams in the "Recv" 917 or "Size Known" states. 919 An endpoint is expected to send another STOP_SENDING frame if a 920 packet containing a previous STOP_SENDING is lost. However, once 921 either all stream data or a RESET_STREAM frame has been received for 922 the stream - that is, the stream is in any state other than "Recv" or 923 "Size Known" - sending a STOP_SENDING frame is unnecessary. 925 An endpoint that wishes to terminate both directions of a 926 bidirectional stream can terminate one direction by sending a 927 RESET_STREAM, and it can encourage prompt termination in the opposite 928 direction by sending a STOP_SENDING frame. 930 4. Flow Control 932 It is necessary to limit the amount of data that a receiver could 933 buffer, to prevent a fast sender from overwhelming a slow receiver, 934 or to prevent a malicious sender from consuming a large amount of 935 memory at a receiver. To enable a receiver to limit memory 936 commitment to a connection and to apply back pressure on the sender, 937 streams are flow controlled both individually and as an aggregate. A 938 QUIC receiver controls the maximum amount of data the sender can send 939 on a stream at any time, as described in Section 4.1 and Section 4.2 941 Similarly, to limit concurrency within a connection, a QUIC endpoint 942 controls the maximum cumulative number of streams that its peer can 943 initiate, as described in Section 4.5. 945 Data sent in CRYPTO frames is not flow controlled in the same way as 946 stream data. QUIC relies on the cryptographic protocol 947 implementation to avoid excessive buffering of data; see [QUIC-TLS]. 948 The implementation SHOULD provide an interface to QUIC to tell it 949 about its buffering limits so that there is not excessive buffering 950 at multiple layers. 952 4.1. Data Flow Control 954 QUIC employs a credit-based flow-control scheme similar to that in 955 HTTP/2 [HTTP2], where a receiver advertises the number of bytes it is 956 prepared to receive on a given stream and for the entire connection. 957 This leads to two levels of data flow control in QUIC: 959 * Stream flow control, which prevents a single stream from consuming 960 the entire receive buffer for a connection by limiting the amount 961 of data that can be sent on any stream. 963 * Connection flow control, which prevents senders from exceeding a 964 receiver's buffer capacity for the connection, by limiting the 965 total bytes of stream data sent in STREAM frames on all streams. 967 A receiver sets initial credits for all streams by sending transport 968 parameters during the handshake (Section 7.3). A receiver sends 969 MAX_STREAM_DATA (Section 19.10) or MAX_DATA (Section 19.9) frames to 970 the sender to advertise additional credit. 972 A receiver advertises credit for a stream by sending a 973 MAX_STREAM_DATA frame with the Stream ID field set appropriately. A 974 MAX_STREAM_DATA frame indicates the maximum absolute byte offset of a 975 stream. A receiver could use the current offset of data consumed to 976 determine the flow control offset to be advertised. A receiver MAY 977 send MAX_STREAM_DATA frames in multiple packets in order to make sure 978 that the sender receives an update before running out of flow control 979 credit, even if one of the packets is lost. 981 A receiver advertises credit for a connection by sending a MAX_DATA 982 frame, which indicates the maximum of the sum of the absolute byte 983 offsets of all streams. A receiver maintains a cumulative sum of 984 bytes received on all streams, which is used to check for flow 985 control violations. A receiver might use a sum of bytes consumed on 986 all streams to determine the maximum data limit to be advertised. 988 A receiver can advertise a larger offset by sending MAX_STREAM_DATA 989 or MAX_DATA frames. Once a receiver advertises an offset, it MAY 990 advertise a smaller offset, but this has no effect. 992 A receiver MUST close the connection with a FLOW_CONTROL_ERROR error 993 (Section 11) if the sender violates the advertised connection or 994 stream data limits. 996 A sender MUST ignore any MAX_STREAM_DATA or MAX_DATA frames that do 997 not increase flow control limits. 999 If a sender runs out of flow control credit, it will be unable to 1000 send new data and is considered blocked. A sender SHOULD send a 1001 STREAM_DATA_BLOCKED or DATA_BLOCKED frame to indicate it has data to 1002 write but is blocked by flow control limits. If a sender is blocked 1003 for a period longer than the idle timeout (Section 10.2), the 1004 connection might be closed even when data is available for 1005 transmission. To keep the connection from closing, a sender that is 1006 flow control limited SHOULD periodically send a STREAM_DATA_BLOCKED 1007 or DATA_BLOCKED frame when it has no ack-eliciting packets in flight. 1009 4.2. Flow Credit Increments 1011 This document leaves when and how many bytes to advertise in a 1012 MAX_STREAM_DATA or MAX_DATA frame to implementations, but offers a 1013 few considerations. These frames contribute to connection overhead. 1014 Therefore frequently sending frames with small changes is 1015 undesirable. At the same time, larger increments to limits are 1016 necessary to avoid blocking if updates are less frequent, requiring 1017 larger resource commitments at the receiver. Thus there is a trade- 1018 off between resource commitment and overhead when determining how 1019 large a limit is advertised. 1021 A receiver can use an autotuning mechanism to tune the frequency and 1022 amount of advertised additional credit based on a round-trip time 1023 estimate and the rate at which the receiving application consumes 1024 data, similar to common TCP implementations. As an optimization, 1025 sending frames related to flow control only when there are other 1026 frames to send or when a peer is blocked ensures that flow control 1027 doesn't cause extra packets to be sent. 1029 If a sender runs out of flow control credit, it will be unable to 1030 send new data and is considered blocked. It is generally considered 1031 best to not let the sender become blocked. To avoid blocking a 1032 sender, and to reasonably account for the possibility of loss, a 1033 receiver should send a MAX_DATA or MAX_STREAM_DATA frame at least two 1034 round trips before it expects the sender to get blocked. 1036 A receiver MUST NOT wait for a STREAM_DATA_BLOCKED or DATA_BLOCKED 1037 frame before sending MAX_STREAM_DATA or MAX_DATA, since doing so will 1038 mean that a sender will be blocked for at least an entire round trip, 1039 and potentially for longer if the peer chooses to not send 1040 STREAM_DATA_BLOCKED or DATA_BLOCKED frames. 1042 4.3. Handling Stream Cancellation 1044 Endpoints need to eventually agree on the amount of flow control 1045 credit that has been consumed, to avoid either exceeding flow control 1046 limits or deadlocking. 1048 On receipt of a RESET_STREAM frame, an endpoint will tear down state 1049 for the matching stream and ignore further data arriving on that 1050 stream. Without the offset included in RESET_STREAM, the two 1051 endpoints could disagree on the number of bytes that count towards 1052 connection flow control. 1054 To remedy this issue, a RESET_STREAM frame (Section 19.4) includes 1055 the final size of data sent on the stream. On receiving a 1056 RESET_STREAM frame, a receiver definitively knows how many bytes were 1057 sent on that stream before the RESET_STREAM frame, and the receiver 1058 MUST use the final size of the stream to account for all bytes sent 1059 on the stream in its connection level flow controller. 1061 RESET_STREAM terminates one direction of a stream abruptly. For a 1062 bidirectional stream, RESET_STREAM has no effect on data flow in the 1063 opposite direction. Both endpoints MUST maintain flow control state 1064 for the stream in the unterminated direction until that direction 1065 enters a terminal state, or until one of the endpoints sends 1066 CONNECTION_CLOSE. 1068 4.4. Stream Final Size 1070 The final size is the amount of flow control credit that is consumed 1071 by a stream. Assuming that every contiguous byte on the stream was 1072 sent once, the final size is the number of bytes sent. More 1073 generally, this is one higher than the offset of the byte with the 1074 largest offset sent on the stream, or zero if no bytes were sent. 1076 For a stream that is reset, the final size is carried explicitly in a 1077 RESET_STREAM frame. Otherwise, the final size is the offset plus the 1078 length of a STREAM frame marked with a FIN flag, or 0 in the case of 1079 incoming unidirectional streams. 1081 An endpoint will know the final size for a stream when the receiving 1082 part of the stream enters the "Size Known" or "Reset Recvd" state 1083 (Section 3). 1085 An endpoint MUST NOT send data on a stream at or beyond the final 1086 size. 1088 Once a final size for a stream is known, it cannot change. If a 1089 RESET_STREAM or STREAM frame is received indicating a change in the 1090 final size for the stream, an endpoint SHOULD respond with a 1091 FINAL_SIZE_ERROR error (see Section 11). A receiver SHOULD treat 1092 receipt of data at or beyond the final size as a FINAL_SIZE_ERROR 1093 error, even after a stream is closed. Generating these errors is not 1094 mandatory, but only because requiring that an endpoint generate these 1095 errors also means that the endpoint needs to maintain the final size 1096 state for closed streams, which could mean a significant state 1097 commitment. 1099 4.5. Controlling Concurrency 1101 An endpoint limits the cumulative number of incoming streams a peer 1102 can open. Only streams with a stream ID less than (max_stream * 4 + 1103 initial_stream_id_for_type) can be opened (see Table 5). Initial 1104 limits are set in the transport parameters (see Section 18.2) and 1105 subsequently limits are advertised using MAX_STREAMS frames 1106 (Section 19.11). Separate limits apply to unidirectional and 1107 bidirectional streams. 1109 If a max_streams transport parameter or MAX_STREAMS frame is received 1110 with a value greater than 2^60, this would allow a maximum stream ID 1111 that cannot be expressed as a variable-length integer (see 1112 Section 16). If either is received, the connection MUST be closed 1113 immediately with a connection error of type STREAM_LIMIT_ERROR (see 1114 Section 10.3). 1116 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 1117 that receives a frame with a stream ID exceeding the limit it has 1118 sent MUST treat this as a connection error of type STREAM_LIMIT_ERROR 1119 (Section 11). 1121 Once a receiver advertises a stream limit using the MAX_STREAMS 1122 frame, advertising a smaller limit has no effect. A receiver MUST 1123 ignore any MAX_STREAMS frame that does not increase the stream limit. 1125 As with stream and connection flow control, this document leaves when 1126 and how many streams to advertise to a peer via MAX_STREAMS to 1127 implementations. Implementations might choose to increase limits as 1128 streams close to keep the number of streams available to peers 1129 roughly consistent. 1131 An endpoint that is unable to open a new stream due to the peer's 1132 limits SHOULD send a STREAMS_BLOCKED frame (Section 19.14). This 1133 signal is considered useful for debugging. An endpoint MUST NOT wait 1134 to receive this signal before advertising additional credit, since 1135 doing so will mean that the peer will be blocked for at least an 1136 entire round trip, and potentially for longer if the peer chooses to 1137 not send STREAMS_BLOCKED frames. 1139 5. Connections 1141 QUIC's connection establishment combines version negotiation with the 1142 cryptographic and transport handshakes to reduce connection 1143 establishment latency, as described in Section 7. Once established, 1144 a connection may migrate to a different IP or port at either endpoint 1145 as described in Section 9. Finally, a connection may be terminated 1146 by either endpoint, as described in Section 10. 1148 5.1. Connection ID 1150 Each connection possesses a set of connection identifiers, or 1151 connection IDs, each of which can identify the connection. 1152 Connection IDs are independently selected by endpoints; each endpoint 1153 selects the connection IDs that its peer uses. 1155 The primary function of a connection ID is to ensure that changes in 1156 addressing at lower protocol layers (UDP, IP) don't cause packets for 1157 a QUIC connection to be delivered to the wrong endpoint. Each 1158 endpoint selects connection IDs using an implementation-specific (and 1159 perhaps deployment-specific) method which will allow packets with 1160 that connection ID to be routed back to the endpoint and identified 1161 by the endpoint upon receipt. 1163 Connection IDs MUST NOT contain any information that can be used by 1164 an external observer (that is, one that does not cooperate with the 1165 issuer) to correlate them with other connection IDs for the same 1166 connection. As a trivial example, this means the same connection ID 1167 MUST NOT be issued more than once on the same connection. 1169 Packets with long headers include Source Connection ID and 1170 Destination Connection ID fields. These fields are used to set the 1171 connection IDs for new connections; see Section 7.2 for details. 1173 Packets with short headers (Section 17.3) only include the 1174 Destination Connection ID and omit the explicit length. The length 1175 of the Destination Connection ID field is expected to be known to 1176 endpoints. Endpoints using a load balancer that routes based on 1177 connection ID could agree with the load balancer on a fixed length 1178 for connection IDs, or agree on an encoding scheme. A fixed portion 1179 could encode an explicit length, which allows the entire connection 1180 ID to vary in length and still be used by the load balancer. 1182 A Version Negotiation (Section 17.2.1) packet echoes the connection 1183 IDs selected by the client, both to ensure correct routing toward the 1184 client and to allow the client to validate that the packet is in 1185 response to an Initial packet. 1187 A zero-length connection ID can be used when a connection ID is not 1188 needed to route to the correct endpoint. However, multiplexing 1189 connections on the same local IP address and port while using zero- 1190 length connection IDs will cause failures in the presence of peer 1191 connection migration, NAT rebinding, and client port reuse; and 1192 therefore MUST NOT be done unless an endpoint is certain that those 1193 protocol features are not in use. 1195 When an endpoint uses a non-zero-length connection ID, it needs to 1196 ensure that the peer has a supply of connection IDs from which to 1197 choose for packets sent to the endpoint. These connection IDs are 1198 supplied by the endpoint using the NEW_CONNECTION_ID frame 1199 (Section 19.15). 1201 5.1.1. Issuing Connection IDs 1203 Each Connection ID has an associated sequence number to assist in 1204 deduplicating messages. The initial connection ID issued by an 1205 endpoint is sent in the Source Connection ID field of the long packet 1206 header (Section 17.2) during the handshake. The sequence number of 1207 the initial connection ID is 0. If the preferred_address transport 1208 parameter is sent, the sequence number of the supplied connection ID 1209 is 1. 1211 Additional connection IDs are communicated to the peer using 1212 NEW_CONNECTION_ID frames (Section 19.15). The sequence number on 1213 each newly-issued connection ID MUST increase by 1. The connection 1214 ID randomly selected by the client in the Initial packet and any 1215 connection ID provided by a Retry packet are not assigned sequence 1216 numbers unless a server opts to retain them as its initial connection 1217 ID. 1219 When an endpoint issues a connection ID, it MUST accept packets that 1220 carry this connection ID for the duration of the connection or until 1221 its peer invalidates the connection ID via a RETIRE_CONNECTION_ID 1222 frame (Section 19.16). Connection IDs that are issued and not 1223 retired are considered active; any active connection ID can be used. 1225 An endpoint SHOULD ensure that its peer has a sufficient number of 1226 available and unused connection IDs. Endpoints store received 1227 connection IDs for future use and advertise the number of connection 1228 IDs they are willing to store with the active_connection_id_limit 1229 transport parameter. An endpoint MUST NOT provide more connection 1230 IDs than the peer's limit. An endpoint that receives more connection 1231 IDs than its advertised active_connection_id_limit MUST close the 1232 connection with an error of type CONNECTION_ID_LIMIT_ERROR. 1234 An endpoint SHOULD supply a new connection ID when the peer retires a 1235 connection ID. If an endpoint provided fewer connection IDs than the 1236 peer's active_connection_id_limit, it MAY supply a new connection ID 1237 when it receives a packet with a previously unused connection ID. An 1238 endpoint MAY limit the frequency or the total number of connection 1239 IDs issued for each connection to avoid the risk of running out of 1240 connection IDs; see Section 10.4.2. 1242 An endpoint that initiates migration and requires non-zero-length 1243 connection IDs SHOULD ensure that the pool of connection IDs 1244 available to its peer allows the peer to use a new connection ID on 1245 migration, as the peer will close the connection if the pool is 1246 exhausted. 1248 5.1.2. Consuming and Retiring Connection IDs 1250 An endpoint can change the connection ID it uses for a peer to 1251 another available one at any time during the connection. An endpoint 1252 consumes connection IDs in response to a migrating peer; see 1253 Section 9.5 for more. 1255 An endpoint maintains a set of connection IDs received from its peer, 1256 any of which it can use when sending packets. When the endpoint 1257 wishes to remove a connection ID from use, it sends a 1258 RETIRE_CONNECTION_ID frame to its peer. Sending a 1259 RETIRE_CONNECTION_ID frame indicates that the connection ID will not 1260 be used again and requests that the peer replace it with a new 1261 connection ID using a NEW_CONNECTION_ID frame. 1263 As discussed in Section 9.5, each connection ID MUST be used on 1264 packets sent from only one local address. An endpoint that migrates 1265 away from a local address SHOULD retire all connection IDs used on 1266 that address once it no longer plans to use that address. 1268 An endpoint can cause its peer to retire connection IDs by sending a 1269 NEW_CONNECTION_ID frame with an increased Retire Prior To field. 1270 Upon receipt, the peer MUST first retire the corresponding connection 1271 IDs using RETIRE_CONNECTION_ID frames and then add the newly provided 1272 connection ID to the set of active connection IDs. Failure to retire 1273 the connection IDs within approximately one PTO can cause packets to 1274 be delayed, lost, or cause the original endpoint to send a stateless 1275 reset in response to a connection ID it can no longer route 1276 correctly. 1278 An endpoint MAY discard a connection ID for which retirement has been 1279 requested once an interval of no less than 3 PTO has elapsed since an 1280 acknowledgement is received for the NEW_CONNECTION_ID frame 1281 requesting that retirement. Until then, the endpoint SHOULD be 1282 prepared to receive packets that contain the connection ID that it 1283 has requested be retired. Subsequent incoming packets using that 1284 connection ID could elicit a response with the corresponding 1285 stateless reset token. 1287 5.2. Matching Packets to Connections 1289 Incoming packets are classified on receipt. Packets can either be 1290 associated with an existing connection, or - for servers - 1291 potentially create a new connection. 1293 Endpoints try to associate a packet with an existing connection. If 1294 the packet has a non-zero-length Destination Connection ID 1295 corresponding to an existing connection, QUIC processes that packet 1296 accordingly. Note that more than one connection ID can be associated 1297 with a connection; see Section 5.1. 1299 If the Destination Connection ID is zero length and the addressing 1300 information in the packet matches the addressing information the 1301 endpoint uses to identify a connection with a zero-length connection 1302 ID, QUIC processes the packet as part of that connection. An 1303 endpoint can use just destination IP and port or both source and 1304 destination addresses for identification, though this makes 1305 connections fragile as described in Section 5.1. 1307 Endpoints can send a Stateless Reset (Section 10.4) for any packets 1308 that cannot be attributed to an existing connection. A stateless 1309 reset allows a peer to more quickly identify when a connection 1310 becomes unusable. 1312 Packets that are matched to an existing connection are discarded if 1313 the packets are inconsistent with the state of that connection. For 1314 example, packets are discarded if they indicate a different protocol 1315 version than that of the connection, or if the removal of packet 1316 protection is unsuccessful once the expected keys are available. 1318 Invalid packets without packet protection, such as Initial, Retry, or 1319 Version Negotiation, MAY be discarded. An endpoint MUST generate a 1320 connection error if it commits changes to state before discovering an 1321 error. 1323 5.2.1. Client Packet Handling 1325 Valid packets sent to clients always include a Destination Connection 1326 ID that matches a value the client selects. Clients that choose to 1327 receive zero-length connection IDs can use the local address and port 1328 to identify a connection. Packets that don't match an existing 1329 connection are discarded. 1331 Due to packet reordering or loss, a client might receive packets for 1332 a connection that are encrypted with a key it has not yet computed. 1333 The client MAY drop these packets, or MAY buffer them in anticipation 1334 of later packets that allow it to compute the key. 1336 If a client receives a packet that has an unsupported version, it 1337 MUST discard that packet. 1339 5.2.2. Server Packet Handling 1341 If a server receives a packet that has an unsupported version, but 1342 the packet is sufficiently large to initiate a new connection for any 1343 version supported by the server, it SHOULD send a Version Negotiation 1344 packet as described in Section 6.1. Servers MAY rate control these 1345 packets to avoid storms of Version Negotiation packets. Otherwise, 1346 servers MUST drop packets that specify unsupported versions. 1348 The first packet for an unsupported version can use different 1349 semantics and encodings for any version-specific field. In 1350 particular, different packet protection keys might be used for 1351 different versions. Servers that do not support a particular version 1352 are unlikely to be able to decrypt the payload of the packet. 1353 Servers SHOULD NOT attempt to decode or decrypt a packet from an 1354 unknown version, but instead send a Version Negotiation packet, 1355 provided that the packet is sufficiently long. 1357 Packets with a supported version, or no version field, are matched to 1358 a connection using the connection ID or - for packets with zero- 1359 length connection IDs - the local address and port. If the packet 1360 doesn't match an existing connection, the server continues below. 1362 If the packet is an Initial packet fully conforming with the 1363 specification, the server proceeds with the handshake (Section 7). 1364 This commits the server to the version that the client selected. 1366 If a server isn't currently accepting any new connections, it SHOULD 1367 send an Initial packet containing a CONNECTION_CLOSE frame with error 1368 code SERVER_BUSY. 1370 If the packet is a 0-RTT packet, the server MAY buffer a limited 1371 number of these packets in anticipation of a late-arriving Initial 1372 packet. Clients are not able to send Handshake packets prior to 1373 receiving a server response, so servers SHOULD ignore any such 1374 packets. 1376 Servers MUST drop incoming packets under all other circumstances. 1378 5.3. Life of a QUIC Connection 1380 A QUIC connection is a stateful interaction between a client and 1381 server, the primary purpose of which is to support the exchange of 1382 data by an application protocol. Streams (Section 2) are the primary 1383 means by which an application protocol exchanges information. 1385 Each connection starts with a handshake phase, during which client 1386 and server establish a shared secret using the cryptographic 1387 handshake protocol [QUIC-TLS] and negotiate the application protocol. 1388 The handshake (Section 7) confirms that both endpoints are willing to 1389 communicate (Section 8.1) and establishes parameters for the 1390 connection (Section 7.3). 1392 An application protocol can also operate in a limited fashion during 1393 the handshake phase. 0-RTT allows application messages to be sent by 1394 a client before receiving any messages from the server. However, 1395 0-RTT lacks certain key security guarantees. In particular, there is 1396 no protection against replay attacks in 0-RTT; see [QUIC-TLS]. 1397 Separately, a server can also send application data to a client 1398 before it receives the final cryptographic handshake messages that 1399 allow it to confirm the identity and liveness of the client. These 1400 capabilities allow an application protocol to offer the option to 1401 trade some security guarantees for reduced latency. 1403 The use of connection IDs (Section 5.1) allows connections to migrate 1404 to a new network path, both as a direct choice of an endpoint and 1405 when forced by a change in a middlebox. Section 9 describes 1406 mitigations for the security and privacy issues associated with 1407 migration. 1409 For connections that are no longer needed or desired, there are 1410 several ways for a client and server to terminate a connection 1411 (Section 10). 1413 5.4. Required Operations on Connections 1415 There are certain operations which an application MUST be able to 1416 perform when interacting with the QUIC transport. This document does 1417 not specify an API, but any implementation of this version of QUIC 1418 MUST expose the ability to perform the operations described in this 1419 section on a QUIC connection. 1421 When implementing the client role, applications need to be able to: 1423 * open a connection, which begins the exchange described in 1424 Section 7; 1426 * enable 0-RTT when available; and 1428 * be informed when 0-RTT has been accepted or rejected by a server. 1430 When implementing the server role, applications need to be able to: 1432 * listen for incoming connections, which prepares for the exchange 1433 described in Section 7; 1435 * if Early Data is supported, embed application-controlled data in 1436 the TLS resumption ticket sent to the client; and 1438 * if Early Data is supported, retrieve application-controlled data 1439 from the client's resumption ticket and enable rejecting Early 1440 Data based on that information. 1442 In either role, applications need to be able to: 1444 * configure minimum values for the initial number of permitted 1445 streams of each type, as communicated in the transport parameters 1446 (Section 7.3); 1448 * control resource allocation of various types, including flow 1449 control and the number of permitted streams of each type; 1451 * identify whether the handshake has completed successfully or is 1452 still ongoing 1454 * keep a connection from silently closing, either by generating PING 1455 frames (Section 19.2) or by requesting that the transport send 1456 additional frames before the idle timeout expires (Section 10.2); 1457 and 1459 * immediately close (Section 10.3) the connection. 1461 6. Version Negotiation 1463 Version negotiation ensures that client and server agree to a QUIC 1464 version that is mutually supported. A server sends a Version 1465 Negotiation packet in response to each packet that might initiate a 1466 new connection; see Section 5.2 for details. 1468 The size of the first packet sent by a client will determine whether 1469 a server sends a Version Negotiation packet. Clients that support 1470 multiple QUIC versions SHOULD pad the first packet they send to the 1471 largest of the minimum packet sizes across all versions they support. 1472 This ensures that the server responds if there is a mutually 1473 supported version. 1475 6.1. Sending Version Negotiation Packets 1477 If the version selected by the client is not acceptable to the 1478 server, the server responds with a Version Negotiation packet (see 1479 Section 17.2.1). This includes a list of versions that the server 1480 will accept. An endpoint MUST NOT send a Version Negotiation packet 1481 in response to receiving a Version Negotiation packet. 1483 This system allows a server to process packets with unsupported 1484 versions without retaining state. Though either the Initial packet 1485 or the Version Negotiation packet that is sent in response could be 1486 lost, the client will send new packets until it successfully receives 1487 a response or it abandons the connection attempt. As a result, the 1488 client discards all state for the connection and does not send any 1489 more packets on the connection. 1491 A server MAY limit the number of Version Negotiation packets it 1492 sends. For instance, a server that is able to recognize packets as 1493 0-RTT might choose not to send Version Negotiation packets in 1494 response to 0-RTT packets with the expectation that it will 1495 eventually receive an Initial packet. 1497 6.2. Handling Version Negotiation Packets 1499 When a client receives a Version Negotiation packet, it MUST abandon 1500 the current connection attempt. Version Negotiation packets are 1501 designed to allow future versions of QUIC to negotiate the version in 1502 use between endpoints. Future versions of QUIC might change how 1503 implementations that support multiple versions of QUIC react to 1504 Version Negotiation packets when attempting to establish a connection 1505 using this version. How to perform version negotiation is left as 1506 future work defined by future versions of QUIC. In particular, that 1507 future work will need to ensure robustness against version downgrade 1508 attacks; see Section 21.10. 1510 6.2.1. Version Negotiation Between Draft Versions 1512 [[RFC editor: please remove this section before publication.]] 1514 When a draft implementation receives a Version Negotiation packet, it 1515 MAY use it to attempt a new connection with one of the versions 1516 listed in the packet, instead of abandoning the current connection 1517 attempt; see Section 6.2. 1519 The client MUST check that the Destination and Source Connection ID 1520 fields match the Source and Destination Connection ID fields in a 1521 packet that the client sent. If this check fails, the packet MUST be 1522 discarded. 1524 Once the Version Negotiation packet is determined to be valid, the 1525 client then selects an acceptable protocol version from the list 1526 provided by the server. The client then attempts to create a new 1527 connection using that version. The new connection MUST use a new 1528 random Destination Connection ID different from the one it had 1529 previously sent. 1531 Note that this mechanism does not protect against downgrade attacks 1532 and MUST NOT be used outside of draft implementations. 1534 6.3. Using Reserved Versions 1536 For a server to use a new version in the future, clients need to 1537 correctly handle unsupported versions. To help ensure this, a server 1538 SHOULD include a version that is reserved for forcing version 1539 negotiation (0x?a?a?a?a as defined in Section 15) when generating a 1540 Version Negotiation packet. 1542 The design of version negotiation permits a server to avoid 1543 maintaining state for packets that it rejects in this fashion. 1545 A client MAY send a packet using a version that is reserved for 1546 forcing version negotiation. This can be used to solicit a list of 1547 supported versions from a server. 1549 7. Cryptographic and Transport Handshake 1551 QUIC relies on a combined cryptographic and transport handshake to 1552 minimize connection establishment latency. QUIC uses the CRYPTO 1553 frame Section 19.6 to transmit the cryptographic handshake. Version 1554 0x00000001 of QUIC uses TLS as described in [QUIC-TLS]; a different 1555 QUIC version number could indicate that a different cryptographic 1556 handshake protocol is in use. 1558 QUIC provides reliable, ordered delivery of the cryptographic 1559 handshake data. QUIC packet protection is used to encrypt as much of 1560 the handshake protocol as possible. The cryptographic handshake MUST 1561 provide the following properties: 1563 * authenticated key exchange, where 1565 - a server is always authenticated, 1567 - a client is optionally authenticated, 1569 - every connection produces distinct and unrelated keys, 1571 - keying material is usable for packet protection for both 0-RTT 1572 and 1-RTT packets, and 1574 - 1-RTT keys have forward secrecy 1576 * authenticated values for transport parameters of both endpoints, 1577 and confidentiality protection for server transport parameters 1578 (see Section 7.3) 1580 * authenticated negotiation of an application protocol (TLS uses 1581 ALPN [RFC7301] for this purpose) 1583 An endpoint can verify support for Explicit Congestion Notification 1584 (ECN) in the first packets it sends, as described in Section 13.4.2. 1586 The CRYPTO frame can be sent in different packet number spaces. The 1587 sequence numbers used by CRYPTO frames to ensure ordered delivery of 1588 cryptographic handshake data start from zero in each packet number 1589 space. 1591 Endpoints MUST explicitly negotiate an application protocol. This 1592 avoids situations where there is a disagreement about the protocol 1593 that is in use. 1595 7.1. Example Handshake Flows 1597 Details of how TLS is integrated with QUIC are provided in 1598 [QUIC-TLS], but some examples are provided here. An extension of 1599 this exchange to support client address validation is shown in 1600 Section 8.1.2. 1602 Once any address validation exchanges are complete, the cryptographic 1603 handshake is used to agree on cryptographic keys. The cryptographic 1604 handshake is carried in Initial (Section 17.2.2) and Handshake 1605 (Section 17.2.4) packets. 1607 Figure 3 provides an overview of the 1-RTT handshake. Each line 1608 shows a QUIC packet with the packet type and packet number shown 1609 first, followed by the frames that are typically contained in those 1610 packets. So, for instance the first packet is of type Initial, with 1611 packet number 0, and contains a CRYPTO frame carrying the 1612 ClientHello. 1614 Note that multiple QUIC packets - even of different encryption levels 1615 - may be coalesced into a single UDP datagram (see Section 12.2), and 1616 so this handshake may consist of as few as 4 UDP datagrams, or any 1617 number more. For instance, the server's first flight contains 1618 packets from the Initial encryption level (obfuscation), the 1619 Handshake level, and "0.5-RTT data" from the server at the 1-RTT 1620 encryption level. 1622 Client Server 1624 Initial[0]: CRYPTO[CH] -> 1626 Initial[0]: CRYPTO[SH] ACK[0] 1627 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1628 <- 1-RTT[0]: STREAM[1, "..."] 1630 Initial[1]: ACK[0] 1631 Handshake[0]: CRYPTO[FIN], ACK[0] 1632 1-RTT[0]: STREAM[0, "..."], ACK[0] -> 1634 1-RTT[1]: STREAM[3, "..."], ACK[0] 1635 <- Handshake[1]: ACK[0] 1637 Figure 3: Example 1-RTT Handshake 1639 Figure 4 shows an example of a connection with a 0-RTT handshake and 1640 a single packet of 0-RTT data. Note that as described in 1641 Section 12.3, the server acknowledges 0-RTT data at the 1-RTT 1642 encryption level, and the client sends 1-RTT packets in the same 1643 packet number space. 1645 Client Server 1647 Initial[0]: CRYPTO[CH] 1648 0-RTT[0]: STREAM[0, "..."] -> 1650 Initial[0]: CRYPTO[SH] ACK[0] 1651 Handshake[0] CRYPTO[EE, FIN] 1652 <- 1-RTT[0]: STREAM[1, "..."] ACK[0] 1654 Initial[1]: ACK[0] 1655 Handshake[0]: CRYPTO[FIN], ACK[0] 1656 1-RTT[1]: STREAM[0, "..."] ACK[0] -> 1658 1-RTT[1]: STREAM[3, "..."], ACK[1] 1659 <- Handshake[1]: ACK[0] 1661 Figure 4: Example 0-RTT Handshake 1663 7.2. Negotiating Connection IDs 1665 A connection ID is used to ensure consistent routing of packets, as 1666 described in Section 5.1. The long header contains two connection 1667 IDs: the Destination Connection ID is chosen by the recipient of the 1668 packet and is used to provide consistent routing; the Source 1669 Connection ID is used to set the Destination Connection ID used by 1670 the peer. 1672 During the handshake, packets with the long header (Section 17.2) are 1673 used to establish the connection ID that each endpoint uses. Each 1674 endpoint uses the Source Connection ID field to specify the 1675 connection ID that is used in the Destination Connection ID field of 1676 packets being sent to them. Upon receiving a packet, each endpoint 1677 sets the Destination Connection ID it sends to match the value of the 1678 Source Connection ID that they receive. 1680 When an Initial packet is sent by a client that has not previously 1681 received an Initial or Retry packet from the server, it populates the 1682 Destination Connection ID field with an unpredictable value. This 1683 MUST be at least 8 bytes in length. Until a packet is received from 1684 the server, the client MUST use the same value unless it abandons the 1685 connection attempt and starts a new one. The initial Destination 1686 Connection ID is used to determine packet protection keys for Initial 1687 packets. 1689 The client populates the Source Connection ID field with a value of 1690 its choosing and sets the SCID Len field to indicate the length. 1692 The first flight of 0-RTT packets use the same Destination and Source 1693 Connection ID values as the client's first Initial. 1695 Upon first receiving an Initial or Retry packet from the server, the 1696 client uses the Source Connection ID supplied by the server as the 1697 Destination Connection ID for subsequent packets, including any 1698 subsequent 0-RTT packets. That means that a client might change the 1699 Destination Connection ID twice during connection establishment, once 1700 in response to a Retry and once in response to the first Initial 1701 packet from the server. Once a client has received an Initial packet 1702 from the server, it MUST discard any packet it receives with a 1703 different Source Connection ID. 1705 A client MUST only change the value it sends in the Destination 1706 Connection ID in response to the first packet of each type it 1707 receives from the server (Retry or Initial); a server MUST set its 1708 value based on the Initial packet. Any additional changes are not 1709 permitted; if subsequent packets of those types include a different 1710 Source Connection ID, they MUST be discarded. This avoids problems 1711 that might arise from stateless processing of multiple Initial 1712 packets producing different connection IDs. 1714 The connection ID can change over the lifetime of a connection, 1715 especially in response to connection migration (Section 9); see 1716 Section 5.1.1 for details. 1718 7.3. Transport Parameters 1720 During connection establishment, both endpoints make authenticated 1721 declarations of their transport parameters. These declarations are 1722 made unilaterally by each endpoint. Endpoints are required to comply 1723 with the restrictions implied by these parameters; the description of 1724 each parameter includes rules for its handling. 1726 The encoding of the transport parameters is detailed in Section 18. 1728 QUIC includes the encoded transport parameters in the cryptographic 1729 handshake. Once the handshake completes, the transport parameters 1730 declared by the peer are available. Each endpoint validates the 1731 value provided by its peer. 1733 Definitions for each of the defined transport parameters are included 1734 in Section 18.2. 1736 An endpoint MUST treat receipt of a transport parameter with an 1737 invalid value as a connection error of type 1738 TRANSPORT_PARAMETER_ERROR. 1740 An endpoint MUST NOT send a parameter more than once in a given 1741 transport parameters extension. An endpoint SHOULD treat receipt of 1742 duplicate transport parameters as a connection error of type 1743 TRANSPORT_PARAMETER_ERROR. 1745 A server MUST include the original_connection_id transport parameter 1746 (Section 18.2) if it sent a Retry packet to enable validation of the 1747 Retry, as described in Section 17.2.5. 1749 7.3.1. Values of Transport Parameters for 0-RTT 1751 Both endpoints store the value of the server transport parameters 1752 from a connection and apply them to any 0-RTT packets that are sent 1753 in subsequent connections to that peer, except for transport 1754 parameters that are explicitly excluded. Remembered transport 1755 parameters apply to the new connection until the handshake completes 1756 and the client starts sending 1-RTT packets. Once the handshake 1757 completes, the client uses the transport parameters established in 1758 the handshake. 1760 The definition of new transport parameters (Section 7.3.2) MUST 1761 specify whether they MUST, MAY, or MUST NOT be stored for 0-RTT. A 1762 client need not store a transport parameter it cannot process. 1764 A client MUST NOT use remembered values for the following parameters: 1765 original_connection_id, preferred_address, stateless_reset_token, 1766 ack_delay_exponent and active_connection_id_limit. The client MUST 1767 use the server's new values in the handshake instead, and absent new 1768 values from the server, the default value. 1770 A client that attempts to send 0-RTT data MUST remember all other 1771 transport parameters used by the server. The server can remember 1772 these transport parameters, or store an integrity-protected copy of 1773 the values in the ticket and recover the information when accepting 1774 0-RTT data. A server uses the transport parameters in determining 1775 whether to accept 0-RTT data. 1777 If 0-RTT data is accepted by the server, the server MUST NOT reduce 1778 any limits or alter any values that might be violated by the client 1779 with its 0-RTT data. In particular, a server that accepts 0-RTT data 1780 MUST NOT set values for the following parameters (Section 18.2) that 1781 are smaller than the remembered value of the parameters. 1783 * initial_max_data 1785 * initial_max_stream_data_bidi_local 1787 * initial_max_stream_data_bidi_remote 1789 * initial_max_stream_data_uni 1791 * initial_max_streams_bidi 1793 * initial_max_streams_uni 1795 Omitting or setting a zero value for certain transport parameters can 1796 result in 0-RTT data being enabled, but not usable. The applicable 1797 subset of transport parameters that permit sending of application 1798 data SHOULD be set to non-zero values for 0-RTT. This includes 1799 initial_max_data and either initial_max_streams_bidi and 1800 initial_max_stream_data_bidi_remote, or initial_max_streams_uni and 1801 initial_max_stream_data_uni. 1803 A server MUST either reject 0-RTT data or abort a handshake if the 1804 implied values for transport parameters cannot be supported. 1806 When sending frames in 0-RTT packets, a client MUST only use 1807 remembered transport parameters; importantly, it MUST NOT use updated 1808 values that it learns from the server's updated transport parameters 1809 or from frames received in 1-RTT packets. Updated values of 1810 transport parameters from the handshake apply only to 1-RTT packets. 1811 For instance, flow control limits from remembered transport 1812 parameters apply to all 0-RTT packets even if those values are 1813 increased by the handshake or by frames sent in 1-RTT packets. A 1814 server MAY treat use of updated transport parameters in 0-RTT as a 1815 connection error of type PROTOCOL_VIOLATION. 1817 7.3.2. New Transport Parameters 1819 New transport parameters can be used to negotiate new protocol 1820 behavior. An endpoint MUST ignore transport parameters that it does 1821 not support. Absence of a transport parameter therefore disables any 1822 optional protocol feature that is negotiated using the parameter. As 1823 described in Section 18.1, some identifiers are reserved in order to 1824 exercise this requirement. 1826 New transport parameters can be registered according to the rules in 1827 Section 22.2. 1829 7.4. Cryptographic Message Buffering 1831 Implementations need to maintain a buffer of CRYPTO data received out 1832 of order. Because there is no flow control of CRYPTO frames, an 1833 endpoint could potentially force its peer to buffer an unbounded 1834 amount of data. 1836 Implementations MUST support buffering at least 4096 bytes of data 1837 received in CRYPTO frames out of order. Endpoints MAY choose to 1838 allow more data to be buffered during the handshake. A larger limit 1839 during the handshake could allow for larger keys or credentials to be 1840 exchanged. An endpoint's buffer size does not need to remain 1841 constant during the life of the connection. 1843 Being unable to buffer CRYPTO frames during the handshake can lead to 1844 a connection failure. If an endpoint's buffer is exceeded during the 1845 handshake, it can expand its buffer temporarily to complete the 1846 handshake. If an endpoint does not expand its buffer, it MUST close 1847 the connection with a CRYPTO_BUFFER_EXCEEDED error code. 1849 Once the handshake completes, if an endpoint is unable to buffer all 1850 data in a CRYPTO frame, it MAY discard that CRYPTO frame and all 1851 CRYPTO frames received in the future, or it MAY close the connection 1852 with a CRYPTO_BUFFER_EXCEEDED error code. Packets containing 1853 discarded CRYPTO frames MUST be acknowledged because the packet has 1854 been received and processed by the transport even though the CRYPTO 1855 frame was discarded. 1857 8. Address Validation 1859 Address validation is used by QUIC to avoid being used for a traffic 1860 amplification attack. In such an attack, a packet is sent to a 1861 server with spoofed source address information that identifies a 1862 victim. If a server generates more or larger packets in response to 1863 that packet, the attacker can use the server to send more data toward 1864 the victim than it would be able to send on its own. 1866 The primary defense against amplification attack is verifying that an 1867 endpoint is able to receive packets at the transport address that it 1868 claims. Address validation is performed both during connection 1869 establishment (see Section 8.1) and during connection migration (see 1870 Section 8.2). 1872 8.1. Address Validation During Connection Establishment 1874 Connection establishment implicitly provides address validation for 1875 both endpoints. In particular, receipt of a packet protected with 1876 Handshake keys confirms that the client received the Initial packet 1877 from the server. Once the server has successfully processed a 1878 Handshake packet from the client, it can consider the client address 1879 to have been validated. 1881 Prior to validating the client address, servers MUST NOT send more 1882 than three times as many bytes as the number of bytes they have 1883 received. This limits the magnitude of any amplification attack that 1884 can be mounted using spoofed source addresses. In determining this 1885 limit, servers only count the size of successfully processed packets. 1887 Clients MUST ensure that UDP datagrams containing Initial packets 1888 have UDP payloads of at least 1200 bytes, adding padding to packets 1889 in the datagram as necessary. Sending padded datagrams ensures that 1890 the server is not overly constrained by the amplification 1891 restriction. 1893 Packet loss, in particular loss of a Handshake packet from the 1894 server, can cause a situation in which the server cannot send when 1895 the client has no data to send and the anti-amplification limit is 1896 reached. In order to avoid this causing a handshake deadlock, 1897 clients SHOULD send a packet upon a probe timeout, as described in 1898 [QUIC-RECOVERY]. If the client has no data to retransmit and does 1899 not have Handshake keys, it SHOULD send an Initial packet in a UDP 1900 datagram of at least 1200 bytes. If the client has Handshake keys, 1901 it SHOULD send a Handshake packet. 1903 A server might wish to validate the client address before starting 1904 the cryptographic handshake. QUIC uses a token in the Initial packet 1905 to provide address validation prior to completing the handshake. 1906 This token is delivered to the client during connection establishment 1907 with a Retry packet (see Section 8.1.2) or in a previous connection 1908 using the NEW_TOKEN frame (see Section 8.1.3). 1910 In addition to sending limits imposed prior to address validation, 1911 servers are also constrained in what they can send by the limits set 1912 by the congestion controller. Clients are only constrained by the 1913 congestion controller. 1915 8.1.1. Token Construction 1917 A token sent in a NEW_TOKEN frames or a Retry packet MUST be 1918 constructed in a way that allows the server to identity how it was 1919 provided to a client. These tokens are carried in the same field, 1920 but require different handling from servers. 1922 8.1.2. Address Validation using Retry Packets 1924 Upon receiving the client's Initial packet, the server can request 1925 address validation by sending a Retry packet (Section 17.2.5) 1926 containing a token. This token MUST be repeated by the client in all 1927 Initial packets it sends for that connection after it receives the 1928 Retry packet. In response to processing an Initial containing a 1929 token, a server can either abort the connection or permit it to 1930 proceed. 1932 As long as it is not possible for an attacker to generate a valid 1933 token for its own address (see Section 8.1.4) and the client is able 1934 to return that token, it proves to the server that it received the 1935 token. 1937 A server can also use a Retry packet to defer the state and 1938 processing costs of connection establishment. Requiring the server 1939 to provide a different connection ID, along with the 1940 original_connection_id transport parameter defined in Section 18.2, 1941 forces the server to demonstrate that it, or an entity it cooperates 1942 with, received the original Initial packet from the client. 1943 Providing a different connection ID also grants a server some control 1944 over how subsequent packets are routed. This can be used to direct 1945 connections to a different server instance. 1947 If a server receives a client Initial that can be unprotected but 1948 contains an invalid Retry token, it knows the client will not accept 1949 another Retry token. The server can discard such a packet and allow 1950 the client to time out to detect handshake failure, but that could 1951 impose a significant latency penalty on the client. A server MAY 1952 proceed with the connection without verifying the token, though the 1953 server MUST NOT consider the client address validated. If a server 1954 chooses not to proceed with the handshake, it SHOULD immediately 1955 close (Section 10.3) the connection with an INVALID_TOKEN error. 1956 Note that a server has not established any state for the connection 1957 at this point and so does not enter the closing period. 1959 A flow showing the use of a Retry packet is shown in Figure 5. 1961 Client Server 1963 Initial[0]: CRYPTO[CH] -> 1965 <- Retry+Token 1967 Initial+Token[1]: CRYPTO[CH] -> 1969 Initial[0]: CRYPTO[SH] ACK[1] 1970 Handshake[0]: CRYPTO[EE, CERT, CV, FIN] 1971 <- 1-RTT[0]: STREAM[1, "..."] 1973 Figure 5: Example Handshake with Retry 1975 8.1.3. Address Validation for Future Connections 1977 A server MAY provide clients with an address validation token during 1978 one connection that can be used on a subsequent connection. Address 1979 validation is especially important with 0-RTT because a server 1980 potentially sends a significant amount of data to a client in 1981 response to 0-RTT data. 1983 The server uses the NEW_TOKEN frame Section 19.7 to provide the 1984 client with an address validation token that can be used to validate 1985 future connections. The client includes this token in Initial 1986 packets to provide address validation in a future connection. The 1987 client MUST include the token in all Initial packets it sends, unless 1988 a Retry replaces the token with a newer one. The client MUST NOT use 1989 the token provided in a Retry for future connections. Servers MAY 1990 discard any Initial packet that does not carry the expected token. 1992 Unlike the token that is created for a Retry packet, there might be 1993 some time between when the token is created and when the token is 1994 subsequently used. Thus, a token SHOULD have an expiration time, 1995 which could be either an explicit expiration time or an issued 1996 timestamp that can be used to dynamically calculate the expiration 1997 time. A server can store the expiration time or include it in an 1998 encrypted form in the token. 2000 A token issued with NEW_TOKEN MUST NOT include information that would 2001 allow values to be linked by an on-path observer to the connection on 2002 which it was issued, unless the values are encrypted. For example, 2003 it cannot include the previous connection ID or addressing 2004 information. A server MUST ensure that every NEW_TOKEN frame it 2005 sends is unique across all clients, with the exception of those sent 2006 to repair losses of previously sent NEW_TOKEN frames. Information 2007 that allows the server to distinguish between tokens from Retry and 2008 NEW_TOKEN MAY be accessible to entities other than the server. 2010 It is unlikely that the client port number is the same on two 2011 different connections; validating the port is therefore unlikely to 2012 be successful. 2014 A token received in a NEW_TOKEN frame is applicable to any server 2015 that the connection is considered authoritative for (e.g., server 2016 names included in the certificate). When connecting to a server for 2017 which the client retains an applicable and unused token, it SHOULD 2018 include that token in the Token field of its Initial packet. 2019 Including a token might allow the server to validate the client 2020 address without an additional round trip. A client MUST NOT include 2021 a token that is not applicable to the server that it is connecting 2022 to, unless the client has the knowledge that the server that issued 2023 the token and the server the client is connecting to are jointly 2024 managing the tokens. A client MAY use a token from any previous 2025 connection to that server. 2027 A token allows a server to correlate activity between the connection 2028 where the token was issued and any connection where it is used. 2029 Clients that want to break continuity of identity with a server MAY 2030 discard tokens provided using the NEW_TOKEN frame. In comparison, a 2031 token obtained in a Retry packet MUST be used immediately during the 2032 connection attempt and cannot be used in subsequent connection 2033 attempts. 2035 A client SHOULD NOT reuse a NEW_TOKEN token for different connection 2036 attempts. Reusing a token allows connections to be linked by 2037 entities on the network path; see Section 9.5. A client MUST NOT 2038 reuse a token if it believes that its point of network attachment has 2039 changed since the token was last used; that is, if there is a change 2040 in its local IP address or network interface. A client needs to 2041 start the connection process over if there is any change in its local 2042 address prior to completing the handshake. 2044 Clients might receive multiple tokens on a single connection. Aside 2045 from preventing linkability, any token can be used in any connection 2046 attempt. Servers can send additional tokens to either enable address 2047 validation for multiple connection attempts or to replace older 2048 tokens that might become invalid. For a client, this ambiguity means 2049 that sending the most recent unused token is most likely to be 2050 effective. Though saving and using older tokens has no negative 2051 consequences, clients can regard older tokens as being less likely be 2052 useful to the server for address validation. 2054 When a server receives an Initial packet with an address validation 2055 token, it MUST attempt to validate the token, unless it has already 2056 completed address validation. If the token is invalid then the 2057 server SHOULD proceed as if the client did not have a validated 2058 address, including potentially sending a Retry. If the validation 2059 succeeds, the server SHOULD then allow the handshake to proceed. 2061 Note: The rationale for treating the client as unvalidated rather 2062 than discarding the packet is that the client might have received 2063 the token in a previous connection using the NEW_TOKEN frame, and 2064 if the server has lost state, it might be unable to validate the 2065 token at all, leading to connection failure if the packet is 2066 discarded. A server SHOULD encode tokens provided with NEW_TOKEN 2067 frames and Retry packets differently, and validate the latter more 2068 strictly. 2070 In a stateless design, a server can use encrypted and authenticated 2071 tokens to pass information to clients that the server can later 2072 recover and use to validate a client address. Tokens are not 2073 integrated into the cryptographic handshake and so they are not 2074 authenticated. For instance, a client might be able to reuse a 2075 token. To avoid attacks that exploit this property, a server can 2076 limit its use of tokens to only the information needed to validate 2077 client addresses. 2079 Clients MAY use tokens obtained on one connection for any connection 2080 attempt using the same version. When selecting a token to use, 2081 clients do not need to consider other properties of the connection 2082 that is being attempted, including the choice of possible application 2083 protocols, session tickets, or other connection properties. 2085 Attackers could replay tokens to use servers as amplifiers in DDoS 2086 attacks. To protect against such attacks, servers SHOULD ensure that 2087 tokens sent in Retry packets are only accepted for a short time. 2088 Tokens that are provided in NEW_TOKEN frames (see Section 19.7) need 2089 to be valid for longer, but SHOULD NOT be accepted multiple times in 2090 a short period. Servers are encouraged to allow tokens to be used 2091 only once, if possible. 2093 8.1.4. Address Validation Token Integrity 2095 An address validation token MUST be difficult to guess. Including a 2096 large enough random value in the token would be sufficient, but this 2097 depends on the server remembering the value it sends to clients. 2099 A token-based scheme allows the server to offload any state 2100 associated with validation to the client. For this design to work, 2101 the token MUST be covered by integrity protection against 2102 modification or falsification by clients. Without integrity 2103 protection, malicious clients could generate or guess values for 2104 tokens that would be accepted by the server. Only the server 2105 requires access to the integrity protection key for tokens. 2107 There is no need for a single well-defined format for the token 2108 because the server that generates the token also consumes it. A 2109 token could include information about the claimed client address (IP 2110 and port), a timestamp, and any other supplementary information the 2111 server will need to validate the token in the future. 2113 8.2. Path Validation 2115 Path validation is used during connection migration (see Section 9 2116 and Section 9.6) by the migrating endpoint to verify reachability of 2117 a peer from a new local address. In path validation, endpoints test 2118 reachability between a specific local address and a specific peer 2119 address, where an address is the two-tuple of IP address and port. 2121 Path validation tests that packets (PATH_CHALLENGE) can be both sent 2122 to and received (PATH_RESPONSE) from a peer on the path. 2123 Importantly, it validates that the packets received from the 2124 migrating endpoint do not carry a spoofed source address. 2126 Path validation can be used at any time by either endpoint. For 2127 instance, an endpoint might check that a peer is still in possession 2128 of its address after a period of quiescence. 2130 Path validation is not designed as a NAT traversal mechanism. Though 2131 the mechanism described here might be effective for the creation of 2132 NAT bindings that support NAT traversal, the expectation is that one 2133 or other peer is able to receive packets without first having sent a 2134 packet on that path. Effective NAT traversal needs additional 2135 synchronization mechanisms that are not provided here. 2137 An endpoint MAY bundle PATH_CHALLENGE and PATH_RESPONSE frames that 2138 are used for path validation with other frames. In particular, an 2139 endpoint may pad a packet carrying a PATH_CHALLENGE for PMTU 2140 discovery, or an endpoint may bundle a PATH_RESPONSE with its own 2141 PATH_CHALLENGE. 2143 When probing a new path, an endpoint might want to ensure that its 2144 peer has an unused connection ID available for responses. The 2145 endpoint can send NEW_CONNECTION_ID and PATH_CHALLENGE frames in the 2146 same packet. This ensures that an unused connection ID will be 2147 available to the peer when sending a response. 2149 8.3. Initiating Path Validation 2151 To initiate path validation, an endpoint sends a PATH_CHALLENGE frame 2152 containing a random payload on the path to be validated. 2154 An endpoint MAY send multiple PATH_CHALLENGE frames to guard against 2155 packet loss. However, an endpoint SHOULD NOT send multiple 2156 PATH_CHALLENGE frames in a single packet. An endpoint SHOULD NOT 2157 send a PATH_CHALLENGE more frequently than it would an Initial 2158 packet, ensuring that connection migration is no more load on a new 2159 path than establishing a new connection. 2161 The endpoint MUST use unpredictable data in every PATH_CHALLENGE 2162 frame so that it can associate the peer's response with the 2163 corresponding PATH_CHALLENGE. 2165 8.4. Path Validation Responses 2167 On receiving a PATH_CHALLENGE frame, an endpoint MUST respond 2168 immediately by echoing the data contained in the PATH_CHALLENGE frame 2169 in a PATH_RESPONSE frame. 2171 An endpoint MUST NOT send more than one PATH_RESPONSE frame in 2172 response to one PATH_CHALLENGE frame (see Section 13.3). The peer is 2173 expected to send more PATH_CHALLENGE frames as necessary to evoke 2174 additional PATH_RESPONSE frames. 2176 8.5. Successful Path Validation 2178 A new address is considered valid when a PATH_RESPONSE frame is 2179 received that contains the data that was sent in a previous 2180 PATH_CHALLENGE. Receipt of an acknowledgment for a packet containing 2181 a PATH_CHALLENGE frame is not adequate validation, since the 2182 acknowledgment can be spoofed by a malicious peer. 2184 Note that receipt on a different local address does not result in 2185 path validation failure, as it might be a result of a forwarded 2186 packet (see Section 9.3.3) or misrouting. It is possible that a 2187 valid PATH_RESPONSE might be received in the future. 2189 8.6. Failed Path Validation 2191 Path validation only fails when the endpoint attempting to validate 2192 the path abandons its attempt to validate the path. 2194 Endpoints SHOULD abandon path validation based on a timer. When 2195 setting this timer, implementations are cautioned that the new path 2196 could have a longer round-trip time than the original. A value of 2197 three times the larger of the current Probe Timeout (PTO) or the 2198 initial timeout (that is, 2*kInitialRtt) as defined in 2199 [QUIC-RECOVERY] is RECOMMENDED. That is: 2201 validation_timeout = max(3*PTO, 6*kInitialRtt) 2203 Note that the endpoint might receive packets containing other frames 2204 on the new path, but a PATH_RESPONSE frame with appropriate data is 2205 required for path validation to succeed. 2207 When an endpoint abandons path validation, it determines that the 2208 path is unusable. This does not necessarily imply a failure of the 2209 connection - endpoints can continue sending packets over other paths 2210 as appropriate. If no paths are available, an endpoint can wait for 2211 a new path to become available or close the connection. 2213 A path validation might be abandoned for other reasons besides 2214 failure. Primarily, this happens if a connection migration to a new 2215 path is initiated while a path validation on the old path is in 2216 progress. 2218 9. Connection Migration 2220 The use of a connection ID allows connections to survive changes to 2221 endpoint addresses (IP address and port), such as those caused by an 2222 endpoint migrating to a new network. This section describes the 2223 process by which an endpoint migrates to a new address. 2225 The design of QUIC relies on endpoints retaining a stable address for 2226 the duration of the handshake. An endpoint MUST NOT initiate 2227 connection migration before the handshake is confirmed, as defined in 2228 section 4.1.2 of [QUIC-TLS]. 2230 An endpoint also MUST NOT send packets from a different local 2231 address, actively initiating migration, if the peer sent the 2232 "disable_active_migration" transport parameter during the handshake. 2233 An endpoint which has sent this transport parameter, but detects that 2234 a peer has nonetheless migrated to a different network MUST either 2235 drop the incoming packets on that path without generating a stateless 2236 reset or proceed with path validation and allow the peer to migrate. 2237 Generating a stateless reset or closing the connection would allow 2238 third parties in the network to cause connections to close by 2239 spoofing or otherwise manipulating observed traffic. 2241 Not all changes of peer address are intentional, or active, 2242 migrations. The peer could experience NAT rebinding: a change of 2243 address due to a middlebox, usually a NAT, allocating a new outgoing 2244 port or even a new outgoing IP address for a flow. An endpoint MUST 2245 perform path validation (Section 8.2) if it detects any change to a 2246 peer's address, unless it has previously validated that address. 2248 When an endpoint has no validated path on which to send packets, it 2249 MAY discard connection state. An endpoint capable of connection 2250 migration MAY wait for a new path to become available before 2251 discarding connection state. 2253 This document limits migration of connections to new client 2254 addresses, except as described in Section 9.6. Clients are 2255 responsible for initiating all migrations. Servers do not send non- 2256 probing packets (see Section 9.1) toward a client address until they 2257 see a non-probing packet from that address. If a client receives 2258 packets from an unknown server address, the client MUST discard these 2259 packets. 2261 9.1. Probing a New Path 2263 An endpoint MAY probe for peer reachability from a new local address 2264 using path validation Section 8.2 prior to migrating the connection 2265 to the new local address. Failure of path validation simply means 2266 that the new path is not usable for this connection. Failure to 2267 validate a path does not cause the connection to end unless there are 2268 no valid alternative paths available. 2270 An endpoint uses a new connection ID for probes sent from a new local 2271 address; see Section 9.5 for further discussion. An endpoint that 2272 uses a new local address needs to ensure that at least one new 2273 connection ID is available at the peer. That can be achieved by 2274 including a NEW_CONNECTION_ID frame in the probe. 2276 Receiving a PATH_CHALLENGE frame from a peer indicates that the peer 2277 is probing for reachability on a path. An endpoint sends a 2278 PATH_RESPONSE in response as per Section 8.2. 2280 PATH_CHALLENGE, PATH_RESPONSE, NEW_CONNECTION_ID, and PADDING frames 2281 are "probing frames", and all other frames are "non-probing frames". 2282 A packet containing only probing frames is a "probing packet", and a 2283 packet containing any other frame is a "non-probing packet". 2285 9.2. Initiating Connection Migration 2287 An endpoint can migrate a connection to a new local address by 2288 sending packets containing non-probing frames from that address. 2290 Each endpoint validates its peer's address during connection 2291 establishment. Therefore, a migrating endpoint can send to its peer 2292 knowing that the peer is willing to receive at the peer's current 2293 address. Thus an endpoint can migrate to a new local address without 2294 first validating the peer's address. 2296 When migrating, the new path might not support the endpoint's current 2297 sending rate. Therefore, the endpoint resets its congestion 2298 controller, as described in Section 9.4. 2300 The new path might not have the same ECN capability. Therefore, the 2301 endpoint verifies ECN capability as described in Section 13.4. 2303 Receiving acknowledgments for data sent on the new path serves as 2304 proof of the peer's reachability from the new address. Note that 2305 since acknowledgments may be received on any path, return 2306 reachability on the new path is not established. To establish return 2307 reachability on the new path, an endpoint MAY concurrently initiate 2308 path validation Section 8.2 on the new path. 2310 9.3. Responding to Connection Migration 2312 Receiving a packet from a new peer address containing a non-probing 2313 frame indicates that the peer has migrated to that address. 2315 In response to such a packet, an endpoint MUST start sending 2316 subsequent packets to the new peer address and MUST initiate path 2317 validation (Section 8.2) to verify the peer's ownership of the 2318 unvalidated address. 2320 An endpoint MAY send data to an unvalidated peer address, but it MUST 2321 protect against potential attacks as described in Section 9.3.1 and 2322 Section 9.3.2. An endpoint MAY skip validation of a peer address if 2323 that address has been seen recently. In particular, if an endpoint 2324 returns to a previously-validated path after detecting some form of 2325 spurious migration, skipping address validation and restoring loss 2326 detection and congestion state can reduce the performance impact of 2327 the attack. 2329 An endpoint only changes the address that it sends packets to in 2330 response to the highest-numbered non-probing packet. This ensures 2331 that an endpoint does not send packets to an old peer address in the 2332 case that it receives reordered packets. 2334 After changing the address to which it sends non-probing packets, an 2335 endpoint could abandon any path validation for other addresses. 2337 Receiving a packet from a new peer address might be the result of a 2338 NAT rebinding at the peer. 2340 After verifying a new client address, the server SHOULD send new 2341 address validation tokens (Section 8) to the client. 2343 9.3.1. Peer Address Spoofing 2345 It is possible that a peer is spoofing its source address to cause an 2346 endpoint to send excessive amounts of data to an unwilling host. If 2347 the endpoint sends significantly more data than the spoofing peer, 2348 connection migration might be used to amplify the volume of data that 2349 an attacker can generate toward a victim. 2351 As described in Section 9.3, an endpoint is required to validate a 2352 peer's new address to confirm the peer's possession of the new 2353 address. Until a peer's address is deemed valid, an endpoint MUST 2354 limit the rate at which it sends data to this address. The endpoint 2355 MUST NOT send more than a minimum congestion window's worth of data 2356 per estimated round-trip time (kMinimumWindow, as defined in 2357 [QUIC-RECOVERY]). In the absence of this limit, an endpoint risks 2358 being used for a denial of service attack against an unsuspecting 2359 victim. Note that since the endpoint will not have any round-trip 2360 time measurements to this address, the estimate SHOULD be the default 2361 initial value (see [QUIC-RECOVERY]). 2363 If an endpoint skips validation of a peer address as described in 2364 Section 9.3, it does not need to limit its sending rate. 2366 9.3.2. On-Path Address Spoofing 2368 An on-path attacker could cause a spurious connection migration by 2369 copying and forwarding a packet with a spoofed address such that it 2370 arrives before the original packet. The packet with the spoofed 2371 address will be seen to come from a migrating connection, and the 2372 original packet will be seen as a duplicate and dropped. After a 2373 spurious migration, validation of the source address will fail 2374 because the entity at the source address does not have the necessary 2375 cryptographic keys to read or respond to the PATH_CHALLENGE frame 2376 that is sent to it even if it wanted to. 2378 To protect the connection from failing due to such a spurious 2379 migration, an endpoint MUST revert to using the last validated peer 2380 address when validation of a new peer address fails. 2382 If an endpoint has no state about the last validated peer address, it 2383 MUST close the connection silently by discarding all connection 2384 state. This results in new packets on the connection being handled 2385 generically. For instance, an endpoint MAY send a stateless reset in 2386 response to any further incoming packets. 2388 Note that receipt of packets with higher packet numbers from the 2389 legitimate peer address will trigger another connection migration. 2391 This will cause the validation of the address of the spurious 2392 migration to be abandoned. 2394 9.3.3. Off-Path Packet Forwarding 2396 An off-path attacker that can observe packets might forward copies of 2397 genuine packets to endpoints. If the copied packet arrives before 2398 the genuine packet, this will appear as a NAT rebinding. Any genuine 2399 packet will be discarded as a duplicate. If the attacker is able to 2400 continue forwarding packets, it might be able to cause migration to a 2401 path via the attacker. This places the attacker on path, giving it 2402 the ability to observe or drop all subsequent packets. 2404 Unlike the attack described in Section 9.3.2, the attacker can ensure 2405 that the new path is successfully validated. 2407 This style of attack relies on the attacker using a path that is 2408 approximately as fast as the direct path between endpoints. The 2409 attack is more reliable if relatively few packets are sent or if 2410 packet loss coincides with the attempted attack. 2412 A non-probing packet received on the original path that increases the 2413 maximum received packet number will cause the endpoint to move back 2414 to that path. Eliciting packets on this path increases the 2415 likelihood that the attack is unsuccessful. Therefore, mitigation of 2416 this attack relies on triggering the exchange of packets. 2418 In response to an apparent migration, endpoints MUST validate the 2419 previously active path using a PATH_CHALLENGE frame. This induces 2420 the sending of new packets on that path. If the path is no longer 2421 viable, the validation attempt will time out and fail; if the path is 2422 viable, but no longer desired, the validation will succeed, but only 2423 results in probing packets being sent on the path. 2425 An endpoint that receives a PATH_CHALLENGE on an active path SHOULD 2426 send a non-probing packet in response. If the non-probing packet 2427 arrives before any copy made by an attacker, this results in the 2428 connection being migrated back to the original path. Any subsequent 2429 migration to another path restarts this entire process. 2431 This defense is imperfect, but this is not considered a serious 2432 problem. If the path via the attack is reliably faster than the 2433 original path despite multiple attempts to use that original path, it 2434 is not possible to distinguish between attack and an improvement in 2435 routing. 2437 An endpoint could also use heuristics to improve detection of this 2438 style of attack. For instance, NAT rebinding is improbable if 2439 packets were recently received on the old path, similarly rebinding 2440 is rare on IPv6 paths. Endpoints can also look for duplicated 2441 packets. Conversely, a change in connection ID is more likely to 2442 indicate an intentional migration rather than an attack. 2444 9.4. Loss Detection and Congestion Control 2446 The capacity available on the new path might not be the same as the 2447 old path. Packets sent on the old path MUST NOT contribute to 2448 congestion control or RTT estimation for the new path. 2450 On confirming a peer's ownership of its new address, an endpoint MUST 2451 immediately reset the congestion controller and round-trip time 2452 estimator for the new path to initial values (see Sections A.3 and 2453 B.3 in [QUIC-RECOVERY]) unless it has knowledge that a previous send 2454 rate or round-trip time estimate is valid for the new path. For 2455 instance, an endpoint might infer that a change in only the client's 2456 port number is indicative of a NAT rebinding, meaning that the new 2457 path is likely to have similar bandwidth and round-trip time. 2458 However, this determination will be imperfect. If the determination 2459 is incorrect, the congestion controller and the RTT estimator are 2460 expected to adapt to the new path. Generally, implementations are 2461 advised to be cautious when using previous values on a new path. 2463 There may be apparent reordering at the receiver when an endpoint 2464 sends data and probes from/to multiple addresses during the migration 2465 period, since the two resulting paths may have different round-trip 2466 times. A receiver of packets on multiple paths will still send ACK 2467 frames covering all received packets. 2469 While multiple paths might be used during connection migration, a 2470 single congestion control context and a single loss recovery context 2471 (as described in [QUIC-RECOVERY]) may be adequate. For instance, an 2472 endpoint might delay switching to a new congestion control context 2473 until it is confirmed that an old path is no longer needed (such as 2474 the case in Section 9.3.3). 2476 A sender can make exceptions for probe packets so that their loss 2477 detection is independent and does not unduly cause the congestion 2478 controller to reduce its sending rate. An endpoint might set a 2479 separate timer when a PATH_CHALLENGE is sent, which is cancelled when 2480 the corresponding PATH_RESPONSE is received. If the timer fires 2481 before the PATH_RESPONSE is received, the endpoint might send a new 2482 PATH_CHALLENGE, and restart the timer for a longer period of time. 2484 9.5. Privacy Implications of Connection Migration 2486 Using a stable connection ID on multiple network paths allows a 2487 passive observer to correlate activity between those paths. An 2488 endpoint that moves between networks might not wish to have their 2489 activity correlated by any entity other than their peer, so different 2490 connection IDs are used when sending from different local addresses, 2491 as discussed in Section 5.1. For this to be effective endpoints need 2492 to ensure that connection IDs they provide cannot be linked by any 2493 other entity. 2495 At any time, endpoints MAY change the Destination Connection ID they 2496 send to a value that has not been used on another path. 2498 An endpoint MUST use a new connection ID if it initiates connection 2499 migration as described in Section 9.2 or probes a new network path as 2500 described in Section 9.1. An endpoint MUST use a new connection ID 2501 in response to a change in the address of a peer if the packet with 2502 the new peer address uses an active connection ID that has not been 2503 previously used by the peer. 2505 Using different connection IDs for packets sent in both directions on 2506 each new network path eliminates the use of the connection ID for 2507 linking packets from the same connection across different network 2508 paths. Header protection ensures that packet numbers cannot be used 2509 to correlate activity. This does not prevent other properties of 2510 packets, such as timing and size, from being used to correlate 2511 activity. 2513 Unintentional changes in path without a change in connection ID are 2514 possible. For example, after a period of network inactivity, NAT 2515 rebinding might cause packets to be sent on a new path when the 2516 client resumes sending. 2518 A client might wish to reduce linkability by employing a new 2519 connection ID and source UDP port when sending traffic after a period 2520 of inactivity. Changing the UDP port from which it sends packets at 2521 the same time might cause the packet to appear as a connection 2522 migration. This ensures that the mechanisms that support migration 2523 are exercised even for clients that don't experience NAT rebindings 2524 or genuine migrations. Changing port number can cause a peer to 2525 reset its congestion state (see Section 9.4), so the port SHOULD only 2526 be changed infrequently. 2528 An endpoint that exhausts available connection IDs cannot probe new 2529 paths or initiate migration, nor can it respond to probes or attempts 2530 by its peer to migrate. To ensure that migration is possible and 2531 packets sent on different paths cannot be correlated, endpoints 2532 SHOULD provide new connection IDs before peers migrate; see 2533 Section 5.1.1. If a peer might have exhausted available connection 2534 IDs, a migrating endpoint could include a NEW_CONNECTION_ID frame in 2535 all packets sent on a new network path. 2537 9.6. Server's Preferred Address 2539 QUIC allows servers to accept connections on one IP address and 2540 attempt to transfer these connections to a more preferred address 2541 shortly after the handshake. This is particularly useful when 2542 clients initially connect to an address shared by multiple servers 2543 but would prefer to use a unicast address to ensure connection 2544 stability. This section describes the protocol for migrating a 2545 connection to a preferred server address. 2547 Migrating a connection to a new server address mid-connection is left 2548 for future work. If a client receives packets from a new server 2549 address not indicated by the preferred_address transport parameter, 2550 the client SHOULD discard these packets. 2552 9.6.1. Communicating a Preferred Address 2554 A server conveys a preferred address by including the 2555 preferred_address transport parameter in the TLS handshake. 2557 Servers MAY communicate a preferred address of each address family 2558 (IPv4 and IPv6) to allow clients to pick the one most suited to their 2559 network attachment. 2561 Once the handshake is finished, the client SHOULD select one of the 2562 two server's preferred addresses and initiate path validation (see 2563 Section 8.2) of that address using the connection ID provided in the 2564 preferred_address transport parameter. 2566 If path validation succeeds, the client SHOULD immediately begin 2567 sending all future packets to the new server address using the new 2568 connection ID and discontinue use of the old server address. If path 2569 validation fails, the client MUST continue sending all future packets 2570 to the server's original IP address. 2572 9.6.2. Responding to Connection Migration 2574 A server might receive a packet addressed to its preferred IP address 2575 at any time after it accepts a connection. If this packet contains a 2576 PATH_CHALLENGE frame, the server sends a PATH_RESPONSE frame as per 2577 Section 8.2. The server MUST send other non-probing frames from its 2578 original address until it receives a non-probing packet from the 2579 client at its preferred address and until the server has validated 2580 the new path. 2582 The server MUST probe on the path toward the client from its 2583 preferred address. This helps to guard against spurious migration 2584 initiated by an attacker. 2586 Once the server has completed its path validation and has received a 2587 non-probing packet with a new largest packet number on its preferred 2588 address, the server begins sending non-probing packets to the client 2589 exclusively from its preferred IP address. It SHOULD drop packets 2590 for this connection received on the old IP address, but MAY continue 2591 to process delayed packets. 2593 9.6.3. Interaction of Client Migration and Preferred Address 2595 A client might need to perform a connection migration before it has 2596 migrated to the server's preferred address. In this case, the client 2597 SHOULD perform path validation to both the original and preferred 2598 server address from the client's new address concurrently. 2600 If path validation of the server's preferred address succeeds, the 2601 client MUST abandon validation of the original address and migrate to 2602 using the server's preferred address. If path validation of the 2603 server's preferred address fails but validation of the server's 2604 original address succeeds, the client MAY migrate to its new address 2605 and continue sending to the server's original address. 2607 If the connection to the server's preferred address is not from the 2608 same client address, the server MUST protect against potential 2609 attacks as described in Section 9.3.1 and Section 9.3.2. In addition 2610 to intentional simultaneous migration, this might also occur because 2611 the client's access network used a different NAT binding for the 2612 server's preferred address. 2614 Servers SHOULD initiate path validation to the client's new address 2615 upon receiving a probe packet from a different address. Servers MUST 2616 NOT send more than a minimum congestion window's worth of non-probing 2617 packets to the new address before path validation is complete. 2619 A client that migrates to a new address SHOULD use a preferred 2620 address from the same address family for the server. 2622 9.7. Use of IPv6 Flow-Label and Migration 2624 Endpoints that send data using IPv6 SHOULD apply an IPv6 flow label 2625 in compliance with [RFC6437], unless the local API does not allow 2626 setting IPv6 flow labels. 2628 The IPv6 flow label SHOULD be a pseudo-random function of the source 2629 and destination addresses, source and destination UDP ports, and the 2630 destination CID. The flow label generation MUST be designed to 2631 minimize the chances of linkability with a previously used flow 2632 label, as this would enable correlating activity on multiple paths 2633 (see Section 9.5). 2635 A possible implementation is to compute the flow label as a 2636 cryptographic hash function of the source and destination addresses, 2637 source and destination UDP ports, destination CID, and a local 2638 secret. 2640 10. Connection Termination 2642 An established QUIC connection can be terminated in one of three 2643 ways: 2645 * idle timeout (Section 10.2) 2647 * immediate close (Section 10.3) 2649 * stateless reset (Section 10.4) 2651 An endpoint MAY discard connection state if it does not have a 2652 validated path on which it can send packets (see Section 8.2). 2654 10.1. Closing and Draining Connection States 2656 The closing and draining connection states exist to ensure that 2657 connections close cleanly and that delayed or reordered packets are 2658 properly discarded. These states SHOULD persist for at least three 2659 times the current Probe Timeout (PTO) interval as defined in 2660 [QUIC-RECOVERY]. 2662 An endpoint enters a closing period after initiating an immediate 2663 close (Section 10.3). While closing, an endpoint MUST NOT send 2664 packets unless they contain a CONNECTION_CLOSE frame (see 2665 Section 10.3 for details). An endpoint retains only enough 2666 information to generate a packet containing a CONNECTION_CLOSE frame 2667 and to identify packets as belonging to the connection. The 2668 endpoint's selected connection ID and the QUIC version are sufficient 2669 information to identify packets for a closing connection; an endpoint 2670 can discard all other connection state. An endpoint MAY retain 2671 packet protection keys for incoming packets to allow it to read and 2672 process a CONNECTION_CLOSE frame. 2674 The draining state is entered once an endpoint receives a signal that 2675 its peer is closing or draining. While otherwise identical to the 2676 closing state, an endpoint in the draining state MUST NOT send any 2677 packets. Retaining packet protection keys is unnecessary once a 2678 connection is in the draining state. 2680 An endpoint MAY transition from the closing period to the draining 2681 period if it receives a CONNECTION_CLOSE frame or stateless reset, 2682 both of which indicate that the peer is also closing or draining. 2683 The draining period SHOULD end when the closing period would have 2684 ended. In other words, the endpoint can use the same end time, but 2685 cease retransmission of the closing packet. 2687 Disposing of connection state prior to the end of the closing or 2688 draining period could cause delayed or reordered packets to generate 2689 an unnecessary stateless reset. Endpoints that have some alternative 2690 means to ensure that late-arriving packets on the connection do not 2691 induce a response, such as those that are able to close the UDP 2692 socket, MAY use an abbreviated draining period which can allow for 2693 faster resource recovery. Servers that retain an open socket for 2694 accepting new connections SHOULD NOT exit the closing or draining 2695 period early. 2697 Once the closing or draining period has ended, an endpoint SHOULD 2698 discard all connection state. This results in new packets on the 2699 connection being handled generically. For instance, an endpoint MAY 2700 send a stateless reset in response to any further incoming packets. 2702 The draining and closing periods do not apply when a stateless reset 2703 (Section 10.4) is sent. 2705 An endpoint is not expected to handle key updates when it is closing 2706 or draining. A key update might prevent the endpoint from moving 2707 from the closing state to draining, but it otherwise has no impact. 2709 While in the closing period, an endpoint could receive packets from a 2710 new source address, indicating a connection migration (Section 9). 2711 An endpoint in the closing state MUST strictly limit the number of 2712 packets it sends to this new address until the address is validated 2713 (see Section 8.2). A server in the closing state MAY instead choose 2714 to discard packets received from a new source address. 2716 10.2. Idle Timeout 2718 If the idle timeout is enabled by either peer, a connection is 2719 silently closed and its state is discarded when it remains idle for 2720 longer than the minimum of the max_idle_timeouts (see Section 18.2) 2721 and three times the current Probe Timeout (PTO). 2723 Each endpoint advertises a max_idle_timeout, but the effective value 2724 at an endpoint is computed as the minimum of the two advertised 2725 values. By announcing a max_idle_timeout, an endpoint commits to 2726 initiating an immediate close (Section 10.3) if it abandons the 2727 connection prior to the effective value. 2729 An endpoint restarts its idle timer when a packet from its peer is 2730 received and processed successfully. The idle timer is also 2731 restarted when sending an ack-eliciting packet (see [QUIC-RECOVERY]), 2732 but only if no other ack-eliciting packets have been sent since last 2733 receiving a packet. Restarting when sending packets ensures that 2734 connections do not prematurely time out when initiating new activity. 2735 An endpoint might need to send packets to avoid an idle timeout if it 2736 is unable to send application data due to being blocked on flow 2737 control limits; see Section 4. 2739 An endpoint that sends packets near the end of the idle timeout 2740 period risks having those packets discarded if its peer enters the 2741 draining state before the packets arrive. If a peer could time out 2742 within a Probe Timeout (PTO; see Section 6.2.2 of [QUIC-RECOVERY]), 2743 it is advisable to test for liveness before sending any data that 2744 cannot be retried safely. Note that it is likely that only 2745 applications or application protocols will know what information can 2746 be retried. 2748 10.3. Immediate Close 2750 An endpoint sends a CONNECTION_CLOSE frame (Section 19.19) to 2751 terminate the connection immediately. A CONNECTION_CLOSE frame 2752 causes all streams to immediately become closed; open streams can be 2753 assumed to be implicitly reset. 2755 After sending a CONNECTION_CLOSE frame, an endpoint immediately 2756 enters the closing state. 2758 During the closing period, an endpoint that sends a CONNECTION_CLOSE 2759 frame SHOULD respond to any incoming packet that can be decrypted 2760 with another packet containing a CONNECTION_CLOSE frame. Such an 2761 endpoint SHOULD limit the number of packets it generates containing a 2762 CONNECTION_CLOSE frame. For instance, an endpoint could wait for a 2763 progressively increasing number of received packets or amount of time 2764 before responding to a received packet. 2766 An endpoint is allowed to drop the packet protection keys when 2767 entering the closing period (Section 10.1) and send a packet 2768 containing a CONNECTION_CLOSE in response to any UDP datagram that is 2769 received. However, an endpoint without the packet protection keys 2770 cannot identify and discard invalid packets. To avoid creating an 2771 unwitting amplification attack, such endpoints MUST reduce the 2772 frequency with which it sends packets containing a CONNECTION_CLOSE 2773 frame. To minimize the state that an endpoint maintains for a 2774 closing connection, endpoints MAY send the exact same packet. 2776 Note: Allowing retransmission of a closing packet contradicts other 2777 advice in this document that recommends the creation of new packet 2778 numbers for every packet. Sending new packet numbers is primarily 2779 of advantage to loss recovery and congestion control, which are 2780 not expected to be relevant for a closed connection. 2781 Retransmitting the final packet requires less state. 2783 New packets from unverified addresses could be used to create an 2784 amplification attack (see Section 8). To avoid this, endpoints MUST 2785 either limit transmission of CONNECTION_CLOSE frames to validated 2786 addresses or drop packets without response if the response would be 2787 more than three times larger than the received packet. 2789 After receiving a CONNECTION_CLOSE frame, endpoints enter the 2790 draining state. An endpoint that receives a CONNECTION_CLOSE frame 2791 MAY send a single packet containing a CONNECTION_CLOSE frame before 2792 entering the draining state, using a CONNECTION_CLOSE frame and a 2793 NO_ERROR code if appropriate. An endpoint MUST NOT send further 2794 packets, which could result in a constant exchange of 2795 CONNECTION_CLOSE frames until the closing period on either peer 2796 ended. 2798 An immediate close can be used after an application protocol has 2799 arranged to close a connection. This might be after the application 2800 protocols negotiates a graceful shutdown. The application protocol 2801 exchanges whatever messages that are needed to cause both endpoints 2802 to agree to close the connection, after which the application 2803 requests that the connection be closed. The application protocol can 2804 use a CONNECTION_CLOSE frame with an appropriate error code to signal 2805 closure. 2807 When sending CONNECTION_CLOSE, the goal is to ensure that the peer 2808 will process the frame. Generally, this means sending the frame in a 2809 packet with the highest level of packet protection to avoid the 2810 packet being discarded. After the handshake is confirmed (see 2811 Section 4.1.2 of [QUIC-TLS]), an endpoint MUST send any 2812 CONNECTION_CLOSE frames in a 1-RTT packet. However, prior to 2813 confirming the handshake, it is possible that more advanced packet 2814 protection keys are not available to the peer, so the frame MAY be 2815 replicated in a packet that uses a lower packet protection level. 2817 A client will always know whether the server has Handshake keys (see 2818 Section 17.2.2.1), but it is possible that a server does not know 2819 whether the client has Handshake keys. Under these circumstances, a 2820 server SHOULD send a CONNECTION_CLOSE frame in both Handshake and 2821 Initial packets to ensure that at least one of them is processable by 2822 the client. Similarly, a peer might be unable to read 1-RTT packets, 2823 so an endpoint SHOULD send CONNECTION_CLOSE in Handshake and 1-RTT 2824 packets prior to confirming the handshake. These packets can be 2825 coalesced into a single UDP datagram; see Section 12.2. 2827 10.4. Stateless Reset 2829 A stateless reset is provided as an option of last resort for an 2830 endpoint that does not have access to the state of a connection. A 2831 crash or outage might result in peers continuing to send data to an 2832 endpoint that is unable to properly continue the connection. An 2833 endpoint MAY send a stateless reset in response to receiving a packet 2834 that it cannot associate with an active connection. 2836 A stateless reset is not appropriate for signaling error conditions. 2837 An endpoint that wishes to communicate a fatal connection error MUST 2838 use a CONNECTION_CLOSE frame if it has sufficient state to do so. 2840 To support this process, a token is sent by endpoints. The token is 2841 carried in the Stateless Reset Token field of a NEW_CONNECTION_ID 2842 frame. Servers can also specify a stateless_reset_token transport 2843 parameter during the handshake that applies to the connection ID that 2844 it selected during the handshake; clients cannot use this transport 2845 parameter because their transport parameters don't have 2846 confidentiality protection. These tokens are protected by 2847 encryption, so only client and server know their value. Tokens are 2848 invalidated when their associated connection ID is retired via a 2849 RETIRE_CONNECTION_ID frame (Section 19.16). 2851 An endpoint that receives packets that it cannot process sends a 2852 packet in the following layout: 2854 0 1 2 3 2855 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 2856 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2857 |0|1| Unpredictable Bits (38 ..) ... 2858 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2859 | | 2860 + + 2861 | | 2862 + Stateless Reset Token (128) + 2863 | | 2864 + + 2865 | | 2866 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2868 Figure 6: Stateless Reset Packet 2870 This design ensures that a stateless reset packet is - to the extent 2871 possible - indistinguishable from a regular packet with a short 2872 header. 2874 A stateless reset uses an entire UDP datagram, starting with the 2875 first two bits of the packet header. The remainder of the first byte 2876 and an arbitrary number of bytes following it that are set to 2877 unpredictable values. The last 16 bytes of the datagram contain a 2878 Stateless Reset Token. 2880 To entities other than its intended recipient, a stateless reset will 2881 appear to be a packet with a short header. For the stateless reset 2882 to appear as a valid QUIC packet, the Unpredictable Bits field needs 2883 to include at least 38 bits of data (or 5 bytes, less the two fixed 2884 bits). 2886 A minimum size of 21 bytes does not guarantee that a stateless reset 2887 is difficult to distinguish from other packets if the recipient 2888 requires the use of a connection ID. To prevent a resulting 2889 stateless reset from being trivially distinguishable from a valid 2890 packet, all packets sent by an endpoint SHOULD be padded to at least 2891 22 bytes longer than the minimum connection ID that the endpoint 2892 might use. An endpoint that sends a stateless reset in response to 2893 packet that is 43 bytes or less in length SHOULD send a stateless 2894 reset that is one byte shorter than the packet it responds to. 2896 These values assume that the Stateless Reset Token is the same as the 2897 minimum expansion of the packet protection AEAD. Additional 2898 unpredictable bytes are necessary if the endpoint could have 2899 negotiated a packet protection scheme with a larger minimum 2900 expansion. 2902 An endpoint MUST NOT send a stateless reset that is three times or 2903 more larger than the packet it receives to avoid being used for 2904 amplification. Section 10.4.3 describes additional limits on 2905 stateless reset size. 2907 Endpoints MUST discard packets that are too small to be valid QUIC 2908 packets. With the set of AEAD functions defined in [QUIC-TLS], 2909 packets that are smaller than 21 bytes are never valid. 2911 Endpoints MUST send stateless reset packets formatted as a packet 2912 with a short header. However, endpoints MUST treat any packet ending 2913 in a valid stateless reset token as a stateless reset, as other QUIC 2914 versions might allow the use of a long header. 2916 An endpoint MAY send a stateless reset in response to a packet with a 2917 long header. Sending a stateless reset is not effective prior to the 2918 stateless reset token being available to a peer. In this QUIC 2919 version, packets with a long header are only used during connection 2920 establishment. Because the stateless reset token is not available 2921 until connection establishment is complete or near completion, 2922 ignoring an unknown packet with a long header might be as effective 2923 as sending a stateless reset. 2925 An endpoint cannot determine the Source Connection ID from a packet 2926 with a short header, therefore it cannot set the Destination 2927 Connection ID in the stateless reset packet. The Destination 2928 Connection ID will therefore differ from the value used in previous 2929 packets. A random Destination Connection ID makes the connection ID 2930 appear to be the result of moving to a new connection ID that was 2931 provided using a NEW_CONNECTION_ID frame (Section 19.15). 2933 Using a randomized connection ID results in two problems: 2935 * The packet might not reach the peer. If the Destination 2936 Connection ID is critical for routing toward the peer, then this 2937 packet could be incorrectly routed. This might also trigger 2938 another Stateless Reset in response; see Section 10.4.3. A 2939 Stateless Reset that is not correctly routed is an ineffective 2940 error detection and recovery mechanism. In this case, endpoints 2941 will need to rely on other methods - such as timers - to detect 2942 that the connection has failed. 2944 * The randomly generated connection ID can be used by entities other 2945 than the peer to identify this as a potential stateless reset. An 2946 endpoint that occasionally uses different connection IDs might 2947 introduce some uncertainty about this. 2949 This stateless reset design is specific to QUIC version 1. An 2950 endpoint that supports multiple versions of QUIC needs to generate a 2951 stateless reset that will be accepted by peers that support any 2952 version that the endpoint might support (or might have supported 2953 prior to losing state). Designers of new versions of QUIC need to be 2954 aware of this and either reuse this design, or use a portion of the 2955 packet other than the last 16 bytes for carrying data. 2957 10.4.1. Detecting a Stateless Reset 2959 An endpoint detects a potential stateless reset using the trailing 16 2960 bytes of the UDP datagram. An endpoint remembers all Stateless Reset 2961 Tokens associated with the connection IDs and remote addresses for 2962 datagrams it has recently sent. This includes Stateless Reset Tokens 2963 from NEW_CONNECTION_ID frames and the server's transport parameters 2964 but excludes Stateless Reset Tokens associated with connection IDs 2965 that are either unused or retired. The endpoint identifies a 2966 received datagram as a stateless reset by comparing the last 16 bytes 2967 of the datagram with all Stateless Reset Tokens associated with the 2968 remote address on which the datagram was received. 2970 This comparison can be performed for every inbound datagram. 2971 Endpoints MAY skip this check if any packet from a datagram is 2972 successfully processed. However, the comparison MUST be performed 2973 when the first packet in an incoming datagram either cannot be 2974 associated with a connection, or cannot be decrypted. 2976 An endpoint MUST NOT check for any Stateless Reset Tokens associated 2977 with connection IDs it has not used or for connection IDs that have 2978 been retired. 2980 When comparing a datagram to Stateless Reset Token values, endpoints 2981 MUST perform the comparison without leaking information about the 2982 value of the token. For example, performing this comparison in 2983 constant time protects the value of individual Stateless Reset Tokens 2984 from information leakage through timing side channels. Another 2985 approach would be to store and compare the transformed values of 2986 Stateless Reset Tokens instead of the raw token values, where the 2987 transformation is defined as a cryptographically-secure pseudo-random 2988 function using a secret key (e.g., block cipher, HMAC [RFC2104]). An 2989 endpoint is not expected to protect information about whether a 2990 packet was successfully decrypted, or the number of valid Stateless 2991 Reset Tokens. 2993 If the last 16 bytes of the datagram are identical in value to a 2994 Stateless Reset Token, the endpoint MUST enter the draining period 2995 and not send any further packets on this connection. 2997 10.4.2. Calculating a Stateless Reset Token 2999 The stateless reset token MUST be difficult to guess. In order to 3000 create a Stateless Reset Token, an endpoint could randomly generate 3001 [RFC4086] a secret for every connection that it creates. However, 3002 this presents a coordination problem when there are multiple 3003 instances in a cluster or a storage problem for an endpoint that 3004 might lose state. Stateless reset specifically exists to handle the 3005 case where state is lost, so this approach is suboptimal. 3007 A single static key can be used across all connections to the same 3008 endpoint by generating the proof using a second iteration of a 3009 preimage-resistant function that takes a static key and the 3010 connection ID chosen by the endpoint (see Section 5.1) as input. An 3011 endpoint could use HMAC [RFC2104] (for example, HMAC(static_key, 3012 connection_id)) or HKDF [RFC5869] (for example, using the static key 3013 as input keying material, with the connection ID as salt). The 3014 output of this function is truncated to 16 bytes to produce the 3015 Stateless Reset Token for that connection. 3017 An endpoint that loses state can use the same method to generate a 3018 valid Stateless Reset Token. The connection ID comes from the packet 3019 that the endpoint receives. 3021 This design relies on the peer always sending a connection ID in its 3022 packets so that the endpoint can use the connection ID from a packet 3023 to reset the connection. An endpoint that uses this design MUST 3024 either use the same connection ID length for all connections or 3025 encode the length of the connection ID such that it can be recovered 3026 without state. In addition, it cannot provide a zero-length 3027 connection ID. 3029 Revealing the Stateless Reset Token allows any entity to terminate 3030 the connection, so a value can only be used once. This method for 3031 choosing the Stateless Reset Token means that the combination of 3032 connection ID and static key MUST NOT be used for another connection. 3033 A denial of service attack is possible if the same connection ID is 3034 used by instances that share a static key, or if an attacker can 3035 cause a packet to be routed to an instance that has no state but the 3036 same static key; see Section 21.9. A connection ID from a connection 3037 that is reset by revealing the Stateless Reset Token MUST NOT be 3038 reused for new connections at nodes that share a static key. 3040 The same Stateless Reset Token MUST NOT be used for multiple 3041 connection IDs. Endpoints are not required to compare new values 3042 against all previous values, but a duplicate value MAY be treated as 3043 a connection error of type PROTOCOL_VIOLATION. 3045 Note that Stateless Reset packets do not have any cryptographic 3046 protection. 3048 10.4.3. Looping 3050 The design of a Stateless Reset is such that without knowing the 3051 stateless reset token it is indistinguishable from a valid packet. 3052 For instance, if a server sends a Stateless Reset to another server 3053 it might receive another Stateless Reset in response, which could 3054 lead to an infinite exchange. 3056 An endpoint MUST ensure that every Stateless Reset that it sends is 3057 smaller than the packet which triggered it, unless it maintains state 3058 sufficient to prevent looping. In the event of a loop, this results 3059 in packets eventually being too small to trigger a response. 3061 An endpoint can remember the number of Stateless Reset packets that 3062 it has sent and stop generating new Stateless Reset packets once a 3063 limit is reached. Using separate limits for different remote 3064 addresses will ensure that Stateless Reset packets can be used to 3065 close connections when other peers or connections have exhausted 3066 limits. 3068 Reducing the size of a Stateless Reset below 41 bytes means that the 3069 packet could reveal to an observer that it is a Stateless Reset, 3070 depending upon the length of the peer's connection IDs. Conversely, 3071 refusing to send a Stateless Reset in response to a small packet 3072 might result in Stateless Reset not being useful in detecting cases 3073 of broken connections where only very small packets are sent; such 3074 failures might only be detected by other means, such as timers. 3076 11. Error Handling 3078 An endpoint that detects an error SHOULD signal the existence of that 3079 error to its peer. Both transport-level and application-level errors 3080 can affect an entire connection (see Section 11.1), while only 3081 application-level errors can be isolated to a single stream (see 3082 Section 11.2). 3084 The most appropriate error code (Section 20) SHOULD be included in 3085 the frame that signals the error. Where this specification 3086 identifies error conditions, it also identifies the error code that 3087 is used; though these are worded as requirements, different 3088 implementation strategies might lead to different errors being 3089 reported. In particular, an endpoint MAY use any applicable error 3090 code when it detects an error condition; a generic error code (such 3091 as PROTOCOL_VIOLATION or INTERNAL_ERROR) can always be used in place 3092 of specific error codes. 3094 A stateless reset (Section 10.4) is not suitable for any error that 3095 can be signaled with a CONNECTION_CLOSE or RESET_STREAM frame. A 3096 stateless reset MUST NOT be used by an endpoint that has the state 3097 necessary to send a frame on the connection. 3099 11.1. Connection Errors 3101 Errors that result in the connection being unusable, such as an 3102 obvious violation of protocol semantics or corruption of state that 3103 affects an entire connection, MUST be signaled using a 3104 CONNECTION_CLOSE frame (Section 19.19). An endpoint MAY close the 3105 connection in this manner even if the error only affects a single 3106 stream. 3108 Application protocols can signal application-specific protocol errors 3109 using the application-specific variant of the CONNECTION_CLOSE frame. 3110 Errors that are specific to the transport, including all those 3111 described in this document, are carried in the QUIC-specific variant 3112 of the CONNECTION_CLOSE frame. 3114 A CONNECTION_CLOSE frame could be sent in a packet that is lost. An 3115 endpoint SHOULD be prepared to retransmit a packet containing a 3116 CONNECTION_CLOSE frame if it receives more packets on a terminated 3117 connection. Limiting the number of retransmissions and the time over 3118 which this final packet is sent limits the effort expended on 3119 terminated connections. 3121 An endpoint that chooses not to retransmit packets containing a 3122 CONNECTION_CLOSE frame risks a peer missing the first such packet. 3123 The only mechanism available to an endpoint that continues to receive 3124 data for a terminated connection is to use the stateless reset 3125 process (Section 10.4). 3127 11.2. Stream Errors 3129 If an application-level error affects a single stream, but otherwise 3130 leaves the connection in a recoverable state, the endpoint can send a 3131 RESET_STREAM frame (Section 19.4) with an appropriate error code to 3132 terminate just the affected stream. 3134 Resetting a stream without the involvement of the application 3135 protocol could cause the application protocol to enter an 3136 unrecoverable state. RESET_STREAM MUST only be instigated by the 3137 application protocol that uses QUIC. 3139 RESET_STREAM carries an application error code, for which the 3140 semantics are defined by the application protocol. Only the 3141 application protocol is able to cause a stream to be terminated. A 3142 local instance of the application protocol uses a direct API call and 3143 a remote instance uses the STOP_SENDING frame, which triggers an 3144 automatic RESET_STREAM. 3146 Application protocols SHOULD define rules for handling streams that 3147 are prematurely cancelled by either endpoint. 3149 12. Packets and Frames 3151 QUIC endpoints communicate by exchanging packets. Packets have 3152 confidentiality and integrity protection (see Section 12.1) and are 3153 carried in UDP datagrams (see Section 12.2). 3155 This version of QUIC uses the long packet header (see Section 17.2) 3156 during connection establishment. Packets with the long header are 3157 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), Handshake 3158 (Section 17.2.4), and Retry (Section 17.2.5). Version negotiation 3159 uses a version-independent packet with a long header (see 3160 Section 17.2.1). 3162 Packets with the short header (Section 17.3) are designed for minimal 3163 overhead and are used after a connection is established and 1-RTT 3164 keys are available. 3166 12.1. Protected Packets 3168 All QUIC packets except Version Negotiation packets use authenticated 3169 encryption with additional data (AEAD) [RFC5116] to provide 3170 confidentiality and integrity protection. Retry packets use an AEAD 3171 to provide integrity protection. Details of packet protection are 3172 found in [QUIC-TLS]; this section includes an overview of the 3173 process. 3175 Initial packets are protected using keys that are statically derived. 3176 This packet protection is not effective confidentiality protection. 3177 Initial protection only exists to ensure that the sender of the 3178 packet is on the network path. Any entity that receives the Initial 3179 packet from a client can recover the keys necessary to remove packet 3180 protection or to generate packets that will be successfully 3181 authenticated. 3183 All other packets are protected with keys derived from the 3184 cryptographic handshake. The type of the packet from the long header 3185 or key phase from the short header are used to identify which 3186 encryption level - and therefore the keys - that are used. Packets 3187 protected with 0-RTT and 1-RTT keys are expected to have 3188 confidentiality and data origin authentication; the cryptographic 3189 handshake ensures that only the communicating endpoints receive the 3190 corresponding keys. 3192 The packet number field contains a packet number, which has 3193 additional confidentiality protection that is applied after packet 3194 protection is applied (see [QUIC-TLS] for details). The underlying 3195 packet number increases with each packet sent in a given packet 3196 number space; see Section 12.3 for details. 3198 12.2. Coalescing Packets 3200 Initial (Section 17.2.2), 0-RTT (Section 17.2.3), and Handshake 3201 (Section 17.2.4) packets contain a Length field, which determines the 3202 end of the packet. The length includes both the Packet Number and 3203 Payload fields, both of which are confidentiality protected and 3204 initially of unknown length. The length of the Payload field is 3205 learned once header protection is removed. 3207 Using the Length field, a sender can coalesce multiple QUIC packets 3208 into one UDP datagram. This can reduce the number of UDP datagrams 3209 needed to complete the cryptographic handshake and start sending 3210 data. This can also be used to construct PMTU probes (see 3211 Section 14.3.1). Receivers MUST be able to process coalesced 3212 packets. 3214 Coalescing packets in order of increasing encryption levels (Initial, 3215 0-RTT, Handshake, 1-RTT) makes it more likely the receiver will be 3216 able to process all the packets in a single pass. A packet with a 3217 short header does not include a length, so it can only be the last 3218 packet included in a UDP datagram. An endpoint SHOULD NOT coalesce 3219 multiple packets at the same encryption level. 3221 Senders MUST NOT coalesce QUIC packets for different connections into 3222 a single UDP datagram. Receivers SHOULD ignore any subsequent 3223 packets with a different Destination Connection ID than the first 3224 packet in the datagram. 3226 Every QUIC packet that is coalesced into a single UDP datagram is 3227 separate and complete. The receiver of coalesced QUIC packets MUST 3228 individually process each QUIC packet and separately acknowledge 3229 them, as if they were received as the payload of different UDP 3230 datagrams. For example, if decryption fails (because the keys are 3231 not available or any other reason), the receiver MAY either discard 3232 or buffer the packet for later processing and MUST attempt to process 3233 the remaining packets. 3235 Retry packets (Section 17.2.5), Version Negotiation packets 3236 (Section 17.2.1), and packets with a short header (Section 17.3) do 3237 not contain a Length field and so cannot be followed by other packets 3238 in the same UDP datagram. Note also that there is no situation where 3239 a Retry or Version Negotiation packet is coalesced with another 3240 packet. 3242 12.3. Packet Numbers 3244 The packet number is an integer in the range 0 to 2^62-1. This 3245 number is used in determining the cryptographic nonce for packet 3246 protection. Each endpoint maintains a separate packet number for 3247 sending and receiving. 3249 Packet numbers are limited to this range because they need to be 3250 representable in whole in the Largest Acknowledged field of an ACK 3251 frame (Section 19.3). When present in a long or short header 3252 however, packet numbers are reduced and encoded in 1 to 4 bytes (see 3253 Section 17.1). 3255 Version Negotiation (Section 17.2.1) and Retry (Section 17.2.5) 3256 packets do not include a packet number. 3258 Packet numbers are divided into 3 spaces in QUIC: 3260 * Initial space: All Initial packets (Section 17.2.2) are in this 3261 space. 3263 * Handshake space: All Handshake packets (Section 17.2.4) are in 3264 this space. 3266 * Application data space: All 0-RTT and 1-RTT encrypted packets 3267 (Section 12.1) are in this space. 3269 As described in [QUIC-TLS], each packet type uses different 3270 protection keys. 3272 Conceptually, a packet number space is the context in which a packet 3273 can be processed and acknowledged. Initial packets can only be sent 3274 with Initial packet protection keys and acknowledged in packets which 3275 are also Initial packets. Similarly, Handshake packets are sent at 3276 the Handshake encryption level and can only be acknowledged in 3277 Handshake packets. 3279 This enforces cryptographic separation between the data sent in the 3280 different packet sequence number spaces. Packet numbers in each 3281 space start at packet number 0. Subsequent packets sent in the same 3282 packet number space MUST increase the packet number by at least one. 3284 0-RTT and 1-RTT data exist in the same packet number space to make 3285 loss recovery algorithms easier to implement between the two packet 3286 types. 3288 A QUIC endpoint MUST NOT reuse a packet number within the same packet 3289 number space in one connection. If the packet number for sending 3290 reaches 2^62 - 1, the sender MUST close the connection without 3291 sending a CONNECTION_CLOSE frame or any further packets; an endpoint 3292 MAY send a Stateless Reset (Section 10.4) in response to further 3293 packets that it receives. 3295 A receiver MUST discard a newly unprotected packet unless it is 3296 certain that it has not processed another packet with the same packet 3297 number from the same packet number space. Duplicate suppression MUST 3298 happen after removing packet protection for the reasons described in 3299 Section 9.3 of [QUIC-TLS]. An efficient algorithm for duplicate 3300 suppression can be found in Section 3.4.3 of [RFC4303]. 3302 Packet number encoding at a sender and decoding at a receiver are 3303 described in Section 17.1. 3305 12.4. Frames and Frame Types 3307 The payload of QUIC packets, after removing packet protection, 3308 consists of a sequence of complete frames, as shown in Figure 7. 3309 Version Negotiation, Stateless Reset, and Retry packets do not 3310 contain frames. 3312 0 1 2 3 3313 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 3314 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3315 | Frame 1 (*) ... 3316 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3317 | Frame 2 (*) ... 3318 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3319 ... 3320 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3321 | Frame N (*) ... 3322 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3324 Figure 7: QUIC Payload 3326 The payload of a packet that contains frames MUST contain at least 3327 one frame, and MAY contain multiple frames and multiple frame types. 3328 Frames always fit within a single QUIC packet and cannot span 3329 multiple packets. 3331 Each frame begins with a Frame Type, indicating its type, followed by 3332 additional type-dependent fields: 3334 0 1 2 3 3335 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 3336 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3337 | Frame Type (i) ... 3338 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3339 | Type-Dependent Fields (*) ... 3340 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3342 Figure 8: Generic Frame Layout 3344 The frame types defined in this specification are listed in Table 3. 3345 The Frame Type in ACK, STREAM, MAX_STREAMS, STREAMS_BLOCKED, and 3346 CONNECTION_CLOSE frames is used to carry other frame-specific flags. 3347 For all other frames, the Frame Type field simply identifies the 3348 frame. These frames are explained in more detail in Section 19. 3350 +-------------+----------------------+---------------+---------+ 3351 | Type Value | Frame Type Name | Definition | Packets | 3352 +=============+======================+===============+=========+ 3353 | 0x00 | PADDING | Section 19.1 | IH01 | 3354 +-------------+----------------------+---------------+---------+ 3355 | 0x01 | PING | Section 19.2 | IH01 | 3356 +-------------+----------------------+---------------+---------+ 3357 | 0x02 - 0x03 | ACK | Section 19.3 | IH_1 | 3358 +-------------+----------------------+---------------+---------+ 3359 | 0x04 | RESET_STREAM | Section 19.4 | __01 | 3360 +-------------+----------------------+---------------+---------+ 3361 | 0x05 | STOP_SENDING | Section 19.5 | __01 | 3362 +-------------+----------------------+---------------+---------+ 3363 | 0x06 | CRYPTO | Section 19.6 | IH_1 | 3364 +-------------+----------------------+---------------+---------+ 3365 | 0x07 | NEW_TOKEN | Section 19.7 | ___1 | 3366 +-------------+----------------------+---------------+---------+ 3367 | 0x08 - 0x0f | STREAM | Section 19.8 | __01 | 3368 +-------------+----------------------+---------------+---------+ 3369 | 0x10 | MAX_DATA | Section 19.9 | __01 | 3370 +-------------+----------------------+---------------+---------+ 3371 | 0x11 | MAX_STREAM_DATA | Section 19.10 | __01 | 3372 +-------------+----------------------+---------------+---------+ 3373 | 0x12 - 0x13 | MAX_STREAMS | Section 19.11 | __01 | 3374 +-------------+----------------------+---------------+---------+ 3375 | 0x14 | DATA_BLOCKED | Section 19.12 | __01 | 3376 +-------------+----------------------+---------------+---------+ 3377 | 0x15 | STREAM_DATA_BLOCKED | Section 19.13 | __01 | 3378 +-------------+----------------------+---------------+---------+ 3379 | 0x16 - 0x17 | STREAMS_BLOCKED | Section 19.14 | __01 | 3380 +-------------+----------------------+---------------+---------+ 3381 | 0x18 | NEW_CONNECTION_ID | Section 19.15 | __01 | 3382 +-------------+----------------------+---------------+---------+ 3383 | 0x19 | RETIRE_CONNECTION_ID | Section 19.16 | __01 | 3384 +-------------+----------------------+---------------+---------+ 3385 | 0x1a | PATH_CHALLENGE | Section 19.17 | __01 | 3386 +-------------+----------------------+---------------+---------+ 3387 | 0x1b | PATH_RESPONSE | Section 19.18 | __01 | 3388 +-------------+----------------------+---------------+---------+ 3389 | 0x1c - 0x1d | CONNECTION_CLOSE | Section 19.19 | IH_1* | 3390 +-------------+----------------------+---------------+---------+ 3391 | 0x1e | HANDSHAKE_DONE | Section 19.20 | ___1 | 3392 +-------------+----------------------+---------------+---------+ 3394 Table 3: Frame Types 3396 The "Packets" column in Table 3 does not form part of the IANA 3397 registry (see Section 22.3). This column summarizes the types of 3398 packets that each frame type can appear in, indicated as up to four 3399 characters indicating: 3401 I: Initial (Section 17.2.2) 3403 H: Handshake (Section 17.2.4) 3405 0: 0-RTT (Section 17.2.3) 3407 1: 1-RTT (Section 17.3) 3409 *: A CONNECTION_CLOSE frame of type 0x1c can appear in Initial, 3410 Handshake, and 1-RTT packets, whereas a CONNECTION_CLOSE of type 3411 0x1d can only appear in a 1-RTT packet. 3413 Section 4 of [QUIC-TLS] provides more detail about these 3414 restrictions. Note that all frames can appear in 1-RTT packets. 3416 An endpoint MUST treat the receipt of a frame of unknown type as a 3417 connection error of type FRAME_ENCODING_ERROR. 3419 All QUIC frames are idempotent in this version of QUIC. That is, a 3420 valid frame does not cause undesirable side effects or errors when 3421 received more than once. 3423 The Frame Type field uses a variable length integer encoding (see 3424 Section 16) with one exception. To ensure simple and efficient 3425 implementations of frame parsing, a frame type MUST use the shortest 3426 possible encoding. Though a two-, four- or eight-byte encoding of 3427 the frame types defined in this document is possible, the Frame Type 3428 field for these frames is encoded on a single byte. For instance, 3429 though 0x4001 is a legitimate two-byte encoding for a variable-length 3430 integer with a value of 1, PING frames are always encoded as a single 3431 byte with the value 0x01. An endpoint MAY treat the receipt of a 3432 frame type that uses a longer encoding than necessary as a connection 3433 error of type PROTOCOL_VIOLATION. 3435 13. Packetization and Reliability 3437 A sender bundles one or more frames in a QUIC packet (see 3438 Section 12.4). 3440 A sender can minimize per-packet bandwidth and computational costs by 3441 bundling as many frames as possible within a QUIC packet. A sender 3442 MAY wait for a short period of time to bundle multiple frames before 3443 sending a packet that is not maximally packed, to avoid sending out 3444 large numbers of small packets. An implementation MAY use knowledge 3445 about application sending behavior or heuristics to determine whether 3446 and for how long to wait. This waiting period is an implementation 3447 decision, and an implementation should be careful to delay 3448 conservatively, since any delay is likely to increase application- 3449 visible latency. 3451 Stream multiplexing is achieved by interleaving STREAM frames from 3452 multiple streams into one or more QUIC packets. A single QUIC packet 3453 can include multiple STREAM frames from one or more streams. 3455 One of the benefits of QUIC is avoidance of head-of-line blocking 3456 across multiple streams. When a packet loss occurs, only streams 3457 with data in that packet are blocked waiting for a retransmission to 3458 be received, while other streams can continue making progress. Note 3459 that when data from multiple streams is bundled into a single QUIC 3460 packet, loss of that packet blocks all those streams from making 3461 progress. Implementations are advised to bundle as few streams as 3462 necessary in outgoing packets without losing transmission efficiency 3463 to underfilled packets. 3465 13.1. Packet Processing 3467 A packet MUST NOT be acknowledged until packet protection has been 3468 successfully removed and all frames contained in the packet have been 3469 processed. For STREAM frames, this means the data has been enqueued 3470 in preparation to be received by the application protocol, but it 3471 does not require that data is delivered and consumed. 3473 Once the packet has been fully processed, a receiver acknowledges 3474 receipt by sending one or more ACK frames containing the packet 3475 number of the received packet. 3477 13.2. Generating Acknowledgements 3479 Endpoints acknowledge all packets they receive and process. However, 3480 only ack-eliciting packets cause an ACK frame to be sent within the 3481 maximum ack delay. Packets that are not ack-eliciting are only 3482 acknowledged when an ACK frame is sent for other reasons. 3484 When sending a packet for any reason, an endpoint should attempt to 3485 bundle an ACK frame if one has not been sent recently. Doing so 3486 helps with timely loss detection at the peer. 3488 In general, frequent feedback from a receiver improves loss and 3489 congestion response, but this has to be balanced against excessive 3490 load generated by a receiver that sends an ACK frame in response to 3491 every ack-eliciting packet. The guidance offered below seeks to 3492 strike this balance. 3494 13.2.1. Sending ACK Frames 3496 Every packet SHOULD be acknowledged at least once, and ack-eliciting 3497 packets MUST be acknowledged at least once within the maximum ack 3498 delay. An endpoint communicates its maximum delay using the 3499 max_ack_delay transport parameter; see Section 18.2. max_ack_delay 3500 declares an explicit contract: an endpoint promises to never 3501 intentionally delay acknowledgments of an ack-eliciting packet by 3502 more than the indicated value. If it does, any excess accrues to the 3503 RTT estimate and could result in spurious or delayed retransmissions 3504 from the peer. For Initial and Handshake packets, a max_ack_delay of 3505 0 is used. The sender uses the receiver's "max_ack_delay" value in 3506 determining timeouts for timer-based retransmission, as detailed in 3507 Section 5.2.1 of [QUIC-RECOVERY]. 3509 An ACK frame SHOULD be generated for at least every second ack- 3510 eliciting packet. This recommendation is in keeping with standard 3511 practice for TCP [RFC5681]. 3513 In order to assist loss detection at the sender, an endpoint SHOULD 3514 send an ACK frame immediately on receiving an ack-eliciting packet 3515 that is out of order. The endpoint MAY continue sending ACK frames 3516 immediately on each subsequently received packet, but the endpoint 3517 SHOULD return to acknowledging every other packet within a period of 3518 1/8 x RTT, unless more ack-eliciting packets are received out of 3519 order. If every subsequent ack-eliciting packet arrives out of 3520 order, then an ACK frame SHOULD be sent immediately for every 3521 received ack-eliciting packet. 3523 Similarly, packets marked with the ECN Congestion Experienced (CE) 3524 codepoint in the IP header SHOULD be acknowledged immediately, to 3525 reduce the peer's response time to congestion events. 3527 As an optimization, a receiver MAY process multiple packets before 3528 sending any ACK frames in response. In this case the receiver can 3529 determine whether an immediate or delayed acknowledgement should be 3530 generated after processing incoming packets. 3532 Packets containing PADDING frames are considered to be in flight for 3533 congestion control purposes [QUIC-RECOVERY]. Sending only PADDING 3534 frames might cause the sender to become limited by the congestion 3535 controller with no acknowledgments forthcoming from the receiver. 3536 Therefore, a sender SHOULD ensure that other frames are sent in 3537 addition to PADDING frames to elicit acknowledgments from the 3538 receiver. 3540 An endpoint that is only sending ACK frames will not receive 3541 acknowledgments from its peer unless those acknowledgements are 3542 included in packets with ack-eliciting frames. An endpoint SHOULD 3543 bundle ACK frames with other frames when there are new ack-eliciting 3544 packets to acknowledge. When only non-ack-eliciting packets need to 3545 be acknowledged, an endpoint MAY wait until an ack-eliciting packet 3546 has been received to bundle an ACK frame with outgoing frames. 3548 The algorithms in [QUIC-RECOVERY] are resilient to receivers that do 3549 not follow guidance offered above. However, an implementor should 3550 only deviate from these requirements after careful consideration of 3551 the performance implications of doing so. 3553 Packets containing only ACK frames are not congestion controlled, so 3554 there are limits on how frequently they can be sent. An endpoint 3555 MUST NOT send more than one ACK-frame-only packet in response to 3556 receiving an ack-eliciting packet. An endpoint MUST NOT send a non- 3557 ack-eliciting packet in response to a non-ack-eliciting packet, even 3558 if there are packet gaps which precede the received packet. Limiting 3559 ACK frames avoids an infinite feedback loop of acknowledgements, 3560 which could prevent the connection from ever becoming idle. However, 3561 the endpoint acknowledges non-ACK-eliciting packets when it sends an 3562 ACK frame. 3564 An endpoint SHOULD treat receipt of an acknowledgment for a packet it 3565 did not send as a connection error of type PROTOCOL_VIOLATION, if it 3566 is able to detect the condition. 3568 13.2.2. Managing ACK Ranges 3570 When an ACK frame is sent, one or more ranges of acknowledged packets 3571 are included. Including older packets reduces the chance of spurious 3572 retransmits caused by losing previously sent ACK frames, at the cost 3573 of larger ACK frames. 3575 ACK frames SHOULD always acknowledge the most recently received 3576 packets, and the more out-of-order the packets are, the more 3577 important it is to send an updated ACK frame quickly, to prevent the 3578 peer from declaring a packet as lost and spuriously retransmitting 3579 the frames it contains. An ACK frame is expected to fit within a 3580 single QUIC packet. If it does not, then older ranges (those with 3581 the smallest packet numbers) are omitted. 3583 Section 13.2.3 and Section 13.2.4 describe an exemplary approach for 3584 determining what packets to acknowledge in each ACK frame. 3586 13.2.3. Receiver Tracking of ACK Frames 3588 When a packet containing an ACK frame is sent, the largest 3589 acknowledged in that frame may be saved. When a packet containing an 3590 ACK frame is acknowledged, the receiver can stop acknowledging 3591 packets less than or equal to the largest acknowledged in the sent 3592 ACK frame. 3594 In cases without ACK frame loss, this algorithm allows for a minimum 3595 of 1 RTT of reordering. In cases with ACK frame loss and reordering, 3596 this approach does not guarantee that every acknowledgement is seen 3597 by the sender before it is no longer included in the ACK frame. 3598 Packets could be received out of order and all subsequent ACK frames 3599 containing them could be lost. In this case, the loss recovery 3600 algorithm could cause spurious retransmits, but the sender will 3601 continue making forward progress. 3603 13.2.4. Limiting ACK Ranges 3605 To limit ACK Ranges (see Section 19.3.1) to those that have not yet 3606 been received by the sender, the receiver SHOULD track which ACK 3607 frames have been acknowledged by its peer. The receiver SHOULD 3608 exclude already acknowledged packets from future ACK frames whenever 3609 these packets would unnecessarily contribute to the ACK frame size. 3610 When the receiver is only sending non-ack-eliciting packets, it can 3611 bundle a PING or other small ack-eliciting frame with a fraction of 3612 them, such as once per round trip, to enable dropping unnecessary ACK 3613 ranges and any state for previously sent packets. The receiver MUST 3614 NOT bundle an ack-eliciting frame, such as a PING, with all packets 3615 that would otherwise be non-ack-eliciting, in order to avoid an 3616 infinite feedback loop of acknowledgements. 3618 To limit receiver state or the size of ACK frames, a receiver MAY 3619 limit the number of ACK Ranges it sends. A receiver can do this even 3620 without receiving acknowledgment of its ACK frames, with the 3621 knowledge this could cause the sender to unnecessarily retransmit 3622 some data. Standard QUIC algorithms ([QUIC-RECOVERY]) declare 3623 packets lost after sufficiently newer packets are acknowledged. 3624 Therefore, the receiver SHOULD repeatedly acknowledge newly received 3625 packets in preference to packets received in the past. 3627 13.2.5. Measuring and Reporting Host Delay 3629 An endpoint measures the delays intentionally introduced between when 3630 the packet with the largest packet number is received and an 3631 acknowledgment is sent. The endpoint encodes this delay in the Ack 3632 Delay field of an ACK frame (see Section 19.3). This allows the 3633 receiver of the ACK to adjust for any intentional delays, which is 3634 important for getting a better estimate of the path RTT when 3635 acknowledgments are delayed. A packet might be held in the OS kernel 3636 or elsewhere on the host before being processed. An endpoint MUST 3637 NOT include delays that it does not control when populating the Ack 3638 Delay field in an ACK frame. 3640 13.2.6. ACK Frames and Packet Protection 3642 ACK frames MUST only be carried in a packet that has the same packet 3643 number space as the packet being ACKed (see Section 12.1). For 3644 instance, packets that are protected with 1-RTT keys MUST be 3645 acknowledged in packets that are also protected with 1-RTT keys. 3647 Packets that a client sends with 0-RTT packet protection MUST be 3648 acknowledged by the server in packets protected by 1-RTT keys. This 3649 can mean that the client is unable to use these acknowledgments if 3650 the server cryptographic handshake messages are delayed or lost. 3651 Note that the same limitation applies to other data sent by the 3652 server protected by the 1-RTT keys. 3654 13.3. Retransmission of Information 3656 QUIC packets that are determined to be lost are not retransmitted 3657 whole. The same applies to the frames that are contained within lost 3658 packets. Instead, the information that might be carried in frames is 3659 sent again in new frames as needed. 3661 New frames and packets are used to carry information that is 3662 determined to have been lost. In general, information is sent again 3663 when a packet containing that information is determined to be lost 3664 and sending ceases when a packet containing that information is 3665 acknowledged. 3667 * Data sent in CRYPTO frames is retransmitted according to the rules 3668 in [QUIC-RECOVERY], until all data has been acknowledged. Data in 3669 CRYPTO frames for Initial and Handshake packets is discarded when 3670 keys for the corresponding encryption level are discarded. 3672 * Application data sent in STREAM frames is retransmitted in new 3673 STREAM frames unless the endpoint has sent a RESET_STREAM for that 3674 stream. Once an endpoint sends a RESET_STREAM frame, no further 3675 STREAM frames are needed. 3677 * ACK frames carry the most recent set of acknowledgements and the 3678 Ack Delay from the largest acknowledged packet, as described in 3679 Section 13.2.1. Delaying the transmission of packets containing 3680 ACK frames or sending old ACK frames can cause the peer to 3681 generate an inflated RTT sample or unnecessarily disable ECN. 3683 * Cancellation of stream transmission, as carried in a RESET_STREAM 3684 frame, is sent until acknowledged or until all stream data is 3685 acknowledged by the peer (that is, either the "Reset Recvd" or 3686 "Data Recvd" state is reached on the sending part of the stream). 3687 The content of a RESET_STREAM frame MUST NOT change when it is 3688 sent again. 3690 * Similarly, a request to cancel stream transmission, as encoded in 3691 a STOP_SENDING frame, is sent until the receiving part of the 3692 stream enters either a "Data Recvd" or "Reset Recvd" state; see 3693 Section 3.5. 3695 * Connection close signals, including packets that contain 3696 CONNECTION_CLOSE frames, are not sent again when packet loss is 3697 detected, but as described in Section 10. 3699 * The current connection maximum data is sent in MAX_DATA frames. 3700 An updated value is sent in a MAX_DATA frame if the packet 3701 containing the most recently sent MAX_DATA frame is declared lost, 3702 or when the endpoint decides to update the limit. Care is 3703 necessary to avoid sending this frame too often as the limit can 3704 increase frequently and cause an unnecessarily large number of 3705 MAX_DATA frames to be sent. 3707 * The current maximum stream data offset is sent in MAX_STREAM_DATA 3708 frames. Like MAX_DATA, an updated value is sent when the packet 3709 containing the most recent MAX_STREAM_DATA frame for a stream is 3710 lost or when the limit is updated, with care taken to prevent the 3711 frame from being sent too often. An endpoint SHOULD stop sending 3712 MAX_STREAM_DATA frames when the receiving part of the stream 3713 enters a "Size Known" state. 3715 * The limit on streams of a given type is sent in MAX_STREAMS 3716 frames. Like MAX_DATA, an updated value is sent when a packet 3717 containing the most recent MAX_STREAMS for a stream type frame is 3718 declared lost or when the limit is updated, with care taken to 3719 prevent the frame from being sent too often. 3721 * Blocked signals are carried in DATA_BLOCKED, STREAM_DATA_BLOCKED, 3722 and STREAMS_BLOCKED frames. DATA_BLOCKED frames have connection 3723 scope, STREAM_DATA_BLOCKED frames have stream scope, and 3724 STREAMS_BLOCKED frames are scoped to a specific stream type. New 3725 frames are sent if packets containing the most recent frame for a 3726 scope is lost, but only while the endpoint is blocked on the 3727 corresponding limit. These frames always include the limit that 3728 is causing blocking at the time that they are transmitted. 3730 * A liveness or path validation check using PATH_CHALLENGE frames is 3731 sent periodically until a matching PATH_RESPONSE frame is received 3732 or until there is no remaining need for liveness or path 3733 validation checking. PATH_CHALLENGE frames include a different 3734 payload each time they are sent. 3736 * Responses to path validation using PATH_RESPONSE frames are sent 3737 just once. The peer is expected to send more PATH_CHALLENGE 3738 frames as necessary to evoke additional PATH_RESPONSE frames. 3740 * New connection IDs are sent in NEW_CONNECTION_ID frames and 3741 retransmitted if the packet containing them is lost. 3742 Retransmissions of this frame carry the same sequence number 3743 value. Likewise, retired connection IDs are sent in 3744 RETIRE_CONNECTION_ID frames and retransmitted if the packet 3745 containing them is lost. 3747 * NEW_TOKEN frames are retransmitted if the packet containing them 3748 is lost. No special support is made for detecting reordered and 3749 duplicated NEW_TOKEN frames other than a direct comparison of the 3750 frame contents. 3752 * PING and PADDING frames contain no information, so lost PING or 3753 PADDING frames do not require repair. 3755 * The HANDSHAKE_DONE frame MUST be retransmitted until it is 3756 acknowledged. 3758 Endpoints SHOULD prioritize retransmission of data over sending new 3759 data, unless priorities specified by the application indicate 3760 otherwise (see Section 2.3). 3762 Even though a sender is encouraged to assemble frames containing up- 3763 to-date information every time it sends a packet, it is not forbidden 3764 to retransmit copies of frames from lost packets. A receiver MUST 3765 accept packets containing an outdated frame, such as a MAX_DATA frame 3766 carrying a smaller maximum data than one found in an older packet. 3768 Upon detecting losses, a sender MUST take appropriate congestion 3769 control action. The details of loss detection and congestion control 3770 are described in [QUIC-RECOVERY]. 3772 13.4. Explicit Congestion Notification 3774 QUIC endpoints can use Explicit Congestion Notification (ECN) 3775 [RFC3168] to detect and respond to network congestion. ECN allows a 3776 network node to indicate congestion in the network by setting a 3777 codepoint in the IP header of a packet instead of dropping it. 3778 Endpoints react to congestion by reducing their sending rate in 3779 response, as described in [QUIC-RECOVERY]. 3781 To use ECN, QUIC endpoints first determine whether a path supports 3782 ECN marking and the peer is able to access the ECN codepoint in the 3783 IP header. A network path does not support ECN if ECN marked packets 3784 get dropped or ECN markings are rewritten on the path. An endpoint 3785 validates the use of ECN on the path, both during connection 3786 establishment and when migrating to a new path (Section 9). 3788 13.4.1. ECN Counts 3790 On receiving a QUIC packet with an ECT or CE codepoint, an ECN- 3791 enabled endpoint that can access the ECN codepoints from the 3792 enclosing IP packet increases the corresponding ECT(0), ECT(1), or CE 3793 count, and includes these counts in subsequent ACK frames (see 3794 Section 13.2 and Section 19.3). Note that this requires being able 3795 to read the ECN codepoints from the enclosing IP packet, which is not 3796 possible on all platforms. 3798 A packet detected by a receiver as a duplicate does not affect the 3799 receiver's local ECN codepoint counts; see (Section 21.8) for 3800 relevant security concerns. 3802 If an endpoint receives a QUIC packet without an ECT or CE codepoint 3803 in the IP packet header, it responds per Section 13.2 with an ACK 3804 frame without increasing any ECN counts. If an endpoint does not 3805 implement ECN support or does not have access to received ECN 3806 codepoints, it does not increase ECN counts. 3808 Coalesced packets (see Section 12.2) mean that several packets can 3809 share the same IP header. The ECN counter for the ECN codepoint 3810 received in the associated IP header are incremented once for each 3811 QUIC packet, not per enclosing IP packet or UDP datagram. 3813 Each packet number space maintains separate acknowledgement state and 3814 separate ECN counts. For example, if one each of an Initial, 0-RTT, 3815 Handshake, and 1-RTT QUIC packet are coalesced, the corresponding 3816 counts for the Initial and Handshake packet number space will be 3817 incremented by one and the counts for the 1-RTT packet number space 3818 will be increased by two. 3820 13.4.2. ECN Validation 3822 It is possible for faulty network devices to corrupt or erroneously 3823 drop packets with ECN markings. To provide robust connectivity in 3824 the presence of such devices, each endpoint independently validates 3825 ECN counts and disables ECN if errors are detected. 3827 Endpoints validate ECN for packets sent on each network path 3828 independently. An endpoint thus validates ECN on new connection 3829 establishment, when switching to a new server preferred address, and 3830 on active connection migration to a new path. Appendix B describes 3831 one possible algorithm for testing paths for ECN support. 3833 Even if an endpoint does not use ECN markings on packets it 3834 transmits, the endpoint MUST provide feedback about ECN markings 3835 received from the peer if they are accessible. Failing to report ECN 3836 counts will cause the peer to disable ECN marking. 3838 13.4.2.1. Sending ECN Markings 3840 To start ECN validation, an endpoint SHOULD do the following when 3841 sending packets on a new path to a peer: 3843 * Set the ECT(0) codepoint in the IP header of early outgoing 3844 packets sent on a new path to the peer [RFC8311]. 3846 * If all packets that were sent with the ECT(0) codepoint are 3847 eventually deemed lost [QUIC-RECOVERY], validation is deemed to 3848 have failed. 3850 To reduce the chances of misinterpreting congestive loss as packets 3851 dropped by a faulty network element, an endpoint could set the ECT(0) 3852 codepoint in the first ten outgoing packets on a path, or for a 3853 period of three RTTs, whichever occurs first. 3855 Implementations MAY experiment with and use other strategies for use 3856 of ECN. Other methods of probing paths for ECN support are possible, 3857 as are different marking strategies. Implementations can also use 3858 the ECT(1) codepoint, as specified in [RFC8311]. 3860 13.4.2.2. Receiving ACK Frames 3862 An endpoint that sets ECT(0) or ECT(1) codepoints on packets it 3863 transmits MUST use the following steps on receiving an ACK frame to 3864 validate ECN. 3866 * If this ACK frame newly acknowledges a packet that the endpoint 3867 sent with either ECT(0) or ECT(1) codepoints set, and if no ECN 3868 feedback is present in the ACK frame, validation fails. This step 3869 protects against both a network element that zeroes out ECN bits 3870 and a peer that is unable to access ECN markings, since the peer 3871 could respond without ECN feedback in these cases. 3873 * For validation to succeed, the total increase in ECT(0), ECT(1), 3874 and CE counts MUST be no smaller than the total number of QUIC 3875 packets sent with an ECT codepoint that are newly acknowledged in 3876 this ACK frame. This step detects any network remarking from 3877 ECT(0), ECT(1), or CE codepoints to Not-ECT. 3879 * Any increase in either ECT(0) or ECT(1) counts, plus any increase 3880 in the CE count, MUST be no smaller than the number of packets 3881 sent with the corresponding ECT codepoint that are newly 3882 acknowledged in this ACK frame. This step detects any erroneous 3883 network remarking from ECT(0) to ECT(1) (or vice versa). 3885 Processing ECN counts out of order can result in validation failure. 3886 An endpoint SHOULD NOT perform this validation if this ACK frame does 3887 not advance the largest packet number acknowledged in this 3888 connection. 3890 An endpoint could miss acknowledgements for a packet when ACK frames 3891 are lost. It is therefore possible for the total increase in ECT(0), 3892 ECT(1), and CE counts to be greater than the number of packets 3893 acknowledged in an ACK frame. When this happens, and if validation 3894 succeeds, the local reference counts MUST be increased to match the 3895 counts in the ACK frame. 3897 13.4.2.3. Validation Outcomes 3899 If validation fails, then the endpoint stops sending ECN markings in 3900 subsequent IP packets with the expectation that either the network 3901 path or the peer does not support ECN. 3903 Upon successful validation, an endpoint can continue to set ECT 3904 codepoints in subsequent packets with the expectation that the path 3905 is ECN-capable. Network routing and path elements can change mid- 3906 connection however; an endpoint MUST disable ECN if validation fails 3907 at any point in the connection. 3909 Even if validation fails, an endpoint MAY revalidate ECN on the same 3910 path at any later time in the connection. 3912 14. Packet Size 3914 The QUIC packet size includes the QUIC header and protected payload, 3915 but not the UDP or IP header. 3917 A client MUST expand the payload of all UDP datagrams carrying 3918 Initial packets to at least 1200 bytes, by adding PADDING frames to 3919 the Initial packet or by coalescing the Initial packet (see 3920 Section 12.2). Sending a UDP datagram of this size ensures that the 3921 network path from the client to the server supports a reasonable 3922 Maximum Transmission Unit (MTU). Padding datagrams also helps reduce 3923 the amplitude of amplification attacks caused by server responses 3924 toward an unverified client address; see Section 8. 3926 Datagrams containing Initial packets MAY exceed 1200 bytes if the 3927 client believes that the Path Maximum Transmission Unit (PMTU) 3928 supports the size that it chooses. 3930 UDP datagrams MUST NOT be fragmented at the IP layer. In IPv4 3931 [IPv4], the DF bit MUST be set to prevent fragmentation on the path. 3933 A server MAY send a CONNECTION_CLOSE frame with error code 3934 PROTOCOL_VIOLATION in response to an Initial packet it receives from 3935 a client if the UDP datagram is smaller than 1200 bytes. It MUST NOT 3936 send any other frame type in response, or otherwise behave as if any 3937 part of the offending packet was processed as valid. 3939 The server MUST also limit the number of bytes it sends before 3940 validating the address of the client; see Section 8. 3942 14.1. Path Maximum Transmission Unit (PMTU) 3944 The PMTU is the maximum size of the entire IP packet including the IP 3945 header, UDP header, and UDP payload. The UDP payload includes the 3946 QUIC packet header, protected payload, and any authentication fields. 3947 The PMTU can depend upon the current path characteristics. 3948 Therefore, the current largest UDP payload an implementation will 3949 send is referred to as the QUIC maximum packet size. 3951 QUIC depends on a PMTU of at least 1280 bytes. This is the IPv6 3952 minimum size [RFC8200] and is also supported by most modern IPv4 3953 networks. All QUIC packets (except for PMTU probe packets) SHOULD be 3954 sized to fit within the maximum packet size to avoid the packet being 3955 fragmented or dropped [RFC8085]. 3957 An endpoint SHOULD use Datagram Packetization Layer PMTU Discovery 3958 ([DPLPMTUD]) or implement Path MTU Discovery (PMTUD) [RFC1191] 3959 [RFC8201] to determine whether the path to a destination will support 3960 a desired message size without fragmentation. 3962 In the absence of these mechanisms, QUIC endpoints SHOULD NOT send IP 3963 packets larger than 1280 bytes. Assuming the minimum IP header size, 3964 this results in a QUIC maximum packet size of 1232 bytes for IPv6 and 3965 1252 bytes for IPv4. A QUIC implementation MAY be more conservative 3966 in computing the QUIC maximum packet size to allow for unknown tunnel 3967 overheads or IP header options/extensions. 3969 Each pair of local and remote addresses could have a different PMTU. 3970 QUIC implementations that implement any kind of PMTU discovery 3971 therefore SHOULD maintain a maximum packet size for each combination 3972 of local and remote IP addresses. 3974 If a QUIC endpoint determines that the PMTU between any pair of local 3975 and remote IP addresses has fallen below the size needed to support 3976 the smallest allowed maximum packet size, it MUST immediately cease 3977 sending QUIC packets, except for PMTU probe packets, on the affected 3978 path. An endpoint MAY terminate the connection if an alternative 3979 path cannot be found. 3981 14.2. ICMP Packet Too Big Messages 3983 PMTU discovery [RFC1191] [RFC8201] relies on reception of ICMP 3984 messages (e.g., IPv6 Packet Too Big messages) that indicate when a 3985 packet is dropped because it is larger than the local router MTU. 3986 DPLPMTUD can also optionally use these messages. This use of ICMP 3987 messages is potentially vulnerable to off-path attacks that 3988 successfully guess the addresses used on the path and reduce the PMTU 3989 to a bandwidth-inefficient value. 3991 An endpoint MUST ignore an ICMP message that claims the PMTU has 3992 decreased below 1280 bytes. 3994 The requirements for generating ICMP ([RFC1812], [RFC4443]) state 3995 that the quoted packet should contain as much of the original packet 3996 as possible without exceeding the minimum MTU for the IP version. 3997 The size of the quoted packet can actually be smaller, or the 3998 information unintelligible, as described in Section 1.1 of 3999 [DPLPMTUD]. 4001 QUIC endpoints SHOULD validate ICMP messages to protect from off-path 4002 injection as specified in [RFC8201] and Section 5.2 of [RFC8085]. 4003 This validation SHOULD use the quoted packet supplied in the payload 4004 of an ICMP message to associate the message with a corresponding 4005 transport connection [DPLPMTUD]. 4007 ICMP message validation MUST include matching IP addresses and UDP 4008 ports [RFC8085] and, when possible, connection IDs to an active QUIC 4009 session. 4011 Further validation can also be provided: 4013 * An IPv4 endpoint could set the Don't Fragment (DF) bit on a small 4014 proportion of packets, so that most invalid ICMP messages arrive 4015 when there are no DF packets outstanding, and can therefore be 4016 identified as spurious. 4018 * An endpoint could store additional information from the IP or UDP 4019 headers to use for validation (for example, the IP ID or UDP 4020 checksum). 4022 The endpoint SHOULD ignore all ICMP messages that fail validation. 4024 An endpoint MUST NOT increase PMTU based on ICMP messages. Any 4025 reduction in the QUIC maximum packet size MAY be provisional until 4026 QUIC's loss detection algorithm determines that the quoted packet has 4027 actually been lost. 4029 14.3. Datagram Packetization Layer PMTU Discovery 4031 Section 6.3 of [DPLPMTUD] provides considerations for implementing 4032 Datagram Packetization Layer PMTUD (DPLPMTUD) with QUIC. 4034 When implementing the algorithm in Section 5 of [DPLPMTUD], the 4035 initial value of BASE_PMTU SHOULD be consistent with the minimum QUIC 4036 packet size (1232 bytes for IPv6 and 1252 bytes for IPv4). 4038 PING and PADDING frames can be used to generate PMTU probe packets. 4039 These frames might not be retransmitted if a probe packet containing 4040 them is lost. However, these frames do consume congestion window, 4041 which could delay the transmission of subsequent application data. 4043 A PING frame can be included in a PMTU probe to ensure that a valid 4044 probe is acknowledged. 4046 The considerations for processing ICMP messages in the previous 4047 section also apply if these messages are used by DPLPMTUD. 4049 14.3.1. PMTU Probes Containing Source Connection ID 4051 Endpoints that rely on the destination connection ID for routing QUIC 4052 packets are likely to require that the connection ID be included in 4053 PMTU probe packets to route any resulting ICMP messages 4054 (Section 14.2) back to the correct endpoint. However, only long 4055 header packets (Section 17.2) contain source connection IDs, and long 4056 header packets are not decrypted or acknowledged by the peer once the 4057 handshake is complete. One way to construct a PMTU probe is to 4058 coalesce (see Section 12.2) a Handshake packet (Section 17.2.4) with 4059 a short header packet in a single UDP datagram. If the UDP datagram 4060 reaches the endpoint, the Handshake packet will be ignored, but the 4061 short header packet will be acknowledged. If the UDP datagram 4062 elicits an ICMP message, that message will likely contain the source 4063 connection ID within the quoted portion of the UDP datagram. 4065 15. Versions 4067 QUIC versions are identified using a 32-bit unsigned number. 4069 The version 0x00000000 is reserved to represent version negotiation. 4070 This version of the specification is identified by the number 4071 0x00000001. 4073 Other versions of QUIC might have different properties to this 4074 version. The properties of QUIC that are guaranteed to be consistent 4075 across all versions of the protocol are described in 4076 [QUIC-INVARIANTS]. 4078 Version 0x00000001 of QUIC uses TLS as a cryptographic handshake 4079 protocol, as described in [QUIC-TLS]. 4081 Versions with the most significant 16 bits of the version number 4082 cleared are reserved for use in future IETF consensus documents. 4084 Versions that follow the pattern 0x?a?a?a?a are reserved for use in 4085 forcing version negotiation to be exercised. That is, any version 4086 number where the low four bits of all bytes is 1010 (in binary). A 4087 client or server MAY advertise support for any of these reserved 4088 versions. 4090 Reserved version numbers will never represent a real protocol; a 4091 client MAY use one of these version numbers with the expectation that 4092 the server will initiate version negotiation; a server MAY advertise 4093 support for one of these versions and can expect that clients ignore 4094 the value. 4096 [[RFC editor: please remove the remainder of this section before 4097 publication.]] 4099 The version number for the final version of this specification 4100 (0x00000001), is reserved for the version of the protocol that is 4101 published as an RFC. 4103 Version numbers used to identify IETF drafts are created by adding 4104 the draft number to 0xff000000. For example, draft-ietf-quic- 4105 transport-13 would be identified as 0xff00000D. 4107 Implementors are encouraged to register version numbers of QUIC that 4108 they are using for private experimentation on the GitHub wiki at 4109 . 4111 16. Variable-Length Integer Encoding 4113 QUIC packets and frames commonly use a variable-length encoding for 4114 non-negative integer values. This encoding ensures that smaller 4115 integer values need fewer bytes to encode. 4117 The QUIC variable-length integer encoding reserves the two most 4118 significant bits of the first byte to encode the base 2 logarithm of 4119 the integer encoding length in bytes. The integer value is encoded 4120 on the remaining bits, in network byte order. 4122 This means that integers are encoded on 1, 2, 4, or 8 bytes and can 4123 encode 6, 14, 30, or 62 bit values respectively. Table 4 summarizes 4124 the encoding properties. 4126 +------+--------+-------------+-----------------------+ 4127 | 2Bit | Length | Usable Bits | Range | 4128 +======+========+=============+=======================+ 4129 | 00 | 1 | 6 | 0-63 | 4130 +------+--------+-------------+-----------------------+ 4131 | 01 | 2 | 14 | 0-16383 | 4132 +------+--------+-------------+-----------------------+ 4133 | 10 | 4 | 30 | 0-1073741823 | 4134 +------+--------+-------------+-----------------------+ 4135 | 11 | 8 | 62 | 0-4611686018427387903 | 4136 +------+--------+-------------+-----------------------+ 4138 Table 4: Summary of Integer Encodings 4140 For example, the eight byte sequence c2 19 7c 5e ff 14 e8 8c (in 4141 hexadecimal) decodes to the decimal value 151288809941952652; the 4142 four byte sequence 9d 7f 3e 7d decodes to 494878333; the two byte 4143 sequence 7b bd decodes to 15293; and the single byte 25 decodes to 37 4144 (as does the two byte sequence 40 25). 4146 Error codes (Section 20) and versions (Section 15) are described 4147 using integers, but do not use this encoding. 4149 17. Packet Formats 4151 All numeric values are encoded in network byte order (that is, big- 4152 endian) and all field sizes are in bits. Hexadecimal notation is 4153 used for describing the value of fields. 4155 17.1. Packet Number Encoding and Decoding 4157 Packet numbers are integers in the range 0 to 2^62-1 (Section 12.3). 4158 When present in long or short packet headers, they are encoded in 1 4159 to 4 bytes. The number of bits required to represent the packet 4160 number is reduced by including the least significant bits of the 4161 packet number. 4163 The encoded packet number is protected as described in Section 5.4 of 4164 [QUIC-TLS]. 4166 The sender MUST use a packet number size able to represent more than 4167 twice as large a range than the difference between the largest 4168 acknowledged packet and packet number being sent. A peer receiving 4169 the packet will then correctly decode the packet number, unless the 4170 packet is delayed in transit such that it arrives after many higher- 4171 numbered packets have been received. An endpoint SHOULD use a large 4172 enough packet number encoding to allow the packet number to be 4173 recovered even if the packet arrives after packets that are sent 4174 afterwards. 4176 As a result, the size of the packet number encoding is at least one 4177 bit more than the base-2 logarithm of the number of contiguous 4178 unacknowledged packet numbers, including the new packet. 4180 For example, if an endpoint has received an acknowledgment for packet 4181 0xabe8bc, sending a packet with a number of 0xac5c02 requires a 4182 packet number encoding with 16 bits or more; whereas the 24-bit 4183 packet number encoding is needed to send a packet with a number of 4184 0xace8fe. 4186 At a receiver, protection of the packet number is removed prior to 4187 recovering the full packet number. The full packet number is then 4188 reconstructed based on the number of significant bits present, the 4189 value of those bits, and the largest packet number received on a 4190 successfully authenticated packet. Recovering the full packet number 4191 is necessary to successfully remove packet protection. 4193 Once header protection is removed, the packet number is decoded by 4194 finding the packet number value that is closest to the next expected 4195 packet. The next expected packet is the highest received packet 4196 number plus one. For example, if the highest successfully 4197 authenticated packet had a packet number of 0xa82f30ea, then a packet 4198 containing a 16-bit value of 0x9b32 will be decoded as 0xa82f9b32. 4199 Example pseudo-code for packet number decoding can be found in 4200 Appendix A. 4202 17.2. Long Header Packets 4204 0 1 2 3 4205 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 4206 +-+-+-+-+-+-+-+-+ 4207 |1|1|T T|X X X X| 4208 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4209 | Version (32) | 4210 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4211 | DCID Len (8) | 4212 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4213 | Destination Connection ID (0..160) ... 4214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4215 | SCID Len (8) | 4216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4217 | Source Connection ID (0..160) ... 4218 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4220 Figure 9: Long Header Packet Format 4222 Long headers are used for packets that are sent prior to the 4223 establishment of 1-RTT keys. Once both conditions are met, a sender 4224 switches to sending packets using the short header (Section 17.3). 4225 The long form allows for special packets - such as the Version 4226 Negotiation packet - to be represented in this uniform fixed-length 4227 packet format. Packets that use the long header contain the 4228 following fields: 4230 Header Form: The most significant bit (0x80) of byte 0 (the first 4231 byte) is set to 1 for long headers. 4233 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4234 containing a zero value for this bit are not valid packets in this 4235 version and MUST be discarded. 4237 Long Packet Type (T): The next two bits (those with a mask of 0x30) 4238 of byte 0 contain a packet type. Packet types are listed in 4239 Table 5. 4241 Type-Specific Bits (X): The lower four bits (those with a mask of 4242 0x0f) of byte 0 are type-specific. 4244 Version: The QUIC Version is a 32-bit field that follows the first 4245 byte. This field indicates which version of QUIC is in use and 4246 determines how the rest of the protocol fields are interpreted. 4248 DCID Len: The byte following the version contains the length in 4249 bytes of the Destination Connection ID field that follows it. 4251 This length is encoded as an 8-bit unsigned integer. In QUIC 4252 version 1, this value MUST NOT exceed 20. Endpoints that receive 4253 a version 1 long header with a value larger than 20 MUST drop the 4254 packet. Servers SHOULD be able to read longer connection IDs from 4255 other QUIC versions in order to properly form a version 4256 negotiation packet. 4258 Destination Connection ID: The Destination Connection ID field 4259 follows the DCID Len and is between 0 and 20 bytes in length. 4260 Section 7.2 describes the use of this field in more detail. 4262 SCID Len: The byte following the Destination Connection ID contains 4263 the length in bytes of the Source Connection ID field that follows 4264 it. This length is encoded as a 8-bit unsigned integer. In QUIC 4265 version 1, this value MUST NOT exceed 20 bytes. Endpoints that 4266 receive a version 1 long header with a value larger than 20 MUST 4267 drop the packet. Servers SHOULD be able to read longer connection 4268 IDs from other QUIC versions in order to properly form a version 4269 negotiation packet. 4271 Source Connection ID: The Source Connection ID field follows the 4272 SCID Len and is between 0 and 20 bytes in length. Section 7.2 4273 describes the use of this field in more detail. 4275 In this version of QUIC, the following packet types with the long 4276 header are defined: 4278 +------+-----------+----------------+ 4279 | Type | Name | Section | 4280 +======+===========+================+ 4281 | 0x0 | Initial | Section 17.2.2 | 4282 +------+-----------+----------------+ 4283 | 0x1 | 0-RTT | Section 17.2.3 | 4284 +------+-----------+----------------+ 4285 | 0x2 | Handshake | Section 17.2.4 | 4286 +------+-----------+----------------+ 4287 | 0x3 | Retry | Section 17.2.5 | 4288 +------+-----------+----------------+ 4290 Table 5: Long Header Packet Types 4292 The header form bit, connection ID lengths byte, Destination and 4293 Source Connection ID fields, and Version fields of a long header 4294 packet are version-independent. The other fields in the first byte 4295 are version-specific. See [QUIC-INVARIANTS] for details on how 4296 packets from different versions of QUIC are interpreted. 4298 The interpretation of the fields and the payload are specific to a 4299 version and packet type. While type-specific semantics for this 4300 version are described in the following sections, several long-header 4301 packets in this version of QUIC contain these additional fields: 4303 Reserved Bits (R): Two bits (those with a mask of 0x0c) of byte 0 4304 are reserved across multiple packet types. These bits are 4305 protected using header protection (see Section 5.4 of [QUIC-TLS]). 4306 The value included prior to protection MUST be set to 0. An 4307 endpoint MUST treat receipt of a packet that has a non-zero value 4308 for these bits, after removing both packet and header protection, 4309 as a connection error of type PROTOCOL_VIOLATION. Discarding such 4310 a packet after only removing header protection can expose the 4311 endpoint to attacks (see Section 9.3 of [QUIC-TLS]). 4313 Packet Number Length (P): In packet types which contain a Packet 4314 Number field, the least significant two bits (those with a mask of 4315 0x03) of byte 0 contain the length of the packet number, encoded 4316 as an unsigned, two-bit integer that is one less than the length 4317 of the packet number field in bytes. That is, the length of the 4318 packet number field is the value of this field, plus one. These 4319 bits are protected using header protection (see Section 5.4 of 4320 [QUIC-TLS]). 4322 Length: The length of the remainder of the packet (that is, the 4323 Packet Number and Payload fields) in bytes, encoded as a variable- 4324 length integer (Section 16). 4326 Packet Number: The packet number field is 1 to 4 bytes long. The 4327 packet number has confidentiality protection separate from packet 4328 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4329 of the packet number field is encoded in the Packet Number Length 4330 bits of byte 0 (see above). 4332 17.2.1. Version Negotiation Packet 4334 A Version Negotiation packet is inherently not version-specific. 4335 Upon receipt by a client, it will be identified as a Version 4336 Negotiation packet based on the Version field having a value of 0. 4338 The Version Negotiation packet is a response to a client packet that 4339 contains a version that is not supported by the server, and is only 4340 sent by servers. 4342 The layout of a Version Negotiation packet is: 4344 0 1 2 3 4345 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 4346 +-+-+-+-+-+-+-+-+ 4347 |1| Unused (7) | 4348 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4349 | Version (32) | 4350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4351 | DCID Len (8) | 4352 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4353 | Destination Connection ID (0..2040) ... 4354 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4355 | SCID Len (8) | 4356 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4357 | Source Connection ID (0..2040) ... 4358 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4359 | Supported Version 1 (32) ... 4360 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4361 | [Supported Version 2 (32)] ... 4362 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4363 ... 4364 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4365 | [Supported Version N (32)] ... 4366 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4368 Figure 10: Version Negotiation Packet 4370 The value in the Unused field is selected randomly by the server. 4371 Clients MUST ignore the value of this field. Servers SHOULD set the 4372 most significant bit of this field (0x40) to 1 so that Version 4373 Negotiation packets appear to have the Fixed Bit field. 4375 The Version field of a Version Negotiation packet MUST be set to 4376 0x00000000. 4378 The server MUST include the value from the Source Connection ID field 4379 of the packet it receives in the Destination Connection ID field. 4380 The value for Source Connection ID MUST be copied from the 4381 Destination Connection ID of the received packet, which is initially 4382 randomly selected by a client. Echoing both connection IDs gives 4383 clients some assurance that the server received the packet and that 4384 the Version Negotiation packet was not generated by an off-path 4385 attacker. 4387 As future versions of QUIC may support Connection IDs larger than the 4388 version 1 limit, Version Negotiation packets could carry Connection 4389 IDs that are longer than 20 bytes. 4391 The remainder of the Version Negotiation packet is a list of 32-bit 4392 versions which the server supports. 4394 A Version Negotiation packet cannot be explicitly acknowledged in an 4395 ACK frame by a client. Receiving another Initial packet implicitly 4396 acknowledges a Version Negotiation packet. 4398 The Version Negotiation packet does not include the Packet Number and 4399 Length fields present in other packets that use the long header form. 4400 Consequently, a Version Negotiation packet consumes an entire UDP 4401 datagram. 4403 A server MUST NOT send more than one Version Negotiation packet in 4404 response to a single UDP datagram. 4406 See Section 6 for a description of the version negotiation process. 4408 17.2.2. Initial Packet 4410 An Initial packet uses long headers with a type value of 0x0. It 4411 carries the first CRYPTO frames sent by the client and server to 4412 perform key exchange, and carries ACKs in either direction. 4414 +-+-+-+-+-+-+-+-+ 4415 |1|1| 0 |R R|P P| 4416 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4417 | Version (32) | 4418 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4419 | DCID Len (8) | 4420 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4421 | Destination Connection ID (0..160) ... 4422 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4423 | SCID Len (8) | 4424 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4425 | Source Connection ID (0..160) ... 4426 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4427 | Token Length (i) ... 4428 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4429 | Token (*) ... 4430 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4431 | Length (i) ... 4432 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4433 | Packet Number (8/16/24/32) ... 4434 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4435 | Payload (*) ... 4436 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4438 Figure 11: Initial Packet 4440 The Initial packet contains a long header as well as the Length and 4441 Packet Number fields. The first byte contains the Reserved and 4442 Packet Number Length bits. Between the SCID and Length fields, there 4443 are two additional field specific to the Initial packet. 4445 Token Length: A variable-length integer specifying the length of the 4446 Token field, in bytes. This value is zero if no token is present. 4447 Initial packets sent by the server MUST set the Token Length field 4448 to zero; clients that receive an Initial packet with a non-zero 4449 Token Length field MUST either discard the packet or generate a 4450 connection error of type PROTOCOL_VIOLATION. 4452 Token: The value of the token that was previously provided in a 4453 Retry packet or NEW_TOKEN frame. 4455 Payload: The payload of the packet. 4457 In order to prevent tampering by version-unaware middleboxes, Initial 4458 packets are protected with connection- and version-specific keys 4459 (Initial keys) as described in [QUIC-TLS]. This protection does not 4460 provide confidentiality or integrity against on-path attackers, but 4461 provides some level of protection against off-path attackers. 4463 The client and server use the Initial packet type for any packet that 4464 contains an initial cryptographic handshake message. This includes 4465 all cases where a new packet containing the initial cryptographic 4466 message needs to be created, such as the packets sent after receiving 4467 a Retry packet (Section 17.2.5). 4469 A server sends its first Initial packet in response to a client 4470 Initial. A server may send multiple Initial packets. The 4471 cryptographic key exchange could require multiple round trips or 4472 retransmissions of this data. 4474 The payload of an Initial packet includes a CRYPTO frame (or frames) 4475 containing a cryptographic handshake message, ACK frames, or both. 4476 PING, PADDING, and CONNECTION_CLOSE frames are also permitted. An 4477 endpoint that receives an Initial packet containing other frames can 4478 either discard the packet as spurious or treat it as a connection 4479 error. 4481 The first packet sent by a client always includes a CRYPTO frame that 4482 contains the start or all of the first cryptographic handshake 4483 message. The first CRYPTO frame sent always begins at an offset of 0 4484 (see Section 7). 4486 Note that if the server sends a HelloRetryRequest, the client will 4487 send another series of Initial packets. These Initial packets will 4488 continue the cryptographic handshake and will contain CRYPTO frames 4489 starting at an offset matching the size of the CRYPTO frames sent in 4490 the first flight of Initial packets. 4492 17.2.2.1. Abandoning Initial Packets 4494 A client stops both sending and processing Initial packets when it 4495 sends its first Handshake packet. A server stops sending and 4496 processing Initial packets when it receives its first Handshake 4497 packet. Though packets might still be in flight or awaiting 4498 acknowledgment, no further Initial packets need to be exchanged 4499 beyond this point. Initial packet protection keys are discarded (see 4500 Section 4.10.1 of [QUIC-TLS]) along with any loss recovery and 4501 congestion control state (see Section 6.5 of [QUIC-RECOVERY]). 4503 Any data in CRYPTO frames is discarded - and no longer retransmitted 4504 - when Initial keys are discarded. 4506 17.2.3. 0-RTT 4508 A 0-RTT packet uses long headers with a type value of 0x1, followed 4509 by the Length and Packet Number fields. The first byte contains the 4510 Reserved and Packet Number Length bits. It is used to carry "early" 4511 data from the client to the server as part of the first flight, prior 4512 to handshake completion. As part of the TLS handshake, the server 4513 can accept or reject this early data. 4515 See Section 2.3 of [TLS13] for a discussion of 0-RTT data and its 4516 limitations. 4518 +-+-+-+-+-+-+-+-+ 4519 |1|1| 1 |R R|P P| 4520 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4521 | Version (32) | 4522 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4523 | DCID Len (8) | 4524 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4525 | Destination Connection ID (0..160) ... 4526 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4527 | SCID Len (8) | 4528 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4529 | Source Connection ID (0..160) ... 4530 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4531 | Length (i) ... 4532 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4533 | Packet Number (8/16/24/32) ... 4534 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4535 | Payload (*) ... 4536 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4538 Figure 12: 0-RTT Packet 4540 Packet numbers for 0-RTT protected packets use the same space as 4541 1-RTT protected packets. 4543 After a client receives a Retry packet, 0-RTT packets are likely to 4544 have been lost or discarded by the server. A client SHOULD attempt 4545 to resend data in 0-RTT packets after it sends a new Initial packet. 4547 A client MUST NOT reset the packet number it uses for 0-RTT packets, 4548 since the keys used to protect 0-RTT packets will not change as a 4549 result of responding to a Retry packet. Sending packets with the 4550 same packet number in that case is likely to compromise the packet 4551 protection for all 0-RTT packets because the same key and nonce could 4552 be used to protect different content. 4554 A client only receives acknowledgments for its 0-RTT packets once the 4555 handshake is complete. Consequently, a server might expect 0-RTT 4556 packets to start with a packet number of 0. Therefore, in 4557 determining the length of the packet number encoding for 0-RTT 4558 packets, a client MUST assume that all packets up to the current 4559 packet number are in flight, starting from a packet number of 0. 4560 Thus, 0-RTT packets could need to use a longer packet number 4561 encoding. 4563 A client MUST NOT send 0-RTT packets once it starts processing 1-RTT 4564 packets from the server. This means that 0-RTT packets cannot 4565 contain any response to frames from 1-RTT packets. For instance, a 4566 client cannot send an ACK frame in a 0-RTT packet, because that can 4567 only acknowledge a 1-RTT packet. An acknowledgment for a 1-RTT 4568 packet MUST be carried in a 1-RTT packet. 4570 A server SHOULD treat a violation of remembered limits as a 4571 connection error of an appropriate type (for instance, a 4572 FLOW_CONTROL_ERROR for exceeding stream data limits). 4574 17.2.4. Handshake Packet 4576 A Handshake packet uses long headers with a type value of 0x2, 4577 followed by the Length and Packet Number fields. The first byte 4578 contains the Reserved and Packet Number Length bits. It is used to 4579 carry acknowledgments and cryptographic handshake messages from the 4580 server and client. 4582 +-+-+-+-+-+-+-+-+ 4583 |1|1| 2 |R R|P P| 4584 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4585 | Version (32) | 4586 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4587 | DCID Len (8) | 4588 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4589 | Destination Connection ID (0..160) ... 4590 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4591 | SCID Len (8) | 4592 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4593 | Source Connection ID (0..160) ... 4594 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4595 | Length (i) ... 4596 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4597 | Packet Number (8/16/24/32) ... 4598 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4599 | Payload (*) ... 4600 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4602 Figure 13: Handshake Protected Packet 4604 Once a client has received a Handshake packet from a server, it uses 4605 Handshake packets to send subsequent cryptographic handshake messages 4606 and acknowledgments to the server. 4608 The Destination Connection ID field in a Handshake packet contains a 4609 connection ID that is chosen by the recipient of the packet; the 4610 Source Connection ID includes the connection ID that the sender of 4611 the packet wishes to use (see Section 7.2). 4613 Handshake packets are their own packet number space, and thus the 4614 first Handshake packet sent by a server contains a packet number of 4615 0. 4617 The payload of this packet contains CRYPTO frames and could contain 4618 PING, PADDING, or ACK frames. Handshake packets MAY contain 4619 CONNECTION_CLOSE frames. Endpoints MUST treat receipt of Handshake 4620 packets with other frames as a connection error. 4622 Like Initial packets (see Section 17.2.2.1), data in CRYPTO frames at 4623 the Handshake encryption level is discarded - and no longer 4624 retransmitted - when Handshake protection keys are discarded. 4626 17.2.5. Retry Packet 4628 A Retry packet uses a long packet header with a type value of 0x3. 4629 It carries an address validation token created by the server. It is 4630 used by a server that wishes to perform a retry (see Section 8.1). 4632 0 1 2 3 4633 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 4634 +-+-+-+-+-+-+-+-+ 4635 |1|1| 3 | Unused| 4636 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4637 | Version (32) | 4638 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4639 | DCID Len (8) | 4640 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4641 | Destination Connection ID (0..160) ... 4642 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4643 | SCID Len (8) | 4644 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4645 | Source Connection ID (0..160) ... 4646 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4647 | Retry Token (*) ... 4648 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4649 | | 4650 + + 4651 | | 4652 + Retry Integrity Tag (128) + 4653 | | 4654 + + 4655 | | 4656 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4658 Figure 14: Retry Packet 4660 A Retry packet (shown in Figure 14) does not contain any protected 4661 fields. The value in the Unused field is selected randomly by the 4662 server. In addition to the long header, it contains these additional 4663 fields: 4665 Retry Token: An opaque token that the server can use to validate the 4666 client's address. 4668 Retry Integrity Tag: See the Retry Packet Integrity section of 4669 [QUIC-TLS]. 4671 The server populates the Destination Connection ID with the 4672 connection ID that the client included in the Source Connection ID of 4673 the Initial packet. 4675 The server includes a connection ID of its choice in the Source 4676 Connection ID field. This value MUST not be equal to the Destination 4677 Connection ID field of the packet sent by the client. A client MUST 4678 discard a Retry packet that contains a Source Connection ID field 4679 that is identical to the Destination Connection ID field of its 4680 Initial packet. The client MUST use the value from the Source 4681 Connection ID field of the Retry packet in the Destination Connection 4682 ID field of subsequent packets that it sends. 4684 A server MAY send Retry packets in response to Initial and 0-RTT 4685 packets. A server can either discard or buffer 0-RTT packets that it 4686 receives. A server can send multiple Retry packets as it receives 4687 Initial or 0-RTT packets. A server MUST NOT send more than one Retry 4688 packet in response to a single UDP datagram. 4690 A client MUST accept and process at most one Retry packet for each 4691 connection attempt. After the client has received and processed an 4692 Initial or Retry packet from the server, it MUST discard any 4693 subsequent Retry packets that it receives. 4695 Clients MUST discard Retry packets that have a Retry Integrity Tag 4696 that cannot be validated, see the Retry Packet Integrity section of 4697 [QUIC-TLS]. This diminishes an off-path attacker's ability to inject 4698 a Retry packet and protects against accidental corruption of Retry 4699 packets. A client MUST discard a Retry packet with a zero-length 4700 Retry Token field. 4702 The client responds to a Retry packet with an Initial packet that 4703 includes the provided Retry Token to continue connection 4704 establishment. 4706 A client sets the Destination Connection ID field of this Initial 4707 packet to the value from the Source Connection ID in the Retry 4708 packet. Changing Destination Connection ID also results in a change 4709 to the keys used to protect the Initial packet. It also sets the 4710 Token field to the token provided in the Retry. The client MUST NOT 4711 change the Source Connection ID because the server could include the 4712 connection ID as part of its token validation logic (see 4713 Section 8.1.4). 4715 The next Initial packet from the client uses the connection ID and 4716 token values from the Retry packet (see Section 7.2). Aside from 4717 this, the Initial packet sent by the client is subject to the same 4718 restrictions as the first Initial packet. A client MUST use the same 4719 cryptographic handshake message it includes in this packet. A server 4720 MAY treat a packet that contains a different cryptographic handshake 4721 message as a connection error or discard it. 4723 A client MAY attempt 0-RTT after receiving a Retry packet by sending 4724 0-RTT packets to the connection ID provided by the server. A client 4725 MUST NOT change the cryptographic handshake message it sends in 4726 response to receiving a Retry. 4728 A client MUST NOT reset the packet number for any packet number space 4729 after processing a Retry packet; Section 17.2.3 contains more 4730 information on this. 4732 A server acknowledges the use of a Retry packet for a connection 4733 using the original_connection_id transport parameter (see 4734 Section 18.2). If the server sends a Retry packet, it MUST include 4735 the Destination Connection ID field from the client's first Initial 4736 packet in the transport parameter. 4738 If the client received and processed a Retry packet, it MUST validate 4739 that the original_connection_id transport parameter is present and 4740 correct; otherwise, it MUST validate that the transport parameter is 4741 absent. A client MUST treat a failed validation as a connection 4742 error of type TRANSPORT_PARAMETER_ERROR. 4744 A Retry packet does not include a packet number and cannot be 4745 explicitly acknowledged by a client. 4747 17.3. Short Header Packets 4749 This version of QUIC defines a single packet type which uses the 4750 short packet header. 4752 0 1 2 3 4753 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 4754 +-+-+-+-+-+-+-+-+ 4755 |0|1|S|R|R|K|P P| 4756 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4757 | Destination Connection ID (0..160) ... 4758 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4759 | Packet Number (8/16/24/32) ... 4760 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4761 | Protected Payload (*) ... 4762 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4764 Figure 15: Short Header Packet Format 4766 The short header can be used after the version and 1-RTT keys are 4767 negotiated. Packets that use the short header contain the following 4768 fields: 4770 Header Form: The most significant bit (0x80) of byte 0 is set to 0 4771 for the short header. 4773 Fixed Bit: The next bit (0x40) of byte 0 is set to 1. Packets 4774 containing a zero value for this bit are not valid packets in this 4775 version and MUST be discarded. 4777 Spin Bit (S): The third most significant bit (0x20) of byte 0 is the 4778 latency spin bit, set as described in Section 17.3.1. 4780 Reserved Bits (R): The next two bits (those with a mask of 0x18) of 4781 byte 0 are reserved. These bits are protected using header 4782 protection (see Section 5.4 of [QUIC-TLS]). The value included 4783 prior to protection MUST be set to 0. An endpoint MUST treat 4784 receipt of a packet that has a non-zero value for these bits, 4785 after removing both packet and header protection, as a connection 4786 error of type PROTOCOL_VIOLATION. Discarding such a packet after 4787 only removing header protection can expose the endpoint to attacks 4788 (see Section 9.3 of [QUIC-TLS]). 4790 Key Phase (K): The next bit (0x04) of byte 0 indicates the key 4791 phase, which allows a recipient of a packet to identify the packet 4792 protection keys that are used to protect the packet. See 4793 [QUIC-TLS] for details. This bit is protected using header 4794 protection (see Section 5.4 of [QUIC-TLS]). 4796 Packet Number Length (P): The least significant two bits (those with 4797 a mask of 0x03) of byte 0 contain the length of the packet number, 4798 encoded as an unsigned, two-bit integer that is one less than the 4799 length of the packet number field in bytes. That is, the length 4800 of the packet number field is the value of this field, plus one. 4801 These bits are protected using header protection (see Section 5.4 4802 of [QUIC-TLS]). 4804 Destination Connection ID: The Destination Connection ID is a 4805 connection ID that is chosen by the intended recipient of the 4806 packet. See Section 5.1 for more details. 4808 Packet Number: The packet number field is 1 to 4 bytes long. The 4809 packet number has confidentiality protection separate from packet 4810 protection, as described in Section 5.4 of [QUIC-TLS]. The length 4811 of the packet number field is encoded in Packet Number Length 4812 field. See Section 17.1 for details. 4814 Protected Payload: Packets with a short header always include a 4815 1-RTT protected payload. 4817 The header form bit and the connection ID field of a short header 4818 packet are version-independent. The remaining fields are specific to 4819 the selected QUIC version. See [QUIC-INVARIANTS] for details on how 4820 packets from different versions of QUIC are interpreted. 4822 17.3.1. Latency Spin Bit 4824 The latency spin bit enables passive latency monitoring from 4825 observation points on the network path throughout the duration of a 4826 connection. The spin bit is only present in the short packet header, 4827 since it is possible to measure the initial RTT of a connection by 4828 observing the handshake. Therefore, the spin bit is available after 4829 version negotiation and connection establishment are completed. On- 4830 path measurement and use of the latency spin bit is further discussed 4831 in [QUIC-MANAGEABILITY]. 4833 The spin bit is an OPTIONAL feature of QUIC. A QUIC stack that 4834 chooses to support the spin bit MUST implement it as specified in 4835 this section. 4837 Each endpoint unilaterally decides if the spin bit is enabled or 4838 disabled for a connection. Implementations MUST allow administrators 4839 of clients and servers to disable the spin bit either globally or on 4840 a per-connection basis. Even when the spin bit is not disabled by 4841 the administrator, endpoints MUST disable their use of the spin bit 4842 for a random selection of at least one in every 16 network paths, or 4843 for one in every 16 connection IDs. As each endpoint disables the 4844 spin bit independently, this ensures that the spin bit signal is 4845 disabled on approximately one in eight network paths. 4847 When the spin bit is disabled, endpoints MAY set the spin bit to any 4848 value, and MUST ignore any incoming value. It is RECOMMENDED that 4849 endpoints set the spin bit to a random value either chosen 4850 independently for each packet or chosen independently for each 4851 connection ID. 4853 If the spin bit is enabled for the connection, the endpoint maintains 4854 a spin value and sets the spin bit in the short header to the 4855 currently stored value when a packet with a short header is sent out. 4856 The spin value is initialized to 0 in the endpoint at connection 4857 start. Each endpoint also remembers the highest packet number seen 4858 from its peer on the connection. 4860 When a server receives a short header packet that increments the 4861 highest packet number seen by the server from the client, it sets the 4862 spin value to be equal to the spin bit in the received packet. 4864 When a client receives a short header packet that increments the 4865 highest packet number seen by the client from the server, it sets the 4866 spin value to the inverse of the spin bit in the received packet. 4868 An endpoint resets its spin value to zero when sending the first 4869 packet of a given connection with a new connection ID. This reduces 4870 the risk that transient spin bit state can be used to link flows 4871 across connection migration or ID change. 4873 With this mechanism, the server reflects the spin value received, 4874 while the client 'spins' it after one RTT. On-path observers can 4875 measure the time between two spin bit toggle events to estimate the 4876 end-to-end RTT of a connection. 4878 18. Transport Parameter Encoding 4880 The "extension_data" field of the quic_transport_parameters extension 4881 defined in [QUIC-TLS] contains the QUIC transport parameters. They 4882 are encoded as a length-prefixed sequence of transport parameters, as 4883 shown in Figure 16: 4885 0 1 2 3 4886 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 4887 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4888 | Sequence Length (16) | 4889 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4890 | Transport Parameter 1 (*) ... 4891 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4892 | Transport Parameter 2 (*) ... 4893 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4894 ... 4895 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4896 | Transport Parameter N (*) ... 4897 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4899 Figure 16: Sequence of Transport Parameters 4901 The Sequence Length field contains the length of the sequence of 4902 transport parameters, in bytes. Each transport parameter is encoded 4903 as an (identifier, length, value) tuple, as shown in Figure 17: 4905 0 1 2 3 4906 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 4907 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4908 | Transport Parameter ID (16) | Transport Param Length (16) | 4909 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4910 | Transport Parameter Value (*) ... 4911 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 4913 Figure 17: Transport Parameter Encoding 4915 The Transport Param Length field contains the length of the Transport 4916 Parameter Value field. 4918 QUIC encodes transport parameters into a sequence of bytes, which are 4919 then included in the cryptographic handshake. 4921 18.1. Reserved Transport Parameters 4923 Transport parameters with an identifier of the form "31 * N + 27" for 4924 integer values of N are reserved to exercise the requirement that 4925 unknown transport parameters be ignored. These transport parameters 4926 have no semantics, and may carry arbitrary values. 4928 18.2. Transport Parameter Definitions 4930 This section details the transport parameters defined in this 4931 document. 4933 Many transport parameters listed here have integer values. Those 4934 transport parameters that are identified as integers use a variable- 4935 length integer encoding (see Section 16) and have a default value of 4936 0 if the transport parameter is absent, unless otherwise stated. 4938 The following transport parameters are defined: 4940 original_connection_id (0x0000): The value of the Destination 4941 Connection ID field from the first Initial packet sent by the 4942 client. This transport parameter is only sent by a server. This 4943 is the same value sent in the "Original Destination Connection ID" 4944 field of a Retry packet (see Section 17.2.5). A server MUST 4945 include the original_connection_id transport parameter if it sent 4946 a Retry packet. 4948 max_idle_timeout (0x0001): The max idle timeout is a value in 4949 milliseconds that is encoded as an integer; see (Section 10.2). 4950 Idle timeout is disabled when both endpoints omit this transport 4951 parameteter or specify a value of 0. 4953 stateless_reset_token (0x0002): A stateless reset token is used in 4954 verifying a stateless reset; see Section 10.4. This parameter is 4955 a sequence of 16 bytes. This transport parameter MUST NOT be sent 4956 by a client, but MAY be sent by a server. A server that does not 4957 send this transport parameter cannot use stateless reset 4958 (Section 10.4) for the connection ID negotiated during the 4959 handshake. 4961 max_packet_size (0x0003): The maximum packet size parameter is an 4962 integer value that limits the size of packets that the endpoint is 4963 willing to receive. This indicates that packets larger than this 4964 limit will be dropped. The default for this parameter is the 4965 maximum permitted UDP payload of 65527. Values below 1200 are 4966 invalid. This limit only applies to protected packets 4967 (Section 12.1). 4969 initial_max_data (0x0004): The initial maximum data parameter is an 4970 integer value that contains the initial value for the maximum 4971 amount of data that can be sent on the connection. This is 4972 equivalent to sending a MAX_DATA (Section 19.9) for the connection 4973 immediately after completing the handshake. 4975 initial_max_stream_data_bidi_local (0x0005): This parameter is an 4976 integer value specifying the initial flow control limit for 4977 locally-initiated bidirectional streams. This limit applies to 4978 newly created bidirectional streams opened by the endpoint that 4979 sends the transport parameter. In client transport parameters, 4980 this applies to streams with an identifier with the least 4981 significant two bits set to 0x0; in server transport parameters, 4982 this applies to streams with the least significant two bits set to 4983 0x1. 4985 initial_max_stream_data_bidi_remote (0x0006): This parameter is an 4986 integer value specifying the initial flow control limit for peer- 4987 initiated bidirectional streams. This limit applies to newly 4988 created bidirectional streams opened by the endpoint that receives 4989 the transport parameter. In client transport parameters, this 4990 applies to streams with an identifier with the least significant 4991 two bits set to 0x1; in server transport parameters, this applies 4992 to streams with the least significant two bits set to 0x0. 4994 initial_max_stream_data_uni (0x0007): This parameter is an integer 4995 value specifying the initial flow control limit for unidirectional 4996 streams. This limit applies to newly created unidirectional 4997 streams opened by the endpoint that receives the transport 4998 parameter. In client transport parameters, this applies to 4999 streams with an identifier with the least significant two bits set 5000 to 0x3; in server transport parameters, this applies to streams 5001 with the least significant two bits set to 0x2. 5003 initial_max_streams_bidi (0x0008): The initial maximum bidirectional 5004 streams parameter is an integer value that contains the initial 5005 maximum number of bidirectional streams the peer may initiate. If 5006 this parameter is absent or zero, the peer cannot open 5007 bidirectional streams until a MAX_STREAMS frame is sent. Setting 5008 this parameter is equivalent to sending a MAX_STREAMS 5009 (Section 19.11) of the corresponding type with the same value. 5011 initial_max_streams_uni (0x0009): The initial maximum unidirectional 5012 streams parameter is an integer value that contains the initial 5013 maximum number of unidirectional streams the peer may initiate. 5014 If this parameter is absent or zero, the peer cannot open 5015 unidirectional streams until a MAX_STREAMS frame is sent. Setting 5016 this parameter is equivalent to sending a MAX_STREAMS 5017 (Section 19.11) of the corresponding type with the same value. 5019 ack_delay_exponent (0x000a): The ACK delay exponent is an integer 5020 value indicating an exponent used to decode the ACK Delay field in 5021 the ACK frame (Section 19.3). If this value is absent, a default 5022 value of 3 is assumed (indicating a multiplier of 8). Values 5023 above 20 are invalid. 5025 max_ack_delay (0x000b): The maximum ACK delay is an integer value 5026 indicating the maximum amount of time in milliseconds by which the 5027 endpoint will delay sending acknowledgments. This value SHOULD 5028 include the receiver's expected delays in alarms firing. For 5029 example, if a receiver sets a timer for 5ms and alarms commonly 5030 fire up to 1ms late, then it should send a max_ack_delay of 6ms. 5031 If this value is absent, a default of 25 milliseconds is assumed. 5032 Values of 2^14 or greater are invalid. 5034 disable_active_migration (0x000c): The disable active migration 5035 transport parameter is included if the endpoint does not support 5036 active connection migration (Section 9). Peers of an endpoint 5037 that sets this transport parameter MUST NOT send any packets, 5038 including probing packets (Section 9.1), from a local address or 5039 port other than that used to perform the handshake. This 5040 parameter is a zero-length value. 5042 preferred_address (0x000d): The server's preferred address is used 5043 to effect a change in server address at the end of the handshake, 5044 as described in Section 9.6. The format of this transport 5045 parameter is shown in Figure 18. This transport parameter is only 5046 sent by a server. Servers MAY choose to only send a preferred 5047 address of one address family by sending an all-zero address and 5048 port (0.0.0.0:0 or ::.0) for the other family. IP addresses are 5049 encoded in network byte order. The CID Length field contains the 5050 length of the Connection ID field. 5052 0 1 2 3 5053 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 5054 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5055 | IPv4 Address (32) | 5056 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5057 | IPv4 Port (16) | 5058 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5059 | | 5060 + + 5061 | | 5062 + IPv6 Address (128) + 5063 | | 5064 + + 5065 | | 5066 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5067 | IPv6 Port (16) | 5068 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5069 | CID Length (8)| 5070 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5071 | Connection ID (*) ... 5072 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5073 | | 5074 + + 5075 | | 5076 + Stateless Reset Token (128) + 5077 | | 5078 + + 5079 | | 5080 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5082 Figure 18: Preferred Address format 5084 active_connection_id_limit (0x000e): The maximum number of 5085 connection IDs from the peer that an endpoint is willing to store. 5086 This value includes the connection ID received during the 5087 handshake, that received in the preferred_address transport 5088 parameter, and those received in NEW_CONNECTION_ID frames. Unless 5089 a zero-length connection ID is being used, the value of the 5090 active_connection_id_limit parameter MUST be no less than 2. If 5091 this transport parameter is absent, a default of 2 is assumed. 5092 When a zero-length connection ID is being used, the 5093 active_connection_id_limit parameter MUST NOT be sent. 5095 If present, transport parameters that set initial flow control limits 5096 (initial_max_stream_data_bidi_local, 5097 initial_max_stream_data_bidi_remote, and initial_max_stream_data_uni) 5098 are equivalent to sending a MAX_STREAM_DATA frame (Section 19.10) on 5099 every stream of the corresponding type immediately after opening. If 5100 the transport parameter is absent, streams of that type start with a 5101 flow control limit of 0. 5103 A client MUST NOT include server-only transport parameters 5104 (original_connection_id, stateless_reset_token, or 5105 preferred_address). A server MUST treat receipt of any of these 5106 transport parameters as a connection error of type 5107 TRANSPORT_PARAMETER_ERROR. 5109 19. Frame Types and Formats 5111 As described in Section 12.4, packets contain one or more frames. 5112 This section describes the format and semantics of the core QUIC 5113 frame types. 5115 19.1. PADDING Frame 5117 The PADDING frame (type=0x00) has no semantic value. PADDING frames 5118 can be used to increase the size of a packet. Padding can be used to 5119 increase an initial client packet to the minimum required size, or to 5120 provide protection against traffic analysis for protected packets. 5122 A PADDING frame has no content. That is, a PADDING frame consists of 5123 the single byte that identifies the frame as a PADDING frame. 5125 19.2. PING Frame 5127 Endpoints can use PING frames (type=0x01) to verify that their peers 5128 are still alive or to check reachability to the peer. The PING frame 5129 contains no additional fields. 5131 The receiver of a PING frame simply needs to acknowledge the packet 5132 containing this frame. 5134 The PING frame can be used to keep a connection alive when an 5135 application or application protocol wishes to prevent the connection 5136 from timing out. An application protocol SHOULD provide guidance 5137 about the conditions under which generating a PING is recommended. 5138 This guidance SHOULD indicate whether it is the client or the server 5139 that is expected to send the PING. Having both endpoints send PING 5140 frames without coordination can produce an excessive number of 5141 packets and poor performance. 5143 A connection will time out if no packets are sent or received for a 5144 period longer than the time negotiated using the max_idle_timeout 5145 transport parameter (see Section 10). However, state in middleboxes 5146 might time out earlier than that. Though REQ-5 in [RFC4787] 5147 recommends a 2 minute timeout interval, experience shows that sending 5148 packets every 15 to 30 seconds is necessary to prevent the majority 5149 of middleboxes from losing state for UDP flows. 5151 19.3. ACK Frames 5153 Receivers send ACK frames (types 0x02 and 0x03) to inform senders of 5154 packets they have received and processed. The ACK frame contains one 5155 or more ACK Ranges. ACK Ranges identify acknowledged packets. If 5156 the frame type is 0x03, ACK frames also contain the sum of QUIC 5157 packets with associated ECN marks received on the connection up until 5158 this point. QUIC implementations MUST properly handle both types 5159 and, if they have enabled ECN for packets they send, they SHOULD use 5160 the information in the ECN section to manage their congestion state. 5162 QUIC acknowledgements are irrevocable. Once acknowledged, a packet 5163 remains acknowledged, even if it does not appear in a future ACK 5164 frame. This is unlike TCP SACKs ([RFC2018]). 5166 Packets from different packet number spaces can be identified using 5167 the same numeric value. An acknowledgment for a packet needs to 5168 indicate both a packet number and a packet number space. This is 5169 accomplished by having each ACK frame only acknowledge packet numbers 5170 in the same space as the packet in which the ACK frame is contained. 5172 Version Negotiation and Retry packets cannot be acknowledged because 5173 they do not contain a packet number. Rather than relying on ACK 5174 frames, these packets are implicitly acknowledged by the next Initial 5175 packet sent by the client. 5177 An ACK frame is shown in Figure 19. 5179 0 1 2 3 5180 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 5181 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5182 | Largest Acknowledged (i) ... 5183 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5184 | ACK Delay (i) ... 5185 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5186 | ACK Range Count (i) ... 5187 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5188 | First ACK Range (i) ... 5189 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5190 | ACK Ranges (*) ... 5191 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5192 | [ECN Counts] ... 5193 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5195 Figure 19: ACK Frame Format 5197 ACK frames contain the following fields: 5199 Largest Acknowledged: A variable-length integer representing the 5200 largest packet number the peer is acknowledging; this is usually 5201 the largest packet number that the peer has received prior to 5202 generating the ACK frame. Unlike the packet number in the QUIC 5203 long or short header, the value in an ACK frame is not truncated. 5205 ACK Delay: A variable-length integer representing the time delta in 5206 microseconds between when this ACK was sent and when the largest 5207 acknowledged packet, as indicated in the Largest Acknowledged 5208 field, was received by this peer. The value of the ACK Delay 5209 field is scaled by multiplying the encoded value by 2 to the power 5210 of the value of the "ack_delay_exponent" transport parameter set 5211 by the sender of the ACK frame (see Section 18.2). Scaling in 5212 this fashion allows for a larger range of values with a shorter 5213 encoding at the cost of lower resolution. Because the receiver 5214 doesn't use the ACK Delay for Initial and Handshake packets, a 5215 sender SHOULD send a value of 0. 5217 ACK Range Count: A variable-length integer specifying the number of 5218 Gap and ACK Range fields in the frame. 5220 First ACK Range: A variable-length integer indicating the number of 5221 contiguous packets preceding the Largest Acknowledged that are 5222 being acknowledged. The First ACK Range is encoded as an ACK 5223 Range (see Section 19.3.1) starting from the Largest Acknowledged. 5224 That is, the smallest packet acknowledged in the range is 5225 determined by subtracting the First ACK Range value from the 5226 Largest Acknowledged. 5228 ACK Ranges: Contains additional ranges of packets which are 5229 alternately not acknowledged (Gap) and acknowledged (ACK Range); 5230 see Section 19.3.1. 5232 ECN Counts: The three ECN Counts; see Section 19.3.2. 5234 19.3.1. ACK Ranges 5236 The ACK Ranges field consists of alternating Gap and ACK Range values 5237 in descending packet number order. The number of Gap and ACK Range 5238 values is determined by the ACK Range Count field; one of each value 5239 is present for each value in the ACK Range Count field. 5241 ACK Ranges are structured as shown in Figure 20. 5243 0 1 2 3 5244 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 5245 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5246 | [Gap (i)] ... 5247 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5248 | [ACK Range (i)] ... 5249 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5250 | [Gap (i)] ... 5251 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5252 | [ACK Range (i)] ... 5253 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5254 ... 5255 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5256 | [Gap (i)] ... 5257 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5258 | [ACK Range (i)] ... 5259 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5261 Figure 20: ACK Ranges 5263 The fields that form the ACK Ranges are: 5265 Gap (repeated): A variable-length integer indicating the number of 5266 contiguous unacknowledged packets preceding the packet number one 5267 lower than the smallest in the preceding ACK Range. 5269 ACK Range (repeated): A variable-length integer indicating the 5270 number of contiguous acknowledged packets preceding the largest 5271 packet number, as determined by the preceding Gap. 5273 Gap and ACK Range value use a relative integer encoding for 5274 efficiency. Though each encoded value is positive, the values are 5275 subtracted, so that each ACK Range describes progressively lower- 5276 numbered packets. 5278 Each ACK Range acknowledges a contiguous range of packets by 5279 indicating the number of acknowledged packets that precede the 5280 largest packet number in that range. A value of zero indicates that 5281 only the largest packet number is acknowledged. Larger ACK Range 5282 values indicate a larger range, with corresponding lower values for 5283 the smallest packet number in the range. Thus, given a largest 5284 packet number for the range, the smallest value is determined by the 5285 formula: 5287 smallest = largest - ack_range 5289 An ACK Range acknowledges all packets between the smallest packet 5290 number and the largest, inclusive. 5292 The largest value for an ACK Range is determined by cumulatively 5293 subtracting the size of all preceding ACK Ranges and Gaps. 5295 Each Gap indicates a range of packets that are not being 5296 acknowledged. The number of packets in the gap is one higher than 5297 the encoded value of the Gap field. 5299 The value of the Gap field establishes the largest packet number 5300 value for the subsequent ACK Range using the following formula: 5302 largest = previous_smallest - gap - 2 5304 If any computed packet number is negative, an endpoint MUST generate 5305 a connection error of type FRAME_ENCODING_ERROR. 5307 19.3.2. ECN Counts 5309 The ACK frame uses the least significant bit (that is, type 0x03) to 5310 indicate ECN feedback and report receipt of QUIC packets with 5311 associated ECN codepoints of ECT(0), ECT(1), or CE in the packet's IP 5312 header. ECN Counts are only present when the ACK frame type is 0x03. 5314 ECN Counts are only parsed when the ACK frame type is 0x03. There 5315 are 3 ECN counts, as shown in Figure 21. 5317 0 1 2 3 5318 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 5319 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5320 | ECT(0) Count (i) ... 5321 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5322 | ECT(1) Count (i) ... 5323 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5324 | ECN-CE Count (i) ... 5325 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5327 Figure 21: ECN Count Format 5329 The three ECN Counts are: 5331 ECT(0) Count: A variable-length integer representing the total 5332 number of packets received with the ECT(0) codepoint in the packet 5333 number space of the ACK frame. 5335 ECT(1) Count: A variable-length integer representing the total 5336 number of packets received with the ECT(1) codepoint in the packet 5337 number space of the ACK frame. 5339 CE Count: A variable-length integer representing the total number of 5340 packets received with the CE codepoint in the packet number space 5341 of the ACK frame. 5343 ECN counts are maintained separately for each packet number space. 5345 19.4. RESET_STREAM Frame 5347 An endpoint uses a RESET_STREAM frame (type=0x04) to abruptly 5348 terminate the sending part of a stream. 5350 After sending a RESET_STREAM, an endpoint ceases transmission and 5351 retransmission of STREAM frames on the identified stream. A receiver 5352 of RESET_STREAM can discard any data that it already received on that 5353 stream. 5355 An endpoint that receives a RESET_STREAM frame for a send-only stream 5356 MUST terminate the connection with error STREAM_STATE_ERROR. 5358 The RESET_STREAM frame is shown in Figure 22. 5360 0 1 2 3 5361 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 5362 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5363 | Stream ID (i) ... 5364 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5365 | Application Error Code (i) ... 5366 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5367 | Final Size (i) ... 5368 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5370 Figure 22: RESET_STREAM Frame Format 5372 RESET_STREAM frames contain the following fields: 5374 Stream ID: A variable-length integer encoding of the Stream ID of 5375 the stream being terminated. 5377 Application Protocol Error Code: A variable-length integer 5378 containing the application protocol error code (see Section 20.1) 5379 which indicates why the stream is being closed. 5381 Final Size: A variable-length integer indicating the final size of 5382 the stream by the RESET_STREAM sender, in unit of bytes. 5384 19.5. STOP_SENDING Frame 5386 An endpoint uses a STOP_SENDING frame (type=0x05) to communicate that 5387 incoming data is being discarded on receipt at application request. 5388 STOP_SENDING requests that a peer cease transmission on a stream. 5390 A STOP_SENDING frame can be sent for streams in the Recv or Size 5391 Known states (see Section 3.1). Receiving a STOP_SENDING frame for a 5392 locally-initiated stream that has not yet been created MUST be 5393 treated as a connection error of type STREAM_STATE_ERROR. An 5394 endpoint that receives a STOP_SENDING frame for a receive-only stream 5395 MUST terminate the connection with error STREAM_STATE_ERROR. 5397 The STOP_SENDING frame is shown in Figure 23. 5399 0 1 2 3 5400 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 5401 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5402 | Stream ID (i) ... 5403 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5404 | Application Error Code (i) ... 5405 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5407 Figure 23: STOP_SENDING Frame Format 5409 STOP_SENDING frames contain the following fields: 5411 Stream ID: A variable-length integer carrying the Stream ID of the 5412 stream being ignored. 5414 Application Error Code: A variable-length integer containing the 5415 application-specified reason the sender is ignoring the stream 5416 (see Section 20.1). 5418 19.6. CRYPTO Frame 5420 The CRYPTO frame (type=0x06) is used to transmit cryptographic 5421 handshake messages. It can be sent in all packet types except 0-RTT. 5422 The CRYPTO frame offers the cryptographic protocol an in-order stream 5423 of bytes. CRYPTO frames are functionally identical to STREAM frames, 5424 except that they do not bear a stream identifier; they are not flow 5425 controlled; and they do not carry markers for optional offset, 5426 optional length, and the end of the stream. 5428 The CRYPTO frame is shown in Figure 24. 5430 0 1 2 3 5431 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 5432 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5433 | Offset (i) ... 5434 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5435 | Length (i) ... 5436 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5437 | Crypto Data (*) ... 5438 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5440 Figure 24: CRYPTO Frame Format 5442 CRYPTO frames contain the following fields: 5444 Offset: A variable-length integer specifying the byte offset in the 5445 stream for the data in this CRYPTO frame. 5447 Length: A variable-length integer specifying the length of the 5448 Crypto Data field in this CRYPTO frame. 5450 Crypto Data: The cryptographic message data. 5452 There is a separate flow of cryptographic handshake data in each 5453 encryption level, each of which starts at an offset of 0. This 5454 implies that each encryption level is treated as a separate CRYPTO 5455 stream of data. 5457 The largest offset delivered on a stream - the sum of the offset and 5458 data length - cannot exceed 2^62-1. Receipt of a frame that exceeds 5459 this limit MUST be treated as a connection error of type 5460 FRAME_ENCODING_ERROR or CRYPTO_BUFFER_EXCEEDED. 5462 Unlike STREAM frames, which include a Stream ID indicating to which 5463 stream the data belongs, the CRYPTO frame carries data for a single 5464 stream per encryption level. The stream does not have an explicit 5465 end, so CRYPTO frames do not have a FIN bit. 5467 19.7. NEW_TOKEN Frame 5469 A server sends a NEW_TOKEN frame (type=0x07) to provide the client 5470 with a token to send in the header of an Initial packet for a future 5471 connection. 5473 The NEW_TOKEN frame is shown in Figure 25. 5475 0 1 2 3 5476 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 5477 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5478 | Token Length (i) ... 5479 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5480 | Token (*) ... 5481 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5483 Figure 25: NEW_TOKEN Frame Format 5485 NEW_TOKEN frames contain the following fields: 5487 Token Length: A variable-length integer specifying the length of the 5488 token in bytes. 5490 Token: An opaque blob that the client may use with a future Initial 5491 packet. The token MUST NOT be empty. An endpoint MUST treat 5492 receipt of a NEW_TOKEN frame with an empty Token field as a 5493 connection error of type FRAME_ENCODING_ERROR. 5495 An endpoint might receive multiple NEW_TOKEN frames that contain the 5496 same token value if packets containing the frame are incorrectly 5497 determined to be lost. Endpoints are responsible for discarding 5498 duplicate values, which might be used to link connection attempts; 5499 see Section 8.1.3. 5501 Clients MUST NOT send NEW_TOKEN frames. Servers MUST treat receipt 5502 of a NEW_TOKEN frame as a connection error of type 5503 PROTOCOL_VIOLATION. 5505 19.8. STREAM Frames 5507 STREAM frames implicitly create a stream and carry stream data. The 5508 STREAM frame takes the form 0b00001XXX (or the set of values from 5509 0x08 to 0x0f). The value of the three low-order bits of the frame 5510 type determines the fields that are present in the frame. 5512 * The OFF bit (0x04) in the frame type is set to indicate that there 5513 is an Offset field present. When set to 1, the Offset field is 5514 present. When set to 0, the Offset field is absent and the Stream 5515 Data starts at an offset of 0 (that is, the frame contains the 5516 first bytes of the stream, or the end of a stream that includes no 5517 data). 5519 * The LEN bit (0x02) in the frame type is set to indicate that there 5520 is a Length field present. If this bit is set to 0, the Length 5521 field is absent and the Stream Data field extends to the end of 5522 the packet. If this bit is set to 1, the Length field is present. 5524 * The FIN bit (0x01) of the frame type is set only on frames that 5525 contain the final size of the stream. Setting this bit indicates 5526 that the frame marks the end of the stream. 5528 An endpoint that receives a STREAM frame for a send-only stream MUST 5529 terminate the connection with error STREAM_STATE_ERROR. 5531 The STREAM frames are shown in Figure 26. 5533 0 1 2 3 5534 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 5535 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5536 | Stream ID (i) ... 5537 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5538 | [Offset (i)] ... 5539 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5540 | [Length (i)] ... 5541 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5542 | Stream Data (*) ... 5543 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5545 Figure 26: STREAM Frame Format 5547 STREAM frames contain the following fields: 5549 Stream ID: A variable-length integer indicating the stream ID of the 5550 stream (see Section 2.1). 5552 Offset: A variable-length integer specifying the byte offset in the 5553 stream for the data in this STREAM frame. This field is present 5554 when the OFF bit is set to 1. When the Offset field is absent, 5555 the offset is 0. 5557 Length: A variable-length integer specifying the length of the 5558 Stream Data field in this STREAM frame. This field is present 5559 when the LEN bit is set to 1. When the LEN bit is set to 0, the 5560 Stream Data field consumes all the remaining bytes in the packet. 5562 Stream Data: The bytes from the designated stream to be delivered. 5564 When a Stream Data field has a length of 0, the offset in the STREAM 5565 frame is the offset of the next byte that would be sent. 5567 The first byte in the stream has an offset of 0. The largest offset 5568 delivered on a stream - the sum of the offset and data length - 5569 cannot exceed 2^62-1, as it is not possible to provide flow control 5570 credit for that data. Receipt of a frame that exceeds this limit 5571 MUST be treated as a connection error of type FRAME_ENCODING_ERROR or 5572 FLOW_CONTROL_ERROR. 5574 19.9. MAX_DATA Frame 5576 The MAX_DATA frame (type=0x10) is used in flow control to inform the 5577 peer of the maximum amount of data that can be sent on the connection 5578 as a whole. 5580 The MAX_DATA frame is shown in Figure 27. 5582 0 1 2 3 5583 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 5584 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5585 | Maximum Data (i) ... 5586 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5588 Figure 27: MAX_DATA Frame Format 5590 MAX_DATA frames contain the following fields: 5592 Maximum Data: A variable-length integer indicating the maximum 5593 amount of data that can be sent on the entire connection, in units 5594 of bytes. 5596 All data sent in STREAM frames counts toward this limit. The sum of 5597 the largest received offsets on all streams - including streams in 5598 terminal states - MUST NOT exceed the value advertised by a receiver. 5599 An endpoint MUST terminate a connection with a FLOW_CONTROL_ERROR 5600 error if it receives more data than the maximum data value that it 5601 has sent, unless this is a result of a change in the initial limits 5602 (see Section 7.3.1). 5604 19.10. MAX_STREAM_DATA Frame 5606 The MAX_STREAM_DATA frame (type=0x11) is used in flow control to 5607 inform a peer of the maximum amount of data that can be sent on a 5608 stream. 5610 A MAX_STREAM_DATA frame can be sent for streams in the Recv state 5611 (see Section 3.1). Receiving a MAX_STREAM_DATA frame for a locally- 5612 initiated stream that has not yet been created MUST be treated as a 5613 connection error of type STREAM_STATE_ERROR. An endpoint that 5614 receives a MAX_STREAM_DATA frame for a receive-only stream MUST 5615 terminate the connection with error STREAM_STATE_ERROR. 5617 The MAX_STREAM_DATA frame is shown in Figure 28. 5619 0 1 2 3 5620 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 5621 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5622 | Stream ID (i) ... 5623 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5624 | Maximum Stream Data (i) ... 5625 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5627 Figure 28: MAX_STREAM_DATA Frame Format 5629 MAX_STREAM_DATA frames contain the following fields: 5631 Stream ID: The stream ID of the stream that is affected encoded as a 5632 variable-length integer. 5634 Maximum Stream Data: A variable-length integer indicating the 5635 maximum amount of data that can be sent on the identified stream, 5636 in units of bytes. 5638 When counting data toward this limit, an endpoint accounts for the 5639 largest received offset of data that is sent or received on the 5640 stream. Loss or reordering can mean that the largest received offset 5641 on a stream can be greater than the total size of data received on 5642 that stream. Receiving STREAM frames might not increase the largest 5643 received offset. 5645 The data sent on a stream MUST NOT exceed the largest maximum stream 5646 data value advertised by the receiver. An endpoint MUST terminate a 5647 connection with a FLOW_CONTROL_ERROR error if it receives more data 5648 than the largest maximum stream data that it has sent for the 5649 affected stream, unless this is a result of a change in the initial 5650 limits (see Section 7.3.1). 5652 19.11. MAX_STREAMS Frames 5654 The MAX_STREAMS frames (type=0x12 and 0x13) inform the peer of the 5655 cumulative number of streams of a given type it is permitted to open. 5656 A MAX_STREAMS frame with a type of 0x12 applies to bidirectional 5657 streams, and a MAX_STREAMS frame with a type of 0x13 applies to 5658 unidirectional streams. 5660 The MAX_STREAMS frames are shown in Figure 29; 5662 0 1 2 3 5663 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 5664 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5665 | Maximum Streams (i) ... 5666 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5667 Figure 29: MAX_STREAMS Frame Format 5669 MAX_STREAMS frames contain the following fields: 5671 Maximum Streams: A count of the cumulative number of streams of the 5672 corresponding type that can be opened over the lifetime of the 5673 connection. Stream IDs cannot exceed 2^62-1, as it is not 5674 possible to encode stream IDs larger than this value. Receipt of 5675 a frame that permits opening of a stream larger than this limit 5676 MUST be treated as a FRAME_ENCODING_ERROR. 5678 Loss or reordering can cause a MAX_STREAMS frame to be received which 5679 states a lower stream limit than an endpoint has previously received. 5680 MAX_STREAMS frames which do not increase the stream limit MUST be 5681 ignored. 5683 An endpoint MUST NOT open more streams than permitted by the current 5684 stream limit set by its peer. For instance, a server that receives a 5685 unidirectional stream limit of 3 is permitted to open stream 3, 7, 5686 and 11, but not stream 15. An endpoint MUST terminate a connection 5687 with a STREAM_LIMIT_ERROR error if a peer opens more streams than was 5688 permitted. 5690 Note that these frames (and the corresponding transport parameters) 5691 do not describe the number of streams that can be opened 5692 concurrently. The limit includes streams that have been closed as 5693 well as those that are open. 5695 19.12. DATA_BLOCKED Frame 5697 A sender SHOULD send a DATA_BLOCKED frame (type=0x14) when it wishes 5698 to send data, but is unable to due to connection-level flow control 5699 (see Section 4). DATA_BLOCKED frames can be used as input to tuning 5700 of flow control algorithms (see Section 4.2). 5702 The DATA_BLOCKED frame is shown in Figure 30. 5704 0 1 2 3 5705 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 5706 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5707 | Data Limit (i) ... 5708 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5710 Figure 30: DATA_BLOCKED Frame Format 5712 DATA_BLOCKED frames contain the following fields: 5714 Data Limit: A variable-length integer indicating the connection- 5715 level limit at which blocking occurred. 5717 19.13. STREAM_DATA_BLOCKED Frame 5719 A sender SHOULD send a STREAM_DATA_BLOCKED frame (type=0x15) when it 5720 wishes to send data, but is unable to due to stream-level flow 5721 control. This frame is analogous to DATA_BLOCKED (Section 19.12). 5723 An endpoint that receives a STREAM_DATA_BLOCKED frame for a send-only 5724 stream MUST terminate the connection with error STREAM_STATE_ERROR. 5726 The STREAM_DATA_BLOCKED frame is shown in Figure 31. 5728 0 1 2 3 5729 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 5730 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5731 | Stream ID (i) ... 5732 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5733 | Stream Data Limit (i) ... 5734 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5736 Figure 31: STREAM_DATA_BLOCKED Frame Format 5738 STREAM_DATA_BLOCKED frames contain the following fields: 5740 Stream ID: A variable-length integer indicating the stream which is 5741 flow control blocked. 5743 Stream Data Limit: A variable-length integer indicating the offset 5744 of the stream at which the blocking occurred. 5746 19.14. STREAMS_BLOCKED Frames 5748 A sender SHOULD send a STREAMS_BLOCKED frame (type=0x16 or 0x17) when 5749 it wishes to open a stream, but is unable to due to the maximum 5750 stream limit set by its peer (see Section 19.11). A STREAMS_BLOCKED 5751 frame of type 0x16 is used to indicate reaching the bidirectional 5752 stream limit, and a STREAMS_BLOCKED frame of type 0x17 indicates 5753 reaching the unidirectional stream limit. 5755 A STREAMS_BLOCKED frame does not open the stream, but informs the 5756 peer that a new stream was needed and the stream limit prevented the 5757 creation of the stream. 5759 The STREAMS_BLOCKED frames are shown in Figure 32. 5761 0 1 2 3 5762 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 5763 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5764 | Stream Limit (i) ... 5765 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5767 Figure 32: STREAMS_BLOCKED Frame Format 5769 STREAMS_BLOCKED frames contain the following fields: 5771 Stream Limit: A variable-length integer indicating the stream limit 5772 at the time the frame was sent. Stream IDs cannot exceed 2^62-1, 5773 as it is not possible to encode stream IDs larger than this value. 5774 Receipt of a frame that encodes a larger stream ID MUST be treated 5775 as a STREAM_LIMIT_ERROR or a FRAME_ENCODING_ERROR. 5777 19.15. NEW_CONNECTION_ID Frame 5779 An endpoint sends a NEW_CONNECTION_ID frame (type=0x18) to provide 5780 its peer with alternative connection IDs that can be used to break 5781 linkability when migrating connections (see Section 9.5). 5783 The NEW_CONNECTION_ID frame is shown in Figure 33. 5785 0 1 2 3 5786 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 5787 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5788 | Sequence Number (i) ... 5789 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5790 | Retire Prior To (i) ... 5791 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5792 | Length (8) | | 5793 +-+-+-+-+-+-+-+-+ Connection ID (8..160) + 5794 | ... 5795 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5796 | | 5797 + + 5798 | | 5799 + Stateless Reset Token (128) + 5800 | | 5801 + + 5802 | | 5803 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5805 Figure 33: NEW_CONNECTION_ID Frame Format 5807 NEW_CONNECTION_ID frames contain the following fields: 5809 Sequence Number: The sequence number assigned to the connection ID 5810 by the sender. See Section 5.1.1. 5812 Retire Prior To: A variable-length integer indicating which 5813 connection IDs should be retired. See Section 5.1.2. 5815 Length: An 8-bit unsigned integer containing the length of the 5816 connection ID. Values less than 1 and greater than 20 are invalid 5817 and MUST be treated as a connection error of type 5818 FRAME_ENCODING_ERROR. 5820 Connection ID: A connection ID of the specified length. 5822 Stateless Reset Token: A 128-bit value that will be used for a 5823 stateless reset when the associated connection ID is used (see 5824 Section 10.4). 5826 An endpoint MUST NOT send this frame if it currently requires that 5827 its peer send packets with a zero-length Destination Connection ID. 5828 Changing the length of a connection ID to or from zero-length makes 5829 it difficult to identify when the value of the connection ID changed. 5830 An endpoint that is sending packets with a zero-length Destination 5831 Connection ID MUST treat receipt of a NEW_CONNECTION_ID frame as a 5832 connection error of type PROTOCOL_VIOLATION. 5834 Transmission errors, timeouts and retransmissions might cause the 5835 same NEW_CONNECTION_ID frame to be received multiple times. Receipt 5836 of the same frame multiple times MUST NOT be treated as a connection 5837 error. A receiver can use the sequence number supplied in the 5838 NEW_CONNECTION_ID frame to identify new connection IDs from old ones. 5840 If an endpoint receives a NEW_CONNECTION_ID frame that repeats a 5841 previously issued connection ID with a different Stateless Reset 5842 Token or a different sequence number, or if a sequence number is used 5843 for different connection IDs, the endpoint MAY treat that receipt as 5844 a connection error of type PROTOCOL_VIOLATION. 5846 The Retire Prior To field counts connection IDs established during 5847 connection setup and the preferred_address transport parameter (see 5848 Section 5.1.2). The Retire Prior To field MUST be less than or equal 5849 to the Sequence Number field. Receiving a value greater than the 5850 Sequence Number MUST be treated as a connection error of type 5851 FRAME_ENCODING_ERROR. 5853 Once a sender indicates a Retire Prior To value, smaller values sent 5854 in subsequent NEW_CONNECTION_ID frames have no effect. A receiver 5855 MUST ignore any Retire Prior To fields that do not increase the 5856 largest received Retire Prior To value. 5858 An endpoint that receives a NEW_CONNECTION_ID frame with a sequence 5859 number smaller than the Retire Prior To field of a previously 5860 received NEW_CONNECTION_ID frame MUST immediately send a 5861 corresponding RETIRE_CONNECTION_ID frame that retires the newly 5862 received connection ID. 5864 19.16. RETIRE_CONNECTION_ID Frame 5866 An endpoint sends a RETIRE_CONNECTION_ID frame (type=0x19) to 5867 indicate that it will no longer use a connection ID that was issued 5868 by its peer. This may include the connection ID provided during the 5869 handshake. Sending a RETIRE_CONNECTION_ID frame also serves as a 5870 request to the peer to send additional connection IDs for future use 5871 (see Section 5.1). New connection IDs can be delivered to a peer 5872 using the NEW_CONNECTION_ID frame (Section 19.15). 5874 Retiring a connection ID invalidates the stateless reset token 5875 associated with that connection ID. 5877 The RETIRE_CONNECTION_ID frame is shown in Figure 34. 5879 0 1 2 3 5880 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 5881 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5882 | Sequence Number (i) ... 5883 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5885 Figure 34: RETIRE_CONNECTION_ID Frame Format 5887 RETIRE_CONNECTION_ID frames contain the following fields: 5889 Sequence Number: The sequence number of the connection ID being 5890 retired. See Section 5.1.2. 5892 Receipt of a RETIRE_CONNECTION_ID frame containing a sequence number 5893 greater than any previously sent to the peer MUST be treated as a 5894 connection error of type PROTOCOL_VIOLATION. 5896 The sequence number specified in a RETIRE_CONNECTION_ID frame MUST 5897 NOT refer to the Destination Connection ID field of the packet in 5898 which the frame is contained. The peer MAY treat this as a 5899 connection error of type FRAME_ENCODING_ERROR. 5901 An endpoint cannot send this frame if it was provided with a zero- 5902 length connection ID by its peer. An endpoint that provides a zero- 5903 length connection ID MUST treat receipt of a RETIRE_CONNECTION_ID 5904 frame as a connection error of type PROTOCOL_VIOLATION. 5906 19.17. PATH_CHALLENGE Frame 5908 Endpoints can use PATH_CHALLENGE frames (type=0x1a) to check 5909 reachability to the peer and for path validation during connection 5910 migration. 5912 The PATH_CHALLENGE frame is shown in Figure 35. 5914 0 1 2 3 5915 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 5916 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5917 | | 5918 + Data (64) + 5919 | | 5920 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5922 Figure 35: PATH_CHALLENGE Frame Format 5924 PATH_CHALLENGE frames contain the following fields: 5926 Data: This 8-byte field contains arbitrary data. 5928 A PATH_CHALLENGE frame containing 8 bytes that are hard to guess is 5929 sufficient to ensure that it is easier to receive the packet than it 5930 is to guess the value correctly. 5932 The recipient of this frame MUST generate a PATH_RESPONSE frame 5933 (Section 19.18) containing the same Data. 5935 19.18. PATH_RESPONSE Frame 5937 The PATH_RESPONSE frame (type=0x1b) is sent in response to a 5938 PATH_CHALLENGE frame. Its format is identical to the PATH_CHALLENGE 5939 frame (Section 19.17). 5941 If the content of a PATH_RESPONSE frame does not match the content of 5942 a PATH_CHALLENGE frame previously sent by the endpoint, the endpoint 5943 MAY generate a connection error of type PROTOCOL_VIOLATION. 5945 19.19. CONNECTION_CLOSE Frames 5947 An endpoint sends a CONNECTION_CLOSE frame (type=0x1c or 0x1d) to 5948 notify its peer that the connection is being closed. The 5949 CONNECTION_CLOSE with a frame type of 0x1c is used to signal errors 5950 at only the QUIC layer, or the absence of errors (with the NO_ERROR 5951 code). The CONNECTION_CLOSE frame with a type of 0x1d is used to 5952 signal an error with the application that uses QUIC. 5954 If there are open streams that haven't been explicitly closed, they 5955 are implicitly closed when the connection is closed. 5957 The CONNECTION_CLOSE frames are shown in Figure 36. 5959 0 1 2 3 5960 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 5961 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5962 | Error Code (i) ... 5963 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5964 | [ Frame Type (i) ] ... 5965 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5966 | Reason Phrase Length (i) ... 5967 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5968 | Reason Phrase (*) ... 5969 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 5971 Figure 36: CONNECTION_CLOSE Frame Format 5973 CONNECTION_CLOSE frames contain the following fields: 5975 Error Code: A variable length integer error code which indicates the 5976 reason for closing this connection. A CONNECTION_CLOSE frame of 5977 type 0x1c uses codes from the space defined in Section 20. A 5978 CONNECTION_CLOSE frame of type 0x1d uses codes from the 5979 application protocol error code space; see Section 20.1 5981 Frame Type: A variable-length integer encoding the type of frame 5982 that triggered the error. A value of 0 (equivalent to the mention 5983 of the PADDING frame) is used when the frame type is unknown. The 5984 application-specific variant of CONNECTION_CLOSE (type 0x1d) does 5985 not include this field. 5987 Reason Phrase Length: A variable-length integer specifying the 5988 length of the reason phrase in bytes. Because a CONNECTION_CLOSE 5989 frame cannot be split between packets, any limits on packet size 5990 will also limit the space available for a reason phrase. 5992 Reason Phrase: A human-readable explanation for why the connection 5993 was closed. This can be zero length if the sender chooses to not 5994 give details beyond the Error Code. This SHOULD be a UTF-8 5995 encoded string [RFC3629]. 5997 The application-specific variant of CONNECTION_CLOSE (type 0x1d) can 5998 only be sent using an 1-RTT packet ([QUIC-TLS], Section 4). When an 5999 application wishes to abandon a connection during the handshake, an 6000 endpoint can send a CONNECTION_CLOSE frame (type 0x1c) with an error 6001 code of 0x15a ("user_canceled" alert; see [TLS13]) in an Initial or a 6002 Handshake packet. 6004 19.20. HANDSHAKE_DONE frame 6006 The server uses the HANDSHAKE_DONE frame (type=0x1e) to signal 6007 confirmation of the handshake to the client. The HANDSHAKE_DONE 6008 frame contains no additional fields. 6010 This frame can only be sent by the server. Servers MUST NOT send a 6011 HANDSHAKE_DONE frame before completing the handshake. A server MUST 6012 treat receipt of a HANDSHAKE_DONE frame as a connection error of type 6013 PROTOCOL_VIOLATION. 6015 19.21. Extension Frames 6017 QUIC frames do not use a self-describing encoding. An endpoint 6018 therefore needs to understand the syntax of all frames before it can 6019 successfully process a packet. This allows for efficient encoding of 6020 frames, but it means that an endpoint cannot send a frame of a type 6021 that is unknown to its peer. 6023 An extension to QUIC that wishes to use a new type of frame MUST 6024 first ensure that a peer is able to understand the frame. An 6025 endpoint can use a transport parameter to signal its willingness to 6026 receive one or more extension frame types with the one transport 6027 parameter. 6029 Extension frames MUST be congestion controlled and MUST cause an ACK 6030 frame to be sent. The exception is extension frames that replace or 6031 supplement the ACK frame. Extension frames are not included in flow 6032 control unless specified in the extension. 6034 An IANA registry is used to manage the assignment of frame types; see 6035 Section 22.3. 6037 20. Transport Error Codes 6039 QUIC error codes are 62-bit unsigned integers. 6041 This section lists the defined QUIC transport error codes that may be 6042 used in a CONNECTION_CLOSE frame. These errors apply to the entire 6043 connection. 6045 NO_ERROR (0x0): An endpoint uses this with CONNECTION_CLOSE to 6046 signal that the connection is being closed abruptly in the absence 6047 of any error. 6049 INTERNAL_ERROR (0x1): The endpoint encountered an internal error and 6050 cannot continue with the connection. 6052 SERVER_BUSY (0x2): The server is currently busy and does not accept 6053 any new connections. 6055 FLOW_CONTROL_ERROR (0x3): An endpoint received more data than it 6056 permitted in its advertised data limits (see Section 4). 6058 STREAM_LIMIT_ERROR (0x4): An endpoint received a frame for a stream 6059 identifier that exceeded its advertised stream limit for the 6060 corresponding stream type. 6062 STREAM_STATE_ERROR (0x5): An endpoint received a frame for a stream 6063 that was not in a state that permitted that frame (see Section 3). 6065 FINAL_SIZE_ERROR (0x6): An endpoint received a STREAM frame 6066 containing data that exceeded the previously established final 6067 size. Or an endpoint received a STREAM frame or a RESET_STREAM 6068 frame containing a final size that was lower than the size of 6069 stream data that was already received. Or an endpoint received a 6070 STREAM frame or a RESET_STREAM frame containing a different final 6071 size to the one already established. 6073 FRAME_ENCODING_ERROR (0x7): An endpoint received a frame that was 6074 badly formatted. For instance, a frame of an unknown type, or an 6075 ACK frame that has more acknowledgment ranges than the remainder 6076 of the packet could carry. 6078 TRANSPORT_PARAMETER_ERROR (0x8): An endpoint received transport 6079 parameters that were badly formatted, included an invalid value, 6080 was absent even though it is mandatory, was present though it is 6081 forbidden, or is otherwise in error. 6083 CONNECTION_ID_LIMIT_ERROR (0x9): The number of connection IDs 6084 provided by the peer exceeds the advertised 6085 active_connection_id_limit. 6087 PROTOCOL_VIOLATION (0xA): An endpoint detected an error with 6088 protocol compliance that was not covered by more specific error 6089 codes. 6091 INVALID_TOKEN (0xB): A server received a Retry Token in a client 6092 Initial that is invalid. 6094 CRYPTO_BUFFER_EXCEEDED (0xD): An endpoint has received more data in 6095 CRYPTO frames than it can buffer. 6097 CRYPTO_ERROR (0x1XX): The cryptographic handshake failed. A range 6098 of 256 values is reserved for carrying error codes specific to the 6099 cryptographic handshake that is used. Codes for errors occurring 6100 when TLS is used for the crypto handshake are described in 6101 Section 4.8 of [QUIC-TLS]. 6103 See Section 22.4 for details of registering new error codes. 6105 In defining these error codes, several principles are applied. Error 6106 conditions that might require specific action on the part of a 6107 recipient are given unique codes. Errors that represent common 6108 conditions are given specific codes. Absent either of these 6109 conditions, error codes are used to identify a general function of 6110 the stack, like flow control or transport parameter handling. 6111 Finally, generic errors are provided for conditions where 6112 implementations are unable or unwilling to use more specific codes. 6114 20.1. Application Protocol Error Codes 6116 Application protocol error codes are 62-bit unsigned integers, but 6117 the management of application error codes is left to application 6118 protocols. Application protocol error codes are used for the 6119 RESET_STREAM frame (Section 19.4), the STOP_SENDING frame 6120 (Section 19.5), and the CONNECTION_CLOSE frame with a type of 0x1d 6121 (Section 19.19). 6123 21. Security Considerations 6125 21.1. Handshake Denial of Service 6127 As an encrypted and authenticated transport QUIC provides a range of 6128 protections against denial of service. Once the cryptographic 6129 handshake is complete, QUIC endpoints discard most packets that are 6130 not authenticated, greatly limiting the ability of an attacker to 6131 interfere with existing connections. 6133 Once a connection is established QUIC endpoints might accept some 6134 unauthenticated ICMP packets (see Section 14.2), but the use of these 6135 packets is extremely limited. The only other type of packet that an 6136 endpoint might accept is a stateless reset (Section 10.4) which 6137 relies on the token being kept secret until it is used. 6139 During the creation of a connection, QUIC only provides protection 6140 against attack from off the network path. All QUIC packets contain 6141 proof that the recipient saw a preceding packet from its peer. 6143 The first mechanism used is the source and destination connection 6144 IDs, which are required to match those set by a peer. Except for an 6145 Initial and stateless reset packets, an endpoint only accepts packets 6146 that include a destination connection that matches a connection ID 6147 the endpoint previously chose. This is the only protection offered 6148 for Version Negotiation packets. 6150 The destination connection ID in an Initial packet is selected by a 6151 client to be unpredictable, which serves an additional purpose. The 6152 packets that carry the cryptographic handshake are protected with a 6153 key that is derived from this connection ID and salt specific to the 6154 QUIC version. This allows endpoints to use the same process for 6155 authenticating packets that they receive as they use after the 6156 cryptographic handshake completes. Packets that cannot be 6157 authenticated are discarded. Protecting packets in this fashion 6158 provides a strong assurance that the sender of the packet saw the 6159 Initial packet and understood it. 6161 These protections are not intended to be effective against an 6162 attacker that is able to receive QUIC packets prior to the connection 6163 being established. Such an attacker can potentially send packets 6164 that will be accepted by QUIC endpoints. This version of QUIC 6165 attempts to detect this sort of attack, but it expects that endpoints 6166 will fail to establish a connection rather than recovering. For the 6167 most part, the cryptographic handshake protocol [QUIC-TLS] is 6168 responsible for detecting tampering during the handshake. 6170 Endpoints are permitted to use other methods to detect and attempt to 6171 recover from interference with the handshake. Invalid packets may be 6172 identified and discarded using other methods, but no specific method 6173 is mandated in this document. 6175 21.2. Amplification Attack 6177 An attacker might be able to receive an address validation token 6178 (Section 8) from a server and then release the IP address it used to 6179 acquire that token. At a later time, the attacker may initiate a 6180 0-RTT connection with a server by spoofing this same address, which 6181 might now address a different (victim) endpoint. The attacker can 6182 thus potentially cause the server to send an initial congestion 6183 window's worth of data towards the victim. 6185 Servers SHOULD provide mitigations for this attack by limiting the 6186 usage and lifetime of address validation tokens (see Section 8.1.3). 6188 21.3. Optimistic ACK Attack 6190 An endpoint that acknowledges packets it has not received might cause 6191 a congestion controller to permit sending at rates beyond what the 6192 network supports. An endpoint MAY skip packet numbers when sending 6193 packets to detect this behavior. An endpoint can then immediately 6194 close the connection with a connection error of type 6195 PROTOCOL_VIOLATION (see Section 10.3). 6197 21.4. Slowloris Attacks 6199 The attacks commonly known as Slowloris [SLOWLORIS] try to keep many 6200 connections to the target endpoint open and hold them open as long as 6201 possible. These attacks can be executed against a QUIC endpoint by 6202 generating the minimum amount of activity necessary to avoid being 6203 closed for inactivity. This might involve sending small amounts of 6204 data, gradually opening flow control windows in order to control the 6205 sender rate, or manufacturing ACK frames that simulate a high loss 6206 rate. 6208 QUIC deployments SHOULD provide mitigations for the Slowloris 6209 attacks, such as increasing the maximum number of clients the server 6210 will allow, limiting the number of connections a single IP address is 6211 allowed to make, imposing restrictions on the minimum transfer speed 6212 a connection is allowed to have, and restricting the length of time 6213 an endpoint is allowed to stay connected. 6215 21.5. Stream Fragmentation and Reassembly Attacks 6217 An adversarial sender might intentionally send fragments of stream 6218 data in order to cause disproportionate receive buffer memory 6219 commitment and/or creation of a large and inefficient data structure. 6221 An adversarial receiver might intentionally not acknowledge packets 6222 containing stream data in order to force the sender to store the 6223 unacknowledged stream data for retransmission. 6225 The attack on receivers is mitigated if flow control windows 6226 correspond to available memory. However, some receivers will over- 6227 commit memory and advertise flow control offsets in the aggregate 6228 that exceed actual available memory. The over-commitment strategy 6229 can lead to better performance when endpoints are well behaved, but 6230 renders endpoints vulnerable to the stream fragmentation attack. 6232 QUIC deployments SHOULD provide mitigations against stream 6233 fragmentation attacks. Mitigations could consist of avoiding over- 6234 committing memory, limiting the size of tracking data structures, 6235 delaying reassembly of STREAM frames, implementing heuristics based 6236 on the age and duration of reassembly holes, or some combination. 6238 21.6. Stream Commitment Attack 6240 An adversarial endpoint can open lots of streams, exhausting state on 6241 an endpoint. The adversarial endpoint could repeat the process on a 6242 large number of connections, in a manner similar to SYN flooding 6243 attacks in TCP. 6245 Normally, clients will open streams sequentially, as explained in 6246 Section 2.1. However, when several streams are initiated at short 6247 intervals, loss or reordering may cause STREAM frames that open 6248 streams to be received out of sequence. On receiving a higher- 6249 numbered stream ID, a receiver is required to open all intervening 6250 streams of the same type (see Section 3.2). Thus, on a new 6251 connection, opening stream 4000000 opens 1 million and 1 client- 6252 initiated bidirectional streams. 6254 The number of active streams is limited by the 6255 initial_max_streams_bidi and initial_max_streams_uni transport 6256 parameters, as explained in Section 4.5. If chosen judiciously, 6257 these limits mitigate the effect of the stream commitment attack. 6258 However, setting the limit too low could affect performance when 6259 applications expect to open large number of streams. 6261 21.7. Peer Denial of Service 6263 QUIC and TLS both contain messages that have legitimate uses in some 6264 contexts, but that can be abused to cause a peer to expend processing 6265 resources without having any observable impact on the state of the 6266 connection. 6268 Messages can also be used to change and revert state in small or 6269 inconsequential ways, such as by sending small increments to flow 6270 control limits. 6272 If processing costs are disproportionately large in comparison to 6273 bandwidth consumption or effect on state, then this could allow a 6274 malicious peer to exhaust processing capacity. 6276 While there are legitimate uses for all messages, implementations 6277 SHOULD track cost of processing relative to progress and treat 6278 excessive quantities of any non-productive packets as indicative of 6279 an attack. Endpoints MAY respond to this condition with a connection 6280 error, or by dropping packets. 6282 21.8. Explicit Congestion Notification Attacks 6284 An on-path attacker could manipulate the value of ECN codepoints in 6285 the IP header to influence the sender's rate. [RFC3168] discusses 6286 manipulations and their effects in more detail. 6288 An on-the-side attacker can duplicate and send packets with modified 6289 ECN codepoints to affect the sender's rate. If duplicate packets are 6290 discarded by a receiver, an off-path attacker will need to race the 6291 duplicate packet against the original to be successful in this 6292 attack. Therefore, QUIC endpoints ignore the ECN codepoint field on 6293 an IP packet unless at least one QUIC packet in that IP packet is 6294 successfully processed; see Section 13.4. 6296 21.9. Stateless Reset Oracle 6298 Stateless resets create a possible denial of service attack analogous 6299 to a TCP reset injection. This attack is possible if an attacker is 6300 able to cause a stateless reset token to be generated for a 6301 connection with a selected connection ID. An attacker that can cause 6302 this token to be generated can reset an active connection with the 6303 same connection ID. 6305 If a packet can be routed to different instances that share a static 6306 key, for example by changing an IP address or port, then an attacker 6307 can cause the server to send a stateless reset. To defend against 6308 this style of denial service, endpoints that share a static key for 6309 stateless reset (see Section 10.4.2) MUST be arranged so that packets 6310 with a given connection ID always arrive at an instance that has 6311 connection state, unless that connection is no longer active. 6313 In the case of a cluster that uses dynamic load balancing, it's 6314 possible that a change in load balancer configuration could happen 6315 while an active instance retains connection state; even if an 6316 instance retains connection state, the change in routing and 6317 resulting stateless reset will result in the connection being 6318 terminated. If there is no chance in the packet being routed to the 6319 correct instance, it is better to send a stateless reset than wait 6320 for connections to time out. However, this is acceptable only if the 6321 routing cannot be influenced by an attacker. 6323 21.10. Version Downgrade 6325 This document defines QUIC Version Negotiation packets in Section 6, 6326 which can be used to negotiate the QUIC version used between two 6327 endpoints. However, this document does not specify how this 6328 negotiation will be performed between this version and subsequent 6329 future versions. In particular, Version Negotiation packets do not 6330 contain any mechanism to prevent version downgrade attacks. Future 6331 versions of QUIC that use Version Negotiation packets MUST define a 6332 mechanism that is robust against version downgrade attacks. 6334 21.11. Targeted Attacks by Routing 6336 Deployments should limit the ability of an attacker to target a new 6337 connection to a particular server instance. This means that client- 6338 controlled fields, such as the initial Destination Connection ID used 6339 on Initial and 0-RTT packets SHOULD NOT be used by themselves to make 6340 routing decisions. Ideally, routing decisions are made independently 6341 of client-selected values; a Source Connection ID can be selected to 6342 route later packets to the same server. 6344 21.12. Overview of Security Properties 6346 A complete security analysis of QUIC is outside the scope of this 6347 document. This section provides an informal description of the 6348 desired security properties as an aid to implementors and to help 6349 guide protocol analysis. 6351 QUIC assumes the threat model described in [SEC-CONS] and provides 6352 protections against many of the attacks that arise from that model. 6354 For this purpose, attacks are divided into passive and active 6355 attacks. Passive attackers have the capability to read packets from 6356 the network, while active attackers also have the capability to write 6357 packets into the network. However, a passive attack may involve an 6358 attacker with the ability to cause a routing change or other 6359 modification in the path taken by packets that comprise a connection. 6361 Attackers are additionally categorized as either on-path attackers or 6362 off-path attackers; see Section 3.5 of [SEC-CONS]. An on-path 6363 attacker can read, modify, or remove any packet it observes such that 6364 it no longer reaches its destination, while an off-path attacker 6365 observes the packets, but cannot prevent the original packet from 6366 reaching its intended destination. An off-path attacker can also 6367 transmit arbitrary packets. 6369 Properties of the handshake, protected packets, and connection 6370 migration are considered separately. 6372 21.12.1. Handshake 6374 The QUIC handshake incorporates the TLS 1.3 handshake and enjoys the 6375 cryptographic properties described in Appendix E.1 of [TLS13]. 6377 In addition to those properties, the handshake is intended to provide 6378 some defense against DoS attacks on the handshake, as described 6379 below. 6381 21.12.1.1. Anti-Amplification 6383 Address validation (Section 8) is used to verify that an entity that 6384 claims a given address is able to receive packets at that address. 6385 Address validation limits amplification attack targets to addresses 6386 for which an attacker is either on-path or off-path. 6388 Prior to validation, endpoints are limited in what they are able to 6389 send. During the handshake, a server cannot send more than three 6390 times the data it receives; clients that initiate new connections or 6391 migrate to a new network path are limited. 6393 21.12.1.2. Server-Side DoS 6395 Computing the server's first flight for a full handshake is 6396 potentially expensive, requiring both a signature and a key exchange 6397 computation. In order to prevent computational DoS attacks, the 6398 Retry packet provides a cheap token exchange mechanism which allows 6399 servers to validate a client's IP address prior to doing any 6400 expensive computations at the cost of a single round trip. After a 6401 successful handshake, servers can issue new tokens to a client which 6402 will allow new connection establishment without incurring this cost. 6404 21.12.1.3. On-Path Handshake Termination 6406 An on-path or off-path attacker can force a handshake to fail by 6407 replacing or racing Initial packets. Once valid Initial packets have 6408 been exchanged, subsequent Handshake packets are protected with the 6409 handshake keys and an on-path attacker cannot force handshake failure 6410 other than by dropping packets to cause endpoints to abandon the 6411 attempt. 6413 An on-path attacker can also replace the addresses of packets on 6414 either side and therefore cause the client or server to have an 6415 incorrect view of the remote addresses. Such an attack is 6416 indistinguishable from the functions performed by a NAT. 6418 21.12.1.4. Parameter Negotiation 6420 The entire handshake is cryptographically protected, with the Initial 6421 packets being encrypted with per-version keys and the Handshake and 6422 later packets being encrypted with keys derived from the TLS key 6423 exchange. Further, parameter negotiation is folded into the TLS 6424 transcript and thus provides the same security guarantees as ordinary 6425 TLS negotiation. Thus, an attacker can observe the client's 6426 transport parameters (as long as it knows the version-specific salt) 6427 but cannot observe the server's transport parameters and cannot 6428 influence parameter negotiation. 6430 Connection IDs are unencrypted but integrity protected in all 6431 packets. 6433 This version of QUIC does not incorporate a version negotiation 6434 mechanism; implementations of incompatible versions will simply fail 6435 to establish a connection. 6437 21.12.2. Protected Packets 6439 Packet protection (Section 12.1) provides authentication and 6440 encryption of all packets except Version Negotiation packets, though 6441 Initial and Retry packets have limited encryption and authentication 6442 based on version-specific keys; see [QUIC-TLS] for more details. 6443 This section considers passive and active attacks against protected 6444 packets. 6446 Both on-path and off-path attackers can mount a passive attack in 6447 which they save observed packets for an offline attack against packet 6448 protection at a future time; this is true for any observer of any 6449 packet on any network. 6451 A blind attacker, one who injects packets without being able to 6452 observe valid packets for a connection, is unlikely to be successful, 6453 since packet protection ensures that valid packets are only generated 6454 by endpoints which possess the key material established during the 6455 handshake; see Section 7 and Section 21.12.1. Similarly, any active 6456 attacker that observes packets and attempts to insert new data or 6457 modify existing data in those packets should not be able to generate 6458 packets deemed valid by the receiving endpoint. 6460 A spoofing attack, in which an active attacker rewrites unprotected 6461 parts of a packet that it forwards or injects, such as the source or 6462 destination address, is only effective if the attacker can forward 6463 packets to the original endpoint. Packet protection ensures that the 6464 packet payloads can only be processed by the endpoints that completed 6465 the handshake, and invalid packets are ignored by those endpoints. 6467 An attacker can also modify the boundaries between packets and UDP 6468 datagrams, causing multiple packets to be coalesced into a single 6469 datagram, or splitting coalesced packets into multiple datagrams. 6470 Aside from datagrams containing Initial packets, which require 6471 padding, modification of how packets are arranged in datagrams has no 6472 functional effect on a connection, although it might change some 6473 performance characteristics. 6475 21.12.3. Connection Migration 6477 Connection Migration (Section 9) provides endpoints with the ability 6478 to transition between IP addresses and ports on multiple paths, using 6479 one path at a time for transmission and receipt of non-probing 6480 frames. Path validation (Section 8.2) establishes that a peer is 6481 both willing and able to receive packets sent on a particular path. 6482 This helps reduce the effects of address spoofing by limiting the 6483 number of packets sent to a spoofed address. 6485 This section describes the intended security properties of connection 6486 migration when under various types of DoS attacks. 6488 21.12.3.1. On-Path Active Attacks 6490 An attacker that can cause a packet it observes to no longer reach 6491 its intended destination is considered an on-path attacker. When an 6492 attacker is present between a client and server, endpoints are 6493 required to send packets through the attacker to establish 6494 connectivity on a given path. 6496 An on-path attacker can: 6498 * Inspect packets 6500 * Modify IP and UDP packet headers 6502 * Inject new packets 6504 * Delay packets 6506 * Reorder packets 6508 * Drop packets 6510 * Split and merge datagrams along packet boundaries 6512 An on-path attacker cannot: 6514 * Modify an authenticated portion of a packet and cause the 6515 recipient to accept that packet 6517 An on-path attacker has the opportunity to modify the packets that it 6518 observes, however any modifications to an authenticated portion of a 6519 packet will cause it to be dropped by the receiving endpoint as 6520 invalid, as packet payloads are both authenticated and encrypted. 6522 In the presence of an on-path attacker, QUIC aims to provide the 6523 following properties: 6525 1. An on-path attacker can prevent use of a path for a connection, 6526 causing it to fail if it cannot use a different path that does 6527 not contain the attacker. This can be achieved by dropping all 6528 packets, modifying them so that they fail to decrypt, or other 6529 methods. 6531 2. An on-path attacker can prevent migration to a new path for which 6532 the attacker is also on-path by causing path validation to fail 6533 on the new path. 6535 3. An on-path attacker cannot prevent a client from migrating to a 6536 path for which the attacker is not on-path. 6538 4. An on-path attacker can reduce the throughput of a connection by 6539 delaying packets or dropping them. 6541 5. An on-path attacker cannot cause an endpoint to accept a packet 6542 for which it has modified an authenticated portion of that 6543 packet. 6545 21.12.3.2. Off-Path Active Attacks 6547 An off-path attacker is not directly on the path between a client and 6548 server, but could be able to obtain copies of some or all packets 6549 sent between the client and the server. It is also able to send 6550 copies of those packets to either endpoint. 6552 An off-path attacker can: 6554 * Inspect packets 6556 * Inject new packets 6558 * Reorder injected packets 6560 An off-path attacker cannot: 6562 * Modify any part of a packet 6564 * Delay packets 6566 * Drop packets 6567 * Reorder original packets 6569 An off-path attacker can modify packets that it has observed and 6570 inject them back into the network, potentially with spoofed source 6571 and destination addresses. 6573 For the purposes of this discussion, it is assumed that an off-path 6574 attacker has the ability to observe, modify, and re-inject a packet 6575 into the network that will reach the destination endpoint prior to 6576 the arrival of the original packet observed by the attacker. In 6577 other words, an attacker has the ability to consistently "win" a race 6578 with the legitimate packets between the endpoints, potentially 6579 causing the original packet to be ignored by the recipient. 6581 It is also assumed that an attacker has the resources necessary to 6582 affect NAT state, potentially both causing an endpoint to lose its 6583 NAT binding, and an attacker to obtain the same port for use with its 6584 traffic. 6586 In the presence of an off-path attacker, QUIC aims to provide the 6587 following properties: 6589 1. An off-path attacker can race packets and attempt to become a 6590 "limited" on-path attacker. 6592 2. An off-path attacker can cause path validation to succeed for 6593 forwarded packets with the source address listed as the off-path 6594 attacker as long as it can provide improved connectivity between 6595 the client and the server. 6597 3. An off-path attacker cannot cause a connection to close once the 6598 handshake has completed. 6600 4. An off-path attacker cannot cause migration to a new path to fail 6601 if it cannot observe the new path. 6603 5. An off-path attacker can become a limited on-path attacker during 6604 migration to a new path for which it is also an off-path 6605 attacker. 6607 6. An off-path attacker can become a limited on-path attacker by 6608 affecting shared NAT state such that it sends packets to the 6609 server from the same IP address and port that the client 6610 originally used. 6612 21.12.3.3. Limited On-Path Active Attacks 6614 A limited on-path attacker is an off-path attacker that has offered 6615 improved routing of packets by duplicating and forwarding original 6616 packets between the server and the client, causing those packets to 6617 arrive before the original copies such that the original packets are 6618 dropped by the destination endpoint. 6620 A limited on-path attacker differs from an on-path attacker in that 6621 it is not on the original path between endpoints, and therefore the 6622 original packets sent by an endpoint are still reaching their 6623 destination. This means that a future failure to route copied 6624 packets to the destination faster than their original path will not 6625 prevent the original packets from reaching the destination. 6627 A limited on-path attacker can: 6629 * Inspect packets 6631 * Inject new packets 6633 * Modify unencrypted packet headers 6635 * Reorder packets 6637 A limited on-path attacker cannot: 6639 * Delay packets so that they arrive later than packets sent on the 6640 original path 6642 * Drop packets 6644 * Modify the authenticated and encrypted portion of a packet and 6645 cause the recipient to accept that packet 6647 A limited on-path attacker can only delay packets up to the point 6648 that the original packets arrive before the duplicate packets, 6649 meaning that it cannot offer routing with worse latency than the 6650 original path. If a limited on-path attacker drops packets, the 6651 original copy will still arrive at the destination endpoint. 6653 In the presence of a limited on-path attacker, QUIC aims to provide 6654 the following properties: 6656 1. A limited on-path attacker cannot cause a connection to close 6657 once the handshake has completed. 6659 2. A limited on-path attacker cannot cause an idle connection to 6660 close if the client is first to resume activity. 6662 3. A limited on-path attacker can cause an idle connection to be 6663 deemed lost if the server is the first to resume activity. 6665 Note that these guarantees are the same guarantees provided for any 6666 NAT, for the same reasons. 6668 22. IANA Considerations 6670 This document establishes several registries for the management of 6671 codepoints in QUIC. These registries operate on a common set of 6672 policies as defined in Section 22.1. 6674 22.1. Registration Policies for QUIC Registries 6676 All QUIC registries allow for both provisional and permanent 6677 registration of codepoints. This section documents policies that are 6678 common to these registries. 6680 22.1.1. Provisional Registrations 6682 Provisional registration of codepoints are intended to allow for 6683 private use and experimentation with extensions to QUIC. Provisional 6684 registrations only require the inclusion of the codepoint value and 6685 contact information. However, provisional registrations could be 6686 reclaimed and reassigned for another purpose. 6688 Provisional registrations require Expert Review, as defined in 6689 Section 4.5 of [RFC8126]. Designated expert(s) are advised that only 6690 registrations for an excessive proportion of remaining codepoint 6691 space or the very first unassigned value (see Section 22.1.2) can be 6692 rejected. 6694 Provisional registrations will include a date field that indicates 6695 when the registration was last updated. A request to update the date 6696 on any provisional registration can be made without review from the 6697 designated expert(s). 6699 All QUIC registries include the following fields to support 6700 provisional registration: 6702 Value: The assigned codepoint. 6704 Status: "Permanent" or "Provisional". 6706 Specification: A reference to a publicly available specification for 6707 the value. 6709 Date: The date of last update to the registration. 6711 Contact: Contact details for the registrant. 6713 Notes: Supplementary notes about the registration. 6715 Provisional registrations MAY omit the Specification and Notes 6716 fields, plus any additional fields that might be required for a 6717 permanent registration. The Date field is not required as part of 6718 requesting a registration as it is set to the date the registration 6719 is created or updated. 6721 22.1.2. Selecting Codepoints 6723 New uses of codepoints from QUIC registries SHOULD use a randomly 6724 selected codepoint that excludes both existing allocations and the 6725 first unallocated codepoint in the selected space. Requests for 6726 multiple codepoints MAY use a contiguous range. This minimizes the 6727 risk that differing semantics are attributed to the same codepoint by 6728 different implementations. Use of the first codepoint in a range is 6729 intended for use by specifications that are developed through the 6730 standards process [STD] and its allocation MUST be negotiated with 6731 IANA before use. 6733 For codepoints that are encoded in variable-length integers 6734 (Section 16), such as frame types, codepoints that encode to four or 6735 eight bytes (that is, values 2^14 and above) SHOULD be used unless 6736 the usage is especially sensitive to having a longer encoding. 6738 Applications to register codepoints in QUIC registries MAY include a 6739 codepoint as part of the registration. IANA MUST allocate the 6740 selected codepoint unless that codepoint is already assigned or the 6741 codepoint is the first unallocated codepoint in the registry. 6743 22.1.3. Reclaiming Provisional Codepoints 6745 A request might be made to remove an unused provisional registration 6746 from the registry to reclaim space in a registry, or portion of the 6747 registry (such as the 64-16383 range for codepoints that use 6748 variable-length encodings). This SHOULD be done only for the 6749 codepoints with the earliest recorded date and entries that have been 6750 updated less than a year prior SHOULD NOT be reclaimed. 6752 A request to remove a codepoint MUST be reviewed by the designated 6753 expert(s). The expert(s) MUST attempt to determine whether the 6754 codepoint is still in use. Experts are advised to contact the listed 6755 contacts for the registration, plus as wide a set of protocol 6756 implementers as possible in order to determine whether any use of the 6757 codepoint is known. The expert(s) are advised to allow at least four 6758 weeks for responses. 6760 If any use of the codepoints is identified by this search or a 6761 request to update the registration is made, the codepoint MUST NOT be 6762 reclaimed. Instead, the date on the registration is updated. A note 6763 might be added for the registration recording relevant information 6764 that was learned. 6766 If no use of the codepoint was identified and no request was made to 6767 update the registration, the codepoint MAY be removed from the 6768 registry. 6770 This process also applies to requests to change a provisional 6771 registration into a permanent registration, except that the goal is 6772 not to determine whether there is no use of the codepoint, but to 6773 determine that the registration is an accurate representation of any 6774 deployed usage. 6776 22.1.4. Permanent Registrations 6778 Permanent registrations in QUIC registries use the Specification 6779 Required policy [RFC8126], unless otherwise specified. The 6780 designated expert(s) verify that a specification exists and is 6781 readily accessible. Expert(s) are encouraged to be biased towards 6782 approving registrations unless they are abusive, frivolous, or 6783 actively harmful (not merely aesthetically displeasing, or 6784 architecturally dubious). The creation of a registry MAY specify 6785 additional constraints on permanent registrations. 6787 The creation of a registries MAY identify a range of codepoints where 6788 registrations are governed by a different registration policy. For 6789 instance, the registries for 62-bit codepoints in this document have 6790 stricter policies for codepoints in the range from 0 to 63. 6792 Any stricter requirements for permanent registrations do not prevent 6793 provisional registrations for affected codepoints. For instance, a 6794 provisional registration for a frame type Section 22.3 of 61 could be 6795 requested. 6797 All registrations made by Standards Track publications MUST be 6798 permanent. 6800 All registrations in this document are assigned a permanent status 6801 and list as contact both the IESG (ietf@ietf.org) and the QUIC 6802 working group (quic@ietf.org). 6804 22.2. QUIC Transport Parameter Registry 6806 IANA [SHALL add/has added] a registry for "QUIC Transport Parameters" 6807 under a "QUIC" heading. 6809 The "QUIC Transport Parameters" registry governs a 16-bit space. 6810 This registry follows the registration policy from Section 22.1. 6811 Permanent registrations in this registry are assigned using the 6812 Specification Required policy [RFC8126]. 6814 In addition to the fields in Section 22.1.1, permanent registrations 6815 in this registry MUST include the following fields: 6817 Parameter Name: A short mnemonic for the parameter. 6819 The initial contents of this registry are shown in Table 6. 6821 +--------+-------------------------------------+---------------+ 6822 | Value | Parameter Name | Specification | 6823 +========+=====================================+===============+ 6824 | 0x0000 | original_connection_id | Section 18.2 | 6825 +--------+-------------------------------------+---------------+ 6826 | 0x0001 | max_idle_timeout | Section 18.2 | 6827 +--------+-------------------------------------+---------------+ 6828 | 0x0002 | stateless_reset_token | Section 18.2 | 6829 +--------+-------------------------------------+---------------+ 6830 | 0x0003 | max_packet_size | Section 18.2 | 6831 +--------+-------------------------------------+---------------+ 6832 | 0x0004 | initial_max_data | Section 18.2 | 6833 +--------+-------------------------------------+---------------+ 6834 | 0x0005 | initial_max_stream_data_bidi_local | Section 18.2 | 6835 +--------+-------------------------------------+---------------+ 6836 | 0x0006 | initial_max_stream_data_bidi_remote | Section 18.2 | 6837 +--------+-------------------------------------+---------------+ 6838 | 0x0007 | initial_max_stream_data_uni | Section 18.2 | 6839 +--------+-------------------------------------+---------------+ 6840 | 0x0008 | initial_max_streams_bidi | Section 18.2 | 6841 +--------+-------------------------------------+---------------+ 6842 | 0x0009 | initial_max_streams_uni | Section 18.2 | 6843 +--------+-------------------------------------+---------------+ 6844 | 0x000a | ack_delay_exponent | Section 18.2 | 6845 +--------+-------------------------------------+---------------+ 6846 | 0x000b | max_ack_delay | Section 18.2 | 6847 +--------+-------------------------------------+---------------+ 6848 | 0x000c | disable_active_migration | Section 18.2 | 6849 +--------+-------------------------------------+---------------+ 6850 | 0x000d | preferred_address | Section 18.2 | 6851 +--------+-------------------------------------+---------------+ 6852 | 0x000e | active_connection_id_limit | Section 18.2 | 6853 +--------+-------------------------------------+---------------+ 6855 Table 6: Initial QUIC Transport Parameters Entries 6857 Additionally, each value of the format "31 * N + 27" for integer 6858 values of N (that is, "27", "58", "89", ...) are reserved and MUST 6859 NOT be assigned by IANA. 6861 22.3. QUIC Frame Type Registry 6863 IANA [SHALL add/has added] a registry for "QUIC Frame Types" under a 6864 "QUIC" heading. 6866 The "QUIC Frame Types" registry governs a 62-bit space. This 6867 registry follows the registration policy from Section 22.1. 6868 Permanent registrations in this registry are assigned using the 6869 Specification Required policy [RFC8126], except for values between 6870 0x00 and 0x3f (in hexadecimal; inclusive), which are assigned using 6871 Standards Action or IESG Approval as defined in Section 4.9 and 4.10 6872 of [RFC8126]. 6874 In addition to the fields in Section 22.1.1, permanent registrations 6875 in this registry MUST include the following fields: 6877 Frame Name: A short mnemonic for the frame type. 6879 In addition to the advice in Section 22.1, specifications for new 6880 permanent registrations SHOULD describe the means by which an 6881 endpoint might determine that it can send the identified type of 6882 frame. An accompanying transport parameter registration (see 6883 Section 22.2) is expected for most registrations. Specifications for 6884 permanent registrations also needs to describe the format and 6885 assigned semantics of any fields in the frame. 6887 The initial contents of this registry are tabulated in Table 3. 6889 22.4. QUIC Transport Error Codes Registry 6891 IANA [SHALL add/has added] a registry for "QUIC Transport Error 6892 Codes" under a "QUIC" heading. 6894 The "QUIC Transport Error Codes" registry governs a 62-bit space. 6895 This space is split into three spaces that are governed by different 6896 policies. Permanent registrations in this registry are assigned 6897 using the Specification Required policy [RFC8126], except for values 6898 between 0x00 and 0x3f (in hexadecimal; inclusive), which are assigned 6899 using Standards Action or IESG Approval as defined in Section 4.9 and 6900 4.10 of [RFC8126]. 6902 In addition to the fields in Section 22.1.1, permanent registrations 6903 in this registry MUST include the following fields: 6905 Code: A short mnemonic for the parameter. 6907 Description: A brief description of the error code semantics, which 6908 MAY be a summary if a specification reference is provided. 6910 The initial contents of this registry are shown in Table 7. 6912 +------+---------------------------+----------------+---------------+ 6913 |Value | Error | Description | Specification | 6914 +======+===========================+================+===============+ 6915 | 0x0 | NO_ERROR | No error | Section 20 | 6916 +------+---------------------------+----------------+---------------+ 6917 | 0x1 | INTERNAL_ERROR | Implementation | Section 20 | 6918 | | | error | | 6919 +------+---------------------------+----------------+---------------+ 6920 | 0x2 | SERVER_BUSY |Server currently| Section 20 | 6921 | | | busy | | 6922 +------+---------------------------+----------------+---------------+ 6923 | 0x3 | FLOW_CONTROL_ERROR | Flow control | Section 20 | 6924 | | | error | | 6925 +------+---------------------------+----------------+---------------+ 6926 | 0x4 | STREAM_LIMIT_ERROR |Too many streams| Section 20 | 6927 | | | opened | | 6928 +------+---------------------------+----------------+---------------+ 6929 | 0x5 | STREAM_STATE_ERROR | Frame received | Section 20 | 6930 | | | in invalid | | 6931 | | | stream state | | 6932 +------+---------------------------+----------------+---------------+ 6933 | 0x6 | FINAL_SIZE_ERROR |Change to final | Section 20 | 6934 | | | size | | 6935 +------+---------------------------+----------------+---------------+ 6936 | 0x7 | FRAME_ENCODING_ERROR | Frame encoding | Section 20 | 6937 | | | error | | 6938 +------+---------------------------+----------------+---------------+ 6939 | 0x8 | TRANSPORT_PARAMETER_ERROR | Error in | Section 20 | 6940 | | | transport | | 6941 | | | parameters | | 6942 +------+---------------------------+----------------+---------------+ 6943 | 0x9 | CONNECTION_ID_LIMIT_ERROR | Too many | Section 20 | 6944 | | | connection IDs | | 6945 | | | received | | 6946 +------+---------------------------+----------------+---------------+ 6947 | 0xA | PROTOCOL_VIOLATION |Generic protocol| Section 20 | 6948 | | | violation | | 6949 +------+---------------------------+----------------+---------------+ 6950 | 0xB | INVALID_TOKEN | Invalid Token | Section 20 | 6951 | | | Received | | 6952 +------+---------------------------+----------------+---------------+ 6953 | 0xD | CRYPTO_BUFFER_EXCEEDED | CRYPTO data | Section 20 | 6954 | | | buffer | | 6955 | | | overflowed | | 6956 +------+---------------------------+----------------+---------------+ 6958 Table 7: Initial QUIC Transport Error Codes Entries 6960 23. References 6962 23.1. Normative References 6964 [DPLPMTUD] Fairhurst, G., Jones, T., Tuexen, M., Ruengeler, I., and 6965 T. Voelker, "Packetization Layer Path MTU Discovery for 6966 Datagram Transports", Work in Progress, Internet-Draft, 6967 draft-ietf-tsvwg-datagram-plpmtud-08, 5 June 2019, 6968 . 6971 [IPv4] Postel, J., "Internet Protocol", STD 5, RFC 791, 6972 DOI 10.17487/RFC0791, September 1981, 6973 . 6975 [QUIC-RECOVERY] 6976 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 6977 and Congestion Control", Work in Progress, Internet-Draft, 6978 draft-ietf-quic-recovery-25, 22 January 2020, 6979 . 6981 [QUIC-TLS] Thomson, M., Ed. and S. Turner, Ed., "Using Transport 6982 Layer Security (TLS) to Secure QUIC", Work in Progress, 6983 Internet-Draft, draft-ietf-quic-tls-25, 22 January 2020, 6984 . 6986 [RFC1191] Mogul, J.C. and S.E. Deering, "Path MTU discovery", 6987 RFC 1191, DOI 10.17487/RFC1191, November 1990, 6988 . 6990 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 6991 Requirement Levels", BCP 14, RFC 2119, 6992 DOI 10.17487/RFC2119, March 1997, 6993 . 6995 [RFC3168] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 6996 of Explicit Congestion Notification (ECN) to IP", 6997 RFC 3168, DOI 10.17487/RFC3168, September 2001, 6998 . 7000 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 7001 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 7002 2003, . 7004 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 7005 "Randomness Requirements for Security", BCP 106, RFC 4086, 7006 DOI 10.17487/RFC4086, June 2005, 7007 . 7009 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 7010 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 7011 . 7013 [RFC6437] Amante, S., Carpenter, B., Jiang, S., and J. Rajahalme, 7014 "IPv6 Flow Label Specification", RFC 6437, 7015 DOI 10.17487/RFC6437, November 2011, 7016 . 7018 [RFC8085] Eggert, L., Fairhurst, G., and G. Shepherd, "UDP Usage 7019 Guidelines", BCP 145, RFC 8085, DOI 10.17487/RFC8085, 7020 March 2017, . 7022 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 7023 Writing an IANA Considerations Section in RFCs", BCP 26, 7024 RFC 8126, DOI 10.17487/RFC8126, June 2017, 7025 . 7027 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 7028 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 7029 May 2017, . 7031 [RFC8201] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 7032 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 7033 DOI 10.17487/RFC8201, July 2017, 7034 . 7036 [RFC8311] Black, D., "Relaxing Restrictions on Explicit Congestion 7037 Notification (ECN) Experimentation", RFC 8311, 7038 DOI 10.17487/RFC8311, January 2018, 7039 . 7041 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 7042 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 7043 . 7045 23.2. Informative References 7047 [EARLY-DESIGN] 7048 Roskind, J., "QUIC: Multiplexed Transport Over UDP", 2 7049 December 2013, . 7051 [HTTP2] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 7052 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 7053 DOI 10.17487/RFC7540, May 2015, 7054 . 7056 [QUIC-INVARIANTS] 7057 Thomson, M., "Version-Independent Properties of QUIC", 7058 Work in Progress, Internet-Draft, draft-ietf-quic- 7059 invariants-07, 22 January 2020, 7060 . 7063 [QUIC-MANAGEABILITY] 7064 Kuehlewind, M. and B. Trammell, "Manageability of the QUIC 7065 Transport Protocol", Work in Progress, Internet-Draft, 7066 draft-ietf-quic-manageability-05, 5 July 2019, 7067 . 7070 [RFC1812] Baker, F., Ed., "Requirements for IP Version 4 Routers", 7071 RFC 1812, DOI 10.17487/RFC1812, June 1995, 7072 . 7074 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 7075 Selective Acknowledgment Options", RFC 2018, 7076 DOI 10.17487/RFC2018, October 1996, 7077 . 7079 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 7080 Hashing for Message Authentication", RFC 2104, 7081 DOI 10.17487/RFC2104, February 1997, 7082 . 7084 [RFC2360] Scott, G., "Guide for Internet Standards Writers", BCP 22, 7085 RFC 2360, DOI 10.17487/RFC2360, June 1998, 7086 . 7088 [RFC4303] Kent, S., "IP Encapsulating Security Payload (ESP)", 7089 RFC 4303, DOI 10.17487/RFC4303, December 2005, 7090 . 7092 [RFC4443] Conta, A., Deering, S., and M. Gupta, Ed., "Internet 7093 Control Message Protocol (ICMPv6) for the Internet 7094 Protocol Version 6 (IPv6) Specification", STD 89, 7095 RFC 4443, DOI 10.17487/RFC4443, March 2006, 7096 . 7098 [RFC4787] Audet, F., Ed. and C. Jennings, "Network Address 7099 Translation (NAT) Behavioral Requirements for Unicast 7100 UDP", BCP 127, RFC 4787, DOI 10.17487/RFC4787, January 7101 2007, . 7103 [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 7104 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 7105 . 7107 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 7108 Key Derivation Function (HKDF)", RFC 5869, 7109 DOI 10.17487/RFC5869, May 2010, 7110 . 7112 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 7113 "Transport Layer Security (TLS) Application-Layer Protocol 7114 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 7115 July 2014, . 7117 [RFC8200] Deering, S. and R. Hinden, "Internet Protocol, Version 6 7118 (IPv6) Specification", STD 86, RFC 8200, 7119 DOI 10.17487/RFC8200, July 2017, 7120 . 7122 [SEC-CONS] Rescorla, E. and B. Korver, "Guidelines for Writing RFC 7123 Text on Security Considerations", BCP 72, RFC 3552, 7124 DOI 10.17487/RFC3552, July 2003, 7125 . 7127 [SLOWLORIS] 7128 RSnake Hansen, R., "Welcome to Slowloris...", June 2009, 7129 . 7132 [STD] Bradner, S., "The Internet Standards Process -- Revision 7133 3", BCP 9, RFC 2026, DOI 10.17487/RFC2026, October 1996, 7134 . 7136 Appendix A. Sample Packet Number Decoding Algorithm 7138 The pseudo-code in Figure 37 shows how an implementation can decode 7139 packet numbers after header protection has been removed. 7141 DecodePacketNumber(largest_pn, truncated_pn, pn_nbits): 7142 expected_pn = largest_pn + 1 7143 pn_win = 1 << pn_nbits 7144 pn_hwin = pn_win / 2 7145 pn_mask = pn_win - 1 7146 // The incoming packet number should be greater than 7147 // expected_pn - pn_hwin and less than or equal to 7148 // expected_pn + pn_hwin 7149 // 7150 // This means we can't just strip the trailing bits from 7151 // expected_pn and add the truncated_pn because that might 7152 // yield a value outside the window. 7153 // 7154 // The following code calculates a candidate value and 7155 // makes sure it's within the packet number window. 7156 // Note the extra checks to prevent overflow and underflow. 7157 candidate_pn = (expected_pn & ~pn_mask) | truncated_pn 7158 if candidate_pn <= expected_pn - pn_hwin and 7159 candidate_pn < (1 << 62) - pn_win: 7160 return candidate_pn + pn_win 7161 if candidate_pn > expected_pn + pn_hwin and 7162 candidate_pn >= pn_win: 7163 return candidate_pn - pn_win 7164 return candidate_pn 7166 Figure 37: Sample Packet Number Decoding Algorithm 7168 Appendix B. Sample ECN Validation Algorithm 7170 Each time an endpoint commences sending on a new network path, it 7171 determines whether the path supports ECN; see Section 13.4. If the 7172 path supports ECN, the goal is to use ECN. Endpoints might also 7173 periodically reassess a path that was determined to not support ECN. 7175 This section describes one method for testing new paths. This 7176 algorithm is intended to show how a path might be tested for ECN 7177 support. Endpoints can implement different methods. 7179 The path is assigned an ECN state that is one of "testing", 7180 "unknown", "failed", or "capable". On paths with a "testing" or 7181 "capable" state the endpoint sends packets with an ECT marking, by 7182 default ECT(0); otherwise, the endpoint sends unmarked packets. 7184 To start testing a path, the ECN state is set to "testing" and 7185 existing ECN counts are remembered as a baseline. 7187 The testing period runs for a number of packets or round-trip times, 7188 as determined by the endpoint. The goal is not to limit the duration 7189 of the testing period, but to ensure that enough marked packets are 7190 sent for received ECN counts to provide a clear indication of how the 7191 path treats marked packets. Section 13.4.2.2 suggests limiting this 7192 to 10 packets or 3 round-trip times. 7194 After the testing period ends, the ECN state for the path becomes 7195 "unknown". From the "unknown" state, successful validation of the 7196 ECN counts an ACK frame (see Section 13.4.2.2) causes the ECN state 7197 for the path to become "capable", unless no marked packet has been 7198 acknowledged. 7200 If validation of ECN counts fails at any time, the ECN state for the 7201 affected path becomes "failed". An endpoint can also mark the ECN 7202 state for a path as "failed" if marked packets are all declared lost 7203 or if they are all CE marked. 7205 Following this algorithm ensures that ECN is rarely disabled for 7206 paths that properly support ECN. Any path that incorrectly modifies 7207 markings will cause ECN to be disabled. For those rare cases where 7208 marked packets are discarded by the path, the short duration of the 7209 testing period limits the number of losses incurred. 7211 Appendix C. Change Log 7213 *RFC Editor's Note:* Please remove this section prior to 7214 publication of a final version of this document. 7216 Issue and pull request numbers are listed with a leading octothorp. 7218 C.1. Since draft-ietf-quic-transport-24 7220 * Added HANDSHAKE_DONE to signal handshake confirmation (#2863, 7221 #3142, #3145) 7223 * Add integrity check to Retry packets (#3014, #3274, #3120) 7225 * Specify handling of reordered NEW_CONNECTION_ID frames (#3194, 7226 #3202) 7228 * Require checking of sequence numbers in RETIRE_CONNECTION_ID 7229 (#3037, #3036) 7231 * active_connection_id_limit is enforced (#3193, #3197, #3200, 7232 #3201) 7234 * Correct overflow in packet number decode algorithm (#3187, #3188) 7235 * Allow use of CRYPTO_BUFFER_EXCEEDED for CRYPTO frame errors 7236 (#3258, #3186) 7238 * Define applicability and scope of NEW_TOKEN (#3150, #3152, #3155, 7239 #3156) 7241 * Tokens from Retry and NEW_TOKEN must be differentiated (#3127, 7242 #3128) 7244 * Allow CONNECTION_CLOSE in response to invalid token (#3168, #3107) 7246 * Treat an invalid CONNECTION_CLOSE as an invalid frame (#2475, 7247 #3230, #3231) 7249 * Throttle when sending CONNECTION_CLOSE after discarding state 7250 (#3095, #3157) 7252 * Application-variant of CONNECTION_CLOSE can only be sent in 0-RTT 7253 or 1-RTT packets (#3158, #3164) 7255 * Advise sending while blocked to avoid idle timeout (#2744, #3266) 7257 * Define error codes for invalid frames (#3027, #3042) 7259 * Idle timeout is symmetric (#2602, #3099) 7261 * Prohibit IP fragmentation (#3243, #3280) 7263 * Define the use of provisional registration for all registries 7264 (#3109, #3020, #3102, #3170) 7266 C.2. Since draft-ietf-quic-transport-23 7268 * Allow ClientHello to span multiple packets (#2928, #3045) 7270 * Client Initial size constraints apply to UDP datagram payload 7271 (#3053, #3051) 7273 * Stateless reset changes (#2152, #2993) 7275 - tokens need to be compared in constant time 7277 - detection uses UDP datagrams, not packets 7279 - tokens cannot be reused (#2785, #2968) 7281 * Clearer rules for sharing of UDP ports and use of connection IDs 7282 when doing so (#2844, #2851) 7284 * A new connection ID is necessary when responding to migration 7285 (#2778, #2969) 7287 * Stronger requirements for connection ID retirement (#3046, #3096) 7289 * NEW_TOKEN cannot be empty (#2978, #2977) 7291 * PING can be sent at any encryption level (#3034, #3035) 7293 * CONNECTION_CLOSE is not ack-eliciting (#3097, #3098) 7295 * Frame encoding error conditions updated (#3027, #3042) 7297 * Non-ack-eliciting packets cannot be sent in response to non-ack- 7298 eliciting packets (#3100, #3104) 7300 * Servers have to change connection IDs in Retry (#2837, #3147) 7302 C.3. Since draft-ietf-quic-transport-22 7304 * Rules for preventing correlation by connection ID tightened 7305 (#2084, #2929) 7307 * Clarified use of CONNECTION_CLOSE in Handshake packets (#2151, 7308 #2541, #2688) 7310 * Discourage regressions of largest acknowledged in ACK (#2205, 7311 #2752) 7313 * Improved robustness of validation process for ECN counts (#2534, 7314 #2752) 7316 * Require endpoints to ignore spurious migration attempts (#2342, 7317 #2893) 7319 * Transport parameter for disabling migration clarified to allow NAT 7320 rebinding (#2389, #2893) 7322 * Document principles for defining new error codes (#2388, #2880) 7324 * Reserve transport parameters for greasing (#2550, #2873) 7326 * A maximum ACK delay of 0 is used for handshake packet number 7327 spaces (#2646, #2638) 7329 * Improved rules for use of congestion control state on new paths 7330 (#2685, #2918) 7332 * Removed recommendation to coordinate spin for multiple connections 7333 that share a path (#2763, #2882) 7335 * Allow smaller stateless resets and recommend a smaller minimum on 7336 packets that might trigger a stateless reset (#2770, #2869, #2927, 7337 #3007). 7339 * Provide guidance around the interface to QUIC as used by 7340 application protocols (#2805, #2857) 7342 * Frames other than STREAM can cause STREAM_LIMIT_ERROR (#2825, 7343 #2826) 7345 * Tighter rules about processing of rejected 0-RTT packets (#2829, 7346 #2840, #2841) 7348 * Explanation of the effect of Retry on 0-RTT packets (#2842, #2852) 7350 * Cryptographic handshake needs to provide server transport 7351 parameter encryption (#2920, #2921) 7353 * Moved ACK generation guidance from recovery draft to transport 7354 draft (#1860, #2916). 7356 C.4. Since draft-ietf-quic-transport-21 7358 * Connection ID lengths are now one octet, but limited in version 1 7359 to 20 octets of length (#2736, #2749) 7361 C.5. Since draft-ietf-quic-transport-20 7363 * Error codes are encoded as variable-length integers (#2672, #2680) 7365 * NEW_CONNECTION_ID includes a request to retire old connection IDs 7366 (#2645, #2769) 7368 * Tighter rules for generating and explicitly eliciting ACK frames 7369 (#2546, #2794) 7371 * Recommend having only one packet per encryption level in a 7372 datagram (#2308, #2747) 7374 * More normative language about use of stateless reset (#2471, 7375 #2574) 7377 * Allow reuse of stateless reset tokens (#2732, #2733) 7378 * Allow, but not require, enforcing non-duplicate transport 7379 parameters (#2689, #2691) 7381 * Added an active_connection_id_limit transport parameter (#1994, 7382 #1998) 7384 * max_ack_delay transport parameter defaults to 0 (#2638, #2646) 7386 * When sending 0-RTT, only remembered transport parameters apply 7387 (#2458, #2360, #2466, #2461) 7389 * Define handshake completion and confirmation; define clearer rules 7390 when it encryption keys should be discarded (#2214, #2267, #2673) 7392 * Prohibit path migration prior to handshake confirmation (#2309, 7393 #2370) 7395 * PATH_RESPONSE no longer needs to be received on the validated path 7396 (#2582, #2580, #2579, #2637) 7398 * PATH_RESPONSE frames are not stored and retransmitted (#2724, 7399 #2729) 7401 * Document hack for enabling routing of ICMP when doing PMTU probing 7402 (#1243, #2402) 7404 C.6. Since draft-ietf-quic-transport-19 7406 * Refine discussion of 0-RTT transport parameters (#2467, #2464) 7408 * Fewer transport parameters need to be remembered for 0-RTT (#2624, 7409 #2467) 7411 * Spin bit text incorporated (#2564) 7413 * Close the connection when maximum stream ID in MAX_STREAMS exceeds 7414 2^62 - 1 (#2499, #2487) 7416 * New connection ID required for intentional migration (#2414, 7417 #2413) 7419 * Connection ID issuance can be rate-limited (#2436, #2428) 7421 * The "QUIC bit" is ignored in Version Negotiation (#2400, #2561) 7423 * Initial packets from clients need to be padded to 1200 unless a 7424 Handshake packet is sent as well (#2522, #2523) 7426 * CRYPTO frames can be discarded if too much data is buffered 7427 (#1834, #2524) 7429 * Stateless reset uses a short header packet (#2599, #2600) 7431 C.7. Since draft-ietf-quic-transport-18 7433 * Removed version negotiation; version negotiation, including 7434 authentication of the result, will be addressed in the next 7435 version of QUIC (#1773, #2313) 7437 * Added discussion of the use of IPv6 flow labels (#2348, #2399) 7439 * A connection ID can't be retired in a packet that uses that 7440 connection ID (#2101, #2420) 7442 * Idle timeout transport parameter is in milliseconds (from seconds) 7443 (#2453, #2454) 7445 * Endpoints are required to use new connection IDs when they use new 7446 network paths (#2413, #2414) 7448 * Increased the set of permissible frames in 0-RTT (#2344, #2355) 7450 C.8. Since draft-ietf-quic-transport-17 7452 * Stream-related errors now use STREAM_STATE_ERROR (#2305) 7454 * Endpoints discard initial keys as soon as handshake keys are 7455 available (#1951, #2045) 7457 * Expanded conditions for ignoring ICMP packet too big messages 7458 (#2108, #2161) 7460 * Remove rate control from PATH_CHALLENGE/PATH_RESPONSE (#2129, 7461 #2241) 7463 * Endpoints are permitted to discard malformed initial packets 7464 (#2141) 7466 * Clarified ECN implementation and usage requirements (#2156, #2201) 7468 * Disable ECN count verification for packets that arrive out of 7469 order (#2198, #2215) 7471 * Use Probe Timeout (PTO) instead of RTO (#2206, #2238) 7473 * Loosen constraints on retransmission of ACK ranges (#2199, #2245) 7474 * Limit Retry and Version Negotiation to once per datagram (#2259, 7475 #2303) 7477 * Set a maximum value for max_ack_delay transport parameter (#2282, 7478 #2301) 7480 * Allow server preferred address for both IPv4 and IPv6 (#2122, 7481 #2296) 7483 * Corrected requirements for migration to a preferred address 7484 (#2146, #2349) 7486 * ACK of non-existent packet is illegal (#2298, #2302) 7488 C.9. Since draft-ietf-quic-transport-16 7490 * Stream limits are defined as counts, not maximums (#1850, #1906) 7492 * Require amplification attack defense after closing (#1905, #1911) 7494 * Remove reservation of application error code 0 for STOPPING 7495 (#1804, #1922) 7497 * Renumbered frames (#1945) 7499 * Renumbered transport parameters (#1946) 7501 * Numeric transport parameters are expressed as varints (#1608, 7502 #1947, #1955) 7504 * Reorder the NEW_CONNECTION_ID frame (#1952, #1963) 7506 * Rework the first byte (#2006) 7508 - Fix the 0x40 bit 7510 - Change type values for long header 7512 - Add spin bit to short header (#631, #1988) 7514 - Encrypt the remainder of the first byte (#1322) 7516 - Move packet number length to first byte 7518 - Move ODCIL to first byte of retry packets 7520 - Simplify packet number protection (#1575) 7522 * Allow STOP_SENDING to open a remote bidirectional stream (#1797, 7523 #2013) 7525 * Added mitigation for off-path migration attacks (#1278, #1749, 7526 #2033) 7528 * Don't let the PMTU to drop below 1280 (#2063, #2069) 7530 * Require peers to replace retired connection IDs (#2085) 7532 * Servers are required to ignore Version Negotiation packets (#2088) 7534 * Tokens are repeated in all Initial packets (#2089) 7536 * Clarified how PING frames are sent after loss (#2094) 7538 * Initial keys are discarded once Handshake are available (#1951, 7539 #2045) 7541 * ICMP PTB validation clarifications (#2161, #2109, #2108) 7543 C.10. Since draft-ietf-quic-transport-15 7545 Substantial editorial reorganization; no technical changes. 7547 C.11. Since draft-ietf-quic-transport-14 7549 * Merge ACK and ACK_ECN (#1778, #1801) 7551 * Explicitly communicate max_ack_delay (#981, #1781) 7553 * Validate original connection ID after Retry packets (#1710, #1486, 7554 #1793) 7556 * Idle timeout is optional and has no specified maximum (#1765) 7558 * Update connection ID handling; add RETIRE_CONNECTION_ID type 7559 (#1464, #1468, #1483, #1484, #1486, #1495, #1729, #1742, #1799, 7560 #1821) 7562 * Include a Token in all Initial packets (#1649, #1794) 7564 * Prevent handshake deadlock (#1764, #1824) 7566 C.12. Since draft-ietf-quic-transport-13 7568 * Streams open when higher-numbered streams of the same type open 7569 (#1342, #1549) 7571 * Split initial stream flow control limit into 3 transport 7572 parameters (#1016, #1542) 7574 * All flow control transport parameters are optional (#1610) 7576 * Removed UNSOLICITED_PATH_RESPONSE error code (#1265, #1539) 7578 * Permit stateless reset in response to any packet (#1348, #1553) 7580 * Recommended defense against stateless reset spoofing (#1386, 7581 #1554) 7583 * Prevent infinite stateless reset exchanges (#1443, #1627) 7585 * Forbid processing of the same packet number twice (#1405, #1624) 7587 * Added a packet number decoding example (#1493) 7589 * More precisely define idle timeout (#1429, #1614, #1652) 7591 * Corrected format of Retry packet and prevented looping (#1492, 7592 #1451, #1448, #1498) 7594 * Permit 0-RTT after receiving Version Negotiation or Retry (#1507, 7595 #1514, #1621) 7597 * Permit Retry in response to 0-RTT (#1547, #1552) 7599 * Looser verification of ECN counters to account for ACK loss 7600 (#1555, #1481, #1565) 7602 * Remove frame type field from APPLICATION_CLOSE (#1508, #1528) 7604 C.13. Since draft-ietf-quic-transport-12 7606 * Changes to integration of the TLS handshake (#829, #1018, #1094, 7607 #1165, #1190, #1233, #1242, #1252, #1450, #1458) 7609 - The cryptographic handshake uses CRYPTO frames, not stream 0 7611 - QUIC packet protection is used in place of TLS record 7612 protection 7614 - Separate QUIC packet number spaces are used for the handshake 7616 - Changed Retry to be independent of the cryptographic handshake 7618 - Added NEW_TOKEN frame and Token fields to Initial packet 7619 - Limit the use of HelloRetryRequest to address TLS needs (like 7620 key shares) 7622 * Enable server to transition connections to a preferred address 7623 (#560, #1251, #1373) 7625 * Added ECN feedback mechanisms and handling; new ACK_ECN frame 7626 (#804, #805, #1372) 7628 * Changed rules and recommendations for use of new connection IDs 7629 (#1258, #1264, #1276, #1280, #1419, #1452, #1453, #1465) 7631 * Added a transport parameter to disable intentional connection 7632 migration (#1271, #1447) 7634 * Packets from different connection ID can't be coalesced (#1287, 7635 #1423) 7637 * Fixed sampling method for packet number encryption; the length 7638 field in long headers includes the packet number field in addition 7639 to the packet payload (#1387, #1389) 7641 * Stateless Reset is now symmetric and subject to size constraints 7642 (#466, #1346) 7644 * Added frame type extension mechanism (#58, #1473) 7646 C.14. Since draft-ietf-quic-transport-11 7648 * Enable server to transition connections to a preferred address 7649 (#560, #1251) 7651 * Packet numbers are encrypted (#1174, #1043, #1048, #1034, #850, 7652 #990, #734, #1317, #1267, #1079) 7654 * Packet numbers use a variable-length encoding (#989, #1334) 7656 * STREAM frames can now be empty (#1350) 7658 C.15. Since draft-ietf-quic-transport-10 7660 * Swap payload length and packed number fields in long header 7661 (#1294) 7663 * Clarified that CONNECTION_CLOSE is allowed in Handshake packet 7664 (#1274) 7666 * Spin bit reserved (#1283) 7667 * Coalescing multiple QUIC packets in a UDP datagram (#1262, #1285) 7669 * A more complete connection migration (#1249) 7671 * Refine opportunistic ACK defense text (#305, #1030, #1185) 7673 * A Stateless Reset Token isn't mandatory (#818, #1191) 7675 * Removed implicit stream opening (#896, #1193) 7677 * An empty STREAM frame can be used to open a stream without sending 7678 data (#901, #1194) 7680 * Define stream counts in transport parameters rather than a maximum 7681 stream ID (#1023, #1065) 7683 * STOP_SENDING is now prohibited before streams are used (#1050) 7685 * Recommend including ACK in Retry packets and allow PADDING (#1067, 7686 #882) 7688 * Endpoints now become closing after an idle timeout (#1178, #1179) 7690 * Remove implication that Version Negotiation is sent when a packet 7691 of the wrong version is received (#1197) 7693 C.16. Since draft-ietf-quic-transport-09 7695 * Added PATH_CHALLENGE and PATH_RESPONSE frames to replace PING with 7696 Data and PONG frame. Changed ACK frame type from 0x0e to 0x0d. 7697 (#1091, #725, #1086) 7699 * A server can now only send 3 packets without validating the client 7700 address (#38, #1090) 7702 * Delivery order of stream data is no longer strongly specified 7703 (#252, #1070) 7705 * Rework of packet handling and version negotiation (#1038) 7707 * Stream 0 is now exempt from flow control until the handshake 7708 completes (#1074, #725, #825, #1082) 7710 * Improved retransmission rules for all frame types: information is 7711 retransmitted, not packets or frames (#463, #765, #1095, #1053) 7713 * Added an error code for server busy signals (#1137) 7714 * Endpoints now set the connection ID that their peer uses. 7715 Connection IDs are variable length. Removed the 7716 omit_connection_id transport parameter and the corresponding short 7717 header flag. (#1089, #1052, #1146, #821, #745, #821, #1166, #1151) 7719 C.17. Since draft-ietf-quic-transport-08 7721 * Clarified requirements for BLOCKED usage (#65, #924) 7723 * BLOCKED frame now includes reason for blocking (#452, #924, #927, 7724 #928) 7726 * GAP limitation in ACK Frame (#613) 7728 * Improved PMTUD description (#614, #1036) 7730 * Clarified stream state machine (#634, #662, #743, #894) 7732 * Reserved versions don't need to be generated deterministically 7733 (#831, #931) 7735 * You don't always need the draining period (#871) 7737 * Stateless reset clarified as version-specific (#930, #986) 7739 * initial_max_stream_id_x transport parameters are optional (#970, 7740 #971) 7742 * Ack Delay assumes a default value during the handshake (#1007, 7743 #1009) 7745 * Removed transport parameters from NewSessionTicket (#1015) 7747 C.18. Since draft-ietf-quic-transport-07 7749 * The long header now has version before packet number (#926, #939) 7751 * Rename and consolidate packet types (#846, #822, #847) 7753 * Packet types are assigned new codepoints and the Connection ID 7754 Flag is inverted (#426, #956) 7756 * Removed type for Version Negotiation and use Version 0 (#963, 7757 #968) 7759 * Streams are split into unidirectional and bidirectional (#643, 7760 #656, #720, #872, #175, #885) 7761 - Stream limits now have separate uni- and bi-directional 7762 transport parameters (#909, #958) 7764 - Stream limit transport parameters are now optional and default 7765 to 0 (#970, #971) 7767 * The stream state machine has been split into read and write (#634, 7768 #894) 7770 * Employ variable-length integer encodings throughout (#595) 7772 * Improvements to connection close 7774 - Added distinct closing and draining states (#899, #871) 7776 - Draining period can terminate early (#869, #870) 7778 - Clarifications about stateless reset (#889, #890) 7780 * Address validation for connection migration (#161, #732, #878) 7782 * Clearly defined retransmission rules for BLOCKED (#452, #65, #924) 7784 * negotiated_version is sent in server transport parameters (#710, 7785 #959) 7787 * Increased the range over which packet numbers are randomized 7788 (#864, #850, #964) 7790 C.19. Since draft-ietf-quic-transport-06 7792 * Replaced FNV-1a with AES-GCM for all "Cleartext" packets (#554) 7794 * Split error code space between application and transport (#485) 7796 * Stateless reset token moved to end (#820) 7798 * 1-RTT-protected long header types removed (#848) 7800 * No acknowledgments during draining period (#852) 7802 * Remove "application close" as a separate close type (#854) 7804 * Remove timestamps from the ACK frame (#841) 7806 * Require transport parameters to only appear once (#792) 7808 C.20. Since draft-ietf-quic-transport-05 7810 * Stateless token is server-only (#726) 7812 * Refactor section on connection termination (#733, #748, #328, 7813 #177) 7815 * Limit size of Version Negotiation packet (#585) 7817 * Clarify when and what to ack (#736) 7819 * Renamed STREAM_ID_NEEDED to STREAM_ID_BLOCKED 7821 * Clarify Keep-alive requirements (#729) 7823 C.21. Since draft-ietf-quic-transport-04 7825 * Introduce STOP_SENDING frame, RESET_STREAM only resets in one 7826 direction (#165) 7828 * Removed GOAWAY; application protocols are responsible for graceful 7829 shutdown (#696) 7831 * Reduced the number of error codes (#96, #177, #184, #211) 7833 * Version validation fields can't move or change (#121) 7835 * Removed versions from the transport parameters in a 7836 NewSessionTicket message (#547) 7838 * Clarify the meaning of "bytes in flight" (#550) 7840 * Public reset is now stateless reset and not visible to the path 7841 (#215) 7843 * Reordered bits and fields in STREAM frame (#620) 7845 * Clarifications to the stream state machine (#572, #571) 7847 * Increased the maximum length of the Largest Acknowledged field in 7848 ACK frames to 64 bits (#629) 7850 * truncate_connection_id is renamed to omit_connection_id (#659) 7852 * CONNECTION_CLOSE terminates the connection like TCP RST (#330, 7853 #328) 7855 * Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 7857 C.22. Since draft-ietf-quic-transport-03 7859 * Change STREAM and RESET_STREAM layout 7861 * Add MAX_STREAM_ID settings 7863 C.23. Since draft-ietf-quic-transport-02 7865 * The size of the initial packet payload has a fixed minimum (#267, 7866 #472) 7868 * Define when Version Negotiation packets are ignored (#284, #294, 7869 #241, #143, #474) 7871 * The 64-bit FNV-1a algorithm is used for integrity protection of 7872 unprotected packets (#167, #480, #481, #517) 7874 * Rework initial packet types to change how the connection ID is 7875 chosen (#482, #442, #493) 7877 * No timestamps are forbidden in unprotected packets (#542, #429) 7879 * Cryptographic handshake is now on stream 0 (#456) 7881 * Remove congestion control exemption for cryptographic handshake 7882 (#248, #476) 7884 * Version 1 of QUIC uses TLS; a new version is needed to use a 7885 different handshake protocol (#516) 7887 * STREAM frames have a reduced number of offset lengths (#543, #430) 7889 * Split some frames into separate connection- and stream- level 7890 frames (#443) 7892 - WINDOW_UPDATE split into MAX_DATA and MAX_STREAM_DATA (#450) 7894 - BLOCKED split to match WINDOW_UPDATE split (#454) 7896 - Define STREAM_ID_NEEDED frame (#455) 7898 * A NEW_CONNECTION_ID frame supports connection migration without 7899 linkability (#232, #491, #496) 7901 * Transport parameters for 0-RTT are retained from a previous 7902 connection (#405, #513, #512) 7903 - A client in 0-RTT no longer required to reset excess streams 7904 (#425, #479) 7906 * Expanded security considerations (#440, #444, #445, #448) 7908 C.24. Since draft-ietf-quic-transport-01 7910 * Defined short and long packet headers (#40, #148, #361) 7912 * Defined a versioning scheme and stable fields (#51, #361) 7914 * Define reserved version values for "greasing" negotiation (#112, 7915 #278) 7917 * The initial packet number is randomized (#35, #283) 7919 * Narrow the packet number encoding range requirement (#67, #286, 7920 #299, #323, #356) 7922 * Defined client address validation (#52, #118, #120, #275) 7924 * Define transport parameters as a TLS extension (#49, #122) 7926 * SCUP and COPT parameters are no longer valid (#116, #117) 7928 * Transport parameters for 0-RTT are either remembered from before, 7929 or assume default values (#126) 7931 * The server chooses connection IDs in its final flight (#119, #349, 7932 #361) 7934 * The server echoes the Connection ID and packet number fields when 7935 sending a Version Negotiation packet (#133, #295, #244) 7937 * Defined a minimum packet size for the initial handshake packet 7938 from the client (#69, #136, #139, #164) 7940 * Path MTU Discovery (#64, #106) 7942 * The initial handshake packet from the client needs to fit in a 7943 single packet (#338) 7945 * Forbid acknowledgment of packets containing only ACK and PADDING 7946 (#291) 7948 * Require that frames are processed when packets are acknowledged 7949 (#381, #341) 7951 * Removed the STOP_WAITING frame (#66) 7953 * Don't require retransmission of old timestamps for lost ACK frames 7954 (#308) 7956 * Clarified that frames are not retransmitted, but the information 7957 in them can be (#157, #298) 7959 * Error handling definitions (#335) 7961 * Split error codes into four sections (#74) 7963 * Forbid the use of Public Reset where CONNECTION_CLOSE is possible 7964 (#289) 7966 * Define packet protection rules (#336) 7968 * Require that stream be entirely delivered or reset, including 7969 acknowledgment of all STREAM frames or the RESET_STREAM, before it 7970 closes (#381) 7972 * Remove stream reservation from state machine (#174, #280) 7974 * Only stream 1 does not contribute to connection-level flow control 7975 (#204) 7977 * Stream 1 counts towards the maximum concurrent stream limit (#201, 7978 #282) 7980 * Remove connection-level flow control exclusion for some streams 7981 (except 1) (#246) 7983 * RESET_STREAM affects connection-level flow control (#162, #163) 7985 * Flow control accounting uses the maximum data offset on each 7986 stream, rather than bytes received (#378) 7988 * Moved length-determining fields to the start of STREAM and ACK 7989 (#168, #277) 7991 * Added the ability to pad between frames (#158, #276) 7993 * Remove error code and reason phrase from GOAWAY (#352, #355) 7995 * GOAWAY includes a final stream number for both directions (#347) 7997 * Error codes for RESET_STREAM and CONNECTION_CLOSE are now at a 7998 consistent offset (#249) 8000 * Defined priority as the responsibility of the application protocol 8001 (#104, #303) 8003 C.25. Since draft-ietf-quic-transport-00 8005 * Replaced DIVERSIFICATION_NONCE flag with KEY_PHASE flag 8007 * Defined versioning 8009 * Reworked description of packet and frame layout 8011 * Error code space is divided into regions for each component 8013 * Use big endian for all numeric values 8015 C.26. Since draft-hamilton-quic-transport-protocol-01 8017 * Adopted as base for draft-ietf-quic-tls 8019 * Updated authors/editors list 8021 * Added IANA Considerations section 8023 * Moved Contributors and Acknowledgments to appendices 8025 Contributors 8027 The original design and rationale behind this protocol draw 8028 significantly from work by Jim Roskind [EARLY-DESIGN]. 8030 The IETF QUIC Working Group received an enormous amount of support 8031 from many people. The following people provided substantive 8032 contributions to this document: Alessandro Ghedini, Alyssa Wilk, 8033 Antoine Delignat-Lavaud, Brian Trammell, Christian Huitema, Colin 8034 Perkins, David Schinazi, Dmitri Tikhonov, Eric Kinnear, Eric 8035 Rescorla, Gorry Fairhurst, Ian Swett, Igor Lubashev, 奥 一穂 (Kazuho 8036 Oku), Lucas Pardue, Magnus Westerlund, Marten Seemann, Martin Duke, 8037 Mike Bishop, Mikkel Fahnøe Jørgensen, Mirja Kühlewind, Nick Banks, 8038 Nick Harper, Patrick McManus, Roberto Peon, Ryan Hamilton, Subodh 8039 Iyengar, Tatsuhiro Tsujikawa, Ted Hardie, Tom Jones, and Victor 8040 Vasiliev. 8042 Authors' Addresses 8044 Jana Iyengar (editor) 8045 Fastly 8047 Email: jri.ietf@gmail.com 8048 Martin Thomson (editor) 8049 Mozilla 8051 Email: mt@lowentropy.net