The difference between TCP and UDP protocols

You may have seen TCP and UDP when setting up port forwarding on the router or when configuring the firewall software. These two protocols are used for different data types.

You may have seen TCP and UDP when setting up port forwarding on the router or when configuring the firewall software. These two protocols are used for different data types.

TCP / IP is a set of ports used by the device to communicate over the Internet and most local networks. It is named after its two original protocols - Transmission Control Protocol (TCP) and Internet Protocol (IP). TCP provides applications with a way to transfer (and receive) an ordered packet of information and check for errors over the network. User Datagram Protocol (UDP) is used by applications to transport a data stream faster by bypassing error checking. When configuring network hardware or software you will see the difference.

The similarities between the two protocols

TCP and UDP are both protocols used to send bits of data - called packets - over the Internet. Both protocols are built on the IP protocol. In other words, even if you send packets over TCP or UDP, this packet will be sent to an IP address. These packets are handled similarly because they are forwarded from your computer to the intermediate router and to the destination.

The difference between TCP and UDP protocols Picture 1The difference between TCP and UDP protocols Picture 1

TCP and UDP are not the only protocols that work on IP, however, they are most widely used.

How TCP works

TCP is the most commonly used protocol on the Internet. When you request a web page in the browser, the computer sends TCP packets to the web server's address, asking it to resend the site. The web server responded by sending a stream of TCP packets, which your web browser combined to form the web page. When you click on a link, log in, post a comment or do anything else, your web browser sends TCP packets to the server and the server sends the packets back to TCP.

The TCP protocol is highly reliable, packets sent by TCP will be monitored so data will not be lost or corrupted during transport. That is why the download file is not corrupted even if the network has a problem. Of course, if the recipient is completely offline, your computer will give up and you will see a write error message that it cannot communicate with the remote host.

The TCP protocol achieves this in two ways. First, it requests packets by numbering them. Second, it checks for errors by asking the recipient to send feedback received to the sender. If the sender does not receive the correct response, it can resend the packet to ensure the recipient receives them correctly.

Process Explorer and other system utilities can display the connection type that the process creates. Here we can see the Chrome browser with TCP connections open to many different web servers.

The difference between TCP and UDP protocols Picture 2The difference between TCP and UDP protocols Picture 2

How UDP works

The UDP protocol works similar to TCP, but it ignores the error checking process. When an application uses the UDP protocol, packets sent to the receiver and sender do not have to wait to ensure that the recipient has received the packet, so it continues to send the next packet. If the receiver misses some UDP packets, they lose because the sender does not send them back. Therefore the device can communicate faster.

UDP is used when speed is fast and error correction is not required. For example, UDP is often used for live broadcasts and online games.

Suppose, you are watching live video playback, usually played with UDP instead of TCP. The server sends a continuous stream of UDP packets to the computer being viewed. If you lose the connection for a few seconds, the video will be stopped or jerked for a moment and then switched to the current bit of the broadcast. If you only lose small packets, the video or audio may be distorted for a moment because the video will continue to play without missing data.

This works similarly in online games. If you miss some UDP packets, the player character can move on the map when you receive a new UDP packet. Ignoring TCP's error correction will help speed up game connection and reduce latency.

The difference between TCP and UDP protocols Picture 3The difference between TCP and UDP protocols Picture 3

The application uses TCP or UDP depending on its developer and what the application needs. Most applications need to fix errors and robustness of TCP. If you activate a network analysis tool like Wireshark, you can see the difference when packets are transported back and forth.

  1. Use Wireshark to analyze data packets in the network

The difference between TCP and UDP protocols Picture 4The difference between TCP and UDP protocols Picture 4

Unless you are a network administrator or software developer, this will not affect you too much. If you configure the firewall or router software, you should select the "Both" option so that the firewall or router software applies the same rules to both TCP and UDP traffic.

See more:

  1. How to check open ports in Linux
  2. Instructions to change Port value on router
  3. Check that the connection is being made in the system
4 ★ | 2 Vote