A time synchronization method and apparatus
By using the source information of the delay request message received from the target device, the time for sending the second delay request message is determined, which solves the problem of reduced time synchronization accuracy in the prior art and realizes high-precision time synchronization that adapts to different network topologies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUPCON TECH CO LTD
- Filing Date
- 2023-02-09
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies cannot adaptively adjust the time synchronization process according to the type of network topology, resulting in reduced time synchronization accuracy.
By obtaining the source information of the delay request message received from the target device, the sending time of the second delay request message is determined so as to synchronize with the master device in time, achieve adaptive adaptation to different network topologies, and avoid redundant calculation of link delay.
It improves the accuracy of time synchronization, ensuring high-precision time synchronization between devices under different network topologies.
Smart Images

Figure CN116155432B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and in particular to a time synchronization method and apparatus. Background Technology
[0002] Currently, a typical control system consists of a main rack and an expansion rack. The expansion rack and the main rack are connected by a communication module. The communication module on the expansion rack needs to be synchronized with the communication module on the main rack to ensure time synchronization between the racks.
[0003] The communication module on the main rack can be designated as the master device, and the communication module on the expansion rack can be designated as the slave device. Each device has two Ethernet ports and can be connected in various network topologies such as star, bus, and ring. The devices can synchronize their time according to the 1588 protocol. In existing technologies, it is not possible to adaptively adjust the time synchronization process according to the type of network topology, which can easily lead to a decrease in the accuracy of time synchronization. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a time synchronization method and apparatus that can adapt to different network topologies, avoid redundant calculation of link delays, and improve the accuracy of time synchronization. The specific solution is as follows:
[0005] Firstly, this application provides a time synchronization method, including:
[0006] A target slave device located in the network topology receives a first delay request message through a target port; the first delay request message includes source information of the first delay request message; the source information of the first delay request message includes device information of the device that sent the first delay request message;
[0007] Based on the source information of the first delay request message, the sending time of the second delay request message sent by the target slave device is determined, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message.
[0008] Secondly, embodiments of this application also provide a time synchronization device, including:
[0009] A receiving unit is configured to receive a first delay request message through a target port from a target slave device located in the network topology; the first delay request message includes source information of the first delay request message; the source information of the first delay request message includes device information of the device that sent the first delay request message;
[0010] The determining unit is configured to determine the sending time of the second delay request message sent by the target slave device based on the source information of the first delay request message, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message.
[0011] Thirdly, embodiments of this application also provide a time synchronization system, including a network topology and a controller, wherein the network topology includes a master device and a target slave device, and the controller is used to execute the time synchronization method described above.
[0012] This application provides a time synchronization method and apparatus. A target slave device located in a network topology receives a first delay request message through a target port. The first delay request message includes source information of the first delay request message. The source information of the first delay request message includes device information of the device that sent the first delay request message. Based on the source information of the first delay request message, the sending time of the target slave device sending a second delay request message is determined so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message. In this way, based on the first delay request message received by the target slave device, the device information of the device that sent the first delay request message is determined. Since the delay request message is only transmitted between two connected ports, the number of ports interacting with the target port, i.e., the number of nodes, can be determined. Then, the number of devices adjacent to the target slave device can be determined, thereby determining the sending time of the second delay request message sent by the target slave device to the adjacent devices. This allows the target slave device to synchronize its time with the master device based on the second delay request message. This realizes the determination of different time synchronization processes according to different network topologies, which can adapt to different network topologies, avoid repeated calculation of link delay, and improve the accuracy of time synchronization. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 A flowchart illustrating a time synchronization method provided in an embodiment of this application is shown;
[0015] Figure 2 A schematic diagram of a ring network topology provided in an embodiment of this application is shown;
[0016] Figure 3A schematic diagram of a star network topology provided in an embodiment of this application is shown;
[0017] Figure 4 A flowchart illustrating a time synchronization method provided in an embodiment of this application is shown;
[0018] Figure 5 A structural block diagram of a time synchronization device provided in an embodiment of this application;
[0019] Figure 6 This is a structural diagram of a time synchronization system provided in an embodiment of this application. Detailed Implementation
[0020] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the specific embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0021] Many specific details are set forth in the following description in order to provide a full understanding of this application. However, this application may also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.
[0022] As described in the background section, it is currently impossible to adaptively adjust the time synchronization process according to the type of network topology, which can easily lead to a decrease in the accuracy of time synchronization.
[0023] Based on the above technical problems, this application provides a time synchronization method and apparatus. A target slave device located in a network topology receives a first delay request message through a target port. The first delay request message includes source information of the first delay request message. The source information of the first delay request message includes device information of the device that sent the first delay request message. Based on the source information of the first delay request message, the sending time of the target slave device sending a second delay request message is determined so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message. In this way, based on the first delay request message received by the target slave device, the device information of the device that sent the first delay request message is determined. Since the delay request message is only transmitted between two connected ports, the number of ports interacting with the target port, i.e., the number of nodes, can be determined. Then, the number of devices adjacent to the target slave device can be determined, thereby determining the sending time of the second delay request message sent by the target slave device to the adjacent devices. This allows the target slave device to synchronize its time with the master device based on the second delay request message. This realizes the determination of different time synchronization processes according to different network topologies, which can adapt to different network topologies, avoid repeated calculation of link delay, and improve the accuracy of time synchronization.
[0024] For ease of understanding, the following detailed description, in conjunction with the accompanying drawings, provides an embodiment of a time synchronization method and apparatus provided in this application.
[0025] refer to Figure 1 The diagram shown is a flowchart of a time synchronization method provided in an embodiment of this application. The method may include the following steps.
[0026] S101, the target slave device located in the network topology receives the first delay request message through the target port.
[0027] In this embodiment, the time synchronization method can be applied to inter-rack communication in industrial control systems. Racks are interconnected via fiber optic cables or network cables. Different racks are distributed in different physical locations, sequentially divided into main racks and expansion racks. The main racks and expansion racks are connected and exchange data via communication modules. The communication module of the main rack is designated as the master device, and the communication module of the expansion rack is designated as the slave device. The master and slave devices can be connected in various network topologies such as star, bus, and ring. A ring network refers to a network where both ports of each device are connected to the remaining devices, forming a closed loop. Each data packet is sent and received twice, providing redundancy. A star network refers to a network where each device connects to a switch via one port, and the other port can be connected to the next device via a bus connection. A special node refers to a port that connects multiple devices.
[0028] The master device can obtain a reference clock from the main rack and send time synchronization packets to the network through the connected port. The time synchronization packet includes Sync and Follow_up. The slave device can receive the synchronization packet from any port, filter and judge it, and update its own timestamp. The slave device that has completed the timestamp update will periodically send the time synchronization packet to other slave devices in the same expansion rack, that is, send the time synchronization packet to the next slave device through another port, thereby realizing time synchronization between the main rack and the expansion rack.
[0029] refer to Figure 2 The diagram shown is a schematic of a ring network topology provided in an embodiment of this application. The master device is connected to the main rack, and slave devices 1, 2, 3, and 4 are connected to the expansion rack. Each device has two ports connected to adjacent devices, forming a ring network. The master device transmits time synchronization packets from two directions through ports 1 and 2, respectively. The slave devices receive time synchronization packets through one port and forward time synchronization packets through the other port, so that slave devices 1, 2, 3, and 4 can synchronize their time with the master device.
[0030] refer to Figure 3The diagram illustrates a star network topology provided in this embodiment. The master device, slave devices 1, 2, 3, and 4 are all connected to a switch via a single port. Another port of slave device 4 is connected to a port of slave device 5. The master device transmits time synchronization packets to slave devices 1, 2, 3, 4, and 5 via port P1 to synchronize their times with the master device. Slave devices connected to only one port do not send time synchronization packets; they passively receive them from the master device. Examples include slave devices 1, 2, 3, and 4. Slave devices connected to two ports operate similarly to those in a ring topology: they receive time synchronization packets from one port and forward them from the other. For example, slave device 4 receives a time synchronization packet from the master device via the switch via one port and then forwards it to slave device 5 via the other port. Among them, the connection ports of the master device, slave device 1, slave device 2 and slave device 3, as well as the port on the left side of slave device 4 that connects to the switch, are special nodes, while the port on the right side of slave device 4 that connects to slave device 5 is not a special node.
[0031] In this embodiment of the application, there is at least one slave device in the network topology. The target slave device can be any slave device located in the network topology. The port where the target slave device is connected to the network can be recorded as the target port. The delay request message is a message that is limited to the interactive transmission between two ports. Both connected devices can send delay request messages to each other.
[0032] Specifically, the target slave device located in the network topology can receive the first delay request message through the target port. (See reference) Figure 2 As shown, the target slave device can be slave device 1, and the target port can be a port connected to the master device. Slave device 1 receives the first delay request message (Pdelay_Req) sent by the master device through the target port. The target slave device can also be slave device 3, and the target port can be a port connected to slave device 4. Slave device 3 receives the first delay request message (Pdelay_Req) sent by slave device 4 through the target port.
[0033] Specifically, the first delay request message may include the source information of the first delay request message, which includes the device information of the device that sent the first delay request message. The device information can be the device number or the rack number. In this way, the target slave device can record the device information of the device that sent the first delay request message. For example, if slave device 1 receives the first delay request message Pdelay_Req sent by the master device through the target port, slave device 1 can record the device information of the master device, such as the device number.
[0034] In this embodiment of the application, during the time synchronization process, taking a ring network as an example, each device periodically sends Pdelay_Req delay request messages from two ports, as shown in the reference. Figure 4 The diagram shown is a flowchart of a time synchronization method provided in an embodiment of this application. The Master is the master device, and the Slave is the slave device. The Slave in the middle position can be slave device 1, and the Slave in the right position can be slave device 4. The master device periodically sends sync messages and records the sending time TMs1. The master device encapsulates the sending time TMs1 into a Follow_up message and sends it to slave device 1. Slave device 1 records the arrival time TSr2 of the sync message. Slave device 1 sends a Pdelay_Req delay request message to the master device and records the sending time as T5. The master device records the arrival time of the Pdelay_Req delay request message as T6. The master device sends a Pdelay_Resp delay request response message to slave device 1 and records the sending time as T7. The Pdelay_Resp delay request response message carries the arrival time T6 of the Pdelay_Req delay request message. Slave device 1 records the arrival time T8 of the Pdelay_Resp delay request response message. The master device sends a Pdelay_Resp_Follow_up message carrying T7 to slave device 1. The transmission delay and time offset between the master device and slave device 1 can be calculated from device 1: Delay = [(T6-T5)+(T8-T7)] / 2, offset = TSr2-TMs1-Delay.
[0035] Specifically, slave device 1 can forward the sync synchronization message and Follow_up message sent by the master device to slave device 4 through another port. The Follow_up message includes the sending time TMs1 of the sync synchronization message sent by the master device. Slave device 4 records the arrival time TSr1 of the sync synchronization message arriving at slave device 4. Slave device 4 sends a Pdelay_Req delay request message to slave device 1 and records the sending time as T1. Slave device 1 records the arrival time of the Pdelay_Req delay request message arriving at slave device 1 as T2. Slave device 1 sends a Pdelay_Resp delay request response message to slave device 4 and records the sending time as T3. The Pdelay_Resp delay request response message carries the arrival time T2 of the Pdelay_Req delay request message. Slave device 4 records the arrival time T4 of the Pdelay_Resp delay request response message. Slave device 1 sends a Pdelay_Resp_Follow_up message carrying T3 to slave device 4. Device 4 can calculate the transmission delay (Delay) between device 1 and device 4, where Delay = [(T2-T1)+(T4-T3)] / 2, and the time offset between device 4 and the master device, where offset = TSr1 - TMs4 - Delay - Stays. Stays is the dwell time of the sync message within device 1, i.e., the time required for the sync message to travel from one port of device 1 to another. The dwell time can be a fixed value or determined based on the time TSr2 when device 1 receives the sync message from the master device and the time when device 1 sends the sync message to device 4.
[0036] S102, based on the source information of the first delay request message, determine the sending time of the second delay request message sent by the target slave device, so that the target slave device can synchronize time with the master device located in the network topology based on the second delay request message.
[0037] In this embodiment of the application, the sending time of the second delay request message sent by the target slave device can be determined based on the source information of the first delay request message, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message.
[0038] Specifically, in different network topologies, the number of ports connected to the target slave device via the target port varies. The target slave device can then receive first delay request messages from one or more devices through the target port, recording device information for those devices. It's understandable that the ports connected to the target slave device via the target port refer to ports where data can be transmitted directly between them, or through a switch. (Refer to...) Figure 2 In the middle, there is one port connected to the target port on the left side of slave device 1, which is port 2 of the master device, as shown in the reference. Figure 3 There are four ports connected to the target port on the left side of device 1: port P1 of the master device, port on the right side of device 2, port on the right side of device 3, and port on the left side of device 4. These ports are also known as special nodes.
[0039] Specifically, based on the source information of the first delay request message, the number of devices connected to the target slave device can be determined, the location of the target slave device in the network topology can be determined, and the type of network topology can be determined. The sending time of the second delay request message sent by the target slave device to the adjacent devices can be determined so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message.
[0040] In this way, based on the first delay request message received by the target slave device, the device information of the device that sent the first delay request message is determined. Since the delay request message is only transmitted between two connected ports, that is, limited to the interaction between two ports, the number of ports interacting with the target port, i.e. the number of nodes, can be determined. Then, the number of devices adjacent to the target slave device can be determined, thereby determining the sending time of the second delay request message sent by the target slave device to the adjacent devices. This allows the target slave device to synchronize time with the master device based on the second delay request message. This realizes the determination of different time synchronization processes according to different network topologies, and can adapt to different network topologies. Devices can communicate with each other through data packets based on the 1588 protocol to achieve high-precision time synchronization, thereby realizing time synchronization between racks. It can avoid repeated calculation of link delay and improve the accuracy of time synchronization.
[0041] In one possible implementation, the sending time of the second delay request message by the target slave device is determined based on the source information of the first delay request message. Specifically, when the source information of the first delay request message includes device information, it is determined that the target slave device periodically sends the second delay request message at a first preset time interval.
[0042] Specifically, when the source information of the first delay request message includes device information, it indicates that the number of ports interacting with the target port is one. For example, it can be considered a ring network topology. In this case, the target slave device will only send the second delay request message to one adjacent device through the target port. The target slave device can be configured to periodically send the second delay request message at a first preset time interval. The first preset time interval can be set arbitrarily without considering whether it conflicts with the time when other slave devices send delay request messages. For example, a timer can be set to send the second delay request message when the first preset time interval is reached. This can improve the accuracy of time synchronization, and since there is no correlation between the times when the delay request messages are sent by different devices, the efficiency of time synchronization can be improved.
[0043] When the source information of the first delay request message includes multiple device information, the target slave device is determined to send a second delay request message periodically according to the second preset time interval, with the target time as the base time.
[0044] Specifically, when the source information of the first delay request message includes multiple device information, it means that the target slave device receives the first delay request message sent by multiple ports of multiple devices through the target port. There are multiple devices connected to the target slave device through the target port, which can be considered as a star network topology.
[0045] refer to Figure 3 In this scenario, device 1 can receive first delay request messages from the master device, slave device 2, slave device 3, and slave device 4 through the target port. The source information of the first delay request message includes four types of device information. Therefore, it can be determined that the target slave device periodically sends second delay request messages according to the second preset time interval, using the target time as the base time. Here, the target time is the time when the master device in the network topology sends the third delay request, and the second preset time interval corresponds one-to-one with the device information of the target slave device.
[0046] In this way, each slave device uses the target time as the base time and determines its own time to send the delay request message based on its own device information. Since there is a one-to-one correspondence between the second preset time interval and the device information of the target slave device, the sending times of each slave device are different. Multiple slave devices in the network topology can send the second delay request message in sequence. This can prevent the master device from receiving the second delay request message sent by multiple slave devices at the same time, which would cause the time of the second delay request message recorded by the master device to be constantly overwritten, resulting in inaccurate arrival time of the recorded second delay request message. Consequently, the calculated transmission delay and time deviation would also be inaccurate, reducing the accuracy of time synchronization. This method can improve the accuracy of time synchronization.
[0047] Specifically, each special node can determine its own time slice for sending delay request messages based on its rack number, avoiding conflicts with delay request messages from other devices in the star network and preventing time calculation discrepancies. For example, in Figure 3 In the star network topology, slave devices 1, 2, 3, and 4 can all use the time when the master device sends a delay request message as the base time. Based on this, slave device 1 periodically sends delay request messages at a preset time interval of 500ms, slave device 2 periodically sends delay request messages at a preset time interval of 1000ms, slave device 3 periodically sends delay request messages at a preset time interval of 1500ms, and slave device 4 periodically sends delay request messages at a preset time interval of 2000ms. This achieves orderly sending of delay request messages in the network, and the master device can correctly record the arrival time of each delay request message, improving the accuracy of time synchronization.
[0048] In this embodiment, the source information of the first delay request message includes device information of the first slave device that sent the first delay request message. The method further includes, if no first delay request message is received from the first slave device within a preset time period, marking the first slave device as an offline device, repeatedly executing the operation of the target slave device in the network topology receiving at least one first delay request message through a target port, and determining the sending time of the target slave device sending a second delay request message based on the source information of the first delay request message. Thus, when the network topology changes, the first slave device can automatically identify the status of its adjacent nodes when interconnected with other devices, and can still send messages normally for time synchronization, improving the accuracy of time synchronization and achieving adaptive adjustment to the network topology.
[0049] Specifically, when a number of devices are removed from the network, a timeout period is set. If a device's port does not receive a delay request message from that device within the timeout period, the device can be marked as offline, its source information can be cleared, and the source can be re-evaluated to determine the sending time of the second delay request message from the target device.
[0050] In this embodiment, the method may further include, if a second slave device is added to the network topology, repeatedly executing the operation of the target slave device in the network topology receiving at least one first delay request message through a target port, and determining the transmission time of the target slave device sending a second delay request message based on the source information of the first delay request message. Thus, when a second slave device is added, it can automatically identify the nodes adjacent to it when interconnected with other devices, and determine the transmission time of the delay request message in the newly formed network topology accordingly, achieving adaptive adjustment of the network topology.
[0051] Specifically, when a new device is added to the network, a waiting time can be set. During this waiting time, no data is sent, only data is received. The operation of receiving at least one first delay request message through the target port of the target slave device located in the network topology, and determining the sending time of the second delay request message of the target slave device based on the source information of the first delay request message, judging the network connection status, and then entering the corresponding send and receive processing.
[0052] In this embodiment, the method may further include, when the source information of the first delay request message includes multiple device information, the target slave device stops sending delay request response messages. These delay request response messages are used to respond to the first delay request message. By disabling the response function for delay request messages on this port, the forwarding and calculation of delay request response messages PDelay_resp and PDelay_resp_follow_up can be avoided, ensuring that link delays on the network are not repeatedly calculated. Only the master device remains in the network responding to delay request response messages from other slave devices, ensuring that only the link delay data between this port and the master device is calculated.
[0053] This application provides a time synchronization method in which a target slave device located in a network topology receives a first delay request message through a target port; the first delay request message includes source information of the first delay request message; the source information of the first delay request message includes device information of the device that sent the first delay request message; based on the source information of the first delay request message, the sending time of the target slave device sending a second delay request message is determined, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message. In this way, based on the first delay request message received by the target slave device, the device information of the device that sent the first delay request message is determined. Since the delay request message is only transmitted between two connected ports, the number of ports interacting with the target port, i.e., the number of nodes, can be determined. Then, the number of devices adjacent to the target slave device can be determined, thereby determining the sending time of the second delay request message sent by the target slave device to the adjacent devices. This allows the target slave device to synchronize its time with the master device based on the second delay request message. This realizes the determination of different time synchronization processes according to different network topologies, which can adapt to different network topologies, avoid repeated calculation of link delay, and improve the accuracy of time synchronization.
[0054] Based on the above time synchronization methods, this application also provides a time synchronization device, see reference. Figure 5 The diagram shown is a structural block diagram of a time synchronization device provided in an embodiment of this application. The device may include:
[0055] The receiving unit 100 is configured to receive a first delay request message through a target port from a target slave device located in the network topology; the first delay request message includes source information of the first delay request message; the source information of the first delay request message includes device information of the device that sent the first delay request message;
[0056] The determining unit 200 is configured to determine the sending time of the second delay request message sent by the target slave device based on the source information of the first delay request message, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message.
[0057] Specifically, the determining unit is used for:
[0058] When the source information of the first delay request message includes device information, it is determined that the target slave device periodically sends a second delay request message at a first preset time interval;
[0059] When the source information of the first delay request message includes multiple device information, it is determined that the target slave device periodically sends a second delay request message according to a second preset time interval, with the target time as the base time; the target time is the sending time of the master device located in the network topology when sending the third delay request; the second preset time interval corresponds one-to-one with the device information of the target slave device.
[0060] Specifically, the source information of the first delay request message includes device information of the first slave device that sent the first delay request message, and the apparatus further includes:
[0061] The first execution unit is configured to, if it does not receive a first delay request message sent by the first slave device within a preset time period, mark the first slave device as an offline device, and repeatedly execute the operation of the target slave device located in the network topology receiving at least one first delay request message through a target port, and the operation of determining the sending time of the target slave device sending a second delay request message based on the source information of the first delay request message.
[0062] Specifically, the device further includes:
[0063] The second execution unit is configured to, if a second slave device is added to the network topology, repeatedly execute the operation of the target slave device located in the network topology receiving at least one first delay request message through a target port, and the operation of determining the sending time of the target slave device sending a second delay request message based on the source information of the first delay request message.
[0064] Specifically, the device further includes:
[0065] A response unit is configured to, when the source information of the first delay request message includes multiple device information, cause the target slave device to stop sending a delay request response message; the delay request response message is used to respond to the first delay request message.
[0066] This application provides a time synchronization device. Based on a first delay request message received by a target slave device, the device information of the device that sent the first delay request message is determined. Since the delay request message is only transmitted between two connected ports, the number of ports interacting with the target port, i.e., the number of nodes, can be determined. This allows the number of devices adjacent to the target slave device to be determined, thereby determining the sending time of the second delay request message sent by the target slave device to the adjacent devices. This enables the target slave device to synchronize time with the master device based on the second delay request message. This device achieves different time synchronization processes based on different network topologies, can adapt to different network topologies, avoids repeated calculation of link delays, and improves the accuracy of time synchronization.
[0067] Based on the above time synchronization methods, this application also provides a time synchronization system, see reference. Figure 6 The diagram shown is a structural diagram of a time synchronization system provided in an embodiment of this application. The time synchronization system includes a network topology 301 and a controller 302. The network topology includes a master device and a target slave device. The controller is used to execute a time synchronization method.
[0068] This application provides a time synchronization system. Based on a first delay request message received by the target slave device, the system determines the device information of the device that sent the first delay request message. Since the delay request message is only transmitted between two connected ports, the number of ports interacting with the target port, i.e., the number of nodes, can be determined. This allows the system to determine the number of devices adjacent to the target slave device, thereby determining the sending time of the second delay request message from the target slave device to the adjacent devices. This enables the target slave device to synchronize its time with the master device based on the second delay request message. This system achieves different time synchronization processes based on different network topologies, can adapt to different network topologies, avoids redundant calculation of link delays, and improves the accuracy of time synchronization.
[0069] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0070] The above description is merely a preferred embodiment of this application. Although this application has disclosed preferred embodiments above, it is not intended to limit this application. Any person skilled in the art can make many possible variations and modifications to the technical solutions of this application using the methods and techniques disclosed above, or modify them into equivalent embodiments with equivalent changes, without departing from the scope of the technical solutions of this application. Therefore, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of this application without departing from the content of the technical solutions of this application shall still fall within the protection scope of the technical solutions of this application.
Claims
1. A time synchronization method, characterized in that, include: The target slave device located in the network topology receives the first delay request message through the target port; The first delay request message includes source information of the first delay request message; The source information of the first delay request message includes the device information of the device that sent the first delay request message; Based on the source information of the first delay request message, the sending time of the second delay request message sent by the target slave device is determined, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message; Determining the sending time of the second delay request message from the target slave device based on the source information of the first delay request message includes: When the source information of the first delay request message includes device information, it is determined that the target slave device periodically sends a second delay request message at a first preset time interval; When the source information of the first delay request message includes multiple device information, it is determined that the target slave device periodically sends a second delay request message according to a second preset time interval, with the target time as the base time; the target time is the sending time of the master device located in the network topology when sending the third delay request; the second preset time interval corresponds one-to-one with the device information of the target slave device.
2. The method according to claim 1, characterized in that, The source information of the first delay request message includes device information of the first slave device that sent the first delay request message, and the method further includes: If the first delay request message sent by the first slave device is not received within the preset time period, the first slave device is marked as an offline device, and the operation of receiving at least one first delay request message through the target port of the target slave device located in the network topology and determining the sending time of the second delay request message sent by the target slave device based on the source information of the first delay request message is repeated.
3. The method according to claim 1, characterized in that, The method further includes: If a second slave device is added to the network topology, the operation of the target slave device located in the network topology receiving at least one first delay request message through the target port and determining the sending time of the second delay request message by the target slave device based on the source information of the first delay request message is repeated.
4. The method according to claim 1, characterized in that, The method further includes: When the source information of the first delay request message includes multiple device information, the target slave device stops sending delay request response messages; the delay request response message is used to respond to the first delay request message.
5. A time synchronization device, characterized in that, include: A receiving unit is used for a target slave device located in the network topology to receive a first delay request message through a target port. The first delay request message includes source information of the first delay request message; the source information of the first delay request message includes device information of the device that sent the first delay request message; The determining unit is configured to determine the sending time of the second delay request message sent by the target slave device based on the source information of the first delay request message, so that the target slave device can synchronize its time with the master device located in the network topology based on the second delay request message; The determining unit is used for: When the source information of the first delay request message includes device information, it is determined that the target slave device periodically sends a second delay request message at a first preset time interval; When the source information of the first delay request message includes multiple device information, it is determined that the target slave device periodically sends a second delay request message according to the second preset time interval, with the target time as the base time. The target time is the time when the master device located in the network topology sends the third delay request; The second preset time interval corresponds one-to-one with the device information of the target slave device.
6. The apparatus according to claim 5, characterized in that, The source information of the first delay request message includes device information of the first slave device that sent the first delay request message, and the apparatus further includes: The first execution unit is configured to, if it does not receive a first delay request message sent by the first slave device within a preset time period, mark the first slave device as an offline device, and repeatedly execute the operation of the target slave device located in the network topology receiving at least one first delay request message through a target port, and the operation of determining the sending time of the target slave device sending a second delay request message based on the source information of the first delay request message.
7. The apparatus according to claim 5, characterized in that, The device further includes: The second execution unit is configured to, if a second slave device is added to the network topology, repeatedly execute the operation of the target slave device located in the network topology receiving at least one first delay request message through a target port, and the operation of determining the sending time of the target slave device sending a second delay request message based on the source information of the first delay request message.
8. A time synchronization system, characterized in that, It includes a master device and a target slave device in a network topology, and a controller for executing the time synchronization method according to any one of claims 1-4.