Core Concepts

Understanding QUIC and HTTP/3 — the protocol stack that nhttp3 implements.

The Protocol Stack

LayerHTTP/2HTTP/3 (nhttp3)
ApplicationHTTP/2HTTP/3 (RFC 9114)
Header CompressionHPACKQPACK (RFC 9204)
TransportTCPQUIC (RFC 9000)
SecurityTLS 1.2/1.3TLS 1.3 only (RFC 9001)
NetworkTCP/IPUDP/IP

Why QUIC?

1-RTT Handshake

TCP requires a 3-way handshake, then TLS adds another round trip. QUIC combines both into a single round trip: the first packet contains both the connection setup and the TLS ClientHello.

No Head-of-Line Blocking

HTTP/2 multiplexes streams over one TCP connection. If a TCP packet is lost, all streams stall until that packet is retransmitted — even streams whose data wasn't in that packet. QUIC gives each stream its own flow control. A lost packet only affects the stream it belongs to.

Connection Migration

TCP connections are identified by (source IP, source port, dest IP, dest port). Change any of these (e.g., WiFi → cellular) and the connection breaks. QUIC uses Connection IDs instead — the connection survives network changes.

Key Types

VarInt

QUIC uses variable-length integers (1-8 bytes) for most numeric fields. The 2 MSBs encode the length. Max value: 2^62-1.

Connection ID

0-20 bytes identifying a connection. Endpoints can use multiple CIDs and rotate them for privacy.

Streams

Lightweight channels within a connection. Can be bidirectional (both sides send/receive) or unidirectional. Stream IDs encode who initiated (client=even, server=odd) and directionality.

Frames

The fundamental data unit inside QUIC packets. 21 frame types: STREAM (data), CRYPTO (TLS), ACK, flow control (MAX_DATA, MAX_STREAM_DATA), and more.