Method and device for synchronizing clock

By setting the NTP assembly package in the extension field of the transmission protocol, the client and the server complete clock synchronization within one transaction cycle, solving the problem of time difference between the mobile terminal and the server and improving the efficiency and accuracy of clock synchronization.

CN118523864BActive Publication Date: 2024-12-10HANGZHOU AKEY ME CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410762379.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-12-10
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

The time difference between mobile terminals and IoT devices and servers causes client applications to fail to obtain accurate time, affecting the efficiency of clock synchronization.

Method used

By setting the Network Time Protocol (NTP) assembly package in the extended field of the transmission protocol, the client sends a service request to the server, parses the NTP response in the response, and generates clock information to achieve the service request and NTP simultaneously within a transaction cycle. Response to requests reduces network communication times and improves the efficiency of synchronizing server clocks.

Benefits of technology

Improve the efficiency and accuracy of synchronous server clocks, reduce the number of network communications, and improve communication efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118523864B_ABST
    Figure CN118523864B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of computer technology, and in particular to a method and device for synchronizing clocks. The present disclosure includes a client sending a service request to a server, and the service request sets a network time protocol assembly package in an extended field of a transmission protocol, and the assembly package includes a network time protocol request and a network time protocol attribute identifier; the service result is parsed based on the service response, and clock information is generated based on the network time protocol response; when the server includes a network time protocol attribute identifier in the service request, a network time protocol response is generated based on the network time protocol request, and a service response is generated based on the service request, and the service response sets a network time protocol response in an extended field of the transmission protocol, and returns the service response to the client. The present disclosure implements the simultaneous completion of responses to service requests and network time protocol requests within a transaction cycle, reduces the number of network communications, improves communication efficiency, and thus improves the efficiency of synchronizing server clocks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for synchronizing clocks. Background Art

[0002] Clock synchronization refers to synchronizing the time between two nodes in the network to eliminate the time difference. Mobile terminals or IoT embedded device terminals are prone to time differences with the server, resulting in the client application being unable to obtain accurate time. Summary of the invention

[0003] In view of this, the present disclosure provides a method, apparatus, computer device, storage medium and program product for synchronizing a clock to solve the problem of how to accurately synchronize a server clock.

[0004] In a first aspect, the present disclosure provides a method for synchronizing clocks, the method comprising: sending a service request to a server, the service request setting a network time protocol assembly package in an extended field of a transmission protocol, the assembly package comprising a network time protocol request and a network time protocol attribute identifier; parsing a service result based on a service response returned by the server, and generating clock information based on a network time protocol response set in an extended field of the transmission protocol based on the service response, the service response being generated by the server based on the service request, and the network time protocol response being generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request.

[0005] The method for synchronizing clocks in this embodiment firstly sets a network time protocol assembly package including a network time protocol request and a network time protocol attribute identifier in an extended field of a transmission protocol through a service request of a client, assembles the network time protocol request into the service request, and sends the service request to a server; thereafter, the client receives a service response from the server, parses the service result based on the service response returned by the server, and generates clock information based on a network time protocol response set in an extended field of the transmission protocol in the service response, wherein the service response is generated by the server based on the service request, and the network time protocol response is generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request, thereby achieving the simultaneous completion of responses to the service request and the network time protocol request within one transaction cycle, reducing the number of network communications, improving communication efficiency, and thus improving the efficiency of synchronizing the server clock.

[0006] In a second aspect, the present disclosure provides a method for synchronizing clocks, the method comprising: receiving a service request sent by a client, the service request setting a network time protocol assembly package in an extended field of a transmission protocol, the assembly package comprising a network time protocol request and a network time protocol attribute identifier; when the service request includes a network time protocol attribute identifier, generating a network time protocol response based on the network time protocol request, generating a service response based on the service request, the service response setting a network time protocol response in an extended field of a transmission protocol, returning the service response to the client so that the client parses the service result based on the service response, and generating clock information based on the network time protocol response.

