iperf测试udp带宽

本文介绍使用iperf工具进行网络带宽测试的方法,包括客户端和服务端命令行配置及测试样本分析,展示了如何通过调整参数来优化测试效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

客户端命令行:iperf -u -c 2xx.1xx.1xx.1xx -p 20001 -l 1380 -B 172.16.28.173 -t 10 -i 1 -b 1800K

e.g. 

iperf -u -c 10.12.23.47 -p 8080 -l 1380  -B 10.12.32.45 -t 10 -i 1 -b 200M

参数解释:

1) 测试对端是10.12.23.47

2) 测试对端的端口是8080

3) 数据包大小是1380个字节

4) 绑定本地网卡10.12.32.45

5) 测试持续10秒钟

6) 每隔1秒钟打印一次信息

7) 最大发送带宽200M


服务器命令行:iperf.exe -s -u -i 1 -p 8080 -l 1380


/* 
* Bandwidth Test with iperf
*
* Client Command Line:
* 1) a packet is of 1380 bytes length.
* 2) bind to a local interface 172.16.28.173
* 3) Test for 10 seconds, and every 1 second, print a recode.
* 4) limit the send Bandwidth to 1800K.
* iperf -u -c 2xx.1xx.1xx.1xx -p 20001 -l 1380 -t 10 -B 172.16.28.173  -t 10 -i 1 -b 1800K
*
* Test Sample I.
------------------------------------------------------------
Client connecting to 211.160.178.10, UDP port 20001
Binding to local address 172.16.28.173
Sending 1380 byte datagrams
UDP buffer size:  112 KByte (default)
------------------------------------------------------------
[  3] local 172.16.28.173 port 20001 connected with 211.160.178.10 port 20001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   221 KBytes  1.81 Mbits/sec
[  3]  1.0- 2.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  2.0- 3.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  3.0- 4.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  4.0- 5.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  5.0- 6.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  6.0- 7.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  7.0- 8.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  8.0- 9.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  9.0-10.0 sec   220 KBytes  1.80 Mbits/sec
[  3]  0.0-10.0 sec  2.15 MBytes  1.80 Mbits/sec
[  3] Sent 1632 datagrams
[  3] Server Report:
[  3]  0.0-10.4 sec  1.66 MBytes  1.34 Mbits/sec   9.661 ms  371/ 1631 (23%)
*
* so the bandwidth is 1.34M, with loss ratio is about 23% 
*
* Test Sample II.
------------------------------------------------------------
Client connecting to 211.160.178.10, UDP port 20001
Binding to local address 172.16.28.173
Sending 1380 byte datagrams
UDP buffer size:  112 KByte (default)
------------------------------------------------------------
[  3] local 172.16.28.173 port 20001 connected with 211.160.178.10 port 20001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  1.0- 2.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  2.0- 3.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  3.0- 4.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  4.0- 5.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  5.0- 6.0 sec   170 KBytes  1.39 Mbits/sec
[  3]  6.0- 7.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  7.0- 8.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  8.0- 9.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  9.0-10.0 sec   171 KBytes  1.40 Mbits/sec
[  3]  0.0-10.0 sec  1.67 MBytes  1.40 Mbits/sec
[  3] Sent 1270 datagrams
[  3] Server Report:
[  3]  0.0-10.1 sec  1.66 MBytes  1.38 Mbits/sec   4.779 ms    5/ 1270 (0.39%)
* 
* so the bandwidth is still about 1.38M, but with loss ratio is about 0.39%
*

* Server Command Line:
* Listen at 8080, expect packet length to 1380 bytes.
* iperf.exe -s -u -i 1 -p 8080 -l 1380
*
* Test sample I.
[  3] local 10.12.23.47 port 8080 connected with 119.6.254.189 port 1313
[  3]  0.0- 1.0 sec   206 KBytes  1.69 Mbits/sec   4.446 ms    0/  153 (0%)
[  3]  1.0- 2.0 sec   206 KBytes  1.69 Mbits/sec   4.582 ms    2/  155 (1.3%)
[  3]  2.0- 3.0 sec   181 KBytes  1.48 Mbits/sec   6.017 ms    0/  134 (0%)
[  3]  3.0- 4.0 sec   187 KBytes  1.53 Mbits/sec   3.772 ms   18/  157 (11%)
[  3]  4.0- 5.0 sec   150 KBytes  1.23 Mbits/sec   6.712 ms   47/  158 (30%)
[  3]  5.0- 6.0 sec   158 KBytes  1.29 Mbits/sec   6.847 ms   59/  176 (34%)
[  3]  6.0- 7.0 sec   150 KBytes  1.23 Mbits/sec   5.924 ms   27/  138 (20%)
[  3]  7.0- 8.0 sec   151 KBytes  1.24 Mbits/sec   7.331 ms   63/  175 (36%)
[  3]  8.0- 9.0 sec   123 KBytes  1.00 Mbits/sec   7.982 ms   48/  139 (35%)
[  3]  9.0-10.0 sec   131 KBytes  1.07 Mbits/sec  11.196 ms   76/  173 (44%)
[  3]  0.0-10.4 sec  1.66 MBytes  1.34 Mbits/sec   9.661 ms  371/ 1631 (23%)
*
* so the bandwidth is about 1.34M with loss ratio about 23%
*
* Test Sample II.
[  4] local 10.12.23.47 port 8080 connected with 119.6.254.189 port 1153
[  4]  0.0- 1.0 sec   150 KBytes  1.23 Mbits/sec   5.167 ms    0/  111 (0%)
[  4]  1.0- 2.0 sec   162 KBytes  1.32 Mbits/sec   4.087 ms    0/  120 (0%)
[  4]  2.0- 3.0 sec   187 KBytes  1.53 Mbits/sec   5.615 ms    0/  139 (0%)
[  4]  3.0- 4.0 sec   178 KBytes  1.46 Mbits/sec   6.416 ms    1/  133 (0.75%)
[  4]  4.0- 5.0 sec   179 KBytes  1.47 Mbits/sec   3.836 ms    0/  133 (0%)
[  4]  5.0- 6.0 sec   171 KBytes  1.40 Mbits/sec   3.852 ms    0/  127 (0%)
[  4]  6.0- 7.0 sec   164 KBytes  1.35 Mbits/sec   4.243 ms    1/  123 (0.81%)
[  4]  7.0- 8.0 sec   175 KBytes  1.44 Mbits/sec   4.258 ms    2/  132 (1.5%)
[  4]  8.0- 9.0 sec   127 KBytes  1.04 Mbits/sec   6.852 ms    1/   95 (1.1%)
[  4]  9.0-10.0 sec   182 KBytes  1.49 Mbits/sec   3.438 ms    0/  135 (0%)
[  4]  0.0-10.1 sec  1.66 MBytes  1.38 Mbits/sec   4.780 ms    5/ 1270 (0.39%) 
* 
* so the bandwidth is still about 1.38M, but with loss ratio 0.39%. 
*
*/

