前一段时间写了一篇关于打流的简单笔记,包含脚本的简单编写,见
一次打流过程的优化反思(iperf3的灵活运用)_sixtome-CSDN博客_iperf3 打流
这几天在实际应用中,发现还是有不少的瑕疵,根据实际情况又进行了思考,在实用性方面进行了部分优化,首先这个是一个最基础的脚本。
root@fetmx6ull-s:~# cat tc1.sh
#!/bin/bash
ifconfig eth0 192.168.0.232 up
ifconfig
sleep 1s
while true
do
iperf3 -c 192.168.0.9 -i 1 -t10
sleep 1s
done
#!/bin/bash
ifconfig eth0 192.168.0.232 up
ifconfig
sleep 1s
while true
do
iperf3 -c 192.168.0.9 -i 1 -t10
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t 10 -R
sleep 1s
done
这样,打流10次后改变方式,从sever端发起数据,查看反方向的数据情况;执行后如下
root@fetmx6ull-s:~# cat tc1.sh
#!/bin/bash
ifconfig eth0 192.168.0.232 up
ifconfig
sleep 1s
while true
do
iperf3 -c 192.168.0.9 -i 1 -t10
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t 10 -R
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t 10 -u -b 10M
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t 10 -u -b 10M -R
sleep 1s
done
执行后效果如下:
root@fetmx6ull-s:~# ./tc1.sh
eth0 Link encap:Ethernet HWaddr AA:CC:DD:EE:FF:DD
inet addr:192.168.0.232 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a8cc:ddff:feee:ffdd%1995478736/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:23529953 errors:0 dropped:0 overruns:0 frame:0
TX packets:3765850 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1864130622 (1.7 GiB) TX bytes:3808531536 (3.5 GiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1%1995478736/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Connecting to host 192.168.0.9, port 5201
[ 4] local 192.168.0.232 port 35969 connected to 192.168.0.9 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.8 MBytes 99.3 Mbits/sec 0 221 KBytes
[ 4] 1.00-2.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
[ 4] 2.00-3.00 sec 11.0 MBytes 92.5 Mbits/sec 0 221 KBytes
[ 4] 3.00-4.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
[ 4] 4.00-5.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
[ 4] 5.00-6.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
[ 4] 6.00-7.00 sec 11.0 MBytes 92.5 Mbits/sec 0 221 KBytes
[ 4] 7.00-8.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
[ 4] 8.00-9.00 sec 11.3 MBytes 94.5 Mbits/sec 0 221 KBytes
[ 4] 9.00-10.00 sec 11.3 MBytes 94.6 Mbits/sec 0 221 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 113 MBytes 94.6 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 112 MBytes 94.2 Mbits/sec receiver
iperf Done.
Connecting to host 192.168.0.9, port 5201
Reverse mode, remote host 192.168.0.9 is sending
[ 4] local 192.168.0.232 port 35971 connected to 192.168.0.9 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 11.4 MBytes 95.9 Mbits/sec
[ 4] 1.00-2.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 2.00-3.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 3.00-4.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 4.00-5.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 5.00-6.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 6.00-7.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 7.00-8.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 8.00-9.00 sec 11.3 MBytes 94.9 Mbits/sec
[ 4] 9.00-10.00 sec 11.3 MBytes 94.9 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-10.00 sec 114 MBytes 95.9 Mbits/sec sender
[ 4] 0.00-10.00 sec 114 MBytes 95.7 Mbits/sec receiver
iperf Done.
Connecting to host 192.168.0.9, port 5201
[ 4] local 192.168.0.232 port 53389 connected to 192.168.0.9 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.00 sec 1.09 MBytes 9.11 Mbits/sec 139
[ 4] 1.00-2.00 sec 1.19 MBytes 9.96 Mbits/sec 152
[ 4] 2.00-3.00 sec 1.20 MBytes 10.0 Mbits/sec 153
[ 4] 3.00-4.00 sec 1.20 MBytes 10.0 Mbits/sec 153
[ 4] 4.00-5.00 sec 1.19 MBytes 9.96 Mbits/sec 152
[ 4] 5.00-6.00 sec 1.20 MBytes 10.0 Mbits/sec 153
[ 4] 6.00-7.00 sec 1.19 MBytes 9.96 Mbits/sec 152
[ 4] 7.00-8.00 sec 1.20 MBytes 10.0 Mbits/sec 153
[ 4] 8.00-9.00 sec 1.19 MBytes 9.96 Mbits/sec 152
[ 4] 9.00-10.00 sec 1.20 MBytes 10.0 Mbits/sec 153
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 11.8 MBytes 9.91 Mbits/sec 0.421 ms 0/1512 (0%)
[ 4] Sent 1512 datagrams
iperf Done.
Connecting to host 192.168.0.9, port 5201
Reverse mode, remote host 192.168.0.9 is sending
[ 4] local 192.168.0.232 port 60697 connected to 192.168.0.9 port 5201
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-1.00 sec 1.22 MBytes 10.2 Mbits/sec 67574.222 ms 0/156 (0%)
[ 4] 1.00-2.00 sec 1.19 MBytes 9.96 Mbits/sec 4.265 ms 0/152 (0%)
[ 4] 2.00-3.00 sec 1.18 MBytes 9.90 Mbits/sec 0.611 ms 0/151 (0%)
[ 4] 3.00-4.00 sec 1.20 MBytes 10.0 Mbits/sec 0.618 ms 0/153 (0%)
[ 4] 4.00-5.00 sec 1.19 MBytes 9.96 Mbits/sec 0.644 ms 0/152 (0%)
[ 4] 5.00-6.00 sec 1.20 MBytes 10.0 Mbits/sec 0.610 ms 0/153 (0%)
[ 4] 6.00-7.00 sec 1.20 MBytes 10.0 Mbits/sec 0.628 ms 0/153 (0%)
[ 4] 7.00-8.00 sec 1.19 MBytes 9.96 Mbits/sec 0.622 ms 0/152 (0%)
[ 4] 8.00-9.00 sec 1.20 MBytes 10.0 Mbits/sec 0.643 ms 0/153 (0%)
[ 4] 9.00-10.00 sec 1.20 MBytes 10.0 Mbits/sec 0.586 ms 0/153 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 11.9 MBytes 10.0 Mbits/sec 0.586 ms 0/1528 (0%)
[ 4] Sent 1528 datagrams
iperf Done.
由于同时打流,就要占用多个端口,需要在另外一块开发板或者电脑上先开辟多个端口
iperf3 -s -p 5000
iperf3 -s -p 5001
iperf3 -s -p 5002
iperf3 -s -p 5003
编写脚本如下:
root@fetmx6ull-s:~# cat tc1.sh
#!/bin/bash
ifconfig eth0 192.168.0.232 up
ifconfig
sleep 1s
while true
do
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5000
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5001
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5002
sleep 1s
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5003
sleep 1s
done
我这里的脚本都使用的一个ip 192.168.0.9 ,真正使用的时候,需要修改成不同的ip地址,执行的时候,可以从服务端上看到4个ip(端口)轮询打流。客户端效果如下:
Connecting to host 192.168.0.9, port 5000
[ 4] local 192.168.0.232 port 35667 connected to 192.168.0.9 port 5000
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.7 MBytes 98.2 Mbits/sec 0 210 KBytes
[ 4] 1.00-2.00 sec 11.5 MBytes 96.6 Mbits/sec 0 210 KBytes
[ 4] 2.00-3.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 3.00-4.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 4.00-5.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 5.00-6.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 6.00-7.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 7.00-8.00 sec 11.5 MBytes 96.6 Mbits/sec 0 210 KBytes
[ 4] 8.00-9.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 9.00-10.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 114 MBytes 95.3 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 113 MBytes 95.0 Mbits/sec receiver
iperf Done.
Connecting to host 192.168.0.9, port 5001
[ 4] local 192.168.0.232 port 51208 connected to 192.168.0.9 port 5001
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.8 MBytes 98.7 Mbits/sec 0 242 KBytes
[ 4] 1.00-2.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 2.00-3.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 3.00-4.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 4.00-5.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 5.00-6.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 6.00-7.00 sec 11.3 MBytes 94.6 Mbits/sec 0 242 KBytes
[ 4] 7.00-8.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 8.00-9.00 sec 11.3 MBytes 95.1 Mbits/sec 0 242 KBytes
[ 4] 9.00-10.00 sec 11.3 MBytes 94.6 Mbits/sec 0 242 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 114 MBytes 95.3 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 113 MBytes 94.9 Mbits/sec receiver
iperf Done.
Connecting to host 192.168.0.9, port 5002
[ 4] local 192.168.0.232 port 48166 connected to 192.168.0.9 port 5002
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.8 MBytes 99.2 Mbits/sec 0 244 KBytes
[ 4] 1.00-2.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 2.00-3.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 3.00-4.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 4.00-5.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 5.00-6.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 6.00-7.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 7.00-8.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 8.00-9.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
[ 4] 9.00-10.00 sec 11.3 MBytes 95.1 Mbits/sec 0 244 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 114 MBytes 95.5 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 113 MBytes 95.0 Mbits/sec receiver
iperf Done.
Connecting to host 192.168.0.9, port 5003
[ 4] local 192.168.0.232 port 51305 connected to 192.168.0.9 port 5003
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.9 MBytes 99.7 Mbits/sec 0 210 KBytes
[ 4] 1.00-2.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 2.00-3.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 3.00-4.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 4.00-5.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 5.00-6.00 sec 11.5 MBytes 96.6 Mbits/sec 0 210 KBytes
[ 4] 6.00-7.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 7.00-8.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 8.00-9.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
[ 4] 9.00-10.00 sec 11.3 MBytes 94.6 Mbits/sec 0 210 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 114 MBytes 95.3 Mbits/sec 0 sender
这样,我们看到虽然可以实现多个打流,但是还不是同时的效果,那么我们如何实现同时打流呢,可以将脚本修成成如下:
root@fetmx6ull-s:~# cat tc1.sh
#!/bin/bash
ifconfig eth0 192.168.0.232 up
ifconfig
sleep 1s
while true
do
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5000 &
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5001 &
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5002 &
iperf3 -c 192.168.0.9 -i 1 -t10 -p 5003 &
sleep 11s
done
让打流的iperf3的后台运行,这样就不用等上一个iperf3运行完,可以达到同时打流的目的。
执行如下:
root@fetmx6ull-s:~# ./tc1.sh &
[1] 1805
root@fetmx6ull-s:~# eth0 Link encap:Ethernet HWaddr AA:CC:DD:EE:FF:DD
inet addr:192.168.0.232 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a8cc:ddff:feee:ffdd%1996404432/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:24314679 errors:0 dropped:0 overruns:0 frame:0
TX packets:3932241 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2089994851 (1.9 GiB) TX bytes:1474977594 (1.3 GiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1%1996404432/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Connecting to host 192.168.0.9, port 5003
Connecting to host 192.168.0.9, port 5001
Connecting to host 192.168.0.9, port 5002
Connecting to host 192.168.0.9, port 5000
[ 4] local 192.168.0.232 port 51328 connected to 192.168.0.9 port 5003
[ 4] local 192.168.0.232 port 51237 connected to 192.168.0.9 port 5001
[ 4] local 192.168.0.232 port 35699 connected to 192.168.0.9 port 5000
[ 4] local 192.168.0.232 port 48192 connected to 192.168.0.9 port 5002
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 2.35 MBytes 19.7 Mbits/sec 0 45.6 KBytes
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 4.20 MBytes 35.2 Mbits/sec 0 98.4 KBytes
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 1.02 MBytes 8.54 Mbits/sec 0 25.7 KBytes
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 4.75 MBytes 39.8 Mbits/sec 0 106 KBytes
[ 4] 1.00-2.00 sec 1.65 MBytes 13.9 Mbits/sec 0 45.6 KBytes
[ 4] 1.00-2.00 sec 3.68 MBytes 30.8 Mbits/sec 0 98.4 KBytes
[ 4] 1.00-2.00 sec 863 KBytes 7.07 Mbits/sec 0 25.7 KBytes
[ 4] 1.00-2.00 sec 5.21 MBytes 43.6 Mbits/sec 0 121 KBytes
[ 4] 2.00-3.00 sec 1.47 MBytes 12.3 Mbits/sec 0 45.6 KBytes
[ 4] 2.00-3.00 sec 3.43 MBytes 28.8 Mbits/sec 0 98.4 KBytes
[ 4] 2.00-3.00 sec 898 KBytes 7.36 Mbits/sec 0 25.7 KBytes
[ 4] 2.00-3.00 sec 5.51 MBytes 46.3 Mbits/sec 0 133 KBytes
[ 4] 3.00-4.00 sec 1.72 MBytes 14.4 Mbits/sec 0 45.6 KBytes
[ 4] 3.00-4.00 sec 3.68 MBytes 30.8 Mbits/sec 0 98.4 KBytes
[ 4] 3.00-4.00 sec 927 KBytes 7.59 Mbits/sec 0 25.7 KBytes
[ 4] 3.00-4.00 sec 5.15 MBytes 43.2 Mbits/sec 0 133 KBytes
[ 4] 4.00-5.00 sec 1.72 MBytes 14.4 Mbits/sec 0 45.6 KBytes
[ 4] 4.00-5.00 sec 3.55 MBytes 29.8 Mbits/sec 0 98.4 KBytes
[ 4] 4.00-5.00 sec 890 KBytes 7.29 Mbits/sec 0 25.7 KBytes
[ 4] 4.00-5.00 sec 5.15 MBytes 43.2 Mbits/sec 0 133 KBytes
[ 4] 5.00-6.00 sec 1.60 MBytes 13.4 Mbits/sec 0 45.6 KBytes
[ 4] 5.00-6.00 sec 3.80 MBytes 31.9 Mbits/sec 0 98.4 KBytes
[ 4] 5.00-6.00 sec 780 KBytes 6.39 Mbits/sec 0 25.7 KBytes
[ 4] 5.00-6.00 sec 5.15 MBytes 43.2 Mbits/sec 0 133 KBytes
[ 4] 6.00-7.00 sec 1.59 MBytes 13.4 Mbits/sec 0 45.6 KBytes
[ 4] 6.00-7.00 sec 3.43 MBytes 28.8 Mbits/sec 0 98.4 KBytes
[ 4] 6.00-7.00 sec 893 KBytes 7.31 Mbits/sec 0 25.7 KBytes
[ 4] 6.00-7.00 sec 5.51 MBytes 46.3 Mbits/sec 0 133 KBytes
[ 4] 7.00-8.00 sec 2.28 MBytes 19.1 Mbits/sec 0 71.3 KBytes
[ 4] 7.00-8.00 sec 3.06 MBytes 25.7 Mbits/sec 0 98.4 KBytes
[ 4] 7.00-8.00 sec 740 KBytes 6.06 Mbits/sec 0 25.7 KBytes
[ 4] 7.00-8.00 sec 5.39 MBytes 45.2 Mbits/sec 0 187 KBytes
[ 4] 8.00-9.00 sec 2.21 MBytes 18.5 Mbits/sec 0 71.3 KBytes
[ 4] 8.00-9.00 sec 2.94 MBytes 24.7 Mbits/sec 0 98.4 KBytes
[ 4] 8.00-9.00 sec 545 KBytes 4.46 Mbits/sec 0 25.7 KBytes
[ 4] 8.00-9.00 sec 5.64 MBytes 47.3 Mbits/sec 0 187 KBytes
[ 4] 9.00-10.00 sec 2.08 MBytes 17.5 Mbits/sec 0 71.3 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 18.7 MBytes 15.7 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 18.5 MBytes 15.5 Mbits/sec receiver
iperf Done.
[ 4] 9.00-10.00 sec 602 KBytes 4.93 Mbits/sec 0 25.7 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 7.99 MBytes 6.70 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 7.89 MBytes 6.62 Mbits/sec receiver
iperf Done.
[ 4] 9.00-10.00 sec 3.06 MBytes 25.7 Mbits/sec 0 98.4 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 34.8 MBytes 29.2 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 34.7 MBytes 29.1 Mbits/sec receiver
iperf Done.
[ 4] 9.00-10.00 sec 5.64 MBytes 47.3 Mbits/sec 0 187 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 53.1 MBytes 44.5 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 52.6 MBytes 44.1 Mbits/sec receiver
iperf Done.
我们可以看到,4个打流进程在同步运行。
注意:
1)由于是同时打流,有可能带宽会有有写变化,这个不同的平台可能数据变化不一。
2) 后面的sleep 11s 的数据,一定不要小于10s,因为每一次的打流参数是t10,就需要10s的时间,小于10s会出错的。
3)同时打流发现数据是乱的。比如
上面这4行,那个分别对应端口号5000,5001,5002,5003呢,分不清了。总不能猜吧?还有如果有一个网络异常,那么会有一个是报错的,但是我们如何知道是那一个出错了呢?也许你会说,看网口的灯,但是如果在做实验的时候,环境下是看不到网口的灯的情况呢?
OK,这个时候我们就要用到 -T 参数,这个也是好多人不知道的了,将上面的脚本修改下,如图
我们看到 -T 后面跟的是对应的端口名称,这样就相当于增加了一个备注功能,执行后效果如下:
5003: Connecting to host 192.168.0.9, port 5003
5001: Connecting to host 192.168.0.9, port 5001
5002: Connecting to host 192.168.0.9, port 5002
5000: Connecting to host 192.168.0.9, port 5000
5003: [ 4] local 192.168.0.232 port 51368 connected to 192.168.0.9 port 5003
5001: [ 4] local 192.168.0.232 port 51276 connected to 192.168.0.9 port 5001
5002: [ 4] local 192.168.0.232 port 48233 connected to 192.168.0.9 port 5002
5000: [ 4] local 192.168.0.232 port 35739 connected to 192.168.0.9 port 5000
5003: [ ID] Interval Transfer Bandwidth Retr Cwnd
5003: [ 4] 0.00-1.00 sec 1.83 MBytes 15.3 Mbits/sec 0 34.2 KBytes
5001: [ ID] Interval Transfer Bandwidth Retr Cwnd
5001: [ 4] 0.00-1.00 sec 1.71 MBytes 14.4 Mbits/sec 0 32.8 KBytes
5002: [ ID] Interval Transfer Bandwidth Retr Cwnd
5002: [ 4] 0.00-1.00 sec 1.73 MBytes 14.5 Mbits/sec 0 31.4 KBytes
5000: [ ID] Interval Transfer Bandwidth Retr Cwnd
5000: [ 4] 0.00-1.00 sec 6.84 MBytes 57.4 Mbits/sec 0 138 KBytes
5003: [ 4] 1.00-2.00 sec 1.49 MBytes 12.5 Mbits/sec 0 34.2 KBytes
5001: [ 4] 1.00-2.00 sec 1.43 MBytes 12.0 Mbits/sec 0 32.8 KBytes
5002: [ 4] 1.00-2.00 sec 1.40 MBytes 11.7 Mbits/sec 0 32.8 KBytes
5000: [ 4] 1.00-2.00 sec 6.98 MBytes 58.6 Mbits/sec 0 138 KBytes
5003: [ 4] 2.00-3.00 sec 1.69 MBytes 14.2 Mbits/sec 0 37.1 KBytes
5001: [ 4] 2.00-3.00 sec 1.65 MBytes 13.9 Mbits/sec 0 35.6 KBytes
5002: [ 4] 2.00-3.00 sec 1.62 MBytes 13.6 Mbits/sec 0 37.1 KBytes
5000: [ 4] 2.00-3.00 sec 6.43 MBytes 54.0 Mbits/sec 0 138 KBytes
5003: [ 4] 3.00-4.00 sec 1.62 MBytes 13.6 Mbits/sec 0 37.1 KBytes
5001: [ 4] 3.00-4.00 sec 1.74 MBytes 14.6 Mbits/sec 0 41.3 KBytes
5002: [ 4] 3.00-4.00 sec 1.63 MBytes 13.7 Mbits/sec 0 37.1 KBytes
5000: [ 4] 3.00-4.00 sec 6.25 MBytes 52.4 Mbits/sec 0 144 KBytes
5003: [ 4] 4.00-5.00 sec 1.48 MBytes 12.4 Mbits/sec 0 37.1 KBytes
5001: [ 4] 4.00-5.00 sec 1.91 MBytes 16.0 Mbits/sec 0 51.3 KBytes
5002: [ 4] 4.00-5.00 sec 1.58 MBytes 13.3 Mbits/sec 0 37.1 KBytes
5000: [ 4] 4.00-5.00 sec 6.43 MBytes 54.0 Mbits/sec 0 144 KBytes
5003: [ 4] 5.00-6.00 sec 1.57 MBytes 13.1 Mbits/sec 0 37.1 KBytes
5001: [ 4] 5.00-6.00 sec 2.33 MBytes 19.5 Mbits/sec 0 57.0 KBytes
5002: [ 4] 5.00-6.00 sec 1.71 MBytes 14.3 Mbits/sec 0 58.5 KBytes
5000: [ 4] 5.00-6.00 sec 5.88 MBytes 49.3 Mbits/sec 0 144 KBytes
5003: [ 4] 6.00-7.00 sec 1.27 MBytes 10.6 Mbits/sec 0 37.1 KBytes
5001: [ 4] 6.00-7.00 sec 2.21 MBytes 18.5 Mbits/sec 0 57.0 KBytes
5002: [ 4] 6.00-7.00 sec 2.21 MBytes 18.5 Mbits/sec 0 58.5 KBytes
5000: [ 4] 6.00-7.00 sec 5.51 MBytes 46.2 Mbits/sec 0 144 KBytes
5003: [ 4] 7.00-8.00 sec 1.48 MBytes 12.4 Mbits/sec 0 37.1 KBytes
5001: [ 4] 7.00-8.00 sec 2.14 MBytes 18.0 Mbits/sec 0 57.0 KBytes
5002: [ 4] 7.00-8.00 sec 2.39 MBytes 20.0 Mbits/sec 0 58.5 KBytes
5000: [ 4] 7.00-8.00 sec 5.33 MBytes 44.7 Mbits/sec 0 144 KBytes
5003: [ 4] 8.00-9.00 sec 1.34 MBytes 11.2 Mbits/sec 0 37.1 KBytes
5001: [ 4] 8.00-9.00 sec 2.21 MBytes 18.5 Mbits/sec 0 57.0 KBytes
5002: [ 4] 8.00-9.00 sec 2.39 MBytes 20.0 Mbits/sec 0 58.5 KBytes
5000: [ 4] 8.00-9.00 sec 5.33 MBytes 44.7 Mbits/sec 0 144 KBytes
5001: [ 4] 9.00-10.00 sec 2.45 MBytes 20.6 Mbits/sec 0 57.0 KBytes
5001: - - - - - - - - - - - - - - - - - - - - - - - - -
5001: [ ID] Interval Transfer Bandwidth Retr
5001: [ 4] 0.00-10.00 sec 19.8 MBytes 16.6 Mbits/sec 0 sender
5001: [ 4] 0.00-10.00 sec 19.6 MBytes 16.4 Mbits/sec receiver
5001:
5001: iperf Done.
5003: [ 4] 9.00-10.00 sec 1.41 MBytes 11.9 Mbits/sec 0 37.1 KBytes
5003: - - - - - - - - - - - - - - - - - - - - - - - - -
5003: [ ID] Interval Transfer Bandwidth Retr
5003: [ 4] 0.00-10.00 sec 15.2 MBytes 12.7 Mbits/sec 0 sender
5003: [ 4] 0.00-10.00 sec 15.1 MBytes 12.7 Mbits/sec receiver
5003:
5003: iperf Done.
5002: [ 4] 9.00-10.00 sec 2.33 MBytes 19.5 Mbits/sec 0 58.5 KBytes
5002: - - - - - - - - - - - - - - - - - - - - - - - - -
5002: [ ID] Interval Transfer Bandwidth Retr
5002: [ 4] 0.00-10.00 sec 19.0 MBytes 15.9 Mbits/sec 0 sender
5002: [ 4] 0.00-10.00 sec 18.8 MBytes 15.8 Mbits/sec receiver
5002:
5002: iperf Done.
5000: [ 4] 9.00-10.00 sec 5.33 MBytes 44.7 Mbits/sec 0 144 KBytes
5000: - - - - - - - - - - - - - - - - - - - - - - - - -
5000: [ ID] Interval Transfer Bandwidth Retr
5000: [ 4] 0.00-10.00 sec 60.3 MBytes 50.6 Mbits/sec 0 sender
5000: [ 4] 0.00-10.00 sec 59.9 MBytes 50.2 Mbits/sec receiver
5000:
5000: iperf Done.
从上面我们可以清晰的看到,每一行的最开始,都标注了本行数据是那个端口的,这样是不是很清楚了~~~。
就写到这里吧,等发现其他的问题后,在整理补充。
后记:由于iperf3存在瞬间的不正常,然后又不能自动恢复,那么能不能实现监视server端,当server端异常的时候,重新启动server端呢,(现在想到的办法是,定时杀死,然后在启动,但是这样的情况下,杀死的时候,client端可能也在连接,这个时候也会报错误,不能完美的实现),如果有牛人可以解决这个问题,欢迎留言或者讨论,如果有和这个iperf3使用相关的问题和技巧也可以留言,欢迎!!!