TCP Keep Alive
OS Configuration (Linux)
tcp_keepalive_time
Since Linux 2.2.
The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes.
(空闲时,启动探测间隔时间(秒))
$ cat /proc/sys/net/ipv4/tcp_keepalive_time
7200
$ sysctl net.ipv4.tcp_keepalive_time
net.ipv4.tcp_keepalive_time = 7200
$ sudo sysctl -w net.ipv4.tcp_keepalive_time = 3600
See tcp_keepalive_time
- tcp(7) - Debian Manpages.
tcp_keepalive_probes
Since Linux 2.2.
The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end.
(网络不可达时,重发探测次数)
$ cat /proc/sys/net/ipv4/tcp_keepalive_probes
9
$ sysctl net.ipv4.tcp_keepalive_probes
net.ipv4.tcp_keepalive_probes = 9
$ sudo sysctl -w net.ipv4.tcp_keepalive_probes = 9
See tcp_keepalive_probes
- tcp(7) - Debian Manpages.
tcp_keepalive_intvl
Since Linux 2.4.
The number of seconds between TCP keep-alive probes.
(网络不可达时,重发探测间隔时间(秒))
$ cat /proc/sys/net/ipv4/tcp_keepalive_intvl
75
$ sysctl net.ipv4.tcp_keepalive_intvl
net.ipv4.tcp_keepalive_intvl = 75
$ sudo sysctl -w net.ipv4.tcp_keepalive_intvl = 25
See tcp_keepalive_intvl
- tcp(7) - Debian Manpages.
Python Recipes
References
SO_KEEPALIVE
- socket(7) - Debian ManpagesTCP_KEEPIDLE
- tcp(7) - Debian ManpagesTCP_KEEPCNT
- tcp(7) - Debian ManpagesTCP_KEEPINTVL
- tcp(7) - Debian Manpagestcp_keepalive_time
- tcp(7) - Debian Manpagestcp_keepalive_probes
- tcp(7) - Debian Manpagestcp_keepalive_intvl
- tcp(7) - Debian Manpages- tcp(7) - Debian Manpages
- RFC 793 - TRANSMISSION CONTROL PROTOCOL (1981.9)