Time synchronization method, electronic device, storage medium and program product

By receiving and comparing the parameters of multiple time synchronization messages, the message with the highest priority is dynamically selected for time synchronization, which solves the problem of low time synchronization accuracy of communication nodes and achieves stability and continuity in the face of network changes.

CN120934668APending Publication Date: 2025-11-11ZTE CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410579858.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-10
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In existing communication systems, the time synchronization accuracy of communication nodes is not high, and it is difficult to maintain stability and continuity when network conditions change.

Method used

By receiving multiple time synchronization messages, determining the priority order based on their respective time synchronization parameters, selecting the message with the highest priority for time synchronization, and quickly switching when network conditions change, backup redundancy is provided to improve accuracy and disaster recovery capabilities.

Benefits of technology

It improves the time synchronization accuracy of communication nodes, ensures the stability and continuity of time synchronization when network conditions change, and enhances the system's disaster recovery capability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120934668A_ABST
    Figure CN120934668A_ABST
Patent Text Reader

Abstract

The invention provides a time synchronization method, electronic equipment, a storage medium and a program product, relates to the field of communication, and is at least used for solving the problem of low accuracy of time synchronization of a communication node in the related technology. The method comprises the following steps: receiving a plurality of time synchronization messages; determining a priority order among the plurality of time synchronization messages; and performing time synchronization operation based on the time synchronization message with the highest priority among the plurality of time synchronization messages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of communications, and more particularly to a time synchronization method, electronic device, storage medium, and program product. Background Technology

[0002] With the development of communication technology, time synchronization is a crucial function in modern network applications, especially for scenarios with strict requirements for time accuracy. High-precision time synchronization ensures that devices in the network can work in a coordinated manner, which is essential for ensuring data consistency, protecting network security, improving system performance, and meeting specific industry standards.

[0003] To achieve time synchronization, various time synchronization protocols exist in communication systems, such as Network Time Protocol (NTP), Precision Time Protocol (PTP), and Internet Time Service (ITS). However, despite the availability of multiple time synchronization protocols, in practical applications, due to various limitations, the accuracy of time synchronization between communication nodes (such as terminal devices) in a communication system is relatively low. Summary of the Invention

[0004] This disclosure provides a time synchronization method, electronic device, storage medium, and program product, which at least solves the problem of low accuracy in time synchronization of communication nodes in related technologies.

[0005] Firstly, a time synchronization method is provided, the method comprising:

[0006] Receive multiple time synchronization messages;

[0007] Based on the time synchronization parameters of each time synchronization message, determine the priority order among the multiple time synchronization messages;

[0008] Time synchronization is performed based on the highest priority time synchronization message among multiple time synchronization messages.

[0009] Based on the time synchronization method provided in this disclosure, the priority of different time synchronization messages is determined by the time synchronization parameters corresponding to different time synchronization messages (i.e., different time synchronization protocols). This allows for a comprehensive comparison of the merits of different time synchronization messages, and the optimal time synchronization protocol is selected as the highest priority time synchronization protocol. Furthermore, time synchronization operations are performed based on the highest priority time synchronization message, thereby improving the accuracy of time synchronization by communication nodes.

[0010] Furthermore, the method provided in this disclosure selects the highest priority time synchronization message from multiple time synchronization messages for time synchronization. This allows for rapid switching to the highest priority time synchronization message for time synchronization when network conditions change or a time synchronization message becomes unavailable. This enables dynamic selection of time synchronization messages, maintains the continuity and stability of network services, provides backup redundancy for time synchronization, improves the disaster recovery capability of communication nodes, and reduces network anomalies.

[0011] Secondly, a time synchronization device is provided, comprising:

[0012] The receiving module is used to receive multiple time synchronization messages;

[0013] The determination module is used to determine the priority order among multiple time synchronization messages based on their respective time synchronization parameters.

[0014] The synchronization module is used to perform time synchronization operations based on the highest priority time synchronization message among multiple time synchronization messages.

[0015] Thirdly, an electronic device is provided, comprising: a memory and a processor; the memory and the processor are coupled; the memory is used to store a computer program; and the processor, when executing the computer program, implements the time synchronization method of any of the above embodiments.

[0016] Fourthly, a computer-readable storage medium is provided, on which computer program instructions are stored, which, when executed by a processor, implement the time synchronization method of any of the above embodiments.

[0017] Fifthly, a computer program product is provided, the computer program product including computer program instructions that, when executed by a processor, implement the time synchronization method of any of the above embodiments.

[0018] For a detailed description of aspects two through five and their various implementations in this disclosure, please refer to the detailed description in aspect one and its various implementations; and for a detailed analysis of the beneficial effects of aspects two through five and their various implementations in aspect one and its various implementations, please refer to the beneficial effect analysis in aspect one and its various implementations, which will not be repeated here. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in this disclosure, the accompanying drawings used in some embodiments of this disclosure will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings.

[0020] Figure 1 A schematic diagram of a communication system provided for some embodiments of this disclosure;

[0021] Figure 2 A schematic diagram of a communication node provided for some embodiments of this disclosure;

[0022] Figure 3 A flowchart illustrating a time synchronization method provided in some embodiments of this disclosure;

[0023] Figure 4 A flowchart illustrating another time synchronization method provided in some embodiments of this disclosure;

[0024] Figure 5 A schematic diagram of a sliding queue provided for some embodiments of this disclosure;

[0025] Figure 6 A schematic diagram illustrating a data filtering method provided for some embodiments of this disclosure;

[0026] Figure 7 A flowchart illustrating yet another time synchronization method provided in some embodiments of this disclosure;

[0027] Figure 8 A flowchart illustrating yet another time synchronization method provided in some embodiments of this disclosure;

[0028] Figure 9 A flowchart illustrating yet another time synchronization method provided in some embodiments of this disclosure;

[0029] Figure 10 A flowchart illustrating yet another time synchronization method provided in some embodiments of this disclosure;

[0030] Figure 11 This is a schematic diagram of the structure of a time synchronization device provided in some embodiments of the present disclosure;

[0031] Figure 12 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this disclosure. Detailed Implementation

[0032] The technical solutions of this disclosure will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0033] It should be noted that, in this disclosure, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this disclosure should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0034] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.

[0035] In the description of this disclosure, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Furthermore, "at least one" means one or more, and "more than one" means two or more.

[0036] This disclosure can be applied to various wireless communication systems, such as: Global System for Mobile Communication (GSM), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), General Packet Radio Service (GPRS), Long Term Evolution (LTE), Advanced Long Term Evolution (LIE-A), Universal Mobile Telecommunication System (UMTS), 5th Generation Mobile Communication Technology (5G), Beyond Fifth Generation (B5G), and 6th Generation (6G). This disclosure can also be applied to various wired communication systems, fixed networks, bearer networks, base station backhaul networks, wireless base station networks, and the Industrial Internet; however, this disclosure is not limited to these systems.

[0037] Figure 1 This is a schematic diagram of the architecture of a communication system provided in an embodiment of this disclosure. Figure 1 As shown, the communication system includes: a communication node 110, a switch 120, an NTP server 130, and a PTP server 140. The communication node 110 is connected to both the NTP server 130 and the PTP server 140 via the switch 120.

[0038] In some embodiments, PTP server 140 may be a server conforming to the IEEE 1588 standard developed by the Institute of Electrical and Electronics Engineers (IEEE). In this embodiment of the disclosure, PTP server 140 may also be referred to as a 1588 server.

