Clock path switching method and device based on PTP clock redundant path

By obtaining health status information in the PTP clock redundancy path, preemptive switching is avoided, the problem of clock jitter during fault recovery is solved, and the stability and continuity of time synchronization are achieved.

CN121809369APending Publication Date: 2026-04-07SHANGHAI DONGTU ZHIYUAN INTELLIGENT TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-25
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In existing technologies, the PTP clock redundancy path experiences clock jitter during the fault recovery period due to preemptive switching, affecting the stability and smoothness of time synchronization.

Method used

A clock path switching method based on PTP clock redundancy is adopted. By obtaining the health status information of the primary path and the backup path, when the primary path has recovered from a fault and the GM clock has been locked, the backup path will only continue to be used as the working path if the backup path meets the preset health requirements, thus avoiding preemptive switching.

Benefits of technology

It effectively prevents clock jitter caused by preemptive switching during fault recovery, ensuring the continuity and stability of time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121809369A_ABST
    Figure CN121809369A_ABST
Patent Text Reader

Abstract

The invention provides a clock path switching method and device based on a PTP clock redundant path, and the method comprises the steps: a master clock GM is connected with a plurality of transparent clocks, a slave clock SLAVE is connected with all clocks connected with the GM at the same time, a path where a BC3 is located is a master path, a path where a BC2 is located is a standby path, the master path and the standby path form a redundant path group, and the redundant path group is connected with the slave clock SLAVE; after a main path breaks down, the SLAVE is synchronized with the GM through the BC2, a standby path where the BC2 is located is switched into a working path, and the method comprises the steps that the SLAVE obtains health state information of the main path and the standby path, and under the condition that the SLAVE determines that the main path is recovered from a fault state according to the health state information of the main path and a GM clock is locked, the SLAVE is switched into the working path. If it is determined that the health state information of the standby path meets the preset health requirement, the standby path continues to serve as the working path, and switching does not occur. According to the invention, the problem of clock jitter caused by preemptive switching in the fault recovery period in the related art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of high-precision time synchronization technology, and in particular to a clock path switching method and apparatus based on PTP clock redundancy path. Background Technology

[0002] Currently, the PTP (IEEE 1588) protocol is widely used in fields with extremely high time synchronization accuracy requirements, such as industrial automation, power systems, and telecommunications. To improve reliability, network architectures typically employ a redundant design, where slave clocks are connected to the same optimal master clock (Grandmaster, GM) via multiple paths.

[0003] Currently, the standard path selection mechanism is BMCA (Best Master Clock Algorithm). BMCA dynamically selects the best master clock and the best timing path by comparing clock quality information (such as priority, clock class, clock accuracy, time source, offset, etc.) in Announce messages received from different ports.

[0004] However, BMCA is essentially a preemptive switching mechanism. For example... Figure 1 Taking the example of GM connecting two transparent clocks BC2 and BC3, the SLAVE connects to both BC2 and BC3 simultaneously. Under normal circumstances, BMCA selects BC3, which has the best clock quality, as the optimal path. The SLAVE synchronizes with GM through BC3. When the upstream link between BC3 and GM fails, the clock quality of BC3 drops sharply (because it cannot synchronize with GM). The SLAVE detects this change through BMCA and automatically switches the timing path to BC2. This switching mechanism has the following inherent flaws: Once the faulty link between BC3 and GM is restored, BC3 will resume receiving high-quality Announce messages from GM. BMCA will immediately determine that BC3's clock quality is superior to the currently used BC2, and will therefore immediately and preemptively force a switch back to BC3 for the timing path. However, at this time, BC3's local PTP clock servo loop may not yet be fully locked to the GM clock, and its output PTP time signal may have a large phase error or be unstable. When SLAVE switches to BC3 at this time, it will use this unstable PTP clock signal as a reference source, causing a significant phase jitter or jump in SLAVE's local clock, disrupting the smoothness and stability of time synchronization.

[0005] Therefore, the relevant technology suffers from clock jitter caused by preemptive switching during the fault recovery period. Summary of the Invention

