TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two of the most widely used transport layer protocols on the Internet.
Both are used to transfer data between applications, but they have different characteristics and are designed for different purposes.
::contentReference[oaicite:0]{index=0}
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented | Connectionless |
| Reliability | Reliable | Best effort |
| Packet Order | Guaranteed | Not guaranteed |
| Error Recovery | Yes | No |
| Speed | Slower | Faster |
| Overhead | Higher | Lower |
| Typical Uses | Web, Email, File Transfer | DNS, VoIP, Streaming, Gaming |
TCP establishes a connection before transmitting data.
It ensures that:
This reliability makes TCP suitable for applications where accuracy is more important than speed.
Examples:
UDP sends packets without establishing a connection.
It does not guarantee:
Instead, it focuses on speed and low latency.
This makes UDP ideal for applications where occasional packet loss is acceptable.
Examples:
Before exchanging data, TCP performs a connection setup called the Three-Way Handshake.
Client Server
SYN ─────►
◄───── SYN-ACK
ACK ─────►
Connection Established
Only after this process begins does application data flow.
UDP has no connection setup.
The sender immediately transmits packets.
Client Packet 1 ─────► Packet 2 ─────► Packet 3 ─────► Server
This reduces delay but provides no guarantee that packets arrive.
TCP detects missing packets and retransmits them.
If packet number 3 is lost:
1 ✓ 2 ✓ 3 ✗ 4 ✓ ↓ TCP retransmits packet 3.
UDP simply continues sending.
The application must decide how to handle missing data.
Because TCP performs acknowledgements, retransmissions, and congestion control, it generally has more overhead.
UDP is usually:
This is why many real-time applications prefer UDP.
Many services use different port numbers.
Examples:
| Service | Protocol | Default Port |
|---|---|---|
| HTTP | TCP | 80 |
| HTTPS | TCP | 443 |
| SSH | TCP | 22 |
| SMTP | TCP | 25 |
| DNS | UDP (usually) | 53 |
| DNS Zone Transfer | TCP | 53 |
| DHCP | UDP | 67 / 68 |
| NTP | UDP | 123 |
Use TCP when:
Use UDP when:
Several Telenegar tools distinguish between TCP and UDP.
Port Check
A port may accept:
For example:
53 TCP ✓ UDP ✓ 443 TCP ✓ UDP ✗
Knowing which protocol a service uses is essential when troubleshooting connectivity.