[0039] In some embodiments, the communication node 110 may be one or more, and the switch 120 may be one or more; however, this disclosure does not limit the scope of the embodiments.

[0040] Communication node 110 is used to send and receive signals and perform time synchronization based on the received signals.

[0041] In some embodiments, communication node 110 can support both NTP and PTP simultaneously. Communication node 110 can receive NTP packets sent by NTP server 130 and PTP packets sent by PTP server 140 from different network ports via switch 120, determine the priority order among the received packets, and perform time synchronization based on the packet with the highest priority among the received packets.

[0042] NTP is a network protocol used to synchronize clocks between devices in a data network via packet switching. It typically operates in a master-slave architecture, where the NTP server, based on the NTP protocol, can use broadcast or multicast methods to enable devices on the local area network to passively listen and update their time.

[0043] PTP is a protocol used for microsecond-level clock synchronization of devices in an Ethernet network. During system synchronization, the PTP server's master reference clock periodically publishes PTP time synchronization and time information. The system receives timestamp information from the master reference clock port, calculates the master-slave line time delay and master-slave time difference based on this information, and uses this time difference to adjust the local time, thereby ensuring that the device time maintains the same frequency and phase as the master device time.

[0044] In some embodiments, Figure 2 This is a schematic diagram of communication node 110. (See diagram below.) Figure 2 As shown, the communication node 110 includes: a time synchronization parameter configuration module 111, a message parsing module 112, a message selection module 113, and an error calibration module 114.

[0045] The time synchronization parameter configuration module 111 is used to configure the parameters required for the time synchronization operation of the communication node 110 before the communication node 110 performs the time synchronization operation, and to start the message listening of the communication node 110 after the parameter configuration takes effect.

[0046] For example, the configuration of the parameters of the communication node 110 includes: the configuration of the time synchronization type, the configuration of the time synchronization period, the configuration of the NTP server 130, and the configuration of the PTP server 140.

[0047] In some embodiments, the time synchronization type configuration includes at least the NTP time synchronization type configuration and the PTP time synchronization type configuration. The time synchronization period configuration is typically in seconds. For example, the time synchronization period can range from 60 seconds to 1200 seconds; for instance, the time synchronization period can be configured to 300 seconds. The NTP server 130 configuration includes configuring the IP address of the NTP server 130. The PTP server 140 configuration includes configuring the IP address and packet sending frequency of the PTP server (also called the 1588 server).

[0048] In some embodiments, after the parameter configuration takes effect, communication node 110 can simultaneously create three threads to periodically listen for NTP and PTP packets. For example, communication node 110 can listen to port 123 of communication node 110 through the NTP thread to obtain NTP packets. Communication node 110 can also listen to ports 319 and 320 of communication node 110 through two PTP threads to obtain synchronization (Sync) and announcement (Announce) messages from the PTP packets, respectively. After obtaining the aforementioned messages, communication node 110 can forward the obtained messages to the packet parsing module 120.

[0049] The message parsing module 112 is used to receive messages (such as NTP messages and PTP messages) forwarded by the communication node 110 through the listening thread, and analyze the messages according to the message type in the message header, extract the required data, and store and forward it.

[0050] In some embodiments, when a message cannot be parsed or the message format is incorrect, the message parsing module 120 can discard the message and release the thread from continuing to wait.

[0051] The message selection module 113 is used to determine the priority order of received messages. For example, in the initial stage, NTP and PTP messages have the same priority. After the communication node 110 creates a thread to listen for NTP and PTP messages, the communication node 110 adjusts the priority order of the message it receives first to the highest. Simultaneously, the message selection module acquires data within the messages according to a preset period for message scheduling and selection. The message selection module 113 can compare the priorities of NTP and PTP messages based on the data within them to ultimately determine the priority order between NTP and PTP messages.

[0052] Error calibration module 114 is used to calibrate the error in the data in the message and compensate the error to the actual value so that the communication node 110 can perform time synchronization based on the error-calibrated message.

[0053] In some embodiments, the communication node 110 may be a base station, a terminal, a server, or other equipment. As an example, the communication node 110 may be a base station in Long Term Evolution (LTE), Long Term Evolution Advanced (LTEA), or an evolved Node B (eNB or eNodeB), a base station in a 5G network, or a base station in a future communication system. The base station may include various network-side equipment such as macro base stations, micro base stations, home base stations, wireless remote extensions, routers, repeaters, and wireless fidelity (WIFI) devices. As another example, the communication node 110 can also be a mobile phone, tablet computer, computer with wireless transceiver function, laptop computer, ultra-mobile personal computer (UMPC), personal digital assistant (PDA), desktop, laptop, handheld computer, vehicle terminal, artificial intelligence device, virtual reality (VR) terminal, augmented reality (AR) terminal, etc. The specific form of the communication node 110 is not limited in the embodiments disclosed herein.

[0054] Switch 120 is used for signal routing and forwarding. In some embodiments, switch 120 can receive time synchronization messages (e.g., NTP messages and PRP messages) sent by NTP server 130 and PTP server 140 respectively, and forward them to communication node 110.

[0055] In some embodiments, if there are multiple switches 120, the multiple switches 120 can be connected in a serial cascade or parallel cascade manner.

[0056] It should be noted that, in order to avoid excessive latency and potential performance issues, if multiple switches 120 are connected in a serial cascade manner, the number of switches 120 should generally not exceed 4.

[0057] NTP server 130 is used to provide a unified time source for devices in the network, ensuring that the time settings of all devices are consistent. In some embodiments, NTP server 130 can send NTP messages to communication node 110 through switch 120, so that communication node 110 can perform time synchronization based on NTP messages.

[0058] PTP server 140 is used to achieve high-precision time synchronization between network devices. In some embodiments, the PTP server can send PTP messages to communication node 110 through switch 120, so that communication node 110 can perform time synchronization based on PTP messages.

[0059] It should be noted that the above scenarios are for the purpose of more clearly illustrating the technical solutions of the embodiments of this disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of this disclosure. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided by the embodiments of this disclosure are also applicable to similar technical problems.

[0060] When different types of communication nodes (such as communication nodes and base stations) exist in a communication network, some communication nodes may support multiple time synchronization protocols simultaneously. Although multiple time synchronization protocols are available, in practical applications, due to trade-offs in compatibility, cost, and performance, only one protocol is often chosen for time synchronization, which may result in less than ideal time synchronization accuracy. For example, while NTP is widely used, its time accuracy is typically at the millisecond level, which is insufficient for applications requiring higher time accuracy (such as financial transactions and telecommunications synchronization). PTP, on the other hand, offers even higher time accuracy, reaching microsecond or even nanosecond levels, but its deployment and maintenance costs are higher, and it has more stringent requirements for the network environment. Therefore, to meet the time synchronization accuracy requirements of communication nodes, a solution is needed to select the optimal time synchronization protocol from multiple protocols for time synchronization operations.

[0061] To address the aforementioned issues, this disclosure provides a time synchronization scheme that determines the priority of different time synchronization messages based on the time synchronization parameters corresponding to different time synchronization protocols (i.e., different time synchronization messages), thereby enabling dynamic selection of the time synchronization protocol and improving the accuracy of time synchronization operations performed by communication nodes.

