CN115941105A - Time synchronization method, device, storage medium and electronic equipment - Google Patents

Time synchronization method, device, storage medium and electronic equipment Download PDF

Info

Publication number
CN115941105A
CN115941105A CN202211569287.0A CN202211569287A CN115941105A CN 115941105 A CN115941105 A CN 115941105A CN 202211569287 A CN202211569287 A CN 202211569287A CN 115941105 A CN115941105 A CN 115941105A
Authority
CN
China
Prior art keywords
time
information
time information
server
client
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211569287.0A
Other languages
Chinese (zh)
Inventor
王红
温卓然
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202211569287.0A priority Critical patent/CN115941105A/en
Publication of CN115941105A publication Critical patent/CN115941105A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The embodiment of the disclosure provides a time synchronization method, a time synchronization device, a storage medium and an electronic device, wherein the method comprises the following steps: sending a time acquisition request to a server, and recording local first time information of a client when the time acquisition request is sent; receiving second time information from the server, and recording local third time information of the client when the second time information is received; determining the actual time length information of the first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is the time consumed by the server for sending the second time information to the client to receive the second time information; and determining the current time information on the server according to the actual time information of the first route and the second time information. The client can accurately know the current time on the server, time errors are reduced, and system performance is improved.

Description

Time synchronization method, device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of communications, and in particular, to a time synchronization method and apparatus, a storage medium, and an electronic device.
Background
In program development, processing regarding time is indispensable, and a problem that a client (or a browser) acquires server time often occurs in a B/S architecture (a browser and server architecture, a kind of software system architecture) or a C/S architecture (a client and server architecture, a kind of software system architecture). For example, the problem of displaying the server time is often encountered in the client software, and the way for the client software to obtain the server time is generally: the client sends a time acquisition request to the server and then directly uses the time value returned by the server, however, the time value is the time value when the server sends the time value, a large time delay exists, and a large error exists in the time value returned by the client directly using the server.
Disclosure of Invention
In view of this, the embodiments of the present disclosure provide a time synchronization method, a time synchronization apparatus, a storage medium, and an electronic device, so as to solve the following problems in the prior art: the time value received by the client is the time value when the server sends the time value, a large time delay exists, and a large error exists when the client directly uses the time value returned by the server.
In one aspect, an embodiment of the present disclosure provides a time synchronization method, including: sending a time acquisition request to a server, and recording local first time information of a client when the time acquisition request is sent; receiving second time information from a server, and recording local third time information of the client when the second time information is received; determining actual time length information of a first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is time consumed for the server to send the second time information to the client to receive the second time information; and determining the current time information on the server according to the actual time information of the first route and the second time information.
In some embodiments, the determining the actual duration information of the first journey according to the first time information, the second time information and the third time information includes: determining the relative duration information of the first distance according to the third time information and the second time information; determining relative duration information of all routes according to the first time information, the second time information and the third time information; determining a proportion value of the time occupied by the first journey in all the journeys according to the relative duration information of the first journey and the relative duration information of all the journeys; and determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all journeys locally determined by the client.
In some embodiments, the actual duration information of the first journey is determined according to the following formula:
Figure BDA0003985518800000021
and the TN is actual time length information of the first route, the T3 is the third time information, the T2 is the second time information, and the T1 is the first time information.
In some embodiments, after sending the time obtaining request to the server, the method further includes: detecting whether the current time information exists according to preset time; and sending the time acquisition request to the server under the condition that the current time information does not exist.
On the other hand, an embodiment of the present disclosure provides a time synchronization apparatus, including: the sending module is used for sending a time obtaining request to the server and recording local first time information of the client when the time obtaining request is sent; the receiving module is used for receiving second time information from the server and recording local third time information of the client when the second time information is received; a first determining module, configured to determine actual duration information of a first route according to the first time information, the second time information, and the third time information, where the actual duration information of the first route is time consumed by the server to send the second time information to the client and receive the second time information; and the second determining module is used for determining the current time information on the server according to the actual time length information of the first route and the second time information.
In some embodiments, the first determining module comprises: the first determining unit is used for determining the relative duration information of the first journey according to the third time information and the second time information; the second determining unit is used for determining the relative duration information of all routes according to the first time information, the second time information and the third time information; a third determining unit, configured to determine, according to the relative duration information of the first route and the relative duration information of all routes, a proportion value of time occupied by the first route in all routes; and the fourth determining unit is used for determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all the journeys locally determined by the client.
In some embodiments, the first determining module is specifically configured to determine the actual duration information of the first journey according to the following formula:
Figure BDA0003985518800000031
and the TN is actual time length information of the first route, the T3 is the third time information, the T2 is the second time information, and the T1 is the first time information.
In some embodiments, further comprising: the detection module is used for detecting whether the current time information exists or not according to preset time; the sending module is further configured to send the time obtaining request to the server under the condition that the current time information does not exist.
In another aspect, an embodiment of the present disclosure provides a storage medium storing a computer program, where the computer program is executed by a processor to implement the method provided in any embodiment of the present disclosure.
On the other hand, the embodiment of the present disclosure provides an electronic device, which at least includes a memory and a processor, where the memory stores a computer program, and the processor implements the method provided in any embodiment of the present disclosure when executing the computer program on the memory.
When the client side synchronizes the time data of the server, the time information is sent to the actual time length required by the client side by the server, and then the current real time on the server when the time information sent by the server is received is determined together with the actual time length information according to the time information sent by the server. According to the embodiment of the invention, time consumption in the information transmission process is considered, the time consumed in the transmission process is calculated through the three time information, and then the client can know the current time on the server accurately, so that the time error is reduced, and the system performance is improved.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a time synchronization method according to a first embodiment of the disclosure;
fig. 2 is a schematic diagram of a time synchronization interaction process provided in a first embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a time synchronization apparatus according to a second embodiment of the disclosure;
fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described below clearly and completely with reference to the accompanying drawings of the embodiments of the present disclosure. It is to be understood that the described embodiments are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the described embodiments of the disclosure without any inventive step, are within the scope of protection of the disclosure.
Unless defined otherwise, technical or scientific terms used herein shall have the ordinary meaning as understood by one of ordinary skill in the art to which this disclosure belongs. The use of "first," "second," and the like in this disclosure is not intended to indicate any order, quantity, or importance, but rather is used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that the element or item listed before the word covers the element or item listed after the word and its equivalents, but does not exclude other elements or items. The terms "connected" or "coupled" and the like are not restricted to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", and the like are used merely to indicate relative positional relationships, and when the absolute position of the object being described is changed, the relative positional relationships may also be changed accordingly.
To maintain the following description of the embodiments of the present disclosure clear and concise, a detailed description of known functions and known components is omitted from the present disclosure.
In the B/S or C/S architecture, when the client (or browser) acquires the time of the server, there is a certain time when the data returned by the server is actually transmitted in the network, so that it is inaccurate that the client (or browser) directly uses the acquired time. In order to solve this problem, in the embodiment of the present disclosure, after the client (or the browser) acquires the time on the server, the client (or the browser) increases the time for transmitting the data sent from the server to the client (or the browser) in the network to obtain the current accurate time on the server when the client (or the browser) receives the time from the server.
A first embodiment of the present disclosure provides a time synchronization method, where the flow of the method is shown in fig. 1, and the method includes steps S101 to S104:
s101, sending a time obtaining request to a server, and recording local first time information of a client when the time obtaining request is sent.
The first time information is the local time of the client recorded by the client, and when the client sends a time obtaining request to the server, the time is recorded for use when the actual time length information of the first journey is calculated subsequently.
And S102, receiving the second time information from the server, and recording the local third time information of the client when the second time information is received.
The second time information is a response message after the server receives the time acquisition request, the server sends the second time information to the client, and the second time information is the time for sending the response message on the server. The third time information is the local time of the client recorded by the client, and when the client receives the second time information, the time is recorded for use in the subsequent calculation of the actual time length information of the first journey.
S103, determining the actual time length information of the first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is the time consumed by the server for sending the second time information to the client for receiving the second time information.
After the first time information, the second time information and the third time information are known, the distance time consumed when the server sends the second time information to the client and receives the second time information can be determined according to needs.
During implementation, firstly, determining the relative duration information of the first route according to the third time information and the second time information; secondly, determining relative duration information of all routes according to the first time information, the second time information and the third time information, namely calculating a time difference value between the first time information and the second time information, and then calculating a time difference value between the second time information and the third time information, wherein the calculation difference values are absolute values because the time information of the client is not determined to be faster than the time information on the server or slower than the time information on the server, and the calculated time length is one time length; then, determining the proportion value of the time occupied by the first route in all routes according to the relative duration information of the first route and the relative duration information of all routes; and finally, determining the actual time length information of the first journey according to the ratio value and the absolute time length information of all the journeys locally determined by the client. Specifically, the actual duration information of the first route may be determined according to the following formula:
Figure BDA0003985518800000051
the TN is actual time length information of the first route, the T3 is third time information, the T2 is second time information, and the T1 is first time information.
And S104, determining the current time information on the server according to the actual time information of the first route and the second time information.
When the client side synchronizes the time data of the server, the time information is sent to the actual time length required by the client side by the server, and then the current real time on the server when the time information sent by the server is received is determined together with the actual time length information according to the time information sent by the server. According to the embodiment of the invention, the time consumption in the information transmission process is considered, the time consumed in the transmission process is calculated through the three time information, and then the client can know the current time on the server accurately, so that the time error is reduced, and the system performance is improved.
After the client sends the time acquisition request to the server, the server may not receive the time acquisition request, or due to other network reasons, the client may not receive the current time information of the server, and therefore the client needs to detect whether the current time information exists according to preset time; if the current time information exists, the time synchronization of the client and the server is completed, and if the current time information does not exist, the time synchronization is not completed, and the client can send a time acquisition request to the server again to realize the time synchronization of the client and the server. After the time synchronization between the client and the server is completed, the obtained current time information may be sent to a display page for displaying, or the current time information may be used for other purposes, which is not described herein any more.
The following description is made in connection with the accompanying drawings and the specific examples.
The time synchronization method provided by the embodiment of the disclosure is applicable to time synchronization systems, including and not limited to systems of C/S architecture or B/S architecture.
The time synchronization method comprises the following steps, and the interaction process can be as shown in fig. 2:
201: the client sends a time acquisition request to the server, and the client records the client time when the time acquisition request is sent and determines the client time as first time, wherein the first time (namely first time information) is marked as T1.
202: the client receives time data (namely, second time information) generated by the server according to the time request, and sets the current time of the client when the client receives the time data as second time (namely, third time information), wherein the time data is marked as T2, and the second time is marked as T3. And determining the current time of the server when the client receives the time data as the target time (namely the current time information), and recording the target time as T4.
Because the server returns the time data generated after receiving the time request to the time of the client, the time of the client receiving the time data generates time delay in the network transmission process due to the information, therefore, T2 and T4 are different time points, and T2 and T4 have a time difference caused by the time delay.
203: according to the mathematical formula for calculating the delta T by the client, which is as follows, the time difference (namely the actual time length information of the first journey) from the time data sent by the server to the client after the time request is received by the server to the time data received by the client can be calculated, wherein the time difference is marked as delta T (namely TN). The current time of the server when the client receives the time data T4= T2+ Δ T.
Figure BDA0003985518800000071
204: and the client calibrates the time data T2 according to the time difference to obtain a target time T4. The target time T4 is displayed on a page or for other purposes.
According to the time synchronization method provided by the embodiment of the invention, the time delay time caused by network transmission and other factors of information is calculated through the time of the client when the client sends the time request, the time of the server when the server receives the time request and the time of the client receiving the data returned by the server, so that the time of the server when the client receives the data returned by the server is calculated, and the time of the client is calibrated.
If the time T1 of the client when the client sends the acquisition time request to the server is 1 hour, 20 minutes and 15 seconds, the time data T2 received by the client and generated according to the time request by the server is 1 hour, 20 minutes and 18 seconds, and the time T3 received by the client and generated according to the time request by the server is 1 hour, 20 minutes and 19 seconds. According to the formula, the time difference delta T from the time when the server receives the time request to the time when the client sends the time data to the time when the client receives the data is calculated as follows:
Figure BDA0003985518800000072
the client receives the time data at the current time T4= T2+ Δ T =1 hour, 20 minutes, 18 seconds +3 seconds =1 hour, 20 minutes, 21 seconds of the server.
As can be seen from the above, in the prior art, after the client sends the time obtaining request to the server, the time difference between the time data returned by the server and received by the client is 3 seconds, which indicates that according to the time synchronization method in the prior art, if the transmission time of the information in the network is long, a huge deviation is caused to the server time obtained by the client. According to the scheme of the embodiment of the disclosure, the server time received by the client can be corrected, the time error is reduced, and the effect of time synchronization accuracy between the client and the server is further improved.
The time synchronization method of the embodiment of the disclosure comprises the following steps: the client sends a time acquisition request to the server and determines the client time of the time acquisition request sent by the client as a first time; the client receives time data generated by the server according to the time request, and determines the current time of the client as second time when the client receives the time data, wherein the time data represents the current time of the server when the server receives the time acquisition request; the client calculates according to the first time, the time data and the second time to obtain a time difference from sending the time data to the client after the server receives the time request to receiving the time data by the client, wherein the time difference is used for representing the time length of the client or the operation time length of the server when the server sends the data to the client and the client receives the data; and adding the time data and the time difference to obtain target time, wherein the target time is used for representing the current time on the server when the client receives the server data. During implementation, calculating according to the first time, the time data and the second time to obtain a time difference; summing the time data and the time difference to obtain target time; and calculating according to the time data and the time difference, and sending the target time to a display page for displaying after the target time is obtained, or using the target data for other purposes.
When the time synchronization operation is performed on the client and the server, checking whether the time synchronization operation is performed; determining a preset interval duration when the execution of the time synchronization operation fails; and performing time synchronization again after the preset interval duration is reached.
When the time difference value is calculated, the time data can be converted into a timestamp mode which is easier to calculate; and when the time difference value is calculated, the absolute value of data obtained by subtracting the time data is taken, wherein the absolute value is mathematical expression and represents that the difference between two numbers is a non-negative number.
A second embodiment of the present disclosure provides a time synchronization apparatus, a structural schematic of which is shown in fig. 3, including:
the sending module 10 is configured to send a time obtaining request to the server, and record local first time information of the client when the time obtaining request is sent; the receiving module 20 is coupled to the sending module 10, and is configured to receive the second time information from the server, and record third time information local to the client when the second time information is received; a first determining module 30, coupled to the receiving module 20, configured to determine actual duration information of the first route according to the first time information, the second time information, and the third time information, where the actual duration information of the first route is time consumed by the server to send the second time information to the client and receive the second time information; and the second determining module 40 is coupled with the first determining module 30 and is used for determining the current time information on the server according to the actual duration information of the first journey and the second time information.
The first time information is the local time of the client recorded by the client, and when the client sends a time obtaining request to the server, the time is recorded for use when the actual time length information of the first journey is calculated subsequently.
The second time information is a response message after the server receives the time acquisition request, the server sends the second time information to the client, and the second time information is the time for sending the response message on the server. And the third time information is the local time of the client recorded by the client, and when the client receives the second time information, the time is recorded for later use when the actual time length information of the first route is calculated.
After the first time information, the second time information and the third time information are known, the distance time consumed when the server sends the second time information to the client and receives the second time information can be determined according to needs. In a specific implementation, the first determining module includes: the first determining unit is used for determining the relative duration information of the first journey according to the third time information and the second time information; the second determining unit is used for determining the relative duration information of all routes according to the first time information, the second time information and the third time information; the third determining unit is used for determining the proportion value of the time of the first route in all routes according to the relative duration information of the first route and the relative duration information of all routes; and the fourth determining unit is used for determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all the journeys locally determined by the client.
The first determining module is specifically configured to determine the actual duration information of the first route according to the following formula:
Figure BDA0003985518800000091
/>
and TN is actual duration information of the first route, T3 is third time information, T2 is second time information, and T1 is first time information.
After the client sends the time obtaining request to the server, the server may not receive the time obtaining request, or due to other reasons such as network, the client may not receive the current time information of the server, and therefore the time synchronization apparatus further includes: the detection module is used for detecting whether current time information exists or not according to preset time; and the sending module is also used for sending a time acquisition request to the server under the condition that the current time information does not exist.
When the client side synchronizes the time data of the server, the time information is sent to the actual time length required by the client side by the server, and then the current real time on the server when the time information sent by the server is received is determined together with the actual time length information according to the time information sent by the server. According to the embodiment of the invention, the time consumption in the information transmission process is considered, the time consumed in the transmission process is calculated through the three time information, and then the client can know the current time on the server accurately, so that the time error is reduced, and the system performance is improved.
A third embodiment of the present disclosure provides a storage medium, which is a computer-readable medium storing a computer program, and when the computer program is executed by a processor, the method provided in any embodiment of the present disclosure is implemented, including the following steps S11 to S14:
s11, sending a time acquisition request to a server, and recording local first time information of a client when the time acquisition request is sent;
s12, receiving second time information from the server, and recording local third time information of the client when the second time information is received;
s13, determining the actual time length information of the first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is the time consumed by the server for sending the second time information to the client to receive the second time information;
and S14, determining the current time information on the server according to the actual time information of the first route and the second time information.
When the computer program is executed by the processor to determine the actual duration information of the first journey according to the first time information, the second time information and the third time information, the processor specifically executes the following steps:
determining the relative duration information of the first route according to the third time information and the second time information; determining relative duration information of all routes according to the first time information, the second time information and the third time information; determining the proportion value of the time of the first route in all routes according to the relative duration information of the first route and the relative duration information of all routes; and determining the actual time length information of the first journey according to the ratio value and the absolute time length information of all the locally determined journeys of the client.
The computer program is further specifically executable by the processor to perform the steps of: determining the actual time length information of the first route according to the following formula:
Figure BDA0003985518800000101
and TN is actual duration information of the first route, T3 is third time information, T2 is second time information, and T1 is first time information.
After the step of sending a time acquisition request to the server is executed by the processor, the computer program further executes the steps of: detecting whether current time information exists according to preset time; and sending a time acquisition request to the server under the condition that the current time information does not exist.
When the client side synchronizes the time data of the server, the time information is sent to the actual time length required by the client side by the server, and then the current real time on the server when the time information sent by the server is received is determined together with the actual time length information according to the time information sent by the server. According to the embodiment of the invention, time consumption in the information transmission process is considered, the time consumed in the transmission process is calculated through the three time information, and then the client can know the current time on the server accurately, so that the time error is reduced, and the system performance is improved.
Optionally, in this embodiment, the storage medium may include but is not limited to: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes. Optionally, in this embodiment, the processor executes the method steps described in the above embodiments according to the program code stored in the storage medium. Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and this embodiment is not described herein again. It will be apparent to those skilled in the art that the modules or steps of the present disclosure described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of multiple computing devices, and alternatively, they may be implemented by program code executable by a computing device, such that they may be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into individual integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. As such, the present disclosure is not limited to any specific combination of hardware and software.
A fourth embodiment of the present disclosure provides an electronic device, a schematic structural diagram of the electronic device may be as shown in fig. 4, where the electronic device includes at least a memory 901 and a processor 902, the memory 901 stores a computer program, and the processor 902, when executing the computer program on the memory 901, implements the method provided in any embodiment of the present disclosure. Illustratively, the electronic device computer program steps are as follows S21 to S24:
s21, sending a time acquisition request to a server, and recording local first time information of a client when the time acquisition request is sent;
s22, receiving second time information from the server, and recording local third time information of the client when the second time information is received;
s23, determining the actual time length information of the first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is the time consumed by the server for sending the second time information to the client to receive the second time information;
and S24, determining the current time information on the server according to the actual time information of the first route and the second time information.
When the processor executes the computer program stored in the memory and used for determining the actual time length information of the first journey according to the first time information, the second time information and the third time information, the following computer program is specifically executed: determining relative duration information of the first route according to the third time information and the second time information; determining relative duration information of all routes according to the first time information, the second time information and the third time information; determining the proportion value of the time of the first route in all routes according to the relative duration information of the first route and the relative duration information of all routes; and determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all the journeys locally determined by the client.
The processor specifically executes the following computer program: determining the actual time length information of the first route according to the following formula:
Figure BDA0003985518800000121
and TN is actual duration information of the first route, T3 is third time information, T2 is second time information, and T1 is first time information.
The processor, after executing the computer program stored on the memory that sends the time acquisition request to the server, further executes the computer program that: detecting whether current time information exists according to preset time; and sending a time acquisition request to the server under the condition that the current time information does not exist.
When the client side synchronizes the time data of the server, the time information is sent to the actual time length required by the client side by the server, and then the current real time on the server when the time information sent by the server is received is determined together with the actual time length information according to the time information sent by the server. According to the embodiment of the invention, time consumption in the information transmission process is considered, the time consumed in the transmission process is calculated through the three time information, and then the client can know the current time on the server accurately, so that the time error is reduced, and the system performance is improved.
Moreover, although exemplary embodiments have been described herein, the scope thereof includes any and all embodiments based on the disclosure having equivalent elements, modifications, omissions, combinations (e.g., of various embodiments across), adaptations or alterations. The elements of the claims are to be interpreted broadly based on the language employed in the claims and not limited to examples described in the present specification or during the prosecution of the application, which examples are to be construed as non-exclusive. It is intended, therefore, that the specification and examples be considered as exemplary only, with a true scope and spirit being indicated by the following claims and their full scope of equivalents.
The above description is intended to be illustrative, and not restrictive. For example, the above-described examples (or one or more versions thereof) may be used in combination with each other. For example, other embodiments may be used by those of ordinary skill in the art upon reading the above description. In addition, in the foregoing detailed description, various features may be grouped together to streamline the disclosure. This should not be interpreted as an intention that a disclosed feature not claimed is essential to any claim. Rather, the subject matter of the present disclosure may lie in less than all features of a particular disclosed embodiment. Thus, the following claims are hereby incorporated into the detailed description as examples or embodiments, with each claim standing on its own as a separate embodiment, and it is contemplated that these embodiments may be combined with each other in various combinations or permutations. The scope of the disclosure should be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.
While the present disclosure has been described in detail with reference to the embodiments, the present disclosure is not limited to the specific embodiments, and those skilled in the art can make various modifications and alterations based on the concept of the present disclosure, and the modifications and alterations should fall within the scope of the present disclosure as claimed.

