IEEE1588 verision 2 报文介绍

PTP 报文

  PTP verision 2 报文是由 报头 / header主体 / body 和 报尾 / suffix 组成,报尾长度可能为 0 ;

  PTP verision 2 报文在 verision 1 的 五种报文(sync 同步报文、follow_up 跟随报文、delay_req 延迟请求报文、delay_resp 延迟响应报文 和 management 管理报文)的基础上,

  增加了点延迟机制( peer-delay mechanism )中的 三种报文( Pdelay_req 报文、Pdelay_resp 报文 和 Pdelay_resp_Follow_up 报文 )signaling 信号报文announce 声明报文 这五种新报文;

  根据报文收发过程中,是否需要记录精确时间戳 分为 事件报文 / 通用报文

 

PTP 报头结构

表 1 PTP 报头的帧结构 [1]

  为了方便直观的理解,我绘制了图1,内容和结构都和 表 1 一致;

  offset 是距离报文首字节的偏移量,单位是 octet;

  >>> 1个 octet = 8 个 bits 

  reserved 是保留域,默认为 0;

图 1 PTP 报头结构

  介绍 PTP 报文报头中一些域:

  (1)messageType,【报文类型】( 0.5 个 octet = 4 bits),不同的值代表不同的PTP报文

  (2)versionPTP,【PTP版本】,(0.5 个 octet = 4bits ),PTP version1的话此处值为1,PTP version 2 的话此处值为 2

        “The value of the versionPTP field shall be the value of the portDS.versionNumber member of the data set of the originating node."

  (3)domainNumber,【PTP域序列号】,(1 个 octet = 8 bits ),对于普通时钟和边界时钟,此处值为数据集中 defaultDS domainNumber 这个变量

        "For ordinary or boundary clocks, the value of domainNumber shall be the value of the defaultDS.domainNumber member of the data set of the originating ordinary or boundary clock."

  (4)flagField,【标志域】,( 2 个 octets = 16 bits ),典型的如二步标志域(twoStepFlag)为 1 表示是二步模式,即同步报文之后有跟随报文     

  (5)correctionField,【修正域】,( 8 个 octets = 64 bits ),传送透明时钟的驻留时间、点对点透明时钟的链路延时以及非对称补偿

        "The correctionField is the value of the correction measured in nanoseconds and multiplied by 216. For example, 2.5 ns is represented as 000000000002800016"

  (6)sourcePortIdentity,【源端口号】,( 10 个 octets = 80 bits ),发送端口的相关属性     

       “The value of the sourcePortIdentity field shall be the value of the portDS.portIdentity member of the dataset of the port that originated this message.”

  (7)sequenceID,【序列号】,( 2 个 octets = 16 bits ),为了区分多条发送端口相同的同一类型的报文 

  (8)controlField,【控制域】,( 1 个 octet = 8 bits ),此处的值由报文类型域的值决定,即根据报文类型不同取值不同

  (9)logMessageInterval,【对数报文时间间隔】,( 1 个 octet = 8 bits ),包括发送声明报文的对数时间间隔,发送同步报文的对数时间间隔,发送延迟请求响应报文的对数时间间隔,它们的值是以2为底取的对数

 

PTP报文介绍

  主要介绍 sync 同步报文delay_req 延迟请求报文follow_up 跟随报文 和 delay_resp 延迟响应报文 四种报文的报文主体 body 部分。

  1)sync 同步报文 & delay_req 延迟请求报文

    两种报文具有相同的报文主体,originTimeStamp 时间戳都是由历元,秒数和纳秒数构成的 80bits 时间戳信息

图 2 sync 同步报文 & delay_req 延迟请求报文的报文主体结构 [1] 

  2) follow_up 跟随报文

图 3 follow_up 跟随报文的报文主体结构 [1] 

  3)delay_resp 延迟响应报文

图 4 delay_resp 延迟响应报文的报文主体结构 [1] 

 

PTP报文封装方式

  PTP报文封装方式分为:PTP over UDP over IPv4、PTP over UDP over IPV6、PTP over UDP over IPV6、PTP over IEEE 802.3 / Ethernet 等承载方式。

 

  1. PTP over UDP over IPv4 (IEEE1588 Standard Annex D

    以太网帧类型域值(Ethertype)为 0x0800,检查 IPv4 报文类型域,若为 0x11 说明上层数据为 UDP 数据报文,再检查 UDP 目的端口号,若为 319/320 则为 PTP 报文;

    四层实现(也称为三层实现或者应用层实现),能够跨 IP 网段,可以支持 E2E 和 P2P;   

    "The first octet of the PTP message shall occupy the first octet of the client data field";

    使用 UDP 协议和以太网协议 version 4( IPv4 )完成 PTP 报文的封装,封装流程如下:

      1). 在应用层中 PTP 报文被应用程序填充后发送;

      2). 在传输层将 PTP 报文加 UDP 报头封装成 UDP 报文;

      3). 在网络层加入 IPv4 的 IP 报头,封装成 IP 报文;

      4). 在数据链路层中封装成以太帧传输;

     

图 5 以 PTP over UDP over IPv4 方式封装 PTP 报文

  2. PTP over UDP over IPv6 (IEEE1588 Standard Annex E)

    此方法与前一种方法没有什么大的差异,只不过加装 IP 报头时以 IPv6 为准。

  3. PTP over IEEE 802.3/Ethernet (IEEE1588 Standard Annex F)

    此方法的以太网帧类型域值(Ethertype)为 0x88F7;

    两层实现,两层以太数据包,只能在一个局域网( MAC 地址广播范围之内)起作用,只支持 P2P;

    

图 6 以 PTP over IEEE802.3 / Ethernet 方式封装 PTP 报文

 

 

 

图 7 PTP over UDP over IP 方式封装 PTP 报文的具体方式

 

[1] IEEE Standard for a precision clock synchronization protocol for networked measurement and control systems. New York:IEEE,2008

 

# 请尊重他人劳动成果,转载或者使用源码请注明出处:http://www.cnblogs.com/AdaminXie

# 如有问题请留言或者联系邮箱 coneypo@foxmail.com

posted @ 2017-04-27 00:06  coneypo  阅读(17654)  评论(3编辑  收藏  举报