iperf TCP 比 UDP 快得多,为什么?

now*_*wox 4 udp tcp iperf

我想知道为什么 iperf 在 TCP 中表现出比 UDP 更好的性能。这个问题和这个问题非常相似。

UDP 应该比 TCP 快得多,因为没有确认和拥塞检测。我正在寻找解释。

UDP(807 兆比特/秒)

$ iperf -u -c 127.0.0.1 -b10G
------------------------------------------------------------
Client connecting to 127.0.0.1, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 127.0.0.1 port 52064 connected with 127.0.0.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   962 MBytes   807 Mbits/sec
[  3] Sent 686377 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec   960 MBytes   805 Mbits/sec   0.004 ms 1662/686376 (0.24%)
[  3]  0.0-10.0 sec  1 datagrams received out-of-order
Run Code Online (Sandbox Code Playgroud)

TCP(26.7 吉比特/秒)

$ iperf -c 127.0.0.1
------------------------------------------------------------
Client connecting to 127.0.0.1, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[  3] local 127.0.0.1 port 60712 connected with 127.0.0.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  31.1 GBytes  26.7 Gbits/sec
Run Code Online (Sandbox Code Playgroud)

A J*_*eph 7

UDP 数据报的默认长度为 1470 字节。您可能需要使用 -l 参数增加长度。对于 26Gb/s,我会尝试使用 -l 参数,例如 50000,然后从那里向上或向下

您可能还需要在“-b10G”之间添加一个空格,以便它知道 10G 是用于 -b 参数的值。我还相信大写的 G 意味着 GigaBYTES。TCP 测试可实现的最大带宽为 26 GigaBITS,与 10GB 相差甚远。我会将 -b 参数值设置为 26g,并使用小写的 g。