[go: up one dir, main page]

CN110620630A - Time synchronization method, device, network equipment and computer readable storage medium - Google Patents

Time synchronization method, device, network equipment and computer readable storage medium Download PDF

Info

Publication number
CN110620630A
CN110620630A CN201810631978.6A CN201810631978A CN110620630A CN 110620630 A CN110620630 A CN 110620630A CN 201810631978 A CN201810631978 A CN 201810631978A CN 110620630 A CN110620630 A CN 110620630A
Authority
CN
China
Prior art keywords
time synchronization
synchronization
time
system clock
chip
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.)
Granted
Application number
CN201810631978.6A
Other languages
Chinese (zh)
Other versions
CN110620630B (en
Inventor
罗俊翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN201810631978.6A priority Critical patent/CN110620630B/en
Priority to PCT/CN2019/076340 priority patent/WO2019242321A1/en
Publication of CN110620630A publication Critical patent/CN110620630A/en
Application granted granted Critical
Publication of CN110620630B publication Critical patent/CN110620630B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)
  • Electric Clocks (AREA)

Abstract

本发明实施例提供一种时间同步方法、装置、网络设备及计算机可读存储介质,处理器先根据时间同步协议对系统时钟进行时间同步,并在确定系统时钟的时间同步达到稳定状态后,切换由时间同步芯片继续对系统时钟进行时间同步。由于处理器根据时间同步协议进行时间同步的方案具有同步收敛速度快的优点,因此在时间同步的开始使用该方案能够使得本设备与主设备之间的时间偏差快速收敛。由于时间同步芯片会对与主设备间的报文数据进行充分的抑制滤波处理,因此系统时钟的时间同步达到稳定状态后切换由时间同步芯片继续进行时间同步,能够避免网络震荡、干扰噪声等对时间同步结果的影响,从而提升了系统时钟时间同步的同步稳定性和同步精度。

Embodiments of the present invention provide a time synchronization method, device, network equipment, and computer-readable storage medium. The processor first performs time synchronization on the system clock according to the time synchronization protocol, and after determining that the time synchronization of the system clock has reached a stable state, switches to The time synchronization chip continues to synchronize the system clock. Since the scheme in which the processor performs time synchronization according to the time synchronization protocol has the advantage of fast synchronization convergence speed, using this scheme at the beginning of time synchronization can quickly converge the time deviation between the local device and the master device. Since the time synchronization chip will fully suppress and filter the message data with the main device, after the time synchronization of the system clock reaches a stable state, the time synchronization chip will continue to perform time synchronization after the time synchronization chip, which can avoid network shocks, interference noise, etc. The impact of the time synchronization result, thereby improving the synchronization stability and synchronization accuracy of the system clock time synchronization.

Description

时间同步方法、装置、网络设备及计算机可读存储介质Time synchronization method, device, network device and computer-readable storage medium

技术领域technical field

本发明涉及通信领域,尤其涉及一种时间同步方法、装置、网络设备及计算机可读存储介质。The present invention relates to the communication field, in particular to a time synchronization method, device, network equipment and computer-readable storage medium.

背景技术Background technique

随着5G(5th Generation,第五代移动通信)网络技术的兴起,以及5G相关应用需求、时钟技术标准的推动,IEEE(Institute of Electrical and Electronics Engineers,电气和电子工程师协会)1588时间同步协议在网络时钟时间同步上起到了重要的作用。作为GPS(Global Positioning System,全球定位系统)时间源的重要备份,1588时钟为整个通讯网络提供高精度的时钟时间同步功能,为网络通讯业务的正常运行提供有力的支撑和保障。With the rise of 5G (5th Generation, fifth-generation mobile communication) network technology, and the promotion of 5G-related application requirements and clock technology standards, the IEEE (Institute of Electrical and Electronics Engineers, Institute of Electrical and Electronics Engineers) 1588 time synchronization protocol is Network clock time synchronization plays an important role. As an important backup of the GPS (Global Positioning System, Global Positioning System) time source, the 1588 clock provides a high-precision clock time synchronization function for the entire communication network, providing strong support and guarantee for the normal operation of network communication services.

现有技术中可以通过网络设备的CPU运行1588时间同步协议栈,与主设备交互从而实现对系统时钟的同步。不过由于从网络设备端口到CPU的路径时延不确定,因此这种时间同步方案精度不高。而且考虑到CPU的处理能力和处理速度,一般在时戳计算和处理时不做或者只做简单的抑制滤波处理。所以这种方案还具有对网络震荡和噪声干扰敏感,稳定性差的缺陷。In the prior art, the CPU of the network device can run the 1588 time synchronization protocol stack to interact with the master device so as to realize the synchronization of the system clock. However, since the path delay from the network device port to the CPU is uncertain, the accuracy of this time synchronization solution is not high. Moreover, considering the processing capability and processing speed of the CPU, generally no or only simple suppression filter processing is performed during time stamp calculation and processing. Therefore, this solution also has the disadvantages of being sensitive to network vibration and noise interference and having poor stability.

所以,现在亟需提供一种新的时间同步方案以解决现有时间同步方案精度低、稳定性差的问题。Therefore, there is an urgent need to provide a new time synchronization solution to solve the problems of low precision and poor stability of the existing time synchronization solution.

发明内容Contents of the invention

本发明实施例提供的时间同步方法、装置、网络设备及计算机可读存储介质,主要解决的技术问题是:提供一种新的时间同步方案,以解决现有时间同步方案精度低、稳定性差的问题。The time synchronization method, device, network equipment, and computer-readable storage medium provided by the embodiments of the present invention mainly solve the technical problem of providing a new time synchronization solution to solve the problem of low precision and poor stability of existing time synchronization solutions question.

为解决上述技术问题,本发明实施例提供一种时间同步方法,包括:In order to solve the above technical problems, an embodiment of the present invention provides a time synchronization method, including:

处理器根据时间同步协议对系统时钟进行时间同步;The processor performs time synchronization on the system clock according to the time synchronization protocol;

在确定系统时钟的时间同步达到稳定状态时,切换由时间同步芯片继续对系统时钟进行时间同步。When it is determined that the time synchronization of the system clock has reached a stable state, the time synchronization chip is switched to continue time synchronization of the system clock.

可选地,切换由同步芯片继续对系统时钟进行时间同步包括:Optionally, switching the synchronization chip to continue time synchronization of the system clock includes:

控制系统时钟向时间同步芯片输出时间;Control the system clock to output time to the time synchronization chip;

在时间同步芯片锁定系统时钟的时间后,控制时间同步芯片对系统时钟进行时间同步,并停止处理器对系统时钟的时间同步。After the time synchronization chip locks the time of the system clock, the time synchronization chip is controlled to synchronize the time of the system clock, and stop the processor from synchronizing the time of the system clock.

可选地,确定系统时钟的时间同步达到稳定状态包括:Optionally, determining that the time synchronization of the system clock reaches a stable state includes:

确定在连续K次同步检测中,本设备与主设备间的时间偏差Δt小于预设偏差ΔTh的次数达到N次,N与K均为大于0的正整数,且K大于等于N。It is determined that in K consecutive synchronization detections, the time deviation Δt between the device and the master device is smaller than the preset deviation ΔTh for N times, N and K are both positive integers greater than 0, and K is greater than or equal to N.

可选地,N等于K。Optionally, N is equal to K.

可选地,时间同步协议为网络测量和控制系统的精密时钟同步协议标准PTP。Optionally, the time synchronization protocol is the precision clock synchronization protocol standard PTP of the network measurement and control system.

可选地,控制同步芯片继续对系统时钟进行时间同步之后,还包括:Optionally, after the control synchronization chip continues to perform time synchronization on the system clock, it also includes:

在同步芯片处于异常状态时,控制处理器继续根据时间同步协议对系统时钟进行时间同步。When the synchronization chip is in an abnormal state, the control processor continues to perform time synchronization on the system clock according to the time synchronization protocol.

本发明实施例还提供一种时间同步装置,包括:The embodiment of the present invention also provides a time synchronization device, including:

第一同步模块,用于根据时间同步协议对系统时钟进行时间同步;The first synchronization module is configured to perform time synchronization on the system clock according to the time synchronization protocol;

同步检测模块,用于检测系统时钟的时间同步是否达到稳定状态;A synchronous detection module is used to detect whether the time synchronization of the system clock reaches a stable state;

第二同步模块,用于在确定系统时钟的时间同步达到稳定状态后,切换由时间同步芯片继续对系统时钟进行时间同步。The second synchronization module is configured to switch the time synchronization chip to continue time synchronization of the system clock after determining that the time synchronization of the system clock has reached a stable state.

本发明实施例还提供一种网络设备,包括处理器、存储器、时间同步芯片、通信单元及通信总线;The embodiment of the present invention also provides a network device, including a processor, a memory, a time synchronization chip, a communication unit, and a communication bus;

通信总线用于实现处理器分别同存储器、时间同步芯片以及通信单元之间的连接通信;The communication bus is used to realize the connection and communication between the processor and the memory, the time synchronization chip and the communication unit;

处理器用于执行存储器中存储的一个或者多个程序,以实现如上任一项的时间同步方法的步骤。The processor is used to execute one or more programs stored in the memory, so as to realize the steps of any one of the above time synchronization methods.

可选地,时间同步芯片为1588功能芯片。Optionally, the time synchronization chip is a 1588 function chip.

本发明实施例还提供一种计算机存储介质,计算机可读存储介质存储有一个或者多个程序,一个或者多个程序可被一个或者多个处理器执行,以实现如上任一项的时间同步方法的步骤。An embodiment of the present invention also provides a computer storage medium, the computer-readable storage medium stores one or more programs, and one or more programs can be executed by one or more processors to implement any of the above time synchronization methods A step of.

本发明的有益效果是:The beneficial effects of the present invention are:

根据本发明实施例提供的时间同步方法、装置、网络设备及计算机可读存储介质,处理器先根据时间同步协议对系统时钟进行时间同步,并在系统时钟的时间同步达到稳定状态时,切换由时间同步芯片继续对系统时钟进行时间同步。由于处理器根据时间同步协议进行时间同步的方案具有同步收敛速度快的优点,因此在时间同步的开始使用该方案能够使得本设备与主设备之间的时间偏差快速收敛。由于时间同步芯片会对与主设备间的报文数据进行充分的抑制滤波处理,因此系统时钟的时间同步达到稳定状态后切换由时间同步芯片继续进行时间同步,能够避免网络震荡、干扰噪声等对时间同步结果的影响,从而提升了系统时钟时间同步的同步稳定性和同步精度。According to the time synchronization method, device, network device, and computer-readable storage medium provided by the embodiments of the present invention, the processor first performs time synchronization on the system clock according to the time synchronization protocol, and when the time synchronization of the system clock reaches a stable state, switches the The time synchronization chip continues to perform time synchronization to the system clock. Since the solution of the processor performing time synchronization according to the time synchronization protocol has the advantage of fast synchronization convergence speed, using this solution at the beginning of time synchronization can make the time deviation between the local device and the master device converge quickly. Since the time synchronization chip will fully suppress and filter the message data with the main device, after the time synchronization of the system clock reaches a stable state, the time synchronization chip will continue to perform time synchronization after the time synchronization chip, which can avoid network shocks, interference noise, etc. The impact of the time synchronization result, thereby improving the synchronization stability and synchronization accuracy of the system clock time synchronization.

本发明其他特征和相应的有益效果在说明书的后面部分进行阐述说明,且应当理解,至少部分有益效果从本发明说明书中的记载变的显而易见。Other features and corresponding beneficial effects of the present invention are explained in the following part of the specification, and it should be understood that at least part of the beneficial effects become obvious from the description in the specification of the present invention.

附图说明Description of drawings

图1为本发明实施例一中提供的时间同步方法的一种流程图;FIG. 1 is a flowchart of a time synchronization method provided in Embodiment 1 of the present invention;

图2为本发明实施例一中提供的切换由时间同步芯片对系统时钟进行时间同步的一种流程图;FIG. 2 is a flow chart of switching the time synchronization of the system clock by the time synchronization chip provided in Embodiment 1 of the present invention;

图3为本发明实施例二中提供的时间同步方法的一种流程图;FIG. 3 is a flowchart of a time synchronization method provided in Embodiment 2 of the present invention;

图4为本发明实施例二中提供的一种网络设备的显示界面示意图;FIG. 4 is a schematic diagram of a display interface of a network device provided in Embodiment 2 of the present invention;

图5为本发明实施例三中提供的时间同步装置的一种结构示意图;FIG. 5 is a schematic structural diagram of a time synchronization device provided in Embodiment 3 of the present invention;

图6为本发明实施例四中提供的时间同步装置的一种结构示意图;FIG. 6 is a schematic structural diagram of a time synchronization device provided in Embodiment 4 of the present invention;

图7为本发明实施例五中提供的网络设备的一种硬件结构示意图。FIG. 7 is a schematic diagram of a hardware structure of a network device provided in Embodiment 5 of the present invention.

具体实施方式Detailed ways

为了使本发明的目的、技术方案及优点更加清楚明白,下面通过具体实施方式结合附图对本发明实施例作进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below through specific implementation manners in conjunction with the accompanying drawings. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.

实施例一:Embodiment one:

IEEE 1588时间同步协议的全称是网络测量和控制系统的精密时钟同步协议标准(IEEE1588Precision Clock Synchronization Protocol),简称PTP(Precision timingProtocol,精确时间协议)。其支持主从设备之间通过包交换的方式进行时间同步,具有亚微妙级的时间同步精度。1588时间同步系统可以用纯软件的方式来实现,例如利用CPU实现1588协议栈,完成PTP报文的收发、时间戳处理和时间同步。利用CPU纯软件的方式实现1588时间同步系统具有这样一些优点:实现简单,只需要维护1588协议栈,与底层的具体硬件无关;同步收敛快;成本低等。但是,受CPU的性能限制,PTP报文的发包速率较低。并且,由于报文从从设备端口到CPU的这一段路径时延的不确定性以及软件处理的延时性,导致这种时间方式无法达到很高的精度。The full name of the IEEE 1588 Time Synchronization Protocol is the Precision Clock Synchronization Protocol Standard for Network Measurement and Control Systems (IEEE1588 Precision Clock Synchronization Protocol), referred to as PTP (Precision timing Protocol, Precision Time Protocol). It supports time synchronization between master and slave devices through packet exchange, with sub-microsecond time synchronization accuracy. The 1588 time synchronization system can be realized by pure software, for example, using the CPU to implement the 1588 protocol stack to complete the sending and receiving of PTP messages, time stamp processing and time synchronization. Realizing the 1588 time synchronization system by CPU pure software has some advantages: simple implementation, only need to maintain 1588 protocol stack, independent of the specific hardware at the bottom; fast synchronization convergence; low cost, etc. However, limited by the performance of the CPU, the sending rate of PTP packets is low. Moreover, due to the uncertainty of the path delay of the message from the device port to the CPU and the delay of software processing, this time method cannot achieve high precision.

为了提高时间同步的精度,可以通过CPU软件和底层硬件结合的方式来实现1588时间同步系统。CPU软件负责协议栈运行,将每次收发报文同步的计算结果下发调整底层硬件。底层硬件负责报文在设备内部传输路径上的延时测量和修正。通过这种方式能够极大的提高网络设备的时间同步精度(可以达到纳秒级),而且同步收敛速度非常快。但是考虑到CPU的处理能力和速度,这种方式一般在时戳计算和处理时不做或者只做简单的抑制滤波处理。因此使得时间同步结果对于网络震荡和噪声干扰非常敏感,时间同步的稳定性较差。In order to improve the precision of time synchronization, the 1588 time synchronization system can be realized by combining CPU software and underlying hardware. The CPU software is responsible for the operation of the protocol stack, and sends the calculation results of each sending and receiving message synchronization to adjust the underlying hardware. The underlying hardware is responsible for delay measurement and correction of packets on the internal transmission path of the device. In this way, the time synchronization accuracy of network devices can be greatly improved (up to nanosecond level), and the synchronization convergence speed is very fast. However, considering the processing power and speed of the CPU, this method generally does not perform or only performs simple suppression filtering during timestamp calculation and processing. Therefore, the result of time synchronization is very sensitive to network oscillation and noise interference, and the stability of time synchronization is poor.

为了摆脱上述方案中CPU软件实现的限制,在设计1588时间同步系统方案时可以考虑增加专门的1588功能芯片。1588功能芯片能够独立于CPU运行1588协议栈,收发PTP报文,进行时间戳处理和运算。CPU只需要做1588功能芯片的配置管理工作,相对于运行整个1588协议栈来说,CPU的开销可以忽略不计。1588功能芯片为了保证1588时间同步的稳定性,在同步时对报文数据做了滑窗滤波处理。这种处理可以防止时钟时间同步受网络震荡的影响,但同时,滑窗滤波处理也增加了同步趋于稳定的时长,而且虽然滑窗越大,防止网络震荡的效果越好,但是时间同步达到稳定状态需要的时间也越长。特别是在1588功能芯片的起始同步时间和对端设备的时间差别太大的情况下,会明显增加同步收敛所需要的时长。In order to get rid of the limitations of the CPU software implementation in the above-mentioned scheme, a special 1588 function chip can be considered when designing the 1588 time synchronization system scheme. The 1588 function chip can run the 1588 protocol stack independently of the CPU, send and receive PTP messages, and perform time stamp processing and calculation. The CPU only needs to do the configuration and management work of the 1588 function chip. Compared with running the entire 1588 protocol stack, the CPU overhead can be ignored. In order to ensure the stability of 1588 time synchronization, the 1588 function chip performs sliding window filtering on the message data during synchronization. This processing can prevent clock time synchronization from being affected by network shocks, but at the same time, the sliding window filter processing also increases the time for synchronization to stabilize, and although the larger the sliding window, the better the effect of preventing network shocks, but the time synchronization reaches The time required for steady state is also longer. Especially when the initial synchronization time of the 1588 function chip is too different from the time of the peer device, the time required for synchronization convergence will be significantly increased.

针对上述方案为了解决CPU纯软件实现时间同步时,同步精度与同步稳定性差的问题而采用1588功能芯片进行时间同步,在提升时间同步的精度与稳定性的同时,增加了同步收敛时长的问题,本实施例提供一种时间同步方案,请参见图1:In view of the above solution, in order to solve the problem of poor synchronization accuracy and synchronization stability when CPU pure software implements time synchronization, the 1588 function chip is used for time synchronization. While improving the accuracy and stability of time synchronization, it increases the problem of synchronization convergence time. This embodiment provides a time synchronization solution, please refer to Figure 1:

S102:处理器根据时间同步协议对系统时钟进行时间同步。S102: The processor performs time synchronization on the system clock according to the time synchronization protocol.

在两个网络设备进行交互时,需要保证两个网络设备的系统时间一致,在通常情况下,是由从设备根据主设备的时间同步自己系统时钟的时间。所以,在本实施例中,时间同步方法可以由从设备来执行。在时间同步开始后,从设备可以控制本设备的处理器根据时间同步协议对本设备的系统时钟进行时间同步。应当理解的是,这里所谓的处理器对系统时钟进行时间同步,是指在对系统时钟进行时间同步时,处理器会进行运行协议栈等主要工作的情景,而非处理器简单地参与系统时钟的时间同步,例如如果处理器仅仅是对时间同步芯片进行参数配置,而不进行时间同步的其他工作,则这种情形不能算作是由处理器进行时间同步。下面对处理器根据时间同步协议对系统时钟进行时间同步的过程进行介绍,例如:When two network devices interact, it is necessary to ensure that the system times of the two network devices are consistent. In general, the slave device synchronizes the time of its own system clock with the time of the master device. Therefore, in this embodiment, the time synchronization method can be performed by the slave device. After the time synchronization starts, the slave device can control the processor of the device to perform time synchronization on the system clock of the device according to the time synchronization protocol. It should be understood that the so-called time synchronization of the system clock by the processor here refers to the situation where the processor will perform the main tasks such as running the protocol stack when the time synchronization of the system clock is performed, rather than the processor simply participating in the system clock For example, if the processor only configures the parameters of the time synchronization chip and does not perform other work of time synchronization, this situation cannot be counted as time synchronization by the processor. The process of the processor synchronizing the system clock according to the time synchronization protocol is introduced below, for example:

从设备控制处理器运行时间同步协议栈,与主设备之间进行时间同步报文收发,然后根据报文时间戳计算本设备与主设备之间的时间偏差,然后根据计算结果对系统时钟的时间进行调整,实现对本设备系统时钟的时间同步。The slave device controls the processor to run the time synchronization protocol stack, sends and receives time synchronization messages with the master device, and then calculates the time deviation between the device and the master device according to the message timestamp, and then calculates the time of the system clock according to the calculation result Make adjustments to achieve time synchronization with the system clock of the device.

