Skip to content

Commit

Permalink
Move stream ID fields to start of frames
Browse files Browse the repository at this point in the history
This also reorders the bits on the STREAM frame so that they appear in
the same order as the fields they affect.
  • Loading branch information
martinthomson committed Jun 13, 2017
1 parent 237dab0 commit dd48c42
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions draft-ietf-quic-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -1478,20 +1478,13 @@ subsequent sections.
## STREAM Frame {#frame-stream}

STREAM frames implicitly create a stream and carry stream data. The type byte
for a STREAM frame contains embedded flags, and is formatted as `11FDSSOO`.
for a STREAM frame contains embedded flags, and is formatted as `11FSSOOD`.
These bits are parsed as follows:

* The first two bits must be set to 11, indicating that this is a STREAM frame.

* `F` is the FIN bit, which is used for stream termination.

* The `D` bit indicates whether a Data Length field is present in the STREAM
header. When set to 0, this field indicates that the Stream Data field
extends to the end of the packet. When set to 1, this field indicates that
Data Length field contains the length (in bytes) of the Stream Data field.
The option to omit the length should only be used when the packet is a
"full-sized" packet, to avoid the risk of corruption via padding.

* The `SS` bits encode the length of the Stream ID header field.
The values 00, 01, 02, and 03 indicate lengths of 8, 16, 24, and 32 bits
long respectively.
Expand All @@ -1500,31 +1493,30 @@ These bits are parsed as follows:
The values 00, 01, 02, and 03 indicate lengths of 0, 16, 32, and
64 bits long respectively.

* The `D` bit indicates whether a Data Length field is present in the STREAM
header. When set to 0, this field indicates that the Stream Data field
extends to the end of the packet. When set to 1, this field indicates that
Data Length field contains the length (in bytes) of the Stream Data field.
The option to omit the length should only be used when the packet is a
"full-sized" packet, to avoid the risk of corruption via padding.

A STREAM frame is shown below.

~~~
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| [Data Length (16)] |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Stream ID (8/16/24/32) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Offset (0/16/32/64) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Stream Data (*) ...
| [Data Length (16)] | Stream Data (*) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
~~~
{: #stream-format title="STREAM Frame Format"}

The STREAM frame contains the following fields:

Data Length:

: An optional 16-bit unsigned number specifying the length of the Stream Data
field in this STREAM frame. This field is present when the `D` bit is set to
1.

Stream ID:

: The stream ID of the stream (see {{stream-id}}).
Expand All @@ -1541,6 +1533,12 @@ Stream Data:

: The bytes from the designated stream to be delivered.

Data Length:

: An optional 16-bit unsigned number specifying the length of the Stream Data
field in this STREAM frame. This field is present when the `D` bit is set to
1.

A STREAM frame MUST have either non-zero data length or the FIN bit set. When
the FIN flag is sent on an empty STREAM frame, the offset in the STREAM frame
MUST be one greater than the last data byte sent on this stream.
Expand Down Expand Up @@ -2002,10 +2000,10 @@ The RST_STREAM frame is as follows:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Error Code (32) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Stream ID (32) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Error Code (32) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ Final Offset (64) +
| |
Expand Down

0 comments on commit dd48c42

Please sign in to comment.