Latest

CCNA: TCP Three-Way Handshake

CCNA: TCP 3-Way Handshake 

In this article, let’s take a look at TCP three-way handshake and other useful information that makes TCP a reliable communication protocol.

Before TCP can send any traffic, it first contacts the other device and establish a reliable and controlled connection. TCP can be considered as a reliable employee to transfer information from PC-1 to PC-2. Let’s consider an example where an HTTP application on PC-1 wants to send data to PC-2. The HTTP data is handed over to TCP for transmission. TCP says wait let me establish a connection with PC-2 to ensure data is sent reliably and a sequence of packets (3-way handshake) happens between the devices.


Figure 1: TCP Three-way Handshake

The three-way handshake process utilizes the fields in TCP headers – Sequence Number (SEQ), the Acknowledgement Number (ACK), the Synchronize flag (SYN), and the ACK flag.

The three-way handshake process is as follows – SYN is sent by source PC-1, SYN-ACK is sent by target PC-2, and ACK from the PC-1 source.

PC-1 starts by creating a TCP packet with no data. It just signals PC-2, “We should start a connection”. PC-1 sets the SEQ = 1, and raises the SYN flag to 1.

PC-2 receives this TCP packet and knows that the Packet is received from PC-1 as the SYN flag is set – PC-1 wants to connect. Now PC-2 informs PC-1 that it received SEQ 1 and now it expect SEQ 2.

PC-2 sends the packet with ACK 2, with both SYN and ACK flag set to 1. In this communication PC-1 and PC-2 sequence numbers are independent. PC-2 sets the SEQ = 11. It means PC-2 is saying “I am using Sequence number 11 to respond to your Sequence number 1”.

PC-1 receives the ACK. PC-1 sends the new packet with SEQ number set to 2 to confirm the PC-2. PC-1 says, “Hey PC-2 you expected the next sequence which is 2 to acknowledge your sequence number 11 and now I expect SEQ 12 from your end”. It sends the ACK and SYN flag raised to 1.

At this point, a reliable communication connection is established. PC-1 and PC-2 both have received and acknowledged a sequence of packets from one another. Now actual data transfer happens.

Let’s say HTTP uses port 80 to identify the application at PC-2, PC-1 chooses Port 80 as the destination port and selects a random port 36000 as the source port. 

I hope you find this blog informative!

 Continue Reading...