Three handshake and four wave summary

three-way handshake

waved four times

1. What do SYN, ACK, FIN, seq, and ack mean?

           SYN: represents the request to create a link, so SYN=1 is required for the first two times in the three-way handshake, indicating that these two times are used to establish a link.

           FIN: Represents a request to close the link. In the four splits, FIN is sent twice. This is because the TCP link is bidirectional, so one FIN can only close one direction. So FIN can only close one direction at a time.

            ACK: Represents confirmation of acceptance. Regardless of the three-way handshake and the four-time breakup, ACK=1 will be added when responding, indicating that the message has been received, and ACK=1 will be added when sending data after the link is established, indicating that the data is successfully received. .

            seq: sequence number. When sending a piece of data, the data is split into multiple data packets to send. The sequence number is to number each data packet, so that the receiver can splicing the data packets again.

           The initial serial number is randomly generated, so that the unpacking and unpacking of different data will not be wrongly connected. (For example: both data are split into 1, 2, 3 and one data is 1, 2, 3 and the other is 101, 102, 103, obviously the latter will not connect error)

            ack: This indicates the number of the next packet, which is why the second request, ack is seq+1

(Summary: A, when creating a connection, 1. The client must first SYN=1, indicating that a connection is to be created; 2. After the server receives the request, it must tell the client: I have received it! So add ACK=1, It becomes ACK=1, SYN=1; 3. In theory, the connection is created successfully at this time, but in order to prevent accidents, the client needs to send another message to the server for confirmation, then only ACK=1 is needed. , that is, a three-way handshake.

               B. When breaking up four times, 1. First, the client requests to close the link from the client to the server. At this time, the client will send a FIN=1, indicating that the link in one direction is to be closed; 2. After the server receives it After confirming, the link in this direction is closed, so an ACK=1 is returned; 3. At this time, only one direction is closed, and the other direction also needs to be closed, so the server also sends a FIN=1 to the client; 4. After the client receives it, it returns an ACK=1, indicating that the acceptance is successful)

2. Why three handshakes?

        If you can link by sending it twice, then as long as the client sends a link request and the server receives and sends an acknowledgment, a link will be established.

       Possible problems: If a link request runs slowly in the network and times out, the client will re-send the request, but the slow request still arrives at the end, and then the server accepts two link requests , then all responses will create two links, wasting resources.

        If a third client confirmation is added, after the client receives a server link confirmation request, the link confirmation received later can be discarded.

3. Why do you need to break up four times?

        TCP is bidirectional, so it needs to be closed in both directions, and the closure of each direction requires a request and confirmation, so there are 4 times in total.

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326522677&siteId=291194637