tcp_fsm.h: sending FIN or FIN+ACK in Closing state

Chuck Swiger cswiger at mac.com
Thu Oct 13 12:27:56 PDT 2005


Vishal M wrote:
[ ... ]
> My question was basically related to "Simultaneous
> close" case wherein both sides initiate a TCP close
> almost at the same time, resulting in FINs crossing 
> each other.

Yes.  But it's not apparent that the way you can handle FIN is much different 
in this case versus that of only one side closing, they are considering that 
case for the sake of completeness in the RFC and Stevens.

> In FIN_WAIT1 state, on receiving FIN from the peer, we
> transition into CLOSING state and send out an ACK.
> My question was related to this ACK pkt. 
> 
> The RFC and Richard Stevens Vol-2 (pg 808) suggests
> just sending an ACK whereas FreeBSD code (in
> tcp_fsm.h) and also Stevens Vol-2 (pg 809) suggests
> sending FIN+ACK. I am not clear on this...which is the
> correct behavior? 

Both are.

So long as you've received all of the sent data up through the FIN from the 
other side, and so long as you drain any unsent traffic on your side, it 
doesn't matter whether you send a FIN+ACK with the last data traffic or whether 
you ACK without a FIN, and then send a bare FIN seperately.

-- 
-Chuck



More information about the freebsd-questions mailing list