[0007] In a third aspect, the present disclosure provides a device for synchronizing a clock, the device comprising: a request sending module, used to send a service request to a server, the service request sets a network time protocol assembly package in an extended field of a transmission protocol, the assembly package comprising a network time protocol request and a network time protocol attribute identifier; a response parsing module, used to parse a service result based on a service response returned by the server, and to generate clock information based on the network time protocol response set in an extended field of the transmission protocol by the service response, the service response being generated by the server based on the service request when the network time protocol attribute identifier is included in the service request, and the network time protocol response being generated by the server based on the network time protocol request.

[0008] In a fourth aspect, the present disclosure provides a device for synchronizing a clock, the device comprising: a request receiving module, used to receive a service request sent by a client, the service request setting a network time protocol assembly package in an extended field of a transmission protocol, the assembly package comprising a network time protocol request and a network time protocol attribute identifier; a response returning module, used to generate the network time protocol response based on the network time protocol request when the network time protocol attribute identifier is included in the service request, generate the service response based on the service request, the service response setting the network time protocol response in an extended field of the transmission protocol, return the service response to the client, so that the client parses the service result based on the service response, and generates clock information based on the network time protocol response.

[0009] In a fifth aspect, the present disclosure provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the method for synchronizing a clock of the first aspect or the method for synchronizing a clock of the second aspect by executing the computer instructions.

[0010] In a sixth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for synchronizing a clock of the first aspect or the method for synchronizing a clock of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 is a system architecture diagram of a method for synchronizing clocks according to an embodiment of the present disclosure;

[0013] Figure 2 is a flowchart of a method for synchronizing clocks according to an embodiment of the present disclosure;

[0014] Figure 3 is a flowchart of another method for synchronizing clocks according to an embodiment of the present disclosure;

[0015] Figure 4 is a flowchart of another method for synchronizing clocks according to an embodiment of the present disclosure;

[0016] Figure 5 is a structural block diagram of a device for synchronizing clocks according to an embodiment of the present disclosure;

[0017] Figure 6 is a structural block diagram of a device for synchronizing clocks according to an embodiment of the present disclosure;

[0018] Figure 7 It is a schematic diagram of the hardware structure of the computer device of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0020] According to an embodiment of the present disclosure, an embodiment of a method for synchronizing a clock is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0021] In this embodiment, a method for synchronizing clocks is provided, which can be used in a computer system architecture.

[0022] Figure 1 The example shown in Figure 1 An exemplary system architecture to which the method for synchronizing clocks of the present application can be applied is shown. Figure 1 As shown, the system architecture may include more than one client 101 , and the client is connected to the server 102 via a gateway.

[0023] It should be noted that the method for synchronizing clocks provided in the embodiment of the present application can be performed by the client 101 and / or the server 102. The server 102 can be hardware or software. When the server 102 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server 102 is software, it can be implemented as multiple software or software modules, or it can be implemented as a single software or software module. No specific limitation is made here.

[0024] It should be understood that Figure 1 The number of clients 101, gateways, and servers 102 in the embodiment is only for illustration. According to the implementation requirements, there may be any number of clients 101, gateways, and servers 102. The client 101 may be a desktop computer, a laptop computer, or a mobile terminal such as a mobile phone or a tablet computer.

[0025] Specifically, see Figure 2 , Figure 2 is a flowchart of a method for synchronizing clocks according to an embodiment of the present disclosure, such as Figure 2 As shown, the process includes the following steps:

[0026] Step S201: The client sends a service request to the server. The service request sets a network time protocol assembly package in an extension field of the transmission protocol. The assembly package includes a network time protocol request and a network time protocol attribute identifier.

[0027] In this embodiment, the client may be a terminal device that provides services to clients, such as a desktop computer, a tablet computer, or a mobile terminal in the above-mentioned computer system. When the client sends a service request to the server, it usually uses a certain application layer transmission protocol to ensure reliable data transmission or meet specific requirements (such as real-time, low latency, etc.).

[0028] Typically, a service request contains multiple fields, among which the extended field is used to carry additional information or data to meet specific application requirements. When a client sends a service request to a server, it can set a Network Time Protocol (NTP) assembly packet in the extended field of the transport protocol, and set a Network Time Protocol request and a Network Time Protocol attribute identifier in the assembly packet.

