If the communicating entities (application) choose to have a reliable connection between them, then TCP is the way to go (presuming TCP/IP suite).
TCP stands for Transmission Control Protocol. TCP ensures reliability by
- establishing a session between the two nodes through a Three-way Handshake process. And
- acknowledging successful delivery of every segment.
In this post, let’s discuss the Three-way Handshake process, lovingly denoted as 3WHS.
As you might have guessed, in 3WHS three TCP segments are exchanged between the sender and the receiver to establish a reliable connection. These are SYN, SYN-ACK and ACK.
Step 2 – SYN-ACK: In response, machine-2 replies back with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number i.e. A+1. And the sequence number that the machine-2 chooses is another random number ‘B’.
Step 3 – ACK: Finally, machine-1 sends an ACK back to the machine-2. The sequence number is set to the received acknowledgment value i.e. A+1, and the acknowledgment number is set to one more than the received sequence number i.e. B+1.
At this point, both machine-1 and machine-2 have received an acknowledgment for the connection. The steps 1 & 2 establish the connection parameter (sequence no.) for one direction and it is acknowledged. The steps 2 & 3 establish the connection parameter (sequence no.) for the other direction and it is acknowledged. With these, a full-duplex communication is established.
- The initial sequence numbers are randomly selected while initiating connection between the two machines.
- The acknowledgment number indicate the next segment’s sequence number being expected from the sender.