Adaptive time synchronization compensation method, terminal device, gateway device and system
By receiving and correcting the timestamps and period values in beacon frames, the terminal device and the gateway device work together to solve the synchronization accumulation error problem in LoRaWAN Class B mode, achieving high-precision time synchronization and stable downlink communication.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XINGLI COMP PRODS ZHUHAI
- Filing Date
- 2026-01-22
- Publication Date
- 2026-07-03
AI Technical Summary
In LoRaWAN Class B mode, synchronization errors caused by gateway hardware timing deviation, terminal clock drift, and over-the-air transmission delay lead to downlink communication failure after a long period of operation, severely limiting its application in mission-critical tasks.
By receiving the timestamp, actual beacon period value, and over-the-air transmission time value from the beacon frame, the terminal device calculates and corrects the local clock, the gateway device measures and broadcasts the actual beacon period value, and the terminal device corrects the clock deviation in real time, eliminating systematic linear cumulative error and achieving source period correction, real-time deviation compensation, and transmission delay alignment.
It achieves high-precision time synchronization of terminal devices, ensuring the long-term accuracy of periodic receiving time slots and guaranteeing highly reliable downlink communication.
Smart Images

Figure CN122340593A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of wireless communication technology, and in particular relates to an adaptive time synchronization compensation method, terminal equipment, gateway equipment and time synchronization system. Background Technology
[0002] LoRaWAN Class B operating mode achieves a balance between low power consumption and downlink reachability by coordinating the wake-up of terminals within precise periodic ping slots to receive downlink data. The normal operation of this mode fundamentally relies on sub-second (typically better than ±100 milliseconds) high-precision time synchronization between the terminal and the gateway. The standard mechanism is as follows: the gateway broadcasts a beacon frame containing a transmission timestamp at fixed intervals (e.g., 128 seconds). The terminal receives the beacon and calculates its dedicated reception slot based on this timestamp and a preset ideal period.
[0003] However, under prolonged operation, synchronization errors accumulate and eventually lead to downlink communication failure. Research indicates that this cumulative system error primarily stems from three inherent, interconnected defects that cannot be overcome by standard mechanisms. First, the actual period of the gateway's beacon broadcast, acting as the synchronization reference, is affected by hardware clock accuracy and system scheduling delays, and is not an ideal configuration value. There exists a fixed or slowly drifting deviation ΔT (e.g., nominal period Tnominal = 16000ms, actual period Tactual = 16006ms). If the terminal uses a fixed Tnominal for timeslot calculation, each period introduces an error of ΔT, causing the error to accumulate linearly over time. This error originates from the gateway side and cannot be eliminated by the terminal through its own measurement. Second, due to cost and power consumption limitations, the terminal's local clock accuracy is limited, and its frequency deviation relative to the high-precision gateway clock translates into a drift error that increases over time. This error accumulates independently on the terminal side, superimposed on the aforementioned gateway period error. Third, the fixed deviation introduced by the inconsistent synchronization reference: the beacon timestamp records the "gateway transmission start time," while the terminal records the "local reception completion time." The difference between the two includes not only clock skew but also non-negligible airborne signal propagation delay (typically 30-100ms in urban environments). To address these issues, existing improvement schemes often perform localized corrections for single error sources while allowing other error sources to accumulate. In practice, gateway periodic error (ΔT) and terminal clock drift error interact, causing the total system error to exhibit "superlinear growth." Experimental results show that after several days of operation, the accumulated error easily exceeds the receive time slot window (typically only 30-100ms), preventing the terminal from listening to downlink messages. Downlink beacon reception success rates are often below 80%, severely limiting the application of Class B mode in mission-critical tasks.
[0004] Therefore, how to systematically and collaboratively prevent error accumulation from the three dimensions of source, path and local clock, and achieve long-term stable high-precision time synchronization is an urgent technical problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of this application provide an adaptive time synchronization compensation method, a terminal device, a gateway device, and a time synchronization system, aiming to systematically and collaboratively solve the problem of cumulative synchronization error caused by gateway hardware timing deviation, terminal clock drift, and over-the-air transmission delay.
[0006] The first aspect of this application provides an adaptive time synchronization compensation method applied to a terminal device, the method comprising: The system receives a beacon frame from the gateway and parses out the timestamp, actual beacon period value, and over-the-air transmission time value carried in the beacon frame. The timestamp represents the absolute time when the gateway started sending the beacon frame, and the actual beacon period value is the actual interval between the start times of two adjacent beacon frame transmissions, as measured by the gateway according to its hardware clock. Record the time when the local reception of the beacon frame is completed on the terminal device side; Based on the timestamp, the over-the-air transmission time value, and the local reception completion time, calculate the first time deviation of the local clock of the terminal device relative to the gateway clock; The local clock of the terminal device is corrected based on the first time deviation; Based on the corrected local clock, the actual beacon period value, and the predefined receive time slot parameters, the subsequent periodic receive time slots of the terminal device are calculated and determined.
[0007] In one embodiment, calculating the first time deviation of the terminal device's local clock relative to the gateway clock based on the timestamp, the over-the-air transmission time value, and the local reception completion time includes: Add the timestamp to the over-the-air transmission time value to obtain the reference time, represented by the gateway clock, at which the terminal device should theoretically complete the reception; Calculate the difference between the local reception completion time and the reference time, and determine the difference as the first time deviation.
[0008] In one embodiment, the method further includes: The first time deviation and historical time deviation data obtained from the current calculation are filtered to generate an optimized second time deviation. The step of correcting the local clock of the terminal device based on the first time deviation includes: The local clock is corrected using the optimized second time offset.
[0009] In one embodiment, the filtering process employs an exponentially weighted moving average algorithm or a Kalman filter algorithm.
[0010] A second aspect of this application provides an adaptive time synchronization compensation method applied to a gateway device, the method comprising: Based on the hardware clock of the gateway device, the actual beacon period value is measured and obtained. The actual beacon period value is the actual time interval between the start times of two adjacent beacon frame transmissions. Beacon frames are broadcast with the actual beacon period value as the period. The beacon frame encapsulates time synchronization information, which includes at least: the timestamp of the start of the current beacon frame transmission, the actual beacon period value, and the air transmission time value used to compensate for signal propagation delay.
[0011] In one embodiment, the method further includes: The actual beacon period value is periodically remeasured and updated to track long-term drift of the gateway device's hardware clock.
[0012] In one embodiment, the over-the-air transmission time value is one of the following: a pre-configured typical network value, a dynamic value estimated based on the network topology, or an empirical value obtained from historical communication round-trip delay statistics.
[0013] A third aspect of this application provides a terminal device, comprising: a first communication module for receiving beacon frames from a gateway; a clock module for providing a local clock; and a first processing module connected to the communication module and the clock module, configured to perform the method described in the first aspect above.
[0014] A fourth aspect of this application provides a gateway device, comprising: a high-precision clock source for providing a time reference; a second communication module for broadcasting beacon frames; and a second processing module connected to the high-precision clock source and the communication module, configured to perform the method as described in any one of claims 5 to 7.
[0015] A fifth aspect of this application provides a time synchronization system, including a terminal device as described in the third aspect above and a gateway device as described in the fourth aspect above, wherein time synchronization information carried in a beacon frame broadcast by the gateway device is used by the terminal device to implement adaptive time synchronization compensation.
[0016] Compared with existing technologies, the adaptive time synchronization compensation method, device, and system provided in this application measure and broadcast the actual beacon period value through the gateway. The terminal directly uses this real period value in the time slot calculation, fundamentally eliminating the systematic and linear cumulative error introduced by the timing deviation of the gateway hardware. When the terminal successfully receives a beacon frame each time, it uses the high-precision timestamp carried in the beacon frame and the local reception time to calculate and correct the clock deviation in real time. This process not only compensates for the random jitter in a single transmission, but more importantly, it continuously suppresses the long-term drift accumulation of the terminal's local crystal oscillator, controlling the drift error within a single period. By introducing and compensating for the air transmission time value, the reference benchmark for time synchronization is unified from the gateway's transmission time to the terminal's reception completion time, solving the fixed deviation caused by different physical distances. This ensures that all terminals, regardless of their distance from the gateway, achieve time benchmark alignment at the physical reception level. The above three technical means are not simply superimposed, but constitute a collaborative system from source (gateway) correction - dynamic tracking (air delay) - benchmark unification (terminal). The three work together to transform multiple independent and cumulative error sources in the traditional solution into a single instantaneous deviation that can be measured and compensated uniformly in real time by the terminal. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating an adaptive time synchronization compensation method provided in an embodiment of this application; Figure 2 An adaptive time synchronization compensation method is provided in another embodiment of this application; Figure 3 A schematic diagram of a terminal device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a gateway device provided in an embodiment of this application. Detailed Implementation
[0019] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.
[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 application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0021] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0024] In the description of the embodiments of this application, the term "multiple frames" refers to two or more (including two).
[0025] In the description of the embodiments of this application, the technical terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing the embodiments of this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.
[0026] This application provides an adaptive time synchronization compensation method, a terminal device, a gateway device, and a time synchronization system, aiming to systematically and collaboratively solve the problem of cumulative synchronization error caused by gateway hardware timing deviation, terminal clock drift, and over-the-air transmission delay.
[0027] Please see Figure 1 As shown, Figure 1 This is a flowchart illustrating an adaptive time synchronization compensation method according to an embodiment of this application. The adaptive time synchronization compensation method provided in this embodiment is applied to terminal devices such as LoRaWAN Class B terminals. This method aims to accurately correct the local clock and calculate the receive time slot by processing enhanced beacon frames from the gateway.
[0028] Depend on Figure 1 As can be seen, the adaptive time synchronization compensation method in this application includes steps S110 to S150. Details are as follows: S110: Receive a beacon frame from the gateway, and parse out the timestamp, actual beacon period value, and air transmission time value carried in the beacon frame. The timestamp represents the absolute time when the gateway started sending the beacon frame, and the actual beacon period value is the actual interval between the start times of two adjacent beacon frame transmissions, as measured by the gateway according to its hardware clock.
[0029] Within its preset beacon listening window, the terminal device receives beacon frames from the gateway via its radio frequency communication module (such as a LoRa RF chip). This beacon frame is an extended Beacon frame, whose payload or specific information elements encapsulate crucial synchronization information. The terminal device's microprocessor (MCU) or baseband processor decodes and parses the received beacon frame, extracting at least three essential parameters: timestamp, actual beacon period value, and over-the-air transmission time value.
[0030] A timestamp is a high-precision time value, typically generated by a highly stable clock source on the gateway side (such as a GPS disciplined clock), and expressed in Coordinated Universal Time (UTC) or as a microsecond / nanosecond count from a given epoch. It precisely records the absolute moment when the first symbol of the current beacon frame begins transmission at the gateway's RF front-end. The actual beacon period value is not the ideal period preset by the terminal (such as the standard 128 seconds), but rather the time interval between the start times of the most recent or historically averaged transmissions of two adjacent beacon frames, actually measured by the gateway using its hardware timer. For example, its value might be 128.006 seconds, indicating a fixed bias of +6 milliseconds per period in the gateway hardware. This value is typically expressed as an integer or floating-point number in milliseconds or microseconds. The airborne transmission time value is a parameter used to compensate for the spatial propagation delay of radio waves. It can be a typical value pre-configured by the gateway based on its network coverage radius (e.g., 10 kilometers) (for example, for 10 kilometers, the air transmission time value tprop ≈ 33.3 μs; in practice, a larger value, such as tens of milliseconds, is often used to consider environmental factors). Alternatively, it can be a dynamic value estimated by the network server based on the approximate location of the terminal and sent to the gateway. This value is used to align the time base from the sending time to the receiving time.
[0031] S120: Record the time when the local reception of the beacon frame is completed on the terminal device side.
[0032] After the last symbol of the beacon frame is successfully received by the terminal RF module and the MCU is notified via a hardware interrupt (such as a GPIO interrupt or a dedicated RF interrupt), the MCU needs to immediately record a high-precision local time, which is the local reception completion time of the beacon frame on the terminal device side.
[0033] For example, a specific implementation includes reading the current count value from a high-precision timer / counter built into the terminal (such as a sub-second count register of an RTC, or a timer specifically for timestamps). The current count value is then converted to a local time value with the same time base and units as the gateway timestamp. The key to this step is that the capture delay at the completion of reception must be as small and deterministic as possible (typically on the microsecond scale), which relies on optimized hardware interrupt responses and register reads.
[0034] S130: Based on the timestamp, the over-the-air transmission time value, and the local reception completion time, calculate the first time deviation of the local clock of the terminal device relative to the gateway clock.
[0035] By calculating the first time deviation, the influence of air transmission delay is eliminated, resulting in a pure clock deviation. Specifically, calculating the first time deviation of the terminal device's local clock relative to the gateway clock based on the timestamp, the air transmission time value, and the local reception completion time includes: adding the timestamp to the air transmission time value to obtain a reference time, represented by the gateway clock, at which the terminal device should theoretically complete reception; calculating the difference between the local reception completion time and the reference time, and determining this difference as the first time deviation.
[0036] It should be noted that the reference time, represented by the gateway clock, at which the terminal device should theoretically complete reception, represents the theoretical time at which the beacon frame should be fully received at the terminal side, considering signal propagation time within the gateway's clock system. The actual local reception completion time recorded by the terminal device is compared with the aforementioned theoretical reference time to obtain the first time deviation. If the first time deviation is positive, it indicates that the terminal device's local clock is faster than the (aligned) gateway clock; conversely, it is slower.
[0037] S140: Correct the local clock of the terminal device according to the first time deviation.
[0038] After obtaining the first time deviation, the processing module of the terminal device corrects the local clock of the terminal device according to the first time deviation calculated in step S130, so as to synchronize the local clock with the gateway clock (after being aligned with the over-the-air transmission time value).
[0039] To further improve robustness and reduce the impact of random errors introduced by channel noise or interrupt response jitter in a single measurement, the first time deviation can be filtered before clock correction to generate an optimized second time deviation value.
[0040] The filtering process employs either an exponentially weighted moving average algorithm or a Kalman filter algorithm.
[0041] The exponentially weighted moving average algorithm can be expressed as: ); Where k represents the current beacon reception sequence number, and α is the filtering coefficient (0 < α ≤ 1, for example, 0.2). This is the first time deviation obtained in this calculation. () represents the optimized time deviation value after filtering in the previous cycle. This algorithm is simple to implement and can effectively smooth random fluctuations.
[0042] The Kalman filter algorithm uses clock skew and its frequency drift rate together as state variables for joint estimation. This algorithm can better distinguish between measurement noise and the dynamic change noise of the clock itself, and can provide predictions of the skew in the next cycle, but its implementation complexity is relatively high. When performing this optional step, "the first time skew" in step S140 should be replaced with "the optimized second time skew value". That is, the step of correcting the local clock of the terminal device according to the first time skew includes: correcting the local clock using the optimized second time skew.
[0043] The "correction of the local clock" can be achieved in any of the following ways: Method 1 is system-level calibration, which includes: if the operating system or underlying protocol stack of the terminal device provides a system clock adjustment interface, then call the interface to subtract (or add) the first time deviation (or optimize the time deviation value) from the system time.
[0044] Method two is application-layer soft correction, which includes maintaining a virtual "soft clock" in the application layer or protocol stack logic of the terminal device. The value of this soft clock is: soft clock time = hardware clock reading + dynamic adjustment. Each time the first time offset (or optimized time offset value) Offset is obtained, the dynamic adjustment is updated, for example: Adjustment = Adjustment - Offset (assuming that a positive Offset indicates that the local clock is ahead). Thereafter, all logic that depends on time synchronization, including the calculation of the receiving time slot described below, is based on this corrected "soft clock".
[0045] S150: Based on the corrected local clock, the actual beacon period value, and the predefined receive time slot parameters, calculate and determine the subsequent periodic receive time slots of the terminal device.
[0046] After completing local clock calibration, the terminal device accurately calculates the start time of its subsequent periodic reception time slots for monitoring downlink data based on the reference time, actual period, and time slot parameters.
[0047] Specifically, the slot parameter is a fixed offset determined by a predefined hash algorithm based on the terminal device's unique network identifier (such as DevAddr), called the receive slot offset. This offset defines the start time of the terminal's dedicated receive window within a complete beacon period (e.g., 1.234 seconds after the start of the period).
[0048] The receive time slot can be represented as: in, The absolute time slot for the reception of the terminal device in the nth future cycle is set. The gateway transmission timestamp is parsed from the current beacon frame. n is a positive integer representing the nth future period starting from the current beacon period (n=1 for the next immediately following time slot). The actual beacon period value measured and reported by the gateway is a key parameter for eliminating periodic system errors. The over-the-air transmission time value is used for reference alignment. C represents the predefined receive time slot offset, and C represents the accumulated clock correction amount. If method one (system-level correction) is used, then C is already incorporated into the system time; if method two (soft correction) is used, then C is the dynamic adjustment amount.
[0049] By explicitly using the actual beacon period value provided by the gateway when calculating future time slots, instead of the ideal configuration period value used in traditional methods, this substitution fundamentally changes the error model of time slot prediction. This allows the terminal's time slot prediction to strictly follow the actual broadcast rhythm of the gateway hardware, which may have inherent biases, thereby completely eliminating the synchronization error that accumulates linearly over time due to the gateway's periodic systematic error.
[0050] As can be seen from the above analysis, the adaptive time synchronization compensation method provided in this application enables the terminal device to achieve multi-dimensional collaborative synchronization including source period correction, real-time deviation compensation and transmission delay alignment, ultimately ensuring the long-term accuracy of periodic reception time slots and laying a technical foundation for achieving highly reliable downlink communication.
[0051] Please see Figure 2 , Figure 2 Another embodiment of this application provides an adaptive time synchronization compensation method. This method is applied to gateway devices (such as LoRaWAN gateways). Figure 2 As shown, the adaptive time synchronization compensation method includes steps S210 to S230. Details are as follows: S210: Based on the hardware clock of the gateway device, the actual beacon period value is measured and obtained. The actual beacon period value is the actual time interval between the start times of two adjacent beacon frame transmissions.
[0052] The gateway device's processing unit (such as a CPU or dedicated timer processor) performs beacon transmission monitoring, triggered either each time a beacon frame is prepared for transmission or periodically by an independent high-precision timed task. The gateway device maintains an absolute time reference based on a high-precision hardware clock, the clock source of which is a GPS-disciplined clock or a temperature-controlled crystal oscillator. At the start of each beacon frame transmission, the moment is precisely marked via a driver layer or hardware timer interrupt. This start moment is the moment when the RF front-end starts modulation and transmits the first radio symbol, and the corresponding absolute time is recorded synchronously.
[0053] The actual period measurement value of the Kth beacon period is obtained by calculating the absolute time difference between the start time of the Kth beacon frame transmission and the start time of the (K-1)th beacon frame transmission. To improve the stability and resistance to transient disturbances of the actual beacon period value, the single period measurement values of N consecutive times (preferably N=10 times) are smoothed using a sliding window averaging or low-pass filtering algorithm to obtain the smoothed actual beacon period value.
[0054] The calculated actual beacon cycle value (word measurement or smoothed value) is stored in the gateway device's non-volatile memory or running memory as the currently used actual beacon cycle value.
[0055] S220: Broadcast beacon frames with the actual beacon period value as the period.
[0056] The gateway device configures its system timer, which is a periodic timer based on a high-precision clock. The timing period of the timer is set to the actual period value determined in the previous steps. When the timer expires, the assembly and transmission process of the beacon frame is triggered, so that the gateway device broadcasts the beacon strictly in accordance with the real period determined by the hardware clock, ensuring the determinism and predictability of the broadcast period.
[0057] S230: Encapsulate time synchronization information in the beacon frame, the time synchronization information including at least: the timestamp of the start of the transmission of this beacon frame, the actual beacon period value, and the air transmission time value used to compensate for the signal air propagation delay.
[0058] The gateway device encapsulates time synchronization information in the beacon frame to be broadcast. The time synchronization information includes at least the timestamp of the start time of the current beacon frame transmission, the actual beacon period value obtained in step S210, and the air transmission time value used to compensate for the signal air propagation delay. The specific execution process is as follows: Record the absolute time value of the start time of the current beacon frame transmission. The absolute time value is directly derived from the high-precision hardware clock established in step S210 to ensure a unified time base and a timestamp accuracy of not less than microseconds. Encapsulate the absolute time value as a timestamp into the beacon frame. Encapsulate the actual beacon period value stored in step S210 into the beacon frame.
[0059] The air transmission time value is one of the following: a pre-configured typical network value, a dynamic value estimated based on the network topology, or an empirical value obtained from historical communication round-trip time statistics. The air transmission time value is determined using any of the following methods and then encapsulated into the beacon frame: Method 1: Pre-configured typical network value, calculated by network planners based on the typical coverage radius of the gateway device (e.g., 5 km in an urban environment), specifically: spatial transmission time value = coverage distance / speed of light, with a preset margin (e.g., set to 5 ms), pre-configured to the gateway device; Method 2: Dynamically estimated value, estimated by the gateway device or its connected network server (NS) based on the approximate location information of registered terminals (obtained through previous communication or GPS reporting), and dynamically sent to the gateway device; Method 3: Historical statistical empirical value, the gateway device statistically analyzes the round-trip time (RTT) of historical communication with multiple terminals, estimates the average propagation time using RTT / 2, and periodically updates the spatial transmission time value.
[0060] Optionally, the actual beacon periodic value is periodically recalibrated to compensate for long-term drift of the gateway hardware clock (such as slow frequency changes caused by temperature variations or device aging). Specifically, a recalibration period is set, which is much longer than the beacon period (preferably T_cal is 1 hour or 24 hours). At each recalibration cycle, the gateway device's processing unit performs a detailed cycle remeasurement, including intensive sampling over multiple beacon cycles and using sophisticated statistical algorithms such as linear regression fitting to estimate the current accurate average actual beacon cycle value; the newly estimated average actual beacon cycle value is updated to the gateway device's storage unit, and the timing cycle setting of the system timer in step S220 is updated synchronously.
[0061] As can be seen from the above analysis, the adaptive time synchronization compensation method provided in this application enables the gateway device to transform from a conventional periodic time broadcaster to a high-precision collaborative synchronization source that is "self-sensing, self-calibrating, and transparent in information": on the one hand, it broadcasts beacon frames with its own real rhythm, and on the other hand, it actively informs the terminal of the real rhythm (actual beacon period value), precise action time (timestamp of the start of transmission), and propagation delay estimation, providing sufficient and necessary data foundation for the terminal device to perform multi-dimensional compensation (source period correction, dynamic correction of the receiving time, and alignment of transmission delay); the gateway device and the terminal device work together to form a complete, closed-loop, and highly robust adaptive time synchronization system.
[0062] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0063] Please see Figure 3 , Figure 3 This is a schematic diagram of a terminal device provided according to an embodiment of this application. Figure 3 As you can see, please refer to Figure 3 , Figure 3 This is a schematic structural diagram of a terminal device provided in an embodiment of this application. Figure 3 As shown, the terminal device 300 includes: a first communication module 310, a local clock module 320, a first processing module 330, and a first memory 340.
[0064] The system includes: a first communication module 310 for receiving beacon frames from the gateway device and interacting with the gateway; a local clock module 320 for providing a local clock signal for the terminal; and a first processing module 330 connected to the first communication module 310, the local clock module 320, and the first memory 340, for executing a computer program stored in the first memory 340 to achieve the following: Figure 1 The adaptive time synchronization compensation method described in the embodiment includes a first memory 340 for storing a computer program executable by the first processing module 330 and related data. For example, the memory stores a first computer program 360, which, when executed by the first processing module 330, implements the following... Figure 1 Each step in the method embodiment shown.
[0065] In some implementations, the first computer program 360 may be divided into one or more functional modules / units, which work together to complete the time synchronization compensation process provided in this application.
[0066] It should be understood that Figure 3 This is merely an exemplary representation of terminal device 300; in actual implementation, it may include more or fewer components, and some components may be integrated or replaced. For example, terminal device 300 may also include components not shown, such as input / output interfaces, network interfaces, and bus systems.
[0067] The first processing module 330 may be one or a combination of a central processing unit (CPU), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices.
[0068] The first memory 340 can be an internal storage unit of the terminal device 300 (such as RAM or flash memory), an external storage device (such as an SD card or portable hard drive), or a combination thereof. In addition to storing program instructions, this memory can also be used to temporarily store data generated during processing.
[0069] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0070] Please see Figure 4 , Figure 4 This is a schematic diagram of a gateway device provided in an embodiment of this application. Figure 4 It can be seen that, as Figure 4 As shown, the gateway device 400 includes: a high-precision clock source 410, a second communication module 420, a second processing module 430, and a second memory 440.
[0071] The system includes: a high-precision clock source 410 for providing a highly stable time reference signal; a second communication module 420 for broadcasting beacon frames to the terminal device and supporting communication with the terminal; and a second processing module 430 connected to the high-precision clock source 410, the second communication module 420, and the second memory 440, for executing computer programs stored in the second memory 440 to achieve the following: Figure 2 The adaptive time synchronization compensation method described in the embodiment includes a second memory 440 for storing a computer program executable by the second processing module 430 and related data. For example, the memory stores a second computer program 450, which, when executed by the second processing module 430, implements the following... Figure 2 The steps in the method embodiment shown are illustrated. The second computer program 450 can also be organized into one or more functional modules / units, which, through combinations of instruction segments, complete the time synchronization control and compensation functions on the gateway side.
[0072] Understandable. Figure 4This is just an example of a gateway device 400; actual devices may include other components as needed, such as network interface modules, power management units, buses, etc.
[0073] The second processing module 430 can be a CPU, DSP, ASIC, FPGA or other chips or circuit combinations with processing capabilities.
[0074] The second memory 440 can be an internal storage unit of the gateway device 400 or an external extended storage device, used to store the operating system, applications, and data required during the synchronization process.
[0075] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0076] This application also provides a time synchronization system. The time synchronization system includes, for example,... Figure 3 The terminal equipment shown and such Figure 4 The gateway device shown. The time synchronization information carried in the beacon frames broadcast by the gateway device is used by the terminal device to achieve adaptive time synchronization compensation.
[0077] For example, the gateway device, acting as the system's time reference source and synchronization initiator, periodically broadcasts beacon frames through its second communication module. These beacon frames are not ordinary data frames, but rather crucial carriers encapsulating time synchronization information generated by the gateway's high-precision clock source. This information typically includes at least a precise timestamp (such as the absolute time of beacon transmission or a sequence number). The terminal device listens for and receives the beacon frames from the gateway through its first communication module, extracting the time synchronization information. The terminal device's first processing module compares and calculates the received time synchronization information with the current time provided by its own local clock module. This is done by executing actions such as... Figure 1 The adaptive time synchronization compensation algorithm described in the embodiment dynamically calculates the deviation (time offset and frequency offset) between the local clock and the gateway reference time, and performs closed-loop compensation and adjustment on the local clock accordingly, so that it gradually converges and maintains high-precision synchronization with the gateway time.
[0078] The time synchronization system provided in this application provides a high-precision time synchronization solution that is efficient, robust, and suitable for large-scale wireless networks by broadcasting beacon frames carrying time synchronization information through the gateway, thereby triggering the terminal side to run an adaptive compensation algorithm.
[0079] This application also provides a network device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the steps in any of the above method embodiments.
[0080] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0081] This application provides a computer program product that, when run on a mobile terminal, enables the mobile terminal to implement the steps described in the above-described method embodiments.
[0082] 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, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a photographing device / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0083] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0084] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are 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 application.
[0085] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or 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 devices or units may be electrical, mechanical, or other forms.
[0086] 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.
[0087] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. An adaptive time synchronization compensation method, characterized in that, Applied to a terminal device, the method includes: The system receives a beacon frame from the gateway and parses out the timestamp, actual beacon period value, and over-the-air transmission time value carried in the beacon frame. The timestamp represents the absolute time when the gateway started sending the beacon frame, and the actual beacon period value is the actual interval between the start times of two adjacent beacon frame transmissions, as measured by the gateway according to its hardware clock. Record the time when the local reception of the beacon frame is completed on the terminal device side; Based on the timestamp, the over-the-air transmission time value, and the local reception completion time, calculate the first time deviation of the local clock of the terminal device relative to the gateway clock; The local clock of the terminal device is corrected based on the first time deviation; Based on the corrected local clock, the actual beacon period value, and the predefined receive time slot parameters, the subsequent periodic receive time slots of the terminal device are calculated and determined.
2. The method according to claim 1, characterized in that, The step of calculating the first time deviation of the terminal device's local clock relative to the gateway clock based on the timestamp, the over-the-air transmission time value, and the local reception completion time includes: Add the timestamp to the over-the-air transmission time value to obtain the reference time, represented by the gateway clock, at which the terminal device should theoretically complete the reception; Calculate the difference between the local reception completion time and the reference time, and determine the difference as the first time deviation.
3. The method according to claim 2, characterized in that, The method further includes: The first time deviation and historical time deviation data obtained from the current calculation are filtered to generate an optimized second time deviation. The step of correcting the local clock of the terminal device based on the first time deviation includes: The local clock is corrected using the optimized second time offset.
4. The method according to claim 3, characterized in that, The filtering process employs either an exponentially weighted moving average algorithm or a Kalman filter algorithm.
5. An adaptive time synchronization compensation method, characterized in that, Applied to a gateway device, the method includes: Based on the hardware clock of the gateway device, the actual beacon period value is measured and obtained. The actual beacon period value is the actual time interval between the start times of two adjacent beacon frame transmissions. Beacon frames are broadcast with the actual beacon period value as the period. The beacon frame encapsulates time synchronization information, which includes at least: the timestamp of the start of the current beacon frame transmission, the actual beacon period value, and the air transmission time value used to compensate for signal propagation delay.
6. The method according to claim 5, characterized in that, The method further includes: The actual beacon period value is periodically remeasured and updated to track long-term drift of the gateway device's hardware clock.
7. The method according to claim 5 or 6, characterized in that, The over-the-air transmission time value is one of the following: a pre-configured typical network value, a dynamic value estimated based on the network topology, or an empirical value obtained from historical communication round-trip delay statistics.
8. A terminal device, characterized in that, include: The first communication module is used to receive beacon frames from the gateway; The clock module is used to provide a local clock. A first processing module, connected to the first communication module and the clock module respectively, is configured to perform the method as described in any one of claims 1 to 4.
9. A gateway device, characterized in that, include: A high-precision clock source is used to provide a time reference; The second communication module is used to broadcast beacon frames; The second processing module, connected to the high-precision clock source and the communication module respectively, is configured to perform the method as described in any one of claims 5 to 7.
10. A time synchronization system, characterized in that, The device includes the terminal device as described in claim 8 and the gateway device as described in claim 9, wherein the time synchronization information carried in the beacon frame broadcast by the gateway device is used by the terminal device to implement adaptive time synchronization compensation.