[0062] This disclosure provides a time synchronization method that can be applied to communication nodes in a network. The time synchronization method provided by this disclosure is described below. Figure 3 As shown, the method includes the following steps:

[0063] S101, Receive multiple time synchronization messages.

[0064] In some embodiments, the aforementioned multiple time synchronization messages may belong to different time synchronization protocols.

[0065] For example, multiple time synchronization messages include a first time synchronization message and a second time synchronization message. The first time synchronization message is an NTP message corresponding to NTP, and the second time synchronization message is a PTP message corresponding to PTP. The PTP message includes a Sync message and an Announce message.

[0066] In some embodiments, before receiving multiple time synchronization messages, the communication node can configure the content required for time synchronization. For example, the configuration required for time synchronization includes: time synchronization type configuration, time synchronization period configuration, NTP server configuration, and PTP server configuration.

[0067] In some embodiments, the time synchronization type configuration includes at least the NTP time synchronization type configuration and the PTP time synchronization type configuration.

[0068] In some embodiments, the time synchronization period is typically configured in seconds. For example, the time synchronization period can range from 60 seconds to 1200 seconds; for instance, it can be configured to be 300 seconds.

[0069] In some embodiments, configuring the NTP server includes configuring the IP address of the NTP server. Configuring the PTP server includes configuring the IP address and packet sending frequency of the PTP server (also known as a 1588 server).

[0070] It is understood that the method provided in this disclosure configures the content required for time synchronization operation before receiving NTP and PTP packets, which can ensure that the communication node can communicate normally with the NTP server and PTP server, reduce the possibility of configuration errors during operation, and improve the stability of the communication node's time synchronization operation.

[0071] In some embodiments, after configuring the necessary elements for time synchronization, the communication node can create an NTP thread and a PTP thread, and receive time synchronization messages through different network ports. For example, the communication node can receive NTP messages through the first network port of the NTP thread, receive the Sync message from the PTP message through the second network port of the PTP thread, and receive the Announce message from the PTP message through the third network port of the PTP thread.

[0072] In some embodiments, the communication node can acquire data (e.g., first time synchronization parameters) of a first time synchronization message in each sub-cycle within a preset configuration period, and acquire data (e.g., second time synchronization parameters) of a second time synchronization message in each sub-cycle within the preset configuration period. The communication node can set up sliding queues with a preset depth to temporarily store the first and second time synchronization messages respectively. Here, sub-cycle * 10 = preset configuration period. For example, the preset value can be 10.

[0073] It is understood that in the method provided in this disclosure, the communication node acquires time synchronization message data in each sub-cycle within a preset configuration period and uses a sliding window to temporarily store this data. This allows the communication node to store sufficient time synchronization data for analysis and use without excessively consuming memory resources. If a time synchronization message in a certain sub-cycle is lost or corrupted, the communication node can use the previous data stored in the sliding window for time synchronization, thereby enhancing the fault tolerance of the communication node in time synchronization. Furthermore, the preset values ​​in this disclosure can be configured based on different application scenarios and requirements, improving the flexibility of time synchronization.

[0074] S102. Determine the priority order among multiple time synchronization messages based on their respective time synchronization parameters.

[0075] In some embodiments, a communication node parses multiple received time synchronization messages to extract time synchronization parameters for each message. Exemplarily, the time synchronization parameters include at least one of the following: time error, round-trip time, number of clock layers, clock accuracy, number of communication paths, clock quality, and path delay. Specifically, the time error indicates the maximum error of the local clock of the server corresponding to the time synchronization message relative to the master reference clock. The round-trip time indicates the total time delay between the local clock of the server corresponding to the time synchronization message and the master reference clock. The number of clock layers indicates the clock accuracy of the server corresponding to the time synchronization message. Clock accuracy indicates the accuracy of the local clock of the server corresponding to the time synchronization message. The number of communication paths indicates the number of nodes traversed during the transmission of the time synchronization message. Clock quality indicates the quality of the master reference clock of the server corresponding to the time synchronization message. Path delay distinguishes between peer-to-peer and non-peer-to-peer mechanisms.

[0076] As an example, a communication node can select the time synchronization parameter that has the greatest impact on the performance of time synchronization messages, and compare the quality of the same type of time synchronization parameters in multiple time synchronization messages to determine the priority order among multiple time synchronization messages.

[0077] As another example, communication nodes can assign weights to each time synchronization parameter, and then determine the overall weight of each time synchronization message based on each time synchronization parameter and its weight, thereby determining the priority order among multiple time synchronization messages. The higher the overall weight, the higher the priority of the time synchronization message.

[0078] In some embodiments, the communication node can also dynamically adjust the priority order among multiple time synchronization messages based on factors such as real-time monitored network conditions and network latency of time synchronization messages.

[0079] S103. Perform time synchronization operation based on the highest priority time synchronization message.

[0080] In some embodiments, the communication node can determine the highest priority time synchronization message from among the received time synchronization messages based on the priority order among multiple time synchronization messages. Then, based on data such as the timestamp and round-trip time delay in the highest priority time synchronization message, time synchronization and calibration are performed.

[0081] It is understood that the time synchronization method provided in this disclosure determines the priority between different time synchronization messages by using the time synchronization parameters corresponding to different time synchronization messages (i.e., different time synchronization protocols). This allows for a comprehensive comparison of the merits of different time synchronization messages, and the optimal time synchronization protocol is selected as the highest priority time synchronization protocol. Consequently, time synchronization operations are performed based on the highest priority time synchronization message, thereby improving the accuracy of time synchronization by communication nodes.

[0082] Furthermore, the method provided in this disclosure selects the highest priority time synchronization message from multiple time synchronization messages for time synchronization. This allows for rapid switching to the highest priority time synchronization message for time synchronization when network conditions change or a time synchronization message becomes unavailable. This enables dynamic selection of time synchronization messages, maintains the continuity and stability of network services, provides backup redundancy for time synchronization, improves the disaster recovery capability of communication nodes, and reduces network anomalies.

[0083] In some embodiments, the time synchronization parameters for each time synchronization message include the time at which the time synchronization message is received. Step S102 can be specifically implemented as follows: determining the priority order of multiple time synchronization messages based on the respective times at which they are received. The earlier the time synchronization message is received, the higher its priority.

[0084] In some embodiments, when a communication node receives multiple time synchronization messages through different network ports, it can record the time of receiving each time synchronization message and associate and store the time with the corresponding time synchronization message for subsequent priority sorting.

[0085] In some embodiments, during the initial stage, before the communication node begins receiving multiple time synchronization messages, the multiple time synchronization messages can be preset to have the same priority. When the communication node creates a thread and begins receiving multiple time synchronization messages through different network ports, the communication node can sort the received multiple time synchronization messages by time from smallest to largest, and adjust the priority of the message that the communication node receives first to be the highest.

[0086] It is understood that the method provided in this disclosure dynamically adjusts priorities based on the real-time received time synchronization messages, enabling rapid response to changes in network conditions. By simply comparing the reception times of time synchronization messages, complex algorithms or calculations are avoided, simplifying the decision-making process for selecting time synchronization messages. Furthermore, if a time synchronization message from a particular protocol always arrives first, it indicates that the time synchronization message (i.e., the time synchronization protocol corresponding to that message) may have lower network latency or higher transmission reliability, and can be used as a higher-priority time synchronization message. If a time synchronization message from a certain protocol cannot be received temporarily, the communication node can quickly switch to other available time synchronization messages, thereby maintaining the continuity of time synchronization and improving its fault tolerance.

