Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2005 12:48:31 -0500
From:      Charles Swiger <cswiger@mac.com>
To:        Robert Gogolok <robertgogolok@web.de>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: FIN_WAIT_2
Message-ID:  <7c82a2d1780970b84810aefc59bdb295@mac.com>
In-Reply-To: <423F05F2.3010101@web.de>
References:  <423EFE41.6040805@web.de> <56b90b3668acea792519e1e70a7b837a@mac.com> <423F05F2.3010101@web.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mar 21, 2005, at 12:35 PM, Robert Gogolok wrote:
> Charles Swiger wrote:
>> The TCP stack wants the remote end to acknowledge the last FIN it 
>> sends and close the connection cleanly, and there is a timer (2 * 
>> MSL?) which gets started when a connection moves into the closing 
>> stages (FIN_WAIT_1, FIN_WAIT_2, LAST_ACK).
>
> So FIN_WAIT_2 is the time the server waits to receive the FIN from the 
> client, but although it doesn't get this last FIN message yet, it 
> sends ACK's for the expected FIN message?

FIN_WAIT_2 is a name describing the state of a TCP connection.  It's 
defined in a state diagram in RFC-793.  But otherwise, your description 
is pretty good:

[ ... ]
    |  CLOSE                   +---------+
    | -------                  |  ESTAB  |
    | snd FIN                  +---------+
    |                   CLOSE    |     |    rcv FIN
    V                  -------   |     |    -------
  +---------+          snd FIN  /       \   snd ACK          +---------+
  |  FIN    |<-----------------           ------------------>|  CLOSE  |
  | WAIT-1  |------------------                              |   WAIT  |
  +---------+          rcv FIN  \                            +---------+
    | rcv ACK of FIN   -------   |                            CLOSE  |
    | --------------   snd ACK   |                           ------- |
    V        x                   V                           snd FIN V
  +---------+                  +---------+                   +---------+
  |FINWAIT-2|                  | CLOSING |                   | LAST-ACK|
  +---------+                  +---------+                   +---------+
    |                rcv ACK of FIN |                 rcv ACK of FIN |
    |  rcv FIN       -------------- |    Timeout=2MSL -------------- |
    |  -------              x       V    ------------        x       V
     \ snd ACK                 +---------+delete TCB         +---------+
      ------------------------>|TIME WAIT|------------------>| CLOSED  |
                               +---------+                   +---------+

                       TCP Connection State Diagram
                                Figure 6.


>> It's not uncommon for some clients (think dialup users running 
>> Win98), to drop the connection rather rather than close it properly.
> So the client has time to ACK the server's FIN, but the user closes 
> the  dialup connection, so the application hasn't sent the FIN?

Your http server answers the HTTP request, and tries to close the 
connection.  It sends a the data, followed by a FIN.  It is waiting to 
receive an ACK of the FIN, and then receive a FIN from the client 
indicating that the client has no more data to send and is willing to 
close the connection.

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7c82a2d1780970b84810aefc59bdb295>