Time compensation method, system and device and storage medium
By acquiring and computing the communication time difference between the devices, and using preset algorithms to compensate time, the problem of slave devices being unable to be synchronized is solved, the time synchronization of master and slave devices is realized, and the consistency of communication time is ensured.
Patent Information
- Application Number
- CN202411246531.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-20
AI Technical Summary
In the prior art, if the slave device itself does not have the ability to modify the communication time, it is difficult to achieve time synchronization between master and slave devices, especially in the precise time protocol communication network.
By obtaining the target clock, the communication time difference between devices is determined, including network time error and device time error, the relative time compensation amount is calculated using a preset algorithm, and the compensation for precise time protocol communication is performed to realize time synchronization of the master and slave devices.
It effectively solves the problem that the slave device itself does not have the ability to modify the communication time, realizes time synchronization between master and slave devices, and ensures the consistency and accuracy of communication time.
Smart Images

Figure CN119172028A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication, and in particular to a time compensation method, system, device and storage medium. Background Art
[0002] Master-slave synchronization refers to setting up a high-precision reference clock in a switching node, and sending this reference clock signal to each slave node in the precision time protocol communication network through a transmission link. Each slave node uses phase-locked loop technology to lock the local clock frequency to the reference clock frequency, thereby achieving clock signal synchronization between nodes in the precision time protocol communication network.
[0003] Currently, the communication time of the slave device and the master device is generally synchronized for the first time by modifying the communication time of the slave device itself. However, if the slave device itself does not have the ability to modify the communication time, it is difficult to perform the initial synchronization of the communication time between the master and slave devices.
[0004] Therefore, it is desirable to provide a time compensation method, system, apparatus and storage medium, which can obtain the relative time between a master device and a slave device, and thereby achieve time synchronization between the master device and the slave device. Summary of the invention
[0005] One or more embodiments of the present specification provide a time compensation method, the method comprising: acquiring a target clock; in response to a first preset condition being satisfied, the first preset condition being related to a first device and a second device performing a precision time protocol communication for a first preset period of time: taking the target clock as a reference, based on a first verification message sent by the first device to the second device, determining a first communication time difference between the first device and the second device, the first communication time difference including a network time error and a first device time error; the first device is a device where the target clock is located, and the second device is a slave device of the first device; taking the target clock as a reference, based on a second verification message sent by the second device to the first device, determining a second communication time difference between the second device and the first device, the second communication time difference including a network time error and a second device time error; determining a network time error based on the first communication time error and the second communication time error; determining a first device time error based on the network time error and the first communication time error by a first preset algorithm; the first preset algorithm being related to the determination of the first device time error; determining a relative time compensation amount by a second preset algorithm based on the first device time error; the second preset algorithm being related to the correction of the first device time error; and compensating for the precision time protocol communication based on the relative time compensation amount.
[0006] One or more embodiments of the present specification provide a time compensation system, which includes a first acquisition module and a compensation module; the first acquisition module is configured to acquire a target clock; the compensation module is configured to respond to a first preset condition being satisfied, the first preset condition being related to a first device and a second device performing a precision time protocol communication for a first preset period of time: taking the target clock as a reference, based on a first verification message sent by the first device to the second device, determining a first communication time difference between the first device and the second device, the first communication time difference including a network time error and a first device time error; the first device is a device where the target clock is located, and the second device is a slave device of the first device; taking the target clock as a reference, based on a second verification message sent by the second device to the first device, determining a second communication time difference between the second device and the first device, the second communication time difference including a network time error and a second device time error; determining a network time error based on the first communication time error and the second communication time error; determining a first device time error based on the network time error and the first communication time difference by a first preset algorithm; determining a relative time compensation amount based on the first device time error by a second preset algorithm; and compensating for the precision time protocol communication based on the relative time compensation amount.
[0007] One or more embodiments of the present specification provide a time compensation device, which includes at least one processor and at least one memory; the at least one memory is used to store computer instructions; and the at least one processor is used to execute at least part of the computer instructions to implement any one of the time compensation methods.
[0008] One or more embodiments of the present specification provide a computer-readable storage medium, wherein the storage medium stores computer instructions. When a computer reads the computer instructions in the storage medium, the computer executes any one of the time compensation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] This specification will be further described in the form of exemplary embodiments, which will be described in detail by the accompanying drawings. These embodiments are not restrictive, and in these embodiments, the same number represents the same structure, wherein:
[0010] Figure 1 is an application scenario diagram of a time compensation system according to some embodiments of this specification;
[0011] Figure 2 is a module diagram of a time compensation system according to some embodiments of this specification;
[0012] Figure 3 is an exemplary flow chart of a time compensation method according to some embodiments of this specification;
[0013] Figure 4is an exemplary flow chart of determining a network stability threshold and a communication stability threshold according to some embodiments of this specification; and
[0014] Figure 5 This is an exemplary flow chart of determining a time error of a first device according to some embodiments of the present specification. DETAILED DESCRIPTION
[0015] In order to more clearly illustrate the technical solutions of the embodiments of this specification, the following briefly introduces the drawings required for describing the embodiments. The drawings do not represent all implementation methods.
[0016] It should be understood that the "system", "device", "unit" and / or "module" used herein are a method for distinguishing different components, elements, parts, portions or assemblies at different levels. If other words can achieve the same purpose, the words can be replaced by other expressions.
[0017] As shown in this specification and claims, unless the context clearly indicates an exception, the words "a", "an", "an" and / or "the" do not refer to the singular and may also include the plural. Generally speaking, the terms "comprise" and "include" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements.
[0018] When the operations are performed according to the step description in the embodiments of this specification, unless otherwise specified, the order of the steps is interchangeable, the steps may be omitted, and other steps may be included in the operation process.
[0019] Figure 1 It is an application scenario diagram of the time compensation system shown in some embodiments of this specification.
[0020] In some embodiments, Figure 1 As shown, an application scenario of the time compensation system 200 (hereinafter referred to as application scenario 100 ) may include a processor 110 , a storage device 120 , a network 130 , a first device 140 , and a second device 150 .
[0021] In some embodiments, the processor 110 may process data and / or information obtained from the storage device 120, the network 130, the first device 140, the second device 150, and / or other components of the application scenario 100. For example, the processor may obtain a target clock.
[0022] For another example, the processor may also respond to a first preset condition being met, where the first preset condition is related to precision time protocol communication between the first device and the second device for a first preset period of time, where the first device is a device where the target clock is located, and the second device is a slave device of the first device:
[0023] Taking the target clock as a reference, based on the first verification message sent by the first device to the second device, determine the first communication time difference between the first device and the second device, the first communication time difference includes the network time error and the first device time error; taking the target clock as a reference, based on the second verification message sent by the second device to the first device, determine the second communication time difference between the second device and the first device, the second communication time difference includes the network time error and the second device time error; based on the first communication time difference and the second communication time difference, determine the network time error; based on the network time error and the first communication time difference, determine the first device time error through a first preset algorithm; the first preset algorithm is related to the determination of the first device time error; based on the first device time error, determine the relative time compensation amount through a second preset algorithm; the second preset algorithm is related to the correction of the first device time error; and based on the relative time compensation amount, compensate for the precision time protocol communication.
[0024] For more information about this part, please refer to the following text Figure 3-Figure 5 See the relevant instructions in .
[0025] In some embodiments, the processor 110 may be a single server or a server group. The server group may be centralized or distributed. As an example only, the processor 110 may be a central processing unit (CPU), a graphics processing unit (GPU), an application specific integrated circuit (ASIC), etc., or any combination thereof.
[0026] In some embodiments, the processor 110 may exchange data with other components of the application scenario 100. For example, the processor 110 may access information and / or data from the storage device 120, the first device 140, and the second device 150 through the network 130. For another example, the processor 110 may be directly connected to the storage device 120, the first device 140, and the second device 150 to access information and / or data.
[0027] In some embodiments, the processor 110 may be local or remote. In some embodiments, the processor 110 may be on the first device 140 or the second device 150. In some embodiments, the processor 110 may also be implemented on a cloud platform. By way of example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-layer cloud, etc., or any combination thereof.
[0028] In some embodiments, the storage device 120 may store data, instructions, and / or any other information. For example, the storage device 120 may store a first verification message and a second verification message, etc. In some embodiments, the storage device 120 may store data and / or instructions that the processor 110 uses to execute or use to complete the time compensation method described in this specification.
[0029] In some embodiments, the storage device 120 may include one or more storage components, each of which may be an independent device or a part of another device. In some embodiments, the storage device 120 may include a random access memory (RAM), a read-only memory (ROM), etc. or any combination thereof. In some embodiments, the storage device 120 may be implemented on a cloud platform. In some embodiments, the storage device 120 may be a part of the first device 140 and / or the second device 150.
[0030] The network 130 may include any suitable network capable of facilitating information and / or data exchange. In some embodiments, at least one component of the application scenario 100 (e.g., the processor 110, the storage device 120, the first device 140, and the second device 150) may exchange information and / or data with other components via the network 130. For example, the processor 110 may obtain a first verification message and a second verification message from the storage device 120 via the network 130.
[0031] The first device 140 refers to the device where the target clock is located. In some embodiments, the first device 140 may also be a device that directly communicates with the target clock, or may be a device that is closest to the target clock. For example, the first device 140 may be a network device such as a switch or a router that is closest to the target clock. For the content of the target clock, please refer to the relevant description below.
[0032] In some embodiments, the first device 140 may send a synchronization message and transmit the synchronization message to other communication devices (eg, the second device 150, etc.) in the precision time protocol communication network.
[0033] A synchronization message (SYNC) refers to a message that, when a first device sends a message, needs to block and wait for the message storage result of other communication devices.
[0034] The second device 150 is a slave device of the first device 140. In some embodiments, the second device 150 may receive a synchronization message through the first device 140 in the precision time protocol communication network.
[0035] In some embodiments, the first device 140 and the second device 150 can achieve time synchronization through a synchronization message to ensure the consistency and accuracy of the time of the first device 140 and the second device 150.
[0036] In some embodiments, the first device 140 may send a first verification message to the second device 150 via the precision time protocol communication network, and the second device 150 may send a second verification message to the first device 140 via the precision time protocol communication network.
[0037] Precision Time Protocol (PTP) is a protocol used to implement time synchronization and time transfer in computer networks.
[0038] In some embodiments, a PTP communication network may be used for master-slave synchronization between a master clock and a slave clock.
[0039] Master-slave synchronization refers to setting up a high-precision reference clock at the switching node of a PTP communication network, and sending this reference clock signal to each slave node in the PTP communication network through a transmission link. Each slave node uses phase-locked loop technology to lock the local clock frequency to the reference clock frequency, thereby achieving clock signal synchronization between nodes in the PTP communication network.
[0040] There may be multiple nodes in the communication network of the precision time protocol, each node corresponds to a communication device, the multiple nodes are connected through the network, and the multiple nodes communicate in a point-to-point communication mode.
[0041] In some embodiments, the communication devices on the multiple nodes may include a first device 140 and a second device 150, the first device 140 may be a master node on the PTP communication network, and the second device 150 may be a slave node on the PTP communication network.
[0042] The master node refers to a node that publishes synchronization messages. The clock of the first device on the master node can be the master clock.
[0043] A slave node refers to a node that receives a synchronization message. The clock of the second device on the slave node can be a slave clock.
[0044] In some embodiments, the master clock may send a Sync message to the slave clock and record the sending time, and the slave clock may receive the Sync message and record the receiving time. In a PTP communication network, there may be one master clock and multiple slave clocks.
[0045] It should be noted that application scenario 100 is provided only for the purpose of illustration and is not intended to limit the scope of this specification. For those of ordinary skill in the art, various modifications or changes can be made according to the description of this specification. For example, application scenario 100 can also include a database, an information source, etc. For another example, application scenario 100 can be implemented on other devices to achieve similar or different functions. However, changes and modifications will not deviate from the scope of this specification.
[0046] Figure 2 is a module diagram of a time compensation system 200 according to some embodiments of the present specification.
[0047] The time compensation system 200 is a system for compensating for precision time protocol communications. Figure 2 As shown, the time compensation system 200 may include a first acquisition module 210 and a compensation module 220 .
[0048] In some embodiments, the first acquisition module 210 may be configured to acquire a target clock.
[0049] The compensation module 220 is a module for compensating for precision time protocol communication.
[0050] In some embodiments, the compensation module 220 may be configured to, in response to the first preset condition being met, determine the first communication time difference between the first device and the second device based on the first verification message sent by the first device to the second device, with the target clock as the reference, the first communication time difference including the network time error and the first device time error; the first device is the device where the target clock is located, and the second device is the slave device of the first device; determine the second communication time difference between the second device and the first device based on the target clock as the reference, based on the second verification message sent by the second device to the first device, the second communication time difference including the network time error and the second device time error; determine the network time error based on the first communication time difference and the second communication time difference; determine the first device time error based on the network time error and the first communication time difference through a first preset algorithm; determine the relative time compensation amount based on the first device time error through a second preset algorithm; and compensate for the precision time protocol communication based on the relative time compensation amount. In some embodiments, the first preset condition is related to the precision time protocol communication between the first device and the second device for a first preset period of time. The first device is the device where the target clock is located, and the second device is the slave device of the first device.
[0051] In some embodiments, the first preset algorithm is a Kalman filtering algorithm, and the compensation module 220 can be further configured to: obtain a first observation value of the network time error and a second observation value of the first communication time difference; based on the network time error, the first communication time difference, the first observation value and the second observation value, perform at least one round of iterative update to determine a first sequence of the first device time error until the iteration stop condition is met; one round of iterative update includes: determining a network error stability value based on the network time error and the first observation value; determining a time error stability value based on the first communication time difference and the second observation value; determining a device error stability value of the first device time error based on the network error stability value and the time error stability value, and adding the device error stability value to the first sequence; in response to the iteration stop condition not being met, using the network error stability value as the first observation value of the next iteration and using the time error stability value as the second observation value of the next iteration; in response to the iteration stop condition being met, using the device error stability value as the first device time error.
[0052] In some embodiments, the time compensation system 200 may further include a second acquisition module 230 and a first determination module 240 .
[0053] In some embodiments, the second acquisition module 230 may be configured to acquire a network communication state sequence and a communication time sequence between the first device and the second device.
[0054] The first determining module 240 is a module for determining a first preset period of time.
[0055] In some embodiments, the first determination module 240 can be configured to respond to the network communication status sequence satisfying a second preset condition and the communication time sequence satisfying a third preset condition, the second preset condition being related to the fluctuation range of the network communication status sequence, and the third preset condition being related to the fluctuation range of the communication time sequence; determine the duration between the current moment and the start moment of the precision time protocol communication of the first device as the first preset time period.
[0056] In some embodiments, the second preset condition includes that the fluctuation range of the network communication status sequence is less than the network stability threshold, and the third preset condition includes that the fluctuation range of the communication time sequence is less than the communication stability threshold. The time compensation system 200 may also include a second determination module 250.
[0057] In some embodiments, the second determination module 250 may be configured to determine a network stability threshold and a communication stability threshold based on a network communication state sequence and a communication time sequence through a threshold estimation model, where the threshold estimation model is a machine learning model.
[0058] In some embodiments, the processor 110 in the application scenario 100 may include a first acquisition module 210 , a compensation module 220 , a second acquisition module 230 , a first determination module 240 , and a second determination module 250 .
[0059] For more details about the first acquisition module 210, the compensation module 220, the second acquisition module 230, the first determination module 240 and the second determination module 250, see Figures 3 to 5 and its related instructions.
[0060] It should be understood that Figure 2 The system and its modules shown can be implemented in various ways. It should be noted that this is for the convenience of description only and does not limit this specification to the scope of the embodiments. It is understandable that for those skilled in the art, after understanding the principle of the system, it is possible to arbitrarily combine the modules or form a subsystem to connect with other modules without deviating from this principle. In some embodiments, Figure 2 The first acquisition module 210, compensation module 220, second acquisition module 230, first determination module 240 and second determination module 250 disclosed in the specification can be different modules in a system, or one module can realize the functions of two or more modules. For example, each module can share a storage module, or each module can have its own storage module. Such variations are all within the protection scope of this specification.
[0061] Figure 3 is an exemplary flow chart of a time compensation method according to some embodiments of the present specification. In some embodiments, process 300 may be executed by processor 110 in application scenario 100 or by time compensation system 200. Figure 3 As shown, process 300 includes the following steps 310 to 370.
[0062] Step 310, obtaining a target clock.
[0063] The target clock refers to a clock with the smallest error selected from the clocks of multiple different communication devices, wherein one communication device corresponds to one clock. The multiple different communication devices may be multiple communication devices in a Precision Time Protocol (PTP) communication network.
[0064] In some embodiments, the plurality of communication devices include a first device and a second device. For a description of the first device and the second device, see Figure 1 See the relevant instructions in .
[0065] In some embodiments, for each communication device, the processor can obtain the start time point and end time point of each program that is executed multiple times (e.g., millions of times) as recorded by the clock of the communication device; obtain the total time spent on each program based on the start time point and end time point of each program; obtain the error of the clock of the communication device based on the total time spent on each program according to a preset error algorithm; and use the clock of the communication device with the smallest error as the target clock.
[0066] Just as an example, the error preset algorithm may be to use the calculated variance value of the total time spent on multiple programs corresponding to each communication device as the error of the clock of the corresponding communication device.
[0067] In some embodiments, the processor may execute the following steps 320 to 370 in response to the first preset condition being met.
[0068] In some embodiments, the first preset condition is related to the first device and the second device performing precision time protocol communication for a first preset period of time. For example, the first preset condition may include that the first device and the second device have completed precision time protocol communication for the first preset period of time.
[0069] Precision Time Protocol (PTP) communication refers to that in a PTP communication network, each communication device communicates in a point-to-point communication mode. The communication device includes a first device and a second device.
[0070] The first preset period refers to the time used to establish stable PTP communication between communication devices.
[0071] In some embodiments, the first preset time period may be preset by those skilled in the art based on experience.
[0072] In some embodiments, the processor may also use the following steps 311-312 to determine the first preset time period:
[0073] Step 311: Acquire a network communication state sequence and a communication time sequence between the first device and the second device.
[0074] The network communication state refers to the network communication state when the first device and the second device perform precision time protocol communication.
[0075] In some embodiments, the network communication state may be represented by a first vector. The elements of the first vector may include the time when the first device and a second device perform precision time protocol communication and the network packet loss rate, network bandwidth, and bandwidth utilization corresponding to the time.
[0076] For example, the first vector of the network communication state at time tn can be expressed as (pn, bn, un, tn), where pn represents the network packet loss rate at time tn, bn represents the network bandwidth at time tn, and un represents the bandwidth utilization at time tn.
[0077] The network communication state sequence refers to a sequence composed of network communication states at multiple specific moments. The multiple specific moments may include multiple moments from the moment when the precision time protocol communication between the first device and a second device starts to the current moment.
[0078] For example, based on the aforementioned embodiment, and the time when the precision time protocol communication between the first device and a second device starts is time t1, and the current time is time tn, then the network communication state sequence can be expressed as ((p1, b1, u1, t1), (p2, b2, u2, t2),...(pn, bn, un, tn)).
[0079] In some embodiments, the processor can obtain the network communication status between the first device and a second device at multiple times from the time when the precision time protocol communication is started to the current time through a network monitoring tool such as Wireshark, Nagios, Zabbix, etc., to form a network communication status sequence. The multiple times can be preset by those skilled in the art based on experience.
[0080] The communication time may include a time point when the first device sends a message and a time point when the second device receives the message sent by the first device, from the time when the precision time protocol communication between the first device and the second device is started to the current time.
[0081] In some embodiments, the communication time may be represented by a second vector. The elements of the second vector may include a time point when the first device sends a message and a time point when the second device receives the message sent by the first device.
[0082] A communication time sequence refers to a sequence consisting of multiple communication times. For example, a communication time sequence can be expressed as ((s1, e1), (s2, e2), ..., (sn, en)), where sn is the time when the first device sends message n, and en is the time when a second device receives message n.
[0083] In some embodiments, the processor can retrieve the sending time of multiple messages from the log of the first device and the receiving time corresponding to the aforementioned multiple messages from the log of the second device from the moment when the precision time protocol communication between the first device and a second device starts to the current moment, thereby obtaining a communication time sequence.
[0084] Step 312, in response to the network communication state sequence satisfying the second preset condition and the communication time sequence satisfying the third preset condition, the duration between the current time and the start time of the precision time protocol communication of the first device is determined as the first preset period.
[0085] In some embodiments, the second preset condition is related to a fluctuation range of the network communication state sequence.
[0086] The fluctuation range of the network communication state sequence refers to the range composed of the upper and lower limits of the vector distance between the network communication states at two adjacent moments in the network communication state sequence.
[0087] In some embodiments, the second preset condition may include that a fluctuation range of the network communication state sequence is smaller than a network stability threshold.
[0088] The network stability threshold refers to the critical value of the fluctuation range of the network communication state sequence. In some embodiments, the network stability threshold can be preset by those skilled in the art based on experience.
[0089] In some embodiments, the third preset condition is related to a fluctuation range of the communication time series.
[0090] The fluctuation range of the communication time series refers to the range composed of the upper and lower limits of each communication time in the communication time series.
[0091] In some embodiments, the third preset condition includes that the fluctuation range of the communication time series is smaller than a communication stability threshold.
[0092] The communication stability threshold refers to the critical value of the fluctuation range of the communication time series. In some embodiments, the communication stability threshold can be preset by those skilled in the art based on experience.
[0093] In some embodiments, the processor may also determine the network stability threshold and the communication stability threshold based on the network communication state sequence and the communication time sequence through a threshold estimation model. For more information about this part, please refer to the following Figure 4 Instructions in .
[0094] Step 320: Taking the target clock as a reference and based on the first verification message sent by the first device to the second device, determine a first communication time difference between the first device and the second device.
[0095] In some embodiments, the first verification message includes a first message sent by the first device to the second device and a second message received by the second device from the first device. The first message may include a synchronization message and a sending time T1 when the first device sends the synchronization message. For a description of the synchronization message, see Figure 1 See the relevant instructions in .
[0096] The second message may include the synchronization message received by the second device from the first device and a reception time T2 at which the second device receives the synchronization message from the first device.
[0097] The first communication time difference refers to the time required for the first device to send a synchronization message and for the second device to receive the synchronization message.
[0098] In some embodiments, the first communication time difference includes a network time error and a first device time error.
[0099] Network time error refers to the delay time of one-way network transmission. Network time error can be related to factors such as network path length and router processing time.
[0100] The first device time error refers to the time difference between the clock on the first device and the clock on the second device. As an example only, the first device time error is equal to the time difference between the clock on the first device and the clock on the second device.
[0101] In some embodiments, the processor may determine the first communication time difference using the following first algorithm:
[0102] The first communication time difference=network time error+first device time error.
[0103] In some embodiments, the processor may also use the following second algorithm to determine the first communication time difference:
[0104] The first communication time difference=the reception time T2 of the second message−the sending time T1 of the first message.
[0105] Step 330: Taking the target clock as a reference and based on the second verification message sent by the second device to the first device, determine a second communication time difference between the second device and the first device.
[0106] In some embodiments, the second verification message may include a third message sent by the second device to the first device and a fourth message received by the first device from the second device. The third message may include a synchronization message fed back by the second device to the first device based on the synchronization message obtained from the first device and the sending time T3 of the synchronization message fed back by the second device to the first device. The fourth message may include a synchronization message received by the first device from the second device and a receiving time T4 of the synchronization message received by the first device from the second device.
[0107] The second communication time difference refers to the time required for the second device to send a synchronization message and for the first device to receive the synchronization message.
[0108] In some embodiments, the second communication time difference includes a network time error and a second device time error.
[0109] The second device time error refers to the time difference between the clock on the second device and the clock on the first device. As an example only, the second device time error is equal to the time difference between the clock on the second device and the clock on the first device.
[0110] In some embodiments, the second device time error and the first device time error are inverse numbers of each other.
[0111] In some embodiments, the processor may use the following third algorithm to determine the second communication time difference:
[0112] The second communication time difference=network time error+second device time error.
[0113] In some embodiments, the processor may also use the following fourth algorithm to determine the second communication time difference:
[0114] The second communication time difference=the reception time T4 of the fourth message−the transmission time T3 of the third message.
[0115] Step 340: Determine a network time error based on the first communication time difference and the second communication time difference.
[0116] In some embodiments, the processor may also use the following fifth algorithm to determine the network time error:
[0117] Network time error = first communication time difference + second communication time difference / 2.
[0118] Step 350: Determine a first device time error based on the network time error and the first communication time difference by using a first preset algorithm.
[0119] The first preset algorithm refers to an algorithm used to determine the time error of the first device.
[0120] Just as an example, the first preset algorithm may be: first device time error=first communication time difference-network time error.
[0121] In some embodiments, the processor may also obtain a first observed value of the network time error and a second observed value of the first communication time difference; perform at least one round of iterative updates based on the network time error, the first communication time difference, the first observed value, and the second observed value to determine a first sequence of the first device time error until the iteration stop condition is met; and in response to the iteration stop condition being met, use the device error stable value as the first device time error. For more information about this part, see Figure 5 Instructions in .
[0122] Step 360: Determine a relative time compensation amount based on the first device time error by using a second preset algorithm.
[0123] The second preset algorithm refers to an algorithm for correcting the time error of the first device.
[0124] The relative time compensation refers to the compensation made to the master clock of the first device when the first device communicates with the second device.
[0125] In some embodiments, the processor may multiply the time error of the first device by a stability coefficient as the relative time compensation amount. The stability coefficient may be preset by those skilled in the art based on experience.
[0126] In some embodiments, the second preset algorithm may include a closed-loop control algorithm, and the processor may further determine the relative time compensation amount through the closed-loop control algorithm based on the first device time error sequence within the second preset time period.
[0127] The second preset period refers to a preset time period. The second preset period can be preset by those skilled in the art based on experience.
[0128] The first device time error sequence refers to a sequence composed of the first device time errors at multiple moments in the second preset time period. For example, the first device time error sequence can be expressed as ((m1, t1), (m2, t2), ..., (mn, tn)), where t1, t2 ... tn are moments in the second preset time period, and mn is the first device time error at moment tn.
[0129] In some embodiments, the processor may use the following closed-loop control algorithm to determine the relative time compensation amount:
[0130] Step 361: For the first device time error at the i-th moment in the first device time error sequence, the sixth algorithm shown in the following formula (1) is used to calculate and predict the first device time error.
[0131] Wherein, u(t) is the predicted first device time error; e(t) is the difference between the predicted first device time error at the i-1th moment and the first device time error at the i-1th moment in the first device time error sequence, where i is a positive integer greater than 1; k p is the proportional gain, k i is the integration time, k d is the differential time.
[0132] k p , k i and k d , which can be preset by those skilled in the art based on experience.
[0133] Step 361: determine a relative time compensation amount based on the predicted first device time error corresponding to each moment in the first device time error sequence.
[0134] In some embodiments, the processor may calculate a mean of the predicted first device time errors based on the predicted first device time errors corresponding to each moment in the first device time error sequence; and determine the mean of the predicted first device time errors as a relative time compensation amount.
[0135] In some embodiments of the present specification, the relative time compensation amount is determined by a closed-loop control algorithm, which can further improve the accuracy of the relative time compensation amount finally determined.
[0136] Step 370, compensate the precision time protocol communication based on the relative time compensation amount.
[0137] In some embodiments, when the first device communicates with the second device using the precision time protocol, the processor may add the relative time compensation amount to the communication time of the first device in the precision time protocol communication to compensate, thereby achieving communication time synchronization between the first device (master device) and the second device (slave device) by adjusting the communication time of the first device (master device).
[0138] In some embodiments of the present specification, a first communication time difference and a second communication time difference between a first device and a second device are obtained to determine a relative time compensation amount, and then the communication time of the first device in the precision time protocol communication is added with the relative time compensation amount to stabilize the first communication time difference and the second communication time difference, thereby achieving communication time synchronization between the first device and the second device. When the second device (slave device) itself does not have the ability to modify the communication time to synchronize with the communication time of the first device, synchronization of the precision time protocol communication time between the master and slave devices is achieved by adjusting the communication time of the first device (master device).
[0139] It should be noted that the above description of process 300 is only for example and illustration, and does not limit the scope of application of this specification. For those skilled in the art, various modifications and changes can be made to process 300 under the guidance of this specification. However, these modifications and changes are still within the scope of this specification.
[0140] Figure 4 is an exemplary flow chart of determining a network stability threshold and a communication stability threshold according to some embodiments of this specification. In some embodiments, Figure 4 It can be executed by the processor 110 or the time compensation system 200 in the application scenario 100 .
[0141] In some embodiments, the processor may determine a network stability threshold 430 and a communication stability threshold 440 through a threshold estimation model 410 based on the network communication state sequence 420 - 1 and the communication time sequence 420 - 2 .
[0142] For more information about network communication status sequence, communication time sequence, network stability threshold and communication stability threshold, please refer to Figure 3 See the relevant instructions in .
[0143] In some embodiments, the threshold estimation model 410 may be a machine learning model, such as a recurrent neural network (CNN), a long short-term memory network (LSTM), etc.
[0144] In some embodiments, the input of the threshold estimation model 410 may include a network communication state sequence 420 - 1 and a communication time sequence 420 - 2 , and the output may include a network stability threshold 430 and / or a communication stability threshold 440 .
[0145] In some embodiments, the input of the threshold estimation model 410 may also include first environment data 420 - 3 and second environment data 420 - 4 .
[0146] In some embodiments, the first environment data 420-3 is related to the environment where the first device is located. For example, the first environment data 420-3 may include temperature data and humidity data of the environment where the first device is located.
[0147] In some embodiments, the processor may obtain first environment data of the environment where the first device is located based on a sensor deployed in the environment where the first device is located. For example, the processor may read temperature data detected by a temperature sensor through a network, and may read humidity data detected by a humidity sensor through a network.
[0148] In some embodiments, the processor may also directly read the temperature data and humidity data of the environment where the first device is located from the storage device, where the storage device stores the temperature data and humidity data of the first device collected by the temperature sensor and the humidity sensor respectively.
[0149] In some embodiments, the second environment data 420-4 is related to the environment where the second device is located. For example, the second environment data 420-4 may include temperature data and humidity data of the environment where the second device is located.
[0150] In some embodiments, the method for acquiring the second environment data 420 - 4 is similar to the method for acquiring the first environment data 420 - 3 , and please refer to the above description for details.
[0151] For more information about the first device and the second device, see Figure 1 See the relevant instructions in .
[0152] In some embodiments of the present specification, since temperature and humidity may cause the clock frequencies of the first device and the second device to drift, or affect the stability of the clocks of the first device and the second device, by also considering the temperature and humidity of the environment in which the first device and the second device are located in the input of the threshold estimation model, the threshold estimation model can take into account the environmental data around the first device and the second device when predicting, thereby increasing the accuracy of the threshold estimation model in predicting the network stability threshold and the communication stability threshold, and thereby improving the accuracy of clock synchronization.
[0153] In some embodiments, the input of the threshold estimation model 410 may also include a first workload 420 - 5 and a second workload 420 - 6 .
[0154] In some embodiments, the first workload 420 - 5 is related to the workload of the first device. For example, the first workload 420 - 5 may include the CPU utilization of the first device, the network load of the first device, and / or the disk load of the first device.
[0155] CPU utilization refers to a parameter used to measure the load level of the CPU of a device. For example, CPU utilization can be expressed as a percentage parameter. The larger the value of CPU utilization, the higher the load level of the CPU of the device. In some embodiments, the processor can determine the CPU utilization of the first device through the API of the operating system of the first device, or by querying the Windows task manager and / or the Linux htop tool to determine the CPU utilization of the first device.
[0156] The network load refers to a parameter used to measure the communication frequency of a device. In some embodiments, the processor can obtain the network load of the first device in real time based on software packages such as Wireshark and Tcpdump. Wireshark and Tcpdump are software packages used to capture network data.
[0157] Disk load refers to a parameter used to measure the data interaction performance of a disk. In some embodiments, the disk load may include the read and write rate of the disk and the length of the waiting queue of the disk. For example, the processor may determine the read and write rate of the disk and the length of the waiting queue of the disk based on the Windows resource monitor and / or the Linux Iostat tool.
[0158] In some embodiments, the second workload 420 - 6 is related to the workload of the second device. For example, the second workload 420 - 6 may include the CPU utilization of the second device, the network load of the second device, and / or the disk load of the second device.
[0159] In some embodiments of the present specification, since changes in the workload of the first device and the second device may cause delayed or unstable clock signal transmission, the first workload and the second workload are also considered in the input of the threshold estimation model, which can further improve the accuracy of the network stability threshold and the communication stability threshold predicted by the threshold prediction model, thereby improving the accuracy of clock synchronization.
[0160] In some embodiments, the threshold estimation model can be trained based on a plurality of labeled training samples.
[0161] In some embodiments, each group of training samples in the training samples may include a network communication state sequence and a communication time sequence between a historical sample first device and a historical sample second device. In some embodiments, the training samples may be acquired based on historical data.
[0162] The label may be an actual network stability threshold and an actual communication stability threshold corresponding to the training samples in the historical data.
[0163] For example, when the communication corresponding to the training sample has established a stable precision time protocol communication relationship, the processor can use the peak value of the network communication state sequence and the peak value (for example, maximum value) of the communication time series corresponding to the training sample as the actual network stability threshold and actual communication stability threshold corresponding to the training sample, respectively.
[0164] A stable PTP communication relationship means that when devices communicate with each other through PTP, starting from a certain moment, the subsequent network communication state sequence and communication time sequence fluctuate stably within a certain range, and there is no situation where the network communication state or communication time exceeds the range.
[0165] In some embodiments, the processor may input the network communication state sequence and the communication time sequence between the historical sample first device and the historical sample second device into the initial threshold estimation model, construct a loss function based on the output of the initial threshold estimation model and the training label, and update the parameters of the initial threshold estimation model based on the loss function until the loss function meets the preset conditions to obtain a trained threshold estimation model. The preset conditions may be that the loss function converges, the number of iterations reaches a threshold, etc.
[0166] In some embodiments, the training sample may further include first environment data of a first device of the historical sample and second environment data of a second device of the historical sample. The first environment data of the first device of the historical sample and the second environment data of the second device of the historical sample may be acquired based on historical data.
[0167] In some embodiments, the training sample may further include a first workload of a first device of a historical sample and a second workload of a second device of a historical sample. The first workload of the first device of the historical sample and the second workload of the second device of the historical sample may be acquired based on historical data.
[0168] In some embodiments of the present specification, the threshold estimation model trained based on multiple historical data (for example, the network communication status series, communication time series, environmental data, and workload data mentioned above) has stronger generalization performance for different network environments and different device states, which is beneficial to improving the accuracy of the threshold estimation model in predicting the network stability threshold and communication stability threshold in different scenarios.
[0169] Figure 5 is an exemplary flow chart of a method for determining a time error of a first device according to some embodiments of this specification. In some embodiments, process 500 may be executed by processor 110 or time compensation system 200 in application scenario 100. In some embodiments, process 500 may include the following steps 510-530.
[0170] Step 510: Obtain a first observed value of a network time error and a second observed value of a first communication time difference.
[0171] For a description of network time errors, see Figure 3 Description of step 310.
[0172] The first observation value refers to the network time error during the actual transmission process.
[0173] In some embodiments, the processor may directly use the network time error at the current moment as the first observation value.
[0174] For an explanation of the first communication time difference, see Figure 3 Description of step 320.
[0175] The second observed value refers to the first communication time difference during the actual transmission process.
[0176] In some embodiments, the processor may directly use the first communication time difference at the current moment as the second observation value.
[0177] Step 520, based on the network time error, the first communication time difference, the first observation value and the second observation value, at least one round of iterative update is performed to determine a first sequence of the first device time error until an iteration stop condition is met.
[0178] In some embodiments, the processor may perform a round of iterative update by performing the following steps 521 to 524:
[0179] Step 521, determining a stable value of a network error based on the network time error and the first observation value.
[0180] The network error stability value refers to the optimal predicted network time error.
[0181] In some embodiments, the processor may iteratively execute the following steps a1-a2; and in response to the difference between the predicted network time error and the initial network time error being smaller than a second preset threshold, taking the last predicted network time error as a stable network time error value.
[0182] Step a1, based on the initial network time error, obtain the predicted network time error value through the first state prediction equation group.
[0183] Just as an example, the first state preset equation group may include the following formula (2)-formula (6):
[0184] in, To predict the network time error value, is the initial network time error, A is the state transfer matrix, B is the control input matrix, u k-1 is the control input of the previous iteration, and k is the number of iterations.
[0185] In some embodiments, A and B can be preset by those skilled in the art based on experience.
[0186] The control input refers to the external input that affects the predicted network time error value during the state transfer process of the time compensation system. The external input may include a temperature sequence, a humidity sequence, etc. The temperature sequence may include the temperature value of the environment where the first device is located and the temperature value of the environment where the second device is located in the time period of the previous round of iterations. The humidity sequence may include the humidity value of the environment where the first device is located and the humidity value of the environment where the second device is located in the time period of the previous round of iterations.
[0187] In some embodiments, in response to the difference between the predicted network time error calculated by formula (2) and the initial network time error being greater than or equal to a second preset threshold, the processor may continue to execute the following formulas (3) to (6) to obtain the initial network time error and covariance matrix for the next round of iterative calculation:
[0188] in, is the covariance matrix of k-round iterations, Q is the process noise covariance, A T is the transposed matrix of A, p k-1 is the covariance matrix in k-1 iterations, where k is the number of iterations.
[0189] p k-1 The initial values of and Q can be preset by those skilled in the art based on experience. k-1 The initial value of refers to the value in the first round of iteration, that is, the value of p0 when k=1.
[0190] Among them, K1 k is the first Kalman gain, R1 is the measurement noise covariance, H is the observation matrix, H T is the transposed matrix of H.
[0191] H can be preset by those skilled in the art based on experience.
[0192] In some embodiments, the processor may use the variance value calculated based on the first observation value sequence corresponding to the network time error sequence as the measurement noise covariance R1.
[0193] Among them, zk1 is the first observation value, is the adjusted predicted network time error value based on the first observation value. It can be used as the initial network time error in the next round of iterative calculation.
[0194] Where I is the identity matrix, P k For the adjusted Covariance matrix. P k It can be used as the covariance matrix for k+1 rounds of iterative calculations.
[0195] Step a2: in response to the difference between the predicted network time error value and the initial network time error being smaller than a second preset threshold, taking the predicted network time error value as a stable network time error value.
[0196] In some embodiments, the second preset threshold is a critical value of the difference between the predicted network time error and the network time error.
[0197] The second preset threshold value may be preset by those skilled in the art based on experience.
[0198] In some embodiments, the second preset threshold is related to a fluctuation range of a communication time series between the first device and the second device.
[0199] For an explanation of the fluctuation range of the communication time series, see Figure 3 Description of step 310.
[0200] In some embodiments, the processor may set a larger value of the second preset threshold in response to a larger fluctuation range of the communication time series.
[0201] In some embodiments of the present specification, when the fluctuation range of the communication time series between the first device and the second device is large, a larger second preset threshold is set to avoid the situation where the first preset algorithm cannot be terminated due to the second threshold being too small.
[0202] Step 522: Determine a stable value of the time error based on the first communication time difference and the second observation value.
[0203] The time error stable value refers to the optimal predicted first communication time difference.
[0204] In some embodiments, the processor may iteratively execute the following steps b1-b2; and in response to the difference between the predicted first communication time difference and the initial first communication time difference being less than a third preset threshold, use the last predicted first communication time difference as a stable time error value.
[0205] Step b1, based on the initial first communication time difference, obtain the predicted first communication time difference through the second state prediction equation group.
[0206] For example only, the second state preset equation group may include the aforementioned formula (3) and formula (6), and the following formula (7)-formula (9):
[0207] in, To predict the first communication time difference, is the initial first communication time difference, A is the state transfer matrix, B is the control input matrix, u k-1 is the control input at the previous moment, and k is the number of iterations.
[0208] For more information about A, B, and control inputs, see the description in the first state preset variance group above.
[0209] In some embodiments, in response to the difference between the predicted first communication time difference calculated by formula (7) and the initial first communication time difference being greater than or equal to a third preset threshold, the processor may sequentially execute the aforementioned formula (3), the following formulas (8)-(9) and the aforementioned formula (6) to obtain the initial first communication time difference and covariance matrix for the next round of iterative calculation:
[0210] Among them, K2 k is the second Kalman gain, R2 is the second measurement noise covariance, H is the observation matrix, H T is the transposed matrix of H.
[0211] H can be preset by those skilled in the art based on experience.
[0212] In some embodiments, the processor may calculate the variance value based on the second observation value sequence as the second measurement noise covariance R2. The second observation value sequence refers to a sequence composed of multiple second observation values. In some embodiments, the processor may use the time error stability value obtained by the previous round of iterative calculation as the second observation value of this round of iteration.
[0213] Among them, zk2 is the second observation value, The first communication time difference is predicted after adjustment based on the second observation value. It can be used as the initial first communication time difference in the next round of iterative calculation.
[0214] Step b2: in response to the difference between the predicted first communication time difference and the initial first communication time difference being smaller than a third preset threshold, taking the last predicted first communication time difference as a stable time error value.
[0215] In some embodiments, the third preset threshold is a critical value of the difference between the predicted first communication time difference and the first communication time difference.
[0216] In some embodiments, the third preset threshold may be preset by those skilled in the art based on experience.
[0217] In some embodiments, the third preset threshold is related to a fluctuation range of a communication time series between the first device and the second device.
[0218] For an explanation of the fluctuation range of the communication time series, see Figure 3 Description of step 310.
[0219] In some embodiments, the processor may set a larger value of the third preset threshold in response to a larger fluctuation range of the communication time series.
[0220] In some embodiments of the present specification, when the fluctuation range of the communication time series between the first device and the second device is large, a larger third preset threshold is set to avoid the situation where the first preset algorithm cannot be terminated due to the third threshold being too small.
[0221] Step 523: Determine a device error stable value of the time error of the first device based on the network error stable value and the time error stable value, and add the device error stable value to the first sequence.
[0222] For information about the time error of the first device, see Figure 3 Description of step 320.
[0223] The device error stability value refers to the difference between the time error stability value and the network error stability value.
[0224] In some embodiments, the processor may directly use the difference between the time error stabilization value and the network error stabilization value as the device error stabilization value.
[0225] The first sequence refers to a sequence consisting of an initial first observation value and a stable value of device error generated by multiple iterations. The initial first observation value is an observation value corresponding to the initial network time error. In some embodiments, the processor can use the network time error between the first device and the second device during the actual transmission process of the PTP communication network at the initial moment as the initial first observation value.
[0226] Step 524: In response to the iteration stop condition not being met, the network error stable value is used as the first observation value of the next iteration and the time error stable value is used as the second observation value of the next iteration.
[0227] In some embodiments, the iteration stop condition may include that the fluctuation value of the first sequence is less than a first preset threshold or the number of iterations reaches an iteration number threshold, etc. The iteration number threshold may be preset by those skilled in the art based on experience.
[0228] The fluctuation value of the first sequence may be a statistical value such as a variance value or a standard deviation of the first sequence.
[0229] The first preset threshold refers to the critical value of the fluctuation range value of the first sequence. The first preset threshold can be preset by those skilled in the art based on experience.
[0230] In some embodiments, the first preset threshold is related to a fluctuation range of the network communication status sequence.
[0231] For a description of the network communication state sequence, see Figure 3 Description of step 310.
[0232] In some embodiments, the processor may set a larger value of the first preset threshold in response to a larger fluctuation range of the network communication status sequence.
[0233] In some embodiments of the present specification, when the fluctuation range of the network communication status sequence is large, the fluctuation range of the first communication time difference will also increase accordingly, and the fluctuation range of the first device time error calculated based on the first communication time difference may also increase accordingly. Appropriately increasing the first preset threshold can avoid the situation where the first preset algorithm cannot be terminated.
[0234] Step 530 , in response to the iteration stop condition being met, taking the device error stable value as the first device time error.
[0235] In some embodiments, in response to an iteration stop condition being met, the processor may use a stable value of the device error in a last round as the first device time error.
[0236] In some embodiments of the present specification, the first device time error is determined by using a Kalman filter algorithm, and the accuracy of the finally determined first device time error may be further improved.
[0237] The basic concepts have been described above. Obviously, for those skilled in the art, the above detailed disclosure is only for example and does not constitute a limitation of this specification. Although not explicitly stated here, those skilled in the art may make various modifications, improvements and corrections to this specification. Such modifications, improvements and corrections are suggested in this specification, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of this specification.
[0238] At the same time, this specification uses specific words to describe the embodiments of this specification. For example, "one embodiment", "an embodiment", and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of this specification. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more in different positions in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures or characteristics in one or more embodiments of this specification can be appropriately combined.
[0239] In addition, unless explicitly stated in the claims, the order of the processing elements and sequences described in this specification, the use of alphanumeric characters, or the use of other names are not intended to limit the order of the processes and methods of this specification. Although the above disclosure discusses some invention embodiments that are currently considered useful through various examples, it should be understood that such details are only for illustrative purposes, and the attached claims are not limited to the disclosed embodiments. On the contrary, the claims are intended to cover all modifications and equivalent combinations that are consistent with the essence and scope of the embodiments of this specification. For example, although the system components described above can be implemented by hardware devices, they can also be implemented only by software solutions, such as installing the described system on an existing server or mobile device.
[0240] Similarly, it should be noted that in order to simplify the description disclosed in this specification and thus help understand one or more embodiments of the invention, in the above description of the embodiments of this specification, multiple features are sometimes combined into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the subject matter of this specification are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.
[0241] In some embodiments, numbers describing the number of components and attributes are used. It should be understood that such numbers used in the description of the embodiments are modified by the modifiers "about", "approximately" or "substantially" in some examples. Unless otherwise specified, "about", "approximately" or "substantially" indicate that the numbers are allowed to vary by ±20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximate values, which may change according to the required features of individual embodiments. In some embodiments, the numerical parameters should take into account the specified significant digits and adopt the general method of retaining digits. Although the numerical domains and parameters used to confirm the breadth of their range in some embodiments of this specification are approximate values, in specific embodiments, the setting of such numerical values is as accurate as possible within the feasible range.
[0242] Each patent, patent application, patent application publication, and other materials, such as articles, books, specifications, publications, documents, etc., cited in this specification are hereby incorporated by reference in their entirety. Except for application history documents that are inconsistent with or conflicting with the contents of this specification, documents that limit the broadest scope of the claims of this specification (currently or later attached to this specification) are also excluded. It should be noted that if the descriptions, definitions, and / or use of terms in the materials attached to this specification are inconsistent or conflicting with the contents described in this specification, the descriptions, definitions, and / or use of terms in this specification shall prevail.
[0243] Finally, it should be understood that the embodiments described in this specification are only used to illustrate the principles of the embodiments of this specification. Other variations may also fall within the scope of this specification. Therefore, as an example and not a limitation, alternative configurations of the embodiments of this specification may be considered consistent with the teachings of this specification. Accordingly, the embodiments of this specification are not limited to the embodiments explicitly introduced and described in this specification.
Claims
1. A time compensation method, characterized in that: include: Get the target clock; In response to a first preset condition being met, the first preset condition being related to precision time protocol communication between a first device and a second device for a first preset period of time, the first device being a device where the target clock is located, and the second device being a slave device of the first device: Taking the target clock as a reference and based on a first verification message sent by the first device to the second device, determining a first communication time difference between the first device and the second device, wherein the first communication time difference includes a network time error and a first device time error; Taking the target clock as a reference and based on a second verification message sent by the second device to the first device, determining a second communication time difference between the second device and the first device, wherein the second communication time difference includes the network time error and the second device time error; Determining the network time error based on the first communication time difference and the second communication time difference; Based on the network time error and the first communication time difference, determining the first device time error by a first preset algorithm; the first preset algorithm is related to the determination of the first device time error; Based on the time error of the first device, determining a relative time compensation amount by a second preset algorithm; the second preset algorithm is related to the correction of the time error of the first device; as well as The precision time protocol communication is compensated based on the relative time offset.
2. The method according to claim 1, characterized in that The method further comprises: Acquire a network communication state sequence and a communication time sequence between the first device and the second device; In response to the network communication status sequence satisfying a second preset condition and the communication time sequence satisfying a third preset condition, the second preset condition being related to the fluctuation range of the network communication status sequence, and the third preset condition being related to the fluctuation range of the communication time sequence; the duration between the current moment and the start moment of the precision time protocol communication of the first device is determined as the first preset time period.
3. The method according to claim 2, characterized in that The second preset condition includes that the fluctuation range of the network communication state sequence is less than the network stability threshold, the third preset condition includes that the fluctuation range of the communication time sequence is less than the communication stability threshold, and the method further includes: Based on the network communication state sequence and the communication time sequence, the network stability threshold and the communication stability threshold are determined through a threshold estimation model, and the threshold estimation model is a machine learning model.
4. The method according to claim 1, characterized in that: The first preset algorithm is a Kalman filter algorithm, and determining the first device time error based on the network time error and the first communication time difference by using the first preset algorithm includes: Obtaining a first observed value of the network time error and a second observed value of the first communication time difference; Based on the network time error, the first communication time difference, the first observation value, and the second observation value, at least one round of iterative update is performed to determine a first sequence of the first device time error until an iteration stop condition is met; one round of iterative update includes: Determining a network error stabilization value based on the network time error and the first observation value; Determining a time error stabilization value based on the first communication time difference and the second observation value; Determine a device error stable value of the first device time error based on the network error stable value and the time error stable value, and add the device error stable value to the first sequence; In response to the iteration stop condition not being met, using the network error stable value as the first observation value of the next iteration and using the time error stable value as the second observation value of the next iteration; In response to the iteration stop condition being met, the device error stable value is used as the first device time error.
5. A time compensation system, characterized in that: It includes a first acquisition module and a compensation module; The first acquisition module is configured to acquire a target clock; The compensation module is configured to respond to a first preset condition being met, the first preset condition being related to a first device and a second device performing precision time protocol communication for a first preset period of time, the first device being a device where the target clock is located, and the second device being a slave device of the first device: Taking the target clock as a reference and based on a first verification message sent by the first device to the second device, determining a first communication time difference between the first device and the second device, wherein the first communication time difference includes a network time error and a first device time error; Taking the target clock as a reference and based on a second verification message sent by the second device to the first device, determining a second communication time difference between the second device and the first device, wherein the second communication time difference includes the network time error and the second device time error; Determining the network time error based on the first communication time difference and the second communication time difference; Determine the first device time error based on the network time error and the first communication time difference by using a first preset algorithm; Based on the time error of the first device, determining a relative time compensation amount by a second preset algorithm; as well as The precision time protocol communication is compensated based on the relative time offset.
6. The system according to claim 5, characterized in that The system also includes a second acquisition module and a first determination module; The second acquisition module is configured to acquire a network communication state sequence and a communication time sequence between the first device and the second device; The first determination module is configured to, in response to the network communication status sequence satisfying a second preset condition and the communication time sequence satisfying a third preset condition, the second preset condition being related to the fluctuation range of the network communication status sequence, and the third preset condition being related to the fluctuation range of the communication time sequence; determine the duration between the current moment and the start moment of the precision time protocol communication of the first device as the first preset period.
7. The system according to claim 6, characterized in that The second preset condition includes that the fluctuation range of the network communication state sequence is less than the network stability threshold, the third preset condition includes that the fluctuation range of the communication time sequence is less than the communication stability threshold, and the system further includes a second determination module; The second determination module is configured to determine the network stability threshold and the communication stability threshold based on the network communication state sequence and the communication time series through a threshold estimation model, and the threshold estimation model is a machine learning model.
8. The system according to claim 5, characterized in that The first preset algorithm is a Kalman filter algorithm, and the compensation module is further configured as follows: Obtaining a first observed value of the network time error and a second observed value of the first communication time difference; Based on the network time error, the first communication time difference, the first observation value, and the second observation value, performing at least one round of iterative updating to determine a first sequence of the first device time error until an iteration stop condition is met; One round of iterative updates includes: Determining a network error stabilization value based on the network time error and the first observation value; Determining a time error stabilization value based on the first communication time difference and the second observation value; Determine a device error stable value of the first device time error based on the network error stable value and the time error stable value, and add the device error stable value to the first sequence; In response to the iteration stop condition not being met, using the network error stable value as the first observation value of the next iteration and using the time error stable value as the second observation value of the next iteration; In response to the iteration stop condition being met, the device error stable value is used as the first device time error.
9. A time compensation device, characterized in that: The apparatus comprises at least one processor and at least one memory; The at least one memory is used to store computer instructions; The at least one processor is configured to execute at least part of the computer instructions to implement the time compensation method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: The storage medium stores computer instructions. When the computer reads the computer instructions in the storage medium, the computer executes the time compensation method according to any one of claims 1 to 4.