[0087] In some embodiments, step S102 can be specifically implemented as: determining the priority order among multiple time synchronization messages based on the priority order among the time synchronization parameters of each of the multiple time synchronization messages.

[0088] For example, a communication node can pre-determine the priority order of time synchronization parameters based on actual needs or preset rules, and configure a priority value for each time synchronization parameter. The communication node determines the overall priority value of each time synchronization message based on the sum of the priority values ​​of all time synchronization parameters for each message. Then, the communication node sorts all time synchronization messages from high to low according to their overall priority values ​​to determine the priority order among multiple time synchronization messages. The higher the overall priority value, the earlier the time synchronization message appears in the priority order.

[0089] It is understood that the method provided in this disclosure determines the priority order of multiple time synchronization messages based on the priority order of their respective time synchronization parameters. This allows for a comprehensive comparison of the merits of different time synchronization messages, with the optimal time synchronization message being selected as the highest priority time synchronization message, thereby improving the accuracy of time synchronization by communication nodes.

[0090] In some embodiments, the multiple time synchronization messages include a first time synchronization message and a second time synchronization message. For example, the first time synchronization message may be a Network Time Protocol (NTP) message, and the second time synchronization message may be a Precision Time Protocol (PTP) message.

[0091] In some embodiments, determining the priority order among multiple time synchronization messages based on the priority order among their respective time synchronization parameters can be specifically implemented as follows: determining the priority order between the first time synchronization message and the second time synchronization message based on the priority order between the first time synchronization parameter and the second synchronization parameter.

[0092] The first time synchronization parameter is the time synchronization parameter corresponding to the first time synchronization message (e.g., NTP message). The second time synchronization parameter is the time synchronization parameter corresponding to the second time synchronization message (e.g., PTP message).

[0093] In some embodiments, the first time synchronization parameter includes at least one of the following: clock layer number (Stratum), first round-trip delay (Root Delay), time error (Root Dispersion), and clock precision (Precision).

[0094] The clock tier number indicates the clock accuracy of the NTP server. For example, a tier number of 1 indicates the highest clock accuracy. Clock tier numbers from 1 to 16 represent decreasing clock accuracy, with tier number 16 indicating that the NTP server's clock is out of sync and cannot be used as the master reference clock. The first round-trip time indicates the total round-trip time between the NTP server's local clock and its master reference clock. The time error indicates the maximum time error of the NTP server's local clock relative to its master reference clock. The clock accuracy indicates the precision of the NTP server's local clock.

[0095] In some embodiments, the second time synchronization parameters include at least one of the following: second round-trip time (offsetFromMaster), clock quality (grandmasterClockQuality), number of communication paths (stepsRemoved), and path delay (meanPathDelay). For example, the path delay can be 0.

[0096] The clock quality indicates the quality of the PTP server's master reference clock. The second round-trip time indicates the time difference between the PTP server's local clock and its master reference clock. The number of communication paths indicates the number of nodes the second time synchronization message passes through during transmission; for example, a path communication count of 1 indicates that the second time synchronization message has passed through one node during transmission. Path delay is used to distinguish whether the PTP server uses a peer-to-peer or non-peer-to-peer mechanism.

[0097] In some embodiments, the second round-trip time is determined as follows: After the local clock (also called slave clock) of the PTP server receives the Sync message, it generates a timestamp (syncEntIngressTimestamp). If the two-step verification flag (twoStepFlag) field of the Sync message is FALSE, indicating that the follow-up message cannot be received, the second round-trip time can be expressed as the following formula (1):

[0098] offsetFromMaster=(syncEventIngressTimestamp)-(originTimestamp)-

[0099] (meanPathDelay) formula (1)

[0100] Here, originTimestamp represents the originTimestamp field of the received Sync message.

[0101] If the twoStepFlag field of the Sync message is TRUE, indicating that a Follow Up message will be received, the second round-trip delay can be expressed as the following formula (2):

[0102] offsetFromMaster=(syncEventIngressTimestamp)-(originTimestamp)-

[0103] (preciseOriginTimestamp)-(meanPathDelay) formula (2)

[0104] Here, preciseOriginTimestamp represents the preciseOriginTimestamp field of the received Sync message.

[0105] As an example, a communication node can pre-determine the priority order between the first and second time synchronization parameters based on actual needs or preset rules, and configure a priority value for each first and second time synchronization parameter. The communication node determines the overall priority value of the first time synchronization message based on the sum of the priority values ​​of the first time synchronization parameters, and determines the overall priority value of the second time synchronization message based on the sum of the priorities of the second time synchronization parameters. Then, the communication node can determine the priority order between the first and second time synchronization messages based on the overall priority value. The higher the overall priority value, the higher the priority order of the time synchronization message.

[0106] It is understood that the method provided in this disclosure ensures that the most important synchronization parameters are processed first by assigning priorities to different time synchronization parameters. NTP and PTP protocols are designed for different application scenarios; NTP is more suitable for a wider range of network environments, while PTP provides higher time accuracy. By setting priorities for the key parameters of each protocol, factors that have the greatest impact on accuracy can be given priority, thus providing more accurate time synchronization. Furthermore, communication nodes can flexibly adjust the priority order of time synchronization parameters according to actual needs or preset rules to adapt to different network conditions and synchronization requirements, improving the accuracy of time synchronization operations.

[0107] As another example, after a communication node receives a first time synchronization message (e.g., an NTP message) within a configuration period, the priority comparison order for the first time synchronization parameters configured for the first time synchronization message is: first round-trip time delay, clock layer number, and time error. After a communication node receives a second time synchronization message (e.g., a PTP message) within the configuration period, the priority comparison order for the second time synchronization parameters is: second round-trip time delay, clock quality, and number of communication paths. Then, based on the priority comparison order of the first and second time synchronization parameters, the communication node compares the priority order of the first and second time synchronization parameters sequentially to determine the priority order between the first and second time synchronization messages.

[0108] It is understood that the method provided in this disclosure provides more granular and flexible time synchronization management for communication nodes by configuring a priority comparison order for the first time synchronization parameter and the second time synchronization parameter, thereby improving the accuracy of time synchronization operations.

[0109] In some embodiments, such as Figure 4 As shown, the priority order between the first time synchronization message and the second time synchronization message is determined based on the priority order between the first time synchronization parameter and the second synchronization parameter. Specifically, this can be implemented as follows: steps S201-S202.

[0110] S201. If the first round-trip delay and the second round-trip delay are equal, and the priority corresponding to the clock layer number and the priority corresponding to the clock quality are equal, determine the number of communication paths.

[0111] In some embodiments, the priority corresponding to the clock layer number and the priority corresponding to the message quality are determined based on the method in Table 1 below.

[0112] Table 1. Priority Comparison Table

[0113] Clock layer Clock quality Priority comparison results 1 (Highest Priority) 6 (Highest Priority) equal 2 7 equal 3-15 14 equal 16 (Unavailable) 52 or 255 (unavailable) equal

[0114] As shown in Table 1 above, the priority of each row in the table is the same. For example, if the clock layer number in the first time synchronization message is 1 and the clock quality in the second time synchronization message is 6, then the priority corresponding to the clock layer number and the priority corresponding to the clock quality are equal and belong to the same level.

