Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Mar 2000 17:06:53 -0800
From:      Scott Hess <scott@avantgo.com>
To:        Veaceslav Revutchi <sl@dnt.md>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: tcp_keepalives, how to set the idle time
Message-ID:  <20000330170653.A1084@avantgo.com>
In-Reply-To: <Pine.BSF.4.10.10003302150180.59947-100000@zeus.dnt.md>
References:  <Pine.BSF.4.10.10003302150180.59947-100000@zeus.dnt.md>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 30, 2000 at 09:54:56PM +0300, Veaceslav Revutchi wrote:
> Can anyone explain a little how tcp_keepalives work? 
> Is tcp sending keepalive packets to the other side 
> waiting for a reply? 
> I actually need to know how can I set the stale time at 
> 5min for example so that if there is no traffic on the
> socket for 5 min. it should close it.

Set the sysctl net.inet.tcp.always_keepalive to 1 to enable
keepalives.  Once enabled, net.inet.tcp.keepidle gives the
number of seconds before the first keepalive packet.
net.inet.tcp.keepintvl gives the number of seconds between
additional keepalive packets.  If 8 keepalive packets are sent
with no response, the connection is dropped.

It sounds like you probaby want to do something like:

sysctl -w net.inet.tcp.always_keepalive=1
sysctl -w net.inet.tcp.keepidle=150
sysctl -w net.inet.tcp.keepintvl=20

I don't think you can use sysctl to set the number of keepalive
packets to wait for before terminating the connection.

You can turn on keepalive on a per-socket basis using setsockopt().
It's not obvious to me if you can adjust the other values the same
way, though I would assume that the same sysctl values are used.

Later,
scott


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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