Networking for Interviews/Transport Layer: TCP & UDP

UDP & When to Use It

Connectionless datagrams, no ordering or retransmission guarantees, checksums — and the real use cases: DNS, QUIC/HTTP/3, gaming, telemetry.

2/5Overview: 15m

What UDP gives you

UDP is connectionless: each datagram is independent, with a source port, destination port, length, and checksum. There is no handshake, no ordering guarantee, and no retransmission — if a packet is lost, the application must handle it (or not care).

When UDP is the right choice

Use caseWhy UDP
DNS queriesSingle request/response, low latency, loss is retried at app layer
QUIC / HTTP/3User-space transport with its own reliability on top of UDP
Real-time media / gamingStale data is worthless; prefer drop over delay
Metrics / logsOccasional loss acceptable at high volume

When TCP wins

Any byte stream where order and completeness matter: HTTP/1.1 and HTTP/2, database connections, RPC between services. TCP retransmits lost segments, buffers out-of-order data, and backs off under congestion.

Interview one-liner

"UDP trades reliability for latency and simplicity; TCP provides a reliable ordered byte stream at the cost of handshake overhead and head-of-line blocking within a connection."

Further Reading