CN111865466A - Time synchronization method and device, timed equipment and storage medium - Google Patents

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

Info

Publication number
CN111865466A
CN111865466A CN202010662789.2A CN202010662789A CN111865466A CN 111865466 A CN111865466 A CN 111865466A CN 202010662789 A CN202010662789 A CN 202010662789A CN 111865466 A CN111865466 A CN 111865466A
Authority
CN
China
Prior art keywords
time
information
current
synchronization
difference
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.)
Granted
Application number
CN202010662789.2A
Other languages
Chinese (zh)
Other versions
CN111865466B (en
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.)
Rundian Energy Science and Technology Co Ltd
Original Assignee
Rundian Energy Science and 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 Rundian Energy Science and Technology Co Ltd filed Critical Rundian Energy Science and Technology Co Ltd
Priority to CN202010662789.2A priority Critical patent/CN111865466B/en
Publication of CN111865466A publication Critical patent/CN111865466A/en
Application granted granted Critical
Publication of CN111865466B publication Critical patent/CN111865466B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Electric Clocks (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The embodiment of the invention provides a time synchronization method, a time synchronization device, time-receiving equipment and a storage medium. The time synchronization method comprises the following steps: the method comprises the steps that a plurality of time service devices carry out time synchronization through a time service source device, the time service devices receive current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; and synchronizing the local time to the target time corresponding to the time information. The effect of reducing the cost of the synchronization time of the timed equipment is achieved.

Description

Time synchronization method and device, timed equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of time synchronization, in particular to a time synchronization method, a time synchronization device, time-receiving equipment and a storage medium.
Background
Time synchronization technology is widely used in various industrial fields. Especially for systems with high-precision equipment such as intellectualization and digitization, the time precision has direct influence on parameter verification of the equipment and stable control of the system. For example, for a power transformation total station protection device in a digital power system, once a clock is incorrect, which means that an abnormal condition or even a fault occurs in a power grid system, the device action time in a system report cannot be matched with the actual time, which may cause a manager to misjudge or fail to judge a power grid fault and lose the optimal time for handling the fault. Therefore, the time synchronization precision of the equipment is improved, and the accident analysis and stable control level of the equipment is further improved, so that the key requirement for efficient and reliable operation of the system is met.
At present, the common time synchronization technology is to allocate a satellite synchronization time synchronization device to each time service device to perform high-precision time synchronization. The satellite synchronous time setting device adopts advanced satellite time setting, network synchronization, frequency measurement and control and other technologies to provide high-precision time information, so that the time-set equipment keeps an accurate clock.
However, the satellite time synchronization device is expensive, and the requirement for installing a plurality of distributed time service devices is large, which results in high cost of synchronization time of the time service devices.
Disclosure of Invention
The embodiment of the invention provides a time synchronization method, a time synchronization device, time-service equipment and a storage medium, so as to reduce the cost of time synchronization of the time-service equipment.
In a first aspect, an embodiment of the present invention provides a time synchronization method, where multiple time-service devices perform time synchronization through a time service source device, and the method is applied to the time-service devices, and the method includes:
receiving current message information sent by the time service source equipment, wherein the current message information carries time information, the time service source equipment carries out time synchronization through a reference clock source, and the reference clock source is used for providing uniform clock information;
And synchronizing the local time to the target time corresponding to the time information.
Optionally, the synchronizing the local time to the target time corresponding to the time information includes:
analyzing the current message information to obtain a message header, information length, cyclic redundancy check code and time information carried by the current message information corresponding to the current message information;
when the message header, the cyclic redundancy check code and the information length are correct, extracting current time information carried by the current message information;
extracting last time information in last message information;
judging whether the current time information is greater than the last time information;
and when the current time information is larger than the last time information, synchronizing the local time to be the target time corresponding to the current time information.
Optionally, when the current time information is greater than the previous time information, synchronizing the local time to a target time corresponding to the current time information includes:
when the current time information is larger than the last time information, the current local time of the timed device is obtained;
calculating a time difference value between the current local time and the current time information;
Judging whether the time difference is larger than a first difference threshold value or not;
when the time difference is larger than the first difference threshold, the current time information is discarded as an abnormal value;
when the time difference is not larger than the first difference threshold, judging whether the time difference is larger than a second difference threshold which is smaller than the first difference threshold;
and when the time difference is larger than a second difference threshold value, synchronizing the local time to the target time corresponding to the current time information.
Optionally, when the time difference is greater than a second difference threshold, synchronizing the local time to the target time corresponding to the current time information includes:
when the time difference is larger than a second difference threshold, acquiring the cumulative times of the time deviation, wherein when the time difference is larger than the second difference threshold, marking the time deviation once, when the time difference is smaller than or equal to the second difference threshold, clearing the cumulative times of the time deviation, and marking the times of the time deviation again;
judging whether the accumulated times of the time deviation is greater than a time threshold value or not;
and when the cumulative times of the time deviation are greater than the time threshold, synchronizing the local time to the target time corresponding to the current time information, and clearing the cumulative times of the time deviation.
Optionally, the receiving current message information sent by the time service source device includes:
establishing communication connection with the time service source equipment;
and receiving the current message information sent by the time service source equipment through a communication channel indicated by the communication connection.
Optionally, the multiple timed devices further communicate with a bus server, and the method further includes:
receiving a time query instruction sent by the bus server, wherein the time query instruction is used for the bus server to acquire the current local time of each timed device;
and sending corresponding current local time to the bus server based on the time query instruction, wherein the bus server is used for calculating the current local time sent by the plurality of timed devices to obtain a time parameter so as to judge whether the timed devices are abnormal or not based on the time parameter.
Optionally, the time parameter includes a mean value and a variance of current local time respectively corresponding to the timed device, and the determining whether the timed device is abnormal based on the time parameter includes:
determining a time interval associated with the mean and variance;
and when the current local time is out of the time interval, the time service equipment is abnormal for time synchronization and step loss.
In a second aspect, an embodiment of the present invention provides a time synchronization apparatus, where multiple time-service devices perform time synchronization through one time service source device, and the apparatus is applied to the time-service devices, and the apparatus includes:
the current message information receiving module is used for receiving current message information sent by the time service source equipment, the current message information carries time information, the time service source equipment carries out time synchronization through a reference clock source, and the reference clock source is used for providing uniform clock information;
and the time synchronization module is used for synchronizing the local time into the target time corresponding to the time information.
In a third aspect, an embodiment of the present invention provides a time service device, including:
one or more processors;
a storage device to store one or more computer programs,
when executed by the one or more processors, cause the one or more processors to implement a method of time synchronization as in any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a time synchronization method according to any embodiment of the present invention.
In the embodiment of the invention, a plurality of time service devices carry out time synchronization through one time service source device, each time service device receives current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; the local time is synchronized to the target time corresponding to the time information, the problems that the satellite time synchronization device is expensive, and the cost of the synchronization time of the time service equipment is high due to the fact that the demand for installing a plurality of scattered time service equipment is large are solved, and the effect of reducing the synchronization time of the time service equipment is achieved.
Drawings
Fig. 1 is a schematic view of a scenario provided in an embodiment of the present invention;
fig. 2 is a schematic flowchart of a time synchronization method according to an embodiment of the present invention;
fig. 3 is a flowchart illustrating a time synchronization method according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a time synchronization apparatus according to a third embodiment of the present invention;
fig. 5 is a schematic structural diagram of a time service device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the steps as a sequential process, many of the steps can be performed in parallel, concurrently or simultaneously. In addition, the order of the steps may be rearranged. A process may be terminated when its operations are completed, but may have additional steps not included in the figure. A process may correspond to a method, a function, a procedure, a subroutine, a sub computer program, or the like.
Furthermore, the terms "first," "second," and the like may be used herein to describe various orientations, actions, steps, elements, or the like, but the orientations, actions, steps, or elements are not limited by these terms. These terms are only used to distinguish one direction, action, step or element from another direction, action, step or element. For example, the first information may be referred to as second information, and similarly, the second information may be referred to as first information, without departing from the scope of the present application. The first information and the second information are both information, but they are not the same information. The terms "first", "second", etc. are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Example one
Fig. 1 is a schematic view of a scenario provided in the first embodiment of the present invention. As can be seen from fig. 1, one time service source device 10 performs time synchronization to a plurality of time receiving devices 20, and the time service source device 10 performs time synchronization by using one reference clock source 30.
Fig. 2 is a flowchart of a time synchronization method according to an embodiment of the present invention, where the method is applied to a time service device, and is applicable to a scenario where the time service device performs time synchronization, and the method may be executed by a time synchronization apparatus, and the apparatus may be implemented in a software and/or hardware manner, and may be integrated on the time service device.
As shown in fig. 2, a time synchronization method provided in an embodiment of the present invention includes:
s110, receiving current message information sent by the time service source equipment, wherein the current message information carries time information, and the time service source equipment carries out time synchronization through a reference clock source.
The time service source device is a device for providing a time synchronization base station for the time service device. In this embodiment, the time service equipment may be a power transformation total station protection device in a digital power system, and is not specifically limited herein. The time service source device may be a single device, or may be one of a plurality of time service receiving devices, and is not limited herein. The current message information refers to data units exchanged and transmitted in the network, that is, data blocks to be sent by the station at one time. In this embodiment, the current packet information refers to information for notifying the time service device to perform time synchronization, and the current packet information carries time information. The time information is information related to time and is used for providing a time reference for time synchronization of the time service source equipment. Specifically, the current message information may be an HTTP (hypertext transfer protocol) message, and the time information may be included in message data in the HTTP message. The reference clock source is a device which provides a high-precision time reference for the time service source device. Optionally, the delay of the reference clock source is below 20ms (milliseconds). Illustratively, the reference clock source may be a satellite synchronous time tick. The satellite synchronous time setting device is advanced in satellite time setting, network synchronization, frequency measurement and control and other technologies, and provides high-precision time information. Optionally, the current message information may be sent by the time service source device every preset time, for example, every 1min (minute), and the current message information is received by the time service device every 1 min; the time service source device may also send a time synchronization request to the time service source device actively, and the time service source device sends current message information carrying time information to the time service source device based on the time synchronization request, which is not limited specifically here. In this embodiment, the reference clock source is used to provide uniform clock information.
In an optional implementation manner, the receiving current message information sent by the time service source device includes:
establishing communication connection with the time service source equipment; and receiving the current message information sent by the time service source equipment through a communication channel indicated by the communication connection.
In this embodiment, the communication connection may be a TCP (Transmission Control Protocol) connection or a UDP (User Datagram Protocol) connection, and the present invention is not limited thereto. The communication channel is a channel indicated by communication connection and is used for transmitting current message information between the time service source device and the time service device.
And S120, synchronizing the local time to the target time corresponding to the time information.
The local time refers to the time of the timed device. The target time refers to a time corresponding to the time information. For example, when the current time information included in the time information is 10:00, the target time is also 10: 00.
The multiple timed devices of the embodiment perform time synchronization through one time service source device, thereby reducing the cost of time synchronization. In addition, the time service source device also carries out time synchronization through a reference clock source, so that the problem that the local time of the timed device is disordered due to the error of the clock of the time service source, such as time jump is avoided. In addition, when the reference clock source is a high-precision clock source, the cost of time synchronization of the time service equipment is reduced on the premise of not losing time precision.
In an optional embodiment, synchronizing the local time to the target time corresponding to the time information includes:
analyzing the current message information to obtain a message header, information length, cyclic redundancy check code and time information carried by the current message information corresponding to the current message information; when the message header, the cyclic redundancy check code and the information length are correct, extracting current time information carried by the current message information; extracting last time information in last message information; judging whether the current time information is greater than the last time information; and when the current time information is larger than the last time information, synchronizing the local time to be the target time corresponding to the current time information.
The information length refers to the byte length of the current message information. The cyclic redundancy check code is used for checking whether the current message information is correct. In this embodiment, the time information carried by the current message information is extracted only when the message header, the cyclic redundancy check code, and the information length are correct. Optionally, when the content of the header is consistent with the preset content and the information length is consistent with the preset length, the header and the information length are considered to be correct. The current time information is a mapping of the current local time of the time service source device. The last time information refers to the time information carried in the last current message information. It should be noted that, it may be determined whether last time information corresponding to the current time information exists first, and when the last time information corresponding to the current time information does not exist, the current time synchronization may be the first time synchronization, and then the step of receiving the current message information sent by the time service source device is returned to be executed. In the embodiment, before the synchronization time, whether the current time information is greater than the last time information is checked, and when the last time information is less than the current time information, the time synchronization is performed, so that the accuracy of the time synchronization is improved.
In an optional implementation manner, when the current time information is greater than the previous time information, synchronizing a local time to a target time corresponding to the current time information includes:
when the current time information is larger than the last time information, the current local time of the timed device is obtained; calculating a time difference value between the current local time and the current time information; judging whether the time difference is larger than a first difference threshold value or not; when the time difference is larger than the first difference threshold, the current time information is discarded as an abnormal value; when the time difference is not larger than the first difference threshold, judging whether the time difference is larger than a second difference threshold; and when the time difference is larger than a second difference threshold value, synchronizing the local time to the target time corresponding to the current time information.
The current local time refers to the current local time of the timed device. The time difference value is the difference value between the current local time and the current time information. Specifically, the time difference is expressed in the form of an absolute value. And when the time difference is not greater than the first difference threshold and is greater than the second difference threshold, synchronizing the local time to be the target time corresponding to the current time information. In this embodiment, the first difference threshold is used to determine whether the current time information is an abnormal value, i.e. the time difference is too large. The first difference threshold may be set according to needs, and the first difference threshold is greater than the second difference threshold, and optionally, the first difference threshold may be set for 1min (minute), which is not limited herein. The second difference threshold may be a time of 1S (second) or more, and may be set as needed, and is not particularly limited herein. In the embodiment, time synchronization is performed only when the time difference is not greater than the first difference threshold and is greater than the second difference threshold, so that the local time is prevented from being updated incorrectly due to the fact that the time service equipment updates the local time frequently.
In an optional implementation manner, when the time difference is greater than a second difference threshold, synchronizing the local time to a target time corresponding to the current time information includes:
when the time difference is larger than a second difference threshold, acquiring the cumulative times of the time deviation, wherein when the time difference is larger than the second difference threshold, marking the time deviation once, when the time difference is smaller than or equal to the second difference threshold, clearing the cumulative times of the time deviation, and marking the times of the time deviation again; judging whether the accumulated times of the time deviation is greater than a time threshold value or not; and when the cumulative times of the time deviation are greater than the time threshold, synchronizing the local time to the target time corresponding to the current time information, and clearing the cumulative times of the time deviation.
The accumulated number of the time deviations is the accumulated number of the time differences larger than the second difference threshold. In each time synchronization process, when the time difference is larger than the second difference threshold, marking one time of time deviation, and when the time difference is smaller than or equal to the second difference threshold, clearing the accumulated times of the time deviation. Specifically, the cumulative number of times of the time deviation represents the number of times that the time difference value is greater than the second difference threshold value continuously occurs in the process of multiple times of synchronization time. Alternatively, the number threshold may be set to any number of times of 1 and more as the number threshold, and is not limited herein. Preferably, the number threshold may be 1. The time synchronization is performed when the cumulative number of time deviations is greater than a number threshold.
For example, taking the number threshold as 1 as an example, when the time service device is in each synchronization time, it is determined whether the time difference is greater than a second difference threshold, if the time difference is greater than the second difference threshold in the process of the current synchronization time, a one-time deviation is marked, and then it is determined whether the cumulative number of times of the time deviation is greater than 1, if the cumulative number is 1, it is determined that the previous time difference is less than or equal to the second difference threshold, and the current time may be out of synchronization; if the cumulative number of times is 2, it indicates that the time difference value of the last time is greater than the second difference threshold, and the time difference value of the current time is greater than the second difference threshold, it is determined that there is an error that cannot be allowed in the local time and the time information for 2 consecutive times, and therefore, the time synchronization operation is performed.
According to the technical scheme of the embodiment of the invention, a plurality of time service devices carry out time synchronization through one time service source device, each time service device receives current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; the local time is synchronized to the target time corresponding to the time information, and because the time synchronization is carried out on the plurality of time service devices through one time service source device, each time service device does not need to be independently allocated to a satellite time synchronization device, so that the technical effect of reducing the time synchronization cost of the time service devices is achieved.
Example two
Fig. 3 is a flowchart illustrating a time synchronization method according to a second embodiment of the present invention. The embodiment is further detailed in the technical scheme, and is suitable for a scene that the timed device performs verification in the synchronous time. The method can be executed by a time synchronization device, which can be implemented in software and/or hardware and can be integrated on a timed device.
As shown in fig. 3, the time synchronization method provided by the second embodiment of the present invention includes:
s210, receiving current message information sent by the time service source equipment, wherein the current message information carries time information, and the time service source equipment carries out time synchronization through a reference clock source.
S220, synchronizing the local time to the target time corresponding to the time information.
S230, receiving a time query instruction sent by the bus server, wherein the time query instruction is used for the bus server to obtain the current local time of each timed device.
The time query instruction refers to an instruction sent by the bus server for acquiring the current local time of each timed device. The current local time refers to the current local time of the timed device. Specifically, in a plurality of time service devices, each time service device corresponds to a current local time, and the current local times corresponding to different time service devices may be different. In this embodiment, the plurality of time service receiving devices also communicate with the bus server.
S240, sending corresponding current local time to the bus server based on the time query instruction, wherein the bus server is used for calculating the current local time sent by the plurality of timed devices to obtain a time parameter, and judging whether the timed devices are abnormal or not based on the time parameter.
In this step, the time service equipment sends the corresponding current local time to the bus server, and the bus server calculates the time parameter according to the current local time sent by each time service equipment, so as to judge whether the time service equipment is abnormal or not according to the time parameter.
In an optional implementation manner, the time parameter may include a mean value and a variance of current local time respectively corresponding to the timed device, and the determining, based on the time parameter, whether the timed device is abnormal includes:
determining a time interval associated with the mean and variance; and when the current local time is out of the time interval, the time service equipment is abnormal for time synchronization and step loss.
Wherein a time interval refers to an interval associated with a mean and a variance. Specifically, the lower limit of the time interval is positively correlated with the mean and negatively correlated with the variance, and the upper limit of the time interval is positively correlated with the mean and positively correlated with the variance. Illustratively, when the mean is μ, the variance is σ 2The time interval may be (μ -3 σ, μ +3 σ), and is not particularly limited herein. According to probability statistics, the probability that the current local time falls within the interval (mu-3 sigma, mu +3 sigma) is 99.7%, and the probability that the current local time falls outside the interval (mu-3 sigma, mu +3 sigma) is less than 3 per thousand. And if the current local time of the timed device is out of the time interval, the abnormity of the timed device is considered as the time synchronization and step loss abnormity. Specifically, each time service device executes the step, and when the current local time of one time service device is outside the time interval, the time service device is abnormal for synchronization and desynchronization, and an alarm prompt is sent. Alternatively, the step of receiving the time inquiry command sent by the bus server may be executed again at preset time intervals, for example, 1h (hour).
In this embodiment, the process of confirming the abnormality is completed in each timed device, each timed device determines whether itself is abnormal according to the time parameter fed back by the bus server, and if so, the abnormal timed device may send out an alarm.
It can be understood that, in another embodiment, the bus server may also determine whether the time-granted device is abnormal according to the time parameter, and if the time-granted device is abnormal, the bus server reports the identification number (ID) of the abnormal time-granted device.
According to the embodiment, the time parameters are obtained by calculating the current local time corresponding to the plurality of time service devices respectively, and the time parameters are used for checking, so that whether the time service devices are abnormal or not is determined, and the accuracy of time synchronization is further improved. Furthermore, a specific anomaly of the time synchronization may be determined.
According to the technical scheme of the embodiment of the invention, a plurality of time service devices carry out time synchronization through one time service source device, each time service device receives current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; the local time is synchronized to the target time corresponding to the time information, and because the time synchronization is carried out on the plurality of time service devices through one time service source device, each time service device does not need to be independently allocated to a satellite time synchronization device, so that the technical effect of reducing the time synchronization cost of the time service devices is achieved.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a time synchronization apparatus according to a third embodiment of the present invention, where this embodiment is applicable to a scenario in which a time service device performs time synchronization, and the apparatus may be implemented in a software and/or hardware manner, and may be integrated on the time service device.
As shown in fig. 4, the time synchronization apparatus provided in this embodiment may include a current packet information receiving module 310 and a time synchronization module 320, where:
a current message information receiving module 310, configured to receive current message information sent by the time service source device, where the current message information carries time information, the time service source device performs time synchronization by using a reference clock source, and the reference clock source is used to provide uniform clock information; the time synchronization module 320 is configured to synchronize the local time to a target time corresponding to the time information.
Optionally, the time synchronization module 320 includes: the analysis unit is used for analyzing the current message information to obtain a message header, information length, cyclic redundancy check code and time information carried by the current message information corresponding to the current message information; the extraction unit is used for extracting the current time information carried by the current message information when the message header, the cyclic redundancy check code and the information length are correct; extracting last time information in last message information; the judging unit is used for judging whether the current time information is larger than the last time information; and the time synchronization unit is used for synchronizing the local time to the target time corresponding to the current time information when the current time information is greater than the last time information.
Optionally, the time synchronization unit includes: the local time obtaining subunit is configured to obtain a current local time of the timed device when the current time information is greater than the previous time information; a time difference calculation subunit, configured to calculate a time difference between the current local time and the current time information; the judging subunit is used for judging whether the time difference value is greater than a first difference threshold value; when the time difference is larger than the first difference threshold, the current time information is discarded as an abnormal value; when the time difference is not larger than the first difference threshold, judging whether the time difference is larger than a second difference threshold which is smaller than the first difference threshold; and the time synchronization subunit is configured to synchronize the local time to a target time corresponding to the current time information when the time difference is greater than a second difference threshold.
Optionally, the time synchronization subunit is specifically configured to, when the time difference is greater than a second difference threshold, obtain an accumulated number of times of time deviation, where, when the time difference is greater than the second difference threshold, once time deviation is marked, and when the time difference is less than or equal to the second difference threshold, zero is performed on the accumulated number of times of time deviation, and the number of times of time deviation is marked again; judging whether the accumulated times of the time deviation is greater than a time threshold value or not; and when the cumulative times of the time deviation are greater than the time threshold, synchronizing the local time to the target time corresponding to the current time information, and clearing the cumulative times of the time deviation.
Optionally, the current packet information receiving module 310 includes: the communication establishing unit is used for establishing communication connection with the time service source equipment; and the current message information receiving unit is used for receiving the current message information sent by the time service source equipment through the communication channel indicated by the communication connection.
Optionally, the multiple timed devices further communicate with a bus server, and the apparatus further includes: the time query instruction receiving module is used for receiving a time query instruction sent by the bus server, and the time query instruction is used for the bus server to obtain the current local time of each timed device; and the current local time sending module is used for sending corresponding current local time to the bus server based on the time query instruction, wherein the bus server is used for calculating the current local time sent by the plurality of timed devices to obtain a time parameter so as to judge whether the timed devices are abnormal or not based on the time parameter.
Optionally, the time parameter includes a mean value and a variance of current local time respectively corresponding to the timed device, and the apparatus further includes an anomaly determination module configured to determine a time interval associated with the mean value and the variance; and when the current local time is out of the time interval, the time service equipment is abnormal for time synchronization and step loss.
The time synchronization device provided by the embodiment of the invention can execute the time synchronization method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. Reference may be made to the description of any method embodiment of the invention not specifically described in this embodiment.
Example four
Fig. 5 is a schematic structural diagram of a time service device according to a fourth embodiment of the present invention. Figure 5 illustrates a block diagram of an exemplary timed device 612 suitable for use in implementing embodiments of the present invention. The timed device 612 shown in figure 5 is only an example and should not bring any limitations to the functionality and scope of use of the embodiments of the present invention.
As shown in fig. 5, the time-receiving device 612 is represented as a general time-receiving device. The components of the timed device 612 may include, but are not limited to: one or more processors 616, a memory device 628, and a bus 618 that couples the various system components including the memory device 628 and the processors 616.
Bus 618 represents one or more of any of several types of bus structures, including a memory device bus or memory device controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The timed device 612 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by the time service device 612 and includes both volatile and nonvolatile media, removable and non-removable media.
Storage 628 may include computer system readable media in the form of volatile Memory, such as Random Access Memory (RAM) 630 and/or cache Memory 632. Terminal 612 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 634 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk such as a Compact disk Read-Only Memory (CD-ROM), Digital Video disk Read-Only Memory (DVD-ROM) or other optical media may be provided. In such cases, each drive may be connected to bus 618 by one or more data media interfaces. The memory device 628 may include at least one computer program product having a set (e.g., at least one) of computer program modules configured to perform the functions of embodiments of the present invention.
A computer program/utility 640 having a set (at least one) of computer program modules 642 may be stored, for example, in storage 628, such computer program modules 642 including, but not limited to, an operating system, one or more application computer programs, other computer program modules, and computer program data, each of which examples or some combination may comprise an implementation of a network environment. The computer program modules 642 generally perform the functions and/or methods of the described embodiments of the present invention.
The timed device 612 may also communicate with one or more external devices 614 (e.g., keyboard, pointing terminal, display 624, etc.), with one or more terminals that enable a user to interact with the timed device 612, and/or with any terminals (e.g., network card, modem, etc.) that enable the timed device 612 to communicate with one or more other computing terminals. Such communication may occur via input/output (I/O) interfaces 622. Also, the timed device 612 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public Network, such as the internet) via the Network adapter 620. As shown in FIG. 5, the network adapter 620 communicates with the other modules of the timed device 612 via the bus 618. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the timed device 612, including but not limited to: microcode, end drives, Redundant processors, external disk drive Arrays, RAID (Redundant Arrays of independent disks) systems, tape drives, and data backup storage systems.
The processor 616 executes various functional applications and data processing by running computer programs stored in the storage device 628, for example, implementing a time synchronization method provided by any embodiment of the present invention, which may include:
receiving current message information sent by the time service source equipment, wherein the current message information carries time information, and the time service source equipment carries out time synchronization through a reference clock source;
and synchronizing the local time to the target time corresponding to the time information.
According to the technical scheme of the embodiment of the invention, a plurality of time service devices carry out time synchronization through one time service source device, each time service device receives current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; the local time is synchronized to the target time corresponding to the time information, and because the time synchronization is carried out on the plurality of time service devices through one time service source device, each time service device does not need to be independently allocated to a satellite time synchronization device, so that the technical effect of reducing the time synchronization cost of the time service devices is achieved.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a time synchronization method provided in any embodiment of the present invention, and the method may include:
receiving current message information sent by the time service source equipment, wherein the current message information carries time information, and the time service source equipment carries out time synchronization through a reference clock source;
and synchronizing the local time to the target time corresponding to the time information.
The computer-readable storage media of embodiments of the invention may take any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable computer program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a computer program for use by or in connection with an instruction execution system, apparatus, or device.
Computer program code embodied on a storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more computer programming languages, including an object oriented computer programming language such as Java, Smalltalk, C + +, and conventional procedural computer programming languages, such as the "C" language or similar computer programming languages. The computer program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or terminal. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
According to the technical scheme of the embodiment of the invention, a plurality of time service devices carry out time synchronization through one time service source device, each time service device receives current message information sent by the time service source device, the current message information carries time information, and the time service source device carries out time synchronization through a reference clock source; the local time is synchronized to the target time corresponding to the time information, and because the time synchronization is carried out on the plurality of time service devices through one time service source device, each time service device does not need to be independently allocated to a satellite time synchronization device, so that the technical effect of reducing the time synchronization cost of the time service devices is achieved.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A time synchronization method is characterized in that a plurality of time service devices carry out time synchronization through a time service source device, and the method is applied to the time service devices and comprises the following steps:
receiving current message information sent by the time service source equipment, wherein the current message information carries time information, the time service source equipment carries out time synchronization through a reference clock source, and the reference clock source is used for providing uniform clock information;
and synchronizing the local time to the target time corresponding to the time information.
2. The method of claim 1, wherein the synchronizing the local time to the target time corresponding to the time information comprises:
analyzing the current message information to obtain a message header, information length, cyclic redundancy check code and time information carried by the current message information corresponding to the current message information;
when the message header, the cyclic redundancy check code and the information length are correct, extracting current time information carried by the current message information;
extracting last time information in last message information;
judging whether the current time information is greater than the last time information;
and when the current time information is larger than the last time information, synchronizing the local time to be the target time corresponding to the current time information.
3. The method of claim 2, wherein the synchronizing the local time to the target time corresponding to the current time information when the current time information is greater than the previous time information comprises:
when the current time information is larger than the last time information, the current local time of the timed device is obtained;
calculating a time difference value between the current local time and the current time information;
judging whether the time difference is larger than a first difference threshold value or not;
when the time difference is larger than the first difference threshold, the current time information is discarded as an abnormal value;
when the time difference is not larger than the first difference threshold, judging whether the time difference is larger than a second difference threshold which is smaller than the first difference threshold;
and when the time difference is larger than a second difference threshold value, synchronizing the local time to the target time corresponding to the current time information.
4. The method of claim 3, wherein when the time difference is greater than a second difference threshold, then synchronizing the local time to a target time corresponding to the current time information comprises:
When the time difference is larger than a second difference threshold, acquiring the cumulative times of the time deviation, wherein when the time difference is larger than the second difference threshold, marking the time deviation once, when the time difference is smaller than or equal to the second difference threshold, clearing the cumulative times of the time deviation, and marking the times of the time deviation again;
judging whether the accumulated times of the time deviation is greater than a time threshold value or not;
and when the cumulative times of the time deviation are greater than the time threshold, synchronizing the local time to the target time corresponding to the current time information, and clearing the cumulative times of the time deviation.
5. The method according to claim 1, wherein the receiving current message information sent by the time service source device includes:
establishing communication connection with the time service source equipment;
and receiving the current message information sent by the time service source equipment through a communication channel indicated by the communication connection.
6. The method of claim 1, wherein the plurality of timed devices are also in communication with a bus server, the method further comprising:
receiving a time query instruction sent by the bus server, wherein the time query instruction is used for the bus server to acquire the current local time of each timed device;
And sending corresponding current local time to the bus server based on the time query instruction, wherein the bus server is used for calculating the current local time sent by the plurality of timed devices to obtain a time parameter so as to judge whether the timed devices are abnormal or not based on the time parameter.
7. The method as claimed in claim 6, wherein the time parameters include a mean value and a variance of current local time respectively corresponding to the timed device, and the determining whether the timed device is abnormal based on the time parameters includes:
determining a time interval associated with the mean and variance;
and when the current local time is out of the time interval, the time service equipment is abnormal for time synchronization and step loss.
8. A time synchronization device is characterized in that a plurality of time service devices carry out time synchronization through a time service source device, the device is applied to the time service devices, and the device comprises:
the current message information receiving module is used for receiving current message information sent by the time service source equipment, the current message information carries time information, the time service source equipment carries out time synchronization through a reference clock source, and the reference clock source is used for providing uniform clock information;
And the time synchronization module is used for synchronizing the local time into the target time corresponding to the time information.
9. A timed device, comprising:
one or more processors;
storage means for storing one or more computer programs;
when executed by the one or more processors, cause the one or more processors to implement the time synchronization method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method for time synchronization according to any one of claims 1-7.
CN202010662789.2A 2020-07-10 2020-07-10 Time synchronization method, device, time-given equipment and storage medium Active CN111865466B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010662789.2A CN111865466B (en) 2020-07-10 2020-07-10 Time synchronization method, device, time-given equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010662789.2A CN111865466B (en) 2020-07-10 2020-07-10 Time synchronization method, device, time-given equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111865466A true CN111865466A (en) 2020-10-30
CN111865466B CN111865466B (en) 2023-11-03

