[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] TCP KeepAlive
From: |
Jeff Barber |
Subject: |
Re: [lwip-users] TCP KeepAlive |
Date: |
Mon, 20 Sep 2010 14:38:21 -0400 |
On Mon, Sep 20, 2010 at 10:07 AM, farid mahini <address@hidden> wrote:
> I am trying to enable KeepAlive/Idle feature, but I do not see a hit on
> tcp_tmr, tcp_slowtmr, tcp_fasttmr on an established connection! I am using
> lwIP 1.3 with FreeRTOS. I do not see the KeepAlive variables being accessed
> anywhere else. Any ideas on what I may have overlooked?
I am using keepalives and they do work. I'm using lwip version 1.3.2.
Here are a few notes that may help.
The keepalive packet is sent in tcp_slowtmr when appropriate (assuming
the SOF_KEEPALIVE flag is set). The eventual timeout is also
determined by that function when the limit of keepalives to be sent is
reached. The per-session tick counter is set to the current global
tick counter value in tcp_process whenever a packet is received on a
given session, and the keep_alive_sent count is reset to zero at the
same time.
I found the documentation for the keepalive variables to be a bit
unclear. Bottom line is that (by default) the first keepalive is sent
when there has been no activity on the session for
TCP_KEEPIDLE_DEFAULT milliseconds, then a new keepalive is sent every
TCP_KEEPINTVL_DEFAULT milliseconds until a total of
TCP_KEEPCNT_DEFAULT probes have been sent. At that point, the session
is closed.
The default settings are such that the first keepalive is not sent
until two hours of inactivity, then 9 keepalives are sent spaced 75
seconds apart. These were much too large for what I wanted: I have a
backplane ethernet between two closely-coupled systems and need to
detect loss of peer relatively quickly. I reduced them to 10 seconds
for the first keepalive, then 9 more probes sent two seconds apart.
(This is also *much* easier to test since you don't have to wait
around for two+ hours to see your session timeout. :-)
Note that the setsockopts API also lets you set the values of these,
but in that case they are specified in seconds, not milliseconds.
Jeff
Re: [lwip-users] TCP KeepAlive, gregoryhouse, 2010/09/20