[0115] In some embodiments, as shown in Table 1 above, when the clock layer number is 1 and the clock quality is 7, the priority corresponding to the clock layer number and the priority corresponding to the clock quality are not equal. In this case, the priority corresponding to the clock layer number is higher, and thus the priority of the first time synchronization message is higher than that of the second time synchronization message.

[0116] In some embodiments, as shown in Table 1 above, when the clock layer number is 16 and the clock quality is 52 or 255, although the priority corresponding to the clock layer number and the priority corresponding to the clock quality are equal, the first time synchronization message and the second time synchronization message are unavailable under these values. At this time, the communication node will discard the first time synchronization message and the second time synchronization message, and re-acquire the new first time synchronization message and the new second time synchronization message in the sliding queue, respectively.

[0117] S202. Based on the relationship between the number of communication paths and the preset path threshold, determine the priority order between the first time synchronization message and the second time synchronization message.

[0118] In some embodiments, when the number of communication paths exceeds a preset path threshold, the priority of the first time synchronization message is higher than that of the second time synchronization message. When the number of communication paths is less than or equal to the preset path threshold, the priority of the second time synchronization message is higher than that of the first time synchronization message. For example, the preset path threshold can be 4.

[0119] It is understandable that round-trip time (RTT) is a direct indicator of network latency, and the number of clock layers and clock quality affect the accuracy and reliability of time synchronization. The method provided in this disclosure first considers whether the first RTT and the second RTT are equal, and prioritizes whether the priority corresponding to the number of clock layers and the priority corresponding to clock quality are equal. This can quickly determine the performance differences between different time synchronization messages, ensuring that the synchronization source corresponding to the selected time synchronization message is optimal in both structure and performance.

[0120] Furthermore, the larger the number of communication paths, the more communication nodes the time synchronization message traverses in the network, resulting in longer transmission times and potentially lower message quality. The method provided in this disclosure determines the number of communication paths when the first round-trip time and the second round-trip time are equal, and the priorities corresponding to clock layer number and clock quality are equal. Based on the relationship between the number of communication paths and a preset path threshold, it determines the priority order between the first and second time synchronization messages. This balances the relationship between the number of communication paths and time synchronization quality, selects synchronization messages with sufficient communication paths, reduces the risk of synchronization interruptions due to network node failures, and improves the system's fault tolerance.

[0121] Furthermore, when multiple key parameters are equal, the number of communication paths provides another dimension of decision-making, increasing the flexibility and adaptability of time synchronization. Moreover, although increasing the number of communication paths may affect the quality of time synchronization, embodiments of this disclosure can ensure that the optimal synchronization message is selected while meeting quality requirements by setting a reasonable preset path threshold, thereby improving the accuracy of time synchronization operations performed by communication nodes.

[0122] In some embodiments, determining the priority order between the first time synchronization message and the second time synchronization message based on the priority order between the first time synchronization parameter and the second synchronization parameter can be specifically implemented as follows: when the first round-trip delay and the second round-trip delay are not equal, and / or when the priority corresponding to the clock layer number and the priority corresponding to the clock quality are not equal, the priority between the first time synchronization message and the second time synchronization message is determined based on the message quality of the first time synchronization message and the message quality of the second time synchronization message.

[0123] For example, a communication node can analyze the first time synchronization message and the second time synchronization message based on factors such as stability, signal strength, and packet loss rate, and comprehensively evaluate the message quality of the first time synchronization message and the message quality of the second time synchronization message.

[0124] It is understood that, when multiple key parameters are not equal, the method provided in this disclosure determines the priority based on the primary factor of the message quality of the first time synchronization message and the message quality of the second time synchronization message, which can ensure that the time synchronization message with the highest quality is selected, thereby improving the accuracy and reliability of time synchronization.

[0125] In some embodiments, the first round-trip time is the average of the latency data of multiple first time synchronization messages within a preset configuration period. The second round-trip time is the average of the latency data of multiple second time synchronization messages within a preset configuration period.

[0126] In this scenario, the latency data of multiple first-time synchronization messages are all less than a preset latency threshold, and the latency data of multiple second-time synchronization messages are all less than a preset latency threshold. For example, the preset latency threshold can be 10ms.

[0127] In some embodiments, after a communication node listens to a first time synchronization message (e.g., an NTP message) via a thread, it parses the data in the first time synchronization message to obtain a set of latency data for the first time synchronization message. For example, each set of latency data can be stored in the form of a structure. Then, the communication node stores the latency data received within a preset configuration period into a sliding queue, thereby determining the first round-trip latency. For example, Figure 5 This is a schematic diagram of a sliding queue. Figure 5 As shown, ten sets of delay data d1 to d10 enter from the left side of the sliding queue and are stored in the sliding queue sequentially. Delay data d11 waits to enter the sliding queue after delay data d10, and delay data d1 waits to leave the sliding queue. Based on the ten sets of delay data in the first time synchronization message in the sliding queue, the communication node filters out delay data exceeding a preset delay threshold from the ten sets of delay data, and then averages the remaining delay data to obtain the average delay (i.e., the first round-trip delay) within a preset configuration period.

[0128] For example, Figure 6 This is a diagram illustrating data filtering. For example... Figure 6 As shown, if the preset delay threshold is 10ms, the values ​​of the ten sets of delay data for the first synchronization message are as follows: d1 = 5ms, d2 = 62ms, d3 = 3ms, d4 = 102ms, d5 = 5ms, d6 = 7ms, d7 = 4.5ms, d8 = 6ms, d9 = 8ms, d10 = 3.2ms. Among these, the values ​​of d2 and d4 are greater than the preset delay threshold. Therefore, these two outlier values ​​should be filtered out. Then, the first round-trip delay is determined based on the average of the eight sets of delay data (d1, d3, and d5-d10).

[0129] In some embodiments, the method for determining the second round-trip time delay may refer to the method for determining the first round-trip time delay described above, and will not be repeated here.

[0130] It is understood that the method provided in this disclosure can reduce abnormal measurement values ​​caused by network jitter, congestion or other temporary problems by filtering out latency data that exceeds a preset latency threshold, thereby improving the accuracy of priority comparison of different time synchronization messages and ensuring the reliability of time synchronization.

[0131] In some embodiments, such as Figure 7As shown, the above step S103 can be specifically implemented as: steps S1031-S1032.

[0132] S1031. Determine the error value of the time synchronization parameters in the highest priority time synchronization message.

[0133] In some embodiments, if the highest priority time synchronization message is the first time synchronization message (e.g., an NTP message), then the error value of the time synchronization parameter in the first time synchronization message is the aforementioned first round-trip delay. For example, if within a preset configuration period, m sets of delay data in the first round-trip delay of the first time synchronization message are normal values ​​(i.e., m sets of average data are less than the preset delay threshold), then within the preset configuration period, the average value of the delay data of multiple first time synchronization messages (i.e., the average value of the first round-trip delay) ntpDelay can be expressed as the following formula (3):

[0134]

[0135] Similarly, if the highest priority time synchronization message is the second time synchronization message (e.g., PTP message), then the error value of the time synchronization parameter in the second time synchronization message is the aforementioned second round-trip delay. For example, if within a preset configuration period, there are n sets of delay data in the second round-trip delay of the second time synchronization message (e.g., PTP message) that are normal values ​​(i.e., there are n sets of average data that are less than the preset delay threshold), then within the preset configuration period, the average value of the delay data of multiple second time synchronization messages, ptpDelay, can be expressed as the following formula (4):

