【3】安装cyclictest和iperf

cyclictest

安装比较简单,我是直接使用命令行:

复制代码
apt-get install rt-tests 

随后,运行

复制代码
sudo cyclictest

但是这个程序会一直运行,直到你手动中断程序,而且每秒生成一行输出也很烦人,所以可以选择把结果输出到一个文档里。

复制代码
max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram
cores=4
for i in `seq 1 $cores`
do
  column=`expr $i + 1`
  cut -f1,$column histogram > histogram$i
done
echo -n -e "set title \"Latency plot\"\n\
set terminal png\n\
set xlabel \"Latency (us), max $max us\"\n\
set xrange [0:150]\n\
set yrange [0.8:*]\n\
set ylabel \"Number of latency samples\"\n\
set output \"plot.png\"\n\
plot " > plotcmd
for i in `seq 1 $cores`
do
  if test $i != 1
  then
    echo -n ", " >> plotcmd
  fi
  cpuno=`expr $i - 1`
  if test $cpuno -lt 10
  then
    title="CPU$cpuno"
   else
    title="CPU$cpuno"
  fi
  echo -n "\"histogram$i\" using 1:2 smooth unique title \"$title\" with lines" >> plotcmd
done

gnuplot -persist < plotcmd

最后画出来的图如图所示。可以看到四核CPU每一个核的时延表现。

Iperf

iperf3 是 iperf 的第三个版本,它支持多种网络性能测试,如带宽、延迟、丢包率等。通过如下命令在ubuntu上安装iperf3.

复制代码
sudo apt install iperf3

在安装过程中会跳出以下页面,问是否将iperf作为开机自动以守护进程(daemon)模式启动。这里建议选否。

随后查看iperf是否安装成功。查看iperf3 --version:

实验配置

这里我要测试两台设备之间的网络情况,所以我在两台计算机上都安装了iperf,但是一台作为host一台作为server。

这两台机器是可以互相ping通的。

选中node1作为server,这会启动 iperf 服务器模式,监听默认端口(5201)等待客户端连接。

复制代码
iperf3 -s

在node2上设置:

复制代码
iperf3 -c 192.168.3.221

可以看到如下界面:

如果要测试双向的通信,或者设置测试时间,可以使用如下语句:

复制代码
iperf3 -c 192.168.3.221 --bidir -u -b 500M
相关推荐
Java后端的Ai之路10 分钟前
在一个 Python 脚本中导入另一个脚本的功能
服务器·开发语言·python
清水白石00823 分钟前
《解锁 Python 潜能:从异步基石到 pytest-asyncio 高级测试实战与最佳实践》
运维·python·pytest
三无少女指南26 分钟前
开发者环境配置最佳实践:编辑器Cursor ,VS Code的上位体验实现 AI 与 WSL 联动
运维·c语言·数据库·windows·git·编辑器
2301_8053489729 分钟前
Haproxy的介绍以及配置示例
运维
BHXDML32 分钟前
VMware 安装 Ubuntu 24.04 详细步骤
运维·服务器·ubuntu
Pr Young36 分钟前
有限状态机
服务器·后端
开开心心就好39 分钟前
文字转语音无字数限,对接微软接口比付费爽
java·linux·开发语言·人工智能·pdf·语音识别
山北雨夜漫步1 小时前
Docker
运维·docker·容器
wangjialelele1 小时前
万字整理计算机网络知识点
linux·c语言·网络·c++·计算机网络·php
草莓熊Lotso1 小时前
Qt文件操作:QFile读写全解析
运维·开发语言·c++·人工智能·qt