Differences between TCP and UDP

TCP and UDP are two very different protocols.  I’ve spent a fair amount of time over the years explaining these two issues to our power engineers and technicians.  What better topic to post here.

TCP is more reliable but has more overhead.

Probably the most important thing to realize is only TCP has a true connection, where UDP simply streams packets.  TCP connections begin with a three-way handshake (SYN, SYN-ACK, ACK) which ensures that both ends of the connection are alive.  TCP also ensures that all packets are passed to the next layer in the proper order, and if any packets are missing they are resent.  UDP is a packet or stream of packets depending on the application.  The protocol itself does not care if the packets arrive out of order or at all.  TCP connections come with the additional overhead required for the reliability, making UDP seem like the ideal choice for low-bandwidth connections.

Before choosing protocols, consider the communications medium and purpose.  A remote ICS/IIoT device connected via a wireless or cellular connection should be configured to use TCP, whereas the same device connected to a leased line should utilize UDP.  My experience is that all cellular data connectivity including 4G experiences enough variation to cause problems for UDP-based devices, where TCP-based devices barely notice.  Additionally, I always recommend TCP unless you are bandwidth constrained on something like an old 56k digital circuit.

Voice, video or other data streams which can withstand missing and out-of-order packets should always be run over UDP for maximum quality.

TCP and UDP ports can exist at the same number

Since TCP and UDP are two different protocols, they are not mutually exclusive. UDP/443 is different that TCP/443. Take care when configuring ACL and NAT rules in your network, especially if the device does not differentiate between the two.

DNS is the most common example of this. UDP/53 is used for the vast majority of domain name lookups, while TCP/53 is used primarily for zone transfers between servers.  If you need to block zone transfers, then simply blocking TCP/53 might be enough (never tried myself).

Disagree with me or I missed something?  Please let me know with a comment!

Sources

Leave a Comment

Your email address will not be published. Required fields are marked *