[0029] Furthermore, the service request includes an NTP attribute identifier to inform the server that, in addition to the service data, the client also needs to synchronize the network time.

[0030] Step S202: When the service request includes a network time protocol attribute identifier, the server generates a network time protocol response based on the network time protocol request, generates a service response based on the service request, and returns the service response to the client.

[0031] In this embodiment, after receiving the service request containing the NTP attribute identifier, the server can obtain accurate time according to the relevant operations of the NTP protocol. For example, the accurate time source can be obtained through an atomic clock, an observatory, a satellite, or other NTP servers on the Internet.

[0032] Specifically, the server can calculate the time difference (Offset) between it and the client according to the working principle of NTP, and prepare an NTP response message. The response message usually includes four timestamps: T1 (the time when the client sends the request), T2 (the time when the server receives the request, that is, the time when the request actually arrives at the server), T3 (the time when the server sends the response), and T4 (the time when the client receives the response).

[0033] Specifically, the service response sets the network time protocol response in the extension field of the transport protocol. The server can embed the relevant information of the NTP response (such as timestamp, time difference, etc.) into a field (such as an extension field or a custom header) of the transport protocol used by the service response, and send the combined service response to the client.

[0034] Step S203: the client parses the service result based on the service response and generates clock information based on the network time protocol response.

[0035] In this embodiment, after receiving the service response, the client can parse the service result from the service response, extract the relevant information of the NTP response from the extended field or custom header of the transmission protocol adopted by the service response, and perform data processing to synchronize the local time.

[0036] The method for synchronizing clocks provided in this embodiment sets a network time protocol assembly package including a network time protocol request and a network time protocol attribute identifier in an extended field of a transmission protocol through a client's service request, and assembles the network time protocol request into the service request; then, when the server detects that the service request includes a network time protocol attribute identifier, it generates a network time protocol response, assembles it into the service response through an extended field of the transmission protocol, and returns the service response to the client; then, the client parses the service result and generates clock information based on the network time protocol response, thereby achieving the response to the service request and the network time protocol request within one transaction cycle, reducing the number of network communications, improving communication efficiency, and thus improving the efficiency of synchronizing the server clock.

[0037] In some optional implementations of the present embodiment, the business request to set the network time protocol assembly package in the extended field of the transmission protocol can be implemented by any of the following: the business request to set the network time protocol assembly package in the user attributes of the message queue telemetry transmission protocol; the business request to set the network time protocol assembly package in the header of the hypertext transfer protocol; the business request to set the network time protocol assembly package in the extended content of the secure transport layer protocol.

[0038] In this implementation, the client can set the NTP assembly package through the user properties of the CONNECT message of the Message Queuing Telemetry Transport (MQTT), for example, the content of the variable named clientSendTs is the time when the client sends the request. In other specific examples, the client can set the NTP assembly package through the request header of the Hypertext Transfer Protocol (Http); or, it can also transmit the service request through the extension of the Transport Layer Security (TLS) protocol.

[0039] This implementation method clarifies the method of setting the network time protocol assembly packet in the extended field of the transmission protocol for the business request, so that it can respond to both the business request and the network time protocol request within one transaction cycle, reducing the number of network communications, improving communication efficiency, and thus improving the efficiency of synchronizing the server clock.

[0040] In some optional implementations of the present embodiment, the assembly package in the above embodiment also includes: expected arrival time at the server, which is the sum of the time when the client sends the request and the predicted network delay; and generating a network time protocol response based on the network time protocol request in step S202 in the above embodiment may include: step S2021, generating a network jitter error based on the actual arrival time of the network time protocol request at the server and the expected arrival time at the server; and step S2022, generating a network time protocol response based on the network jitter error.

[0041] In this implementation, in order to determine the network jitter error, after the client obtains the result of the first NTP calculation, it can carry the expected arrival time of the server additionally when submitting it to the server next time based on the derived current network delay value. After receiving the message, the server uses the actual arrival time of the server minus the expected arrival time of the server to obtain the network jitter error. Then, according to the specific situation of the network jitter error, a network time protocol response is generated and returned to the client.

