TCP vs UDP: Understanding the Basics of These Two Transport Protocols

When you browse a website, stream a video, or play an online game, data is constantly moving between devices. But this data doesn’t just travel randomly, it follows rules, or “protocols,” to make sure it reaches the right place in the right way. Two of the most common protocols that make this possible are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).
If you’re new to networking, these might sound like complicated technical terms, but they’re easier to understand than you think. Both TCP and UDP live in the Transport Layer of the OSI model, and each plays a different role in how data is sent and received.
Before we break down what makes TCP and UDP different, let’s take a quick look at what the Transport Layer actually does. Understanding its role will make it much easier to see why these two protocols exist and when to use each one.
Functions of the Transport Layer (Layer 4)
The Transport Layer is like a delivery manager for data. It takes information from the application you’re using (like a web browser or a chat app), breaks it into smaller chunks, and sends it to the right destination. On the receiving end, it puts the chunks back together in the correct order so you can view the complete message, file, or video.
Some of its key functions include:
Segmentation and reassembly: Splitting data into smaller segments before sending and reassembling them at the destination.
Error checking: Making sure data isn’t corrupted during transmission.
Flow control: Preventing one device from sending too much data too quickly for the other to handle.
Port addressing: Using port numbers to make sure data goes to the correct application on a device.
Port Numbers in the Transport Layer
Ports are like numbered doors in a building, they tell the Transport Layer exactly where to deliver data once it reaches the right computer. Without ports, your email, web browsing, and video streaming would all get mixed up.
Port numbers are managed by IANA (Internet Assigned Numbers Authority) and are divided into three main ranges:
Well-Known Ports (0–1023): Reserved for common services and applications.
- Example: HTTP uses port 80, HTTPS uses port 443, and FTP uses ports 20 and 21.
Registered Ports (1024–49151): Used by applications that aren’t as universal as the well-known ones but still registered with IANA.
- Example: Microsoft SQL Server uses port 1433, and Minecraft servers use port 25565.
Dynamic or Ephemeral Ports (49152–65535): Temporary ports chosen automatically by a device when a client starts a connection.
- Example: When you connect to a website, your computer picks a random ephemeral port to talk to the server.
With this in mind, TCP and UDP use these ports to make sure data gets to the right application whether it’s a web page, a video call, or an online game.
TCP: Transmission Control Protocol
TCP is like a careful and reliable courier service. Its main goal is to make sure your data arrives complete, in order, and without errors. If any data gets lost or damaged along the way, TCP will notice and request it again before delivering it to the application.
It works in a connection-oriented way. This means that before sending data, TCP sets up a connection between the sender and receiver through a process called the three-way handshake:
SYN: The sender asks to start a connection.
SYN-ACK: The receiver agrees and sends back a response.
ACK: The sender confirms, and now they can start sending data.
Because of this process and the extra checks along the way, TCP is great for activities where accuracy matters, like loading web pages, downloading files, or sending emails.
TCP Headers
Every TCP segment (chunk of data) has a header; extra information that tells the receiving device how to handle the data. Think of it as the address label and instructions on a package.
Key fields in a TCP header include:
Source Port & Destination Port: Indicate where the data is coming from and where it’s going.
Sequence Number: Tells the receiver the order of the data segments so they can be reassembled correctly.
Acknowledgment Number: Confirms which segments have been received.
Data Offset: Specifies the length of the TCP header.
Flags: Control how the connection is managed. Examples include:
SYN (start connection)
ACK (acknowledge received data)
FIN (end connection)
Window Size: Controls how much data can be sent before needing an acknowledgment.
Checksum: Checks for errors in the segment.
Urgent Pointer: Marks urgent data that needs to be processed right away.
With TCP, the focus is always on making sure the data is correct and in the right order before passing it along to the application.
But not every situation needs this careful, step-by-step process. Sometimes speed matters more than perfection and that’s where UDP comes in.
UDP: User Datagram Protocol
Unlike TCP, UDP is like sending a quick text message without waiting for a reply. It’s connectionless, meaning it doesn’t set up a handshake before sending data, and it doesn’t double-check if the data arrives in the correct order or at all.
This makes UDP much faster than TCP because there’s no extra process of establishing a connection or verifying every packet. It simply sends the data and moves on. While that means it’s less reliable, it’s perfect for situations where speed is more important than accuracy, such as:
Live video or audio streaming
Online gaming
Voice over IP (VoIP) calls
If a packet is lost, UDP doesn’t stop to resend it, which keeps things moving smoothly without delays.
UDP Headers
UDP headers are much simpler than TCP headers. They only have four fields:
Source Port: The sending application’s port number.
Destination Port: The receiving application’s port number.
Length: The total size of the UDP header and data.
Checksum: Used to check for errors in the data (optional in IPv4, required in IPv6).
Because the header is so small and simple, UDP adds very little overhead, which is one of the reasons it’s faster.
Feature | TCP (Transmission Control Protocol) | UDP (User Datagram Protocol) |
Connection Type | Connection-oriented (requires handshake before sending data) | Connectionless (no handshake) |
Reliability | Reliable – checks for errors, resends lost data, and ensures correct order | Unreliable – no error checks or resending of lost data |
Speed | Slower due to extra steps for accuracy | Faster because there’s no extra verification |
Header Size | Larger (20 bytes minimum) | Smaller (8 bytes) |
Data Order | Guarantees correct sequence of data | No guarantee of order |
Overhead | Higher due to error checking and connection management | Lower because it sends data without extra processes |
Best For | Web browsing, emails, file downloads, online banking | Streaming, online gaming, live video/audio calls |
Example Ports | HTTP (80), HTTPS (443), FTP (20, 21) | DNS (53), DHCP (67, 68), VoIP |
From Protocols to Ports
Now that you know how TCP and UDP work, let’s connect the dots to port numbers. Remember, ports act like numbered doors in a device, helping the Transport Layer deliver data to the correct application.
Some ports are specifically assigned to popular services, and knowing them can make networking tasks much easier. These are called well-known ports, and they’re used across the internet so devices can recognize services instantly.
Here are some of the most common TCP and UDP ports and their corresponding services:
Port Number | Protocol | Service Name |
20, 21 | TCP | File Transfer Protocol (FTP) |
22 | TCP | Secure Shell (SSH) |
23 | TCP | Telnet |
25 | TCP | Simple Mail Transfer Protocol (SMTP) |
53 | TCP/UDP | Domain Name System (DNS) |
67, 68 | UDP | Dynamic Host Configuration Protocol (DHCP) |
80 | TCP | Hypertext Transfer Protocol (HTTP) |
110 | TCP | Post Office Protocol v3 (POP3) |
143 | TCP | Internet Message Access Protocol (IMAP) |
443 | TCP | HTTP Secure (HTTPS) |
3389 | TCP | Remote Desktop Protocol (RDP) |
These are just a few, but they’re among the most commonly encountered when working with networks. Being familiar with them will help you quickly recognize what kind of traffic is moving through a network.
Wrap-Up
TCP and UDP are the backbone of how data moves across networks. TCP focuses on reliability, making sure every piece of data arrives correctly, while UDP prioritizes speed, sending data without the extra checks. Both rely on port numbers to direct information to the right application, with well-known ports making it easy for devices to recognize common services.
By understanding these basics, you’ll have a clearer picture of how everyday online activities from browsing websites to streaming videos actually work. It’s a small step, but an important one, in building your networking knowledge.
Subscribe to my newsletter
Read articles from Pits directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
