How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

Post by George Walfo » Sat, 17 Jun 2000 04:00:00



This is a Linux Networking Question (I think my first question got
nuked because it appeared to be an NT question...)

We are using a Pervasive SQL v.7 Database on a Linux server, our
clients attach to this database via TCP/IP. There is a problem that
can occur with the database: If a client crashes it will take up to
two hours for the server to recognize that the client has crashed and
attempt a reconnect to the client. This is because the default TCP/IP
timeout is set to two hours. (At least this is what Pervasive tells
us, we have not had a client crash yet.(The clients HAVE to be windows
based))

So, if a client crashes it cannot connect to the server for a full two
hours (after coming back up naturally!) until the server times out the
TCP/IP connection. The solution for this (under NT not Linux) is to
edit the registry to modify the keepalive time and then reboot the
machine. At least this is the solution that we were sent by Pervasive.

Apparently (?) this timeout is standard in TCP/IP and most likely in
Linux. What is the default keepalive time and how can it be changed?
(there seems to be no setting of any kind like that in ifconfig)
Will this be a problem with Linux or does Linux handle the connections
in a completly different way?

Basically, what I am asking is how often does the Linux kernel poll
active TCP/IP connections to see if they are up? And, if that time is
(like the mail message below says) the same as NT's two hours, how do
I shorten it???

The body of the (NT oriented) Email from pervasive follows:

Thanks

========================================================

Title:  TCP/IP Connections Appear in Btrieve Monitor After Workstation
Is Powered Down

Goal:   TCP/IP Connections Appear in Btrieve Monitor After Workstation
Is Powered Down

Fact:   Pervasive.SQL v7

Fact:   TCP/IP Protocol

Symptom:        TCP/IP connection remains active to the MicroKernel
engine when a workstation is powered down or rebooted without cleanly
disconnecting from the server.

Cause:   By default, the Windows NT Server TCP/IP service will not
poll an inactive TCP/IP connection unless the connection has been idle
for approximately two hours. Thus, if a workstation establishes a
connection with the MicroKernel engine via TCP/IP and is powered down
or rebooted without cleanly disconnecting from the server, no
indication that the connection has failed is given to the MicroKernel
engine for two hours, and therefore the connection remains active to
the MicroKernel engine during that time. You may use the Btrieve
monitor to delete a connection in that state.

Fix:    For inactive connections to be detected sooner than the
default two hours, change the Windows NT registry database as follows:

a)      Open up the
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"
key using the standard registry editor (REGEDT32.EXE).

b)      Add or set the following value: Value name: KeepAliveTime
type: REG_DWORD data: which is a numeric value representing the number
of milliseconds after which "keep alive" messages will be sent across
the network in case of inactive connections.

c)      Reboot your machine.

NOTE: The "KeepAliveTime" setting affects the whole TCP/IP protocol
stack not just Pervasive.SQL. This information is also on the
Microsoft Knowledgebase, go to
http://support.microsoft.com/support/kb/articles/Q120/6/42.asp

========================================================

 
 
 

How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

Post by George Walfo » Sat, 17 Jun 2000 04:00:00


If anyone is interested I found the answer by grepping the kernel for
keepalive.
Its in the kernel documentation. It does default to 2 hours (7200
seconds) the value is an integer.
You can set this by:
echo 7200 > /proc/sys/net/ipv4/tcp_keepalive_time
this will set it to a 2 hour timeout.
however,
echo 1800 > /proc/sys/net/ipv4/tcp_keepalive_time
sets it to 30 min.
Thought you might like to know. :)

*DAMN* You have to love access to the source!

 
 
 

How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

Post by Tom East » Sat, 17 Jun 2000 04:00:00



>Basically, what I am asking is how often does the Linux kernel poll
>active TCP/IP connections to see if they are up? And, if that time is
>(like the mail message below says) the same as NT's two hours, how do
>I shorten it???

The default is two hours and can be changed by storing a new value into
/proc/sys/net/ipv4/tcp_keepalive_time. You'll need to set the value
each time that you boot (in RedHat 6.2, you should be able to do this by
modifying /etc/sysctl.conf).

For more about ip-related settings in /proc, see
/usr/src/linux/Documentation/ip-sysctl.txt.

-Tom
--
Tom Eastep             \  Eastep's First Principle of Computing:
ICQ #60745924           \  "Any sane computer will tell you how it

Shoreline, Washington USA \___________________________________________

 
 
 

How is the KeepAliveTime in the TCP/IP protocol stack handled in Linux?

Post by Michael Muelle » Sun, 18 Jun 2000 04:00:00


Hi George,


> can occur with the database: If a client crashes it will take up to
> two hours for the server to recognize that the client has crashed and
> attempt a reconnect to the client. This is because the default TCP/IP

Usally the client connects to the server rather than the server to the
client.

Quote:> So, if a client crashes it cannot connect to the server for a full two
> hours (after coming back up naturally!) until the server times out the

Why not? If the database implements a restriction to one session per
client, shouldn't it then close the old connection as soon as a new one
got established by the means of the application? If it does not I would
call it *broken*. The closed socket then will cleanup quite rapidly
since the client should send a RST as answer to the packet(s) generated
now.

Quote:> TCP/IP connection. The solution for this (under NT not Linux) is to
> edit the registry to modify the keepalive time and then reboot the
> machine. At least this is the solution that we were sent by Pervasive.

See /proc/sys/net/ipv4/tcp_keepalive_* for the current settings. They
also can be adjusted there. There is no need to reboot after the change.
However it will not be stored permanently. So you have to perform the
change from one of the init-scripts if you wish it to stay modified
after a reboot.

Quote:> Apparently (?) this timeout is standard in TCP/IP and most likely in
> Linux. What is the default keepalive time and how can it be changed?

It defaults to 7200 seconds too. Notice the remark about the system-wide
application of the new value remains valid for Linux. Additionally it is
only of use if the application (here your SQL server) does enable this
feature for the socket in question.

Quote:> (there seems to be no setting of any kind like that in ifconfig)

Ifconfig is for configuring network interfaces not sockets or global
options of the TCP protocol.

Malware

 
 
 

1. tcp/ip protocol stack

Is it possible to either globally or locally put a module between the transport
and network layer modules in the Solaris 2.[34] tcp/ip protocol stack with out
having access to source?  By globally, I mean for all processes and by locally
I will allow a nonstanard initialization, but it must be transparent to all
normal network interface calls.  Where can I find documentation on how to do it?
Thank you.

        Paul T. Keener
        Department of Physics and Astronomy
        University of Pennsylvania

2. command by alias

3. TCP/IP Protocol stacks

4. Konqueror SSL support broken?

5. TCP/IP protocol Stack

6. question obout "vmstat" and "sar -r" "swap -l"

7. IP Accounting doesn't work for PPP dial-ins :-(( ??

8. Philosophical question about emulator

9. Sherlock linux plug-ins / sherlock for linux?

10. Packets from bottom of TCP/IP stack direct to application bypassing stack

11. List of plug-ins for linux/netscape please!

12. Errors compiling Wingz 1.4 Add-ins (Linux 1.3.99, GCC 2.6)

13. Linux and Dial-ins (?)