A bidirectional time synchronization method, system and apparatus

By using timestamp recording and function fitting between master and slave nodes in a co-band positioning system, the problem of high time synchronization resource consumption is solved, and an efficient time synchronization method is achieved, reducing the consumption of communication and computing resources.

CN116546610BActive Publication Date: 2026-11-27BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310414681.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-18
Publication Date
2026-11-27
Estimated Expiration
2043-04-18

AI Technical Summary

Technical Problem

The time synchronization methods in existing co-band positioning systems consume a large amount of communication and computing resources, resulting in a waste of these resources.

Method used

By recording timestamps within the interaction cycle through master and slave nodes, and performing function fitting to calculate clock drift coefficients and initial phase, the transmission of time information in the interaction signal is reduced, and clock synchronization is performed using the fitting results.

Benefits of technology

It achieves high-precision time synchronization, reduces communication resource consumption and computational complexity, and lowers communication overhead and computing power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116546610B_ABST
    Figure CN116546610B_ABST
Patent Text Reader

Abstract

The application provides a bidirectional time synchronization method, system and device, a communication link is established based on a bidirectional time synchronization mechanism of a sender and a receiver, and the number of signal interaction cycles between a master node and a slave node is preset. Time stamps are recorded locally at the master node and the slave node respectively in the cycle. After the preset cycle is completed, the local time stamps are fitted by a function respectively at the master node and the slave node to obtain time characteristic values of the master node and the slave node. In the next interaction cycle, the time characteristic values are sent by the master node to the slave node. Based on a time relationship of the master node and the slave node, the clock phase difference and the clock drift coefficient ratio of the master node and the slave node are calculated at the slave node according to the time characteristic values of the master node and the slave node, and the time synchronization is completed at the slave node according to the calculated results. The technology reduces the frequency of exchanging time information in the communication process, greatly reduces the communication overhead and the calculation power loss, and ensures a high-precision time synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of time synchronization technology in communication technology, and in particular to a two-way time synchronization method, system and device. Background Technology

[0002] Co-band positioning systems are a novel and promising communication and navigation fusion system. By combining wireless communication networks and positioning and navigation networks and leveraging their respective advantages, co-band positioning systems achieve high-precision positioning in constrained scenarios. The accuracy of the wireless time synchronization algorithm is one of the key factors affecting positioning accuracy.

[0003] Currently, time synchronization in co-band positioning systems employs bidirectional time synchronization communication based on TPSN. This method sends time information with each communication and performs time synchronization calculations during each communication, achieving high-precision time synchronization through repeated calculations. This means that existing technologies require continuous interaction and synchronization calculations between the two nodes, consuming significant communication and computing resources. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a bidirectional time synchronization communication method to eliminate or improve one or more defects existing in the prior art, so as to solve the problem of high communication and computing resource overhead in traditional communication methods.

[0005] One aspect of the present invention provides a bidirectional time synchronization method, the method comprising the following steps: The master node and the slave node establish a communication link; The master node and the slave node perform signal synchronization interaction. Within one interaction cycle, the slave node first sends a first synchronization signal to the master node and receives a second synchronization signal fed back by the master node. The slave node records a first timestamp of sending the first synchronization signal and a second timestamp of receiving the second synchronization signal, which are generated locally. The master node records a third timestamp of receiving the first synchronization signal and a fourth timestamp of sending the second synchronization signal, which are generated locally. After executing multiple interaction cycles, the master node performs a linear function fit on the third and fourth timestamps corresponding to each interaction cycle recorded locally to obtain a first linear function. The slope of the first linear function is used as the master clock drift coefficient, and the intercept of the first linear function is used as the master clock initial phase. The slave node performs a linear function fit on the first and second timestamps corresponding to each interaction cycle recorded locally to obtain a second linear function. The slope of the second linear function is used as the slave clock drift coefficient, and the intercept of the second linear function is used as the slave clock initial phase. After each interaction cycle ends, the master node sends the master clock drift coefficient, the master clock initial phase, and the fifth timestamp as time feature information to the slave node at the fifth timestamp of the local time. Based on the master clock drift coefficient and the slave clock drift coefficient, establish the relationship between the local time of the master node and the local time of the slave node at the same moment, and derive the expression for the clock phase difference between the master node and the slave node. Calculate the clock phase difference using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the initial phase of the master clock, and the initial phase of the slave clock. The ratio of the clock drift coefficients of the slave node and the master node can be calculated from the slave clock drift coefficient and the master clock drift coefficient. Perform clock synchronization operation based on the clock phase difference and the clock drift coefficient ratio.

