「Networking」- 使用 iperf 工具,测试网络吞吐

问题描述

通过 iperf 工具,可以测试两台主机间网络吞吐,比如带宽、延迟、抖动、丢包等等。它可以测试 TCP 吞吐,也可以测试 UDP 吞吐。

该笔记将记录:如何使用 iperf 进行网络吞吐测试。

解决方案

拓扑简述

测试两台主机间的吞吐,需要在两台主机中同时运行 iperf 命令:
1)host-0 作为 Server 运行(iperf -s),负责丢弃流量。
2)host-1 作为 Client 运行(iperf -c),负责生产流量。

第一步、安装命令

在每台主机中,执行如下命令,以安装 iperf 工具:

# Debian/Ubuntu
apt-get update && apt-get install -y iperf

# RHEL/CentOS
yum install -y iperf

如果是 Window 系统,访问 iPerf – Download iPerf3 and original iPerf pre-compiled binaries 下载。

第二步、执行测试

在服务端中,执行如下命令:

iperf -s

在客户端中,执行如下命令:

iperf -c '<server_ip_address>'

注意事项

如果服务器开启防火墙,则需要添加端口。服务默认使用 5201 端口。也可以使用选项 -p 指定自定义端口。

参考文献

How to test the network speed/throughput between two Linux servers