A method and system for correcting node clock skew under multiple time source switching

By sending paired test time messages to downstream nodes during the multi-time source switching process, calculating the downstream visible time deviation and determining the switching correction amount, the problem of insufficient time continuity of downstream nodes in the prior art is solved, and the stability and continuity of node output time are achieved.

CN122870322BActive Publication Date: 2026-11-10HANGZHOU LINWEI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611364746.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-09-04
Publication Date
2026-11-10
Estimated Expiration
2046-09-04

AI Technical Summary

Technical Problem

Existing technologies fail to effectively consider the time variations of downstream nodes during multi-time source switching, leading to increased downstream synchronization deviations or unstable node output time corrections after switching. This is especially true for nodes that act as relays, where factors such as output port delays, packet forwarding queuing, and link jitter make it difficult to accurately reflect the time continuity of downstream nodes.

Method used

Before a node switches its output time, it sends a pair of test time messages carrying the timestamps of the current and target time sources to downstream nodes, receives the timestamps returned by downstream nodes, calculates the downstream visible time deviation, determines the switching correction amount based on the deviation, generates the node output time, and updates the switching correction amount in combination with a preset frequency adjustment limit to ensure the time continuity of the downstream receiving side.

Benefits of technology

This reduces the time jumps seen by downstream nodes, avoids abnormal feedback results triggering incorrect timing source switching or output time correction, ensures the stability and continuity of node output time, and reduces the disruption of downstream time continuity caused by repeated changes in correction direction after switching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122870322B_ABST
    Figure CN122870322B_ABST
Patent Text Reader

Abstract

This invention relates to the field of distributed time synchronization technology, specifically to a method and system for correcting node clock skew during multi-time source switching. Addressing the problem that node input skew during multi-time source switching is difficult to reflect the actual visible time jumps of downstream nodes, the method acquires time samples of the current and target time sources at the same node, establishes a correspondence between the time of the time source and the node's local count value, sends paired test time messages carrying timestamps from different time sources before switching, and determines the downstream visible time skew based on the received timestamps returned by the downstream node; then, a switching correction amount is generated accordingly, and the target time source time is superimposed during switching to generate the node's output time; after switching, the switching correction amount is gradually updated according to a preset frequency adjustment limit, thereby reducing the time abrupt changes perceived by downstream nodes and maintaining the continuity of node output time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of distributed time synchronization technology, specifically to a method and system for correcting node clock deviations under multiple time synchronization source switching. Background Technology

[0002] Distributed time synchronization networks are commonly used in scenarios such as navigation enhancement, communication base stations, industrial control, power synchronization, radar arrays, and precision measurement. They provide unified time to multiple nodes through satellite time synchronization, a master clock from a higher level, or time messages transmitted via wired or fiber optic networks. When a node accesses multiple time synchronization sources, it typically selects the current time synchronization source based on the source's priority, signal quality, message delay, phase difference, or local timekeeping status. If the current time synchronization source fails or the primary time synchronization source needs to be restored, a time synchronization source switch is performed to maintain the continuous operation of the node's local clock and the time output to the outside world.

[0003] However, existing methods mostly compensate for handover based on the time difference between upstream time sources or the local clock deviation of the node, failing to adequately consider the actual time variations received by downstream devices. For nodes acting as relays, the handover process is also affected by factors such as output port delay, packet forwarding queuing, downstream node receiving timestamp reference, and link jitter. Simply relying on the quality of the upstream time source or the phase difference between sources may not accurately reflect the time continuity seen by downstream nodes, leading to increased downstream synchronization deviation or unstable node output time correction direction after handover. Therefore, a node clock deviation correction method and system under multi-time source handover are needed to solve the above problems. Summary of the Invention

[0004] To address the above problems, this invention provides the following technical solution: a method for correcting node clock skew under multiple time source switching, comprising: S1. Obtain time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples; S2. If the node does not switch its external output time, send a pair of test time messages to at least one downstream node. The pair of test time messages include a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. S3. Receive the first and second timestamps returned by the downstream node based on its local output time. S4. Determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. S5. Determine the switching correction amount based on the downstream visible time deviation, and add the target time source time and the switching correction amount together when switching the time source to generate the node output time; S6. After the time source is switched, the switching correction amount is updated according to the return timestamps corresponding to the subsequent paired test time messages, based on the preset frequency adjustment limit.

[0005] Furthermore, the time sample includes a time source identifier, a source timestamp, a second pulse arrival time, a local count value, an input channel identifier, and a channel calibration delay; Determining the correspondence between the time of the time synchronization source and the local count value of the node includes determining the time deviation of the corresponding time synchronization source relative to the local count value of the node based on the source timestamp, the local count value corresponding to the arrival time of the second pulse, and the channel calibration delay.

[0006] Furthermore, sending paired test time messages to at least one downstream node includes: For each downstream node, select the same output port corresponding to that downstream node within the same test window, and keep the message length and transmission priority the same. Write the same test sequence number and node local transmission count value into the first test time message and the second test time message respectively, and write the current time synchronization source transmission timestamp into the first test time message and the target time synchronization source transmission timestamp into the second test time message; The first test time message and the second test time message are sent to the downstream node at preset intervals.

[0007] Furthermore, determining the downstream visible time deviation includes: For each downstream node, the return latency of the downstream node is calculated based on the node's local transmission count value and the node's local count value when receiving the return message from the downstream node. Valid downstream nodes are obtained by filtering downstream nodes that return the first and second receiving timestamps under the same test sequence number and whose return delay is within the preset return delay range. For each valid downstream node, calculate the difference between the target time source sending timestamp in the second test time message and the current time source sending timestamp in the first test time message to obtain the sending time interval; Subtract the first receiving timestamp from the second receiving timestamp to obtain the receiving time interval; Subtracting the receiving time interval from the sending time interval yields the downstream visible time deviation corresponding to the effective downstream node. When there are no valid downstream nodes, maintain the current time source outputting time.

[0008] Furthermore, when multiple valid downstream nodes exist, determining the downstream visible time deviation also includes: The downstream visible time deviations corresponding to multiple valid downstream nodes are sorted to determine the median deviation; Valid downstream nodes whose difference from the median deviation exceeds a preset port jitter threshold are marked as abnormal downstream nodes. When the number of valid downstream nodes that are not marked as abnormal downstream nodes reaches a preset number condition, the median deviation is re-determined based on the downstream visible time deviation corresponding to the valid downstream nodes that are not marked as abnormal downstream nodes, and the re-determined median deviation is used as the downstream visible time deviation of the node. When the number of valid downstream nodes that are not marked as abnormal is lower than a preset number, the current time source continues to output time.

