Home/Labs/TCP vs UDP vs QUIC
All 280 Labs
INTERACTIVE LAB📡

TCP vs UDP Tradeoffs Lab (Interactive)

Stream identical media frames over TCP, UDP, and QUIC under a seeded loss pattern and compare stalls. Head-of-line blocking visualizer: reliability, ordering, and congestion control against zero-handshake datagram latency.

TCP vs UDP vs QUIC — Head-of-Line Blocking Under Loss

Stream the same 20 ms media frames over three transports on an identical loss pattern.

TCP (reliable stream)

Ordered, acknowledged byte stream with flow + congestion control. A lost segment holds every later segment in the receive buffer until retransmitted.

No frames sent yet

Result: 0/0 delivered on time, 0 stalled behind head-of-line blocking — ideal for HTTP/1.1, HTTP/2, databases, file transfer.

UDP (raw datagram)

8-byte header, zero handshake, no retransmission. A lost frame is simply skipped — the application interpolates (VP9/AV1 handle drops gracefully).

No frames sent yet

Result: 0/0 delivered with zero stalls — the freshness-over-reliability choice for VoIP, gaming, WebRTC.

QUIC / HTTP/3 (UDP + streams)

Independent streams multiplexed over UDP with built-in TLS 1.3. Loss on stream 1 only retransmits stream 1 — other streams keep flowing.

No frames sent yet

Result: 0 streams: per-stream gaps instead of whole-connection freezes; connection IDs survive WiFi→LTE migration.

Frames sent
0
TCP on-time delivery
100%
TCP frozen time
0 ms
UDP effective FPS
0

How It Works Under the Hood

TCP guarantees an ordered, acknowledged byte stream through sequence numbers, retransmission with exponential backoff, flow-control windows, and congestion algorithms — CUBIC reacting to loss by cutting the window, BBR modeling bottleneck bandwidth and RTT instead, which shines on lossy mobile and satellite links. Those guarantees become poison in real-time media: a 20ms audio frame retransmitted after 120ms is worthless, yet TCP freezes the entire stream waiting for it. UDP fires 8-byte-header datagrams with no state, letting apps skip stale frames. QUIC takes the middle path: independent multiplexed streams and built-in TLS 1.3 over UDP, eliminating cross-stream head-of-line blocking.

Core Architectural Principles

  • TCP retransmission stalls every later segment in the receive buffer (head-of-line blocking).
  • UDP drops are skipped — freshness beats completeness for VoIP, gaming, and live video.
  • QUIC streams are independent, negotiate TLS 1.3 in 1 RTT, and migrate via Connection ID across networks.
Interview Round Script

For live systems, contrast VoD versus video conferencing: Netflix downloads HLS chunks over TCP/HTTPS and buffers, while Zoom ships 20ms Opus frames over UDP/WebRTC and interpolates losses. Mention BBR for lossy last-mile users and QUIC for eliminating HOL blocking — precise protocol-to-workload mapping is what earns senior points.

Key Trade-Offs

TCP trades latency spikes under loss for guaranteed integrity; UDP trades correctness for immediacy; QUIC approximates both at CPU cost.

Related Curriculum Chapter

TCP vs UDP Tradeoffs

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs