LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   tcp keepalive - why new connections have value slightly greater than value I just set. (https://www.linuxquestions.org/questions/linux-networking-3/tcp-keepalive-why-new-connections-have-value-slightly-greater-than-value-i-just-set-4175600415/)

myjess 02-23-2017 04:15 AM

tcp keepalive - why new connections have value slightly greater than value I just set.
 
Hi,
I have executed this command
sysctl -w net.ipv4.tcp_keepalive_time=2925
which reduces the keepalive time from the default 7200 seconds down to 2925 seconds.

But, for some reason, some new connections seem to start at a value of 2930 or thereabouts when I execute the command
netstat -an --timers | grep ESTAB

Can anyone explain this?

Thank you.

dijetlo 02-24-2017 05:37 AM

I think, with netstat, you're measuring the remaining interval
Try running this shell script, add to the grep to limit the output to one of the sockets that exhibits this behaviour
Quote:

#!/bin/sh
erp=1
netstat -ano | head -2 | tail -1 | awk '{ print " --- " $8 " ------- " $9}'
while [ $erp -le 10 ]
do
netstat -ano | grep keepalive | awk '{print $6 " " $7 " " $8}'
sleep 1
erp=$(( $erp+1 ))
done
It gives me this output.
Quote:

--- State ------- Timer
ESTABLISHED keepalive (31.76/0/0)
ESTABLISHED keepalive (30.75/0/0)
ESTABLISHED keepalive (29.74/0/0)
ESTABLISHED keepalive (28.72/0/0)
ESTABLISHED keepalive (27.71/0/0)
ESTABLISHED keepalive (26.69/0/0)
ESTABLISHED keepalive (25.68/0/0)
ESTABLISHED keepalive (24.67/0/0)
ESTABLISHED keepalive (23.66/0/0)
ESTABLISHED keepalive (22.65/0/0)

If you see the same thing, look at the application that's associated with the socket, since keep_alive can be manipulated by the application layer or the peer you're connected to

dijetlo 02-24-2017 06:16 AM

And BTW, good question for your second post.


All times are GMT -5. The time now is 08:05 PM.