当前位置: 首页 > news >正文

Linux PTP 测量实操 (IEEE 1588)

测量 IEEE 1588 需要使用 linuxptp 这个工程, 官网是

https://linuxptp.sourceforge.net/

获取代码可以通过git

git clone git://git.code.sf.net/p/linuxptp/code linuxptp

如果是当前环境本地编译的话, 直接在下载好的代码路径make就可以.

如果需要在开发板上面使用的话,就需要交叉编译,将makefile里面的gcc替换为你平台的toolchain就可以了.

编译好之后, 我们需要的就只有1个文件, 就是 ptp4l.

下面开始测试:

我的环境 : 开发板上的双网口,使用网线直连, 可以ping通.

看下网口对ptp协议的支持情况:

通过 https://linuxptp.sourceforge.net/ 第5节的介绍得知, 当前的网卡既支持 Hardware 模式, 又支持 software 模式.

看一下 ptp4l 的版本,验证交叉编译的正确性.

# ./ptp4l -v
4.4-dirty

因为是串口连接, 所以只有一个中端, 就决定, 一个网口后台跑 server, 一个网口前台跑 client.

./ptp4l -2 -i eth0 -m -H &
//eth0 作为server端,硬件时间戳 -m  print messages to stdout 是输出信息到串口. -H是HARDWARE模式, & 是后台运行
./ptp4l -2 -i eth1 -m -H -s
//eth1 作为client端,硬件时间戳 -m  print messages to stdout 是输出信息到串口. -H是HARDWARE模式, -s 是 client only synchronization mode,就是从模式

输出的log如下

