4 way TCP handshake
Why TCP connection termination needs four-way handshake?
Note that the server sends two packets:
ACK: 1 and SYN: 1 in sequence. Why not combine these two packets into one to have a better network performance?We didn’t combine the ACK: 1 packet (marked as ②) and the FIN: 1 packet (marked as ③) into one packet.
The reason is ACK: 1 packet (marked as ②) is send by TCP stack automatically. And the next FIN: 1 packet (marked as ③) is controlled in application level by calling close socket API. Application has the control to terminate the connection. So in common case, we didn’t merge this two packets into one.
It’s flexible for the application to control this process, for example, in this way the application can reuse existing TCP connection to reduce the overhead and improve the performance.
Comments
Post a Comment