[0009] Furthermore, before determining the target time synchronization source, each candidate time synchronization source is used as a temporary target time synchronization source to send the paired test time messages. For each candidate time source, calculate the downstream visible time deviation of each effective downstream node corresponding to the candidate time source, sort the multiple downstream visible time deviations corresponding to the candidate time source, and take the median as the candidate deviation corresponding to the candidate time source. Candidate time sources that meet the preset number of effective downstream nodes and whose absolute value of the candidate deviation does not exceed the preset correctable range are selected to obtain the time source that is allowed to be switched. The time source that is allowed to be switched with the smallest absolute value of the candidate deviation is determined as the target time source.

[0010] Furthermore, determining the switching correction amount based on the downstream visible time deviation includes: When the downstream visible time deviation is positive, calculate the negative switching correction amount used to reduce the node output time relative to the target time source time; When the downstream visible time deviation is negative, calculate the positive switching correction amount used to improve the node output time relative to the target time source time; When the downstream visible time deviation is zero, the switching correction amount is set to zero; The node output time is obtained by adding the target time source time to the switching correction amount.

[0011] Furthermore, updating the switching correction amount according to the preset frequency adjustment limit includes: After the time source is switched, the pair of test time messages after the switch continues to be sent. The first test time message in the pair of test time messages after the switch carries the node output timestamp after the switch correction amount is superimposed, and the second test time message carries the target time source timestamp without the switch correction amount being superimposed. Calculate the remaining downstream visible time deviation based on the received timestamp of the downstream node's back transmission of the paired test time messages after the switch. The switching correction amount is gradually converged toward zero in such a way that each correction cycle does not exceed the preset frequency adjustment limit. The preset frequency adjustment limit is used to limit the maximum adjustment amount of the node output time relative to the target time source time in each correction cycle. When the number of effective downstream nodes is lower than a preset quantity condition or the dispersion of the remaining downstream visible time deviations corresponding to multiple effective downstream nodes exceeds a preset dispersion threshold, the switching correction amount is paused to converge to zero, and the output time of the current node is kept continuous.

[0012] This invention also provides a node clock skew correction system under multiple time source switching, used to implement the above-mentioned node clock skew correction method under multiple time source switching, including: The time sample acquisition module is used to acquire time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples. The test message sending module is used to send a pair of test time messages to at least one downstream node when the node does not switch the external output time. The pair of test time messages includes a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. The timestamp return module is used to receive the first and second timestamps returned by the downstream node based on its local output time. The visible deviation determination module is used to determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. The switching output module is used to determine the switching correction amount based on the downstream visible time deviation, and to superimpose the target time source time and the switching correction amount during time source switching to generate the node output time. The post-switching correction module is used to update the switching correction amount according to the return timestamps corresponding to the subsequent paired test time messages after the time source is switched, adjusting the limit at a preset frequency.

[0013] Compared with the prior art, the present invention has the following beneficial effects: By sending paired test time messages to downstream nodes before switching their output time, each carrying a timestamp from the current time source and a timestamp from the target time source, and receiving the first and second received timestamps from downstream nodes based on their local output time, nodes can determine the downstream visible time deviation based on the difference between the sending and receiving time intervals. Therefore, the correction basis during time source switching no longer depends solely on the time difference between upstream time sources but reflects the actual time changes received by downstream nodes, thus reducing the likelihood of downstream nodes experiencing time jumps when directly compensating for inter-source deviations.

[0014] By calculating the return latency for each downstream node, filtering valid downstream nodes, and marking abnormal downstream nodes using median deviation and port jitter thresholds when multiple valid downstream nodes exist, link return latency anomalies, port jitter, or individual downstream node timestamp anomalies do not directly participate in the node output time switching correction. When the number of valid downstream nodes is insufficient, maintaining the current time source's output time avoids generating unclear switching correction amounts when samples are insufficient, thereby reducing the likelihood of abnormal return results triggering incorrect time source switching or incorrect node output time correction.

[0015] By superimposing the target time source time and the switching correction amount during time source switching to generate the node output time, and then adjusting the switching correction amount towards zero according to the return timestamps of subsequent paired test time messages after the switch, the node output time can first maintain the continuity of the downstream receiver and then gradually revert to the target time source time under limited conditions. Convergence is paused when the number of effective downstream nodes is insufficient or the remaining downstream visible time deviations are too dispersed. This avoids inconsistent downstream feedback directly changing the node output time, thereby reducing the disruption of downstream time continuity caused by repeated changes in the correction direction after the switch. Attached Figure Description

[0016] Figure 1 A schematic diagram illustrating the method steps of a node clock deviation correction method under multiple time source switching provided by the present invention; Figure 2 The overall flowchart of a node clock deviation correction method under multiple timing source switching provided by the present invention; Figure 3 A comparison diagram of downstream visible time deviations for a node clock deviation correction method under multiple time source switching provided by the present invention; Figure 4 This invention provides an effective downstream node screening distribution diagram for a node clock deviation correction method under multiple time source switching. Figure 5 The convergence trend diagram of the switching correction amount of the node clock deviation correction method under multiple timing source switching provided by the present invention; Figure 6 The present invention provides a system structure diagram of a node clock deviation correction system under multiple timing source switching. Detailed Implementation

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

[0018] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0019] Please see Figure 1 and Figure 2 , Figure 1 This is a schematic diagram illustrating the method steps of a node clock offset correction method under multiple timing source switching provided by the present invention. Figure 2 This invention provides an overall flowchart of a node clock skew correction method under multiple time source switching. The invention provides a node clock skew correction method under multiple time source switching, comprising: S1. Obtain time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples; Specifically, in this embodiment, the node is an intermediate node in a fiber optic Ethernet distributed timing network. This node includes a local crystal oscillator, a local counter, at least two timing source input channels, at least one downstream output port, and a processor or programmable logic device. The local counter is driven by the local crystal oscillator, and its counting frequency is denoted as... When a node receives a second pulse, time message, or time code from the current time source and the target time source, it simultaneously latches the corresponding local count value, so that the time of different time sources can be converted to the same local count reference of the node.

[0020] Each node establishes a time mapping record for each time synchronization source. This record includes at least the time synchronization source identifier, input channel identifier, source timestamp, local counter value corresponding to the second pulse arrival time, channel calibration delay, sample validity status, and most recent update time. The channel calibration delay can be written during installation calibration, link self-test, or maintenance configuration to deduct fixed delays introduced by the input channel, electro-optical conversion, receiving circuit, and message parsing path. If a time synchronization source is not updated within the preset sample validity time, or if the second pulse arrival time and source timestamp do not satisfy a monotonic relationship, the sample corresponding to that time synchronization source is marked as invalid and will not participate in subsequent handover correction calculations.

[0021] In one embodiment, the node determines the correspondence between the time source time and the node's local count value in the following manner:

[0022]

