|
From: | David Empson |
Subject: | Re: [lwip-users] TCP Close State |
Date: | Thu, 14 Feb 2008 11:00:34 +1300 |
Rick Culver wrote:
Using symbolic names, that's
ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, then TIME_WAIT.
This means you have sent FIN, received
ACK, received FIN and sent ACK, so the connection is fully closed. The
TIME_WAIT state is there to deal with ACKing retries of the received FIN
if your first ACK reply was lost. It transitions automatically to CLOSED
after a timeout.
If the connection is closed by the other end first,
a different series of states are used: CLOSE_WAIT, LAST_ACK, then CLOSED. The
events are receive FIN, send ACK, close() called locally, send FIN, receive ACK.
The TIME_WAIT state is not used, but the LAST_ACK state also has a timeout (if
the ACK never arrives).
From a quick glance at the source code in lwip
1.2.0, the timeout in the TIME_WAIT and LAST_ACK states is handled by
tcp_slowtmr(), based on the _expression_ 2 * TCP_MSL (two minutes) divided by
TCP_SLOW_INTERVAL.
If your timer implementation has a problem,
e.g. tcp_slowtmr() isn't being called at all, or isn't being called at the
rate specified in TCP_SLOW_INTERVAL, then this would explain a timeout never
occurring, or taking much longer than expected.
|
[Prev in Thread] | Current Thread | [Next in Thread] |