Method, related device and system for obtaining absolute timestamp
By sending a timestamp request message to the GPS timer device in the server of a distributed system, the absolute timestamp is calculated, which solves the problem of complex and costly configuration of high-precision time synchronization protocols in the prior art, and realizes the comparability and accuracy of timestamps, while reducing the implementation complexity and cost of the server.
Patent Information
- Application Number
- CN201911035344.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-29
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2039-10-29
AI Technical Summary
In distributed systems, when each server obtains time stamps, the existing technology requires the deployment of high-precision time synchronization protocols, resulting in complex configuration and high cost.
The server sends a timestamp request message to the local GPS timing device, and calculates the absolute timestamp of the application task at the first moment based on the timestamp in the received response message, avoiding the need to deploy a high-precision time synchronization protocol on each server.
The comparability and accuracy of the absolute timestamps obtained by each server in a distributed system are realized, while reducing the implementation complexity and cost of the server.
Smart Images

Figure CN112751636B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and particularly to a method for obtaining an absolute timestamp and a distributed system. Background Art
[0002] Currently, many applications are distributed applications, and the system for executing distributed applications is called a distributed system. The application programs of distributed applications are often distributed on multiple servers in different data centers of the distributed system. These servers respectively execute one or more application tasks of the distributed application to implement the functions of the distributed application. The application tasks executed on each server need to be carried out in a certain time sequence. Otherwise, the application tasks may be disordered, resulting in the inability to implement the functions of the distributed application. Therefore, when the server executes the application tasks, it needs to obtain and record the timestamp of each application task, and moreover, the timestamps of each application task should come from the same time source to ensure the comparability of these timestamps.
[0003] To ensure the time sequence of each application task, a high-precision time synchronization protocol (such as the 1588V2 protocol) can be deployed for each server, and a dedicated network card supporting the high-precision time synchronization protocol can be equipped for each server. In this way, each server can obtain a timestamp from a Global Positioning System (GPS) time service device, and the time in each GPS time service device is obtained from a satellite, so it can be ensured that the timestamps obtained by each application task come from the same time source. The timestamp from the GPS time service device can be called an absolute timestamp.
[0004] However, deploying a high-precision time synchronization protocol on each server is too complex in configuration. Summary of the Invention
[0005] Embodiments of this application provide a method for obtaining an absolute timestamp, related devices and systems, which can be used to determine the absolute timestamp required for an application task. The related devices for obtaining an absolute timestamp can be a chip, a computer-readable storage medium, a server, etc., and the systems for obtaining an absolute timestamp can be a service system, a distributed system, etc. The method for obtaining an absolute timestamp, related devices and systems are as follows:
[0006] In a first aspect, a method for obtaining an absolute timestamp is provided, including: when an application task executed on a server in a service system needs to obtain the absolute timestamp at a first moment, the server determines the local timestamp T0 at the first moment; the server sends a timestamp request message to a GPS time synchronization device in the service system and determines the sending timestamp T1 of the timestamp request message; the server receives a timestamp response message sent by the GPS time synchronization device to the server, where the timestamp response message carries the reception timestamp T2 of the timestamp request message on the GPS time synchronization device and the sending timestamp T3 of the GPS time synchronization device for sending the timestamp response message; the server determines the reception timestamp T4 of the timestamp response message; the server determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4.
[0007] Wherein, the GPS time synchronization device is a switch that can obtain standard time signals from satellites, and it can provide the obtained standard time signals to other devices. Optionally, the satellite can be a GPS satellite or a Beidou satellite. It should be noted that even a time synchronization device that obtains standard time signals from Beidou satellites can also be referred to as a GPS time synchronization device.
[0008] The server is any computer device that can execute an application task. The server can be any server that executes an application task among multiple servers in the service system. The application task can also be referred to as an application process. The service system can be a data center, an enterprise network, etc. The server can be a server in the data center or a server in the enterprise network.
[0009] The absolute timestamp refers to the timestamp obtained from a satellite. Since the time signals in each GPS time synchronization device are obtained from satellites, the timestamp recorded in the GPS time synchronization device is the absolute timestamp. The local timestamp is the timestamp recorded on the server. Among T0, T1, T2, T3, and T4, T0, T1, and T4 are local timestamps on the server, and T2 and T3 are absolute timestamps on the GPS time synchronization device. The time accuracy of T0, T1, T2, T3, and T4 can be at the nanosecond level.
[0010] The local timestamp T0 at the first moment refers to the local timestamp on the server at the first moment. The absolute timestamp at the first moment refers to the timestamp on the GPS time synchronization device at the first moment. The local timestamp T0 at the first moment corresponds to the absolute timestamp at the first moment. The method for obtaining the absolute timestamp provided in the embodiments of the present application is to calibrate the local timestamp T0 at the first moment through the absolute timestamp obtained from the GPS time synchronization device, so as to determine the absolute timestamp at the first moment.
[0011] The timestamp request message may be an Internet Control Message Protocol (ICMP) timestamp query message, and T1 may also be carried in the timestamp request message. The timestamp response message may be an ICMP echo message, and the ICMP echo message may also be referred to as an ICMP echo message.
[0012] In the solution shown in the embodiments of the present application, when an application task executed on a server in a service system needs to obtain the absolute timestamp of the first moment, the server determines the local timestamp T0 of the first moment. Then, the server sends a timestamp request message to the GPS timing device of the service system and determines the sending timestamp T1 of the timestamp request message. Then, the GPS timing device determines the receiving timestamp T2 of the timestamp request message. Then, the GPS timing device sends a timestamp response message carrying T2 and the sending timestamp T3 of the timestamp response message to the server. Then, the server determines the receiving timestamp T4 of the timestamp response message. Finally, the server determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4. By adopting the technical solution provided in the embodiments of the present application, not only can the absolute timestamp required by the application task be obtained, but also there is no need to equip the server with a dedicated network card supporting a high-precision time synchronization protocol, thereby reducing the cost and the implementation complexity of the server.
[0013] Moreover, in the solution shown in the embodiments of the present application, the server sends a timestamp request message to the GPS timing device of the service system where it is located, rather than all servers sending timestamp request messages to the same time source device. This avoids the problems of the time source device malfunctioning or the timestamp response message not being sent in a timely manner when the time source device receives a large number of timestamp request messages at the same time, and also avoids the problem of a large difference in the sending delay when different servers send timestamp request messages to the time source device. Furthermore, the server and the GPS timing device are located in the same service system, rather than in different service systems, which also shortens the sending delay of the timestamp request message and makes the determination of the absolute timestamp more timely.
[0014] In a possible implementation manner, one primary GPS timing device and one standby GPS timing device are provided in the service system.
[0015] Among them, the priority of the primary GPS timing device is higher than that of the standby GPS timing device, and the standby GPS timing device is used only when the primary GPS timing device cannot work properly.
[0016] In the solution shown in the embodiments of the present application, by setting a primary GPS timing device and a backup GPS timing device in each service system, when the primary GPS timing device fails, the server can still send a timestamp request message to the backup GPS timing device and obtain a timestamp response message from the backup GPS timing device, thereby enhancing the reliability of the GPS timing device for timing.
[0017] In a possible implementation manner, when the GPS timing device is the primary GPS timing device of the service system, the server sending a timestamp request message to the GPS timing device of the service system includes: the server sending the timestamp request message to the primary GPS timing device.
[0018] In the solution shown in the embodiments of the present application, by default, the server uses the primary GPS timing device of the service system as the GPS timing device and sends a timestamp request message to the primary GPS timing device.
[0019] In a possible implementation manner, when the GPS timing device is the backup GPS timing device of the service system, the server sending a timestamp request message to the GPS timing device of the service system includes: if the server sends a timestamp request message to the primary GPS timing device and does not receive a timestamp response message sent by the primary GPS timing device within a set duration, then sending the timestamp request message to the backup GPS timing device.
[0020] In the solution shown in the embodiments of the present application, by default, the server uses the primary GPS timing device of the service system as the target GPS timing device for priority sending. Then the server first sends a timestamp request message to the primary GPS timing device of the service system. If it does not receive a timestamp response message sent by the primary GPS timing device within the set duration, it means that the primary GPS timing device cannot work properly. At this time, the backup GPS timing device should be determined as the target GPS timing device and a timestamp request message should be sent to the backup GPS timing device.
[0021] In a possible implementation manner, the server determining the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4 includes: the server determining that the value of T3 - ((T2 - T1) - (T4 - T3)) / 2 - T0 is the absolute timestamp of the application task at the first moment.
[0022] In the solution shown in the embodiments of the present application, the server calculates the value of T3–((T2-T1)-(T4-T3)) / 2-T0, corrects T0, and thus determines the absolute timestamp that the application task needs to obtain at the first moment.
[0023] In a possible implementation, the GPS time service device is connected beside the core switch of the service system, or the GPS time service device is connected beside a server of the service system.
[0024] Herein, being connected beside can be understood as being connected. When the GPS time service device is connected beside the core switch of the service system, it can be understood that the GPS time service device is directly connected to the core switch of the service system. When the GPS time service device is connected beside a server of the service system, it can be understood that the GPS time service device is directly connected to a certain server of the service system.
[0025] In the solution shown in the embodiments of the present application, according to the different positions where the GPS time service device is connected beside, the specific situation of the server sending a timestamp request message to the GPS time service device is also different.
[0026] When the GPS time service device is connected beside the core switch of the service system, the server sends a timestamp request message to the GPS time service device through each level of switches.
[0027] When the GPS time service device is connected beside a server of the service system, it can be divided into two cases. In the first case, if the GPS time service device is connected beside the server that executes the application task, then the server that executes the application task directly sends a timestamp request message to the GPS time service device. In the second case, if the GPS time service device is not connected beside the server that executes the application task, then the server that executes the application task sends a timestamp request message to the GPS time service device through the switch and the server beside which the GPS time service device is connected.
[0028] Correspondingly, according to the different positions where the GPS time service device is connected beside, the specific situation of the GPS time service device sending a timestamp response message to the server is also different.
[0029] When the GPS time service device is connected beside the core switch of the service system, the GPS time service device sends a timestamp response message to the server through each level of switches.
[0030] When the GPS time service device is attached to the server of the service system, it can be divided into two cases. In the first case, when the GPS time service device is attached to the server that executes the application task, the GPS time service device directly sends a timestamp response message to the server that executes the application task. In the second case, when the GPS time service device is not attached to the server that executes the application task, the GPS time service device sends a timestamp response message to the server that executes the application task through the server and switch to which the GPS time service device is attached.
[0031] In a possible implementation, the T1 is carried in the timestamp request message.
[0032] In the solution shown in the embodiments of the present application, by carrying T1 in the timestamp request message, the server does not have to record T1 locally. It can be understood that even if T1 is carried in the timestamp request message, the server can also record T1 locally, and the present application does not make any limitation in this regard.
[0033] In a possible implementation, the timestamp request message is an ICMP timestamp query packet, and the timestamp response message is an ICMP echo packet.
[0034] Among them, the ICMP timestamp query packet is a packet used to request a timestamp. The ICMP echo packet is a packet used to respond to a timestamp request.
[0035] In the solution shown in the embodiments of the present application, the IP address of the server, the IP address of the GPS time service device, and the type information and code information of the ICMP timestamp query packet are carried in the ICMP timestamp query packet. The IP address of the server, the IP address of the GPS time service device, and the type information and code information of the ICMP echo packet are also carried in the ICMP echo packet.
[0036] In a possible implementation, the value of the type field of the ICMP timestamp query packet is 13, and the value of the code field is 10; the value of the type field of the ICMP echo packet is 14, and the value of the code field is 10.
[0037] Among them, the value of the type field being 13 represents that the corresponding packet is a timestamp request packet. The value of the type field being 14 represents that the corresponding packet is a timestamp response packet.
[0038] The value of the code field of the ICMP timestamp query packet being 10 represents that the ICMP timestamp query packet is an extended ICMP timestamp query packet. Compared with the conventional ICMP timestamp query packet, the time accuracy of the timestamp carried in the extended ICMP timestamp query packet is higher.
[0039] The value of the code field of the ICMP echo message is 10, indicating that the ICMP echo message is an extended ICMP echo message. Compared with the conventional ICMP echo message, the extended ICMP echo message carries a timestamp with higher time precision.
[0040] In the solution shown in the embodiments of the present application, when the application task executed on the server needs to obtain the absolute timestamp at the first moment, the server determines the local timestamp T0 at the first moment.
[0041] Then, the server encapsulates the extended ICMP timestamp query message and sends the ICMP timestamp query message to the GPS time service device in the service system where it is located. The ICMP timestamp query message carries the sending timestamp T1 of the ICMP timestamp query message, and the time precision of T1 is nanosecond-level precision.
[0042] Then, the GPS time service device receives the ICMP timestamp query message and, through the value of the code field, identifies that the ICMP timestamp query message is an extended ICMP timestamp query message. The GPS time service device encapsulates the extended ICMP echo message and sends the ICMP echo message to the server. The ICMP echo message carries the receiving timestamp T2 of the ICMP timestamp query message and the sending timestamp T3 of the ICMP echo message, and the time precision of T2 and T3 is nanosecond-level precision.
[0043] Then, the server receives the ICMP echo message and determines the receiving timestamp T4 of the ICMP echo message.
[0044] Finally, the server determines the absolute timestamp that the application task needs to obtain at the first moment based on T0, T1, T2, T3, and T4.
[0045] In a possible implementation, the time precision of T0, T1, T2, T3, and T4 is nanosecond-level precision.
[0046] Among them, the time precision of nanosecond-level precision means that T0, T1, T2, T3, and T4 can be accurate to several nanoseconds.
[0047] In the solution shown in the embodiments of the present application, by making the time precision of T0, T1, T2, T3, and T4 be nanosecond-level precision, the time precision of the absolute timestamp obtained by the application task is also nanosecond-level precision. Thus, the determined absolute timestamp is more accurate, which is more conducive to the comparison of the absolute timestamps obtained by subsequent application tasks and is more convenient for the execution of each application task.
[0048] In a second aspect, a device for obtaining an absolute timestamp is provided, including: a local timestamp determination module, configured to determine a local timestamp T0 of a first moment when an executed application task needs to obtain the absolute timestamp of the first moment; a sending module, configured to send a timestamp request message to a GPS time service device of the service system where the device is located, and determine a sending timestamp T1 of the timestamp request message; a receiving module, configured to receive a timestamp response message sent by the GPS time service device, where the timestamp response message carries a receiving timestamp T2 of the timestamp request message on the GPS time service device and a sending timestamp T3 of the GPS time service device for sending the timestamp response message; a receiving timestamp determination module, configured to determine a receiving timestamp T4 of the timestamp response message; an absolute timestamp determination module, configured to determine the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4.
[0049] In a possible implementation, the service system is provided with a primary GPS time service device and a backup GPS time service device.
[0050] In a possible implementation, the GPS time service device is the primary GPS time service device of the service system, and the sending module is configured to: send the timestamp request message to the primary GPS time service device.
[0051] In a possible implementation, the GPS time service device is the backup GPS time service device of the service system, and the sending module is configured to: if a timestamp request message is sent to the primary GPS time service device and a timestamp response message sent by the primary GPS time service device is not received within a set duration, then send the timestamp request message to the backup GPS time service device.
[0052] In a possible implementation, the absolute timestamp determination module is configured to:
[0053] Determine that the value of T3–((T2-T1)-(T4-T3)) / 2-T0 is the absolute timestamp of the application task at the first moment.
[0054] In a possible implementation, the T1 is further carried in the timestamp request message and the timestamp response message.
[0055] In a possible implementation, the time accuracy of the T0, the T1, the T2, the T3, and the T4 is nanosecond-level accuracy.
[0056] In a possible implementation, the GPS timing device is hung beside the core switch of the service system, or the GPS timing device is hung beside the server of the service system.
[0057] In a possible implementation, the timestamp request message is an Internet Control Message Protocol (ICMP) timestamp query message, and the timestamp response message is an ICMP echo message.
[0058] In a possible implementation, the value of the type field of the ICMP timestamp query message is 13, and the value of the code field is 10; the value of the type field of the ICMP echo message is 14, and the value of the code field is 10.
[0059] An embodiment of the present application further provides a service system, which includes a server and at least one GPS timing device. When an application task executed on the server needs to obtain the absolute timestamp of the first moment, the server determines the local timestamp of the first moment, sends a timestamp request message to the GPS timing device, and determines the sending timestamp T1 of the timestamp request message. The GPS timing device determines the receiving timestamp T2 of the timestamp request message and sends a timestamp response message to the server. The timestamp response message carries the receiving timestamp T2 of the timestamp request message on the GPS timing device and the sending timestamp T3 of the GPS timing device for sending the timestamp response message. Then, the server determines the receiving timestamp T4 of the timestamp response message and determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4.
[0060] In a possible implementation, the service system is provided with a primary GPS timing device and a standby GPS timing device.
[0061] In a possible implementation, the GPS timing device is the primary GPS timing device of the service system, and the sending the timestamp request message to the GPS timing device includes: sending the timestamp request message to the primary GPS timing device.
[0062] In a possible implementation, the GPS timing device is the standby GPS timing device of the service system, and the sending the timestamp request message to the GPS timing device includes: if the timestamp request message is sent to the primary GPS timing device and the timestamp response message sent by the primary GPS timing device is not received within the set duration, then send the timestamp request message to the standby GPS timing device.
[0063] In a possible implementation, determining the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4 includes: determining that the value of T3 – ((T2 - T1) - (T4 - T3)) / 2 - T0 is the absolute timestamp of the application task at the first moment.
[0064] In a possible implementation, the T1 is further carried in the timestamp request message and the timestamp response message.
[0065] In a possible implementation, the time precision of the T0, the T1, the T2, the T3, and the T4 is nanosecond-level precision.
[0066] In a possible implementation, the GPS time service device is connected in parallel to the core switch of the service system, or the GPS time service device is connected in parallel to the server of the service system.
[0067] In a possible implementation, the timestamp request message is an Internet Control Message Protocol (ICMP) timestamp query message, and the timestamp response message is an ICMP echo message.
[0068] In a possible implementation, the value of the type field of the ICMP timestamp query message is 13, and the value of the code field is 10; the value of the type field of the ICMP echo message is 14, and the value of the code field is 10.
[0069] Fourthly, a distributed system is provided. The distributed system includes servers and GPS time service devices in multiple service systems as described in the third aspect.
[0070] Fifthly, a computer program product containing instructions is provided. When the computer program product runs on a server, the server is caused to execute the method for obtaining an absolute timestamp as described in the first aspect.
[0071] Sixthly, a server is provided. The server includes a memory and a processor. The memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method for obtaining an absolute timestamp as described in the first aspect.
[0072] Seventhly, a computer-readable storage medium is provided. The computer-readable storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the method for obtaining an absolute timestamp as described in the first aspect.
[0073] The beneficial effects brought by the technical solutions provided in the embodiments of the present application are:
[0074] In the technical solution provided by the embodiment of the present application, when the application task executed on the server needs to obtain the absolute timestamp at the first moment, the server determines the local timestamp T0 at the first moment. Then, the server sends a timestamp request message to the GPS time service device in the service system where it is located, and determines the sending timestamp T1 of the timestamp request message. Then, the GPS time service device determines the receiving timestamp T2 of the timestamp request message. Then, the GPS time service device sends a timestamp response message carrying T2 and the sending timestamp T3 of the timestamp response message to the server. Then, the server determines the receiving timestamp T4 of the timestamp response message. Finally, the server determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4. By adopting the technical solution provided by the embodiment of the present application, the application task can obtain the required absolute timestamp, and it is not necessary to equip the server with a dedicated network card supporting a high-precision time synchronization protocol, thereby reducing the implementation complexity of the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Figure 1 is a schematic diagram of a distributed system provided by an embodiment of the present application;
[0076] Figure 2 is a schematic diagram of a data center provided by an embodiment of the present application;
[0077] Figure 3 is a schematic diagram of another data center provided by an embodiment of the present application;
[0078] Figure 4 is a schematic diagram of the interaction process between a server and a GPS time service device provided by an embodiment of the present application;
[0079] Figure 5 is a flowchart of a method for obtaining an absolute timestamp provided by an embodiment of the present application;
[0080] Figure 6 is a block diagram of the structure of a server provided by an embodiment of the present application;
[0081] Figure 7 is a block diagram of the structure of a GPS time service device provided by an embodiment of the present application;
[0082] Figure 8 is a block diagram of the structure of a device for obtaining an absolute timestamp provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0083] An embodiment of the present application provides a method for obtaining an absolute timestamp, which enables a server in a distributed system to conveniently obtain the absolute timestamp of an application task and avoid the problem of complex configuration caused by deploying a high-precision time synchronization protocol on each server. Specifically, the distributed system may include multiple service systems, and the method may be independently implemented by each service system in the distributed system. Each service system may include a server and a GPS (Global Positioning System) time service device. Among them, the server is any server in the service system. The server may be any device that executes an application task. The GPS time service device is a GPS time service device that provides an absolute timestamp for the server in the service system where the server is located. The service system is any system that includes a server and a GPS authorization device, such as a data center, an enterprise network, etc. The following takes the service system as a data center as an example to illustrate various embodiments of the present application.
[0084] The architecture of the distributed system may be as Figure 1 shown. The distributed system includes multiple servers and multiple GPS time service devices. The multiple servers are located in different data centers, and at least one GPS time service device is provided in each data center. The distributed system may be managed by a distributed system network manager.
[0085] As Figure 2 shown, a method of hanging the GPS time service device beside is provided. The data center includes multiple servers, multiple switches, and a GPS time service device. The GPS time service device is hung beside the core switch of the data center.
[0086] As Figure 3 shown, another method of hanging the GPS time service device beside is provided. The data center includes multiple servers, multiple switches, and a GPS time service device. The GPS time service device is hung beside the server of the data center.
[0087] As Figure 6As shown, the server includes a transmitter, a receiver, a processor, and a memory, which are interconnected. The processor can be the control center of the server. The processor can be a CPU (Central Processing Unit), and optionally, the processor can integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, and the modem processor mainly processes wireless communication. The processor can also be a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, etc. The memory can be used to store software programs and modules. The processor executes various functional applications and data processing of the server by reading the software codes and modules stored in the memory. The memory can store a timestamp request message, a timestamp response message, T0, T1, T2, T3, and T4, etc. The processor can be used to determine the current local timestamp T0, generate a timestamp request message, determine the transmission timestamp T1 of the timestamp request message, determine the reception timestamp T4 of the timestamp response message, and determine the absolute timestamp that the application task needs to obtain based on T0, T1, T2, T3, and T4, etc. The transmitter is used to transmit messages externally. For example, it can transmit a timestamp request message externally. The receiver is used to receive messages transmitted by external devices. For example, it can be used to receive the timestamp response message transmitted by a GPS timing device.
[0088] As Figure 7 shown, the GPS timing device includes a transmitter, a receiver, a processor, and a memory, which are interconnected. The processor can be the control center of the GPS timing device. The processor can be a CPU (Central Processing Unit), and optionally, the processor can integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, and the modem processor mainly processes wireless communication. The processor can also be a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, etc. The memory can be used to store software programs and modules. The processor executes various functional applications and data processing of the GPS timing device by reading the software codes and modules stored in the memory. The memory can store a timestamp request message, a timestamp response message, T2, and T3. The processor can be used to determine the reception timestamp T2 of the timestamp request message, generate a timestamp response message, and determine the transmission timestamp T3 of the timestamp response message, etc. The transmitter is used to transmit messages externally. For example, it can transmit a timestamp response message externally. The receiver is used to receive messages transmitted by external devices. For example, it can be used to receive the timestamp request message transmitted by the server, and can also be used to receive the standard time signal transmitted by the satellite.
[0089] It is understandable that the method provided by the embodiments of the present application requires information interaction between the server and the GPS timing device. Therefore, before implementing the method provided by the embodiments of the present application, it is necessary to ensure that the IP (Internet Protocol) routing between the server and the GPS timing device is reachable. Optionally, this can be achieved by adding the GPS timing device to the routing domain where the server is located and publishing the IP route of the timing device within the routing domain.
[0090] The embodiments of the present application provide a method for obtaining an absolute timestamp. Referring to Figure 4 and Figure 5 , this method can be executed by the server of the service system. The processing flow of this method can include the following steps:
[0091] Step 501, when the application task executed on the server in the service system needs to obtain the absolute timestamp of the first moment, the server determines the local timestamp T0 of the first moment.
[0092] Among them, the server can be any one of multiple servers in the service system. When the application task executed on a certain server needs to obtain the absolute timestamp, this server becomes the server. The application task can also be called an application process.
[0093] The local timestamp T0 of the first moment refers to the local timestamp of the first moment on the server. The absolute timestamp of the first moment refers to the timestamp of the first moment on the GPS timing device. The local timestamp T0 of the first moment corresponds to the absolute timestamp of the first moment. The method for obtaining the absolute timestamp provided by the embodiments of the present application is to calibrate the local timestamp T0 of the first moment through the absolute timestamp obtained from the GPS timing device, so as to determine the absolute timestamp of the first moment.
[0094] The time accuracy of T0 can be nanosecond-level accuracy. The format of the timestamp is defined in RFC1305 as follows: the high 32 bits represent the seconds since January 1, 1900, and the low 32 bits represent the fractional part of the seconds.
[0095] In the solution shown in the embodiments of the present application, when the application task executed on the server needs to obtain the absolute timestamp of the first moment, the server determines and records the local timestamp T0 of the first moment on the server.
[0096] Step 502, the server sends a timestamp request message to the GPS timing device of the service system and determines the sending timestamp T1 of the timestamp request message.
[0097] Among them, the timestamp request message can be an ICMP timestamp query packet, and T1 can also be carried in the timestamp request message. The time accuracy of T1 can be nanosecond-level accuracy.
[0098] The sending timestamp T1 refers to the local timestamp on the server when the server sends a timestamp request message to the GPS time service device.
[0099] In the solution shown in the embodiments of the present application, when the server detects that an application task needs to obtain an absolute timestamp, it sends a timestamp request message to the GPS time service device. It can be understood that before sending the timestamp request message, a timestamp request message needs to be generated, so there is a certain time interval between T1 and T0. For example, when the timestamp request message is an ICMP timestamp query packet, before sending the ICMP timestamp query packet, encapsulation of the ICMP timestamp query packet needs to be performed.
[0100] The GPS time service device can be hung beside the core switch of the data center where it is located, or can be hung beside the server of the data center where it is located. According to the different positions where the GPS time service device is hung, the specific situation of the server sending a timestamp request message to the GPS time service device is also different.
[0101] When the GPS time service device is hung beside the core switch of the data center where it is located, the server sends a timestamp request message to the GPS time service device through each level of switch.
[0102] When the GPS time service device is hung beside the server of the data center where it is located, it can be divided into two cases. In the first case, if the GPS time service device is hung beside the server that executes the application task, the server that executes the application task directly sends a timestamp request message to the GPS time service device. In the second case, if the GPS time service device is not hung beside the server that executes the application task, the server that executes the application task sends a timestamp request message to the GPS time service device through the switch and the server where the GPS time service device is hung.
[0103] It should be noted that for the convenience of description, the GPS time service device that receives the timestamp request message is called the target GPS time service device. Then the target GPS time service device is determined according to factors such as the number, priority, and whether it is working properly of the GPS time service devices in each data center. When there is only one GPS time service device in each data center, the target GPS time service device is the GPS time service device of the data center where the server is located. When there are multiple GPS time service devices in each data center, the target GPS time service device is determined according to the priorities and whether they are working properly of the GPS time service devices.
[0104] In a possible implementation manner, each service system is provided with a primary GPS time service device and a standby GPS time service device.
[0105] Among them, the priority of the primary GPS time synchronization device is higher than that of the backup GPS time synchronization device. The backup GPS time synchronization device will only be used when the primary GPS time synchronization device fails to work properly.
[0106] In the solution shown in the embodiments of this application, by setting a primary GPS time synchronization device and a backup GPS time synchronization device in each service system (for example, a data center), when the primary GPS time synchronization device fails, the server can still send a timestamp request message to the backup GPS time synchronization device and obtain a timestamp response message from the backup GPS time synchronization device, thereby enhancing the reliability of GPS time synchronization.
[0107] When a primary GPS time synchronization device and a backup GPS time synchronization device are set in each service system, the target GPS time synchronization device can be either the primary GPS time synchronization device or the backup GPS time synchronization device. The specific situation is as follows.
[0108] In a possible implementation, if the target GPS time synchronization device is the primary GPS time synchronization device of the data center where the server is located, then at this time, the server sends a timestamp request message to the primary GPS time synchronization device of the data center where it is located.
[0109] In the solution shown in the embodiments of this application, by default, the server uses the primary GPS time synchronization device of the data center where it is located as the target GPS time synchronization device and sends a timestamp request message to the primary GPS time synchronization device.
[0110] In another possible implementation, the target GPS time synchronization device is the backup GPS time synchronization device of the data center where the server is located. Then the situation at this time is that if the server sends a timestamp request message to the primary GPS time synchronization device of the data center where it is located and does not receive a timestamp response message sent by the primary GPS time synchronization device of the data center where it is located within the set duration, it will send a timestamp request message to the backup GPS time synchronization device of the data center where it is located.
[0111] In the solution shown in the embodiments of this application, by default, the server uses the primary GPS time synchronization device of the data center where it is located as the target GPS time synchronization device. Then the server first sends a timestamp request message to the primary GPS time synchronization device of the data center where it is located. If it does not receive a timestamp response message sent by the primary GPS time synchronization device within the set duration, it means that the primary GPS time synchronization device cannot work properly. Then at this time, the backup GPS time synchronization device should be determined as the target GPS time synchronization device and a timestamp request message should be sent to the backup GPS time synchronization device.
[0112] It can be seen that, by default, the target GPS time synchronization device is the primary GPS time synchronization device. When the primary GPS time synchronization device fails to work properly, in order to ensure that the server can successfully obtain the absolute timestamp, the backup GPS time synchronization device replaces the primary GPS time synchronization device as the target GPS time synchronization device.
[0113] In a possible implementation, the timestamp request message carries T1.
[0114] In the solution shown in the embodiments of the present application, by carrying T1 in the timestamp request message, the server does not have to record T1 locally. It can be understood that even if the timestamp request message carries T1, the server can also record T1 locally, and the present application does not make any limitations in this regard. In another possible implementation, T1 is not carried in the time acquisition request, and after the server determines T1, T1 is recorded in the server.
[0115] In a possible implementation, the timestamp request message is an ICMP timestamp query packet, and correspondingly, the timestamp response message is an ICMP echo packet.
[0116] In the solution shown in the embodiments of the present application, the ICMP timestamp query packet carries the IP address of the server, the IP address of the GPS time synchronization device, and the type information and code information of the ICMP timestamp query packet.
[0117] In a possible implementation, the value of the type field of the ICMP timestamp query packet is 13, and the value of the code field is 10.
[0118] Among them, the value of the type field being 13 indicates that the corresponding packet is a timestamp request packet. The value of the code field of the ICMP timestamp query packet being 10 indicates that the ICMP timestamp query packet is an extended ICMP timestamp query packet. Compared with the conventional ICMP timestamp query packet, the timestamp carried by the extended ICMP timestamp query packet has a higher time accuracy, and the time accuracy of the timestamp carried by the extended ICMP timestamp query packet is nanosecond-level accuracy.
[0119] The format of the ICMP timestamp query packet can be as shown in Table 1. The ICMP timestamp query packet carries an IP packet header, the transmitting-end IP (server IP), the receiving-end IP (time synchronization device IP), type information, code information, checksum information, identifier information, and sequence number information.
[0120] Among them, the transmitting-end IP (server IP) is the IP address of the server; the receiving-end IP (time synchronization device IP) is the IP address of the GPS time synchronization device, which can be the IP address of the primary GPS time synchronization device or the IP address of the standby GPS time synchronization device; the value of the type field is 13, and 13 represents that the type of this message is the timestamp request type; the value of the code field is 10, indicating that this ICMP timestamp query message is an extended ICMP timestamp query message, and the time accuracy of the timestamp carried by the extended ICMP timestamp query message is nanosecond-level accuracy.
[0121] The ICMP timestamp query message also carries the transmission timestamp T1 of the ICMP timestamp query message. The time accuracy of T1 is nanosecond-level accuracy, so the number of bits of T1 is 64 bits.
[0122] Table 1
[0123]
[0124] Step 503, the server receives the timestamp response message sent by the GPS time synchronization device to the server.
[0125] Among them, the timestamp response message carries the reception timestamp T2 of the timestamp request message on the GPS time synchronization device and the transmission timestamp T3 of the GPS time synchronization device when sending the timestamp response message. The timestamp response message can be an ICMP echo message. The time accuracy of T2 and T3 is nanosecond-level accuracy. T2 and T3 are timestamps recorded on the GPS time synchronization device and are absolute timestamps.
[0126] In the solution shown in the embodiments of the present application, the GPS time synchronization device receives the timestamp request message sent by the server, determines the reception timestamp T2 of the timestamp request message, and sends a timestamp response message to the server. It can be understood that it takes a certain amount of time from the server sending the timestamp request message to the GPS time synchronization device receiving the timestamp request message. Therefore, there is a time interval between T2 and T1. And before sending the timestamp response message, it is necessary to generate the timestamp response message. Therefore, there is a certain time interval between T3 and T2. For example, when the timestamp response message is an ICMP echo message, before sending the ICMP echo message, it is necessary to perform the encapsulation of the ICMP echo message.
[0127] Optionally, in order to improve processing accuracy and avoid time delay errors in control plane processing, the forwarding plane of the GPS timing device can directly receive and identify ICMP timestamp query messages, and encapsulate and send ICMP response messages. To ensure time delay accuracy, it is usually executed on a high-speed processing chip, such as an ASIC (application specific integrated circuit) chip, an FPGA (field programmable gate array) chip, or an NP (networking processor) microcode chip.
[0128] The GPS timing device can be hung beside the core switch of the data center where it is located, or beside the server of the data center where it is located. According to the different positions where the GPS timing device is hung beside, the specific situation of the GPS timing device sending a timestamp response message to the server is also different. When the GPS timing device is hung beside the core switch of the data center where it is located, the GPS timing device sends a timestamp response message to the server through each level of switch. When the GPS timing device is hung beside the server of the data center where it is located, it can be divided into two situations. In the first situation, if the GPS timing device is hung beside the server performing the application task, the GPS timing device directly sends a timestamp response message to the server. In the second situation, if the GPS timing device is not hung beside the server performing the application task, the GPS timing device sends a timestamp response message to the server through the server and switch where the GPS timing device is hung beside.
[0129] In a possible implementation, if the timestamp response message is an ICMP response message, correspondingly, the timestamp request message is an ICMP timestamp query message.
[0130] In the solution shown in the embodiments of this application, the ICMP response message carries the IP address of the server, the IP address of the GPS timing device, and the type information and code information of the ICMP response message.
[0131] In a possible implementation, the value of the type field of the ICMP response message is 14, and the value of the code field is 10.
[0132] Among them, the value of the type field being 14 indicates that the corresponding message is a timestamp response message. The value of the code field of the ICMP response message being 10 indicates that the ICMP response message is an extended ICMP response message. Compared with the conventional ICMP response message, the timestamp carried by the extended ICMP response message has higher time accuracy, and the time accuracy of the timestamp carried by the extended ICMP timestamp query message is nanosecond-level accuracy.
[0133] The format of the ICMP echo message can be as shown in Table 2. The ICMP echo message carries an IP packet header, the transmitting end IP (the IP of the timing device), the receiving end IP (the IP of the server), type information, code information, checksum information, identifier information, and sequence number information. Among them, the receiving end IP (the IP of the server) is the IP address of the server; the transmitting end IP (the IP of the timing device) is the IP address of the GPS timing device, which can be the IP address of the primary GPS timing device or the IP address of the backup GPS timing device; the value of the type field is 14, and 14 represents that the type of this message is the timestamp response type; the value of the code field is 10, indicating that this ICMP echo message is an extended ICMP echo message, and the time accuracy of the timestamp carried by the extended ICMP echo message is nanosecond-level accuracy. The ICMP echo message also carries the sending timestamp T1 of the ICMP timestamp query message, the receiving timestamp T2 of the ICMP timestamp query message, and the sending timestamp T3 of the ICMP echo message. The time accuracy of T1, T2, and T3 is nanosecond-level accuracy, so the number of bits of T1, T2, and T3 is 64 bits.
[0134] Table 2
[0135]
[0136] Step 504, the server determines the receiving timestamp T4 of the timestamp response message.
[0137] Among them, T4 is the local timestamp recorded on the server, and the time accuracy of T4 is nanosecond-level accuracy.
[0138] In the solution shown in the embodiments of the present application, the server receives the timestamp response message sent by the GPS timing device and determines the receiving timestamp T4 of the timestamp response message. The receiving timestamp T4 is the local timestamp when the server receives the timestamp response message.
[0139] Step 505, the server determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4.
[0140] Among them, T0, T1, and T4 are local timestamps, and T2 and T3 are absolute timestamps. The time accuracy of T0, T1, T2, T3, and T4 can be nanosecond-level accuracy.
[0141] In the solution shown in the embodiments of the present application, by making the time accuracy of T0, T1, T2, T3, and T4 be nanosecond-level accuracy, the time accuracy of the absolute timestamp obtained by the application task is also nanosecond-level accuracy. Therefore, the determined absolute timestamp is more accurate, which is more conducive to the comparison of the absolute timestamps obtained by subsequent application tasks and is more convenient for the execution of each application task.
[0142] It is understandable that the method for obtaining the absolute timestamp provided by the embodiments of the present application can also be applied to other service systems except for the data center. For example, for a network management system, the network manager or the controller itself belongs to a service system. If it is necessary to obtain the standard time, the method provided by the embodiments of the present application can also be used to obtain a high-precision timestamp message from the standard time timing device. For another example, for an office or production network, the hosts in the network can obtain high-precision timestamp messages from the standard time timing device according to the method provided by the embodiments of the present application. For another example, the VNF network devices virtualized by server virtual machines in the network can also apply the method provided by the embodiments of the present application.
[0143] Based on the same technical concept, the embodiments of the present application also provide a device for obtaining an absolute timestamp, as Figure 8 shown. The device includes:
[0144] A local timestamp determination module 801, configured to determine the local timestamp T0 of the first moment when the executed application task needs to obtain the absolute timestamp of the first moment;
[0145] A sending module 802, configured to send a timestamp request message to the GPS timing device of the service system where the device is located, and determine the sending timestamp T1 of the timestamp request message;
[0146] A receiving module 803, configured to receive the timestamp response message sent by the GPS timing device. The timestamp response message carries the receiving timestamp T2 of the timestamp request message on the GPS timing device and the sending timestamp T3 of the GPS timing device for sending the timestamp response message;
[0147] A receiving timestamp determination module 804, configured to determine the receiving timestamp T4 of the timestamp response message;
[0148] An absolute timestamp determination module 805, configured to determine the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4.
[0149] In a possible implementation manner, the service system is provided with a primary GPS timing device and a standby GPS timing device.
[0150] In a possible implementation manner, when the GPS timing device is the primary GPS timing device of the service system, the sending module 802 is configured to:
[0151] Send a timestamp request message to the primary GPS timing device.
[0152] In a possible implementation manner, when the GPS timing device is the standby GPS timing device of the service system, the sending module 802 is configured to:
[0153] If a timestamp request message is sent to the primary GPS time synchronization device and a timestamp response message sent by the primary GPS time synchronization device is not received within a set duration, then a timestamp request message is sent to the backup GPS time synchronization device.
[0154] In a possible implementation, the absolute timestamp determination module 805 is configured to:
[0155] Determine that the value of T3 – ((T2 - T1) - (T4 - T3)) / 2 - T0 is the absolute timestamp of the application task at the first moment.
[0156] In a possible implementation, T1 is also carried in the timestamp request message and the timestamp response message.
[0157] In a possible implementation, the time accuracies of T0, T1, T2, T3, and T4 are at the nanosecond level.
[0158] In a possible implementation, the GPS time synchronization device is connected in parallel to the core switch of the service system, or the GPS time synchronization device is connected in parallel to the server of the service system.
[0159] In a possible implementation, the timestamp request message is an Internet Control Message Protocol (ICMP) timestamp query message, and the timestamp response message is an ICMP echo message.
[0160] In a possible implementation, the value of the type field of the ICMP timestamp query message is 13, and the value of the code field is 10;
[0161] The value of the type field of the ICMP echo message is 14, and the value of the code field is 10.
[0162] It should be noted that the above local timestamp determination module 801, sending module 802, receiving module 803, received timestamp determination module 804, and absolute timestamp determination module 805 can be implemented by a processor, or implemented by a processor in cooperation with a memory, or the processor executes program instructions in the memory to implement.
[0163] It should also be noted that when the device for obtaining the absolute timestamp provided in the above embodiments obtains the absolute timestamp, only the above division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the server is divided into different functional modules to complete all or part of the functions described above. In addition, the device for obtaining the absolute timestamp provided in the above embodiments and the method embodiments for obtaining the absolute timestamp belong to the same concept, and the specific implementation process is detailed in the method embodiments and will not be elaborated here.
[0164] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the device, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer instructions can be stored in a computer-readable storage medium. The computer-readable storage medium can be any available medium that the device can access or a data storage device integrating one or more available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, and a magnetic tape, etc.), an optical medium (such as a digital video disk (DVD), etc.), or a semiconductor medium (such as a solid-state drive, etc.).
[0165] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disk, etc.
[0166] The embodiment of the present application also provides a service system. The service system includes a server and at least one GPS time service device. When an application task executed on the server needs to obtain the absolute timestamp at the first moment, the server determines the local timestamp at the first moment, sends a timestamp request message to the GPS time service device, and determines the sending timestamp T1 of the timestamp request message. The GPS time service device determines the receiving timestamp T2 of the timestamp request message and sends a timestamp response message to the server. The timestamp response message carries the receiving timestamp T2 of the timestamp request message on the GPS time service device and the sending timestamp T3 of the GPS time service device when sending the timestamp response message. Then, the server determines the receiving timestamp T4 of the timestamp response message and determines the absolute timestamp of the application task at the first moment based on T0, T1, T2, T3, and T4.
[0167] In a possible implementation, the service system is provided with a primary GPS time service device and a backup GPS time service device.
[0168] In a possible implementation, when the GPS time service device is the primary GPS time service device of the service system, sending a timestamp request message to the GPS time service device includes:
[0169] Sending a timestamp request message to the primary GPS time service device.
[0170] In a possible implementation, the GPS time synchronization device is a backup GPS time synchronization device for the service system. Sending a timestamp request message to the GPS time synchronization device includes:
[0171] If a timestamp request message is sent to the primary GPS time synchronization device and no timestamp response message is received from the primary GPS time synchronization device within a set duration, then a timestamp request message is sent to the backup GPS time synchronization device.
[0172] In a possible implementation, based on T0, T1, T2, T3, and T4, determining the absolute timestamp of the application task at the first moment includes:
[0173] Determine the value of T3 – ((T2 - T1) - (T4 - T3)) / 2 - T0 as the absolute timestamp of the application task at the first moment.
[0174] In a possible implementation, T1 is also carried in the timestamp request message and the timestamp response message.
[0175] In a possible implementation, the time precision of T0, T1, T2, T3, and T4 is nanosecond-level precision.
[0176] In a possible implementation, the GPS time synchronization device is connected in parallel to the core switch of the service system, or the GPS time synchronization device is connected in parallel to the server of the service system.
[0177] In a possible implementation, the timestamp request message is an Internet Control Message Protocol (ICMP) timestamp query message, and the timestamp response message is an ICMP echo message.
[0178] In a possible implementation, the value of the type field of the ICMP timestamp query message is 13, and the value of the code field is 10;
[0179] The value of the type field of the ICMP echo message is 14, and the value of the code field is 10.
[0180] The embodiment of the present application also provides a distributed system, and this distributed system includes multiple service systems described above.
[0181] The above are only the embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included within the protection scope of the present application.
Claims
1. A method for obtaining an absolute timestamp, characterized in that, it includes: When an application task executed on a server in a service system needs to obtain an absolute timestamp at a first moment, the server determines the local timestamp T0 at the first moment; The server sends a timestamp request message to the GPS time service device of the service system, and the timestamp request message carries the sending timestamp T1 of the timestamp request message; The server receives a timestamp response message sent by the GPS time service device to the server, and the timestamp response message carries the T1, the reception timestamp T2 of the timestamp request message on the GPS time service device, and the sending timestamp T3 of the GPS time service device sending the timestamp response message; The server determines the reception timestamp T4 of the timestamp response message; The server determines the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4; Wherein, the timestamp request message is an ICMP timestamp query message of the Network Control Message Protocol, the timestamp response message is an ICMP echo message, and the ICMP timestamp query message and the ICMP echo message respectively further carry the IP address of the server and the IP address of the GPS time service device.
2. The method according to claim 1, characterized in that, The service system is provided with a primary GPS time service device and a backup GPS time service device.
3. The method according to claim 2, characterized in that, The GPS time service device is the primary GPS time service device of the service system, and the server sending a timestamp request message to the GPS time service device of the service system includes: The server sends the timestamp request message to the primary GPS time service device.
4. The method according to claim 2, characterized in that, The GPS time service device is the backup GPS time service device of the service system, and the server sending a timestamp request message to the GPS time service device of the service system includes: If the server sends a timestamp request message to the primary GPS time service device and does not receive a timestamp response message sent by the primary GPS time service device within a set duration, then sends the timestamp request message to the backup GPS time service device.
5. The method according to any one of claims 1-4, characterized in that, The server determining the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4 includes: The server determines that the value of T3–((T2-T1)-(T4-T3)) / 2-T0 is the absolute timestamp of the application task at the first moment.
6. The method according to claim 1, characterized in that, The time precision of the T0, the T1, the T2, the T3, and the T4 is nanosecond-level precision.
7. A device for obtaining an absolute timestamp, characterized in that, it includes: A local timestamp determination module, configured to determine the local timestamp T0 of the first moment when an application task executed on the server needs to obtain the absolute timestamp of the first moment; A sending module, configured to send a timestamp request message to a GPS time service device of the service system where the device is located, where the timestamp request message carries the sending timestamp T1 of the timestamp request message; A receiving module, configured to receive a timestamp response message sent by the GPS time service device, where the timestamp response message carries the T1, the receiving timestamp T2 of the timestamp request message on the GPS time service device, and the sending timestamp T3 of the GPS time service device for sending the timestamp response message; A received timestamp determination module, configured to determine the received timestamp T4 of the timestamp response message; An absolute timestamp determination module, configured to determine the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4; Wherein, the timestamp request message is an ICMP timestamp query message of the network control message protocol, the timestamp response message is an ICMP echo message, and the ICMP timestamp query message and the ICMP echo message respectively further carry the IP address of the server and the IP address of the GPS time service device.
8. The device according to claim 7, wherein, The service system is provided with a primary GPS time service device and a standby GPS time service device.
9. The device according to claim 8, wherein, The GPS time service device is the primary GPS time service device of the service system, and the sending module is configured to: Send the timestamp request message to the primary GPS time service device.
10. The device according to claim 8, wherein, The GPS time service device is the standby GPS time service device of the service system, and the sending module is configured to: If a timestamp request message is sent to the primary GPS time service device and a timestamp response message sent by the primary GPS time service device is not received within a set duration, then send the timestamp request message to the standby GPS time service device.
11. The device according to any one of claims 7-10, wherein, The absolute timestamp determination module is configured to: Determine that the value of T3–((T2-T1)-(T4-T3)) / 2-T0 is the absolute timestamp of the application task at the first moment.
12. The device according to claim 7, wherein, The time precision of the T0, the T1, the T2, the T3, and the T4 is nanosecond-level precision.
13. A service system, wherein, The service system includes a server and a GPS time service device, wherein, The server is configured to determine the local timestamp T0 of the first moment when an application task executed on the server needs to obtain the absolute timestamp of the first moment; The server is further configured to send a timestamp request message to the GPS time synchronization device, where the timestamp request message carries the sending timestamp T1 of the timestamp request message; The GPS time synchronization device is configured to determine the receiving timestamp T2 of the timestamp request message and send a timestamp response message to the server, where the timestamp response message carries the T1, the receiving timestamp T2 of the timestamp request message on the GPS time synchronization device, and the sending timestamp T3 of the timestamp response message; The server is further configured to determine the receiving timestamp T4 of the timestamp response message; The server is further configured to determine the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4; Wherein, the timestamp request message is an Internet Control Message Protocol (ICMP) timestamp query message, the timestamp response message is an ICMP echo message, and the ICMP timestamp query message and the ICMP echo message respectively further carry the IP address of the server and the IP address of the GPS time synchronization device.
14. The service system according to claim 13, wherein, The service system is provided with a primary GPS time synchronization device and a standby GPS time synchronization device.
15. The service system according to claim 14, wherein, The GPS time synchronization device is the primary GPS time synchronization device of the service system, and the sending the timestamp request message to the GPS time synchronization device includes: Sending the timestamp request message to the primary GPS time synchronization device.
16. The service system according to claim 14, wherein, The GPS time synchronization device is the standby GPS time synchronization device of the service system, and the sending the timestamp request message to the GPS time synchronization device includes: If a timestamp request message is sent to the primary GPS time synchronization device and a timestamp response message sent by the primary GPS time synchronization device is not received within a set duration, then sending the timestamp request message to the standby GPS time synchronization device.
17. The service system according to any one of claims 13-16, wherein, The determining the absolute timestamp of the application task at the first moment based on the T0, the T1, the T2, the T3, and the T4 includes: Determining that the value of T3–((T2-T1)-(T4-T3)) / 2-T0 is the absolute timestamp of the application task at the first moment.
18. The service system according to claim 13, wherein, The time precision of the T0, the T1, the T2, the T3, and the T4 is nanosecond-level precision.
19. A distributed system, wherein, The distributed system includes a plurality of service systems according to any one of claims 13-18.
20. A server, wherein, The server includes a processor and a memory; The memory stores one or more programs, and the one or more programs are configured to be executed by the processor for implementing the method for obtaining an absolute timestamp as described in any one of claims 1-6.
21. A computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, and when the computer instructions run on a device, the device is caused to execute the method for obtaining an absolute timestamp as described in any one of claims 1-6.
Citation Information
Patent Citations
Distributed network clock synchronization method
CN108650050A