【IoT开发工具箱 | 02】嵌入式Linux设备网速测试方法

这是机器未来的第48篇文章

原文首发地址:https://robotsfutures.blog.csdn.net/article/details/126847220

【IoT开发工具箱 | 02】嵌入式Linux设备网速测试方法_第1张图片

《IoT开发工具箱系列》快速导航:

  • 【IoT开发工具箱 | 01】Postman模拟https请求

文章目录

  • 《IoT开发工具箱系列》快速导航:
  • 1. 概述
  • 2. 测试环境
  • 3. perf3
  • 4. curl
  • 5. 总结
  • 6. 其它网络测速方法:
    • 6.1 wget
    • 6.2 fast
    • 6.3 speedtest
    • 6.4 bench.sh


写在开始:

  • 博客简介:专注AIoT领域,追逐未来时代的脉搏,记录路途中的技术成长!
  • 博主社区:AIoT机器智能, 欢迎加入!
  • 专栏简介:记录嵌入式开发过程中使用到的工具集合。
  • 面向人群:嵌入式工程师

1. 概述

简单总结了两种实用的嵌入式设备网速测试的方法:iperf和curl,这两种工具基本上都属于文件系统自带的指令。

2. 测试环境

  • 测试设备:嵌入式Linux设备
  • 测试场景:办公区
  • 测试方法:连接远程服务器,测试网速

3. perf3

  • 测试命令:
iperf3 -c xxx.xxx.xxx.xxx -p 5002 -i 1 -t 60000 -P 10

xxx.xxx.xxx.xxx,服务器IP

-i,指定打印间隔

-t,指定测试时间,单位s

-P,指定测试并行数,不添加默认为1个线程

-p,指定测试端口

-c,指定测试模式,-c客户端模式,-s服务端模式

  • 测试结果:
/usrdata/QuecOpen # iperf3 -c xxx.xxx.xxx.xxx -p 5002 -i 1 -t 60000 -P 10
Connecting to host xxx.xxx.xxx.xxx, port 5002
[  4] local 10.15.187.129 port 44479 connected to xxx.xxx.xxx.xxx port 5002
[  6] local 10.15.187.129 port 44480 connected to xxx.xxx.xxx.xxx port 5002
[  8] local 10.15.187.129 port 44481 connected to xxx.xxx.xxx.xxx port 5002
[ 10] local 10.15.187.129 port 44482 connected to xxx.xxx.xxx.xxx port 5002
[ 12] local 10.15.187.129 port 44483 connected to xxx.xxx.xxx.xxx port 5002
[ 14] local 10.15.187.129 port 44484 connected to xxx.xxx.xxx.xxx port 5002
[ 16] local 10.15.187.129 port 44485 connected to xxx.xxx.xxx.xxx port 5002
[ 18] local 10.15.187.129 port 44486 connected to xxx.xxx.xxx.xxx port 5002
[ 20] local 10.15.187.129 port 44487 connected to xxx.xxx.xxx.xxx port 5002
[ 22] local 10.15.187.129 port 44488 connected to xxx.xxx.xxx.xxx port 5002
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   115 KBytes   937 Kbits/sec   16   27.6 KBytes       
[  6]   0.00-1.00   sec  56.6 KBytes   463 Kbits/sec   12   9.21 KBytes       
[  8]   0.00-1.00   sec  52.7 KBytes   431 Kbits/sec   13   18.4 KBytes       
[ 10]   0.00-1.00   sec  52.7 KBytes   431 Kbits/sec   10   14.5 KBytes       
[ 12]   0.00-1.00   sec  54.0 KBytes   441 Kbits/sec   12   17.1 KBytes       
[ 14]   0.00-1.00   sec  90.8 KBytes   743 Kbits/sec    5   23.7 KBytes       
[ 16]   0.00-1.00   sec  43.4 KBytes   355 Kbits/sec    7   11.8 KBytes       
[ 18]   0.00-1.00   sec  39.5 KBytes   323 Kbits/sec    7   9.21 KBytes       
[ 20]   0.00-1.00   sec  39.8 KBytes   326 Kbits/sec    3   6.64 KBytes       
[ 22]   0.00-1.00   sec  39.8 KBytes   326 Kbits/sec    7   9.30 KBytes       
[SUM]   0.00-1.00   sec   584 KBytes  4.78 Mbits/sec   92             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   1.00-2.00   sec  82.9 KBytes   680 Kbits/sec    7   19.7 KBytes       
[  6]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec   11   10.5 KBytes       
[  8]   1.00-2.00   sec  44.8 KBytes   367 Kbits/sec    7   11.8 KBytes       
[ 10]   1.00-2.00   sec  11.8 KBytes  97.1 Kbits/sec   13   15.8 KBytes       
[ 12]   1.00-2.00   sec  11.8 KBytes  97.1 Kbits/sec   12   13.2 KBytes       
[ 14]   1.00-2.00   sec  1.32 KBytes  10.8 Kbits/sec   16   1.32 KBytes       
[ 16]   1.00-2.00   sec  26.3 KBytes   216 Kbits/sec    5   7.90 KBytes       
[ 18]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec    6   1.32 KBytes       
[ 20]   1.00-2.00   sec  2.66 KBytes  21.8 Kbits/sec    5   2.66 KBytes       
[ 22]   1.00-2.00   sec  9.30 KBytes  76.2 Kbits/sec    4   10.6 KBytes       
[SUM]   1.00-2.00   sec   191 KBytes  1.57 Mbits/sec   86             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   2.00-3.00   sec  42.1 KBytes   345 Kbits/sec    6   17.1 KBytes       
[  6]   2.00-3.00   sec  29.0 KBytes   237 Kbits/sec    3   7.90 KBytes       
[  8]   2.00-3.00   sec  27.6 KBytes   227 Kbits/sec    2   11.8 KBytes       
[ 10]   2.00-3.00   sec  38.2 KBytes   313 Kbits/sec    5   11.8 KBytes       
[ 12]   2.00-3.00   sec  34.2 KBytes   281 Kbits/sec    9   11.8 KBytes       
[ 14]   2.00-3.00   sec  42.1 KBytes   345 Kbits/sec    9   26.3 KBytes       
[ 16]   2.00-3.00   sec  25.0 KBytes   205 Kbits/sec    2   9.21 KBytes       
[ 18]   2.00-3.00   sec  34.2 KBytes   281 Kbits/sec    3   13.2 KBytes       
[ 20]   2.00-3.00   sec  19.9 KBytes   163 Kbits/sec    6   10.6 KBytes       
[ 22]   2.00-3.00   sec  1.33 KBytes  10.9 Kbits/sec    1   2.66 KBytes       
[SUM]   2.00-3.00   sec   294 KBytes  2.41 Mbits/sec   46             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   3.00-4.00   sec  32.9 KBytes   269 Kbits/sec    3   10.5 KBytes       
[  6]   3.00-4.00   sec  13.2 KBytes   108 Kbits/sec    4   10.5 KBytes       
[  8]   3.00-4.00   sec  17.1 KBytes   140 Kbits/sec    4   5.27 KBytes       
[ 10]   3.00-4.00   sec  23.7 KBytes   194 Kbits/sec    3   7.90 KBytes       
[ 12]   3.00-4.00   sec  22.4 KBytes   183 Kbits/sec    9   7.90 KBytes       
[ 14]   3.00-4.00   sec  32.9 KBytes   269 Kbits/sec   14   19.7 KBytes       
[ 16]   3.00-4.00   sec  17.1 KBytes   140 Kbits/sec    4   5.27 KBytes       
[ 18]   3.00-4.00   sec  26.3 KBytes   216 Kbits/sec    3   10.5 KBytes       
[ 20]   3.00-4.00   sec  15.9 KBytes   130 Kbits/sec    3   5.31 KBytes       
[ 22]   3.00-4.00   sec  3.98 KBytes  32.6 Kbits/sec    7   6.64 KBytes       
[SUM]   3.00-4.00   sec   206 KBytes  1.68 Mbits/sec   54             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  4]   4.00-5.00   sec  29.0 KBytes   237 Kbits/sec    1   6.58 KBytes       
[  6]   4.00-5.00   sec  13.2 KBytes   108 Kbits/sec    3   7.90 KBytes       
[  8]   4.00-5.00   sec  21.1 KBytes   172 Kbits/sec    1   5.27 KBytes       
[ 10]   4.00-5.00   sec  6.58 KBytes  53.9 Kbits/sec    4   5.27 KBytes       
[ 12]   4.00-5.00   sec  27.6 KBytes   226 Kbits/sec    0   9.21 KBytes       
[ 14]   4.00-5.00   sec  35.5 KBytes   291 Kbits/sec    5   11.8 KBytes       
[ 16]   4.00-5.00   sec  13.2 KBytes   108 Kbits/sec    1   5.27 KBytes       
[ 18]   4.00-5.00   sec  30.3 KBytes   248 Kbits/sec    2   9.21 KBytes       
[ 20]   4.00-5.00   sec  5.31 KBytes  43.5 Kbits/sec    3   5.31 KBytes       
[ 22]   4.00-5.00   sec  19.9 KBytes   163 Kbits/sec    2   6.64 KBytes       
[SUM]   4.00-5.00   sec   202 KBytes  1.65 Mbits/sec   22 