Claims (10)

1. A method of time synchronization, comprising:
sending a time acquisition request to a server, and recording local first time information of a client when the time acquisition request is sent;
receiving second time information from a server, and recording local third time information of the client when the second time information is received;
determining actual time length information of a first route according to the first time information, the second time information and the third time information, wherein the actual time length information of the first route is time consumed for the server to send the second time information to the client to receive the second time information;
and determining the current time information on the server according to the actual time information of the first distance and the second time information.
2. The method of claim 1, wherein determining the actual duration information for the first trip based on the first time information, the second time information, and the third time information comprises:
determining the relative duration information of the first route according to the third time information and the second time information;
determining relative duration information of all routes according to the first time information, the second time information and the third time information;
determining a proportion value of the time occupied by the first journey in all the journeys according to the relative duration information of the first journey and the relative duration information of all the journeys;
and determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all the journeys locally determined by the client.
3. The method according to claim 2, wherein the actual time length information of the first trip is determined according to the following formula:
Figure FDA0003985518790000011
and TN is actual time length information of the first route, T3 is the third time information, T2 is the second time information, and T1 is the first time information.
4. The method of any of claims 1 to 3, wherein after sending the time acquisition request to the server, further comprising:
detecting whether the current time information exists according to preset time;
and sending the time acquisition request to the server under the condition that the current time information does not exist.
5. A time synchronization apparatus, comprising:
the sending module is used for sending a time obtaining request to the server and recording local first time information of the client when the time obtaining request is sent;
the receiving module is used for receiving second time information from the server and recording local third time information of the client when the second time information is received;
a first determining module, configured to determine actual duration information of a first route according to the first time information, the second time information, and the third time information, where the actual duration information of the first route is time consumed by the server to send the second time information to the client and receive the second time information;
and the second determining module is used for determining the current time information on the server according to the actual time length information of the first route and the second time information.
6. The apparatus of claim 5, wherein the first determining module comprises:
the first determining unit is used for determining the relative duration information of the first journey according to the third time information and the second time information;
the second determining unit is used for determining the relative duration information of all routes according to the first time information, the second time information and the third time information;
a third determining unit, configured to determine, according to the relative duration information of the first route and the relative duration information of all routes, a proportion value of time occupied by the first route in all routes;
and the fourth determining unit is used for determining the actual time length information of the first journey according to the proportion value and the absolute time length information of all the journeys locally determined by the client.
7. The apparatus according to claim 6, wherein the first determining module is specifically configured to determine the actual duration information of the first journey according to the following formula:
Figure FDA0003985518790000021
and TN is actual time length information of the first route, T3 is the third time information, T2 is the second time information, and T1 is the first time information.
8. The apparatus of any of claims 5 to 7, further comprising:
the detection module is used for detecting whether the current time information exists or not according to preset time;
the sending module is further configured to send the time obtaining request to the server under the condition that the current time information does not exist.
9. A storage medium storing a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1 to 4 when executed by a processor.
10. An electronic device comprising at least a memory, a processor, the memory having a computer program stored thereon, characterized in that the processor realizes the steps of the method of any one of claims 1 to 4 when executing the computer program on the memory.
CN202211569287.0A 2022-12-07 2022-12-07 Time synchronization method, device, storage medium and electronic equipment Pending CN115941105A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211569287.0A CN115941105A (en) 2022-12-07 2022-12-07 Time synchronization method, device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211569287.0A CN115941105A (en) 2022-12-07 2022-12-07 Time synchronization method, device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115941105A true CN115941105A (en) 2023-04-07

Family

ID=86551751

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211569287.0A Pending CN115941105A (en) 2022-12-07 2022-12-07 Time synchronization method, device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115941105A (en)

Similar Documents

Publication Publication Date Title
US8108557B2 (en) System and method for measuring clock skew on a network
US9312974B2 (en) Master apparatus and slave apparatus and time-synchronization method
EP3329292B1 (en) Pps tagging of acoustic sample data
CN113114533B (en) Network time consumption display method and device for distributed service invocation
CN112486246A (en) Clock delay detection and compensation method, device, terminal and readable storage medium
US11489746B2 (en) Detection device, detection method, and detection program
CN106095688A (en) A kind of software performance testing method and device
CN112702231B (en) Network delay measuring method and system
US8924343B2 (en) Method and system for using confidence factors in forming a system
CN112230212B (en) Radar ranging signal processing method and device
CN112968747A (en) Time calibration method and device, computer equipment and storage medium
CN115941105A (en) Time synchronization method, device, storage medium and electronic equipment
US7577883B2 (en) Data transmission speed test system and method
CN109064248A (en) Order data synchronous method of calibration, device and equipment
CN115150019A (en) Multi-sensor time synchronization method, device, equipment and medium
CN113381910B (en) Multi-star coarse timing integrity analysis method and device, computer equipment and medium
WO2012005035A1 (en) Data processing apparatus and data processing method and program
KR102037002B1 (en) Method for Estimating Performance of Distributed Data Processing System and Node device for the Distributed Data Processing System
CN112507180B (en) Method and device for converting time of analog machine, electronic equipment and storage medium
CN114051276B (en) Serial time code time service method, system and electronic equipment
US20230259156A1 (en) Estimation of Event Generation Times to Synchronize Recordation Data
CN113407411B (en) Device and method for monitoring accuracy of online data in live broadcast scene
CN111106890B (en) Method and equipment for time synchronization
CN116633820A (en) Time delay testing method and device based on bottom layer communication and electronic equipment
CN117294378A (en) Clock synchronization method, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination