From 5c3a6c1d8ae7a0e03c8bbf6c4b71ff51c6532c57 Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 30 May 2018 12:49:25 +1000 Subject: [PATCH 1/4] Seek more clarify on Largest Reference/Base Index encoding --- draft-ietf-quic-qpack.md | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/draft-ietf-quic-qpack.md b/draft-ietf-quic-qpack.md index 53210d4081..22f5c84594 100644 --- a/draft-ietf-quic-qpack.md +++ b/draft-ietf-quic-qpack.md @@ -550,18 +550,36 @@ the block. Blocking decoders use the Largest Reference to determine when it is safe to process the rest of the block. `Base Index` is used to resolve references in the dynamic table as described in -{{indexing}}. To save space, Base Index is encoded relative to Largest -Reference using a one-bit sign flag. +{{indexing}}. - baseIndex = largestReference + deltaBaseIndex +To save space, Base Index is encoded as a relative to the Base Index using a +one-bit sign and the `Delta Base Index` value. A sign bit set to 0 indicates +that the Base Index has a greater absolute index than the Largest Reference; the +value of Delta Base Index is added to the Largest Reference to determine the +absolute value of the Base Index. A sign bit of 1 indicates that the Base Index +is smaller than the Base Index. -If the encoder inserted entries to the table while the encoding the block, -Largest Reference will be greater than Base Index, so deltaBaseIndex will be -negative and encoded with S=1. If the block did not reference the most recent -entry in the table and did not insert any new entries, Largest Reference will be -less than Base Index, so deltaBaseIndex will be positive and encoded with S=0. -When Largest Reference and Base Index are equal, deltaBaseIndex is 0 and encoded -with S=0. +That is, after turning a sign bit of 1 to -1 and 0 to 1, the absolute Base Index +is: + +~~~ + baseIndex = largestReference + sign * deltaBaseIndex +~~~ + +If the encoder inserted entries to the table while the encoding the header +block, Largest Reference will be greater than Base Index, so the encoded +difference is negative and the sign bit will be 1. If the header block did not +reference the most recent entry in the table and did not insert any new entries, +Base Index will be greater than the Largest Reference, so the delta will be +positive and the sign bit will be 0. + +When Largest Reference and Base Index are equal, the Delta Base Index is encoded +with a zero sign bit. A sign bit set to 1 when the Delta Base Index is 0 MUST +be treated as a decoder error. + +A header block that does not reference the dynamic table can use any value for +Base Index and Largest Reference; sending zero values for both fields is the +most efficient. ### Instructions @@ -697,7 +715,7 @@ represented as an 8-bit prefix string literal. # Encoding Strategies -## Single pass encoding +## Single Pass Encoding An encoder making a single pass over a list of headers must choose Base Index before knowing Largest Reference. When trying to reference a header inserted to From 43df5c3c5e8e895c3b660ec84a70b5b0600b63bb Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Thu, 31 May 2018 13:48:55 +1000 Subject: [PATCH 2/4] Tweaks from review --- draft-ietf-quic-qpack.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/draft-ietf-quic-qpack.md b/draft-ietf-quic-qpack.md index 22f5c84594..120909abc1 100644 --- a/draft-ietf-quic-qpack.md +++ b/draft-ietf-quic-qpack.md @@ -552,9 +552,9 @@ safe to process the rest of the block. `Base Index` is used to resolve references in the dynamic table as described in {{indexing}}. -To save space, Base Index is encoded as a relative to the Base Index using a -one-bit sign and the `Delta Base Index` value. A sign bit set to 0 indicates -that the Base Index has a greater absolute index than the Largest Reference; the +To save space, Base Index is encoded relative to Largest Reference using a +one-bit sign and the `Delta Base Index` value. A sign bit of 0 indicates that +the Base Index has a greater absolute index than the Largest Reference; the value of Delta Base Index is added to the Largest Reference to determine the absolute value of the Base Index. A sign bit of 1 indicates that the Base Index is smaller than the Base Index. @@ -563,23 +563,24 @@ That is, after turning a sign bit of 1 to -1 and 0 to 1, the absolute Base Index is: ~~~ - baseIndex = largestReference + sign * deltaBaseIndex + baseIndex = largestReference + (sign * deltaBaseIndex) ~~~ -If the encoder inserted entries to the table while the encoding the header -block, Largest Reference will be greater than Base Index, so the encoded -difference is negative and the sign bit will be 1. If the header block did not -reference the most recent entry in the table and did not insert any new entries, -Base Index will be greater than the Largest Reference, so the delta will be -positive and the sign bit will be 0. +An encoder is expected to determine the absolute value of Base Index before +encoding a header block. If the encoder inserted entries in the dynamic table +while encoding the header block, Largest Reference will be greater than Base +Index, so the encoded difference is negative and the sign bit will be 1. If the +header block did not reference the most recent entry in the table and did not +insert any new entries, Base Index will be greater than the Largest Reference, +so the delta will be positive and the sign bit will be 0. When Largest Reference and Base Index are equal, the Delta Base Index is encoded with a zero sign bit. A sign bit set to 1 when the Delta Base Index is 0 MUST be treated as a decoder error. A header block that does not reference the dynamic table can use any value for -Base Index and Largest Reference; sending zero values for both fields is the -most efficient. +Base Index; setting both Largest Reference and Base Index to zero is the most +efficient encoding. ### Instructions From fcd33ba69d4a265dcf9a23850fbdb2317171a8fe Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Fri, 1 Jun 2018 11:21:05 +1000 Subject: [PATCH 3/4] Alan's comments --- draft-ietf-quic-qpack.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/draft-ietf-quic-qpack.md b/draft-ietf-quic-qpack.md index 120909abc1..e2753f305d 100644 --- a/draft-ietf-quic-qpack.md +++ b/draft-ietf-quic-qpack.md @@ -557,26 +557,28 @@ one-bit sign and the `Delta Base Index` value. A sign bit of 0 indicates that the Base Index has a greater absolute index than the Largest Reference; the value of Delta Base Index is added to the Largest Reference to determine the absolute value of the Base Index. A sign bit of 1 indicates that the Base Index -is smaller than the Base Index. - -That is, after turning a sign bit of 1 to -1 and 0 to 1, the absolute Base Index -is: +is smaller than the Base Index. That is: ~~~ - baseIndex = largestReference + (sign * deltaBaseIndex) + if sign == 0: + baseIndex = largestReference + deltaBaseIndex + else: + baseIndex = largestReference - deltaBaseIndex ~~~ -An encoder is expected to determine the absolute value of Base Index before -encoding a header block. If the encoder inserted entries in the dynamic table -while encoding the header block, Largest Reference will be greater than Base -Index, so the encoded difference is negative and the sign bit will be 1. If the -header block did not reference the most recent entry in the table and did not -insert any new entries, Base Index will be greater than the Largest Reference, -so the delta will be positive and the sign bit will be 0. - -When Largest Reference and Base Index are equal, the Delta Base Index is encoded -with a zero sign bit. A sign bit set to 1 when the Delta Base Index is 0 MUST -be treated as a decoder error. +A single-pass encoder is expected to determine the absolute value of Base Index +before encoding a header block. If the encoder inserted entries in the dynamic +table while encoding the header block, Largest Reference will be greater than +Base Index, so the encoded difference is negative and the sign bit is set to 1. +If the header block did not reference the most recent entry in the table and did +not insert any new entries, Base Index will be greater than the Largest +Reference, so the delta will be positive and the sign bit is set to 0. + +An encoder that produces table updates before encoding a header block might set +Largest Reference and Base Index to the same value. When Largest Reference and +Base Index are equal, the Delta Base Index is encoded with a zero sign bit. A +sign bit set to 1 when the Delta Base Index is 0 MUST be treated as a decoder +error. A header block that does not reference the dynamic table can use any value for Base Index; setting both Largest Reference and Base Index to zero is the most From dae9232c00701b824005df6c9df433504ccae585 Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Sat, 2 Jun 2018 09:46:58 +1000 Subject: [PATCH 4/4] Include equal to, can't be less than itself --- draft-ietf-quic-qpack.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/draft-ietf-quic-qpack.md b/draft-ietf-quic-qpack.md index e2753f305d..586686ace0 100644 --- a/draft-ietf-quic-qpack.md +++ b/draft-ietf-quic-qpack.md @@ -554,10 +554,10 @@ safe to process the rest of the block. To save space, Base Index is encoded relative to Largest Reference using a one-bit sign and the `Delta Base Index` value. A sign bit of 0 indicates that -the Base Index has a greater absolute index than the Largest Reference; the -value of Delta Base Index is added to the Largest Reference to determine the -absolute value of the Base Index. A sign bit of 1 indicates that the Base Index -is smaller than the Base Index. That is: +the Base Index has an absolute index that is greater than or equal to the +Largest Reference; the value of Delta Base Index is added to the Largest +Reference to determine the absolute value of the Base Index. A sign bit of 1 +indicates that the Base Index is less than the Largest Reference. That is: ~~~ if sign == 0: