Please enable Javascript to view the contents

 ·  ☕ 2 分钟

Normal TCP Close Phases

https://accedian.com/blog/close-tcp-sessions-diagnose-disconnections/

Figure 1 – Simplified TCP closing with FIN.

Figure 1 – Simplified TCP closing with FIN.

The standard way to close TCP sessions is to send a FIN packet, then wait for a FIN response from the other party.

  1. A sends a FIN packet and waits for a response; it can release some resources but awaits the response of the other part (Fin Wait)
  2. B receives the FIN packet and must release resources; it waits for a closing application level (Close Wait)
  3. B can now send a FIN to A and then await its acknowledgement (Last Ack wait).
  4. A can now fully close its job, but it must wait for network collision (?) (Time Wait); it may have to send the final ACK another time.
  5. B eventually receives the final ACK and destroys (kills) the connection.

This works fine in a perfect world. However, what happens when one part of the conversation is broken? That’s why the Reset (RST) packet exists.

TCP RESET

what happens when one part of the conversation is broken? That’s why the Reset (RST) packet exists.

Figure 2 – RST sent to force the end of a TCP session.

Those abnormal terminations (i.e., either an aborted setup or a disconnection) could appear due to:

  • A lack of resources or network interruption
  • A crash/bug during the session
  • While one pair has already closed its part of the connexion, the other part continues to send data
  • The server refuses to open a connection to the client
分享

Mark Zhu
作者
Mark Zhu
An old developer