Family

ID=73153175

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010662789.2A Active CN111865466B (en) 2020-07-10 2020-07-10 Time synchronization method, device, time-given equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111865466B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114006674A (en) * 2021-12-31 2022-02-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment
CN114765586A (en) * 2021-01-13 2022-07-19 华为技术有限公司 Method, device and system for detecting time synchronization performance
WO2023125392A1 (en) * 2021-12-27 2023-07-06 华为技术有限公司 Communication method and apparatus
WO2023226821A1 (en) * 2022-05-24 2023-11-30 华为技术有限公司 Clock synchronization method and apparatus, and serial number generation method and apparatus

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105141406A (en) * 2015-09-29 2015-12-09 北京润科通用技术有限公司 Time synchronization method, time synchronization apparatus and simulation system
CN110932839A (en) * 2018-09-20 2020-03-27 中兴通讯股份有限公司 Network card, time synchronization method, equipment and computer storage medium
CN111064538A (en) * 2019-12-13 2020-04-24 新华三大数据技术有限公司 Time service message sending method, device and equipment, medium main control board and frame type equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105141406A (en) * 2015-09-29 2015-12-09 北京润科通用技术有限公司 Time synchronization method, time synchronization apparatus and simulation system
CN110932839A (en) * 2018-09-20 2020-03-27 中兴通讯股份有限公司 Network card, time synchronization method, equipment and computer storage medium
CN111064538A (en) * 2019-12-13 2020-04-24 新华三大数据技术有限公司 Time service message sending method, device and equipment, medium main control board and frame type equipment

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114765586A (en) * 2021-01-13 2022-07-19 华为技术有限公司 Method, device and system for detecting time synchronization performance
WO2023125392A1 (en) * 2021-12-27 2023-07-06 华为技术有限公司 Communication method and apparatus
CN114006674A (en) * 2021-12-31 2022-02-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment
CN114006674B (en) * 2021-12-31 2022-04-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment
WO2023226821A1 (en) * 2022-05-24 2023-11-30 华为技术有限公司 Clock synchronization method and apparatus, and serial number generation method and apparatus

