[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN116131984A - Reference time determining method and device, electronic equipment and storage medium - Google Patents

Reference time determining method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116131984A
CN116131984A CN202310019566.8A CN202310019566A CN116131984A CN 116131984 A CN116131984 A CN 116131984A CN 202310019566 A CN202310019566 A CN 202310019566A CN 116131984 A CN116131984 A CN 116131984A
Authority
CN
China
Prior art keywords
time
satellite
reference time
local system
preset
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
CN202310019566.8A
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.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent 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 Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202310019566.8A priority Critical patent/CN116131984A/en
Publication of CN116131984A publication Critical patent/CN116131984A/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
    • H04J3/0641Change of the master or reference, e.g. take-over or failure of the master
    • 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)

Abstract

The embodiment of the invention provides a reference time determining method, a device, electronic equipment and a storage medium, wherein the method is applied to a Network Time Protocol (NTP) server, and the NTP server is configured with a Global Positioning System (GPS) module, and the method comprises the following steps: acquiring an update period for a reference time; according to the updating period, acquiring satellite time and the number of currently searched satellites through a GPS module, and acquiring local system time; judging whether the number of satellites is larger than or equal to a preset value; if the number of satellites is greater than or equal to a preset value, using satellite time as reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time. The method can continuously provide stable and accurate reference time for the NTP server.

Description

Reference time determining method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of network timing technologies, and in particular, to a method and apparatus for determining a reference time, an electronic device, and a storage medium.
Background
NTP (Network Time Protocol ) is a protocol used to time synchronize computers. NTP servers, i.e. servers based on the NTP protocol, are used for time synchronization between a distributed time server and clients. The NTP server is equipped with a GPS (Global Positioning System ) module, and can acquire satellite system time through the GPS module and take the time as NTP server reference time. However, the satellite system time acquired by the GPS module is affected by many factors, and there is instability, so that abnormal offset and jitter may occur in the satellite system time acquired by the GPS module, which may cause inaccuracy in the reference time acquired by the NTP server, and further the NTP server may not perform accurate time synchronization on the terminal device.
Disclosure of Invention
In view of the foregoing, embodiments of the present invention are directed to providing a reference time determining method, apparatus, electronic device, and storage medium that overcome or at least partially solve the foregoing problems.
To solve the above-mentioned problems, in a first aspect, an embodiment of the present invention discloses a reference time determining method, which is applied to a network time protocol NTP server, where the NTP server is configured with a GPS module, and the method includes:
acquiring an update period for a reference time; the reference time is a time for performing time synchronization;
according to the updating period, acquiring satellite time and the number of currently searched satellites through the GPS module, and acquiring local system time;
judging whether the satellite number is larger than or equal to a preset value;
if the satellite number is greater than or equal to the preset value, using the satellite time as a reference time; and if the satellite number is smaller than the preset value, using the local system time as the reference time.
Optionally, the using the local system time as a reference time includes:
acquiring a deviation value of the local system time and the satellite time 5 when the reference time is updated every time in a first preset time period;
adjusting the local system time according to the average value of the deviation values;
and using the adjusted local system time as a reference time.
Optionally, the adjusting the local system time according to the average value of the deviation values includes:
acquiring the deviation value of the local system time and the satellite time when the reference time of the NTP server is switched from the local system 0 time to the satellite time in a second preset time period,
and taking the deviation value as a fault deviation value;
subtracting the last fault deviation value in the second preset time period from the average value of the deviation values in the first preset time period to obtain a time adjustment value;
and adjusting the local system time according to the time adjustment value.
5, optionally, if the number of satellites is greater than or equal to the preset value, using the satellites
Time as a reference time, including:
and if the number of the satellites is larger than or equal to the preset value and the deviation value of the satellite time and the local system time is smaller than or equal to the average value of the deviation values, using the satellite time as the reference time.
0, the method further comprising:
if the number of the satellites is larger than or equal to the preset value, recording the deviation value of the local system time and the satellite time, and synchronizing the satellite time to the local system time.
Optionally, the method further comprises:
acquiring the satellite 5 time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
if the satellite time and the satellite number cannot be acquired, recording the times of the satellite time and the satellite number which cannot be acquired;
if the satellite time and the satellite number cannot be acquired more than or equal to the preset times before the reference time is updated, the local system time is used as the reference time when the reference time is updated.
Optionally, the method further comprises:
acquiring the satellite time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
if the satellite time and the satellite number cannot be acquired when the reference time is updated, sequentially judging whether the satellite number acquired before the reference time is updated is greater than or equal to the preset value;
and if the satellite number is greater than or equal to the preset value, using the satellite time acquired simultaneously with the satellite number as a reference time.
In a second aspect, an embodiment of the present invention discloses a reference time determining apparatus, which is applied to a network time protocol NTP server, where the NTP server is configured with a GPS module, and the apparatus includes:
the updating period acquisition module is used for acquiring the updating period aiming at the reference time; the reference time is a time for performing time synchronization;
the reference time acquisition module is used for acquiring satellite time and the number of currently searched satellites and acquiring local system time through the GPS module according to the updating period;
the reference time judging module is used for judging whether the number of satellites is larger than or equal to a preset value;
the reference time determining module is used for using the satellite time as reference time if the number of the satellites is larger than or equal to the preset value; and if the satellite number is smaller than the preset value, using the local system time as the reference time.
Optionally, the reference time determining module includes: the local system time adjusting module is used for acquiring the deviation value of the local system time and the satellite time when the reference time is updated every time in a first preset time period;
adjusting the local system time according to the average value of the deviation values;
the local system time synchronization module is used for using the adjusted local system time as a reference time.
Optionally, the local system time adjustment module is further configured to:
acquiring a deviation value of the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time in a second preset time period, and taking the deviation value as a fault deviation value;
subtracting the last fault deviation value in the second preset time period from the average value of the deviation values in the first preset time period to obtain a time adjustment value;
and adjusting the local system time according to the time adjustment value.
Optionally, the reference time determining module includes a satellite time synchronization module, where the satellite time synchronization module is configured to:
and if the number of the satellites is larger than or equal to the preset value and the deviation value of the satellite time and the local system time is smaller than or equal to the average value of the deviation values, using the satellite time as the reference time.
Optionally, the reference time determining module includes a bias value recording module and a satellite time synchronizing module, where the bias value recording module is configured to:
and if the number of the satellites is larger than or equal to the preset value, recording a deviation value of the local system time and the satellite time, wherein the satellite time synchronizing module is used for synchronizing the satellite time to the local system time.
Optionally, the reference time determining device includes a satellite time monitoring module and a satellite time synchronization module, where the satellite time monitoring module is configured to:
acquiring the satellite time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
if the satellite time and the satellite number cannot be acquired, recording the times of the satellite time and the satellite number which cannot be acquired;
the satellite time synchronization module is configured to use the local system time as a reference time when the reference time is updated if the satellite time and the number of satellites cannot be obtained by more than or equal to a preset number of times before the reference time is updated.
Optionally, the reference time determining device includes a satellite time monitoring module and a satellite time synchronization module, where the satellite time monitoring module is configured to:
acquiring the satellite time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
the satellite time synchronization module is configured to sequentially determine whether the number of satellites acquired before the reference time is updated is greater than or equal to the preset value if the satellite time and the number of satellites cannot be acquired when the reference time is updated;
and if the satellite number is greater than or equal to the preset value, using the satellite time acquired simultaneously with the satellite number as a reference time.
In a third aspect, the invention shows an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, which processor, when executing the program, implements the steps of the reference time determination method according to the first aspect.
In a fourth aspect, the present invention shows a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the reference time determination method according to the first aspect.
The embodiment of the invention has the following advantages:
acquiring an update period for a reference time; acquiring satellite time and the number of currently searched satellites according to the updating period, and acquiring local system time; judging whether the number of satellites is larger than or equal to a preset value; if the number of satellites is greater than or equal to a preset value, using satellite time as reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time. The embodiment of the invention can continuously provide stable and accurate reference time for the NTP server.
Drawings
FIG. 1 is a flowchart of steps of a reference time determining method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a reference time determination method according to an embodiment of the present invention;
FIG. 3 is a block diagram of a reference time determining apparatus according to an embodiment of the present invention;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present invention;
fig. 5 is a block diagram of a computer-readable storage medium according to an embodiment of the present invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
In order to solve the problems that the reference time of the NTP server is unavailable, unrecognizable, unavailable and the like, the invention provides a method for providing a plurality of selectable reference times for the NTP server, wherein the selectable reference times comprise satellite time and local system time, the satellite time is monitored, and the local system time is rectified, so that the accurate reference time is continuously and stably provided for terminal equipment.
Referring to fig. 1, a step flowchart of a reference time determining method provided by an embodiment of the present invention is shown, where the method is applied to a network time protocol NTP server, and the NTP server is configured with a GPS module, and the method specifically may include the following steps:
step 101, acquiring an update period for reference time; the reference time is a time for performing time synchronization.
The NTP server may be applied to time synchronization, and the NTP server is divided into two types, i.e., a client NTP server and a server NTP server when used for time synchronization. The client NTP server obtains the time information sent by the server NTP server through the existing network environment, and the function of a slave clock is realized. The server side NTP server mainly provides a time unifying function for network devices such as a server, a computer and the like in a network, and realizes the function of a master clock. The time for time synchronization provided by the server side NTP server for the client side NTP server is the reference time.
The NTP server may update the reference time once every preset period, where the update period may be set by itself, for example, the update period may be set to 20 minutes, that is, the reference time may be updated once every 20 minutes, or the update period may be set to 30 minutes, that is, the reference time may be updated once every 30 minutes, and so on.
Step 102, according to the update period, acquiring satellite time and the number of currently searched satellites and acquiring local system time through the GPS module.
After the update period for the reference time is acquired, the local system time can be acquired according to the update period, and the satellite time and the number of currently searched satellites can be acquired through a GPS module configured on the NTP server. For example, with an update period of 20 minutes, satellite time, satellite number, and local system time may be acquired every 20 minutes.
The local system time may be obtained by a system command. For example, a "running" dialog box can be called out through the windows+r combination key, then "cmd" is input in the "running" input box, the cmd command is opened, and under the condition that the computer is ensured to be connected to the network, the local system time can be obtained by entering "net time\\local IP address" in the command box and then getting back. The local system time obtaining method is also many, and will not be described in detail here.
The GPS navigation satellite is generally equipped with a high-precision anchor atomic clock and a hydrogen atomic clock, and can provide accurate and high-precision time. The GPS module configured on the NTP server can receive satellite signals sent by the GPS navigation satellites, the satellite signals comprise time information provided by the GPS navigation satellites, and satellite time can be obtained by analyzing the time information. The number of satellites refers to the number of satellites that can be searched when the satellite time is acquired.
And step 103, judging whether the satellite number is larger than or equal to a preset value.
The signal quality of the current GPS module can be judged through the number of satellites, in general, the GPS module can simultaneously receive signals of 4-8 satellites in the visual field range at any time, and the more the received satellite signals are, namely the larger the number of the searched satellites is, the better the signal quality acquired by the GPS module is proved. Therefore, after the number of satellites is obtained through the GPS module, whether the satellite time is accurate or not can be judged according to the comparison of the number of satellites and a preset value. The preset value can be set correspondingly according to the maximum number of satellites that can be searched by the GPS module, for example, the preset value can be set to be 6, and after the number of satellites is obtained each time, whether the number of satellites is greater than or equal to 6 is judged.
104, if the number of satellites is greater than or equal to the preset value, using the satellite time as a reference time; and if the satellite number is smaller than the preset value, using the local system time as the reference time.
If the number of satellites is greater than or equal to the preset value, the satellite time acquired simultaneously with the number of satellites is proved to be relatively accurate, so that the satellite time is used as the reference time of the NTP server. If the number of satellites is smaller than the preset value, it is proved that the satellite time acquired simultaneously with the number of satellites may not be accurate enough, so that the local system time can be used as the reference time of the NTP server at this time.
In the embodiment of the invention, an update period for reference time is acquired; acquiring satellite time and the number of currently searched satellites according to the updating period, and acquiring local system time; judging whether the number of satellites is larger than or equal to a preset value; if the number of satellites is greater than or equal to a preset value, using satellite time as reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time. A stable, accurate reference time can be continuously provided for the NTP server.
In one embodiment, if the number of acquired satellites is greater than or equal to a preset value, the deviation value between the local system time and the satellite time is recorded, and the satellite time is synchronized to the local system time. The deviation value between the local system time and the satellite time refers to the difference value between the local system time and the satellite time, for example, the local system time is 2022, 1 month and 1 day 19:00:00, and satellite time of 2022, 1 month, 1 day 19:01:00, the deviation value of the local system time and the satellite time is 1 minute. When the reference time of the NTP server is the satellite time, the acquired local system time, satellite time and deviation value of the local system time and the satellite time can be recorded first, and then the satellite time is synchronized to the local system time.
In one embodiment, if the satellite time is not acquired or the acquired satellite time is not accurate enough, the local system time may be used as the reference time of the NTP server, and before the local system time is used as the reference time of the NTP server, the local system time may be adjusted first, and the adjusted local system time is used as the reference time of the NTP server, so as to improve the accuracy of the local system time. The method for adjusting the local system time can be as follows: acquiring a deviation value of local system time and satellite time when the reference time is updated every time in a first preset time period; and adjusting the local system time according to the average value of the deviation values.
The first preset time period is a time period set by itself, and for example, the first preset time period may be set to 12 hours, 24 hours, or the like. Assuming that the first preset time period is 12 hours and the update period for the reference time is 20 minutes, before the local system time is used as the reference time of the NTP server, the deviation value between the local system time and the satellite time can be obtained within the previous 12 hours before the local system time is used as the reference time of the NTP server, and 36 deviation values between the local system time and the satellite time can be obtained. And then, calculating the average value of the deviation values of the local system time and the satellite time according to the 36 deviation values, and adjusting the local system time according to the average value of the deviation values. For example, the average value of the calculated deviation values is 40 seconds, which means that the local system time is 40 seconds faster than the satellite time in the first 12 hours, and the local system time may be added with 40 seconds after the local system time is acquired, and the adjusted local system time is used as the reference time of the NTP server.
The offset value and the average value of the offset value may be negative, and if the offset value is negative, it may indicate that the local system time is slower than the satellite time, and if the average value of the offset value is negative, it may indicate that the local system time average is slower than the satellite time. The deviation value and the average value of the deviation value are positive and negative, and can be defined by a person skilled in the art according to the requirements. For example, if the deviation value is positive, it may be set to indicate that the satellite time is faster than the local system time, or if the deviation value is only positive, or the like.
In one embodiment, adjusting the local system time according to the average value of the bias values may further include: acquiring a deviation value of the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time in a second preset time period, and taking the deviation value as a fault deviation value; subtracting the last fault deviation value in the second preset time period from the average value of the deviation values in the first preset time period to obtain a time adjustment value; and adjusting the local system time according to the time adjustment value.
The second preset time period is a time period set by oneself, and in general, the second preset time period is not suitable to be set in too large a range, because if the setting range of the second preset time period is too large, the acquired fault deviation value has little reference meaning. The second preset time period may be set to within 3 days. The fault deviation value refers to a deviation value between the local system time and the satellite time when the NTP server uses the local system time as the reference time and then resumes using the satellite time as the reference time.
Assuming that the first preset time period is 12 hours and the second preset time period is 72 hours, the local system time adjusting method may be: acquiring the deviation value of the local system time and the satellite time in the first 12 hours when updating the reference time each time; when the reference time of the NTP server in 3 days is switched from the local system time to the satellite time, the fault deviation value of the local system time and the satellite time is obtained, and the latest fault deviation value in the second preset time period is subtracted from the average value of the deviation values in the first preset time period to obtain a time adjustment value; and adjusting the local system time according to the time adjustment value. Assuming that the average value of the deviation values in the first preset time period is 1 minute, and the latest fault deviation value in the second preset time period is 10 seconds, the time adjustment value can be obtained to be 50 seconds, which means that the local system time is 50 seconds faster than the satellite time on average, and the local system time can be added with 50 seconds after the local system time is obtained, and the adjusted local system time is used as the reference time of the NTP server.
If a plurality of fault deviation values are obtained in the second preset time period, the latest fault deviation value can be used for substitution calculation, or the average value of the plurality of fault deviation values can be used for substitution calculation. For example, the average value of the error values in the first preset time period may be subtracted from the average value of the fault deviation values in the second preset time period to obtain the time adjustment value; and adjusting the local system time according to the time adjustment value. If there is no fault deviation value in the second preset time period, the fault deviation value can be directly set to be 0.
After the local system time is adjusted, the adjusted local system time is used as the reference time of the NTP server, so that the accuracy of the local system time can be improved, and the problem that the reference time deviation is larger because the accurate satellite time cannot be acquired for a long time can be solved.
In one embodiment, if the number of acquired satellites is greater than or equal to a preset value, the satellite time is used as the reference time, including: if the number of satellites is greater than or equal to a preset value and the deviation value of the satellite time and the local system time is less than or equal to the average value of the deviation values, the satellite time is used as the reference time.
When the satellite time cannot be acquired or the acquired satellite time is not accurate enough, the NTP server can use the local system time as the reference time, but when the NTP server can normally acquire the satellite time and the satellite number, the acquired satellite number is larger than or equal to a preset value, the deviation value of the acquired satellite time and the local system time is smaller than or equal to the average value of the deviation values in a first preset time period, namely, the satellite number acquired by the GPS module reaches the preset value at the moment, the satellite time is compared with the local system time to be expected, the GPS module is normally operated, the acquired satellite time is accurate, and the NTP server reference time can be switched from the local system time to the satellite time.
In one embodiment, the reference time determining method further comprises:
before updating the reference time, acquiring satellite time and satellite number once every third preset time period; the third preset time period is less than an update period for the reference time;
if the satellite time and the satellite number cannot be acquired, recording the times of the satellite time and the satellite number which cannot be acquired;
if the satellite time and the satellite number cannot be acquired more than or equal to the preset times before the reference time is updated, the local system time is used as the reference time when the reference time is updated.
The third preset time period is a time period set by oneself, and the third preset time period may be set to a time period smaller than the update period. For example, if the update period is 20 minutes, the third preset time period may be set to 1 minute, that is, the satellite time and the satellite number are acquired once every 1 minute, then 19 times of satellite time and satellite number may be acquired within 20 minutes, if the satellite time and satellite number can be normally acquired each time, the operation of the GPS module is proved to be stable, if the satellite time and satellite number cannot be acquired up to the preset number of times, the operation of the GPS module is proved to be unstable, and the preset number of times may be set according to the third preset period, for example, in this example, the preset number of times may be set to any number of 19 or less. If the satellite time and the satellite number cannot be obtained for a preset number of times before updating the reference time, then the local system time may be used as the reference time when updating the reference time for the NTP server at the 20 th minute.
According to the embodiment of the invention, the stability of the satellite time acquired by the GPS module is monitored, and when abnormal jitter and offset occur in the GPS module, the NTP server can take the local system time as the reference time, so that the condition that the NTP server has no reference time and can be used is avoided.
In one embodiment, the reference time determining method further comprises:
before updating the reference time, acquiring satellite time and satellite number once every third preset time period; the third preset time period is less than an update period for the reference time;
if the satellite time and the satellite number cannot be acquired when the reference time is updated, sequentially judging whether the satellite number acquired before the reference time is updated is greater than or equal to a preset value;
if the number of satellites is greater than or equal to the preset value, satellite time acquired simultaneously with the number of satellites is used as reference time.
The satellite time and the number of satellites may be acquired once every third preset time period before updating the reference time. When the reference time is updated, if the satellite time and the satellite number cannot be acquired, one of the satellite times acquired before the reference time is updated may be selected as the reference time. For example, the update period is set to 20 minutes, and the third preset period is set to 1 minute, then the satellite time and the satellite number are acquired once every 1 minute, and 19 times of satellite time and satellite number can be acquired within 20 minutes. When the reference time of the NTP server is required to be updated in the 20 th minute, but the satellite time and the satellite number cannot be obtained, the satellite number obtained in the 19 th minute, the 18 th minute and the 17 th minute up to the 1 st minute can be sequentially judged, whether the satellite number obtained in the 19 th minute is greater than or equal to a preset value is firstly judged, and if the satellite number is greater than or equal to the preset value, the satellite time obtained in the 19 th minute is used as the reference time. If the number of satellites acquired at the 19 th minute is smaller than the preset value, continuing to judge whether the number of satellites acquired at the 18 th minute is larger than or equal to the preset value, and if the number of satellites acquired at the 18 th minute is larger than or equal to the preset value, using the satellite time acquired at the 18 th minute as the reference time, and the like. If the number of satellites acquired up to the 1 st minute is up to a preset value, the local system time acquired at the 20 th minute is used as the reference time of the NTP server.
Referring to fig. 2, a flowchart of a reference time determining method according to an embodiment of the present invention is shown. The NTP server acquires satellite time and satellite quantity through the GPS module, and the NTP server judges whether the information acquired by the GPS module is normal or not, and the judging method can be as follows: judging whether the number of satellites reaches a preset value or judging whether the deviation value of the satellite time and the local system time is smaller than or equal to the average value of the deviation values or the like. If the information acquired by the GPS module is normal, the time of the geosynchronous satellite is up to the NTP server, and the time of the geosynchronous satellite is up to the local system time. If the information acquired by the GPS module is abnormal, starting automatic correction to the local system time, and synchronizing the corrected local system time to the NTP server.
According to the invention, the stability of satellite time acquired by the GPS module is monitored, and when abnormal jitter and offset occur in the GPS module, the NTP service can take local system time as reference time; meanwhile, the automatic deviation correcting process of the local system time is started, so that the high accuracy of the local system time is improved, and the continuous, stable and high accuracy of the NTP server reference time is comprehensively ensured.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 3, a block diagram of a reference time determining apparatus according to an embodiment of the present invention is shown, where the apparatus is applied to a network time protocol NTP server, and the NTP server is configured with a GPS module, and the apparatus may specifically include the following modules:
the updating period acquisition module is used for acquiring the updating period aiming at the reference time; the reference time is a time for performing time synchronization;
the reference time acquisition module is used for acquiring satellite time and the number of currently searched satellites and acquiring local system time through the GPS module according to the updating period;
the reference time judging module is used for judging whether the number of satellites is larger than or equal to a preset value;
the reference time determining module is used for using the satellite time as the reference time if the number of satellites is larger than or equal to a preset value; if the number of satellites is less than the preset value, the local system time is used as the reference time.
Optionally, the reference time determining module includes: the system comprises a local system time adjusting module and a local system time synchronizing module, wherein the local system time adjusting module is used for acquiring a deviation value of local system time and satellite time when the reference time is updated every time in a first preset time period;
adjusting the local system time according to the average value of the deviation values;
and the local system time synchronization module is used for using the adjusted local system time as the reference time.
Optionally, the local system time adjustment module is further configured to:
acquiring a deviation value of the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time in a second preset time period, and taking the deviation value as a fault deviation value;
subtracting the last fault deviation value in the second preset time period from the average value of the deviation values in the first preset time period to obtain a time adjustment value;
and adjusting the local system time according to the time adjustment value.
Optionally, the reference time determining module includes a satellite time synchronization module, where the satellite time synchronization module is configured to:
if the number of satellites is greater than or equal to a preset value and the deviation value of the satellite time and the local system time is less than or equal to the average value of the deviation values, the satellite time is used as the reference time.
Optionally, the reference time determining module includes a bias value recording module and a satellite time synchronizing module, where the bias value recording module is configured to:
if the number of satellites is greater than or equal to the preset value, the deviation value of the local system time and the satellite time is recorded, and the satellite time synchronizing module is used for synchronizing the satellite time to the local system time.
Optionally, the reference time determining device includes a satellite time monitoring module and a satellite time synchronization module, where the satellite time monitoring module is configured to:
before updating the reference time, acquiring satellite time and satellite number once every third preset time period; the third preset time period is less than an update period for the reference time;
if the satellite time and the satellite number cannot be acquired, recording the times of the satellite time and the satellite number which cannot be acquired;
the satellite time synchronization module is used for using the local system time as the reference time when the reference time is updated if the satellite time and the satellite number cannot be acquired more than or equal to the preset times before the reference time is updated.
Optionally, the reference time determining device includes a satellite time monitoring module and a satellite time synchronization module, where the satellite time monitoring module is configured to:
before updating the reference time, acquiring satellite time and satellite number once every third preset time period; the third preset time period is less than an update period for the reference time;
the satellite time synchronization module is used for sequentially judging whether the number of the acquired satellites before the reference time is updated is larger than or equal to a preset numerical value if the satellite time and the number of the satellites cannot be acquired when the reference time is updated;
if the number of satellites is greater than or equal to the preset value, satellite time acquired simultaneously with the number of satellites is used as reference time.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
Referring to fig. 4, a block diagram of an electronic device 30 according to an embodiment of the present invention is shown, where the electronic device 30 includes:
the processor 301, the memory 302, and the computer program 3021 stored in the memory 302 and capable of running on the processor 301, where the computer program 3021 when executed by the processor 301 implements the respective processes of the above-mentioned embodiment of the reference time determining method, and the same technical effects are achieved, and for avoiding repetition, a detailed description is omitted herein.
Referring to fig. 5, a block diagram of a computer readable storage medium 40 according to an embodiment of the present invention is shown, where a computer program 401 is stored on the computer readable storage medium 40, and when the computer program 401 is executed by a processor, the processes of the above-mentioned embodiment of the reference time determining method are implemented, and the same technical effects can be achieved, so that repetition is avoided and redundant description is omitted.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It will be apparent to those skilled in the art that embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the invention may take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or may be up to such process, method, article, or terminal
An element inherent to the terminal device. Without further limitation, an element defined by the phrase "comprising 5 elements … …" does not exclude the presence of a process, method, article, or article of manufacture comprising the element
Additional identical elements are present in the end device.
The above detailed description of the method, the device, the electronic device and the storage medium for determining the reference time provided by the invention applies specific examples to the principles and the implementation modes of the invention
The above examples are presented for illustration only to aid in understanding the method of the present invention and its core concept 0; at the same time, for a person skilled in the art, according to the idea of the invention, in a specific embodiment
The formulae and application ranges can vary, and in view of the above, the present description should not be construed as limiting the invention.

Claims (10)

1. A reference time determination method, applied to a network time protocol NTP server configured with a GPS module, the method comprising:
acquiring an update period for a reference time; the reference time is a time for performing time synchronization;
according to the updating period, acquiring satellite time and the number of currently searched satellites through the GPS module, and acquiring local system time;
judging whether the satellite number is larger than or equal to a preset value;
if the satellite number is greater than or equal to the preset value, using the satellite time as a reference time; and if the satellite number is smaller than the preset value, using the local system time as the reference time.
2. The reference time determination method according to claim 1, wherein the using the local system time as a reference time includes:
acquiring a deviation value of the local system time and the satellite time when the reference time is updated every time in a first preset time period;
adjusting the local system time according to the average value of the deviation values;
and using the adjusted local system time as a reference time.
3. The reference time determining method according to claim 2, wherein the adjusting the local system time according to the average value of the deviation values includes:
acquiring a deviation value of the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time in a second preset time period, and taking the deviation value as a fault deviation value;
subtracting the last fault deviation value in the second preset time period from the average value of the deviation values in the first preset time period to obtain a time adjustment value;
and adjusting the local system time according to the time adjustment value.
4. The reference time determining method according to claim 2, wherein if the number of satellites is equal to or greater than the preset value, using the satellite time as the reference time includes:
and if the number of the satellites is larger than or equal to the preset value and the deviation value of the satellite time and the local system time is smaller than or equal to the average value of the deviation values, using the satellite time as the reference time.
5. The reference time determination method according to claim 1, characterized in that the method further comprises:
if the number of the satellites is larger than or equal to the preset value, recording the deviation value of the local system time and the satellite time, and synchronizing the satellite time to the local system time.
6. The reference time determination method according to claim 1, characterized in that the method further comprises:
acquiring the satellite time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
if the satellite time and the satellite number cannot be acquired, recording the times of the satellite time and the satellite number which cannot be acquired;
if the satellite time and the satellite number cannot be acquired more than or equal to the preset times before the reference time is updated, the local system time is used as the reference time when the reference time is updated.
7. The reference time determination method according to claim 1, characterized in that the method further comprises:
acquiring the satellite time and the satellite number once every third preset time period before updating the reference time; the third preset time period is smaller than the update period for the reference time;
if the satellite time and the satellite number cannot be acquired when the reference time is updated, sequentially judging whether the satellite number acquired before the reference time is updated is greater than or equal to the preset value;
and if the satellite number is greater than or equal to the preset value, using the satellite time acquired simultaneously with the satellite number as a reference time.
8. A reference time determining apparatus for use with a network time protocol, NTP, server configured with a GPS module, the apparatus comprising:
the updating period acquisition module is used for acquiring the updating period aiming at the reference time; the reference time is a time for performing time synchronization;
the reference time acquisition module is used for acquiring satellite time and the number of currently searched satellites and acquiring local system time through the GPS module according to the updating period;
the reference time judging module is used for judging whether the number of satellites is larger than or equal to a preset value;
the reference time determining module is used for using the satellite time as reference time if the number of the satellites is larger than or equal to the preset value; and if the satellite number is smaller than the preset value, using the local system time as the reference time.
9. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and capable of running on the processor, which when executed by the processor carries out the steps of the reference time determination method according to any one of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the reference time determination method according to any of claims 1-7.
CN202310019566.8A 2023-01-06 2023-01-06 Reference time determining method and device, electronic equipment and storage medium Pending CN116131984A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310019566.8A CN116131984A (en) 2023-01-06 2023-01-06 Reference time determining method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310019566.8A CN116131984A (en) 2023-01-06 2023-01-06 Reference time determining method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116131984A true CN116131984A (en) 2023-05-16

Family

ID=86309598

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310019566.8A Pending CN116131984A (en) 2023-01-06 2023-01-06 Reference time determining method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116131984A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117979412A (en) * 2024-03-29 2024-05-03 江铃汽车股份有限公司 Internal time synchronization method and system for vehicle-mounted communication remote terminal

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117979412A (en) * 2024-03-29 2024-05-03 江铃汽车股份有限公司 Internal time synchronization method and system for vehicle-mounted communication remote terminal

Similar Documents

Publication Publication Date Title
Mills Precision synchronization of computer network clocks
US9256658B2 (en) Ranging scalable time stamp data synchronization
EP2378718B1 (en) Method, node and system for controlling version in distributed system
CA2195459C (en) Disciplined time scale generator for primary reference clocks
US10958367B2 (en) Network apparatus and clock synchronization method
EP3942717A2 (en) Method of remotely monitoring the timing performance of a ptp slave
US20030177154A1 (en) Synchronization of distributed systems
US20040223515A1 (en) Method and apparatus for the synchronization of a system time of a communications network with a clock reference
US10901372B2 (en) Time synchronization device, time synchronization system, and time synchronization method
CN104283956A (en) Strong consistence distributed data storage method, device and system
WO2012111112A1 (en) Information processing device, time setting method, and time setting program
CN102754369A (en) Method for time synchronization in a communication network
CN116131984A (en) Reference time determining method and device, electronic equipment and storage medium
CN112769517B (en) T-BOX time synchronization method and device
CN111865468B (en) Precise time synchronization method
CN107547160B (en) A kind of method for synchronizing time and device
US11300688B2 (en) Phase clock performance improvement for a system embedded with GNSS receiver
CN112748758A (en) Clock source selection method and device, electronic equipment and storage medium
CN112019288B (en) Time synchronization method, service single board and network equipment
JP2009008444A (en) Time management server, time management program, and time management method
CN112527628A (en) Configuration data synchronization method and device and electronic equipment
CN113141227A (en) Time determination method, system and medium based on hierarchical control
JP2018157462A (en) Log storage method
US12216489B2 (en) Clock adjustment holdover
US20230046689A1 (en) Multiple and cascaded redundant disciplined oscillator systems in a spoofing resistant reference time source system and methods thereof

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