TCP vs UDP
Compare the two main transport protocols and what each guarantees.
| Dimension | TCP | UDP | What it means in practice |
|---|---|---|---|
| Connection | Connection-oriented with a three-way handshake. | Connectionless; no handshake. | Firewalls track TCP state precisely; UDP state is timer-based. |
| Reliability | Retransmits lost segments and keeps order. | No retransmission or ordering. | Applications on UDP add their own reliability if needed (QUIC does). |
| Flow and congestion control | Window-based flow control and congestion control. | None in the protocol. | UDP floods can starve TCP traffic on a congested link. |
| Header size | 20 bytes minimum. | 8 bytes. | Small headers matter for voice and DNS. |
| Typical uses | HTTP/1.1–2, SSH, SMTP, database protocols. | DNS, DHCP, VoIP/RTP, syslog, QUIC/HTTP3. | DNS falls back to TCP for large responses and zone transfers. |
| Verification | ss -tan or show tcp brief; look for ESTABLISHED. | ss -uan; test with an application-level request. | A UDP port scan cannot prove a service is listening. |