CLOSE_WAIT a problem - TCP three-way handshake principle (memo)

CLOSE_WAIT problem

The reason is simple: TCP four waved issue, launched in FIN instruction

Details, your own Baidu

Note that, CLOSE_WAIT exist only after the connection has been successfully connected to the socket

Articles induced error

Under criticized: http://blog.huoding.com/2016/01/19/488

Specific summarized as follows:
Here Insert Picture Description

Learn the server connection is successfully established in the process of behavior

Reference article:

  • https://blog.csdn.net/alitech2017/article/details/80922902
  • http://veithen.github.io/2014/01/01/how-tcp-backlog-works-in-linux.html

The above two articles the problem server-side connection process, as well as works backlog see very clearly

Here again simply repeat the procedure, see:
Here Insert Picture Description

  1. Client (53302) sends a SYN instruction request to establish a connection
  2. The server (999) transmits SYN-ACK command, a response (socket to the sync queue)
  3. Client (53302) transmitting an ACK command, and that they have a connection completion
  4. After receiving the ACK command server (999), found that accept queue is full, the packet is discarded ACK
  5. The server (999) repeats BackOff (退避算法), SYN-ACK transmission command
  6. The server (999) has not received client ACK command, then eventually send RST command, closes the connection

The above process, the server side portions 5 do, the client does the following things:

  • Client (53302) will begin sending data PSH-ACK (because the client considers the connection has been established successfully)
  • Since then the server does not receive an ACK packet (999), the repeated BackOff (退避算法)transmission data PSH-ACK

The above figures do not another case, that the client after the connection is successfully established, data is not sent, then the server (999) will eventually send command RST, the connection is closed

Therefore, the server:

  • Or receive ACK command sent by the client to complete the three-way handshake. accpet () function returns the socket object
  • RST instruction is either transmitting end connection

FIG state socket

The following diagram taken from the network article, under the main Description: CLOSE_WAIT may only appear later in the ESTABLISHED state; and only receive instruction before transferring FIN
Here Insert Picture Description

in conclusion

  1. TCP connection establishment, the server only sends a reset command RST is connected
  2. backlog values ​​may only make a lot of connections can not connect to the server
  3. CLOSE_WAIT may only appear later in the ESTABLISHED state; and only receive instruction before transferring FIN

other

The article mentioned BackOff (退避算法), this may not be the TCP proper noun, a word to express a meaning, repeatedly sent the next time will be longer command

Published 129 original articles · won praise 73 · views 160 000 +

Guess you like

Origin blog.csdn.net/u013272009/article/details/99762576