[0042] In some specific examples, the server generates a network time protocol response based on a network jitter error, which may include: identifying the network jitter error in a variable of the network time protocol response when generating the network time protocol response; and the client generates clock information based on the network time protocol response, including: calculating the network time protocol time based on the network time protocol response; and generating clock information by subtracting the network jitter error from the network time protocol time.

[0043] Among them, based on the network time protocol response, the NTP time can be calculated by using the four timestamps of the response message based on the following formula: NTP time = (T2+T3+T4-T1) / 2. The clock information can be obtained by subtracting the network jitter error from the NTP time.

[0044] In some specific examples, generating a network time protocol response based on a network jitter error may include: when the network jitter error is less than an error threshold, not identifying the network jitter error in the network time protocol response.

[0045] The method for generating a network time protocol response based on a network time protocol request in this implementation can generate a network jitter error based on the actual arrival time and expected arrival time of the network time protocol request on the server, and generate an NTP response based on the network jitter error and return it to the client, thereby improving the accuracy of the server clock synchronized by the client.

[0046] In some optional implementations of this embodiment, the above-mentioned predicted network delay is determined based on the following steps: the time when the server receives the service request in the last network time protocol response is subtracted from the time when the client sent the request last time, to obtain the server reception delay duration; the local time when the service response was last received is subtracted from the time when the server returns the service response in the last network time protocol response, to obtain the client reception delay duration; the average of the server reception delay duration and the client reception delay duration is used as the predicted network delay.

[0047] The step of determining the network delay in this implementation method clearly defines the average of the server reception delay duration and the client reception delay duration as the predicted network delay, thereby improving the accuracy of determining the expected arrival time at the server, and further improving the accuracy of generating network jitter errors, and improving the information dimension of the network time protocol response, thereby improving the accuracy of the clock information generated by the client.

[0048] In this embodiment, another method for synchronizing clocks is provided, which can be used as follows: Figure 1 In the client of the computer system architecture shown in FIG. Figure 3 , Figure 3 is a flowchart of a method for synchronizing clocks according to an embodiment of the present disclosure, such as Figure 3 As shown, the process includes the following steps:

[0049] Step S301, sending a service request to a server, wherein the service request sets a network time protocol assembly packet in an extension field of a transmission protocol.

[0050] The assembly package includes a network time protocol request and a network time protocol attribute identifier.

[0051] For details, please see Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.

[0052] Step S302: Parse the service result based on the service response returned by the server, and generate clock information based on the network time protocol response set in the extended field of the transmission protocol of the service response.

[0053] The service response is generated by the server based on the service request, and the network time protocol response is generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request.

[0054] For details, please see Figure 2 Step S203 of the illustrated embodiment will not be described in detail here.

[0055] The method for synchronizing clocks in this embodiment firstly sets a network time protocol assembly package including a network time protocol request and a network time protocol attribute identifier in an extended field of a transmission protocol through a service request of a client, assembles the network time protocol request into the service request, and sends the service request to a server; thereafter, the client receives a service response from the server, parses the service result based on the service response returned by the server, and generates clock information based on a network time protocol response set in an extended field of the transmission protocol in the service response, wherein the service response is generated by the server based on the service request, and the network time protocol response is generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request, thereby achieving the simultaneous completion of responses to the service request and the network time protocol request within one transaction cycle, reducing the number of network communications, improving communication efficiency, and thus improving the efficiency of synchronizing the server clock.

[0056] In some optional implementations of the present embodiment, in some optional implementation modes, the business request to set the network time protocol assembly package in the extended field of the transmission protocol can be implemented by any of the following: the business request to set the network time protocol assembly package in the user attributes of the message queue telemetry transmission protocol; the business request to set the network time protocol assembly package in the header of the hypertext transfer protocol; the business request to set the network time protocol assembly package in the extended content of the secure transport layer protocol.

[0057] In some optional embodiments, the assembly package also includes: expected arrival time at the server, which is the sum of the time when the client sends the request and the predicted network delay; a network time protocol response is generated by the server based on the network time protocol request and the network jitter error, and the network jitter error is generated by the server based on the actual arrival time at the server and the expected arrival time at the server.

