Linux IPv4转发吞吐量受限

Linux IPv4转发吞吐量受限

我的症状是,我的 LAN 上的客户端 PC 通过 WG 隧道连接到远程主机的最大速度约为 250 Mbps,但实际速度可能在 150 到 300 Mbps 之间(即变化很大,需要很长时间才能稳定下来)。我在虚拟机上运行一些 WireGuard 隧道,连接到 Vultr 虚拟机。如果我运行涉及相同主机的 iperf3,我会得到相同的结果。

我读过这个:

https://serverfault.com/questions/777354/huge-performance-penalty-in-gbit-link-with-ip-forwarding-masquerade-through-cl

和评论,但我仍然没有解决问题。

但是,WG 主机之间的 iperf3 本身可以提供高达 650 Mbps 的速度。CPU 似乎不是限制因素,但我可以接受 650 而不是 250。我主要想了解其中的机制。

我最初的猜测是 AlmaLinux 9.1 的 IPv4 转发性能似乎干扰了吞吐量。在客户端连接到远程 WG 主机的情况下,中间 AL 9.1 服务器正在转发和加密。

WG 主机之间的往返时间为 10 毫秒,我知道 Linux 接收窗口是自适应的。我使用 3 个 iperf3 流进行测试,更改它不会改变总吞吐量。

在另一篇文章中,他们使用 UDP“实现”了 1 Gbps,但大多数数据包都丢失了,因此显然该链接不支持该吞吐量。我的情况也一样,最高速度约为 250 Mbps 左右。有什么设置可以使用吗?我的 sysctl.conf 中只有转发:

net.ipv4.ip_forward=1

我只是使用 Linux 主机测试了子网之间的转发,而且它是全千兆位......所以这个理论被推翻了,并解释了为什么我没有看到有关性能的最新帖子。

以下是从客户端到删除 WG 对等点的 iperf3 输出示例:

Connecting to host 10.0.33.1, port 5201
[  4] local 192.168.10.50 port 60045 connected to 10.0.33.1 port 5201
[  6] local 192.168.10.50 port 60046 connected to 10.0.33.1 port 5201
[  8] local 192.168.10.50 port 60047 connected to 10.0.33.1 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  10.4 MBytes  86.6 Mbits/sec                  
[  6]   0.00-1.00   sec  9.25 MBytes  77.2 Mbits/sec                  
[  8]   0.00-1.00   sec  5.62 MBytes  47.0 Mbits/sec                  
[SUM]   0.00-1.00   sec  25.2 MBytes   211 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   1.00-2.00   sec  11.2 MBytes  94.5 Mbits/sec                  
[  6]   1.00-2.00   sec  9.50 MBytes  79.8 Mbits/sec                  
[  8]   1.00-2.00   sec  10.0 MBytes  84.0 Mbits/sec                  
[SUM]   1.00-2.00   sec  30.8 MBytes   258 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   2.00-3.00   sec  9.62 MBytes  81.0 Mbits/sec                  
[  6]   2.00-3.00   sec  9.50 MBytes  79.9 Mbits/sec                  
[  8]   2.00-3.00   sec  9.25 MBytes  77.8 Mbits/sec                  
[SUM]   2.00-3.00   sec  28.4 MBytes   239 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   3.00-4.00   sec  9.38 MBytes  78.4 Mbits/sec                  
[  6]   3.00-4.00   sec  10.1 MBytes  84.7 Mbits/sec                  
[  8]   3.00-4.00   sec  10.1 MBytes  84.7 Mbits/sec                  
[SUM]   3.00-4.00   sec  29.6 MBytes   248 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   4.00-5.00   sec  8.38 MBytes  70.2 Mbits/sec                  
[  6]   4.00-5.00   sec  7.88 MBytes  66.0 Mbits/sec                  
[  8]   4.00-5.00   sec  10.2 MBytes  85.9 Mbits/sec                  
[SUM]   4.00-5.00   sec  26.5 MBytes   222 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   5.00-6.00   sec  9.75 MBytes  81.9 Mbits/sec                  
[  6]   5.00-6.00   sec  7.12 MBytes  59.8 Mbits/sec                  
[  8]   5.00-6.00   sec  11.0 MBytes  92.4 Mbits/sec                  
[SUM]   5.00-6.00   sec  27.9 MBytes   234 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   6.00-7.01   sec  11.1 MBytes  93.1 Mbits/sec                  
[  6]   6.00-7.01   sec  6.25 MBytes  52.3 Mbits/sec                  
[  8]   6.00-7.01   sec  11.0 MBytes  92.0 Mbits/sec                  
[SUM]   6.00-7.01   sec  28.4 MBytes   237 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   7.01-8.00   sec  10.0 MBytes  84.1 Mbits/sec                  
[  6]   7.01-8.00   sec  6.38 MBytes  53.6 Mbits/sec                  
[  8]   7.01-8.00   sec  8.00 MBytes  67.3 Mbits/sec                  
[SUM]   7.01-8.00   sec  24.4 MBytes   205 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   8.00-9.01   sec  10.8 MBytes  89.8 Mbits/sec                  
[  6]   8.00-9.01   sec  9.25 MBytes  77.3 Mbits/sec                  
[  8]   8.00-9.01   sec  9.38 MBytes  78.3 Mbits/sec                  
[SUM]   8.00-9.01   sec  29.4 MBytes   245 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   9.01-10.00  sec  8.75 MBytes  73.9 Mbits/sec                  
[  6]   9.01-10.00  sec  9.25 MBytes  78.1 Mbits/sec                  
[  8]   9.01-10.00  sec  8.00 MBytes  67.5 Mbits/sec                  
[SUM]   9.01-10.00  sec  26.0 MBytes   219 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  99.4 MBytes  83.4 Mbits/sec                  sender
[  4]   0.00-10.00  sec  99.2 MBytes  83.2 Mbits/sec                  receiver
[  6]   0.00-10.00  sec  84.5 MBytes  70.9 Mbits/sec                  sender
[  6]   0.00-10.00  sec  84.4 MBytes  70.8 Mbits/sec                  receiver
[  8]   0.00-10.00  sec  92.6 MBytes  77.7 Mbits/sec                  sender
[  8]   0.00-10.00  sec  92.5 MBytes  77.6 Mbits/sec                  receiver
[SUM]   0.00-10.00  sec   276 MBytes   232 Mbits/sec                  sender
[SUM]   0.00-10.00  sec   276 MBytes   232 Mbits/sec                  receiver

iperf Done.

相关内容