Get the current/default value of TCP initcwnd on Linux

I don't really know for sure, but this seems like a legit reference

Hunch:

$ grep -A 2 initcwnd `find /usr/src/linux/include -type f -iname '*h'`

out:

/usr/src/linux/include/net/tcp.h:
/* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */
#define TCP_INIT_CWND          10

Well, I can't say I'm 100 % sure this should be the answer, buuut, as it often comes, ss is the good choice to get some info revealed, for e. g.:

 ss -nli|fgrep cwnd
     westwood rto:1000 mss:536 cwnd:10
     westwood rto:1000 mss:536 cwnd:10
     westwood rto:1000 mss:536 cwnd:10

-n is typical to get rid of annoying DNS resolving, -l is we stick to listening sockets only and -i (the key) is "Show internal TCP information". As it can be seen, both congestion algorithm and default cwnd are shown.


If I understood you correctly, you're looking for the initial value of the snd_cwnd parameter set when a TCP socket is initialized.

It looks like starting with linux kernel 2.6.39, a macro TCP_INIT_CWND has been introduced in linux/include/net/tcp.h which populates the value of snd_cwnd when initializing a TCP socket.

I know where this code is in the kernel for IPv4, and unfortunately it does not seem to use any macro to populate the value for kernels older than 2.6.39

/* net/ipv4/tcp_ipv4.c from 2.6.37 kernel */
static int tcp_v4_init_sock(struct sock *sk)
{
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);

        ....
        ....
        ....

        /* So many TCP implementations out there (incorrectly) count the
         * initial SYN frame in their delayed-ACK and congestion control
         * algorithms that we must have the following bandaid to talk
         * efficiently to them.  -DaveM
         */
        tp->snd_cwnd = 2;

        ....
        ....
        ....
}

A similar init code exists for IPv6 as well inside tcp_v6_init_sock() function in net/ipv6/tcp_ipv6.c

Tags:

Linux

Tcp