TCP provides reliable, ordered delivery by establishing a connection and retransmitting missing data. UDP sends data without establishing a connection, reducing overhead and delay but providing no guarantee of delivery or ordering.
Both are transport-layer protocols. They divide application data into smaller units and use port numbers to direct data to the correct application, but they handle transmission differently.
TCP is connection-oriented. Before transmitting application data, it establishes a connection using a three-way handshake. Sequence numbers allow received segments to be reordered, acknowledgements confirm arrival, and missing segments can be retransmitted. TCP also provides flow control and congestion control.
UDP is connectionless. It sends each datagram independently without a handshake, acknowledgements, or protocol-level retransmission. Its smaller header produces lower overhead, making it suitable when low latency is more important than perfect delivery.
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented | Connectionless |
| Delivery | Reliable through acknowledgements and retransmission | Best-effort, with no delivery guarantee |
| Ordering | Uses sequence numbers to preserve order | Datagrams may arrive out of order |
| Overhead | Higher because of its larger header and control mechanisms | Lower because of its smaller header |
| Typical uses | Web pages, email, file transfer | Live streaming, online gaming, voice calls, DNS queries |
For example, losing part of a downloaded program could corrupt the file, so TCP is appropriate. In a live voice call, retransmitting an old audio datagram may be less useful than continuing with current audio, so UDP may be preferred.
A common misconception is that UDP is always faster. UDP has lower protocol overhead and may reduce latency, but actual performance still depends on network conditions and the application's own reliability mechanisms.
Exam technique: For a compare question, give paired differences rather than two separate descriptions. Link each protocol's features to a justified application: reliability and ordering for TCP, or low overhead and low latency for UDP.