iperf3测试服务器带宽
开发中遇到带宽问题,做一下带宽测试。
mii-tool 直接查看网卡带宽
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
-V, --version display version information
-v, --verbose more verbose output
-R, --reset reset MII to poweron state
-r, --restart restart autonegotiation
-w, --watch monitor for link status changes
-l, --log with -w, write events to syslog
-A, --advertise=media,... advertise only specified media
-F, --force=media force specified media technology
media: 1000baseTx-HD, 1000baseTx-FD,
100baseT4, 100baseTx-FD, 100baseTx-HD,
10baseT-FD, 10baseT-HD,
(to advertise both HD and FD) 1000baseTx, 100baseTx, 10baseT
root@ubuntu:~# mii-tool
SIOCGMIIREG on eth0 failed: Input/output error
SIOCGMIIREG on eth0 failed: Input/output error
eth0: negotiated 1000baseT-FD flow-control, link ok
先用mii-tool命令测试网线是否有问题,网线没做好,1000M网口会识别成100M的网口,首先排除网线问题。
搜一下软件包
root@ubuntu:~# apt-cache search iperf3 | grep iperf3
iperf3 - Internet Protocol bandwidth measuring tool
安装iperf3
sudo apt-get install -y iperf3
help看看怎么用
root@ubuntu:~# iperf3 --help
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Server or Client:
-p, --port # server port to listen on/connect to
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-F, --file name xmit/recv the specified file
-A, --affinity n/n,m set CPU affinity
-B, --bind <host> bind to a specific interface
-V, --verbose more detailed output
-J, --json output in JSON format
-d, --debug emit debugging output
-v, --version show version information and quit
-h, --help show this message and quit
Server specific:
-s, --server run in server mode
-D, --daemon run the server as a daemon
-1, --one-off handle one client connection then exit
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-u, --udp use UDP rather than TCP
-b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
(default 1 Mbit/sec for UDP, unlimited for TCP)
(optional slash and packet count for burst mode)
-t, --time # time in seconds to transmit for (default 10 secs)
-n, --bytes #[KMG] number of bytes to transmit (instead of -t)
-k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n)
-l, --len #[KMG] length of buffer to read or write
(default 128 KB for TCP, 8 KB for UDP)
-P, --parallel # number of parallel client streams to run
-R, --reverse run in reverse mode (server sends, client receives)
-w, --window #[KMG] set window size / socket buffer size
-C, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)
-M, --set-mss # set TCP maximum segment size (MTU - 40 bytes)
-N, --nodelay set TCP no delay, disabling Nagle's Algorithm
-4, --version4 only use IPv4
-6, --version6 only use IPv6
-S, --tos N set the IP 'type of service'
-L, --flowlabel N set the IPv6 flow label (only supported on Linux)
-Z, --zerocopy use a 'zero copy' method of sending data
-O, --omit N omit the first n seconds
-T, --title str prefix every output line with this string
--get-server-output get results from server
[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-
iperf3 homepage at: http://software.es.net/iperf/
Report bugs to: https://github.com/esnet/iperf
测试
启动服务端
iperf3 -s
(启动后使用默认的端口5201如需使用其他端口则需要添加 -p 端口号)
启动客户端
iperf3 -u -c 192.168.1.120 -b 200M -i 1 -t 60 -l 1454
以上参数表示
-u 使用udp进行测试;
-c 为客户端运行并要指定服务端的IP地址;
-b 表示使用的测试带宽;
-i 表示每次报告的间隔,单位为秒;
-t 表示以时间为测试结束条件进行测试,默认为 10 秒;
-l 用于设置包的大小 (UDP包大小设置为300字节,PPS数值接近研发估算的dMCU实际使用情况,即每100M流量对应40K PPS)。
结果
root@A9300:/home/xuean# iperf3 -u -c 192.168.1.229 -b 1000M -i 1 -t 10 -l 1454
Connecting to host 192.168.1.229, port 5201
[ 4] local 192.168.1.224 port 39043 connected to 192.168.1.229 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.00 sec 103 MBytes 860 Mbits/sec 73936
[ 4] 1.00-2.00 sec 114 MBytes 953 Mbits/sec 81931
[ 4] 2.00-3.00 sec 113 MBytes 949 Mbits/sec 81560
[ 4] 3.00-4.00 sec 114 MBytes 953 Mbits/sec 81938
[ 4] 4.00-5.00 sec 114 MBytes 955 Mbits/sec 82065
[ 4] 5.00-6.00 sec 114 MBytes 955 Mbits/sec 82089
[ 4] 6.00-7.00 sec 114 MBytes 955 Mbits/sec 82134
[ 4] 7.00-8.00 sec 114 MBytes 956 Mbits/sec 82183
[ 4] 8.00-9.00 sec 113 MBytes 949 Mbits/sec 81585
[ 4] 9.00-10.00 sec 114 MBytes 953 Mbits/sec 81919
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 1.10 GBytes 944 Mbits/sec 0.014 ms 3487/811337 (0.43%)
[ 4] Sent 811337 datagrams
解决
ovirt创建网卡时候有3中选择,分别是e1000, rtl8139, virtio。
“rtl8139”这个网卡模式是qemu-kvm默认的模拟网卡类型,RTL8139是Realtek半导体公司的一个10/100M网卡系列,是曾经非常流行(当然现在看来有点古老)且兼容性好的网卡,几乎所有的现代操作系统都对RTL8139网卡驱动的提供支持。
“e1000”系列提供Intel e1000系列的网卡模拟,纯的QEMU(非qemu-kvm)默认就是提供Intel e1000系列的虚拟网卡。
“virtio” 类型是qemu-kvm对半虚拟化IO(virtio)驱动的支持。
这三个网卡的最大区别(此处指最需要关注的地方)是速度:
rtl8139 10/100Mb/s
e1000 1Gb/s
virtio 10Gb/s