[0023] in, Indicates the time synchronization source identifier. Indicates the time source The source timestamp corresponding to the second pulse. This represents the local count value latched by the node when the second pulse arrives. Indicates the time source The corresponding input channel calibration delay, Indicates the time source The time deviation relative to the node's local count value This indicates that the local count value on the node is... The time source time is calculated. This correspondence is written to the time source time mapping record of the node, and this record is read when generating the current time source sending timestamp, the target time source sending timestamp, and the target time source time.

[0024] To facilitate understanding of this correspondence, in one example, the local counter counting frequency... The local count value latched by the node when the second pulse of a certain time source arrives at 100 MHz. The value is 1000000000, which translates to a local counting time of 10 seconds; if the time source corresponds to the source timestamp The channel calibration delay for the input channel is 10 seconds. If the time is 80 nanoseconds, the node first subtracts the channel calibration delay from the local counting time, resulting in 9.999999920 seconds, and then compares this with the source timestamp to obtain the time deviation. Nanoseconds. Subsequently, when the node's local count value reaches 1005000000, the time source time calculated by the node is 10.050000080 seconds. This value is the source for generating the time source sending timestamp or the target time source time.

[0025] Furthermore, in one embodiment provided by the present invention, the time sample includes a time source identifier, a source timestamp, a second pulse arrival time, a local count value, an input channel identifier, and a channel calibration delay; Determining the correspondence between the time of the time synchronization source and the local count value of the node includes determining the time deviation of the corresponding time synchronization source relative to the local count value of the node based on the source timestamp, the local count value corresponding to the arrival time of the second pulse, and the channel calibration delay.

[0026] Specifically, the time source identifier is used to distinguish the current time source, the target time source, and candidate time sources; the source timestamp is used to represent the standard time published by the corresponding time source; the arrival time of the second pulse is latched by the node's input capture circuit; the local count value is used to unify the time base of each time source at the same node; and the input channel identifier is used to find the channel calibration delay corresponding to that channel. The node first reads the channel calibration delay according to the input channel identifier, and then substitutes the source timestamp, the local count value corresponding to the arrival time of the second pulse, and the channel calibration delay into the above correspondence to obtain the current time source time deviation and the target time source time deviation. When the same time source acquires multiple time samples within multiple consecutive second pulse cycles, the node can perform mean or median processing on the multiple time deviations and use the processed time deviation as the current valid time deviation of the time source; when the number of samples is insufficient, the node maintains the previous valid time deviation and restricts the time source switching process from entering the formal switching.

[0027] S2. If the node does not switch its external output time, send a pair of test time messages to at least one downstream node. The pair of test time messages include a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. Specifically, nodes still output time driven by the current time synchronization source. The target time synchronization source is only used as a calculation object before the switchover and does not directly take over the node's output time. Nodes generate pairs of test time messages within the test window. Each pair of messages has the same test sequence number and sets the following fields: message type, target downstream node identifier, node local transmission count, time synchronization source transmission timestamp, output port identifier, message length padding, and transmission priority. The time synchronization source transmission timestamp of the first test time message is calculated from the current time synchronization source time mapping record, and the time synchronization source transmission timestamp of the second test time message is calculated from the target time synchronization source time mapping record.

[0028] In one embodiment, for downstream nodes and test serial number The time synchronization source timestamps in the first and second test time messages are generated as follows:

[0029]

[0030] in, This represents the local transmission count value latched by the node when the first test time message is sent. This represents the node's local transmission count value latched when the second test time message is sent. This indicates the time deviation of the current time source relative to the node's local count value. This indicates the time deviation of the target time source relative to the node's local count value. and Write the time stamp field of the time synchronization source to the corresponding test time message. If any transmission count value fails to be latched successfully, or the corresponding time synchronization source time mapping record is invalid, the node marks the test sequence number as a transmission timestamp generation anomaly and will not use it for downstream visible time deviation calculation.

[0031] When generating a message, the node latches its local transmission count value when the message is dequeued from the transmission queue or when transmission is triggered by a hardware timestamp unit. This count is denoted as... and The data is then written into the first test time message and the second test time message, respectively. For implementations that do not support hardware transmission timestamps, the node can latch a local count value when the message enters the fixed priority transmission queue and compensate for it with a pre-defined fixed delay in the transmission queue; this compensation parameter is written into the node configuration table as an example parameter and is not the only limitation.

[0032] Furthermore, in one embodiment of the present invention, sending paired test time messages to at least one downstream node includes: For each downstream node, select the same output port corresponding to that downstream node within the same test window, and keep the message length and transmission priority the same. Write the same test sequence number and node local transmission count value into the first test time message and the second test time message respectively, and write the current time synchronization source transmission timestamp into the first test time message and the target time synchronization source transmission timestamp into the second test time message; The first test time message and the second test time message are sent to the downstream node at preset intervals.

[0033] Specifically, each node establishes a downstream node test table for each downstream node. This table includes at least the downstream node identifier, corresponding output port, test sequence number, first test time message sending status, second test time message sending status, first test time message local transmission count, second test time message local transmission count, and return status. For each downstream node, the node reads its corresponding output port from the downstream node test table and uses only this output port to send paired test time messages for that downstream node within the same test window. This avoids port latency differences caused by two test messages from the same downstream node passing through different ports. If multiple downstream nodes are located on different output ports, the node selects the same output port for each downstream node, rather than requiring all downstream nodes to share the same output port.

[0034] The message length can be padded to the same number of bytes using a padding field, such as 128 bytes, 256 bytes, or the length specified in the node configuration table; the transmission priority can be written to the Ethernet priority field or the node's internal queue priority field, ensuring that the first test time message and the second test time message are sent under the same queue rule. Preset transmission interval. This can be given by the node configuration table, for example, from 10 milliseconds to 200 milliseconds; the node calculates the preset transmission interval using a local counter value, when... fall into If the error falls within the allowable error range, the test time message is considered valid; otherwise, the test sequence number is marked as an abnormal transmission interval.

[0035] S3. Receive the first and second timestamps returned by the downstream node based on its local output time. Specifically, when a downstream node receives the first and second test time messages, it does not adjust its local output time accordingly. Instead, it records the first and second reception timestamps based on its local output time. The downstream node's return message includes at least the downstream node identifier, test sequence number, first reception timestamp, second reception timestamp, reception status field, and return message transmission status field. When a node receives a return message, it latches its local count value at the time of receiving the downstream node's return message, using this count as input for subsequent calculations of the downstream node's return delay.

[0036] The downstream node records the first and second receive timestamps based on its local output time. This means that the downstream node uses its published or maintained local time as the receive timestamp reference, rather than using the receive time after the backhaul link arrives at the node as the first or second receive timestamp. The downstream node can complete the recording through a hardware receive timestamp unit, a software receive timestamp unit with fixed delay compensation, or a local output time counter, and write the timestamp resolution and receive status fields into the return message. If the downstream node's local output time is in an unlocked state, the timestamp resolution is lower than the minimum resolution in the node configuration table, or the two receive timestamps do not satisfy a monotonic relationship, the downstream node writes an invalid status in the receive status field, and the node will not include this return result in the set of valid downstream nodes.