应当理解的是,由于处理器运行时间同步协议栈对系统时钟进行时间同步时,只会做简单的抑制滤波处理甚至是完全不做时间滤波处理,因此,从设备控制处理器根据时间同步协议对系统时钟进行同步时,能够使得系统时钟的时间较为快速的达到同步收敛。在控制处理器对系统时钟进行时间同步的同时,从设备会对系统时钟当前的时间同步进行检测,确定系统时钟的时间同步是否满足达到稳定状态。It should be understood that when the processor runs the time synchronization protocol stack to synchronize the time of the system clock, it only performs simple suppression filtering processing or even does not perform time filtering processing at all. Therefore, the slave device controls the processor according to the time synchronization protocol. When the system clock is synchronized, the time of the system clock can be achieved relatively quickly to achieve synchronization convergence. While controlling the processor to synchronize the time of the system clock, the slave device will detect the current time synchronization of the system clock to determine whether the time synchronization of the system clock is satisfied and reaches a stable state.

S104:在确定系统时钟的时间同步达到稳定状态后,切换由时间同步芯片继续对系统时钟进行时间同步。S104: After determining that the time synchronization of the system clock has reached a stable state, switch the time synchronization chip to continue time synchronization of the system clock.

在确定系统时钟的时间同步达到稳定状态后,从设备可以控制切换由时间同步芯片继续对系统时钟进行时间同步。这样,当切换由时间同步芯片进行时间同步时,时间同步芯片的时间同步能够越过同步未收敛的过程,从而避免时间同步芯片同步收敛速度慢的问题。在本实施例的一种示例中,从设备在控制器处理器进行时间同步的同时,会检测系统时钟的时间同步是否达到稳定状态,一旦检测到系统时钟的时间同步达到稳定状态,就切换由时间同步芯片继续对系统时钟进行时间同步。当然,在一些特殊的情形下,也可以在系统时钟的时间同步达到稳定状态以后,继续采用处理器进行一段时间的时间同步,然后才切换到由时间同步芯片进行同步的同步阶段。After determining that the time synchronization of the system clock has reached a stable state, the slave device can control the switching and the time synchronization chip continues to perform time synchronization on the system clock. In this way, when the time synchronization chip is switched to perform time synchronization, the time synchronization of the time synchronization chip can skip the synchronization unconverged process, thereby avoiding the problem of slow convergence speed of the time synchronization chip. In an example of this embodiment, while the controller processor is performing time synchronization, the slave device will detect whether the time synchronization of the system clock has reached a stable state. Once it detects that the time synchronization of the system clock has reached a stable state, it will switch to the The time synchronization chip continues to perform time synchronization to the system clock. Of course, in some special cases, after the time synchronization of the system clock reaches a stable state, the processor can continue to be used for time synchronization for a period of time, and then switch to the synchronization stage where the time synchronization chip performs synchronization.

系统时钟的同步达到稳定状态有这样两方面的要求:一、系统时钟的时间同步精度满足要求;二、系统时钟的时间同步趋于稳定,也即系统时钟与主设备间的时间差波动不大。为了确定系统时钟的时间同步是否达到稳定状态,从设备在处理器每一次计算出系统时钟当前时间与主设备时间之间的时间偏差后,就会做一次同步检测,确定本设备系统时钟与主设备之间的时间偏差Δt是否小于预设偏差ΔTh。如果从设备确定在连续的K次检测中,有N次检测结果均为Δt小于ΔTh,则可以判定本设备系统时钟的时间同步当前已达到稳定状态。例如,如果将K设置为50,N设置为45,则至少在从设备最近的50次同步检测中,存在至少45次的检测结果为Δt小于ΔTh,就可以判定系统时钟的时间同步已达到稳定状态。当然在本实施例的一些示例中,还可以将K和N的取值设置为相同,即N=K,在这种情况下,只要从设备确定已经有连续K次的检测结果均为Δt小于ΔTh,则可以判定系统时钟的时间同步达到稳定状态。例如,N=K=5,则只要从设备连续5次检测到系统时钟与主设备间的时间偏差Δt小于预设偏差ΔTh,就可以判定系统时钟的时间同步达到稳定状态,可以切换由时间同步芯片继续对系统时钟进行时间同步。There are two requirements for the synchronization of the system clock to reach a stable state: first, the time synchronization accuracy of the system clock meets the requirements; second, the time synchronization of the system clock tends to be stable, that is, the time difference between the system clock and the master device does not fluctuate much. In order to determine whether the time synchronization of the system clock has reached a stable state, the slave device will perform a synchronization detection every time the processor calculates the time deviation between the current time of the system clock and the time of the master device to determine whether the system clock of the device is consistent with the time of the master device. Whether the time deviation Δt between devices is smaller than the preset deviation ΔTh. If the slave device determines that Δt is less than ΔTh in N times of detections among the K consecutive detections, it can be determined that the time synchronization of the system clock of the device has reached a stable state. For example, if K is set to 50 and N is set to 45, at least 45 of the latest 50 synchronization detections from the slave device have a detection result of Δt less than ΔTh, and it can be determined that the time synchronization of the system clock has reached stability state. Of course, in some examples of this embodiment, the values of K and N can also be set to be the same, that is, N=K. In this case, as long as the slave device determines that there have been K consecutive detection results that Δt ΔTh, it can be determined that the time synchronization of the system clock has reached a stable state. For example, N=K=5, as long as the slave device detects that the time deviation Δt between the system clock and the master device is less than the preset deviation ΔTh for 5 consecutive times, it can be determined that the time synchronization of the system clock has reached a stable state, and the time synchronization can be switched The chip continues to time-synchronize to the system clock.

时间同步芯片对系统时钟进行时间同步的大体过程与处理器对系统时钟进行时间同步的大体过程基本相似:时间同步芯片独立于处理器运行时间同步协议栈,让从设备与主设备之间进行时间同步报文的收发,并计算本设备与主设备之间的时间偏差,并根据该时间偏差对系统时钟的时间进行调整。The general process of the time synchronization chip for the system clock is basically similar to that of the processor for the time synchronization of the system clock: the time synchronization chip runs the time synchronization protocol stack independently of the processor, allowing the slave device and the master device to perform time synchronization. Synchronize the sending and receiving of messages, and calculate the time deviation between the device and the master device, and adjust the time of the system clock according to the time deviation.

应当理解的是,前面所谓的“继续”是指时间同步芯片是在处理器已进行的时间同步的基础上对系统时钟进行时间同步,因此,在切换到时间同步芯片进行时间同步时,从设备应当保证时间同步芯片先获取到系统时钟当前的时间。在本实施例中,从由处理器对系统时钟进行时间同步切换到由时间同步芯片对系统时钟进行时间同步的过程可以参见图2的流程图所示:It should be understood that the so-called "continuation" above means that the time synchronization chip synchronizes the system clock on the basis of the time synchronization performed by the processor. Therefore, when switching to the time synchronization chip for time synchronization, the slave device It should be ensured that the time synchronization chip first obtains the current time of the system clock. In this embodiment, the process of switching from the time synchronization switching of the system clock by the processor to the time synchronization of the system clock by the time synchronization chip can be shown in the flowchart of FIG. 2:

S202:控制系统时钟向时间同步芯片输出时间。S202: Control the system clock to output time to the time synchronization chip.

在控制处理器对系统时钟进行时间同步同步的过程中,从设备会同时检测系统时钟的时间同步是否满足达到稳定状态,如果检测结果表征当前已达到稳定状态,则从设备可以控制系统时钟向时间同步芯片输出时间,以使时间同步芯片能够锁定系统时钟的时间,该过程能够使得时间同步芯片获取到处理器进行时间同步的同步结果,该同步结果将作为时间同步芯片后续时间同步的基础。In the process of controlling the time synchronization of the system clock by the control processor, the slave device will simultaneously detect whether the time synchronization of the system clock is satisfied and reaches a stable state. If the detection result indicates that the current stable state has been reached, the slave device can control the system clock to time The synchronization chip outputs the time so that the time synchronization chip can lock the time of the system clock. This process enables the time synchronization chip to obtain the synchronization result of the processor's time synchronization. The synchronization result will be used as the basis for the subsequent time synchronization of the time synchronization chip.

S204:在时间同步芯片锁定系统时钟的时间后,控制时间同步芯片对系统时钟进行时间同步,并停止处理器对系统时钟的时间同步。S204: After the time synchronization chip locks the time of the system clock, control the time synchronization chip to synchronize the time of the system clock, and stop the processor from synchronizing the time of the system clock.

在检测到时间同步芯片已经锁定了系统时钟输出的时间后,从设备可以控制时间同步芯片对系统时钟进行时间同步,同时停止处理器对系统时钟的时间同步。此后,系统时钟所接收的同步时间应当是由时间同步芯片输出的。After detecting that the time synchronization chip has locked the time output by the system clock, the slave device can control the time synchronization chip to synchronize the time of the system clock, and at the same time stop the processor from synchronizing the time of the system clock. Thereafter, the synchronization time received by the system clock should be output by the time synchronization chip.

应当明白的是,虽然时间同步芯片对系统时钟的时间同步过程与处理器对系统时钟的时间同步过程大体类似,但是,在本实施例中,时间同步芯片会对收发的报文数据进行滑窗滤波处理,因此可以防止系统时钟的时间同步结果受到网络震荡与干扰噪声的影响。所以,本实施例提供的时间同步方法,能够综合处理器进行时间同步时同步收敛快的优点以及时间同步芯片进行时间同步时同步稳定性好、同步精度高的优点。It should be understood that although the time synchronization process of the time synchronization chip to the system clock is generally similar to the time synchronization process of the processor to the system clock, in this embodiment, the time synchronization chip will perform a sliding window on the message data sent and received. Filter processing, so the time synchronization result of the system clock can be prevented from being affected by network oscillation and interference noise. Therefore, the time synchronization method provided in this embodiment can combine the advantages of fast synchronization convergence when the processor performs time synchronization and the advantages of good synchronization stability and high synchronization accuracy when the time synchronization chip performs time synchronization.

本实施例中所谓的时间同步协议可以是PTP协议,时间同步芯片可以是1588功能芯片,或者是具有与1588功能芯片相似功能的用于时间同步的其他芯片。1588功能芯片在报文发包速率上比处理器运行PTP协议栈的方式存在较大的优势,可以很好的应对频率恢复等对报文收发速率要求较高的场景。The so-called time synchronization protocol in this embodiment may be the PTP protocol, and the time synchronization chip may be a 1588 function chip, or other chips for time synchronization with functions similar to the 1588 function chip. The 1588 function chip has a greater advantage in the packet sending rate than the way the processor runs the PTP protocol stack, and can well cope with scenarios that require a higher packet sending and receiving rate, such as frequency recovery.

本实施例提供的时间同步方法,首先采用处理器运行时间同步协议栈,对系统时钟进行时间同步,从而时间时间同步快速收敛。在确定系统时钟的时间同步处于稳定状态后,可以切换采用时间同步芯片,以处理器的时间同步结果为基础继续进行后续时间同步,从而使得时间同步拥有较好的同步精度与稳定性,提升系统时钟的同步效果。In the time synchronization method provided in this embodiment, first, a processor is used to run a time synchronization protocol stack to perform time synchronization on a system clock, so that the time synchronization converges quickly. After confirming that the time synchronization of the system clock is in a stable state, you can switch to the time synchronization chip and continue to perform subsequent time synchronization based on the time synchronization result of the processor, so that the time synchronization has better synchronization accuracy and stability and improves the system Clock synchronization effect.

更进一步地,由于时间同步芯片具有较好的报文收发速率,因此,适合对系统时钟进行频率同步,能够应对频率回复等场景的需求。Furthermore, since the time synchronization chip has a relatively good message sending and receiving rate, it is suitable for frequency synchronization of the system clock and can meet the needs of scenarios such as frequency recovery.

实施例二:Embodiment two:

本实施例将结合一些具体的示例继续对本实施例提供的时间同步方法做进一步介绍,请参见图3示出的时间同步方法的流程图:This embodiment will continue to further introduce the time synchronization method provided by this embodiment in conjunction with some specific examples. Please refer to the flowchart of the time synchronization method shown in FIG. 3:

本实施例中,以时间同步协议为1588时间同步协议,即PTP协议,时间同步芯片为1588功能芯片为例进行说明,不过本领域技术人员应当明白的是,这只是本实施例给出的一种示例,并不是本发明唯一的实现方式。另外,在从设备中,系统时钟可以通过FPGA(Field-Programmable Gate Array,现场可编程门阵列)来实现,并提供给设备内各个需要使用系统时间的器件、模块等。In this embodiment, the time synchronization protocol is the 1588 time synchronization protocol, that is, the PTP protocol, and the time synchronization chip is a 1588 function chip for example. This example is not the only implementation of the present invention. In addition, in the slave device, the system clock can be implemented by an FPGA (Field-Programmable Gate Array, Field Programmable Gate Array), and provided to each device, module, etc. in the device that needs to use the system time.

S302:处理器根据时间同步协议对系统时钟进行时间同步。S302: The processor performs time synchronization on the system clock according to the time synchronization protocol.

从设备控制处理器根据时间同步协议运行时间同步协议栈,与主设备进行报文交互,并根据报文时间戳计算与主设备之间的时间偏差,并根据该时间偏差对系统时钟的时间进行调整。应当理解的是,处理器在运行时间同步协议栈的时候,是控制从设备的通信单元与主设备进行报文收发。The slave device control processor runs the time synchronization protocol stack according to the time synchronization protocol, exchanges messages with the master device, calculates the time deviation with the master device according to the message timestamp, and calculates the time of the system clock according to the time deviation Adjustment. It should be understood that when the processor runs the time synchronization protocol stack, it controls the communication unit of the slave device to send and receive messages with the master device.

S304:检测系统时钟的时间同步是否达到稳定状态。S304: Detect whether the time synchronization of the system clock reaches a stable state.

若判断结果为是,则说明系统时钟的时间同步当前已达到稳定状态,因此可以进入S306,否则的话说明系统时钟的时间同步尚未达到稳定状态,因此需要继续执行S302。在本实施例中,检测系统时钟的时间同步是否达到稳定状态,可以检测系统时钟与主设备之间的时间偏差Δt小于预设偏差ΔTh的连续次数是否达到预设次数。If the judgment result is yes, it means that the time synchronization of the system clock has reached a stable state at present, so S306 can be entered, otherwise, it means that the time synchronization of the system clock has not yet reached a stable state, so it is necessary to continue to execute S302. In this embodiment, to detect whether the time synchronization of the system clock reaches a stable state, it may be detected whether the number of consecutive times that the time deviation Δt between the system clock and the master device is smaller than the preset deviation ΔTh reaches the preset number.

应当理解的是,预设次数的取值与当前同步的网络环境相关。例如,在有同步以太网支持的同步环境下,可以适当减小预设次数的取值,在不支持同步以太网,如单纯的1588同步环境下,可以适当增大预设次数的取值。同样地,ΔTh的取值也与当前同步的网络环境有关,在有同步以太网支持的同步环境下,ΔTh的取值可以适当减小,在不支持同步以太网,如单纯1588同步的环境下,可以适当增大ΔTh的取值。不过ΔTh的取值不能低于从设备所支持的同步精度,例如对于自身支持的时间精度为8ns的从设备,ΔTh取值应当大于等于8ns。考虑到处理器的同步精度不高,因此,对于自身支持的时间精度为8ns的从设备,ΔTh取值通常大于8ns。It should be understood that the value of the preset number of times is related to the current synchronization network environment. For example, in a synchronous environment supported by synchronous Ethernet, the value of the preset number of times may be appropriately reduced, and in a synchronous environment that does not support synchronous Ethernet, such as a pure 1588 synchronization environment, the value of the preset number of times may be appropriately increased. Similarly, the value of ΔTh is also related to the current synchronous network environment. In a synchronous environment supported by synchronous Ethernet, the value of ΔTh can be appropriately reduced. In an environment that does not support synchronous Ethernet, such as pure 1588 synchronization , the value of ΔTh can be appropriately increased. However, the value of ΔTh cannot be lower than the synchronization precision supported by the slave device. For example, for a slave device whose time precision is 8 ns, the value of ΔTh should be greater than or equal to 8 ns. Considering that the synchronization precision of the processor is not high, therefore, for a slave device whose time precision is 8 ns, the value of ΔTh is usually greater than 8 ns.

S306:控制系统时钟向时间同步芯片输出时间。S306: Control the system clock to output time to the time synchronization chip.

在从设备检测到系统时钟的时间同步达到稳定状态之后,从设备可以控制系统时钟向时间同步芯片输出时间,即让系统时钟将处理器的时间同步结果传输给时间同步芯片。After the slave device detects that the time synchronization of the system clock has reached a stable state, the slave device can control the system clock to output time to the time synchronization chip, that is, let the system clock transmit the time synchronization result of the processor to the time synchronization chip.

S308:控制时间同步芯片继续对系统时钟进行时间同步。S308: Control the time synchronization chip to continue to perform time synchronization on the system clock.

在确保时间同步芯片锁定系统时钟的时间后,从设备控制进行切换,让系统时钟根据时间同步芯片的输出进行时间同步,此时,处理器不需要再运行时间同步协议栈与主设备进行报文交互,因此可以在极大程度上降低处理器的处理开销。另外,由于时间同步芯片运行时间同步协议栈进行报文收发的速度可以满足频率恢复的要求,因此,在控制时间同步芯片继续对系统时钟进行时间同步后,也可以对系统时钟的频率与主设备的频率进行同步。After ensuring that the time synchronization chip locks the time of the system clock, the slave device controls the switch, allowing the system clock to perform time synchronization according to the output of the time synchronization chip. At this time, the processor does not need to run the time synchronization protocol stack to communicate with the master device. interaction, so the processing overhead of the processor can be greatly reduced. In addition, because the time synchronization chip runs the time synchronization protocol stack to send and receive messages, the speed can meet the requirements of frequency recovery. Therefore, after the time synchronization chip is controlled to continue time synchronization of the system clock, the frequency of the system clock and the master device can also be synchronized. frequency for synchronization.

S310:检测时间同步芯片是否处于异常状态。S310: Detect whether the time synchronization chip is in an abnormal state.

在控制时间同步芯片对系统时钟进行时间同步的同时,从设备还会对时间同步芯片的工作进行检测,以确定时间同步芯片是否处于异常状态,例如时间同步芯片是否故障等,如果确定时间同步芯片处于异常状态,则进入S312,否则继续执行S308。While controlling the time synchronization chip to synchronize the system clock, the slave device will also detect the work of the time synchronization chip to determine whether the time synchronization chip is in an abnormal state, such as whether the time synchronization chip is faulty, etc. If it is determined that the time synchronization chip If it is in an abnormal state, go to S312, otherwise go to S308.

S312:切换由处理器对系统时钟进行时间同步。S312: Switching the processor to perform time synchronization on the system clock.

如果确定时间同步芯片处于异常状态,则从设备可以控制切换为处理器对系统时钟进行时间同步,让系统时钟不再根据时间同步芯片的输出进行时间同步,此时,从设备可以控制关闭时间同步芯片。另外,从设备还可以发出告警信息,提示从设备的管理人员时间同步芯片异常,让管理人员及时对异常情况进行处理。图4示出了一种网络设备检测到1588功能芯片故障后,向管理人员发出提示信息的一种显示界面示意图,应当理解的是,除了通过显示对管理人员进行提示的方式以外,网络设备还可以通过发出提示音,发出提示语音等方式进行告警。If it is determined that the time synchronization chip is in an abnormal state, the slave device can control and switch to the processor for time synchronization of the system clock, so that the system clock no longer performs time synchronization based on the output of the time synchronization chip. At this time, the slave device can control the time synchronization to be turned off chip. In addition, the slave device can also send an alarm message to remind the management personnel of the slave device that the time synchronization chip is abnormal, so that the management personnel can deal with the abnormal situation in time. Figure 4 shows a schematic diagram of a display interface for a network device to send prompt information to the management personnel after detecting a 1588 function chip failure. It should be understood that, in addition to the way of prompting the The alarm can be issued by sending out a prompt sound or a prompt voice.

另外,在重新切回由处理器对系统时钟进行时间同步以后,从设备将不再根据系统时钟的时间同步达到稳定状态来进行时间同步方式的切换,因此从设备也不需要再检测系统时钟的时间同步是否达到稳定状态。In addition, after switching back to the time synchronization of the system clock by the processor, the slave device will no longer switch the time synchronization mode according to the time synchronization of the system clock reaching a stable state, so the slave device does not need to detect the status of the system clock. Whether time synchronization has reached a steady state.

本实施例提供的时间同步方法,不仅综合了采用处理器运行协议栈进行时间同步的方案与采用时间同步芯片进行时间同步的方案各自的优点,使得整个时间同步过程表现出同步收敛速度快,同步精度高,同步稳定性好等优点;而且,还可以利用时间同步芯片报文收发速度快的优点对系统时钟进行频率同步。更进一步的,在采用时间同步芯片对系统时钟进行时间同步的过程中,从设备还会监测时间同步芯片是否故障,并在时间同步芯片不能正常工作时,切换到由处理器继续进行时间同步,避免了时间同步芯片发生硬件故障的情况下,无法输出或者输出时钟异常,严重影响系统正常工作的问题。The time synchronization method provided in this embodiment not only combines the respective advantages of the scheme of using the processor to run the protocol stack for time synchronization and the scheme of using the time synchronization chip for time synchronization, so that the entire time synchronization process shows a fast synchronization convergence speed, synchronization It has the advantages of high precision and good synchronization stability; moreover, it can also use the advantages of fast sending and receiving speed of the time synchronization chip to synchronize the frequency of the system clock. Furthermore, in the process of using the time synchronization chip to synchronize the time of the system clock, the slave device will also monitor whether the time synchronization chip is faulty, and when the time synchronization chip cannot work normally, it will switch to the processor to continue the time synchronization. It avoids the problem that when the time synchronization chip has a hardware failure, it cannot output or the output clock is abnormal, which seriously affects the normal operation of the system.

实施例三:Embodiment three:

本实施例提供一种时间同步装置,请参见图5,该时间同步装置50包括软件同步模块502以及芯片同步模块504。其中第一同步模块502用于控制处理器根据时间同步协议对系统时钟进行时间同步,而同步检测模块504用于检测系统时钟的时间同步是否达到稳定状态;第二同步模块506用于在同步检测模块504的检测结果为是后,切换由时间同步芯片继续对系统时钟进行时间同步。This embodiment provides a time synchronization device. Referring to FIG. 5 , the time synchronization device 50 includes a software synchronization module 502 and a chip synchronization module 504 . Wherein the first synchronization module 502 is used to control the processor to perform time synchronization on the system clock according to the time synchronization protocol, and the synchronization detection module 504 is used to detect whether the time synchronization of the system clock has reached a stable state; After the detection result of the module 504 is yes, the time synchronization chip is switched to continue time synchronization of the system clock.

在两个网络设备进行交互时,需要保证两个网络设备的系统时间一致,在通常情况下,是由从设备根据主设备的时间同步自己系统时钟的时间。所以,在本实施例中,时间同步装置50可以部署在各种作为从设备上网络设备上。在时间同步开始后,第一同步模块502可以根据时间同步协议对本设备的系统时钟进行时间同步。应当理解的是,这里所谓的第一同步模块502对系统时钟进行时间同步,是指在对系统时钟进行时间同步时,第一同步模块502会进行运行协议栈等主要工作的情景,而非第一同步模块502简单地参与系统时钟的时间同步,例如如果第一同步模块502仅仅是对时间同步芯片进行参数配置,而不进行时间同步的其他工作,则这种情形不能算作是由第一同步模块502进行时间同步。下面对第一同步模块502根据时间同步协议对系统时钟进行时间同步的过程进行介绍,例如:When two network devices interact, it is necessary to ensure that the system times of the two network devices are consistent. In general, the slave device synchronizes the time of its own system clock with the time of the master device. Therefore, in this embodiment, the time synchronization apparatus 50 may be deployed on various network devices serving as slave devices. After the time synchronization starts, the first synchronization module 502 can perform time synchronization on the system clock of the device according to the time synchronization protocol. It should be understood that the so-called first synchronization module 502 here synchronizes the time of the system clock, which means that when the system clock is time synchronized, the first synchronization module 502 will perform main tasks such as running the protocol stack, rather than the first synchronization module 502. A synchronization module 502 simply participates in the time synchronization of the system clock. For example, if the first synchronization module 502 only configures the parameters of the time synchronization chip, but does not perform other tasks of time synchronization, then this situation cannot be regarded as caused by the first synchronization module. The synchronization module 502 performs time synchronization. The process of time synchronization of the system clock by the first synchronization module 502 according to the time synchronization protocol is introduced below, for example:

第一同步模块502运行时间同步协议栈,与主设备之间进行时间同步报文收发,然后根据报文时间戳计算本设备与主设备之间的时间偏差,然后根据计算结果对系统时钟的时间进行调整,实现对本设备系统时钟的时间同步。The first synchronization module 502 runs the time synchronization protocol stack, sends and receives time synchronization messages with the master device, then calculates the time deviation between the device and the master device according to the message timestamp, and then calculates the time of the system clock according to the calculation result Make adjustments to achieve time synchronization with the system clock of the device.

应当理解的是,由于第一同步模块502运行时间同步协议栈对系统时钟进行时间同步时,只会做简单的抑制滤波处理甚至是完全不做时间滤波处理,因此,第一同步模块502根据时间同步协议对系统时钟进行同步时,能够使得系统时钟的时间较为快速的达到同步收敛。在对系统时钟进行时间同步的同时,同步检测模块504会对系统时钟当前的时间同步进行检测,确定系统时钟的时间同步是否达到稳定状态。It should be understood that when the first synchronization module 502 runs the time synchronization protocol stack to synchronize the system clock, it will only perform simple suppression filtering processing or even no time filtering processing at all. Therefore, the first synchronization module 502 according to the time When the synchronization protocol synchronizes the system clock, it can make the time of the system clock achieve synchronization convergence relatively quickly. While performing time synchronization on the system clock, the synchronization detection module 504 will detect the current time synchronization of the system clock to determine whether the time synchronization of the system clock has reached a stable state.

在同步检测模块504确定系统时钟的时间同步达到稳定状态后,第二同步模块506可以控制切换由时间同步芯片继续对系统时钟进行时间同步。这样,当切换由时间同步芯片进行时间同步时,时间同步芯片的时间同步能够越过同步未收敛的过程,从而避免时间同步芯片同步收敛速度慢的问题。在本实施例的一种示例中,在第一同步模块502控制器处理器进行时间同步的同时,同步检测模块504会检测系统时钟的时间同步是否达到稳定状态,一旦检测到系统时钟的时间同步达到稳定状态,则第二同步模块506立即控制切换由时间同步芯片继续进行时间同步。当然,在一些特殊的情形下,第一同步模块502也可以在同步检测模块504检测到系统时钟的时间同步达到稳定状态以后,继续采用处理器进行一段时间的时间同步,然后第二同步模块506才切换到由时间同步芯片进行同步的同步阶段。After the synchronization detection module 504 determines that the time synchronization of the system clock has reached a stable state, the second synchronization module 506 may control to switch the time synchronization chip to continue time synchronization of the system clock. In this way, when the time synchronization chip is switched to perform time synchronization, the time synchronization of the time synchronization chip can skip the synchronization unconverged process, thereby avoiding the problem of slow convergence speed of the time synchronization chip. In an example of this embodiment, while the controller processor of the first synchronization module 502 is performing time synchronization, the synchronization detection module 504 will detect whether the time synchronization of the system clock has reached a stable state, once the time synchronization of the system clock is detected When a stable state is reached, the second synchronization module 506 immediately controls to switch to the time synchronization chip to continue time synchronization. Of course, in some special cases, the first synchronization module 502 can also continue to use the processor to perform time synchronization for a period of time after the synchronization detection module 504 detects that the time synchronization of the system clock has reached a stable state, and then the second synchronization module 506 It is switched to the synchronization stage where the time synchronization chip performs synchronization.

系统时钟的同步达到稳定状态有这样两方面的要求:一、系统时钟的时间同步精度满足要求;二、系统时钟的时间同步趋于稳定,也即系统时钟与主设备间的时间差波动不大。为了确定系统时钟的时间同步是否达到稳定状态,同步检测模块504在处理器每一次计算出系统时钟当前时间与主设备时间之间的时间偏差后,就会做一次同步检测,确定本设备系统时钟与主设备之间的时间偏差Δt是否小于预设偏差ΔTh。如果同步检测模块504确定在连续的K次检测中,有N次检测结果均为Δt小于ΔTh,则可以判定本设备系统时钟的时间同步当前已达到稳定状态。例如,如果将K设置为50,N设置为45,则至少在同步检测模块504最近的50次同步检测中,存在至少45次的检测结果为Δt小于ΔTh,就可以判定系统时钟的时间同步已达到稳定状态。当然在本实施例的一些示例中,还可以将K和N的取值设置为相同,即N=K,在这种情况下,只同步检测模块504确定已经有连续K次的检测结果均为Δt小于ΔTh,则可以判定系统时钟的时间同步达到稳定状态。例如,N=K=5,则只要同步检测模块504连续5次检测到系统时钟与主设备间的时间偏差Δt小于预设偏差ΔTh,就可以判定系统时钟的时间同步达到稳定状态,可以切换由时间同步芯片继续对系统时钟进行时间同步。There are two requirements for the synchronization of the system clock to reach a stable state: first, the time synchronization accuracy of the system clock meets the requirements; second, the time synchronization of the system clock tends to be stable, that is, the time difference between the system clock and the master device does not fluctuate much. In order to determine whether the time synchronization of the system clock has reached a stable state, the synchronization detection module 504 will perform a synchronization detection after the processor calculates the time deviation between the current time of the system clock and the time of the master device each time to determine the system clock of this device. Whether the time deviation Δt with the master device is smaller than the preset deviation ΔTh. If the synchronization detection module 504 determines that in the K consecutive detections, there are N detection results where Δt is less than ΔTh, it can be determined that the time synchronization of the device's system clock has reached a stable state. For example, if K is set to 50, and N is set to 45, then at least among the latest 50 synchronization detections of the synchronization detection module 504, there are at least 45 detection results that Δt is less than ΔTh, and it can be determined that the time synchronization of the system clock has been completed. reach a steady state. Of course, in some examples of this embodiment, the values of K and N can also be set to be the same, that is, N=K. In this case, only the synchronization detection module 504 determines that there are K consecutive detection results that are all If Δt is less than ΔTh, it can be determined that the time synchronization of the system clock has reached a stable state. For example, if N=K=5, as long as the synchronization detection module 504 detects that the time deviation Δt between the system clock and the master device is less than the preset deviation ΔTh for 5 consecutive times, it can be determined that the time synchronization of the system clock has reached a stable state, and it can be switched by The time synchronization chip continues to perform time synchronization to the system clock.

第二同步模块506控制时间同步芯片对系统时钟进行时间同步的大体过程与处理器对系统时钟进行时间同步的大体过程基本相似:第二同步模块506控制时间同步芯片独立于处理器运行时间同步协议栈,与主设备之间进行时间同步报文的收发,并计算本设备与主设备之间的时间偏差,并根据该时间偏差对系统时钟的时间进行调整。The general process that the second synchronization module 506 controls the time synchronization chip to synchronize the system clock is basically similar to the general process that the processor performs time synchronization to the system clock: the second synchronization module 506 controls the time synchronization chip to run the time synchronization protocol independently of the processor The stack sends and receives time synchronization messages with the master device, and calculates the time deviation between the device and the master device, and adjusts the time of the system clock according to the time deviation.

