CN110855394A - Time correction method, device, system, equipment and storage medium - Google Patents

Time correction method, device, system, equipment and storage medium Download PDF

Info

Publication number
CN110855394A
CN110855394A CN201810954004.1A CN201810954004A CN110855394A CN 110855394 A CN110855394 A CN 110855394A CN 201810954004 A CN201810954004 A CN 201810954004A CN 110855394 A CN110855394 A CN 110855394A
Authority
CN
China
Prior art keywords
time
difference
time difference
server
correction
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
CN201810954004.1A
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.)
Hangzhou Hikvision System Technology Co Ltd
Original Assignee
Hangzhou Hikvision System Technology 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 Hangzhou Hikvision System Technology Co Ltd filed Critical Hangzhou Hikvision System Technology Co Ltd
Priority to CN201810954004.1A priority Critical patent/CN110855394A/en
Publication of CN110855394A publication Critical patent/CN110855394A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0658Clock or time synchronisation among packet nodes
    • H04J3/0661Clock or time synchronisation among packet nodes using timestamps
    • H04J3/0667Bidirectional timestamps, e.g. NTP or PTP for compensation of clock drift and for compensation of propagation delays
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L7/00Arrangements for synchronising receiver with transmitter
    • H04L7/0016Arrangements for synchronising receiver with transmitter correction of synchronization errors

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Electric Clocks (AREA)

Abstract

The invention discloses a time correction method, a time correction device, a time correction system, time correction equipment and a storage medium, and belongs to the technical field of computers. The invention calculates the time difference among a plurality of timing servers by setting a timing server cluster comprising a plurality of timing servers, selects the time difference not exceeding a first preset error, determines whether to update the system time based on a plurality of times which do not exceed the time difference of the first preset error and are obtained from the plurality of timing servers, if the time of a certain timing server is inaccurate, the timing server will have a large time difference with other timing servers, and thus when calculating the system time, can avoid calculating the system time according to the time of the timing server, and also avoid the influence of the time of the timing server on the accuracy of the system time, by eliminating the interference caused by inaccurate time of the timing server when determining whether to update the system time, the system time can be ensured to have high reliability and high accuracy.

Description

Time correction method, device, system, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a system, a device, and a storage medium for time correction.
Background
In computer technology, the requirements for the accuracy and uniformity of the time of the device are extremely high. In order to ensure that the whole network equipment keeps clock synchronization, a reliable clock source needs to be provided, the time provided by the clock source can be used as system time, and the whole network equipment can uniformly correct the time of the whole network equipment into the time of the clock source.
At present, a timing server serves as a clock source of the whole network equipment, and the whole network equipment takes time provided by the timing server as system time and corrects the time of the whole network equipment into the time of the timing server. Referring to fig. 1, a network connection is established between the timing server and the satellite, and a network connection is established between the timing server and each terminal in the network. The Time-correcting server can acquire the Time of the satellite in real Time so as to keep clock synchronization with the satellite, and the whole Network equipment can acquire the Time of the Time-correcting server in real Time based on a Network Time Protocol (NTP) Protocol so as to keep clock synchronization with the Time-correcting server.
Due to communication problems such as unstable network links between the timing server and the satellites, and hardware problems such as crystal oscillator aging, inaccurate time often occurs, and the reliability and accuracy of the provided system time are poor.
Disclosure of Invention
The embodiment of the invention provides a time correction method, a time correction device, a time correction system, time correction equipment and a storage medium, and can solve the problem of poor reliability and accuracy of system time in the related technology. The technical scheme is as follows:
in one aspect, a time correction method is provided, and the method includes:
the method comprises the steps of obtaining the time of each time correction server in a time correction server cluster to obtain a plurality of times, wherein the time correction server cluster comprises a plurality of time correction servers;
calculating a difference value between adjacent times of the numerical values in the plurality of times to obtain at least one time difference;
selecting at least one second time difference from the at least one time difference, wherein each second time difference is a time difference not exceeding a first preset error;
and determining whether to update the system time based on a plurality of times of each second time difference.
Optionally, the determining whether to update the system time based on the plurality of times at which each of the second time differences is obtained includes:
calculating to obtain a plurality of time statistics of each second time difference;
and determining whether to update the system time according to the statistical value and the current system time.
Optionally, the determining whether to update the system time according to the statistical value and the current system time includes:
when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or the like, or, alternatively,
and when the time difference between the statistical value and the current system time does not exceed a second preset error, not updating the system time.
Optionally, the time of the timing server is obtained after clock synchronization is performed between the timing server and a Global Positioning System (GPS) or a beidou satellite.
Optionally, the calculating a difference between adjacent times of the numerical values in the plurality of times to obtain at least one time difference specifically includes:
sorting the plurality of times from small to large or from large to small according to time values;
and calculating the difference between every two adjacent times to obtain at least one time difference.
Optionally, calculating statistics of a plurality of times corresponding to the at least one second time difference includes:
calculating an average value of a plurality of times corresponding to the at least one second time difference as the statistical value; and/or the presence of a gas in the gas,
calculating a weighted average value of a plurality of times corresponding to the at least one second time difference as the statistical value; and/or the presence of a gas in the gas,
and determining the statistic value according to the variance of a plurality of times corresponding to the at least one second time difference.
In another aspect, there is provided a time correction apparatus, the apparatus including:
the system comprises an acquisition module, a time correction module and a time correction module, wherein the acquisition module is used for acquiring the time of each time correction server in a time correction server cluster to obtain a plurality of times, and the time correction server cluster comprises a plurality of time correction servers;
the calculation module is used for calculating the difference between the adjacent times of the numerical values in the plurality of times to obtain at least one time difference between the plurality of timing servers;
the selecting module is used for selecting at least one second time difference from the at least one time difference, and each second time difference is a time difference not exceeding a first preset error;
and the determining module is used for determining whether to update the system time based on a plurality of times of obtaining each second time difference.
Optionally, the determining module includes:
the calculation submodule is used for calculating and obtaining statistics values of a plurality of times of each second time difference;
and the determining submodule is used for determining whether to update the system time according to the statistic value and the current system time.
Optionally, the determining sub-module is configured to: when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or when the time difference between the statistic value and the current system time does not exceed a second preset error, the system time is not updated.
Optionally, the time of the timing server is obtained after the timing server and the GPS or the beidou satellite perform clock synchronization.
Optionally, the calculation module includes:
the sorting submodule is used for sorting the plurality of times from small to large or from large to small according to the time values;
and the calculating submodule is used for calculating the difference between every two adjacent times to obtain at least one time difference.
In another aspect, a time correction system is provided, where the time correction system includes a time correction server cluster and a clock source subsystem;
the time correction server cluster comprises a plurality of time correction servers, and each time correction server is used for providing time;
the clock source subsystem is used for acquiring the time of each timing server in the timing server cluster to obtain a plurality of times; calculating a difference value between adjacent times of the numerical values in the plurality of times to obtain at least one time difference; selecting at least one second time difference from the at least one time difference, wherein each second time difference is a time difference not exceeding a first preset error; and determining whether to update the system time based on a plurality of times of each second time difference.
In one possible design, the time correction system further includes a time system monitoring subsystem;
the time system monitoring subsystem is used for synchronizing the system time to at least one terminal; and/or the presence of a gas in the gas,
the time system monitoring subsystem is used for acquiring the time of at least one terminal; and when the time difference between the time of any terminal and the system time exceeds a third preset error, prompting the time difference between the time of the terminal and the system time according to a preset prompting mode.
In another aspect, a server is provided, which includes a processor and a memory, where the memory stores at least one instruction, and the instruction is loaded and executed by the processor to implement the time correction method.
In another aspect, a computer-readable storage medium is provided, in which at least one instruction is stored, the instruction being loaded and executed by a processor to implement the above time correction method.
According to the method, the device, the system and the storage medium provided by the embodiment of the invention, the time deviation condition between different timing servers can be determined by calculating the difference value between the adjacent times of the numerical values in the plurality of times provided by the timing server cluster, and if the time of a certain timing server is not accurate, the time difference between the timing server and other timing servers is larger, so that the system time can be prevented from being calculated according to the time of the timing server when the system time is calculated, and the influence of the time of the timing server on the accuracy of the system time is also avoided. Because the interference caused by inaccurate time of the timing server is eliminated when determining whether to update the system time, the system time can be ensured to have high reliability and high accuracy.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic diagram of a time correction system provided in the related art;
FIG. 2 is a schematic diagram of a time correction system according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a time correction system according to an embodiment of the present invention;
FIG. 4 is a flow chart of a time correction method provided by an embodiment of the invention;
FIG. 5 is a flow chart of a time correction method provided by an embodiment of the present invention;
FIG. 6 is a flow chart of a time correction method provided by an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of a time correction apparatus according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
For the sake of understanding, terms referred to in the embodiments of the present invention are explained below:
cluster (cluster): a cluster refers to a group of devices that are independent of each other, and all devices in the cluster can execute the same service.
Hot standby of double machines: it refers to a hot standby based on two servers in a High Availability (HA) system. The dual-computer hot Standby mechanism comprises a host computer and a Standby computer, wherein the host computer is in an Active state (namely an Active state) of a certain service, the Standby computer is in a Standby state (namely a Standby state) of the service, and the Standby computer can be automatically switched to the Standby computer to execute the service after the host computer is down. In combination with a dual-computer hot standby mechanism, the time correction method provided by the embodiment of the present invention can be alternately executed by a host computer and a standby computer, where the host computer executes a process of acquiring time from a timing server cluster and a process of determining system time under normal conditions, and when the host computer fails, the host computer switches to the standby computer to execute the process of acquiring time from the timing server cluster and the process of determining system time.
NTP protocol: a protocol for synchronizing the time of various devices in a network.
Time system: the method is to ensure that the time of each terminal on the ground is coordinated and consistent, and ensure that the time of the terminal is related to the time provided by the astronomical equipment.
Fig. 2 is a schematic structural diagram of a time correction system according to an embodiment of the present invention, where the time correction system includes a timing server cluster 201 and a clock source subsystem 202, and the timing server cluster 201 and the clock source subsystem 202 establish a network connection and may perform information interaction through the network connection.
(1) The cluster of timing servers 201.
The timing server cluster 201 comprises a plurality of timing servers, the service of the plurality of timing servers can be the same, each timing server can independently operate, and information and data interaction with other timing servers is not needed. The plurality of timing servers can be physically isolated, and different timing servers can be deployed in different places and can have different physical forms. Each time correction server is also called as an NTP server, and the time correction server can perform clock synchronization with astronomical equipment, for example, the time correction server can perform clock synchronization with a GPS or a Beidou satellite.
(2) Clock source subsystem 202.
The clock source subsystem 202 serves as a clock source of the time correction system, and the clock source subsystem 202 may compare and verify a plurality of times provided by the time correction server cluster 201 based on a clock fault tolerance mechanism, so as to ensure that the finally determined system time has high reliability.
Optionally, in order to monitor whether the time of the terminal is accurate, referring to fig. 3, the time correction system may further include a time monitoring subsystem 203, where the time monitoring subsystem 203 establishes a network connection with the clock source subsystem 202 and at least one terminal, and may perform information interaction with the clock source subsystem 202 and at least one terminal through the established network connection.
(3) The timing system monitors the subsystem 203.
The time system monitoring subsystem 203 may be a server, a server cluster formed by a plurality of servers, or a cloud computing service center, and the time system monitoring subsystem 203 is configured to monitor a current time of at least one terminal. The at least one terminal may be a front-end device, a back-end device, and a center-end device, where the front-end device may be a Video camera, a mobile phone, a tablet computer, a personal computer, a wearable device, an unmanned aerial vehicle, and the like, the front-end device may be configured to collect data, the back-end device may be a Storage Area Network (SAN), an Internet Protocol Storage Area Network (IPSAN), a Video Central Storage (CVR), an embedded Video Recorder (DVR), and the like, the back-end device may be configured to store data, the center-end device may be a database server, a streaming media server, a center management server, and the like, and the center-end device may be configured to process data.
The embodiment of the invention can be applied to various application scenes with strict time requirements, such as monitoring security, investigation and solution, traffic control, aerospace, automatic test, industrial control and the like, and has great practicability by providing high-reliability and high-precision system time. For example, in a traffic control scene, in order to determine whether a vehicle violates an overspeed, it is necessary to ensure that the calculated speed of the vehicle is accurate, and by applying the time correction method provided by the embodiment of the present invention, an accurate system time can be provided for each camera, and each camera can ensure that the time recorded in each frame of picture in a captured video is accurate by performing time correction according to the accurate system time, thereby ensuring that the vehicle speed calculated according to the time recorded in the video is accurate.
Based on the system architecture of the time correction system described in the above embodiments, the time correction method provided in the embodiments of the present invention is described below.
Fig. 4 is a flowchart of a time correction method provided in an embodiment of the present invention, and referring to fig. 4, the method includes the following steps:
401. the method comprises the steps of obtaining the time of each time correction server in a time correction server cluster to obtain a plurality of times, wherein the time correction server cluster comprises a plurality of time correction servers.
402. And calculating the difference between the adjacent times of the numerical values in the plurality of times to obtain at least one time difference.
403. At least one second time difference is selected from the at least one time difference, and each second time difference is a time difference which does not exceed a first preset error.
404. Determining whether to update the system time based on a plurality of times at which each of the second time differences is obtained.
In the method provided by this embodiment, a time server cluster including a plurality of time servers is set, time differences among the plurality of time servers are calculated, a time difference not exceeding a first preset error is selected, and whether to update the system time is determined based on a plurality of times of the time difference not exceeding the first preset error obtained from the plurality of time servers, if the time of a certain time server is inaccurate, the timing server will have a large time difference with other timing servers, and thus when calculating the system time, can avoid calculating the system time according to the time of the timing server, and also avoid the influence of the time of the timing server on the accuracy of the system time, by eliminating the interference caused by inaccurate time of the timing server when determining whether to update the system time, the system time can be ensured to have high reliability and high accuracy.
Optionally, the determining whether to update the system time based on the plurality of times at which each of the second time differences is obtained includes:
calculating the statistics of a plurality of times of each second time difference;
and determining whether to update the system time according to the statistical value and the current system time.
Optionally, the determining whether to update the system time according to the statistical value and the current system time includes:
when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or the like, or, alternatively,
and when the time difference between the statistical value and the current system time does not exceed a second preset error, not updating the system time.
Optionally, the time of the timing server is obtained after the timing server and a global positioning system GPS or a beidou satellite perform clock synchronization.
Optionally, the calculating a difference between adjacent times of the numerical values in the plurality of times to obtain at least one time difference specifically includes:
sorting the plurality of times from small to large or from large to small according to the time values;
and calculating the difference between every two adjacent times to obtain at least one time difference.
Optionally, calculating statistics of a plurality of times corresponding to the at least one second time difference includes:
calculating an average value of a plurality of times corresponding to the at least one second time difference as the statistical value; and/or the presence of a gas in the gas,
calculating a weighted average value of a plurality of times corresponding to the at least one second time difference as the statistical value; and/or the presence of a gas in the gas,
and determining the statistical value according to the variance of a plurality of times corresponding to the at least one second time difference.
In the related art, the timing server can directly serve as a clock source of the whole network device, and each terminal in the network can actively acquire the time of the timing server to correct the time. The technical scheme has three technical problems: first, poor reliability: the time correction server is likely to cause time inaccuracy due to various factors such as unstable communication link and crystal oscillator failure in operation. However, even if the time calibration server is inaccurate, the time calibration server cannot be discriminated, and each terminal performs time calibration by using the time provided by the time calibration server as the system time, so that the time of each terminal is misled. Secondly, poor stability: when the time correction server is in operation, a fault may occur, and once the time correction server is in fault, each terminal in the network loses a clock source, clock synchronization cannot be performed, so that serious consequences are caused, and obviously, the time correction system is unstable and lacks robustness. Thirdly, the time accuracy of the terminal cannot be ensured: due to factors such as network faults and configuration errors, the situation that the terminal does not successfully acquire time from the timing server may occur, in addition, due to factors such as insufficient authority and program bug, the situation that the terminal cannot successfully correct the time even acquiring the time of the timing server may occur, in the two situations, the terminal does not keep clock synchronization with the timing server, the time of the terminal is inaccurate, but a user cannot perceive the situation, so that the time of the terminal cannot be corrected in time, and the performance of the terminal is influenced.
In the time correction method designed by the embodiment of the invention, the time provided by the time correction server is not directly used as the system time, but the time of different time correction servers in the time correction server cluster is compared and verified, so that the provided system time has high reliability; by adopting a clustered design timing server and applying a dual-computer hot standby mechanism, the method can be ensured to have high stability; by monitoring the time of each terminal in real time, the condition that the time of the terminal is inaccurate can be detected in time and the time is alarmed.
Fig. 5 is a flowchart of a time correction method provided in an embodiment of the present invention, and is described by taking an example that an interaction subject of the time correction method includes a time correction server cluster, a clock source subsystem, and a time system monitoring subsystem, referring to fig. 5, where the method includes the following steps:
501. and each time correction server in the time correction server cluster performs clock synchronization with the astronomical equipment.
Each timing server can be configured with a network card, a satellite antenna or other types of signal transceivers, and can perform information interaction with the astronomical equipment through the configured signal transceivers, so as to perform clock synchronization with the astronomical equipment, and the timing server can use the time obtained after the clock synchronization with the astronomical equipment as the time of the timing server. Wherein the astronomical equipment may comprise at least one of a GPS satellite, a beidou satellite, an astronomical Time desk, or other Universal Time providing (UTC).
It should be noted that the time correction server cluster may include three or more than three time correction servers, and after one time correction server in the time correction server cluster goes down, the time correction server cluster can still normally output at least two times, and the time correction system can still normally operate, and has high stability. The specific number of the timing servers in the timing server cluster can be determined according to actual service requirements, and the embodiment of the invention does not limit the specific number.
In the embodiment of the invention, the time correction servers are in a clustering design, and even if one time correction server fails when the time correction server cluster runs, other time correction servers can provide time, so that the condition that the time correction server cluster cannot provide time due to the failure of one time correction server is avoided, the condition that a terminal loses a clock source due to the failure of one time correction server in the time correction system is further avoided, and the stability of the time correction system is improved.
502. The clock source subsystem obtains the time of each time correction server in the time correction server cluster to obtain a plurality of times.
The clock source subsystem may obtain time from each timing server in real time or periodically, thereby obtaining multiple times. Specifically, the clock source subsystem and the time correction server cluster may perform information interaction through a communication mode of a C/S (client/server), each time correction server may operate a server, the clock source subsystem may operate a client, and the clock source subsystem may obtain time from each time correction server through a communication link between the client and the server.
When the time of the timing server is the time obtained after the timing server and the GPS or the beidou satellite perform clock synchronization, the time obtained by the clock source subsystem may be the time obtained after the timing server and the GPS or the beidou satellite perform clock synchronization.
It should be noted that, when any timing server in the timing server cluster cannot normally provide time due to shutdown, equipment failure, and other factors, the clock source subsystem may send a notification message to the terminal, where the notification message is used to notify the terminal that a certain timing server cannot provide time, and the terminal may receive the notification message and display the notification message, so that the user can know the situation in time.
503. The clock source subsystem calculates a difference between times with adjacent values in the plurality of times to obtain at least one first time difference.
In this embodiment, different timing servers in the timing server cluster operate independently, and on the premise that two timing servers do not perform information interaction, if two timing servers provide the same or similar time, the time of the two timing servers is considered to be reliable, and the system time can be calculated according to the time provided by the two timing servers. And if the time difference provided by the two timing servers is larger, which indicates that the time of at least one of the two timing servers is unreliable, the system time cannot be calculated according to the time provided by the two timing servers, so that the accuracy of the system time is prevented from being influenced when the system time is calculated according to inaccurate time.
To determine the time offset between different timing servers, the clock source subsystem may sort the plurality of times by numerical magnitude, for example, the plurality of times may be sorted from small to large by time value, or the plurality of times may be sorted from large to small by time value. Then, the clock source subsystem may calculate a difference between every two adjacent times to obtain at least one first time difference.
Exemplarily, assuming that the time correction server cluster includes three time correction servers, the times acquired by the clock source subsystem from the three time correction servers are t1, t2, and t3, respectively, the clock source subsystem orders the three times from small to large according to time values, assuming that t1< t2< t3 is obtained, the clock source subsystem calculates a time difference between t1 and t2, obtains a first time difference d1, calculates a time difference between t2 and t3, obtains a first time difference d2, and obtains two first time differences in total: d1 and d 2.
504. The clock source subsystem selects at least one second time difference from the at least one first time difference, and each second time difference is the first time difference which does not exceed a first preset error.
A first preset error: the first preset error is used to indicate whether the first time difference is too large, that is, whether the deviation between two adjacent time values is too large, the first preset error may be set in the clock source subsystem in advance, and the first preset error may be determined according to experience or business requirements, for example, 1 s.
And when any first time difference exceeds the first preset error, the first time difference is taken as the second time difference, and the first time difference does not need to be selected if the deviation of two times corresponding to the first time difference is larger. Thus, after each first time difference is judged, at least one second time difference can be obtained.
In a possible design, the timing method provided in the embodiment of the present invention may provide a prompt function: when at least one first time difference exceeds a first preset error, the clock source subsystem can prompt the first time difference exceeding the first preset error according to a preset prompting mode so as to prompt a user that the time difference of different timing servers in the timing server cluster is too large, help the user to timely know the condition that the time difference of the different timing servers is too large, and perform manual intervention on the time of the timing servers. For the specific way of prompting, the clock source subsystem may perform an alarm, for example, may send an alarm message to the terminal, and the terminal may perform an alarm after receiving the alarm message, for example, the terminal may display an alarm page, send an alarm audio, and the like.
In a possible design, the timing method provided by the embodiment of the present invention may provide a function of logging. When any first time difference exceeds a first preset error, the clock source subsystem can record the time of obtaining the first time difference exceeding the first preset error, so that the condition that the time difference of the timing server cluster is overlarge is recorded, and the operation of the timing server cluster is maintained. For example, the clock source subsystem may record: the time when the timing server is acquired at 7-05-1915: 00:27 is as follows: 7-05-1915: 00:27, 7-05-1916:00:30 and 7-05-1917: 00: 30. In addition, the clock source subsystem can also determine the time of obtaining the first time difference exceeding the first preset error, and record the identification of the timing server according to the timing server providing the time, so as to record which timing servers have time inaccuracy.
It should be noted that the clock source subsystem may prompt according to a preset prompting manner when all the first time differences exceed the first preset error, may prompt according to a preset prompting manner when any one of the first time differences exceeds the preset error, and may prompt according to a preset prompting manner when the first time differences exceeding the preset error reach a preset number.
505. The clock source subsystem determines a system time based on the plurality of times for each second time difference.
Specifically, for each of the at least one second time difference, the clock source subsystem may determine two times at which the second time difference is obtained, i.e., the two times at which the second time difference is calculated in step 503, thereby determining a plurality of times at which each second time difference is obtained based on each second time difference, and determining the system time based on the plurality of times. The system time can be regarded as time which is finally provided by the timing server cluster and the clock source subsystem, and can be used as a reference for timing of each terminal.
For example, assuming that the time correction server cluster includes three time correction servers, the times of the three time correction servers are t1, t2 and t3, the first time difference between t1 and t2 is d1, and the first time difference between t2 and t3 is d2, if d1 does not exceed the first preset error and d2 exceeds the first preset error, d1 is selected as the second time difference, and the two times of d1, i.e., t1 and t2, are determined, so as to determine the system time based on t1 and t 2. If d1 and d2 do not exceed the first preset error, d1 and d2 are selected as the second time difference, two times for obtaining d1, namely t1 and t2, two times for obtaining d2, t2 and t3 are determined, and therefore the system time is determined based on t1, t2 and t 3.
Optionally, the process of determining the system time may include the following steps one to two:
step one, calculating to obtain a plurality of time statistics values of each second time difference.
Step one may include any one or combination of the following implementation one to implementation three:
in the first implementation manner, an average value of a plurality of times corresponding to the at least one second time difference is calculated as the statistical value.
In the second implementation manner, a weighted average value of a plurality of times corresponding to the at least one second time difference is calculated as the statistical value.
For example, a mapping relationship between the second time difference and the weight may be established in advance, the mapping relationship may be queried for each of a plurality of times corresponding to at least one second time difference according to the second time difference corresponding to the time, the weight corresponding to the second time difference may be used as the weight of the time, so as to obtain the weight of each time, and the plurality of times may be weighted and averaged according to the weight of each time, so as to obtain a weighted average. Wherein the weight corresponding to the second time difference may be inversely related to the magnitude of the second time difference,
in a third implementation manner, the statistical value is determined according to the variance of a plurality of times corresponding to the at least one second time difference.
The variance of a plurality of times may be calculated as a statistical value.
And step two, determining whether to update the system time according to the statistic value and the current system time.
Optionally, a time difference between the statistical value and the current system time may be calculated, and when the time difference between the statistical value and the current system time exceeds a second preset error, it indicates that the current system time has a large deviation from the statistical value, and indicates that the current system time is not accurate enough, the system time is updated to the statistical value, so as to ensure the accuracy of the system time. Correspondingly, when the time difference between the statistical value and the current system time does not exceed a second preset error, the accuracy of the current system time is acceptable, and the system time is not updated, so that the influence of frequent updating of the current system time on the performance of the equipment is avoided.
The second preset error is used for indicating whether the time difference between the current system time and the statistical value is large enough, the second preset error can be determined according to actual business requirements, and the second preset error can be set to be 0 by taking milliseconds as a unit.
Optionally, when the clock source subsystem updates the system time to the statistical value, the clock source subsystem may record an event of updating the current system time, for example, the clock source subsystem may record: the system time is updated from 7-05-1915: 00:27 to 7-05-1916:00:30 from 7-05-1915: 00: 27.
Illustratively, suppose that the time correction server cluster includes three time correction servers, the time is t1, t2, t3, the time difference between t1 and t2 is d1, the time difference between t2 and t3 is d2, and the current system time is td. If d1 does not exceed the first preset error and d2 exceeds the first preset error, t1 and t2 can be taken as second times, statistics t of t1 and t2 are calculated, td is updated to t and logged when the time difference between t and td exceeds the second preset error, and td is kept unchanged when the time difference between t and td does not exceed the second preset error.
Optionally, after the clock source subsystem determines the system time, the system time may be synchronized to the at least one terminal. Specifically, the clock source subsystem may perform network connection with at least one terminal, and each terminal may obtain the system time from the clock source subsystem through the network connection, and may also update its own time to the system time, thereby maintaining clock synchronization with the clock source subsystem. The clock source subsystem can communicate with each terminal based on the NTP protocol, the clock source subsystem can be a service end of the NTP protocol, and each terminal can be a client end of the NTP protocol.
In combination with the above steps 501 to 505, this embodiment provides a clock fault tolerance mechanism, which obtains the system time by comparing and checking the time provided by the time calibration server cluster, and if the time difference between any two time calibration servers is large, the time of the two time calibration servers does not participate in the calculation process of the system time, so the time of the two time calibration servers does not affect the accuracy of the system time. Then, by excluding the interference caused by inaccurate time before calculating the system time, it is possible to ensure high reliability and high accuracy of the system time.
In a possible design, the time correction method provided in the embodiment of the present invention may be operated based on a dual-device hot-standby mechanism: in combination with the concept of the dual-host hot standby mechanism, the clock source subsystem may include a host and a standby, when the host operates normally, the host executes the time acquisition process and the system time determination process, and the standby may keep silent, and when the host fails, the standby may be activated, thereby switching to the standby execution time acquisition process and the system time determination process. The standby machine can detect the operation state of the host machine, for example, the host machine and the standby machine operate the hot standby software of the two machines, the standby machine can establish connection with the host machine through a heartbeat line or a heartbeat network link, and detect the operation state of the host machine through the established connection, when the host machine fails, the standby machine can immediately sense that the host machine fails, and the service of the host machine is automatically switched to the standby machine to operate through the hot standby software of the two machines.
By designing the clock source subsystem to operate as a dual-machine hot standby mechanism, the clock source subsystem can be ensured to have high stability: when the host of the clock source subsystem breaks down, the standby machine of the clock source subsystem can automatically take over the service of the host, the clock source subsystem can still provide system time for the terminal to monitor the subsystem in time by the standby machine, the condition that the time correction system lacks a clock source due to the failure of the host can be avoided, and the stability of the clock source subsystem is improved.
506. The time system monitoring subsystem acquires the time of at least one terminal.
The time system monitoring subsystem and the at least one terminal can establish a private or public communication protocol in advance, the time system monitoring subsystem can communicate with each terminal through the communication protocol, and obtains time from each terminal in real time or periodically to obtain the time of each terminal, so that the time of the at least one terminal is obtained.
507. And when the time difference between the time of any terminal and the system time exceeds a third preset error, the time system monitoring subsystem prompts the time difference between the time of the terminal and the system time according to a preset prompting mode.
For each terminal in at least one terminal, calculating a time difference between the time of the terminal and the system time, and judging whether the time difference between the time of the terminal and the system time exceeds a third preset error, when the time difference between the time of the terminal and the system time exceeds the third preset error, the time difference between the time of the terminal and the system time is too large, and the time of the terminal is not accurate, the time difference between the time of the terminal and the system time can be prompted by the time monitoring subsystem according to a preset prompting mode, when the time of the terminal and the system time does not exceed the third preset error, the time monitoring subsystem indicates that the time of the terminal and the system time are small in deviation, the time of the terminal is accurate, and the time monitoring subsystem does not need to process. The third preset error is used for measuring the deviation degree between the time of the terminal and the system time, and can be determined according to the actual service requirement.
The preset prompting mode may be to perform an alarm, or may be to display a prompting interface, where the prompting interface is used to prompt a time difference between the terminal time and the system time, or may be to play a prompting audio, where the prompting audio is used to prompt a time difference between the terminal time and the system time.
The time difference between the time of the terminal and the system time is prompted, so that the time of the user terminal can be prompted to be inaccurate, the user can know the condition in time, and manual intervention is performed on the time of the terminal.
The mode that the time system monitoring subsystem acquires the system time is related to, the time system monitoring subsystem can perform information interaction with the clock source subsystem through a communication mode of a client/server (hereinafter referred to as C/S), the clock source subsystem can operate a server, the time system monitoring subsystem can operate the client, and the time system monitoring subsystem can acquire the system time from the clock source subsystem through a communication link between the client and the server.
It should be noted that, in the above step 507, the prompt is performed only when the time difference between the time of any terminal and the system time exceeds the third preset error, in implementation, a large number of terminals may be deployed in the network, and the time-system monitoring subsystem may calculate the time difference between the time of the terminal and the system time for each terminal and perform the prompt for each terminal similarly.
Taking the prompt mode as an example of performing the alarm, referring to fig. 6, it shows an operation flowchart of the time system monitoring subsystem performing the alarm, and the time system monitoring subsystem may sequentially execute each step in the operation flowchart to implement the alarm function.
Optionally, the time system monitoring subsystem may further have a logging function, and when a time difference between the time of the terminal and the system time exceeds a third preset error, the time system monitoring subsystem may record the event, for example, record the time of the terminal, the identifier of the terminal, and the like.
When the design of the system monitoring subsystem is combined, in the time correction method provided by the embodiment of the invention, the system monitoring subsystem is arranged in the system architecture and actively monitors the time of each terminal in the network, so that even if a certain terminal generates time deviation due to failure in acquiring the system time or failure in performing time correction based on the system time, the terminal with the time deviation can be timely found by the system monitoring subsystem, and the function of the time correction system is expanded. Meanwhile, when the time difference between the time of the terminal and the system time exceeds a third error value, the time system monitoring subsystem can give an alarm to ensure that a user can know the inaccurate time of the terminal in time.
In the method provided by this embodiment, a time server cluster including a plurality of time servers is set, time differences among the plurality of time servers are calculated, a time difference not exceeding a first preset error is selected, and whether to update the system time is determined based on a plurality of times of the time difference not exceeding the first preset error obtained from the plurality of time servers, if the time of a certain time server is inaccurate, the timing server will have a large time difference with other timing servers, and thus when calculating the system time, can avoid calculating the system time according to the time of the timing server, and also avoid the influence of the time of the timing server on the accuracy of the system time, by eliminating the interference caused by inaccurate time of the timing server when determining whether to update the system time, the system time can be ensured to have high reliability and high accuracy.
It should be noted that the time calibration method provided in the embodiment of fig. 5 is only described by dividing different steps into different subsystems to be executed as an example, in practical applications, each step distribution in the embodiment of fig. 5 may be completed by different program modules in one server according to needs, for example, the clock source subsystem and the time system monitoring subsystem may be deployed in the same server, and the server may successively execute the process of acquiring time from the time calibration server cluster, the process of determining system time, the process of acquiring time from the terminal, and the process of performing an alarm when the time of the terminal is not correct in the embodiment of fig. 5, of course, each step distribution in the embodiment of fig. 5 may be respectively executed by different program modules of multiple servers to complete all or part of the functions described above.
Fig. 7 is a schematic structural diagram of a time correction apparatus according to an embodiment of the present invention, and as shown in fig. 7, the apparatus includes: the device comprises an acquisition module 701, a calculation module 702, a selection module 703 and a determination module 704.
An obtaining module 701, configured to obtain a time of each timing server in a timing server cluster to obtain multiple times, where the timing server cluster includes multiple timing servers;
a calculating module 702, configured to calculate a difference between times in the plurality of times, where the values are adjacent to each other, to obtain at least one time difference between the plurality of timing servers;
a selecting module 703, configured to select at least one second time difference from the at least one time difference, where each second time difference is a time difference that does not exceed a first preset error;
a determining module 704, configured to determine whether to update the system time based on a plurality of times at which each of the second time differences is obtained.
The time correction device provided by this embodiment can determine the time deviation condition between different timing servers by calculating the difference between times with adjacent numerical values in a plurality of times provided by the timing server cluster, and if the time of the timing server is inaccurate, the time of the timing server will not be selected as the second time due to the large generated time difference, and will not participate in the calculation process of the system time, so that the accuracy of the system time will not be affected. When the system time is obtained based on the selected second time, the interference caused by inaccurate time is eliminated, and the system time can be ensured to have high reliability and high accuracy.
Optionally, the determining module 702 includes:
the calculation submodule is used for calculating statistical values of a plurality of times corresponding to the at least one second time difference;
and the determining submodule is used for determining whether to update the system time according to the statistic value and the current system time.
Optionally, the determining sub-module is configured to: when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or when the time difference between the statistic value and the current system time does not exceed a second preset error, the system time is not updated.
Optionally, the time of the timing server is obtained after the timing server and the GPS or the beidou satellite perform clock synchronization.
Optionally, the calculating module 702 includes:
the sorting submodule is used for sorting the plurality of times from small to large or from large to small according to the time values;
and the calculating submodule is used for calculating the difference between every two adjacent times to obtain at least one time difference.
All the above optional technical solutions may be combined arbitrarily to form the optional embodiments of the present disclosure, and are not described herein again.
It should be noted that: in the time correction device provided in the above embodiment, only the division of the above functional modules is taken as an example for time correction, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the server is divided into different functional modules to complete all or part of the above described functions. In addition, the time correction device and the time correction method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments and are not described herein again.
Fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention, where the server 800 may be provided as any one of the clock source subsystem and the time system monitoring subsystem in the foregoing embodiments. The server 800 may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 801 and one or more memories 802, where the memory 802 stores at least one instruction, and the at least one instruction is loaded and executed by the processor 801 to implement the methods provided by the method embodiments. Of course, the server may also have a wired or wireless network interface, an input/output interface, and other components to facilitate input and output, and the server may also include other components for implementing the functions of the device, which are not described herein again.
In an exemplary embodiment, a computer-readable storage medium, such as a memory, is also provided that includes instructions executable by a processor to perform the time correction method of the above embodiments. For example, the computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (14)