[0037] If a node does not receive a complete return message from a downstream node under the same test sequence number within the preset return message waiting time, or only receives one of the first and second receive timestamps, then the test sequence number corresponding to that downstream node is marked as incomplete return message. If multiple return messages are received for the same test sequence number, the node prioritizes the one with a valid receive status field and the earliest received time, and records other duplicate messages as duplicate return messages, which are not included in the downstream visible time deviation calculation.

[0038] S4. Determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. Specifically, the node first matches paired test time messages and downstream node return messages under the same test sequence number. The matching key includes the downstream node identifier and the test sequence number. After a successful match, the node reads the current time source sending timestamp from the first test time message, the target time source sending timestamp from the second test time message, and the first and second receive timestamps returned by the downstream node. The sending time interval represents the time difference between the target time source sending timestamp and the current time source sending timestamp, and the receiving time interval represents the actual time difference recorded by the downstream node between the two reception times. Once both are in the same time unit, the node subtracts the receiving time interval from the sending time interval to obtain the downstream visible time deviation corresponding to that downstream node.

[0039] In one embodiment, for downstream nodes and test serial number The downstream visible time deviation is calculated as follows:

[0040]

[0041]

[0042] in, This indicates the timestamp sent by the target time source in the second test time message. This indicates the timestamp of the current time source in the first test time message. and Representing downstream nodes Based on its local output time return, the first and second received timestamps are transmitted back. This represents the downstream visibility time offset corresponding to the effective downstream node. (Calculated...) Write the deviation to the downstream node's deviation table, which will be used later to determine the switching correction amount or candidate deviation.

[0043] In one example, the first test time message carries a current time source transmission timestamp of 100.000000000 seconds, and the second test time message carries a target time source transmission timestamp of 100.050000080 seconds, resulting in a transmission time interval of 50.000080 milliseconds. If the downstream node transmits a first reception timestamp of 200.000000000 seconds and a second reception timestamp of 200.050000020 seconds based on its local output time, the reception time interval is 50.000020 milliseconds. Subtracting these two timestamps yields a downstream visible time deviation of 60 nanoseconds. This 60 nanoseconds represents the target time source takeover effect observed from the downstream node, rather than simply representing the source time difference between the two time sources at the node's input.

[0044] Furthermore, in one embodiment of the present invention, determining the downstream visible time deviation includes: For each downstream node, the return latency of the downstream node is calculated based on the node's local transmission count value and the node's local count value when receiving the return message from the downstream node. Valid downstream nodes are obtained by filtering downstream nodes that return the first and second receiving timestamps under the same test sequence number and whose return delay is within the preset return delay range. For each valid downstream node, calculate the difference between the target time source sending timestamp in the second test time message and the current time source sending timestamp in the first test time message to obtain the sending time interval; Subtract the first receiving timestamp from the second receiving timestamp to obtain the receiving time interval; Subtracting the receiving time interval from the sending time interval yields the downstream visible time deviation corresponding to the effective downstream node. When there are no valid downstream nodes, maintain the current time source outputting time.

[0045] Specifically, for each downstream node, the node reads the local transmission count value of the node that wrote the first test time message or the second test time message under that test sequence number, and also reads the local count value latched by the node when receiving the return message from that downstream node. The return latency is calculated as follows:

[0046] in, Indicates the node's downstream nodes The node local transmission count value written when sending the test message corresponding to the test sequence number is, in one embodiment, taken as the node local transmission count value of the second test time message, and in another embodiment, taken as the node local transmission count value corresponding to the earlier frame sent in the paired test time messages and used in conjunction with the return reference field in the configuration table; This represents the local counter value when a node receives a message sent back from the downstream node. This indicates the return latency of the downstream node. The preset return latency range can be determined based on the downstream link length, the number of switching and forwarding stages, and historical return latency calculations, for example, configured as follows: ,when If the data is outside this range, it indicates that the return message may be affected by queuing, retransmission, or link congestion. The node will mark the data of the downstream node under this test sequence number as having abnormal return latency.

[0047] A valid downstream node must simultaneously meet three conditions: First, the downstream node identifier and test sequence number in the returned message must match the node's transmission record; second, the returned message must simultaneously carry the first and second reception timestamps under the same test sequence number; and third, the return latency must be within the preset return latency range. If any condition is not met, the downstream node is not added to the valid downstream node set but is instead written to the exception record table. If the valid downstream node set is empty, the node does not generate a new handover correction, does not execute the target time source takeover output, maintains the current time source's output time, and can resend paired test time messages in the next test window.

[0048] Furthermore, in one embodiment of the present invention, when multiple valid downstream nodes exist, determining the downstream visible time deviation further includes: The downstream visible time deviations corresponding to multiple valid downstream nodes are sorted to determine the median deviation; Valid downstream nodes whose difference from the median deviation exceeds a preset port jitter threshold are marked as abnormal downstream nodes. When the number of valid downstream nodes that are not marked as abnormal downstream nodes reaches a preset number condition, the median deviation is re-determined based on the downstream visible time deviation corresponding to the valid downstream nodes that are not marked as abnormal downstream nodes, and the re-determined median deviation is used as the downstream visible time deviation of the node. When the number of valid downstream nodes that are not marked as abnormal is lower than a preset number, the current time source continues to output time.

[0049] Specifically, the node reads the downstream visible time deviations corresponding to multiple valid downstream nodes within the same test window from the downstream node deviation table, and sorts them in ascending order of value. When the number of valid downstream nodes is odd, the deviation in the middle position after sorting is taken as the median deviation; when the number of valid downstream nodes is even, the average of the two middle deviations is taken as the median deviation. The preset port jitter threshold can be determined by the historical transmission jitter of the output port, the downstream reception timestamp resolution, and the link forwarding jitter statistics, for example, set to 3 times the standard deviation of the historical normal deviation or a fixed nanosecond-level threshold in the node configuration table.

[0050] The node compares the downstream visible time deviation corresponding to each valid downstream node with the median deviation. If the absolute value of the difference exceeds a preset port jitter threshold, the valid downstream node is marked as an abnormal downstream node, and the downstream node identifier, test sequence number, downstream visible time deviation, median deviation, and reason for the abnormality are written to the abnormal record table. After completing the abnormality marking, the node only reorders the deviations of downstream nodes not marked as abnormal and redetermines the median deviation. When the number of valid downstream nodes not marked as abnormal reaches a preset number condition, such as no less than 2 or no less than the minimum number of valid nodes specified in the configuration table, the redetermined median deviation is used as the downstream visible time deviation of the node; otherwise, the current time source output time is maintained to avoid incorrect switching due to insufficient individual nodes or samples.

