Junior
What is the difference between TCP and UDP protocols?
sobes.tech AI
Answer from AI
TCP (Transmission Control Protocol):
- Reliable: Guarantees delivery of packets, retransmits lost packets, maintains order. Uses acknowledgments and timers.
- Connection-oriented: Requires a "handshake" (three-way handshake) to start data exchange.
- Stream-oriented: Data is transmitted as a continuous stream of bytes.
- Slow: Overhead for connection setup and delivery guarantees makes it slower than UDP.
- Applications: HTTP/HTTPS, FTP, SMTP, Telnet.
UDP (User Datagram Protocol):
- Unreliable: Does not guarantee delivery, order, or duplicate protection.
- Connectionless: Does not require a "handshake".
- Datagram-oriented: Data is sent in separate packets (datagrams).
- Fast: Low overhead ensures high speed.
- Applications: DNS, DHCP, streaming audio/video, online gaming.
| Characteristic | TCP | UDP |
|---|---|---|
| Reliability | High (guaranteed delivery and order) | Low (no guarantees) |
| Connection establishment | Yes (three-way "handshake") | No |
| Data transmission | Stream-based | Datagram-based |
| Speed | Slower | Faster |
| Error control | Yes | No (only header checksum) |
| Order guarantee | Yes | No |
| Flow control | Yes | No |