Time synchronization method and apparatus, electronic device, storage medium, and program product

By having the client actively initiate the time synchronization process, recording and calculating timestamps, the problems of resource waste and network bandwidth occupation in existing technologies are solved, achieving more efficient time synchronization.

CN122372129APending Publication Date: 2026-07-10CHINA MOBILE COMM LTD RES INST +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA MOBILE COMM LTD RES INST
Filing Date
2025-01-09
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing time synchronization methods suffer from severe resource waste, making it difficult to flexibly distinguish and process terminals that require time synchronization, resulting in improper network bandwidth usage.

Method used

The client initiates the time synchronization process by sending a request message and recording a timestamp, receiving synchronization and notification messages from the time server, and calculating the time difference to achieve synchronization. This process only consumes network bandwidth for the clients that need to synchronize.

Benefits of technology

It reduces network bandwidth usage by clients that do not require time synchronization, improves network resource utilization efficiency, and enhances the flexibility and reliability of time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122372129A_ABST
    Figure CN122372129A_ABST
Patent Text Reader

Abstract

This application provides a time synchronization method, apparatus, electronic device, storage medium, and program product, applied in the field of communication technology. The method includes: a client sending a request message to a time server at a first moment and recording a first timestamp corresponding to the first moment; receiving a synchronization message sent by the time server at a fourth moment and recording a fourth timestamp corresponding to the fourth moment; receiving a notification message sent by the time server; and calculating the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. In this method, the time synchronization process is initiated by the client; clients that do not require time synchronization may not initiate it, thereby reducing network resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a time synchronization method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] With the continuous development of technology, the demand for high-precision synchronization services such as network time synchronization is increasing daily. The amount of data and the scale of parameters used in basic large-scale models are growing exponentially, and the scale of distributed intelligent computing clusters is constantly expanding. Compared with traditional network time synchronization, data center network time synchronization is particularly large in scale and highly scalable. A data center may have tens of thousands or even hundreds of thousands of cards, all of which may require time synchronization. Moreover, data center data transmission has high reliability requirements, and the impact of time synchronization interruption or resynchronization is significant.

[0003] The existing technology uses the Precision Time Protocol (PTP) to achieve high-precision time synchronization. This protocol requires a master time server to initiate synchronization, which then proceeds downstream. If some terminals in the network require time synchronization while others do not, it is difficult to flexibly differentiate and handle this situation. Furthermore, this requires support from the entire network, potentially leading to resource waste. Summary of the Invention

[0004] This application provides a time synchronization method, apparatus, electronic device, storage medium, and program product to solve the problem of resource waste in existing time synchronization methods.

[0005] To solve the above-mentioned technical problems, this application is implemented as follows:

[0006] In a first aspect, embodiments of this application provide a time synchronization method, executed by a client, the method comprising:

[0007] Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0008] The system receives the synchronization message sent by the time server at the fourth moment and records the fourth timestamp corresponding to the fourth moment.

[0009] Receive notification messages sent by the time server;

[0010] The time difference with the time server is calculated based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0011] Optionally, the timestamp carried in the synchronization message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0012] Optionally, the timestamp carried in the notification message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0013] Optionally, the timestamp carried in the synchronization message is different from the timestamp carried in the notification message.

[0014] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes a third timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0015] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes a second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0016] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0017] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0018] Optionally, the request message carries the first timestamp.

[0019] Optionally, the client and the time server may include multiple intermediate nodes;

[0020] The timestamp carried in the synchronization message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0021] Optionally, the timestamp related to the first time processing difference carried in the synchronization message is the timestamp corresponding to the difference between the first time processing difference and the second timestamp, where the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message.

[0022] Optionally, the client and the time server may include multiple intermediate nodes;

[0023] The timestamp carried in the synchronization message includes a timestamp corresponding to the second time processing difference. The second time processing difference is calculated by accumulating the time processing differences of each intermediate node forwarding the synchronization message. The time processing difference of the intermediate node forwarding the synchronization message is calculated based on the time value of the synchronization message arriving at the intermediate node and the time value of the synchronization message leaving the intermediate node.

[0024] Optionally, the client and the time server may include multiple intermediate nodes;

[0025] The timestamp carried in the notification message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0026] Optionally, the timestamp related to the first time processing difference carried in the notification message is the timestamp corresponding to the first time processing difference.

[0027] Optionally, there are multiple time servers, and each time server sends a notification message that also carries the status information of that time server.

[0028] The step of calculating the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp includes:

[0029] Based on the status information of the multiple time servers, a first target time server whose status information meets the preset conditions is determined from the multiple time servers;