[0006] This application provides a clock path switching method and apparatus based on PTP clock redundancy path, so as to at least solve the problem of clock jitter caused by preemptive switching during the fault recovery period in related technologies.

[0007] According to one aspect of the embodiments of this application, a clock path switching method based on PTP clock redundancy path is provided. A master clock GM connects to multiple transparent clocks, and a slave clock SLAVE simultaneously connects to all clocks connected to GM. The path where BC3 is located is the master path, and the path where BC2 is located is the backup path. The master path and the backup path form a redundancy path group. After the master path fails, the SLAVE synchronizes with GM through BC2, and the backup path where BC2 is located switches to the working path. The method includes: SLAVE obtains the health status information of the primary path and the backup path. If the SLAVE determines that the primary path has recovered from a fault state and the GM clock has been locked based on the health status information of the primary path, and if it determines that the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

[0008] Optionally, as described above, the method further includes: If, based on the health status information of the primary path, SLAVE determines that the primary path has recovered from a fault state and the GM clock has been locked, and if it determines that the health status information of the backup path does not meet the preset health requirements, SLAVE will switch the primary path to the working path.

[0009] Optionally, as described above, the health status information of the backup path meets preset health requirements, including: Based on the health status information of the backup path, determine the first historical moment when the current port on the backup path last acquired the target packet, wherein the current port is the main port currently used to publish the PTP time signal; If the time elapsed between the first historical moment and the current moment is less than or equal to a preset time limit, and the master clock identifier in the target message is consistent with the clock identifier, then the health status information of the backup path is determined to meet the preset health requirements.

[0010] Optionally, as described above, before obtaining the health status information of each path in the primary path and backup paths, the method further includes: Obtain the port information of each port and the master clock identifier of the GM connected to each port, wherein each port in the same redundant path group is used to connect to the same GM, each port is located on a slave clock and is used to listen to the PTP time signal of the connected GM through the corresponding path; The port information of the port corresponding to the main path and the master clock identifier are determined as the path identifier of the main path; the port information of the port corresponding to the backup path and the master clock identifier are determined as the path identifier of the backup path. The status field of each port is identified according to the health status information of each port; The step of obtaining the health status information of the primary path and the backup path includes: obtaining the health status information of each port based on the identifier in the status field of each port, and determining the health status information of each path according to the health status information of each port.

[0011] Optionally, as described above, after determining that the main path has recovered from a fault state based on the health status information of the main path and that the GM clock has been locked, the method further includes: The main path is selected as a candidate available path.

[0012] Optionally, as described above, after obtaining the health status information of the primary path and the backup path, the method further includes: If the health status information of the backup path does not meet the preset health requirements, the target available path with the best clock quality is selected from all available paths in the redundant path group as the working path.

[0013] According to another aspect of the embodiments of this application, a clock path switching device based on PTP clock redundancy path is also provided, applied to SLAVE. The master clock GM is connected to multiple transparent clocks, and the slave clock SLAVE is simultaneously connected to all clocks connected to GM. The path where BC3 is located is the master path, and the path where BC2 is located is the backup path. The master path and the backup path form a redundancy path group. After the master path fails, the SLAVE synchronizes with GM through BC2, and the backup path where BC2 is located switches to the working path. The device includes: The path health detection module is used to obtain the health status information of the main path and the backup path; The determination module is used to determine that, if the main path has recovered from a fault state and the GM clock has been locked based on the health status information of the main path, and if the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

[0014] Optionally, in the aforementioned apparatus, the determining module includes: The time acquisition unit is used to determine the first historical time when the current port on the backup path last acquired the target packet based on the health status information of the backup path, wherein the current port is the main port currently used to publish the PTP time signal; The determining unit is configured to determine that the health status information of the backup path meets the preset health requirements when the time elapsed between the first historical time and the current time is less than or equal to a preset time limit and the master clock identifier in the target message is consistent with the clock identifier.

