4.3.25 · D3Computer Networks

Worked examples — HTTP - 2 — multiplexing, header compression (HPACK), server push

4,437 words20 min readBack to topic

Every symbol we use is built from zero. A byte = 8 bits. A bit is a single 0 or 1. When we write 0b01010 the 0b just means "read the following as binary digits". That is all the notation you need to start.


What a "prefix integer" actually is (build this before any example)


The scenario matrix

Every case class this topic can throw at you, and which worked example covers it:

Cell Case class Covered by
A Prefix integer — small value, fits in the prefix Example 1
B Prefix integer — value overflows into continuation bytes Example 2
C Boundary value (the "off by one" trap) Example 3
D Zero / degenerate input (, empty header) Example 4
E HPACK byte-savings count over repeated requests Example 5
F Stream ID assignment — odd vs even, ordering Example 6
G Multiplexing interleave + TCP HOL limiting case Example 7
H Server push cache-hit vs wasted-push (real-world) Example 8
I Exam twist — decode raw bytes back to a number Example 9
J Invalid / limiting — negative or over-long integer See [!mistake] above

Example 1 — Cell A: prefix integer that fits


Example 2 — Cell B: prefix integer that overflows


Example 3 — Cell C: the boundary value


Example 4 — Cell D: zero and degenerate inputs


Example 5 — Cell E: counting HPACK's byte savings (with real overhead)


Example 6 — Cell F: stream ID assignment


Example 7 — Cell G: multiplexing interleave and the TCP-HOL limit

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push

Example 8 — Cell H: real-world server push, hit vs waste


Example 9 — Cell I: exam twist, decode raw bytes


Recall Self-test — cover the answers

What structurally is a "5-bit prefix"? ::: The low 5 bits of a byte hold (the start of) the integer; the top 3 bits are flag bits set by the representation type. How many flag bits and prefix bits does the "literal with incremental indexing" (01) representation use? ::: 2 flag bits (01) on top, a 6-bit prefix for the name index. What is for a 5-bit prefix, and why is that value special? ::: ; it is the reserved overflow marker, so any (including itself) must use continuation bytes. Encode in a 5-bit prefix (show the full byte). ::: One byte 000 01010. Encode in a 5-bit prefix. ::: Two bytes: 31, 0. Decode bytes 31, 154, 10 (5-bit prefix). ::: . Can be negative? ::: No — HPACK integers are non-negative only; there is no sign bit, and over-long continuation runs are rejected as errors. Which Stream IDs does a client use, and which does server push use? ::: Client = odd (1,3,5,…); server push = even (2,4,…); 0 = connection-level. Does HTTP/2 multiplexing remove TCP-level head-of-line blocking? ::: No — only application-layer HOL. A lost TCP segment still stalls all streams; QUIC fixes this. When does server push hurt? ::: When it pushes an already-cached resource, wasting bytes and stealing congestion-window capacity from the real HTML.


See also: Huffman-Coding (how HPACK compresses literal strings), Varint-encoding (the 7-bit continuation trick), CRIME-and-BREACH-attacks (why HPACK avoids naive gzip), TLS and TCP (the handshake and ordering costs), HTTP-3-and-QUIC (the transport-HOL fix).