I have a server running on my Linux box, also on which the following commands were run:

$ cat /proc/sys/net/ipv4/tcp_keepalive_time
$ cat /proc/sys/net/ipv4/tcp_keepalive_intvl
$ cat /proc/sys/net/ipv4/tcp_keepalive_probes

My server listens on port 58080, and I create a connection on it having set TCP keep-alive in my code. I then set Wireshark tracing this connection; a screenshot of the output is shown below:


You can see that the first keep-alive packet is sent after 7200 seconds, or 2 hours as expected (the value of 'tcp_keepalive_time'). However I would also expect each probe to be sent at 75 seconds (the value of 'tcp_keepalive_intvl'); what I see though is that each probe is sent at 2 hours.

Can someone please tell me why my configuration option for 'tcp_keepalive_intvl' is not being honoured?


It seems that specifying a keep-alive interval that is greater than the keep-alive time results in the interval time being adhered to...

2 Answers 2


After discussion with a super-smart colleague, we think we have figured out what's wrong, but are yet to prove this. What is likely happening is that the keep-alive interval is only taken into account when no keep-alive ACK is received. So after 2 hours, if no ACK was received to this first keep-alive packet, a second packet would be sent after 75 seconds and repeatedly at 75 second intervals until an ACK was received.

It turns out that the reason the interval is taken into account only when it is greater than the keep-alive time is due to the way the Linux keep-alive mechanism works, as described on my other question.


Indeed, from the documentation :


the interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive probe; after the connection is marked to need keepalive, this counter is not used any further


the interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime


the number of unacknowledged probes to send before considering the connection dead and notifying the application layer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .