Time synchronization method, device and equipment and readable storage medium
By determining the sending time of the synchronization frame and the delay request frame in the PTP system, and using the same network to transmit the time synchronization data, the problem of high PTP time synchronization application costs is solved, the time synchronization accuracy is improved, and the system cost is reduced.
Patent Information
- Application Number
- CN202310377218.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-10
- Publication Date
- 2024-10-15
AI Technical Summary
The application cost of PTP time synchronization is high, mainly because it requires a separate time synchronization network, which increases the deployment and maintenance costs of the system.
By determining the sending time of the synchronization frame and the delay request frame between the master device and the slave device, and using the same network to transmit time synchronization data and business data, the accuracy of the clock deviation is improved and the need to set up a separate time synchronization network is avoided.
It improves the accuracy of PTP time synchronization and reduces application costs, achieving high efficiency and economy in the time synchronization process.
Smart Images

Figure CN118784123A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of timing technology, and in particular, relates to a time synchronization method, device, equipment and readable storage medium. Background Art
[0002] In a system with a high degree of automation, it is usually necessary for the time of each device in the system to be consistent to ensure the real-time and effectiveness of information exchange between devices. Therefore, during the operation of the system, the time of each device needs to be synchronized to keep the clocks of each device synchronized.
[0003] Among them, the precise time protocol (PTP) can achieve a time synchronization accuracy of sub-microsecond level, so it is widely used in systems with high clock accuracy requirements.
[0004] When using PTP time synchronization, in order to maintain high time synchronization accuracy, it is necessary to set up a separate time synchronization network in the system to transmit the data of each device in the system during the time synchronization process through the time synchronization network. Separate networking not only makes the system deployment cost higher, but also makes the system maintenance cost higher, thus making the application cost of PTP time synchronization higher. Summary of the invention
[0005] The embodiments of the present application provide a time synchronization method, apparatus, device and readable storage medium, which can solve the problem of high application cost of PTP time synchronization.
[0006] In a first aspect, an embodiment of the present application provides a time synchronization method, which is applied to a master device, and the method includes:
[0007] Determine the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame;
[0008] A follow-up frame is sent to the slave device, wherein the follow-up frame includes indication information of the sending time of the synchronization frame.
[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the master device determines the moment when the synchronization frame is sent from the sending queue as the sending moment of the synchronization frame. Since the sending moment of the synchronization frame is the moment when the master device actually sends the synchronization frame, even if the synchronization data and the service data are transmitted using the same network, the accuracy of the sending moment of the synchronization frame is relatively high, so that the clock deviation determined based on the sending moment of the synchronization frame can have a high accuracy, thereby making the synchronization process have a high precision, and further making PTP synchronization unnecessary to form a separate network, thereby reducing the application cost of PTP synchronization.
[0010] In one embodiment, determining the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame includes:
[0011] Determine a first time when the synchronization frame enters the first sending queue, and a first waiting time of the synchronization frame in the first sending queue;
[0012] The sending time of the synchronization frame is determined according to the first time and the first waiting period.
[0013] In an embodiment of the present application, in the process of determining the sending time of the synchronization frame, the time when the synchronization frame enters the sending queue of the main device is determined, and the waiting time of the synchronization frame in the sending queue is determined. The actual sending time of the synchronization frame is determined based on the time of entering the sending queue and the waiting time. The time when the synchronization frame is actually sent out from the main device can be determined more accurately.
[0014] In one embodiment, the indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0015] In one embodiment, when the first waiting time is greater than a first preset threshold, sending the synchronization frame is stopped.
[0016] In an embodiment of the present application, the master device does not send a synchronization frame to the slave device when the waiting time for the synchronization frame is long, so that the master device and the slave device can directly end the synchronization when the synchronization is not completed in time in the current synchronization cycle, and the probability of the master device sending the synchronization frame in the current cycle to the slave device in the next synchronization cycle can be reduced, thereby reducing the probability of errors in the synchronization process.
[0017] In one embodiment, when the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent out from the first sending queue before the other data.
[0018] In an embodiment of the present application, when other data are pre-stored in the sending queue, the master device can give priority to sending the synchronization frames in the sending queue according to the priority of the data, so that the synchronization frames can be sent from the sending queue in a timely manner, which can reduce the waiting time of the synchronization frames in the sending queue, thereby improving the synchronization success rate in the current synchronization cycle.
[0019] In a second aspect, an embodiment of the present application provides a time synchronization method, which is applied to a slave device, and the method includes:
[0020] Acquire indication information from a follow-up frame sent by the master device, wherein the indication information indicates that a sending time of the synchronization frame is a time when the synchronization frame is sent from a first sending queue of the master device;
[0021] Determining a clock deviation between the master device and the slave device according to a sending time of the synchronization frame;
[0022] The clock of the slave device is corrected according to the clock deviation.
[0023] In one embodiment, determining the clock deviation between the master device and the slave device according to the sending time of the synchronization frame includes:
[0024] The clock deviation is determined according to a sending time of a delay request frame and a sending time of the synchronization frame, wherein the sending time of the delay request frame is a time when the delay request frame is sent from the second sending queue of the slave device.
[0025] In an embodiment of the present application, the moment when the delay request frame is determined to be sent from the sending queue by the slave device is the sending moment of the delay request frame. Since the sending moment of the delay request frame is the moment when the slave device actually sends the delay request frame, even if the synchronization data and the business data are transmitted using the same network, the accuracy of the sending moment of the delay request frame is relatively high, so that the clock deviation determined based on the sending moment of the delay request frame can have a high accuracy, thereby making the synchronization process have a higher precision, and further making PTP synchronization without separate networking, thereby reducing the application cost of PTP synchronization.
[0026] In one embodiment, before determining the clock deviation according to the sending time of the delay request frame and the sending time of the synchronization frame, the method further includes:
[0027] Determine a second time when the delay request frame enters the second sending queue, and a second waiting time of the delay request frame in the second sending queue;
[0028] The sending time of the delay request frame is determined according to the second time and the second waiting period.
[0029] In an embodiment of the present application, in the process of determining the sending time of a delayed request frame, the time when the delayed request frame enters the sending queue of the slave device is determined, and the waiting time of the delayed request frame in the sending queue is determined. The actual sending time of the delayed request frame is determined based on the time of entering the sending queue and the waiting time. The time when the delayed request frame is actually sent out from the slave device can be determined more accurately.
[0030] In one embodiment, when the second waiting time reaches a second preset threshold, sending the delay request frame is stopped.
[0031] In an embodiment of the present application, the slave device does not send a delay request frame to the master device when the waiting time for the delay request frame is long, so that the master device and the slave device can directly end the synchronization when the synchronization is not completed in time within the current synchronization cycle, and the probability of the slave device sending the delay request frame in the current cycle to the master device in the next synchronization cycle can be reduced, thereby reducing the probability of errors in the synchronization process.
[0032] In one embodiment, when the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent out from the second sending queue before the other data.
[0033] In an embodiment of the present application, when other data are pre-stored in the sending queue, the slave device can give priority to sending the delay request frame in the sending queue according to the priority of the data, so that the delay request frame can be sent from the sending queue in time, which can reduce the waiting time of the delay request frame in the sending queue, thereby improving the synchronization success rate in the current synchronization cycle.
[0034] In one embodiment, before determining the clock deviation, the method further includes:
[0035] Determine the sending time of the synchronization frame according to the first time and the first waiting time in the indication information;
[0036] The first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0037] In a third aspect, an embodiment of the present application provides a time synchronization method, which is applied to a slave device, including:
[0038] Determine the time when the delay request frame is sent from the second sending queue of the slave device as the sending time of the delay request frame;
[0039] Determine the clock deviation between the slave device and the master device according to the sending time of the delay request frame;
[0040] The clock of the slave device is corrected according to the clock deviation.
[0041] In a fourth aspect, an embodiment of the present application provides a time synchronization device, including:
[0042] A determination module, configured to determine the time when a synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame;
[0043] The sending module is used to send a follow-up frame to the slave device, wherein the follow-up frame includes indication information of the sending time of the synchronization frame.
[0044] In one embodiment, the determination module is specifically used to determine the first moment when the synchronization frame enters the first sending queue, and the first waiting time of the synchronization frame in the first sending queue; and determine the sending time of the synchronization frame based on the first moment and the first waiting time.
[0045] In one embodiment, the indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0046] In one embodiment, the sending module is further configured to stop sending the synchronization frame when the first waiting time is greater than a first preset threshold.
[0047] In one embodiment, when the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent out from the first sending queue before the other data.
[0048] In a fifth aspect, an embodiment of the present application provides a time synchronization device, including:
[0049] An acquisition module, used for acquiring indication information from a follow-up frame sent by a master device, wherein the indication information indicates that the sending time of the synchronization frame is the time when the synchronization frame is sent from a first sending queue of the master device;
[0050] A determination module, used to determine the clock deviation between the master device and the slave device according to the sending time of the synchronization frame;
[0051] A correction module is used to correct the clock of the slave device according to the clock deviation.
[0052] In one embodiment, the determination module is specifically used to determine the clock deviation based on the sending time of the delay request frame and the sending time of the synchronization frame, and the sending time of the delay request frame is the time when the delay request frame is sent from the second sending queue of the slave device.
[0053] In one embodiment, the determination module is also used to determine a second moment when the delay request frame enters the second sending queue, and a second waiting period of the delay request frame in the second sending queue; and determine the sending moment of the delay request frame based on the second moment and the second waiting period.
[0054] In one embodiment, the device further comprises:
[0055] The sending module is used to stop sending the delay request frame when the second waiting time reaches a second preset threshold.
[0056] In one embodiment, when the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent out from the second sending queue before the other data.
[0057] In one embodiment, the determination module is also used to determine the sending time of the synchronization frame based on the first moment and the first waiting time in the indication information; wherein, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0058] In the sixth aspect, an embodiment of the present application provides a time synchronization device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, it implements the method described in any one of the first to third aspects.
[0059] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the first to third aspects is implemented.
[0060] In an eighth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute a method as described in any one of the first to third aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0062] Figure 1 It is a schematic diagram of a system structure provided in an embodiment of the present application.
[0063] Figure 2 This is a schematic diagram of a time synchronization process of a precise time protocol provided in an embodiment of the present application.
[0064] Figure 3 This is a data transmission schematic diagram provided by an embodiment of the present application.
[0065] Figure 4It is a flowchart of a time synchronization method provided in one embodiment of the present application.
[0066] Figure 5 This is a signaling interaction diagram of a time synchronization process provided in an embodiment of the present application.
[0067] Figure 6 This is a schematic diagram of a time synchronization process of a master device provided in an embodiment of the present application.
[0068] Figure 7 This is a schematic diagram of a time synchronization process of a slave device provided in an embodiment of the present application.
[0069] Figure 8 It is a structural schematic diagram of a flexible direct current high-voltage energy storage system provided in one embodiment of the present application.
[0070] Fig. 9 A structural block diagram of a time synchronization device provided in an embodiment of the application.
[0071] Fig.10 A structural block diagram of another time synchronization device provided in an embodiment of the application.
[0072] Fig.11 A structural block diagram of another time synchronization device provided in an embodiment of the application. DETAILED DESCRIPTION
[0073] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0074] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0075] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0076] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0077] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0078] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0079] In order to facilitate the understanding of this application, the PTP time synchronization principle is first briefly introduced.
[0080] Figure 1 Schematic diagram of a system structure provided by an embodiment of the present application. Figure 1 As shown, the system includes a first device, a second device, a third device, a fourth device and a fifth device. The multiple devices are connected through two sets of networks, one set of networks is as follows: Figure 1 The solid line in the middle can be called a time synchronization network. The time synchronization network is used to transmit the data of each device during the time synchronization process, which can be called time synchronization data. Figure 1 The dotted line in the middle may be referred to as a business network, which is used to transmit other data except timing data during the operation of each device in the system. Other data may be referred to as business data.
[0081] The symbol "P" indicates the network port in the device used to transmit service data. The symbols "M" and "S" indicate the network ports in the device used to transmit timing data. "M" indicates the network port of the master device, and "S" indicates the network port of the slave device.
[0082] In a time synchronization network, each network segment includes a master device and a slave device. The master device is also called a master clock, and the slave device is also called a slave clock. For example, in the network segment between the first device and the second device, the first device is the master device, and the second device is the slave device. In the network segment between the second device and the third device, the second device is the master device, and the third device is the slave device. In the network segment between the second device and the fourth device, the second device is the master device, and the fourth device is the slave device.
[0083] Among them, the first device can be called the master clock. The first device can obtain accurate time from the timing center through satellite timing, long-wave timing, short-wave timing and other timing methods to achieve time synchronization with the timing center. The second device is a slave device of the first device. The second device can achieve time synchronization with the first device through PTP timing. Similarly, the third device is a slave device of the second device, and the fourth device is a slave device of the second device. The third device and the fourth device can respectively achieve time synchronization with the second device through PTP timing, and so on. Time synchronization between each device in the timing network and the timing center can be achieved.
[0084] It should be noted that Figure 1 This is only an illustrative example. The structure of the system, as well as the structures of the timing network and the service network in the system can be set according to needs, and this embodiment does not limit this.
[0085] Figure 2 This is a schematic diagram of a time synchronization process of a precise time protocol provided in an embodiment of the present application.
[0086] like Figure 2 As shown, each time synchronization process includes steps 21 to 24 in sequence. The time synchronization data includes a synchronization frame (also referred to as a synchronization message), a follow-up frame (also referred to as a follow-up message), a delay request frame (also referred to as a delay request message), and a response frame (also referred to as a delay request response frame or a delay request response message).
[0087] Step 21: The master device sends a synchronization frame to the slave device.
[0088] In the process of using PTP time synchronization, the master device periodically sends synchronization frames to the slave device, and the master device records the sending time of the synchronization frame when sending the synchronization frame. Figure 2 Symbol t1 represents the sending time of the synchronization frame.
[0089] After receiving the synchronization frame, the slave device determines and records the reception time of the synchronization frame. Figure 2 Symbol t2 represents the reception time of the synchronization frame.
[0090] Step 22: The master device sends a follow frame to the slave device.
[0091] After sending the synchronization frame to the slave device, the master device sends a follow-up frame to the slave device, the follow-up frame includes the sending time t1 of the synchronization frame, and the slave device can obtain the sending time t1 of the synchronization frame from the follow-up frame.
[0092] Step 23: The slave device sends a delay request frame to the master device.
[0093] wherein the slave device sends a delay request frame to the master device after receiving the follow frame, and determines and records the sending time of the delay request frame, Figure 2 Symbol t3 indicates the time when the delay request frame is sent.
[0094] Step 24: The master device sends a response frame to the slave device.
[0095] After receiving the delay request frame, the master device records the reception time of the delay request frame and sends a response frame to the slave device, wherein the response frame includes the reception time of the delay request frame. Figure 2 Symbol t4 indicates the reception time of the delay request frame.
[0096] After receiving the response frame, the slave device can obtain t1, t2, t3 and t4, and can determine the clock deviation (offset) between the slave device and the master device according to t1, t2, t3 and t4, as well as the network delay (delay) between the slave device and the master device. The slave device can correct the clock of the slave device according to the clock deviation to synchronize the time of the slave device with the master device.
[0097] The time difference between the sending time t1 and the receiving time t2 is composed of the network delay and clock deviation between the master device and the slave device. The time difference between the sending time t3 and the receiving time t4 is equal to the time difference between the network delay and the clock deviation. Therefore, the clock deviation and network delay can be determined by the following formula:
[0098]
[0099]
[0100] It can be seen from formula (1) and formula (2) that the more accurate t1, t2, t3 and t4 determined in the time synchronization process are, the more accurate the clock deviation is, and the more accurate the clock deviation is, the higher the time synchronization accuracy is.
[0101] It can be understood that the master device and the slave device perform a synchronization in each synchronization cycle. In each synchronization cycle, the master device first sends a synchronization frame to the slave device, and then sends a follow-up frame to the slave device. After receiving the follow-up frame, the slave device sends a delay request frame to the master device, and then receives the response frame sent by the master device, and finally determines the clock deviation, and corrects the clock of the slave device according to the clock deviation to complete a synchronization.
[0102] like Figure 1 As shown in the figure, in order to maintain a high time synchronization accuracy, when using PTP time synchronization, a separate time synchronization network is usually established outside the system's business network. The network ports of each device in the time synchronization network are only used to transmit time synchronization data, which can avoid congestion of network port "M" and network port "S", thereby improving the accuracy of t1, t2, t3 and t4. Among them, when the network port is congested, it mainly affects the sending process of the synchronization frame and the delay request frame. Therefore, when the network port is congested, it mainly affects the accuracy of the sending time t1 and the sending time t3.
[0103] Obviously, establishing a separate timing network outside the business network will increase the cost of system deployment, and during system maintenance, the timing network and the business network need to be maintained at the same time, which makes the system maintenance cost relatively high. As a result, the application cost of PTP timing is high and it is difficult to be widely used.
[0104] Among them, the main reason that affects the accuracy of the sending time when the synchronization data and business data are transmitted in the same network is that the device usually sends data through the sending queue. During the process of sending a certain data, if the sending queue is empty, the network port is not congested and the data can be sent directly through the network port. When there is other data to be sent in the sending queue, which causes the network port to be congested, the data will first enter the sending queue and wait. When the other data that entered the sending queue in advance is sent, the data will be sent from the network port.
[0105] When timing data and business data are transmitted in the same network, business data may enter the sending queue in advance during the sending of timing data. After entering the sending queue, the timing data will most likely wait for a period of time before being sent, which may cause the final determined sending time to be inaccurate.
[0106] Figure 3 Schematic diagram of data transmission provided by an embodiment of the present application. Figure 3 As shown, the software architecture of each device includes an application layer, a data link layer, a physical layer, and other layers not shown. When sending certain data, the application layer first transmits the data to the data link layer, and the data link layer calls the sending function to send the data. The data enters the sending queue at the input time and is sent from the sending queue at the sending time. The data sent from the sending queue is transmitted to other devices through the network port.
[0107] The input time is the time when the send function is called, and the send time is the time when the data is sent from the send queue and sent through the network port, which is the time when the device actually sends the data. The device is equipped with a clock inside. The input time is the time when the send function is called, and the send time is the time when the data is sent from the send queue by the clock inside the device.
[0108] When the sending queue is empty and the network port is not congested, the input time is close to the sending time or is the same as the sending time, that is, the input time is close to the actual sending time of the data or is the same as the actual sending time. When other data to be sent is pre-stored in the sending queue, after the data enters the sending queue at the input time, it needs to wait for a period of time before it can be sent from the sending queue. At this time, there is a certain time difference between the sending time and the input time, that is, there is a time difference between the input time and the actual sending time of the data.
[0109] In the related art, when the master device sends a synchronization frame, after the application layer sends the synchronization frame to the data link layer, the data link layer calls the sending function at the input time to send the synchronization frame, and determines the input time as the sending time of the synchronization frame. Since an independent timing network is used to transmit the timing data, the sending queue is generally empty and the network port is generally not congested, so the determined sending time is close to the actual sending time of the synchronization frame or is the actual sending time of the synchronization frame.
[0110] Similarly, when the slave device is sending a delay request frame, after the application layer sends the delay request frame to the data link layer, the data link layer calls the sending function at the input time to send the delay request frame, and determines the input time as the sending time of the delay request frame. Since an independent timing network is used to transmit timing data, the sending queue is generally empty and the network port is generally not congested, so the determined sending time is close to the actual sending time of the delay request frame or is the actual sending time of the delay request frame.
[0111] When the timing data and business data are transmitted in the same network, since the amount of business data is usually large, the sending queue is generally not empty during the process of sending the delay request frame or the synchronization frame. When the sending time is determined by the above method, there is a high probability that there will be a certain time difference between the final determined sending time and the actual sending time, making the determined sending time inaccurate. Therefore, in order to improve the timing accuracy, the related technology usually adopts an independent networking method for PTP timing.
[0112] Based on the discovery of the above reasons, the embodiment of the present application provides a PTP-based time synchronization method, in which the master device determines the time when the synchronization frame is sent from the sending queue during the process of sending the synchronization frame to the slave device, and uses the time as the sending time of the synchronization frame. Even if the synchronization data and the service data are transmitted using the same network, since the sending time is the time when the master device actually sends the synchronization frame, the accuracy is relatively high, and the clock deviation determined based on the sending time can have a high accuracy, so that the time synchronization process can have a high precision.
[0113] like Figure 3 As shown, in the timing method provided in an embodiment of the present application, during the process of sending a synchronization frame, the master device can determine the sending time when the synchronization frame is sent from the sending queue as the sending time of the synchronization frame. The sending time is close to or equal to the time when the synchronization frame is actually sent from the network port of the master device, and has high accuracy.
[0114] Since the synchronization method provided in the embodiment of the present application can also make the synchronization process have high accuracy when the synchronization data and business data are transmitted in a set of networks, PTP synchronization does not require a separate network, thereby reducing the application cost of PTP synchronization.
[0115] Among them, for the sake of ease of distinction, the embodiment of the present application refers to the sending queue in the master device as the first sending queue, and the sending queue in the slave device as the second sending queue. The first sending queue is used to store data to be sent in the master device, and the second sending queue is used to store data to be sent in the slave device.
[0116] Figure 4 FIG. 1 is a flow chart of a time synchronization method provided in an embodiment of the present application. Figure 4 As shown, the method is applied to a master device and may include steps 41 and 42.
[0117] Step 41: The master device determines the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame.
[0118] In this embodiment, the master device determines the sending time t1 in the process of sending the synchronization frame to the slave device. In each synchronization cycle, the master device first sends the synchronization frame to the slave device, and determines and records the sending time t1 of the synchronization frame. Figure 3 As shown, in the process of sending the synchronization frame, after the data link layer of the master device receives the synchronization frame sent by the application layer, it calls the sending function to send the synchronization frame at the input time. The synchronization frame enters the first sending queue at the input time, and is sent from the first sending queue at the sending time and sent to the slave device through the network port of the master device.
[0119] Exemplarily, during the process of sending a synchronization frame, the master device can monitor the synchronization frame after calling the sending function. When it is detected that the synchronization frame is sent from the first sending queue, the time of the clock in the master device can be obtained, and the time of the master device clock can be determined as the sending time t1 of the synchronization frame.
[0120] Step 42: The master device sends a follow frame to the slave device.
[0121] In this embodiment, after the master device sends a synchronization frame to the slave device and determines the sending time t1, it sends a follow-up frame including indication information of the sending time t1 to the slave device. For example, the indication information may be the sending time t1, and the master device may send a follow-up frame including the sending time t1 to the slave device. Correspondingly, after receiving the follow-up frame, the slave device may obtain the sending time t1 from the follow-up frame.
[0122] In one embodiment, after receiving the follow-up frame sent by the master device, the slave device may send a delay request frame to the master device. In the process of sending the delay request frame, the slave device may determine the input time when the delay request frame enters the second sending queue as the sending time t3 of the delay request frame.
[0123] like Figure 2 As shown, after receiving the delay request frame, the master device determines the receiving time t4 of the delay request frame, and sends a response frame including the receiving time t4 to the slave device. After receiving the response frame, the slave device can obtain the sending time t1 and the receiving time t4, and can determine the pre-recorded receiving time t2 and the sending time t3, and then input the sending time t1, the receiving time t2, the sending time t3 and the receiving time t4 into formulas (1) and (2), and determine the clock deviation between the master device and the slave device through formulas (1) and (2), and then correct the clock of the slave device according to the clock deviation, so that the time of the slave device clock is synchronized with the time of the master device clock.
[0124] It should be noted that the method for correcting the clock of the slave device according to the clock deviation can be specifically set according to requirements, and this embodiment does not limit this.
[0125] Optionally, step 41 may include:
[0126] Determine a first time when the synchronization frame enters the first sending queue, and a first waiting time of the synchronization frame in the first sending queue;
[0127] The sending time of the synchronization frame is determined according to the first time and the first waiting time.
[0128] In one embodiment, when determining the sending time t1, the master device may first determine the first time when the synchronization frame enters the first sending queue, then determine the first waiting time of the synchronization frame in the first sending queue, and determine the sending time t1 according to the first time and the first waiting time. Figure 3 As shown, in the process of sending a synchronization frame to a slave device, the master device first calls a sending function at an input time to send the synchronization frame. The synchronization frame enters a first sending queue at the input time, and the input time is the first time.
[0129] Exemplarily, in the process of sending a synchronization frame, the master device starts timing when calling a sending function to send a synchronization frame, and determines the first moment when the sending function is called. When the synchronization frame is detected to be sent from the first sending queue, the timing is stopped, and the timing duration is the first waiting duration. The sending time t1 can be obtained by adding the first waiting duration to the first moment. The method for determining the first waiting duration may include but is not limited to the above examples.
[0130] like Figure 3 As shown, the first waiting time is the time difference between the input time and the sending time. When no other data to be sent is stored in the sending queue, the time difference between the input time and the sending time is close to or equal to 0, and the sending time t1 is close to the first time or is the first time. When other data to be sent is pre-stored in the sending queue, the time difference between the input time and the sending time is large, and the actual sending time of the synchronization frame, that is, the sending time t1, can be obtained by adding the first waiting time to the base length of the first time.
[0131] If the first time is represented by symbol t01 and the first waiting time is represented by symbol td1, the sending time t1 = t01 + td1.
[0132] In an embodiment of the present application, in the process of determining the sending time of the synchronization frame, the time when the synchronization frame enters the sending queue of the main device is determined, and the waiting time of the synchronization frame in the sending queue is determined. The actual sending time of the synchronization frame is determined based on the time of entering the sending queue and the waiting time. The time when the synchronization frame is actually sent out from the main device can be determined more accurately.
[0133] Optionally, the indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0134] In one embodiment, the indication information of the sending time of the synchronization frame may include the first time t01 and the first waiting time td1. Correspondingly, after receiving the follow-up frame, the slave device may obtain the indication information including the first time t01 and the first waiting time td1 from the follow-up frame, and then determine the sending time t1 according to the first time t01 and the first waiting time td1, t1=t01+td1.
[0135] Optionally, the method may further include:
[0136] When the first waiting time is greater than the first preset threshold, the sending of synchronization frames is stopped.
[0137] In one implementation, during the process of sending synchronization frames to the slave device, the master device may stop sending the synchronization frames when the first waiting time reaches a first preset threshold, so as to end the current time synchronization.
[0138] Exemplarily, the master device starts timing after inputting the synchronization frame into the first transmission queue, and when the timing duration reaches the first preset threshold, it is determined that the first waiting duration reaches the first preset threshold. When it is determined that the first waiting duration reaches the first preset threshold, it can be determined that the waiting duration of the synchronization frame is too long, and the current time synchronization is invalid, and the master device can stop sending the synchronization frame to end the current time synchronization.
[0139] After the master device stops sending synchronization frames to end the current time synchronization, the master device may send synchronization frames to the slave device again in the next time synchronization period to start the next time synchronization.
[0140] It can be understood that the first preset threshold is smaller than the period length of the timing cycle. When the first waiting period reaches the first preset threshold, the current timing cycle is close to ending, or the current timing cycle ends when the first waiting period reaches the first preset threshold. The specific value of the first preset threshold can be set according to demand, and this embodiment does not impose any restrictions on this.
[0141] In an embodiment of the present application, the master device does not send a synchronization frame to the slave device when the waiting time for the synchronization frame is long, so that the master device and the slave device can directly end the synchronization when the synchronization is not completed in time in the current synchronization cycle, and the probability of the master device sending the synchronization frame in the current cycle to the slave device in the next synchronization cycle can be reduced, thereby reducing the probability of errors in the synchronization process.
[0142] Optionally, when the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent from the first sending queue before the other data.
[0143] In one embodiment, when the master device is sending a synchronization frame to the slave device, if the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame may be sent before sending the other data.
[0144] In the timing method provided in the embodiment of the present application, timing data and business data can be transmitted in a set of networks. When the timing data and business data are transmitted in a set of networks, when the master device is in the process of sending a synchronization frame to the slave device, when the synchronization frame enters the first sending queue, there is a high probability that some business data will be pre-stored in the first sending queue.
[0145] In this embodiment, for different types of business data and synchronization data in the synchronization process, the priority of each type of data can be pre-set. In the process of sending a synchronization frame to a slave device, after calling the sending function to input the synchronization frame into the first sending queue, if it is determined that one or more different types of other data are pre-stored in the first sending queue, the master device can determine the priority of the synchronization frame and the priority of other data stored in the first sending queue. When the priority of the synchronization frame is higher than the priority of a certain data in the first sending queue, the master device can give priority to sending the synchronization frame so that the synchronization frame is sent from the first sending queue before the data.
[0146] Among them, when there is a lot of business data pre-stored in the first sending queue, the synchronization frame needs to wait for a long time in the first sending queue. When the waiting time is long, the synchronization frame cannot be sent in time, which will cause the time synchronization to fail. Therefore, the longer the synchronization frame waits in the first sending queue, the lower the success rate of time synchronization.
[0147] In an embodiment of the present application, when other data are pre-stored in the sending queue, the master device can give priority to sending the synchronization frames in the sending queue according to the priority of the data, so that the synchronization frames can be sent from the sending queue in a timely manner, which can reduce the waiting time of the synchronization frames in the sending queue, thereby improving the synchronization success rate in the current synchronization cycle.
[0148] To sum up, in the embodiment of the present application, the master device determines the moment when the synchronization frame is sent from the sending queue as the sending moment of the synchronization frame. Since the sending moment of the synchronization frame is the moment when the master device actually sends the synchronization frame, even if the synchronization data and the business data are transmitted using the same network, the accuracy of the sending moment of the synchronization frame is relatively high, so that the clock deviation determined based on the sending moment of the synchronization frame can have a higher accuracy, thereby making the synchronization process have a higher precision, and further making PTP synchronization without separate networking, which can reduce the application cost of PTP synchronization.
[0149] Figure 5 FIG. 1 is a schematic diagram of a signaling interaction of a time synchronization process provided by an embodiment of the present application. Figure 5 As shown, the method may include steps 51 to 56.
[0150] Step 51: The master device sends a synchronization frame to the slave device.
[0151] Step 52: The master device determines the time to send the synchronization frame.
[0152] In the process of sending the synchronization frame to the slave device, the master device may determine the time when the synchronization frame is sent from the first sending queue as the sending time t1. The method for determining the sending time t1 may refer to step 41, and this embodiment will not be described in detail here.
[0153] Step 53: The slave device determines the reception time of the synchronization frame.
[0154] In this embodiment, after receiving the synchronization frame sent by the master device, the slave device determines the time when the synchronization frame is received as the reception time t2 of the synchronization frame, and records the reception time t2.
[0155] Step 54: The master device sends a follow frame to the slave device.
[0156] The following frame includes indication information of the sending time t1. The indication information may include the sending time t1 or include the first time t01 and the first waiting time td1.
[0157] Step 55: The slave device sends a delay request frame to the master device.
[0158] Step 56: The slave device determines the time to send the delay request frame.
[0159] In this embodiment, when determining the sending time t3, the slave device may directly determine that the time when the delay request frame enters the second sending queue is t3.
[0160] In one implementation, the sending time of the delay request frame is the time when the delay request frame is sent from the second sending queue of the slave device.
[0161] In the embodiment of the present application, the slave device determines the sending time of the delay request frame from the sending queue in the process of sending the delay request frame to the master device. Even if the synchronization data and the service data are transmitted using the same network, since the sending time of the delay request frame is the time when the slave device actually sends the delay request frame, the accuracy is high, and the clock deviation determined based on the sending time can also have a high accuracy, so that the synchronization process can have a high precision.
[0162] Optionally, step 56 may include:
[0163] Determine a second time when the delay request frame enters the second sending queue, and a second waiting time of the delay request frame in the second sending queue;
[0164] The sending time of the delay request frame is determined according to the second time and the second waiting time.
[0165] In one embodiment, when determining the sending time t3, the slave device may first determine the second time when the delay request frame enters the second sending queue, then determine the second waiting time of the delay request frame in the second sending queue, and determine the sending time t3 according to the first time and the second waiting time. Figure 3 As shown, in the process of sending a delay request frame to the master device, the slave device first calls the sending function to send the delay request frame at the input time, and the delay request frame enters the second sending queue at the input time, and the input time is the second time.
[0166] Exemplarily, in the process of sending a delay request frame, the slave device starts timing when calling a sending function to send a delay request frame, and determines a second time when the sending function is called. When it is detected that the delay request frame is sent from the second sending queue, the timing is ended, and the timing duration is the second waiting duration. The sending time t3 can be obtained by adding the second waiting duration to the second time.
[0167] like Figure 3 As shown, the second waiting time is the time difference between the input time and the sending time. When no other data to be sent is stored in the sending queue, the time difference between the input time and the sending time is close to or equal to 0, and the sending time t3 is close to the input time or the sending time t3 is the input time. When other data to be sent is pre-stored in the sending queue, the time difference between the input time and the sending time is large, and the actual sending time of the delay request frame, that is, the sending time t3, can be obtained by adding the second waiting time to the base length of the first time.
[0168] If the second time is represented by symbol t02 and the second waiting time is represented by symbol td2, then the sending time t3 = t02 + td2.
[0169] In an embodiment of the present application, in the process of determining the sending time of a delayed request frame, the time when the delayed request frame enters the sending queue of the slave device is determined, and the waiting time of the delayed request frame in the sending queue is determined. The actual sending time of the delayed request frame is determined based on the time of entering the sending queue and the waiting time. The time when the delayed request frame is actually sent out from the slave device can be determined more accurately.
[0170] Step 57: The master device determines the reception time of the delay request frame.
[0171] In this embodiment, after receiving the delay request frame sent by the slave device, the master device determines the time when the delay request frame is received as the receiving time t4, and records the receiving time t4.
[0172] Step 58: The master device sends a response frame to the slave device.
[0173] In this embodiment, after receiving the delay request frame sent by the slave device and determining the receiving time t4 of the delay request frame, the master device may send a response frame including the receiving time t4 to the slave device.
[0174] Step 59: Determine the clock deviation from the device.
[0175] In this embodiment, after receiving the response frame sent by the master device, the slave device can obtain the sending time t1 from the follow-up frame, obtain the receiving time t4 from the response frame, and obtain the pre-recorded receiving time t2 and sending time t3. Then, the slave device can input the sending time t1, the receiving time t2, the sending time t3 and the receiving time t4 into formula (1) and formula (2) respectively, and determine the clock deviation between the master device and the slave device through formula (1) and formula (2).
[0176] In one embodiment, when the indication information in the follow-up frame sent by the master device includes the first time and the first waiting time, the slave device can determine the sending time t1 according to the first time and the first waiting time in the indication information.
[0177] Step 60: The slave device corrects the clock according to the clock deviation.
[0178] Optionally, during the time synchronization process of the slave device, the sending of the delay request frame may be stopped when the second waiting time reaches a second preset threshold, so as to end the time synchronization.
[0179] In one implementation, during the process of sending the delay request frame to the master device, the slave device may stop sending the delay request frame when the second waiting time reaches a second preset threshold, so as to end the current time synchronization.
[0180] Exemplarily, the slave device starts timing after inputting the delay request frame into the second transmission queue, and when the timing duration reaches the second preset threshold, it is determined that the second waiting duration reaches the second preset threshold. When it is determined that the second waiting duration reaches the second preset threshold, it can be determined that the waiting duration of the delay request frame is too long, and this synchronization fails, and the slave device can stop sending the delay request frame to end this synchronization.
[0181] After the slave device stops sending delay request frames to end the current time synchronization, the master device cannot receive delay request frames in the current time synchronization cycle. After the master device fails to receive delay request frames sent by the slave device in the current time synchronization cycle, it can automatically end the time synchronization of the current time synchronization cycle, and send synchronization frames to the slave device again at the beginning of the next time synchronization cycle to start the next time synchronization.
[0182] It can be understood that the second preset threshold is smaller than the period length of the timing cycle. When the second waiting period reaches the second preset threshold, the current timing cycle is close to ending, or the current timing cycle ends when the second waiting period reaches the first preset threshold. The specific value of the second preset threshold can be set according to demand, and this embodiment does not impose any restrictions on this.
[0183] In an embodiment of the present application, the slave device does not send a delay request frame to the master device when the waiting time for the delay request frame is long, so that the master device and the slave device can directly end the synchronization when the synchronization is not completed in time within the current synchronization cycle, and the probability of the slave device sending the delay request frame in the current cycle to the master device in the next synchronization cycle can be reduced, thereby reducing the probability of errors in the synchronization process.
[0184] Optionally, when the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent from the second sending queue before the other data.
[0185] In one embodiment, when the slave device is sending a delay request frame to the master device, if the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame may be sent before sending the other data.
[0186] In the timing method provided in the embodiment of the present application, timing data and business data can be transmitted in a set of networks. When the timing data and business data are transmitted in a set of networks, when the slave device is in the process of sending a delay request frame to the master device, when the delay request frame enters the second sending queue, there is a high probability that some business data will be pre-stored in the second sending queue.
[0187] In this embodiment, for different types of business data and synchronization data in the synchronization process, the priority of each type of data can be pre-set. In the process of sending a delay request frame from the slave device to the master device, after calling the sending function to input the delay request frame into the second sending queue, if it is determined that one or more different types of data are pre-stored in the second sending queue, the slave device can determine the priority of the delay request frame and the priority of other data stored in the second sending queue. When the priority of the delay request frame is higher than the priority of a certain data in the second sending queue, the slave device can give priority to sending the delay request frame so that the delay request frame can be sent from the second sending queue before the data.
[0188] Among them, when there is a lot of business data pre-stored in the second sending queue, the delay request frame needs to wait for a long time in the second sending queue. When the waiting time is long, the delay request frame cannot be sent in time, which will cause the failure of this time synchronization. Therefore, the longer the delay request frame waits in the second sending queue, the lower the success rate of this time synchronization.
[0189] In an embodiment of the present application, when other data are pre-stored in the sending queue, the slave device can give priority to sending the delay request frame in the sending queue according to the priority of the data, so that the delay request frame can be sent from the sending queue in time, which can reduce the waiting time of the delay request frame in the sending queue, thereby improving the synchronization success rate in the current synchronization cycle.
[0190] It should be noted that, in one embodiment, the master device can determine the time when the synchronization frame is sent from the first sending queue as the sending time of the synchronization frame, and the slave device can determine the time when the delay request frame enters the second sending queue as the sending time of the delay request frame. In this case, since the sending time of the synchronization frame is close to or equal to the time when the synchronization frame is actually sent from the master device, the accuracy is relatively high, and the PTP synchronization can maintain a high accuracy, so that the PTP synchronization does not need to be networked separately.
[0191] In another embodiment, the master device may determine the time when the synchronization frame enters the first transmission queue as the transmission time of the synchronization frame, and the slave device may determine the time when the delay request frame is sent from the second transmission queue as the transmission time of the delay request frame. In this case, since the transmission time of the delay request frame is close to or equal to the time when the delay request frame is actually sent from the slave device, the accuracy is relatively high, and the PTP synchronization can maintain a high accuracy, so that the PTP synchronization does not need to be networked separately.
[0192] In another embodiment, the master device may determine the time when the synchronization frame is sent from the first sending queue as the sending time of the synchronization frame, and the slave device may determine the time when the delay request frame is sent from the second sending queue as the sending time of the delay request frame. In this case, since the sending time of the synchronization frame is close to or equal to the time when the synchronization frame is actually sent from the master device, and the sending time of the delay request frame is close to or equal to the time when the delay request frame is actually sent from the slave device, the accuracy of the sending time of the synchronization frame and the sending time of the delay request frame are relatively high, which can keep the PTP synchronization at a high accuracy, so that the PTP synchronization does not need to be networked separately.
[0193] Figure 6 1 is a schematic diagram of a time synchronization process of a master device provided in an embodiment of the present application. Figure 6As shown, during the time synchronization process, the time synchronization process of the master device includes steps 61 to 66 in sequence.
[0194] Step 61, time synchronization is ready. The master device performs necessary preparation actions before time synchronization, and determines that time synchronization is ready after the preparation actions are completed. The preparation actions include determining the corresponding slave device, detecting whether the network connection with the slave device is normal, and other preparation actions, which are not limited in this embodiment.
[0195] Step 62: Maintain the pulse per second regularly. During the synchronization process, the master device regularly maintains the pulse per second (PPS) to generate a pulse signal every second. The pulse per second is used to control the synchronization cycle, so that the master device performs synchronization with the slave device once within each pulse per second.
[0196] Step 63: Send a synchronization frame to the slave device at time 0 of the second pulse. The master device starts a time synchronization cycle at time 0 of each second pulse signal and sends a synchronization frame to the slave device.
[0197] In the process of sending the synchronization frame to the slave device, the master device determines the second time t01 when the synchronization frame enters the second sending queue, and determines the waiting time td1 of the synchronization frame in the second sending queue.
[0198] Step 64: After sending the synchronization frame, the master device sends a follow frame including t01 and td1 to the slave device.
[0199] Step 65: After sending the synchronization frame, the master device waits to receive a delay request frame sent by the slave device.
[0200] After receiving the delay request frame sent by the slave device, the master device determines the receiving time t4 of the delay request frame. After failing to receive the delay request frame sent by the master device, the master device returns to execute step 61 to start the next time synchronization cycle at time 0 of the next second pulse.
[0201] Step 66: The master device sends a response frame including the receiving time t4 to the slave device.
[0202] After sending the response frame to the slave device, the master device returns to execute step 61 to start the next time synchronization cycle at time 0 of the next second pulse.
[0203] Figure 7 1 is a schematic diagram of a time synchronization process of a slave device provided in an embodiment of the present application. Figure 7 As shown, during the time synchronization process, the time synchronization process of the slave device includes steps 71 to 78 in sequence.
[0204] Step 71, time synchronization is ready. The slave device performs necessary preparation actions before starting time synchronization, and determines that time synchronization is ready after the preparation actions are completed. The preparation actions include determining the corresponding master device, detecting whether the network connection with the master device is normal, and other preparation actions, which are not limited in this embodiment.
[0205] Step 72: The slave device determines whether it has received the synchronization frame sent by the master device.
[0206] In this embodiment, after receiving the synchronization frame sent by the master device, the slave device determines the reception time t2 of the synchronization frame and executes step 73. After failing to receive the synchronization frame sent by the master device, the slave device returns to execute step 71 to start the next synchronization in the next synchronization cycle.
[0207] Step 73: The slave device determines whether it has received a follow-up frame sent by the master device.
[0208] In this embodiment, after receiving the follow-up frame sent by the master device, the slave device obtains the sending time t1 of the delay request frame from the follow-up frame and executes step 74. If the follow-up frame sent by the master device is not received, it returns to execute step 71 to start the next time synchronization in the next time synchronization cycle.
[0209] Step 74: The slave device sends a delay request frame to the master device.
[0210] Step 75: The slave device determines and records the sending time t3 of the delay request frame.
[0211] In this embodiment, when the slave device sends a delayed request frame to the master device, it determines the second moment t02 when the delayed request frame enters the second sending queue, and determines the second waiting time td2 of the delayed request frame in the second sending queue. Based on the second moment t02 and the second waiting time td2, the sending moment t3 of the request frame can be determined and delayed, and the sending moment t3 is recorded.
[0212] Step 76: The slave device determines whether it has received a response frame sent by the master device.
[0213] In this embodiment, the slave device waits to receive a response frame sent by the master device after sending a delay request frame to the master device. After receiving the response frame sent by the master device, step 77 is executed, and if no response frame sent by the master device is received, step 71 is returned to execute.
[0214] Step 77: The slave device determines the clock deviation between itself and the master device according to the sending time t1, the receiving time t2, the sending time t3 and the receiving time t4.
[0215] Step 78: The slave device corrects the clock of the slave device according to the clock deviation so that the time of the slave device clock is synchronized with the time of the master device clock.
[0216] The time synchronization method provided in the embodiment of the present application can be applied to systems that require higher time synchronization accuracy, such as energy storage substation systems, energy storage systems, etc., but is not limited thereto.
[0217] For example, Figure 8 Schematic diagram of a flexible direct current high voltage energy storage system provided in one embodiment of the present application. Figure 8 As shown, the flexible DC high-voltage energy storage system can be divided into the station control layer, the local control layer and the process equipment layer in sequence.
[0218] Among them, the station control layer includes the converter valve control and protection system, the energy storage valve cooling system, and the time synchronization master clock, etc. The local control layer includes the pole control device, the energy storage valve local control system, the energy storage battery local control system, the energy storage valve control device, the valve control expansion box, the energy storage valve protection device three-out-of-two device, etc. The process equipment layer includes the power control module, the battery management control device, and the pole bus merging unit, etc.
[0219] like Figure 8 As shown, there is only one network in the flexible DC high-voltage energy storage system. The devices in the network can be connected through optical fibers. The devices can transmit business data to each other through the Ethernet protocol, and transmit timing data to each other through the Ethernet protocol. During the timing process, the master device and the slave device can use the timing method in the above example to ensure the timing accuracy during the timing process.
[0220] It should be noted that the time synchronization method provided in the embodiment of the present application can also use a separate networking method to perform PTP time synchronization. During the time synchronization process, the master device and the slave device transmit the time synchronization data through an independent time synchronization network.
[0221] Fig. 9 1 is a structural block diagram of a time synchronization device provided in an embodiment of the application. The time synchronization device 9 can be set in a main device, including Fig. 9 A determination module 91 and a sending module 92 are shown.
[0222] A determination module 91, configured to determine the time when a synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame;
[0223] The sending module 92 is used to send a follow-up frame to the slave device, wherein the follow-up frame includes indication information of the sending time of the synchronization frame.
[0224] In one embodiment, the determination module 91 is specifically used to determine the first moment when the synchronization frame enters the first sending queue, and the first waiting time of the synchronization frame in the first sending queue; and determine the sending time of the synchronization frame based on the first moment and the first waiting time.
[0225] In one embodiment, the indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0226] In one embodiment, the sending module 92 is further configured to stop sending the synchronization frame when the first waiting time is greater than a first preset threshold.
[0227] In one embodiment, when the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent out from the first sending queue before the other data.
[0228] Fig.10 The structural block diagram of another time synchronization device provided in the embodiment of the application. The time synchronization device 10 can be set in a slave device, including Fig.10 The acquisition module 101, the determination module 102 and the correction module 103 are shown.
[0229] An acquisition module 101 is used to acquire indication information from a follow-up frame sent by a master device, wherein the indication information indicates that a sending time of a synchronization frame is a time when the synchronization frame is sent from a first sending queue of the master device;
[0230] A determination module 102, configured to determine a clock deviation between the master device and the slave device according to a sending time of the synchronization frame;
[0231] The correction module 103 is used to correct the clock of the slave device according to the clock deviation.
[0232] In one embodiment, the determination module 102 is specifically used to determine the clock deviation based on the sending time of the delay request frame and the sending time of the synchronization frame, and the sending time of the delay request frame is the time when the delay request frame is sent from the second sending queue of the slave device.
[0233] In one embodiment, the determination module 102 is also used to determine a second moment when the delay request frame enters the second sending queue, and a second waiting period of the delay request frame in the second sending queue; and determine the sending moment of the delay request frame based on the second moment and the second waiting period.
[0234] In one embodiment, the device 10 further includes:
[0235] The sending module is used to stop sending the delay request frame when the second waiting time reaches a second preset threshold.
[0236] In one embodiment, when the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent out from the second sending queue before the other data.
[0237] In one embodiment, the determination module 102 is also used to determine the sending time of the synchronization frame based on the first moment and the first waiting time in the indication information; wherein the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
[0238] The embodiment of the present application also provides a time synchronization device, Fig.11 The structural block diagram of a time synchronization device provided in the embodiment of the application. The time synchronization device can be a master device or a slave device, such as Fig.11 As shown, the timing device 11 includes a processor 111 and a memory 113, and the processor 111 and the memory 113 can be connected via one or more buses 114.
[0239] The time synchronization device 11 includes a computer program 112, which is stored in a memory 113. When the computer program 112 is executed by the processor 111, the time synchronization device 11 performs the above Figure 4 The timing method shown. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding physical device, and will not be repeated here.
[0240] An embodiment of the present application also provides a computer-readable storage medium, which includes a computer program. When the computer-readable storage medium is run on a computer, the computer executes the method provided by the above method embodiment.
[0241] An embodiment of the present application also provides a computer program product comprising instructions, and when the computer program product is run on a computer, the computer is enabled to execute the method provided by the above method embodiment.
[0242] An embodiment of the present application also provides a chip system, including a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that a network device equipped with the chip system executes the method provided in the above method embodiment.
[0243] Among them, the chip system may include an input circuit or interface for sending information or data, and an output circuit or interface for receiving information or data.
[0244] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0245] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0246] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0247] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0248] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0249] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0250] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0251] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0252] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A time synchronization method, characterized in that: Applied to a master device, the method comprises: Determine the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame; A follow-up frame is sent to the slave device, wherein the follow-up frame includes indication information of the sending time of the synchronization frame.
2. The method according to claim 1, characterized in that The step of determining the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame comprises: Determine a first time when the synchronization frame enters the first sending queue, and a first waiting time of the synchronization frame in the first sending queue; The sending time of the synchronization frame is determined according to the first time and the first waiting period.
3. The method according to claim 1, characterized in that The indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
4. The method according to claim 2 or 3, characterized in that The method further comprises: When the first waiting time is greater than a first preset threshold, the sending of the synchronization frame is stopped.
5. The method according to any one of claims 1 to 3, characterized in that In the case where the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent out from the first sending queue before the other data.
6. A time synchronization method, characterized in that: Applied to a slave device, the method comprises: Acquire indication information from a follow-up frame sent by the master device, wherein the indication information indicates that a sending time of the synchronization frame is a time when the synchronization frame is sent from a first sending queue of the master device; Determining a clock deviation between the master device and the slave device according to a sending time of the synchronization frame; The clock of the slave device is corrected according to the clock deviation.
7. The method according to claim 6, characterized in that The step of determining the clock deviation between the master device and the slave device according to the sending time of the synchronization frame includes: The clock deviation is determined according to a sending time of a delay request frame and a sending time of the synchronization frame, wherein the sending time of the delay request frame is a time when the delay request frame is sent from the second sending queue of the slave device.
8. The method according to claim 7, characterized in that Before determining the clock deviation according to the sending time of the delay request frame and the sending time of the synchronization frame, the method further includes: Determine a second time when the delay request frame enters the second sending queue, and a second waiting time of the delay request frame in the second sending queue; The sending time of the delay request frame is determined according to the second time and the second waiting period.
9. The method according to claim 8, characterized in that The method further comprises: When the second waiting time reaches a second preset threshold, stop sending the delay request frame.
10. The method according to claim 7, characterized in that In a case where the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent out from the second sending queue before the other data.
11. The method according to any one of claims 6 to 10, characterized in that: Before determining the clock deviation, the method further includes: Determine the sending time of the synchronization frame according to the first time and the first waiting time in the indication information; The first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
12. A time synchronization device, characterized in that: Set in the main equipment, the device includes: A determination module, used to determine the time when the synchronization frame is sent from the first sending queue of the master device as the sending time of the synchronization frame; The sending module is used to send a follow-up frame to the slave device, wherein the follow-up frame includes indication information of the sending time of the synchronization frame.
13. The device according to claim 12, characterized in that The determination module is specifically used to determine the first moment when the synchronization frame enters the first sending queue, and the first waiting time of the synchronization frame in the first sending queue; and determine the sending moment of the synchronization frame according to the first moment and the first waiting time.
14. The device according to claim 12, characterized in that The indication information includes a first moment and a first waiting time, the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
15. The device according to claim 13 or 14, characterized in that The sending module is further configured to stop sending the synchronization frame when the first waiting time is greater than a first preset threshold.
16. The device according to any one of claims 12 to 14, characterized in that In the case where the priority of other data stored in the first sending queue is lower than the priority of the synchronization frame, the synchronization frame is sent out from the first sending queue before the other data.
17. A time synchronization device, characterized in that: Set in a slave device, the device includes: An acquisition module, used for acquiring indication information from a follow-up frame sent by a master device, wherein the indication information indicates that the sending time of the synchronization frame is the time when the synchronization frame is sent from a first sending queue of the master device; A determination module, used to determine the clock deviation between the master device and the slave device according to the sending time of the synchronization frame; A correction module is used to correct the clock of the slave device according to the clock deviation.
18. The device according to claim 17, characterized in that The determination module is specifically used to determine the clock deviation according to the sending time of the delay request frame and the sending time of the synchronization frame. The sending time of the delay request frame is the time when the delay request frame is sent from the second sending queue of the slave device.
19. The device according to claim 18, characterized in that The determination module is also used to determine a second moment when the delay request frame enters the second sending queue, and a second waiting period of the delay request frame in the second sending queue; and determine the sending moment of the delay request frame according to the second moment and the second waiting period.
20. The device according to claim 19, characterized in that The device also includes: The sending module is used to stop sending the delay request frame when the second waiting time reaches a second preset threshold.
21. The device according to claim 18, characterized in that In a case where the priority of other data stored in the second sending queue is lower than the priority of the delay request frame, the delay request frame is sent out from the second sending queue before the other data.
22. The device according to any one of claims 17 to 21, characterized in that The determination module is also used to determine the sending time of the synchronization frame according to the first moment and the first waiting time in the indication information; wherein the first moment is the moment when the synchronization frame enters the first sending queue, and the first waiting time is the waiting time of the synchronization frame in the first sending queue.
23. A time synchronization device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 11 when executing the computer program.
24. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