# ./ptp4l -2 -i eth0 -m -S &
# ptp4l[159.928]: port 1 (eth0): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[159.928]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[159.929]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE#
#
# ptp4l[167.408]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[167.408]: selected local clock fefefe.fffe.1b951a as best master
ptp4l[167.408]: port 1 (eth0): assuming the grand master role#
#
# ./ptp4l -2 -i eth1 -m -S -s
ptp4l[171.096]: port 1 (eth1): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[171.096]: uds: removed existing /var/run/ptp4l
ptp4l[171.096]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[171.097]: uds: removed existing /var/run/ptp4lro
ptp4l[171.097]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[171.420]: port 1 (eth1): new foreign master fefefe.fffe.1b951a-1
ptp4l[175.428]: selected best master clock fefefe.fffe.1b951a
ptp4l[175.428]: foreign master not using PTP timescale
ptp4l[175.428]: port 1 (eth1): LISTENING to UNCALIBRATED on RS_SLAVE
ptp4l[177.448]: master offset      -8166 s0 freq      -0 path delay     42458
ptp4l[178.452]: master offset      -3083 s0 freq      -0 path delay     42458
ptp4l[179.456]: master offset      -5625 s0 freq      -0 path delay     39833
ptp4l[180.460]: master offset      -4322 s0 freq      -0 path delay     39822
ptp4l[181.464]: master offset      -3281 s0 freq      -0 path delay     39822
ptp4l[182.468]: master offset      -1124 s0 freq      -0 path delay     39833
ptp4l[183.472]: master offset      -3739 s0 freq      -0 path delay     40781
ptp4l[184.476]: master offset      -2792 s0 freq      -0 path delay     41292
ptp4l[185.480]: master offset      -4125 s0 freq      -0 path delay     41292
ptp4l[186.484]: master offset      -3489 s0 freq      -0 path delay     41031
ptp4l[187.488]: master offset      -1438 s0 freq      -0 path delay     40771
ptp4l[188.492]: master offset      -4395 s0 freq      -0 path delay     41020
ptp4l[189.496]: master offset      -3811 s0 freq      -0 path delay     41020
ptp4l[190.500]: master offset      -1917 s0 freq      -0 path delay     40417
ptp4l[191.504]: master offset      -7333 s0 freq      -0 path delay     40833
ptp4l[192.508]: master offset       2501 s0 freq      -0 path delay     40833
ptp4l[193.512]: master offset      -5239 s2 freq    +182 path delay     41281
ptp4l[193.512]: port 1 (eth1): UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED
ptp4l[194.516]: master offset      -2542 s2 freq     -75 path delay     41083
ptp4l[195.520]: master offset      -7000 s2 freq    -527 path delay     41083
ptp4l[196.524]: master offset      -4708 s2 freq    -303 path delay     40833
ptp4l[197.528]: master offset      -3500 s2 freq    -186 path delay     40000
ptp4l[198.532]: master offset      -5155 s2 freq    -356 path delay     40322
ptp4l[199.536]: master offset      -3530 s2 freq    -197 path delay     40322
ptp4l[200.540]: master offset      11553 s2 freq   +1323 path delay     40322
ptp4l[201.544]: master offset      -4188 s2 freq    -256 path delay     40729
ptp4l[202.548]: master offset      -4114 s2 freq    -252 path delay     40322
ptp4l[203.552]: master offset       -864 s2 freq     +72 path delay     40322
ptp4l[204.556]: master offset      -3405 s2 freq    -186 path delay     40322
ptp4l[205.560]: master offset      -5437 s2 freq    -394 path delay     40729
ptp4l[206.564]: master offset      -4562 s2 freq    -311 path delay     40729
ptp4l[207.568]: master offset      -6562 s2 freq    -518 path delay     40729
ptp4l[208.572]: master offset      -5979 s2 freq    -466 path delay     40729
ptp4l[209.576]: master offset      -5187 s2 freq    -392 path delay     40729
ptp4l[210.580]: master offset      -5041 s2 freq    -382 path delay     39041
ptp4l[211.584]: master offset      -3166 s2 freq    -198 path delay     39041
ptp4l[212.588]: master offset      -2916 s2 freq    -176 path delay     39041
ptp4l[213.592]: master offset      -5166 s2 freq    -406 path delay     39416
ptp4l[214.596]: master offset      -4187 s2 freq    -312 path delay     39270
ptp4l[215.600]: master offset      -4353 s2 freq    -333 path delay     39270
ptp4l[216.604]: master offset      -2292 s2 freq    -129 path delay     39000
ptp4l[217.608]: master offset      -3208 s2 freq    -224 path delay     39000
ptp4l[218.612]: master offset      -1083 s2 freq     -13 path delay     38917
ptp4l[219.616]: master offset      -1104 s2 freq     -16 path delay     39146
ptp4l[220.620]: master offset      -3125 s2 freq    -221 path delay     39375
ptp4l[221.624]: master offset      -4239 s2 freq    -337 path delay     39406
ptp4l[222.628]: master offset       3510 s2 freq    +442 path delay     39406
ptp4l[223.632]: master offset      -1603 s2 freq     -71 path delay     39562
ptp4l[224.636]: master offset      -4198 s2 freq    -335 path delay     39739
ptp4l[225.640]: master offset      -4780 s2 freq    -398 path delay     39739
ptp4l[226.644]: master offset      -1989 s2 freq    -121 path delay     39739
ptp4l[227.648]: master offset      -5000 s2 freq    -427 path delay     40083
ptp4l[228.652]: master offset      -5041 s2 freq    -436 path delay     40083
ptp4l[229.656]: master offset      -5562 s2 freq    -494 path delay     40437
ptp4l[230.660]: master offset      -1645 s2 freq    -104 path delay     40562
ptp4l[231.664]: master offset      -3978 s2 freq    -341 path delay     40437
ptp4l[232.668]: master offset      -5854 s2 freq    -534 path delay     40562
ptp4l[233.672]: master offset      -6750 s2 freq    -631 path delay     40542
ptp4l[234.676]: master offset      -5083 s2 freq    -469 path delay     40542
ptp4l[235.680]: master offset      -5635 s2 freq    -530 path delay     40052
ptp4l[236.684]: master offset       6615 s2 freq    +702 path delay     40052
ptp4l[237.688]: master offset      -6114 s2 freq    -577 path delay     40198
ptp4l[238.692]: master offset      -4230 s2 freq    -393 path delay     39396
ptp4l[239.696]: master offset      -4354 s2 freq    -410 path delay     39396
ptp4l[240.700]: master offset      -1083 s2 freq     -84 path delay     39333
ptp4l[241.704]: master offset      -4813 s2 freq    -462 path delay     39396
ptp4l[242.708]: master offset      -3104 s2 freq    -294 path delay     39396
ptp4l[243.712]: master offset      -4166 s2 freq    -404 path delay     39375
ptp4l[244.716]: master offset       4354 s2 freq    +452 path delay     39646
ptp4l[245.720]: master offset      -4229 s2 freq    -410 path delay     39646
ptp4l[246.724]: master offset      -4656 s2 freq    -458 path delay     40656
ptp4l[247.728]: master offset      -6958 s2 freq    -695 path delay     41500
ptp4l[248.732]: master offset      -4344 s2 freq    -438 path delay     39677
ptp4l[249.736]: master offset      -3927 s2 freq    -400 path delay     39677
ptp4l[250.740]: master offset      -2521 s2 freq    -262 path delay     39729
ptp4l[251.744]: master offset      -6406 s2 freq    -657 path delay     40656
ptp4l[252.748]: master offset      -1271 s2 freq    -145 path delay     39729
ptp4l[253.752]: master offset      -2145 s2 freq    -234 path delay     39729
ptp4l[254.756]: master offset      -3042 s2 freq    -327 path delay     39875
ptp4l[255.760]: master offset       1458 s2 freq    +124 path delay     39875
ptp4l[256.764]: master offset        281 s2 freq      +7 path delay     39552
ptp4l[257.768]: master offset      -4969 s2 freq    -523 path delay     39552
ptp4l[258.772]: master offset       1479 s2 freq    +123 path delay     39187
ptp4l[259.776]: master offset      -7125 s2 freq    -744 path delay     39875