1. A method of time correction, the method comprising:
the method comprises the steps of obtaining the time of each time correction server in a time correction server cluster to obtain a plurality of times, wherein the time correction server cluster comprises a plurality of time correction servers;
calculating a difference value between adjacent times of the numerical values in the plurality of times to obtain at least one time difference;
selecting at least one second time difference from the at least one time difference, wherein each second time difference is a time difference not exceeding a first preset error;
and determining whether to update the system time based on a plurality of times of each second time difference.
2. The method of claim 1, wherein determining whether to update the system time based on the plurality of times at which each of the second time differences is derived comprises:
calculating to obtain a plurality of time statistics of each second time difference;
and determining whether to update the system time according to the statistical value and the current system time.
3. The method of claim 2, wherein said determining whether to update the system time based on the statistical value and a current system time comprises:
when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or the like, or, alternatively,
and when the time difference between the statistical value and the current system time does not exceed a second preset error, not updating the system time.
4. The method of claim 1, wherein the time of the timing server is the time obtained after the timing server and a Global Positioning System (GPS) or a Beidou satellite perform clock synchronization.
5. The method according to claim 1, wherein the calculating a difference between times that are adjacent to each other in the plurality of times to obtain at least one time difference specifically comprises:
sorting the plurality of times from small to large or from large to small according to time values;
and calculating the difference between every two adjacent times to obtain at least one time difference.
6. A time correction apparatus, characterized in that the apparatus comprises:
the system comprises an acquisition module, a time correction module and a time correction module, wherein the acquisition module is used for acquiring the time of each time correction server in a time correction server cluster to obtain a plurality of times, and the time correction server cluster comprises a plurality of time correction servers;
the calculation module is used for calculating the difference between the adjacent times of the numerical values in the plurality of times to obtain at least one time difference between the plurality of timing servers;
the selecting module is used for selecting at least one second time difference from the at least one time difference, and each second time difference is a time difference not exceeding a first preset error;
and the determining module is used for determining whether to update the system time based on a plurality of times of obtaining each second time difference.
7. The apparatus of claim 6, wherein the determining module comprises:
the calculation submodule is used for calculating and obtaining statistics values of a plurality of times of each second time difference;
and the determining submodule is used for determining whether to update the system time according to the statistic value and the current system time.
8. The apparatus of claim 7, wherein the determination submodule is configured to: when the time difference between the statistic value and the current system time exceeds a second preset error, updating the system time into the statistic value; or when the time difference between the statistic value and the current system time does not exceed a second preset error, the system time is not updated.
9. The device of claim 6, wherein the time of the timing server is the time obtained after the timing server and a Global Positioning System (GPS) or a Beidou satellite perform clock synchronization.
10. The apparatus of claim 6, wherein the computing module comprises:
the sorting submodule is used for sorting the plurality of times from small to large or from large to small according to the time values;
and the calculating submodule is used for calculating the difference between every two adjacent times to obtain at least one time difference.
11. A time correction system is characterized in that the time correction system comprises a time correction server cluster and a clock source subsystem;
the time correction server cluster comprises a plurality of time correction servers, and each time correction server is used for providing time;
the clock source subsystem is used for acquiring the time of each timing server in the timing server cluster to obtain a plurality of times; calculating a difference value between adjacent times of the numerical values in the plurality of times to obtain at least one time difference; selecting at least one second time difference from the at least one time difference, wherein each second time difference is a time difference not exceeding a first preset error; and determining whether to update the system time based on a plurality of times of each second time difference.
12. The time correction system of claim 11, further comprising a time system monitoring subsystem;
the time system monitoring subsystem is used for synchronizing the system time to at least one terminal; and/or the presence of a gas in the gas,
the time system monitoring subsystem is used for acquiring the time of at least one terminal; and when the time difference between the time of any terminal and the system time exceeds a third preset error, prompting the time difference between the time of the terminal and the system time according to a preset prompting mode.
13. A server, comprising a processor and a memory, wherein at least one instruction is stored in the memory, and wherein the instruction is loaded and executed by the processor to perform the operations performed by the time correction method of any one of claims 1 to 5.
14. A computer-readable storage medium having stored therein at least one instruction which is loaded and executed by a processor to perform operations performed by the time correction method of any one of claims 1 to 5.
CN201810954004.1A 2018-08-21 2018-08-21 Time correction method, device, system, equipment and storage medium Pending CN110855394A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810954004.1A CN110855394A (en) 2018-08-21 2018-08-21 Time correction method, device, system, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810954004.1A CN110855394A (en) 2018-08-21 2018-08-21 Time correction method, device, system, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN110855394A true CN110855394A (en) 2020-02-28

Family

ID=69595188

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810954004.1A Pending CN110855394A (en) 2018-08-21 2018-08-21 Time correction method, device, system, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110855394A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113783649A (en) * 2021-08-06 2021-12-10 深圳市科陆电子科技股份有限公司 Terminal timing method, system, electronic equipment and storage medium
CN113922908A (en) * 2021-09-30 2022-01-11 西安诺瓦星云科技股份有限公司 GPS timing precision improvement and synchronous playing method, storage medium and equipment thereof
CN116032413A (en) * 2023-03-30 2023-04-28 小米汽车科技有限公司 Communication method, device, vehicle and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103370635A (en) * 2011-01-14 2013-10-23 迪尔公司 Method and system for determining clock corrections
CN108075852A (en) * 2017-11-16 2018-05-25 北京三快在线科技有限公司 Acquisition methods, device, electronic equipment and the storage medium of network standard time

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103370635A (en) * 2011-01-14 2013-10-23 迪尔公司 Method and system for determining clock corrections
CN108075852A (en) * 2017-11-16 2018-05-25 北京三快在线科技有限公司 Acquisition methods, device, electronic equipment and the storage medium of network standard time

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113783649A (en) * 2021-08-06 2021-12-10 深圳市科陆电子科技股份有限公司 Terminal timing method, system, electronic equipment and storage medium
CN113783649B (en) * 2021-08-06 2023-12-29 深圳市科陆电子科技股份有限公司 Terminal timing method, system, electronic equipment and storage medium
CN113922908A (en) * 2021-09-30 2022-01-11 西安诺瓦星云科技股份有限公司 GPS timing precision improvement and synchronous playing method, storage medium and equipment thereof
CN113922908B (en) * 2021-09-30 2023-11-14 西安诺瓦星云科技股份有限公司 GPS timing precision improvement and synchronous playing method, storage medium and equipment thereof
CN116032413A (en) * 2023-03-30 2023-04-28 小米汽车科技有限公司 Communication method, device, vehicle and storage medium
CN116032413B (en) * 2023-03-30 2023-06-30 小米汽车科技有限公司 Communication method, device, vehicle and storage medium