[0030] The time difference with the first target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp.

[0031] Optionally, when there are multiple first target time servers, the synchronization message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server.

[0032] The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes:

[0033] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0034] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0035] Optionally, when there are multiple first target time servers, the notification message sent by the first target time server also carries hop count information, which is used to indicate the number of network hops between the client and the first target time server.

[0036] The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes:

[0037] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0038] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0039] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0040] The second transmission path is determined by routing the IP address carried in the header of the message sent from the time server to the client.

[0041] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path and the second transmission path are determined in the following manner:

[0042] Specify via a centralized control unit.

[0043] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0044] The second transmission path is determined by the path information of the first transmission path recorded by the time server.

[0045] Secondly, embodiments of this application provide a time synchronization method, executed by a time server, the method comprising:

[0046] Receive request messages sent by the client at the second moment;

[0047] A synchronization message is sent to the client at the third moment;

[0048] Send a notification message to the client.

[0049] Thirdly, embodiments of this application also provide a time synchronization device, which includes:

[0050] The first sending module is used to send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0051] The second sending module is used to receive the synchronization message sent by the time server at the fourth time and record the fourth timestamp corresponding to the fourth time.

[0052] The first receiving module is used to receive notification messages sent by the time server;

[0053] The first calculation module is used to calculate the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0054] Fourthly, embodiments of this application also provide a time synchronization device, which includes:

[0055] The second receiving module is used to receive the request message sent by the client at the second moment;

[0056] The third sending module is used to send a synchronization message to the client at a third moment;

[0057] The fourth sending module is used to send notification messages to the client.

[0058] Fifthly, embodiments of this application provide a client, including a transceiver and a processor, wherein the transceiver is used for:

[0059] Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0060] The system receives the synchronization message sent by the time server at the fourth moment and records the fourth timestamp corresponding to the fourth moment.

[0061] Receive notification messages sent by the time server;

[0062] The processor is used for:

[0063] The time difference with the time server is calculated based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0064] Sixthly, embodiments of this application provide a time server, including a transceiver and a processor, wherein the transceiver is used for:

[0065] Receive request messages sent by the client at the second moment;

[0066] A synchronization message is sent to the client at the third moment;

[0067] Send a notification message to the client.

[0068] In a seventh aspect, embodiments of this application also provide an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the time synchronization method described above.

[0069] Eighthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the time synchronization method described above.

[0070] Ninthly, a computer program product is provided, including computer instructions that, when executed by a processor, implement the time synchronization method described above.

[0071] The time synchronization method in this application embodiment involves a client sending a request message to a time server at a first moment and recording a first timestamp corresponding to the first moment; receiving a synchronization message from the time server at a fourth moment and recording a fourth timestamp corresponding to the fourth moment; receiving a notification message from the time server; and calculating the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. This time difference is used for time synchronization between the client and the time server. In this method, the time synchronization process is initiated by the client. Clients that do not need time synchronization may not initiate it. This means that only clients that need synchronization will consume network bandwidth. Compared to the time server actively initiating the time synchronization process, which may result in a large number of clients that do not need time synchronization consuming network bandwidth, this method reduces the consumption of network resources. Attached Figure Description

[0072] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0073] Figure 1 This is a schematic diagram of PTP time synchronization provided in an embodiment of this application;

[0074] Figure 2 This is one of the flowcharts of the time synchronization method provided in the embodiments of this application;

[0075] Figure 3This is a schematic diagram of the time synchronization method provided in an embodiment of this application;

[0076] Figure 4 This is the second flowchart of the time synchronization method provided in the embodiments of this application;

[0077] Figure 5 This is one of the structural diagrams of a time synchronization device provided in an embodiment of this application;

[0078] Figure 6 This is a second structural diagram of a time synchronization device provided in an embodiment of this application;

[0079] Figure 7 This is one of the structural diagrams of an electronic device provided in an embodiment of this application;

[0080] Figure 8 This is a second structural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0081] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0082] To further understand the technical means of this application, a brief introduction to the process and principle of time synchronization in the existing PTP technology is first provided. (See [link to relevant documentation]). Figure 1 :

[0083] The master clock sends a Sync message at time t1, and the Sync message contains the sending time t1.

[0084] Record the time t2 when the Sync message is received from the clock, and then send a Delay_Req message at time t3.

[0085] The master clock records the time t4 when it receives the Delay_Req message, and then sends a Delay_Resp message carrying the time t4 to inform the slave clock.

[0086] Assuming the link delay between the master and slave clocks is symmetrical, the slave clock can calculate the time deviation and link delay from the master clock based on the four known time values.

[0087] Assuming the slave clock leads the master clock by an offset, then:

[0088] (t2-Offset)-t1 = Delay;

[0089] t4 - (t3 - Offset) = Delay;

[0090] The time deviation between the slave clock and the master clock can be calculated:

[0091] Offset=[(t2-t1)+(t3-t4)] / 2;

[0092] Link delay between slave clock and master clock:

[0093] Delay=[(t2-t1)+(t4-t3)] / 2;

[0094] Correcting local time from the clock, the value is the local time value minus the calculated offset value.

[0095] This application provides a time synchronization method, executed by a client, see [link to relevant documentation]. Figure 2 , Figure 2 This is a flowchart of the time synchronization method provided in the embodiments of this application, such as... Figure 2 As shown, it includes the following steps:

[0096] Step 201: Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0097] In this step, the client actively sends a request (Delay_Req) ​​message to the time server at the first moment and records the first timestamp corresponding to the first moment.

[0098] Step 202: Receive the synchronization message sent by the time server at the fourth time and record the fourth timestamp corresponding to the fourth time.

[0099] In this step, the time server receives the request message at the second time and records the second timestamp corresponding to that time. Then, the time server sends a synchronization message to the client at the third time. The client receives the synchronization message at the fourth time and records the fourth timestamp corresponding to that time.

[0100] Step 203: Receive the notification message sent by the time server;

[0101] In this step, after the time server sends the synchronization message to the client, it then sends an announcement message to the client.

[0102] Step 204: Calculate the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0103] In one implementation, see Figure 3 The client sends a request message to the time server at a first moment, the request message carrying a first timestamp corresponding to the first moment; at a fourth moment, it receives a synchronization message sent by the time server and records a fourth timestamp corresponding to the fourth moment; it receives a notification message sent by the time server; and it calculates the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. In this implementation, the time synchronization process is initiated by the client. Clients that do not need time synchronization may not initiate it. This way, only clients that need synchronization will consume network bandwidth. Compared to the time server actively initiating the time synchronization process, which may result in a large number of clients that do not need time synchronization consuming network bandwidth, this implementation reduces the consumption of network resources.

[0104] Optionally, the timestamp carried in the synchronization message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0105] Optionally, the timestamp carried in the notification message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0106] Optionally, the timestamp carried in the synchronization message is different from the timestamp carried in the notification message.

[0107] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes a third timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0108] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes a second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0109] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0110] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0111] In some implementations, synchronization and notification messages carry a second and a third timestamp to the client, but there are several different ways to implement this:

[0112] Synchronization messages carry a second timestamp, while notification messages carry a third timestamp;

[0113] Alternatively, synchronization messages may carry a third timestamp, while notification messages may carry a second timestamp.

[0114] Alternatively, the synchronization message carries a second timestamp, and the notification message carries the difference between the third timestamp and the second timestamp;

[0115] Alternatively, the synchronization message carries a third timestamp, and the notification message carries the difference between the third timestamp and the second timestamp.

[0116] After receiving the synchronization message and notification message, the client calculates the time offset with the time server based on the second and third timestamps extracted from the synchronization message and notification message, as well as the first and second timestamps recorded by itself, in order to synchronize time with the time server.

[0117] Please refer to the following calculation formula for details:

[0118] Timeoffset=(T4-T3-T2+T1) / 2;

[0119] Where T1 represents the first timestamp, T2 represents the second timestamp, T3 represents the third timestamp, and T4 represents the fourth timestamp.

[0120] It should be noted that when the synchronization message carries a second timestamp and the notification message carries a third timestamp, or vice versa, the client can directly extract the second and third timestamps to calculate the Timeoffset. However, when the synchronization message carries a second timestamp and the notification message carries the difference between the third and second timestamps, or vice versa, the second and third timestamps need to be calculated intermediately before calculating the Timeoffset.

[0121] Optionally, the request message carries the first timestamp.

[0122] In one implementation, the first timestamp records the exact time the request message was sent from the client. This is critical information because the time synchronization protocol needs to know this accurate sending time so that the time server can help adjust and correct the client's time.

[0123] Optionally, the client and the time server may include multiple intermediate nodes;

[0124] The timestamp carried in the synchronization message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0125] Optionally, the timestamp related to the first time processing difference carried in the synchronization message is the timestamp corresponding to the difference between the first time processing difference and the second timestamp, where the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message.

[0126] Optionally, the client and the time server may include multiple intermediate nodes;

[0127] The timestamp carried in the synchronization message includes a timestamp corresponding to the second time processing difference. The second time processing difference is calculated by accumulating the time processing differences of each intermediate node forwarding the synchronization message. The time processing difference of the intermediate node forwarding the synchronization message is calculated based on the time value of the synchronization message arriving at the intermediate node and the time value of the synchronization message leaving the intermediate node.

[0128] Optionally, the client and the time server may include multiple intermediate nodes;

[0129] The timestamp carried in the notification message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0130] Optionally, the timestamp related to the first time processing difference carried in the notification message is the timestamp corresponding to the first time processing difference.

[0131] In some implementations, multiple intermediate nodes are involved between the client and the time server. Request messages sent by the client are forwarded through these intermediate nodes before reaching the time server. Synchronization messages sent by the time server are forwarded through these intermediate nodes before reaching the client.

[0132] After receiving request and synchronization messages, intermediate nodes use their local clocks to record the arrival and departure times of the messages. They then calculate the time difference between these arrival and departure times and update a fixed field in the message. Specifically, an intermediate node can subtract the arrival time from a field at the entry point, update the field at the exit point, and add the departure time. This effectively stores the time difference between the message's arrival and departure times in the specified field.

[0133] For example, there are three intermediate nodes, a, b, and c, between the client and the server. The first intermediate node, a, forwards a packet with a time processing difference of TEa, and updates a fixed field in the packet with TEa. The second intermediate node, b, forwards a packet with a time processing difference of TEb, and updates the value in a fixed field of the packet to TEa + TEb. Finally, intermediate node c further updates the value in a fixed field of the packet to TEa + TEb + TEc based on the time processing difference.

[0134] When a request message arrives at the time server, the cumulative time processing difference between the intermediate nodes is set to the first time processing difference TE1. When a synchronization message arrives at the client, the cumulative time processing difference between the intermediate nodes is set to the second time processing difference TE2. The time server extracts TE1 from a specific field in the request message and sends this value to the client via a synchronization message or a notification message. There are several possible implementations, exemplified below:

[0135] Enter TE1 in the specific field of the notification message;

[0136] Alternatively, the synchronization message carries T2-TE1.

[0137] Then, after receiving the synchronization message and the notification message, the client calculates the Timeoffset with the time server based on the second timestamp, the third timestamp, the first time processing difference and the second time processing difference extracted from the synchronization message and the notification message, as well as the first timestamp and the second timestamp recorded by itself, so as to synchronize the time with the time server.

[0138] Please refer to the following calculation formula for details:

[0139] Timeoffset=(T4-T3-T2+T1-TE2+TE1) / 2.

[0140] In this implementation, the processing of intermediate nodes is relatively simple and does not require system clock synchronization. When calculating time deviation, by considering the time processing difference caused by intermediate nodes, the client can eliminate the cumulative processing delay of each intermediate node on signal transmission when calculating the actual transmission delay. This ensures that the calculated delay and clock adjustment only reflect the actual physical link propagation delay, thus achieving more accurate time synchronization.

[0141] Optionally, there are multiple time servers, and each time server sends a notification message that also carries the status information of that time server.

[0142] The step of calculating the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp includes:

[0143] Based on the status information of the multiple time servers, a first target time server whose status information meets the preset conditions is determined from the multiple time servers;

[0144] The time difference with the first target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp.

[0145] In one implementation, the client can configure multiple time servers simultaneously and send request messages to them concurrently. Upon receiving the request messages, each time server sends a synchronization message and a notification message to the client. The time server may include its own status information in the notification message. The client can then select the time server with the best status from the received status information for time synchronization.

[0146] In this implementation, the client can receive information from multiple time servers simultaneously. If one time server malfunctions, it can seamlessly switch to tracking another time server. Messages from multiple time servers are always available, which reduces switching time and avoids time synchronization interruptions caused by the switchover, thereby improving the reliability of the entire system.

[0147] In addition, clients can choose a time server with better performance (such as the lowest error, lowest load, or fastest response) for synchronization, which can improve the accuracy of time synchronization.

[0148] Optionally, when there are multiple first target time servers, the synchronization message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server.

[0149] The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes:

[0150] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0151] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0152] In one implementation, the synchronization message sent by the time server also carries hop count information. When an intermediate node receives the message, it updates the field containing the time processing difference and the field containing the network hop count. The network hop count increments by one for each intermediate node it passes through. After receiving the message from the time server, the client extracts the hop count information to obtain the number of network hops from the time server to the client. Upon receiving the message from the time server, the client selects a time server with a better status for time synchronization. If multiple time servers are in a good state, the client selects the time server with the fewer network hops for time synchronization.

[0153] In this implementation, choosing a time server with fewer hops means that data packets pass through fewer intermediate nodes. Generally, the more intermediate nodes a packet passes through, the greater the potential processing and transmission latency; therefore, choosing a path with fewer hops can effectively reduce latency. Furthermore, fewer network hops mean a relatively more stable and reliable connection, thus improving the reliability of the overall synchronization process.

[0154] Optionally, when there are multiple first target time servers, the notification message sent by the first target time server also carries hop count information, which is used to indicate the number of network hops between the client and the first target time server.

[0155] The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes:

[0156] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0157] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0158] In one implementation, the notification message sent by the time server also carries hop count information. When an intermediate node receives the message, it updates the field containing the time processing difference and the field containing the network hop count. The network hop count increments by one for each intermediate node it passes through. After receiving the message from the time server, the client extracts the hop count information to obtain the number of network hops from the time server to the client. Upon receiving the message from the time server, the client selects a time server with a better status for time synchronization. If multiple time servers are in a good state, the client selects the time server with the fewer network hops for time synchronization.

[0159] In this implementation, choosing a time server with fewer hops means that data packets pass through fewer intermediate nodes. Generally, the more intermediate nodes a packet passes through, the greater the potential processing and transmission latency; therefore, choosing a path with fewer hops can effectively reduce latency. Furthermore, fewer network hops mean a relatively more stable and reliable connection, thus improving the reliability of the overall synchronization process.

[0160] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0161] The second transmission path is determined by routing the IP address carried in the header of the message sent from the time server to the client.

[0162] In one implementation, the transmission path between the client and the time server can be determined as follows: when the client sends a message to the time server, it carries an IP header and reaches the time server via IP address routing. Similarly, messages sent by the time server to the client also carry an IP header and are routed to the client via IP address routing.

[0163] In this implementation, the network has automatic load balancing capabilities as IP address routing provides automatic hops to the optimal path. This means that when there are multiple path options, the network can allocate bandwidth and other resources more efficiently.

[0164] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path and the second transmission path are determined in the following manner:

[0165] Specify via a centralized control unit.

[0166] In one implementation, the transmission path between the client and the time server can be determined as follows: the centralized unit (network management controller, etc.) specifies the path from the client to the time server and the path from the time server to the client. In order to avoid the problem of time synchronization error caused by the asymmetry of transmission delay when using different paths for uplink and downlink, the centralized unit specifies the same path for both directions.

[0167] In this implementation, specifying paths through a centralized control unit (e.g., a network management controller) enhances network flexibility and reliability. Centralized control facilitates rapid response to changes in network conditions, real-time path optimization, and path switching when necessary to ensure stable performance.

[0168] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0169] The second transmission path is determined by the path information of the first transmission path recorded by the time server.

[0170] In one implementation, the transmission path between the client and the time server can be determined as follows: when the client sends a message to the time server, it includes an IP header, routes the message to the time server via IP address, and records the path information. The time server then sends messages to the client using the recorded path information. This avoids time synchronization errors caused by asymmetric transmission delays due to different uplink and downlink paths.

[0171] This application provides a time synchronization method, executed by a time server, see [link to relevant documentation]. Figure 4 , Figure 4 This is a flowchart of the time synchronization method provided in the embodiments of this application, such as... Figure 4 As shown, it includes the following steps:

[0172] Step 401: Receive the request message sent by the client at the second moment;

[0173] Step 402: Send a synchronization message to the client at the third moment;

[0174] Step 403: Send a notification message to the client.

[0175] It should be noted that this embodiment is used as a reference for... Figure 2 The implementation method of the time server in the illustrated embodiment can be found in the following examples. Figure 2The related descriptions of the embodiments shown will not be repeated in this embodiment to avoid repetition, and can achieve the same beneficial effects.

[0176] See Figure 5 , Figure 5 This is a structural diagram of a time synchronization device provided in an embodiment of this application. This time synchronization device is applied to a client, such as... Figure 5 As shown, the time synchronization device 500 includes:

[0177] The first sending module 501 is used to send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0178] The second sending module 502 is used to receive the synchronization message sent by the time server at the fourth time and record the fourth timestamp corresponding to the fourth time.

[0179] The first receiving module 503 is used to receive the notification message sent by the time server;

[0180] The first calculation module 504 is used to calculate the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0181] Optionally, the timestamp carried in the synchronization message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0182] Optionally, the timestamp carried in the notification message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0183] Optionally, the timestamp carried in the synchronization message is different from the timestamp carried in the notification message.

[0184] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes a third timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0185] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes a second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0186] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0187] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0188] Optionally, the request message carries the first timestamp.

[0189] Optionally, the client and the time server may include multiple intermediate nodes;

[0190] The timestamp carried in the synchronization message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0191] Optionally, the timestamp related to the first time processing difference carried in the synchronization message is the timestamp corresponding to the difference between the first time processing difference and the second timestamp, where the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message.

[0192] Optionally, the client and the time server may include multiple intermediate nodes;

[0193] The timestamp carried in the synchronization message includes a timestamp corresponding to the second time processing difference. The second time processing difference is calculated by accumulating the time processing differences of each intermediate node forwarding the synchronization message. The time processing difference of the intermediate node forwarding the synchronization message is calculated based on the time value of the synchronization message arriving at the intermediate node and the time value of the synchronization message leaving the intermediate node.

[0194] Optionally, the client and the time server may include multiple intermediate nodes;

[0195] The timestamp carried in the notification message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0196] Optionally, the timestamp related to the first time processing difference carried in the notification message is the timestamp corresponding to the first time processing difference.

[0197] Optionally, there are multiple time servers, and each time server sends a notification message that also carries the status information of that time server.

[0198] The first computing module includes:

[0199] The first determining unit is configured to determine a first target time server whose status information meets preset conditions from among the multiple time servers based on the status information of the multiple time servers.

[0200] The first calculation unit is used to calculate the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp.

[0201] Optionally, when there are multiple first target time servers, the synchronization message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server.

[0202] The first computing unit includes:

[0203] The first determining subunit is used to determine the second target time server with the fewest hops from among the multiple first target time servers based on the hop count information of the multiple first target time servers;

[0204] The first calculation subunit is used to calculate the time difference with the second target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0205] Optionally, when there are multiple first target time servers, the notification message sent by the first target time server also carries hop count information, which is used to indicate the number of network hops between the client and the first target time server.

[0206] The first computing unit includes:

[0207] The second determining subunit is used to determine the second target time server with the fewest hops from among the multiple first target time servers based on the hop count information of the multiple first target time servers;

[0208] The second calculation subunit is used to calculate the time difference with the second target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0209] See Figure 6 , Figure 6 This is a structural diagram of a time synchronization device provided in an embodiment of this application. This time synchronization device is applied to a time server, such as... Figure 6 As shown, the time synchronization device 600 includes:

[0210] The second receiving module 601 is used to receive the request message sent by the client at the second moment;

[0211] The third sending module 602 is used to send a synchronization message to the client at a third moment;

[0212] The fourth sending module 603 is used to send a notification message to the client.

[0213] This application also provides a client. Since the principle behind the client's problem-solving is similar to the time synchronization method in this application, the implementation of this client can be found in the implementation of the method, and repeated details will not be elaborated further. Figure 7As shown, the client in this embodiment includes: a processor 700, configured to read a program from the memory 720 and execute the following process: via transceiver 710:

[0214] Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment;

[0215] The system receives the synchronization message sent by the time server at the fourth moment and records the fourth timestamp corresponding to the fourth moment.

[0216] Receive notification messages sent by the time server;

[0217] The processor 700 is used to read the program in the memory 720 and execute the following processes:

[0218] The time difference with the time server is calculated based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

[0219] Among them, Figure 7 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 700) and memory (memory 720). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 710 can be multiple elements, including transmitters and transceivers, providing a unit for communicating with various other devices over a transmission medium. The processor 700 is responsible for managing the bus architecture and general processing, and the memory 720 can store data used by the processor 700 during operation.

[0220] Optionally, the timestamp carried in the synchronization message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0221] Optionally, the timestamp carried in the notification message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0222] Optionally, the timestamp carried in the synchronization message is different from the timestamp carried in the notification message.

[0223] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes a third timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0224] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes a second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0225] Optionally, the timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0226] Optionally, the timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

[0227] Optionally, the request message carries the first timestamp.

[0228] Optionally, the client and the time server may include multiple intermediate nodes;

[0229] The timestamp carried in the synchronization message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0230] Optionally, the timestamp related to the first time processing difference carried in the synchronization message is the timestamp corresponding to the difference between the first time processing difference and the second timestamp, where the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message.

[0231] Optionally, the client and the time server may include multiple intermediate nodes;

