* keep-alive on tcp/ip-socket connections
@ 1996-10-21 4:00 Ole Joergensen
1996-10-21 4:00 ` David P Cutter
0 siblings, 1 reply; 4+ messages in thread
From: Ole Joergensen @ 1996-10-21 4:00 UTC (permalink / raw)
Does anybody know how to control sending of 'keep-alives' on
tcp-connections
(OSF/1 - alpha platforms) ?
The problem arises when programming tcp at the socket-level (in C).
Consider, as an example, a proces running under OSF (on an alphabox)
which communicates with a proces running on (say) a PC via a connected
pair of tcp/ip-sockets.
If the pc is turned of (or explodes or whatever) the socket-software
on the PC won't have time to tell that it's going down and the
socket-software on the alphabox will not recieve any notification that
the connection is
broken.
To deal with this one needs to set up the tcp-connection so that it is
periodically probed
by sending 'keep-alives'. This is indeed possible in C, under OSF. In
the file
/usr/include/netinet/tcp_timers.h
two constants are defined:
#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* dflt time before probing
*/
#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* default probe interval */
and this, as far as I understand, means that the first keep-alive will
be sendt
2 hours after establishing the connection, and then keep-alives will be
sendt every
75 seconds.
The question is then: How does one change this? How can you make the
probing start as soon
as the connection is established?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: keep-alive on tcp/ip-socket connections
1996-10-21 4:00 keep-alive on tcp/ip-socket connections Ole Joergensen
@ 1996-10-21 4:00 ` David P Cutter
1996-10-22 4:00 ` Glen Turner
1996-10-23 4:00 ` Jeffrey Mogul
0 siblings, 2 replies; 4+ messages in thread
From: David P Cutter @ 1996-10-21 4:00 UTC (permalink / raw)
In article <54fqd5$m4e@news.uni-c.dk>, Ole Joergensen <oj@dk-online.dk> wrote:
>Does anybody know how to control sending of 'keep-alives' on
>tcp-connections
>(OSF/1 - alpha platforms) ?
>
>The problem arises when programming tcp at the socket-level (in C).
>
[...stuff deleted...]
>
>The question is then: How does one change this? How can you make the
>probing start as soon
>as the connection is established?
>
Yes! I've been complaining about this one for a while. We have to solve
the same type of problems as described above.
Most TCP/IP vendors do not allow a programmer to specify a timer value
for keep-alives. And on top of that, there is no way to specify a
different timer per/socket - it's global value based per net interface.
For that reason most vendors implement these values in the kernel. On
Solaris we can use the ndd utility to change these values, on DUnix
edit /sys/conf/<SYSNODE> and add/change the tcp_keepidle, tcp_keepintvl
values [...opps, I never did try this on DUnix...]. If the kernel
config doesn't work, you may have to "adb" the kernel and change the
values by hand (yuk).
Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: keep-alive on tcp/ip-socket connections
1996-10-21 4:00 ` David P Cutter
@ 1996-10-22 4:00 ` Glen Turner
1996-10-23 4:00 ` Jeffrey Mogul
1 sibling, 0 replies; 4+ messages in thread
From: Glen Turner @ 1996-10-22 4:00 UTC (permalink / raw)
David P Cutter wrote:
>
> In article <54fqd5$m4e@news.uni-c.dk>, Ole Joergensen <oj@dk-online.dk> wrote:
> >Does anybody know how to control sending of 'keep-alives' on
> >tcp-connections
> >(OSF/1 - alpha platforms) ?
> >...
> >The question is then: How does one change this? How can you make the
> >probing start as soon
> >as the connection is established?
> >
> Yes! I've been complaining about this one for a while. We have to solve
> the same type of problems as described above.
>
> Most TCP/IP vendors do not allow a programmer to specify a timer value
> for keep-alives. And on top of that, there is no way to specify a
> different timer per/socket - it's global value based per net interface.
> For that reason most vendors implement these values in the kernel. On
> Solaris we can use the ndd utility to change these values, on DUnix
> edit /sys/conf/<SYSNODE> and add/change the tcp_keepidle, tcp_keepintvl
> values [...opps, I never did try this on DUnix...]. If the kernel
> config doesn't work, you may have to "adb" the kernel and change the
> values by hand (yuk).
This is because most network programmers, me included, see
keep-alives as something to be discouraged in a global internet.
(Try asking this question in comp.protocols.tcpip and you'll see
what I mean.)
If the user is using the application, there will be traffic enough
to see if the link goes down. If the user isn't using the application,
than what does it matter if the link goes down and is restored
before the next packet?
At the program level, network problems can't be predicted, so network
programs need to be robust enough to cope with errors at any I/O.
So there is no difference to the programmer if a network error
is delivered instantaneously, or when convenient. A classic
mistake of C programmers is to write:
(void)fclose(output_file);
as if no error could occur on closing a file, whereas that is
where most I/O errors are reported, as it forces an end-to-end
write of buffers.
From what I have seen in the past, TCP keep-alives are usually
a substitute for a lack of design for robustness. This can
be best seen in the SQL stacks of database manufacturers, where
they maintain large amounts of inappropiate state information
on the servers.
Some applications, escpecially authentication protocols, need
keep-alives to log out users of rebooted machines. However,
this is a matter for the protocol, not for TCP, as these keep-alives
need to be authenticated to prevent session capture.
--
glen.turner@itd.adelaide.edu.au Network Support Specialist
Tel: (08) 8303 3936 Information Technology Division
Fax: (08) 8303 4400 University of Adelaide SA 5005
--
There are two major products that came out of Berkeley:
LSD and UNIX. This is no coincidence.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: keep-alive on tcp/ip-socket connections
1996-10-21 4:00 ` David P Cutter
1996-10-22 4:00 ` Glen Turner
@ 1996-10-23 4:00 ` Jeffrey Mogul
1 sibling, 0 replies; 4+ messages in thread
From: Jeffrey Mogul @ 1996-10-23 4:00 UTC (permalink / raw)
In article <54g21p$fum@rit.cs.rit.edu>, dpc6787@illinois.cs.rit.edu (David P Cutter) writes:
|> In article <54fqd5$m4e@news.uni-c.dk>, Ole Joergensen <oj@dk-online.dk> wrote:
|> >Does anybody know how to control sending of 'keep-alives' on
|> >tcp-connections (OSF/1 - alpha platforms) ?
|> >
|> >The problem arises when programming tcp at the socket-level (in C).
|> >
|> [...stuff deleted...]
|> >
|> Yes! I've been complaining about this one for a while. We have to solve
|> the same type of problems as described above.
|>
|> Most TCP/IP vendors do not allow a programmer to specify a timer value
|> for keep-alives. And on top of that, there is no way to specify a
|> different timer per/socket - it's global value based per net interface.
|> For that reason most vendors implement these values in the kernel. On
|> Solaris we can use the ndd utility to change these values, on DUnix
|> edit /sys/conf/<SYSNODE> and add/change the tcp_keepidle, tcp_keepintvl
|> values [...opps, I never did try this on DUnix...]. If the kernel
|> config doesn't work, you may have to "adb" the kernel and change the
|> values by hand (yuk).
Actually, in Digital UNIX V4.0, you can indeed set the TCP keepalive
parameters per-socket. See "man 7 tcp", wherein it is written:
TCP_KEEPIDLE
When the SO_KEEPALIVE option is enabled, TCP probes a connection that
has been idle for some amount of time. The default value for this idle
period is 2 hours. The TCP_KEEPIDLE option can be used to affect this
value for a given socket, and specifies the number of seconds of idle
time between keepalive probes. This option takes an int value, with a
range of 1 to N (where N is tcp_keepidle divided by PR_SLOWHZ). For
more information on tcp_keepidle see the information on the inet sub-
system configuration attributes in the System Tuning and Performance
Management guide. PR_SLOWHZ is defined in the <sys/protosw.h> header
file.
Similarly for TCP_KEEPINTVL and TCP_KEEPCNT, and a few other knobs
to twiddle.
-Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1996-10-23 4:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-10-21 4:00 keep-alive on tcp/ip-socket connections Ole Joergensen
1996-10-21 4:00 ` David P Cutter
1996-10-22 4:00 ` Glen Turner
1996-10-23 4:00 ` Jeffrey Mogul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox