在mac环境下,对android网络性能进行iperf测试,步骤如下:

1. iperf的安装

Mac的iperf安装

brew install iperf

android的iperf,有两种方式,一种安装iperf apk,下载地址:https://iperf.fr/iperf-download.php ,第二种方式为用iperf binary, 下载: https://pan.baidu.com/s/11voArkUDLV7eXEj2EzDvBA 密码: 8ael (android 9测试有效)

2. iperf的基本使用

服务端
iperf -s -p 5001 -P 1 -f m -i 2
# 说明:
# -s      表示作为服务端启动
# -p 5001 表示监听的端口为5001
# -P 1    表示服务端与客户端之前的线程数为1。客户端同时使用此参数
# -f m    表示显示数据相关大小时输出格式为Mbps
# -i 2    表示每2秒刷新一次log

客户端
iperf -c xx.xx.xx.xx -p 5001 -t 60 -P 1 -n 100M
# 说明:
# -c xxxx 表示作为客户端启动,xx.xx.xx.xx即服务端ip地址
# -p 5001 表示服务端监听的端口为5001
# -t 60   表示测试时长为60秒
# -P 1    表示客户端与服务端之间的线程数为1。服务端同时使用此参数
# -n 100M 表示发送总数据量为100M。此时-t限定的时长将无效
# -i 2    表示每2秒刷新一次log

3. 测试流程:

Mac服务器端:

	$ iperf -s -p 5001 -P 1 -f m -i 2
	------------------------------------------------------------
	Server listening on TCP port 5001
	TCP window size: 0.12 MByte (default)
	------------------------------------------------------------
	[  4] local 192.168.10.72 port 5001 connected with 192.168.10.64 port 60334
	[ ID] Interval       Transfer     Bandwidth
	[  4]  0.0- 2.0 sec  4.12 MBytes  17.3 Mbits/sec
	[  4]  2.0- 4.0 sec  8.45 MBytes  35.4 Mbits/sec
	[  4]  4.0- 6.0 sec  21.2 MBytes  89.0 Mbits/sec
	[  4]  6.0- 8.0 sec  21.6 MBytes  90.6 Mbits/sec
	[  4]  8.0-10.0 sec  21.0 MBytes  88.1 Mbits/sec
	[  4] 10.0-12.0 sec  20.4 MBytes  85.7 Mbits/sec
	[  4]  0.0-12.3 sec   100 MBytes  68.1 Mbits/sec
	[SUM]  0.0-12.3 sec   104 MBytes  70.9 Mbits/sec

Android客户端:

	/data/local/tmp # ./iperf -c 192.168.10.72 -p 5001 -t 60 -P 1 -n 100M
	------------------------------------------------------------
	Client connecting to 192.168.10.72, TCP port 5001
	TCP window size: 1.00 MByte (default)
	------------------------------------------------------------
	[  3] local 192.168.10.64 port 60334 connected with 192.168.10.72 port 5001
	[ ID] Interval       Transfer     Bandwidth
    [  3]  0.0-12.2 sec    100 MBytes  68.7 Mbits/sec

本文地址:https://blog.csdn.net/wcyan/article/details/107428748