NTP high-precision time synchronization method and device based on link layer
By generating and extracting timestamps at the link layer, and combining linear regression and weighted least squares to calculate clock drift rate and offset, the systematic error introduced by traditional NTP at the application layer is solved, achieving high-precision time synchronization and improving the time synchronization accuracy and stability in industrial environments.
Patent Information
- Application Number
- CN202511705631.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-02-27
AI Technical Summary
The systematic errors caused by the timestamp operation at the application layer in traditional network time protocols limit the accuracy of time synchronization in harsh industrial environments.
By generating and extracting timestamps at the link layer, combining linear regression and weighted least squares, clock drift rate and time offset are calculated, and clock frequency is adjusted through a proportional-integral controller to achieve high-precision time synchronization.
It significantly reduces random jitter and asymmetric latency introduced by the system stack, improves the accuracy and stability of time synchronization, and ensures time consistency of multi-device collaborative operation in complex network environments.
Smart Images

Figure CN121585300A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the field of high-precision time synchronization technology, and particularly relates to an NTP high-precision time synchronization method and device based on a link layer. BACKGROUND
[0002] The core technical problem of the traditional network time protocol is caused by the inherent system architecture defect of the time stamp operation in the application layer. The fundamental design choice causes the accurate time information to have to pass through the protocol stack of the operating system at the beginning.
[0003] The protocol stack is a complex software layer for general communication services, and the data buffering, queue scheduling and interrupt processing mechanism in the protocol stack will introduce a large amount of non-deterministic and difficult-to-track delay jitter when facing dynamic changes of system load and network conditions. Since these random delays are not symmetrical on the uplink and downlink paths of the data packet and cannot be accurately measured, they are finally included in the calculation of the clock offset and converted into systematic errors that cannot be eliminated, thereby seriously restricting the final time synchronization accuracy in harsh industrial environments. SUMMARY
[0004] The application aims to provide an NTP high-precision time synchronization method and device based on a link layer, and solve the above technical problems.
[0005] The purpose of the application can be achieved by the following technical solutions: The NTP high-precision time synchronization method based on the link layer comprises the following steps: The master device sends a link layer broadcast frame containing a sending time stamp; The slave device receives the link layer broadcast frame and records a corresponding local receiving time stamp; The slave device collects a plurality of continuous sending time stamps and a plurality of continuous local receiving time stamps to form a time stamp pair sequence; Based on the time stamp pair sequence, a linear regression algorithm is used to calculate the clock drift rate and time offset of the slave device clock relative to the master device clock; The local clock of the slave device is adjusted by using the calculated clock drift rate and time offset.
[0006] As a further scheme of the application, when constructing the link layer broadcast frame, the master device fills the sending time stamp into a predetermined field between the frame header and the payload of the link layer broadcast frame; The slave device analyzes the received link layer broadcast frame at the link layer, and extracts the sending time stamp from the predetermined field; The operation of recording the local receiving timestamp and the operation of extracting the sending timestamp are successively completed in a link layer processing flow.
[0007] As a further scheme of the present application, when constructing the link layer broadcast frame, the master device fills the sending timestamp into a predetermined field between a frame header and a payload of the link layer broadcast frame. The slave device parses the received link layer broadcast frame at a link layer, and extracts the sending timestamp from the predetermined field. The operation of recording the local receiving timestamp and the operation of extracting the sending timestamp are successively completed in a link layer processing flow.
[0008] As a further scheme of the present application, calculating the clock drift rate and the time offset comprises: Taking a plurality of the sending timestamps in the timestamp pair sequence as an independent variable set, and taking a plurality of the local receiving timestamps corresponding to the independent variable set as a dependent variable set. Based on a least square method, performing linear fitting on the independent variable set and the dependent variable set to obtain a slope parameter and an intercept parameter of a fitting straight line. Determining the slope parameter as the clock drift rate, and determining the intercept parameter as the time offset.
[0009] As a further scheme of the present application, after obtaining the fitting straight line, further calculating a residual of each timestamp pair with respect to the fitting straight line. Calculating an absolute value of the residual of each timestamp pair. Taking an inverse of all the absolute values of the residuals as initial weights. Performing normalization processing on the initial weights, so that a sum of all the weights is equal to a preset fixed value; and assigning the normalized weights to the corresponding timestamp pairs, wherein the absolute value of the residual is inversely proportional to the weight. Using a weighted least square method to re-fit the independent variable set and the dependent variable set, and updating the clock drift rate and the time offset.
[0010] As a further scheme of the present application, adjusting the local clock of the slave device comprises: Adding the calculated time offset to a current local time value of the slave device, and directly replacing the current time value of the local clock with a sum result. Based on the calculated clock drift rate, calculating an analog voltage value for adjusting an oscillator frequency through a proportional-integral controller, outputting the analog voltage value to a control end of a clock oscillator of the slave device, and realizing continuous and slight adjustment on an oscillator output frequency.
[0011] As a further scheme of the application: when it is detected that consecutive missing occurs in the timestamp pair sequence, the missing sending timestamp or local receiving timestamp is estimated based on the existing timestamp pair sequence using a linear extrapolation algorithm; When the number of consecutive missing exceeds a set threshold, the currently stored timestamp pair sequence is emptied and the collection process is restarted.
[0012] The link layer-based NTP high-precision time synchronization device comprises: A broadcast module: the master device sends a link layer broadcast frame containing a sending timestamp; A receiving module: the slave device receives the link layer broadcast frame and records a corresponding local receiving timestamp; The slave device collects a plurality of consecutive sending timestamps and a plurality of consecutive local receiving timestamps to form a timestamp pair sequence; A processing module: based on the timestamp pair sequence, a clock drift rate and a time offset of the slave device clock relative to the master device clock are calculated using a linear regression algorithm; An adjustment module: the local clock of the slave device is adjusted using the calculated clock drift rate and time offset.
[0013] The application has the following advantages over the prior art: The application generates and extracts timestamps at the link layer, avoids the uncertainty delay caused by the traditional network time protocol in the application layer, and completes the time synchronization process at a level closer to the hardware, thereby significantly reducing the random jitter and asymmetric delay introduced by the system stack. By collecting consecutive sending and receiving timestamps and performing linear regression calculation, the clock drift rate and time offset of the slave device relative to the master device can be accurately estimated, thereby realizing high-precision correction of the slave device clock. The weighted least squares method is used to further improve the anti-exception data interference capability and ensure the robustness of the regression result. The time window capacity is dynamically adjusted to adapt the sample quantity to the network state change, thereby balancing the response speed and calculation stability. The proportional integral control mode is combined to continuously fine-tune the clock oscillator, thereby realizing smooth correction and long-term synchronization stability of the clock frequency. Overall, the application can realize higher time consistency and system stability in a complex network environment, and ensure the time reference uniformity of multiple device collaborative operation. BRIEF DESCRIPTION OF DRAWINGS
[0014] The application will be further described below with reference to the drawings.
[0015] Figure 1 is a flowchart of the link layer-based NTP high-precision time synchronization method of the application. DETAILED DESCRIPTION
[0016] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the present application.
[0017] Please refer to Figure 1 The present application is a link layer-based NTP high-precision time synchronization method, which comprises the following steps: The master device sends a link layer broadcast frame containing a sending timestamp; The slave device receives the link layer broadcast frame and records a corresponding local receiving timestamp; In a preferred embodiment of the present application, when constructing the link layer broadcast frame, the master device fills the sending timestamp into a predetermined field between the frame header and the payload of the link layer broadcast frame; The slave device analyzes the received link layer broadcast frame at the link layer, and extracts the sending timestamp from the predetermined field; The operation of recording the local receiving timestamp and the operation of extracting the sending timestamp are continuously completed in the link layer processing flow.
[0018] It can be understood that the above process directly completes time marking and reading at the link layer, and the master device writes the sending timestamp into a predetermined field between the frame header and the payload when framing, and the slave device extracts the field and records the local receiving timestamp in the same processing flow immediately after receiving the frame at the link layer, and the two are continuously completed to ensure the correspondence under the same timing reference; the timestamp operation is compressed to the shortest data path close to the physical interface, bypassing the uncertain delay caused by upper layer buffering, queue and scheduling, so that the time information is as close as possible to the real sending and arrival time, thereby providing low-noise samples for subsequent linear modeling based on the timestamp pair and reducing the pollution of asymmetric jitter to parameter estimation. In implementation, the sending path of the master device calls the time reference reading and writes the predetermined field during the link layer encapsulation stage, and the receiving path of the slave device parses the field at the link layer after the frame passes the check, and simultaneously calls the local high-precision timing source to record the arrival time, which are sequentially completed in one receiving processing process, without complex algorithms, only strict field definition and processing timing control; the processing provides stable input for subsequent linear regression and weighted regression, so that the estimation of clock offset and drift is based on reliable link layer measurement, thereby more effectively supporting the improvement of overall synchronization accuracy. The link layer broadcast frame refers to an Ethernet frame or equivalent data link frame sent with a link layer broadcast address and received and parsed by multiple devices simultaneously within the same link. Through this one-time sending and multi-end visible mode, the master device can synchronously distribute reference information with a sending timestamp to multiple slave devices.
[0019] The slave device collects a plurality of consecutive sending timestamps and a plurality of consecutive local receiving timestamps to form a timestamp pair sequence; In another preferred embodiment of the application, the slave device maintains a fixed-capacity time window for storing the timestamp pair sequence, wherein each timestamp pair consists of one sending timestamp and one corresponding local receiving timestamp; When a new link layer broadcast frame arrives, the newly extracted sending timestamp and the newly recorded local receiving timestamp are stored as a new timestamp pair in the time window, and the oldest timestamp pair in the time window is removed; Further comprising: The variance value of the interval between all adjacent local receiving timestamps in the time window is calculated; When the variance value is greater than a preset upper threshold, the capacity of the time window is increased; when the variance value is less than a preset lower threshold, the capacity of the time window is decreased; By dynamically adjusting the capacity of the time window, the number of samples used for linear regression calculation matches the current network condition.
[0020] It should be noted that the sample sequence used for fitting is constituted by continuously acquiring the sending and local receiving time stamps, and the time effectiveness and quantity of the samples are limited by the sliding time window, so that the data relied on by the regression represents the current network state and is not outdated. The level of link jitter is characterized by calculating the variance of the interval between adjacent local receiving time stamps. An increase in the variance means an increase in random disturbance and a decrease in the reliability of a single observation. At this time, expanding the window can introduce more samples to reduce the impact of noise on fitting while maintaining recency. A decrease in the variance indicates that the link is more stable. Reducing the window size can improve the response speed to state changes and reduce unnecessary calculation cumulative errors. The specific mapping relationship can be set by experience. The window capacity is adaptively adjusted according to the jitter, so that the sample size entering the linear regression matches the current network status, thereby obtaining a more stable and timely estimate of the clock drift rate and time offset, providing a more reliable parameter basis for subsequent local clock correction, and ultimately improving the stability and consistency of the synchronization process.
[0021] Based on the sequence of time stamps, a clock drift rate and a time offset of a slave device clock relative to a master device clock are calculated using a linear regression algorithm; In another preferred embodiment of the application, calculating the clock drift rate and the time offset comprises: A plurality of the sending time stamps in the sequence of time stamp pairs are taken as an independent variable set, and a plurality of the corresponding local receiving time stamps are taken as a dependent variable set; A straight line is fitted to the independent variable set and the dependent variable set based on the least square method, to obtain a slope parameter and an intercept parameter of the fitted straight line; The slope parameter is determined as the clock drift rate, and the intercept parameter is determined as the time offset.
[0022] It can be understood that by establishing a functional relationship between the master and slave device times in a mathematical sense, the master device sending time and the slave device receiving time are regarded as a corresponding variable set. Within a controllable time window, the difference between the two mainly reflects the slight deviation of the clock running rate and the initial time difference. This linear relationship is derived from the stability characteristics of the clock oscillator, and the frequency drift is a slowly changing systematic deviation, which can be regarded as constant in a short time.
[0023] The least square method is used to fit a straight line to these time stamp pairs, which can obtain the linear mapping that best fits the overall trend in the presence of noise, so that random fluctuations are smoothed. The slope of the fitted straight line reflects the deviation of the slave device clock rate relative to the master device, and the intercept corresponds to the time difference between the two at the reference time.
[0024] Through this statistical method, stable clock drift and time offset information can be extracted from continuous observations without relying on the accuracy of a single measurement. Even if network load changes or link jitter introduce local anomalies, the dynamic time window mechanism will limit the effective interval of the linear assumption by updating the sample set, avoiding the influence of nonlinear errors on the regression result. Therefore, this step theoretically establishes a linearly fitting model for clock synchronization, and the assumption condition is continuously established through sample adaptation in mechanism, so that the calculated drift rate and offset have stability and reliability, providing accurate basis for subsequent clock correction and ensuring overall synchronization accuracy.
[0025] In one preferred embodiment, after obtaining the fitted straight line, the residual of each timestamp pair with respect to the fitted straight line is further calculated. The absolute value of the residual of each timestamp pair is calculated. The reciprocal of all residual absolute values is taken to obtain initial weights. The initial weights are normalized so that the sum of all weights is equal to a predetermined fixed value. The normalized weights are assigned to the corresponding timestamp pairs, where the residual absolute value is inversely proportional to the weight. The independent variable set and the dependent variable set are re-fitted using the weighted least squares method to update the clock drift rate and the time offset.
[0026] It should be noted that on the basis of the initial linear fitting only giving the overall trend, the residual size of each timestamp pair with respect to the fitted straight line is further used to measure its consistency with the linear relationship. The larger the residual, the more likely it is to be affected by instantaneous jitter or abnormal disturbance and deviate from the true relationship, so the reciprocal of the residual absolute value is taken and normalized as the weight. The samples with small deviation and high reliability contribute more in the second fitting, and the samples with large deviation are naturally suppressed. This error inverse weighting method is equivalent to using the consistency information of the data itself to adaptively adjust the sample's right to speak, suppressing the pulling effect of abnormal points on parameters without changing the form of the linear model. The second weighted least squares re-fitting is thus closer to the stable linear mapping between the master and slave clocks, making the slope and intercept less sensitive to instantaneous noise, and providing a more robust parameter basis for subsequent drift and offset correction, so that the synchronization effect remains continuous, reliable and consistent under complex network conditions.
[0027] The local clock of the slave device is adjusted using the calculated clock drift rate and time offset.
[0028] It is worth noting that the time reference of the slave device is corrected by the calculated time offset and clock drift rate, so that the time synchronization is not only numerically aligned, but also consistent in running rate. By directly updating the clock by adding the time offset to the current local time, the fixed difference between the master and the slave can be immediately eliminated, and the time scale is synchronized to the same reference point. However, correcting the time difference alone cannot prevent the clock from deviating again due to the error in the oscillation frequency, so the oscillator frequency needs to be adjusted according to the drift rate. The proportional-integral controller outputs a continuous differentiable analog control voltage according to the change of the drift rate, so that the oscillator frequency slowly tends to the target value in the feedback loop, thereby dynamically correcting the running rate of the clock at the hardware level. Through the combination of instantaneous correction of time value and continuous fine tuning of frequency, the system eliminates static errors while maintaining the consistency of time advancement rate, avoids frequent jumps or accumulated deviations, and keeps the clocks of the master and the slave devices stable and synchronized over a long period of time.
[0029] It is worth noting that when consecutive missing of the timestamp pair sequence is detected, the missing sending timestamp or local receiving timestamp is estimated using a linear extrapolation algorithm based on the existing timestamp pair sequence; When the number of consecutive missing exceeds a set threshold, the currently stored timestamp pair sequence is emptied and the collection process is restarted.
[0030] It can be understood that for the case of consecutive missing of the timestamp pair sequence, the missing data is estimated by a linear extrapolation algorithm to maintain the continuity and calculability of the time sequence. The timestamp pair should be approximately linear in statistics, and the missing samples are often not caused by clock abnormalities but by communication instantaneous interruption or buffer frame loss. Therefore, by using the existing effective timestamp points, the missing values can be extended according to the linear trend without destroying the overall linear structure, so as to maintain the stable input of the regression model. The implementation of the linear extrapolation algorithm is based on the last known timestamp pair, the average change rate between adjacent points is calculated, and the change law is extrapolated to the missing position in time sequence, so as to generate an estimated value for temporarily replacing the real data, so that the subsequent linear regression is not interrupted by individual data gaps. If the consecutive missing exceeds the threshold, it means that the original trend is invalid or the system is abnormal, and continued extrapolation may amplify the error, so the sequence is emptied and re-collected to ensure that the new timestamp pair is re-established on the basis of effective observation. Overall, this mechanism maintains short-term continuous calculation through linear prediction and prevents error accumulation through anomaly detection, so that the synchronization process can still maintain stability and calculation reliability even in the case of incomplete data, and in principle ensures that the drift and offset estimation is always based on reliable data support.
[0031] The overall design idea of the application is to move the key operation of time synchronization from the application layer of the traditional network time protocol to the link layer, so that the time information is generated and analyzed at the communication layer closest to the hardware, thereby avoiding the unpredictable delay introduced by the operating system protocol stack in the timestamp propagation process. Since the link layer processing is directly completed between the driver and the physical interface, the time stamp can truly reflect the actual sending and receiving time of the data packet, reducing the jitter interference caused by interrupts, caches and scheduling. By embedding the sending timestamp in the master device broadcast frame and directly parsing and recording the receiving timestamp at the slave device link layer, the time measurement path is minimized, the system level delay which cannot be controlled is avoided from the root, and the bottleneck of the application layer synchronization accuracy affected by the system load is broken in principle.
[0032] In the utilization layer of time measurement data, the application does not rely on the calculation of time difference in a single interaction, but introduces a continuous time stamp pair sequence, extracts the drift trend and fixed offset between the master and slave clocks through linear regression. Linear regression is based on the physical characteristics of stable clock oscillator frequency, which maps the time difference as a linear function, so that random delay is regarded as noise and is smoothed out in a statistical sense, thereby extracting the stable clock evolution relationship. Further, by using the weighted least squares method, data points with large residuals are given lower weights, so that the fitting process has adaptive suppression ability to abnormal disturbances. This processing makes the synchronization parameters no longer depend on the instantaneous communication state, but reflect the overall consistency of the time sequence, significantly improving the stability and reliability of the calculation results under noise conditions.
[0033] The application also designs a dynamic time window and a frame loss compensation mechanism, so that the algorithm can adjust the number and continuity of data samples in real time according to the network condition. When the link fluctuation causes the variance of the receiving interval to increase, the system automatically expands the window to enhance the statistical smoothing ability; when the network is stable, the window is reduced to speed up the response; if there is a short packet loss, the missing timestamp is completed by linear extrapolation to maintain the continuity of calculation, and when there are too many packet losses, the sequence is automatically reset to prevent error accumulation. Through this dynamic mechanism, the system can maintain the effectiveness of the linear model under different loads and interference conditions, thereby ensuring the long-term stable operation of the synchronization algorithm.
[0034] In the time adjustment link, the application separates the static offset and the dynamic drift for processing, the former eliminates the fixed difference by directly correcting the current clock value, and the latter continuously adjusts the oscillator frequency through proportional integral control, so that the clock frequency gradually approaches the ideal value. This combination realizes the immediacy of time correction and the smoothness of frequency adjustment, avoids the system instability caused by time jump, and at the same time ensures that the calibration result can maintain accuracy for a long time.
[0035] The application is a structural improvement and bottom reconstruction based on the traditional network time protocol (NTP) principle system, and the core idea still continues the basic mechanism of realizing master-slave clock alignment through timestamp exchange, but breaks through the architecture limitation of NTP relying on application layer timestamp. Although the traditional NTP can calculate the clock deviation through the network round-trip delay, the time information must pass through the operating system protocol stack, resulting in that the synchronization accuracy is subject to non-deterministic factors such as system load and kernel scheduling. The scheme directly sinks the generation and extraction of the timestamp to the link layer, and completes the time marking and capture at the bottom layer of physical transmission, so that the time information no longer traverses the operating system path, and the random jitter error introduced by the protocol stack is fundamentally eliminated. It can be said that the scheme inherits the time synchronization logic of NTP in thought, but realizes the system-level evolution in implementation level, and forms a high-precision time synchronization mechanism based on the link layer, which solves the synchronization accuracy bottleneck that the traditional NTP cannot break through in structure.
[0036] The NTP high-precision time synchronization device based on the link layer comprises: A broadcast module: the master device sends a link layer broadcast frame containing a sending timestamp; A receiving module: the slave device receives the link layer broadcast frame and records a corresponding local receiving timestamp; The slave device collects a plurality of continuous sending timestamps and a plurality of continuous local receiving timestamps to form a timestamp pair sequence; A processing module: based on the timestamp pair sequence, a linear regression algorithm is used to calculate a clock drift rate and a time offset of the slave device clock relative to the master device clock; An adjustment module: the local clock of the slave device is adjusted by using the calculated clock drift rate and time offset.
[0037] The above one embodiment of the application is described in detail, but the content is only the preferred embodiment of the application, and cannot be considered as limiting the scope of the application. Any equivalent changes and improvements made within the scope of the application should still belong to the scope of the application.
Claims
1. A high-precision time synchronization method based on the link layer NTP, characterized in that, Includes the following steps: The master device sends a link-layer broadcast frame containing a transmission timestamp; Receive the link layer broadcast frame from the device and record the corresponding local reception timestamp; The device collects multiple consecutive transmission timestamps and multiple consecutive local reception timestamps to form a timestamp pair sequence; Based on the timestamp pair sequence, the clock drift rate and time offset of the slave device clock relative to the master device clock are calculated using a linear regression algorithm; The local clock of the slave device is adjusted using the calculated clock drift rate and the time offset.
2. The NTP high-precision time synchronization method based on the link layer according to claim 1, characterized in that, When constructing the link layer broadcast frame, the master device fills the transmission timestamp into a predetermined field between the frame header and the payload of the link layer broadcast frame; The device parses the received link layer broadcast frame at the link layer and extracts the transmission timestamp from the predetermined field. The operation of recording the local received timestamp and the operation of extracting the sent timestamp are completed consecutively in the link layer processing flow.
3. The NTP high-precision time synchronization method based on the link layer according to claim 2, characterized in that, The slave device maintains a fixed-capacity time window for storing a sequence of timestamp pairs, wherein each timestamp pair consists of a sent timestamp and a corresponding local received timestamp. When a new link layer broadcast frame arrives, the newly extracted sending timestamp and the newly recorded local receiving timestamp are stored as a new timestamp pair in the time window, and the oldest timestamp pair in the time window is removed. This also includes: Calculate the variance of the interval between all adjacent local received timestamps within the time window; When the variance value is greater than a preset upper threshold, the capacity of the time window is increased; when the variance value is less than a preset lower threshold, the capacity of the time window is decreased. By dynamically adjusting the size of the time window, the number of samples used for linear regression calculations is matched to the current network condition.
4. The NTP high-precision time synchronization method based on the link layer according to claim 3, characterized in that, Calculating clock drift rate and time offset includes: The multiple sending timestamps in the timestamp pair sequence are used as the set of independent variables, and the multiple corresponding local receiving timestamps are used as the set of dependent variables. The set of independent variables and the set of dependent variables are fitted with a straight line using the least squares method to obtain the slope parameter and intercept parameter of the fitted line. The slope parameter is determined as the clock drift rate, and the intercept parameter is determined as the time offset.
5. The NTP high-precision time synchronization method based on the link layer according to claim 4, characterized in that, After obtaining the fitted straight line, the residual between each timestamp pair and the fitted straight line is further calculated; Calculate the absolute value of the residual for each of the timestamp pairs; The initial weights are obtained by taking the reciprocal of the absolute value of all the residuals. The initial weights are normalized so that the sum of all weights equals a preset fixed value; the normalized weights are then assigned to the corresponding timestamp pairs, where the absolute value of the residual is inversely proportional to the weight. The set of independent variables and the set of dependent variables are refitted using weighted least squares to update the clock drift rate and the time offset.
6. The NTP high-precision time synchronization method based on the link layer according to claim 5, characterized in that, Adjusting the local clock of the slave device includes: The calculated time offset is added to the current local time value of the slave device, and the result of the addition is used to directly replace the current time value of the local clock. Based on the calculated clock drift rate, an analog voltage value for adjusting the oscillator frequency is calculated by a proportional-integral controller, and the analog voltage value is output to the control terminal of the clock oscillator of the slave device to realize continuous micro-adjustment of the oscillator output frequency.
7. The NTP high-precision time synchronization method based on the link layer according to claim 6, characterized in that, When consecutive missing timestamps are detected in the timestamp pair sequence, the missing sending timestamp or local receiving timestamp is estimated using a linear extrapolation algorithm based on the existing timestamp pair sequence. When the number of consecutive missing items exceeds a set threshold, the currently stored timestamp pair sequence is cleared, and the collection process restarts.
8. A high-precision time synchronization device based on the link layer NTP, characterized in that, include: Broadcast module: The master device sends a link layer broadcast frame containing a transmission timestamp; Receiving module: Receives the link layer broadcast frames from the device and records the corresponding local receiving timestamps; The device collects multiple consecutive transmission timestamps and multiple consecutive local reception timestamps to form a timestamp pair sequence; Processing module: Based on the timestamp pair sequence, calculate the clock drift rate and time offset of the slave device clock relative to the master device clock using a linear regression algorithm; Adjustment module: Adjusts the local clock of the slave device using the calculated clock drift rate and time offset.