[0051] In one example, the downstream visible time deviations corresponding to three valid downstream nodes within the same test window are 60 nanoseconds, 65 nanoseconds, and 210 nanoseconds, respectively. After sorting, these deviations are 60 nanoseconds, 65 nanoseconds, and 210 nanoseconds, with a median deviation of 65 nanoseconds. If the preset port jitter threshold is 80 nanoseconds, the difference between 60 nanoseconds and 65 nanoseconds is 5 nanoseconds, and the difference between 65 nanoseconds and 65 nanoseconds is 0, neither of which is marked as abnormal. The difference between 210 nanoseconds and 65 nanoseconds is 145 nanoseconds, exceeding the preset port jitter threshold, therefore the corresponding downstream node is marked as an abnormal downstream node. After removing the abnormal nodes, the remaining two deviations are 60 nanoseconds and 65 nanoseconds. The redefined median deviation is 62.5 nanoseconds, which is used as the downstream visible time deviation for the node's current handover correction.

[0052] Furthermore, in one embodiment of the present invention, before determining the target time synchronization source, each candidate time synchronization source is used as a temporary target time synchronization source to send the paired test time messages; for each candidate time synchronization source, the downstream visible time deviation of each effective downstream node corresponding to the candidate time synchronization source is calculated, and the multiple downstream visible time deviations corresponding to the candidate time synchronization source are sorted, and the median is taken as the candidate deviation corresponding to the candidate time synchronization source; candidate time synchronization sources with the number of effective downstream nodes reaching a preset number condition and the absolute value of the candidate deviation not exceeding a preset correctable range are selected to obtain the time synchronization source that is allowed to be switched, and the time synchronization source with the smallest absolute value of the candidate deviation that is allowed to be switched is determined as the target time synchronization source.

[0053] Specifically, when a node has more than two candidate time synchronization sources, it can first enter the candidate time synchronization source pre-selection stage. The node sequentially writes each candidate time synchronization source into the temporary target time synchronization source field, and without switching its external output time, performs paired test time message transmission, timestamp reception, and downstream visible time deviation calculation for that temporary target time synchronization source. For candidate time synchronization sources... The node obtains a set of downstream visible time deviations corresponding to multiple valid downstream nodes. And take the median of the set as the candidate bias. The node then reads the number of valid downstream nodes corresponding to the candidate time source. and preset adjustable range ,when The preset quantity condition is met and When the candidate time source is selected, it is added to the set of allowed time sources. If the candidate deviation exceeds the preset correctable range, it indicates that the time correction required after switching the candidate time source may exceed the node's allowed output adjustment capability, and the node will not use it as the target time source for this operation. If the set of allowed time sources contains multiple time sources, the node sorts the candidate time sources by their absolute deviation values ​​from smallest to largest and determines the allowed time source with the smallest absolute deviation value as the target time source. If the set is empty, the current time source is kept in its output time.

[0054] In one example, candidate time source The downstream visibility time offsets for the three valid downstream nodes are 60 nanoseconds, 65 nanoseconds, and 210 nanoseconds. After removing outliers and recalculating the median, candidate offsets are obtained. Nanosecond; Candidate time source The corresponding multiple downstream visible time deviations were processed in the same way to obtain candidate deviations. Nanoseconds. If the preset correctable range is... If the time interval is 500 nanoseconds and the number of valid downstream nodes for both candidate time sources reaches a preset threshold, then both are considered valid time sources for handover. (Node comparison) and Candidate time sources with smaller absolute values ​​of candidate deviations The target time synchronization source has been identified. Therefore, the candidate bias is the aggregated result of the biases of multiple valid downstream nodes corresponding to the candidate time synchronization source, rather than the bias of any single downstream node.

[0055] S5. Determine the switching correction amount based on the downstream visible time deviation, and add the target time source time and the switching correction amount together when switching the time source to generate the node output time; Specifically, the node reads the downstream visible time deviation determined by S4 and uses it as an estimate of the impact of the downstream receiver on the takeover of the target time source before the handover. The node does not change the time of the target time source itself, but instead adds a handover correction amount during the node output time generation stage. The handover correction amount is written into the output time correction table, which includes at least the target time source identifier, the local count value at the start of the handover, the downstream visible time deviation, the handover correction amount, the correction status, and the effective period. When the time source is switched, the node output time generator reads the target time source time mapping record and adds the handover correction amount from the output time correction table to generate the node output time to be published externally.

[0056] In one embodiment, the node output time is determined as follows:

[0057]

[0058] in, This indicates the downstream visible time deviation of the node. Indicates the change in correction amount. Indicates the target time source time. This indicates that the node's local count value is The generated node output time. This formula indicates that the switching correction amount is determined based on the negative of the downstream visible time deviation, used to offset the change in the visible time of downstream nodes when the target time source directly takes over.

[0059] In one example, if the visible time deviation is downstream of the node If the value is positive 62.5 nanoseconds, then switch the correction amount. The value is -62.5 nanoseconds, and the node outputs this value when the target time source takes over. This ensures that the output time seen by downstream nodes does not suddenly become too fast due to the target time source taking over; if the visible time deviation of the downstream nodes is... If the value is -40 nanoseconds, then switch the correction amount. 40 nanoseconds, node output This ensures that the output time seen by downstream nodes does not suddenly slow down due to the target time source taking over; if If it is 0, then If the value is 0, the node directly outputs the target time source time.

[0060] Furthermore, in one embodiment of the present invention, determining the switching correction amount based on the downstream visible time deviation includes: When the downstream visible time deviation is positive, calculate the negative switching correction amount used to reduce the node output time relative to the target time source time; When the downstream visible time deviation is negative, calculate the positive switching correction amount used to improve the node output time relative to the target time source time; When the downstream visible time deviation is zero, the switching correction amount is set to zero; The node output time is obtained by adding the target time source time to the switching correction amount.

[0061] Specifically, when the downstream visible time deviation is positive, it indicates that if the target time source directly takes over, the target time source time changes faster relative to the time currently seen by the downstream node. The node sets the switching correction to a negative value, causing the node's output time to decrease relative to the target time source time. When the downstream visible time deviation is negative, it indicates that the target time source time changes slower relative to the time currently seen by the downstream node. The node sets the switching correction to a positive value, causing the node's output time to increase relative to the target time source time. When the downstream visible time deviation is zero, the node writes the switching correction to zero, and the target time source time is directly used as the node's output time. The switching correction only applies to the node's output time generation process and does not write back or change the target time source time mapping record.

[0062] S6. After the time source is switched, the switching correction amount is updated according to the return timestamps corresponding to the subsequent paired test time messages, based on the preset frequency adjustment limit.

