取得 Linux 上 TCP initcwnd 的目前/預設值

取得 Linux 上 TCP initcwnd 的目前/預設值

我可以透過以下方式操縱這樣的值:

ip route change ... initcwnd 10

然後獲得回饋:

ip route show

但是修改之前的預設值呢?有沒有辦法從系統查詢該值?

或者,您可以提供一個有效的顯示每個核心版本的預設硬編碼值的參考?

答案1

我不太確定,但這似乎是一個合法的參考

直覺:

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

出去:

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

答案2

好吧,我不能說我 100% 確定這應該是答案,但是,正如它經常出現的那樣,ss是透露一些資訊的好選擇,例如:

 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擺脫煩人的 DNS 解析的典型方法-l是,我們只堅持偵聽套接字,-i(關鍵)是「顯示內部 TCP 資訊」。可以看到,擁塞演算法和預設cwnd都被顯示了。

答案3

如果我理解正確的話,您正在尋找snd_cwnd初始化 TCP 套接字時設定的參數的初始值。

看起來從linux核心開始,引入了2.6.39一個宏TCP_INIT_CWNDlinux/include/net/tcp.hsnd_cwnd它填充初始化 TCP 套接字時的值。

我知道這段程式碼在核心中的位置IPv4,不幸的是它似乎沒有使用任何巨集來填充早於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;

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

類似的初始化程式碼IPv6也存在於tcp_v6_init_sock()函數內部net/ipv6/tcp_ipv6.c

相關內容