TCP is a connection-oriented protocol. Before data is transmitted, a connection is established between sender and receiver (3-way handshake). TCP guarantees that all packets arrive in the correct order and requests retransmission if packets are lost.
UDP is a connectionless protocol. Data is sent without prior connection setup. There is no guarantee that packets arrive, arrive in order, or arrive at all. This makes UDP much faster but less reliable.
The choice between TCP and UDP depends on the application requirements:
| Port | Service | Protocol |
|---|---|---|
| 80 / 443 | HTTP / HTTPS | TCP |
| 22 | SSH | TCP |
| 25 / 587 | SMTP (Email) | TCP |
| 53 | DNS | UDP / TCP |
| 67 / 68 | DHCP | UDP |
| 123 | NTP (Time) | UDP |
| 443 | QUIC / HTTP/3 | UDP |
TCP and UDP are the two most important transport layer protocols (Layer 4 of the OSI model). TCP provides reliable, ordered data transmission with error checking – ideal for applications where data integrity is paramount. UDP sacrifices reliability for speed, making it ideal for real-time applications like video calls, online gaming and DNS queries where a small amount of data loss is acceptable.