Disclosure of Invention
The invention mainly aims to provide a time correction method based on pigeon clock equipment, a cloud platform and a storage medium, and aims to solve the problem that the game fairness is damaged due to malicious tampering of the pigeon clock equipment.
In order to achieve the above object, the invention provides a time correction method based on a pigeon clock device, which is applied to a cloud platform, wherein the pigeon clock device realizes data interaction with the cloud platform through an edge computing box, and the method comprises the following steps:
an acquisition step: initiating a time correction request to the edge computing box in real time or at regular time, receiving and recording the current local time of the pigeon clock equipment fed back by the edge computing box, constructing an NTP protocol packet and sending the NTP protocol packet to an NTP server, and receiving and recording the network time fed back by the NTP server;
a calculation step: calculating to obtain a time difference value between the edge computing box and the cloud platform based on a predetermined time difference algorithm according to the current local time and the network time; and
a correction step: comparing the time difference value with a preset threshold value, if the time difference value is greater than or equal to the preset threshold value, correcting the network time according to a predetermined error correction algorithm to obtain correct time, calculating by using the correct time and the current local time to obtain an error value, and sending the error value to an edge calculation box so that the edge calculation box corrects the current time of the pigeon clock equipment according to the error value.
Preferably, when there are a plurality of pigeon clock devices connected in a distributed manner at the same time, the program further performs the following steps: and allocating a unique preset identifier for each pigeon clock device in advance, and when the edge computing box receives a time correction request initiated by a cloud platform, the edge computing box acquires the current local time of all pigeon clock devices and feeds the current local time back to the cloud platform, wherein each current local time carries the corresponding preset identifier.
Preferably, the correcting step further comprises the steps of: and when the time difference value is greater than or equal to a preset threshold value, generating early warning information and sending the early warning information to a preset client.
Preferably, the time difference algorithm comprises:
=(t3-t0)-(t2-t1)
wherein d is a time difference value between the edge computing box and the cloud platform, t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3And receiving the current time of the pigeon clock equipment by the cloud platform according to the NTP data packet.
Preferably, the error correction algorithm comprises:
t=t2+θ
wherein t is correct time, theta is time difference of the cloud platform relative to the NTP server, and t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time for NTP server feedback NTP data packetTime, i.e. network time, t3And receiving the current time of the pigeon clock equipment by the cloud platform according to the NTP data packet.
To achieve the above object, the present invention further provides a server, which includes a memory and a processor, wherein the memory stores a time correction program based on a pigeon clock device, and the time correction program based on the pigeon clock device realizes the following steps when being executed by the processor:
an acquisition step: initiating a time correction request to the edge computing box in real time or at regular time, receiving and recording the current local time of the pigeon clock equipment fed back by the edge computing box, constructing an NTP protocol packet and sending the NTP protocol packet to an NTP server, and receiving and recording the network time fed back by the NTP server;
a calculation step: calculating to obtain a time difference value between the edge computing box and the cloud platform based on a predetermined time difference algorithm according to the current local time and the network time; and
a correction step: comparing the time difference value with a preset threshold value, if the time difference value is greater than or equal to the preset threshold value, correcting the network time according to a predetermined error correction algorithm to obtain correct time, calculating by using the correct time and the current local time to obtain an error value, and sending the error value to an edge calculation box so that the edge calculation box corrects the current time of the pigeon clock equipment according to the error value.
Preferably, when there are a plurality of distributed connected pigeon clock devices simultaneously, the method further comprises the steps of: and allocating a unique preset identifier for each pigeon clock device in advance, and when the edge computing box receives a time correction request initiated by a cloud platform, the edge computing box acquires the current local time of all pigeon clock devices and feeds the current local time back to the cloud platform, wherein each current local time carries the corresponding preset identifier.
Preferably, the correcting step further comprises the steps of: and when the time difference value is greater than or equal to a preset threshold value, generating early warning information and sending the early warning information to a preset client.
Preferably, the time difference algorithm comprises:
=(t3-t0)-(t2-t1)
wherein d is a time difference value between the edge computing box and the cloud platform, t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3And receiving the current time of the pigeon clock equipment by the cloud platform according to the NTP data packet.
To achieve the above object, the present invention further provides a computer readable storage medium having stored thereon a pigeon clock equipment based time correction program, which is executable by one or more processors to implement the steps of the pigeon clock equipment based time correction method as described above.
The invention provides a time correction method, a server and a storage medium based on pigeon clock equipment, which initiate a time correction request to an edge calculation box, receive and record the current local time of the pigeon clock equipment fed back by the edge calculation box, meanwhile, an NTP protocol packet is constructed and sent to the NTP server, the network time fed back by the NTP server is received and recorded, calculating a time difference value between the edge computing box and the cloud platform according to the current local time and the network time, comparing the time difference value with a preset threshold value, if the time difference value is greater than or equal to the preset threshold value, and after the network time is corrected according to an error correction algorithm to obtain correct time, calculating by using the correct time and the current local time to obtain an error value, and sending the error value to the edge calculation box so that the edge calculation box corrects the current time of the pigeon clock equipment according to the error value. The invention can prevent the pigeon clock equipment from being maliciously tampered to destroy the fairness of the competition.
Detailed Description
In order to make the objects, technical embodiments and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the description relating to "first", "second", etc. in the present invention is for descriptive purposes only and is 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 at least one such feature. In addition, the technical embodiments of the present invention may be combined with each other, but it must be based on the realization of those skilled in the art, and when the combination of the technical embodiments contradicts each other or cannot be realized, such combination of the technical embodiments should be considered to be absent and not within the protection scope of the present invention.
The invention provides a cloud platform 1.
The cloud platform 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13.
The memory 11 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 11 may in some embodiments be an internal storage unit of the cloud platform 1, for example a hard disk of the cloud platform 1. The memory 11 may also be an external storage device of the cloud platform 1 in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the cloud platform 1.
Further, the memory 11 may also include both an internal storage unit and an external storage device of the cloud platform 1. The memory 11 may be used not only to store application software installed in the cloud platform 1 and various kinds of data, such as a code of the pigeon clock device-based time correction program 10, etc., but also to temporarily store data that has been output or will be output.
The processor 12 may be, in some embodiments, a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip for running program code stored in the memory 11 or Processing data, such as executing the time correction program 10 based on a pigeon clock device.
The network interface 13 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), and is typically used to establish a communication link between the cloud platform 1 and other electronic devices.
The client can be a desktop computer, a notebook, a tablet computer, a mobile phone, and the like.
Examples of such wired and wireless communication protocols may include, but are not limited to, at least one of transmission control protocol and internet protocol (TCP/IP), User Datagram Protocol (UDP), hypertext transfer protocol (HTTP), File Transfer Protocol (FTP), ZigBee, EDGE, IEEE 802.11, optical fidelity (L i-Fi), 802.16, IEEE 802.11s, IEEE 802.11g, multi-hop communications, wireless Access Points (APs), device-to-device communications, cellular communication protocols, and/or Bluetooth (ToBlueth) communication protocols, or combinations thereof.
Optionally, the cloud platform 1 may further comprise a user interface, which may comprise a Display (Display), an input unit such as a Keyboard (Keyboard), and an optional user interface may also comprise a standard wired interface, a wireless interface, optionally, in some embodiments, the Display may be an L ED Display, a liquid crystal Display, a touch-sensitive liquid crystal Display, an O L ED (Organic light-Emitting Diode) touch screen, and the like.
While fig. 1 only shows the cloud platform 1 with components 11-13 and the pigeon-equipment based time correction program 10, it will be understood by those skilled in the art that the structure shown in fig. 1 does not constitute a limitation of the cloud platform 1, and may include fewer or more components than shown, or combine certain components, or a different arrangement of components.
In this embodiment, the pigeon clock device based time correction program 10 of fig. 1, when executed by the processor 12, implements the following steps:
an acquisition step: initiating a time correction request to the edge computing box in real time or at regular time, receiving and recording the current local time of the pigeon clock equipment fed back by the edge computing box, constructing an NTP protocol packet and sending the NTP protocol packet to an NTP server, and receiving and recording the network time fed back by the NTP server;
a calculation step: calculating to obtain a time difference value between the edge computing box and the cloud platform 1 based on a predetermined time difference algorithm according to the current local time and the network time; and
a correction step: comparing the time difference value with a preset threshold value, if the time difference value is greater than or equal to the preset threshold value, correcting the network time according to a predetermined error correction algorithm to obtain correct time, calculating by using the correct time and the current local time to obtain an error value, and sending the error value to an edge calculation box so that the edge calculation box corrects the current time of the pigeon clock equipment according to the error value.
In another embodiment, when there are multiple pigeon clock devices in a distributed connection at the same time, the program further performs the following steps:
and allocating a unique preset identifier for each pigeon clock device in advance, and when the edge computing box receives a time correction request initiated by the cloud platform 1, the edge computing box acquires the current local time of all pigeon clock devices and feeds the current local time back to the cloud platform 1, wherein each current local time carries the corresponding preset identifier.
In another embodiment, the program performs the steps of:
and when the time difference value is greater than or equal to a preset threshold value, generating early warning information and sending the early warning information to a preset client.
For the detailed description of the above steps, please refer to the following description of fig. 2 regarding a schematic program module diagram of an embodiment of the time correction program 10 based on the pigeon clock facility and fig. 3 regarding a schematic method flow diagram of an embodiment of the time correction method based on the pigeon clock facility.
Referring to fig. 2, a schematic diagram of program modules of an embodiment of the pigeon clock equipment-based time correction program 10 in fig. 1 is shown. The time correction program 10 based on the pigeon clock equipment is divided into a plurality of modules, which are stored in the memory 11 and executed by the processor 12, to complete the present invention. The modules referred to herein are referred to as a series of computer program instruction segments capable of performing specified functions.
In the present embodiment, the time calibration program 10 based on the pigeon clock equipment comprises an obtaining module 110, a calculating module 120 and a calibrating module 130.
The obtaining module 110 is configured to initiate a time correction request to the edge computing box in real time or at regular time, receive and record the current local time of the pigeon clock device fed back by the edge computing box, construct an N TP protocol packet, send the N TP protocol packet to an NTP server, and receive and record the network time fed back by the NTP server.
In the racing competition of racing pigeons, time is an important factor influencing the competition result. Only when the accuracy of the time of the pigeon clock equipment is ensured, the accuracy and the fairness of the competition result can be ensured.
In the existing pigeon clock equipment, the competition result statistics is mainly carried out by depending on a time chip in the pigeon clock equipment and the time of a locally deployed server system, and a lot of artificial operation spaces exist. People who do not obey the competition rules can cheat by cracking the time chip and maliciously tampering the time of the local server, so that the fairness of the competition is damaged, and the benefits of the majority of the pigeon players are damaged.
Therefore, in order to avoid the above situation, in this embodiment, the cloud platform 1 initiates a time correction request to the edge computing box in real time or at regular time, where the time correction request is communicated with the pigeon clock device, receives and records the current local time of the pigeon clock device fed back by the edge computing box, constructs an NTP protocol packet and sends the NTP protocol packet to the NTP server, and receives and records the network time fed back by the NTP server.
The NTP server (Network Time Protocol) is a Protocol for synchronizing computer Time, it can make computer synchronize its server or clock source (quartz clock, GPS, etc.), it can provide high-precision Time correction (L AN has standard deviation less than 1 millisecond, WAN has several tens milliseconds), and it can prevent malicious Protocol attack by means of encryption confirmation.
Therefore, whether the time of the pigeon clock equipment is accurate or not is detected in real time or at regular time by a reverse NTP mode (the cloud platform 1 sends a time correction request to the edge computing box).
And the identification module 120 is configured to calculate a time difference value between the edge computing box and the cloud platform 1 based on a predetermined time difference algorithm according to the current local time and the network time.
Data errors exist due to the fact that network delay and the like may exist in the process that the cloud platform 1 performs data interaction with the edge computing box and the NTP server. Therefore, to avoid errors causing time correction errors. In this embodiment, according to the current local time of the pigeon clock device uploaded by the edge computing box and the network time fed back by the N TP server, a time difference value between the edge computing box and the cloud platform 1 is obtained through computing based on a predetermined time difference algorithm. If the time difference value is greater than or equal to the preset threshold value, it is indicated that a large error exists between the edge computing box and the cloud platform 1, and the time correction request needs to be issued again to the edge computing box until the time difference value is smaller than the preset threshold value.
Wherein the time difference algorithm comprises:
=(t3-t0)-(t2-t1)
wherein d is a time difference value between the edge computing box and the cloud platform 1, t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3The current time of the pigeon clock device is when the cloud platform 1 receives the NTP data packet.
The issuing module 130 is configured to compare the time difference value with a preset threshold, correct the network time according to a predetermined error correction algorithm to obtain correct time if the time difference value is greater than or equal to the preset threshold, calculate an error value by using the correct time and the current local time, and send the error value to the edge calculation box, so that the edge calculation box corrects the current time of the pigeon clock device according to the error value.
In this embodiment, by comparing the time difference value with a preset threshold, if the time difference value is greater than or equal to the preset threshold, the network time is corrected according to an error correction algorithm to obtain correct time, an error value is calculated by using the correct time and the current local time, and the error value is sent to the edge calculation box, so that the edge calculation box corrects the current time of the pigeon clock device according to the error value.
Wherein the error correction algorithm comprises:
t=t2+θ
wherein t is correct time, theta is time difference of the cloud platform 1 relative to the NTP server, and t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3The current time of the pigeon clock device is when the cloud platform 1 receives the NTP data packet.
In another embodiment, the program further performs the steps of:
when the time difference value is larger than or equal to the preset threshold value, generating early warning information to be sent to a preset client, for example, a mobile phone or a computer of a technician at a game sponsor, and reminding the technician that the time of the pigeon clock equipment is abnormal and needs to be adjusted.
In another embodiment, when there are multiple pigeon clock devices at the game site, the program further performs the steps of:
the method comprises the steps that a unique preset identification (such as id) is allocated to each pigeon clock device in advance, when an edge computing box receives a time correction request initiated by a cloud platform 1, the edge computing box obtains the current local time of all pigeon clock devices and feeds the current local time back to the cloud platform 1, wherein each current local time carries the corresponding preset identification. When a certain pigeon clock device is abnormal, the early warning information carrying the preset identification corresponding to the abnormal pigeon clock device can be generated and sent to the client, and technicians of game sponsors can know which pigeon clock device is abnormal.
In addition, the invention also provides a time correction method based on the pigeon clock equipment. Fig. 3 is a schematic method flow diagram of an embodiment of the time correction method based on the pigeon clock device according to the present invention. The processor 12 of the cloud platform 1, when executing the time correction program 10 based on the pigeon clock facility stored in the memory 11, implements the following steps of the time correction method based on the pigeon clock facility:
and S110, initiating a time correction request to the edge computing box in real time or at regular time, receiving and recording the current local time of the pigeon clock equipment fed back by the edge computing box, constructing an NTP protocol packet and sending the NTP protocol packet to an NTP server, and receiving and recording the network time fed back by the NTP server.
In the racing competition of racing pigeons, time is an important factor influencing the competition result. Only when the accuracy of the time of the pigeon clock equipment is ensured, the accuracy and the fairness of the competition result can be ensured.
In the existing pigeon clock equipment, the competition result statistics is mainly carried out by depending on a time chip in the pigeon clock equipment and the time of a locally deployed server system, and a lot of artificial operation spaces exist. People who do not obey the competition rules can cheat by cracking the time chip and maliciously tampering the time of the local server, so that the fairness of the competition is damaged, and the benefits of the majority of the pigeon players are damaged.
Therefore, in order to avoid the above situation, in this embodiment, the cloud platform 1 initiates a time correction request to the edge computing box in real time or at regular time, where the time correction request is communicated with the pigeon clock device, receives and records the current local time of the pigeon clock device fed back by the edge computing box, constructs an NTP protocol packet and sends the NTP protocol packet to the NTP server, and receives and records the network time fed back by the NTP server.
The NTP server (Network Time Protocol) is a Protocol for synchronizing computer Time, it can make computer synchronize its server or clock source (quartz clock, GPS, etc.), it can provide high-precision Time correction (L AN has standard deviation less than 1 millisecond, WAN has several tens milliseconds), and it can prevent malicious Protocol attack by means of encryption confirmation.
Therefore, whether the time of the pigeon clock equipment is accurate or not is detected in real time or at regular time by a reverse NTP mode (the cloud platform 1 sends a time correction request to the edge computing box).
And S120, calculating to obtain a time difference value between the edge computing box and the cloud platform 1 based on a predetermined time difference algorithm according to the current local time and the network time.
Data errors exist due to the fact that network delay and the like may exist in the process that the cloud platform 1 performs data interaction with the edge computing box and the NTP server. Therefore, to avoid errors causing time correction errors. In this embodiment, according to the current local time of the pigeon clock device uploaded by the edge computing box and the network time fed back by the NTP server, a time difference value between the edge computing box and the cloud platform 1 is obtained through computation based on a predetermined time difference algorithm. If the time difference value is greater than or equal to the preset threshold value, it is indicated that a large error exists between the edge computing box and the cloud platform 1, and the time correction request needs to be issued again to the edge computing box until the time difference value is smaller than the preset threshold value.
Wherein the time difference algorithm comprises:
=(t3-t0)-(t2-t1)
wherein d is a time difference value between the edge computing box and the cloud platform 1, t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3The current time of the pigeon clock device is when the cloud platform 1 receives the NTP data packet.
And S130, comparing the time difference value with a preset threshold value, if the time difference value is greater than or equal to the preset threshold value, correcting the network time according to a predetermined error correction algorithm to obtain correct time, calculating by using the correct time and the current local time to obtain an error value, and sending the error value to an edge calculation box so that the edge calculation box corrects the current time of the pigeon clock equipment according to the error value.
In this embodiment, by comparing the time difference value with a preset threshold, if the time difference value is greater than or equal to the preset threshold, the network time is corrected according to an error correction algorithm to obtain correct time, an error value is calculated by using the correct time and the current local time, and the error value is sent to the edge calculation box, so that the edge calculation box corrects the current time of the pigeon clock device according to the error value.
Wherein the error correction algorithm comprises:
t=t2+θ
wherein t is correct time, theta is time difference of the cloud platform 1 relative to the NTP server, and t0Pigeon clock equipment current time, i.e. current local time, t, when transmitting NTP data packets for the pigeon clock equipment1For the current time, t, of the NTP server when the NTP server receives the NTP data packet2NTP server current time, i.e. network time, t, when NTP data packet is fed back for NTP server3The current time of the pigeon clock device is when the cloud platform 1 receives the NTP data packet.
In another embodiment, the method further comprises the steps of:
when the time difference value is larger than or equal to the preset threshold value, generating early warning information to be sent to a preset client, for example, a mobile phone or a computer of a technician at a game sponsor, and reminding the technician that the time of the pigeon clock equipment is abnormal and needs to be adjusted.
In another embodiment, when there are a plurality of pigeon clock devices at the game site, the method further comprises the steps of:
the method comprises the steps that a unique preset identification (such as id) is allocated to each pigeon clock device in advance, when an edge computing box receives a time correction request initiated by a cloud platform 1, the edge computing box obtains the current local time of all pigeon clock devices and feeds the current local time back to the cloud platform 1, wherein each current local time carries the corresponding preset identification. When a certain pigeon clock device is abnormal, the early warning information carrying the preset identification corresponding to the abnormal pigeon clock device can be generated and sent to the client, and technicians of game sponsors can know which pigeon clock device is abnormal.
In addition, the embodiment of the present invention further provides a computer-readable storage medium, which may be any one of or any combination of a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a Read Only Memory (ROM), an Erasable Programmable Read Only Memory (EPROM), a portable compact disc read only memory (CD-ROM), a USB memory, and the like. The computer-readable storage medium includes a time calibration program 10 based on a pigeon clock device, and the specific implementation of the computer-readable storage medium of the present invention is substantially the same as the above-mentioned time calibration method based on a pigeon clock device and the specific implementation of the cloud platform 1, and will not be described herein again.
It should be noted that the sequence of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description of the embodiments of the present invention is for illustrative purposes only and does not represent the merits of the embodiments. Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical embodiments of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.