[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used to store a computer program; and the processor is used to execute the method steps of any of the above embodiments by running the computer program stored in the memory.

[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the method steps of any of the above embodiments when running.

[0017] In this embodiment, a master clock (GM) connects to multiple transparent clocks, and a slave clock (SLAVE) simultaneously connects to all clocks connected to the GM. The path containing BC3 is the primary path, and the path containing BC2 is the backup path. The primary path and the backup path form a redundant path group. If the primary path fails, the SLAVE synchronizes with the GM via BC2, and the backup path containing BC2 switches to the working path. The method includes: the SLAVE acquiring the health status information of the primary path and the backup path. When SLAVE determines that the main path has recovered from a fault state and has locked the GM clock based on the health status information of the main path, if it determines that the health status information of the backup path meets the preset health requirements, it continues to use the backup path as the working path without switching. By ensuring that the health status information of the current path meets the preset health requirements, even if the main path with the highest clock quality has locked the GM clock, it does not use a preemptive method to switch the optimal master clock to the main path. This achieves the goal of preventing clock jitter caused by instability of the master clock or the best timing path (i.e., the main path with the highest clock quality) when the main path has just recovered to health. It achieves the technical effect of eliminating clock jitter caused by preemptive switching during the fault recovery period, and thus solves the problem of clock jitter caused by preemptive switching during the fault recovery period in related technologies. Attached Figure Description

[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a network topology diagram of an optional time synchronization system according to this application; Figure 2 This is a flowchart illustrating an optional clock switching method according to an embodiment of this application; Figure 3 This is a flowchart illustrating another optional clock switching method according to an embodiment of this application; Figure 4 This is a structural block diagram of an optional clock switching device according to an embodiment of this application; Figure 5 This is a structural block diagram of an optional electronic device according to an embodiment of this application. Detailed Implementation

[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0022] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0023] According to one aspect of the embodiments of this application, a clock switching method is provided, applied to a SLAVE (i.e., a slave clock). Optionally, Figure 2 A clock switching method provided in this application embodiment, such as Figure 1 As shown, the master clock GM connects to multiple transparent clocks, and the slave clock SLAVE connects to all clocks connected to GM simultaneously. The path containing BC3 is the master path, and the path containing BC2 is the backup path. The master path and the backup path form a redundant path group. After the master path fails, the SLAVE synchronizes with GM through BC2, and the backup path containing BC2 switches to the working path, including the following steps: Step S202: SLAVE obtains the health status information of the primary path and the backup path.

[0024] The clock switching method in this embodiment can be applied to high-precision time synchronization, in a Precision Time Protocol (PTP) network, in the scenario where multiple redundant time synchronization paths exist, and the master clock path is switched from the clock device.

[0025] Specifically, this can be achieved through a local clock switching method implemented by a slave clock (i.e., SLAVE). A SLAVE can classify all paths (i.e., primary and backup paths) that use the same time signal (i.e., are connected to the same master clock) into a redundant path group. Within this redundant path group, these paths are logically equal and can serve as backups for each other. For example... Figure 1 The GM information published by BC2 and BC3 is the same, therefore the two ports of SLAVE connecting BC2 and BC3 are assigned to the same redundant path group.

[0026] The SLAVE can determine the health status of each port's path by monitoring one or more of the following information: physical and link layer health, time quality health (e.g., clock class, clock accuracy, clock variance, etc.), network performance health (indicating the network transmission quality of the port's path), and protocol and state health (indicating the port's status at the PTP protocol logical layer). This allows the SLAVE to obtain the health status information of the primary path and the backup path. Furthermore, the health status includes at least two types: "available" and "unavailable (or, faulty)." When the primary path, which was originally the working path, fails, the SLAVE synchronizes with the GM via BC2, and the backup path where BC2 resides becomes the working path. In other words, the primary path can be the original working path before the backup path was used as the working path.

[0027] In step S204, if the SLAVE determines that the main path has recovered from the fault state and the GM clock has been locked based on the health status information of the main path, and if the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

[0028] Specifically, after obtaining the health status information for each path, the health status information of the primary path containing BC3, which has the highest clock quality, and the health status information of the backup path currently serving as the working path can be determined. Optionally, clock quality can include one or more of the following dimensions: Clock Class, Clock Accuracy, Clock Variance, Offset FromMaster, Offset Jitter, Path Delay, and Delay Jitter, etc. The clock quality of each port can be obtained by weighting the information of each dimension, and the target port with the highest clock quality can be determined.

[0029] Furthermore, the primary path can be a path recovered from a fault. After a primary path fault occurs, its fault state can be recorded. After obtaining the primary path's health status information, it can be determined whether the primary path currently meets preset health requirements. If it does, the primary path is considered recovered from the fault state to meet the preset health requirements. Then, it is determined whether the GM clock is locked. If the primary path has locked the GM clock and the backup path's health status information meets the preset health requirements, the output PTP time signal may have a large phase error or be unstable because the primary path is a path recovered from a fault. In this case, the backup path continues to be used as the working path for receiving the PTP time signal. Conversely, when the SLAVE determines that the primary path has recovered from a fault state and has locked the GM clock based on the primary path's health status information, but determines that the backup path's health status information does not meet the preset health requirements, the primary path is switched to the working path. In other words, when the primary path has recovered from a fault state and locked the GM clock, and the backup path's health status information does not meet the preset health requirements, the primary path is used as the working path for receiving the PTP time signal.

[0030] In other words, as long as the current working path remains "available," the BMCA clock quality of other paths will remain unchanged (e.g., Figure 1 (As shown, after BC3 recovers, its clock quality information becomes better than BC2). Both continue to use the current working path, that is, the path is not switched.

[0031] As an optional implementation, as described above, the health status information of the backup path meets preset health requirements, including: Based on the health status information of the backup path, determine the first historical moment when the current port on the backup path last acquired the target packet, wherein the current port is the main port currently used to publish the PTP time signal; If the time elapsed between the first historical moment and the current moment is less than or equal to the preset time limit, and the master clock identifier in the target message is consistent with the clock identifier, then the health status information of the backup path is determined to meet the preset health requirements.

[0032] In other words, if no target packet is received within a preset continuous time window (i.e., a preset duration limit) (e.g., the packet interval of multiple preset target packets), the path is determined to be in an "unavailable" state. The target packet can be a PTP packet, which contains a CLOCK ID (i.e., clock identifier) ​​and a Grandmaster CLOCK ID (i.e., master clock identifier). The Grandmaster CLOCK ID comes from the CLOCK ID carried in the Announce message sent by the master clock to the current port. That is, the clock identifier in the target packet can be a pre-stored identifier of the master clock (i.e., GM) connected to the current port; the master clock identifier can be a real-time acquired identifier of the master clock connected to the current port. In other words, if the duration from the first historical moment to the current moment is less than or equal to the preset duration limit, the master clock identifier in the target packet matches the clock identifier, and the health status information of the current port indicates that the physical link of the current port is normal (i.e., the backup path is in normal health status), the health status information of the backup path is determined to meet the preset health requirements at the first historical moment. This allows for a comprehensive assessment of the health status of backup paths based on factors such as whether message reception timed out, whether the message is normal, and whether the link layer status is available.

[0033] In addition, a real-time updated health status table can be generated by maintaining the health status information of each path.

[0034] In this embodiment, even if the main path with the highest clock quality has locked the GM clock, the optimal master clock is not switched to the main path in a preemptive manner when the health status information of the current path meets the preset health requirements. This can prevent clock jitter caused by instability of the master clock or the best timing path (i.e., the main path with the highest clock quality) when the main path has just recovered its health. This achieves the technical effect of eliminating clock jitter caused by preemptive switching during the fault recovery period, and solves the problem of clock jitter caused by preemptive switching during the fault recovery period in related technologies.

[0035] As an optional implementation, the method described above further includes the following steps: If the health status information of the backup path does not meet the preset health requirements, the working path will be switched to the primary path. That is, if the backup path is unhealthy, the primary path with the highest clock quality calculated by BMCA will be selected from all healthy (AVAILABLE) paths as the new working path for receiving PTP time signals.

[0036] Furthermore, if the primary path also fails to recover from the fault and the health status information of the backup path does not meet the preset health requirements, then the working path for receiving the PTP time signal is determined from all remaining backup paths. The remaining backup paths are all available paths from all ports of the clock, excluding the primary path and the backup paths.

[0037] The method described in this embodiment can switch the working path to a healthy and available path (with the GM clock locked) when the current working path fails, thereby ensuring service continuity.

[0038] like Figure 3 As shown, as an optional implementation, the method described above further includes the following steps before obtaining the health status information of each path in the primary path and backup paths: Step S302: Obtain the port information for each port and the master clock identifier of the GM connected to each port. Each port in the same redundant path group is used to connect to the same GM. Each port is located on a slave clock and is used to listen to the PTP time signal of the connected GM through its corresponding path. In other words, the port information for each port can be obtained, and each port's information is globally unique. Furthermore, the master clock identifier of the master clock connected to each port is determined.

[0039] Step S304: The port information and master clock identifier of the port corresponding to the main path are determined as the path identifier of the main path; the port information and master clock identifier of the port corresponding to the backup path are determined as the path identifier of the backup path. Specifically, after determining the port and the master clock connected to the port, a unique path can be determined. Then, the port information and master clock identifier of the port corresponding to each path can be determined as the path identifier of the path corresponding to each port. Optionally, the path identifier may include the corresponding port information and master clock identifier.

[0040] Step S306: Identify the status field of each port according to its health status information. Specifically, this can be achieved by extending a status field, such as `port_health`, for each port on the PTP redundancy path. Furthermore, the status field can be identified as available (e.g., AVAILABLE) or unavailable (e.g., UNAVAILABLE). Then, a health monitoring routine is added to the packet receiving thread. If a port does not receive any PTP packets within N * announce_interval time (i.e., an optional preset upper limit), its `port_health` is marked as UNAVAILABLE; if it receives packets, it is marked as AVAILABLE, where `announce_interval` is the packet transmission time interval.

[0041] The health status information of each path in the primary and backup paths can be obtained through the following steps: Based on the identifier in the status field of each port, the health status information of each port is obtained; and based on the health status information of each port, the health status information of each path is determined. Specifically, after identifying the status field of each port in the aforementioned steps, the health status information of each port can be determined based on the identifier in the status field. Then, based on the correspondence between paths and ports, the health status information of each path (i.e., the primary and backup paths) can be determined.

[0042] As an optional implementation, the method described above, after determining that the main path has recovered from a fault state and the GM clock has been locked based on the health status information of the main path, further includes: treating the main path as a candidate available path. That is, when the previously faulty main path recovers (i.e., the health status information of the target port corresponding to the faulty path changes from "unavailable" to "available," and the GM clock is locked), the decision module can update the target port / main path corresponding to the main path to an "available" state and add the main path as an available path to the candidate pool without triggering any switching action. The available paths in the candidate pool can be used as new working paths in the event of a fault in the current working path.

[0043] As an optional implementation, the method described above, after obtaining the health status information of each path in the primary path and backup paths, further includes: If the health status information of the backup path does not meet the preset health requirements, the system selects the target available path with the best clock quality from all available paths in the redundant path group as the new working path. Specifically, if the health status information of the backup path does not meet the preset health requirements (e.g., path latency exceeding limits, high packet loss rate, degraded clock quality, or link failure), the system will comprehensively evaluate all available paths in the redundant path group that are in the "available" state, based on clock quality indicators (such as clockClass, clockAccuracy, offsetScaledLogVariance, priority1 / 2, and other PTP clock attributes), and select the target available path (i.e., the target path) with the best clock quality as the new working path. This process ensures the continuity and reliability of the time synchronization service.

[0044] According to another aspect of the embodiments of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used to store a computer program; and the processor is used to execute the method steps of any of the above embodiments by running the computer program stored in the memory.

[0045] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to execute the method steps of any of the above embodiments when running.

[0046] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0047] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.

[0048] According to another aspect of the embodiments of this application, a clock path switching device based on PTP clock redundancy path is also provided for implementing the above-described clock path switching method based on PTP clock redundancy path. Figure 4 This is a structural block diagram of an optional clock path switching device based on a PTP clock redundancy path according to an embodiment of this application, such as... Figure 4 As shown, this device is used in a SLAVE. The master clock GM connects to multiple transparent clocks, and the slave clock SLAVE simultaneously connects to all clocks connected to GM. The path containing BC3 is the master path, and the path containing BC2 is the backup path. The master path and the backup path form a redundant path group. After a failure of the master path, the SLAVE synchronizes with GM through BC2, and the backup path containing BC2 switches to the working path. The device includes: The path health detection module 41 is used to obtain the health status information of the primary path and the backup path. The determination module 42 is used to determine that if the main path has recovered from the fault state and the GM clock has been locked, and the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

[0049] It should be noted that the path health detection module 41 in this embodiment can be used to perform the above step S202, and the determination module 42 in this embodiment can be used to perform the above step S204.

[0050] Through the above module, even if the target port with the highest clock quality also meets the preset health requirements, the optimal master clock will not be switched to the master clock connected to the target port in a preemptive manner, and the master port will not be switched from the current port to the target port, provided that the health status information of the current port meets the preset health requirements. This can prevent clock jitter caused by instability of the master clock or the optimal timing path (i.e., the path where the target port with the highest clock quality is located) when the target port has just recovered its health. This achieves the technical effect of eliminating clock jitter caused by preemptive switching during the fault recovery period, and thus solves the problem of clock jitter caused by preemptive switching during the fault recovery period in related technologies.

[0051] As an optional implementation, the determining module of the aforementioned apparatus includes: The time acquisition unit is used to determine the first historical time of the most recent acquisition of the target packet by the current port on the backup path based on the health status information of the backup path, wherein the current port is the main port currently used to publish the PTP time signal; The determination unit is used to determine whether the health status information of the backup path meets the preset health requirements when the time interval between the first historical time and the current time is less than or equal to the preset time limit and the master clock identifier in the target message is consistent with the clock identifier.

[0052] In addition to the modules described above, the apparatus in this embodiment may also include modules that execute any method in any of the aforementioned clock switching methods.

[0053] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the content disclosed in the above embodiments. It should also be noted that the above modules, as part of a device, can operate in environments such as... Figure 1 The hardware environment shown can be implemented through software or hardware, and the hardware environment includes the network environment.

[0054] According to another aspect of the embodiments of this application, an electronic device for implementing the above clock switching method is also provided. The electronic device may be a server, a terminal, or a combination thereof.

[0055] According to another embodiment of this application, an electronic device is also provided, comprising: Figure 5 As shown, the electronic device may include: a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504, wherein the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.

[0056] Memory 1503 is used to store computer programs; When processor 1501 executes the program stored in memory 1503, it performs the following steps: Step S202: SLAVE obtains the health status information of the primary path and the backup path.

[0057] In step S204, if the SLAVE determines that the main path has recovered from the fault state and the GM clock has been locked based on the health status information of the main path, and if the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

[0058] Optionally, in this embodiment, the communication bus can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the aforementioned electronic device and other devices.

[0059] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0060] As an example, the memory 1503 described above may include, but is not limited to, the path health detection module 41 and the determination module 42 from the clock switching device described above. Furthermore, it may include, but is not limited to, other module units from the clock switching device described above, which will not be elaborated upon in this example.

[0061] The processor mentioned above can be a general-purpose processor, including but not limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0062] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the method steps of the above method embodiments when it runs.