[0232] The timestamp carried in the synchronization message includes a timestamp corresponding to the second time processing difference. The second time processing difference is calculated by accumulating the time processing differences of each intermediate node forwarding the synchronization message. The time processing difference of the intermediate node forwarding the synchronization message is calculated based on the time value of the synchronization message arriving at the intermediate node and the time value of the synchronization message leaving the intermediate node.

[0233] Optionally, the client and the time server may include multiple intermediate nodes;

[0234] The timestamp carried in the notification message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

[0235] Optionally, the timestamp related to the first time processing difference carried in the notification message is the timestamp corresponding to the first time processing difference.

[0236] Optionally, there are multiple time servers, and each time server sends a notification message that also carries the status information of that time server.

[0237] The processor 700 is used to read the program in the memory 720 and execute the following processes:

[0238] Based on the status information of the multiple time servers, a first target time server whose status information meets the preset conditions is determined from the multiple time servers;

[0239] The time difference with the first target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp.

[0240] Optionally, when there are multiple first target time servers, the synchronization message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server.

[0241] The processor 700 is used to read the program in the memory 720 and execute the following processes:

[0242] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0243] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0244] Optionally, when there are multiple first target time servers, the notification message sent by the first target time server also carries hop count information, which is used to indicate the number of network hops between the client and the first target time server.

[0245] The processor 700 is used to read the program in the memory 720 and execute the following processes:

[0246] Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers;

[0247] The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

[0248] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0249] The second transmission path is determined by routing the IP address carried in the header of the message sent from the time server to the client.

[0250] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path and the second transmission path are determined in the following manner:

[0251] Specify via a centralized control unit.

[0252] Optionally, the client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server.

[0253] The second transmission path is determined by the path information of the first transmission path recorded by the time server.

[0254] This application also provides a time server. Since the principle behind the time server's solution is similar to the time synchronization method in this application, the implementation of the terminal can be found in the method implementation; repeated details will not be elaborated further. Figure 8 As shown, the time server in this embodiment includes: a processor 800, configured to read a program from a memory 820 and execute the following process: via a transceiver 810:

[0255] Receive request messages sent by the client at the second moment;

[0256] A synchronization message is sent to the client at the third moment;

[0257] Send a notification message to the client.

[0258] Among them, Figure 8 In this context, the bus architecture can include any number of interconnected buses and bridges, specifically linking various circuits together, represented by one or more processors (processor 800) and memory (memory 820). The bus architecture can also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. The bus interface provides an interface. The transceiver 810 can be multiple elements, including transmitters and transceivers, providing a unit for communicating with various other devices over a transmission medium. The processor 800 is responsible for managing the bus architecture and general processing, and the memory 820 can store data used by the processor 800 during operation.

[0259] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the above-described time synchronization method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0260] This application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the above-described... Figure 2 or Figure 4 The various processes of the method embodiments shown can achieve the same technical effect, and will not be described again here to avoid repetition.

[0261] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0262] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0263] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A time synchronization method, characterized in that, The method, executed by the client, includes: Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment; The system receives the synchronization message sent by the time server at the fourth moment and records the fourth timestamp corresponding to the fourth moment. Receive notification messages sent by the time server; The time difference with the time server is calculated based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

2. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

3. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the notification message is related to at least one of a second timestamp and a third timestamp, wherein the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

4. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message is different from the timestamp carried in the notification message.

5. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes a third timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

6. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes a second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

7. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message includes a second timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

8. The time synchronization method according to claim 1, characterized in that, The timestamp carried in the synchronization message includes a third timestamp, and the timestamp carried in the notification message includes the difference between the third timestamp and the second timestamp. The second timestamp is the timestamp corresponding to the second moment when the time server receives the request message, and the third timestamp is the timestamp corresponding to the third moment when the time server sends the synchronization message.

9. The time synchronization method according to claim 1, characterized in that, The request message carries the first timestamp.

10. The time synchronization method according to claim 1, characterized in that, The client and the time server include multiple intermediate nodes; The timestamp carried in the synchronization message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

11. The time synchronization method according to claim 10, characterized in that, The timestamp carried in the synchronization message related to the first time processing difference is the timestamp corresponding to the difference between the first time processing difference and the second timestamp, where the second timestamp is the timestamp corresponding to the second moment when the time server receives the request message.

12. The time synchronization method according to claim 1, characterized in that, The client and the time server include multiple intermediate nodes; The timestamp carried in the synchronization message includes a timestamp corresponding to the second time processing difference. The second time processing difference is calculated by accumulating the time processing differences of each intermediate node forwarding the synchronization message. The time processing difference of the intermediate node forwarding the synchronization message is calculated based on the time value of the synchronization message arriving at the intermediate node and the time value of the synchronization message leaving the intermediate node.