[0063] Specifically, after the time source switch is completed, the node continues to periodically send paired test time messages to downstream nodes and continues to receive the received timestamps returned by downstream nodes. These paired test time messages are used to determine the remaining impact of the current switch correction on the downstream receiver, rather than to reselect a target time source. Within each correction cycle, the node calculates the remaining downstream visible time deviation and limits the maximum step size for the switch correction to converge to zero based on a preset frequency adjustment limit, ensuring that the adjustment of the node's output time relative to the target time source time does not exceed the node's allowed change in output time slope.

[0064] Furthermore, in one embodiment of the present invention, updating the switching correction amount according to the preset frequency adjustment limit includes: After the time source is switched, the pair of test time messages after the switch continues to be sent. The first test time message in the pair of test time messages after the switch carries the node output timestamp after the switch correction amount is superimposed, and the second test time message carries the target time source timestamp without the switch correction amount being superimposed. Calculate the remaining downstream visible time deviation based on the received timestamp of the downstream node's back transmission of the paired test time messages after the switch. The switching correction amount is gradually converged toward zero in such a way that each correction cycle does not exceed the preset frequency adjustment limit. The preset frequency adjustment limit is used to limit the maximum adjustment amount of the node output time relative to the target time source time in each correction cycle. When the number of effective downstream nodes is lower than a preset quantity condition or the dispersion of the remaining downstream visible time deviations corresponding to multiple effective downstream nodes exceeds a preset dispersion threshold, the switching correction amount is paused to converge to zero, and the output time of the current node is kept continuous.

[0065] Specifically, after the switch, the first During each correction cycle, when a node generates the first test time message, it reads the current node's output time. The node output timestamp after overlaying the handover correction is written into the first test time message; when generating the second test time message, the target time source time without overlaying the handover correction is read. The target time source timestamp is written into the second test time message. Downstream nodes still transmit the corresponding received timestamp based on their local output time. Nodes select the effective downstream nodes after the switch according to the effective downstream node selection method in S4, and then calculate the remaining downstream visible time deviation corresponding to each effective downstream node.

[0066] In one embodiment, after the switch, the effective downstream node is targeted. and correction cycle The remaining downstream visible time deviation is calculated as follows:

[0067]

[0068]

[0069] in, This indicates the node output timestamp after the handover correction is added, carried in the first test time message after the handover. This indicates the target time source timestamp, without the superimposed handover correction, carried in the second test time message after the handover. and These represent the timestamps received by the downstream node for the paired test time messages returned after the handover. This indicates that the effective downstream node is at the 1st rank. The remaining downstream visible time deviation corresponding to each correction cycle. The node will correspond to multiple valid downstream nodes. Write the deviation table after the switch, and sort, process the median, and determine the degree of dispersion.

[0070] In one embodiment, the preset frequency adjustment limit is represented by the maximum time adjustment allowed per correction cycle, denoted as . When the configuration table provides a frequency slope limit. and correction cycle duration At that time, the node is... The maximum adjustment amount of the node output time relative to the target time source time within each correction cycle is calculated. If the current switching correction amount is... If the number of valid downstream nodes in the deviation table after the switch meets the preset quantity condition, and the dispersion of the remaining downstream visible time deviations does not exceed the preset dispersion threshold, then multiple nodes will be selected first. The median is used as the median of the residual deviation for that correction period. .when symbols and When the signs are opposite, it indicates that reducing the current switching correction amount is beneficial for bringing the node's output time closer to the target time source time; the node updates the switching correction amount as follows:

[0071]

[0072] in, Indicates the first The adjustment amount of the switching correction amount per correction cycle. Indicates the first The amount of handover correction that takes effect in each correction cycle. This indicates the amount of handover adjustment that will take effect in the next adjustment cycle. This represents the sign function of the median of the residual bias. The update rule is constrained by the median of the residual bias, the absolute value of the current switching correction, and a preset frequency adjustment limit, ensuring that the switching correction changes towards zero each time and preventing the adjustment of the node output time relative to the target time source from exceeding a certain value within a single correction cycle. .like symbols and If the signs are the same, or the dispersion of the remaining downstream visible time deviations corresponding to multiple valid downstream nodes exceeds a preset dispersion threshold, the node is frozen. The zero-convergence update for that cycle will not be performed.

[0073] In one example, if the current switching correction amount The preset frequency adjustment limit is -62.5 nanoseconds. The median remaining deviation for the current correction period is 10 nanoseconds. If it is positive 18 nanoseconds, then and With the signs reversed, the node takes the minimum value of 10 nanoseconds among 18 nanoseconds, 62.5 nanoseconds, and 10 nanoseconds, and the adjustment amount is obtained according to the positive sign. Nanosecond, after update Nanosecond. If the next cycle The value remains negative, while the median of the remaining deviation becomes -8 nanoseconds. Since both have the same sign, it indicates that continuing to converge towards zero may amplify the downstream deviation. The node keeps the periodic switching correction unchanged and waits for the subsequent return timestamp to make another judgment.

[0074] The dispersion of the remaining downstream visible time deviation can be determined by the difference between the maximum and minimum values, the interquartile range, or the standard deviation. In one embodiment, the difference between the maximum and minimum values ​​is used as the dispersion. If this difference is greater than a preset dispersion threshold, it is considered that the feedback of different downstream nodes on the remaining deviation is inconsistent. The node pauses to allow the handover correction amount to converge to zero, while maintaining the continuity of the current node's output time. During the pause, the node continues to send paired test time messages after the handover. When the number of valid downstream nodes and the dispersion amount meet the conditions for a subsequent preset number of consecutive times, the handover correction amount is updated according to the preset frequency adjustment limit.

[0075] This embodiment also provides a continuous operation example to illustrate the implementability of the above method. A node connects to the current time source A, candidate time source B, and candidate time source C, and publishes its output time to downstream nodes D1, D2, and D3. The local counter has a counting frequency of 100 MHz and a counting resolution of 10 nanoseconds; the test window is 200 milliseconds; the preset transmission interval is 50 milliseconds; the preset return latency range is 1 to 20 milliseconds; the preset port jitter threshold is 80 nanoseconds; the preset quantity condition is at least two valid downstream nodes; and the preset correctable range is 500 nanoseconds.

[0076] During the candidate time source pre-selection phase, the node sends paired test time messages with candidate time source B as the temporary target time source, obtaining downstream visible time deviations of 60 nanoseconds, 65 nanoseconds, and 210 nanoseconds for D1, D2, and D3, respectively. The difference between 210 nanoseconds and the median of 65 nanoseconds exceeds the preset port jitter threshold and is marked as an abnormal downstream node. The remaining D1 and D2 meet the preset quantity condition, and the re-determined candidate deviation is 62.5 nanoseconds. The node then uses candidate time source C as the temporary target time source, obtaining a candidate deviation of 180 nanoseconds. Since neither exceeds the preset correctable range, the node determines candidate time source B, with the smaller absolute value of the candidate deviation, as the target time source.