[0063] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0064] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0065] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0066] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0067] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.

[0068] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of the solution provided in this embodiment, depending on actual needs.

[0069] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0070] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A clock path switching method based on PTP clock redundancy path, characterized in that, The master clock (GM) connects to multiple transparent clocks, and the slave clock (SLAVE) simultaneously connects to all clocks connected to the GM. The path containing BC3 is the master path, and the path containing BC2 is the backup path. The master path and the backup path form a redundant path group. If the master path fails, the SLAVE synchronizes with the GM via BC2, and the backup path containing BC2 switches to the working path. The method includes: SLAVE obtains the health status information of the primary and backup paths. If the SLAVE determines that the primary path has recovered from a fault state and the GM clock has been locked based on the health status information of the primary path, and if it determines that the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

2. The method according to claim 1, characterized in that, The method further includes: If, based on the health status information of the primary path, SLAVE determines that the primary path has recovered from a fault state and the GM clock has been locked, and if it determines that the health status information of the backup path does not meet the preset health requirements, SLAVE will switch the primary path to the working path.

3. The method according to claim 1, characterized in that, The health status information of the backup path meets preset health requirements, including: Based on the health status information of the backup path, determine the first historical moment when the current port on the backup path last acquired the target packet, wherein the current port is the main port currently used to publish the PTP time signal; If the time elapsed between the first historical moment and the current moment is less than or equal to a preset time limit, and the master clock identifier in the target message is consistent with the clock identifier, then the health status information of the backup path is determined to meet the preset health requirements.