[0006] In some embodiments, the interaction cycle is executed at least 30 times.

[0007] In some embodiments, the master node performs a linear function fitting on the third timestamp and the fourth timestamp corresponding to each interaction period recorded locally to obtain a first linear function, including: After averaging the third and fourth timestamps corresponding to each interaction cycle, the first linear function is obtained by fitting the average values ​​using the least squares method, and its expression is: ; in, This represents the local time of the master node. Represents a time variable. This represents the master clock drift coefficient obtained through fitting. This represents the initial phase of the master clock obtained through fitting; The second linear function is obtained by performing a linear function fit on the first timestamp and the second timestamp corresponding to each interaction period recorded locally by the slave node, including: After averaging the first and second timestamps for each interaction cycle, the second linear function is obtained by fitting the averages using the least squares method. The expression is as follows: ; in, This indicates the local time of the slave node. Represents a time variable. The clock drift coefficient obtained from the fitting is represented as... The initial phase of the clock obtained from the fitting is represented.

[0008] In some embodiments, the method further includes: The master node stores the third and fourth timestamps corresponding to each interaction cycle in the first storage space of the master node's local hardware. The slave node stores the first timestamp and the second timestamp corresponding to each interaction cycle in the second storage space of the slave node's local hardware.

[0009] In some embodiments, the relationship between the local time of the master node and the local time of the slave node at the same moment is established based on the master clock drift coefficient and the slave clock drift coefficient. The relationship is as follows: ; ; in, This indicates the local time of the slave node. This represents the local time of the master node. This indicates the actual initial clock phase of the master node. This represents the clock drift coefficient. This represents the master clock drift coefficient. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This represents the initial phase difference between the master and slave clocks.

[0010] In some embodiments, deriving an expression for the clock phase difference between the master node and the slave node, and calculating the clock phase difference using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the master clock initial phase, and the slave clock initial phase, includes: The expression for calculating the initial phase difference between the master and slave clocks based on the aforementioned relationship is as follows: ; and and By combining the two equations, we get: ; in, This indicates the local time of the slave node. This represents the local time of the master node. This indicates the actual initial clock phase of the master node. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; Based on the relationship between the local time of the master node and the local time of the slave node at the same moment, the formula for calculating the slave node's time when the master node sends the time feature information is as follows: ; in, This indicates the time of the slave node when the master node sends the time feature information. This represents the fifth timestamp. This indicates the actual initial clock phase of the master node. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; The difference between the slave node's time and the fifth timestamp when the master node sends the time feature information is the phase difference between the master and slave clocks at that moment, calculated as follows: ; Introduction ,get: ; in, This represents the fifth timestamp. This indicates the actual initial clock phase of the master node. This represents the initial phase of the master clock obtained through fitting, where... , This represents the ratio of the clock drift coefficient between the slave clock and the master clock.

[0011] In some embodiments, before the master node and the slave node establish a communication link, the method further includes: The slave node performs timing and initiates bidirectional time synchronization at set time intervals.

[0012] In some embodiments, the method further includes: The standard deviation is calculated from the clock phase difference and clock drift coefficient obtained by the slave node through multiple calculations. The standard deviation is compared with a preset warning value. When the standard deviation is greater than or equal to the preset warning value, an alarm message is generated.

[0013] Another aspect of the present invention provides a bidirectional time synchronization system, the system including at least one master node and a slave node; both the master node and the slave node include a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the master node and the slave node in the system implement the steps of the above method.

[0014] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the above-described method.

