In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1. Why is there a three-way handshake when connecting and a four-way handshake when closing?
Because when the server receives the SYN connection request message from the Client, it can directly send the SYN+ACK message. The ACK message is used for reply, and the SYN message is used for synchronization. However, when the connection is closed, when the Server receives the FIN message, it is likely that SOCKET will not be closed immediately, so it can only reply an ACK message to tell the Client that "I received the FIN message you sent." I can't send FIN messages until all messages on my Server end have been sent, so I can't send them together. A four-way handshake is required.
2. Why can't I connect with a two-way handshake?
This is mainly to prevent the connection request segment that has failed from suddenly being transmitted to B, thus generating errors.
Assume an anomaly in which the first connection request segment sent by A is not lost, but is held up at some network node for such a long time that it arrives at B some time after the connection is released. It was a message segment that had long since expired. However, after receiving this invalid connection request message segment, B mistakenly thinks that A has sent a new connection request, so it sends an acknowledgement message segment to A and agrees to establish the connection. Assuming no third handshake, the new connection is established as soon as B sends an acknowledgement.
Since A has not yet requested a connection, it ignores B's acknowledgement and does not send data to B, but B assumes that a new transport connection has been established and waits for data from A. A lot of B's resources are wasted in this way.
The three-way handshake connection can prevent the above phenomenon from happening. For example, in the abnormal situation just now, A will not send an acknowledgement to B's acknowledgement, and B, because it does not receive an acknowledgement, knows that A has not requested to establish a connection, so B will not establish a connection again.
3. Why does the TIME_WAIT state take 2MSL to return to CLOSE state? First, in order to ensure that the last ACK segment sent by A can reach B. Assuming the network is unreliable, there can be a last ACK loss. The TIME_WAIT state is used to retransmit ACK messages that may be lost. The Client sends the final ACK reply, but the ACK may be lost. If the Server does not receive an ACK, it repeatedly sends FIN fragments. So the Client cannot shut down immediately, it must acknowledge that the Server received the ACK. The Client will enter the TIME_WAIT state after sending an ACK. The Client sets a timer to wait 2MSL. If FIN is received again within that time, the Client resends the ACK and waits again for 2MSL. 2MSL is twice the MSL(Maximum Segment Lifetime). MSL is the maximum lifetime of a fragment in the network, and MSL is the maximum time required for a send and a reply. If the Client does not receive FIN again until 2MSL, the Client concludes that the ACK has been successfully received by the Server and ends the TCP connection. Second, prevent "failed connection request segments" from appearing in the connection. After sending the last ACK segment, A can make all the segments generated during the duration of the connection disappear from the network after a time of 2MSL. This ensures that the old connection request segment does not appear on the next new connection. 4. What if the connection has been established, but the client suddenly fails?
TCP also has a keep-alive timer, obviously, if the client fails, the server can't wait forever, wasting resources. The timer is reset every time the server receives a request from the client. The timer is usually set to 2 hours. If no data is received from the client in 2 hours, the server will send a probe message segment and send it every 75 minutes. If 10 probes fail, the server assumes that the client is down and closes the connection.
Original link: https://www.linuxprobe.com/tcp-usually-question.html
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.