Command Palette

Search for a command to run...

Hectal
PHASE 2Intermediate ~7 min· topic 4 of 4

Topic 2.4

UDP, and QUIC Built on Top of It

In one line

UDP sends independent datagrams with no connection, ordering, or retransmission; it's the right choice when speed matters more than perfection, and it's the foundation of QUIC and HTTP/3.

0/4 · 0%

Think of it like this

TCP is a registered courier with signatures and tracking; UDP is dropping postcards in a postbox. Postcards are cheaper and faster, but some might get lost and they may arrive out of order.

Key ideas

  1. 01

    UDP has an 8-byte header (ports, length, checksum) and nothing else: no handshake, no ACKs, no retransmission, no congestion control. The application gets exactly what arrives, and nothing more.

  2. 02

    Where UDP fits: DNS queries (one small request, one small response; retrying is cheaper than a handshake), real-time audio and video (a late packet is useless anyway), gaming, metrics shipping (StatsD), and VPN and overlay tunnels (WireGuard, VXLAN).

  3. 03

    QUIC (the transport under HTTP/3) runs on UDP and rebuilds reliability, congestion control, and encryption in user space: TLS 1.3 is built in (1-RTT, or 0-RTT resumption), there are independent streams (so one lost packet only delays its own stream, with no head-of-line blocking), and connections survive network changes like Wi-Fi to mobile (connection IDs instead of the 5-tuple).

  4. 04

    Operational gotchas: firewalls and security groups need UDP rules separately (UDP 443 for HTTP/3, UDP 53 for DNS); UDP load balancing needs L4 balancers that support it (AWS NLB); and because UDP is connectionless, 'is it working?' checks must be application-level.

Code & diagrams

udp.shbash
dig @1.1.1.1 example.com            # a DNS query: one UDP packet out, one back
nc -u -l 9999 &                    # listen on UDP 9999
echo "hello" | nc -u -w1 127.0.0.1 9999
curl -sI --http3 https://cloudflare.com | head -1   # HTTP/3 over QUIC (needs curl built with HTTP/3)

Explain it without notes

01

Why does DNS use UDP by default, and when does it switch to TCP?

Practice

01

You enable HTTP/3 on your CDN but see no HTTP/3 traffic from your office. What network-level cause would you check first?

Trade-offs

  • ↔

    UDP gives control and low latency but pushes reliability, ordering, and congestion responsibilities onto the application (or a library like QUIC). Most applications should use TCP or QUIC rather than raw UDP.

Done when you can

  • I can explain what UDP does not provide compared to TCP.

  • I know which common protocols use UDP and why.

  • I understand how QUIC fixes TCP's head-of-line blocking.