[0015] The beneficial effects of the present invention are at least as follows: The bidirectional time synchronization method, system, and apparatus described in this invention require that during the first N interaction cycles, the master and slave nodes only record the local timestamps when transmitting and receiving synchronization signals, without additionally packaging time information into the interaction signals, thus reducing errors in the packed time information. After the Nth interaction cycle, the master and slave nodes respectively perform linear function fitting on the locally recorded timestamps to obtain the master clock drift coefficient and initial phase of the master clock, as well as the slave clock drift coefficient and initial phase of the slave node. By establishing a relationship between the local time of the master node and the local time of the slave node at the same moment, the clock phase difference between the master node and the slave node is derived and calculated based on the local timestamp of the interaction signal transmitted by the master node, the master clock drift coefficient, the master clock initial phase, the slave clock drift coefficient, and the slave clock initial phase. The clock drift coefficient ratio between the slave node and the master node is calculated from the slave clock drift coefficient and the master clock drift coefficient. Clock synchronization operation is performed based on the clock phase difference and the clock drift coefficient ratio.

[0016] This invention requires only a minimal amount of time information to achieve time synchronization, consumes minimal resources and time during computation, and features a simple and easy-to-implement algorithm. It significantly reduces communication resource consumption while maintaining a high degree of time accuracy.

[0017] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the description, or may be learned by practice of the invention. The objects and other advantages of the invention can be realized and obtained by means of the structures specifically pointed out in the description and drawings.

[0018] Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable with the present invention will become clearer from the following detailed description. Attached Figure Description

[0019] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, are not intended to limit the scope of the invention. In the drawings: Figure 1 This is a flowchart of a bidirectional time synchronization method according to an embodiment of the present invention.

[0020] Figure 2 This is a schematic diagram of the signal transmission cycle in a bidirectional time synchronization method according to an embodiment of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.

[0022] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.

[0023] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.

[0024] During device communication, timestamps are needed to mark the order of information or program execution. Each hardware component uses a local clock for timing. This clock utilizes the high-precision and stable oscillation characteristics of a crystal oscillator to convert the clock signal into a counting signal based on the crystal oscillation period. Under relatively stable operating conditions, the crystal oscillator frequencies of each hardware component will not change significantly. However, due to manufacturing variations in each hardware component, there are certain differences in crystal oscillator frequencies between different devices. This can lead to a difference between the actual time and the real time on different devices, resulting in time errors between them. It should be noted that the actual time is the time corresponding to the device's local timekeeping, i.e., the local timestamp, while the real time refers to the actual standard time.

[0025] To achieve high-precision time synchronization, traditional methods send timestamp information with each communication, repeatedly performing time synchronization calculations to achieve high accuracy. While this method can achieve fairly high-precision time synchronization, it often consumes a large amount of communication resources: each communication transmits time information, and the slave node performs calculations and adjustments, meaning that a significant portion of communication resources is used to maintain high-precision time synchronization between the master and slave nodes over a period of time, consuming other communication resources and also significantly depleting the computing resources of both the master and slave nodes. To address this, the present invention provides a bidirectional time synchronization method, system, and apparatus.

[0026] Specifically, this embodiment provides a bidirectional time synchronization method. This method is used to operate on two communicating entities, which can be different main devices in a communication or positioning system, or different components in an electronic device establishing communication. The method is as follows... Figure 1 As shown, the process includes the following steps S101 to S105: Step S101: The master node and the slave node establish a communication link.

[0027] Step S102: The master node and the slave node perform signal synchronization interaction. Within one interaction cycle, the slave node first sends a first synchronization signal to the master node and receives a second synchronization signal fed back by the master node. The slave node records the first timestamp of sending the first synchronization signal and the second timestamp of receiving the second synchronization signal, which are generated locally. The master node records the third timestamp of receiving the first synchronization signal and the fourth timestamp of sending the second synchronization signal, which are generated locally.

[0028] Step S103: After executing multiple interaction cycles, the master node performs a linear function fitting on the third and fourth timestamps recorded locally for each interaction cycle to obtain a first linear function. The slope of the first linear function is used as the master clock drift coefficient, and the intercept of the first linear function is used as the master clock initial phase. The slave node performs a linear function fitting on the first and second timestamps recorded locally for each interaction cycle to obtain a second linear function. The slope of the second linear function is used as the slave clock drift coefficient, and the intercept of the second linear function is used as the slave clock initial phase.

