4.3.25 · D1Computer Networks

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

3,689 words17 min readBack to topic

This page builds every word, number, and symbol the parent note leans on — starting from "what is a byte" and ending at "what does mean here". If the parent note said it without explaining it, we explain it here.


1. Bit, byte, and why we count in powers of two

Before any protocol, there is the smallest thing a computer stores: a bit — a single switch that is either or . Eight bits in a row make one byte.

WHY the topic needs this: every "frame header is 9 bytes", every "24-bit Length", every "one byte for a whole header" in the parent note is literally counting these bulbs. If you can't see the bulbs, those numbers are meaningless.

Figure s01 — what it shows: eight bulbs make one byte. The pattern 0110 1010 is drawn with lit bulbs = ; each column is labelled with its place-value . Adding the lit place-values () shows how a row of bulbs becomes a number. Read the caption bulb by bulb before moving on.

Figure — HTTP - 2 — multiplexing, header compression (HPACK), server push
  • , so 7 bits hold to .
  • , so 8 bits hold to (that's patterns, but the biggest single number is ).
  • — this is the parent's "default max frame size" (the count of possible values; the largest is ).
  • is the number of patterns a 24-bit Length field has, so it names the values to — the largest single Length is , not .
  • ≈ 2.1 billion — the number of Stream IDs (we'll meet these below).
Recall Why is the max value

and not ? Because we include as a valid pattern ::: with bits you get patterns numbered , so the largest single number is .


2. Text vs binary — what "binary framing" actually means

HTTP/1.1 is a text protocol: it literally sends the letters G, E, T, a space, then the path — human-readable when printed. HTTP/2 is a binary protocol: it sends raw numbers in fixed slots, not spelled-out words.

WHY hex here: the wire is bytes, and one byte = two hex digits reads far cleaner than eight bits. Every "" below is just a byte written in this shorthand.

WHY the topic needs this: the parent's whole "Text → binary framing" line rests on this distinction. Binary lets HTTP/2 pack a whole header line into one byte (Section 4 of the parent) — impossible with spelled-out text. And without a fixed byte order, two machines would read the same Length or Stream ID as two different numbers, so every field diagram below assumes big-endian, most-significant-byte-first.


3. Powers, exponents, and the notation , ,

The parent's HPACK section uses three bits of math notation without defining them. Here they are.

WHY the topic needs this: the parent's prefix-integer trick emits (I' mod 128) + 128 and updates I' ← floor(I'/128). That is exactly "leftover eggs into a 7-bit carton, then count the full cartons," repeated until nothing is left. We verify the parent's example below.

Figure s02 — what it shows: the three output bytes for as coloured boxes, left to right: the prefix 31 (blue, "full, I overflowed"), then 154 (orange, 26 + 128, its continuation flag on), then 10 (green, last byte). Arrows carry the working value from box to box, and the bottom line reproduces the arithmetic . Trace the arrows to see shrinking.

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

4. Stream ID, odd/even, and the label idea

A Stream ID is just a whole number written into 31 bits of the frame header. It is the label that says "this chunk belongs to conversation number 3."

WHY the topic needs this: multiplexing (parent §3) reassembles interleaved chunks by this label. Server push (parent §5) reserves an even ID so a pushed resource can't clash with a client request. And the parent's SETTINGS frame has to live somewhere — it lives on stream , the connection-wide channel. The 31-bit size gives possible labels — plenty.


5. The frame — one labeled chunk

Now we can read the parent's frame formula symbol-by-symbol. A frame is a fixed 9-byte header followed by a payload.

Figure s03 — what it shows: the 9-byte header drawn as a single left-to-right strip, each field a coloured box whose width is proportional to its bit-count (Length widest at 24, Stream ID next at 31, R a sliver at 1). Labels under each box give the bit-count; call-out arrows mark "no more than by default" on Length and "odd = client, even = server push, 0 = connection" on Stream ID. The strip is the byte layout you'd see on the wire.

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

WHY the topic needs this: every higher idea is a stream of these frames. A message (request or response) = one HEADERS frame + zero or more DATA frames sharing one Stream ID. Multiplexing = interleaving frames of different Stream IDs on one connection.


6. The layers under HTTP/2 — TCP, TLS, and RTT

HTTP/2 does not touch the wire directly; it rides on top of two lower layers the parent assumes you know.

WHY the topic needs this:

  • The parent's "one handshake vs six" is a claim about TCP+TLS RTTs: vs that.
  • The famous "TCP-level head-of-line blocking still exists" mistake is because TCP insists on in-order bytes — one lost packet stalls every stream. That's why HTTP-3-and-QUIC switches transports.
Recall Why can multiplexing remove application HOL blocking but not transport HOL blocking?

Streams are independent at the HTTP layer, but they all share one TCP byte-stream ::: TCP delivers bytes strictly in order, so one lost packet forces every stream to wait for the retransmission — a transport-level stall HTTP/2 can't dodge.


7. Compression prerequisites — Huffman, varint, and the CRIME idea

HPACK (parent §4) stitches together three ideas that each have their own vault note. None is new machinery invented for HTTP/2 — HPACK just combines them, so meeting each one now makes the parent's §4 read as assembly rather than magic.

Figure s04 — what it shows: one header field entering HPACK and taking one of two forks. Fork A (green, "already known") → a varint index number → tiny output. Fork B (orange, "new literal") → Huffman-coded characters → small output. A red guard box labelled "fixed table, no adaptive mixing" sits across both forks with the caption "blocks CRIME length-leak." Follow whichever fork applies to see which tool does the shrinking.

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

WHY the topic needs this: without Huffman you can't explain "literal header encoded in fewer bits"; without varint you can't read the index bytes; without the CRIME idea you can't explain why the parent insists "HPACK is not just gzip."


8. How it all feeds the topic

The map below reads top-to-bottom: an arrow means "you need before makes sense." The bottom node "HTTP 2 topic" is the parent note; every other node is a foundation built on this page. Follow any path down and you retrace the order we taught these ideas.

  • Left branch (blue foundations): bit/bytepowers of twoStream ID and frame headermultiplexing.
  • Transport branch: TCP in-order bytes feeds both multiplexing and the TCP HOL blocking caveat.
  • Right branch (compression): Huffman, varint prefix int, and the CRIME idea all feed HPACK.
  • Push branch: even Stream ID feeds server push.

bit and byte

powers of two 2 to the N

Stream ID 31 bits

frame header 9 bytes

text vs binary and endianness

multiplexing

TCP in-order bytes

TCP HOL blocking

Huffman coding

HPACK

varint prefix int

CRIME attack idea

even Stream ID

server push

HTTP 2 topic


Equipment checklist

Test yourself — say the answer before revealing it.

How many distinct patterns can bits show?
(numbers to ), where is a nonnegative whole number.
What is the biggest single number a 24-bit Length field can name?
(there are patterns, but the largest value is one less).
What is , and where does it appear in HTTP/2?
— the default maximum frame payload size.
What is the difference between a text protocol and a binary protocol?
Text carries meaning in readable characters and separators; binary carries meaning in fixed byte positions and lengths.
What does the prefix mean, and how many hex digits are in one byte?
It marks a hexadecimal (base-16) number; one byte = two hex digits.
In what byte order do HTTP/2 multi-byte fields appear on the wire?
Network byte order = big-endian, most significant byte first.
What does compute?
The remainder after dividing by (a value from to ).
What does mean?
Round down to the nearest whole number.
In the prefix-integer algorithm, what is and what is its initial value?
The overflow part of that didn't fit the prefix; it starts at .
Why do varint continuation bytes carry only 7 bits of value?
The top bit of each byte is a continuation flag (1 = more bytes follow, 0 = last), leaving 7 bits for value.
What is a Stream ID and how many bits is it?
A number labeling which stream a frame belongs to; 31 bits (the top bit is Reserved).
Which parity of Stream ID does the client use, and which does server push use?
Client uses odd IDs, server push uses even IDs — so they never collide.
What is Stream ID 0 used for?
It is reserved for connection-level frames like SETTINGS, PING, WINDOW_UPDATE, and GOAWAY.
Name the five fields of the 9-byte frame header.
Length (24), Type (8), Flags (8), R (1), Stream ID (31).
Which two lower layers does HTTP/2 ride on, and what does each guarantee?
TCP (reliable in-order bytes) and TLS (encryption/privacy).
Why does TCP still cause head-of-line blocking under HTTP/2?
TCP delivers bytes strictly in order, so one lost packet stalls all streams until retransmission.
Which three prior ideas combine to make HPACK, and what job does each do?
Varint (shrinks index numbers), Huffman (shrinks literal text), and CRIME-awareness (dictates the fixed non-adaptive design).

Return to parent: HTTP/2 topic note · Prev generation: HTTP-1.1 · Next: HTTP-3-and-QUIC.