[0058] In some optional embodiments, a network jitter error is identified in a variable of a network time protocol response; and based on the network time protocol response, generating clock information includes: generating a network time protocol time based on the network time protocol response; and generating clock information by subtracting the network jitter error from the network time protocol time.

[0059] In some optional embodiments, the predicted network delay is determined based on the following steps: the server reception delay is obtained by subtracting the time when the client last sent a request from the time when the server received the service request in the last network time protocol response; the client reception delay is obtained by subtracting the time when the server returned the service response in the last network time protocol response from the local time when the service response was last received; and the average of the server reception delay and the client reception delay is used as the predicted network delay.

[0060] In this embodiment, another method for synchronizing clocks is provided, which can be used as follows: Figure 1 In the client of the computer system architecture shown in FIG. Figure 4 , Figure 4 is a flowchart of a method for synchronizing clocks according to an embodiment of the present disclosure, such as Figure 4 As shown, the process includes the following steps:

[0061] Step S401: receiving a service request sent by a client.

[0062] The service request sets a network time protocol assembly packet in an extension field of the transmission protocol, and the assembly packet includes a network time protocol request and a network time protocol attribute identifier.

[0063] For details on the service request sent by the client, see Figure 2 Step S201 of the illustrated embodiment will not be described in detail here.

[0064] Step S402: When the service request includes a network time protocol attribute identifier, a network time protocol response is generated based on the network time protocol request.

[0065] Step S403: Generate a service response based on the service request, and set a network time protocol response in an extension field of the transmission protocol.

[0066] Step S404: Return a service response to the client, so that the client can parse the service result based on the service response and generate clock information based on the network time protocol response.

[0067] The service response is generated by the server based on the service request, and the network time protocol response is generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request.

[0068] For details of the above steps S402, S403 and S404, please refer to Figure 2 Step S202 of the illustrated embodiment will not be described in detail here.

[0069] The method for synchronizing clocks in this embodiment sets a network time protocol assembly package including a network time protocol request and a network time protocol attribute identifier in an extended field of a transmission protocol through a client's service request, and assembles the network time protocol request into the service request; then, when the server detects that the service request includes a network time protocol attribute identifier, it generates a network time protocol response, assembles it into the service response through an extended field of the transmission protocol, and returns the service response to the client; then, the client parses the service result and generates clock information based on the network time protocol response, thereby achieving the response to the service request and the network time protocol request within one transaction cycle, reducing the number of network communications, improving communication efficiency, and thus improving the efficiency of synchronizing the server clock.

[0070] In some optional implementations, the business request to set the network time protocol assembly package in the extended field of the transmission protocol can be implemented by any of the following: the business request to set the network time protocol assembly package in the user attributes of the message queue telemetry transmission protocol; the business request to set the network time protocol assembly package in the header of the hypertext transfer protocol; the business request to set the network time protocol assembly package in the extended content of the secure transport layer protocol.

[0071] In some optional embodiments, the assembly package also includes: expected arrival time at the server, which is the sum of the time when the client sends the request and the predicted network delay; generating a network time protocol response based on the network time protocol request, including: generating a network jitter error based on the actual arrival time at the server and the expected arrival time at the server of the network time protocol request; generating a network time protocol response based on the network jitter error.

[0072] In some optional embodiments, generating a network time protocol response based on a network jitter error includes: identifying the network jitter error in a variable of the network time protocol response when generating the network time protocol response; and returning a business response to the client so that the client parses the business result based on the business response, and generating clock information based on the network time protocol response includes: returning a business response to the client so that the client generates a network time protocol time based on the network time protocol response; and generating clock information by subtracting the network jitter error from the network time protocol time.

[0073] In some optional implementations, generating a network time protocol response based on a network jitter error includes: when the network jitter error is less than an error threshold, not identifying the network jitter error in the network time protocol response.

[0074] In some optional embodiments, the predicted network delay is determined based on the following steps: the server reception delay is obtained by subtracting the time when the client last sent a request from the time when the server received the service request in the last network time protocol response; the client reception delay is obtained by subtracting the time when the server returned the service response in the last network time protocol response from the local time when the service response was last received; and the average of the server reception delay and the client reception delay is used as the predicted network delay.

[0075] In the present embodiment, a device for synchronizing clocks is also provided, and the device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made are not repeated here. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0076] This embodiment provides a device for synchronizing clocks, such as Figure 5 As shown, including:

[0077] The request sending module 501 is used to send a service request to the server. The service request sets a network time protocol assembly package in the extension field of the transmission protocol. The assembly package includes a network time protocol request and a network time protocol attribute identifier.

[0078] The response parsing module 502 is used to parse the business results based on the business response returned by the server, and generate clock information based on the network time protocol response set in the extended field of the transmission protocol of the business response. The business response is generated by the server based on the business request when the network time protocol attribute identifier is included in the business request. The network time protocol response is generated by the server based on the network time protocol request.

[0079] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0080] This embodiment also provides another device for synchronizing clocks, such as Figure 6 As shown, including:

[0081] The request receiving module 601 is used to receive a service request sent by a client. The service request sets a network time protocol assembly package in an extension field of a transmission protocol. The assembly package includes a network time protocol request and a network time protocol attribute identifier.

[0082] The response returning module 602 is used to generate a network time protocol response based on the network time protocol request when the network time protocol attribute identifier is included in the business request, generate a business response based on the business request, set the network time protocol response in the extended field of the transmission protocol of the business response, return the business response to the client so that the client can parse the business result based on the business response, and generate clock information based on the network time protocol response.

[0083] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0084] The clock synchronization device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0085] See also Figure 7 , Figure 7 1 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present disclosure, and the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system).

[0086] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0087] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0088] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0089] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0090] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0091] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for synchronizing a clock, characterized in that: The method comprises: Sending a service request to a server, wherein the service request sets a network time protocol assembly package in an extension field of a transmission protocol, wherein the assembly package includes a network time protocol request and a network time protocol attribute identifier; the assembly package also includes: an expected arrival time at the server, wherein the expected arrival time at the server is the sum of the time when the client sends the request and the predicted network delay; The clock information is generated based on the service result parsed based on the service response returned by the server, and based on the network time protocol response set in the extension field of the transmission protocol of the service response, wherein the service response is generated by the server based on the service request, and the network time protocol response is generated by the server based on the network time protocol request when the network time protocol attribute identifier is included in the service request; the network time protocol response is generated by the server based on the network time protocol request and the network jitter error, and the network jitter error is generated by the server based on the actual arrival time at the server and the expected arrival time at the server.

2. The method according to claim 1, characterized in that: The service request sets the network time protocol assembly packet in the extension field of the transmission protocol, which can be implemented by any of the following methods: The service request sets a network time protocol assembly packet in a user attribute of a message queue telemetry transmission protocol; The service request sets a network time protocol assembly packet in the header of the hypertext transfer protocol; The service request sets a network time protocol assembly packet in the extended content of the secure transport layer protocol.

3. The method according to claim 1, characterized in that The network jitter error is identified in a variable of the network time protocol response; as well as The generating clock information based on the network time protocol response includes: generating network time protocol time based on the network time protocol response; The network jitter error is subtracted from the network time protocol time to generate clock information.

4. The method according to claim 1, characterized in that: The predicted network delay is determined based on the following steps: The server receiving delay is obtained by subtracting the time when the client last sent a request from the time when the server received the service request in the last network time protocol response. The client receiving delay duration is obtained by subtracting the time when the server returns the service response in the last network time protocol response from the local time when the service response was last received; The average value of the server reception delay duration and the client reception delay duration is used as the predicted network delay.

5. A method for synchronizing a clock, characterized in that: The method comprises: Receive a service request sent by a client, wherein the service request sets a network time protocol assembly packet in an extension field of a transmission protocol, wherein the assembly packet includes a network time protocol request and a network time protocol attribute identifier; the assembly packet also includes: an expected arrival time at a server, wherein the expected arrival time at a server is the sum of a time when the client sends the request and a predicted network delay; When the service request includes a network time protocol attribute identifier, a network time protocol response is generated based on the network time protocol request, a service response is generated based on the service request, the service response sets the network time protocol response in an extended field of a transmission protocol, and the service response is returned to the client so that the client parses the service result based on the service response, and generates clock information based on the network time protocol response; the generating of the network time protocol response based on the network time protocol request includes: generating a network jitter error based on the actual arrival time of the network time protocol request at the server and the expected arrival time at the server; and generating the network time protocol response based on the network jitter error.