13. The time synchronization method according to claim 1, characterized in that, The client and the time server include multiple intermediate nodes; The timestamp carried in the notification message includes a timestamp related to the first time processing difference. The first time processing difference is calculated by accumulating the time processing difference of each intermediate node forwarding the request message. The time processing difference of the intermediate node forwarding the request message is the difference between the time value of the request message arriving at the intermediate node and the time value of the request message leaving the intermediate node.

14. The time synchronization method according to claim 13, characterized in that, The timestamp carried in the notification message related to the first time processing difference is the timestamp corresponding to the first time processing difference.

15. The time synchronization method according to claim 1, characterized in that, There are multiple time servers, and each time server sends a notification message that also carries the status information of that time server. The step of calculating the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp includes: Based on the status information of the multiple time servers, a first target time server whose status information meets the preset conditions is determined from the multiple time servers; The time difference with the first target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp.

16. The time synchronization method according to claim 15, characterized in that, When there are multiple first target time servers, the synchronization message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server. The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes: Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers; The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

17. The time synchronization method according to claim 15, characterized in that, When there are multiple first target time servers, the notification message sent by the first target time server also carries hop count information, which is used to indicate the network hop count between the client and the first target time server. The step of calculating the time difference with the first target time server based on the first timestamp, the timestamp carried in the synchronization message sent by the first target time server, the timestamp carried in the notification message sent by the first target time server, and the fourth timestamp includes: Based on the hop count information of multiple first target time servers, determine the second target time server with the fewest hop counts from among the multiple first target time servers; The time difference with the second target time server is calculated based on the first timestamp, the timestamp carried in the synchronization message sent by the second target time server, the timestamp carried in the notification message sent by the second target time server, and the fourth timestamp.

18. The time synchronization method according to any one of claims 1 to 17, characterized in that, The client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server. The second transmission path is determined by routing the IP address carried in the header of the message sent from the time server to the client.

19. The time synchronization method according to any one of claims 1 to 17, characterized in that, The client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path and the second transmission path are determined in the following way: Specify via a centralized control unit.

20. The time synchronization method according to any one of claims 1 to 17, characterized in that, The client transmits a message to the time server through a first transmission path, and the time server transmits a message to the client through a second transmission path. The first transmission path is determined by routing addressing the IP address carried in the header of the message transmitted by the client to the time server. The second transmission path is determined by the path information of the first transmission path recorded by the time server.

21. A time synchronization method, characterized in that, The method, executed by a time server, includes: Receive request messages sent by the client at the second moment; A synchronization message is sent to the client at the third moment; Send a notification message to the client.

22. A time synchronization device, characterized in that, Applied to a client, the device includes: The first sending module is used to send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment; The second sending module is used to receive the synchronization message sent by the time server at the fourth time and record the fourth timestamp corresponding to the fourth time. The first receiving module is used to receive notification messages sent by the time server; The first calculation module is used to calculate the time difference with the time server based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

23. A time synchronization device, characterized in that, The device, used in a time server, includes: The second receiving module is used to receive the request message sent by the client at the second moment; The third sending module is used to send a synchronization message to the client at a third moment; The fourth sending module is used to send notification messages to the client.

24. A client application, characterized in that, Includes a transceiver and a processor, the transceiver being used for: Send a request message to the time server at the first moment and record the first timestamp corresponding to the first moment; The system receives the synchronization message sent by the time server at the fourth moment and records the fourth timestamp corresponding to the fourth moment. Receive notification messages sent by the time server; The processor is used for: The time difference with the time server is calculated based on the first timestamp, the timestamp carried in the synchronization message, the timestamp carried in the notification message, and the fourth timestamp. The time difference is used for the client to synchronize time with the time server.

25. A time server, characterized in that, Includes a transceiver and a processor, the transceiver being used for: Receive request messages sent by the client at the second moment; A synchronization message is sent to the client at the third moment; Send a notification message to the client.

26. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, it implements the steps of the time synchronization method as described in any one of claims 1 to 20, or when the computer program is executed by the processor, it implements the steps of the time synchronization method as described in claim 21.

27. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the time synchronization method as described in any one of claims 1 to 20, or, when executed by the processor, implements the steps of the time synchronization method as described in claim 21.

28. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps of the time synchronization method as described in any one of claims 1 to 20, or, when executed by the processor, implement the steps of the time synchronization method as described in claim 21.