[0077] During the formal handover phase, the node determines the handover correction to be -62.5 nanoseconds based on the downstream visible time deviation of 62.5 nanoseconds, and generates this correction when the target timing source B takes over the output. The node outputs the time. After the switchover, the maximum allowable adjustment amount for each correction cycle is 10 nanoseconds. If the number of valid downstream nodes is no less than 2 in each of the 1st to 5th correction cycles and the dispersion of the remaining downstream visible time deviation does not exceed the preset dispersion threshold, the switchover correction amount is adjusted sequentially from -62.5 nanoseconds to -52.5 nanoseconds, -42.5 nanoseconds, -32.5 nanoseconds, -22.5 nanoseconds, and -12.5 nanoseconds. If the difference between the remaining downstream visible time deviations corresponding to D1 and D2 exceeds the preset dispersion threshold in a certain cycle, the node keeps the switchover correction amount unchanged for that cycle and continues to send paired test time messages after the switchover, waiting for the determination in the next cycle.

[0078] Please see Figure 6 , Figure 6 This invention provides a system structure diagram of a node clock skew correction system under multiple time source switching. The invention also provides a node clock skew correction system under multiple time source switching, used to implement the aforementioned node clock skew correction method under multiple time source switching, comprising: The time sample acquisition module is used to acquire time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples. The test message sending module is used to send a pair of test time messages to at least one downstream node when the node does not switch the external output time. The pair of test time messages includes a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. The timestamp return module is used to receive the first and second timestamps returned by the downstream node based on its local output time. The visible deviation determination module is used to determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. The switching output module is used to determine the switching correction amount based on the downstream visible time deviation, and to superimpose the target time source time and the switching correction amount during time source switching to generate the node output time. The post-switching correction module is used to update the switching correction amount according to the return timestamps corresponding to the subsequent paired test time messages after the time source is switched, adjusting the limit at a preset frequency.

[0079] Specifically, the time sample acquisition module can be deployed in the node's time synchronization input processing unit, connecting the current time synchronization source input channel, the target time synchronization source input channel, the local counter, and the channel calibration delay configuration table to generate a time synchronization source time mapping record. The test message sending module can be deployed in the node's Ethernet message processing unit, reading the time synchronization source time mapping record, the downstream node test table, and the output port configuration table to generate and send the first and second test time messages. The return timestamp receiving module parses the downstream node's return messages and writes the first and second receive timestamps, along with the node's local counter value when receiving the return message, into the return record table. The visible deviation determination module reads the sending record table and the return record table, calculates the return delay, sending time interval, receiving time interval, and downstream visible time deviation, and performs effective downstream node filtering, median processing, and abnormal downstream node marking. The switching output module reads the target time synchronization source time, the downstream visible time deviation, and the switching correction amount to control the node output time generation unit to generate the node output time. After the switchover, the correction module periodically calls the test message sending module and the return timestamp receiving module, and updates the switchover correction amount based on the remaining downstream visible time deviation and the preset frequency adjustment limit.

[0080] Please see Figures 3 to 5 , Figure 3 This is a downstream visible time deviation comparison diagram for a node clock deviation correction method under multiple time source switching provided by the present invention. Figure 4 This invention provides an effective downstream node selection distribution diagram for a node clock skew correction method under multiple timing source switching. Figure 5 This invention provides a convergence trend diagram of the switching correction amount for a node clock deviation correction method under multiple time source switching. In experimental verification, this invention sets up 30 time source switching tests, 3 downstream nodes, the same test window, and the same preset transmission interval. The control scheme is one where the target time source directly takes over the node's output time without adding a switching correction amount. The invention's scheme adds the switching correction amount based on the downstream visible time deviation. During the experiment, the downstream visible time deviation is calculated using the transmission and reception time intervals under the same test sequence number, and the median and maximum absolute deviation are statistically analyzed. Figure 3 It can be seen that the median downstream visible time deviation of the control scheme is 78 nanoseconds and the maximum absolute deviation is 126 nanoseconds. After adding the switching correction, the median downstream visible time deviation is reduced to 14 nanoseconds and the maximum absolute deviation is reduced to 32 nanoseconds. This shows that the switching correction can offset the visible time jump variable of the downstream node when the timing source takes over the output time of the node.

[0081] Depend on Figure 4 It can be seen that in the process of selecting effective downstream nodes, the first step is to determine whether the downstream node is included in the deviation statistics based on the backhaul latency. Figure 4 The backhaul delays of D1, D2 and D3 shown on the left are approximately 8 milliseconds, 9 milliseconds and 12 milliseconds respectively, all within the preset backhaul delay range of 1 millisecond to 20 milliseconds. Therefore, they continue to the downstream visible time deviation screening. Figure 4 The right side further shows that the downstream visible time deviations corresponding to D1 and D2 are near the median deviation, and are thus considered valid downstream nodes in the median deviation determination. The downstream visible time deviation corresponding to D3 deviates significantly from the median deviation and exceeds the preset port jitter threshold, and is therefore marked as an abnormal downstream node. When analyzing the backhaul data of 15 downstream nodes, 3 groups were removed because their backhaul latency exceeded the preset backhaul latency range or deviated from the median deviation by more than the preset port jitter threshold. Before removal, the deviation dispersion was 94 nanoseconds; after removal, the deviation dispersion was 18 nanoseconds. This indicates that removing abnormal downstream nodes can reduce the impact of single port jitter or abnormal backhaul on node switching correction.

[0082] Depend on Figure 5 It can be seen that after the time source is switched, the switching correction amount is not canceled all at once, but gradually converges to zero under the constraint of the preset frequency adjustment limit. Figure 5 As shown above, the switching correction amount is adjusted sequentially from the initial -62.5 nanoseconds to -52.5 nanoseconds, -42.5 nanoseconds, and -32.5 nanoseconds, with the adjustment amount in each adjacent correction cycle not exceeding 10 nanoseconds; when the pause condition is triggered in the 4th correction cycle, the switching correction amount remains at -32.5 nanoseconds to maintain the continuity of the current node's output time; subsequently, it is adjusted to -22.5 nanoseconds, -12.5 nanoseconds, and -7.5 nanoseconds. Figure 5 As shown below, the remaining downstream visible time deviation decreased from 18 nanoseconds to 6 nanoseconds overall, with a brief rebound of 22 nanoseconds in the 4th correction cycle, corresponding to the upper pause that caused the switching correction amount to converge to zero. Thus, this invention, through a combination of "constrained convergence" and "abnormal pause," allows the node output time to gradually approach the target time source time after the time source switch, while avoiding new time abrupt changes caused by excessive single-cycle adjustments or downstream backhaul dispersion.