6. The method according to claim 5, characterized in that The service request sets the network time protocol assembly packet in the extension field of the transmission protocol, which can be implemented by any of the following methods: The service request sets a network time protocol assembly packet in a user attribute of a message queue telemetry transmission protocol; The service request sets a network time protocol assembly packet in the header of the hypertext transfer protocol; The service request sets a network time protocol assembly packet in the extended content of the secure transport layer protocol.

7. The method according to claim 5, characterized in that The generating the network time protocol response based on the network jitter error comprises: When generating a network time protocol response, identifying the network jitter error in a variable of the network time protocol response; and The returning the service response to the client so that the client can parse the service result based on the service response, and generating the clock information based on the network time protocol response includes: returning the service response to the client so that the client can generate the network time protocol time based on the network time protocol response; and generating the clock information by subtracting the network jitter error from the network time protocol time.

8. The method according to claim 5, characterized in that The generating the network time protocol response based on the network jitter error comprises: When the network jitter error is less than an error threshold, the network jitter error is not identified in the network time protocol response.

9. The method according to claim 5, characterized in that The predicted network delay is determined based on the following steps: The server receiving delay is obtained by subtracting the time when the client last sent a request from the time when the server received the service request in the last network time protocol response. The client receiving delay duration is obtained by subtracting the time when the server returns the service response in the last network time protocol response from the local time when the service response was last received; The average value of the server reception delay duration and the client reception delay duration is used as the predicted network delay.

10. A device for synchronizing a clock, characterized in that: The device comprises: A request sending module is used to send a service request to a server, wherein the service request sets a network time protocol assembly package in an extension field of a transmission protocol, wherein the assembly package includes a network time protocol request and a network time protocol attribute identifier; the assembly package also includes: an expected arrival time at the server, wherein the expected arrival time at the server is the sum of the time when the client sends the request and the predicted network delay; A response parsing module is used to parse the business result based on the business response returned by the server, and generate clock information based on the network time protocol response set in the extended field of the transmission protocol of the business response, wherein the business response is generated by the server based on the business request when the network time protocol attribute identifier is included in the business request, and the network time protocol response is generated by the server based on the network time protocol request; the network time protocol response is generated by the server based on the network time protocol request and the network jitter error, and the network jitter error is generated by the server based on the actual arrival time at the server and the expected arrival time at the server.

11. A device for synchronizing a clock, characterized in that: The device comprises: The request receiving module is used to receive a service request sent by a client, wherein the service request sets a network time protocol assembly package in an extension field of a transmission protocol, wherein the assembly package includes a network time protocol request and a network time protocol attribute identifier; the assembly package also includes: an expected arrival time at the server, wherein the expected arrival time at the server is the sum of the time when the client sends the request and the predicted network delay; A response returning module is used to generate a network time protocol response based on the network time protocol request when the service request includes a network time protocol attribute identifier, generate a service response based on the service request, the service response sets the network time protocol response in an extended field of a transmission protocol, return the service response to the client so that the client parses the service result based on the service response, and generate clock information based on the network time protocol response; the generating of the network time protocol response based on the network time protocol request includes: generating a network jitter error based on the actual arrival time of the network time protocol request at the server and the expected arrival time at the server; generating the network time protocol response based on the network jitter error.

12. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for synchronizing a clock as described in any one of claims 1 to 4, or executes the method for synchronizing a clock as described in any one of claims 5 to 9 by executing the computer instructions.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for synchronizing clocks according to any one of claims 1 to 4, or to execute the method for synchronizing clocks according to any one of claims 5 to 9.

Citation Information

Patent Citations

  • Wireless flow media key parameter statistics and method for improving transmission thereof

    CN101207506A

  • Network time protocol conversion method and system

    CN108667547A

  • Session message transmission method and device and electronic equipment

    CN111641691A

  • Communication method, system and device, computer storage medium and electronic device

    CN116346802A

  • Priority based selection of time services

    US20200287784A1