[0136]

[0137] S1032. Perform time synchronization operation based on time synchronization parameters and error values.

[0138] In some embodiments, the time synchronization parameter further includes: message precision. As an example, referring to the method for determining the first round-trip delay described above, if the time synchronization message with the highest priority is the first time synchronization message (e.g., an NTP message), and within a preset configuration period, there are q sets of data with normal precision in the first time synchronization message (i.e., not exceeding the preset precision range), then the actual value of the first time synchronization message (i.e., the average value of the message precision of the first time synchronization message), ntpPrecision, can be expressed as the following formula (5):

[0139]

[0140] At this time, the precise time ntpTime of the first synchronization message can be expressed as the following formula (6):

[0141] ntpTime=ntpPrecision+ntpDelay+Δt Formula (6)

[0142] Where Δt represents the time it takes for the communication node to determine the error value of the time synchronization parameter in the highest priority time synchronization message.

[0143] Once the precise time of the first synchronization message is determined, the communication nodes can perform time synchronization operations based on the precise time of the first synchronization message.

[0144] As another example, referring to the method for determining the first round-trip delay described above, if the highest priority time synchronization message is the second time synchronization message (e.g., a PTP message), and within the preset configuration period, P sets of data in the second time synchronization message have normal values ​​(i.e., do not exceed the preset precision range), then the error value of the time synchronization parameter in the second time synchronization message (i.e., the error value of the second time synchronization parameter) is...

[0145] The mean precision of the step message (ptpPrecision) can be expressed as the following formula (7):

[0146]

[0147] At this point, the precise time ptpTime of the second time synchronization message can be expressed as the following formula (8):

[0148] ptpTime=ptpPrecision+ptpDelay+Δt Formula (8)

[0149] After determining the precise time of the second time synchronization message, the communication nodes can perform time synchronization operations based on the precise time of the second time synchronization message.

[0150] It is understood that the method provided in this disclosure improves the accuracy of time synchronization by calibrating the time synchronization parameters in the time synchronization message to correct deviations introduced by factors such as network latency, hardware performance limitations, or measurement errors. By calibrating the time synchronization parameters, it is ensured that time synchronization maintains high reliability even under suboptimal network conditions or interference.

[0151] In some embodiments, the above method further includes: issuing an alarm message if no time synchronization message is received within a preset time threshold.

[0152] For example, if a communication node does not receive the first synchronization message within a preset time threshold,

[0153] Alternatively, if no second time synchronization message is received within a preset time threshold, an alarm message will be issued.

[0154] As an example, based on a preset configuration period, if a communication node does not receive a first-time synchronization message (e.g., an NTP message) within a preset configuration period, the priority of the second-time synchronization message (e.g., a PTP message) is adjusted to the highest. If the communication node does not receive a first-time synchronization message for three consecutive preset configuration periods, an alarm message is issued, reporting an anomaly in the first-time synchronization message. Then, the communication node will attempt to receive the first-time synchronization message three more times based on a new period of preset configuration period * 2. If the first-time synchronization message is received in all three new periods, the communication node determines that the first-time synchronization message is normal. At this point, the communication node cancels the alarm and continues to listen for first-time synchronization messages based on the preset configuration period.

[0155] If the communication node still fails to receive the first-time synchronization message within three new cycles, the communication node will listen for the first-time synchronization message at one-hour intervals. If the communication node can receive the first-time synchronization message normally for three consecutive hours, the communication node will cancel the alarm and listen for the first-time synchronization message according to the preset configuration cycle.

[0156] As another example, if a communication node does not receive a second time synchronization message (e.g., a PTP message) within a preset configuration period, it will adjust the priority of the first time synchronization message (e.g., an NTP message) to the highest. If the communication node does not receive a second time synchronization message for three consecutive preset configuration periods, it will issue an alarm message to report the anomaly of the second time synchronization message. Then, the communication node will attempt to receive the second time synchronization message three more times based on a new period of preset configuration period * 2. If it receives the second time synchronization message in all three new periods, the communication node will determine that the second time synchronization message is normal. At this point, the communication node will cancel the alarm and continue to listen for the second time synchronization message based on the preset configuration period.

[0157] If the communication node still fails to receive the second time synchronization message within three new cycles, the communication node will listen for the second time synchronization message at one-hour intervals. If the communication node can receive the second time synchronization message normally for three consecutive hours, the communication node will cancel the alarm and listen for the second time synchronization message according to the preset configuration cycle.

[0158] It should be noted that the above example is only one way for the communication node to handle the situation when it determines that the reception of the first time synchronization message or the second time synchronization message is abnormal in the embodiments of this disclosure. In actual implementation, the communication node can choose different processing methods based on actual needs, and the embodiments of this disclosure do not limit this.

[0159] It is understood that the method provided in this disclosure can quickly identify the loss or delay of time synchronization messages when no first time synchronization message is received within a preset time threshold, or when no second time synchronization message is received within a preset time threshold, and then issue an alarm message. This allows communication nodes to monitor the reception of different time synchronization messages in real time, thereby improving the stability of time synchronization.

[0160] It is understood that the method provided in this disclosure, by parsing multiple time synchronization messages (e.g., NTP messages and PTP messages), comparing the time synchronization parameters of different time synchronization messages, calibrating the time synchronization parameters for errors, and issuing alarm information and performing anomaly maintenance when time synchronization message reception is abnormal, enables communication nodes to dynamically select the optimal time synchronization message among multiple time synchronization messages (i.e., multiple time synchronization protocols) and perform time synchronization operations (e.g., implement clock synchronization and time synchronization functions). This provides communication nodes with more choices and backup redundancy when performing time synchronization operations, reducing network anomalies and equipment failures caused by time asynchrony.

[0161] For ease of understanding, the time synchronization method of this disclosure embodiment will be further described below with examples.

[0162] Example 1: Taking an NTP message as the first time synchronization message and a PTP message as the second time synchronization message as an example, this illustrates the time synchronization method provided in this embodiment. Figure 8 As shown, the method includes the following steps:

[0163] Step Sa1: Configure the parameters required for time synchronization operation.

[0164] Step Sa2: Periodically listen for messages.

[0165] Step Sa3: Determine whether the message is a time synchronization message; if yes, proceed to step Sa4; if no, proceed to step Sa2.

[0166] Step Sa4: Determine whether the time synchronization message type is a PTP message; if yes, proceed to step Sa5; if no, proceed to step Sa6.

[0167] Step Sa5: parse the Announce and Sync messages in the PTP message.

[0168] Step Sa6: Parse NTP packets.

[0169] Step Sa7: Determine the time synchronization message with the highest priority.

[0170] Step Sa8: Perform error calibration on the highest priority time synchronization message.

[0171] Step Sa9: Perform time synchronization.

[0172] Step Sa10: Determine whether the parameters required for time synchronization are configured; if yes, proceed to step Sa11; if no, proceed to step Sa12.

[0173] Step Sa11: Determine if the time synchronization message is being received normally; if yes, proceed to step Sa2; if no, proceed to step Sa12.

[0174] Step Sa12: End, stop listening to messages.