应当理解的是,前面所谓的“继续”是指时间同步芯片是在处理器已进行的时间同步的基础上对系统时钟进行时间同步,因此,在切换到时间同步芯片进行时间同步时,第二同步模块506应当保证时间同步芯片先获取到系统时钟当前的时间。It should be understood that the so-called "continuation" above means that the time synchronization chip synchronizes the time of the system clock on the basis of the time synchronization performed by the processor. Therefore, when switching to the time synchronization chip for time synchronization, the second The synchronization module 506 should ensure that the time synchronization chip obtains the current time of the system clock first.

在第一同步模块502控制处理器对系统时钟进行时间同步同步的过程中,同步检测模块504会同时检测系统时钟的时间同步是否满足达到稳定状态,如果检测结果表征当前已达到稳定状态,则第二同步模块506可以控制系统时钟向时间同步芯片输出时间,以使时间同步芯片能够锁定系统时钟的时间,该过程能够使得时间同步芯片获取到处理器进行时间同步的同步结果,该同步结果将作为时间同步芯片后续时间同步的基础。During the process of the first synchronization module 502 controlling the processor to perform time synchronization on the system clock, the synchronization detection module 504 will simultaneously detect whether the time synchronization of the system clock meets the requirements of reaching a stable state. If the detection result indicates that the current state has reached a stable state, then the first The second synchronization module 506 can control the system clock to output time to the time synchronization chip, so that the time synchronization chip can lock the time of the system clock. This process can enable the time synchronization chip to obtain the synchronization result of the processor performing time synchronization, and the synchronization result will be used as The basis for the subsequent time synchronization of the time synchronization chip.

在检测到时间同步芯片已经锁定了系统时钟输出的时间后,第二同步模块506可以控制时间同步芯片对系统时钟进行时间同步,同时停止处理器对系统时钟的时间同步。此后,系统时钟所接收的同步时间应当是由时间同步芯片输出的。After detecting that the time synchronization chip has locked the output time of the system clock, the second synchronization module 506 can control the time synchronization chip to synchronize the time of the system clock, and at the same time stop the processor from synchronizing the time of the system clock. Thereafter, the synchronization time received by the system clock should be output by the time synchronization chip.

应当明白的是,虽然时间同步芯片对系统时钟的时间同步过程与处理器对系统时钟的时间同步过程大体类似,但是,在本实施例中,时间同步芯片会对收发的报文数据进行滑窗滤波处理,因此可以防止系统时钟的时间同步结果受到网络震荡与干扰噪声的影响。所以,本实施例提供的时间同步装置50,能够综合处理器进行时间同步时同步收敛快的优点以及时间同步芯片进行时间同步时同步稳定性好、同步精度高的优点。It should be understood that although the time synchronization process of the time synchronization chip to the system clock is generally similar to the time synchronization process of the processor to the system clock, in this embodiment, the time synchronization chip will perform a sliding window on the message data sent and received. Filter processing, so the time synchronization result of the system clock can be prevented from being affected by network oscillation and interference noise. Therefore, the time synchronization device 50 provided in this embodiment can combine the advantages of fast synchronization convergence when the processor performs time synchronization and the advantages of good synchronization stability and high synchronization accuracy when the time synchronization chip performs time synchronization.

本实施例中所谓的时间同步协议可以是PTP协议,时间同步芯片可以是1588功能芯片,或者是具有与1588功能芯片相似功能的用于时间同步的其他芯片。1588功能芯片在报文发包速率上比处理器运行PTP协议栈的方式存在较大的优势,可以很好的应对频率恢复等对报文收发速率要求较高的场景。The so-called time synchronization protocol in this embodiment may be the PTP protocol, and the time synchronization chip may be a 1588 function chip, or other chips for time synchronization with functions similar to the 1588 function chip. The 1588 function chip has a greater advantage in the packet sending rate than the way the processor runs the PTP protocol stack, and can well cope with scenarios that require a higher packet sending and receiving rate, such as frequency recovery.

本实施例提供的时间同步装置,首先采用处理器运行时间同步协议栈,对系统时钟进行时间同步,从而时间时间同步快速收敛。在确定系统时钟的时间同步处于稳定状态后,可以切换采用时间同步芯片,以处理器的时间同步结果为基础继续进行后续时间同步,从而使得时间同步拥有较好的同步精度与稳定性,提升系统时钟的同步效果。The time synchronization device provided in this embodiment first uses a processor to run a time synchronization protocol stack to perform time synchronization on a system clock, so that time and time synchronization converges quickly. After confirming that the time synchronization of the system clock is in a stable state, you can switch to the time synchronization chip and continue to perform subsequent time synchronization based on the time synchronization result of the processor, so that the time synchronization has better synchronization accuracy and stability and improves the system Clock synchronization effect.

更进一步地,由于时间同步芯片具有较好的报文收发速率,因此,适合对系统时钟进行频率同步,能够应对频率回复等场景的需求。Furthermore, since the time synchronization chip has a relatively good message sending and receiving rate, it is suitable for frequency synchronization of the system clock and can meet the needs of scenarios such as frequency recovery.

实施例四:Embodiment four:

本实施例将结合一些具体的示例继续对前述时间同步装置做进一步介绍,本实施例中,假定时间同步协议为1588时间同步协议,即PTP协议,时间同步芯片为1588功能芯片,不过本领域技术人员应当明白的是,这只是本实施例给出的一种示例,并不是本发明唯一的实现方式。This embodiment will continue to further introduce the aforementioned time synchronization device in conjunction with some specific examples. In this embodiment, it is assumed that the time synchronization protocol is the 1588 time synchronization protocol, that is, the PTP protocol, and the time synchronization chip is a 1588 function chip. Personnel should understand that this is only an example given in this embodiment, and is not the only implementation manner of the present invention.

请参见图6示出的时间同步装置的一种结构示意图:时间同步装置60包括第一同步模块602、同步检测模块604、第二同步模块606以外,还包括异常处置模块608,其中第一同步模块602、同步检测模块604、第二同步模块606与图5中各模块的功能对应类似,而异常处理模块608用于在同步芯片处于异常状态时,控制处理器继续根据时间同步协议对系统时钟进行时间同步。下面对时间同步装置60对从设备系统时钟进行时间同步的过程进行介绍:Please refer to a schematic structural diagram of a time synchronization device shown in FIG. 6: the time synchronization device 60 includes a first synchronization module 602, a synchronization detection module 604, and a second synchronization module 606, as well as an exception handling module 608, wherein the first synchronization Module 602, synchronization detection module 604, and second synchronization module 606 are similar to the functions of the modules in FIG. Perform time synchronization. The following is an introduction to the process in which the time synchronization device 60 performs time synchronization of the slave device system clock:

第一同步模块602控制处理器根据时间同步协议运行时间同步协议栈,与主设备进行报文交互,并根据报文时间戳计算与主设备之间的时间偏差,并根据该时间偏差对系统时钟的时间进行调整。应当理解的是,处理器在运行时间同步协议栈的时候,是通过控制从设备的通信单元与主设备进行报文收发。The first synchronization module 602 controls the processor to run the time synchronization protocol stack according to the time synchronization protocol, interacts with the master device, and calculates the time deviation with the master device according to the message timestamp, and adjusts the system clock according to the time deviation time to adjust. It should be understood that when the processor runs the time synchronization protocol stack, it sends and receives messages with the master device by controlling the communication unit of the slave device.

在第一同步模块602控制处理器运行时间同步协议栈对系统时钟进行时间同步时,同步检测模块604可以检测系统时钟的时间同步是否达到稳定状态。若同步检测模块604的判断结果为是,则说明系统时钟的时间同步当前已达到稳定状态,因此,第二同步模块606可以开始工作。否则的话说明系统时钟的时间同步尚未达到稳定状态,所以会由第一同步模块602继续工作。在本实施例中,同步检测模块604检测系统时钟的时间同步是否达到稳定状态,可以检测系统时钟与主设备之间的时间偏差Δt小于预设偏差ΔTh的连续次数是否达到预设次数。When the first synchronization module 602 controls the processor to run the time synchronization protocol stack to synchronize the system clock, the synchronization detection module 604 can detect whether the time synchronization of the system clock has reached a stable state. If the judgment result of the synchronization detection module 604 is yes, it means that the time synchronization of the system clock has reached a stable state, and therefore, the second synchronization module 606 can start working. Otherwise, it means that the time synchronization of the system clock has not reached a stable state, so the first synchronization module 602 will continue to work. In this embodiment, the synchronization detection module 604 detects whether the time synchronization of the system clock has reached a stable state, and may detect whether the number of consecutive times that the time deviation Δt between the system clock and the master device is smaller than the preset deviation ΔTh reaches the preset number.

应当理解的是,预设次数的取值与当前同步的网络环境相关。例如,在有同步以太网支持的同步环境下,可以适当减小预设次数的取值,在不支持同步以太网,如单纯的1588同步环境下,可以适当增大预设次数的取值。同样地,ΔTh的取值也与当前同步的网络环境有关,在有同步以太网支持的同步环境下,ΔTh的取值可以适当减小,在不支持同步以太网,如单纯1588同步的环境下,可以适当增大ΔTh的取值。不过ΔTh的取值不能低于从设备所支持的同步精度,例如对于自身支持的时间精度为8ns的从设备,ΔTh取值应当大于等于8ns。考虑到处理器的同步精度不高,因此,对于自身支持的时间精度为8ns的从设备,ΔTh取值通常大于8ns。It should be understood that the value of the preset number of times is related to the current synchronization network environment. For example, in a synchronous environment supported by synchronous Ethernet, the value of the preset number of times may be appropriately reduced, and in a synchronous environment that does not support synchronous Ethernet, such as a pure 1588 synchronization environment, the value of the preset number of times may be appropriately increased. Similarly, the value of ΔTh is also related to the current synchronous network environment. In a synchronous environment supported by synchronous Ethernet, the value of ΔTh can be appropriately reduced. In an environment that does not support synchronous Ethernet, such as pure 1588 synchronization , the value of ΔTh can be appropriately increased. However, the value of ΔTh cannot be lower than the synchronization precision supported by the slave device. For example, for a slave device whose time precision is 8 ns, the value of ΔTh should be greater than or equal to 8 ns. Considering that the synchronization precision of the processor is not high, therefore, for a slave device whose time precision is 8 ns, the value of ΔTh is usually greater than 8 ns.

在同步检测模块604检测到系统时钟的时间同步达到稳定状态之后,第二同步模块606可以控制系统时钟向时间同步芯片输出时间,即让系统时钟将处理器的时间同步结果传输给时间同步芯片。After the synchronization detection module 604 detects that the time synchronization of the system clock has reached a stable state, the second synchronization module 606 can control the system clock to output time to the time synchronization chip, that is, let the system clock transmit the time synchronization result of the processor to the time synchronization chip.

