Is it guaranteed that an RST packet will be sent when a process terminates?

1.2k views Asked by At

If I have a process with a connected socket, and I terminate this process, then Windows will cause an RST packet to be sent.

Is it guaranteed (is it documented somewhere) that an RST packet will always be sent when a process terminates, or could a FIN packet be sent instead?

1

There are 1 answers

19
Filipe Gonçalves On

TCP is not supposed to send an RST packet when a connection is closed. To close a connection, TCP goes through the following states on the client side:

  1. Send a FIN packet. This action will change TCP state to FIN_WAIT_1.
  2. In FIN_WAIT_1, TCP waits for an acknowledgement (ACK) from the server.
  3. Once the acknowledgement is received, TCP enters FIN_WAIT_2.
  4. In FIN_WAIT_2, TCP waits for a FIN packet from the server
  5. Once FIN arrives, the client sends an ACK and enters TIME_WAIT
  6. TIME_WAIT is exited after a while (typically, 30 secs. or 1 minute). The purpose of this state is to make it possible to resend the final ACK to the server in case it was lost.

There is no RST packet anywhere. RST is used to respond to unexpected traffic, not to close a connection.

For example, if you send a TCP packet to port 80, and the server is not running an HTTP server (and assuming the packet makes all the way to the server and is not blocked / ignored), then an RST reply is sent back to the client.