← All lessons
How QUIC and HTTP/3 work
One round trip, then zero
Phone
shop.test
quic-client.js
// first flight, inside a UDP datagramsend(initial({ clientHello, keyShare }));const hello = await receive(); // ServerHello, cert, Finishedconst keys = derive(hello.keyShare, myKey);send(oneRtt(keys, [finished, "GET /"])); // next visit: a saved ticket, so data goes in the first flightsend(initial({ clientHello, ticket }), zeroRtt(ticket.keys, "GET /"));tcp-client.js
await tcp.connect(); // 1 RTT: SYN, SYN-ACKawait tls.handshake(); // 1 more RTT with TLS 1.3send("GET /"); // the request leaves after 2 RTTLose one packet and see who has to wait
Packets in the order they were sent tap one to lose it
Each file is ready at
receiver.js
// HTTP/2 over TCP: one ordered byte stream for every filetcp.on("data", (bytes) => { for (const frame of h2.parse(bytes)) deliver(frame);}); // HTTP/3 over QUIC: each stream is ordered on its ownquic.on("stream", (stream) => { stream.on("data", (bytes) => deliver(stream.id, bytes));});Walk out of Wi-Fi the connection follows you
Next packet from the phone
from
lookup key
Server's connection table
QUIC still checks the new address with PATH_CHALLENGE before it sends much there
server.js
// TCP: a connection is its 4-tuplefunction onTcp(seg) { const key = `${seg.src} → ${seg.dst}`; const conn = conns.get(key); if (!conn) return sendReset(); // unknown key: reset} // QUIC: a connection is its connection IDfunction onQuic(packet) { const conn = conns.get(packet.dcid); if (packet.from !== conn.path) { sendPathChallenge(conn, packet.from); }}Topics
Next: How NAT works
Open lesson