Explanation and verification of time_wait status:
In TCP synchronous duplex disconnection, if there is no time-Wait Status, the ACK n + 1 is returned when the last fin N is sent and the active shutdown party receives the request. at this time, if the n + 1 package is not correctly met, the other party will remain in the last ack status, and the sender will not be in the tim_wait status, if the message is correctly sent, it exits, causing the recipient to wait. After time_wait is added, the value of time_wait itself also indicates the time when the package can survive on the network. the receiver can simply think that n + 1 packets are not received during this time.
If this disconnection fails, you need to resend the serial number of the fin n. At this time, the time_wait end also needs to change the status
The status of the fin to be sent next time.
For the socket connection with repeated connections: Imagine that without the time_wait, you have just exited the socket and the socket has not been disconnected for four times.
After that, you may quit in close_wait and then immediately connect and issue your ack. The consequence is very serious, and
The other party may think that you are still in the last four disconnections ..
First, verification fails. Verify the second one as follows: bind a sockaddr_in on the client and specify the port. When disconnected, connect again immediately.
[tnsmcc@localhost client]$ ./client.exe 127.0.0.1 9000fdsfdsfdsfdsfdsfds[tnsmcc@localhost client]$ ./client.exe 127.0.0.1 9000[tnsmcc@localhost client]$ ./client.exe 127.0.0.1 9000[tnsmcc@localhost client]$ ./client.exe 127.0.0.1 9000
At this time, the port is in
- 127.0.0.1: 9005 127.0.0.1: 9000 time_wait