TCP Keep-Alive Messages
A Keep-Alive telegram is a confirmation message or an acknowledge. This makes it possible to check in the background whether a communication partner who has established a connection is still active and thus still participating in the communication. If a communication partner is no longer active, the communication channel is closed cleanly and regularly to be free for a new participant.
Keep-Alive under Windows
Keep-Alive can be configured under Windows by the keys "KeepAliveTime" and "KeepAliveInterval" in the registry. The default value for the keep alive time is set to two hours, the interval time, i.e. the time until a non-answered alive request is repeated, is set to one second by default. All values are given in milliseconds. If the corresponding keys do not already exist in the registry, they must be created as follows.
![]() | These are not TwinCAT settings, but specific settings of the operating system. Further information can therefore be found in the operating system documentation, for example, on the Microsoft website. |
Under Windows W2K, XP, Windows Embedded Standard:
- In the folder HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ an object named KeepAliveTime must be created as DWORD. To do this, add Edit > New > DWORD Value. If you set 0x4E20 as the value here, this corresponds to 20 seconds.
- In the folder HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ an object named KeepAliveInterval must be created as DWORD. To do this, add Edit > New > DWORD Value. If you set 0x1388 as value here, this corresponds to 5 seconds.
Under Windows CE:
- In the folder HKEY_LOCAL_MACHINE\Comm\TcpIp\Parms\ an object with the name KeepAliveTime must be created as DWORD. To do this, add Edit > New > DWORD Value. If you set 0x4E20 as the value here, this corresponds to 20 seconds.
- In the folder HKEY_LOCAL_MACHINE\Comm\TcpIp\Parms\ an object named KeepAliveInterval must be created as DWORD. To do this, add Edit > New > DWORD Value. If you set 0x1388 as value here, this corresponds to 5 seconds.


Keep-Alive under TC/BSD
The "sysctl" parameters are used by the operating system to configure TCP Keep-Alive messages.
keepidle
: Amount of time, in milliseconds, that the connection must be idle before keepalive probes (if enabled) are sent. The default is 7200000 msec (2 hours).keepintvl
: The interval, in milliseconds, between keepalive probes sent to remote machines, when no response is received on a keepidle probe. The default is 75000 msec.
> sysctl -d net.inet.tcp | grep -e keep
net.inet.tcp.keepidle: time before keepalive probes begin
net.inet.tcp.keepintvl: time between keepalive probes
net.inet.tcp.keepinit: time to establish connection
net.inet.tcp.keepcnt: Number of keepalive probes to send
net.inet.tcp.always_keepalive: Assume SO_KEEPALIVE on all TCP connections
Sample:
keepidle is set to 4000 (ms) and keepintvl to 4000 (ms).
sysctl net.inet.tcp.keepidle=4000
sysctl net.inet.tcp.keepintvl=4000
Permanent (persistent) configuration of TCP Keep-Alive messages is done in the file /etc/sysctl.conf.
See also here: https://www.freebsd.org/cgi/man.cgi?query=tcp