Consultor Eletrônico



Kbase 13493: FAQ on TCP Keepalive for UNIX
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/13/2009
Status: Verified

GOAL:

FAQ on TCP Keepalive for UNIX

GOAL:

What is keepalive?

GOAL:

How to set up keepalive?

FACT(s) (Environment):

UNIX
Progress/OpenEdge Product Family

FIX:

Q: What is the Socket Keepalive Option?
A: The Keepalive socket option is a process. When there is no other activity on a given socket, periodic transmissions are made to ensure that the connection is still operating properly.

Q: How do I know if my Socket implementation supports the Keepalive option?
A: Your system supports the Keepalive process if in the file usr/sys/socket.h, or /usr/include/sys/socket.h depending on the OS, the following line exists:
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
Q: How long has the Keepalive process existed?
A: The Keepalive process is really a part of TCP/IP and has been around for many years.

Q: Is the Keepalive option the same for all platforms?
A: No. Keepalive is TCP/IP and Socket implementation specific. However, it should behave the same on most Progress platforms.

Q: Do other protocols have a similar process?
A: Yes, SPX has the so-called connection watchdog.

Q: When should you use the Keepalive process?
A: If you have clients who "go away" without telling the server, the Keepalive process properly terminates the connection/session.

Q: How can a client "go away" without telling the server?
A: If:
- The client turns your machine off.
- There is a hard network failure (for example, a cable problem).
- The machine hangs.

Q: Are there any side effects of the Keepalive?
A: The Keepalive process generates a few small probe packets. These packets have very small bandwidth requirements and should not affect performance.

Q: How long does it take to notice that a client has "gone away" using Keepalive?
A: It depends on kernel parameters.

Q: What are these kernel parameters?
A: In the file /usr/sys
etinet/tcp_times.h, there are three parameters:
- On some platforms, this file is in: /usr/include
etinet/tcp_timer.h

#define TCPTV_KEEP_IDLE /* default time before probing, idle time */
#define TCPTV_KEEPINTVL /* default probe interval, time between probes */
#define TCPTV_KEEPCNT /* max probes before drop */
Q: Can I change these parameters?
A: Yes, and then you must rebuild your kernel.

Q: Are there any side effects in changing these parameters?
A: Yes, all socket-based processes use the parameters such as rlogin or telnet. Hence, you should keep this in mind.

Q: Are there any guidelines for changing these parameters?
A: Yes:
TCPTV_KEEP_IDLE should be greater than 15 mins.
TCPTV_KEEPINTVL should be greater than 1 min.
TCPTV_KEEPCNT should be greater than 6.

Q: How can I test if the Keepalive is working properly?
A: Start up a client and then cause a hard network failure pulling off the network cable. The server should disconnect the client based on the time specified by the above parameters. For example, in: /usr/sys
etinet/tcp_timer.h or /usr/include
etinet/tcp_timer.h

#define TCPTV_KEEP_IDLE (120*60*PR_SLOWHZ) /* two hours */
#define TCPTV_KEEPINTVL ( 75*PR_SLOWHZ) /* 1 min 15 sec */
#define TCPTV_KEEPCNT 8 /* number of failures */
After there is no activity on the socket for 2 hours, the server starts to probe the client every 75 seconds. If eight (8) of these probes fail, the server disconnects the client. In other words, it takes 2 hours and 10 mins to disconnect the client.

Q: Why is the TCPTV._KEEP_IDLE set to two hours?
A: Remember that the probing process generates network traffic and you should only start the probing after an extended idle time.
Keep in mind that users (client) go to lunch, have meetings, etc. and the server should not start to probe until it (the server) thinks the user0 has gone away for good..