CN106877959B - A method, device and system for clock synchronization - Google Patents
A method, device and system for clock synchronization Download PDFInfo
- Publication number
- CN106877959B CN106877959B CN201510918940.3A CN201510918940A CN106877959B CN 106877959 B CN106877959 B CN 106877959B CN 201510918940 A CN201510918940 A CN 201510918940A CN 106877959 B CN106877959 B CN 106877959B
- Authority
- CN
- China
- Prior art keywords
- message
- time
- delay
- residence time
- control board
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 76
- ATJFFYVFTNAWJD-UHFFFAOYSA-N Tin Chemical compound [Sn] ATJFFYVFTNAWJD-UHFFFAOYSA-N 0.000 claims description 54
- 238000012937 correction Methods 0.000 claims description 46
- 230000008569 process Effects 0.000 claims description 35
- 230000007246 mechanism Effects 0.000 claims description 8
- 238000004806 packaging method and process Methods 0.000 claims 4
- 230000001360 synchronised effect Effects 0.000 abstract description 3
- 238000010586 diagram Methods 0.000 description 16
- 230000003287 optical effect Effects 0.000 description 13
- 238000004590 computer program Methods 0.000 description 7
- 238000012545 processing Methods 0.000 description 7
- 238000012795 verification Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000008901 benefit Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 230000014759 maintenance of location Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L7/00—Arrangements for synchronising receiver with transmitter
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Physics & Mathematics (AREA)
- Optics & Photonics (AREA)
- Computer And Data Communications (AREA)
Abstract
Description
技术领域technical field
本发明涉及网络通信技术,尤其涉及一种时钟同步的方法、设备和系统。The present invention relates to network communication technology, and in particular, to a method, device and system for clock synchronization.
背景技术Background technique
在现有通信设备中,各设备间进行时间同步的方案大部分都根据电气和电子工程师协会(IEEE,Institute of Electrical and Electronics Engineers)于2002年提出并在2007年进行修改的网络测量和控制系统的精密时钟同步协议标准来实现,该标准又称为IEEE 1588协议。In the existing communication equipment, most of the solutions for time synchronization among the equipment are based on the network measurement and control system proposed by the Institute of Electrical and Electronics Engineers (IEEE, Institute of Electrical and Electronics Engineers) in 2002 and modified in 2007 It is implemented by the precision clock synchronization protocol standard, which is also known as the IEEE 1588 protocol.
目前,在IEEE 1588协议的应用中,通常采用分布式架构组网方式处理IEEE 1588协议,即每个网络业务节点均运行一套IEEE 1588协议系统,这样的优点就是能够对网络节点进行扩展。但是,由于每个网络节点都要通过运行最佳主时钟算法(BMC,Best MasterClock algorithm)找到本网络节点中各接口的最佳时钟,而本地节点中每个接口的时钟都是来自于上一个主设备的时钟,这样就导致网络节点之间的耦合性较强。因此,出现故障的时候维护比较困难,且实现也较复杂。At present, in the application of the IEEE 1588 protocol, the IEEE 1588 protocol is usually processed in a distributed architecture networking mode, that is, each network service node runs a set of the IEEE 1588 protocol system, which has the advantage of being able to expand the network nodes. However, because each network node has to find the best clock of each interface in the network node by running the best master clock algorithm (BMC, Best MasterClock algorithm), and the clock of each interface in the local node comes from the previous one The clock of the master device, which results in strong coupling between network nodes. Therefore, maintenance in the event of a failure is more difficult and implementation is more complex.
另外,IEEE 1588协议对传送网的传送驻留有严格的要求,即参与时间同步的设备之间的延时必须是一个相对固定的值,且设备收发双向的驻留时间必须相等,否则对时间同步产生较大的误差。而在光传送网(OTN,Optical Transport Network)网络中,由于存在链路不对称、OTN帧处理延时等现象,可能会导致参与时间同步的设备收发双向驻留时间存在一定的误差,进而影响参与时间同步的设备之间进行时间同步的精度。In addition, the IEEE 1588 protocol has strict requirements on the transmission residency of the transport network, that is, the delay between the devices participating in time synchronization must be a relatively fixed value, and the two-way dwell time of the devices must be equal, otherwise the time Synchronization produces large errors. In the Optical Transport Network (OTN, Optical Transport Network) network, due to the phenomenon of link asymmetry and OTN frame processing delay, it may cause a certain error in the two-way residence time of the devices involved in time synchronization. The precision of time synchronization between devices participating in time synchronization.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明实施例期望提供一种时钟同步的方法、设备和系统,降低了时间同步时网络节点之间的耦合性,提高了参与时间同步的设备之间进行时间同步的精度。In view of this, embodiments of the present invention are expected to provide a clock synchronization method, device, and system, which reduces the coupling between network nodes during time synchronization and improves the accuracy of time synchronization between devices participating in time synchronization.
为达到上述目的,本发明的技术方案是这样实现的:In order to achieve the above object, the technical scheme of the present invention is achieved in this way:
第一方面,本发明实施例提供一种时间同步的方法,所述方法应用于主设备,所述方法包括:主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至从设备;所述主设备接收由所述从设备发送的第二报文;其中,所述第二报文包括第三驻留时间;所述主设备在接收所述第二报文时,获取第四驻留时间和第四时间值;所述主设备将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备。In a first aspect, an embodiment of the present invention provides a method for time synchronization. The method is applied to a master device, and the method includes: the master device encapsulates the generated first time value and the obtained first dwell time into a first message, and send the first message to the slave device; the master device receives the second message sent by the slave device; wherein, the second message includes a third dwell time; the When receiving the second packet, the master device obtains the fourth dwell time and the fourth time value; the master device obtains the fourth time value, the fourth dwell time and the value in the second packet The third dwell time is encapsulated into a third packet, and the third packet is sent to the slave device.
在上述方案中,所述主设备包括一个第一主控板和至少一个第一业务板;所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。In the above solution, the main device includes a first main control board and at least one first service board; the first message is a sync message; the second message is a delay-req message; the The third packet is a delay-resp packet.
在上述方案中,所述主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至从设备,具体包括:所述第一主控板在生成所述sync报文时记录生成所述sync报文的第一时间值T1,并且将所述第一时间值T1封装于所述sync报文的预留字段;所述第一主控板将所述sync报文发送至所述第一业务板,并记录所述第一主控板发送所述sync报文的时间Tout1;所述第一业务板解析所述sync报文,获得所述第一主控板发送所述sync报文的时间Tout1;所述第一业务板在将所述sync报文向所述从设备发送时,记录所述第一业务板发送所述sync报文的时间tout1,并根据所述第一主控板发送所述sync报文的时间Tout1与所述第一业务板发送所述sync报文的时间tout1获取所述第一驻留时间Δt1,以及将所述第一驻留时间Δt1封装于所述sync报文中的修正域ΔT1向所述从设备发送。In the above solution, the master device encapsulates the generated first time value and the obtained first dwell time into a first packet, and sends the first packet to the slave device, specifically including: the first packet A main control board records the first time value T 1 for generating the sync message when generating the sync message, and encapsulates the first time value T 1 in the reserved field of the sync message; The first main control board sends the sync message to the first service board, and records the time Tout 1 when the first main control board sends the sync message; the first service board parses the sync message, obtain the time Tout 1 when the first main control board sends the sync message; the first service board records the first service when sending the sync message to the slave device the time tout 1 when the board sends the sync message, and obtains the data according to the time Tout 1 when the first main control board sends the sync message and the time tout 1 when the first service board sends the sync message The first dwell time Δt 1 and the correction field ΔT 1 encapsulating the first dwell time Δt 1 in the sync message are sent to the slave device.
在上述方案中,所述主设备在接收所述第二报文时,获取第四驻留时间和第四时间值,具体包括:所述第一业务板在接收所述delay-req报文时,记录所述第一业务板接收所述delay-req报文的时间tin4;所述第一业务板将所述delay-req报文发送至所述第一主控板;所述第一主控板记录接收到所述delay-req报文的时间Tin4,并解析所述delay-req报文得到封装的所述第一业务板接收delay-req报文的时间tin4,获取得到所述第四驻留时间Δt4;所述第一主控板记录解析所述delay-req报文的所述第四时间值T4。In the above solution, the master device obtains the fourth dwell time and the fourth time value when receiving the second message, which specifically includes: when the first service board receives the delay-req message , record the time tin 4 when the first service board receives the delay-req message; the first service board sends the delay-req message to the first main control board; the first main control board The control board records the time Tin 4 when the delay-req message is received, and parses the delay-req message to obtain the time tin 4 when the encapsulated first service board receives the delay-req message, and obtains the Fourth dwell time Δt 4 ; the first main control board records and parses the fourth time value T 4 of the delay-req message.
在上述方案中,所述主设备将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备,具体包括:所述第一主控板产生所述delay-resp报文,将所述第四时间值T4、所述第四驻留时间Δt4以及所述delay-req报文修正域中的第三驻留时间Δt3封装入所述delay-resp报文,并将所述delay-resp报文发送至所述第一业务板;所述第一业务板接收所述第一主控板发送过来的所述delay-resp报文,并将所述delay-resp报文发送至所述从设备。In the above solution, the master device encapsulates the fourth time value, the fourth dwell time, and the third dwell time in the second packet into a third packet, and encapsulates the third packet in the third packet. The message is sent to the slave device, which specifically includes: the first main control board generates the delay-resp message, and sends the fourth time value T 4 , the fourth dwell time Δt 4 and the delay-req The third dwell time Δt3 in the message correction field is encapsulated into the delay-resp message, and the delay-resp message is sent to the first service board; the first service board receives the the delay-resp message sent by the first main control board, and send the delay-resp message to the slave device.
第二方面,本发明实施例提供一种时间同步的方法,所述方法应用于从设备,所述方法包括:从设备在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;从设备记录第三时间值,将获取的第三驻留时间封装至第二报文,并将所述第二报文发送至主设备;从设备在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延。In a second aspect, an embodiment of the present invention provides a method for time synchronization. The method is applied to a slave device. The method includes: when the slave device receives a first packet, acquiring a first dwell time, a second dwell time, and a second dwell time. time, the first time value, and the second time value; the slave device records the third time value, encapsulates the obtained third dwell time into a second packet, and sends the second packet to the master device; the slave device When receiving the third packet, obtain the fourth time value, the fourth dwell time included in the third packet, and the third dwell time in the second packet, two time values, the third time value and the fourth time value, and the first dwell time, the second dwell time, the third dwell time and the fourth dwell time, the calculated time offset and delay between the master device and the slave device.
在上述方案中,所述从设备包括一个第二主控板和至少一个第二业务板;所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。In the above solution, the slave device includes a second main control board and at least one second service board; the first message is a sync message; the second message is a delay-req message; the The third packet is a delay-resp packet.
在上述方案中,所述从设备在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值,具体包括:所述第二业务板在接收所述sync报文时,记录所述第二业务板接收到所述sync报文的时间tin2;所述第二业务板将所述sync报文发送至所述第二主控板;所述第二主控板记录接收到所述sync报文的时间Tin2;并解析所述sync报文得到封装的所述第二业务板接收到sync报文的时间tin2,获取得到所述第二驻留时间Δt2;所述第二主控板记录解析所述sync报文的第二时间值T2;所述第二主控板记录sync报文的修正域ΔT1中的第一驻留时间Δt1和预留字段中的第一时间值T1。In the above solution, the slave device acquires the first dwell time, the second dwell time, the first time value and the second time value when receiving the first packet, which specifically includes: the second service board is in When receiving the sync message, record the time tin 2 when the second service board receives the sync message; the second service board sends the sync message to the second main control board; The second main control board records the time Tin 2 when the sync message is received; and parses the sync message to obtain the time tin 2 when the second service board that is encapsulated receives the sync message, and obtains the first Two dwell time Δt 2 ; the second main control board records the second time value T 2 for parsing the sync message; the second main control board records the first dwell time in the correction field ΔT 1 of the sync message The reservation time Δt 1 and the first time value T 1 in the reservation field.
在上述方案中,所述从设备记录第三时间值,并将获取的第三驻留时间封装至第二报文,并将所述第二报文发送至主设备,具体包括:所述第二主控板在生成所述delay-req报文时记录生成所述delay-req报文的第三时间值T3;所述第二主控板将所述delay-req报文发送至所述第二业务板,并记录所述第二主控板发送所述delay-req报文的时间Tout3;所述第二业务板解析所述delay-req报文,获得所述第二主控板发送所述delay-req报文的时间Tout3;所述第二业务板在将所述delay-req报文向所述主设备发送时,记录所述第二业务板发送所述delay-req报文的时间tout3,并根据所述第二主控板发送所述delay-req报文的时间Tout3与所述第二业务板发送所述delay-req报文的时间tout3获取所述第三驻留时间Δt3,以及将所述第三驻留时间Δt3封装于所述delay-req报文的修正域ΔT2向所述主设备发送。In the above solution, the slave device records the third time value, encapsulates the acquired third dwell time into a second packet, and sends the second packet to the master device, specifically including: the first The second main control board records the third time value T 3 for generating the delay-req message when generating the delay-req message; the second main control board sends the delay-req message to the the second service board, and records the time Tout 3 when the second main control board sends the delay-req message; the second service board parses the delay-req message to obtain the second main control board Time Tout 3 for sending the delay-req message; when the second service board sends the delay-req message to the master device, it records that the second service board sends the delay-req message time tout 3 of the message, and obtain the first Three dwell times Δt 3 , and the third dwell time Δt 3 is encapsulated in the correction field ΔT 2 of the delay-req message and sent to the master device.
在上述方案中,所述从设备在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延,具体包括:所述从设备通过精确时间协议PTP的同步机制,根据所述第一时间值、所述第二时间值、所述第三时间值和所述第四时间值分别对应的时间戳T1、T2、T3和T4,以及第一驻留时间Δt1、第二驻留时间Δt2、第三驻留时间Δt3和第四驻留时间Δt4,计算出主设备与从设备之间的时间偏差和时延;其中,所述第一驻留时间Δt1保存在所述第一报文的修正域ΔT1=Δt1,所述第三驻留时间Δt3保存在所述第二报文的修正域ΔT2=Δt3。In the above solution, when receiving the third packet, the slave device obtains the fourth time value included in the third packet, the fourth dwell time, and the third dwell time in the second packet, and According to the first time value, the second time value, the third time value and the fourth time value, and the first dwell time, the second dwell time, the third dwell time and the The fourth residence time is to calculate the time deviation and delay between the master device and the slave device, which specifically includes: the slave device uses the synchronization mechanism of the Precision Time Protocol PTP, according to the first time value, Timestamps T 1 , T 2 , T 3 , and T 4 corresponding to the second time value, the third time value, and the fourth time value, respectively, as well as the first dwell time Δt 1 , the second dwell time The time Δt 2 , the third dwell time Δt 3 and the fourth dwell time Δt 4 are used to calculate the time deviation and delay between the master device and the slave device; wherein, the first dwell time Δt 1 is stored in all The correction field ΔT 1 =Δt 1 of the first packet, and the third dwell time Δt 3 is stored in the correction field ΔT 2 =Δt 3 of the second packet.
第三方面,本发明实施例提供一种主设备,所述主设备包括:第一主控板和第一业务板;其中,所述第一主控板,用于将生成的第一时间值与获取的第一驻留时间封装至第一报文;所述第一业务板,用于将所述第一报文发送至从设备;以及,接收由所述从设备发送的第二报文;所述第二报文包括第三驻留时间;所述第一主控板,还用于在所述第一业务板接收所述第二报文时,获取第四驻留时间和第四时间值;以及,将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文;所述业务板,还用于将所述第三报文发送至从设备。In a third aspect, an embodiment of the present invention provides a main device, the main device includes: a first main control board and a first service board; wherein the first main control board is used to generate a first time value encapsulating a first packet with the acquired first dwell time; the first service board is configured to send the first packet to a slave device; and receive a second packet sent by the slave device ; the second message includes a third dwell time; the first main control board is further configured to obtain the fourth dwell time and the fourth dwell time when the first service board receives the second message time value; and encapsulating the fourth time value, the fourth dwell time, and the third dwell time in the second packet into a third packet; the service board is further configured to encapsulate the The third message is sent to the slave device.
在上述方案中,所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。In the above solution, the first message is a sync message; the second message is a delay-req message; and the third message is a delay-resp message.
在上述方案中,所述第一主控板,具体用于在生成所述sync报文时记录生成所述sync报文的第一时间值T1,并且将所述第一时间值T1封装于所述sync报文的预留字段;以及,将所述sync报文发送至所述第一业务板,并记录发送所述sync报文的时间Tout1;所述第一业务板,具体用于解析所述sync报文,获得所述发送所述sync报文的时间Tout1;以及,在将所述sync报文向所述从设备发送时,记录发送所述sync报文的时间tout1,并根据所述第一主控板发送所述sync报文的时间Tout1与所述第一业务板发送所述sync报文的时间tout1获取所述第一驻留时间Δt1,以及将所述第一驻留时间Δt1封装于所述sync报文中的修正域ΔT1向所述从设备发送。In the above solution, the first main control board is specifically configured to record the first time value T 1 for generating the sync message when generating the sync message, and encapsulate the first time value T 1 In the reserved field of the sync message; And, the sync message is sent to the first service board, and the time Tout 1 for sending the sync message is recorded; the first service board, specifically using In parsing the sync message, obtain the time Tout 1 for sending the sync message; And, when sending the sync message to the slave device, record the time Tout 1 for sending the sync message , and obtain the first dwell time Δt 1 according to the time Tout 1 when the first main control board sends the sync message and the time tout 1 when the first service board sends the sync message, and the The first dwell time Δt 1 is encapsulated in the correction field ΔT 1 in the sync message and sent to the slave device.
在上述方案中,所述第一业务板,具体用于在接收所述delay-req报文时,记录所述第一业务板接收所述delay-req报文的时间tin4;以及,将所述delay-req报文发送至所述第一主控板;所述第一主控板,具体用于记录接收到所述delay-req报文的时间Tin4,并解析所述delay-req报文得到封装的所述第一业务板接收delay-req报文的时间tin4,获取得到所述第四驻留时间Δt4;以及,记录解析所述delay-req报文的所述第四时间值T4。In the above solution, the first service board is specifically configured to, when receiving the delay-req message, record the time tin 4 when the first service board receives the delay-req message; The delay-req message is sent to the first main control board; the first main control board is specifically configured to record the time Tin 4 when the delay-req message is received, and parse the delay-req message obtain the time tin 4 at which the encapsulated first service board receives the delay-req message, obtain the fourth dwell time Δt 4 ; and record the fourth time for parsing the delay-req message value T 4 .
在上述方案中,所述第一主控板,具体用于产生所述delay-resp报文,将所述delay-req报文中的所述第四时间值T4,以及所述delay-req报文修正域中的第三驻留时间Δt3封装入所述delay-resp报文,并将所述delay-resp报文发送至所述第一业务板;所述第一业务板,具体用于接收所述第一主控板发送过来的所述delay-resp报文,并将所述delay-resp报文发送至所述从设备。In the above solution, the first main control board is specifically configured to generate the delay-resp message, and combine the fourth time value T 4 in the delay-req message with the delay-req The third dwell time Δt 3 in the message correction field is encapsulated into the delay-resp message, and the delay-resp message is sent to the first service board; the first service board, specifically using receiving the delay-resp message sent by the first main control board, and sending the delay-resp message to the slave device.
第四方面,本发明实施例提供一种从设备,所述从设备包括第二主控板和第二业务板,其中,所述第二业务板,用于接收第一报文;所述第二主控板,用于获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;以及,记录第三时间值,并将获取的第三驻留时间封装至第二报文;所述第二业务板,还用于将该第二报文发送至主设备;以及,接收第三报文;所述第二主控板,还用于获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延。In a fourth aspect, an embodiment of the present invention provides a slave device, where the slave device includes a second main control board and a second service board, wherein the second service board is used to receive a first packet; the first Two main control boards, for acquiring the first dwell time, the second dwell time, the first time value and the second time value; and recording the third time value, and encapsulating the acquired third dwell time into the two packets; the second service board is also used to send the second packet to the main device; and, receive the third packet; the second main control board is also used to obtain the information in the third packet the included fourth time value, the fourth dwell time and the third dwell time in the second message, and according to the first time value, the second time value, the third time value and the fourth time value, And the first dwell time, the second dwell time, the third dwell time and the fourth dwell time, calculate the time deviation between the master device and the slave device and time delay.
在上述方案中,所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。In the above solution, the first message is a sync message; the second message is a delay-req message; and the third message is a delay-resp message.
在上述方案中,所述第二业务板,具体用于在接收所述sync报文时,记录所述第二业务板接收到所述sync报文的时间tin2;以及,将所述sync报文发送至所述第二主控板;所述第二主控板,具体用于记录接收到所述sync报文的时间Tin2;并解析所述sync报文得到封装的所述第二业务板接收到sync报文的时间tin2,获取得到所述第二驻留时间Δt2;所述第二主控板记录解析所述sync报文的第二时间值T2;所述第二主控板记录sync报文的修正域ΔT1中的第一驻留时间Δt1和预留字段中的第一时间值T1。In the above solution, the second service board is specifically configured to, when receiving the sync message, record the time tin 2 when the second service board receives the sync message; and, report the sync message The message is sent to the second main control board; the second main control board is specifically used to record the time Tin 2 when the sync message is received; and parse the sync message to obtain the encapsulated second service the time tin 2 when the board receives the sync message, and obtains the second dwell time Δt 2 ; the second main control board records and parses the second time value T 2 of the sync message; The control board records the first dwell time Δt 1 in the correction field ΔT 1 of the sync message and the first time value T 1 in the reservation field.
在上述方案中,所述第二主控板,具体用于在生成所述delay-req报文时记录生成所述delay-req报文的第三时间值T3;以及,将所述delay-req报文发送至所述第二业务板,并记录所述第二主控板发送所述delay-req报文的时间Tout3;所述第二业务板,具体用于解析所述delay-req报文,获得所述第二主控板发送所述delay-req报文的时间Tout3;以及,在将所述delay-req报文向所述主设备发送时,记录所述第二业务板发送所述delay-req报文的时间tout3,并根据所述第二主控板发送所述delay-req报文的时间Tout3与所述第二业务板发送所述delay-req报文的时间tout3获取所述第三驻留时间Δt3,以及将所述第三驻留时间Δt3封装于所述delay-req报文的修正域ΔT2向所述主设备发送。In the above solution, the second main control board is specifically configured to record the third time value T 3 for generating the delay-req message when generating the delay-req message; The req message is sent to the second service board, and the time Tout 3 when the second main control board sends the delay-req message is recorded; the second service board is specifically used to parse the delay-req message, obtain the time Tout 3 when the second main control board sends the delay-req message; and, when sending the delay-req message to the main device, record the second service board Time tout 3 of sending the delay-req message, and time Tout 3 of sending the delay-req message by the second main control board and the time Tout 3 of the second service board sending the delay-req message The time tout 3 acquires the third dwell time Δt 3 , and encapsulates the third dwell time Δt 3 in the correction field ΔT 2 of the delay-req message and sends it to the master device.
在上述方案中,所述第二主控板,具体用于通过精确时间协议PTP的同步机制,根据所述第一时间值、所述第二时间值、所述第三时间值和所述第四时间值分别对应的时间戳T1、T2、T3和T4,以及所述第一驻留时间Δt1、所述第二驻留时间Δt2、所述第三驻留时间Δt3和所述第四驻留时间Δt4,计算出所述主设备与所述从设备之间的时间偏差和时延。In the above solution, the second main control board is specifically configured to use the synchronization mechanism of the Precision Time Protocol (PTP) according to the first time value, the second time value, the third time value and the first time value. The time stamps T 1 , T 2 , T 3 and T 4 corresponding to the four time values, as well as the first dwell time Δt 1 , the second dwell time Δt 2 , and the third dwell time Δt 3 and the fourth dwell time Δt 4 , the time offset and time delay between the master device and the slave device are calculated.
第五方面,本发明实施例提供一种时间同步的系统,所述系统包括:主设备和从设备;其中,In a fifth aspect, an embodiment of the present invention provides a system for time synchronization, the system includes: a master device and a slave device; wherein,
所述主设备,用于将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至所述从设备;以及,接收由所述从设备发送的第二报文;所述第二报文包括第三驻留时间;以及,在接收所述第二报文时,获取第四驻留时间和第四时间值;其中,所述第二报文包括第三驻留时间;以及,将所述第二报文中的第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备;The master device is configured to encapsulate the generated first time value and the obtained first dwell time into a first message, and send the first message to the slave device; A second message sent from the device; the second message includes a third dwell time; and when receiving the second message, a fourth dwell time and a fourth time value are obtained; wherein the The second packet includes a third dwell time; and encapsulating the fourth time value, the fourth dwell time in the second packet, and the third dwell time in the second packet into a third message, and send the third message to the slave device;
所述从设备,用于在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;以及,记录获取第三时间值,将获取的第三驻留时间封装至第二报文,并将该第二报文发送至所述主设备;以及,在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延。The slave device is used to obtain the first dwell time, the second dwell time, the first time value and the second time value when receiving the first message; The third dwell time is encapsulated into a second packet, and the second packet is sent to the master device; and, when the third packet is received, the fourth time value included in the third packet, the fourth dwell time and the third dwell time in the second message, and according to the first time value, the second time value, the third time value and the fourth time value, and the first dwell time , the second dwell time, the third dwell time and the fourth dwell time, and the time offset and time delay between the master device and the slave device are calculated.
本发明实施例提供了一种时钟同步的方法、设备和系统,通过主、从设备之间的多次报文交互,从而能够获取主、从设备收发双向的驻留时间,并且根据主、从设备收发双向的驻留时间获知主、从设备间延时,降低了时间同步时网络节点之间的耦合性,提高了参与时间同步的设备之间进行时间同步的精度。The embodiments of the present invention provide a method, device and system for clock synchronization. Through multiple packet exchanges between the master and slave devices, the two-way residence time of the master and slave devices can be obtained. The two-way residence time of the device sending and receiving can know the delay between the master and slave devices, which reduces the coupling between network nodes during time synchronization and improves the accuracy of time synchronization between devices participating in time synchronization.
附图说明Description of drawings
图1为本发明实施例提供的一种时钟同步的方法详细流程示意图;FIG. 1 is a detailed flowchart of a method for clock synchronization provided by an embodiment of the present invention;
图2为本发明实施例提供的一种主设备发送第一报文的具体流程示意图;FIG. 2 is a schematic schematic diagram of a specific flow of a master device sending a first packet according to an embodiment of the present invention;
图3为本发明实施例提供的一种从设备获取第二驻留时间和第二时间值的具体流程示意图;3 is a schematic flowchart of a specific process for obtaining a second dwell time and a second time value from a device according to an embodiment of the present invention;
图4为本发明实施例提供的一种从设备发送第二报文的具体流程示意图;FIG. 4 is a schematic flowchart of a specific process of sending a second packet from a device according to an embodiment of the present invention;
图5为本发明实施例提供的一种主设备获取第四驻留时间和第四时间值的具体流程示意图;5 is a schematic diagram of a specific flow of a master device acquiring a fourth dwell time and a fourth time value according to an embodiment of the present invention;
图6为本发明实施例提供的一种主设备发送第三报文的具体流程示意图;6 is a schematic diagram of a specific flow of a master device sending a third packet according to an embodiment of the present invention;
图7为本发明实施例提供的一种主设备的结构示意图;7 is a schematic structural diagram of a master device according to an embodiment of the present invention;
图8为本发明实施例提供的一种从设备的结构示意图;FIG. 8 is a schematic structural diagram of a slave device according to an embodiment of the present invention;
图9为本发明实施例提供的另一种主设备发送第一报文的具体流程示意图;FIG. 9 is a schematic diagram of a specific flow of another master device sending a first packet according to an embodiment of the present invention;
图10为本发明实施例提供的另一种从设备获取第二驻留时间和第二时间值的具体流程示意图;10 is a schematic flowchart of another specific process of acquiring a second dwell time and a second time value from a device according to an embodiment of the present invention;
图11为本发明实施例提供的另一种从设备发送第二报文的具体流程示意图;FIG. 11 is another schematic flowchart of a specific process of sending a second packet from a device according to an embodiment of the present invention;
图12为本发明实施例提供的另一种主设备获取第四驻留时间和第四时间值的具体流程示意图;12 is a schematic schematic diagram of a specific flow of another master device acquiring a fourth dwell time and a fourth time value according to an embodiment of the present invention;
图13为本发明实施例提供的另一种主设备发送第三报文的具体流程示意图;FIG. 13 is a schematic flowchart of another specific flow of a master device sending a third packet according to an embodiment of the present invention;
图14为本发明实施例提供的一种主设备侧的时间同步方法流程示意图;14 is a schematic flowchart of a time synchronization method on the master side provided by an embodiment of the present invention;
图15为本发明实施例提供的一种从设备侧的时间同步方法流程示意图;15 is a schematic flowchart of a time synchronization method on a slave device side according to an embodiment of the present invention;
图16为本发明实施例提供的另一种主设备的结构示意图;16 is a schematic structural diagram of another master device according to an embodiment of the present invention;
图17为本发明实施例提供的另一种从设备的结构示意图;17 is a schematic structural diagram of another slave device provided by an embodiment of the present invention;
图18为本发明实施例提供的一种时间同步的系统结构示意图。FIG. 18 is a schematic structural diagram of a system for time synchronization provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
实施例一Example 1
参见图1,为本发明实施例提供的一种时间同步的方法,该方法可以应用于一时间同步的系统,该系统可以包括:进行报文交互的主设备和从设备;其中,主设备包括一个第一主控板和至少一个第一业务板,从设备包括一个第二主控板和至少一个第二业务板。该方法可以包括:Referring to FIG. 1 , a time synchronization method is provided in an embodiment of the present invention. The method can be applied to a time synchronization system, and the system may include: a master device and a slave device that perform message interaction; wherein, the master device includes A first main control board and at least one first service board, and the slave device includes a second main control board and at least one second service board. The method can include:
S101:主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将该第一报文发送至从设备;S101: The master device encapsulates the generated first time value and the obtained first dwell time into a first message, and sends the first message to the slave device;
需要说明的是,第一报文可以为主设备向从设备发送的同步sync报文,也可以为其他类型的报文,本发明实施例对此不作具体限定。而且,第一驻留时间为主设备在进行报文发送时,报文在主设备内的驻留时间。It should be noted that the first packet may be a synchronization sync packet sent by the master device to the slave device, or may be other types of packets, which are not specifically limited in this embodiment of the present invention. Moreover, the first dwell time is the dwell time of the packet in the master device when the master device sends the packet.
示例性地,由于主设备可以包括一个第一主控板和至少一个第一业务板,因此,步骤S101的实现过程如图2所示,具体可以包括:Exemplarily, since the main device may include one first main control board and at least one first service board, the implementation process of step S101 is shown in FIG. 2 , and may specifically include:
S1011:第一主控板在生成sync报文时记录生成sync报文的第一时间值T1,并且将第一时间值T1封装于sync报文的预留字段;具体在本实施例中,第一主控板将第一时间值T1可以通过系统时间戳的形式进行保存,封装于sync报文的precisetime字段域;S1011: The first main control board records the first time value T 1 for generating the sync message when generating the sync message, and encapsulates the first time value T 1 in a reserved field of the sync message; specifically in this embodiment , the first main control board can save the first time value T1 in the form of a system timestamp, and encapsulate it in the precisetime field of the sync message;
S1012:第一主控板将sync报文发送至第一业务板,并记录第一主控板发送sync报文的时间Tout1;具体地,第一主控板发送sync报文的时间Tout1也可以通过系统时间戳的形式进行保存,并封装于sync报文中PTP信息之后、FCS校验之前的字段域;可以理解地,T1要早于Tout1;S1012: the first main control board sends the sync message to the first service board, and records the time Tout 1 when the first main control board sends the sync message; specifically, the time Tout 1 when the first main control board sends the sync message It can also be saved in the form of a system timestamp, and encapsulated in the field field after the PTP information and before the FCS check in the sync message; it is understandable that T 1 is earlier than Tout 1 ;
S1013:第一业务板解析sync报文,获得第一主控板发送sync报文的时间Tout1;S1013: The first service board parses the sync message, and obtains the time Tout 1 when the first main control board sends the sync message;
S1014:第一业务板在将sync报文向从设备发送时,记录第一业务板发送sync报文的时间tout1,并根据第一主控板发送sync报文的时间Tout1与第一业务板发送sync报文的时间tout1获取第一驻留时间Δt1,以及将第一驻留时间Δt1封装于sync报文中向从设备发送;具体地,第一驻留时间Δt1=tout1-Tout1,第一驻留时间可以封装于sync报文的修正域,从而有ΔT1=Δt1。S1014: When the first service board sends the sync message to the slave device, it records the time tout 1 when the first service board sends the sync message, and according to the time Tout 1 when the first main control board sends the sync message and the first service The time tout 1 when the board sends the sync message obtains the first dwell time Δt 1 , and encapsulates the first dwell time Δt 1 in the sync message and sends it to the slave device; specifically, the first dwell time Δt 1 =tout 1 -Tout 1 , the first dwell time can be encapsulated in the correction field of the sync message, so that ΔT 1 =Δt 1 .
可选地,在步骤S1011中,第一时间值T1可以封装于sync报文之后发送的Follow-up报文中,并由第一业务板发送至从设备,需要说明的是,对于Follow-up报文,第一业务板仅负责发送,并不进行解析等其他处理。Optionally, in step S1011, the first time value T 1 may be encapsulated in a Follow-up message sent after the sync message, and sent to the slave device by the first service board. It should be noted that, for the Follow-up message Up packets, the first service board is only responsible for sending, and does not perform other processing such as parsing.
S102:从设备在接收第一报文时,获取第一时间值、第二时间值、第一驻留时间和第二驻留时间;S102: When the slave device receives the first message, obtain the first time value, the second time value, the first dwell time and the second dwell time;
需要说明的是,第二驻留时间为从设备在接收报文的过程中,报文在从设备内的驻留时间。可以理解地,本实施例中以第一报文为sync报文为例进行说明,此时,从设备获得第一时间值、第二时间值、第一驻留时间和第二驻留时间。It should be noted that the second dwell time is the dwell time of the packet in the slave device during the process of receiving the packet by the slave device. It can be understood that, in this embodiment, the first packet is a sync packet as an example for description. In this case, the slave device obtains the first time value, the second time value, the first dwell time, and the second dwell time.
示例性地,由于从设备可以包括一个第二主控板和至少一个第二业务板,因此,步骤S102的实现过程如图3所示,具体可以包括:Exemplarily, since the slave device may include a second main control board and at least one second service board, the implementation process of step S102 is shown in FIG. 3 , and may specifically include:
S1021:第二业务板在接收sync报文时,记录第二业务板接收到sync报文的时间tin2;具体地,第二业务板接收到sync报文的时间tin2也可以通过系统时间戳的形式进行保存,并封装于sync报文中位于PTP信息之后、FCS校验之前的字段域;S1021: when the second service board receives the sync message, record the time tin 2 when the second service board receives the sync message; specifically, the time tin 2 when the second service board receives the sync message can also pass the system timestamp It is stored in the form of the sync message and encapsulated in the field field after the PTP information and before the FCS check in the sync message;
S1022:第二业务板将sync报文发送至第二主控板;S1022: The second service board sends the sync message to the second main control board;
S1023:第二主控板记录接收到sync报文的时间Tin2;并解析sync报文得到封装的第二业务板接收到sync报文的时间tin2,获取得到第二驻留时间Δt2;S1023: the second main control board records the time Tin 2 when the sync message is received; and parses the sync message to obtain the time tin 2 when the encapsulated second service board receives the sync message, and obtains the second dwell time Δt 2 ;
具体地,第二主控板可以通过解析sync报文中位于PTP信息之后、FCS校验之前的字段域获取得到tin2,随后根据Δt2=Tin2-tin2获取得到第二驻留时间。Specifically, the second main control board can obtain tin 2 by parsing the fields in the sync packet after the PTP information and before the FCS check, and then obtain the second dwell time according to Δt 2 =Tin 2 -tin 2 .
S1024:第二主控板记录解析sync报文的第二时间值T2,具体在本实施例中,第二主控板可以将第二时间值T2通过系统时间戳的形式进行保存;同时,记录sync报文的修正域ΔT1中的第一驻留时间Δt1和precisetime字段域中的第一时间值T1。S1024: The second main control board records and parses the second time value T 2 of the sync message. Specifically, in this embodiment, the second main control board may save the second time value T 2 in the form of a system time stamp; , record the first dwell time Δt 1 in the correction field ΔT 1 of the sync message and the first time value T 1 in the precisetime field.
S103:从设备记录第三时间值,将获取的第三驻留时间封装至第二报文,并将所述第二报文发送至主设备;S103: The slave device records the third time value, encapsulates the obtained third dwell time into a second message, and sends the second message to the master device;
需要说明的是,第二报文可以为从设备向主设备发送的delay-req报文,也可以为其他类型的报文,本发明实施例对此不作具体限定。而且,第三驻留时间为从设备在进行报文发送时,报文在从设备内的驻留时间。It should be noted that the second packet may be a delay-req packet sent by the slave device to the master device, or may be other types of packets, which are not specifically limited in this embodiment of the present invention. Moreover, the third dwell time is the dwell time of the message in the slave device when the slave device sends the message.
示例性地,由于从设备可以包括一个第二主控板和至少一个第二业务板,因此,步骤S103的实现过程如图4所示,具体可以包括:Exemplarily, since the slave device may include one second main control board and at least one second service board, the implementation process of step S103 is shown in FIG. 4 , and may specifically include:
S1031:第二主控板在生成delay-req报文时记录生成delay-req报文的第三时间值T3;具体在本实施例中,第二主控板可以将第三时间值T3通过系统时间戳的形式进行保存;S1031: When generating the delay-req message, the second main control board records the third time value T 3 for generating the delay-req message; specifically in this embodiment, the second main control board may record the third time value T 3 Save in the form of system timestamp;
S1032:第二主控板将delay-req报文发送至第二业务板,并记录第二主控板发送delay-req报文的时间Tout3;具体地,第二主控板发送delay-req报文的时间Tout3也可以通过系统时间戳的形式进行保存,并封装于delay-req报文中PTP信息之后、FCS校验之前的字段域;可以理解地,T3要早于Tout3;S1032: The second main control board sends the delay-req message to the second service board, and records the time Tout 3 when the second main control board sends the delay-req message; specifically, the second main control board sends the delay-req message The time Tout 3 of the message can also be saved in the form of a system timestamp, and encapsulated in the field field after the PTP information and before the FCS check in the delay-req message; it is understandable that T 3 is earlier than Tout 3 ;
S1033:第二业务板解析delay-req报文,获得第二主控板发送delay-req报文的时间Tout3;S1033: The second service board parses the delay-req message, and obtains the time Tout 3 at which the second main control board sends the delay-req message;
S1034:第二业务板在将delay-req报文向主设备发送时,记录第二业务板发送delay-req报文的时间tout3,并根据第二主控板发送delay-req报文的时间Tout3与第二业务板发送delay-req报文的时间tout3获取第三驻留时间Δt3,以及将第三驻留时间封装于delay-req报文中向主设备发送;具体地,第三驻留时间Δt3=Tout3-tout3,第三驻留时间Δt3可以封装于delay-req报文的修正域,从而有ΔT2=Δt3。S1034: When the second service board sends the delay-req message to the master device, it records the time tout 3 at which the second service board sends the delay-req message, and according to the time at which the second main control board sends the delay-req message Tout 3 obtains the third dwell time Δt 3 at the time tout 3 at which the delay-req message is sent by the second service board, and encapsulates the third dwell time in the delay-req message and sends it to the master device; specifically, the third dwell time is Three dwell times Δt 3 =Tout 3 -tout 3 , and the third dwell time Δt 3 can be encapsulated in the correction field of the delay-req message, so that ΔT 2 =Δt 3 .
S104:主设备在接收第二报文时,获取第四驻留时间和第四时间值;S104: When receiving the second packet, the master device obtains a fourth dwell time and a fourth time value;
需要说明的是,第四驻留时间为主设备在接收报文的过程中,报文在主设备内的驻留时间。It should be noted that the fourth dwell time is the dwell time of the packet in the master device during the process of receiving the packet by the master device.
示例性地,由于主设备可以包括一个第一主控板和至少一个第一业务板,因此,步骤S104的实现过程如图5所示,具体可以包括:Exemplarily, since the main device may include one first main control board and at least one first service board, the implementation process of step S104 is shown in FIG. 5 , and may specifically include:
S1041:第一业务板在接收delay-req报文时,记录第一业务板接收delay-req报文的时间tin4;具体地,第一业务板接收delay-req报文的时间也可以通过系统时间戳的形式进行保存,并封装于delay-req报文中位于PTP信息之后、FCS校验之前的字段域;S1041: When receiving the delay-req message, the first service board records the time tin 4 when the first service board receives the delay-req message; specifically, the time when the first service board receives the delay-req message can also be passed through the system It is stored in the form of timestamp and encapsulated in the field field of the delay-req packet after the PTP information and before the FCS check;
S1042:第一业务板将delay-req报文发送至第一主控板;S1042: The first service board sends the delay-req message to the first main control board;
S1043:第一主控板记录接收到delay-req报文的时间Tin4,并解析delay-req报文得到封装的第一业务板接收delay-req报文的时间tin4,获取得到第四驻留时间Δt4;S1043: The first main control board records the time Tin 4 when the delay-req message is received, and parses the delay-req message to obtain the time tin 4 when the encapsulated first service board receives the delay-req message, and obtains the fourth stay time Δt 4 ;
具体地,第一主控板可以通过解析delay-req报文中位于PTP信息之后、FCS校验之前的字段域获取到tin4,随后根据Δt4=Tin4-tin4获取得到第四驻留时间。Specifically, the first main control board can obtain tin 4 by parsing the fields in the delay-req message after the PTP information and before the FCS check, and then obtain the fourth resident according to Δt 4 =Tin 4 -tin 4 time.
S1044:第一主控板记录解析delay-req报文的第四时间值T4;具体在本实施例中,第一主控板可以将第四时间值T4通过系统时间戳的形式进行保存。S1044: The first main control board records and parses the fourth time value T 4 of the delay-req message; specifically in this embodiment, the first main control board may store the fourth time value T 4 in the form of a system time stamp .
S105:主设备将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将该第三报文发送至从设备;S105: The master device encapsulates the fourth time value, the fourth dwell time, and the third dwell time in the second message into a third message, and sends the third message to the slave device;
需要说明的是,第三报文可以为主设备向从设备发送的delay-resp报文,也可以为其他类型的报文,本发明实施例对此不作具体限定。It should be noted that the third packet may be a delay-resp packet sent by the master device to the slave device, or may be other types of packets, which are not specifically limited in this embodiment of the present invention.
示例性地,由于主设备可以包括一个第一主控板和至少一个第一业务板,因此,步骤S105的实现过程如图6所示,具体可以包括:Exemplarily, since the main device may include a first main control board and at least one first service board, the implementation process of step S105 is shown in FIG. 6 , and may specifically include:
S1051:第一主控板产生delay-resp报文,将delay-req报文中的第四时间值T4、第四驻留时间Δt4以及delay-req报文修正域中的第三驻留时间Δt3封装入delay-resp报文,并将delay-resp报文发送至第一业务板;S1051: The first main control board generates a delay-resp message, and modifies the fourth time value T 4 , the fourth dwell time Δt 4 in the delay-req message, and the third dwell time in the delay-req message field. Time Δt 3 encapsulates the delay-resp message, and sends the delay-resp message to the first service board;
S1052:第一业务板接收第一主控板发送过来的delay-resp报文,并将delay-resp报文发送至从设备。S1052: The first service board receives the delay-resp message sent by the first main control board, and sends the delay-resp message to the slave device.
S106:从设备在接收第三报文时,获取第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、第二驻留时间、第三驻留时间和第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延,通过时间偏差和时延来调整从设备的当前时间,使主从设备时间同步。S106: When receiving the third packet, the slave device acquires the fourth time value, the fourth dwell time, and the third dwell time in the second packet, and obtains the fourth time value, the fourth dwell time, and the third dwell time in the second packet, The third time value and the fourth time value, as well as the first dwell time, the second dwell time, the third dwell time and the fourth dwell time, calculate the distance between the master device and the slave device The current time of the slave device is adjusted by the time deviation and delay, so that the time of the master and slave devices is synchronized.
需要说明的是,第三报文可以为主设备向从设备发送的delay-resp报文,也可以为其他类型的报文,本发明实施例对此不作具体限定。It should be noted that the third packet may be a delay-resp packet sent by the master device to the slave device, or may be other types of packets, which are not specifically limited in this embodiment of the present invention.
另外,第一时间值T1可以在从设备之前收到的sync报文的precisetime字段域中获取得到,并且第一报文修正域中的数值ΔT'1也可以在上述sync报文的修正域中获取得到。In addition, the first time value T 1 can be obtained from the precisetime field of the sync packet received by the slave device, and the value ΔT' 1 in the correction field of the first packet can also be found in the correction field of the sync packet. obtained in.
在具体实施过程中,由精确时间协议(PTP,Precision Time Protocol)的同步机制,根据第一时间值、第二时间值、第三时间值和第四时间值分别对应的时间戳T1、T2、T3和T4,以及第一驻留时间Δt1、第二驻留时间Δt2、第三驻留时间Δt3和第四驻留时间Δt4,计算出主设备与从设备之间的时间偏差和时延;其中,第一驻留时间Δt1保存在第一报文的修正域ΔT1=Δt1,第三驻留时间Δt3保存在第二报文的修正域ΔT2=Δt3。In the specific implementation process, by the synchronization mechanism of the Precision Time Protocol (PTP, Precision Time Protocol), according to the timestamps T 1 , T corresponding to the first time value, the second time value, the third time value and the fourth time value respectively 2 , T 3 and T 4 , as well as the first dwell time Δt 1 , the second dwell time Δt 2 , the third dwell time Δt 3 and the fourth dwell time Δt 4 , to calculate the distance between the master device and the slave device where the first dwell time Δt 1 is stored in the correction field ΔT 1 =Δt 1 of the first packet, and the third dwell time Δt 3 is stored in the correction field ΔT 2 = Δt 3 .
具体来说,可以根据时间偏差和时延计算出主从设备之间的时间偏差和时 延,进而根据PTP得到第一主控板的当前时间,实现了将主设备的第一主控板的当前时间同 步到从设备的第二主控板的目的。 Specifically, according to the time offset and delay Calculate the time deviation and delay between the master and slave devices, and then obtain the current time of the first master control board according to the PTP, which realizes the synchronization of the current time of the first master control board of the master device to the second master control of the slave device. purpose of the board.
需要说明的是,业务板还需要与各自设备中的主控板对时,使得所有设备中的单板的时间保持一致。It should be noted that the service boards also need to be time-synchronized with the main control boards in their respective devices, so that the time of the boards in all devices is consistent.
实施例二Embodiment 2
基于上述实施例相同的技术构思,本实施例提供了一种时间同步的方法具体实现流程,该具体实现流程对实施例一中各步骤的具体实现过程进行了描述。Based on the same technical concept as the above embodiments, this embodiment provides a specific implementation process of a time synchronization method, and the specific implementation process describes the specific implementation process of each step in the first embodiment.
具体的,在本实施例中,如图7所示,主设备包含一个第一主控板和至少一个第一业务板;其中,第一主控板除了CPU外,还包含第一FPGA模块和第一主控板sgmii接口,第一FPGA模块又包含:第一Sync单元、第一Delay-req单元、第一Delay-resp单元、第一Timer0单元、第一Timer1单元;第一业务板包含第一业务板sgmii接口、第一Framer模块和第一光模块,第一Framer模块又包含第一Framer serdes单元;需要说明的是,第一Sync单元、第一Delay-req单元、第一Delay-resp单元均为第一主控板进行报文处理的单元,对相应类型的报文进行处理。Specifically, in this embodiment, as shown in FIG. 7 , the main device includes a first main control board and at least one first service board; wherein, in addition to the CPU, the first main control board also includes a first FPGA module and The first main control board sgmii interface, the first FPGA module further includes: a first Sync unit, a first Delay-req unit, a first Delay-resp unit, a first Timer0 unit, and a first Timer1 unit; the first service board includes the first A service board sgmii interface, a first Framer module and a first optical module, and the first Framer module further includes a first Framer serdes unit; it should be noted that the first Sync unit, the first Delay-req unit, the first Delay-resp The units are all units for the first main control board to process messages, and process messages of corresponding types.
如图8所示,从设备包含一个第二主控板和至少一个第二业务板;其中,第二主控板中包含第二FPGA模块和第二主控板sgmii接口,第二FPGA模块又包含:第二Sync单元、第二Delay-req单元、第二Delay-resp单元、第二Timer0单元、第二Timer1单元;第二业务板包含第二业务板sgmii接口、第二Framer模块和第二光模块,第二Framer模块又包含第二Framer serdes单元;需要说明的是,第二Sync单元、第二Delay-req单元、第二Delay-resp单元均为第二主控板进行报文处理的单元,对相应类型的报文进行处理。As shown in FIG. 8 , the slave device includes a second main control board and at least one second service board; wherein, the second main control board includes a second FPGA module and an sgmii interface of the second main control board, and the second FPGA module also Including: the second Sync unit, the second Delay-req unit, the second Delay-resp unit, the second Timer0 unit, the second Timer1 unit; the second service board includes the second service board sgmii interface, the second Framer module and the second Optical module, the second Framer module also includes a second Framer serdes unit; it should be noted that the second Sync unit, the second Delay-req unit, and the second Delay-resp unit are all processed by the second main control board. unit to process the corresponding type of message.
本领域技术人员可以意识到,本发明实施方式并不局限于上述的场景中,而还可以适用于其他任意的场景之中。Those skilled in the art can realize that the embodiments of the present invention are not limited to the above-mentioned scenarios, but can also be applied to any other scenarios.
基于上述设备的具体构成,针对实施例一中各步骤的具体实现如下:Based on the specific structure of the above equipment, the specific implementation of each step in the first embodiment is as follows:
优选地,参见图9,对于步骤S101:所述主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将该第一报文发送至从设备的实现过程可以包括:Preferably, referring to FIG. 9, for step S101: the master device encapsulates the generated first time value and the acquired first dwell time into a first packet, and sends the first packet to the slave device. The process can include:
S901:主设备上的第一Sync单元产生并发送sync报文至第一Timer0单元,第一Timer0单元接收第一Sync单元发送过来的sync报文,并将sync报文发送至第一Timer1单元;S901: the first Sync unit on the master device generates and sends a sync message to the first Timer0 unit, the first Timer0 unit receives the sync message sent by the first Sync unit, and sends the sync message to the first Timer1 unit;
S902:第一主控板记录第一Timer0单元发送sync报文的时间为第一时间值,以时间戳T1的形式保存,并将时间戳T1装入sync报文的precisetime字段域;S902: the first main control board records the time at which the first Timer0 unit sends the sync message as the first time value, saves it in the form of a time stamp T 1 , and loads the time stamp T 1 into the precisetime field of the sync message;
S903:第一Timer1单元接收第一Timer0单元发送过来的sync报文,并将sync报文发送至第一主控板sgmii接口模块;S903: The first Timer1 unit receives the sync message sent by the first Timer0 unit, and sends the sync message to the first main control board sgmii interface module;
S904:第一主控板记录第一Timer1单元发送sync报文的时间,以系统时间戳Tout1的形式保存,并将系统时间戳Tout1装入sync报文中位于PTP信息之后、FCS校验之前的字段域;S904: The first main control board records the time at which the first Timer1 unit sends the sync message, saves it in the form of a system time stamp Tout 1 , and loads the system time stamp Tout 1 into the sync message, which is located after the PTP information and is checked by the FCS. the previous field field;
S905:第一主控板sgmii接口模块接收第一Timer1单元发送过来的sync报文,并将sync报文传输至第一业务板sgmii接口模块;S905: the sgmii interface module of the first main control board receives the sync message sent by the first Timer1 unit, and transmits the sync message to the sgmii interface module of the first service board;
S906:第一业务板sgmii接口模块接收第一主控板sgmii接口模块传输过来的sync报文,并将sync报文发送至第一Framer模块;S906: The sgmii interface module of the first service board receives the sync message transmitted by the sgmii interface module of the first main control board, and sends the sync message to the first Framer module;
S907:第一Framer模块中的第一Framer串行器(serdes,SERializer)单元接收并发送sync报文,并将sync报文发送至第一光模块;S907: the first Framer serializer (serdes, SERializer) unit in the first Framer module receives and sends the sync message, and sends the sync message to the first optical module;
S908:第一业务板记录第一Framer serdes单元发送sync报文的时间,并以系统时间戳tout1的形式保存;S908: The first service board records the time when the first Framer serdes unit sends the sync message, and saves it in the form of a system time stamp tout 1 ;
S909:第一业务板解析sync报文中位于PTP信息之后、FCS校验之前的字段域,以获取第一Timer1单元发送sync报文的时间Tout1;S909: The first service board parses the field fields in the sync message that are located after the PTP information and before the FCS verification, to obtain the time Tout 1 when the first Timer1 unit sends the sync message;
S910:第一业务板计算出第一Timer1单元发送sync报文和第一Framer serdes单元发送sync报文之间的时间差值,具体可以记为第一驻留时间Δt1=tout1-Tout1,并且将第一驻留时间Δt1写入sync报文的修正域ΔT1=Δt1;S910: The first service board calculates the time difference between the sync packet sent by the first Timer1 unit and the sync packet sent by the first Framer serdes unit, which may be specifically recorded as the first dwell time Δt 1 =tout 1 -Tout 1 , and write the first dwell time Δt 1 into the correction field ΔT 1 =Δt 1 of the sync message;
S911:第一光模块接收第一Framer serdes单元发送过来的sync报文,并将sync报文发送至从设备。S911: The first optical module receives the sync message sent by the first Framer serdes unit, and sends the sync message to the slave device.
可选地,在步骤S901中,第一时间值T1可以封装于sync报文之后发送的Follow-up报文中,并由第一业务板发送至从设备,需要说明的是,对于Follow-up报文,第一业务板仅负责发送,并不进行解析等其他处理。Optionally, in step S901, the first time value T1 may be encapsulated in a Follow-up message sent after the sync message, and sent to the slave device by the first service board. It should be noted that, for the Follow-up message Up packets, the first service board is only responsible for sending, and does not perform other processing such as parsing.
优选地,参见图10,对于步骤S102:所述从设备在接收第一报文时,获取第一时间值、第二时间值、第一驻留时间和第二驻留时间的实现过程可以包括:Preferably, referring to FIG. 10, for step S102: when the slave device receives the first packet, the implementation process of acquiring the first time value, the second time value, the first dwell time and the second dwell time may include: :
S1001:从设备中的第二光模块接收主设备发送过来的报文,并发送报文至第二Framer模块,由第二Framer模块识别出sync报文,并将sync报文统一到板间通信定义的以太网报文格式上;S1001: Receive the message sent by the master device from the second optical module in the device, and send the message to the second Framer module, the second Framer module recognizes the sync message, and unifies the sync message to the inter-board communication On the defined Ethernet message format;
S1002:第二Framer模块中的第二Framer serdes单元接收sync报文,并将sync报文发送至第二业务板sgmii接口模块;S1002: the second Framer serdes unit in the second Framer module receives the sync message, and sends the sync message to the sgmii interface module of the second service board;
S1003:第二业务板记录第二Framer serdes单元接收sync报文的时间,以时间戳tin2的形式保存,并将时间戳tin2封装入sync报文中位于PTP信息之后、FCS校验之前的字段域;S1003: The second service board records the time when the second Framer serdes unit receives the sync packet, saves it in the form of a timestamp tin 2 , and encapsulates the timestamp tin 2 into the sync packet after the PTP information and before the FCS check. field field;
S1004:第二业务板sgmii接口模块接收第二Framer serdes单元发送过来的sync报文,并将sync报文传输至第二主控板sgmii接口模块;S1004: the sgmii interface module of the second service board receives the sync message sent by the second Framer serdes unit, and transmits the sync message to the sgmii interface module of the second main control board;
S1005:第二主控板sgmii接口模块接收第二业务板sgmii接口模块传输过来的sync报文,再将sync报文发送至第二Timer1单元;S1005: The sgmii interface module of the second main control board receives the sync message transmitted by the sgmii interface module of the second service board, and then sends the sync message to the second Timer1 unit;
S1006:第二主控板记录第二Timer1单元接收sync报文的时间,以系统时间戳Tin2的形式保存;S1006: The second main control board records the time when the second Timer1 unit receives the sync message, and saves it in the form of a system time stamp Tin 2 ;
S1007:第二主控板解析sync报文中位于PTP信息之后、FCS校验之前的字段域,得到第二Framer serdes单元接收sync报文的时间tin2;S1007: The second main control board parses the field fields located after the PTP information and before the FCS verification in the sync message, and obtains the time tin 2 when the second Framer serdes unit receives the sync message;
S1008:第二主控板计算出第二Framer serdes单元接收sync报文和第二Timer1单元接收sync报文之间的时间差值,具体可以记为第二驻留时间Δt2=Tin2-tin2;S1008: The second main control board calculates the time difference between the sync packet received by the second Framer serdes unit and the sync packet received by the second Timer1 unit, which can be specifically recorded as the second dwell time Δt 2 =Tin 2 -tin 2 ;
S1009:第二Timer1单元发送sync报文至第二Timer0单元,记录第二Timer0单元接收sync报文的时间为第二时间值,以时间戳T2的形式保存;S1009: the second Timer1 unit sends the sync message to the second Timer0 unit, and records the time when the second Timer0 unit receives the sync message as the second time value, and saves it in the form of a timestamp T2;
S1010:第二Timer0单元发送sync报文至第二Sync单元,第二Sync单元解析sync报文,并记录sync报文的修正域ΔT1中的第一驻留时间Δt1和precisetime字段域中的第一时间值T1。S1010: The second Timer0 unit sends a sync message to the second Sync unit, and the second Sync unit parses the sync message, and records the first dwell time Δt 1 in the correction field ΔT 1 of the sync message and the precision time field in the precisetime field The first time value T 1 .
优选地,参见图11,对于步骤S103,所述从设备记录第三时间值,将获取的第三驻留时间封装至第二报文,并将所述第二报文发送至主设备的实现过程可以包括:Preferably, referring to FIG. 11 , for step S103, the slave device records the third time value, encapsulates the acquired third dwell time into a second packet, and sends the second packet to the master device. The process can include:
S1101:从设备中的第二Delay-req单元产生delay-req报文后,第二Timer0单元接收第二Delay-req单元发送过来的delay-req报文,并将delay-req报文发送至第二Timer1单元;S1101: After generating the delay-req message from the second Delay-req unit in the device, the second Timer0 unit receives the delay-req message sent by the second Delay-req unit, and sends the delay-req message to the first Two Timer1 units;
S1102:第二主控板记录第二Timer0单元发送delay-req报文的时间为第三时间值,以时间戳T3的形式保存;S1102: The second main control board records the time at which the second Timer0 unit sends the delay-req message as a third time value, and saves it in the form of a timestamp T3;
S1103:第二Timer1单元接收第二Timer0单元发送过来的delay-req报文,并将delay-req报文发送至第二主控板sgmii接口模块;S1103: The second Timer1 unit receives the delay-req message sent by the second Timer0 unit, and sends the delay-req message to the sgmii interface module of the second main control board;
S1104:第二主控板记录第二Timer1单元发送delay-req报文的时间,以系统时间戳Tout3的形式保存,并将系统时间戳Tout3装入delay-req报文中位于PTP信息之后、FCS校验之前的字段域;S1104: The second main control board records the time when the second Timer1 unit sends the delay-req message, saves it in the form of a system time stamp Tout 3 , and loads the system time stamp Tout 3 into the delay-req message after the PTP information , the field field before FCS verification;
S1105:第二主控板sgmii接口模块接收第二Timer1单元发送过来的delay-req报文,并将delay-req报文传输至第二业务板sgmii接口模块;S1105: The sgmii interface module of the second main control board receives the delay-req message sent by the second Timer1 unit, and transmits the delay-req message to the sgmii interface module of the second service board;
S1106:第二业务板sgmii接口模块接收第二主控板sgmii接口模块传输过来的delay-req报文,并将delay-req报文发送至第二Framer模块;S1106: The sgmii interface module of the second service board receives the delay-req message transmitted by the sgmii interface module of the second main control board, and sends the delay-req message to the second Framer module;
S1107:第二Framer模块中的第二Framer serdes单元接收delay-req报文,并将delay-req报文发送至第二光模块;S1107: the second Framer serdes unit in the second Framer module receives the delay-req message, and sends the delay-req message to the second optical module;
S1108:第二业务板记录第二Framer serdes单元发送delay-req报文的时间,并以系统时间戳tout3的形式保存;S1108: The second service board records the time when the second Framer serdes unit sends the delay-req message, and saves it in the form of a system time stamp tout 3 ;
S1109:第二业务板解析delay-req报文中位于PTP信息之后、FCS校验之前的字段域,以获取第二Timer1单元发送delay-req报文的时间Tout3;S1109: The second service board parses the fields in the delay-req message after the PTP information and before the FCS check, to obtain the time Tout 3 when the second Timer1 unit sends the delay-req message;
S1110:第二业务板计算出第二Timer1单元发送delay-req报文和第二Framerserdes单元发送delay-req报文之间的时间差值,具体可以记为第三驻留时间Δt3=tout3-Tout3,并且将第三驻留时间Δt3写入delay-req报文的修正域ΔT2=Δt3;S1110: The second service board calculates the time difference between the delay-req message sent by the second Timer1 unit and the delay-req message sent by the second Framerserdes unit, which can be specifically recorded as the third dwell time Δt 3 =tout 3 -Tout 3 , and write the third dwell time Δt 3 into the correction field ΔT 2 =Δt 3 of the delay-req message;
S1111:第二光模块接收第二Framer serdes单元发送过来的delay-req报文,并将delay-req报文发送至主设备。S1111: The second optical module receives the delay-req message sent by the second Framer serdes unit, and sends the delay-req message to the master device.
优选地,参见图12,对于步骤S104,所述主设备在接收第二报文时,获取第四驻留时间和第四时间值的实现过程可以包括:Preferably, referring to FIG. 12, for step S104, when the master device receives the second packet, the implementation process of acquiring the fourth dwell time and the fourth time value may include:
S1201:主设备中的第一光模块接收从设备发送过来的报文,并发送报文至第一Framer模块,由第一Framer模块识别出delay-req报文,并将delay-req报文统一到板间通信定义的以太网报文格式上;S1201: The first optical module in the master device receives the message sent from the slave device, and sends the message to the first Framer module, the first Framer module identifies the delay-req message, and unifies the delay-req message to the Ethernet message format defined by the inter-board communication;
S1202:第一Framer模块中的第一Framer serdes单元接收delay-req报文,并将delay-req报文发送至第一业务板sgmii接口模块;S1202: the first Framer serdes unit in the first Framer module receives the delay-req message, and sends the delay-req message to the first service board sgmii interface module;
S1203:第一业务板记录第一Framer serdes单元接收delay-req报文的时间,以时间戳tin4的形式保存,并将时间戳tin4封装入delay-req报文中位于PTP信息之后、FCS校验之前的字段域;S1203: The first service board records the time when the first Framer serdes unit receives the delay-req message, saves it in the form of a time stamp tin 4 , and encapsulates the time stamp tin 4 into the delay-req message, which is located after the PTP information, and the FCS Field field before verification;
S1204:第一业务板sgmii接口模块接收第一Framer serdes单元发送过来的delay-req报文,再将delay-req报文传输至第一主控板sgmii接口模块;S1204: The sgmii interface module of the first service board receives the delay-req message sent by the first Framer serdes unit, and then transmits the delay-req message to the sgmii interface module of the first main control board;
S1205:第一主控板sgmii接口模块接收第一业务板sgmii接口模块传输过来的sync报文,再将delay-req报文发送至第一Timer1单元;S1205: The sgmii interface module of the first main control board receives the sync message transmitted by the sgmii interface module of the first service board, and then sends the delay-req message to the first Timer1 unit;
S1206:第一主控板记录第一Timer1单元接收delay-req报文的时间,以系统时间戳Tin4的形式保存;S1206: The first main control board records the time when the first Timer1 unit receives the delay-req message, and saves it in the form of a system timestamp Tin 4 ;
S1207:第一主控板解析delay-req报文中位于PTP信息之后、FCS校验之前的字段域,得到第一Framer serdes单元接收delay-req报文的时间tin4;S1207: The first main control board parses the fields in the delay-req message after the PTP information and before the FCS verification, and obtains the time tin 4 when the first Framer serdes unit receives the delay-req message;
S1208:第一主控板计算出第一Framer serdes单元接收delay-req报文和第一Timer1单元接收delay-req报文之间的时间差值,具体可以记为第四驻留时间Δt4=Tin4-tin4;S1208: The first main control board calculates the time difference between the delay-req message received by the first Framer serdes unit and the delay-req message received by the first Timer1 unit, which can be specifically recorded as the fourth dwell time Δt 4 = Tin 4 -tin 4 ;
S1209:第一Timer1单元发送delay-req报文至第一Timer0单元,记录第一Timer0单元接收delay-req报文的时间为第四时间值,以时间戳T4的形式保存;S1209: The first Timer1 unit sends the delay-req message to the first Timer0 unit, and records the time when the first Timer0 unit receives the delay-req message as the fourth time value, which is stored in the form of a timestamp T4;
S1210:第一Timer0单元发送delay-req报文至第一delay-req单元,第一delay-req单元接收并解析delay-req报文;S1210: The first Timer0 unit sends a delay-req message to the first delay-req unit, and the first delay-req unit receives and parses the delay-req message;
优选地,参见图13,对于步骤S105:所述主设备将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将该第三报文发送至从设备的实现过程可以包括:Preferably, referring to FIG. 13, for step S105: the master device encapsulates the fourth time value, the fourth dwell time and the third dwell time in the second packet into a third packet, and The implementation process of sending the third packet to the slave device may include:
S1301:主设备中的第一Delay-resp单元产生delay-resp报文,将delay-req报文中的第四时间值T4、第四驻留时间Δt4以及delay-req报文修正域中的第三驻留时间Δt3封装入delay-resp报文,并将delay-resp报文发送至第一Timer0单元;S1301: The first Delay-resp unit in the master device generates a delay-resp message, and modifies the fourth time value T 4 , the fourth dwell time Δt 4 and the delay-req message correction field in the delay-req message The third dwell time Δt 3 is encapsulated into a delay-resp message, and the delay-resp message is sent to the first Timer0 unit;
S1302:第一Timer0单元接收第一Delay-resp单元发送过来的delay-resp报文,并将delay-resp报文发送至第一Timer1单元;S1302: The first Timer0 unit receives the delay-resp message sent by the first Delay-resp unit, and sends the delay-resp message to the first Timer1 unit;
S1303:第一Timer1单元接收第一Timer0单元发送过来的delay-resp报文,并将delay-resp报文发送至的至第一主控板sgmii接口模块;S1303: The first Timer1 unit receives the delay-resp message sent by the first Timer0 unit, and sends the delay-resp message to the first main control board sgmii interface module;
S1304:第一主控板sgmii接口模块接收第一Timer1单元发送过来的delay-resp报文,并将delay-resp报文传输至第一业务板sgmii接口模块;S1304: The sgmii interface module of the first main control board receives the delay-resp message sent by the first Timer1 unit, and transmits the delay-resp message to the sgmii interface module of the first service board;
S1305:第一业务板sgmii接口模块接收第一主控板sgmii接口模块发送过来的delay-resp报文,并将delay-resp报文经第一Framer模块发送至第一光模块;S1305: The sgmii interface module of the first service board receives the delay-resp message sent by the sgmii interface module of the first main control board, and sends the delay-resp message to the first optical module via the first Framer module;
S1306:第一光模块接收第一Framer模块发送过来的delay-resp报文,并将delay-resp报文发送至从设备。S1306: The first optical module receives the delay-resp packet sent by the first Framer module, and sends the delay-resp packet to the slave device.
优选地,对于步骤S106:所述从设备在接收第三报文时,获取第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、第二驻留时间、第三驻留时间和第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延,通过时间偏差和时延来调整从设备的当前时间,使主从设备时间同步的实现过程可以包括:Preferably, for step S106: when receiving the third packet, the slave device obtains the fourth time value, the fourth dwell time and the third dwell time in the second packet, and according to the first time value, the second time value, the third time value and the fourth time value, and the first dwell time, the second dwell time, the third dwell time and the fourth dwell time, to calculate the master device The time deviation and delay between the slave device and the time deviation and the time delay are used to adjust the current time of the slave device, so that the realization process of the time synchronization of the master and slave devices can include:
由精确时间协议(PTP,Precision Time Protocol)的同步机制,根据第一时间值、第二时间值、第三时间值和第四时间值分别对应的时间戳T1、T2、T3和T4,以及第一驻留时间、第二驻留时间、第三驻留时间和第四驻留时间,计算出主设备与从设备之间的时间偏差和时延;其中,第一驻留时间Δt1保存在第一报文的修正域ΔT1=Δt1,第三驻留时间Δt3保存在第二报文的修正域ΔT2=Δt3。By the synchronization mechanism of the Precision Time Protocol (PTP), according to the timestamps T 1 , T 2 , T 3 and T corresponding to the first time value, the second time value, the third time value and the fourth time value respectively 4 , and the first dwell time, the second dwell time, the third dwell time and the fourth dwell time, to calculate the time deviation and delay between the master device and the slave device; wherein, the first dwell time Δt 1 is stored in the correction field ΔT 1 =Δt 1 of the first packet, and the third dwell time Δt 3 is stored in the correction field ΔT 2 =Δt 3 of the second packet.
需要说明的是,第三报文可以为主设备向从设备发送的delay-resp报文,也可以为其他类型的报文,本发明实施例对此不作具体限定。It should be noted that the third packet may be a delay-resp packet sent by the master device to the slave device, or may be other types of packets, which are not specifically limited in this embodiment of the present invention.
另外,第一时间值T1可以在从设备之前收到的sync报文的precisetime字段域中获取得到,并且第一报文修正域中的数值ΔT1也可以在上述sync报文的修正域中获取得到。In addition, the first time value T 1 can be obtained from the precisetime field of the sync packet received by the slave device, and the value ΔT 1 in the correction field of the first packet can also be found in the correction field of the sync packet. Get it.
具体地,可以根据时间偏差和时延计算出主从设备之间的时间偏差和时 延,进而根据PTP得到第一主控板的当前时间,实现了将主设备的第一主控板的当前时间同 步到从设备的第二主控板的目的。 Specifically, according to the time offset and delay Calculate the time deviation and delay between the master and slave devices, and then obtain the current time of the first master control board according to the PTP, which realizes the synchronization of the current time of the first master control board of the master device to the second master control of the slave device. purpose of the board.
还需要说明的是,业务板还需要与各自设备中的主控板时间同步,使得所有设备中的单板的时间保持一致,具体时间同步的过程可以按照上述过程进行,本发明实施例对此不作赘述。It should also be noted that the service boards also need to be time synchronized with the main control boards in their respective devices, so that the time of the boards in all devices is consistent. The specific time synchronization process can be performed according to the above process, and this embodiment of the present invention I won't go into details.
实施例三Embodiment 3
基于上述两个实施例相同的技术构思,参见图14,其示出了本发明实施例提供的一种主设备侧的时间同步方法流程,该方法可以包括:Based on the same technical concept of the above two embodiments, referring to FIG. 14 , which shows a flow of a time synchronization method on the master device side provided by an embodiment of the present invention, and the method may include:
S1401:主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至从设备;S1401: The master device encapsulates the generated first time value and the obtained first dwell time into a first message, and sends the first message to the slave device;
S1402:主设备接收由所述从设备发送的第二报文;S1402: The master device receives the second packet sent by the slave device;
其中,所述第二报文包括第三驻留时间;Wherein, the second message includes a third dwell time;
S1403:主设备在接收所述第二报文时,获取第四驻留时间和第四时间值;S1403: When receiving the second message, the master device obtains a fourth dwell time and a fourth time value;
S1404:主设备将所述第二报文中的第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备。S1404: The master device encapsulates the fourth time value, the fourth dwell time in the second packet, and the third dwell time in the second packet into a third packet, and encapsulates the third The message is sent to the slave device.
示例性地,主设备可以包括一个第一主控板和至少一个第一业务板;所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。Exemplarily, the main device may include a first main control board and at least one first service board; the first packet is a sync packet; the second packet is a delay-req packet; the third The packet is a delay-resp packet.
优选地,所述主设备将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至从设备,具体包括:Preferably, the master device encapsulates the generated first time value and the obtained first dwell time into a first packet, and sends the first packet to the slave device, specifically including:
所述第一主控板在生成所述sync报文时记录生成所述sync报文的第一时间值T1,并且将所述第一时间值T1封装于所述sync报文的预留字段;The first main control board records the first time value T 1 for generating the sync message when generating the sync message, and encapsulates the first time value T 1 in the reservation of the sync message field;
所述第一主控板将所述sync报文发送至所述第一业务板,并记录所述第一主控板发送所述sync报文的时间Tout1;The first main control board sends the sync message to the first service board, and records the time Tout 1 when the first main control board sends the sync message;
所述第一业务板解析所述sync报文,获得所述第一主控板发送所述sync报文的时间Tout1;The first service board parses the sync message, and obtains the time Tout 1 when the first main control board sends the sync message;
所述第一业务板在将所述sync报文向所述从设备发送时,记录所述第一业务板发送所述sync报文的时间tout1,并根据所述第一主控板发送所述sync报文的时间Tout1与所述第一业务板发送所述sync报文的时间tout1获取所述第一驻留时间Δt1,以及将所述第一驻留时间Δt1封装于所述sync报文中的修正域ΔT1向所述从设备发送。When the first service board sends the sync message to the slave device, it records the time tout 1 when the first service board sends the sync message, and sends the data according to the first main control board. The time Tout 1 of the sync message and the time tout 1 of the first service board sending the sync message obtain the first dwell time Δt 1 , and encapsulate the first dwell time Δt 1 in the The correction field ΔT 1 in the sync message is sent to the slave device.
优选地,所述主设备在接收所述第二报文时,获取第四驻留时间和第四时间值;并将所述第四驻留时间和所述第四时间值封装于所述第二报文中,具体包括:Preferably, when receiving the second message, the master device obtains a fourth dwell time and a fourth time value; and encapsulates the fourth dwell time and the fourth time value in the first In the second message, it specifically includes:
所述第一业务板在接收所述delay-req报文时,记录所述第一业务板接收所述delay-req报文的时间tin4;When the first service board receives the delay-req message, it records the time tin 4 when the first service board receives the delay-req message;
所述第一业务板将所述delay-req报文发送至所述第一主控板;the first service board sends the delay-req message to the first main control board;
所述第一主控板记录接收到所述delay-req报文的时间Tin4,并解析所述delay-req报文得到封装的所述第一业务板接收delay-req报文的时间tin4,获取得到所述第四驻留时间Δt4;The first main control board records the time Tin 4 when the delay-req message is received, and parses the delay-req message to obtain the time tin 4 when the encapsulated first service board receives the delay-req message. , obtain the fourth dwell time Δt 4 ;
所述第一主控板记录解析所述delay-req报文的所述第四时间值T4。The first main control board records and parses the fourth time value T 4 of the delay-req message.
优选地,所述主设备将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备,具体包括:Preferably, the master device encapsulates the fourth time value, the fourth dwell time, and the third dwell time in the second packet into a third packet, and sends the third packet To slave devices, including:
所述第一主控板产生所述delay-resp报文,将所述第四时间值T4、所述第四驻留时间Δt4以及所述delay-req报文修正域中的第三驻留时间Δt3封装入所述delay-resp报文,并将所述delay-resp报文发送至所述第一业务板;The first main control board generates the delay-resp message, and modifies the fourth time value T 4 , the fourth dwell time Δt 4 , and the third dwell time in the delay-req message correction field. leaving time Δt 3 to encapsulate the delay-resp message, and send the delay-resp message to the first service board;
所述第一业务板接收所述第一主控板发送过来的所述delay-resp报文,并将所述delay-resp报文发送至所述从设备。The first service board receives the delay-resp message sent by the first main control board, and sends the delay-resp message to the slave device.
实施例四Embodiment 4
基于前述实施例相同的技术构思,参见图15,其示出了本发明实施例提供的一种从设备侧的时间同步方法流程,该方法可以包括:Based on the same technical concept as the foregoing embodiments, referring to FIG. 15 , it shows a flow of a time synchronization method on the slave side provided by an embodiment of the present invention. The method may include:
S1501:从设备在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;S1501: When the slave device receives the first message, obtain the first dwell time, the second dwell time, the first time value and the second time value;
S1502:从设备记录第三时间值,将获取的第三驻留时间封装至第二报文,并将该第二报文发送至主设备;S1502: The slave device records the third time value, encapsulates the obtained third dwell time into a second packet, and sends the second packet to the master device;
S1503:从设备在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延。S1503: When receiving the third packet, the slave device acquires the fourth time value, the fourth dwell time included in the third packet, and the third dwell time in the second packet, and calculates according to the first a time value, a second time value, a third time value, and a fourth time value, and the first dwell time, the second dwell time, the third dwell time, and the fourth dwell time , and calculate the time offset and delay between the master device and the slave device.
示例性地,所述从设备包括一个第二主控板和至少一个第二业务板;所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。Exemplarily, the slave device includes a second main control board and at least one second service board; the first packet is a sync packet; the second packet is a delay-req packet; The third packet is a delay-resp packet.
优选地,所述从设备在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;具体包括:Preferably, when receiving the first message, the slave device obtains the first dwell time, the second dwell time, the first time value and the second time value; specifically, it includes:
所述第二业务板在接收所述sync报文时,记录所述第二业务板接收到所述sync报文的时间tin2;When the second service board receives the sync message, it records the time tin 2 when the second service board receives the sync message;
所述第二业务板将所述sync报文发送至所述第二主控板;the second service board sends the sync message to the second main control board;
所述第二主控板记录接收到所述sync报文的时间Tin2;并解析所述sync报文得到封装的所述第二业务板接收到sync报文的时间tin2,获取得到所述第二驻留时间Δt2;The second main control board records the time Tin 2 when the sync message is received; and parses the sync message to obtain the time tin 2 when the second service board encapsulated receives the sync message, and obtains the the second dwell time Δt 2 ;
所述第二主控板记录解析所述sync报文的第二时间值T2;the second main control board records and parses the second time value T 2 of the sync message;
所述第二主控板记录sync报文的修正域ΔT1中的第一驻留时间Δt1和precisetime字段域中的第一时间值T1。The second main control board records the first dwell time Δt 1 in the correction field ΔT 1 of the sync message and the first time value T 1 in the precisetime field.
优选地,所述从设备记录第三时间值,并将获取的第三驻留时间封装至第二报文,并将所述第二报文发送至主设备,具体包括:Preferably, the slave device records the third time value, encapsulates the acquired third dwell time into a second packet, and sends the second packet to the master device, specifically including:
所述第二主控板在生成所述delay-req报文时记录生成所述delay-req报文的第三时间值T3;The second main control board records, when generating the delay-req message, a third time value T 3 for generating the delay-req message;
所述第二主控板将所述delay-req报文发送至所述第二业务板,并记录所述第二主控板发送所述delay-req报文的时间Tout3;The second main control board sends the delay-req message to the second service board, and records the time Tout 3 when the second main control board sends the delay-req message;
所述第二业务板解析所述delay-req报文,获得所述第二主控板发送所述delay-req报文的时间Tout3;The second service board parses the delay-req message, and obtains the time Tout 3 when the second main control board sends the delay-req message;
所述第二业务板在将所述delay-req报文向所述主设备发送时,记录所述第二业务板发送所述delay-req报文的时间tout3,并根据所述第二主控板发送所述delay-req报文的时间Tout3与所述第二业务板发送所述delay-req报文的时间tout3获取所述第三驻留时间Δt3,以及将所述第三驻留时间Δt3封装于所述delay-req报文的修正域ΔT2向所述主设备发送。When the second service board sends the delay-req message to the master device, it records the time tout 3 when the second service board sends the delay-req message, and records the time tout 3 when the second service board sends the delay-req message, and records the delay-req message according to the second service board. The time Tout 3 when the control board sends the delay-req message and the time tout 3 when the second service board sends the delay-req message obtains the third dwell time Δt 3 , and the third The dwell time Δt 3 is encapsulated in the correction field ΔT 2 of the delay-req message and sent to the master device.
优选地,所述从设备在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延,具体包括:Preferably, when receiving the third packet, the slave device acquires the fourth time value, the fourth dwell time included in the third packet, and the third dwell time in the second packet, and obtains the fourth time value included in the third packet, the fourth dwell time and the third dwell time in the second packet. the first time value, the second time value, the third time value and the fourth time value, and the first dwell time, the second dwell time, the third dwell time and the fourth dwell time Dwell time, calculate the time deviation and delay between the master device and the slave device, including:
从设备通过精确时间协议PTP的同步机制,根据所述第一时间值、所述第二时间值、所述第三时间值和所述第四时间值分别对应的时间戳T1、T2、T3和T4,以及第一驻留时间Δt1、第二驻留时间Δt2、第三驻留时间Δt3和第四驻留时间Δt4,计算出主设备与从设备之间的时间偏差和时延;其中,所述第一驻留时间Δt1保存在所述第一报文的修正域ΔT1=Δt1,所述第三驻留时间Δt3保存在所述第二报文的修正域ΔT2=Δt3。The slave device uses the synchronization mechanism of the Precision Time Protocol (PTP), according to the timestamps T 1 , T 2 , T 2 , T 2 , T 1 , T 2 , T 3 and T 4 , as well as the first dwell time Δt 1 , the second dwell time Δt 2 , the third dwell time Δt 3 and the fourth dwell time Δt 4 , the time between the master device and the slave device is calculated Deviation and delay; wherein, the first dwell time Δt 1 is stored in the correction field ΔT 1 =Δt 1 of the first message, and the third dwell time Δt 3 is stored in the second message The correction domain of ΔT 2 =Δt 3 .
实施例五Embodiment 5
基于上述实施例相同的技术构思,参见图16,其示出了本发明实施例提供的一种主设备160,该主设备160包括:第一主控板1601和第一业务板1602;其中,Based on the same technical concept of the above-mentioned embodiments, referring to FIG. 16 , it shows a main device 160 provided by an embodiment of the present invention. The main device 160 includes: a first main control board 1601 and a first service board 1602; wherein,
所述第一主控板1601,用于将生成的第一时间值与获取的第一驻留时间封装至第一报文;The first main control board 1601 is used to encapsulate the generated first time value and the obtained first dwell time into a first packet;
所述第一业务板1602,用于将所述第一报文发送至从设备;the first service board 1602, configured to send the first packet to the slave device;
以及,接收由所述从设备发送的第二报文;所述第二报文包括第三驻留时间;and, receiving a second message sent by the slave device; the second message includes a third dwell time;
所述第一主控板1601,还用于在所述第一业务板1602接收所述第二报文时,获取第四驻留时间和第四时间值;The first main control board 1601 is further configured to acquire a fourth dwell time and a fourth time value when the first service board 1602 receives the second packet;
以及,将所述第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文;and, encapsulating the fourth time value, the fourth dwell time and the third dwell time in the second message into a third message;
所述业务板,还用于将所述第三报文发送至从设备。The service board is further configured to send the third packet to the slave device.
示例性地,所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。Exemplarily, the first packet is a sync packet; the second packet is a delay-req packet; and the third packet is a delay-resp packet.
优选地,所述第一主控板1601,具体用于在生成所述sync报文时记录生成所述sync报文的第一时间值T1,并且将所述第一时间值T1封装于所述sync报文的预留字段;Preferably, the first main control board 1601 is specifically configured to record the first time value T 1 for generating the sync message when generating the sync message, and encapsulate the first time value T 1 in a the reserved field of the sync message;
以及,将所述sync报文发送至所述第一业务板1602,并记录发送所述sync报文的时间Tout1;And, the sync message is sent to the first service board 1602, and the time Tout 1 for sending the sync message is recorded;
所述第一业务板1602,具体用于解析所述sync报文,获得所述发送所述sync报文的时间Tout1;The first service board 1602 is specifically configured to parse the sync message, and obtain the time Tout 1 for sending the sync message;
以及,在将所述sync报文向所述从设备发送时,记录发送所述sync报文的时间tout1,并根据所述第一主控板1601发送所述sync报文的时间Tout1与所述第一业务板1602发送所述sync报文的时间tout1获取所述第一驻留时间Δt1,以及将所述第一驻留时间Δt1封装于所述sync报文中的修正域ΔT1向所述从设备发送。And, when sending the sync message to the slave device, record the time tout 1 of sending the sync message, and according to the time Tout 1 of the first main control board 1601 sending the sync message and The time tout 1 at which the first service board 1602 sends the sync message obtains the first dwell time Δt 1 , and encapsulates the first dwell time Δt 1 in the correction field in the sync message ΔT 1 is sent to the slave device.
优选地,所述第一业务板1602,具体用于在接收所述delay-req报文时,记录所述第一业务板1602接收所述delay-req报文的时间tin4;Preferably, the first service board 1602 is specifically configured to, when receiving the delay-req message, record the time tin 4 when the first service board 1602 receives the delay-req message;
以及,将所述delay-req报文发送至所述第一主控板1601;and, sending the delay-req message to the first main control board 1601;
所述第一主控板1601,具体用于记录接收到所述delay-req报文的时间Tin4,并解析所述delay-req报文得到封装的所述第一业务板1602接收delay-req报文的时间tin4,获取得到所述第四驻留时间Δt4;The first main control board 1601 is specifically configured to record the time Tin 4 when the delay-req message is received, and parse the delay-req message to obtain the encapsulated first service board 1602 to receive the delay-req The time tin 4 of the message is obtained, and the fourth dwell time Δt 4 is obtained;
以及,记录解析所述delay-req报文的所述第四时间值。And, recording and parsing the fourth time value of the delay-req message.
优选地,所述第一主控板1601,具体用于产生所述delay-resp报文,将所述delay-req报文中的所述第四时间值T4,以及所述delay-req报文修正域中的第三驻留时间Δt3封装入所述delay-resp报文,并将所述delay-resp报文发送至所述第一业务板1602;Preferably, the first main control board 1601 is specifically configured to generate the delay-resp message, report the fourth time value T 4 in the delay-req message, and the delay-req message The third dwell time Δt3 in the text correction field is encapsulated into the delay-resp message, and the delay-resp message is sent to the first service board 1602;
所述第一业务板1602,具体用于接收所述第一主控板1601发送过来的所述delay-resp报文,并将所述delay-resp报文发送至所述从设备。The first service board 1602 is specifically configured to receive the delay-resp message sent by the first main control board 1601, and send the delay-resp message to the slave device.
实施例六Embodiment 6
基于前述实施例相同的技术构思,参见图17,其示出了本发明实施例提供的一种从设备170,该从设备170可以包括第二主控板1701和第二业务板1702,其中,Based on the same technical concept as the foregoing embodiments, see FIG. 17 , which shows a slave device 170 provided by an embodiment of the present invention. The slave device 170 may include a second main control board 1701 and a second service board 1702 , wherein,
所述第二业务板1702,用于接收第一报文;the second service board 1702, configured to receive the first message;
所述第二主控板1701,用于获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;The second main control board 1701 is used to obtain the first dwell time, the second dwell time, the first time value and the second time value;
以及,记录第三时间值,并将获取的第三驻留时间封装至第二报文;And, recording the third time value, and encapsulating the obtained third dwell time into the second message;
所述第二业务板1702,还用于将该第二报文发送至主设备;The second service board 1702 is further configured to send the second packet to the master device;
以及,接收第三报文;and, receiving the third message;
所述第二主控板1701,还用于获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一驻留时间、所述第二驻留时间、所述第三驻留时间和所述第四驻留时间,计算出所述主设备与所述从设备之间的时间偏差和时延。The second main control board 1701 is further configured to obtain the fourth time value included in the third packet, the fourth dwell time, and the third dwell time in the second packet, and according to the first a time value, a second time value, a third time value, and a fourth time value, and the first dwell time, the second dwell time, the third dwell time, and the fourth dwell time , and calculate the time offset and delay between the master device and the slave device.
示例性地,所述第一报文为sync报文;所述第二报文为delay-req报文;所述第三报文为delay-resp报文。Exemplarily, the first packet is a sync packet; the second packet is a delay-req packet; and the third packet is a delay-resp packet.
优选地,所述第二业务板1702,具体用于在接收所述sync报文时,记录所述第二业务板1702接收到所述sync报文的时间tin2;Preferably, the second service board 1702 is specifically configured to, when receiving the sync message, record the time tin 2 when the second service board 1702 receives the sync message;
以及,将所述sync报文发送至所述第二主控板1701;and, sending the sync message to the second main control board 1701;
所述第二主控板1701,具体用于记录接收到所述sync报文的时间Tin2;并解析所述sync报文得到封装的所述第二业务板1702接收到sync报文的时间tin2,获取得到所述第二驻留时间Δt2;The second main control board 1701 is specifically used to record the time Tin 2 when the sync message is received; and parse the sync message to obtain the time tin when the second service board 1702 encapsulated receives the sync message 2 , obtaining the second dwell time Δt 2 ;
以及,记录解析所述sync报文的第二时间值T2。And, record the second time value T 2 for parsing the sync message.
所述第二主控板1701记录sync报文的修正域ΔT1中的第一驻留时间Δt1和precisetime字段域中的第一时间值T1。The second main control board 1701 records the first dwell time Δt 1 in the correction field ΔT 1 of the sync message and the first time value T 1 in the precisetime field.
优选地,所述第二主控板1701,具体用于在生成所述delay-req报文时记录生成所述delay-req报文的第三时间值T3;Preferably, the second main control board 1701 is specifically configured to record the third time value T 3 for generating the delay-req message when generating the delay-req message;
以及,将所述delay-req报文发送至所述第二业务板1702,并记录所述第二主控板1701发送所述delay-req报文的时间Tout3;and, sending the delay-req message to the second service board 1702, and recording the time Tout 3 when the second main control board 1701 sends the delay-req message;
所述第二业务板1702,具体用于解析所述delay-req报文,获得所述第二主控板1701发送所述delay-req报文的时间Tout3;The second service board 1702 is specifically configured to parse the delay-req message, and obtain the time Tout 3 when the second main control board 1701 sends the delay-req message;
以及,在将所述delay-req报文向所述主设备发送时,记录所述第二业务板1702发送所述delay-req报文的时间tout3,并根据所述第二主控板1701发送所述delay-req报文的时间Tout3与所述第二业务板1702发送所述delay-req报文的时间tout3获取所述第三驻留时间Δt3,以及将所述第三驻留时间Δt3封装于所述delay-req报文的修正域ΔT2向所述主设备发送。And, when sending the delay-req message to the main device, record the time tout 3 when the second service board 1702 sends the delay-req message, and record the time tout 3 when the second service board 1702 sends the delay-req message, and record the time tout 3 when the second service board 1702 sends the delay-req message, and record the time tout 3 when the second service board 1702 sends the delay-req message, The time Tout 3 when the delay-req message is sent and the time tout 3 when the second service board 1702 sends the delay-req message obtains the third dwell time Δt 3 , and sets the third dwell time Δt 3 . The retention time Δt 3 is encapsulated in the correction field ΔT 2 of the delay-req message and sent to the master device.
优选地,所述第二主控板1701,具体用于通过精确时间协议PTP的同步机制,根据所述第一时间值、所述第二时间值、所述第三时间值和所述第四时间值分别对应的时间戳T1、T2、T3和T4,以及所述第一驻留时间Δt1、所述第二驻留时间Δt2、所述第三驻留时间Δt3和所述第四驻留时间Δt4,计算出所述主设备与所述从设备之间的时间偏差和时延。Preferably, the second main control board 1701 is specifically configured to use the synchronization mechanism of the Precision Time Protocol (PTP) according to the first time value, the second time value, the third time value and the fourth time value. Time stamps T 1 , T 2 , T 3 and T 4 corresponding to the time values, as well as the first dwell time Δt 1 , the second dwell time Δt 2 , the third dwell time Δt 3 and For the fourth dwell time Δt 4 , the time offset and time delay between the master device and the slave device are calculated.
实施例七Embodiment 7
基于前述实施例相同的技术构思,参见图18,其示出了本发明实施例提供的一种时间同步的系统180,该系统180包括:主设备160和从设备170;Based on the same technical idea of the previous embodiments, see FIG. 18 , which shows a time synchronization system 180 provided by an embodiment of the present invention, the system 180 includes: a master device 160 and a slave device 170;
其中,in,
所述主设备160,用于将生成的第一时间值与获取的第一驻留时间封装至第一报文,并将所述第一报文发送至所述从设备170;the master device 160, configured to encapsulate the generated first time value and the acquired first dwell time into a first packet, and send the first packet to the slave device 170;
以及,接收由所述从设备170发送的第二报文;所述第二报文包括第三驻留时间;and, receiving a second packet sent by the slave device 170; the second packet includes a third dwell time;
以及,在接收所述第二报文时,获取第四驻留时间和第四时间值;其中,所述第二报文包括第三驻留时间;and, when receiving the second message, obtain a fourth dwell time and a fourth time value; wherein, the second message includes a third dwell time;
以及,将所述第二报文中的第四时间值、第四驻留时间以及所述第二报文中的第三驻留时间封装入第三报文,并将所述第三报文发送至从设备170;and, encapsulating the fourth time value, the fourth dwell time in the second message, and the third dwell time in the second message into a third message, and encapsulating the third message sent to the slave device 170;
所述从设备170,用于在接收第一报文时,获取第一驻留时间、第二驻留时间、第一时间值和第二时间值;The slave device 170 is configured to acquire the first dwell time, the second dwell time, the first time value and the second time value when receiving the first message;
以及,记录获取第三时间值,将获取的第三驻留时间封装至第二报文,并将该第二报文发送至所述主设备160;and, recording and obtaining the third time value, encapsulating the obtained third dwell time into a second message, and sending the second message to the master device 160;
以及,在接收第三报文时,获取第三报文中所包括的第四时间值、第四驻留时间以及第二报文中的第三驻留时间,并根据所述第一时间值、第二时间值、第三时间值和第四时间值,以及所述第一报文和第二报文修正域中的数值,计算出所述主设备160与所述从设备170之间的时间偏差和时延。and, when receiving the third packet, obtain the fourth time value, the fourth dwell time included in the third packet, and the third dwell time in the second packet, and obtain the fourth time value, the fourth dwell time in the second packet, and the third dwell time in the second packet according to the first time value. , the second time value, the third time value and the fourth time value, and the values in the correction fields of the first message and the second message, to calculate the distance between the master device 160 and the slave device 170 Time skew and delay.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the invention may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein, including but not limited to disk storage, optical storage, and the like.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the protection scope of the present invention.
Claims (21)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510918940.3A CN106877959B (en) | 2015-12-11 | 2015-12-11 | A method, device and system for clock synchronization |
PCT/CN2016/098770 WO2017096994A1 (en) | 2015-12-11 | 2016-09-12 | Clock synchronization method, device and system, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510918940.3A CN106877959B (en) | 2015-12-11 | 2015-12-11 | A method, device and system for clock synchronization |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106877959A CN106877959A (en) | 2017-06-20 |
CN106877959B true CN106877959B (en) | 2019-04-30 |
Family
ID=59012639
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510918940.3A Active CN106877959B (en) | 2015-12-11 | 2015-12-11 | A method, device and system for clock synchronization |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106877959B (en) |
WO (1) | WO2017096994A1 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107678764B (en) * | 2017-09-30 | 2020-09-08 | 杭州迪普科技股份有限公司 | Method and device for upgrading VSM system based on ISSU |
CN109995557B (en) * | 2017-12-29 | 2022-05-13 | 中国移动通信集团陕西有限公司 | A communication method and device |
CN108737007A (en) * | 2018-08-24 | 2018-11-02 | 新华三技术有限公司 | A kind of method for synchronizing time, device and equipment |
CN113079183B (en) * | 2021-04-25 | 2022-09-06 | 安徽科大擎天科技有限公司 | Inter-board communication system of distributed firewall and communication method thereof |
CN116436555B (en) * | 2023-06-09 | 2023-08-18 | 新华三技术有限公司 | Time synchronization method and device and distributed network equipment |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102082697A (en) * | 2009-11-27 | 2011-06-01 | 华为技术有限公司 | Communication path asymmetric time delay measuring method, device and system |
CN102237995A (en) * | 2010-04-20 | 2011-11-09 | 中兴通讯股份有限公司 | Time processing device and method based on device Precision Time Protocol |
CN102447745A (en) * | 2012-01-11 | 2012-05-09 | 中兴通讯股份有限公司 | Method and device for processing message residence time on TC (train control) equipment |
CN103441833A (en) * | 2013-08-26 | 2013-12-11 | 瑞斯康达科技发展股份有限公司 | Method and system for synchronizing frequency of master unit and frequency of slave unit |
CN103581205A (en) * | 2013-11-20 | 2014-02-12 | 盛科网络(苏州)有限公司 | Method and system for realizing precise timestamps in multiple MACs (media access controls) |
WO2014187369A1 (en) * | 2013-07-23 | 2014-11-27 | 中兴通讯股份有限公司 | Method and apparatus for processing time synchronization |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103441832B (en) * | 2013-08-22 | 2016-12-28 | 瑞斯康达科技发展股份有限公司 | Clock synchronizing method based on PTP, system and equipment |
US9112631B2 (en) * | 2013-09-11 | 2015-08-18 | Khalifa University of Science, Technology, and Research | Method and devices for frequency distribution |
CN103546268B (en) * | 2013-10-15 | 2016-08-10 | 瑞斯康达科技发展股份有限公司 | The compensation method of a kind of system time and equipment |
US9270395B2 (en) * | 2014-05-05 | 2016-02-23 | Telefonaktiebolaget L M Ericsson (Publ) | Method for robust PTP synchronization with default 1588V2 profile |
-
2015
- 2015-12-11 CN CN201510918940.3A patent/CN106877959B/en active Active
-
2016
- 2016-09-12 WO PCT/CN2016/098770 patent/WO2017096994A1/en active Application Filing
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102082697A (en) * | 2009-11-27 | 2011-06-01 | 华为技术有限公司 | Communication path asymmetric time delay measuring method, device and system |
CN102237995A (en) * | 2010-04-20 | 2011-11-09 | 中兴通讯股份有限公司 | Time processing device and method based on device Precision Time Protocol |
CN102447745A (en) * | 2012-01-11 | 2012-05-09 | 中兴通讯股份有限公司 | Method and device for processing message residence time on TC (train control) equipment |
WO2014187369A1 (en) * | 2013-07-23 | 2014-11-27 | 中兴通讯股份有限公司 | Method and apparatus for processing time synchronization |
CN103441833A (en) * | 2013-08-26 | 2013-12-11 | 瑞斯康达科技发展股份有限公司 | Method and system for synchronizing frequency of master unit and frequency of slave unit |
CN103581205A (en) * | 2013-11-20 | 2014-02-12 | 盛科网络(苏州)有限公司 | Method and system for realizing precise timestamps in multiple MACs (media access controls) |
Also Published As
Publication number | Publication date |
---|---|
CN106877959A (en) | 2017-06-20 |
WO2017096994A1 (en) | 2017-06-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106877959B (en) | A method, device and system for clock synchronization | |
TWI753199B (en) | Indirect packet classification timestamping system and method | |
US9548833B2 (en) | Method, apparatus and system for time distribution in a telecommunications network | |
WO2020135857A1 (en) | Time synchronization method, system and device, and storage medium | |
US20160094312A1 (en) | Confirming Data Accuracy in a Distributed Control System | |
KR20170105573A (en) | Time synchronization method, apparatus, system and storage medium in OTN network | |
WO2018041228A1 (en) | Method, device and system for transferring synchronization information | |
CN103929293A (en) | Asymmetric delay time synchronization method and system | |
CN112887086B (en) | Quantum key synchronization method and system | |
US20140293825A1 (en) | Timestamping data packets | |
EP3868043B1 (en) | Wireless audio synchronization | |
CN111327385A (en) | Clock synchronization method, device and equipment of Internet of things equipment | |
CN111382201A (en) | Heterogeneous database synchronization method, device, computer equipment and storage medium | |
CN103299582B (en) | A kind of delay compensation method and device | |
CN103457714A (en) | Method and system for synchronizing server time | |
US20130336129A1 (en) | Multipurpose Use of Delay Measurement Message Buffer for Software Processing of Delay Measurement Response | |
WO2016150021A1 (en) | Packet forwarding delay measurement method, device and system | |
CN108989246B (en) | Audio transmission between devices using sparse streams | |
CN108092942B (en) | Message processing method and device | |
US12022411B2 (en) | Communication apparatus and communication system | |
CN114554355B (en) | Vehicle-mounted immersive audio transmission method and device | |
CN105320517B (en) | Adapter middleware system and method based on web services | |
CN113055113A (en) | Clock time synchronization method, device, equipment and storage medium | |
CN103813382A (en) | Clock synchronization method, device and system | |
CN103338353B (en) | Image acquisition, transmission and storage system and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
EE01 | Entry into force of recordation of patent licensing contract |
Application publication date: 20170620 Assignee: Xi'an Chris Semiconductor Technology Co. Ltd. Assignor: SHENZHEN ZTE MICROELECTRONICS TECHNOLOGY CO., LTD. Contract record no.: 2019440020036 Denomination of invention: Clock synchronization method, equipment and system thereof Granted publication date: 20190430 License type: Common License Record date: 20190619 |
|
EE01 | Entry into force of recordation of patent licensing contract |