4. The method according to claim 1, characterized in that, Before obtaining the health status information of each path in the primary path and backup paths, the method further includes: Obtain the port information of each port and the master clock identifier of the GM connected to each port, wherein each port in the same redundant path group is used to connect to the same GM, each port is located on a slave clock and is used to listen to the PTP time signal of the connected GM through the corresponding path; The port information of the port corresponding to the main path and the master clock identifier are determined as the path identifier of the main path; the port information of the port corresponding to the backup path and the master clock identifier are determined as the path identifier of the backup path. The status field of each port is identified according to the health status information of each port; The step of obtaining the health status information of the primary path and the backup path includes: obtaining the health status information of each port based on the identifier in the status field of each port, and determining the health status information of each path according to the health status information of each port.

5. The method according to claim 1, characterized in that, After determining, based on the health status information of the primary path, that the primary path has recovered from a fault state and the GM clock has been locked, the method further includes: The main path is selected as a candidate available path.

6. The method according to claim 1, characterized in that, After obtaining the health status information of the primary path and the backup path, the method further includes: If the health status information of the backup path does not meet the preset health requirements, the target available path with the best clock quality is selected from all available paths in the redundant path group as the working path.

7. A clock path switching device based on PTP clock redundancy path, characterized in that, Applied to SLAVE, the master clock GM connects to multiple transparent clocks, and the slave clock SLAVE simultaneously connects to all clocks connected to GM. The path containing BC3 is the master path, and the path containing BC2 is the backup path. The master path and the backup path form a redundant path group. After the master path fails, the SLAVE synchronizes with GM through BC2, and the backup path containing BC2 switches to the working path. The device includes: The path health detection module is used to obtain the health status information of the main path and the backup path; The determination module is used to determine that, if the main path has recovered from a fault state and the GM clock has been locked based on the health status information of the main path, and if the health status information of the backup path meets the preset health requirements, then the backup path will continue to be used as the working path without switching.

8. The apparatus according to claim 7, characterized in that, The determining module includes: The time acquisition unit is used to determine the first historical time when the current port on the backup path last acquired the target packet based on the health status information of the backup path, wherein the current port is the main port currently used to publish the PTP time signal; The determining unit is configured to determine that the health status information of the backup path meets the preset health requirements when the time elapsed between the first historical time and the current time is less than or equal to a preset time limit and the master clock identifier in the target message is consistent with the clock identifier.

9. An electronic device comprising a processor, a communication interface, a memory, and a communication bus, wherein, The processor, the communication interface, and the memory communicate with each other via the communication bus, characterized in that... The memory is used to store computer programs; The processor is configured to perform the method of any one of claims 1 to 6 by running the computer program stored in the memory.

10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 6 when run on a processor.