[0083] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0084] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for correcting node clock skew under multiple time source switching, characterized in that, include: S1. Obtain time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples; S2. If the node does not switch its external output time, send a pair of test time messages to at least one downstream node. The pair of test time messages include a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. S3. Receive the first and second timestamps returned by the downstream node based on its local output time. S4. Determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. S5. Determine the switching correction amount based on the downstream visible time deviation, and add the target time source time and the switching correction amount together when switching the time source to generate the node output time; S6. After the time source is switched, the switching correction amount is updated according to the return timestamps corresponding to the subsequent paired test time messages, based on the preset frequency adjustment limit.

2. The node clock deviation correction method under multiple time source switching according to claim 1, characterized in that, The time sample includes the time source identifier, source timestamp, second pulse arrival time, local count value, input channel identifier, and channel calibration delay; Determining the correspondence between the time of the time synchronization source and the local count value of the node includes determining the time deviation of the corresponding time synchronization source relative to the local count value of the node based on the source timestamp, the local count value corresponding to the arrival time of the second pulse, and the channel calibration delay.

3. The node clock deviation correction method under multiple time source switching according to claim 1, characterized in that, Sending paired test time messages to at least one downstream node includes: For each downstream node, select the same output port corresponding to that downstream node within the same test window, and keep the message length and transmission priority the same. Write the same test sequence number and node local transmission count value into the first test time message and the second test time message respectively, and write the current time synchronization source transmission timestamp into the first test time message and the target time synchronization source transmission timestamp into the second test time message; The first test time message and the second test time message are sent to the downstream node at preset intervals.

4. The node clock deviation correction method under multiple time source switching according to claim 3, characterized in that, The determination of downstream visible time deviation includes: For each downstream node, the return latency of the downstream node is calculated based on the node's local transmission count value and the node's local count value when receiving the return message from the downstream node. Valid downstream nodes are obtained by filtering downstream nodes that return the first and second receiving timestamps under the same test sequence number and whose return delay is within the preset return delay range. For each valid downstream node, calculate the difference between the target time source sending timestamp in the second test time message and the current time source sending timestamp in the first test time message to obtain the sending time interval; Subtract the first receiving timestamp from the second receiving timestamp to obtain the receiving time interval; Subtracting the receiving time interval from the sending time interval yields the downstream visible time deviation corresponding to the effective downstream node. When there are no valid downstream nodes, maintain the current time source outputting time.

5. The node clock deviation correction method under multiple time source switching according to claim 4, characterized in that, When multiple valid downstream nodes exist, determining the downstream visible time deviation also includes: The downstream visible time deviations corresponding to multiple valid downstream nodes are sorted to determine the median deviation; Valid downstream nodes whose difference from the median deviation exceeds a preset port jitter threshold are marked as abnormal downstream nodes. When the number of valid downstream nodes that are not marked as abnormal downstream nodes reaches a preset number condition, the median deviation is re-determined based on the downstream visible time deviation corresponding to the valid downstream nodes that are not marked as abnormal downstream nodes, and the re-determined median deviation is used as the downstream visible time deviation of the node. When the number of valid downstream nodes that are not marked as abnormal is lower than a preset number, the current time source continues to output time.

6. The node clock deviation correction method under multiple timing source switching according to claim 4, characterized in that, Before determining the target time source, each candidate time source is used as a temporary target time source to send the paired test time messages. For each candidate time source, calculate the downstream visible time deviation of each effective downstream node corresponding to the candidate time source, sort the multiple downstream visible time deviations corresponding to the candidate time source, and take the median as the candidate deviation corresponding to the candidate time source. Candidate time sources that meet the preset number of effective downstream nodes and whose absolute value of the candidate deviation does not exceed the preset correctable range are selected to obtain the time source that is allowed to be switched. The time source that is allowed to be switched with the smallest absolute value of the candidate deviation is determined as the target time source.

7. The node clock deviation correction method under multiple time source switching according to claim 4, characterized in that, The step of determining the switching correction amount based on the downstream visible time deviation includes: When the downstream visible time deviation is positive, calculate the negative switching correction amount used to reduce the node output time relative to the target time source time; When the downstream visible time deviation is negative, calculate the positive switching correction amount used to improve the node output time relative to the target time source time; When the downstream visible time deviation is zero, the switching correction amount is set to zero; The node output time is obtained by adding the target time source time to the switching correction amount.

8. A node clock deviation correction method under multiple time source switching according to claim 7, characterized in that, The step of updating the switching correction amount according to the preset frequency adjustment limit includes: After the time source is switched, the pair of test time messages after the switch continues to be sent. The first test time message in the pair of test time messages after the switch carries the node output timestamp after the switch correction amount is superimposed, and the second test time message carries the target time source timestamp without the switch correction amount being superimposed. Calculate the remaining downstream visible time deviation based on the received timestamp of the downstream node's back transmission of the paired test time messages after the switch. The switching correction amount is gradually converged toward zero in such a way that each correction cycle does not exceed the preset frequency adjustment limit. The preset frequency adjustment limit is used to limit the maximum adjustment amount of the node output time relative to the target time source time in each correction cycle. When the number of effective downstream nodes is lower than a preset quantity condition or the dispersion of the remaining downstream visible time deviations corresponding to multiple effective downstream nodes exceeds a preset dispersion threshold, the switching correction amount is paused to converge to zero, and the output time of the current node is kept continuous.

9. A node clock skew correction system under multiple time source switching, characterized in that, A method for correcting node clock skew under multiple timing source switching as described in any one of claims 1 to 8 includes: The time sample acquisition module is used to acquire time samples of the current time source and the target time source at the same node, and determine the correspondence between the time source time and the local count value of the node based on the time samples. The test message sending module is used to send a pair of test time messages to at least one downstream node when the node does not switch the external output time. The pair of test time messages includes a first test time message carrying the timestamp of the current time source and a second test time message carrying the timestamp of the target time source. The timestamp return module is used to receive the first and second timestamps returned by the downstream node based on its local output time. The visible deviation determination module is used to determine the downstream visible time deviation based on the transmission time interval between the first test time message and the second test time message, and the reception time interval between the first reception timestamp and the second reception timestamp. The switching output module is used to determine the switching correction amount based on the downstream visible time deviation, and to superimpose the target time source time and the switching correction amount during time source switching to generate the node output time. The post-switching correction module is used to update the switching correction amount according to the return timestamps corresponding to the subsequent paired test time messages after the time source is switched, adjusting the limit at a preset frequency.

Citation Information

Patent Citations

  • Hybrid time service method based on Beidou satellite navigation and TSN

    CN120639232A

  • Time service synchronous control method for multi-sensor system

    CN121634778A