[Network Engineering] Easy to understand TCP/IP protocol three-way handshake and four-way wave

Table of contents

What is a three-way handshake?

How to perform a three-way handshake

What is four waves?

How to do four waves


What is a three-way handshake?

Why the three-way handshake? is to ensure a secure and reliable link

How to perform a three-way handshake

The first handshake is initiated by the client, and a message 1 is sent to the server to indicate the initiation of a new connection. ( first handshake )

After receiving message 1, the server knows that the client wants to request to establish a new connection, and then responds with a confirmation packet to the client, indicating that the first connection request initiated by the client (the second handshake) is confirmed .

For the client, it has been confirmed that it can send a message to the server and receive a response from the server. For the server, the message is only received once, and it is not yet known whether the second handshake response to the client can be received, so a third handshake is required.

When the client receives the response information from the server, it continues to respond to the server ( the third handshake )

At this time, through the above three connections, whether it is the server or the client, I know that I can send a message to the other party and receive a response from the other party.

What is four waves?

Why wave four times? In order to ensure that the message transmission can be completed before the connection is disconnected

How to do four waves

For the first wave, the client initiates a disconnection message. After receiving the message, the server knows that the client wants to disconnect ( the first wave )

Since the server may not be ready to disconnect immediately, there may be messages that have not been sent, or messages that are being sent, the server can only do a message confirmation at this time, telling the client that you already know that you want to disconnect Yes, but the server is not ready yet, need to wait for a while ( second wave )

After the second wave, the server may have finished sending the message in hand, and will send a disconnection message to the client, indicating that the server is ready to disconnect (the third wave )

When the client receives the message from the server, it also needs to give the server a message confirmation ( the fourth wave )

After four connections, both the server and the client are ready to disconnect

おすすめ

転載: blog.csdn.net/haidong55/article/details/126721753