Also Published As

Publication number Publication date
CN111865466B (en) 2023-11-03

Similar Documents

Publication Publication Date Title
CN111865466A (en) Time synchronization method and device, timed equipment and storage medium
CN110427422B (en) Data consistency checking method and equipment during data synchronization abnormity and storage medium
CN111726420A (en) Communication method, device, equipment and storage medium based on RPA
CN111259022A (en) Information synchronization method, synchronization system, computer equipment and medium
CN112968747B (en) Time calibration method and device, computer equipment and storage medium
CN111796978B (en) Interface detection method, device, system, equipment and storage medium
US8793402B2 (en) Synchronizing time across a plurality of devices connected to a network
CN111061740A (en) Data synchronization method, equipment and storage medium
CN113032412A (en) Data synchronization method and device, electronic equipment and computer readable medium
CN111162880B (en) Data transmission method, device, equipment and storage medium
CN109889922B (en) Method, device, equipment and storage medium for forwarding streaming media data
CN111125222A (en) Data testing method and device
CN110995538B (en) Network data acquisition method, device, system, equipment and storage medium
CN110585724B (en) Method and device for updating form data in game client
CN112994980A (en) Time delay testing method and device, electronic equipment and storage medium
CN108306865B (en) Modbus packet-sticking processing method and device based on Netty framework
CN114553663B (en) Abnormality detection method, abnormality detection device, abnormality detection equipment and storage medium
CN115865753A (en) Data processing method and device and electronic equipment
CN111741046B (en) Data reporting method, data acquisition method, device, equipment and medium
CN110928955B (en) Data interaction method and device, computer equipment and storage medium
CN111628913B (en) Online time length determining method and device, readable medium and electronic equipment
CN110569182B (en) Crash rate calculation method and device, computer equipment and storage medium
CN110365763B (en) Data synchronization method, device, equipment and storage medium
CN110633182B (en) System, method and device for monitoring server stability
CN112948195A (en) Interface testing method and device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant