You’ve probably seen references to TCP and UDP when setting up port-forwarding on a router or when configuring firewall software. These two protocols are used for different types of data.
TCP/IP is a suite of protocols used by devices to communicate over the Internet and most local networks. It is named after two of it’s original protocols—the Transmission Control Protocol (TCP) and the Internet Protocol (IP). TCP provides apps a way to deliver (and receive) an ordered and error-checked stream of information packets over the network. The User Datagram Protocol (UDP) is used by apps to deliver a faster stream of information by doing away with error-checking. When configuring some network hardware or software, you may need to know the difference.
What They Have In Common
RELATED: How to Find Your Private and Public IP Addresses
Both TCP and UDP are protocols used for sending bits of data—known as packets—over the Internet. Both protocols build on top of the IP protocol. In other words, whether you’re sending a packet via TCP or UDP, that packet is sent to an IP address. These packets are treated similarly, as they’re forwarded from your computer to intermediary routers and on to the destination.
TCP and UDP aren’t the only protocols that work on top of IP. However, they are the most widely used.
How TCP Works
TCP is the most commonly used protocol on the Internet.
When you request a web page in your browser, your computer sends TCP packets to the web server’s address, asking it to send the web page back to you. The web server responds by sending a stream of TCP packets, which your web browser stitches together to form the web page. When you click a link, sign in, post a comment, or do anything else, your web browser sends TCP packets to the server and the server sends TCP packets back.
TCP is all about reliability—packets sent with TCP are tracked so no data is lost or corrupted in transit. This is why file downloads don’t become corrupted even if there are network hiccups. Of course, if the recipient is completely offline, your computer will give up and you’ll see an error message saying it can’t communicate with the remote host.
TCP achieves this in two ways. First, it orders packets by numbering them. Second, it error-checks by having the recipient send a response back to the sender saying that it has received the message. If the sender doesn’t get a correct response, it can resend the packets to ensure the recipient receives them correctly.
RELATED: Understanding Process Explorer
Process Explorer and other system utilities can show the type of connections a process makes—here we can see the Chrome browser with open TCP connections to a variety of web servers.
How UDP Works
RELATED: How Latency Can Make Even Fast Internet Connections Feel Slow
The UDP protocol works similarly to TCP, but it throws out all the error-checking stuff. All the back-and-forth communication introduce latency, slowing things down.
When an app uses UDP, packets are just sent to the recipient. The sender doesn’t wait to make sure the recipient received the packet—it just continues sending the next packets. If the recipient misses a few UDP packets here and there, they are just lost—the sender won’t resend them. Losing all this overhead means the devices can communicate more quickly.
UDP is used when speed is desirable and error correction isn’t necessary. For example, UDP is frequently used for live broadcasts and online games.
For example, let’s say you’re watching a live video stream, which are often broadcast using UDP instead of TCP. The server just sends a constant stream of UDP packets to computers watching. If you lose your connection for a few seconds, the video may freeze or get jumpy for a moment and then skip to the current bit of the broadcast. If you experience minor packet-loss, the video or audio may be distorted for a moment as the video continues to play without the missing data.
This works similarly in online games. If you miss some UDP packets, player characters may appear to teleport across the map as you receive the newer UDP packets. There’s no point in requesting the old packets if you missed them, as the game is continuing without you. All that matters is what’s happening right now on the game server—not what happened a few seconds ago. Ditching TCP’s error correction helps speed up the game connection and reduce latency.
RELATED: How to Use Wireshark to Capture, Filter and Inspect Packets
Whether an application uses TCP or UDP is up to its developer, and the choice depends on what an application needs. Most apps need the error-correction and robustness of TCP, but some applications need the speed and reduced overhead of UDP. If you fire up a network analysis tool like Wireshark, you can see the different types of packets traveling back and forth.
Unless you’re a network administrator or software developer, this shouldn’t doesn’t affect you too much. If you’re configuring your router or firewall software and you’re not sure whether an application uses TCP or UDP, you can generally select the “Both” option to have your router or firewall apply the same rule to both TCP and UDP traffic.
- › How to Port Forward on Your Router
- › How Quake Shook the World: Quake Turns 25
- › What Are Denial of Service and DDoS Attacks?
- › 22 Common Network Jargon Terms Explained
- › What Is the Best VPN Protocol? OpenVPN vs. WireGuard vs. SSTP and More
- › How to Get Started With firewalld on Linux
- › HTG Explains: What is Port Scanning?
- › Update iTunes on Windows Now to Fix a Security Flaw