在确保时间同步芯片锁定系统时钟的时间后,第二同步模块606控制进行切换,让系统时钟根据时间同步芯片的输出进行时间同步,此时,处理器不需要再运行时间同步协议栈与主设备进行报文交互,因此可以在极大程度上降低处理器的处理开销。另外,由于时间同步芯片运行时间同步协议栈进行报文收发的速度可以满足频率恢复的要求,因此,在控制时间同步芯片继续对系统时钟进行时间同步后,也可以对系统时钟的频率与主设备的频率进行同步。After ensuring that the time synchronization chip locks the time of the system clock, the second synchronization module 606 controls to switch, allowing the system clock to perform time synchronization according to the output of the time synchronization chip. At this time, the processor does not need to run the time synchronization protocol stack and the master device Packet interaction is carried out, so the processing overhead of the processor can be greatly reduced. In addition, because the time synchronization chip runs the time synchronization protocol stack to send and receive messages, the speed can meet the requirements of frequency recovery. Therefore, after the time synchronization chip is controlled to continue time synchronization of the system clock, the frequency of the system clock and the master device can also be synchronized. frequency for synchronization.

在控制时间同步芯片对系统时钟进行时间同步的同时,异常处置模块608会对时间同步芯片的工作进行检测,以确定时间同步芯片是否处于异常状态,例如时间同步芯片是否故障等,如果确定时间同步芯片处于异常状态,则进入异常处置模块608切换由处理器对系统时钟进行时间同步,让系统时钟不再根据时间同步芯片的输出进行时间同步,此时,异常处置模块608可以控制关闭时间同步芯片。另外,异常处置模块608还可以让从设备发出告警信息,以提示从设备的管理人员时间同步芯片异常,让管理人员及时对异常情况进行处理。图4示出了一种网络设备检测到1588功能芯片故障后,向管理人员发出提示信息的一种显示界面示意图,应当理解的是,除了通过显示对管理人员进行提示的方式以外,网络设备还可以通过发出提示音,发出提示语音等方式进行告警。While controlling the time synchronization chip to synchronize the system clock, the abnormal handling module 608 will detect the work of the time synchronization chip to determine whether the time synchronization chip is in an abnormal state, such as whether the time synchronization chip is faulty, etc. If the chip is in an abnormal state, it enters into the abnormal handling module 608 to switch the time synchronization of the system clock by the processor, so that the system clock no longer performs time synchronization according to the output of the time synchronization chip. At this time, the abnormal handling module 608 can control the shutdown of the time synchronization chip . In addition, the exception handling module 608 can also make the slave device send out an alarm message to prompt the management personnel of the slave device that the time synchronization chip is abnormal, so that the management personnel can deal with the abnormal situation in time. Figure 4 shows a schematic diagram of a display interface for a network device to send prompt information to the management personnel after detecting a 1588 function chip failure. It should be understood that, in addition to the way of prompting the The alarm can be issued by sending out a prompt sound or a prompt voice.

另外,在重新切回由处理器对系统时钟进行时间同步以后,第二同步模块606将不再根据系统时钟的时间同步达到稳定状态来进行时间同步方式的切换,因此同步检测模块604也不需要再检测系统时钟的时间同步是否达到稳定状态。所以同步检测模块604和第二同步模块606均可以处于休眠状态。In addition, after switching back to the time synchronization of the system clock by the processor, the second synchronization module 606 will no longer switch the time synchronization mode according to the time synchronization of the system clock reaching a stable state, so the synchronization detection module 604 does not need Then check whether the time synchronization of the system clock has reached a stable state. Therefore, both the synchronization detection module 604 and the second synchronization module 606 may be in a dormant state.

本实施例以及实施例三中提供的时间同步装置均可以部署在网络设备上,其中第一同步模块、同步检测模块、第二同步模块以及异常处置模块的功能均可以通过网络设备的处理器来实现。The time synchronization devices provided in this embodiment and Embodiment 3 can all be deployed on network equipment, wherein the functions of the first synchronization module, the synchronization detection module, the second synchronization module and the exception handling module can all be implemented by the processor of the network equipment accomplish.

本实施例提供的时间同步装置,不仅综合了采用处理器运行协议栈进行时间同步的方案与采用时间同步芯片进行时间同步的方案各自的优点,使得整个时间同步过程表现出同步收敛速度快,同步精度高,同步稳定性好等优点;而且,还可以利用时间同步芯片报文收发速度快的优点对系统时钟进行频率同步。更进一步的,在采用时间同步芯片对系统时钟进行时间同步的过程中,从设备还会监测时间同步芯片是否故障,并在时间同步芯片不能正常工作时,切换到由处理器继续进行时间同步,避免了时间同步芯片发生硬件故障的情况下,无法输出或者输出时钟异常,严重影响系统正常工作的问题。The time synchronization device provided in this embodiment not only combines the respective advantages of the scheme of using the processor to run the protocol stack for time synchronization and the scheme of using the time synchronization chip for time synchronization, so that the entire time synchronization process shows a fast synchronization convergence speed, synchronization It has the advantages of high precision and good synchronization stability; moreover, it can also use the advantages of fast sending and receiving speed of the time synchronization chip to synchronize the frequency of the system clock. Furthermore, in the process of using the time synchronization chip to synchronize the time of the system clock, the slave device will also monitor whether the time synchronization chip is faulty, and when the time synchronization chip cannot work normally, it will switch to the processor to continue the time synchronization. It avoids the problem that in the case of a hardware failure of the time synchronization chip, the output cannot be output or the output clock is abnormal, which seriously affects the normal operation of the system.

实施例五:Embodiment five:

本实施例先提供一种计算机可读存储介质,该计算机可读存储介质中可以存储有一个或多个可供一个或多个处理器读取、编译并执行的计算机程序,在本实施例中,该计算机可读存储介质可以存储有时间同步程序,该时间同步程序可供一个或多个处理器执行实现前述实施例一和二中介绍的任意一种时间同步方法。This embodiment first provides a computer-readable storage medium, which can store one or more computer programs that can be read, compiled, and executed by one or more processors. In this embodiment The computer-readable storage medium may store a time synchronization program, and the time synchronization program may be executed by one or more processors to implement any one of the time synchronization methods described in Embodiments 1 and 2 above.

本实施例还提供一种网络设备,请参见图7示出的网络设备7的硬件结构示意图:This embodiment also provides a network device, please refer to the schematic diagram of the hardware structure of the network device 7 shown in FIG. 7:

网络设备7包括处理器71、存储器72、时间同步芯片73、通信单元74以及用于实现处理器71分别同存储器72、时间同步芯片73、通信单元74三者之间通信连接的通信总线75,其中存储器72可以为前述存储有时间同步程序的存储介质。处理器71可以读取存储器72中存储的时间同步程序,进行编译并执行实现实施例一和二中介绍的任意一种时间同步方法。The network device 7 includes a processor 71, a memory 72, a time synchronization chip 73, a communication unit 74, and a communication bus 75 for realizing the communication between the processor 71 and the memory 72, the time synchronization chip 73, and the communication unit 74 respectively. The memory 72 may be the aforementioned storage medium storing the time synchronization program. The processor 71 can read the time synchronization program stored in the memory 72, compile and execute any time synchronization method introduced in Embodiments 1 and 2.

在本实施例中,网络设备7的处理器71根据时间同步程序对本设备的系统时钟进行时间同步,可以根据1588时间同步协议进行,并且,时间同步芯片73也可以是1588功能芯片。下面对网络设备7的时间同步过程进行简单介绍:In this embodiment, the processor 71 of the network device 7 performs time synchronization on the system clock of the device according to the time synchronization program, which may be performed according to the 1588 time synchronization protocol, and the time synchronization chip 73 may also be a 1588 function chip. The time synchronization process of the network device 7 is briefly introduced below:

处理器71可以运行时间同步协议栈,例如1588时间同步协议栈,控制通信单元74与主设备进行报文交互,根据报文时间戳计算本设备与主设备之间的时间偏差,并根据该时间偏差对本设备的系统时间进行同步调整。处理器71在运行协议栈对系统时钟的时间进行同步的同时,还会检测系统时钟的时间同步是否已达到稳定状态,如果检测结果为是,则处理器71通知时间同步芯片73继续对系统时钟的时间进行同步。可选地,处理器71可以通知系统时钟,例如FPGA芯片向时间同步芯片73输出时间,在确定时间同步芯片73锁定系统时钟的时间后,处理器71可以停止运行时间同步协议栈,由时间同步芯片73独立运行时间同步协议栈对系统时钟进行同步。The processor 71 can run a time synchronization protocol stack, such as a 1588 time synchronization protocol stack, control the communication unit 74 to interact with the master device, calculate the time deviation between the device and the master device according to the message timestamp, and calculate the time deviation between the device and the master device according to the time stamp. The deviation adjusts the system time of this device synchronously. Processor 71 also can detect whether the time synchronization of system clock has reached a steady state when operating the protocol stack to synchronize the time of system clock, if the detection result is yes, then processor 71 notifies time synchronization chip 73 to continue to system clock time to synchronize. Optionally, the processor 71 can notify the system clock, for example, the FPGA chip outputs the time to the time synchronization chip 73, after determining the time when the time synchronization chip 73 locks the system clock, the processor 71 can stop running the time synchronization protocol stack, and the time synchronization is performed by the time synchronization chip 73. The chip 73 independently runs the time synchronization protocol stack to synchronize the system clock.

另外,在时间同步芯片73对系统时钟进行同步的同时,处理器71还可以对时间同步芯片73的工作状态进行监测,如果确定时间同步芯片73处于异常状态,例如时间同步芯片73故障,则处理器71将继续运行协议栈对系统时钟进行时间同步。与此同时,处理器71可以控制关闭异常的时间同步芯片73,避免时间同步芯片73向系统时钟输出错误的同步信息。In addition, while the time synchronization chip 73 is synchronizing the system clock, the processor 71 can also monitor the working state of the time synchronization chip 73. If it is determined that the time synchronization chip 73 is in an abnormal state, such as a failure of the time synchronization chip 73, then processing The controller 71 will continue to run the protocol stack to synchronize the system clock. At the same time, the processor 71 can control to turn off the abnormal time synchronization chip 73 to prevent the time synchronization chip 73 from outputting wrong synchronization information to the system clock.

对于网络设备7的时间同步的其他细节,可以参见前述实施例的介绍,这里不再赘述。For other details of the time synchronization of the network device 7, reference may be made to the introduction of the foregoing embodiments, which will not be repeated here.

