Linux Iperf 测试网络性能

Iperf必须安装在正在测试两者之间的连接的两台计算机上。 如果在个人计算机上使用基于Unix或Linux的操作系统,则可以在本地计算机上安装Iperf。 但是,如果正在测试Linode的吞吐量,最好使用另一台服务器作为终端,因为本地ISP可能会施加可能影响测试结果的网络限制。

TCP Clients & Servers

Iperf需要两个系统,因为一个系统必须充当一个服务器(DUT),而另一个则作为客户端(Server)。

  1. DUT端运行:
iperf -s

2.DUT端会出现下列输出:

Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)

3.Server端运行下面的命令连接到DUT端对应的网口的IP:

iperf -c 198.51.100.5

4.Server端会出现下面输出:

Client connecting to 198.51.100.5, TCP port 5001
TCP window size: 45.0 KByte (default)

[ 3] local 198.51.100.6 port 50616 connected with 198.51.100.5 port 5001
[ID] Interval Transfer Bandwidth
[ 3] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec

5.DUT端也会出现下列输出:

Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)

[ 4] local 198.51.100.5 port 5001 connected with 198.51.100.6 port 50616
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec

6.退出:CTRL + c.


UDP Clients & Servers

使用Iperf,还可以测试通过UDP连接实现的最大吞吐量。

1.Start a UDP Iperf server:

iperf -s -u

2.server 的输出:

Server listening on UDP port 5001
Receiving 1470 byte datagrams UDP buffer size: 208 KByte (default)

3.连接Client 和 Server 使用下面的命令

iperf -c 198.51.100.5 -u

4.我们已经通过-u选项告诉Iperf我们是通过UDP连接的,因为我们希望看到通过UDP实现的最大吞吐量。输出应类似于:

Client connecting to 198.51.100.5, UDP port 5001
Sending 1470 byte datagrams

UDP buffer size: 208 KByte (default)
[ 3] local 198.51.100.6 port 58070 connected with 198.51.100.5 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec
[ 3] Sent 893 datagrams
[ 3] Server Report:
[ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.084 ms 0/ 893 (0%)

5.看看我们收到的输出:1.05 Mbits / sec远远低于我们在TCP测试中收到的输出。 它也远远低于1GB DUT(Client)提供的最大出站带宽上限。 这是因为默认情况下,Iperf将UDP客户端的带宽限制为每秒1 Mbit。

6.可以使用-b标志进行更改,将数字替换为要测试的最大带宽速率。如果您正在测试网络速度,我们建议将此数字设置在DUT(Client)提供的最大带宽上限之上。例如,这个测试是在1GB的线程上运行的:

iperf -c 198.51.100.5 -u -b 1000m

7.这说明,如果可能,我们希望每秒最多可以达到1000 Mbits。 -b标志仅在使用UDP连接时有效,因为Iperf不会在TCP客户端上设置带宽限制。

8.输出类似于:

Client connecting to 198.51.100.5, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)

[ 3] local 198.51.100.5 port 52308 connected with 198.51.100.5 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 966 MBytes 810 Mbits/sec
[ 3] Sent 688897 datagrams
[ 3] Server Report:
[ 3] 0.0-10.0 sec 966 MBytes 810 Mbits/sec 0.001 ms
0/688896 (0%) [ 3] 0.0-10.0 sec 1 datagrams received out-of-order

9.现在比以前看到的1.05 Mbits / sec好多了!


Bidirectional(双向) Tests

在某些情况下,可能需要测试两个服务器的最大吞吐量。这可以使用Iperf提供的内置双向测试功能轻松完成。

 iperf -c 198.51.100.5 -d

结果是Iperf将在原始客户端服务器上启动服务器和客户端连接(198.51.100.6)。 一旦这样做,Iperf将原始的Iperf服务器连接到客户端连接,该客户端连接现在充当服务器连接和客户端连接。输出类似于:

Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)

Client connecting to 198.51.100.5, TCP port 5001
TCP window size: 351 KByte (default)

[ 3] local 198.51.100.6 port 50618 connected with 198.51.100.5 port 5001
[ 5] local 198.51.100.6 port 5001 connected with 198.51.100.5 port 58650
[ ID] Interval Transfer Bandwidth
[ 5] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec
[ 3] 0.0-10.2 sec 1.28 GBytes 1.08 Gbits/sec

在原始的Iperf Server将会看到:

Client connecting to 198.51.100.6, TCP port 5001
TCP window size: 153 KByte (default)

[ 6] local 198.51.100.5 port 58650 connected with 198.51.100.6 port 5001
[ 6] 0.0-10.1 sec 1.27 GBytes 1.08 Gbits/sec
[ 5] 0.0-10.2 sec 1.28 GBytes 1.08 Gbits/sec

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值