In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of TCP's three-way handshake and four waves, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this TCP's three-way handshake and four waves. Let's take a look.
The header format of the TCP message paragraph
* * the sequence number seq:** occupies 4 bytes and is used to mark the order of data segments. TCP numbers all the data bytes sent in the connection, and the number of the first byte is randomly generated locally. After numbering the bytes, each message segment is assigned a sequence number. The sequence number seq is the data number of the first byte in the message segment.
* * the confirmation number ack:** occupies 4 bytes and expects to receive the sequence number of the first data byte of the next message segment; the sequence number indicates the number of the first byte of the data carried by the message segment; and the confirmation number refers to the number of the next byte expected to be received; therefore, the number + 1 of the last byte of the current message segment is the confirmation number.
* * confirm that ACK:** occupies 1 bit. The confirmation number field is valid only when ACK=1 is used. When ACK=0, the confirmation number is invalid. TCP stipulates that all message segments sent after the connection is established must have ACK set to 1.
* * it is used to synchronize the sequence number when a synchronous SYN:** connection is established. When SYN=1,ACK=0 says: this is a connection request message segment. If you agree to connect, make SYN=1,ACK=1 in the response message segment. Therefore, SYN=1 indicates that this is a connection request, or a connection accept message. The SYN flag is set to 1 only when TCP builds a production connection, and the SYN flag bit is set to 0 after the handshake is completed.
* * terminating the FIN:** is used to release a connection. FIN=1 said: the data of the sender of this message segment has been sent and requires the release of the shipping connection
* * uppercase words such as PS:**ACK, SYN, and FIN indicate flag bits, and their values are either 1 or 0, and lowercase words seq indicate sequence numbers.
The field indicates whether the URG emergency pointer is valid. Is 1, indicating that a bit needs to be given priority to determine whether the ACK confirmation number is valid, which is generally set to 1. PSH prompts the receiving application to read the data from the TCP buffer immediately. The RST party requests to re-establish the connection and reset. SYN requests to establish a connection and sets the initial value of the serial number in the field of its serial number. Establish a connection and set it so that 1FIN wants to disconnect. TCP three-way handshake
* * first handshake: * * when establishing a connection, the client sends a syn packet (syn=j) to the server and enters the SYN_SENT status, waiting for the server to confirm; SYN: synchronous sequence number (Synchronize Sequence Numbers).
* * second handshake: * * when the server receives the syn packet, it must confirm the customer's SYN (ack=j+1). At the same time, it also sends a SYN packet (syn=k), that is, SYN+ACK packet. At this time, the server enters the SYN_RECV status.
* * third handshake: * * the client receives the SYN+ACK packet from the server and sends the acknowledgement packet ACK (ack=k+1) to the server. After the packet is sent, the client and the server enter the ESTABLISHED (TCP connection successfully) state and complete the three-way handshake.
TCP waved four times.
1) the client process sends a connection release message and stops sending data. Release the header of the data message, FIN=1, whose sequence number is seq=u (equal to the sequence number of the last byte of the previously transmitted data plus 1), and the client enters the FIN-WAIT-1 (termination waiting for 1) state. TCP stipulates that FIN message segments consume a serial number even if they do not carry data.
2) the server receives the connection release message, sends out a confirmation message, ACK=1,ack=u+1, and takes its own serial number seq=v. At this time, the server enters the CLOSE-WAIT (shutdown waiting) state. When the TCP server notifies the high-level application process, the direction of the client to the server is released, and it is in a semi-closed state, that is, the client has no data to send, but if the server sends data, the client still has to accept it. This state will continue for a while, that is, the duration of the entire CLOSE-WAIT state.
3) after the client receives the confirmation request from the server, the client enters the FIN-WAIT-2 (termination waiting 2) state and waits for the server to send the connection release message (before that, it needs to receive the last data sent by the server).
4) after the server sends the final data, it sends a connection release message, FIN=1,ack=u+1, to the client. Since the server is in a semi-closed state, the server probably sends some more data. Assuming that the serial number is seq=w, the server enters the LAST-ACK (final acknowledgement) state and waits for confirmation from the client.
5) after receiving the connection release message from the server, the client must issue an acknowledgement, ACK=1,ack=w+1, and its serial number is seq=u+1. At this point, the client enters the TIME-WAIT (time waiting) state. Note that the TCP connection has not been released at this time. The time of 2 ∗∗ MSL (maximum message segment life) has elapsed, and the client will not enter the CLOSED state until the corresponding TCB is revoked.
6) as soon as the server receives the confirmation from the client, it immediately enters the CLOSED state. Similarly, after revoking TCB
This is the end of the article on "what is the three-way handshake and four waves of TCP". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what is the three-way handshake and four waves of TCP". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.