本实施例提供的网络设备及计算机可读存储介质,确保系统时钟时间同步的同步收敛速度快,同步精度高,同步稳定性好。同时,在时间同步芯片故障后,还能即时切换到由处理器继续进行时间同步,避免了时间同步芯片发生硬件故障影响系统正常工作的问题。The network device and the computer-readable storage medium provided in this embodiment ensure fast synchronization convergence speed, high synchronization precision and good synchronization stability of system clock time synchronization. At the same time, after the time synchronization chip fails, it can be switched to the processor to continue the time synchronization immediately, avoiding the problem that the hardware failure of the time synchronization chip affects the normal operation of the system.

显然,本领域的技术人员应该明白,上述本发明实施例的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在计算机存储介质(ROM/RAM、磁碟、光盘)中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。所以,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that each module or each step of the above-mentioned embodiments of the present invention can be realized by a general-purpose computing device, and they can be concentrated on a single computing device, or distributed across multiple computing devices. On the network, optionally, they can be implemented with executable program codes of computing devices, thus, they can be stored in computer storage media (ROM/RAM, magnetic disk, optical disk) to be executed by computing devices, and in some In some cases, the steps shown or described can be performed in a different order than here, or they can be fabricated into individual integrated circuit modules, or multiple modules or steps can be fabricated into a single integrated circuit module for implementation. . Therefore, the present invention is not limited to any specific combination of hardware and software.

以上内容是结合具体的实施方式对本发明实施例所作的进一步详细说明,不能认定本发明的具体实施只局限于这些说明。对于本发明所属技术领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干简单推演或替换,都应当视为属于本发明的保护范围。The above content is a further detailed description of the embodiments of the present invention in conjunction with specific implementation modes, and it cannot be assumed that the specific implementation of the present invention is limited to these descriptions. For those of ordinary skill in the technical field of the present invention, without departing from the concept of the present invention, some simple deduction or replacement can be made, which should be regarded as belonging to the protection scope of the present invention.

Claims (10)

1. A method of time synchronization, comprising:
the processor carries out time synchronization on the system clock according to a time synchronization protocol;
and after the time synchronization of the system clock is determined to reach a stable state, switching a time synchronization chip to continue to perform time synchronization on the system clock.
2. The time synchronization method of claim 1, wherein the switching to continue time synchronizing the system clock by a synchronization chip comprises:
controlling the system clock to output time to the time synchronization chip;
and after the time synchronization chip locks the time of the system clock, controlling the time synchronization chip to perform time synchronization on the system clock, and stopping the time synchronization of the processor on the system clock.
3. The method of time synchronization of claim 1, wherein the determining that the time synchronization of the system clock reaches a steady state comprises:
and determining that the time deviation delta t between the equipment and the main equipment is less than the preset deviation delta Th for a preset time.
4. The time synchronization method according to claim 3, wherein the determining that the number of times that the time deviation Δ t between the own device and the master device is smaller than the preset deviation Δ Th reaches a preset number of times includes:
and determining whether the continuous times that the time deviation delta t between the equipment and the main equipment is smaller than the preset deviation delta Th reach the preset times.
5. The method for time synchronization of claim 1, wherein the time synchronization protocol is a precision clock synchronization protocol standard, PTP, of a network measurement and control system.
6. The time synchronization method according to any one of claims 1 to 5, wherein after controlling the synchronization chip to continue time synchronizing the system clock, further comprising:
and when the synchronization chip is in an abnormal state, controlling the processor to continue to perform time synchronization on the system clock according to the time synchronization protocol.
7. A time synchronization apparatus, comprising:
the first synchronization module is used for carrying out time synchronization on the system clock according to a time synchronization protocol;
the synchronous detection module is used for detecting whether the time synchronization of the system clock reaches a stable state;
and the second synchronization module is used for switching the time synchronization chip to continue to perform time synchronization on the system clock after the time synchronization of the system clock is determined to reach a stable state.
8. A network device is characterized by comprising a processor, a memory, a time synchronization chip, a communication unit and a communication bus;
the communication bus is used for realizing the connection and communication among the processor, the memory, the time synchronization chip and the communication unit respectively;
the processor is configured to execute one or more programs stored in the memory to implement the steps of the time synchronization method of any one of claims 1 to 6.
9. The network device of claim 8, wherein the time synchronization chip is a 1588 function chip.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more programs which are executable by one or more processors to implement the steps of the time synchronization method according to any one of claims 1 to 6.
CN201810631978.6A 2018-06-19 2018-06-19 Time synchronization method, device, network equipment and computer readable storage medium Active CN110620630B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201810631978.6A CN110620630B (en) 2018-06-19 2018-06-19 Time synchronization method, device, network equipment and computer readable storage medium
PCT/CN2019/076340 WO2019242321A1 (en) 2018-06-19 2019-02-27 Time synchronization method, device, network device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810631978.6A CN110620630B (en) 2018-06-19 2018-06-19 Time synchronization method, device, network equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110620630A true CN110620630A (en) 2019-12-27
CN110620630B CN110620630B (en) 2022-04-26

Family

ID=68920281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810631978.6A Active CN110620630B (en) 2018-06-19 2018-06-19 Time synchronization method, device, network equipment and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN110620630B (en)
WO (1) WO2019242321A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112040472A (en) * 2020-08-10 2020-12-04 烽火通信科技股份有限公司 Clock synchronization method, system and readable storage medium
CN113839730A (en) * 2020-06-24 2021-12-24 中兴通讯股份有限公司 Time synchronization method, network device and storage medium
CN115085850A (en) * 2022-06-27 2022-09-20 中国电信股份有限公司 A clock synchronization method, device, electronic device and storage medium
CN116321402A (en) * 2023-03-16 2023-06-23 湖南大学重庆研究院 4G/5G-oriented lightweight PTP time synchronization system and method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113098650B (en) * 2021-03-29 2023-07-25 大连市共进科技有限公司 Time deviation measurement method, device, communication device and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447931B1 (en) * 2005-12-09 2008-11-04 Rockwell Automation Technologies, Inc. Step time change compensation in an industrial automation network
CN101867469A (en) * 2010-06-10 2010-10-20 北京东土科技股份有限公司 A Realization Method of Precise Synchronous Clock
CN102104475A (en) * 2011-01-31 2011-06-22 上海交通大学 IEEE 1588-based synchronization system and synchronization method thereof
CN108234057A (en) * 2018-01-24 2018-06-29 郑州云海信息技术有限公司 Method for synchronizing time, device and the storage medium of server based on BMC

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100581164C (en) * 2006-03-15 2010-01-13 重庆邮电学院 Precise Time Synchronization Method and System for Measurement and Control
CN101217330B (en) * 2008-01-02 2012-07-25 中兴通讯股份有限公司 A method and device for time synchronism calibration
CN102447553A (en) * 2010-10-12 2012-05-09 研祥智能科技股份有限公司 Realizing device of accurate time synchronization protocol
CN202353572U (en) * 2011-11-25 2012-07-25 中国西电电气股份有限公司 Institute of Electrical and Electronic Engineers (IEEE) 1588 time synchronization system for electronic type mutual inductor merging units
KR101682978B1 (en) * 2016-07-26 2016-12-07 쿨사인 주식회사 Video playback synchronization system and method using Precision Time Protocol

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7447931B1 (en) * 2005-12-09 2008-11-04 Rockwell Automation Technologies, Inc. Step time change compensation in an industrial automation network
CN101867469A (en) * 2010-06-10 2010-10-20 北京东土科技股份有限公司 A Realization Method of Precise Synchronous Clock
CN102104475A (en) * 2011-01-31 2011-06-22 上海交通大学 IEEE 1588-based synchronization system and synchronization method thereof
CN108234057A (en) * 2018-01-24 2018-06-29 郑州云海信息技术有限公司 Method for synchronizing time, device and the storage medium of server based on BMC

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113839730A (en) * 2020-06-24 2021-12-24 中兴通讯股份有限公司 Time synchronization method, network device and storage medium
CN112040472A (en) * 2020-08-10 2020-12-04 烽火通信科技股份有限公司 Clock synchronization method, system and readable storage medium
CN112040472B (en) * 2020-08-10 2022-10-18 烽火通信科技股份有限公司 Clock synchronization method, system and readable storage medium
CN115085850A (en) * 2022-06-27 2022-09-20 中国电信股份有限公司 A clock synchronization method, device, electronic device and storage medium
CN116321402A (en) * 2023-03-16 2023-06-23 湖南大学重庆研究院 4G/5G-oriented lightweight PTP time synchronization system and method

Also Published As

Publication number Publication date
WO2019242321A1 (en) 2019-12-26
CN110620630B (en) 2022-04-26

Similar Documents

Publication Publication Date Title
CN110620630A (en) Time synchronization method, device, network equipment and computer readable storage medium
CN102215101B (en) A kind of clock synchronizing method and equipment
US10075287B2 (en) Time synchronization method and device
CN102843205B (en) The method and apparatus that a kind of time synchronized based on Precision Time Protocol restrains
US11316605B2 (en) Method, device, and computer program for improving synchronization of clocks in devices linked according to a daisy-chain topology
US20230262625A1 (en) Time Synchronization Fault Processing Method, Apparatus, And System
CN105376043B (en) A kind of method for synchronizing time of double board systems
CN106899370A (en) A kind of clock chain circuit changing method, device and base station
EP3352392B1 (en) Time synchronization packet processing method and device
CN103001759B (en) A kind of network method for synchronizing time, system and device
EP2749968A1 (en) Time control device, time control method, and program
US12149603B2 (en) Clock port attribute recovery method, device, and system
US9641269B2 (en) Apparatus and method for synchronizing clocks among communication devices
US20140241479A1 (en) Frequency difference detection device, frequency difference detection method, and program
JP2015099983A (en) Time synchronization system, time synchronization method, and computer program
CN106301745A (en) The method and device of time synchronized between main control board and slave control board
CN103686982A (en) A time synchronization method based on clock information and node equipment
US20230208544A1 (en) Method, apparatus, and system for processing time synchronization fault and storage medium
US12041154B2 (en) Clock distribution method and apparatus in network
CN118802046B (en) Time synchronization method, device, electronic device and storage medium
JP2015173311A (en) Communications system
JP6068031B2 (en) Time synchronization apparatus, time synchronization method, and time synchronization program
CN102780554A (en) Method and system for realizing synchronization through 1588 protocol
CN121488569A (en) Multi-port high-precision time synchronization method in 5G user plane function
CN103001718B (en) Adjust the method and device of frequency

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