Uniqcli

TCP vs UDP: Which to Use and When

Reliable ordered delivery versus low-latency best-effort datagrams — how to match the transport protocol to the workload, and what each means for network security policy.

The TCP-versus-UDP question rarely comes up in the abstract. It surfaces when a monitoring rollout floods the network with SNMP and syslog traffic, when a unified-communications deployment has to carry voice and video without stutter, or when a security team writes firewall rules and finds that half the flows have no connection to track. Both are transport-layer protocols that ride on IP and use the same 16-bit port numbers, so at first glance they look interchangeable. They are not: they make opposite promises about whether your data is guaranteed to arrive, and that single difference drives almost every real decision an engineer or buyer makes about them.

The split comes down to one tradeoff. TCP establishes a connection with a three-way handshake, then guarantees that every byte arrives, in order, retransmitting anything lost and pacing itself to avoid congestion. That reliability costs a round trip up front, a larger header, and added latency whenever the network drops a packet. UDP does none of it — no handshake, no acknowledgments, no reordering, just an 8-byte header wrapped around your payload and sent best-effort. Where reliability is essential, TCP saves you from reinventing it; where latency or scale dominate, UDP gets out of the way and lets the application decide what to guarantee for itself.

At a glance

Side by side

FactorTCPUDP
Connection modelConnection-oriented; a three-way handshake sets up state before any data movesConnectionless; datagrams are sent with no setup or teardown
Delivery guaranteeReliable — acknowledgments, sequence numbers and automatic retransmission of lost dataBest-effort — no acknowledgment and no retransmission if a packet is dropped
OrderingBytes are reassembled in the order they were sentNone; datagrams may arrive out of order, duplicated, or not at all
Flow & congestion controlBuilt in — sliding window plus congestion control pace the senderNone built in; the application must manage pacing itself
Header overhead20-byte minimum header, up to 60 bytes with options8-byte fixed header
Data modelByte stream; message boundaries are not preservedMessage/datagram oriented; each send is one bounded message
Latency profileHandshake and retransmission add latency; one lost segment can stall later dataLower latency; no handshake and no retransmit stalls
Typical usesWeb (HTTP/HTTPS), SSH, email (SMTP/IMAP), file transferDNS, DHCP, NTP, SNMP, VoIP/RTP, live video, and QUIC (HTTP/3)

Choose TCP when

  • Every byte must arrive intact and in order — file transfers, database sessions, financial transactions, and email.
  • The application needs delivery guarantees it would otherwise have to reimplement itself over a raw datagram service.
  • You are running standard services such as HTTP/HTTPS, SSH, and SMTP that assume a reliable, connection-oriented transport.
  • Throughput and integrity matter more than shaving milliseconds, and occasional retransmission latency is acceptable.

Choose UDP when

  • Low latency outweighs perfect reliability — live voice, video conferencing, and real-time telemetry tolerate occasional loss.
  • The workload is small request/response traffic, like DNS lookups, DHCP, NTP, or SNMP polling.
  • You are broadcasting or multicasting to many receivers, where per-connection state would not scale.
  • The application implements its own reliability and congestion control on top, as QUIC and HTTP/3 do.

Bottom line

Neither protocol is better in the abstract — they trade the same axis in opposite directions. TCP spends a handshake, sequence numbers, and retransmission to guarantee an ordered, complete byte stream, which is why the web, SSH, and email default to it. UDP strips that machinery down to an 8-byte header and best-effort delivery, winning wherever latency, fan-out, or tiny request/response exchanges matter more than guaranteed arrival — DNS, DHCP, NTP, VoIP, and live video. Modern stacks blur the line, since QUIC and HTTP/3 run reliability over UDP in userspace. Match the protocol to what the endpoints actually need, then make sure firewall and segmentation rules account for both: stateful tracking for TCP, explicit port rules for UDP.

FAQ

Common questions

Is TCP more secure than UDP?
Neither protocol provides encryption or authentication on its own — security comes from a layer above, such as TLS over TCP or DTLS and QUIC over UDP. TCP's connection state does make some traffic easier to filter, and stateful firewalls track it automatically, but UDP's statelessness is a filtering consideration rather than an inherent weakness. Choose the transport for its delivery behavior, then secure it explicitly at a higher layer.
Why does DNS use UDP?
Most DNS queries and responses are small enough to fit in a single datagram, so the low overhead and no-handshake speed of UDP suit the request/response pattern of a lookup. When a response is too large or a zone transfer is needed, DNS falls back to TCP. Newer encrypted variants run DNS over TLS or over HTTPS, both TCP-based, so the picture is no longer UDP-only.
Does UDP mean my data will be lost?
Not necessarily — UDP simply does not guarantee delivery, ordering, or protection against duplicates. On a healthy local network, loss is often negligible, but the protocol makes no promise and adds no retransmission of its own. Applications that care build their own acknowledgment and recovery on top, which is exactly what QUIC does. If loss is unacceptable and you have no such layer, use TCP.
How do firewall and segmentation rules differ for TCP and UDP?
Stateful firewalls track TCP connections through the handshake and teardown, so return traffic is matched to an established session automatically. UDP has no connection state, so devices approximate it with short-lived pseudo-sessions or rely on explicit allow rules for specific ports such as 53, 123, or 161. When planning network segmentation, account for both models rather than assuming TCP-style tracking covers UDP flows.
Ask AI about Uniqcli

Wi-Fi 6 vs Wi-Fi 6E APs

Need help speccing the right hardware?

Send a bill of materials or your requirement — we confirm stock, TAA country of origin and a below-market total. No payment up front.