CN106899371B - Time synchronization method and device - Google Patents
Time synchronization method and device Download PDFInfo
- Publication number
- CN106899371B CN106899371B CN201510957093.1A CN201510957093A CN106899371B CN 106899371 B CN106899371 B CN 106899371B CN 201510957093 A CN201510957093 A CN 201510957093A CN 106899371 B CN106899371 B CN 106899371B
- Authority
- CN
- China
- Prior art keywords
- time information
- data packet
- time
- information data
- synchronization
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04J—MULTIPLEX COMMUNICATION
- H04J3/00—Time-division multiplex systems
- H04J3/02—Details
- H04J3/06—Synchronising arrangements
- H04J3/0635—Clock or time synchronisation in a network
- H04J3/0638—Clock or time synchronisation among nodes; Internode synchronisation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W56/00—Synchronisation arrangements
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
- Mobile Radio Communication Systems (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a time synchronization method, which comprises the following steps: a receiving side receives a time information data packet sent by a sending side; the receiving side checks the time information data packet and acquires time information according to the time information data packet; and initiating time synchronization by the receiving side according to the acquired time information. The invention also discloses a time synchronization device. The invention reduces the engineering cost and the maintenance cost while ensuring the high precision of the time synchronization of the base station equipment, and avoids the problem of limited networking environment.
Description
Technical Field
The present invention relates to the field of mobile communications technologies, and in particular, to a time synchronization method and apparatus.
Background
Currently, a GNSS (Global Navigation Satellite System) or IEEE 1588(Institute of Electrical and Electronics Engineers1588, i.e., a protocol standard for a precision clock synchronization protocol of a network measurement and control System) is mainly used for time synchronization of a base station device.
The GNSS system generally refers to all satellite navigation systems including global, regional, and augmentation systems, such as GPS in the united states, Glonass in russia, Galileo in europe, and beidou satellite navigation system in china, and related augmentation systems, such as WAAS (wide area augmentation system) in the united states, EGNOS (european geostationary navigation overlay system) in europe, and MSAS (multi-function transportation satellite augmentation system) in japan, and also covers other satellite navigation systems to be built and later built. The GNSS system is a complex combined system with multiple systems, multiple layers and multiple modes. When the base station adopts the GNSS system to perform time synchronization, the time precision is high, but the hardware equipment cost is high, an antenna needs to be additionally erected, factors such as base station site selection, difficulty degree of laying a feed cable, installation cost and the like need to be considered, and meanwhile, the engineering maintenance difficulty is high. Therefore, if the base stations all adopt the GNSS system for time synchronization, high networking engineering cost and maintenance cost of the base stations are generated.
IEEE 1588time precision is high, need not extra clock line, uses the data line transmission clock signal of ethernet, makes the networking of base station connect the simplification, simultaneously, has reduced engineering cost and maintenance cost. However, since IEEE 1588 uses the ethernet network to transmit information, the accuracy of time synchronization is affected by the networking environment, so that the application scenario is also limited, for example, if the transmission of information is exchanged and forwarded for many times or a link in the networking is blocked, the accuracy of time synchronization of IEEE 1588 is seriously affected.
Therefore, it can be seen that, in the prior art, time synchronization of base station equipment is performed, and if precision needs to be guaranteed, the consumed engineering cost and maintenance cost are high; if the engineering cost and the maintenance cost need to be reduced, the networking environment is limited, otherwise, the precision of time synchronization cannot be guaranteed.
Disclosure of Invention
The invention mainly aims to provide a time synchronization method and a time synchronization device, and aims to solve the technical problems of high engineering and maintenance cost and limited networking environment caused by the fact that time synchronization is guaranteed when base station equipment carries out time synchronization.
In order to achieve the above object, the present invention provides a time synchronization method, including the steps of:
a receiving side receives a time information data packet sent by a sending side;
the receiving side checks the time information data packet and acquires time information according to the time information data packet;
and initiating time synchronization by the receiving side according to the acquired time information.
In one embodiment, the transmitting side transmits the time information data packet in a fragmented manner, and the receiving side receives the time information data packet transmitted by the transmitting side, including:
and the receiving side receives the time information data packet fragments sent by the sending side and reassembles the time information data packet fragments into a time information data packet.
In one embodiment, the step of the receiving side verifying the time information data packet and acquiring the time information according to the time information data packet includes:
the receiving side checks whether the time information data packet is correct and complete;
and if the time data packet is correct and complete, acquiring a message payload according to the time information data packet to obtain time information, wherein the message payload comprises the time information.
In one embodiment, the time information packet includes a frame header, a message length field, a message payload, and a frame check sequence field, and the step of checking whether the time information packet is correct and complete at the receiving side includes:
the receiving side checks whether the time information data packet is correct according to the frame header, checks whether the time information data packet is correct according to the message header, checks whether the time information data packet is complete according to the message length field and the message payload, and checks whether the time information data packet is complete according to the message payload and the frame check sequence field;
and if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, judging that the time information data packet is correct and complete.
In one embodiment, after the step of verifying whether the time information data packet is correct and complete, the receiving side further includes:
and if the time information data packet is incorrect or incomplete, the receiving side discards the time information data packet.
In one embodiment, the step of sending the time information data packet by the sending side in a fragmentation manner, where a message header of the time information data packet carries a cycle number of the current time synchronization, and the step of checking whether the time information data packet is correct and complete by the receiving side further includes:
checking whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers; if the cycle number is verified correctly, the execution step is carried out: if the time data packet is correct and complete, acquiring a message payload according to the time information data packet to obtain time information, wherein the message payload comprises the time information; if the cycle number is not checked correctly, the execution step is carried out: if the time information data packet is incorrect or incomplete, the receiving side discards the time information data packet;
after the step of discarding the time information packet by the receiving side if the time information packet is incorrect or incomplete, the method further includes:
acquiring the packet loss rate of the time information data packet in a preset quality detection period according to the period number;
and if the packet loss rate of the information data packet is greater than a preset threshold value, the receiving side does not initiate time synchronization.
In one embodiment, the time synchronization includes absolute time synchronization and/or pulse-per-second synchronization, and the step of initiating time synchronization by the receiving side according to the acquired time information includes:
the receiving side judges whether the time information meets a preset condition for initiating time synchronization;
and if the time information meets the preset condition of initiating time synchronization, initiating absolute time synchronization and/or second pulse synchronization.
In one embodiment, if the time information satisfies a preset condition for initiating time synchronization, the step of initiating absolute time synchronization and/or pulse-per-second synchronization includes:
if the time information meets the preset condition of initiating time synchronization, the receiving side initiates absolute time synchronization according to the time information;
recovering the pulse per second signal of the transmitting side according to the time information data packet transmitted by the transmitting side;
and adjusting the local clock frequency of the receiving side according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
In one embodiment, the step of adjusting the local clock frequency of the receiving side according to the pulse-per-second signal of the transmitting side, and the step of initiating pulse-per-second synchronization includes:
acquiring a phase deviation value of the local pulse per second signal of the receiving side according to the pulse per second signal of the transmitting side;
judging whether the phase deviation value exceeds a preset deviation threshold value or not;
if the phase deviation value exceeds a preset deviation threshold value, adjusting the local clock frequency of the receiving side according to the phase deviation value, acquiring a second pulse signal adjusted by the receiving side, and turning to the execution step: acquiring a phase deviation value of the local pulse per second signal of the receiving side according to the pulse per second signal of the transmitting side;
and if the phase deviation value does not exceed a preset deviation threshold value, judging that the second pulse synchronization is finished.
In addition, to achieve the above object, the present invention also provides a time synchronization apparatus, including:
the receiving module is used for receiving the time information data packet sent by the sending side;
the information module is used for checking the time information data packet and acquiring time information according to the time information data packet;
and the synchronization module is used for initiating time synchronization according to the acquired time information.
In one embodiment, the sending side fragments the time information data packet, and the receiving module is further configured to,
and receiving the time information data packet fragments sent by the sending side and reassembling the time information data packet fragments into a time information data packet.
In one embodiment, the information module comprises:
the checking unit is used for checking whether the time information data packet is correct and complete;
and the information unit is used for acquiring a message payload according to the time information data packet to obtain the time information if the time data packet is correct and complete, wherein the message payload comprises the time information.
In one embodiment, the time information packet comprises a frame header, a message length field, a message payload, and a frame check sequence field, the check unit is further configured to,
checking whether the time information data packet is correct according to the frame header, checking whether the time information data packet is correct according to the message header, checking whether the time information data packet is complete according to the message length field and the message payload, and checking whether the time information data packet is complete according to the message payload and the frame check sequence field;
and if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, judging that the time information data packet is correct and complete.
In one embodiment, the time synchronization apparatus further comprises:
and the discarding module is used for discarding the time information data packet if the time information data packet is incorrect or incomplete.
In one embodiment, the sending side sends the time information data packet in a fragmented manner, a message header of the time information data packet carries a cycle number of the current time synchronization, the checking unit is further configured to,
checking whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers;
the time synchronization apparatus further includes:
the quality inspection module is used for acquiring the packet loss rate of the time information data packet in a preset quality inspection period according to the period number; and if the packet loss rate of the information data packet is greater than a preset threshold value, not initiating time synchronization.
In one embodiment, the time synchronization comprises absolute time synchronization and/or pulse-per-second synchronization, the synchronization module comprising:
the condition unit is used for judging whether the time information meets a preset condition for initiating time synchronization;
and the synchronization unit is used for initiating absolute time synchronization and/or second pulse synchronization if the time information meets the preset condition of initiating time synchronization.
In one embodiment, the synchronization unit includes:
the absolute time synchronization subunit is used for initiating absolute time synchronization according to the time information if the time information meets a preset condition for initiating time synchronization;
the pulse per second synchronization subunit is used for recovering a pulse per second signal of the sending side according to the time information data packet sent by the sending side; and adjusting local clock frequency according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
In one embodiment, the pulse-per-second synchronization subunit is further operable,
acquiring a phase deviation value with a local pulse per second signal according to the pulse per second signal at the transmitting side;
judging whether the phase deviation value exceeds a preset deviation threshold value or not;
if the phase deviation value exceeds a preset deviation threshold value, adjusting local clock frequency according to the phase deviation value, and acquiring an adjusted pulse per second signal;
and if the phase deviation value does not exceed a preset deviation threshold value, judging that the second pulse synchronization is finished.
The embodiment of the invention provides a time synchronization method and a time synchronization device, wherein a receiving side receives a time information data packet sent by a sending side; the receiving side checks the obtained time information data packet and obtains time information according to the time information data packet; and according to the acquired time information, the receiving side initiates time synchronization. According to the embodiment of the invention, the time information is acquired by the sending side and is packaged into the time information data packet, so that the receiving side can carry out time synchronization according to the time information in the time information data packet, the time precision reduction caused by multiple exchange and forwarding of the time information data packet when the 1588 networking is carried out is avoided, and meanwhile, the time information data packet is sent to the receiving side by the sending side through the wireless interface without an additional antenna, so that the construction cost and the maintenance cost of the base station networking are reduced. The implementation reduces the engineering cost and the maintenance cost while ensuring the high precision of the time synchronization of the base station equipment, and avoids the problem of limited networking environment.
Drawings
FIG. 1 is a schematic flow chart of a first embodiment of a time synchronization method according to the present invention;
FIG. 2 is a flowchart illustrating a time synchronization method according to a second embodiment of the present invention
FIG. 3 is a flowchart illustrating a time synchronization method according to a third embodiment of the present invention;
fig. 4 is a detailed flowchart of the step of checking whether the time information data packet is correct and complete by the receiving side according to the third embodiment of the time synchronization method of the present invention;
FIG. 5 is a flowchart illustrating a fifth embodiment of a time synchronization method according to the present invention;
FIG. 6 is a flowchart illustrating a sixth embodiment of a time synchronization method according to the present invention;
FIG. 7 is a flowchart illustrating a seventh embodiment of a time synchronization method according to the present invention;
FIG. 8 is a flowchart illustrating an eighth embodiment of a time synchronization method according to the present invention;
FIG. 9 is a flowchart illustrating a ninth embodiment of a time synchronization method according to the present invention;
FIG. 10 is a functional block diagram of a time synchronizer according to a first embodiment and a second embodiment of the present invention;
fig. 11 is a functional block diagram of a time synchronization apparatus according to a third embodiment and a fourth embodiment of the present invention;
FIG. 12 is a functional block diagram of a time synchronizer according to a fifth embodiment of the present invention;
FIG. 13 is a functional block diagram of a time synchronizer according to a sixth embodiment of the present invention;
FIG. 14 is a functional block diagram of a seventh embodiment of a time synchronizer according to the present invention;
fig. 15 is a functional block diagram of an eighth embodiment and a ninth embodiment of the time synchronizer according to the present invention;
FIG. 16 is a diagram illustrating an application scenario in an embodiment of the present invention;
FIG. 17 is a diagram illustrating frame information content of a GNSS TOD frame according to an embodiment of the present invention;
fig. 18 is a diagram illustrating a synchronization of the pulse-per-second signal according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The main solution of the embodiment of the invention is as follows: a receiving side receives a time information data packet sent by a sending side; the receiving side checks the time information data packet and acquires time information according to the time information data packet; and initiating time synchronization by the receiving side according to the acquired time information.
Because the time synchronization of the base station equipment is carried out in the prior art, the consumed engineering cost and maintenance cost are higher if the precision needs to be ensured; if the engineering cost and the maintenance cost need to be reduced, the networking environment is limited.
The invention provides a solution, which obtains time through a sending side and encapsulates the time information into a time information data packet, so that the receiving side can carry out time synchronization according to the time information in the time information data packet, and the time precision is prevented from being reduced by carrying out multiple times of exchange and forwarding on the time information data packet when IEEE 1588 networking is used for carrying out time synchronization. Meanwhile, the sending side sends the time information data packet to the receiving side through the wireless interface, so that an additional antenna is not needed, and the construction cost and the maintenance cost of the base station networking are reduced. The invention reduces the engineering cost and the maintenance cost while ensuring the high precision of the time synchronization of the base station equipment, and avoids the problem of limited networking environment.
Referring to fig. 1, a first embodiment of a time synchronization method according to the present invention provides a time synchronization method, including:
in step S10, the receiving side receives the time information packet transmitted by the transmitting side.
The embodiment of the present invention is exemplified by time synchronization of a Base Station (BS) device, for example, referring to fig. 16, time synchronization between a base station and a terminal device, such as a mobile phone, and the like.
In the embodiment of the present invention, the communication between the transmitting side and the receiving side of the base station device is mainly performed by using a wireless Interface, such as an Air Interface (Air Interface).
In this embodiment, a base station providing a time synchronization function is used as a transmitting side, and a base station to be synchronized is used as a receiving side.
Specifically, as an embodiment, when the base station apparatus performs time synchronization, first, the receiving side receives a time information packet transmitted by the transmitting side.
The transmitting side is used as a macro base station, and obtains time service from GNSS (Global Navigation Satellite System) or IEEE 1588(Institute of Electrical and Electronics Engineers1588, i.e., the precision clock synchronization protocol standard of the network measurement and control System), and the obtained time precision is high. Of course, the sending side may also obtain time service from other time systems, and may be flexibly set according to actual needs.
Then, the transmitting side encapsulates the obtained Time and the information Of the current Time synchronization to obtain a Time information packet, such as a GNSS TOD frame (Global Navigation Satellite System Time Of Day) and a 1588 synchronization frame.
If the sending side acquires time from the GNSS system, the time information data packet obtained by encapsulation is a GNSS TOD frame. The GNSS TOD frame comprises a frame header, a message length field, a message payload and a frame check sequence field. The frame header, the message length field, the message payload and the frame check sequence field can be used as check information to check the correctness and integrity of the current time information data packet; the message payload is time information carried by the current time information data packet, and the time information includes information such as absolute time, time precision level, link transmission delay (link delay for short), wireless interface signal quality and the like of a sending side. The absolute time of the sending side is the local absolute time of the sending side when the sending side sends the time information data packet; the time precision level is used for representing the time precision of the current sending side and carries information such as a clock source, pulse per second (pps for short) jitter magnitude and the like; the link time delay is used for representing the link transmission time between the current sending side and the current receiving side and can be measured by the sending side; the wireless interface signal quality is the wireless interface signal quality of the current transmitting side and can be measured by the transmitting side. Of course, the time information may also include other information, and may be flexibly set according to actual needs.
If the sending side acquires time from IEEE 1588, the time information data packet obtained by encapsulation is 1588 frames. 1588 frame includes header, message length field, message payload and frame check sequence field. The frame header, the message length field, the message payload and the frame check sequence field can be used as check information to check the correctness and the integrity of the current time information data packet; the message payload is time information carried by the current time information data packet, and the time information comprises a 1588header, a 1588timestamp, link time delay, wireless interface signal quality and the like. 1588header records the time information type, message length field and other information carried by the current time information data packet; 1588timestamp is the local absolute time of the sending side when the sending side sends the time information data packet; the link time delay is used for representing the link transmission time between the current sending side and the current receiving side and can be measured by the sending side; the wireless interface signal quality is the wireless interface signal quality of the current transmitting side and can be measured by the transmitting side. Of course, the time information may also include other information, and may be flexibly set according to actual needs.
The sending side sends the time information data packet to the receiving side periodically through the wireless interface, and the sending period can be flexibly set according to the application scene, the time synchronization requirement and other factors according to the actual situation.
The receiving side receives the time information data packet transmitted by the transmitting side.
Step S20, the receiving side verifies the time information data packet, and acquires time information according to the time information data packet.
After the receiving side receives the time information data packet sent by the sending side, the receiving side checks the obtained time information data packet and obtains time information according to the time information data packet.
Specifically, as an implementation manner, first, the receiving side obtains the verification information according to the GNSS TOD frame or the 1588 frame to perform verification, and determines whether the received time information data packet is correct and complete.
If the time information data packet received by the receiving side is correct and complete, the receiving side analyzes the time information data packet to obtain the time information. If the current time information data packet is a GNSS TOD frame, the obtained time information comprises the information of absolute time, time precision level, link delay, wireless interface signal quality and the like of a sending side; if the current time information data packet is 1588 frames, the obtained time information comprises information such as a timestamp, link delay, wireless interface signal quality and the like.
If the currently received time information packet is incorrect or incomplete, as an implementation, the receiving side discards the current time information packet.
Thereby, the receiving side obtains time information.
Step S30, the receiving side initiates time synchronization according to the acquired time information.
After obtaining the time information, the receiving side initiates time synchronization according to the obtained time information.
Specifically, as an embodiment, if the current time information data packet is a GNSS TOD frame, the receiving side performs local absolute time synchronization of the receiving side according to the absolute time, the time accuracy level, and the link delay in the time information.
Then, the receiving side recovers the pulse-per-second signal from the time information packet, and uses the recovered pulse-per-second signal as a reference pulse-per-second. Then, the receiving side adjusts the frequency of the local clock crystal of the receiving side according to the obtained reference second pulse so as to synchronize the local second pulse signal with the reference second pulse signal.
And if the current time information data packet is 1588 frames, the receiving side carries out local absolute time synchronization of the receiving side according to 1588time delay and link delay in the time information.
Then, the receiving side recovers the pulse-per-second signal from the time information packet, and uses the recovered pulse-per-second signal as a reference pulse-per-second. Then, the receiving side adjusts the frequency of the local clock crystal of the receiving side according to the obtained reference second pulse so as to synchronize the local second pulse signal with the reference second pulse signal.
Thereby, the receiving side achieves synchronization of local absolute time and second pulse.
As another embodiment, the receiving side may determine whether to initiate local time synchronization according to the quality of the wireless signal interface in the time information packet.
If the current wireless signal interface quality is poor or unavailable, the receiving side discards the time information data packet, time synchronization is not performed for the moment, and time synchronization can be started when the wireless signal interface quality is good or can be used.
And if the current wireless signal interface is good in quality or available, the receiving side initiates time synchronization according to the obtained time information.
In this embodiment, the receiving side receives the time information packet transmitted by the transmitting side; then, the receiving side checks the obtained time information data packet and obtains time information according to the time information data packet; then, according to the acquired time information, the receiving side initiates time synchronization. In this embodiment, the time is acquired by the sending side, and the time information is encapsulated into the time information data packet, so that the receiving side can perform time synchronization according to the time information in the time information data packet, thereby avoiding time precision reduction due to multiple exchanges and forwarding of the time information data packet when performing time synchronization by using IEEE 1588 networking. Meanwhile, the sending side sends the time information data packet to the receiving side through the wireless interface, so that an additional antenna is not needed, and the construction cost and the maintenance cost of the base station networking are reduced. The implementation reduces the engineering cost and the maintenance cost while ensuring the high precision of the time synchronization of the base station equipment, and avoids the problem of limited networking environment.
Further, referring to fig. 2, a second embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the above embodiment shown in fig. 1, where the sending side sends the time information packet in a fragmented manner, and the step S10 includes:
step S11, the receiving side receives the time information packet fragment sent by the sending side and reassembles the time information packet fragment into a time information packet.
In the embodiment of the invention, the sending side can directly receive the time information data packet obtained by encapsulation in the wireless frame of the wireless interface and send the time information data packet to the receiving side, can also fragment the time information data packet and receive the time information data packet in the wireless frame of the wireless interface and send the time information data packet to the receiving side, and can be flexibly set according to actual requirements.
When the transmitting side transmits the time information data packet fragments to the receiving side, the receiving side receives the time information data packet fragments transmitted by the transmitting side and reassembles the time information data packet fragments into a time information data packet.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
Referring to fig. 17, the GNSS TOD frame includes a frame header, a message length field, a message payload, and a frame check sequence field.
The frame header may be composed of 2 fixed byte SYNC CHAR (synchronization character) for notifying the receiving side that the current message is a time synchronization message, that is, a time information data packet sent by the sending side. For example, the fixed value may be 0x43, where 0x43 represents the "C" character in ASCII (American Standard Code for Information exchange) Code; the fixed value may also be 0x4D, with 0x4D representing the "M" character in ASCII code.
The message header may be composed of 4 bytes and includes a message type and an ID number, where the message classification is used to characterize the type of time information carried by the current GNSS TOD frame, and the ID number is used to characterize the number of the current message in the message period. For example, using a fixed value of 0x8001 indicates that the current message is a GNSS TOD message; and using unsigned numbers 0-65535 to represent the number of the current time information data packet in the time synchronization period. It should be noted that the time synchronization period is a period for performing time synchronization between the transmitting side and the receiving side, and can be flexibly referred to according to actual needs; and the sending side marks the sent time information data packets in sequence according to the sending time sequence, and represents the cycle number of the current time information data packet by the ID number.
The message length field, which may consist of 4 bytes, contains the length of the message payload.
The frame check sequence field may be composed of 1byte, 2 bytes or 4 bytes. 1byte, the polynomial of the frame check sequence is g (x) ═ x8+ x5+ x4+ 1; at 2 bytes, the Check sequence may be calculated using a CRC (Cyclic Redundancy Check) 16; at 4 bytes, the check sequence may be calculated using CRC 32. The frame check sequence field is 2 bytes in this embodiment, and CRC16 is used for illustration.
The message payload includes the content of the time information, which includes absolute time, time accuracy level, link delay, and radio interface signal quality, etc., as shown in table 1 below.
TABLE 1
Specifically, the absolute time includes the second in the week, the number of weeks, and LeapS (offset). The intra-week seconds represent the GNSS time intra-week seconds, the byte offset is 0, and the data type is an unsigned char (unsigned character) of 4 bytes, and the unit is s (seconds); the week number represents the GNSS time week number, the byte offset is 4, the data type is 2byte unidentified char, and the unit is week; LeapS characterizes the offset between GNSS Time and UTC (Coordinated Universal Time), where the byte offset is 6, and the signed char (signed character) with 1byte data type is given in s.
The time precision level includes the pulse per second state, clock source, TAcc (jitter magnitude), clock source working state and monitoring alarm.
The pulse per second state is the state of the current pulse per second, the byte offset is 7, and the data type is an unscheduled char of 1 byte. For example, a pulse per second state of 0x00 indicates that the pulse per second is normal; when the pulse per second state is 0x01, the atomic clock of the time synchronization equipment is represented as a holding state; when the pulse per second state is 0x02, the pulse per second is not available; when the pulse per second state is 0x03, the high-crystal oscillator of the time synchronization equipment is represented as a holding state; when the pulse per second state is 0x04, the transmission bearing equipment is characterized to keep; 0x05 and subsequent values 0xff are reserved values (reserved), and other pulse-per-second states may be added.
The clock source is the clock source of the current second pulse, the byte offset is 8, and the data type is the unsigned char of 1 byte. For example, when the clock source is 0x00, the representation clock source is a beidou satellite navigation system; when the clock source is 0x01, the clock source is characterized as a Global Positioning System (GPS); when the clock source is 0x02, the clock source is represented by GLONASS (abbreviation of global satellite navigation system in russian); when the clock source is 0x03, the characterization clock source is Galileo satellite navigation system; when the clock source is 0x04, characterizing that the clock source is IEEE 1588; when the clock source is 0x05, the representation clock source is NTP (Network Time Protocol); 0x06 and subsequent values 0xff are reserved values (reserved), and other clock sources may be added.
TAcc characterizes the jitter magnitude of the pulse-per-second, byte offset 9, and data type 1byte unsigned char. The jitter amount of the second pulse ranges from 0 to 255 levels, and is 15ns (nanoseconds) per level, for example, when TAcc is 0, the jitter amount representing the second pulse is 0 ns; when TACc is 2, the jitter amount representing the pulse per second is 30 ns; by analogy, when TAcc is 255, the jitter amount of the current second pulse is too large, and is meaningless.
The working state of the clock source represents the working state of the current clock source, the byte offset is 10, and the data type is an unidentified char of 2 bytes. The working state of the clock source defines the working Type (GNSS Fix Type) of the GNSS, and the range (range) representing the working quality is 0 to 3. For example, when the working state of the clock source is 0x00, it represents the current no fix (no fixed state); when the working state of the clock source is 0x01, representing the current dead reckoning only; when the working state of the clock source is 0x02, representing that the current working state is a 2D plane; when the working state of the clock source is 0x03, representing that the current working state is 3D stereo; when the working state of the clock source is 0x04, the current working state is represented as GNSS + dead reckoning (GNSS and dead reckoning); when the working state of the clock source is 0x05, representing the current Time only fix (only positioning Time); 0x06 and subsequent values 0xff are reserved values (reserved), and other clock source operating states may be added.
The monitoring alarm represents the state alarm of the current clock source, the byte offset is 12, and the data type is an unidentified char of 2 bytes. For example, when the monitoring alarm is Bit0, the current clock source antennaopen is characterized; when the monitoring warning is Bit1, characterizing the antenna short of the current clock source; when the monitoring alarm is Bit2, characterizing the current clock source not tracking satellites (satellites are not monitored); when the monitoring warning is Bit3, the current clock source surfey in progress is represented (under investigation); when the monitoring warning is Bit4, the current clock source no stored position is represented (no storage position); when the monitoring warning is Bit5, representing the current clock source leaf second pending; when the monitoring warning is Bit6, characterizing the current clock source in test mode (in test mode); when the monitoring alarm is Bit7, the current clock source position is queried; when the monitoring warning is Bit8, the current clock source almanac not complete is represented; when the monitoring warning is Bit9, characterizing the current clock source pps wa generated (pulse per second is generated); bit10 through Bit15 are reserved values (reserved), and other monitoring warnings may be added.
The link delay is the link delay between the current sending side and the current receiving side, and is measured by the initiating side, the byte offset is 14, and the data type is an unknown char of 2 bytes. The link delay is 260.42ns (1chip, i.e. 1 wireless basic frame time) as a delay level, for example, when the link delay is 0x0, it represents that the current link has no delay; when the link delay is 0x1, the current link delay is represented to be 260.42ns (1chip, namely 1 wireless basic frame time); when the link time delay is 0x2, representing that the current link time delay is 520.84ns, and so on; when the link delay is 0x9600, the current link delay is represented to be 10 ms. 0x9601 and subsequent values 0xffff are reserved values (reserved), and other link delays may be added.
The signal quality of the wireless interface characterizes the signal quality of the wireless interface at the current transmitting side, the byte offset is 16, and the data type is 1byte assigned char. For example, when the signal quality of the wireless interface is 0x0, it represents that the current wireless interface quality is high; when the signal quality of the wireless interface is 0x1, representing the quality of the current wireless interface; when the signal quality of the wireless interface is 0x2, the current wireless interface quality is low; when the signal quality of the wireless interface is 0x3, the quality of the current wireless interface is represented as ineligible. 0x4 and the subsequent value 0xff are reserved values (reserved), and other radio interface signal qualities may be added.
In addition, the message payload reserves 3 bytes of data as a reserved value (reserved) for adding other information. It can be seen that the message payload is 20 bytes, i.e., 20 bytes.
Thus, the GNSS TOD frame encapsulated by the transmitting side is 32 bytes, that is, 32 bytes.
Then, the transmitting side divides the data of 32 bytes of the GNSS TOD frame into 16 subframes, each subframe being 2 bytes. The sending side sends data to the receiving side through a wireless interface, and the 16 sub-frames with 2 bytes are loaded in a wireless frame of the wireless interface for 16 times and sent out. Wherein the absolute time of transmission in the message payload is kept consistent with the local transmission time of the transmitting side.
And after receiving the time information data packet fragments sent by the sending side, namely the sub-frames of each 2byte, the receiving side reassembles the obtained sub-frames to obtain the GNSS TOD frame of the time information data packet.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames. In this embodiment, the time information carried in the 1588 frame uses a sync message, a foldup message, or an announce message. Of course, other types of messages may be used for the 1588 frame.
1588 frame includes header, message length field, message payload and frame check sequence field.
The frame header may be composed of 2 fixed byte SYNC CHAR (synchronization character) for notifying the receiving side that the current message is a time synchronization message, that is, a time information data packet sent by the sending side. For example, the fixed value may be 0x43, where 0x43 represents the "C" character in ASCII (American Standard Code for Information exchange) Code; the fixed value may also be 0x4D, with 0x4D representing the "M" character in ASCII code.
The message header can be composed of 4 bytes and is a message type and an ID number, the message classification is used for representing the type of the time information carried by the current 1588 frame, and the ID number is used for representing the number of the current message in the message period. For example, a fixed value of 0x8002 is used to indicate that the current message is a sync message; using a fixed numerical value 0x8003 to indicate that the current message is a followup message; using a fixed numerical value 0x8004 to represent that the current message is an announce message; and using unsigned numbers 0-65535 to represent the number of the current time information data packet in the time synchronization period. It should be noted that the time synchronization period is a period for performing time synchronization between the transmitting side and the receiving side, and can be flexibly referred to according to actual needs; and the sending side marks the sent time information data packets in sequence according to the sending time sequence, and represents the cycle number of the current time information data packet by the ID number.
The message length field, which may consist of 4 bytes, contains the length of the message payload.
The frame check sequence field may be composed of 1byte, 2 bytes or 4 bytes. 1byte, the polynomial of the frame check sequence is g (x) ═ x8+ x5+ x4+ 1; at 2 bytes, the Check sequence may be calculated using a CRC (Cyclic Redundancy Check) 16; at 4 bytes, the check sequence may be calculated using CRC 32. The frame check sequence field is 2 bytes in this embodiment, and CRC16 is used for illustration.
The message payload includes the content of time information, and when the time information carried by the 1588 frame is a sync message or a followup message, the time information includes a 1588header, a 1588timestamp, a link delay, a wireless interface signal quality, and the like. When the time information carried by the 1588 frame is an announce message, the time information includes 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
As shown in table 2 below, the 1588header includes information carrying the type of the current message, and the like, for a total of 34 bytes.
TABLE 2
Wherein, the Message Type carried by the 1588header is Transport Specific (dedicated for transmission), the byte offset is 0, and the size is 1 byte; version PTP (Precision Time Protocol Version), reserved, byte offset 1, size 1 byte; the Message length records the length of the payload of the current Message, the byte offset is 2, and the size is 2 bytes; the Domain number byte offset is 4 and the size is 1 byte; reserved byte offset is 5, size is 1 byte; flag field byte offset is 6, size is 2 bytes; correction field byte offset is 8, size is 8 bytes; reserved byte offset is 16, size is 4 bytes; source port Identity byte offset is 20 and size is 10 bytes; sequence ID (sequence ID) byte offset is 30, size is 2 bytes; control field byte offset is 32, size is 1 byte; the Log message Interval byte offset is 33 and the size is 1 byte.
1588time difference is time difference with UTC, including second bit information of 6 bytes and nanosecond bit information of 4 bytes, and the total is 10 bytes.
The 1588time precision exists only when the time information carried by the 1588 frame is an announce message, and the total time is 20 bytes. 1588 the time precision includes clock priority, clock class, clock precision, clock jitter, time source and transfer hop count. For example, clock priority characterizes the priority level of the current clock; the value range of the clock grade is 0-255, and the smaller the value is, the higher the clock grade is; the clock precision represents the time precision by using a numerical value; the clock jitter represents the jitter amount of the current clock; the transfer hop count represents the transfer hop count from the time source to the node, and 1 is added to each transfer hop; the time source characterizes the source of the current time, such as a satellite, an internal clock, etc.
The link delay represents the delay of the link between the transmitting side and the receiving side, and in this embodiment, the transmitting side and the receiving side do not need to calculate the link delay interactively, and the link delay can be measured by the transmitting side. The link delay is 260.42ns (1chip, i.e. 1 wireless basic frame time) as a delay level, for example, when the link delay is 0x0, it represents that the current link has no delay; when the link delay is 0x1, the current link delay is represented to be 260.42ns (1chip, namely 1 wireless basic frame time); when the link time delay is 0x2, representing that the current link time delay is 520.84ns, and so on; when the link delay is 0x9600, the current link delay is represented to be 10 ms. 0x9601 and subsequent values 0xffff are reserved values (reserved), and other link delays may be added.
The signal quality of the wireless interface characterizes the signal quality of the wireless interface at the current transmitting side. For example, when the signal quality of the wireless interface is 0x0, it represents that the current wireless interface quality is high; when the signal quality of the wireless interface is 0x1, representing the quality of the current wireless interface; when the signal quality of the wireless interface is 0x2, the current wireless interface quality is low; when the signal quality of the wireless interface is 0x3, the quality of the current wireless interface is represented as ineligible. 0x4 and the subsequent value 0xff are reserved values (reserved), and other radio interface signal qualities may be added.
It should be noted that the link delay and the signal quality of the wireless interface total 2 bytes.
In addition, the message payload reserves 2 bytes of data as a reserved value (reserved) for adding other information.
The message payload is 48 bytes when the time information carried by the 1588 frame is a sync message or a followup message; and when the time information carried by the 1588 frame is an announce message, the message payload is 68 byte.
Therefore, 60 bytes (when the time information is a sync message or a followup message) or 80 bytes (when the time information is an announce message) can be obtained in total by 1588 frames. Then, the transmitting side divides the 1588 frame into 30 or 40 subframes, each subframe being 2 bytes. And the transmitting side transmits data through a wireless interface, and the 30 or 40 sub-frames with 2 bytes are loaded in a wireless frame of the wireless interface for 30 times or 40 times and transmitted. Wherein the absolute time of transmission in the message payload is kept consistent with the local transmission time of the transmitting side.
And after receiving the time information data packet fragments sent by the sending side, namely the sub-frames of each 2byte, the receiving side reassembles the obtained sub-frames to obtain 1588 frames of the time information data packet.
In this embodiment, the transmitting side transmits the time information packet in a fragmentation manner to adapt to the transmission capability of the network link, so as to improve the transmission efficiency, and the receiving side receives the time information packet fragments transmitted by the transmitting side and reassembles the time information packet fragments into the time information packet, thereby performing time synchronization. The embodiment realizes the sending of the time information data packet in various modes, improves the transmission efficiency of the time information data packet, and effectively ensures the precision of time synchronization of the receiving side.
Further, referring to fig. 3, a third embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the above embodiment shown in fig. 1 or fig. 2 (this embodiment takes fig. 1 as an example), where the step S20 includes:
step S21, the receiving side checks whether the time information data packet is correct and complete.
After acquiring the time information data packet sent by the sending side, the receiving side verifies the correctness and the integrity of the time information data packet.
Specifically, as an embodiment, the time information packet includes a frame header, a message length field, a message payload, and a frame check sequence field.
First, the receiving side checks whether the time information packet is correct or not according to the frame header, and whether the time information packet is a time synchronization frame, such as a GNSS TOD frame or a 1588 frame.
And the receiving side checks whether the type of the time information carried by the time information data packet is correct or not according to the message header, whether the time information carried by the time information data packet is a GNSS TOD message corresponding to a GNSS TOD frame or not, or whether the time information carried by the time information data packet is a sync message, a foldup message or an announce message corresponding to a 1588 frame.
And the receiving side verifies whether the message payload carried by the time information data packet is complete or not according to the message length field.
And the receiving side checks whether the time information data packet is complete according to the message payload and the frame check sequence field. And if the current time information data packet is not complete, discarding the current time information data packet. And if the current time information data packet is complete, the current time information data packet is confirmed to be correct and complete.
And if the receiving side is verified correctly according to the frame header, verified correctly according to the message header, completely verified according to the message length field, and completely verified according to the message payload and the frame verification sequence field, the current time information data packet is confirmed to be correct and complete.
Therefore, the receiving side obtains the checking result of the current time information data packet.
Step S22, if the time data packet is correct and complete, obtaining a message payload according to the time information data packet to obtain time information, wherein the message payload comprises the time information.
If the current time information data packet is correct and complete, the receiving side obtains a message payload according to the time information data packet, wherein the message payload comprises time information, and therefore the receiving side obtains the time information.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
And the receiving side analyzes the currently obtained time information data packet to obtain the message payload. The message payload is time information encapsulated in the GNSS TOD frame by the transmitting side, and includes absolute time, time accuracy level, link delay, radio interface signal quality, and the like. Of course, the time information encapsulated at the transmitting side may also include other information, and may be flexibly set according to actual needs.
Thus, the receiving side obtains time information including absolute time, time accuracy level, link delay, radio interface signal quality, and the like.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames.
In this embodiment, the time information carried in the 1588 frame uses a sync message, a foldup message, or an announce message. Of course, other types of messages may be used for the 1588 frame.
And the receiving side analyzes the currently obtained time information data packet to obtain the message payload. The message payload is time information encapsulated in a 1588 frame by a sending side, and if the time information encapsulated by the sending side is a sync message or a followup message, the message payload comprises a 1588header, a 1588timestamp, link delay, wireless interface signal quality and the like; when the time information carried by the 1588 frame is an announce message, the message payload comprises 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
Thereby, the receiving side obtains time information. It should be noted that, when the time information encapsulated at the sending side is a sync message or a followup message, the time information includes 1588header, 1588timestamp, link delay, wireless interface signal quality, and the like; when the time information carried by the 1588 frame is an announce message, the time information includes 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
In this embodiment, the receiving side checks whether the currently obtained time information data packet is correct and complete; and if the current time data packet is correct and complete, the receiving side acquires the message payload according to the time information data packet to obtain the time information, wherein the message payload comprises the time information. In this embodiment, the sending side encapsulates the time information in the time information data packet, and the receiving side firstly verifies whether the obtained time information data packet is correct and complete after obtaining the time information data packet, and obtains the time information only when the time information data packet is correct and complete, thereby avoiding that the incorrect or incomplete data packet reduces the time synchronization affecting the receiving side, and reducing the time synchronization precision. The embodiment realizes the verification of the correctness and the integrity of the time information data packet, and improves the correctness and the accuracy of the time synchronization of the receiving side.
Further, referring to fig. 4, a fourth embodiment of the time synchronization method according to the embodiment of the present invention provides a time synchronization method, based on the embodiment shown in fig. 3, where the time information packet includes a frame header, a message length field, a message payload, and a frame check sequence field, and step S21 includes:
step S211, the receiving side checks whether the time information data packet is correct according to the frame header, checks whether the time information data packet is correct according to the message header, checks whether the time information data packet is complete according to the message length field and the message payload, and checks whether the time information data packet is complete according to the message payload and the frame check sequence field.
In this embodiment, the time information packets sent by the sending side all include a frame header, a message length field, a message payload, and a frame check sequence field. And the transmitting side flexibly selects the GNSS or IEEE 1588 acquisition time according to the working state of the clock source of the current acquisition time, and encapsulates the GNSS or IEEE 1588 acquisition time to obtain a GNSS TOD frame or 1588 frame.
After acquiring the time information data packet sent by the sending side, the receiving side firstly checks whether the received time information data packet is correct and complete.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
And the receiving side checks whether the time information data packet is correct or not according to the frame header. The receiving side judges whether the keyword of the frame header is 0x43 or 0x4d pre-configured by the sending side, and if the keyword of the frame header is 0x43 or 0x4d, the time information data packet received this time is judged to be correct; otherwise, the time information data packet received this time is judged to be incorrect.
And the receiving side checks whether the time information data packet is correct or not according to the message header. The receiving side obtains a message type keyword carried by a message header, and the receiving side does not know the time information type sent by the sending side before receiving the time information data packet, so that the receiving side judges whether the message type keyword is 0x8001, 0x8002, 0x8003 or 0x8004, that is, whether the time information carried by the current time information data packet is one of a GNSS TOD message, a sync message, a followup message or an announce message. If the keyword of the message header is 0x8001, 0x8002, 0x8003 or 0x8003, judging that the time information data packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect. For example, if the keyword of the message header is 0x8001, it is determined that the time information packet received this time is correct, and the time information carried by the current time information packet is acquired according to 0x8001 as the GNSS TOD message.
And the receiving side checks whether the time information data packet is complete or not according to the message length field and the message payload. The receiving side obtains the message payload length carried by the current time information data packet according to the time length field, for example, when the message length field is 0x14, the message payload length is 20 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 20 bytes, and if the length of the payload of the message is 20 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, receiving the message payload sent by the sending side in 10 times and 2 bytes each time, judging whether the length of the current message payload is 20 bytes or not after the time information data packet is obtained through repacking, and if the length of the message payload is 20 bytes, judging that the received time information data packet is complete; otherwise, the received time information data packet is judged to be incomplete.
And the receiving side checks whether the time information data packet is complete according to the message payload and the frame check sequence field. The receiving side carries out CRC16 check calculation for 1 time on the received message payload of 20 bytes and the frame check sequence, and if a fixed sequence x 15-x 0:0001110100001111 is obtained through calculation, the received time information data packet is judged to be complete; otherwise, the received time information data packet is judged to be incomplete.
Thereby, the receiving side obtains the verification result.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames.
And the receiving side checks whether the time information data packet is correct or not according to the frame header. The receiving side judges whether the keyword of the frame header is 0x43 or 0x4d pre-configured by the sending side, and if the keyword of the frame header is 0x43 or 0x4d, the time information data packet received this time is judged to be correct; otherwise, the time information data packet received this time is judged to be incorrect.
And the receiving side checks whether the time information data packet is correct or not according to the message header. The receiving side obtains a message type keyword carried by a message header, and the receiving side does not know the time information type sent by the sending side before receiving the time information data packet, so that the receiving side judges whether the message type keyword is 0x8001, 0x8002, 0x8003 or 0x8004, that is, whether the time information carried by the current time information data packet is one of a GNSS TOD message, a sync message, a followup message or an announce message. If the keyword of the message header is 0x8001, 0x8002, 0x8003 or 0x8003, judging that the time information data packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect. For example, if the keyword of the message header is 0x8002, it is determined that the time information packet received this time is correct, and the time information carried by the current time information packet is acquired according to 0x8002 as a sync message.
And the receiving side checks whether the time information data packet is complete or not according to the message length field and the message payload. The receiving side obtains the message payload length carried by the current time information data packet according to the time length field, for example, when the message length field is 0x30, the message payload length is represented as 48 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 48 bytes, and if the length of the payload of the message is 48 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, the message payload sent by the sending side is received in 24 times and 2 bytes each time, whether the length of the current message payload is 48 bytes or not is judged after the time information data packet is obtained through reloading, and if the length of the message payload is 48 bytes, the time information data packet received this time is judged to be complete; otherwise, the received time information data packet is judged to be incomplete. And when the message length field is 0x44, the message payload length is 60 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 60 bytes, and if the length of the payload of the message is 60 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, receiving the message payload sent by the sending side in 2 bytes for 30 times each time, judging whether the length of the current message payload is 60 bytes or not after the time information data packet is obtained through repacking, and if the length of the message payload is 60 bytes, judging that the received time information data packet is complete; otherwise, the received time information data packet is judged to be incomplete.
And the receiving side checks whether the time information data packet is complete according to the message payload and the frame check sequence field. The receiving side carries out 1 time of CRC16 check calculation on the received message payload of 48 bytes or 60 bytes and the frame check sequence, and if a fixed sequence x 15-x 0:0001110100001111 is obtained through calculation, the received time information data packet is judged to be complete; otherwise, the received time information data packet is judged to be incomplete.
Thereby, the receiving side obtains the verification result.
It should be noted that, in this embodiment, if the sending side transmits the time information data packet in a fragmented manner, the receiving side may perform, after receiving the time information data packet fragments, verification respectively according to the received time information data packet fragments, and the verification method is the same as described above, and obtain the verification result.
Step S212, if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, the time information data packet is judged to be correct and complete.
If the receiving side verifies that the time information data packet is correct according to the frame header, verifies that the time information data packet is correct according to the message header, verifies that the time information data packet is complete according to the message payload and the frame verification sequence field, and verifies that the time information data packet is complete according to the message payload and the frame verification sequence field, the receiving side judges that the time information data packet received at this time is correct and complete; otherwise, the receiving side judges that the time information data packet received this time is incorrect or incomplete.
Therefore, the receiving side obtains the verification result of the time information data packet received this time.
In this embodiment, the receiving side checks whether the time information data packet is correct according to the frame header, checks whether the time information data packet is correct according to the message header, checks whether the time information data packet is complete according to the message length field and the message payload, and checks whether the time information data packet is complete according to the message payload and the frame check sequence field; if the frame header is correctly checked, the message length field and the message payload are completely checked, and the message payload field and the frame check sequence field are completely checked, the time information data packet received by the receiving side is judged to be correct and complete. In the embodiment, the time information data packet is verified in multiple modes, so that multiple verification on the correctness and the completeness of the time information data packet is realized, the receiving side only carries out time synchronization according to the correct and complete time information data packet, and the correctness and the accuracy of the time synchronization of the receiving side are improved.
Further, referring to fig. 5, a fifth embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the above embodiment shown in fig. 4, the step S21 is followed by further including:
step S40, if the time information packet is incorrect or incomplete, the receiving side discards the time information packet.
And after a verification result is obtained, if the time information data packet received this time is incorrect or incomplete, the receiving side discards the time information data packet received this time and is not used for time synchronization of the receiving side.
Then, the receiving side receives the next time information data packet sent by the sending side and checks the next time information data packet.
In this embodiment, if the time information packet received this time is incorrect or incomplete, the receiving side discards the current time information packet. The embodiment realizes the control of the quality of the time information data packet, and the receiving side discards the time information data packet when the quality of the time information data packet cannot meet the preset requirement. The embodiment improves the time synchronization accuracy and precision of the receiving side by controlling the quality of the time information data packet.
Further, referring to fig. 6, a sixth embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the embodiment shown in fig. 5, where the sending side sends the time information data packet in a fragmented manner, a message header of the time information data packet carries a cycle number of the current time synchronization, and after step S21, the method further includes:
step S23, checking whether the time information data packet fragment sent by the sending side is correct according to the cycle number; if the cycle number is verified correctly, the step S22 is executed; if the cycle number is not verified correctly, the process proceeds to step S40.
In this embodiment, the transmitting side periodically transmits the time information packets to the receiving side, and the receiving side performs time synchronization according to the received time information packets. It should be noted that the cycle number carried when the transmitting side transmits the time information packet is synchronized with the cycle number that is time-synchronized at the receiving side.
In the time information data packet sent by the sending side, the ID number carried by the message header is the cycle number of the current time synchronization. For example, the transmitting side uses the unsigned numbers 0 to 65535 as the ID number, which indicates the number of the current time information packet in the time synchronization period, that is, the period number of the current time synchronization.
Specifically, as an embodiment, the transmitting side sequentially performs ID numbering on the headers of the time information packets according to the transmission time sequence of the time information packets. When the sending side fragments the time information data packet, each fragment of the time information data packet carries the same cycle number of the time synchronization, and the influence of the cycle number on the byte amount of each fragment is negligible.
And after receiving the time information data packet fragments, the receiving side acquires the cycle numbers carried by each time information data packet fragment.
Then, the receiving side judges whether the cycle number carried by the received time information data packet fragment is the cycle number of the current time synchronization cycle or not according to the current time synchronization cycle. If the cycle number carried by the received time information data packet fragment is the cycle number of the current time synchronization cycle, judging that the time information data packet fragment is correct; otherwise, the current time information data packet is judged to be incorrect.
Meanwhile, the receiving side judges whether the received time information data packet fragments are fragments of the same time information data packet according to whether the cycle numbers carried by the received time information data packet fragments are the same.
If the receiving side carries the same cycle number in the time synchronization cycle, and the cycle number of the time information data packet fragment is the same as the cycle number of the time synchronization cycle, the time information data packet fragment sent by the sending side is judged to be correct. Otherwise, the time information data packet fragment sent by the sending side is judged to be incorrect.
And if the time information data packet fragment sent by the current sending side is correct, the receiving side acquires the message payload according to the time information data packet to obtain the time information.
And if the time information data packet fragment sent by the current sending side is incorrect, the receiving side discards the currently received time information data packet.
As another embodiment, when the transmitting side transmits the time information data packet in a fragmented manner, the receiving side may perform verification when receiving the time information data packet in a fragmented manner; if the time information data packet fragments are correct, repacking the time information data packet fragments to obtain time information data packets; and if the time information data packet fragments are incorrect, discarding the time information data packet fragments, and not reassembling the time information data packets according to the received time information data fragments at this time by the receiving side.
After the step S23, the method further includes:
step S50, obtaining a packet loss rate of the time information packet in a preset quality detection period according to the period number.
When the sending side sends the time information data packet in a whole manner or sends the time information data packet in a slicing manner, the receiving side can obtain the packet loss rate of the time information data packet in a preset quality detection period according to the cycle number of the received time information data packet.
The preset quality detection period is a time synchronization signal quality detection period configured in advance by the receiving side, and can be flexibly set according to an application scene of the receiving side or actual requirements on signal quality.
Because the ID numbers carried by the message heads of the time information data packets by the sending side are continuous and different numbers, the receiving side can identify different time information data packets according to the cycle numbers of the received time information data packets, thereby obtaining the quantity of the time information data packets received by the receiving side. Of course, the continuity of the transmission time information packets of the transmitting side may also be obtained by the cycle number.
In this embodiment, the correct and complete time information data packet is taken as an available data packet, and the incorrect or incomplete time information data packet is taken as an unavailable data packet.
Specifically, as an embodiment, the receiving side records an available packet and a discarded unavailable packet according to the cycle number, respectively, to obtain a packet record.
The receiving side can obtain the total number of the available data packets and the unavailable data packets received by the receiving side in the preset quality detection period according to the data packet record, namely the total number of the data packets received by the receiving side.
The receiving side can obtain the number of the unavailable data packets received by the receiving side in a preset quality detection period according to the data packet record.
Then, the receiving side calculates the proportion of the number of the unavailable data packets to the total number of the received data packets to obtain the packet loss rate of the receiving side, that is, the packet loss rate of the time information data packets.
Therefore, the receiving side obtains the packet loss rate of the time information data packet in the preset quality detection period.
Step S60, if the packet loss rate of the information data packet is greater than the preset threshold, the receiving side does not initiate time synchronization.
After the packet loss rate of the receiving side is obtained, if the packet loss rate of the receiving side is greater than a preset threshold value in a preset quality detection period, that is, the packet loss rate of the receiving side for the time information data packet exceeds the preset threshold value, the quality of the time information data packet may be poor due to a failure or a link of the transmitting side.
As an embodiment, the receiving side does not initiate time synchronization according to the time information packet in the quality detection period.
Then, the receiving side continues to check according to the time information data packet transmitted by the transmitting side.
And when the packet loss rate of the receiving side to the time information data packet is less than or equal to a preset threshold value in any quality detection period, the receiving side initiates time synchronization according to the time information data packet in the period.
It should be noted that the preset threshold is a preset proportional value, and can be flexibly set according to different application scenarios or quality requirements of the receiving side for the time information data packet.
In this embodiment, the sending side sends the time information data packet in a slicing manner, and the message header of the time information data packet carries the cycle number of the current time synchronization; the receiving side checks whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers; if the cycle number is verified correctly, the time information data packet received this time is correct and complete, and the receiving side acquires the time information to carry out time synchronization; if the cycle number is not checked correctly, the receiving side discards the current time information data packet; then, the receiving side acquires the packet loss rate of the time information data packet in a preset quality detection period according to the period number; and if the packet loss rate is greater than a preset threshold value, the receiving side does not initiate time synchronization for the moment. The embodiment realizes that the correctness of the time information data packet fragments is judged through the cycle number, the strict degree of the quality control of the time information data packet is improved, when the quality of the time information data packet cannot meet the preset requirement, the receiving side does not initiate time synchronization temporarily, and the time synchronization is started after the quality of the time information data packet meets the preset requirement. The embodiment improves the time synchronization accuracy and precision of the receiving side by controlling the quality of the time information data packet.
Further, referring to fig. 7, a seventh embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the embodiment shown in any one of fig. 1 to fig. 6 (taking fig. 6 as an example in this embodiment), where the time synchronization includes absolute time synchronization and/or second pulse synchronization, and the step S30 includes:
step S31, the receiving side determines whether the time information satisfies a preset condition for initiating time synchronization.
After obtaining the time information according to the time information data packet, the receiving side judges whether the obtained time information meets the preset condition of initiating time synchronization.
Specifically, as an implementation, the preset condition for initiating time synchronization is a requirement on current time information, which is configured in advance by the receiving side, and may include a requirement on a jitter magnitude of a clock source, a requirement on a working state of the clock source, a requirement on a state alarm of the clock source, a requirement on a link delay, a requirement on signal quality of a wireless interface, and the like. The receiving side can flexibly set the condition for initiating time synchronization according to the application scene of the receiving side or the quality requirement of the time information data packet, for example, the preset condition for initiating time synchronization is that the signal quality of a wireless interface is good and the link delay cannot exceed 530 ns.
The conditions of initiating time synchronization configured in advance by the current receiving side are as follows: the wireless interface signal quality is high or medium, as an example.
If the quality of the wireless interface signal in the obtained time information is 0x0, the receiving side judges that the quality of the current wireless interface is high, and the current time information meets the preset condition of initiating time synchronization.
If the signal quality of the wireless interface in the obtained time information is 0x3, the receiving side judges that the current wireless interface is unavailable, and the current time information does not meet the preset condition for initiating time synchronization.
Thereby, the receiving side obtains the determination result.
And step S32, if the time information meets the preset condition of initiating time synchronization, initiating absolute time synchronization and/or second pulse synchronization.
And after the judgment result is obtained, if the current time information meets the preset condition of initiating time synchronization, initiating time synchronization by the receiving side, wherein the time synchronization of the receiving side comprises absolute time synchronization and/or second pulse synchronization.
Specifically, as an embodiment, a GNSS TOD frame is taken as an example of a time information packet currently encapsulated by the transmitting side.
The time information acquired by the receiving side includes absolute time, time precision level, link delay and wireless interface signal quality.
The receiving side can synchronize local absolute time according to the absolute time of the transmitting side and the link delay.
The receiving side can recover the pulse-per-second signal of the transmitting side according to the absolute time of a plurality of time information data packets and the link delay in a certain time range. Then, the recovered second pulse signal is used as a reference second pulse. Then, the receiving side adjusts the frequency of the local clock crystal of the receiving side according to the obtained reference second pulse, so that the phase of the local second pulse signal reaches the reference second pulse.
The receiving side thus achieves synchronization of local absolute time and/or synchronization of local second pulses.
As another embodiment, a time information packet currently encapsulated by the transmitting side is taken as 1588 frame for example.
The time information acquired by the receiving side comprises 1588header, 1588timestamp, link time delay and wireless interface signal quality. When the time information is an announce message, the time information additionally comprises 1588time precision.
The receiving side can synchronize local absolute time according to 1588timestamp and link delay of the transmitting side.
The receiving side can recover the pulse per second signal of the transmitting side according to 1588time delay and link delay of a plurality of time information data packets in a certain time range. Then, the recovered second pulse signal is used as a reference second pulse. Then, the receiving side adjusts the frequency of the local clock crystal of the receiving side according to the obtained reference second pulse, so that the phase of the local second pulse signal reaches the reference second pulse.
The receiving side thus achieves synchronization of local absolute time and/or synchronization of local second pulses.
In this embodiment, the receiving side determines whether the obtained time information meets a preset condition for initiating time synchronization; and if the time information meets the preset condition of initiating time synchronization, the receiving side initiates absolute time synchronization and/or second pulse synchronization. According to the implementation, when the time information meets the preset condition of initiating time synchronization, absolute time synchronization and/or pulse per second synchronization are/is initiated according to the time information, so that whether time synchronization needs to be initiated or not is flexibly grasped according to factors such as the precision of the time information, and the accuracy of time synchronization at a receiving side is effectively improved.
Further, referring to fig. 8, an eighth embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the above-mentioned embodiment shown in fig. 7, where the step S32 includes:
step S321, if the time information meets a preset condition for initiating time synchronization, the receiving side initiates absolute time synchronization according to the time information.
And if the obtained time information meets the preset condition of initiating time synchronization, the receiving side initiates absolute time synchronization according to the time information.
Specifically, as an embodiment, a GNSS TOD frame is taken as an example of a time information packet currently encapsulated by the transmitting side.
And the receiving side initiates absolute time synchronization according to the absolute time in the time information, the link time delay and the local time of receiving the time information data packet by the receiving side.
For example, the absolute time T1 of the transmitting side is added to the link delay T2 to obtain the absolute time T3 of the transmitting side at the time when the receiving side receives the time information packet.
If the current time of the receiving side receiving the time information data packet is T4, the receiving side obtains the absolute time difference between the receiving side and the sending side according to the time difference between T3 and T4, and adjusts the local absolute time according to the obtained absolute time difference, thereby realizing the synchronization of the local absolute time of the receiving side.
As another embodiment, a time information packet currently encapsulated by the transmitting side is taken as 1588 frame for example.
And the receiving side initiates absolute time synchronization according to 1588timestamp in the time information, the link time delay and the local time of receiving the time information data packet by the receiving side.
For example, the link delay T2 is added to the time T1 of the 1588timestamp on the transmitting side to obtain the absolute time T3 of the transmitting side when the receiving side receives the time information packet.
If the current time of the receiving side receiving the time information data packet is T4, the receiving side obtains the absolute time difference between the receiving side and the sending side according to the time difference between T3 and T4, and adjusts the local absolute time according to the obtained absolute time difference, thereby realizing the synchronization of the local absolute time of the receiving side.
Thereby, the receiving side realizes absolute time synchronization.
And step S322, recovering the pulse per second signal of the transmitting side according to the time information data packet transmitted by the transmitting side.
The receiving side can recover and obtain the pulse per second signal of the transmitting side according to the received time information data packet.
Specifically, as an embodiment, since the transmitting side transmits the time information packet using a fixed frequency, for example, the transmitting side transmits the time information packet once every 10ms (millisecond), the transmitting side transmits 100 time information packets per second. If the absolute time of the first time information packet transmitted by the current transmitting side is 0 second, the absolute time of the transmitting side for transmitting the 101 st time information packet is 1 second, and the second bit time of the 1 st and 101 th time information packets can be used as the second pulse of the transmitting side.
Thereby, the receiving side obtains the pulse-per-second signal of the transmitting side.
Of course, the receiving side can also recover the pulse per second signal of the transmitting side in other modes, and the pulse per second signal can be flexibly set according to actual needs.
And step S323, adjusting the local clock frequency of the receiving side according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
After acquiring the pulse-per-second signal of the transmitting side, the receiving side adjusts the local clock frequency according to the pulse-per-second signal of the transmitting side, and performs pulse-per-second synchronization.
Specifically, as an embodiment, referring to fig. 20, the receiving side synchronizes the second pulse signal to the receiving side using a Phase Locked Loop (PLL) circuit.
After the pulse per second signal of the sending side is obtained, the receiving side controls a phase discriminator pd (phasedetector) to discriminate the phase according to the pulse per second signal of the sending side and the local pulse per second signal, and obtain a phase deviation value. Then, the phase discriminator converts the phase deviation value into the change of voltage, outputs an analog voltage signal, and filters out high-frequency clutter through a Low Pass Filter (LPF) (Low Pass Filter).
Then, the oven Controlled Crystal oscillator ocxo (oven Controlled Crystal oscillator) receives the signal of the low pass filter LPF, and uses the obtained voltage signal as a voltage-Controlled voltage, controls the oscillation of the local clock Crystal, and outputs the oscillation frequency of the local clock Crystal.
Then, the frequency divider feeds back the output frequency of the OXCO to the phase discriminator for judging whether the pulse-per-second signal of the current local clock is synchronous with the input reference pulse-per-second signal.
If the second pulse signal of the current local clock is synchronous with the input reference second pulse signal, the adjustment of the local second pulse signal is not carried out, the phase locking is carried out by a PLL (phase locked loop), the current local clock oscillation frequency is kept, and the local clock oscillation frequency is kept consistent with the clock oscillation frequency of the sending side.
If the pulse per second signal of the current local clock is not synchronous with the input reference pulse per second signal, the phase discriminator PD continues to discriminate the phase and adjusts the oscillation frequency of the local clock.
The local clock may be a rubidium clock, or may be another clock, and may be flexibly set according to actual needs.
Thereby, the reception side realizes the second pulse synchronization.
In this embodiment, if the obtained time information meets a preset condition for initiating time synchronization, the receiving side initiates absolute time synchronization according to the time information; the receiving side recovers the pulse per second signal of the transmitting side according to the time information data packet transmitted by the transmitting side; then, the receiving side adjusts the local clock frequency of the receiving side based on the second pulse signal of the transmitting side, and performs second pulse synchronization. In the embodiment, absolute time synchronization is performed according to the time information carried by the time information data packet, and the pulse per second signal of the sending side is recovered according to the received time information data packet, so that synchronization of local pulse per second is realized, and synchronization precision of local absolute time and pulse per second of the receiving side is improved.
Further, referring to fig. 9, a ninth embodiment of the time synchronization method according to the present invention provides a time synchronization method, based on the above embodiment shown in fig. 8, where the step S323 includes:
step S3231, a phase offset value from the local pulse per second signal of the receiving side is obtained according to the pulse per second signal of the transmitting side.
After the transmitting-side pulse-per-second signal is acquired, a phase deviation value from the receiving-side local pulse-per-second signal is acquired by using the transmitting-side pulse-per-second signal as a reference pulse-per-second signal.
Specifically, as an embodiment, the receiving side performs phase discrimination on the reference pulse-per-second signal and the local pulse-per-second signal, and obtains a phase deviation value between the reference pulse-per-second signal and the local pulse-per-second signal.
Step S3232, determining whether the phase deviation value exceeds a preset deviation threshold.
And after the phase deviation value is obtained, the receiving side judges whether the phase deviation value meets a preset deviation threshold value.
When it is necessary to be noted that, the preset deviation threshold is configured in advance by the receiving side according to the application scenario or the accuracy requirement for the local pulse per second. For example, if the error requirement of the receiving side for the local pulse per second is not strict, a deviation threshold with a large value may be set; if the error requirement of the receiving side for the local pulse per second is strict, a deviation threshold with a small value may be set.
If the phase deviation value is larger than a preset deviation threshold value, judging that the phase deviation value exceeds the preset deviation threshold value; and if the phase deviation value is smaller than or equal to the preset deviation threshold value, judging that the phase deviation value does not exceed the preset deviation threshold value.
Thereby, the receiving side obtains the determination result.
Step S3233, if the phase deviation value exceeds a preset deviation threshold, adjusting a local clock frequency of the receiving side according to the phase deviation value, obtaining the adjusted pulse-per-second signal of the receiving side, and proceeding to execute step S3231.
If the phase deviation value exceeds a preset deviation threshold value, the receiving side adjusts the local clock frequency of the receiving side according to the phase deviation value.
Specifically, as an embodiment, the receiving side converts the phase deviation value into a change of a voltage signal, and controls the oscillation of the local clock crystal according to the obtained voltage signal.
Then, the receiving side obtains the oscillation frequency adjusted by the local clock crystal, and obtains the second pulse signal adjusted by the receiving side according to the adjusted oscillation frequency.
And then, the receiving side performs phase discrimination on the reference pulse-per-second signal and the adjusted local pulse-per-second signal of the receiving side, and obtains a phase deviation value of the reference pulse-per-second signal and the adjusted local pulse-per-second signal.
And then, judging whether the phase deviation threshold value of the time exceeds a preset deviation threshold value, and if so, continuously adjusting the oscillation frequency of the local clock.
Step S3234, if the phase deviation value does not exceed the preset deviation threshold, determining that the current pulse per second synchronization is completed.
And if the phase deviation value does not exceed the preset deviation threshold value, the receiving side determines that the error between the current local clock pulse per second signal and the reference pulse per second signal meets the current use requirement, and judges that the pulse per second synchronization is finished.
Thereby, the reception side completes synchronization of the local second pulse.
In this embodiment, the receiving side acquires a phase deviation value from the local pulse per second signal according to the pulse per second signal of the transmitting side; judging whether the phase deviation value exceeds a preset deviation threshold value or not; if the phase deviation value exceeds a preset deviation threshold value, adjusting the local clock frequency of the receiving side according to the phase deviation value, acquiring the second pulse signal adjusted by the receiving side, acquiring the phase difference value between the second pulse signal adjusted by the receiving side and the second pulse signal of the sending side, and performing the next operation according to the phase difference value; and if the phase deviation value does not exceed the preset deviation threshold value, the receiving side judges that the second pulse synchronization is finished. In the embodiment, by configuring a deviation threshold in advance, only when the phase difference value between the local pulse per second signal at the receiving side and the local pulse per second signal at the transmitting side exceeds the deviation threshold, pulse per second synchronization is initiated until the phase difference value between the local pulse per second signal at the receiving side and the local pulse per second signal at the transmitting side is less than or equal to the deviation threshold; and when the phase difference value of the local pulse-per-second signal of the receiving side and the pulse-per-second signal of the sending side does not exceed the deviation threshold, judging that the pulse-per-second synchronization of the receiving side is finished. The implementation realizes flexible control of the error between the local pulse per second signal of the receiving side and the pulse per second signal of the sending side by presetting the deviation threshold, thereby ensuring the synchronization precision of the local pulse per second of the receiving side.
Referring to fig. 10, a first embodiment of the time synchronization apparatus according to the present invention provides a time synchronization apparatus, including:
a receiving module 10, configured to receive the time information data packet sent by the sending side.
The embodiment of the present invention is exemplified by time synchronization of a Base Station (BS) device, for example, referring to fig. 16, time synchronization between a base station and a terminal device, such as a mobile phone, and the like.
In the embodiment of the present invention, the communication between the transmitting side and the receiving side of the base station device is mainly performed by using a wireless Interface, such as an Air Interface (Air Interface).
In this embodiment, a base station providing a time synchronization function is used as a transmitting side, and a base station to be synchronized is used as a receiving side. The receiving side realizes the time synchronization function through the time synchronization device.
Specifically, as an embodiment, when the base station device performs time synchronization, first, the receiving module 10 receives a time information packet transmitted by the transmitting side.
The transmitting side is used as a macro base station, and obtains time service from GNSS (Global Navigation Satellite System) or IEEE 1588(Institute of Electrical and Electronics Engineers1588, i.e., the precision clock synchronization protocol standard of the network measurement and control System), and the obtained time precision is high. Of course, the sending side may also obtain time service from other time systems, and may be flexibly set according to actual needs.
Then, the transmitting side encapsulates the obtained Time and the information Of the current Time synchronization to obtain a Time information packet, such as a GNSS TOD frame (Global Navigation Satellite System Time Of Day) and a 1588 synchronization frame.
If the sending side acquires time from the GNSS system, the time information data packet obtained by encapsulation is a GNSS TOD frame. The GNSS TOD frame comprises a frame header, a message length field, a message payload and a frame check sequence field. The frame header, the message length field, the message payload and the frame check sequence field can be used as check information to check the correctness and integrity of the current time information data packet; the message payload is time information carried by the current time information data packet, and the time information includes information such as absolute time, time precision level, link transmission delay (link delay for short), wireless interface signal quality and the like of a sending side. The absolute time of the sending side is the local absolute time of the sending side when the sending side sends the time information data packet; the time precision level is used for representing the time precision of the current sending side and carries information such as a clock source, pulse per second (pps for short) jitter magnitude and the like; the link time delay is used for representing the link transmission time between the current sending side and the time synchronization device and can be obtained by the measurement of the sending side; the wireless interface signal quality is the wireless interface signal quality of the current transmitting side and can be measured by the transmitting side. Of course, the time information may also include other information, and may be flexibly set according to actual needs.
If the sending side acquires time from IEEE 1588, the time information data packet obtained by encapsulation is 1588 frames. 1588 frame includes header, message length field, message payload and frame check sequence field. The frame header, the message length field, the message payload and the frame check sequence field can be used as check information to check the correctness and the integrity of the current time information data packet; the message payload is time information carried by the current time information data packet, and the time information comprises a 1588header, a 1588timestamp, link time delay, wireless interface signal quality and the like. 1588header records the time information type, message length field and other information carried by the current time information data packet; 1588timestamp is the local absolute time of the sending side when the sending side sends the time information data packet; the link time delay is used for representing the link transmission time between the current sending side and the time synchronization device and can be obtained by the measurement of the sending side; the wireless interface signal quality is the wireless interface signal quality of the current transmitting side and can be measured by the transmitting side. Of course, the time information may also include other information, and may be flexibly set according to actual needs.
The sending side sends the time information data packet to the receiving module 10 periodically through the wireless interface, and the sending period can be flexibly set according to the application scene, the time synchronization requirement and other factors according to the actual situation.
The receiving module 10 receives the time information packet transmitted from the transmitting side.
And the information module 20 is configured to verify the time information data packet and obtain time information according to the time information data packet.
After receiving the time information data packet transmitted from the transmitting side, the information module 20 checks the obtained time information data packet, and obtains time information according to the time information data packet.
Specifically, as an implementation manner, first, the information module 20 obtains the verification information according to the GNSS TOD frame or the 1588 frame to perform verification, and determines whether the received time information data packet is correct and complete.
If the received time information data packet is correct and complete, the information module 20 parses the time information data packet to obtain the time information. If the current time information data packet is a GNSS TOD frame, the obtained time information comprises the information of absolute time, time precision level, link delay, wireless interface signal quality and the like of a sending side; if the current time information data packet is 1588 frames, the obtained time information comprises information such as a timestamp, link delay, wireless interface signal quality and the like.
If the currently received time information packet is incorrect or incomplete, the information module 20 discards the current time information packet as an embodiment.
Thereby, the information module 20 obtains time information.
And a synchronization module 30, configured to initiate time synchronization according to the acquired time information.
After obtaining the time information, the synchronization module 30 initiates time synchronization according to the obtained time information.
Specifically, as an embodiment, if the current time information data packet is a GNSS TOD frame, the synchronization module 30 performs local absolute time synchronization according to the absolute time, the time precision level, and the link delay in the time information.
Then, the synchronization module 30 recovers the pulse-per-second signal according to the time information packet, and uses the recovered pulse-per-second signal as a reference pulse-per-second. Then, the synchronization module 30 adjusts the frequency of the local clock crystal of the time synchronization apparatus according to the obtained reference second pulse, so as to synchronize the local second pulse signal with the reference second pulse signal.
If the current time information data packet is 1588 frames, the synchronization module 30 performs local absolute time synchronization according to 1588timestamp and link delay in the time information.
Then, the synchronization module 30 recovers the pulse-per-second signal according to the time information packet, and uses the recovered pulse-per-second signal as a reference pulse-per-second. The synchronization module 30 then adjusts the frequency of the local clock crystal based on the obtained reference second pulse to synchronize the local second pulse signal with the reference second pulse signal.
Thus, the synchronization module 30 achieves synchronization of local absolute time and second pulses.
As another embodiment, the synchronization module 30 may determine whether to initiate local time synchronization according to the quality of the wireless signal interface in the time information packet.
If the quality of the current wireless signal interface is poor or unavailable, the synchronization module 30 discards the time information packet, temporarily does not perform time synchronization, and performs time synchronization when the quality of the wireless signal interface is good or the time synchronization can be performed again when the quality of the wireless signal interface is good or the time is available.
If the quality of the current wireless signal interface is good or available, the synchronization module 30 initiates time synchronization according to the obtained time information.
In this embodiment, the receiving module 10 receives a time information data packet sent by a sending side; then, the information module 20 checks the obtained time information data packet, and acquires time information according to the time information data packet; then, based on the acquired time information, the synchronization module 30 initiates time synchronization. In this embodiment, the time is acquired by the sending side, and the time information is encapsulated into the time information data packet, so that the receiving side can perform time synchronization according to the time information in the time information data packet, thereby avoiding time precision reduction due to multiple exchanges and forwarding of the time information data packet when performing time synchronization by using IEEE 1588 networking. Meanwhile, the sending side sends the time information data packet to the receiving side through the wireless interface, so that an additional antenna is not needed, and the construction cost and the maintenance cost of the base station networking are reduced. The implementation reduces the engineering cost and the maintenance cost while ensuring the high precision of the time synchronization of the base station equipment, and avoids the problem of limited networking environment.
Further, referring to fig. 10, a second embodiment of the time synchronizer according to the present invention provides a time synchronizer, based on the first embodiment of the time synchronizer according to the present invention shown in fig. 10, the sending side transmits the time information packet in a slicing manner, the receiving module 10 is further configured to,
and receiving the time information data packet fragments sent by the sending side and reassembling the time information data packet fragments into a time information data packet.
In the embodiment of the invention, the sending side can directly receive the time information data packet obtained by encapsulation in the wireless frame of the wireless interface and send the time information data packet to the time synchronization device, can also fragment the time information data packet and receive the time information data packet in the wireless frame of the wireless interface and send the time information data packet to the time synchronization device, and can be flexibly set according to actual needs.
When the transmitting side transmits the time information packet fragment to the receiving side, the receiving module 10 receives the time information packet fragment transmitted from the transmitting side and reassembles into the time information packet.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
Referring to fig. 17, the GNSS TOD frame includes a frame header, a message length field, a message payload, and a frame check sequence field.
The frame header may be composed of 2 fixed byte SYNC CHAR (synchronization character), and is used to notify the time synchronization apparatus that the current message is a time synchronization message, that is, a time information data packet sent by the sending side. For example, the fixed value may be 0x43, where 0x43 represents the "C" character in ASCII (American Standard Code for Information exchange) Code; the fixed value may also be 0x4D, with 0x4D representing the "M" character in ASCII code.
The message header may be composed of 4 bytes and includes a message type and an ID number, where the message classification is used to characterize the type of time information carried by the current GNSS TOD frame, and the ID number is used to characterize the number of the current message in the message period. For example, using a fixed value of 0x8001 indicates that the current message is a GNSS TOD message; and using unsigned numbers 0-65535 to represent the number of the current time information data packet in the time synchronization period. It should be noted that the time synchronization period is a period in which the sending side performs time synchronization with the time synchronization apparatus, and can be flexibly referred to according to actual needs; and the sending side marks the sent time information data packets in sequence according to the sending time sequence, and represents the cycle number of the current time information data packet by the ID number.
The message length field, which may consist of 4 bytes, contains the length of the message payload.
The frame check sequence field may be composed of 1byte, 2 bytes or 4 bytes. 1byte, the polynomial of the frame check sequence is g (x) ═ x8+ x5+ x4+ 1; at 2 bytes, the Check sequence may be calculated using a CRC (Cyclic Redundancy Check) 16; at 4 bytes, the check sequence may be calculated using CRC 32. The frame check sequence field is 2 bytes in this embodiment, and CRC16 is used for illustration.
The message payload includes the content of the time information, which includes the absolute time, the time accuracy level, the link delay, the signal quality of the radio interface, etc., as shown in table 1 above.
Specifically, the absolute time includes the second in the week, the number of weeks, and LeapS (offset). The intra-week seconds represent the GNSS time intra-week seconds, the byte offset is 0, and the data type is an unsigned char (unsigned character) of 4 bytes, and the unit is s (seconds); the week number represents the GNSS time week number, the byte offset is 4, the data type is 2byte unidentified char, and the unit is week; LeapS characterizes the offset between GNSS Time and UTC (Coordinated Universal Time), where the byte offset is 6, and the signed char (signed character) with 1byte data type is given in s.
The time precision level includes the pulse per second state, clock source, TAcc (jitter magnitude), clock source working state and monitoring alarm.
The pulse per second state is the state of the current pulse per second, the byte offset is 7, and the data type is an unscheduled char of 1 byte. For example, a pulse per second state of 0x00 indicates that the pulse per second is normal; when the pulse per second state is 0x01, the atomic clock of the time synchronization equipment is represented as a holding state; when the pulse per second state is 0x02, the pulse per second is not available; when the pulse per second state is 0x03, the high-crystal oscillator of the time synchronization equipment is represented as a holding state; when the pulse per second state is 0x04, the transmission bearing equipment is characterized to keep; 0x05 and subsequent values 0xff are reserved values (reserved), and other pulse-per-second states may be added.
The clock source is the clock source of the current second pulse, the byte offset is 8, and the data type is the unsigned char of 1 byte. For example, when the clock source is 0x00, the representation clock source is a beidou satellite navigation system; when the clock source is 0x01, the clock source is characterized as a Global Positioning System (GPS); when the clock source is 0x02, the clock source is represented by GLONASS (abbreviation of global satellite navigation system in russian); when the clock source is 0x03, the characterization clock source is Galileo satellite navigation system; when the clock source is 0x04, characterizing that the clock source is IEEE 1588; when the clock source is 0x05, the representation clock source is NTP (Network Time Protocol); 0x06 and subsequent values 0xff are reserved values (reserved), and other clock sources may be added.
TAcc characterizes the jitter magnitude of the pulse-per-second, byte offset 9, and data type 1byte unsigned char. The jitter amount of the second pulse ranges from 0 to 255 levels, and is 15ns (nanoseconds) per level, for example, when TAcc is 0, the jitter amount representing the second pulse is 0 ns; when TACc is 2, the jitter amount representing the pulse per second is 30 ns; by analogy, when TAcc is 255, the jitter amount of the current second pulse is too large, and is meaningless.
The working state of the clock source represents the working state of the current clock source, the byte offset is 10, and the data type is an unidentified char of 2 bytes. The working state of the clock source defines the working Type (GNSS Fix Type) of the GNSS, and the range (range) representing the working quality is 0 to 3. For example, when the working state of the clock source is 0x00, it represents the current no fix (no fixed state); when the working state of the clock source is 0x01, representing the current dead reckoning only; when the working state of the clock source is 0x02, representing that the current working state is a 2D plane; when the working state of the clock source is 0x03, representing that the current working state is 3D stereo; when the working state of the clock source is 0x04, the current working state is represented as GNSS + dead reckoning (GNSS and dead reckoning); when the working state of the clock source is 0x05, representing the current Time only fix (only positioning Time); 0x06 and subsequent values 0xff are reserved values (reserved), and other clock source operating states may be added.
The monitoring alarm represents the state alarm of the current clock source, the byte offset is 12, and the data type is an unidentified char of 2 bytes. For example, when the monitoring alarm is Bit0, the current clock source antennaopen is characterized; when the monitoring warning is Bit1, characterizing the antenna short of the current clock source; when the monitoring alarm is Bit2, characterizing the current clock source not tracking satellites (satellites are not monitored); when the monitoring warning is Bit3, the current clock source surfey in progress is represented (under investigation); when the monitoring warning is Bit4, the current clock source no stored position is represented (no storage position); when the monitoring warning is Bit5, representing the current clock source leaf second pending; when the monitoring warning is Bit6, characterizing the current clock source in test mode (in test mode); when the monitoring alarm is Bit7, the current clock source position is queried; when the monitoring warning is Bit8, the current clock source almanac not complete is represented; when the monitoring warning is Bit9, characterizing the current clock source pps wa generated (pulse per second is generated); bit10 through Bit15 are reserved values (reserved), and other monitoring warnings may be added.
The link delay is the link delay between the current sending side and the time synchronization device, and is measured by the initiating side, the byte offset is 14, and the data type is an unknown char of 2 bytes. The link delay is 260.42ns (1chip, i.e. 1 wireless basic frame time) as a delay level, for example, when the link delay is 0x0, it represents that the current link has no delay; when the link delay is 0x1, the current link delay is represented to be 260.42ns (1chip, namely 1 wireless basic frame time); when the link time delay is 0x2, representing that the current link time delay is 520.84ns, and so on; when the link delay is 0x9600, the current link delay is represented to be 10 ms. 0x9601 and subsequent values 0xffff are reserved values (reserved), and other link delays may be added.
The signal quality of the wireless interface characterizes the signal quality of the wireless interface at the current transmitting side, the byte offset is 16, and the data type is 1byte assigned char. For example, when the signal quality of the wireless interface is 0x0, it represents that the current wireless interface quality is high; when the signal quality of the wireless interface is 0x1, representing the quality of the current wireless interface; when the signal quality of the wireless interface is 0x2, the current wireless interface quality is low; when the signal quality of the wireless interface is 0x3, the quality of the current wireless interface is represented as ineligible. 0x4 and the subsequent value 0xff are reserved values (reserved), and other radio interface signal qualities may be added.
In addition, the message payload reserves 3 bytes of data as a reserved value (reserved) for adding other information. It can be seen that the message payload is 20 bytes, i.e., 20 bytes.
Thus, the GNSS TOD frame encapsulated by the transmitting side is 32 bytes, that is, 32 bytes.
Then, the transmitting side divides the data of 32 bytes of the GNSS TOD frame into 16 subframes, each subframe being 2 bytes. The sending side sends data to the time synchronization device through the wireless interface, and the 16 sub-frames with 2 bytes are loaded in the wireless frame of the wireless interface for 16 times and sent out. Wherein the absolute time of transmission in the message payload is kept consistent with the local transmission time of the transmitting side.
After receiving the time information packet fragments sent by the sending side, that is, the subframes of each 2byte, the receiving module 10 reassembles the obtained subframes to obtain the GNSS TOD frames of the time information packet.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames. In this embodiment, the time information carried in the 1588 frame uses a sync message, a foldup message, or an announce message. Of course, other types of messages may be used for the 1588 frame.
1588 frame includes header, message length field, message payload and frame check sequence field.
The frame header may be composed of 2 fixed byte SYNC CHAR (synchronization character), and is used to notify the time synchronization apparatus that the current message is a time synchronization message, that is, a time information data packet sent by the sending side. For example, the fixed value may be 0x43, where 0x43 represents the "C" character in ASCII (American Standard Code for Information exchange) Code; the fixed value may also be 0x4D, with 0x4D representing the "M" character in ASCII code.
The message header can be composed of 4 bytes and is a message type and an ID number, the message classification is used for representing the type of the time information carried by the current 1588 frame, and the ID number is used for representing the number of the current message in the message period. For example, a fixed value of 0x8002 is used to indicate that the current message is a sync message; using a fixed numerical value 0x8003 to indicate that the current message is a followup message; using a fixed numerical value 0x8004 to represent that the current message is an announce message; and using unsigned numbers 0-65535 to represent the number of the current time information data packet in the time synchronization period. It should be noted that the time synchronization period is a period in which the sending side performs time synchronization with the time synchronization apparatus, and can be flexibly referred to according to actual needs; and the sending side marks the sent time information data packets in sequence according to the sending time sequence, and represents the cycle number of the current time information data packet by the ID number.
The message length field, which may consist of 4 bytes, contains the length of the message payload.
The frame check sequence field may be composed of 1byte, 2 bytes or 4 bytes. 1byte, the polynomial of the frame check sequence is g (x) ═ x8+ x5+ x4+ 1; at 2 bytes, the Check sequence may be calculated using a CRC (Cyclic Redundancy Check) 16; at 4 bytes, the check sequence may be calculated using CRC 32. The frame check sequence field is 2 bytes in this embodiment, and CRC16 is used for illustration.
The message payload includes the content of time information, and when the time information carried by the 1588 frame is a sync message or a followup message, the time information includes a 1588header, a 1588timestamp, a link delay, a wireless interface signal quality, and the like. When the time information carried by the 1588 frame is an announce message, the time information includes 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
1588header includes information carrying type of current message, and 34 bytes in total. Specifically, as shown in table 2, the Message Type carried by the 1588header is Transport Specific (dedicated for transmission), the byte offset is 0, and the size is 1 byte; version PTP (Precision Time Protocol Version), reserved, byte offset 1, size 1 byte; the Message length records the length of the payload of the current Message, the byte offset is 2, and the size is 2 bytes; the Domain number byte offset is 4 and the size is 1 byte; reserved byte offset is 5, size is 1 byte; flag field byte offset is 6, size is 2 bytes; correction field byte offset is 8, size is 8 bytes; reserved byte offset is 16, size is 4 bytes; source port Identity byte offset is 20 and size is 10 bytes; sequence ID (sequence ID) byte offset is 30, size is 2 bytes; control field byte offset is 32, size is 1 byte; the Log message Interval byte offset is 33 and the size is 1 byte.
1588time difference is time difference with UTC, including second bit information of 6 bytes and nanosecond bit information of 4 bytes, and the total is 10 bytes.
The 1588time precision exists only when the time information carried by the 1588 frame is an announce message, and the total time is 20 bytes. 1588 the time precision includes clock priority, clock class, clock precision, clock jitter, time source and transfer hop count. For example, clock priority characterizes the priority level of the current clock; the value range of the clock grade is 0-255, and the smaller the value is, the higher the clock grade is; the clock precision represents the time precision by using a numerical value; the clock jitter represents the jitter amount of the current clock; the transfer hop count represents the transfer hop count from the time source to the node, and 1 is added to each transfer hop; the time source characterizes the source of the current time, such as a satellite, an internal clock, etc.
The link delay represents the delay of the link between the sending side and the time synchronization device, in this embodiment, the sending side and the time synchronization device do not need to calculate the link delay interactively, and the link delay can be measured by the sending side. The link delay is 260.42ns (1chip, i.e. 1 wireless basic frame time) as a delay level, for example, when the link delay is 0x0, it represents that the current link has no delay; when the link delay is 0x1, the current link delay is represented to be 260.42ns (1chip, namely 1 wireless basic frame time); when the link time delay is 0x2, representing that the current link time delay is 520.84ns, and so on; when the link delay is 0x9600, the current link delay is represented to be 10 ms. 0x9601 and subsequent values 0xffff are reserved values (reserved), and other link delays may be added.
The signal quality of the wireless interface characterizes the signal quality of the wireless interface at the current transmitting side. For example, when the signal quality of the wireless interface is 0x0, it represents that the current wireless interface quality is high; when the signal quality of the wireless interface is 0x1, representing the quality of the current wireless interface; when the signal quality of the wireless interface is 0x2, the current wireless interface quality is low; when the signal quality of the wireless interface is 0x3, the quality of the current wireless interface is represented as ineligible. 0x4 and the subsequent value 0xff are reserved values (reserved), and other radio interface signal qualities may be added.
It should be noted that the link delay and the signal quality of the wireless interface total 2 bytes.
In addition, the message payload reserves 2 bytes of data as a reserved value (reserved) for adding other information.
The message payload is 48 bytes when the time information carried by the 1588 frame is a sync message or a followup message; and when the time information carried by the 1588 frame is an announce message, the message payload is 68 byte.
Therefore, 60 bytes (when the time information is a sync message or a followup message) or 80 bytes (when the time information is an announce message) can be obtained in total by 1588 frames. Then, the transmitting side divides the 1588 frame into 30 or 40 subframes, each subframe being 2 bytes. And the transmitting side transmits data through a wireless interface, and the 30 or 40 sub-frames with 2 bytes are loaded in a wireless frame of the wireless interface for 30 times or 40 times and transmitted. Wherein the absolute time of transmission in the message payload is kept consistent with the local transmission time of the transmitting side.
After receiving the time information packet fragments sent by the sending side, that is, the subframes of each 2byte, the receiving module 10 reassembles the obtained subframes to obtain 1588 frames of the time information packet.
In this embodiment, the sending side transmits the time information data packet in a fragmentation manner to adapt to the transmission capability of the network link, so as to improve the transmission efficiency, and the receiving module 10 receives the time information data packet fragmentation transmitted by the sending side and reassembles the time information data packet into the time information data packet, thereby performing time synchronization. The embodiment realizes the sending of the time information data packet in various modes, improves the transmission efficiency of the time information data packet, and effectively ensures the precision of time synchronization of the receiving side.
Further, referring to fig. 11, a third embodiment of the time synchronizer according to the present invention provides a time synchronizer, based on the first embodiment or the second embodiment of the time synchronizer according to the present invention shown in fig. 10 (the present embodiment takes the first embodiment of the time synchronizer according to the present invention shown in fig. 10 as an example), the information module 20 includes:
a checking unit 21, configured to check whether the time information data packet is correct and complete.
After acquiring the time information data packet transmitted by the transmitting side, the verification unit 21 verifies the correctness and integrity of the time information data packet.
Specifically, as an embodiment, the time information packet includes a frame header, a message length field, a message payload, and a frame check sequence field.
First, the checking unit 21 checks whether the time information packet is correct or not according to the frame header, and whether the time information packet is a time synchronization frame, such as a GNSS TOD frame or a 1588 frame.
The checking unit 21 checks whether the type of the time information carried by the time information data packet is correct or not according to the message header, whether the time information is a GNSS TOD message corresponding to a GNSS TOD frame, or whether the time information is a sync message, a foldup message or an announce message corresponding to a 1588 frame.
The checking unit 21 checks whether the message payload carried by the time information data packet is complete according to the message length field.
The checking unit 21 checks whether the time information data packet is complete according to the message payload and the frame check sequence field. And if the current time information data packet is not complete, discarding the current time information data packet. And if the current time information data packet is complete, the current time information data packet is confirmed to be correct and complete.
If the checking unit 21 checks correctly according to the frame header, correctly according to the message header, completely according to the message length field, and completely according to the message payload and the frame checking sequence field, it is determined that the current time information data packet is correct and complete.
Thereby, the verification unit 21 obtains the verification result of the current time information packet.
And an information unit 22, configured to, if the time data packet is correct and complete, obtain a message payload according to the time information data packet to obtain time information, where the message payload includes the time information.
If the current time information data packet is correct and complete, the information unit 22 obtains a message payload according to the time information data packet, where the message payload includes time information, and thus, the information unit 22 obtains the time information.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
The information unit 22 parses the currently obtained time information data packet to obtain a message payload. The message payload is time information encapsulated in the GNSS TOD frame by the transmitting side, and includes absolute time, time accuracy level, link delay, radio interface signal quality, and the like. Of course, the time information encapsulated at the transmitting side may also include other information, and may be flexibly set according to actual needs.
The information unit 22 thus obtains time information including absolute time, time accuracy level, link delay, and radio interface signal quality, etc.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames.
In this embodiment, the time information carried in the 1588 frame uses a sync message, a foldup message, or an announce message. Of course, other types of messages may be used for the 1588 frame.
The information unit 22 parses the currently obtained time information data packet to obtain a message payload. The message payload is time information encapsulated in a 1588 frame by a sending side, and if the time information encapsulated by the sending side is a sync message or a followup message, the message payload comprises a 1588header, a 1588timestamp, link delay, wireless interface signal quality and the like; when the time information carried by the 1588 frame is an announce message, the message payload comprises 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
Thereby, the information unit 22 obtains time information. It should be noted that, when the time information encapsulated at the sending side is a sync message or a followup message, the time information includes 1588header, 1588timestamp, link delay, wireless interface signal quality, and the like; when the time information carried by the 1588 frame is an announce message, the time information includes 1588header, 1588time frame, 1588time precision, link delay, wireless interface signal quality and the like.
In this embodiment, the checking unit 21 checks whether the currently obtained time information data packet is correct and complete; if the current time data packet is correct and complete, the information unit 22 obtains a message payload according to the time information data packet to obtain time information, where the message payload includes the time information. In this embodiment, the sending side encapsulates the time information in the time information data packet, and the receiving side firstly verifies whether the obtained time information data packet is correct and complete after obtaining the time information data packet, and obtains the time information only when the time information data packet is correct and complete, thereby avoiding that the incorrect or incomplete data packet reduces the time synchronization affecting the receiving side, and reducing the time synchronization precision. The embodiment realizes the verification of the correctness and the integrity of the time information data packet, and improves the correctness and the accuracy of the time synchronization of the receiving side.
Further, referring to fig. 11, a fourth embodiment of the time synchronization apparatus according to the present invention provides a time synchronization apparatus, based on the third embodiment of the time synchronization apparatus shown in fig. 11, where the time information packet includes a frame header, a message length field, a message payload, and a frame check sequence field, and the check unit 21 is further configured to,
checking whether the time information data packet is correct according to the frame header, checking whether the time information data packet is correct according to the message header, checking whether the time information data packet is complete according to the message length field and the message payload, and checking whether the time information data packet is complete according to the message payload and the frame check sequence field; and if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, judging that the time information data packet is correct and complete.
In this embodiment, the time information packets sent by the sending side all include a frame header, a message length field, a message payload, and a frame check sequence field. And the transmitting side flexibly selects the GNSS or IEEE 1588 acquisition time according to the working state of the clock source of the current acquisition time, and encapsulates the GNSS or IEEE 1588 acquisition time to obtain a GNSS TOD frame or 1588 frame.
After acquiring the time information data packet sent by the sending side, the checking unit 21 first checks whether the received time information data packet is correct and complete.
Specifically, as an embodiment, the time information packet currently encapsulated by the transmitting side is taken as a GNSS TOD frame for example.
The checking unit 21 checks whether the time information packet is correct according to the frame header. The checking unit 21 determines whether the keyword of the frame header is 0x43 or 0x4d preconfigured at the sending side, and if the keyword of the frame header is 0x43 or 0x4d, determines that the time information packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect.
The checking unit 21 checks whether the time information data packet is correct according to the message header. The checking unit 21 obtains the message type keyword carried by the message header, and since the checking unit 21 does not know the time information type sent by the sending side before receiving the time information data packet, the checking unit 21 determines whether the message type keyword is 0x8001, 0x8002, 0x8003, or 0x8004, that is, whether the time information carried by the current time information data packet is one of a GNSS TOD message, a sync message, a foldup message, or an announce message. If the keyword of the message header is 0x8001, 0x8002, 0x8003 or 0x8003, judging that the time information data packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect. For example, if the keyword of the message header is 0x8001, it is determined that the time information packet received this time is correct, and the time information carried by the current time information packet is acquired according to 0x8001 as the GNSS TOD message.
The checking unit 21 checks whether the time information data packet is complete according to the message length field and the message payload. The checking unit 21 obtains the message payload length carried by the current time information data packet according to the time length field, for example, when the message length field is 0x14, the message payload length is 20 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 20 bytes, and if the length of the payload of the message is 20 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, receiving the message payload sent by the sending side in 10 times and 2 bytes each time, judging whether the length of the current message payload is 20 bytes or not after the time information data packet is obtained through repacking, and if the length of the message payload is 20 bytes, judging that the received time information data packet is complete; otherwise, the received time information data packet is judged to be incomplete.
The checking unit 21 checks whether the time information data packet is complete according to the message payload and the frame check sequence field. The check unit 21 performs CRC16 check calculation for 1 time on the received message payload of 20 bytes and the frame check sequence, and if a fixed sequence x 15-x 0:0001110100001111 is obtained through calculation, the received time information data packet is judged to be complete; otherwise, the received time information data packet is judged to be incomplete.
Thereby, the verification unit 21 obtains a verification result.
As another embodiment, the time information packet currently encapsulated by the transmitting side is illustrated as 1588 frames.
The checking unit 21 checks whether the time information packet is correct according to the frame header. The checking unit 21 determines whether the keyword of the frame header is 0x43 or 0x4d preconfigured at the sending side, and if the keyword of the frame header is 0x43 or 0x4d, determines that the time information packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect.
The checking unit 21 checks whether the time information data packet is correct according to the message header. The checking unit 21 obtains the message type keyword carried by the message header, and since the checking unit 21 does not know the time information type sent by the sending side before receiving the time information data packet, the checking unit 21 determines whether the message type keyword is 0x8001, 0x8002, 0x8003, or 0x8004, that is, whether the time information carried by the current time information data packet is one of a GNSS TOD message, a sync message, a foldup message, or an announce message. If the keyword of the message header is 0x8001, 0x8002, 0x8003 or 0x8003, judging that the time information data packet received this time is correct; otherwise, the time information data packet received this time is judged to be incorrect. For example, if the keyword of the message header is 0x8002, it is determined that the time information packet received this time is correct, and the time information carried by the current time information packet is acquired according to 0x8002 as a sync message.
The checking unit 21 checks whether the time information data packet is complete according to the message length field and the message payload. The checking unit 21 obtains the message payload length carried by the current time information data packet according to the time length field, for example, when the message length field is 0x30, the message payload length is represented as 48 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 48 bytes, and if the length of the payload of the message is 48 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, the message payload sent by the sending side is received in 24 times and 2 bytes each time, whether the length of the current message payload is 48 bytes or not is judged after the time information data packet is obtained through reloading, and if the length of the message payload is 48 bytes, the time information data packet received this time is judged to be complete; otherwise, the received time information data packet is judged to be incomplete. And when the message length field is 0x44, the message payload length is 60 bytes. Then, if the sending side sends the time information data packet in the whole, judging whether the length of the payload of the current message is 60 bytes, and if the length of the payload of the message is 60 bytes, judging that the time information data packet received in the time is complete; otherwise, the received time information data packet is judged to be incomplete. If the sending side sends the time information data packet in a slicing mode, receiving the message payload sent by the sending side in 2 bytes for 30 times each time, judging whether the length of the current message payload is 60 bytes or not after the time information data packet is obtained through repacking, and if the length of the message payload is 60 bytes, judging that the received time information data packet is complete; otherwise, the received time information data packet is judged to be incomplete.
The checking unit 21 checks whether the time information data packet is complete according to the message payload and the frame check sequence field. The check unit 21 performs 1 CRC16 check calculation on the received message payload of 48 bytes or 60 bytes and the frame check sequence, and if a fixed sequence x 15-x 0:0001110100001111 is obtained by calculation, the received time information data packet is judged to be complete; otherwise, the received time information data packet is judged to be incomplete.
Thereby, the verification unit 21 obtains a verification result.
It should be noted that, in this embodiment, if the sending side fragments the time information data packet, the verifying unit 21 may perform the verification respectively according to the received time information data packet fragments after the receiving module 10 receives the time information data packet fragments, and the verifying method is the same as described above, and obtains the verifying result.
If the checking unit 21 checks that the time information data packet is correct according to the frame header, checks that the time information data packet is correct according to the message header, checks that the time information data packet is complete according to the message payload and the frame checking sequence field, and checks that the time information data packet is complete according to the message payload and the frame checking sequence field, the checking unit 21 judges that the received time information data packet is correct and complete; otherwise, the checking unit 21 determines that the time information data packet received this time is incorrect or incomplete.
Thereby, the verification unit 21 obtains a verification result for the time information packet received this time.
In this embodiment, the checking unit 21 checks whether the time information data packet is correct according to the frame header, checks whether the time information data packet is correct according to the message header, checks whether the time information data packet is complete according to the message length field and the message payload, and checks whether the time information data packet is complete according to the message payload and the frame check sequence field; and if the frame header is correctly checked, the message length field and the message payload are completely checked, and the message payload field and the frame check sequence field are completely checked, judging that the received time information data packet is correct and complete. In the embodiment, the time information data packet is verified in multiple modes, so that multiple verification on the correctness and the completeness of the time information data packet is realized, the receiving side only carries out time synchronization according to the correct and complete time information data packet, and the correctness and the accuracy of the time synchronization of the receiving side are improved.
Further, referring to fig. 12, a fifth embodiment of the time synchronizer according to the present invention provides a time synchronizer, based on the fourth embodiment of the time synchronizer according to the present invention shown in fig. 11, the time synchronizer further includes:
a discarding module 40, configured to discard the time information packet if the time information packet is incorrect or incomplete.
In the checking unit 21, whether the time information data packet is correct is checked according to the frame header, whether the time information data packet is correct is checked according to the message header, whether the time information data packet is complete is checked according to the message length field and the message payload, whether the time information data packet is complete is checked according to the message payload and the frame check sequence field, and after a check result is obtained, if the time information data packet received this time is incorrect or incomplete, the discarding module 40 discards the time information data packet received this time, which is not used for time synchronization of the time synchronization device.
Then, the receiving module 10 receives the next time information packet transmitted from the transmitting side, and the verifying unit 21 performs verification.
In this embodiment, if the time information packet received this time is incorrect or incomplete, the discarding module 40 discards the current time information packet. The embodiment realizes the control of the quality of the time information data packet, and the receiving side discards the time information data packet when the quality of the time information data packet cannot meet the preset requirement. The embodiment improves the time synchronization accuracy and precision of the receiving side by controlling the quality of the time information data packet.
Further, referring to fig. 13, a sixth embodiment of the time synchronization apparatus of the present invention provides a time synchronization apparatus, based on the fifth embodiment of the time synchronization apparatus of the present invention shown in fig. 12, the sending side sends the time information data packet in a fragmented manner, a message header of the time information data packet carries a cycle number of the current time synchronization, the checking unit 21 is further configured to,
and checking whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers.
In this embodiment, the transmitting side periodically transmits time information packets to the time synchronizer, and the time synchronizer performs time synchronization according to the received time information packets. It should be noted that the cycle number carried when the transmitting side transmits the time information packet is synchronized with the cycle number that the time synchronizer performs time synchronization.
In the time information data packet sent by the sending side, the ID number carried by the message header is the cycle number of the current time synchronization. For example, the transmitting side uses the unsigned numbers 0 to 65535 as the ID number, which indicates the number of the current time information packet in the time synchronization period, that is, the period number of the current time synchronization.
Specifically, as an embodiment, the transmitting side sequentially performs ID numbering on the headers of the time information packets according to the transmission time sequence of the time information packets. When the sending side fragments the time information data packet, each fragment of the time information data packet carries the same cycle number of the time synchronization, and the influence of the cycle number on the byte amount of each fragment is negligible.
After the receiving module 10 receives the time information data packet fragments, the checking unit 21 obtains the cycle number carried by each time information data packet fragment.
Then, the checking unit 21 determines whether the cycle number carried by the received time information packet fragment is the cycle number of the current time synchronization cycle according to the current time synchronization cycle. If the cycle number carried by the received time information data packet fragment is the cycle number of the current time synchronization cycle, judging that the time information data packet fragment is correct; otherwise, the current time information data packet is judged to be incorrect.
Meanwhile, the checking unit 21 determines whether the received time information data packet fragments are fragments of the same time information data packet according to whether the cycle numbers carried by the received time information data packet fragments are the same.
If the received time information data packet fragments carry the same cycle number in the current time synchronization cycle, and the cycle number of the time information data packet fragments is the same as the cycle number of the current time synchronization cycle, the verification unit 21 determines that the time information data packet fragments sent by the sending side are correct. Otherwise, the checking unit 21 determines that the time information packet fragment transmitted by the transmitting side is not correct.
If the time information data packet fragment sent by the current sending side is correct, the information unit 22 obtains the message payload according to the time information data packet, and obtains the time information.
If the time information data packet fragment sent by the current sending side is incorrect, the discarding module 40 discards the currently received time information data packet.
As another embodiment, when the transmitting side fragments the time information data packet, the checking unit 21 may check when the receiving module 10 receives the time information data packet fragments; if the time information data packet fragments are correct, the receiving module 10 reassembles the time information data packet fragments to obtain time information data packets; if the time information data packet fragment is incorrect, the discarding module 40 discards the time information data packet fragment, and the receiving module 10 does not reassemble the time information data packet according to the currently received time information data packet fragment.
The time synchronization apparatus further includes:
the quality inspection module 50 is configured to obtain a packet loss rate of the time information packet within a preset quality detection period according to the period number; and if the packet loss rate of the information data packet is greater than a preset threshold value, not initiating time synchronization.
When the sending side sends the time information data packet as a whole or sends the time information data packet in a fragmented manner, the quality inspection module 50 may number the time information data packet according to the period of the received time information data packet, and may obtain the packet loss rate of the time information data packet within a preset quality inspection period.
The preset quality detection period is a time synchronization signal quality detection period configured in advance by the receiving side, and can be flexibly set according to an application scene of the receiving side or actual requirements on signal quality.
Since the ID numbers carried by the message headers of the time information packets by the sending side are consecutive and different numbers, the quality inspection module 50 can identify different time information packets according to the cycle number of the received time information packet, thereby obtaining the number of the received time information packets. Of course, the continuity of the transmission time information packets of the transmitting side may also be obtained by the cycle number.
In this embodiment, the correct and complete time information data packet is taken as an available data packet, and the incorrect or incomplete time information data packet is taken as an unavailable data packet.
Specifically, as an embodiment, the quality inspection module 50 records an available data packet and a discarded unavailable data packet according to the cycle number, respectively, to obtain a data packet record.
The quality inspection module 50 may obtain the total number of the available data packets and the unavailable data packets received by the receiving module 10 in the preset quality inspection period, that is, the total number of the data packets received by the receiving module 10, according to the data packet record.
The quality inspection module 50 may obtain the number of the unavailable data packets received by the receiving module 10 in a preset quality inspection period according to the data packet record.
Then, the quality inspection module 50 calculates the ratio of the number of the unavailable data packets to the total number of the received data packets to obtain the packet loss rate of the receiving side, that is, the packet loss rate of the time information data packets.
Therefore, the quality inspection module 50 obtains the packet loss rate of the time information packet within the preset quality inspection period.
After the packet loss rate of the receiving side is obtained, if the packet loss rate is greater than the preset threshold value in the preset quality detection period, that is, the packet loss rate of the time information packet by the time synchronization device exceeds the preset threshold value, the quality of the time information packet may be poor due to a failure or a link of the transmitting side.
As an embodiment, the quality inspection module 50 controls the synchronization module 30 not to initiate time synchronization according to the time information packet in the quality inspection period.
Then, the quality inspection module 50 continues to perform the verification based on the time information packet transmitted from the transmitting side.
When the packet loss rate of the time information data packet is less than or equal to the preset threshold in any quality detection period, the synchronization module 30 initiates time synchronization according to the time information data packet in the period.
It should be noted that the preset threshold is a preset proportional value, and can be flexibly set according to different application scenarios or quality requirements of the receiving side for the time information data packet.
In this embodiment, the sending side sends the time information data packet in a slicing manner, and the message header of the time information data packet carries the cycle number of the current time synchronization; the checking unit 21 checks whether the time information data packet fragment sent by the sending side is correct according to the cycle number; if the cycle number is verified correctly, the time information data packet received this time is correct and complete, and the information unit 22 acquires the time information to perform time synchronization; if the cycle number is not checked correctly, the receiving side of the discarding module 40 discards the current time information data packet; then, the quality inspection module 50 obtains the packet loss rate of the time information packet within a preset quality inspection period according to the period number; if the packet loss rate is greater than the preset threshold, the quality inspection module 50 controls the synchronization module 30 to temporarily not initiate time synchronization. The embodiment realizes that the correctness of the time information data packet fragments is judged through the cycle number, the strict degree of the quality control of the time information data packet is improved, when the quality of the time information data packet cannot meet the preset requirement, the receiving side does not initiate time synchronization temporarily, and the time synchronization is started after the quality of the time information data packet meets the preset requirement. The embodiment improves the time synchronization accuracy and precision of the receiving side by controlling the quality of the time information data packet.
Further, referring to fig. 14, a seventh embodiment of the time synchronization apparatus according to the present invention provides a time synchronization apparatus, based on the embodiment shown in any one of fig. 10 to fig. 13 (taking fig. 13 as an example in this embodiment), where the time synchronization includes absolute time synchronization and/or second pulse synchronization, and the synchronization module 30 includes:
a condition unit 31, configured to determine whether the time information meets a preset condition for initiating time synchronization.
After obtaining the time information from the time information packet, the condition unit 31 determines whether the obtained time information satisfies a preset condition for initiating time synchronization.
Specifically, as an embodiment, the preset condition for initiating time synchronization is a requirement on the current time information, which is configured in advance by the condition unit 31, and may include a requirement on a jitter level of the clock source, a requirement on an operating state of the clock source, a requirement on a clock source state alarm, a requirement on a link delay, a requirement on signal quality of the wireless interface, and the like. The condition unit 31 may flexibly set the condition for initiating time synchronization according to the application scenario itself or the quality requirement for the time information data packet, for example, the preset condition for initiating time synchronization is that the signal quality of the wireless interface is good, and the link delay cannot exceed 530 ns.
The conditions for initiating time synchronization pre-configured by the current condition unit 31 are as follows: the wireless interface signal quality is high or medium, as an example.
If the quality of the radio interface signal in the obtained time information is 0x0, the condition unit 31 determines that the quality of the current radio interface is high, and the current time information satisfies a preset condition for initiating time synchronization, and can be used for initiating time synchronization.
If the signal quality of the wireless interface in the obtained time information is 0x3, the condition unit 31 determines that the current wireless interface is unavailable, and the current time information does not satisfy the preset condition for initiating time synchronization and cannot be used for initiating time synchronization.
Thereby, the condition unit 31 obtains the determination result.
A synchronization unit 32, configured to initiate absolute time synchronization and/or pulse-per-second synchronization if the time information meets a preset condition for initiating time synchronization.
After the determination result is obtained, if the current time information satisfies the preset condition for initiating time synchronization, the synchronization unit 32 initiates time synchronization, where the time synchronization includes absolute time synchronization and/or pulse per second synchronization.
Specifically, as an embodiment, a GNSS TOD frame is taken as an example of a time information packet currently encapsulated by the transmitting side.
The time information obtained by the information unit 22 includes absolute time, time accuracy level, link delay and radio interface signal quality.
The synchronization unit 32 may synchronize the local absolute time according to the absolute time of the transmitting side and the link delay.
The synchronization unit 32 may recover the pulse-per-second signal at the transmitting side according to the absolute time of the plurality of time information packets and the link delay within a certain time range. Then, the recovered second pulse signal is used as a reference second pulse. Then, the synchronization unit 32 adjusts the frequency of the local clock crystal according to the obtained reference second pulse to synchronize the local second pulse signal with the reference second pulse signal.
The synchronization unit 32 thus achieves synchronization of local absolute time and/or synchronization of local second pulses.
As another embodiment, a time information packet currently encapsulated by the transmitting side is taken as 1588 frame for example.
The time information acquired by the information unit 22 includes 1588header, 1588timestamp, link delay and radio interface signal quality. When the time information is an announce message, the time information additionally comprises 1588time precision.
The synchronization unit 32 may synchronize the local absolute time according to 1588timestamp and the link delay of the transmitting side.
The synchronization unit 32 may recover the pulse-per-second signal at the transmitting side according to 1588time delay and link delay of a plurality of time information packets within a certain time range. Then, the recovered second pulse signal is used as a reference second pulse. Then, the synchronization unit 32 adjusts the frequency of the local clock crystal according to the obtained reference second pulse to synchronize the local second pulse signal with the reference second pulse signal.
The synchronization unit 32 thus achieves synchronization of local absolute time and/or synchronization of local second pulses.
In this embodiment, the condition unit 31 determines whether the obtained time information meets a preset condition for initiating time synchronization; if the time information satisfies a preset condition for initiating time synchronization, the synchronization unit 32 initiates absolute time synchronization and/or pulse-per-second synchronization. According to the implementation, when the time information meets the preset condition of initiating time synchronization, absolute time synchronization and/or pulse per second synchronization are/is initiated according to the time information, so that whether time synchronization needs to be initiated or not is flexibly grasped according to factors such as the precision of the time information, and the accuracy of time synchronization at a receiving side is effectively improved.
Further, referring to fig. 15, an eighth embodiment of the time synchronizer according to the present invention provides a time synchronizer, and based on the above embodiment shown in fig. 14, the synchronizing unit 32 includes:
an absolute time synchronization subunit 321, configured to initiate absolute time synchronization according to the time information if the time information meets a preset condition for initiating time synchronization.
If the obtained time information satisfies a preset condition for initiating time synchronization, the absolute time synchronization subunit 321 initiates absolute time synchronization according to the time information.
Specifically, as an embodiment, a GNSS TOD frame is taken as an example of a time information packet currently encapsulated by the transmitting side.
The synchronization unit 32 initiates absolute time synchronization according to the absolute time in the time information, the link delay, and the local time when the receiving module 10 receives the time information packet.
For example, the absolute time T1 of the transmitting side is added to the link delay T2 to obtain the absolute time T3 of the transmitting side when the receiving module 10 receives the time information packet.
If the current time when the receiving module 10 receives the time information packet is T4, the absolute time synchronization subunit 321 obtains the absolute time difference between the receiving side and the transmitting side according to the time difference between T3 and T4, and adjusts the local absolute time according to the obtained absolute time difference, thereby implementing the synchronization of the local absolute time.
As another embodiment, a time information packet currently encapsulated by the transmitting side is taken as 1588 frame for example.
And the receiving side initiates absolute time synchronization according to 1588timestamp in the time information, the link time delay and the local time of receiving the time information data packet by the receiving module 10.
For example, the link delay T2 is added to the time T1 of the 1588timestamp on the transmitting side, so as to obtain the absolute time T3 of the transmitting side when the receiving module 10 receives the time information packet.
If the current time when the receiving module 10 receives the time information packet is T4, the absolute time synchronization subunit 321 obtains the absolute time difference between the receiving side and the transmitting side according to the time difference between T3 and T4, and adjusts the local absolute time according to the obtained absolute time difference, thereby implementing the synchronization of the local absolute time.
Thus, the absolute time synchronization subunit 321 achieves synchronization of local absolute time.
A pulse-per-second synchronization subunit 322, configured to recover a pulse-per-second signal of the transmitting side according to the time information packet sent by the transmitting side; and adjusting local clock frequency according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
The pulse-per-second synchronization subunit 322 may recover the pulse-per-second signal from the received time information packet.
Specifically, as an embodiment, since the transmitting side transmits the time information packet using a fixed frequency, for example, the transmitting side transmits the time information packet once every 10ms (millisecond), the transmitting side transmits 100 time information packets per second. If the absolute time of the first time information packet transmitted by the current transmitting side is 0 second, the absolute time of the transmitting side for transmitting the 101 st time information packet is 1 second, and the second bit time of the 1 st and 101 th time information packets can be used as the second pulse of the transmitting side.
Thereby, the second pulse synchronization subunit obtains the second pulse signal on the transmitting side.
Of course, the pulse-per-second synchronization subunit 322 may also recover the pulse-per-second signal at the transmitting side in other manners, and may be flexibly set according to actual needs.
After acquiring the pulse-per-second signal from the transmitting side, the pulse-per-second synchronization subunit 322 adjusts the local clock frequency according to the pulse-per-second signal from the transmitting side, and performs pulse-per-second synchronization.
Specifically, as an embodiment, referring to fig. 20, the pulse-per-second synchronization subunit 322 uses a Phase Locked Loop (PLL) circuit to perform local pulse-per-second signal synchronization.
After acquiring the pulse-per-second signal of the transmitting side, the pulse-per-second synchronization subunit 322 controls a phase detector pd (phasedetector) to perform phase detection according to the pulse-per-second signal of the transmitting side and the local pulse-per-second signal, and obtains a phase deviation value. Then, the phase discriminator converts the phase deviation value into the change of voltage, outputs an analog voltage signal, and filters out high-frequency clutter through a Low Pass Filter (LPF) (Low Pass Filter).
Then, the oven Controlled Crystal oscillator ocxo (oven Controlled Crystal oscillator) receives the signal of the low pass filter LPF, and uses the obtained voltage signal as a voltage-Controlled voltage, controls the oscillation of the local clock Crystal, and outputs the oscillation frequency of the local clock Crystal.
Then, the frequency divider feeds back the output frequency of the OXCO to the phase discriminator for judging whether the pulse-per-second signal of the current local clock is synchronous with the input reference pulse-per-second signal.
If the second pulse signal of the current local clock is synchronous with the input reference second pulse signal, the adjustment of the local second pulse signal is not carried out, the phase locking is carried out by a PLL (phase locked loop), the current local clock oscillation frequency is kept, and the local clock oscillation frequency is kept consistent with the clock oscillation frequency of the sending side.
If the pulse per second signal of the current local clock is not synchronous with the input reference pulse per second signal, the phase discriminator PD continues to discriminate the phase and adjusts the oscillation frequency of the local clock.
The local clock may be a rubidium clock, or may be another clock, and may be flexibly set according to actual needs.
Thus, the pulse-per-second synchronization subunit 322 realizes pulse-per-second synchronization.
In this embodiment, if the obtained time information meets the preset condition for initiating time synchronization, the absolute time synchronization subunit 321 initiates absolute time synchronization according to the time information; the pulse-per-second synchronization subunit 322 recovers the pulse-per-second signal of the transmitting side according to the time information data packet transmitted by the transmitting side; then, the pulse-per-second synchronization subunit 322 adjusts the local clock frequency of the receiving side based on the pulse-per-second signal of the transmitting side, and performs pulse-per-second synchronization. In the embodiment, absolute time synchronization is performed according to the time information carried by the time information data packet, and the pulse per second signal of the sending side is recovered according to the received time information data packet, so that synchronization of local pulse per second is realized, and synchronization precision of local absolute time and pulse per second of the receiving side is improved.
Further, referring to fig. 15, a ninth embodiment of the time synchronizer according to the present invention provides a time synchronizer, based on the eighth embodiment of the time synchronizer according to the present invention shown in fig. 15, the pulse per second synchronization subunit 322 is further configured to,
acquiring a phase deviation value with a local pulse per second signal according to the pulse per second signal at the transmitting side; judging whether the phase deviation value exceeds a preset deviation threshold value or not; if the phase deviation value exceeds a preset deviation threshold value, adjusting local clock frequency according to the phase deviation value, and acquiring an adjusted pulse per second signal; and if the phase deviation value does not exceed a preset deviation threshold value, judging that the second pulse synchronization is finished.
After acquiring the transmitting-side second pulse signal, the second pulse synchronization subunit 322 acquires a phase deviation value from the local second pulse signal using the transmitting-side second pulse signal as a reference second pulse signal.
Specifically, as an embodiment, the pulse-per-second synchronization subunit 322 phase-discriminates the reference pulse-per-second signal and the local pulse-per-second signal, and obtains a phase deviation value between the reference pulse-per-second signal and the local pulse-per-second signal.
After obtaining the phase deviation value, the pulse-per-second synchronization subunit 322 determines whether the phase deviation value satisfies a preset deviation threshold.
It should be noted that the preset deviation threshold is preset by the pulse-per-second synchronization subunit 322 according to the application scenario or the accuracy requirement for the local pulse-per-second. For example, if the pulse-per-second synchronization subunit 322 has less strict requirement on the error of the local pulse-per-second, a deviation threshold with a larger value may be set; if the pulse-per-second synchronization subunit 322 has strict requirements on the error of the local pulse-per-second, a deviation threshold with a smaller value may be set.
If the phase deviation value is larger than a preset deviation threshold value, judging that the phase deviation value exceeds the preset deviation threshold value; and if the phase deviation value is smaller than or equal to the preset deviation threshold value, judging that the phase deviation value does not exceed the preset deviation threshold value.
Thereby, the pulse-per-second synchronization subunit 322 obtains the determination result.
If the phase deviation exceeds the predetermined deviation threshold, the pulse-per-second synchronization subunit 322 adjusts the local clock frequency according to the phase deviation.
Specifically, as an embodiment, the receiving side converts the phase deviation value into a change of a voltage signal, and controls the oscillation of the local clock crystal according to the obtained voltage signal.
Then, the pulse-per-second synchronization subunit 322 obtains the oscillation frequency adjusted by the local clock crystal, and obtains an adjusted pulse-per-second signal according to the adjusted oscillation frequency.
Then, the pulse-per-second synchronization subunit 322 performs phase discrimination on the reference pulse-per-second signal and the adjusted local pulse-per-second signal, and obtains a phase deviation value between the reference pulse-per-second signal and the adjusted local pulse-per-second signal.
And then, judging whether the phase deviation threshold value of the time exceeds a preset deviation threshold value, and if so, continuously adjusting the oscillation frequency of the local clock.
If the phase deviation value does not exceed the preset deviation threshold, the pulse-per-second synchronization subunit 322 determines that the error between the current local clock pulse-per-second signal and the reference pulse-per-second signal meets the current use requirement, and determines that the pulse-per-second synchronization is completed.
Thus, the pulse-per-second synchronization subunit 322 completes the synchronization of the local pulse-per-second.
In this embodiment, the pulse per second synchronization subunit 322 obtains a phase deviation value from the local pulse per second signal according to the pulse per second signal on the transmitting side; judging whether the phase deviation value exceeds a preset deviation threshold value or not; if the phase deviation value exceeds a preset deviation threshold value, adjusting local clock frequency according to the phase deviation value, acquiring an adjusted pulse per second signal, acquiring a phase difference value between the adjusted pulse per second signal and a pulse per second signal at a sending side, and performing the next operation according to the phase difference value; if the phase deviation value does not exceed the preset deviation threshold, the pulse-per-second synchronization subunit 322 determines that the pulse-per-second synchronization is completed. In the embodiment, by configuring a deviation threshold in advance, only when the phase difference value between the local pulse per second signal at the receiving side and the local pulse per second signal at the transmitting side exceeds the deviation threshold, pulse per second synchronization is initiated until the phase difference value between the local pulse per second signal at the receiving side and the local pulse per second signal at the transmitting side is less than or equal to the deviation threshold; and when the phase difference value of the local pulse-per-second signal of the receiving side and the pulse-per-second signal of the sending side does not exceed the deviation threshold, judging that the pulse-per-second synchronization of the receiving side is finished. The implementation realizes flexible control of the error between the local pulse per second signal of the receiving side and the pulse per second signal of the sending side by presetting the deviation threshold, thereby ensuring the synchronization precision of the local pulse per second of the receiving side.
The above description is only an alternative 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.
Claims (10)
1. A time synchronization method, characterized in that the time synchronization method comprises the steps of:
a receiving side receives a time information data packet sent by a sending side;
the receiving side checks the time information data packet and acquires time information according to the time information data packet;
according to the acquired time information, the receiving side initiates time synchronization;
the time synchronization comprises absolute time synchronization and/or pulse per second synchronization, and the step of initiating the time synchronization by the receiving side according to the acquired time information comprises the following steps:
the receiving side judges whether the time information meets a preset condition for initiating time synchronization;
if the time information meets the preset condition of initiating time synchronization, absolute time synchronization and/or second pulse synchronization are initiated,
the step of the receiving side checking the time information data packet and obtaining the time information according to the time information data packet comprises the following steps:
the receiving side checks whether the time information data packet is correct and complete;
if the time information data packet is correct and complete, acquiring a message payload according to the time information data packet to obtain time information, wherein the message payload comprises the time information,
after the step of verifying whether the time information data packet is correct and complete by the receiving side, the method further includes:
if the time information data packet is incorrect or incomplete, the receiving side discards the time information data packet,
the sending side sends the time information data packet in a slicing mode, a message header of the time information data packet carries a cycle number of the time synchronization, and the receiving side checks whether the time information data packet is correct and complete, and the method further comprises the following steps:
checking whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers; if the cycle number is verified correctly, the execution step is carried out: if the time information data packet is correct and complete, acquiring a message payload according to the time information data packet to obtain time information, wherein the message payload comprises the time information; if the cycle number is not checked correctly, the execution step is carried out: if the time information data packet is incorrect or incomplete, the receiving side discards the time information data packet;
after the step of discarding the time information packet by the receiving side if the time information packet is incorrect or incomplete, the method further includes:
acquiring the packet loss rate of the time information data packet in a preset quality detection period according to the period number;
and if the packet loss rate of the information data packet is greater than a preset threshold value, the receiving side does not initiate time synchronization.
2. The time synchronization method of claim 1, wherein the transmitting side transmits the time information packet in a burst manner, and the receiving side receives the time information packet transmitted from the transmitting side, including:
and the receiving side receives the time information data packet fragments sent by the sending side and reassembles the time information data packet fragments into a time information data packet.
3. The time synchronization method of claim 1, wherein the time information packet comprises a frame header, a message length field, a message payload, and a frame check sequence field, and the step of the receiving side checking whether the time information packet is correct and complete comprises:
the receiving side checks whether the time information data packet is correct according to the frame header, checks whether the time information data packet is correct according to the message header, checks whether the time information data packet is complete according to the message length field and the message payload, and checks whether the time information data packet is complete according to the message payload and the frame check sequence field;
and if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, judging that the time information data packet is correct and complete.
4. The time synchronization method according to claim 1, wherein the step of initiating absolute time synchronization and/or pulse-per-second synchronization if the time information satisfies a predetermined condition for initiating time synchronization comprises:
if the time information meets the preset condition of initiating time synchronization, the receiving side initiates absolute time synchronization according to the time information;
recovering the pulse per second signal of the transmitting side according to the time information data packet transmitted by the transmitting side;
and adjusting the local clock frequency of the receiving side according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
5. The time synchronization method of claim 4, wherein the step of adjusting the clock frequency local to the receiving side according to the pulse-per-second signal of the transmitting side, and the step of initiating the pulse-per-second synchronization comprises:
acquiring a phase deviation value of the local pulse per second signal of the receiving side according to the pulse per second signal of the transmitting side;
judging whether the phase deviation value exceeds a preset deviation threshold value or not;
if the phase deviation value exceeds a preset deviation threshold value, adjusting the local clock frequency of the receiving side according to the phase deviation value, acquiring a second pulse signal adjusted by the receiving side, and turning to the execution step: acquiring a phase deviation value of the local pulse per second signal of the receiving side according to the pulse per second signal of the transmitting side;
and if the phase deviation value does not exceed a preset deviation threshold value, judging that the second pulse synchronization is finished.
6. A time synchronization apparatus, characterized in that the time synchronization apparatus comprises:
the receiving module is used for receiving the time information data packet sent by the sending side;
the information module is used for checking the time information data packet and acquiring time information according to the time information data packet;
the synchronization module is used for initiating time synchronization according to the acquired time information;
the time synchronization comprises absolute time synchronization and/or pulse per second synchronization, and the synchronization module comprises:
the condition unit is used for judging whether the time information meets a preset condition for initiating time synchronization;
a synchronization unit for initiating absolute time synchronization and/or pulse per second synchronization if the time information satisfies a preset condition for initiating time synchronization,
the information module includes:
the checking unit is used for checking whether the time information data packet is correct and complete;
an information unit, configured to, if the time information data packet is correct and complete, obtain a message payload according to the time information data packet to obtain time information, where the message payload includes the time information,
the time synchronization apparatus further includes:
a discarding module for discarding the time information packet if the time information packet is incorrect or incomplete,
the sending side sends the time information data packet in a slicing way, the message head of the time information data packet carries the cycle number of the time synchronization, the checking unit is also used for checking the time information data packet,
checking whether the time information data packet fragments sent by the sending side are correct or not according to the cycle numbers;
the time synchronization apparatus further includes:
the quality inspection module is used for acquiring the packet loss rate of the time information data packet in a preset quality inspection period according to the period number; and if the packet loss rate of the information data packet is greater than a preset threshold value, not initiating time synchronization.
7. The time synchronizer of claim 6 wherein said transmitting side transmits said time information packet in a burst, said receiving module further configured to,
and receiving the time information data packet fragments sent by the sending side and reassembling the time information data packet fragments into a time information data packet.
8. The time synchronization apparatus of claim 6, wherein the time information packet comprises a frame header, a message length field, a message payload, and a frame check sequence field, the check unit is further configured to,
checking whether the time information data packet is correct according to the frame header, checking whether the time information data packet is correct according to the message header, checking whether the time information data packet is complete according to the message length field and the message payload, and checking whether the time information data packet is complete according to the message payload and the frame check sequence field;
and if the frame header is verified correctly, the message length field and the message payload are verified completely, and the message payload field and the frame verification sequence field are verified completely, judging that the time information data packet is correct and complete.
9. The time synchronization apparatus of claim 6, wherein the synchronization unit comprises:
the absolute time synchronization subunit is used for initiating absolute time synchronization according to the time information if the time information meets a preset condition for initiating time synchronization;
the pulse per second synchronization subunit is used for recovering a pulse per second signal of the sending side according to the time information data packet sent by the sending side; and adjusting local clock frequency according to the pulse per second signal of the transmitting side, and initiating pulse per second synchronization.
10. The time synchronization apparatus of claim 9, wherein the pulse-per-second synchronization subunit is further configured to,
acquiring a phase deviation value with a local pulse per second signal according to the pulse per second signal at the transmitting side;
judging whether the phase deviation value exceeds a preset deviation threshold value or not;
if the phase deviation value exceeds a preset deviation threshold value, adjusting local clock frequency according to the phase deviation value, and acquiring an adjusted pulse per second signal;
and if the phase deviation value does not exceed a preset deviation threshold value, judging that the second pulse synchronization is finished.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510957093.1A CN106899371B (en) | 2015-12-18 | 2015-12-18 | Time synchronization method and device |
PCT/CN2016/095861 WO2017101484A1 (en) | 2015-12-18 | 2016-08-18 | Time synchronization method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510957093.1A CN106899371B (en) | 2015-12-18 | 2015-12-18 | Time synchronization method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106899371A CN106899371A (en) | 2017-06-27 |
CN106899371B true CN106899371B (en) | 2020-12-11 |
Family
ID=59055665
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510957093.1A Active CN106899371B (en) | 2015-12-18 | 2015-12-18 | Time synchronization method and device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106899371B (en) |
WO (1) | WO2017101484A1 (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108964825A (en) * | 2018-07-10 | 2018-12-07 | 重庆思柏高科技有限公司 | Calibration method, correction device and time server |
CN109347589B (en) * | 2018-10-15 | 2021-11-09 | ***通信有限公司研究院 | Data transmission method and network node |
US10958727B2 (en) | 2019-02-07 | 2021-03-23 | International Business Machines Corporation | Facilitating precision time protocol use in a coordinated timing network |
US10903924B2 (en) | 2019-02-07 | 2021-01-26 | International Business Machines Corporation | Setting primary reference time of server time protocol facility of a coordinated timing network to a precision-time-protocol source |
CN116132011A (en) * | 2021-11-15 | 2023-05-16 | 深圳市中兴微电子技术有限公司 | Clock synchronization system and method |
CN114071694B (en) * | 2021-11-17 | 2023-12-15 | 成都天奥电子股份有限公司 | Time service precision improving method and device based on Beidou satellite signals and storage medium |
CN114221833B (en) * | 2021-12-15 | 2023-12-05 | 傲普(上海)新能源有限公司 | BMS system data communication method |
CN114499731B (en) * | 2022-01-25 | 2024-05-28 | 中电科航空电子有限公司 | Ethernet synchronization method and system for cabin broadcast audio |
CN115150251B (en) * | 2022-05-27 | 2023-11-03 | 中国南方电网有限责任公司 | Fault diagnosis method, system and management platform for dispatching communication link of power private network |
CN115175297B (en) * | 2022-06-22 | 2024-05-14 | 中国电子科技集团公司第二十九研究所 | Satellite load second pulse autonomous recovery synchronization method |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1523830A (en) * | 2003-02-20 | 2004-08-25 | 华为技术有限公司 | Decapsulate method for synchronous digital series link access procedure |
CN1929337A (en) * | 2005-09-05 | 2007-03-14 | 华为技术有限公司 | Method and system for realizing information transfer between wireless transmitting-receiving equipments |
CN101483497A (en) * | 2008-12-15 | 2009-07-15 | 华亚微电子(上海)有限公司 | Data transmission system, receiving terminal and data packet recovery method thereof |
CN102083194A (en) * | 2009-11-30 | 2011-06-01 | 大唐移动通信设备有限公司 | Method, system and equipment for sending time information and synchronizing time |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR100902601B1 (en) * | 2007-05-17 | 2009-06-12 | 한양네비콤주식회사 | Wireless Time System And Method for Synchronizing Time |
CN101257442B (en) * | 2008-04-03 | 2010-05-12 | 中国人民解放军国防科学技术大学 | Method for exchanging time deterministic data based on time pressure |
CN101615948A (en) * | 2008-06-25 | 2009-12-30 | 鼎桥通信技术有限公司 | A kind of method and system that realize time synchronized |
CN102882669A (en) * | 2012-08-23 | 2013-01-16 | 上海柏飞电子科技有限公司 | Two-wire interface time synchronization protocol method |
CN103401672B (en) * | 2013-07-24 | 2016-08-24 | 福建星网锐捷网络有限公司 | Time synchronism apparatus, equipment and system |
CN104468013B (en) * | 2014-11-21 | 2017-06-27 | 中国运载火箭技术研究院 | A kind of structure of time slot of wireless networking communications determines method |
-
2015
- 2015-12-18 CN CN201510957093.1A patent/CN106899371B/en active Active
-
2016
- 2016-08-18 WO PCT/CN2016/095861 patent/WO2017101484A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1523830A (en) * | 2003-02-20 | 2004-08-25 | 华为技术有限公司 | Decapsulate method for synchronous digital series link access procedure |
CN1929337A (en) * | 2005-09-05 | 2007-03-14 | 华为技术有限公司 | Method and system for realizing information transfer between wireless transmitting-receiving equipments |
CN101483497A (en) * | 2008-12-15 | 2009-07-15 | 华亚微电子(上海)有限公司 | Data transmission system, receiving terminal and data packet recovery method thereof |
CN102083194A (en) * | 2009-11-30 | 2011-06-01 | 大唐移动通信设备有限公司 | Method, system and equipment for sending time information and synchronizing time |
Also Published As
Publication number | Publication date |
---|---|
CN106899371A (en) | 2017-06-27 |
WO2017101484A1 (en) | 2017-06-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106899371B (en) | Time synchronization method and device | |
US10257798B1 (en) | Synchronizing clocks in a wireless system | |
US8675634B2 (en) | Terminal measurement based synchronization for mesh satellite communications | |
US11115941B2 (en) | Wireless communication system, wireless terminal, and time synchronization method | |
US9548831B2 (en) | Synchronizing system, synchronizing method, first synchronizing device, second synchronizing device, and computer program | |
US9813173B2 (en) | Time signal verification and distribution | |
JP4941775B2 (en) | Time synchronizer | |
CN1620827B (en) | Method, apparatus and system for synchronizing a cellular communication system to GPS time | |
US9876596B2 (en) | Method and device for detecting fault in synchronization link | |
KR102226879B1 (en) | System and method for precise time tagging of events over a imprecise link | |
US9763207B2 (en) | Timing synchronization device and timing synchronization control method | |
CN101485126A (en) | Method for synchronization of assemblies in a base station | |
WO2023124403A1 (en) | Clock synchronization method, apparatus and system | |
EP3425969B1 (en) | Synchronization information sending or receiving method, base station, and communication node | |
WO2023124404A1 (en) | Precision information sending method, device, and system | |
CN105245324A (en) | Clock synchronization method and device | |
US9295017B2 (en) | Methods and arrangement for supporting base station synchronization by use of long wave signaling | |
CN107493599B (en) | Method, device and system for realizing time synchronization between base station devices through baseband radio frequency interface | |
CN116599616A (en) | Base station clock switching method, device, base station and medium | |
TW202143766A (en) | Time synchronization operation in vehicle communication | |
JP2011109165A (en) | Radio communication system, method of calculating error time, and method of acquiring time synchronization between base stations | |
KR20150016735A (en) | Network synchronization system using centralized control plane | |
KR20040007159A (en) | Time Synchronization Method for Automatic Identification System and AIS Transponder using the same | |
US20230032067A1 (en) | Method and apparatus for acquisition of reliable time in a wireless network | |
EP3170274B1 (en) | A method and a device for generating a timing signal |
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 |