TCP 4-Way Termination Handshake

TCP 4-Way Termination Handshake

We know that it works as the full-duplex mode, so if the one-side connection is broken down, then no more data can be sent from that side of the connection. But it can still receive the data from another side.?

Here four-way handshake is necessary in this case, as the first FIN flag, that is sent to the server by the client is a request for termination. And the first ACK, received by the client is just a response to FIN 1. Now here only the connection from the client is disconnected, but the server is still in a working position. This means it may still have some data to send. So, in this condition, the connection cannot be cut down suddenly. here, the other two steps are needed to be performed by the server.

?Now the other reason is that it can become difficult for both sides to define why the peer does not respond. Also, not only the offline state can cause a packet lost. Alongside, the other exceptions in the server’s processing can also lead to it. And there is another problem with this idea is that in this condition, the client will have to wait for a long time until the time is out. Here, the four-way handshake looks like a better and easier option to address these problems.

?

No alt text provided for this image
TCP 4 Way Handshake

Why Does TCP Connect Termination Need 4-way-Handshake?

  1. FIN : It is sent by client or server can also sent it in order to terminate the session. It is called FIN_WAIT_1 state.
  2. ACK : Sent by the server in response for FIN.

At this time, the connection has been terminated from client side only since FIN has been sent from client only and it has received ACK from Server but Server still has TCP connection open because server hasnt sent its FIN yet. This state is called FIN_WAIT_2 State because the client is expected to get FIN from server as well.

3. FIN-ACK : It is sent by the server to client stating i am also closing the connection.

4. ACK : This is sent by client to server acknowledges the FIN from server. It is called TIME_WAIT state. The?TIME_WAIT?state lets the client resend the final acknowledgment in case the?ACK?is lost.

The time spent by clients in the?TIME_WAIT?state depends on their implementation, but their typical values are 30 seconds, 1 minute, and 2 minutes. After the wait, the connection formally closes and all resources on the client-side (including port numbers and buffer data) are released.

?

TCP states visited by Client Side –?

No alt text provided for this image

?TCP states visited by Server Side –?

No alt text provided for this image
MD EMON HOSSAIN

Network Engineer | Expert in F5 Network Solutions

1 年

Great article for network engineer. Thanks

回复
Ali Syed

printf("Hello world")

2 年

thanks for sharing, informative

要查看或添加评论,请登录

Ibraham Ajazz的更多文章

社区洞察

其他会员也浏览了