Junior — Middle
Can you explain the three-way handshake principle in the TCP protocol?
sobes.tech AI
Answer from AI
The three-way handshake in TCP is a process that ensures a reliable and synchronized connection between the client and the server.
- The client sends a segment with the SYN (synchronize) flag to initiate the connection and propose an initial sequence number.
- The server responds with a segment with SYN and ACK (acknowledge) flags, confirming receipt of the client's SYN and sending its own initial sequence number.
- The client responds with a segment with the ACK flag, confirming receipt of the server's SYN-ACK.
After this, the connection is considered established, and data transfer begins.
Example:
- Client -> Server: SYN seq=100
- Server -> Client: SYN seq=300, ACK ack=101
- Client -> Server: ACK ack=301
This process ensures the consistency of initial sequence numbers and the readiness of both parties to exchange data.