[0029] Step S104: After each interaction cycle ends, the master node sends the master clock drift coefficient, the master clock initial phase, and the fifth timestamp as time feature information to the slave node at the fifth timestamp of the local time.

[0030] Step S105: Establish the relationship between the local time of the master node and the local time of the slave node at the same moment based on the master clock drift coefficient and the slave clock drift coefficient, and derive the expression for the clock phase difference between the master node and the slave node. Calculate the clock phase difference using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the initial phase of the master clock, and the initial phase of the slave clock. The ratio of the clock drift coefficients of the slave node and the master node can be calculated from the slave clock drift coefficient and the master clock drift coefficient. Perform clock synchronization operation based on the clock phase difference and the clock drift coefficient ratio.

[0031] In step S101, the master node and slave node pre-set an interaction cycle. To ensure the fitting effect of the linear function in the subsequent step S103, the interaction cycle is executed at least 30 times. To balance synchronization efficiency and saving computing power, the number of times the interaction cycle is executed is preferably 30 times in this embodiment. In other embodiments, the number of times the interaction cycle is executed can be adjusted according to the needs of specific application scenarios.

[0032] In step S102, the first synchronization signal and the second synchronization signal are communication signals with a preset format, which may include frame header information, node identification identifier, frame data, and frame tail information. During the first N interaction cycles, the first and second synchronization signals are only used for alternating responses, but do not transmit other data information related to the interaction time. During the first N interaction cycles of clock synchronization, the master node and slave node, in addition to executing the alternating response of the first and second synchronization signals, only record the timestamps of locally sending and receiving the first and second synchronization signals.

[0033] In step S103, the local timestamps of the master and slave nodes are generated based on their local crystal oscillators, which differ from the real time. Due to the frequency difference of the local crystal oscillators, the timestamps generated by the master and slave nodes at the same moment also differ. However, it should be noted that since the frequency of the crystal oscillator is stable under stable conditions, the clock drift coefficients between the local clocks of the master and slave nodes and the real time are also stable. Therefore, a stable conversion relationship can be established between the local clocks of the master and slave nodes. Based on this, after multiple interaction cycles, the timestamps recorded locally by the master and slave nodes can be obtained by fitting a linear function to obtain the master clock drift coefficient, the master clock initial phase, the slave clock drift coefficient, and the slave clock initial phase.

[0034] Specifically, in step S103, the master node performs a linear function fitting on the third and fourth timestamps corresponding to each interaction period recorded locally to obtain a first linear function. This includes: averaging the third and fourth timestamps corresponding to each interaction period, and then fitting the average values ​​using the least squares method to obtain the first linear function, the expression of which is: ; in, Indicates the local time of the master node. Represents a time variable. This represents the master clock drift coefficient obtained from the fitting. This represents the initial phase of the master clock obtained through fitting. Here, the master clock drift coefficient refers to the ratio of the master clock time to the standard time.

[0035] In step S103, the slave node performs a linear function fitting on the first and second timestamps corresponding to each interaction cycle recorded locally to obtain a second linear function. This includes: averaging the first and second timestamps corresponding to each interaction cycle, and then fitting the average values ​​using the least squares method to obtain the second linear function, the expression of which is: ; in, Indicates the local time of the node. Represents a time variable. This represents the clock drift coefficient obtained from the fitting. This represents the initial phase of the fitted clock. Here, the clock drift coefficient refers to the ratio of the clock time to the standard time.

[0036] In step S104, after the current N interaction cycles are completed, the master node sends the time feature information and its local fifth timestamp when sending the time feature information to the slave node. The difference between the slave node's time and the fifth timestamp when the master node sends the time feature information in cycle N+1 is the current clock phase difference between the master and slave nodes. It should be noted that when the master node sends the time-frequency information in cycle N+1, the slave node's time is an unknown quantity.

[0037] In step S105, since the master clock drift coefficient and slave clock drift coefficient are stable values, a relationship between the local time of the master node and the local time of the slave node at the same moment can be established.

[0038] Specifically, in establishing the relationship between the local time of the master node and the local time of the slave node at the same moment based on the master clock drift coefficient and the slave clock drift coefficient, the relationship is as follows: ; ; in, Indicates the local time of the node. Indicates the local time of the master node. This indicates the actual initial clock phase of the master clock. Indicates the clock drift coefficient, Indicates the master clock drift coefficient. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This represents the initial phase difference between the master and slave clocks.

[0039] Furthermore, deriving the expression for the clock phase difference between the master node and the slave node, and calculating the clock phase difference using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the initial phase of the master clock, and the initial phase of the slave clock, includes: The expression for calculating the initial phase difference between the master and slave clocks based on the relational formula is as follows: ; and and By combining the two equations, we get: ; in, Indicates the local time of the node. Indicates the local time of the master node. This indicates the actual initial clock phase of the master clock. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; When a slave node receives time feature information, the formula for calculating the slave node's time during the N+1 period when the master node sends time-frequency information locally is: ; in, This indicates the time of the slave node when the master node sends the time feature information. Indicates the fifth timestamp. This indicates the actual initial clock phase of the master node. The ratio of the clock drift factor between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; The difference between the slave node's time and the fifth timestamp when the master node sends time feature information is the phase difference between the master and slave clocks at that moment, calculated as follows: Introduction ,get: According to the above formula, where, It is the fifth timestamp time collected by the master node and sent to the slave node. , and for calculation of , It is obtained based on the fitting in step S103, here Then the clock phase difference between the master and slave nodes can be calculated when the master node sends time characteristic information.

[0040] In some embodiments, the method further includes: The master node stores the third and fourth timestamps corresponding to each interaction cycle in the first storage space of the master node's local hardware. The slave node stores the first and second timestamps corresponding to each interaction cycle in the second storage space of the slave node's local hardware.

[0041] In some embodiments, before step S101, i.e. before the master node and slave node establish a communication link, the method further includes: the slave node performing timing and initiating bidirectional time synchronization at set time intervals. Furthermore, the time synchronization can be initiated based on set time intervals, or corresponding initiation conditions can be set based on actual needs.

[0042] In some embodiments, the method further includes: calculating a standard deviation from the clock phase difference obtained by the slave node through multiple calculations, comparing the standard deviation with a preset warning value, and generating an alarm message when the standard deviation is greater than or equal to the preset warning value.

[0043] The purpose of this embodiment is to evaluate the discreteness of the clock phase difference generated by multiple synchronizations. If the discreteness level is higher than expected, it proves that the crystal oscillator levels of one or two between the master and slave nodes are not stable, which may indicate a device failure that requires maintenance.

[0044] Another aspect of the present invention provides a bidirectional time synchronization system, including at least one master node and a slave node; both the master node and the slave node include a processor and a memory, the memory stores computer instructions, and the processor is used to execute the computer instructions stored in the memory. When the computer instructions are executed by the processor, the master node and the slave node in the system implement the steps of the above method.

[0045] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the above-described method.

[0046] Specifically, this invention proposes a bidirectional time synchronization method based on sender and receiver. In this method, the master node and slave node each locally record the timestamps of the synchronization signal transmission and reception during N communication cycles. The master and slave nodes calculate time feature values ​​based on their locally recorded timestamps. Then, the master node sends the calculated time feature values ​​to the slave node in the (N+1)th interaction cycle. The slave node uses the time feature values ​​calculated by the master node to calculate the phase difference between the master and slave clocks and adjusts its local clock accordingly, achieving high-precision time synchronization.

[0047] The timestamp is the time information recorded based on the actual time of the clock; the time characteristic value refers to the characteristic information expressing the clock information, including the clock drift coefficient and the initial phase of the clock; the clock phase difference refers to the phase difference between two clocks, which is the time difference. For example... Figure 2 As shown, the method includes the following steps S201~S209: Step S201: The master and slave nodes establish a communication link to ensure effective communication between them. The synchronization signal period has also been set.

[0048] Step S202: The slave node initiates the transmission of a synchronization signal, and at the time of transmission, the slave node records the timestamp of the transmission locally, denoted as . .

