CN112040539B - Clock synchronization method, device and storage medium - Google Patents
Clock synchronization method, device and storage medium Download PDFInfo
- Publication number
- CN112040539B CN112040539B CN202010914929.0A CN202010914929A CN112040539B CN 112040539 B CN112040539 B CN 112040539B CN 202010914929 A CN202010914929 A CN 202010914929A CN 112040539 B CN112040539 B CN 112040539B
- Authority
- CN
- China
- Prior art keywords
- time
- clock
- time interval
- measurement
- clock 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
- 238000000034 method Methods 0.000 title claims description 47
- 238000005259 measurement Methods 0.000 claims abstract description 136
- 230000004044 response Effects 0.000 claims abstract description 20
- 230000001360 synchronised effect Effects 0.000 claims abstract description 12
- 238000005516 engineering process Methods 0.000 claims description 24
- 238000004891 communication Methods 0.000 claims description 13
- 238000012545 processing Methods 0.000 claims description 11
- 230000005540 biological transmission Effects 0.000 abstract description 19
- 230000002452 interceptive effect Effects 0.000 description 12
- 230000005236 sound signal Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 7
- 230000008569 process Effects 0.000 description 4
- 238000004364 calculation method Methods 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 229920001621 AMOLED Polymers 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003321 amplification Effects 0.000 description 1
- 239000013078 crystal Substances 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003199 nucleic acid amplification method Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000002096 quantum dot Substances 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000005070 sampling Methods 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W56/00—Synchronisation arrangements
- H04W56/004—Synchronisation arrangements compensating for timing error of reception due to propagation delay
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W4/00—Services specially adapted for wireless communication networks; Facilities therefor
- H04W4/80—Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W56/00—Synchronisation arrangements
- H04W56/001—Synchronization between nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W84/00—Network topologies
- H04W84/02—Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
- H04W84/10—Small scale networks; Flat hierarchical networks
- H04W84/12—WLAN [Wireless Local Area Networks]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Electric Clocks (AREA)
- Synchronisation In Digital Transmission Systems (AREA)
Abstract
In one measurement, a first time is the time when a slave device sends a clock synchronization request, a second time is the time when a master device receives the clock synchronization request, a third time is the time when the slave device receives a clock synchronization response, and the clock synchronization response carries the second time. Acquiring a time interval of two measurements, wherein the time difference between the first moment and the third moment is smaller than a preset time difference, and the time interval is determined according to the first moment and/or the third moment in the two measurements; if the time interval is greater than the preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two measurements, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device. Precise clock synchronization is performed in wireless transmission.
Description
Technical Field
The present application relates to the field of wireless audio transmission technologies, and in particular, to a clock synchronization method, apparatus, and storage medium.
Background
In the wireless audio transmission technology, key technical indicators include: the transmission bandwidth for determining the definition of voice, the transmission delay for determining the system delay, the anti-interference performance and the like. In common application scenarios, wireless audio is mostly insensitive to clock synchronization, and in these application scenarios, it is only necessary that audio data (signals) are transmitted to an opposite end without packet loss. But some application scenarios have strict requirements on clock synchronization. For example, in a conference system, if a microphone is to be wireless, a clock offset between two digital wireless devices needs to be considered due to an acoustic echo cancellation problem, and if the clock offset exceeds 10ppm (ppm: parts per million), the acoustic echo cancellation performance will be significantly reduced, which may cause interference such as echo and howling in the conference system, and seriously affect the user experience, and thus a problem needs to be solved.
At present, most of clock synchronization technologies based on a wired method are implemented based on a Precision Time Protocol (PTP), which is mature. PTP, among other things, requires that the round-trip time of a data packet be as small as possible and that the time at which the data packet is sent out or arrives can be measured precisely. However, the transmission time of the data packet in wireless transmission is difficult to stabilize, so the current clock synchronization technology based on the wired method is not suitable for clock synchronization of wireless transmission.
Disclosure of Invention
The application provides a clock synchronization method, a clock synchronization device and a storage medium, so as to perform accurate clock synchronization in wireless transmission.
In a first aspect, an embodiment of the present application provides a clock synchronization method, which is applied to a slave device, where the slave device uses a clock of a master device as a standard clock, and in one measurement, a first time is a time when the slave device sends a clock synchronization request, a second time is a time when the master device receives the clock synchronization request, a third time is a time when the slave device receives a clock synchronization response, and the clock synchronization response carries the second time. The method comprises the following steps: acquiring a time interval of two measurements, wherein the two measurements are two measurements of which the time difference between the first time and the third time is smaller than a preset time difference, and the time interval is determined according to the first time and/or the third time in the two measurements; if the time interval is greater than the preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two measurements, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device.
In one possible embodiment, the determining the clock offset of the slave device from the master device according to the time interval and the third time of the two measurements may include: determining the clock offset of the slave device relative to the master device according to the following formula:
Δt=(ΔtB-ΔtA)/ΔtA
wherein, Δ tAThe difference value between the third time instants in the two measurements is obtained; Δ tBAre time intervals.
In a second aspect, an embodiment of the present application provides a clock synchronization apparatus, which is applied to a slave device, where the slave device uses a clock of a master device as a standard clock, and in one measurement, a first time is a time when the slave device sends a clock synchronization request, a second time is a time when the master device receives the clock synchronization request, and a third time is a time when the slave device receives a clock synchronization response, where the clock synchronization response carries the second time. The clock synchronization device includes:
the acquisition module is used for acquiring a time interval of two times of measurement, wherein the two times of measurement are two times of measurement that the time difference between the first time and the third time is smaller than a preset time difference, and the time interval is determined according to the first time and/or the third time in the two times of measurement;
the processing module is used for determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two times of measurement when the time interval is greater than the preset time interval, and the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device.
In a possible embodiment, the processing module, when determining the clock offset of the slave device with respect to the master device according to the time interval and the third time in the two measurements, is specifically configured to: determining the clock offset of the slave device relative to the master device according to the following formula:
Δt=(ΔtB-ΔtA)/ΔtA
wherein, Δ tAThe difference value between the third time instants in the two measurements is obtained; Δ tBAre time intervals.
On the basis of the above embodiment:
alternatively, the preset time difference is determined according to the characteristics of the wireless technology.
Optionally, the wireless technology may include at least one of:
bluetooth, wireless Internet of things (WiFi), Zigbee protocol (Zigbee), Z-Wave and household Internet of things communication protocol (Thread).
Optionally, the size of the preset time interval is a value obtained by dividing the preset time difference by the preset clock skew measurement accuracy.
Optionally, the time interval is a difference between first time instants of the two measurements; alternatively, the time interval is the difference between the third time instants in the two measurements.
Optionally, the time interval is: Δ tB=(tB4+tB3)/2-(tB2+tB1) /2, wherein tB3And tB4A first time and a third time of one measurement in the two measurements respectively; t is tB1And tB2A first time and a third time of the other of the two measurements, respectively.
In a third aspect, an embodiment of the present application provides an electronic device, including:
a memory for storing program instructions;
a processor for invoking and executing program instructions in a memory to perform a method as claimed in any one of the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which program instructions are stored; the program instructions, when executed, implement the method of any one of the first aspect.
The clock synchronization method, the clock synchronization device and the storage medium provided by the embodiment of the application are applied to the slave device which takes the clock of the master device as a standard clock, in one measurement, the first time is the time when the slave device sends the clock synchronization request, the second time is the time when the master device receives the clock synchronization request, the third time is the time when the slave device receives the clock synchronization response, and the clock synchronization response carries the second time. The method comprises the following steps: acquiring a time interval of two measurements, wherein the two measurements are two measurements of which the time difference between the first time and the third time is smaller than a preset time difference, and the time interval is determined according to the first time and/or the third time in the two measurements; when the time interval is greater than the preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two measurements, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device. The second time in one measurement is between the first time and the third time, and the smaller the time difference between the first time and the third time, the more credible the second time is, so that the time difference between the first time and the third time of the two measurements obtained by the application is smaller than the preset time difference; in addition, when the time interval of the two times of measurement is greater than the preset time interval, the clock deviation of the slave equipment relative to the master equipment is determined, and the preset time interval is set to meet the preset clock deviation measurement accuracy, so that accurate clock synchronization is carried out in wireless transmission.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is an exemplary diagram of an application scenario provided in an embodiment of the present application;
fig. 2 is a flowchart of a clock synchronization method according to an embodiment of the present application;
fig. 3 is a diagram illustrating signaling interaction in a clock synchronization method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a clock synchronization apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terms "first" and "second" and the like in the description and in the claims, and in the accompanying drawings of the embodiments of the application, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. "/" indicates a relationship of "or".
In a common application scenario, wireless audio is mostly insensitive to clock synchronization, for example, a mobile phone is used to watch live broadcast, a wireless microphone, a wireless interphone, and the like. In these application scenarios, it is only necessary to transmit audio data (signals) to the opposite end without packet loss, and even in a real-time audio scenario, the delay is only required to be as low as possible, for example, wireless microphone sound amplification. But some application scenarios have strict requirements on clock synchronization, e.g. conferencing systems.
In a conferencing system, if the microphones are to be wireless, it is necessary to take into account that there may be a clock skew in the clock between the two digital wireless devices due to acoustic echo cancellation issues. The clock skew is caused by an error in the accuracy of a device such as a crystal oscillator. This clock skew results in a slight difference in the audio sampling rates of the two digital wireless devices, which has a large effect on the acoustic echo cancellation process. If the clock deviation exceeds 10ppm, the acoustic echo cancellation performance will be significantly reduced, which may cause interference such as echo and howling in the conference system, and seriously affect the user experience.
The clock synchronization of wireless transmission is difficult mainly because the wireless transmission intermediate link has interference, impact and other uncontrollable factors, which can cause the transmission time of the data packet to be difficult to be stable, and in the current clock synchronization technology based on a wired mode, PTP requires the round-trip time of the data packet to be as small as possible and can accurately measure the time when the data packet is sent or arrives. Therefore, a clock synchronization scheme suitable for wireless transmission is needed.
The core of clock synchronization is as follows: the clock skew between the two devices is calculated.
Based on the above findings, the present application provides a method for clock synchronization in a wireless environment, which can obtain an accurate clock synchronization result even in a complex environment with large interference. Specifically, the slave device determines the clock skew of the slave device relative to the master device by acquiring two times of measurement when the time difference between the first time and the third time is smaller than the preset time difference, and determining the preset clock skew measurement accuracy by setting the preset time interval when the time interval between the two times of measurement is larger than the preset time interval.
In addition, the scheme has low requirements on transmission delay, timestamp measurement and the like of the data packet, and has strong adaptability; moreover, the scheme does not depend on specific wireless technologies, such as WiFi, Bluetooth, Zigbee, Z-Wave, the communication protocol technology (Thread) of the family Internet of things, U-segment and the like.
Fig. 1 is an exemplary diagram of an application scenario provided in an embodiment of the present application. As shown in fig. 1:
the electronic device A and the electronic device B communicate with each other through a wireless technology, and the electronic device A and the electronic device B need to be time synchronized. The clock synchronization method provided by the application can accurately calculate the clock deviation between the electronic equipment B and the electronic equipment A, so that data compensation and processing are performed through software.
In the example shown in fig. 1, the electronic device a is exemplified by an interactive tablet (interactive tablet) and the electronic device B is exemplified by a wireless microphone, but the present application is not limited thereto. The interactive flat panel is integrated with any one or more functions of a projector, an electronic whiteboard, a curtain, a sound box, a television, a video conference terminal and the like; a wireless microphone, or wireless microphone, is an acoustic apparatus for transmitting sound signals, and is composed of a transmitter and a receiver, which are generally called a wireless microphone system. The wireless microphone in the present application is a two-way wireless communication system. Specifically, conference software is installed in the interactive tablet, and both a local conference participant and an opposite conference participant can log in the conference software through the interactive tablet to participate in the same conference. In the conference process, the wireless microphone transmits the acquired audio signals of the local conference participants to the interactive flat plate through a wireless technology, the interactive flat plate transmits the local conference contents to the opposite terminal, and the local conference contents comprise the audio signals and the video signals of the local conference participants; meanwhile, the interactive flat plate receives the opposite-end conference content and plays the audio signals and the video signals related to the opposite-end conference content to the local-end conference participants. When the interactive flat panel plays an audio signal, the wireless microphone also receives the audio signal, and in order to avoid interference such as echo and howling, the wireless microphone needs to perform acoustic echo cancellation. At this time, the wireless microphone needs to use the clock of the interactive tablet as a standard clock to perform clock synchronization.
Fig. 1 illustrates a conference scenario as an example, but the present application is not limited thereto; in addition, the master device and the slave device are relative concepts, and one of the two electronic devices performing wireless transmission through a wireless technology is the master device, and the other electronic device is the slave device, and the two electronic devices can be interchanged, depending on the actual situation. If not specifically stated, for a one-to-many scenario, the electronic device corresponding to "one" is the master device, and the electronic devices corresponding to "many" are the slave devices.
The clock synchronization method provided by the present application is explained below with reference to specific embodiments.
Fig. 2 is a flowchart of a clock synchronization method according to an embodiment of the present application. The clock synchronization method may be performed by a clock synchronization apparatus, which may be implemented by software and/or hardware. In practical applications, the clock synchronization apparatus may be a slave device or a chip or a circuit of the slave device.
Referring to fig. 2, the clock synchronization method provided in this embodiment includes:
s201, obtaining a time interval of two times of measurement, wherein the two times of measurement are two times of measurement that the time difference between the first time and the third time is smaller than a preset time difference, and the time interval is determined according to the first time and/or the third time in the two times of measurement.
Specifically, in one measurement, the first time is a time when the slave device sends a clock synchronization request, the second time is a time when the master device receives the clock synchronization request, the third time is a time when the slave device receives a clock synchronization response, and the clock synchronization response carries the second time.
As shown in fig. 3:
1. the slave device sends a clock synchronization request and simultaneously records the time when the clock synchronization request is sent: first time tB1;
2. Recording the received time when the master device receives the clock synchronization request: second time tA1And immediately about the second time tA1The clock synchronization response is carried in the clock synchronization response and replied to the slave equipment;
3. recording the received time when the slave device receives the clock synchronization response: third time tB2And a second time t is resolvedA1;
One measurement can be completed in the three steps, and at this time, the slave device acquires a group of clock information which is respectively recorded as: first time tB1A second time tA1And a third time tB2。
After a period of time, the slave device takes measurements again, resulting in another set of clock information: first time tB3A second time tA2And a third time tB4。
After a further period of time, the slave device takes a further measurement, resulting in a further set of clock information: first time tB5A second time tA3And a third time tB6。
At this time, if it is assumed that the two sets of clock information are accurate values, the clock skew of the slave device with respect to the master device can be determined based on the clock information. However, in practical situations, due to factors such as interference of a wireless environment or preemption of software operation, many clock information have large errors, and therefore two sets of relatively reliable clock information need to be selected from the clock information.
It should be clear that the slave device may periodically obtain the clock information after powering on, for example, every 3 seconds.
Generally, the above three clock information are obtained by software without special hardware support, so that errors necessarily exist, and the smaller the error, the better the error.
Since the second time must be recorded between the first time and the third time, it can be understood that the second time can be considered more reliable (less error) as the time difference between the third time and the first time is smaller. Therefore, the error of the second time can be measured by comparing the time difference between the third time and the first time, and if the time difference between the third time and the first time is small, which indicates that the information (such as the clock synchronization request and the clock synchronization response) between the slave device and the master device is transmitted faster, the three clock information are relatively accurate, and the clock offset determined according to the three clock information is more accurate. Thus, the present application requires that two measurements involved in the clock skew calculation satisfy: the time difference between the first time and the third time is smaller than the preset time difference. For example, referring to fig. 3, Δ TB1 needs to be smaller than the predetermined time difference, and if Δ TB1 is greater than or equal to the predetermined time difference, the set of time information is discarded, that is, the measurement does not participate in the calculation of the clock offset. Similarly, Δ TB2 needs to be smaller than the preset time difference, otherwise the group of time information is discarded, and so on.
For "the time interval is determined according to the first time and/or the third time of two measurements", the following can be understood:
firstly, the time interval is determined according to the first moment in two measurements;
secondly, the time interval is determined according to the third moment in the two measurements;
and thirdly, determining the time interval according to the first time and the third time in the two measurements.
The time interval is a time interval corresponding to the slave device in two measurements, and the specific determination manner may refer to the following embodiments.
And S202, if the time interval is greater than the preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two times of measurement, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation.
It can be understood that different wireless technologies have different requirements on the measurement accuracy of the clock skew, and therefore, the preset time intervals corresponding to different wireless technologies are determined according to the preset clock skew measurement accuracy, and the clock skew measurement accuracy is exchanged by time. The wireless technology is a technology used for wireless transmission between a master device and a slave device.
In one implementation, the steps may specifically be: the time interval corresponding to the master device in the two measurements can be determined through the third moment in the two measurements, so that the time intervals corresponding to the master device and the slave device in the two measurements are known; further, according to the time interval corresponding to the master device and the slave device in the two measurements, the clock deviation of the slave device relative to the master device can be determined.
And S203, determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device.
It can be understood that the sum of the system clock and the clock skew of the slave device is approximate to the synchronous clock of the master device, so that the clock synchronization of the master device and the slave device is realized.
The method is applied to the slave equipment which takes a clock of the master equipment as a standard clock, firstly, the slave equipment acquires a time interval of two times of measurement, the two times of measurement are two times of measurement when the time difference between a first time and a third time is smaller than a preset time difference, and the time interval is determined according to the first time and/or the third time in the two times of measurement; then, when the time interval is greater than the preset time interval, the slave device determines the clock deviation of the slave device relative to the master device according to the time interval and the third moment in the two measurements, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation; and then, determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device. The second time in one measurement is between the first time and the third time, and the smaller the time difference between the first time and the third time, the more credible the second time is, so that the time difference between the first time and the third time of the two measurements obtained by the application is smaller than the preset time difference; in addition, when the time interval of the two times of measurement is greater than the preset time interval, the clock deviation of the slave equipment relative to the master equipment is determined, and the preset time interval is set to meet the preset clock deviation measurement accuracy, so that accurate clock synchronization is carried out in wireless transmission.
In the above embodiment, the preset time difference is determined according to the characteristics of the wireless technology (actual delay conditions of different platforms). For example, when the wireless technology is WiFi, the preset time difference is 1 millisecond (ms), that is, the time difference between the third time and the first time is 1ms, the third time is considered to be reliable; for another example, when the wireless technology is bluetooth, the predetermined time difference is 500 microseconds (μ s).
In some embodiments, the predetermined time interval is a value obtained by dividing the predetermined time difference by the predetermined clock skew measurement accuracy. For example, the measurement accuracy of the clock skew is preset to be 10ppm, and if the preset time difference is considered to be reliable within 1ms (depending on the actual delay conditions of different platforms), two measurement results with a time interval greater than 100 seconds need to be found to meet the accuracy requirement, that is, the preset time interval is 100 seconds(s).
Further, the determining the clock offset of the slave device from the master device according to the time interval and the third time of the two measurements may include: determining the clock offset of the slave device relative to the master device according to the following formula:
Δt=(ΔtB-ΔtA)/ΔtA
wherein, Δ tAThe difference value between the third time instants in the two measurements is obtained; Δ tBAre time intervals.
Still taking the example shown in fig. 3, we obtain:
time elapsed by master: Δ tA=tA2-tA1;
The elapsed time of the slave device, i.e. the time interval, has at least the following three calculation modes:
the time interval is the difference between the first time instants of the two measurements: Δ tB=tB3-tB1;
The time interval is the difference between the third time instants in the two measurements: t is tB4-tB2;
The time intervals are as follows: Δ tB=(tB4+tB3)/2-(tB2+tB1) /2) in which tB3And tB4A first time and a third time of one measurement in the two measurements respectively; t is tB1And tB2A first time and a third time of the other measurement in the two measurements respectively;
and so on.
The present application does not limit the manner in which the time interval is obtained.
The clock synchronization method is simple, reliable, good in adaptability and low in resource consumption; and the flexibility is better, and the wireless technology is not relied on.
The following are embodiments of the apparatus of the present application that may be used to perform the above-described embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method described above in the present application.
Fig. 4 is a schematic structural diagram of a clock synchronization apparatus according to an embodiment of the present application. The clock synchronization means may be implemented in software and/or hardware. In practical application, the clock synchronization device can be an electronic device such as a computer, a mobile phone, a tablet, a PDA or an interactive tablet; alternatively, the clock synchronization means may be a chip or a circuit of the electronic device.
The clock synchronization device provided by the embodiment of the application is applied to the slave device, the slave device uses the clock of the master device as a standard clock, in one measurement, the first time is the time when the slave device sends the clock synchronization request, the second time is the time when the master device receives the clock synchronization request, the third time is the time when the slave device receives the clock synchronization response, and the clock synchronization response carries the second time.
As shown in fig. 4, the clock synchronization device 40 includes: an acquisition module 41 and a processing module 42. Wherein:
and an obtaining module 41, configured to obtain a time interval between two measurements. The two measurements are two measurements of which the time difference between the first time and the third time is smaller than the preset time difference, and the time interval is determined according to the first time and/or the third time in the two measurements.
The processing module 42 is configured to determine, when the time interval is greater than the preset time interval, a clock offset of the slave device with respect to the master device according to the time interval and a third time in the two measurements; the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device.
In some embodiments, the processing module 42, when determining the clock offset of the slave device from the master device according to the time interval and the third time of the two measurements, is specifically configured to: determining the clock offset of the slave device relative to the master device according to the following formula:
Δt=(ΔtB-ΔtA)/ΔtA
wherein, Δ tAThe difference value between the third time instants in the two measurements is obtained; Δ tBAre time intervals.
On the basis of the above-described embodiment:
alternatively, the preset time difference is determined according to the characteristics of the wireless technology.
Optionally, the wireless technology may include at least one of:
bluetooth, WiFi, Zigbee), Z-Wave, Thread, etc.
Optionally, the size of the preset time interval is a value obtained by dividing the preset time difference by the preset clock skew measurement accuracy.
Further, the time interval is the difference between the first time instants in the two measurements; alternatively, the time interval is the difference between the third time instants in the two measurements.
Optionally, the time interval is: Δ tB=(tB4+tB3)/2-(tB2+tB1) /2, wherein tB3And tB4A first time and a third time of one measurement in the two measurements respectively; t is tB1And tB2A first time and a third time of the other of the two measurements, respectively.
The clock synchronization device of the embodiment of the application is applied to the slave device which takes the clock of the master device as the standard clock, firstly, the time interval of two times of measurement is obtained, the two times of measurement are two times of measurement that the time difference between the first time and the third time is smaller than the preset time difference, and the time interval is determined according to the first time and/or the third time in the two times of measurement; then, when the time interval is greater than the preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two measurements, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation; and then, determining the synchronous clock of the master device according to the system clock and the clock deviation of the slave device. The second time in one measurement is between the first time and the third time, and the smaller the time difference between the first time and the third time, the more credible the second time is, so that the time difference between the first time and the third time of the two measurements obtained by the application is smaller than the preset time difference; in addition, when the time interval of the two times of measurement is greater than the preset time interval, the clock deviation of the slave equipment relative to the master equipment is determined, and the preset time interval is set to meet the preset clock deviation measurement accuracy, so that accurate clock synchronization is carried out in wireless transmission.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the electronic apparatus 50 includes: a processor 51, and a memory 52, a communication module 53 and a sound pickup module 54 connected to the processor 51.
The processor 51 may comprise one or more processing units, such as: the Processor 51 may be a Central Processing Unit (CPU), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in the incorporated application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
The memory 52 may be used to store program instructions. The memory 52 may include a program storage area and a data storage area. The storage program area may store an operating system, an application program (such as a sound playing function) required by at least one function, and the like. The storage data area may store data (such as audio data) created during use of the electronic device 50, and the like. In addition, the memory 52 may include a high-speed random access memory, and may further include a nonvolatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (UFS), and the like. The processor 51 executes various functional applications of the electronic device 50 and data processing by executing program instructions stored in the memory 52.
The communication module 53 may provide a solution for wireless communication including 2G/3G/4G/5G, etc. applied to the electronic device 50. The communication module 53 may receive electromagnetic waves from an antenna, filter, amplify, etc. the received electromagnetic waves, and transmit the electromagnetic waves to a modem processor for demodulation. The communication module 53 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic wave through the antenna to radiate the electromagnetic wave. In some embodiments, at least part of the functional modules of the communication module 53 may be provided in the processor 51. In some embodiments, at least part of the functional modules of the communication module 53 may be provided in the same device as at least part of the modules of the processor 51.
The pickup module 54 may convert analog audio input to digital audio signals, and the pickup module 54 may also be used to encode and decode audio signals. In some embodiments, the pickup module 54 may be disposed in the processor 51, or some functional modules of the pickup module 54 may be disposed in the processor 51. Illustratively, the sound pickup module 54 includes a speaker, and is matched with an intelligent noise reduction and echo cancellation algorithm to effectively reduce conference background noise and harsh whistling, improve sound clarity, and bring high-quality voice experience.
Optionally, the electronic device 50 further comprises: camera 55 and/or display screen 56, etc.
The camera 55 may take an image or video. For example, the camera 55 may take a video under the control of the processor 51 and store the video to the memory 52.
The display screen 56 is used to display images, video, etc. The display screen 56 includes a display panel. The Display panel may be a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), an Active Matrix Organic Light-Emitting Diode (AMOLED), a flexible Light-Emitting Diode (FLED), a miniature, a Micro-oLed, a Quantum Dot Light-Emitting Diode (QLED), or the like. In some embodiments, the electronic device 50 may include 1 or N display screens 56, with N being a positive integer greater than 1. The display panel may receive a touch operation input by a user through a finger or an input device. Wherein the input device includes but is not limited to: a stylus, an infrared pen, and/or a capacitive pen, etc.
It should be noted that, the number of the memory 52 and the processor 51 is not limited in the embodiment of the present application, and may be one or more, and fig. 5 illustrates one example; the memory 52 and the processor 51 may be connected by various means, such as a bus, by wire or wirelessly. In practical applications, the electronic device 50 may be a computer, a mobile phone, a tablet, a PDA, or an interactive tablet.
The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (enhanced Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present application are not limited to only one bus or one type of bus.
The electronic device of this embodiment may be configured to execute the technical solution in the foregoing method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
The embodiments of the present application further provide a computer-readable storage medium, on which program instructions are stored, and when the program instructions are executed, the method for clock synchronization as described in any of the above embodiments is implemented.
In the above embodiments, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of modules may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
In addition, functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may exist alone physically, or two or more modules are integrated into one unit. The unit formed by the modules can be realized in a hardware form, and can also be realized in a form of hardware and a software functional unit.
The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present application.
The storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks, and so forth. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.
Claims (10)
1. A clock synchronization method is applied to a slave device, wherein the slave device uses a clock of a master device as a standard clock, and in one measurement, a first time is a time when the slave device sends a clock synchronization request, a second time is a time when the master device receives the clock synchronization request, and a third time is a time when the slave device receives a clock synchronization response, wherein the clock synchronization response carries the second time;
the method comprises the following steps:
acquiring a time interval of two times of measurement, wherein the two times of measurement are two times of measurement of which the time difference between a third moment and a first moment is smaller than a preset time difference, and the time interval is determined according to the first moment and/or the third moment in the two times of measurement;
if the time interval is greater than a preset time interval, determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two times of measurement, wherein the preset time interval is determined according to the measurement precision of the preset clock deviation;
and determining the synchronous clock of the master device according to the system clock of the slave device and the clock deviation.
2. The method of claim 1, wherein the predetermined time difference is determined according to characteristics of a wireless technology.
3. The method of claim 2, wherein the wireless technology comprises at least one of:
bluetooth, wireless internet WiFi, ZigBee protocol, Z-Wave, and home Internet of things communication protocol.
4. The method of claim 1, wherein the predetermined time interval is a value obtained by dividing the predetermined time difference by the predetermined clock skew measurement accuracy.
5. The method according to any one of claims 1 to 4, wherein determining the clock offset of the slave device from the master device according to the time interval and the third time of the two measurements comprises:
determining a clock offset of the slave device relative to the master device according to the following equation:
Δt=(ΔtB-ΔtA)/ΔtA
wherein, Δ tAThe difference value between the third time instants in the two measurements is obtained; Δ tBIs the time interval.
6. The method according to any one of claims 1 to 4, wherein the time interval is the difference between the first time instants of the two measurements; or, the time interval is a difference value between third time instants of the two measurements.
7. The method according to any one of claims 1 to 4, wherein the time interval is: Δ tB=(tB4+tB3)/2-(tB2+tB1) /2, wherein tB3And tB4The first time and the third time of one measurement in the two measurements are respectively; t is tB1And tB2The first time and the third time of the other measurement of the two measurements are respectively.
8. A clock synchronization device is applied to a slave device, wherein the slave device uses a clock of a master device as a standard clock, and in one measurement, a first time is a time when the slave device sends a clock synchronization request, a second time is a time when the master device receives the clock synchronization request, and a third time is a time when the slave device receives a clock synchronization response, wherein the clock synchronization response carries the second time;
the device comprises:
the acquisition module is used for acquiring a time interval of two times of measurement, wherein the time interval of the two times of measurement is determined according to the first time and/or the third time in the two times of measurement, and the time difference between the third time and the first time is smaller than a preset time difference;
the processing module is used for determining the clock deviation of the slave equipment relative to the master equipment according to the time interval and the third moment in the two times of measurement when the time interval is greater than a preset time interval, and the preset time interval is determined according to the measurement precision of the preset clock deviation; and determining the synchronous clock of the master device according to the system clock of the slave device and the clock deviation.
9. An electronic device, comprising:
a memory for storing program instructions;
a processor for calling and executing program instructions in said memory, performing the method of any of claims 1 to 7.
10. A computer-readable storage medium having program instructions stored thereon; the program instructions, when executed, implement the method of any one of claims 1 to 7.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010914929.0A CN112040539B (en) | 2020-09-03 | 2020-09-03 | Clock synchronization method, device and storage medium |
PCT/CN2020/139742 WO2022048075A1 (en) | 2020-09-03 | 2020-12-26 | Clock synchronization method and apparatus, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010914929.0A CN112040539B (en) | 2020-09-03 | 2020-09-03 | Clock synchronization method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112040539A CN112040539A (en) | 2020-12-04 |
CN112040539B true CN112040539B (en) | 2021-09-14 |
Family
ID=73591853
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010914929.0A Active CN112040539B (en) | 2020-09-03 | 2020-09-03 | Clock synchronization method, device and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112040539B (en) |
WO (1) | WO2022048075A1 (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112040539B (en) * | 2020-09-03 | 2021-09-14 | 广州视源电子科技股份有限公司 | Clock synchronization method, device and storage medium |
CN112731049B (en) * | 2020-12-08 | 2023-07-07 | 深圳供电局有限公司 | Clock synchronization abnormality monitoring method, device and computer readable storage medium |
CN113687686B (en) * | 2021-08-10 | 2024-05-14 | 北京小米移动软件有限公司 | Clock synchronization method, clock synchronization device, electronic equipment and storage medium |
CN115225244B (en) * | 2022-07-14 | 2023-08-18 | 广东电网有限责任公司 | Clock time setting method and device for low-voltage meter reading, main equipment and medium |
CN115347972B (en) * | 2022-10-18 | 2024-01-16 | 杭州聆巡科技有限公司 | Sonar clock synchronization method, device, equipment and storage medium |
CN116436555B (en) * | 2023-06-09 | 2023-08-18 | 新华三技术有限公司 | Time synchronization method and device and distributed network equipment |
Family Cites Families (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101860952B (en) * | 2009-04-09 | 2012-06-06 | 中兴通讯股份有限公司 | Clock correcting method and system based on IP network for wireless base station |
CN102577194B (en) * | 2009-08-25 | 2014-11-12 | Sem技术公司 | System and method of synchronizing clocks in a distributed network |
CN102098155B (en) * | 2011-03-18 | 2013-11-13 | 北京国智恒电力管理科技有限公司 | Method for realizing sub-microsecond synchronization accuracy based on PTP (Precision Time Protocol) |
CN103814338A (en) * | 2011-07-20 | 2014-05-21 | 航空网络公司 | Systems and methods of network synchronization |
CN102769505B (en) * | 2012-07-19 | 2015-09-16 | 中兴通讯股份有限公司 | A kind of method and device realizing clock synchronous |
CN104581923B (en) * | 2013-10-25 | 2018-08-28 | 上海无线通信研究中心 | Pass through the method for transmission of radio links precise time information |
CN104135359B (en) * | 2014-07-22 | 2017-12-12 | 南京磐能电力科技股份有限公司 | Tandem type multi-node synchronization sampling and data transmission method when a kind of strong |
CN104158647A (en) * | 2014-08-26 | 2014-11-19 | 太原理工大学 | Clock synchronizing method for wireless sensing network |
EP3089386A1 (en) * | 2015-04-29 | 2016-11-02 | ABB Technology AG | Method, system and device for clock synchronization over time-varying and lossy networks |
CN105024777B (en) * | 2015-07-29 | 2017-10-24 | 上海新时达电气股份有限公司 | Servo-driver synchronous method based on EtherCAT real-time ethernets |
CN105049309B (en) * | 2015-07-29 | 2018-03-09 | 上海新时达电气股份有限公司 | Servo-driver synchronous method based on POWERLINK real-time ethernets |
EP3507925B1 (en) * | 2016-08-30 | 2024-03-13 | Finisar Corporation | Bi-directional transceiver with time synchronization |
CN110266420B (en) * | 2019-04-29 | 2021-02-12 | 北京达佳互联信息技术有限公司 | Clock synchronization method, clock synchronization apparatus, and computer-readable storage medium |
CN112040539B (en) * | 2020-09-03 | 2021-09-14 | 广州视源电子科技股份有限公司 | Clock synchronization method, device and storage medium |
-
2020
- 2020-09-03 CN CN202010914929.0A patent/CN112040539B/en active Active
- 2020-12-26 WO PCT/CN2020/139742 patent/WO2022048075A1/en active Application Filing
Also Published As
Publication number | Publication date |
---|---|
CN112040539A (en) | 2020-12-04 |
WO2022048075A1 (en) | 2022-03-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112040539B (en) | Clock synchronization method, device and storage medium | |
RU2648262C2 (en) | Method and device for implementing multimedia data synchronization | |
CN104506650B (en) | A kind of user equipment cooperative control method, user equipment and communication system | |
US8755785B2 (en) | Collaborative image control | |
CN104980820B (en) | Method for broadcasting multimedia file and device | |
US20160006526A1 (en) | Systems and methods of network clock comparison | |
WO2022094835A1 (en) | Audio synchronization playback method, apparatus, device, and storage medium | |
CN112039623B (en) | Audio synchronous playing method, device, equipment and storage medium | |
WO2020211535A1 (en) | Network delay control method and apparatus, electronic device, and storage medium | |
CN112130616B (en) | Clock synchronization method, device and storage medium | |
US10877512B2 (en) | Audio data transmission method and apparatus | |
CN103856648A (en) | echo cancellation system | |
CN107395311A (en) | Clock synchronizing method, device and computer-readable recording medium | |
CN109104900A (en) | Transmission method, device and the computer readable storage medium of system information | |
CN110634488A (en) | Information processing method, device and system and storage medium | |
CN113596904B (en) | Method and equipment for transmitting aperiodic positioning report | |
CN105163391A (en) | Data transmission method, terminal and wireless access point | |
CN109753262B (en) | Frame display processing method and device, terminal equipment and storage medium | |
CN105099644B (en) | Half-duplex communication method and related device | |
US20230379529A1 (en) | Distributed media stream playback suspension and synchronization | |
CN105611191B (en) | Voice and video file synthesis method, apparatus and system | |
WO2023078232A1 (en) | Transmission method and apparatus | |
CN115469525B (en) | Input/output time measurement method, system, device, terminal equipment and medium | |
CN113687686B (en) | Clock synchronization method, clock synchronization device, electronic equipment and storage medium | |
WO2022155879A1 (en) | Time synchronization method and related device |
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 |