Junior
What is the TCP protocol?
sobes.tech AI
Answer from AI
TCP (Transmission Control Protocol) is a transport layer protocol in the TCP/IP protocol stack that provides reliable, connection-oriented delivery of a byte stream between applications.
Main features of TCP:
- Reliability: Guarantees delivery of all data segments in the correct order, retransmitting lost or corrupted segments. Uses acknowledgments (ACK) and timeouts.
- Connection-oriented: A logical connection is established between sender and receiver before data transfer (three-way handshake). The connection is maintained throughout the session.
- Flow Control: Regulates the data transfer rate so that the sender does not overwhelm the receiver's buffer. Uses a receive window.
- Congestion Control: Prevents network congestion by dynamically adjusting the data transfer rate based on network conditions. Uses algorithms like Slow Start, Congestion Avoidance.
- Stream-oriented: TCP treats data as a continuous stream of bytes, not separate packets. Ensures data is delivered in the same order it was sent.
- Full duplex: Allows data to be transmitted in both directions simultaneously after the connection is established.
Applications of TCP:
- HTTP/HTTPS (web traffic)
- FTP (file transfer)
- SMTP (email)
- SSH (remote management)
Comparison with UDP:
| Characteristic | TCP | UDP |
|---|---|---|
| Reliability | High (guaranteed delivery) | Low (no guarantee) |
| Connection-oriented | Yes (establishment and maintenance) | No (connectionless transfer) |
| Data ordering | Yes (delivery in send order) | No (possible out-of-order delivery) |
| Flow control | Yes | No |
| Congestion control | Yes | No |
| Speed | Lower (due to overhead) | Higher |
| Examples | HTTP, FTP, SSH, SMTP | DNS, DHCP, VoIP, online gaming |