[0049] Step S203: The master node receives the synchronization signal transmitted by the slave node and records the timestamp of receiving the synchronization signal locally on the master node, denoted as . .

[0050] Step S204: The master node starts transmitting a synchronization signal according to the settings, and records the timestamp of the transmission of the synchronization signal locally on the master node, denoted as . .

[0051] Step S205: The slave node receives the synchronization signal transmitted by the master node and records the timestamp of the transmitted synchronization signal locally on the slave node, denoted as . .

[0052] Step S206: Repeat steps S202-S205 to transmit and receive communication signals. This achieves signal communication for the set N cycles.

[0053] Step S207: After the master and slave nodes have completed N periodic signal communication, they calculate the time feature value locally according to the recorded discrete timestamps and the time synchronization algorithm.

[0054] Step S208: In the N+1th communication cycle, the master node sends the locally calculated time feature value to the slave node.

[0055] Step S209: The slave node receives the time characteristic value transmitted by the master node, and calculates the clock phase difference and clock drift coefficient ratio between the master and slave clocks based on the time characteristic value calculated locally by the slave node, thus completing time synchronization.

[0056] The time synchronization algorithm in this invention will be described below with reference to a specific embodiment: The frequency of a crystal oscillator refers to how many times the crystal oscillator oscillates per second in real time, which is the actual standard time. Due to inherent manufacturing errors in the hardware, the crystal oscillator frequencies of different clocks vary, so the manufactured clock will always differ from the actual time T. Under stable temperature conditions, the clock frequency and the crystal oscillator frequency itself do not change significantly. The ratio between the master / slave clock and the actual time T is relatively fixed, and this ratio is represented by the clock drift factor. Therefore, the relationship between the master / slave clock and the actual time can be expressed by a linear function formula. After data acquisition, the timestamp information of the slave clock and the master clock is shown in the table below: Table 1. Timestamp Information of Slave Clock and Master Clock After collecting N sets of time information, from node T 1,K T 4,K As a group, the master node is named T 2,K T 3,K For each set of time information collected locally by the slave and master nodes, the average value is calculated. This average value is called the average time information. The slave and master nodes then perform a linear function fit on the collected average time information locally. The master node obtains the following functions: ; (2-1) The following functions are obtained from the node: ; (2-2) in Master clock time, For clock time, The fitted master clock drift coefficients are... The fitted clock drift coefficients are... The initial phase of the fitted master clock. The initial phase of the fitted clock.

[0057] The purpose of time synchronization is mainly to ensure that the master and slave clocks have the same drift coefficients and time. Therefore, the time relationship between the master and slave clocks is assumed to be as follows: (2-3) in For clock time, Master clock time, The ratio of the clock drift coefficient between the slave clock and the master clock: (2-4) The actual initial clock phase of the master clock. The initial phase difference between the master and slave clocks. The initial clock phase refers to the time displayed by the master clock when time synchronization begins; the initial phase difference refers to the time difference between the two clocks when time synchronization begins.

[0058] Therefore, when starting time synchronization, we can obtain the following using formula (2-3): By combining formulas (2-1) and (2-2), we can further derive: (2-5) According to formula (2-3), when the master node is in period N+1, the time characteristic value of the master node will be... and The message is sent to the slave node, and the master-slave clock time relationship is as follows: (2-6) The phase difference between the master and slave clocks at this point is: (2-7) Substituting formula (2-5) into formula (2-7), we get: .

[0059] At this time We define the transmission time as T when the master node sends the time characteristic value calculated by the master node to the slave node during the N+1 cycle. 1,N+1 .and The time of the slave node when the master node sends the time characteristic value in the N+1 cycle.

[0060] Using this algorithm, the clock drift ratio between the slave clock and the master clock can be calculated as follows: The clock phase differences are as follows: at this time That is, the actual initial phase of the master clock can be replaced by the initial phase of the master clock obtained after fitting.

[0061] In summary, the bidirectional time synchronization method, system, and apparatus of this invention, based on a bidirectional time synchronization mechanism between sender and receiver, predefines the number of signal interaction cycles between the master node and slave node. During these cycles, timestamps are recorded locally on both the master and slave nodes, without additionally packaging the timestamps into the interaction signals, thus reducing errors in timestamp packaging and decoding during each signal interaction. After the predetermined cycle is completed, the master node and slave node perform linear function fitting on their locally recorded timestamps to obtain the master clock drift coefficient and initial phase of the master clock, as well as the slave clock drift coefficient and initial phase of the slave node. In the next interaction cycle, the master node sends its calculated master clock drift coefficient, initial phase, and the local timestamp used when sending the interaction signal for this cycle to the slave node. The clock phase difference between the master and slave nodes is calculated at the slave node. By establishing a relationship between the local time of the master node and the local time of the slave node at the same moment, the clock phase difference between the master and slave nodes is derived based on this relationship, using the master clock drift coefficient, the master clock initial phase, the local timestamp when the master node sends the interaction signal, the slave clock drift coefficient, and the slave clock initial phase. The clock drift coefficient ratio between the slave and master nodes can then be calculated from the slave and master clock drift coefficients. The slave node then completes time synchronization based on the calculated clock phase difference and clock drift coefficient ratio. Compared with traditional bidirectional time synchronization techniques, this technology reduces the frequency of exchanging time information during communication, avoids errors in packaging and decoding timestamps during each signal interaction, has low computational complexity, significantly reduces communication overhead and computing power consumption, and still ensures a certain level of high-precision time synchronization.

[0062] Corresponding to the above method, the present invention also provides an apparatus / system including a computer device, the computer device including a processor and a memory, the memory storing computer instructions, the processor executing the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the apparatus / system performs the steps of the method as described above.

[0063] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the aforementioned edge computing server deployment method. The computer-readable storage medium can be a tangible storage medium, such as random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, floppy disks, hard disks, removable storage disks, CD-ROMs, or any other form of storage medium known in the art.

[0064] Those skilled in the art will understand that the exemplary components, systems, and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Whether implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention. When implemented in hardware, it can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this invention are programs or code segments used to perform the desired tasks. The programs or code segments can be stored in a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried in a carrier wave.

[0065] It should be clarified that the present invention is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of the present invention.

[0066] In this invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or in place of features of other embodiments.

[0067] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations of the embodiments of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A bidirectional time synchronization communication method, characterized in that, The method is executed on a preset communication system, which includes at least one master node and one slave node, and the method includes the following steps: The master node and the slave node establish a communication link; The master node and the slave node perform signal synchronization interaction. Within one interaction cycle, the slave node first sends a first synchronization signal to the master node and receives a second synchronization signal fed back by the master node. The slave node records a first timestamp of sending the first synchronization signal and a second timestamp of receiving the second synchronization signal, which are generated locally. The master node records a third timestamp of receiving the first synchronization signal and a fourth timestamp of sending the second synchronization signal, which are generated locally. After executing multiple interaction cycles, the master node performs a linear function fit on the third and fourth timestamps corresponding to each interaction cycle recorded locally to obtain a first linear function. The slope of the first linear function is used as the master clock drift coefficient, and the intercept of the first linear function is used as the master clock initial phase. The slave node performs a linear function fit on the first and second timestamps corresponding to each interaction cycle recorded locally to obtain a second linear function. The slope of the second linear function is used as the slave clock drift coefficient, and the intercept of the second linear function is used as the slave clock initial phase. After each interaction cycle ends, the master node sends the master clock drift coefficient, the master clock initial phase, and the fifth timestamp as time feature information to the slave node at the fifth timestamp of the local time. Based on the master clock drift coefficient and the slave clock drift coefficient, establish the relationship between the local time of the master node and the local time of the slave node at the same moment, and derive the expression for the clock phase difference between the master node and the slave node. Calculate the clock phase difference using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the initial phase of the master clock, and the initial phase of the slave clock. The ratio of the clock drift coefficients of the slave node and the master node can be calculated from the slave clock drift coefficient and the master clock drift coefficient. Perform clock synchronization operation based on the clock phase difference and the clock drift coefficient ratio.

2. The bidirectional time synchronization communication method according to claim 1, characterized in that, The interaction cycle is executed at least 30 times.

3. The bidirectional time synchronization communication method according to claim 1, characterized in that, The first linear function is obtained by the master node performing a linear function fit on the third and fourth timestamps corresponding to each interaction period recorded locally, including: After averaging the third and fourth timestamps corresponding to each interaction cycle, the first linear function is obtained by fitting the average values ​​using the least squares method, and its expression is: ; in, This represents the local time of the master node. Represents a time variable. This represents the master clock drift coefficient obtained through fitting. This represents the initial phase of the master clock obtained through fitting; The second linear function is obtained by performing a linear function fit on the first timestamp and the second timestamp corresponding to each interaction period recorded locally by the slave node, including: After averaging the first and second timestamps for each interaction cycle, the second linear function is obtained by fitting the averages using the least squares method. The expression is as follows: ; in, This indicates the local time of the slave node. Represents a time variable. The clock drift coefficient obtained from the fitting is represented as... The initial phase of the clock obtained from the fitting is represented.

4. The bidirectional time synchronization communication method according to claim 1, characterized in that, The method further includes: The master node stores the third and fourth timestamps corresponding to each interaction cycle in the first storage space of the master node's local hardware. The slave node stores the first timestamp and the second timestamp corresponding to each interaction cycle in the second storage space of the slave node's local hardware.

5. The bidirectional time synchronization communication method according to claim 3, characterized in that, Based on the master clock drift coefficient and the slave clock drift coefficient, a relationship is established between the local time of the master node and the local time of the slave node at the same moment. The relationship is as follows: ; ; in, This indicates the local time of the slave node. This represents the local time of the master node. This indicates the actual initial clock phase of the master node. This represents the clock drift coefficient. This represents the master clock drift coefficient. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This represents the initial phase difference between the master and slave clocks.

6. The bidirectional time synchronization communication method according to claim 5, characterized in that, The expression for the clock phase difference between the master node and the slave node is derived, and the clock phase difference is calculated using the fifth timestamp, the master clock drift coefficient, the slave clock drift coefficient, the initial phase of the master clock, and the initial phase of the slave clock, including: The expression for calculating the initial phase difference between the master and slave clocks based on the aforementioned relationship is as follows: ; and and By combining the two equations, we get: ; in, This indicates the local time of the slave node. This represents the local time of the master node. This indicates the actual initial clock phase of the master node. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; Based on the relationship between the local time of the master node and the local time of the slave node at the same moment, the formula for calculating the slave node's time when the master node sends the time feature information is as follows: ; in, This indicates the time of the slave node when the master node sends the time feature information. This represents the fifth timestamp. This indicates the actual initial clock phase of the master node. This represents the ratio of the clock drift coefficient between the slave clock and the master clock. This indicates the initial phase difference between the master and slave clocks; The difference between the slave node's time and the fifth timestamp when the master node sends the time feature information is the phase difference between the master and slave clocks at that moment, calculated as follows: ; Introduction ,get: ; in, This represents the fifth timestamp. This indicates the actual initial clock phase of the master node. This represents the initial phase of the master clock obtained through fitting, where... , This represents the ratio of the clock drift coefficient between the slave clock and the master clock.

7. The bidirectional time synchronization communication method according to claim 1, characterized in that, Before the master node and the slave node establish a communication link, the following steps are also included: The slave node performs timing and initiates bidirectional time synchronization at set time intervals.

8. The bidirectional time synchronization communication method according to claim 1, characterized in that, The method further includes: The standard deviation is calculated from the clock phase difference and clock drift coefficient obtained by the slave node through multiple calculations. The standard deviation is compared with a preset warning value. When the standard deviation is greater than or equal to the preset warning value, an alarm message is generated.

9. A system suitable for bidirectional time synchronization communication, characterized in that, The system includes at least one master node and a slave node; both the master node and the slave node include a processor and a memory, the memory storing computer instructions, and the processor executing the computer instructions stored in the memory. When the computer instructions are executed by the processor, the master node and the slave node in the system implement the steps of the method as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1 to 8.