办公室网速大概 1.6Mbps左右。

4. curl

  • 生成测试大文件:
dd if=/dev/urandom of=file1 bs=1M count=20
  • 启动测试:
curl -u  "user:name" -T file1 ftp://xxx.xxx.xxx.xxx/90400535/
  • 测试结果:
/usrdata/QuecOpen # curl -u  "user:name" -T file1 ftp://118.178.106.
177/90400535/
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20.0M    0     0  100 20.0M      0   190k  0:01:47  0:01:47 --:--:--  208k

使用curl实际传输文件平均速度为208kB/s

5. 总结

总结,使用curl、iperf测试结果 一致 ,iperf:1.6Mbps,curl:208KB/s,等价208*8=1.6Mbps

6. 其它网络测速方法:

6.1 wget

测试下行速度。

wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz

Saving to: `lnmp1.8.tar.gz'

100%[===========================================>] 488,716,790 48.5M/s in 8.9s    

2032-11-21 3:11:59 (52.4 MB/s) - `lnmp1.8.tar.gz' saved [488716790/488716790]

6.2 fast

https://github.com/sindresorhus/fast-cli

6.3 speedtest

$ wget https://raw.github.com/sivel/speedtest-cli/master/speedtest.py
$ chmod a+rx speedtest.py
$ mv speedtest.py /usr/local/bin/speedtest
$ speedtest

6.4 bench.sh

https://github.com/teddysun/across/blob/master/bench.sh

—博主热门专栏推荐 —

  • Python零基础快速入门系列
  • 深入浅出i.MX8企业级开发实战系列
  • MQTT从入门到提高系列
  • 物体检测快速入门系列
  • 自动驾驶模拟器AirSim快速入门
  • 安全利器SELinux入门系列
  • Python数据科学快速入门系列

你可能感兴趣的:(物联网,linux,网络测速,iperf,curl)