idnits 2.17.1 draft-hamilton-quic-transport-protocol-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** There are 19 instances of too long lines in the document, the longest one being 9 characters in excess of 72. 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). -- The document date (October 31, 2016) is 2733 days in the past. Is this intentional? Checking references for intended status: Experimental ---------------------------------------------------------------------------- == Missing Reference: 'RFC4821' is mentioned on line 1250, but not defined -- Looks like a reference, but probably isn't: '1' on line 2062 == Unused Reference: 'RFC2119' is defined on line 2040, but no explicit reference was found in the text -- Obsolete informational reference (is this intentional?): RFC 7540 (Obsoleted by RFC 9113) Summary: 3 errors (**), 0 flaws (~~), 4 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group R. Hamilton 3 Internet-Draft J. Iyengar 4 Intended status: Experimental I. Swett 5 Expires: May 4, 2017 A. Wilk 6 Google 7 October 31, 2016 9 QUIC: A UDP-Based Multiplexed and Secure Transport 10 draft-hamilton-quic-transport-protocol-01 12 Abstract 14 QUIC is a multiplexed and secure transport protocol that runs on top 15 of UDP. QUIC builds on past transport experience, and implements 16 mechanisms that make it useful as a modern general-purpose transport 17 protocol. Using UDP as the basis of QUIC is intended to address 18 compatibility issues with legacy clients and middleboxes. QUIC 19 authenticates all of its headers, preventing third parties from from 20 changing them. QUIC encrypts most of its headers, thereby limiting 21 protocol evolution to QUIC endpoints only. Therefore, middleboxes, 22 in large part, are not required to be updated as new protocol 23 versions are deployed. This document describes the core QUIC 24 protocol, including the conceptual design, wire format, and 25 mechanisms of the QUIC protocol for connection establishment, stream 26 multiplexing, stream and connection-level flow control, and data 27 reliability. Accompanying documents describe QUIC's loss recovery 28 and congestion control, and the use of TLS 1.3 for key negotiation. 30 Status of This Memo 32 This Internet-Draft is submitted in full conformance with the 33 provisions of BCP 78 and BCP 79. 35 Internet-Drafts are working documents of the Internet Engineering 36 Task Force (IETF). Note that other groups may also distribute 37 working documents as Internet-Drafts. The list of current Internet- 38 Drafts is at http://datatracker.ietf.org/drafts/current/. 40 Internet-Drafts are draft documents valid for a maximum of six months 41 and may be updated, replaced, or obsoleted by other documents at any 42 time. It is inappropriate to use Internet-Drafts as reference 43 material or to cite them other than as "work in progress." 45 This Internet-Draft will expire on May 4, 2017. 47 Copyright Notice 49 Copyright (c) 2016 IETF Trust and the persons identified as the 50 document authors. All rights reserved. 52 This document is subject to BCP 78 and the IETF Trust's Legal 53 Provisions Relating to IETF Documents 54 (http://trustee.ietf.org/license-info) in effect on the date of 55 publication of this document. Please review these documents 56 carefully, as they describe your rights and restrictions with respect 57 to this document. Code Components extracted from this document must 58 include Simplified BSD License text as described in Section 4.e of 59 the Trust Legal Provisions and are provided without warranty as 60 described in the Simplified BSD License. 62 Table of Contents 64 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 65 2. Conventions and Definitions . . . . . . . . . . . . . . . . . 4 66 3. A QUIC Overview . . . . . . . . . . . . . . . . . . . . . . . 4 67 3.1. Low-Latency Version Negotiation . . . . . . . . . . . . . 5 68 3.2. Low-Latency Connection Establishment . . . . . . . . . . 5 69 3.3. Stream Multiplexing . . . . . . . . . . . . . . . . . . . 5 70 3.4. Rich Signaling for Congestion Control and Loss Recovery . 5 71 3.5. Stream and Connection Flow Control . . . . . . . . . . . 6 72 3.6. Authenticated and Encrypted Header and Payload . . . . . 6 73 3.7. Connection Migration and Resilience to NAT Rebinding . . 7 74 4. Packet Types and Formats . . . . . . . . . . . . . . . . . . 7 75 4.1. Common Header . . . . . . . . . . . . . . . . . . . . . . 7 76 4.2. Regular Packets . . . . . . . . . . . . . . . . . . . . . 9 77 4.2.1. Packet Number Compression and Reconstruction . . . . 10 78 4.2.2. Frames and Frame Types . . . . . . . . . . . . . . . 11 79 4.3. Version Negotiation Packet . . . . . . . . . . . . . . . 12 80 4.4. Public Reset Packet . . . . . . . . . . . . . . . . . . . 12 81 5. Life of a Connection . . . . . . . . . . . . . . . . . . . . 13 82 5.1. Version Negotiation . . . . . . . . . . . . . . . . . . . 13 83 5.2. Crypto and Transport Handshake . . . . . . . . . . . . . 14 84 5.2.1. Transport Parameters and Options . . . . . . . . . . 14 85 5.2.2. Proof of Source Address Ownership . . . . . . . . . . 15 86 5.2.3. Crypto Handshake Protocol Features . . . . . . . . . 16 87 5.3. Connection Migration . . . . . . . . . . . . . . . . . . 17 88 5.4. Connection Termination . . . . . . . . . . . . . . . . . 17 89 6. Frame Types and Formats . . . . . . . . . . . . . . . . . . . 18 90 6.1. STREAM Frame . . . . . . . . . . . . . . . . . . . . . . 19 91 6.2. ACK Frame . . . . . . . . . . . . . . . . . . . . . . . . 20 92 6.2.1. Time Format . . . . . . . . . . . . . . . . . . . . . 23 93 6.3. STOP_WAITING Frame . . . . . . . . . . . . . . . . . . . 23 94 6.4. WINDOW_UPDATE Frame . . . . . . . . . . . . . . . . . . . 24 95 6.5. BLOCKED Frame . . . . . . . . . . . . . . . . . . . . . . 24 96 6.6. RST_STREAM Frame . . . . . . . . . . . . . . . . . . . . 25 97 6.7. PADDING Frame . . . . . . . . . . . . . . . . . . . . . . 25 98 6.8. PING frame . . . . . . . . . . . . . . . . . . . . . . . 25 99 6.9. CONNECTION_CLOSE frame . . . . . . . . . . . . . . . . . 26 100 6.10. GOAWAY Frame . . . . . . . . . . . . . . . . . . . . . . 26 101 7. Packetization and Reliability . . . . . . . . . . . . . . . . 27 102 8. Streams: QUIC's Data Structuring Abstraction . . . . . . . . 28 103 8.1. Life of a Stream . . . . . . . . . . . . . . . . . . . . 29 104 8.1.1. idle . . . . . . . . . . . . . . . . . . . . . . . . 31 105 8.1.2. reserved . . . . . . . . . . . . . . . . . . . . . . 31 106 8.1.3. open . . . . . . . . . . . . . . . . . . . . . . . . 31 107 8.1.4. half-closed (local) . . . . . . . . . . . . . . . . . 32 108 8.1.5. half-closed (remote) . . . . . . . . . . . . . . . . 32 109 8.1.6. closed . . . . . . . . . . . . . . . . . . . . . . . 33 110 8.2. Stream Identifiers . . . . . . . . . . . . . . . . . . . 33 111 8.3. Stream Concurrency . . . . . . . . . . . . . . . . . . . 34 112 8.4. Sending and Receiving Data . . . . . . . . . . . . . . . 34 113 9. Flow Control . . . . . . . . . . . . . . . . . . . . . . . . 35 114 9.1. Edge Cases and Other Considerations . . . . . . . . . . . 36 115 9.1.1. Mid-stream RST_STREAM . . . . . . . . . . . . . . . . 36 116 9.1.2. Response to a RST_STREAM . . . . . . . . . . . . . . 37 117 9.1.3. Offset Increment . . . . . . . . . . . . . . . . . . 37 118 9.1.4. BLOCKED frames . . . . . . . . . . . . . . . . . . . 37 119 10. Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . 38 120 11. Security and Privacy Considerations . . . . . . . . . . . . . 43 121 11.1. Spoofed Ack Attack . . . . . . . . . . . . . . . . . . . 43 122 12. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 44 123 13. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 44 124 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 44 125 14.1. Normative References . . . . . . . . . . . . . . . . . . 44 126 14.2. Informative References . . . . . . . . . . . . . . . . . 44 127 14.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 45 128 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 45 130 1. Introduction 132 QUIC is a multiplexed and secure transport protocol that runs on top 133 of UDP. QUIC builds on past transport experience and implements 134 mechanisms that make it useful as a modern general-purpose transport 135 protocol. Using UDP as the substrate, QUIC seeks to be compatible 136 with legacy clients and middleboxes. QUIC authenticates all of its 137 headers, preventing middleboxes and other third parties from changing 138 them, and encrypts most of its headers, limiting protocol evolution 139 largely to QUIC endpoints only. 141 This document describes the core QUIC protocol, including the 142 conceptual design, wire format, and mechanisms of the QUIC protocol 143 for connection establishment, stream multiplexing, stream and 144 connection-level flow control, and data reliability. Accompanying 145 documents describe QUIC's loss detection and congestion control 146 [draft-iyengar-quic-loss-detection], and the use of TLS 1.3 for key 147 negotiation [draft-thomson-quic-tls]. 149 2. Conventions and Definitions 151 Definitions of terms that are used in this document: 153 o Client: The endpoint initiating a QUIC connection. 155 o Server: The endpoint accepting incoming QUIC connections. 157 o Endpoint: The client or server end of a connection. 159 o Stream: A logical, bi-directional channel of ordered bytes within 160 a QUIC connection. 162 o Connection: A conversation between two QUIC endpoints with a 163 single encryption context that multiplexes streams within it. 165 o Connection ID: The identifier for a QUIC connection. 167 o QUIC packet: A well-formed UDP payload that can be parsed by a 168 QUIC receiver. QUIC packet size in this document refers to the 169 UDP payload size. 171 3. A QUIC Overview 173 This section briefly describes QUIC's key mechanisms and benefits. 174 Key strengths of QUIC include: 176 o Low-latency Version Negotiation 178 o Low-latency connection establishment 180 o Multiplexing without head-of-line blocking 182 o Authenticated and encrypted header and payload 184 o Rich signaling for congestion control and loss recovery 186 o Stream and connection flow control 188 o Connection Migration and Resilience to NAT rebinding 190 3.1. Low-Latency Version Negotiation 192 QUIC combines version negotiation with the rest of connection 193 establishment to avoid unnecessary roundtrip delays. A QUIC client 194 proposes a version to use for the connection, and encodes the rest of 195 the handshake using the proposed version. If the server does not 196 speak the client-chosen version, it forces version negotiation by 197 sending back a Version Negotiation packet to the client, causing a 198 roundtrip of delay before connection establishment. 200 This mechanism eliminates roundtrip latency when the client's 201 optimistically-chosen version is spoken by the server, and 202 incentivizes servers to not lag behind clients in deployment of newer 203 versions. Additionally, an application may negotiate QUIC versions 204 out-of-band to increase chances of success in the first roundtrip and 205 to obviate the additional roundtrip in the case of version mismatch. 207 3.2. Low-Latency Connection Establishment 209 QUIC relies on a combined crypto and transport handshake for setting 210 up a secure transport connection. QUIC connections are expected to 211 commonly use 0-RTT handshakes, meaning that for most QUIC 212 connections, data can be sent immediately following the client 213 handshake packet, without waiting for a reply from the server. QUIC 214 provides a dedicated stream (Stream ID 1) to be used for performing 215 the crypto handshake and QUIC options negotiation. The format of the 216 QUIC options and parameters used during negotiation are described in 217 this document, but the handshake protocol that runs on Stream ID 1 is 218 described in the accompanying crypto handshake draft [draft-thomson- 219 quic-tls]. 221 3.3. Stream Multiplexing 223 When application messages are transported over TCP, independent 224 application messages can suffer from head-of-line blocking. When an 225 application multiplexes many streams atop TCP's single-bytestream 226 abstraction, a loss of a TCP segment results in blocking of all 227 subsequent segments until a retransmission arrives, irrespective of 228 the application streams that are encapsulated in subsequent segments. 229 QUIC ensures that lost packets carrying data for an individual stream 230 only impact that specific stream. Data received on other streams can 231 continue to be reassembled and delivered to the application. 233 3.4. Rich Signaling for Congestion Control and Loss Recovery 235 QUIC's packet framing and acknowledgments carry rich information that 236 help both congestion control and loss recovery in fundamental ways. 237 Each QUIC packet carries a new packet number, including those 238 carrying retransmitted data. This obviates the need for a separate 239 mechanism to distinguish acks for retransmissions from those for 240 original transmissions, avoiding TCP's retransmission ambiguity 241 problem. QUIC acknowledgments also explicitly encode the delay 242 between the receipt of a packet and its acknowledgment being sent, 243 and together with the monotonically-increasing packet numbers, this 244 allows for precise network roundtrip-time (RTT) calculation. QUIC's 245 ACK frames support up to 256 ack blocks, so QUIC is more resilient to 246 reordering than TCP with SACK support, as well as able to keep more 247 bytes on the wire when there is reordering or loss. 249 3.5. Stream and Connection Flow Control 251 QUIC implements stream- and connection-level flow control, closely 252 following HTTP/2's flow control mechanisms. At a high level, a QUIC 253 receiver advertises the absolute byte offset within each stream up to 254 which the receiver is willing to receive data. As data is sent, 255 received, and delivered on a particular stream, the receiver sends 256 WINDOW_UPDATE frames that increase the advertised offset limit for 257 that stream, allowing the peer to send more data on that stream. In 258 addition to this stream-level flow control, QUIC implements 259 connection-level flow control to limit the aggregate buffer that a 260 QUIC receiver is willing to allocate to all streams on a connection. 261 Connection-level flow control works in the same way as stream-level 262 flow control, but the bytes delivered and highest received offset are 263 all aggregates across all streams. 265 3.6. Authenticated and Encrypted Header and Payload 267 TCP headers appear in plaintext on the wire and are not 268 authenticated, causing a plethora of injection and header 269 manipulation issues for TCP, such as receive-window manipulation and 270 sequence-number overwriting. While some of these are mechanisms used 271 by middleboxes to improve TCP performance, others are active attacks. 272 Even "performance-enhancing" middleboxes that routinely interpose on 273 the transport state machine end up limiting the evolvability of the 274 transport protocol, as has been observed in the design of MPTCP and 275 in its subsequent deployability issues. 277 Generally, QUIC packets are always authenticated and the payload is 278 typically fully encrypted. The parts of the packet header which are 279 not encrypted are still authenticated by the receiver, so as to 280 thwart any packet injection or manipulation by third parties. Some 281 early handshake packets, such as the Version Negotiation packet, are 282 not encrypted, but information sent in these unencrypted handshake 283 packets is later verified under crypto cover. 285 PUBLIC_RESET packets that reset a connection are currently not 286 authenticated. 288 3.7. Connection Migration and Resilience to NAT Rebinding 290 QUIC connections are identified by a 64-bit Connection ID, randomly 291 generated by the client. QUIC's consistent connection ID allows 292 connections to survive changes to the client's IP and port, such as 293 those caused by NAT rebindings or by the client changing network 294 connectivity to a new address. QUIC provides automatic cryptographic 295 verification of a rebound client, since the client continues to use 296 the same session key for encrypting and decrypting packets. The 297 consistent connection ID can be used to allow migration of the 298 connection to a new server IP address as well, since the Connection 299 ID remains consistent across changes in the client's and the server's 300 network addresses. 302 4. Packet Types and Formats 304 We first describe QUIC's packet types and formats, since some are 305 referenced in subsequent mechanisms. Note that unless otherwise 306 noted, all values specified in this document are in little-endian 307 format and all field sizes are in bits. 309 4.1. Common Header 311 All QUIC packets begin with a QUIC Common header, as shown below: 313 +------------+---------------------------------+ 314 | Flags(8) | Connection ID (64) (optional) | 315 +------------+---------------------------------+ 317 The fields in the Common Header are the following: 319 o Flags: 321 * 0x01 = VERSION. The semantics of this flag depends on whether 322 the packet is sent by the server or the client. A client MAY 323 set this flag and include exactly one proposed version. A 324 server may set this flag when the client-proposed version was 325 unsupported, and may then provide a list (0 or more) of 326 acceptable versions as a part of version negotiation (described 327 in Section XXX.) 329 * 0x02 = PUBLIC_RESET. Set to indicate that the packet is a 330 Public Reset packet. 332 * 0x04 = DIVERSIFICATION_NONCE. Set to indicate the presence of 333 a 32-byte diversification nonce in the header. 334 (DISCUSS_AND_MODIFY: This flag should be removed along with the 335 Diversification Nonce bits, as discussed further below.) 337 * 0x08 = CONNECTION_ID. Indicates the Connection ID is present 338 in the packet. This must be set in all packets until 339 negotiated to a different value for a given direction. For 340 instance, if a client indicates that the 5-tuple fully 341 identifies the connection at the client, the connection ID is 342 optional in the server-to-client direction. 344 * 0x30 = PACKET_NUMBER_SIZE. These two bits indicate the number 345 of low-order-bytes of the packet number that are present in 346 each packet. 348 + 11 indicates that 6 bytes of the packet number are present 350 + 10 indicates that 4 bytes of the packet number are present 352 + 01 indicates that 2 bytes of the packet number are present 354 + 00 indicates that 1 byte of the packet number is present 356 * 0x40 = MULTIPATH. This bit is reserved for multipath use. 358 * 0x80 is currently unused, and must be set to 0. 360 o Connection ID: An unsigned 64-bit random number chosen by the 361 client, used as the identifier of the connection. Connection ID 362 is tied to a QUIC connection, and remains consistent across client 363 and/or server IP and port changes. 365 While all QUIC packets have the same common header, there are three 366 types of packets: Regular packets, Version Negotiation packets, and 367 Public Reset packets. The flowchart below shows how a packet is 368 classified into one of these three packet types: 370 Check the flags in the common header 371 | 372 | 373 V 374 +--------------+ 375 | PUBLIC_RESET | YES 376 | flag set? |-------> Public Reset packet 377 +--------------+ 378 | 379 | NO 380 V 381 +------------+ +-------------+ 382 | VERSION | YES | Packet sent | YES 383 | flag set? |-------->| by server? |--------> Version Negotiation 384 +------------+ +-------------+ packet 385 | | 386 | NO | NO 387 V V 388 Regular packet with Regular packet with 389 no QUIC Version in header QUIC Version in header 391 4.2. Regular Packets 393 Each Regular packet's header consists of a Common Header followed by 394 fields specific to Regular packets, as shown below: 396 +------------+---------------------------------+ 397 | Flags(8) | Connection ID (64) (optional) | -> 398 +------------+---------------------------------+ 399 +---------------------------------------+-------------------------------+ 400 | Version (32) (client-only, optional) | Diversification Nonce (256) | -> 401 +---------------------------------------+-------------------------------+ 402 +------------------------------------+ 403 | Packet Number (8, 16, 32, or 48) | -> 404 +------------------------------------+ 405 +------------+ 406 | AEAD Data | 407 +------------+ 409 Decrypted AEAD Data: 410 +------------+-----------+ +-----------+ 411 | Frame 1 | Frame 2 | ... | Frame N | 412 +------------+-----------+ +-----------+ 414 The fields in a Regular packet past the Common Header are the 415 following: 417 o QUIC Version: A 32-bit opaque tag that represents the version of 418 the QUIC protocol. Only present in the client-to-server 419 direction, and if the VERSION flag is set. Version Negotiation is 420 described in Section XXX. 422 o DISCUSS_AND_REPLACE: Diversification Nonce: A 32-byte nonce 423 generated by the server and used only in the Server->Client 424 direction to ensure that the server is able to generate unique 425 keys per connection. Specifically, when using QUIC's 0-RTT crypto 426 handshake, a repeated CHLO with the exact same connection ID and 427 CHLO can lead to the same (intermediate) initial-encryption keys 428 being derived for the connection. A server-generated nonce 429 disallows a client from causing the same keys to be derived for 430 two distinct connections. Once the connection is forward-secure, 431 this nonce is no longer present in packets. This nonce can be 432 removed from the packet header if a requirement can be added for 433 the crypto handshake to ensure key uniqueness. The expectation is 434 that TLS1.3 meets this requirement. Upon working group adoption 435 of this document, this requirement should be added to the crypto 436 handshake requirements, and the nonce should be removed from the 437 packet format. 439 o Packet Number: The lower 8, 16, 32, or 48 bits of the packet 440 number, based on the PACKET_NUMBER_SIZE flag. Each Regular packet 441 is assigned a packet number by the sender. The first packet sent 442 by an endpoint MUST have a packet number of 1. 444 o AEAD Data: A Regular packet's header, which includes the Common 445 Header, and the Version, Diversification Nonce, and Packet Number 446 fields, is authenticated but not encrypted. The rest of a Regular 447 packet, starting with the first frame, is both authenticated and 448 encrypted. Immediately following the header, Regular packets 449 contain AEAD (Authenticated Encryption with Associated Data) data. 450 This data must be decrypted in order for the contents to be 451 interpreted. After decryption, the plaintext consists of a 452 sequence of frames, as shown (frames are described in 453 Section XXX). 455 4.2.1. Packet Number Compression and Reconstruction 457 The complete packet number is a 64-bit unsigned number and is used as 458 part of a cryptographic nonce for packet encryption. To reduce the 459 number of bits required to represent the packet number over the wire, 460 at most 48 bits of the packet number are transmitted over the wire. 461 A QUIC endpoint MUST NOT reuse a complete packet number within the 462 same connection (that is, under the same cryptographic keys). If the 463 total number of packets transmitted in this connection reaches 2^64 - 464 1, the sender MUST close the connection by sending a CONNECTION_CLOSE 465 frame with the error code QUIC_SEQUENCE_NUMBER_LIMIT_REACHED 466 (connection termination is described in Section XXX.) For 467 unambiguous reconstruction of the complete packet number by a 468 receiver from the lower-order bits, a QUIC sender MUST NOT have more 469 than 2^(packet_number_size - 2) in flight at any point in the 470 connection. In other words, 472 o If a sender sets PACKET_NUMBER_SIZE bits to 11, it MUST NOT have 473 more than (2^46) packets in flight. 475 o If a sender sets PACKET_NUMBER_SIZE bits to 10, it MUST NOT have 476 more than (2^30) packets in flight. 478 o If a sender sets PACKET_NUMBER_SIZE bits to 01, it MUST NOT have 479 more than (2^14) packets in flight. 481 o If a sender sets PACKET_NUMBER_SIZE bits to 00, it MUST NOT have 482 more than (2^6) packets in flight. 484 DISCUSS: Should the receiver be required to enforce this rule that 485 the sender MUST NOT exceed the inflight limit? Specifically, should 486 the receiver drop packets that are received outside this window? 488 Any truncated packet number received from a peer MUST be 489 reconstructed as the value closest to the next expected packet number 490 from that peer. 492 (TODO: Clarify how packet number size can change mid-connection.) 494 4.2.2. Frames and Frame Types 496 A Regular packet MUST contain at least one frame, and MAY contain 497 multiple frames and multiple frame types. Frames MUST fit within a 498 single QUIC packet and MUST NOT span a QUIC packet boundary. Each 499 frame begins with a Frame Type byte, indicating its type, followed by 500 type-dependent headers, and variable-length data, as follows: 502 +-----------+---------------------------+-------------------------+ 503 | Type (8) | Headers (type-dependent) | Data (type-dependent) | 504 +-----------+---------------------------+-------------------------+ 506 The following table lists currently defined frame types. Note that 507 the Frame Type byte in STREAM and ACK frames is used to carry other 508 frame-specific flags. For all other frames, the Frame Type byte 509 simply identifies the frame. These frames are explained in more 510 detail as they are referenced later in the document. 512 +------------------+--------------------+ 513 | Type-field value | Frame type | 514 +------------------+--------------------+ 515 | 1FDOOOSS | STREAM | 516 | 01NTLLMM | ACK | 517 | 00000000 (0x00) | PADDING | 518 | 00000001 (0x01) | RST_STREAM | 519 | 00000010 (0x02) | CONNECTION_CLOSE | 520 | 00000011 (0x03) | GOAWAY | 521 | 00000100 (0x04) | WINDOW_UPDATE | 522 | 00000101 (0x05) | BLOCKED | 523 | 00000110 (0x06) | STOP_WAITING | 524 | 00000111 (0x07) | PING | 525 +------------------+--------------------+ 527 4.3. Version Negotiation Packet 529 A Version Negotiation packet is only sent by the server, MUST have 530 the VERSION flag set, and MUST include the full 64-bit Connection ID. 531 The rest of the Version Negotiation packet is a list of 4-byte 532 versions which the server supports, as shown below. 534 +-----------------------------------+ 535 | Flags(8) | Connection ID (64) | -> 536 +-----------------------------------+ 537 +------------------------------+----------------------------------------+ 538 | 1st Supported Version (32) | 2nd Supported Version (32) supported | ... 539 +------------------------------+----------------------------------------+ 541 4.4. Public Reset Packet 543 A Public Reset packet MUST have the PUBLIC_RESET flag set, and MUST 544 include the full 64-bit connection ID. The rest of the Public Reset 545 packet is encoded as if it were a crypto handshake message of the tag 546 PRST, as shown below. 548 +-----------------------------------+ 549 | Flags(8) | Connection ID (64) | -> 550 +-----------------------------------+ 551 +-------------------------------------+ 552 | Quic Tag (PRST) and tag value map | 553 +-------------------------------------+ 555 The tag value map contains the following tag-values: 557 o RNON (public reset nonce proof) - a 64-bit unsigned integer. 559 o RSEQ (rejected packet number) - a 64-bit packet number. 561 o CADR (client address) - the observed client IP address and port 562 number. This is currently for debugging purposes only and hence 563 is optional. 565 DISCUSS_AND_REPLACE: The crypto handshake message format is described 566 in the QUIC crypto document, and should be replaced with something 567 simpler when this document is adopted. The purpose of the tag-value 568 map following the PRST tag is to enable the receiver of the Public 569 Reset packet to reasonably authenticate the packet. This map is an 570 extensible map format that allows specification of various tags, 571 which should again be replaced by something simpler. 573 5. Life of a Connection 575 A QUIC connection is a single conversation between two QUIC 576 endpoints. QUIC's connection establishment intertwines version 577 negotiation with the crypto and transport handshakes to reduce 578 connection establishment latency, as described in Section XXX. Once 579 established, a connection may migrate to a different IP or port at 580 either endpoint, due to NAT rebinding or mobility, as described in 581 Section XXX. Finally a connection may be terminated by either 582 endpoint, as described in Section XXX. 584 5.1. Version Negotiation 586 QUIC's connection establishment begins with version negotiation, 587 since all communication between the endpoints, including packet and 588 frame formats, relies on the two endpoints agreeing on a version. 590 A QUIC connection begins with a client sending a handshake packet. 591 The details of the handshake mechanisms are described in Section XX, 592 but all of the initial packets sent from the client to the server 593 MUST have the VERSION flag set, and MUST specify the version of the 594 protocol being used. 596 When the server receives a packet from a client with the VERSION flag 597 set for a connection that has not yet been established, it compares 598 the client's version to the versions it supports. 600 o If the client's version is acceptable to the server, the server 601 MUST use this protocol version for the lifetime of the connection. 602 All subsequent packets sent by the server MUST have the version 603 flag off. 605 o If the client's version is not acceptable to the server, the 606 server MUST send a Version Negotiation packet to the client. This 607 packet will have the VERSION flag set and will include the 608 server's set of supported versions. On subsequently received 609 packets for the same connection ID with the unacceptable version, 610 the server MUST continue responding with a Version Negotiation 611 packet. 613 When the client receives a Version Negotiation packet from the 614 server, it should select an acceptable protocol version. If such a 615 version is found, the client MUST resend all packets using the new 616 version, and the resent packets MUST use new packet numbers. These 617 packets MUST continue to have the VERSION flag set and MUST include 618 the new negotiated protocol version. 620 The client MUST send its version on all packets until it receives a 621 packet from the server with the VERSION flag off. If version 622 negotiation is successful, the client should receive a packet from 623 the server with the VERSION flag off indicating the end of version 624 negotiation. All subsequent packets the client sends MUST have the 625 version flag off. 627 Once the server receives a packet from the client with the VERSION 628 flag off, it MUST ignore the VERSION flag in subsequently received 629 packets. 631 The Version Negotiation packet is unencrypted and exchanged without 632 authentication. To avoid a downgrade attack, the client needs to 633 verify its record of the server's version list in the Version 634 Negotiation packet and the server needs to verify its record of the 635 client's originally proposed version. Therefore, the client and 636 server MUST include this information later in their corresponding 637 crypto handshake data. 639 5.2. Crypto and Transport Handshake 641 QUIC relies on a combined crypto and transport handshake to minimize 642 connection establishment latency. QUIC provides a dedicated stream 643 (Stream ID 1) to be used for performing a combined connection and 644 security handshake (streams are described in detail in Section XXX). 645 The crypto handshake protocol encapsulates and delivers QUIC's 646 transport handshake to the peer on the crypto stream. The first QUIC 647 packet from the client to the server MUST carry handshake information 648 as data on Stream ID 1. 650 5.2.1. Transport Parameters and Options 652 During connection establishment, the handshake must negotiate various 653 transport parameters. The currently defined transport parameters are 654 described later in the document. 656 The transport component of the handshake is responsible for 657 exchanging and negotiating the following parameters for a QUIC 658 connection. Not all parameters are negotiated, some are parameters 659 sent in just one direction. These parameters and options are encoded 660 and handed off to the crypto handshake protocol to be transmitted to 661 the peer. 663 5.2.1.1. Encoding 665 (TODO: Describe format with example) 667 QUIC encodes the transport parameters and options as tag-value pairs, 668 all as 7-bit ASCII strings. QUIC parameter tags are listed below. 670 5.2.1.2. Required Transport Parameters 672 o SFCW: Stream Flow Control Window. The stream level flow control 673 byte offset advertised by the sender of this parameter. 675 o CFCW: Connection Flow Control Window. The connection level flow 676 control byte offset advertised by the sender of this parameter. 678 o MSPC: Maximum number of incoming streams per connection. 680 5.2.1.3. Optional Transport Parameters 682 o TCID: Indicates support for truncated Connection IDs. If sent by 683 a peer, indicates that connection IDs sent to the peer should be 684 truncated to 0 bytes. This is expected to commonly be used by an 685 endpoint where the 5-tuple is sufficient to identify a connection. 686 For instance, if the 5-tuple is unique at the client, the client 687 MAY send a TCID parameter to the server. When a TCID parameter is 688 received, an endpoint MAY choose to not send the connection ID on 689 subsequent packets. 691 o COPT: Connection Options are a repeated tag field. The field 692 contains any connection options being requested by the client or 693 server. These are typically used for experimentation and will 694 evolve over time. Example use cases include changing congestion 695 control algorithms and parameters such as initial window. (TODO: 696 List connection options.) 698 5.2.2. Proof of Source Address Ownership 700 Transport protocols commonly use a roundtrip time to verify a 701 client's address ownership for protection from malicious clients that 702 spoof their source address. QUIC uses a cookie, called the Source 703 Address Token (STK), to mostly eliminate this roundtrip of delay. 705 This technique is similar to TCP Fast Open's use of a cookie to avoid 706 a roundtrip of delay in TCP connection establishment. 708 On a new connection, a QUIC server sends an STK, which is opaque to 709 and stored by the client. On a subsequent connection, the client 710 echoes it in the transport handshake as proof of IP ownership. 712 A QUIC server also uses the STK to store server-designated connection 713 IDs for Stateless Rejects, to verify that an incoming connection 714 contains the correct connection ID. 716 A QUIC server MAY additionally store other data in a the STK, such as 717 measured bandwidth and measured minimum RTT to the client that may 718 help the server better bootstrap a subsequent connection from the 719 same client. A server MAY send an updated STK message mid-connection 720 to update server state that is stored at the client in the STK. 722 (TODO: Describe server and client actions on STK, encoding, 723 recommendations for what to put in an STK. Describe SCUP messages.) 725 5.2.3. Crypto Handshake Protocol Features 727 QUIC's current crypto handshake mechanism is documented in [QUIC- 728 CRYPTO]. QUIC does not restrict itself to using a specific handshake 729 protocol, so the details of a specific handshake protocol are out of 730 this document's scope. If not explicitly specified in the 731 application mapping, TLS is assumed to be the default crypto 732 handshake protocol, as described in [draft-mthomson-quic-tls]. An 733 application that maps to QUIC MAY however specify an alternative 734 crypto handshake protocol to be used. 736 The following list of requirements and recommendations documents 737 properties of the current prototype handshake which should be 738 provided by any handshake protocol. 740 o The crypto handshake MUST ensure that the final negotiated key is 741 distinct for every connection between two endpoints. 743 o Transport Negotiation: The crypto handshake MUST provide a 744 mechanism for the transport component to exchange transport 745 parameters and Source Address Tokens. To avoid downgrade attacks, 746 the transport parameters sent and received MUST be verified before 747 the handshake completes successfully. 749 o Connection Establishment in 0-RTT: Since low-latency connection 750 establishment is a critical feature of QUIC, the QUIC handshake 751 protocol SHOULD attempt to achieve 0-RTT connection establishment 752 latency for repeated connections between the same endpoints. 754 o Source Address Spoofing Defense: Since QUIC handles source address 755 verification, the crypto protocol SHOULD NOT impose a separate 756 source address verification mechanism. 758 o Server Config Update: A QUIC server may refresh the source-address 759 token (STK) mid-connection, to update the information stored in 760 the STK at the client and to extend the period over which 0-RTT 761 connections can be established by the client. 763 o Certificate Compression: Early QUIC experience demonstrated that 764 compressing certificates exchanged during a handshake is valuable 765 in reducing latency. This additionally helps to reduce the 766 amplification attack footprint when a server sends a large set of 767 certificates, which is not uncommon with TLS. The crypto protocol 768 SHOULD compress certificates and any other information to minimize 769 the number of packets sent during a handshake. 771 The following information used during the QUIC handshake MUST be 772 cryptographically verified by the crypto handshake protocol: 774 o Client's originally proposed version in its first packet. 776 o Server's version list in it's Version Negotiation packet, if one 777 was sent. 779 5.3. Connection Migration 781 QUIC connections are identified by their 64-bit Connection ID. 782 QUIC's consistent connection ID allows connections to survive changes 783 to the client's IP and/or port, such as those caused by client or 784 server migrating to a new network. QUIC also provides automatic 785 cryptographic verification of a rebound client, since the client 786 continues to use the same session key for encrypting and decrypting 787 packets. 789 DISCUSS: Simultaneous migration. Is this reasonable? 791 TODO: Perhaps move mitigation techniques from Security Considerations 792 here. 794 5.4. Connection Termination 796 Connections should remain open until they become idle for a pre- 797 negotiated period of time. A QUIC connection, once established, can 798 be terminated in one of three ways: 800 1. Explicit Shutdown: An endpoint sends a CONNECTION_CLOSE frame to 801 the peer initiating a connection termination. An endpoint may 802 send a GOAWAY frame to the peer prior to a CONNECTION_CLOSE to 803 indicate that the connection will soon be terminated. A GOAWAY 804 frame signals to the peer that any active streams will continue 805 to be processed, but the sender of the GOAWAY will not initiate 806 any additional streams and will not accept any new incoming 807 streams. On termination of the active streams, a 808 CONNECTION_CLOSE may be sent. If an endpoint sends a 809 CONNECTION_CLOSE frame while unterminated streams are active (no 810 FIN bit or RST_STREAM frames have been sent or received for one 811 or more streams), then the peer must assume that the streams were 812 incomplete and were abnormally terminated. 814 2. Implicit Shutdown: The default idle timeout for a QUIC connection 815 is 30 seconds, and is a required parameter (ICSL) in connection 816 negotiation. The maximum is 10 minutes. If there is no network 817 activity for the duration of the idle timeout, the connection is 818 closed. By default a CONNECTION_CLOSE frame will be sent. A 819 silent close option can be enabled when it is expensive to send 820 an explicit close, such as mobile networks that must wake up the 821 radio. 823 3. Abrupt Shutdown: An endpoint may send a Public Reset packet at 824 any time during the connection to abruptly terminate an active 825 connection. A Public Reset packet SHOULD only be used as a final 826 recourse. Commonly, a public reset is expected to be sent when a 827 packet on an established connection is received by an endpoint 828 that is unable decrypt the packet. For instance, if a server 829 reboots mid-connection and loses any cryptographic state 830 associated with open connections, and then receives a packet on 831 an open connection, it should send a Public Reset packet in 832 return. (TODO: articulate rules around when a public reset 833 should be sent.) 835 TODO: Connections that are terminated are added to a TIME_WAIT list 836 at the server, so as to absorb any straggler packets in the network. 837 Discuss TIME_WAIT list. 839 6. Frame Types and Formats 841 As described in Section XXX, Regular packets contain one or more 842 frames. We now describe the various QUIC frame types that can be 843 present in a Regular packet. The use of these frames and various 844 frame header bits are described in subsequent sections. 846 6.1. STREAM Frame 848 STREAM frames implicitly create a stream and carry stream data. A 849 STREAM frame is shown below. 851 +------------+--------------------------------+ 852 | Type (8) | Stream ID (8, 16, 24, or 32) | 853 +------------+--------------------------------+ 854 +---------------------------------------------+ 855 | Offset (0, 16, 24, 32, 40, 48, 56, or 64) | 856 +---------------------------------------------+ 857 +-------------------------+---------------------------------+ 858 | Data length (0 or 16) | Stream Data (per data length) | 859 +-------------------------+---------------------------------+ 861 The STREAM frame header fields are as follows: 863 o Frame Type: The Frame Type byte is an 8-bit value containing 864 various flags, and is formatted as the following 8 bits: 1FDOOOSS. 866 * The leftmost bit must be set to 1 indicating that this is a 867 STREAM frame. 869 * 'F' is the FIN bit, which is used for stream termination. 871 * The 'D' bit indicates whether a Data Length field is present in 872 the STREAM header. When set to 0, this field indicates that 873 the Stream Data field extends to the end of the packet. When 874 set to 1, this field indicates that Data Length field contains 875 the length (in bytes) of the Stream Data field. The option to 876 omit the length should only be used when the packet is a "full- 877 sized" packet, to avoid the risk of corruption via padding. 879 * The 'OOO' bits encode the length of the Offset header field as 880 0, 16, 24, 32, 40, 48, 56, or 64 bits long. 882 * The 'SS' bits encode the length of the Stream ID header field 883 as 8, 16, 24, or 32 bits. (DISCUSS: Consider making this 8, 884 16, 32, 64.) 886 o Stream ID: A variable-sized unsigned ID unique to this stream. 888 o Offset: A variable-sized unsigned number specifying the byte 889 offset in the stream for the data in this STREAM frame. The first 890 byte in the stream has an offset of 0. 892 o Data Length: An optional 16-bit unsigned number specifying the 893 length of the Stream Data field in this STREAM frame. 895 A STREAM frame MUST have either non-zero data length or the FIN bit 896 set. 898 Stream multiplexing is achieved by interleaving STREAM frames from 899 multiple streams into one or more QUIC packets. A single QUIC packet 900 MAY bundle STREAM frames from multiple streams. 902 Implementation note: One of the benefits of QUIC is avoidance of 903 head-of-line blocking across multiple streams. When a packet loss 904 occurs, only streams with data in that packet are blocked waiting for 905 a retransmission to be received, while other streams can continue 906 making progress. Note that when data from multiple streams is 907 bundled into a single QUIC packet, loss of that packet blocks all 908 those streams from making progress. An implementation is therefore 909 advised to bundle as few streams as necessary in outgoing packets 910 without losing transmission efficiency to underfilled packets. 912 6.2. ACK Frame 914 Receivers send ACK frames to inform senders which packets they have 915 received, as well as which packets are considered missing. The ACK 916 frame contains between 1 and 256 ack blocks. Ack blocks are ranges 917 of acknowledged packets. 919 To limit the ACK blocks to the ones that haven't yet been received by 920 the sender, the sender periodically sends STOP_WAITING frames that 921 signal the receiver to stop acking packets below a specified sequence 922 number, raising the "least unacked" packet number at the receiver. A 923 sender of an ACK frame thus reports only those ACK blocks between the 924 received least unacked and the reported largest observed packet 925 numbers. It is recommended for the sender to send the most recent 926 largest acked packet it has received in an ack as the STOP_WAITING 927 frame's least unacked value. 929 Unlike TCP SACKs, QUIC ACK blocks are irrevocable. Once a packet is 930 acked, even if it does not appear in a future ack frame, it is 931 assumed to be acked. 933 A sender MAY intentionally skip packet numbers to introduce entropy 934 into the connection, to avoid opportunistic ack attacks. The sender 935 MUST close the connection if an unsent packet number is acked. The 936 format of the ACK frame is efficient at expressing blocks of missing 937 packets; skipping packet numbers between 1 and 255 effectively 938 provides up to 8 bits of efficient entropy on demand, which should be 939 adequate protection against most opportunistic ack attacks. 941 +--------------------------------------------------------------+ 942 | Type (8) | Largest Acked (8, 16, 32, or 48) | Ack Delay (16) | 943 +--------------------------------------------------------------+ 945 Ack Block Section: 946 +-------------------------------------------------------------------------+ 947 | Number Blocks (8) (opt) | First Ack Block Length (8, 16, 32 or 48 bits) | 948 +-------------------------------------------------------------------------+ 949 +-----------------------------------------------------------------+ 950 | Gap To Next Block (8) | Ack Block Length (8, 16, 32, or 48 bits | <-- optional, 951 +-----------------------------------------------------------------+ repeats 953 Timestamp Section: 954 +--------------------+ 955 | Num Timestamps (8) | 956 +--------------------+ 957 +---------------------------------------------------------+ 958 | Delta Largest Acked (8) | Time Since Largest Acked (32) | <-- optional 959 +---------------------------------------------------------+ 960 +---------------------------------------------------------------+ 961 | Delta Largest Acked (8) | Time Since Previous Timestamp (16) | <-- optional, 962 +---------------------------------------------------------------+ repeats 964 The fields in the ACK frame are as follows: 966 o Frame Type: The Frame Type byte is an 8-bit value containing 967 various flags. This byte is formatted as the following 8 bits: 968 01NULLMM. 970 * The first two bits must be set to 01 indicating that this is an 971 ACK frame. 973 * The 'N' bit indicates whether the frame has more than 1 ack 974 range. 976 * The 'U' bit is unused. 978 * The two 'LL' bits encode the length of the Largest Acked field 979 as 1, 2, 4, or 6 bytes long. 981 * The two 'MM' bits encode the length of the Ack Block Length 982 fields as 1, 2, 4, or 6 bytes long. 984 o Largest Acked: A variable-sized unsigned value representing the 985 largest packet number the peer is acking in this packet (typically 986 the largest that the peer has seen thus far.) 988 o Ack Delay: Time from when the largest acked, as indicated in the 989 Largest Acked field, was received by this peer to when this ack 990 was sent. 992 o Ack Block Section: 994 * Num Blocks (opt): An optional 8-bit unsigned value specifying 995 the number of additional ack blocks (besides the required First 996 Ack Block) in this ACK frame. Only present if the 'N' flag bit 997 is 1. 999 * First Ack Block Length: An unsigned packet number delta that 1000 indicates the number of contiguous additional packets being 1001 acked starting at the Largest Acked. 1003 * Gap To Next Block (opt, repeated): An unsigned number 1004 specifying the number of contiguous missing packets from the 1005 end of the previous ack block to the start of the next. 1007 * Ack Block Length (opt, repeated): An unsigned packet number 1008 delta that indicates the number of contiguous packets being 1009 acked starting after the end of the previous gap. Along with 1010 the previous field, this field is repeated "Num Blocks" times. 1012 o Timestamp Section: 1014 * Num Timestamps: An unsigned 8-bit number specifying the total 1015 number of pairs following, including 1016 the First Timestamp. 1018 * Delta Largest Acked (opt): An optional 8-bit unsigned packet 1019 number delta specifying the delta between the largest acked and 1020 the first packet whose timestamp is being reported. In other 1021 words, this first packet number may be computed as (Largest 1022 Acked - Delta Largest Acked.) 1024 * First Timestamp (opt): An optional 32-bit unsigned value 1025 specifying the time delta in microseconds, from the beginning 1026 of the connection to the arrival of this packet. 1028 * Delta Largest Observed (opt, repeated): (Same as above.) 1030 * Time Since Previous Timestamp (opt, repeated): An optional 1031 16-bit unsigned value specifying time delta from the previous 1032 reported timestamp. It is encoded in the same format as the 1033 Ack Delay. Along with the previous field, this field is 1034 repeated "Num Timestamps" times. 1036 6.2.1. Time Format 1038 DISCUSS_AND_REPLACE: Perhaps make this format simpler. 1040 The time format used in the ACK frame above is a 16-bit unsigned 1041 float with 11 explicit bits of mantissa and 5 bits of explicit 1042 exponent, specifying time in microseconds. The bit format is loosely 1043 modeled after IEEE 754. For example, 1 microsecond is represented as 1044 0x1, which has an exponent of zero, presented in the 5 high order 1045 bits, and mantissa of 1, presented in the 11 low order bits. When 1046 the explicit exponent is greater than zero, an implicit high-order 1047 12th bit of 1 is assumed in the mantissa. For example, a floating 1048 value of 0x800 has an explicit exponent of 1, as well as an explicit 1049 mantissa of 0, but then has an effective mantissa of 4096 (12th bit 1050 is assumed to be 1). Additionally, the actual exponent is one-less 1051 than the explicit exponent, and the value represents 4096 1052 microseconds. Any values larger than the representable range are 1053 clamped to 0xFFFF. 1055 6.3. STOP_WAITING Frame 1057 The STOP_WAITING frame is sent to inform the peer that it should not 1058 continue to wait for packets with packet numbers lower than a 1059 specified value. The packet number is encoded in 1, 2, 4 or 6 bytes, 1060 using the same coding length as is specified for the packet number 1061 for the enclosing packet's header (specified in the QUIC Frame 1062 packet's Flags field.) The frame is as follows: 1064 +---------------------------------------------------+ 1065 | Type (8) | Least unacked delta (8, 16, 32, or 48) | 1066 +---------------------------------------------------+ 1068 The fields in the STOP_WAITING frame are as follows: 1070 o Frame Type: The Frame Type byte is an 8-bit value that must be set 1071 to 0x06 indicating that this is a STOP_WAITING frame. 1073 o Least Unacked Delta: A variable-length packet number delta with 1074 the same length as the packet header's packet number. Subtract it 1075 from the complete packet number of the enclosing packet to 1076 determine the least unacked packet number. The resulting least 1077 unacked packet number is the earliest packet for which the sender 1078 is still awaiting an ack. If the receiver is missing any packets 1079 earlier than this packet, the receiver SHOULD consider those 1080 packets to be irrecoverably lost and MUST NOT report those packets 1081 as missing in subsequent acks. 1083 6.4. WINDOW_UPDATE Frame 1085 The WINDOW_UPDATE frame informs the peer of an increase in an 1086 endpoint's flow control receive window. The StreamID can be zero, 1087 indicating this WINDOW_UPDATE applies to the connection level flow 1088 control window, or non-zero, indicating that the specified stream 1089 should increase its flow control window. The frame is as follows: 1091 +---------------------------------------------------+ 1092 | Type(8) | Stream ID (32) | Byte offset (64) | 1093 +---------------------------------------------------+ 1095 The fields in the WINDOW_UPDATE frame are as follows: 1097 o Frame Type: The Frame Type byte is an 8-bit value that must be set 1098 to 0x04 indicating that this is a WINDOW_UPDATE frame. 1100 o Stream ID: ID of the stream whose flow control windows is being 1101 updated, or 0 to specify the connection-level flow control window. 1103 o Byte offset: A 64-bit unsigned integer indicating the absolute 1104 byte offset of data which can be sent on the given stream. In the 1105 case of connection level flow control, the cumulative number of 1106 bytes which can be sent on all currently open streams. 1108 6.5. BLOCKED Frame 1110 A sender sends a BLOCKED frame when it is ready to send data (and has 1111 data to send), but is currently flow control blocked. BLOCKED frames 1112 are purely informational frames, but extremely useful for debugging 1113 purposes. A receiver of a BLOCKED frame should simply discard it 1114 (after possibly printing a helpful log message). The frame is as 1115 follows: 1117 +------------------------------+ 1118 | Type(8) | Stream ID (32) | 1119 +------------------------------+ 1121 The fields in the BLOCKED frame are as follows: 1123 o Frame Type: The Frame Type byte is an 8-bit value that must be set 1124 to 0x05 indicating that this is a BLOCKED frame. 1126 o Stream ID: A 32-bit unsigned number indicating the stream which is 1127 flow control blocked. A non-zero Stream ID field specifies the 1128 stream that is flow control blocked. When zero, the Stream ID 1129 field indicates that the connection is flow control blocked. 1131 6.6. RST_STREAM Frame 1133 An endpoint may use a RST_STREAM frame to abruptly terminate a 1134 stream. The frame is as follows: 1136 +----------------------------------------------------------------------+ 1137 | Type(8) | StreamID (32) | Byte offset (64) | Error code (32) | 1138 +----------------------------------------------------------------------+ 1140 The fields are: 1142 o Frame type: The Frame Type is an 8-bit value that must be set to 1143 0x01 specifying that this is a RST_STREAM frame. 1145 o Stream ID: The 32-bit Stream ID of the stream being terminated. 1147 o Byte offset: A 64-bit unsigned integer indicating the absolute 1148 byte offset of the end of data written on this stream by the 1149 RST_STREAM sender. 1151 o Error code: A 32-bit error code which indicates why the stream is 1152 being closed. 1154 6.7. PADDING Frame 1156 The PADDING frame pads a packet with 0x00 bytes. When this frame is 1157 encountered, the rest of the packet is expected to be padding bytes. 1158 The frame contains 0x00 bytes and extends to the end of the QUIC 1159 packet. A PADDING frame only has a Frame Type field, and must have 1160 the 8-bit Frame Type field set to 0x00. 1162 +--------+ 1163 | 0x00 | 1164 +--------+ 1166 6.8. PING frame 1168 Endpoints can use PING frames to verify that their peers are still 1169 alive or to check reachability to the peer. The PING frame contains 1170 no payload. The receiver of a PING frame simply needs to ACK the 1171 packet containing this frame. The PING frame SHOULD be used to keep 1172 a connection alive when a stream is open. The default is to send a 1173 PING frame after 15 seconds of quiescence. A PING frame only has a 1174 Frame Type field, and must have the 8-bit Frame Type field set to 1175 0x07. 1177 +--------+ 1178 | 0x07 | 1179 +--------+ 1181 6.9. CONNECTION_CLOSE frame 1183 An endpoint sends a CONNECTION_CLOSE frame to notify its peer that 1184 the connection is being closed. If there are open streams that 1185 haven't been explicitly closed, they are implicitly closed when the 1186 connection is closed. (Ideally, a GOAWAY frame would be sent with 1187 enough time that all streams are torn down.) The frame is as 1188 follows: 1190 +-----------------------------------------------------------------------+ 1191 | Type(8) | Error code (32) | Reason phrase length (16) | Reason phrase | 1192 +-----------------------------------------------------------------------+ 1194 The fields of a CONNECTION_CLOSE frame are as follows: 1196 o Frame Type: An 8-bit value that must be set to 0x02 specifying 1197 that this is a CONNECTION_CLOSE frame. 1199 o Error Code: A 32-bit error code which indicates the reason for 1200 closing this connection. 1202 o Reason Phrase Length: A 16-bit unsigned number specifying the 1203 length of the reason phrase. This may be zero if the sender 1204 chooses to not give details beyond the QuicErrorCode. 1206 o Reason Phrase: An optional human-readable explanation for why the 1207 connection was closed. 1209 6.10. GOAWAY Frame 1211 An endpoint may use a GOAWAY frame to notify its peer that the 1212 connection should stop being used, and will likely be aborted in the 1213 future. The endpoints will continue using any active streams, but 1214 the sender of the GOAWAY will not initiate any additional streams, 1215 and will not accept any new streams. The frame is as follows: 1217 +-----------------------------------------------------------+ 1218 | Type (8) | Error code (32) | Last Good Stream ID (32) | 1219 +-----------------------------------------------------------+ 1220 +----------------------------------------------+ 1221 | Reason phrase length (16) | Reason phrase | 1222 +----------------------------------------------+ 1224 The fields of a GOAWAY frame are as follows: 1226 o Frame type: An 8-bit value that must be set to 0x03 specifying 1227 that this is a GOAWAY frame. 1229 o Error Code: A 32-bit field error code which indicates the reason 1230 for closing this connection. 1232 o Last Good Stream ID: The last Stream ID which was accepted by the 1233 sender of the GOAWAY message. If no streams were replied to, this 1234 value must be set to 0. 1236 o Reason Phrase Length: A 16-bit unsigned number specifying the 1237 length of the reason phrase. This may be zero if the sender 1238 chooses to not give details beyond the error code. 1240 o Reason Phrase: An optional human-readable explanation for why the 1241 connection was closed. 1243 7. Packetization and Reliability 1245 The maximum packet size for QUIC is the maximum size of the encrypted 1246 payload of the resulting UDP datagram. All QUIC packets SHOULD be 1247 sized to fit within the path's MTU to avoid IP fragmentation. The 1248 recommended default maximum packet size is 1350 bytes for IPv6 and 1249 1370 bytes for IPv4. To optimize better, endpoints MAY use PLPMTUD 1250 [RFC4821] for detecting the path's MTU and setting the maximum packet 1251 size appropriately. 1253 A sender bundles one or more frames in a Regular QUIC packet. A 1254 sender MAY bundle any set of frames in a packet. All QUIC packets 1255 MUST contain a packet number and MAY contain one or more frames 1256 (Section XX). Packet numbers MUST be unique within a connection and 1257 MUST NOT be reused within the same connection. Packet numbers MUST 1258 be assigned to packets in a strictly monotonically increasing order. 1259 The initial packet number used, at both the client and the server, 1260 MUST be 0. That is, the first packet in both directions of the 1261 connection MUST have a packet number of 0. 1263 A sender SHOULD minimize per-packet bandwidth and computational costs 1264 by bundling as many frames as possible within a QUIC packet. A 1265 sender MAY wait for a short period of time to bundle multiple frames 1266 before sending a packet that is not maximally packed, to avoid 1267 sending out large numbers of small packets. An implementation may 1268 use heuristics about expected application sending behavior to 1269 determine whether and for how long to wait. This waiting period is 1270 an implementation decision, and an implementation should be careful 1271 to delay conservatively, since any delay is likely to increase 1272 application-visible latency. 1274 Regular QUIC packets are "containers" of frames; a packet is never 1275 retransmitted whole, but frames in a lost packet may be rebundled and 1276 transmitted in a subsequent packet as necessary. 1278 A packet may contain frames and/or application data, only some of 1279 which may require reliability. When a packet is detected as lost, 1280 the sender SHOULD only resend frames that require retransmission. 1282 o All application data sent in STREAM frames MUST be retransmitted, 1283 with one exception. When an endpoint sends a RST_STREAM frame, 1284 data outstanding on that stream SHOULD NOT be retransmitted, since 1285 subsequent data on this stream is expected to not be delivered by 1286 the receiver. 1288 o ACK, STOP_WAITING, and PADDING frames MUST NOT be retransmitted. 1289 New frames of these types may however be bundled with any outgoing 1290 packet. 1292 o All other frames MUST be retransmitted. 1294 Upon detecting losses, a sender MUST take appropriate congestion 1295 control action. The details of loss detection and congestion control 1296 are described in [draft-loss-recovery]. 1298 A receiver acknowledges receipt of a received packet by sending one 1299 or more ACK frames containing the packet number of the received 1300 packet. To avoid perpetual acking between endpoints, a receiver MUST 1301 NOT generate an ack in response to every packet containing only ACK 1302 frames. However, since it is possible that an endpoint sends only 1303 packets containing ACK frame (or other non-retransmittable frames), 1304 the receiving peer MAY send an ACK frame after a reasonable number 1305 (currently 20) of such packets have been received. 1307 Strategies and implications of the frequency of generating 1308 acknowledgments are discussed in more detail in [draft-loss- 1309 recovery]. 1311 8. Streams: QUIC's Data Structuring Abstraction 1313 Streams in QUIC provide a lightweight, ordered, and bidirectional 1314 byte-stream abstraction. Streams can be created either by the client 1315 or the server, can concurrently send data interleaved with other 1316 streams, and can be cancelled. QUIC's stream lifetime is modeled 1317 closely after HTTP/2's [RFC7540]. Streams are independent of each 1318 other in delivery order. That is, data that is received on a stream 1319 is delivered in order within that stream, but there is no particular 1320 delivery order across streams. Transmit ordering among streams is 1321 left to the implementation. QUIC streams are considered lightweight 1322 in that the creation and destruction of streams are expected to have 1323 minimal bandwidth and computational cost. A single STREAM frame may 1324 create, carry data for, and terminate a stream, or a stream may last 1325 the entire duration of a connection. Implementations are therefore 1326 advised to keep these extremes in mind and to implement stream 1327 creation and destruction to be as lightweight as possible. 1329 An alternative view of QUIC streams is as an elastic "message" 1330 abstraction, similar to the way ephemeral streams are used in SST 1331 [cite SST], which may be a more appealing description for some 1332 applications. 1334 8.1. Life of a Stream 1336 The semantics of QUIC streams is based on HTTP/2 streams, and the 1337 lifecycle of a QUIC stream therefore closely follows that of an 1338 HTTP/2 stream [RFC7540], with some differences to accommodate the 1339 possibility of out-of-order delivery due to the use of multiple 1340 streams in QUIC. The lifecycle of a QUIC stream is shown in the 1341 following figure and described below. 1343 app +--------+ 1344 reserve_stream | | 1345 ,--------------| idle | 1346 / | | 1347 / +--------+ 1348 V | 1349 +----------+ send data/ | 1350 | | recv data | send data/ 1351 ,---| reserved |------------. | recv data 1352 | | | \ | 1353 | +----------+ v v 1354 | recv FIN/ +--------+ send FIN/ 1355 | app read_close | | app write_close 1356 | ,---------| open |-----------. 1357 | / | | \ 1358 | v +--------+ v 1359 | +----------+ | +----------+ 1360 | | half | | | half | 1361 | | closed | | send RST/ | closed | 1362 | | (remote) | | recv RST | (local) | 1363 | +----------+ | +----------+ 1364 | | | | 1365 | | recv FIN/ | send FIN/ | 1366 | | app write_close/ | app read_close/ | 1367 | | send RST/ v send RST/ | 1368 | | recv RST +--------+ recv RST | 1369 | send RST/ `------------->| |<---------------' 1370 | recv RST | closed | 1371 `-------------------------->| | 1372 +--------+ 1374 send: endpoint sends this frame 1375 recv: endpoint receives this frame 1377 data: application data in a STREAM frame 1378 FIN: FIN flag in a STREAM frame 1379 RST: RST_STREAM frame 1381 app: application API signals to QUIC 1382 reserve_stream: causes a StreamID to be reserved for later use 1383 read_close: causes stream to be half-closed without receiving a FIN 1384 write_close: causes stream to be half-closed without sending a FIN 1386 Note that this diagram shows stream state transitions and the frames 1387 and flags that affect those transitions only. For the purpose of 1388 state transitions, the FIN flag is processed as a separate event to 1389 the frame that bears it; a STREAM frame with the FIN flag set can 1390 cause two state transitions. When the FIN bit is sent on an empty 1391 STREAM frame, the offset in the STREAM frame MUST be one greater than 1392 the last data byte sent on this stream. 1394 Both endpoints have a subjective view of the state of a stream that 1395 could be different when frames are in transit. Endpoints do not 1396 coordinate the creation of streams; they are created unilaterally by 1397 either endpoint. The negative consequences of a mismatch in states 1398 are limited to the "closed" state after sending RST_STREAM, where 1399 frames might be received for some time after closing. 1401 Streams have the following states: 1403 8.1.1. idle 1405 All streams start in the "idle" state. 1407 The following transitions are valid from this state: 1409 Sending or receiving a STREAM frame causes the stream to become 1410 "open". The stream identifier is selected as described in 1411 Section XX. The same STREAM frame can also cause a stream to 1412 immediately become "half-closed". 1414 An application can reserve an idle stream for later use. The stream 1415 state for the reserved stream transitions to "reserved". 1417 Receiving any frame other than STREAM or RST_STREAM on a stream in 1418 this state MUST be treated as a connection error (Section XX) of type 1419 YYYY. 1421 8.1.2. reserved 1423 A stream in this state has been reserved for later use by the 1424 application. In this state only the following transitions are 1425 possible: 1427 o Sending or receiving a STREAM frame causes the stream to become 1428 "open". 1430 o Sending or receiving a RST_STREAM frame causes the stream to 1431 become "closed". 1433 8.1.3. open 1435 A stream in the "open" state may be used by both peers to send frames 1436 of any type. In this state, a sending peer must observe the flow- 1437 control limit advertised by its receiving peer (Section XX). 1439 From this state, either endpoint can send a frame with the FIN flag 1440 set, which causes the stream to transition into one of the "half- 1441 closed" states. An endpoint sending an FIN flag causes the stream 1442 state to become "half-closed (local)". An endpoint receiving a FIN 1443 flag causes the stream state to become "half-closed (remote)"; the 1444 receiving endpoint MUST NOT process the FIN flag until all preceding 1445 data on the stream has been received. 1447 Either endpoint can send a RST_STREAM frame from this state, causing 1448 it to transition immediately to "closed". 1450 8.1.4. half-closed (local) 1452 A stream that is in the "half-closed (local)" state MUST NOT be used 1453 for sending STREAM frames; WINDOW_UPDATE and RST_STREAM MAY be sent 1454 in this state. 1456 A stream transitions from this state to "closed" when a frame that 1457 contains an FIN flag is received or when either peer sends a 1458 RST_STREAM frame. 1460 An endpoint can receive any type of frame in this state. Providing 1461 flow-control credit using WINDOW_UPDATE frames is necessary to 1462 continue receiving flow-controlled frames. In this state, a receiver 1463 MAY ignore WINDOW_UPDATE frames for this stream, which might arrive 1464 for a short period after a frame bearing the FIN flag is sent. 1466 8.1.5. half-closed (remote) 1468 A stream that is "half-closed (remote)" is no longer being used by 1469 the peer to send any data. In this state, a sender is no longer 1470 obligated to maintain a receiver stream-level flow-control window. 1472 If an endpoint receives any STREAM frames for a stream that is in 1473 this state, it MUST close the connection with a 1474 QUIC_STREAM_DATA_AFTER_TERMINATION error (Section XX). 1476 A stream in this state can be used by the endpoint to send frames of 1477 any type. In this state, the endpoint continues to observe 1478 advertised stream-level and connection-level flow-control limits 1479 (Section XX). 1481 A stream can transition from this state to "closed" by sending a 1482 frame that contains a FIN flag or when either peer sends a RST_STREAM 1483 frame. 1485 8.1.6. closed 1487 The "closed" state is the terminal state. 1489 A final offset is present in both a frame bearing a FIN flag and in a 1490 RST_STREAM frame. Upon sending either of these frames for a stream, 1491 the endpoint MUST NOT send a STREAM frame carrying data beyond the 1492 final offset. 1494 An endpoint that receives any frame for this stream after receiving 1495 either a FIN flag and all stream data preceding it, or a RST_STREAM 1496 frame, MUST quietly discard the frame, with one exception. If a 1497 STREAM frame carrying data beyond the received final offset is 1498 received, the endpoint MUST close the connection with a 1499 QUIC_STREAM_DATA_AFTER_TERMINATION error (Section XX). 1501 An endpoint that receives a RST_STREAM frame (and which has not sent 1502 a FIN or a RST_STREAM) MUST immediately respond with a RST_STREAM 1503 frame, and MUST NOT send any more data on the stream. This endpoint 1504 may continue receiving frames for the stream on which a RST_STREAM is 1505 received. 1507 If this state is reached as a result of sending a RST_STREAM frame, 1508 the peer that receives the RST_STREAM might have already sent -- or 1509 enqueued for sending -- frames on the stream that cannot be 1510 withdrawn. An endpoint MUST ignore frames that it receives on closed 1511 streams after it has sent a RST_STREAM frame. An endpoint MAY choose 1512 to limit the period over which it ignores frames and treat frames 1513 that arrive after this time as being in error. 1515 STREAM frames received after sending RST_STREAM are counted toward 1516 the connection and stream flow-control windows. Even though these 1517 frames might be ignored, because they are sent before their sender 1518 receives the RST_STREAM, the sender will consider the frames to count 1519 against its flow-control windows. 1521 In the absence of more specific guidance elsewhere in this document, 1522 implementations SHOULD treat the receipt of a frame that is not 1523 expressly permitted in the description of a state as a connection 1524 error (Section XX). Frames of unknown types are ignored. 1526 (TODO: QUIC_STREAM_NO_ERROR is a special case. Write it up.) 1528 8.2. Stream Identifiers 1530 Streams are identified by an unsigned 32-bit integer, referred to as 1531 the StreamID. To avoid StreamID collision, clients MUST initiate 1532 streams usinge odd-numbered StreamIDs; streams initiated by the 1533 server MUST use even-numbered StreamIDs. 1535 A StreamID of zero (0x0) is reserved and used for connection-level 1536 flow control frames (Section XX); the StreamID of zero cannot be used 1537 to establish a new stream. 1539 StreamID 1 (0x1) is reserved for the crypto handshake. StreamID 1 1540 MUST NOT be used for application data, and MUST be the first client- 1541 initiated stream. 1543 Streams MUST be created or reserved in sequential order, but MAY be 1544 used in arbitrary order. A QUIC endpoint MUST NOT reuse a StreamID 1545 on a given connection. 1547 8.3. Stream Concurrency 1549 An endpoint can limit the number of concurrently active incoming 1550 streams by setting the MSPC parameter (see Section XX) in the 1551 transport parameters. The maximum concurrent streams setting is 1552 specific to each endpoint and applies only to the peer that receives 1553 the setting. That is, clients specify the maximum number of 1554 concurrent streams the server can initiate, and servers specify the 1555 maximum number of concurrent streams the client can initiate. 1557 Streams that are in the "open" state or in either of the "half- 1558 closed" states count toward the maximum number of streams that an 1559 endpoint is permitted to open. Streams in any of these three states 1560 count toward the limit advertised in the MSPC setting. 1562 Endpoints MUST NOT exceed the limit set by their peer. An endpoint 1563 that receives a STREAM frame that causes its advertised concurrent 1564 stream limit to be exceeded MUST treat this as a stream error of type 1565 QUIC_TOO_MANY_OPEN_STREAMS (Section XX). 1567 8.4. Sending and Receiving Data 1569 Once a stream is created, endpoints may use the stream to send and 1570 receive data. Each endpoint may send a series of STREAM frames 1571 encapsulating data on a stream until the stream is terminated in that 1572 direction. Streams are an ordered byte-stream abstraction, and they 1573 have no other structure within them. STREAM frame boundaries are not 1574 expected to be preserved in retransmissions from the sender or during 1575 delivery to the application at the receiver. 1577 When new data is to be sent on a stream, a sender MUST set the 1578 encapsulating STREAM frame's offset field to the stream offset of the 1579 first byte of this new data. The first byte of data that is sent on 1580 a stream has the stream offset 0. A receiver MUST ensure that 1581 received stream data is delivered to the application as an ordered 1582 byte-stream. Data received out of order MUST be buffered for later 1583 delivery, as long as it is not in violation of the receiver's flow 1584 control limits. 1586 An endpoint MUST NOT send any stream data without consulting the 1587 congestion controller and the flow controller, with the following two 1588 exceptions. 1590 o The crypto handshake stream, Stream 1, MUST NOT be subject to 1591 congestion control or connection-level flow control, but MUST be 1592 subject to stream-level flow control. 1594 o An application MAY exclude specific stream IDs from connection- 1595 level flow control. If so, these streams MUST NOT be subject to 1596 connection-level flow control. 1598 Flow control is described in detail in Section XX, and congestion 1599 control is described in the companion document [draft-iyengar-quic- 1600 loss-recovery]. 1602 9. Flow Control 1604 It is necessary to limit the amount of data that a sender may have 1605 outstanding at any time, so as to prevent a fast sender from 1606 overwhelming a slow receiver, or to prevent a malicious sender from 1607 consuming significant resources at a receiver. This section 1608 describes QUIC's flow-control mechanisms. 1610 QUIC employs a credit-based flow-control scheme similar to HTTP/2's 1611 flow control [RFC7540]. A receiver advertises the number of octets 1612 it is prepared to receive on a given stream and for the entire 1613 connection. This leads to two levels of flow control in QUIC: (i) 1614 Connection flow control, which prevents senders from exceeding a 1615 receiver's buffer capacity for the connection, and (ii) Stream flow 1616 control, which prevents a single stream from consuming the entire 1617 receive buffer for a connection. 1619 A receiver sends WINDOW_UPDATE frames to the sender to advertise 1620 additional credit, for both connection and stream flow control. A 1621 receiver advertises the maximum absolute byte offset in the stream or 1622 in the connection which the receiver is willing to receive. 1624 The initial flow control credit is 65536 bytes for both the stream 1625 and connection flow controllers. 1627 A receiver MAY advertise a larger offset at any point in the 1628 connection by sending a WINDOW_UPDATE frame. A receiver MUST NOT 1629 renege on an advertisement; that is, once a receiver advertises an 1630 offset via a WINDOW_UPDATE frame, it MUST NOT subsequently advertise 1631 a smaller offset. A sender may receive WINDOW_UPDATE frames out of 1632 order; a sender MUST therefore ignore any reductions in flow control 1633 credit. 1635 A sender MUST send BLOCKED frames to indicate it has data to write 1636 but is blocked by lack of connection or stream flow control credit. 1637 BLOCKED frames are expected to be sent infrequently in common cases, 1638 but they are considered useful for debugging and monitoring purposes. 1640 A receiver advertises credit for a stream by sending a WINDOW_UPDATE 1641 frame with the StreamID set appropriately. A receiver may simply use 1642 the current received offset to determine the flow control offset to 1643 be advertised. 1645 Connection flow control is a limit to the total bytes of stream data 1646 sent in STREAM frames. A receiver advertises credit for a connection 1647 by sending a WINDOW_UPDATE frame with the StreamID set to zero 1648 (0x00). A receiver may maintain a cumulative sum of bytes received 1649 cumulatively on all streams to determine the value of the connection 1650 flow control offset to be advertised in WINDOW_UPDATE frames. A 1651 sender may maintain a cumulative sum of stream data bytes sent to 1652 impose the connection flow control limit. 1654 9.1. Edge Cases and Other Considerations 1656 There are some edge cases which must be considered when dealing with 1657 stream and connection level flow control. Given enough time, both 1658 endpoints must agree on flow control state. If one end believes it 1659 can send more than the other end is willing to receive, the 1660 connection will be torn down when too much data arrives. Conversely 1661 if a sender believes it is blocked, while endpoint B expects more 1662 data can be received, then the connection can be in a deadlock, with 1663 the sender waiting for a WINDOW_UPDATE which will never come. 1665 9.1.1. Mid-stream RST_STREAM 1667 On receipt of an RST_STREAM frame, an endpoint will tear down state 1668 for the matching stream and ignore further data arriving on that 1669 stream. This could result in the endpoints getting out of sync, 1670 since the RST_STREAM frame may have arrived out of order and there 1671 may be further bytes in flight. The data sender would have counted 1672 the data against its connection level flow control budget, but a 1673 receiver that has not received these bytes would not know to include 1674 them as well. The receiver must learn of the number of bytes that 1675 were sent on the stream to make the same adjustment in its connection 1676 flow controller. 1678 To avoid this de-synchronization, a RST_STREAM sender MUST include 1679 the final byte offset sent on the stream in the RST_STREAM frame. On 1680 receiving a RST_STREAM frame, a receiver definitively knows how many 1681 bytes were sent on that stream before the RST_STREAM frame, and the 1682 receiver MUST use the final offset to account for all bytes sent on 1683 the stream in its connection level flow controller. 1685 9.1.2. Response to a RST_STREAM 1687 Since streams are bidirectional, a sender of a RST_STREAM needs to 1688 know how many bytes the peer has sent on the stream. If an endpoint 1689 receives a RST_STREAM frame and has sent neither a FIN nor a 1690 RST_STREAM, it MUST send a RST_STREAM in response, bearing the offset 1691 of the last byte sent on this stream as the final offset. 1693 9.1.3. Offset Increment 1695 This document leaves when and how many bytes to advertise in a 1696 WINDOW_UPDATE to the implementation, but offers a few considerations. 1697 WINDOW_UPDATE frames constitute overhead, and therefore, sending a 1698 WINDOW_UPDATE with small offset increments is undesirable. At the 1699 same time, sending WINDOW_UPDATES with large offset increments 1700 requires the sender to commit to that amount of buffer. 1701 Implementations must find the correct tradeoff between these sides to 1702 determine how large an offset increment to send in a WINDOW_UPDATE. 1704 A receiver MAY use an autotuning mechanism to tune the size of the 1705 offset increment to advertise based on a roundtrip time estimate and 1706 the rate at which the receiving application consumes data, similar to 1707 common TCP implementations. 1709 9.1.4. BLOCKED frames 1711 If a sender does not receive a WINDOW_UPDATE frame when it has run 1712 out of flow control credit, the sender will be blocked and MUST send 1713 a BLOCKED frame. A BLOCKED frame is expected to be useful for 1714 debugging at the receiver. A receiver SHOULD NOT wait for a BLOCKED 1715 frame before sending with a WINDOW_UPDATE, since doing so will cause 1716 at least one roundtrip of quiescence. For smooth operation of the 1717 congestion controller, it is generally considered best to not let the 1718 sender go into quiescence if avoidable. To avoid blocking a sender, 1719 and to reasonably account for the possibiity of loss, a receiver 1720 should send a WINDOW_UPDATE frame at least two roundtrips before it 1721 expects the sender to get blocked. 1723 10. Error Codes 1725 This section lists all the QUIC error codes that may be used in a 1726 CONNECTION_CLOSE frame. TODO: Trim list and group errors for 1727 readabiity. 1729 o 0x01: QUIC_INTERNAL_ERROR. (Connection has reached an invalid 1730 state.) 1732 o 0x02: QUIC_STREAM_DATA_AFTER_TERMINATION. (There were data frames 1733 after the a fin or reset.) 1735 o 0x03: QUIC_INVALID_PACKET_HEADER. (Control frame is malformed.) 1737 o 0x04: QUIC_INVALID_FRAME_DATA. (Frame data is malformed.) 1739 o 0x30: QUIC_MISSING_PAYLOAD. (The packet contained no payload.) 1741 o 0x2e: QUIC_INVALID_STREAM_DATA. (STREAM frame data is malformed.) 1743 o 0x57: QUIC_OVERLAPPING_STREAM_DATA. (STREAM frame data overlaps 1744 with buffered data.) 1746 o 0x3d: QUIC_UNENCRYPTED_STREAM_DATA. (Received STREAM frame data 1747 is not encrypted.) 1749 o 0x58: QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA. (Attempt to 1750 send unencrypted STREAM frame. Not sent on the wire, used for 1751 local logging.) 1753 o 0x59: QUIC_MAYBE_CORRUPTED_MEMORY. (Received a frame which is 1754 likely the result of memory corruption.) 1756 o 0x06: QUIC_INVALID_RST_STREAM_DATA. (RST_STREAM frame data is 1757 malformed.) 1759 o 0x07: QUIC_INVALID_CONNECTION_CLOSE_DATA. (CONNECTION_CLOSE frame 1760 data is malformed.) 1762 o 0x08: QUIC_INVALID_GOAWAY_DATA. (GOAWAY frame data is malformed.) 1764 o 0x39: QUIC_INVALID_WINDOW_UPDATE_DATA. (WINDOW_UPDATE frame data 1765 is malformed.) 1767 o 0x3a: QUIC_INVALID_BLOCKED_DATA. (BLOCKED frame data is 1768 malformed.) 1770 o 0x3c: QUIC_INVALID_STOP_WAITING_DATA. (STOP_WAITING frame data is 1771 malformed.) 1773 o 0x4e: QUIC_INVALID_PATH_CLOSE_DATA. (PATH_CLOSE frame data is 1774 malformed.) 1776 o 0x09: QUIC_INVALID_ACK_DATA. (ACK frame data is malformed.) 1778 o 0x0a: QUIC_INVALID_VERSION_NEGOTIATION_PACKET. (Version 1779 negotiation packet is malformed.) 1781 o 0x0b: QUIC_INVALID_PUBLIC_RST_PACKET. (Public RST packet is 1782 malformed.) 1784 o 0x0c: QUIC_DECRYPTION_FAILURE. (There was an error decrypting.) 1786 o 0x0d: QUIC_ENCRYPTION_FAILURE. (There was an error encrypting.) 1788 o 0x0e: QUIC_PACKET_TOO_LARGE. (The packet exceeded 1789 kMaxPacketSize.) 1791 o 0x10: QUIC_PEER_GOING_AWAY. (The peer is going away. May be a 1792 client or server.) 1794 o 0x11: QUIC_INVALID_STREAM_ID. (A stream ID was invalid.) 1796 o 0x31: QUIC_INVALID_PRIORITY. (A priority was invalid.) 1798 o 0x12: QUIC_TOO_MANY_OPEN_STREAMS. (Too many streams already 1799 open.) 1801 o 0x4c: QUIC_TOO_MANY_AVAILABLE_STREAMS. (The peer created too many 1802 available streams.) 1804 o 0x13: QUIC_PUBLIC_RESET. (Received public reset for this 1805 connection.) 1807 o 0x14: QUIC_INVALID_VERSION. (Invalid protocol version.) 1809 o 0x16: QUIC_INVALID_HEADER_ID. (The Header ID for a stream was too 1810 far from the previous.) 1812 o 0x17: QUIC_INVALID_NEGOTIATED_VALUE. (Negotiable parameter 1813 received during handshake had invalid value.) 1815 o 0x18: QUIC_DECOMPRESSION_FAILURE. (There was an error 1816 decompressing data.) 1818 o 0x19: QUIC_NETWORK_IDLE_TIMEOUT. (The connection timed out due to 1819 no network activity.) 1821 o 0x43: QUIC_HANDSHAKE_TIMEOUT. (The connection timed out waiting 1822 for the handshake to complete.) 1824 o 0x1a: QUIC_ERROR_MIGRATING_ADDRESS. (There was an error 1825 encountered migrating addresses.) 1827 o 0x56: QUIC_ERROR_MIGRATING_PORT. (There was an error encountered 1828 migrating port only.) 1830 o 0x1b: QUIC_PACKET_WRITE_ERROR. (There was an error while writing 1831 to the socket.) 1833 o 0x33: QUIC_PACKET_READ_ERROR. (There was an error while reading 1834 from the socket.) 1836 o 0x32: QUIC_EMPTY_STREAM_FRAME_NO_FIN. (We received a STREAM_FRAME 1837 with no data and no fin flag set.) 1839 o 0x38: QUIC_INVALID_HEADERS_STREAM_DATA. (We received invalid data 1840 on the headers stream.) 1842 o 0x3b: QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA. (The peer 1843 received too much data, violating flow control.) 1845 o 0x3f: QUIC_FLOW_CONTROL_SENT_TOO_MUCH_DATA. (The peer sent too 1846 much data, violating flow control.) 1848 o 0x40: QUIC_FLOW_CONTROL_INVALID_WINDOW. (The peer received an 1849 invalid flow control window.) 1851 o 0x3e: QUIC_CONNECTION_IP_POOLED. (The connection has been IP 1852 pooled into an existing connection.) 1854 o 0x44: QUIC_TOO_MANY_OUTSTANDING_SENT_PACKETS. (The connection has 1855 too many outstanding sent packets.) 1857 o 0x45: QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS. (The connection 1858 has too many outstanding received packets.) 1860 o 0x46: QUIC_CONNECTION_CANCELLED. (The quic connection has been 1861 cancelled.) 1863 o 0x47: QUIC_BAD_PACKET_LOSS_RATE. (Disabled QUIC because of high 1864 packet loss rate.) 1866 o 0x49: QUIC_PUBLIC_RESETS_POST_HANDSHAKE. (Disabled QUIC because 1867 of too many PUBLIC_RESETs post handshake.) 1869 o 0x4a: QUIC_TIMEOUTS_WITH_OPEN_STREAMS. (Disabled QUIC because of 1870 too many timeouts with streams open.) 1872 o 0x4b: QUIC_FAILED_TO_SERIALIZE_PACKET. (Closed because we failed 1873 to serialize a packet.) 1875 o 0x55: QUIC_TOO_MANY_RTOS. (QUIC timed out after too many RTOs.) 1877 o 0x1c: QUIC_HANDSHAKE_FAILED. (Crypto errors.Hanshake failed.) 1879 o 0x1d: QUIC_CRYPTO_TAGS_OUT_OF_ORDER. (Handshake message contained 1880 out of order tags.) 1882 o 0x1e: QUIC_CRYPTO_TOO_MANY_ENTRIES. (Handshake message contained 1883 too many entries.) 1885 o 0x1f: QUIC_CRYPTO_INVALID_VALUE_LENGTH. (Handshake message 1886 contained an invalid value length.) 1888 o 0x20: QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE. (A crypto 1889 message was received after the handshake was complete.) 1891 o 0x21: QUIC_INVALID_CRYPTO_MESSAGE_TYPE. (A crypto message was 1892 received with an illegal message tag.) 1894 o 0x22: QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER. (A crypto message 1895 was received with an illegal parameter.) 1897 o 0x34: QUIC_INVALID_CHANNEL_ID_SIGNATURE. (An invalid channel id 1898 signature was supplied.) 1900 o 0x23: QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND. (A crypto message 1901 was received with a mandatory parameter missing.) 1903 o 0x24: QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP. (A crypto message 1904 was received with a parameter that has no overlapwith the local 1905 parameter.) 1907 o 0x25: QUIC_CRYPTO_MESSAGE_INDEX_NOT_FOUND. (A crypto message was 1908 received that contained a parameter with too fewvalues.) 1910 o 0x5e: QUIC_UNSUPPORTED_PROOF_DEMAND. (A demand for an unsupport 1911 proof type was received.) 1913 o 0x26: QUIC_CRYPTO_INTERNAL_ERROR. (An internal error occured in 1914 crypto processing.) 1916 o 0x27: QUIC_CRYPTO_VERSION_NOT_SUPPORTED. (A crypto handshake 1917 message specified an unsupported version.) 1919 o 0x48: QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT. (A crypto handshake 1920 message resulted in a stateless reject.) 1922 o 0x28: QUIC_CRYPTO_NO_SUPPORT. (There was no intersection between 1923 the crypto primitives supported by thepeer and ourselves.) 1925 o 0x29: QUIC_CRYPTO_TOO_MANY_REJECTS. (The server rejected our 1926 client hello messages too many times.) 1928 o 0x2a: QUIC_PROOF_INVALID. (The client rejected the server's 1929 certificate chain or signature.) 1931 o 0x2b: QUIC_CRYPTO_DUPLICATE_TAG. (A crypto message was received 1932 with a duplicate tag.) 1934 o 0x2c: QUIC_CRYPTO_ENCRYPTION_LEVEL_INCORRECT. (A crypto message 1935 was received with the wrong encryption level (i.e. itshould have 1936 been encrypted but was not.)) 1938 o 0x2d: QUIC_CRYPTO_SERVER_CONFIG_EXPIRED. (The server config for a 1939 server has expired.) 1941 o 0x35: QUIC_CRYPTO_SYMMETRIC_KEY_SETUP_FAILED. (We failed to setup 1942 the symmetric keys for a connection.) 1944 o 0x36: QUIC_CRYPTO_MESSAGE_WHILE_VALIDATING_CLIENT_HELLO. (A 1945 handshake message arrived, but we are still validating theprevious 1946 handshake message.) 1948 o 0x41: QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE. (A server 1949 config update arrived before the handshake is complete.) 1951 o 0x5a: QUIC_CRYPTO_CHLO_TOO_LARGE. (CHLO cannot fit in one 1952 packet.) 1954 o 0x37: QUIC_VERSION_NEGOTIATION_MISMATCH. (This connection 1955 involved a version negotiation which appears to have beentampered 1956 with.) 1958 o 0x50: QUIC_IP_ADDRESS_CHANGED. (IP address changed causing 1959 connection close.) 1961 o 0x51: QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS. 1962 (Connection migration errors.Network changed, but connection had 1963 no migratable streams.) 1965 o 0x52: QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES. (Connection 1966 changed networks too many times.) 1968 o 0x53: QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK. (Connection 1969 migration was attempted, but there was no new network tomigrate 1970 to.) 1972 o 0x54: QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM. (Network 1973 changed, but connection had one or more non-migratable streams.) 1975 o 0x5d: QUIC_TOO_MANY_FRAME_GAPS. (Stream frames arrived too 1976 discontiguously so that stream sequencer buffermaintains too many 1977 gaps.) 1979 o 0x5f: QUIC_STREAM_SEQUENCER_INVALID_STATE. (Sequencer buffer get 1980 into weird state where continuing read/write will leadto crash.) 1982 o 0x60: QUIC_TOO_MANY_SESSIONS_ON_SERVER. (Connection closed 1983 because of server hits max number of sessions allowed. 1985 11. Security and Privacy Considerations 1987 11.1. Spoofed Ack Attack 1989 An attacker receives an STK from the server and then releases the IP 1990 address on which it received the STK. The attacked may in the 1991 future, spoof this same address (which now presumably addresses a 1992 different endpoint), and initiates a 0-RTT connection with a server 1993 on the victim's behalf. The attacker then spoofs ack packets to the 1994 server which cause the server to potentially drown the victim in 1995 data. 1997 There are two possible mitigations to this attack. The simplest one 1998 is that a server can unilaterally create a gap in packet-number 1999 space. In the non-attack scenario, the client will send an ack with 2000 a larger largest acked. In the attack scenario, the attacker may ack 2001 a packet in the gap. If the server sees an ack for a packet that was 2002 never sent, the connection can be aborted. 2004 The second mitigation is that the server can require that acks for 2005 sent packets match the encryption level of the sent packet. This 2006 mitigation is useful if the connection has an ephemeral forward- 2007 secure key that is generated and used for every new connection. If a 2008 packet sent is encrypted with a forward-secure key, then any acks 2009 that are received for them must also be forward-secure encrypted. 2010 Since the attacker will not have the forward secure key, the attacker 2011 will not be able to generate forward-secure encrypted ack packets. 2013 12. Contributors 2015 This protocol is the outcome of work by many engineers, not just the 2016 authors of this document. The design and rationale behind QUIC draw 2017 significantly from work by Jim Roskind [1]. In alphabetical order, 2018 the contributors to the project are: Britt Cyr, Jeremy Dorfman, Ryan 2019 Hamilton, Jana Iyengar, Fedor Kouranov, Charles Krasic, Jo Kulik, 2020 Adam Langley, Jim Roskind, Robbie Shade, Satyam Shekhar, Cherie Shi, 2021 Ian Swett, Raman Tenneti, Victor Vasiliev, Antonio Vicente, Patrik 2022 Westin, Alyssa Wilk, Dale Worley, Fan Yang, Dan Zhang, Daniel 2023 Ziegler. 2025 13. Acknowledgments 2027 Special thanks are due to the following for helping shape QUIC and 2028 its deployment: Chris Bentzel, Misha Efimov, Roberto Peon, Alistair 2029 Riddoch, Siddharth Vijayakrishnan, and Assar Westerlund. QUIC has 2030 also benefited immensely from discussions with folks in private 2031 conversations and public ones on the proto-quic@chromium.org mailing 2032 list. 2034 . 2036 14. References 2038 14.1. Normative References 2040 [RFC2119] Bradner, S., "Key Words for use in RFCs to Indicate 2041 Requirement Levels", March 1997. 2043 [draft-thomson-quic-tls] 2044 Thomson, M. and R. Hamilton, "Porting QUIC to TLS", March 2045 2016. 2047 [draft-iyengar-quic-loss-recovery] 2048 Iyengar, J. and I. Swett, "QUIC Loss Recovery and 2049 Congestion Control", July 2016. 2051 14.2. Informative References 2053 [RFC7540] Belshe, M., Peon, R., and M. Thomson, "Hypertext Transfer 2054 Protocol Version 2 (HTTP/2)", May 2015. 2056 [QUIC-CRYPTO] 2057 Langley, A. and W. Chang, "QUIC Crypto", June 2015, 2058 . 2060 14.3. URIs 2062 [1] https://goo.gl/dMVtFi 2064 Authors' Addresses 2066 Ryan Hamilton 2067 Google 2069 Email: rch@google.com 2071 Janardhan Iyengar 2072 Google 2074 Email: jri@google.com 2076 Ian Swett 2077 Google 2079 Email: ianswett@google.com 2081 Alyssa Wilk 2082 Google 2084 Email: alyssar@google.com