[0175] As can be seen from Example 1 above, after configuring the parameters required for time synchronization, devices with time synchronization needs periodically listen to NTP and PTP packets according to the configured parameters. Upon receiving time synchronization packets, they parse them based on different packet types. Specifically, they parse the Announce and Sync packets in the PTP packets to obtain time synchronization parameters such as the number of communication paths, clock quality, time error, and path delay. They parse the NTP packets to obtain time synchronization parameters such as time error, first round-trip time, and clock layer number. Through the processing and scheduling of these time synchronization parameters, the optimal time synchronization parameters for time synchronization operations can be determined. Then, devices with time synchronization needs can combine error calibration data to finally update the device's time. Furthermore, when received packets are abnormal or the parameters required for time synchronization operations are deleted, packet listening can be stopped.

[0176] It is understood that the method provided in this disclosure, when there are multiple types of time synchronization messages in the network (e.g., broadcast synchronization messages corresponding to different time synchronization protocols), selects the optimal time synchronization message for time synchronization operation. This method can be applied to network devices with high time accuracy requirements, such as industrial internet networks and wireless base station networks, thereby improving the accuracy of time synchronization.

[0177] Example 2: Taking an NTP message as the first time synchronization message and a PTP message as the second time synchronization message as an example, this illustrates how the time synchronization method provided in this embodiment determines the priority of the time synchronization messages. Figure 9 As shown, the method includes the following steps:

[0178] Step Sb1: Request data to be stored in the sliding queue.

[0179] Step Sb2: Read the data in the sliding queue based on the preset configuration period.

[0180] Step Sb3: Determine the first round-trip delay and the second round-trip delay.

[0181] Step Sb4: Determine whether the first round-trip delay and the second round-trip delay are equal; if yes, proceed to step Sb5; if no, proceed to step Sb9.

[0182] Step Sb5: Determine whether the priority corresponding to the clock layer number and the priority corresponding to the clock quality are equal; if yes, proceed to step Sb6; if no, proceed to step Sb9.

[0183] Step Sb6: Determine if NTP and PTP packets are available; if yes, proceed to step Sb7; if no, proceed to step Sb11.

[0184] Step Sb7: Determine if the number of communication paths is greater than 4; if yes, proceed to step Sb8; if no, proceed to step Sb10.

[0185] Step Sb8: Adjust the priority of NTP packets to the highest and execute step Sb12.

[0186] Step Sb9: In the NTP and PTP packets, adjust the priority of the time synchronization packet with the highest packet quality to the highest and execute step Sb12.

[0187] Step Sb10: Adjust the priority of the PTP message to the highest and execute step Sb12.

[0188] Step Sb11: Discard the first and second time synchronization messages.

[0189] Step Sb12: Clear the data in the sliding queue and initialize the memory of the sliding queue, then execute step Sb2.

[0190] Example 3: Taking the first time synchronization message as an NTP message and the second time synchronization message as a PTP message as an example, this illustrates the handling method for abnormal reception of time synchronization messages in the time synchronization method provided in this embodiment of the disclosure. Figure 10 As shown, the method includes the following steps:

[0191] Step Sc1: Listen for time synchronization messages.

[0192] Step Sc2: Determine that NTP packets cannot be received.

[0193] Step Sc3: Set the priority of PTP packets to the highest.

[0194] Step Sc4: Determine whether no NTP message has been received for more than three preset configuration periods; if yes, proceed to step Sc5; if no, proceed to step Sc1.

[0195] Step Sc5: Report the abnormal alarm and continue to monitor NTP packets based on a new period of 2 times the preset configuration period.

[0196] Step Sc6: Determine if no NTP message has been received for more than three new cycles; if yes, proceed to step Sc7; if no, proceed to step Sc9.

[0197] Step Sc7: Listen for NTP packets every hour.

[0198] Step Sc8: Determine if no NTP packets have been received for three consecutive hours; if yes, proceed to step Sc7; if no, proceed to step Sc9.

[0199] Step Sc9: NTP message reception is normal. Alarm cleared and step Sc1 executed.

[0200] The foregoing primarily describes the solutions of the embodiments of this disclosure from a methodological perspective. It is understood that, in order to achieve the aforementioned functions, the time synchronization device includes at least one of the hardware structures and software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, the embodiments of this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure.

[0201] It is understood that, in order to achieve the above-mentioned functions, the time synchronization device includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should readily recognize that, based on the algorithmic steps of the examples described in conjunction with the embodiments of this disclosure, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0202] This disclosure embodiment can divide the time synchronization device into functional modules according to the above method embodiment. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one functional module. The integrated module can be implemented in hardware or software. It should be noted that the module division in this disclosure embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. The following description uses the example of dividing each function into a separate functional module.

[0203] Figure 11 This is a schematic diagram of a time synchronization device provided in an embodiment of this disclosure, which can execute the time synchronization method provided in the above-described method embodiments. Figure 11 As shown, the time synchronization device 200 includes: a receiving module 201, a determining module 202, a synchronization module 203, and an alarm module 204.

[0204] The receiving module 201 is used to receive multiple time synchronization messages;

[0205] The determination module 202 is used to determine the priority order among multiple time synchronization messages based on their respective time synchronization parameters.

[0206] Synchronization module 203 is used to perform time synchronization operations based on the highest priority time synchronization message.

[0207] In some embodiments, the determining module 202 is specifically used to determine the priority order among multiple time synchronization messages based on the priority order among the time synchronization parameters of each of the multiple time synchronization messages.

[0208] In some embodiments, the multiple time synchronization messages include a first time synchronization message and a second time synchronization message; the determining module 202 is specifically used to determine the priority order between the first time synchronization message and the second time synchronization message based on the priority order between the first time synchronization parameter and the second synchronization parameter; the first time synchronization parameter is the time synchronization parameter corresponding to the first time synchronization message; the second time synchronization parameter is the time synchronization parameter corresponding to the second time synchronization message.

[0209] In some embodiments, the first time synchronization message is a Network Time Protocol (NTP) message, and the first time synchronization parameters include at least one of the following: clock layer number, first round-trip time delay, and time error; the clock layer number is used to indicate the clock accuracy of the NTP server; the first round-trip time delay is used to indicate the total round-trip time between the local clock of the NTP server and the master reference clock of the NTP server; and the time error is used to indicate the maximum time error of the local clock of the NTP server relative to the master reference clock of the NTP server.

[0210] In some embodiments, the second time synchronization message is a Precision Time Protocol (PTP) message, and the second time synchronization parameters include at least one of the following: second round-trip time, clock quality, and number of communication paths; clock quality is used to indicate the quality of the PTP server's master reference clock; second round-trip time is used to indicate the time difference between the PTP server's local clock and the PTP server's master reference clock; and the number of communication paths is used to indicate the number of nodes the second time synchronization message passes through during transmission.

[0211] In some embodiments, the determining module 202 is specifically used to determine the number of communication paths when the first round-trip delay and the second round-trip delay are equal and the priority corresponding to the clock layer number and the priority corresponding to the clock quality are equal; and to determine the priority order between the first time synchronization message and the second time synchronization message based on the relationship between the number of communication paths and the preset path threshold.

[0212] In some embodiments, the determining module 202 is specifically configured to determine the priority between the first time synchronization message and the second time synchronization message based on the message quality of the first time synchronization message and the message quality of the second time synchronization message when the first round-trip delay and the second round-trip delay are not equal, and / or when the priority corresponding to the clock layer number and the priority corresponding to the clock quality are not equal.

[0213] In some embodiments, the first round-trip time is the average of the latency data of multiple first time synchronization messages within a preset configuration period; the second round-trip time is the average of the latency data of multiple second time synchronization messages within a preset configuration period; the latency data of multiple first time synchronization messages are all greater than a preset latency threshold; and the latency data of multiple second time synchronization messages are all greater than the preset latency threshold.

[0214] In some embodiments, the time synchronization parameters of each time synchronization message include: the time when the time synchronization message is received; the determining module 202 is specifically used to determine the priority order among the multiple time synchronization messages based on the respective times when the multiple time synchronization messages are received; the earlier the time synchronization message is received, the higher the priority of the time synchronization message.

[0215] In some embodiments, the synchronization module 203 is specifically used to determine the error value of the time synchronization parameter in the highest priority time synchronization message; and to perform time synchronization operation based on the time synchronization parameter and the error value.

[0216] In some embodiments, the alarm module 204 is used to issue an alarm message if no time synchronization message is received within a preset time threshold.

[0217] When the functions of the integrated modules described above are implemented in hardware, this disclosure provides a possible structure for the electronic device involved in the above embodiments. For example... Figure 12 As shown, the electronic device 300 includes: a processor 302 and a bus 304. Optionally, the electronic device 300 may also include a memory 301; optionally, the electronic device 300 may also include a communication interface 303.

[0218] Processor 302 may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with embodiments of this disclosure. Processor 302 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with embodiments of this disclosure. Processor 302 may also be a combination of functions implementing computational capabilities, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0219] Communication interface 303 is used to connect to other devices via a communication network. This communication network can be Ethernet, wireless access network, wireless local area network (WLAN), etc.

[0220] The memory 301 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0221] As one possible implementation, the memory 301 can exist independently of the processor 302. The memory 301 can be connected to the processor 302 via a bus 304 and is used to store instructions or program code. When the processor 302 calls and executes the instructions or program code stored in the memory 301, it can implement the time synchronization method provided in the embodiments of this disclosure.

[0222] In another possible implementation, the memory 301 can also be integrated with the processor 302.

[0223] Bus 304 can be an extended industry standard architecture (EISA) bus, etc. Bus 304 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0224] Some embodiments of this disclosure provide a computer-readable storage medium (e.g., a non-transitory computer-readable storage medium) storing computer program instructions that, when executed on a computer, cause the computer to perform a time synchronization method as described in any of the above embodiments.

[0225] Exemplary examples of computer-readable storage media may include, but are not limited to: magnetic storage devices (e.g., hard disks, floppy disks, or magnetic tapes), optical discs (e.g., compact disks (CDs), digital versatile disks (DVDs), etc.), smart cards, and flash memory devices (e.g., erasable programmable read-only memory (EPROMs), cards, sticks, or key drives, etc.). The various computer-readable storage media described in this disclosure may represent one or more devices and / or other machine-readable storage media for storing information. The term "machine-readable storage medium" may include, but is not limited to, wireless channels and various other media capable of storing, containing, and / or carrying instructions and / or data.

[0226] This disclosure provides a computer program product containing instructions that, when run on a computer, cause the computer to execute any of the time synchronization methods described above.

[0227] The above are merely specific embodiments of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any changes or substitutions within the technical scope disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A time synchronization method, characterized in that, The method includes: Receive multiple time synchronization messages; Based on the time synchronization parameters of each of the multiple time synchronization messages, the priority order among the multiple time synchronization messages is determined; Time synchronization is performed based on the highest priority time synchronization message.

2. The method according to claim 1, characterized in that, Determining the priority order among the multiple time synchronization messages based on their respective time synchronization parameters includes: The priority order among the multiple time synchronization messages is determined based on the priority order among their respective time synchronization parameters.

3. The method according to claim 2, characterized in that, The plurality of time synchronization messages include a first time synchronization message and a second time synchronization message; Determining the priority order among the multiple time synchronization messages based on the priority order among their respective time synchronization parameters includes: The priority order between the first time synchronization parameter and the second time synchronization parameter is determined based on the priority order between the first time synchronization parameter and the second time synchronization parameter; the first time synchronization parameter is the time synchronization parameter corresponding to the first time synchronization parameter; the second time synchronization parameter is the time synchronization parameter corresponding to the second time synchronization parameter.

4. The method according to claim 3, characterized in that, The first time synchronization message is a Network Time Protocol (NTP) message, and the first time synchronization parameters include at least one of the following: clock layer number, first round-trip time, and time error; The clock layer number is used to indicate the clock accuracy of the NTP server; the first round-trip delay is used to indicate the total round-trip delay between the local clock of the NTP server and the master reference clock of the NTP server. The time error is used to indicate the maximum time error of the local clock of the NTP server relative to the master reference clock of the NTP server.

5. The method according to claim 4, characterized in that, The second time synchronization message is a Precision Time Protocol (PTP) message, and the second time synchronization parameters include at least one of the following: second round-trip time, clock quality, and number of communication paths; The clock quality is used to indicate the quality of the PTP server's master reference clock; the second round-trip delay is used to indicate the time difference between the PTP server's local clock and the PTP server's master reference clock. The number of communication paths is used to indicate the number of nodes that the second time synchronization message passes through during transmission.

6. The method according to claim 5, characterized in that, Determining the priority order between the first time synchronization message and the second time synchronization message based on the priority order between the first time synchronization parameter and the second time synchronization parameter includes: The number of communication paths is determined when the first round-trip delay and the second round-trip delay are equal and the priority corresponding to the clock layer number is equal to the priority corresponding to the clock quality. Based on the relationship between the number of communication paths and the preset path threshold, the priority order between the first time synchronization message and the second time synchronization message is determined.

7. The method according to claim 5, characterized in that, The step of determining the priority order between the first time synchronization message and the second time synchronization message based on the priority order between the first time synchronization parameter and the second time synchronization parameter further includes: If the first round-trip time and the second round-trip time are not equal, and / or if the priority corresponding to the clock layer number and the priority corresponding to the clock quality are not equal, the priority between the first time synchronization message and the second time synchronization message is determined based on the message quality of the first time synchronization message and the message quality of the second time synchronization message.

8. The method according to claim 5, characterized in that, The first round-trip time is the average of the latency data of multiple first time synchronization messages within a preset configuration period; the second round-trip time is the average of the latency data of multiple second time synchronization messages within the preset configuration period; the latency data of the multiple first time synchronization messages is greater than a preset latency threshold; the latency data of the multiple second time synchronization messages is greater than the preset latency threshold.

9. The method according to claim 1, characterized in that, The time synchronization parameters for each time synchronization message include: the time when the time synchronization message is received; Determining the priority order among the multiple time synchronization messages based on their respective time synchronization parameters includes: The priority order of the multiple time synchronization messages is determined based on the time when each message is received; the earlier the time synchronization message is received, the higher its priority.

10. The method according to claim 1, characterized in that, The time synchronization operation based on the highest priority time synchronization message includes: Determine the error value of the time synchronization parameter in the highest priority time synchronization message; The time synchronization operation is performed based on the time synchronization parameters and the error value.

11. The method according to claim 1, characterized in that, The method further includes: If the time synchronization message is not received within a preset time threshold, an alarm message will be issued.

12. An electronic device, characterized in that, include: A processor and a memory for storing processor-executable instructions; The processor is configured to execute the instructions, causing the electronic device to perform the method as described in any one of claims 1-11.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-11.

14. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-11.