Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jul 1997 11:07:20 -0700 (PDT)
From:      Vinay Bannai <vinay@agni.nuko.com>
To:        ormonde@trem.cnt.org.br (Rodrigo Ormonde)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: keepalive time interval
Message-ID:  <199707211807.LAA02995@agni.nuko.com>
In-Reply-To: <9707211418.AA31840@trem.cnt.org.br> from "Rodrigo Ormonde" at "Jul 21, 97 12:18:34 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
According to Rodrigo Ormonde:
>   Hello.
> 
>   I'm writing a daemon process that listens to connections on a socket. I 
> don't want to have my daemon waiting forever to receive data from a dead
> client, so I'm using the SO_KEEPALIVE option on the socket. The problem is
> that the default time that the system waits until it discover that the 
> client no longer exists is too long for my needs.
> 
>   Is there a way to change this default time by a system call ? If it's not
> possible, could someone point me what I have to change in the kernel source
> code to reduce this value ?
> 
>   Thanks in advance.
> 
>   P.S. Please send a copy of the answers to me, I'm not on the list.
> 
> -- 
> Rodrigo de La Rocque Ormonde
> e-mail: ormonde@cnt.org.br
> PGP Public key: finger ormonde@cnt.org.br 
> 
> -> Turn your PC into a workstation - Use FreeBSD ! <-

Well, keeptime timer is reset to 2 hours every time a segment is received
for the connection. If the keepalive option is set for the socket then
this timer is enforced by dropping the connection after a set number of no
responses to the probes (this comes to 9 probes set at 75 seconds
apart). The first probe is sent after 2 hours of idle time. 

Now to change these default values, you have to edit the tcp timers file 
  /usr/src/sys/netinet/tcp_timers.h

The variables that you would be interested in messing around would be

TCPTV_KEEP_INIT	
TCPTV_KEEP_IDLE	
TCPTV_KEEPINTVL	
TCPTV_KEEPCNT	

But, remember change at your own peril. If you make the keep alive timers
smaller than the RTT (which itself varies based on the congestion on the
network) then you have to deal with connections getting dropped for
problems other than network connectivity.

A more elegant solution would be to use the application level probes and
not depend on the TCP keep alives, which are not a requirement for the TCP
implementation as per the RFC's.

Vinay
-- 
Vinay Bannai                     E-mail: vinay@agni.nuko.com
(408)-526-0280 x 275 (Work)     http://agni.nuko.com/~vinay




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