Streams A, B and C share one HTTP/2 connection over TCP. A packet carrying part of stream A is lost. B's and C's next packets arrive 2 ms later. When does the browser get B's data?
Multiplexing is an HTTP/2 idea; TCP underneath sees one byte stream and hands bytes to the application only in order. B's bytes arrived on time and wait behind A's hole until the retransmission lands. Loss does not reset a TCP connection.
HTTP/2 runs many requests as streams over one TCP connection, interleaving their frames. That fixes HTTP/1.1’s queue of requests. It does not fix the layer below.
TCP gives the receiver one ordered byte stream. It has no idea that bytes 3000 to 4400 belong to stream A and the next ones to stream B. When a segment is lost, every later byte waits in the kernel’s receive buffer until the retransmission fills the hole. Your app sees nothing. That stall is head-of-line blocking. QUIC moves ordering into each stream, so a hole blocks only its own stream.
▶ SIMULATION
0 / 12
STREAM A
delivered 0 / 0 sent
held in buffer 0
worst wait after arrival: 0 ms
STREAM B
delivered 0 / 0 sent
held in buffer 0
worst wait after arrival: 0 ms
STREAM C
delivered 0 / 0 sent
held in buffer 0
worst wait after arrival: 0 ms
clock · RTTt = 0 ms · RTT 100 ms · ordering: one TCP byte stream
on the wire (send order)—
receive buffernothing owed
✓ streams that lost nothing are delivered the moment they arrive
SCHEDULE
01[RCV]receiver: one TCP byte stream, delivered in order
02[A]send A1 (stream A, frame 1 of 3)
03[B]send B1 (stream B, frame 1 of 3)
04[C]send C1 (stream C, frame 1 of 3)
05[A]send A2 (stream A, frame 2 of 3)
06[B]send B2 (stream B, frame 2 of 3)
07[C]send C2 (stream C, frame 2 of 3)
08[A]send A3 (stream A, frame 3 of 3)
09[B]send B3 (stream B, frame 3 of 3)
10[C]send C3 (stream C, frame 3 of 3)
11[NET]every segment that was not lost has arrived
12[NET]retransmissions arrive; the receiver drains
Start of http/2 over tcp, no loss scenario. 12 steps.
// TCP receiver: one sequence space for the whole connection.
// HTTP/2 frames for streams A, B, C are interleaved inside it.
while (buffer.has(nextSeq)) {
const seg = buffer.take(nextSeq);
app.deliver(seg); // in connection order only
nextSeq += seg.length;
}
// a hole at nextSeq stops B and C too
// QUIC receiver: each stream has its own offsets.
for (const frame of packet.streamFrames) {
const st = streams.get(frame.streamId);
st.buffer.put(frame.offset, frame.data);
while (st.buffer.has(st.nextOffset)) {
const d = st.buffer.take(st.nextOffset);
app.deliver(frame.streamId, d);
st.nextOffset += d.length;
}
}
// a hole in stream A stops only stream A
Watch the stream boxes at the step where every segment that was not lost has arrived. Over TCP, B and C have arrived and sit in the buffer; their worst wait turns red. With per-stream ordering only stream A waits, for its own retransmission.
BREAK ITNOT YET
Three streams share one TCP connection and nothing is lost. Inject one packet drop and pick where it lands so that a stream that lost nothing has to wait.
GOAL: a stream that lost nothing waits after its data arrived
FIX ITNOT YET
Write the receiver. packets arrive in time order as { stream, seq, off, at }: seq counts within the stream, off across the connection. Return every delivery to the app as { stream, seq, at }. With perStreamOrdering false, deliver in connection order (TCP). With it true, a packet must wait only for earlier packets of its own stream.
IN PRODUCTION
HTTP/2 on lossy mobile and Wi-Fi links, gRPC channels carrying many calls on one connection, and any protocol multiplexed over a single TCP or TLS session (SSH channels, database wire protocols with pipelining). HTTP/3 over QUIC is the production fix.
IN INTERVIEWS
“Does HTTP/2 solve head-of-line blocking?” Say it fixes it at the HTTP layer and moves it into TCP; one lost segment stalls every stream for about an RTT. Then explain how QUIC carries stream offsets so a loss blocks only its own stream, and note that HTTP/1.1 with several connections can win on very lossy links.
RECALL CARDSTap to flip. They join your review deck when you mark the lesson complete.