Linuxptp安装部署
ptp介绍
PTP(Precision Time Protocol)精确时间协议,由IEEE1588规定,用于同步网络中多台设备。
ptp工作原理
PTP时钟可以实现主时钟和从时钟功能,但是一个PTP通信子网内只能有一个主时钟。在系统的同步过程中,PTP主时钟提供时间同步及时间信息,从时钟接收主时钟发来的时间戳信息,系统根据此信息计算出主从线路时间延迟及主从时间差,并利用该时间差调整本地时间,从而使设备时间保持与主设备时间一致的频率和相位,实现频率同步和时间同步。
ptp中的设备类型
PTP作用的对象是时钟,主要分为全局主时钟(GrandMaster),主时钟(MasterClock),透明时钟(TransparentClock),边界时钟(BoundaryClock)和普通时钟(OrdinaryClock)。
全局主时钟(GM) | 全局唯一,为PTP域中的所有设备提供时间基准。 |
主时钟(MC) | OC和BC的基准时钟称为主时钟。 |
边界时钟 (BC) | 有多个端口连接到网络的时钟,一个slave端口连接到上游设备的PTP端口,其他的端口作为master连接到下游设备的slave端口。下游slave端口同构PTP协议直接同步于边界时钟,而不是直接和grandmaster通信。 |
普通时钟(OC) | 只有一个端口(port)连接到网络的时钟,可以作为master或slave之一; 作为master时候,可以是 grandmaster,作为slave时候,一般作为时钟分发网络的端点设备(end,最后一级)。 |
透明时钟(TC) | 可以担负同步系统中信号分配器的角色。它拥有多个PTP端口,不需要像普通时钟和边界时钟一样与其他节点进行时间同步,仅负责在端口之间转发PTP报文时,对其进行转发延时校正(在PTP报文中增加时间校正信息)。 |
linuxptp介绍
在服务器上安装部署linuxptp就不做过多说明了,联网安装可执行下面的指令
yum install -y linuxptp
Linuxptp主要包含两个软件,一个是ptp4l,一个是phc2sys。作用分别如下
- ptp4l:遵循IEEE 1588-2008标准文档规范,实现了BC(Boundary Clock)、OC(Ordinary Clock)和TC(Transparent Clock);
- phc2sys:phc2sys是一个同步系统中两个或多个时钟的程序。通常,它用于将系统时钟与PTP硬件时钟(PHC)同步,该硬件时钟本身由ptp4l(8)程序同步;
- pcm:在ptp4l运行期间对其进行配置。
ptp4l指令详解
[root@localhost ~]# ptp4l -husage: ptp4l [options]Delay Mechanism-A Auto, starting with E2E-E E2E, delay request-response (default)-P P2P, peer delay mechanismNetwork Transport-2 IEEE 802.3-4 UDP IPV4 (default)-6 UDP IPV6Time Stamping-H HARDWARE (default)-S SOFTWARE-L LEGACY HWOther Options-f [file] read configuration from 'file'-i [dev] interface device to use, for example 'eth0'(may be specified multiple times)-p [dev] PTP hardware clock device to use, default auto(ignored for SOFTWARE/LEGACY HW time stamping)-s slave only mode (overrides configuration file)-t transparent clock-l [num] set the logging level to 'num'-m print messages to stdout-q do not print messages to the syslog-v prints the software version and exits-h prints this message and exits
phc2sys指令详解
[root@localhost ~]# phc2sys
autoconfiguration or valid source clock must be selected.usage: phc2sys [options]automatic configuration:-a turn on autoconfiguration-r synchronize system (realtime) clockrepeat -r to consider it also as a time sourcemanual configuration:-c [dev|name] slave clock (CLOCK_REALTIME)-d [dev] master PPS device-s [dev|name] master clock-O [offset] slave-master time offset (0)-w wait for ptp4lcommon options:-f [file] configuration file-E [pi|linreg] clock servo (pi)-P [kp] proportional constant (0.7)-I [ki] integration constant (0.3)-S [step] step threshold (disabled)-F [step] step threshold only on start (0.00002)-R [rate] slave clock update rate in HZ (1.0)-N [num] number of master clock readings per update (5)-L [limit] sanity frequency limit in ppb (200000000)-M [num] NTP SHM segment number (0)-u [num] number of clock updates in summary stats (0)-n [num] domain number (0)-x apply leap seconds by servo instead of kernel-z [path] server address for UDS (/var/run/ptp4l)-l [num] set the logging level to 'num' (6)-t [tag] add tag to log messages-m print messages to stdout-q do not print messages to the syslog-v prints the software version and exits-h prints this message and exits
检查网卡是否支持ptp硬件时钟,并确定时钟的设备名称
命令
ethtool -T p2p1
可以看到p2p1占用的端口为/dev/ptp5
C2模式下的server配置
这时候server充当的角色是OC(slave角色),只接收ptp信号,Switch充当的角色是TC
启动ptp4l进程
/usr/sbin/ptp4l -2 -A -q -i p2p1 -f /etc/ptp4l.conf -s -m
-2: IEEE 802.3协议
-A: 自动选择延迟测量机制,运行时使用E2E,但接收到peer delay request报文后自动切换到P2P。
-q: 不将信息发送到系统logger
-i: 指定网口(PTP port),可以多次使用指定多个网口,但该选项或配置文件中至少要指定一个。
-f: 指定配置文件,若没有指定,则使用默认配置。
-s: slaveOnly模式
-m: 将信息打印到标准输出
启动phc2sys进程,同步系统时钟跟PHC时钟
/usr/sbin/phc2sys -s /dev/ptp5 -c CLOCK_REALTIME -w -r -n 24 -m
-s: 按设备(如/dev/ptp0)或接口(如eth0)或名称(如系统时钟的clock_REALTIME)指定主时钟(即ptp4l绑定的接口)
-c: 按设备(如/dev/ptp1)或接口(如eth1)或名称指定从时钟。默认值CLOCK_REALTIME(系统时钟)
-w: 等待直到ptp4l处于同步状态
-r: 指示phc2sys也同步系统时钟(clock_REALTIME)
-n: 指定ptp4l使用的域号。默认值为0
-m: 将信息打印到标准输出
C1模式下的server配置
这时候server充当的角色是BC(既是slave又是master),网络中没有Switch。
说明:
p2p1从GM获取PTP,然后将PHC同步到系统时钟,充当的是slave角色;
p3p2将p2p1中的信号从p3p2下发给RU,充当的是master的角色。
slave配置
/usr/sbin/ptp4l -2 -A -q -i p2p1 -f /etc/ptp4l.conf -s -m
/usr/sbin/phc2sys -s /dev/ptp5 -c CLOCK_REALTIME -w -r -n 24 -m
master配置
获取p2p1跟p3p2设备
启动进程
/usr/sbin/ptp4l -2 -A -q -i p3p2 -f /etc/ptp4l_m.conf -m
/usr/sbin/phc2sys -q -m -s /dev/ptp5 -c /dev/ptp3 -w -r -n 24
配置BC是如果进程报错,按照错误时进行修改参数即可
例如如下报错:
在配置文件中修改tx_timestamp_timeout参数即可,将timeout值设置的大一点,单位是ms
tx_timestamp_timeout: 等待发送时间戳的超时时间,单位ms
配置文件参数含义
参考:转载:linuxptp/ptp4l PTP时钟同步配置选项_小学生Yi的博客-CSDN博客_ptp4l
配置选项 | 描述 | 默认值 |
---|---|---|
twoStepFlag | 两步时间戳模式,单步时间戳模式选择 | 1 |
slaveOnly | 绕过BMCA,使clock工作在slave模式 | 0 |
socket_priority | 报文优先级,0~15,只在L2协议下生效 | 0 |
gmCapable | 是否具有master能力,只对gPTP模式生效 | 1 |
priority1 | 时钟priority1属性,0~255 | 128 |
priority2 | 时钟priority2属性,0~255 | 128 |
clockClass | 时钟clockClass属性 | 248 |
clockAccuracy | 时钟clockAccuracy属性 | 0xFE |
clockIdentity | 时钟clockIdentity属性,使用默认值则会在运行时自动生成 | 000000.0000.000000 |
offsetScaledLogVariance | 时钟offsetScaledLogVariance属性 | 0xFFFF |
G.8275.defaultDS.localPriority | ITU-T G.8275.1 and G.8275.2使用 | 128 |
maxStepsRemoved | Announce报文的stepsRemoved值大于等于该值时,则不参与BMCA | 255 |
domainNumber | PTP域 | 0 |
utc_offset | TAI和UTC时间差 | 37 |
free_running | 不调整物理时钟 | 0 |
freq_est_interval | 评估本地时钟和对端时钟频率比值的时间间隔,时间间隔值为该值的2的次方。 | 1(2秒) |
assume_two_step | 按两步报文的方式,处理单步报文 | 0 |
tc_spanning_tree | 透明时钟生成树模式,在PTP网络中,实现所有透明时钟内增加Announce报文的stepsRemoved值,和相应BMCA,可以避免环形PTP报文循环。 | 0 |
tx_timestamp_timeout | 等待发送时间戳的超时时间,单位ms | 1 |
check_fup_sync | 检查sync,follow_up报文顺序 | 0 |
clock_servo | 时钟伺服器,可选择pi,ntpshm,nullf | pi |
clock_type | 时钟类型,OC,BC,E2E_TC,P2P_TC | OC |
pi_proportional_const | pi算法选项 | 0.0 |
pi_integral_const | pi算法选项 | 0.0 |
pi_proportional_scale | pi算法选项 | 0.0 |
pi_proportional_exponent | pi算法选项 | -0.3 |
pi_proportional_norm_max | pi算法选项 | 0.7 |
pi_integral_scale | pi算法选项 | 0.0 |
pi_integral_exponent | pi算法选项 | 0.4 |
pi_integral_norm_max | pi算法选项 | 0.3 |
step_threshold | 步进时钟的阈值,超过阈值,直接调整时钟时间,单位秒 | 0.0 |
first_step_threshold | 第一次步进时钟的阈值,超过阈值,直接调整时钟时间,单位秒 | 0.00002 |
max_frequency | 最大频率调整值,单位ppb | 900000000 (90%) |
sanity_freq_limit | PTP时钟和系统monotonic时钟频率偏差限制,单位ppb | 200000000 (20%) |
initial_delay | 链路延迟初始值,单位ns。设置为0的话,程序会先测量 | 0 |
ntpshm_segment | ntpshm私服使用的SHM段的数目 | 0 |
udp6_scope | IPv6多播报文的范围,默认为全局范围 | 0x0E |
uds_address | UNIX domain socket地址 | /var/run/ptp4l |
dscp_event | PTP事件报文使用的Differentiated Services Codepoint (DSCP),0~63 | 0 |
dscp_general | PTP通用报文使用的Differentiated Services Codepoint (DSCP),0~63 | 0 |
dataset_comparison | BMCA比较dataset的方法,可选择"ieee1588"或 “G.8275.x” | ieee1588 |
logging_level | log级别 | 6 (LOG_INFO) |
message_tag | 可以添加到所有打印信息中 | 空字符 |
verbose | 打印消息到标准输出 | 0 |
use_syslog | 打印消息到系统日志 | 1 |
summary_interval | 打印统计信息时间间隔,时间间隔值为该值的2的次方。 | 0(1秒) |
time_stamping | 时间戳类型,可选择hardware, software, legacy, onestep, 或p2p1step | hardware |
productDescription | 时钟描述 | ;; |
revisionData | 时钟描述 | ;; |
userDescription | 时钟描述 | 空字符 |
manufacturerIdentity | 时钟描述 | 00:00:00 |
kernel_leap | linux内核闰秒 | 1 |
timeSource | 时钟类型 | 0xA0 |
hwts_filter | 硬件时间戳过滤器设置模式,可选择normal, check, full | normal |
asCapable | 如果设置为true,就认为是gPTP设备,不再检查。 | auto |
BMCA | 最优时钟算法,可选择masterOnly,slaveOnly或ptp | ptp |
inhibit_announce | 禁止发送Annouce报文,需要使能ignore_source_id | 0 |
ignore_source_id | 忽略sync和follow_up报文的source port id检查 | 0 |
msg_interval_request | 是否使能请求调整sync和peer delay request报文的发送间隔 | 0 |
servo_num_offset_values | 时间偏差值连续小于servo_offset_threshold的数目,达到这个数目伺服器进入stable状态 | 10 |
servo_offset_threshold | 时间偏差阈值 | 0 |
slave_event_monitor | slave事件监测的UNIX domain socket地址 | 空字符 |
write_phase_mode | 使用PTP硬件写相位功能,代替调整频率偏差 | 0 |
5.3 单播发现选项
配置选项 | 描述 |
---|---|
table_id | table id,正数值 |
logQueryInterval | 单播协商时间间隔,时间间隔值为该值的2的次方。 |
peer_address | P2P单播地址 |
L2|UDPv4|UDPv6 | 传输协议 |
Linuxptp安装部署相关推荐
- 2021年大数据Flink(三):Flink安装部署 Local本地模式
目录 Flink安装部署 Local本地模式 原理 操作 测试 Flink安装部署 Flink支持多种安装模式 - Local-本地单机模式,学习测试时使用 - Standalone-独立集群模式,F ...
- Mycat 读写分离 数据库分库分表 中间件 安装部署,及简单使用
MyCat是一个开源的分布式数据库系统,是一个实现了MySQL协议的服务器,前端用户可以把它看作是一个数据库代理,用MySQL客户端工具和命令行访问,而其后端可以用MySQL原生协议与多个MySQL服 ...
- 【SVN】1. SVN 安装部署
一. SVN概述 1. SVN 简介 Subversion 版本控制系统 简称 SVN. SVN 是一个跨平台开放源代码的集中式版本控制系统,可以实现文件及目录的保存及版本回溯. SVN ...
- Docker概述和安装部署
概述 Docker产生的背景 一款产品从开发到上线,从操作系统,到运行环境,再到应用配置.作为开发+运维之间的协作我们需要关心很多东西,这也是很多互联网公司都不得不面对的问题,特别是各种版本的迭代之后 ...
- DSVS7050签名服务器的网站,吉大正元数字签名服务器-安装部署手册(COM版 VCTK_S接口)2.1.1.doc...
吉大正元数字签名服务器-安装部署手册(COM版 VCTK_S接口)2.1.1 数字签名服务器v2.1.1 安装部署手册 (VSTK接口 COM版) V2.1.1 长 春 吉 大 正 元 信 息 技 术 ...
- Airflow安装部署
Airflow安装部署 新闻信息是通过爬虫获取,使用scrapy框架进行爬虫任务:使用airflow工作流监控平台对爬虫任务进行管理.监控(可使用CeleryExecutor分布式,也可使用Local ...
- logicaldoc 6.5 结合postgresql 9.x安装部署—基于windows平台
2019独角兽企业重金招聘Python工程师标准>>> 湘中朱生 2012年9月于深圳 说明:原创内容,请勿转载! <1> 从官网下载部署包 官方网站提供源码包和集成 ...
- Centos6.0 64位MySQL 5.5.20 CMake 安装部署
Centos6.0 64位下 MySQL 5.5.20 CMake 安装部署 一.下载所需软件 linux用 wget 下载需要的软件,保存到目录 /usr/local/src 下 wget ftp: ...
- 【原创 HadoopSpark 动手实践 1】Hadoop2.7.3 安装部署实践
目录: 第一部分:操作系统准备工作: 1. 安装部署CentOS7.3 1611 2. CentOS7软件安装(net-tools, wget, vim等) 3. 更新CentOS7的Yum源,更新软 ...
- DinnerNow - 如何安装部署
DinnerNow - 如何安装部署 记得还是去年七月份.在微软的一次培训中,一位姓杨的讲师提到了这个DEMO.我后来回到公司就从相关站点 http://www.dinnernow.net 下载了一 ...
最新文章
- Webservice开发流程
- python coding_python开头的coding设置方法
- vary渲染图没了_云渲染哪个好用?云渲染平台对比
- 特斯拉“刹车失灵”不绝于耳网络营销外包怎样看特斯拉进驻中国?
- 搭建glusterfs集群
- ansys经典界面分析工字钢_ANSYS做一个工字钢的热分析
- nssl1148,jzoj5461-购物【可撤回贪心,堆】
- mysql 5.7.21-linux_MySQL 5.7.21 Linux平台安装 Part 2
- 万万没想到,我的炼丹炉玩坏了
- 读取文件中的文本并返回字符串
- C++_结构体的定义和使用_结构体数组---C++语言工作笔记025
- [转]【建议收藏】优秀实用的OpenCV开源项目汇总
- ResNet 6大变体对比
- 影响网站跳出率的因素
- 史上最全无线通信频率分配表
- mysql 日期查询 今天、明天、本周、七天内、本月、后一个月
- pytorch torchvision.ops.roi_align
- 录音文件转换成文字很难吗?这几个步骤就可以解决烦恼了
- kali linux改root密码
- Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (defau-cli) on project