Clock synchronization method of ultra-short-distance shared medium network and related equipment
By employing broadcast timestamps and time status reporting mechanisms in robot-in-body communication, combined with a moving average filtering algorithm and a hierarchical constraint strategy, efficient time synchronization under full-duplex communication is achieved. This solves the problem of excessive processing load on resource-constrained devices in existing technologies and ensures network synchronization accuracy and communication stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-16
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies cannot meet the requirements of full-duplex, low-latency, and highly deterministic data transmission in robot-in-body communication. Furthermore, existing time synchronization methods are too demanding in resource-constrained embedded devices, failing to achieve an oversupply of time synchronization information and dynamic priority adjustment.
By employing a broadcast timestamp oversupply mechanism and a time status report oversupply mechanism, combined with a moving average filtering algorithm and a hierarchical restriction strategy, efficient time synchronization under full-duplex communication is achieved through the collaborative work of master and slave nodes.
It reduces the processing load on slave nodes, ensures the overall network synchronization accuracy, avoids communication interruptions, and is suitable for the application needs of resource-constrained embedded devices in deterministic communication scenarios.
Smart Images

Figure CN121791997A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication technology, and in particular to a clock synchronization method and related equipment for ultra-short-range shared medium networks. Background Technology
[0002] With the rapid development of industrial robots, collaborative robots, and precision automated equipment, the demand for deterministic communication in robot-in-body communication systems is becoming increasingly urgent. In robot-in-body communication scenarios, there is typically a communication requirement between the main control board and dozens of actuators such as motors and sensors, with communication distances usually within an ultra-short range of 1-2 meters. These communication scenarios require full-duplex, low-latency, and highly deterministic data transmission, and both the master and slave nodes are resource-constrained embedded devices.
[0003] Currently, two main industrial bus solutions are used for communication within robots. One is the CAN (Controller Area Network) bus, but it is half-duplex communication, meaning it can only transmit data in one direction at a time, failing to meet the requirements of full-duplex communication. The other is EtherCat (Ethernet for Control Automation Technology), which supports deterministic communication. However, from a communication medium perspective, each node forms a point-to-point standard Ethernet communication link with its upstream neighbor. Each node terminates the link from the upstream and establishes independent communication with the downstream, not belonging to a shared medium network. Furthermore, EtherCat's time synchronization requires each node to perform sequential calculations. Considering the time jitter introduced by each node, achieving accurate time synchronization requires complex calculations to reduce the impact of jitter, placing a heavy burden on resource-constrained nodes.
[0004] For shared-medium networks, existing Wi-Fi networks provide a Timing Synchronization Function (TSF) time synchronization mechanism based on the IEEE 802.11 protocol. The Access Point (AP) acts as the master clock source, periodically sending Beacon frames every 100 milliseconds. These frames contain a precise timestamp of the TSF timer. Terminals receive the Beacon frames, parse the timestamp, and calibrate their own TSF timers. For scenarios requiring high precision, time synchronization can also be achieved using the IEEE 1588 Precision Time Protocol (PTP).
[0005] However, the aforementioned existing technologies have the following limitations: First, the fixed transmission period of the TSF mechanism is difficult to balance; too long a period affects time accuracy, while too short a period results in excessive processing load on the slave nodes. In resource-constrained scenarios such as intra-robot communication, the processing capacity of slave nodes is limited, requiring time synchronization protocols to minimize the impact on other critical tasks. Second, the IEEE 1588 PTP protocol is based on a multi-hop network design, resulting in high protocol complexity, which is unsuitable for the single-hop shared medium network scenario described in this invention. Third, traditional methods do not consider the characteristic that both master and slave nodes can actively send data in a full-duplex shared medium network, making it impossible to achieve an oversupply of time synchronization information and dynamic priority adjustment. Summary of the Invention
[0006] In view of this, the purpose of this invention is to provide a clock synchronization method and related equipment for ultra-short-distance shared medium networks, so as to solve one or more technical problems existing in the prior art and provide at least one beneficial option or create conditions.
[0007] On one hand, embodiments of the present invention provide a clock synchronization method for ultra-short-distance shared medium networks, the method comprising the following steps: The master node inserts broadcast timestamp information into the downlink communication frame and sends it to all slave nodes. The broadcast timestamp information carries the real-time timestamp of the master node. If the master node does not send downlink data for a continuous first preset threshold time, the master node independently sends a broadcast time synchronization frame. After receiving the broadcast timestamp information from the node, the local real-time clock register is updated according to the local preset update period timer when the task scheduling priority allows. The slave node inserts a time status report message into the uplink communication frame and sends it to the master node. The time status report message carries the slave node's real-time timestamp. If the slave node does not send uplink data for a continuous second preset threshold time, the slave node independently sends a time synchronization report frame. After receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp. If the master node detects that the time deviation of the slave node exceeds the first deviation threshold, the master node sends a unicast timestamp message to the slave node. The slave node that receives the unicast timestamp message updates its local real-time clock register in real time and returns an acknowledgment message.
[0008] Optionally, the method further includes: If the master node detects that the time deviation of the slave node continues to exceed the second deviation threshold and the duration exceeds the third preset threshold time, the master node sends a time synchronization alarm to the network management system. The master node takes corresponding restrictive measures based on the degree of time deviation: when the time deviation is greater than the first preset value, the master node instructs the corresponding slave node to enter the receive-only mode; when the time deviation is between the first preset value and the second preset value, the master node instructs the corresponding slave node to increase the duration of the front and back guard bands of the transmission window, and the duration of the front and back guard bands is positively correlated with the degree of deviation.
[0009] Optionally, after receiving the broadcast timestamp information, the slave node updates its local real-time clock register according to a locally preset update period timer, when the task scheduling priority allows, including: The slave node maintains an update cycle timer. When the update cycle timer reaches a preset cycle value, the slave node enters a waiting timestamp state. After receiving a broadcast timestamp message or a unicast timestamp message, the slave node parses the master node's real-time timestamp carried in it, calculates the time offset, updates the local real-time clock register according to the time offset, and resets the update period timer.
[0010] Optionally, after receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp, including: The master node extracts the time status report message from the received uplink frame and parses it to obtain the real-time timestamp of the slave node; The master node obtains the real-time timestamp of the local reception time and calculates the clock difference between the master and slave nodes as the master-slave time deviation; The master node records the historical time deviation data of each slave node, and uses a moving average filtering algorithm to calculate the deviation trend value. When the deviation trend value exceeds the first deviation threshold, the unicast timestamp correction mechanism is triggered.
[0011] On the other hand, embodiments of the present invention provide a clock synchronization device for an ultra-short-distance shared medium network, applied to a master node, comprising: The broadcast timestamp module is used to insert broadcast timestamp information into downlink communication frames and send it to all slave nodes. The broadcast timestamp information carries the real-time timestamp of the master node. If the master node does not send downlink data for a continuous first preset threshold time, it independently sends a broadcast time synchronization frame. The time deviation verification module is used to receive time status report messages sent by slave nodes, the time status report messages carrying the real-time timestamp of the slave nodes; and to verify the time deviation of the corresponding slave nodes based on the real-time timestamp of the master node. The unicast timestamp module is used to send a unicast timestamp message to a slave node when the time deviation of the slave node is detected to exceed a first deviation threshold, and to receive a response message returned by the slave node.
[0012] On the other hand, embodiments of the present invention provide a clock synchronization device for an ultra-short-distance shared medium network, applied to a slave node, comprising: The clock update module is used to receive the broadcast timestamp information sent by the master node and update the local real-time clock register according to the local preset update period timer when the task scheduling priority allows. The time reporting module is used to insert a time status report message into the uplink communication frame and send it to the master node. The time status report message carries the real-time timestamp of the slave node. If the slave node does not send uplink data for a continuous second preset threshold time, it independently sends a time synchronization report frame. The response module is used to update the local real-time clock register in real time and return an acknowledgment message when a unicast timestamp message is received from the master node.
[0013] On the other hand, embodiments of the present invention provide a clock synchronization system for an ultra-short-range shared medium network, including a master node and multiple slave nodes. The master node includes the aforementioned device applied to the master node, and the slave nodes include the aforementioned device applied to the slave nodes. The master node and the slave nodes are connected through a shared medium network, with a communication distance of 1 to 2 meters, and adopt a full-duplex communication mode.
[0014] On the other hand, embodiments of the present invention provide a computer-readable storage medium storing a processor-executable program, which, when executed by a processor, is used to perform the above-described method.
[0015] The embodiments of the present invention have the following beneficial effects: This invention employs a broadcast timestamp oversupply mechanism in downlink communication by the master node, allowing slave nodes to process time synchronization information with lower priority based on their own task load, effectively reducing the processing load on slave nodes. Conversely, by employing a time status report oversupply mechanism in uplink communication by slave nodes, the master node can flexibly prioritize time deviation verification, avoiding impact on other critical tasks. When a large time deviation is detected, the master node triggers a high-priority immediate response mechanism from the slave node via unicast timestamp messages, achieving rapid time correction. For nodes with persistently large deviations, the master node employs a tiered restriction strategy, ensuring overall network synchronization accuracy while avoiding communication interruptions caused by directly removing nodes. This invention fully utilizes the full-duplex communication characteristics of ultra-short-range shared medium networks, significantly reducing node processing burden while maintaining time synchronization accuracy through a hybrid synchronization mechanism combining broadcast and unicast. It is particularly suitable for resource-constrained embedded devices in deterministic communication scenarios. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating the steps of a clock synchronization method for an ultra-short-distance shared medium network provided in an embodiment of the present invention; Figure 2 This is a system architecture diagram of an ultra-short-range shared medium network provided in an embodiment of the present invention; Figure 3 This is a timing diagram of clock synchronization information interaction provided in an embodiment of the present invention; Figure 4 This is a structural block diagram of a clock synchronization device for an ultra-short-distance shared medium network provided in an embodiment of the present invention; Figure 5 This is a structural block diagram of a clock synchronization system for an ultra-short-distance shared medium network provided in an embodiment of the present invention. Detailed Implementation
[0018] 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 accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] It should be noted that although the device diagram shows a modular division and the flowchart illustrates a logical order, in some cases, the steps shown or described may be performed in a different order than the modular division in the device or the order shown in the flowchart. The terms "first," "second," etc., used in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0021] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of the invention. However, those skilled in the art will recognize that the technical solutions of the invention can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of the invention.
[0022] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0023] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0024] To address the aforementioned technical problems, this invention proposes a clock synchronization method and related equipment for ultra-short-distance shared medium networks. By constructing a hybrid synchronization mechanism combining broadcast and unicast, and incorporating oversupply and priority dynamic adjustment strategies, efficient time synchronization between resource-constrained nodes is achieved.
[0025] like Figure 1 As shown, Figure 1 A clock synchronization method for an ultra-short-distance shared medium network provided in this embodiment of the invention includes the following steps: S100, the master node inserts broadcast timestamp information into the downlink communication frame and sends it to all slave nodes; S200: After receiving the broadcast timestamp information from the node, it updates the local real-time clock register according to the local preset update period timer when the task scheduling priority allows. S300: The slave node inserts a time status report message into the uplink communication frame and sends it to the master node; S400: After receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp. S500, if the master node detects that the time deviation of the slave node exceeds the first deviation threshold, the master node sends a unicast timestamp message to the slave node. The S600 receives a unicast timestamp message, updates its local real-time clock register in real time, and returns an acknowledgment message.
[0026] This invention proposes a clock synchronization method and related equipment for ultra-short-range shared medium networks. By employing a broadcast timestamp oversupply mechanism in downlink communication by the master node, slave nodes can process time synchronization information with lower priority based on their own task load, effectively reducing the processing load on slave nodes. Furthermore, by employing a time status report oversupply mechanism in uplink communication by slave nodes, the master node can flexibly arrange the priority of time deviation verification, avoiding impact on other critical tasks. When a large time deviation is detected, the master node triggers a high-priority immediate response mechanism from the slave nodes via unicast timestamp messages, achieving rapid time correction. For nodes with persistently large deviations, the master node adopts a tiered restriction strategy, ensuring the overall synchronization accuracy of the network while avoiding communication interruptions caused by directly removing nodes.
[0027] The clock synchronization method for ultra-short-distance shared medium networks proposed in this invention will be described in detail below according to the processing steps in engineering practice: In this embodiment, an ultra-short-range shared medium network system is first constructed, and the system architecture is as follows: Figure 2 As shown, the network consists of one master node and multiple slave nodes. The master and slave nodes are connected via a shared medium network with a communication distance of 1-2 meters, using full-duplex communication mode. The shared medium can be implemented using fiber optic splitters, wireless signals, or wired cables. Communication management is performed above the physical layer using a Media Access Control (MAC) layer protocol.
[0028] In some embodiments, the master node inserts broadcast timestamp information into downlink communication frames and sends it to all slave nodes, including: the master node inserts a timestamp sub-message field into the frame header of each downlink communication frame. (See reference) Figure 3 The timing diagram shows that the master node maintains a broadcast timestamp timer, which is reset after each downlink frame is sent. The timestamp sub-message field contains a message type identifier (0x01 indicates a broadcast timestamp), a master node device identifier (16 bits), a timestamp validity flag (1 bit), and a 64-bit real-time timestamp. The master node broadcasts downlink communication frames through the shared medium network, and all slave nodes receive and parse the timestamp sub-message field through an address filtering mechanism.
[0029] If the master node does not send downlink data for a continuous first preset threshold time period (e.g., 10 milliseconds), the master node independently sends a broadcast time synchronization frame. This broadcast time synchronization frame adopts the same frame structure as the downlink communication frame, contains only a timestamp sub-message field, and does not carry other service data.
[0030] In some embodiments, after receiving the broadcast timestamp information, the slave node updates its local real-time clock register according to a locally preset update period timer, when the task scheduling priority allows. This includes: the slave node maintaining an update period timer (e.g., ...). Figure 3 The timer (timer 5) has a preset period value that can be configured according to application requirements, typically ranging from 50 to 200 milliseconds. When the update period timer reaches the preset period value, the slave node enters a waiting timestamp state and sets the timestamp waiting flag.
[0031] After receiving a broadcast timestamp message or a unicast timestamp message, the slave node parses the master node's real-time timestamp Tm and records its local real-time timestamp Ts. It calculates the time offset ΔT = Tm - Ts and applies this offset to update its local real-time clock register: T_local_new = T_local_old + ΔT × α, where T_local_new and T_local_old are the local real-time clock registers before and after the update, respectively, and α is a smoothing coefficient (0 < α ≤ 1) to prevent clock jumps. After the update is complete, the update cycle timer is reset, and the timestamp wait flag is cleared.
[0032] In some embodiments, the slave node inserting a time status report message into the uplink communication frame and sending it to the master node includes: the slave node inserting a time status report sub-message field into the frame header of each uplink communication frame. (See reference) Figure 3 The slave node maintains a time report timer, which is reset after each uplink frame is sent. The time status report sub-message field contains a message type identifier (0x02 indicates time status report), a slave node device identifier (16 bits), a timestamp validity flag (1 bit), and a 64-bit real-time timestamp.
[0033] If the slave node does not send uplink data for a consecutive second preset threshold time (e.g., 10 milliseconds), the slave node independently sends a time synchronization report frame. This time synchronization report frame adopts the same frame structure as the uplink communication frame, and only contains the time status report sub-message field.
[0034] In some embodiments, after receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp. This includes: the master node extracting the time status report message from the received uplink frame and parsing it to obtain the slave node's real-time timestamp. The master node obtains the real-time timestamp of its local reception time and calculates the clock difference between the master and slave nodes as the master-slave time deviation.
[0035] The master node maintains a circular buffer for time skew for each slave node, storing the skew values for the most recent N times (e.g., 32 times). A moving average filtering algorithm is used to calculate the skew trend value. When the skew trend value exceeds a first skew threshold (e.g., 10 microseconds), a unicast timestamp correction mechanism is triggered.
[0036] In some embodiments, the master node sends a unicast timestamp message to the slave node, including: the master node constructing a unicast time synchronization frame, wherein the destination address field of the frame is filled with the address of the slave node that needs to be corrected, and the frame header contains a unicast timestamp flag (1 bit) and the master node's real-time timestamp. The master node sends the unicast time synchronization frame to the designated slave node through the shared medium network, and starts an acknowledgment timeout timer after sending, with a typical timeout value of 1 millisecond.
[0037] If the master node does not receive a response message from the slave node within the response timeout period, the master node will retransmit the unicast time synchronization frame, with the number of retransmissions not exceeding the maximum retry threshold (e.g., 3 times). If no response is received after retransmission, the slave node will be marked as having a communication abnormal state.
[0038] Upon receiving a unicast timestamp message, the slave node updates its local real-time clock register in real time and returns an acknowledgment message. This acknowledgment message includes the slave node device identifier, an acknowledgment flag, and the updated real-time timestamp.
[0039] In some embodiments, the method further includes a mechanism for handling excessive deviation: if the master node detects that the time deviation of the slave node continues to exceed a second deviation threshold (e.g., 50 microseconds) and the duration exceeds a third preset threshold time (e.g., 100 milliseconds), the master node sends a time synchronization alarm to the network management system. The alarm information includes the slave node identifier, deviation value, and duration.
[0040] The master node implements tiered limiting measures based on the degree of time deviation: when the time deviation exceeds a first preset value (e.g., 100 microseconds), the master node instructs the corresponding slave node to enter a receive-only mode, implemented via a transmission mode configuration command (command code 0x03); when the time deviation is between the first and second preset values (e.g., 20 microseconds), the master node instructs the corresponding slave node to increase the duration of the front and rear guard bands of the transmission window. The master node sends a guard band configuration command (command code 0x04), which includes adjustments for the front and rear guard band durations. After receiving the command, the slave node dynamically adjusts the start time advance and end time delay of the transmission window.
[0041] See Figure 4 This invention provides a clock synchronization device for an ultra-short-distance shared medium network, applied to a master node, comprising: The broadcast timestamp module is used to insert broadcast timestamp information into downlink communication frames and send it to all slave nodes. The broadcast timestamp information carries the real-time timestamp of the master node. If the master node does not send downlink data for a continuous first preset threshold time, it independently sends a broadcast time synchronization frame. The time deviation verification module is used to receive time status report messages sent by slave nodes, the time status report messages carrying the real-time timestamp of the slave nodes; and to verify the time deviation of the corresponding slave nodes based on the real-time timestamp of the master node. The unicast timestamp module is used to send a unicast timestamp message to a slave node when the time deviation of the slave node is detected to exceed a first deviation threshold, and to receive a response message returned by the slave node.
[0042] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0043] In some embodiments, the clock synchronization device for an ultra-short-distance shared medium network further includes: The synchronization management module is used to send a time synchronization alarm to the network management system when it detects that the time deviation of the slave node has continuously exceeded the second deviation threshold and the duration has exceeded the third preset threshold time, and to take restrictive measures according to the degree of deviation.
[0044] See Figure 5 This invention also provides a clock synchronization device for an ultra-short-distance shared medium network, applied to a slave node, comprising: The clock update module is used to receive the broadcast timestamp information sent by the master node and update the local real-time clock register according to the local preset update period timer when the task scheduling priority allows. The time reporting module is used to insert a time status report message into the uplink communication frame and send it to the master node. The time status report message carries the real-time timestamp of the slave node. If the slave node does not send uplink data for a continuous second preset threshold time, it independently sends a time synchronization report frame. The response module is used to update the local real-time clock register in real time and return an acknowledgment message when a unicast timestamp message is received from the master node.
[0045] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0046] This invention provides a clock synchronization system for an ultra-short-distance shared medium network, comprising: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.
[0047] It is evident that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0048] Furthermore, embodiments of the present invention also disclose a computer program product or computer program stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the described method. Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0049] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0050] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.
[0051] The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] It should be understood that in this invention, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0053] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0054] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0055] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0056] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0057] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and spirit of the present invention should be within the scope of the claims of the present invention.
Claims
1. A clock synchronization method for an ultra-short-distance shared medium network, characterized in that, The method includes the following steps: The master node inserts broadcast timestamp information into the downlink communication frame and sends it to all slave nodes. The broadcast timestamp information carries the real-time timestamp of the master node. If the master node does not send downlink data for a continuous first preset threshold time, the master node independently sends a broadcast time synchronization frame. After receiving the broadcast timestamp information from the node, the local real-time clock register is updated according to the local preset update period timer when the task scheduling priority allows. The slave node inserts a time status report message into the uplink communication frame and sends it to the master node. The time status report message carries the slave node's real-time timestamp. If the slave node does not send uplink data for a continuous second preset threshold time, the slave node independently sends a time synchronization report frame. After receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp. If the master node detects that the time deviation of the slave node exceeds the first deviation threshold, the master node sends a unicast timestamp message to the slave node. The slave node that receives the unicast timestamp message updates its local real-time clock register in real time and returns an acknowledgment message.
2. The method according to claim 1, characterized in that, The method further includes: If the master node detects that the time deviation of the slave node continues to exceed the second deviation threshold and the duration exceeds the third preset threshold time, the master node sends a time synchronization alarm to the network management system. The master node takes corresponding restrictive measures based on the degree of time deviation: when the time deviation is greater than the first preset value, the master node instructs the corresponding slave node to enter the receive-only mode; when the time deviation is between the first preset value and the second preset value, the master node instructs the corresponding slave node to increase the duration of the front and back guard bands of the transmission window, and the duration of the front and back guard bands is positively correlated with the degree of deviation.
3. The method according to claim 1, characterized in that, After receiving the broadcast timestamp information, the slave node updates its local real-time clock register according to a locally preset update period timer, when the task scheduling priority allows, including: The slave node maintains an update cycle timer. When the update cycle timer reaches a preset cycle value, the slave node enters a waiting timestamp state. After receiving a broadcast timestamp message or a unicast timestamp message, the slave node parses the master node's real-time timestamp carried in it, calculates the time offset, updates the local real-time clock register according to the time offset, and resets the update period timer.
4. The method according to claim 1, characterized in that, After receiving the time status report message, the master node verifies the time deviation of the corresponding slave node based on the master node's real-time timestamp, including: The master node extracts the time status report message from the received uplink frame and parses it to obtain the real-time timestamp of the slave node; The master node obtains the real-time timestamp of the local reception time and calculates the clock difference between the master and slave nodes as the master-slave time deviation; The master node records the historical time deviation data of each slave node, and uses a moving average filtering algorithm to calculate the deviation trend value. When the deviation trend value exceeds the first deviation threshold, the unicast timestamp correction mechanism is triggered.
5. The method according to claim 1, characterized in that, The master node inserts broadcast timestamp information into the downlink communication frame and sends it to all slave nodes, including: The master node inserts a timestamp sub-message field at the frame header of each downlink communication frame. The timestamp sub-message field includes a message type identifier, a master node device identifier, a timestamp validity flag, and a real-time timestamp. The master node broadcasts the downlink communication frames through the shared medium network, and all slave nodes receive and parse the timestamp sub-message field through the address filtering mechanism.
6. The method according to claim 1, characterized in that, The slave node inserts a time status report message into the uplink communication frame and sends it to the master node, including: The slave node inserts a time status report sub-message field at the frame header of each uplink communication frame. The time status report sub-message field includes a message type identifier, a slave node device identifier, a timestamp validity flag, and a real-time timestamp. The slave node sends the uplink communication frame to the master node through the shared medium network.
7. The method according to claim 1, characterized in that, The master node sends a unicast timestamp message to the slave node, including: The master node constructs a unicast time synchronization frame, the frame header of which includes the target slave node address, the unicast timestamp flag, and the master node's real-time timestamp. The master node sends the unicast time synchronization frame to the designated slave node through the shared medium network, and starts an acknowledgment timeout timer after sending; If the master node does not receive a response message from the slave node within the response timeout period, the master node will retransmit the unicast time synchronization frame, and the number of retransmissions shall not exceed the maximum retry threshold.
8. The method according to claim 2, characterized in that, The master node instruction corresponds to the duration of the guard band before and after the transmission window added by the slave node, including: The master node determines the protection zone increase factor based on the time deviation calculation value, and the protection zone increase factor is proportional to the absolute value of the deviation. The master node sends a guard band configuration command to the corresponding slave node. The command includes the front guard band duration adjustment value and the rear guard band duration adjustment value. After receiving the guard band configuration command from the node, the start time advance and end time delay of the sending window are dynamically adjusted.
9. A clock synchronization device for an ultra-short-distance shared medium network, applied to a master node, characterized in that, include: The broadcast timestamp module is used to insert broadcast timestamp information into downlink communication frames and send it to all slave nodes. The broadcast timestamp information carries the real-time timestamp of the master node. If the master node does not send downlink data within a continuous first preset threshold time, it will independently send a broadcast time synchronization frame. The time deviation verification module is used to receive time status report messages sent by slave nodes, the time status report messages carrying the real-time timestamp of the slave nodes; and to verify the time deviation of the corresponding slave nodes based on the real-time timestamp of the master node. The unicast timestamp module is used to send a unicast timestamp message to a slave node when the time deviation of the slave node is detected to exceed a first deviation threshold, and to receive a response message returned by the slave node.
10. A clock synchronization device for an ultra-short-distance shared medium network, applied to a slave node, characterized in that, include: The clock update module is used to receive the broadcast timestamp information sent by the master node and update the local real-time clock register according to the local preset update period timer when the task scheduling priority allows. The time reporting module is used to insert a time status report message into the uplink communication frame and send it to the master node. The time status report message carries the real-time timestamp of the slave node. If a node does not send uplink data within a consecutive second preset threshold time period, it will independently send a time synchronization report frame. The response module is used to update the local real-time clock register in real time and return an acknowledgment message when a unicast timestamp message is received from the master node.