【问题标题】:Get cwnd of my TCP connection from a program从程序中获取我的 TCP 连接的 cwnd
【发布时间】:2022-01-17 14:56:02
【问题描述】:

我正在使用 boost.asio 从我的 linux 程序创建 TCP 连接。我想知道如何从程序中获取其拥塞窗口(cwnd)的值?我知道的唯一方法是解析/proc/net/tcp,但这感觉不对。我宁愿使用专门的系统调用来获取此信息。

类似问题的解决方案 (How to monitor cwnd and ssthresh values for a TCP connection?) 建议使用 TCP Probe,但感觉更不吸引人。

那么获取 cwnd 值的最佳方法是什么?

【问题讨论】:

  • 拥塞窗口是单侧的,不与另一侧通信。它也不断变化,一直增长直到出现问题,然后在再次增长之前缩小。你永远无法从接收者那里得到发送者的拥塞窗口。
  • 我明白这一点,我只想知道我的拥塞窗口现在
  • 我认为this question 的答案也能回答你的问题
  • 这里也是struct tcp_infotcpi_snd_cwnd(第 246 行)应该是拥塞窗口。

标签: c++ linux networking tcp congestion-control


【解决方案1】:

我根据这个有用的示例使用 netlink 和 INET_DIAG-sockets 做到了这一点:https://github.com/kristrev/inet-diag-example

【讨论】:

    【解决方案2】:

    事实证明,getsockopt() 在使用TCP_INFO 选项调用时能够返回相同的tcp_info

      tcp_info tcpi = {};
      socklen_t len = sizeof(tcp_info);
      getsockopt(tcp_socket, SOL_TCP, TCP_INFO, &tcpi, &len);
      tcpi.tcpi_snd_cwnd;  // <-- CWND
    

    【讨论】:

      猜你喜欢
      • 2022-09-26
      • 1970-01-01
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      相关资源
      最近更新 更多