Opscraft
TCP vs UDP · Lesson 3 of 8 · 3 min read

UDP in depth

Properties

UDP (User Datagram Protocol) is minimal:

  • Connectionless — no handshake; just send.
  • No reliability — no ACKs, no retransmission; datagrams may be lost, duplicated or reordered.
  • Message-oriented — each send is one datagram, delivered whole or not at all (boundaries preserved).
  • No flow or congestion control — the application must be responsible.
  • 8-byte header: source port, destination port, length, checksum (detects corruption; the receiver silently drops bad datagrams).
  • Supports broadcast and multicast (TCP can't).

The unit is a datagram. A UDP datagram larger than the path MTU is fragmented at the IP layer — losing one fragment loses the whole datagram — so UDP protocols keep messages small (classic DNS: 512 bytes; EDNS0 ~1,232 bytes recommended).

Why choose UDP

"UDP is unreliable so it's bad" misses the point. UDP lets the application decide what reliability it needs:

  • Real-time media (VoIP, video calls, live streaming, gaming): a late packet is useless — retransmitting a 200 ms-old audio frame only adds delay. Better to skip it.
  • Simple request/response (DNS, NTP, DHCP, SNMP): one small query, one small answer — a TCP handshake would triple the cost; the client just retries on timeout.
  • High-volume telemetry (StatsD, some metrics/logging): occasional loss is acceptable and senders must never block.
  • Protocols that build their own reliability: QUIC, WireGuard and many game protocols implement exactly the features they need on top of UDP.

QUIC and HTTP/3

QUIC runs over UDP and reimplements transport features in user space:

  • Reliable, ordered streams — but loss on one stream doesn't block others (no TCP head-of-line blocking).
  • TLS 1.3 built in: the transport and crypto handshakes are combined — 1 RTT for a new connection, 0-RTT for resumption (vs TCP + TLS 1.2's 3 RTTs).
  • Connection migration — connections survive IP changes (phone moving from Wi-Fi to 4G) via connection IDs.
  • Encrypted headers make it harder for middleboxes to interfere (and to inspect).

HTTP/3 is HTTP over QUIC. CloudFront and many CDNs support it; clients fall back to HTTP/2 over TCP if UDP 443 is blocked.

Enlarge diagramTCP + TLS 1.2round trip 1round trip 2round trip 3TCP + TLS 1.3round trip 1round trip 2QUIC (HTTP/3)round trip 1QUIC resumed0-RTT: data goes with the first packetAt 150 ms per round trip, TCP + TLS 1.2 spends 450 ms before the request even leaves.
Figure 1. Round trips before the first request can be sent. QUIC combines transport and encryption setup, which matters most on slow mobile links.
Swipe sideways to see all of it, or tap to open it full screen.