Initial SYN timeout on linux

When establishing a TCP connection, what is the timeout for the first SYN packet sent? If no answer is received another SYN packet is resent (up to net.ipv4.tcp_syn_retries) with approximately doubling the timeout. I'm wondering how can I check or alter the initial timeout.


Solution 1:

The initial retransmission timeout setting is hardcoded in the kernel to be 1 second in modern versions: https://elixir.bootlin.com/linux/v5.9.11/source/include/net/tcp.h#L142

#define TCP_TIMEOUT_INIT ((unsigned)(1*HZ)) /* RFC6298 2.1 initial RTO value

The constant is referenced in tcp.c: https://elixir.bootlin.com/linux/v5.9/source/net/ipv4/tcp.c#L420

You cannot change it without recompiling the kernel: How can I tune the initial TCP retransmit timeout? (it seems that it used to be 3 seconds in older versions)