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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM