Re: keep-alive doesn't seem to work on 2.3.13

Bradley M Keryan (keryan@andrew.cmu.edu)
Sat, 25 Dec 1999 19:41:36 -0500 (EST)


On Sat, 25 Dec 1999, Richard B. Johnson wrote:

>
> The default keep-alive time is a long time to wait.
> cat /proc/sys/net/ipv4/tcp_keepalive_time
> 10800
>
> Therefore I set it to 60. I suppose this means 60 seconds.

RFC 1122 says:

Keep-alive packets MUST only be sent when no data or
acknowledgement packets have been received for the
connection within an interval. This interval MUST be
configurable and MUST default to no less than two hours.

The default is 3 hours, which is reasonable. It appears that the keepalive
timer is only checked every 75 seconds anyway.

And I just noticed that the comment in tcp.h says "two hours" instead of
"three hours".

>
> I do:
> int on = 1;
> setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on));
>
> It returns no errors, so this should mean that it's been accepted.
> I do this with both an echo-sender and an echo-receiver, not the
> default null-sink, because who knows what it's configured for.
>
> The client does:
> write(s, buf, len);
>
> The server does:
> read(s, buf, sizeof(buf));
>
> Everything runs fine, 8.5 megabytes/second on a dedicated 100Mb line.
> If I disconenct the wire, I would expect that either the server or
> the client would give up and return an error code within some
> reasonable period of time. This is not true. Neither the client nor
> the server will give up even after 4 days.
>
> My Sun, although not obviously configurable, gives up after 2 minutes.

I think that's related to user timeout (SO_SNDTIMEO and SO_RCVTIMEO?), not
keepalives. Keepalives are for keeping an idle link alive. Your problem is
making a dead link give up.

> Question:
> How do I make keepalive work?

If you open a TCP connection and don't send/receive anything for 3 hours
then it should send a keep-alive packet. I'm not sure if it does though.

Brad

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/