可以看到软模式执行良好. 我的环境, 硬模式有问题,出错log如下,还不知道原因.

# ./ptp4l -2 -i eth0 -m -H &
# ptp4l[38041.506]: selected /dev/ptp0 as PTP clock
ptp4l[38041.548]: port 1 (eth0): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[38041.548]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[38041.548]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
# ./ptp4l -2 -i eth1 -m -H -s
ptp4l[38048.235]: selected /dev/ptp1 as PTP clock
ptp4l[38048.276]: port 1 (eth1): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[38048.276]: uds: removed existing /var/run/ptp4l
ptp4l[38048.276]: port 0 (/var/run/ptp4l): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[38048.276]: uds: removed existing /var/run/ptp4lro
ptp4l[38048.277]: port 0 (/var/run/ptp4lro): INITIALIZING to LISTENING on INIT_COMPLETE
ptp4l[38049.376]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[38049.376]: selected local clock fefefe.fffe.1b951a as best master
ptp4l[38049.376]: port 1 (eth0): assuming the grand master role
ptp4l[38049.380]: port 1 (eth1): new foreign master fefefe.fffe.1b951a-1
ptp4l[38050.380]: port 1 (eth1): received SYNC without timestamp
ptp4l[38050.392]: timed out while polling for tx timestamp
ptp4l[38050.392]: increasing tx_timestamp_timeout or increasing kworker priority may correct this issue, but a driver bug likely causes it
ptp4l[38050.392]: port 1 (eth0): send sync failed
ptp4l[38050.392]: port 1 (eth0): MASTER to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)
ptp4l[38055.048]: selected local clock fefefe.fffe.1b951b as best master
ptp4l[38066.472]: port 1 (eth0): FAULTY to LISTENING on INIT_COMPLETE
ptp4l[38074.144]: port 1 (eth0): LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES
ptp4l[38074.144]: port 1 (eth0): assuming the grand master role
ptp4l[38075.148]: port 1 (eth1): received SYNC without timestamp
ptp4l[38075.160]: timed out while polling for tx timestamp
ptp4l[38075.160]: increasing tx_timestamp_timeout or increasing kworker priority may correct this issue, but a driver bug likely causes it
ptp4l[38075.160]: port 1 (eth0): send sync failed
ptp4l[38075.160]: port 1 (eth0): MASTER to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED)

参考文章:

12 – 利用LinuxPTP进行时间同步(软/硬件时间戳) – 研一-腾讯云开发者社区-腾讯云

Linux下交叉编译 linuxptp-CSDN博客

linuxptp时钟同步测试_ptp时钟测试-CSDN博客

Linuxptp使用总结_linuxptp版权-CSDN博客

RT-Thread : IEEE1588/PTP 协议的实现_stm32 ptp-CSDN博客

IEEE1588v2解析(3)--PTP的路径时延测量方法介绍_1588测试操作指导-CSDN博客

数据采集和测试中的时间精度协议(PTP) | HBM

linux下ptp性能测试_ptp测试软件-CSDN博客

PTP简介-IEEE1588协议-CSDN博客

SSZTAU5 Technical article | TI.com

以太网帧

PTP(Precision Time Protocol)高精度时间同步协议+linuxptp代码学习_【ptp(precision time protocol)高精度时间同步协议+linuxptp代码学-CSDN博客

【时间同步】IEEE-1588总结_ieee1588-CSDN博客

手把手教你解决PL2303驱动在Win10无法使用-CSDN博客

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • vscode 链接数据库
  • RLS带遗忘因子的递归最小二乘法
  • SSH软链接后门从入门到应急响应
  • AI创意引擎:优化Prompt提示词的高效提问技巧
  • 《深度学习》OpenCV 高阶 图像金字塔 用法解析及案例实现
  • Linux学习-ELK(一)
  • 线性代数 第六讲 特征值和特征向量_相似对角化_实对称矩阵_重点题型总结详细解析
  • 探索信号处理:使用傅里叶小波变换分析和恢复信号
  • 阿里的云盘竟然也能那么容易的泄露,可见,互联网几乎没有绝对的安全!水平越权和高并发的关系到底是什么?用户权限怎么隔离才算好? 全局拦截器怎么设计的这么垃圾?
  • 多输入多输出 | Matlab实现SSA-BP麻雀搜索算法优化BP神经网络多输入多输出预测
  • 4款数据恢复软件,包含易我数据恢复软件在内
  • oracle数据库安装和配置详细讲解
  • 基于python+django+vue的社区爱心养老管理系统
  • 【Node.js】初识 RabbitMQ
  • 短文写作竞赛系统小程序的设计
  • JavaScript-如何实现克隆(clone)函数
  • Akka系列(七):Actor持久化之Akka persistence
  • IndexedDB
  • Java到底能干嘛?
  • JS 面试题总结
  • Js实现点击查看全文(类似今日头条、知乎日报效果)
  • linux学习笔记
  • MySQL QA
  • PHP 程序员也能做的 Java 开发 30分钟使用 netty 轻松打造一个高性能 websocket 服务...
  • 机器学习中为什么要做归一化normalization
  • 码农张的Bug人生 - 见面之礼
  • 面试题:给你个id,去拿到name,多叉树遍历
  • 浅谈Golang中select的用法
  • 深度学习在携程攻略社区的应用
  • 学习HTTP相关知识笔记
  • 应用生命周期终极 DevOps 工具包
  • FaaS 的简单实践
  • ​2020 年大前端技术趋势解读
  • ​configparser --- 配置文件解析器​
  • ​VRRP 虚拟路由冗余协议(华为)
  • # Panda3d 碰撞检测系统介绍
  • #ifdef 的技巧用法
  • $.ajax()
  • $nextTick的使用场景介绍
  • (k8s中)docker netty OOM问题记录
  • (二)十分简易快速 自己训练样本 opencv级联lbp分类器 车牌识别
  • (回溯) LeetCode 77. 组合
  • (理论篇)httpmoudle和httphandler一览
  • (七)理解angular中的module和injector,即依赖注入
  • (一) 初入MySQL 【认识和部署】
  • (转)Android学习笔记 --- android任务栈和启动模式
  • (转)mysql使用Navicat 导出和导入数据库
  • (转)创业的注意事项
  • (总结)Linux下的暴力密码在线破解工具Hydra详解
  • **PHP二维数组遍历时同时赋值
  • *1 计算机基础和操作系统基础及几大协议
  • .chm格式文件如何阅读
  • .config、Kconfig、***_defconfig之间的关系和工作原理
  • .NET Compact Framework 多线程环境下的UI异步刷新
  • .net core 调用c dll_用C++生成一个简单的DLL文件VS2008