TCP Handshake

tcp-3-way-handshake-ipcisco

TCP (Transmission Control Protocol) is one of the important transport layer protocols like UDP and SCTP. We use TCP in various networking activities. In this lesson, we will focus on the TCP messaging and we will learn phases of TCP handshake mechanisms. We will learn what are the three phases of tcp three-way handshake and what are the four phases of tcp four-way handshake. We will explain the difference between 3-way handshake and 4-way handshake.

 

Here, we will explain TCP handshaking or TCP handshake mechanism in two title:

  • TCP 3-way Handshake
  • TCP 4-Way Handshake

 

Let’s start to the details of these messaging mechanism.

 


You can also check TCP vs UDP Comparison Lesson. 


 

TCP Three-Way Handshake

TCP (Transmission Control Protocol) is a connection-oriented protocol. This means that, if we use TCP between two peers, TCP session must be established. This TCP session establishment is done with TCP three-way handshake. With this mechanism, two ends negotiate TCP sequence number before session start.

 

There are three phases of TCP 3-way handshake. So, what are the three phases of tcp three-way handshake? These phases (messages) are given below:

  • SYN
  • SYN ACK
  • ACK

 

There are 9 bits flags area in TCP Header. Here, the SYN and ACK bits in the TCP Header are set to 0 or 1 according to the message.

tcp-header-ipcisco

 

Let’s think that one end is a client and the other end is a server. And our client will start the session.

 

tcp-3-way-handshake-ipcisco

Firstly, the client sends SYN (Synchronize Sequence Number) message. This means that “I would like to start a TCP session with this sequence number!” After sending SYN, clients wait for a reply from the server.

 

The server gets SYN message and replies with SYN ACK message. With this message it says that “This sequence number is OK for me!”

 

Lastly, the client sends ACK message and they establish a reliable connection for data transfer with this TCP handshaking mechanism.

 


 

TCP Four-Way Handshake

To use TCP, we have established a TCP Session with TCP three-way handshake. How about TCP session termination? To terminate a TCP session, this time, we will use TCP four-way handshake.

 

There are two messages in TCP 4-way handshake mechanism. So, what are the messages of tcp four-way handshake? These messages are given below:

  • FIN
  • ACK

 

Each of this message is sent from one end to other, so it is named TCP four-way handshake with four messages.

 

Here, the FIN and ACK bits in the TCP Header are set to 0 or 1 according to the message.

 

What is the meaning of these TCP four-way handshake messages? Let’s explain one by one with a client server architecture again.

tcp-4-way-handshake-ipcisco

 

Firstly, the client end which wants to terminate TCP session sends a FIN message with FIN flag set. This means that a request for a session termination.

 

The server end which receives this message sends an ACK message. This is the acknowledgement message for this session termination request.

 

In the third step, this time the server sends a FIN message with FIN flag set which means that he will terminate the session.

 

In last step the client receives FIN message and then sends an Acknowledgement too with an ACK message.

 


 

Last Word

In this lesson, we have learned TCP handshake mechanisms and the differences of TCP 3-way handshake and TCP 4-way handshake. We have learned the messages used in these mechanisms.

 

Back to: CCNA 200-301 > TCP and UDP

Leave a Reply

Your email address will not be published. Required fields are marked *

CCNA 200-301

Collapse
Expand