### 测试 UDP 网络性能的 `iperf` 命令用法 在使用 `iperf` 测试 UDP 网络性能时,需要分别配置服务端和客户端,并指定相关参数以实现对 UDP 传输性能的评估。 #### 服务端设置 启动 `iperf` 服务端并启用 UDP 模式,可以使用以下命令: ```bash iperf -s -u ``` 该命令会启动 `iperf` 并监听默认端口(通常为5001),同时使用 UDP 协议进行测试。若需自定义监听端口,可以通过 `-p` 参数指定端口号,例如: ```bash iperf -s -u -p 6666 ``` 此操作将使服务端在端口6666上监听来自客户端的 UDP 数据流[^1]。 #### 客户端设置 在客户端,需指定目标服务器的 IP 地址、使用的协议(UDP)、带宽以及测试持续时间等参数。基本命令如下: ```bash iperf -c <服务器IP> -u -b <带宽> -t <测试时间> ``` 其中: - `<服务器IP>` 是服务端的 IP 地址。 - `-u` 表示使用 UDP 协议。 - `-b` 后接的是希望模拟的数据传输速率,例如 `20M` 表示每秒20兆比特。 - `-t` 后接的是测试持续时间,单位为秒。 例如,向 IP 地址为 `192.168.1.107` 的服务器发送持续时间为60秒、速率为10Mbps的 UDP 数据流,命令如下: ```bash iperf -c 192.168.1.107 -u -b 10M -t 60 ``` 此命令将测试从客户端到服务器的 UDP 传输性能,并提供包括带宽、数据包丢失率及延迟抖动在内的关键指标信息[^2]。 #### 使用 `iperf3` 进行 UDP 测试 对于 `iperf3` 版本,其服务端与客户端的命令更为简洁。服务端只需运行: ```bash iperf3 -s ``` 客户端则通过以下命令发起 UDP 测试: ```bash iperf3 -c <服务器IP> -u -b <带宽> -t <测试时间> ``` 例如,向 IP 地址为 `192.168.1.107` 的服务器发送持续时间为10秒、速率为50Mbps的 UDP 数据流: ```bash iperf3 -c 192.168.1.107 -u -b 50M -t 10 ``` 此命令将返回详细的网络性能统计数据,帮助用户分析 UDP 通信的质量[^1]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值