Similar Documents

Publication Publication Date Title
US10491671B2 (en) Method and apparatus for switching between servers in server cluster
CN110855394A (en) Time correction method, device, system, equipment and storage medium
CN112583648B (en) Intelligent service fault processing method based on DNS
US20210226871A1 (en) Cluster management method, apparatus and system
CN111131357B (en) Screen projection processing method, device and equipment
CN111104283B (en) Fault detection method, device, equipment and medium of distributed storage system
CN111708560A (en) Automatic deployment method and device of database high-availability management system
CN106533751B (en) SDN controller cluster merging method and device
US8327028B1 (en) Method and apparatus for providing time synchronization in a data protection system
CN110224880B (en) Heartbeat monitoring method and monitoring equipment
CN111342986A (en) Distributed node management method and device, distributed system and storage medium
CN111400263A (en) Monitoring switch-back method and device based on file change
CN114064343B (en) Abnormal handling method and device for block chain
CN108681558B (en) Data rollback method, device and terminal
JP2009008444A (en) Time management server, time management program, and time management method
CN115102862A (en) Automatic synchronization method and device for SDN equipment
CN114978945A (en) Network dial testing method, device, system, electronic equipment and storage medium
CN114384508A (en) Multi-source track fusion method based on dynamic and static parameter normalization comparison
CN112988882B (en) System, method and device for preparing data from different places and computing equipment
CN109451521B (en) GPS synchronization method for base station intensive distributed networking
CN115686951A (en) Fault processing method and device for database server
CN113596195A (en) Public IP address management method, device, main node and storage medium
CN112965902A (en) Application system evaluation method and device
CN107665258B (en) File system availability determining method and device
US20230120135A1 (en) Running status switching method, apparatus, active/standby management system, and network 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200228