CN105530698A - Time synchronization method and system among wireless devices - Google Patents

Time synchronization method and system among wireless devices Download PDF

Info

Publication number
CN105530698A
CN105530698A CN201510961306.8A CN201510961306A CN105530698A CN 105530698 A CN105530698 A CN 105530698A CN 201510961306 A CN201510961306 A CN 201510961306A CN 105530698 A CN105530698 A CN 105530698A
Authority
CN
China
Prior art keywords
time
wireless device
packet
server
physical address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510961306.8A
Other languages
Chinese (zh)
Inventor
张洁
唐扬伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
TCL Tongli Electronics Huizhou Co Ltd
Original Assignee
TCL Tongli Electronics Huizhou Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TCL Tongli Electronics Huizhou Co Ltd filed Critical TCL Tongli Electronics Huizhou Co Ltd
Priority to CN201510961306.8A priority Critical patent/CN105530698A/en
Publication of CN105530698A publication Critical patent/CN105530698A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W56/00Synchronisation arrangements
    • H04W56/001Synchronization between nodes
    • H04W56/0015Synchronization between nodes one node acting as a reference for the others

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention discloses a time synchronization method among wireless devices. The procedures of the method comprise: determining a wireless device as a time server in a wireless local area network, taking other wireless devices in the wireless local area network as time customers; sending first data packets comprising current first time points to the time server by the time customers, after the time server receives the first data packets, sending second data packets to the time customers by the time server, wherein the second data packets comprise first time points, second time points at which the time server receives the first data packets and third time points at which the time server sends the second data packets; when the time customers receive the second data packets, obtaining fourth time points at which the second data packets are received; calculating the time difference between the time customers and the time server by the time customers according to the time data. The invention also discloses a time synchronization system among wireless devices. According to the invention, the problem that the multiple wireless devices play non-synchronously is solved.

Description

Method for synchronizing time between wireless device and system
Technical field
The present invention relates to wireless device technology field, particularly relate to the method for synchronizing time between a kind of wireless device and system.
Background technology
More and more abundanter along with wireless technology, carrying out wireless connections between multiple wireless device, becoming more and more general for synchronously playing same program.But because the system time of multiple wireless device is inconsistent, the asynchronous of the broadcasting of multiple equipment can be caused.Such as, existing wireless sound box, along with the application of the wireless technology such as bluetooth, WIFI on audio amplifier, can be connected to each other between the wireless audio video equipment such as wireless sound box, synchronously can play with a piece of music on different wireless sound boxes.But because people's ear is more responsive to voice signal, when the reproduction time of the same frame audio signal between wireless sound box exists the error of more than 50ms, people's ear just likely can identify.And existing method for synchronizing time adopts Network Time Protocol (NetworkTimeProtocol, NTP (Network Time Protocol)), precision is 200ms to the maximum, cannot meet the synchronous broadcasting of wireless sound box.
Summary of the invention
The invention provides the method for synchronizing time between a kind of wireless device and system, its main purpose is to solve multiple wireless device in prior art and plays nonsynchronous problem.
For achieving the above object, the invention provides the method for synchronizing time between a kind of wireless device, the method for synchronizing time between this wireless device comprises:
Determine between wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end;
Described Time-Client end sends the first packet comprising point of the current very first time to described time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet;
When described Time-Client termination receives described second packet, obtain the 4th time point receiving described second packet;
Described Time-Client end calculates the time difference between described Time-Client end and described time server, with the system time according to synchronous described Time-Client end of described time difference and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point.
Preferably, described Time-Client end calculates the time difference between described Time-Client end and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point, before the step of the system time according to synchronous described Time-Client end of described time difference and described time server, the method for synchronizing time between described wireless device also comprises step:
Described Time-Client end according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judges whether described delay duration is greater than preset duration;
If described Delay time is grown up in described preset duration, then Time-Client end re-executes the step sending the first packet comprising point of the current very first time to described time server, until the delay duration calculated is less than or equal to described preset duration.
Preferably, described Time-Client end calculates the time difference between described Time-Client end and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point, after the step of the system time according to synchronous described Time-Client end of described time difference and described time server, the method for synchronizing time between described wireless device also comprises step:
Described Time-Client end is according to described adjustment System time time difference calculated.
Preferably, determine between described wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) all comprise as the step of Time-Client end:
Each described wireless device in WLAN (wireless local area network) sends the data query bag including the first physical address, and wherein, described first physical address is the native physical address of the wireless device sending described data query bag;
When described wireless device receives the response message of other wireless devices transmission in described local area network (LAN), then using sending the wireless device of described response message as time server, send the wireless device of the wireless device of described data query bag as Time-Client end.
Preferably, each the described wireless device in described WLAN (wireless local area network) is after unlatching, and after broadcast packet contains the step of data query bag of the physical address of the machine, the method for synchronizing time between described wireless device also comprises:
When described wireless device does not receive the response message of other wireless devices transmission in described local area network (LAN), detect and whether receive the data query bag including the second physical address that in described local area network (LAN), other wireless devices send;
When receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
If described first physical address is less than described second physical address, then described wireless device is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
In addition, for achieving the above object, the present invention also provides the clock synchronization system between a kind of wireless device, and the clock synchronization system between this wireless device comprises multiple stage wireless device, and described wireless device comprises:
Determination module, for determining between the wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end
Sending module, for sending the first packet comprising point of the current very first time to the wireless device as time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet;
Acquisition module, during for receiving described second packet, obtains the 4th time point receiving described second packet;
Computing module, for calculate according to described very first time point, described second time point, described 3rd time point and described 4th time point and as time server described wireless device between time difference, using the wireless device according to synchronous described sending module place of described time difference and system time as the described wireless device of time server.
Preferably, described computing module, also for according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judges whether described delay duration is greater than preset duration;
Described sending module, if also grow up in described preset duration for described Delay time, then sends the first packet comprising point of the current very first time, until described delay duration is less than or equal to described preset duration to the wireless device as time server.
Preferably, described wireless device also comprises:
Adjusting module, for described adjustment System time time difference that basis calculates.
Preferably, described determination module comprises:
Transmitting element, for sending the data query bag including the first physical address, wherein, described first physical address is the physical address of the wireless device at described sending module place;
Determining unit, for when receiving the response message that other wireless devices in described local area network (LAN) send, then will send the wireless device of described response message as time server, the wireless device at described transmitting element place is as Time-Client end.
Preferably, described determination module also comprises:
Judging unit, during for not receiving response message that other wireless devices in described local area network (LAN) send, detecting and whether receiving the data query bag including the second physical address that in described local area network (LAN), other wireless devices send; And, when receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
Described determining unit, if be also less than described second physical address for described first physical address, then the wireless device at described determination module place is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
Method for synchronizing time between the wireless device that the present invention proposes and system, in WLAN (wireless local area network), determine that a wireless device is as time server, using the system time of this wireless device as the reference time, other wireless device is as Time-Client end, to the first Packet Generation of point of the current very first time be included to time server, time server sends the second packet to Time-Client end, second packet includes very first time point, receive the second time point of the first packet and send the 3rd time point of the second packet, when Time-Client termination receives above-mentioned second packet, obtain the 4th time point receiving the second packet, and according to above-mentioned very first time point, second time point, 3rd time point and the 4th time point calculate the time difference between time server and Time-Client end, like this, just can according to above-mentioned time difference adjustment reproduction time when wireless device is play, achieve between multiple wireless device and can synchronously play.
Accompanying drawing explanation
Fig. 1 is the flow chart of method for synchronizing time first embodiment between wireless device of the present invention;
Fig. 2 is that method for synchronizing time first embodiment between wireless device of the present invention is fixed time the schematic flow sheet of server really;
Fig. 3 is that method for synchronizing time first embodiment between wireless device of the present invention is fixed time the schematic flow sheet of server really;
Fig. 4 is that method for synchronizing time first embodiment between wireless device of the present invention is fixed time the schematic flow sheet of server really;
Fig. 5 is the time flow schematic diagram of method for synchronizing time first embodiment between wireless device of the present invention;
Fig. 6 is the high-level schematic functional block diagram of wireless device in clock synchronization system first embodiment between wireless device of the present invention.
The realization of the object of the invention, functional characteristics and advantage will in conjunction with the embodiments, are described further with reference to accompanying drawing.
Embodiment
Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
The invention provides the method for synchronizing time between a kind of wireless device.
With reference to shown in Fig. 1, it is the flow chart of method for synchronizing time first embodiment between wireless device of the present invention.
In a first embodiment, the method for synchronizing time between this wireless device comprises:
Step S10, determine between the wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end;
Step S20, described Time-Client end sends the first packet comprising point of the current very first time to described time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet.
The method of the present embodiment can be used in the synchronous broadcasting of audio frequency, video etc. between multiple stage wireless device, or the broadcasting of extended formatting file, the such as synchronous broadcasting etc. of PPT file, therefore above-mentioned wireless device can be as wifi audio amplifier, the wireless sound boxes such as Baffle Box of Bluetooth, or wireless video playback equipment, or the wireless device that can realize the broadcasting of extended formatting file.Be interconnected when there being multiple stage wireless device, and when needing synchronously to play, need to determine that a wireless device in local area network (LAN) is as time server, other wireless device is as Time-Client end, using the system time of time server as with reference to the time to carry out time synchronized, wherein, determine that time server can have numerous embodiments, in one embodiment, can using a fixing wireless device as time server, in another embodiment, can according to arbitration mechanism using opening time wireless device the earliest as time server, or using wireless device best for wireless signal as time server, particularly, can according to following steps:
Each described wireless device in WLAN (wireless local area network) sends the data query bag including the first physical address, and wherein, described first physical address is the native physical address of the wireless device sending described data query bag;
When described wireless device receives the response message of other wireless devices transmission in described local area network (LAN), then using sending the wireless device of described response message as time server, send the wireless device of the wireless device of described data query bag as Time-Client end.
When described wireless device does not receive the response message of other wireless devices transmission in described local area network (LAN), detect and whether receive the data query bag including the second physical address that in described local area network (LAN), other wireless devices send;
When receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
If described first physical address is less than described second physical address, then described wireless device is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
When there being wireless opening of device in WLAN (wireless local area network), send the data query bag including native physical address, can send with the form of broadcast, the wireless device that in such local area network (LAN), other are opened can receive, such as UDP (UserDatagramProtocol, User Datagram Protoco (UDP)) form broadcast, described packet is udp broadcast bag.If now do not receive any return information, then illustrate and now only have in local area network (LAN) a wireless device to open, then this wireless device is as time server, when the follow-up wireless device having other is opened, the transmission of data query bag can be carried out equally, so now, the above-mentioned wireless device as time server just can send response message to other wireless devices, oneself is exactly time server to inform.If there is multiple stage wireless device to open in WLAN (wireless local area network) simultaneously, then every platform wireless device all can receive the data query bag including native physical address that other wireless devices simultaneously opened send, now, the multiple physical address received and the physical address of oneself all contrast by each wireless device, using wireless device maximum for physical address as time server, other wireless device is as Time-Client end, such as, after a certain wireless device carries out the contrast of physical address, confirm that the physical address of the machine is less than the physical address of other equipment, then determine that the machine is Time-Client end, perform step S20, after another wireless device carries out the contrast of physical address, confirm that the physical address of the machine is greater than other wireless device, then determine that the machine is as time server, after receiving the first packet sent as the wireless device of Time-Client end, the second packet is replied to it.
With reference to shown in Fig. 2 to Fig. 4, for wireless device is by the schematic diagram of broadcast mode determination time server, after a wireless device A starts, udp broadcast can be sent and send data query bag, check in local area network (LAN) whether life period server.If this wireless device A does not receive any response and do not receive the udp broadcast data query bag of other wireless devices yet, wireless device A just becomes time server.If there is the wireless device B as time server in local area network (LAN), then can receive the response of wireless device B, then wireless device A becomes Time-Client end, and prepares to carry out time synchronized with the wireless device B as time server.
Start when there being several wireless devices simultaneously, such as wireless device A and wireless device B start, capital outwardly inquires in local area network (LAN) whether there is other times server, wireless device A and wireless device B can enter arbitration mechanism and held consultation this time, in the present embodiment, with physical address for comparing criterion, physical address maximum as time server, other are as Time-Client end.After negotiation completes, carry out the time synchronized between the wireless device A of local area network (LAN) and wireless device B.
It should be noted that, in the present embodiment, about the comparison of the size of physical address, compare from first, if first identical, then compare second, by that analogy, wherein, if a certain position is letter, then letter is converted into numeral, such as, the corresponding numeral 1 of letter A, the corresponding numeral 2 of B, until the corresponding numeral 26 of zed, in other embodiments, also after the letter in physical address can being converted into numeral, numeral on each is added and obtains digital summation, numeral summation is maximum, then physical address is maximum, the wireless device of its correspondence is as time server.
Below there to be the first wireless device A and the second wireless device B to be described in local area network (LAN), determine that the first wireless device A is Time-Client end, the second wireless device B is as time server.
The first wireless device A as Time-Client end sends the first packet, the current system time of the machine is included in this first packet, i.e. very first time point T1, second wireless device B is after receiving the first packet, obtain very first time point T1, and record the system time of the second wireless device B when receiving this first packet, as the second time point T2.Then the second wireless device B replys the second packet immediately to the first wireless device A, and records described second wireless device B and send the second packet to the system time of the first wireless device A, as the second time point T3.Wherein the second packet comprises very first time point T1, the second time point T2, and send the time point T3 of this second packet, it should be noted that, the form of above-mentioned first packet and the second packet can be determined according to data transfer mode, such as, if with UDP (UserDatagramProtocol, User Datagram Protoco (UDP)) form broadcast, described packet is udp broadcast bag, in other embodiments, also can send by other forms of packet, such as, the form of load time stamp after data packing is sent data.
Step S30, when described Time-Client termination receives described second packet, obtains the 4th time point receiving described second packet.
Step S40, described Time-Client end calculates the time difference between described Time-Client end and described time server, with the system time according to synchronous described Time-Client end of described time difference and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point.
When first wireless device A receives the second packet of the second wireless device B reply, obtain and receive the 4th time point T4 of the second packet, device A according to T1, T2, T3, T4 according to the time difference between following formulae discovery first wireless device A and the second wireless device B:
To=(T2-T1+T3-T4)/2
Be understandable that, when there being multiple wireless device in local area network (LAN), obtain all in the manner described above as each first wireless device of Time-Client end and as time server the second wireless device between time difference, wherein, there be positive and negative dividing time difference, if the time difference is positive number, then the time of description time client is slower than the time of time server, if the time difference is negative, then the time of description time client is faster than time of time server, after getting the time difference, first wireless device can store this time difference, and calculate the correct system plays time when audio and video playing according to the reproduction time of setting and time difference, such as a certain wireless device and as time server wireless device between time difference be+5s, the system time of this wireless device 5s slow relative to the reference time is described, and default synchronously plays music when 19:00, so this wireless device can start to play music when system time is 18:55, music is play with the second wireless device synchronizes as time server to reach, in other examples, the first wireless device also can according to the time difference calculated, the system time of adjustment the machine.
With reference to shown in Fig. 5, be the time flow schematic diagram of the present embodiment, Time-Client end device A by the machine present system time (900) by udp broadcast to time server equipment B, be T1=900 by this time mark; Time server equipment B can receive the udp broadcast bag that Time-Client end device A sends over time, and suppose that the transmission time is 2, then time server equipment B receives the time of this udp broadcast bag for being labeled as T2=1002; This time, time server equipment B can reply a udp broadcast bag immediately to Time-Client end device A, the content of this udp broadcast bag comprises T1, T2, T3, wherein T3 is that time server equipment B replys udp broadcast bag to time during Time-Client end device A, usual time server equipment B can reply udp broadcast bag immediately to A, so the time of this step very short, supposes T3=1003 here; Time-Client end device A can receive the udp broadcast bag that time server equipment B sends over time, is T4, supposes that the transmission time is also 2, then T4=905 by the timing definition that Time-Client end device A receives this udp broadcast bag.Then according to above-mentioned formula, To=100.
The present embodiment using the second wireless device in local area network (LAN) as time server, in local area network (LAN), determine that a wireless device is as time server, using the system time of this wireless device as the reference time, other wireless device is as Time-Client end, to the first Packet Generation of point of the current very first time be included to time server, time server sends the second packet to Time-Client end, second packet includes very first time point, receive the second time point of the first packet and send the 3rd time point of the second packet, when Time-Client termination receives above-mentioned second packet, obtain the 4th time point receiving the second packet, and according to above-mentioned very first time point, second time point, 3rd time point and the 4th time point calculate the time difference between time server and Time-Client end, like this, just can according to above-mentioned time difference adjustment reproduction time when wireless device is play, achieve between multiple wireless device and can synchronously play.
Further, the first embodiment based on the method for synchronizing time between wireless device of the present invention proposes the second embodiment.In the present embodiment, before step S40, the method for synchronizing time between this wireless device also comprises step:
Described Time-Client end according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judges whether described delay duration is greater than preset duration;
If described Delay time is grown up in described preset duration, then Time-Client end re-executes step S20, until the delay duration calculated is less than or equal to described preset duration.
In the present embodiment, in order to promote the accuracy of time synchronized, first calculating the difference of the time that the first packet and the second packet take in transmitting procedure, namely postponing duration, postpone duration by following formulae discovery:
Td=(T2-T1)-(T3-T4)
Above-mentioned embodiment, Td=0 is obtained according to this formulae discovery, because this execution mode supposes in the ideal situation, therefore the time that each wireless device transmission packet takies is identical, and the Td value therefore obtained is zero, but implements in the process of the method in reality, due to the impact of the factors such as network environment, often have the time difference in transfer of data, causing postponing duration is not zero, and this numerical value is often larger.
It should be noted that, after going out Td by above-mentioned formulae discovery, take absolute value, namely postpone duration be on the occasion of, judge whether the delay duration Td calculated is greater than preset duration, wherein, postpone the difference that duration is the duration that the duration that takies of first data transmission process and the second transmission of data packets take, if Td is less than or equal to preset duration, then think that the time difference obtained is effective value, if Td is greater than preset duration, then think that the time difference that the first packet and the second packet take in the process of transmission is larger, cause the time difference accuracy that obtains lower, cause the precision of time synchronized lower, now, re-execute step S20, until the delay duration obtained is less than preset duration, further increase the precision of time synchronized.
The present invention also proposes the clock synchronization system between a kind of wireless device.
With reference to shown in Fig. 6, it is the high-level schematic functional block diagram of wireless device in clock synchronization system first embodiment between wireless device of the present invention.
In this embodiment, the wireless device in the clock synchronization system between this wireless device comprises:
Determination module 10, for determining between the wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end;
Sending module 20, for sending the first packet comprising point of the current very first time to the wireless device as time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet;
The present embodiment can realize the synchronous broadcasting of audio frequency, video etc. between multiple stage wireless device, or the broadcasting of extended formatting file, the such as synchronous broadcasting etc. of PPT file, therefore above-mentioned wireless device can be as wifi audio amplifier, the wireless sound boxes such as Baffle Box of Bluetooth, or wireless video playback equipment, or the wireless device that can realize the broadcasting of extended formatting file.Be interconnected when there being multiple stage wireless device, and when needing synchronously to play, need to determine that a wireless device in local area network (LAN) is as time server, other wireless device is as Time-Client end, using the system time of time server as with reference to the time to carry out time synchronized, wherein, determine that time server can have numerous embodiments, in one embodiment, can using a fixing wireless device as time server, in another embodiment, can according to arbitration mechanism using opening time wireless device the earliest as time server, or using wireless device best for wireless signal as time server, particularly, determination module 10 can comprise with lower unit:
Transmitting element, for sending the data query bag including the first physical address, wherein, described first physical address is the physical address of the wireless device at described sending module place;
Determining unit, for when receiving the response message that other wireless devices in described local area network (LAN) send, then will send the wireless device of described response message as time server, the wireless device at described transmitting element place is as Time-Client end.
Further, determination module 10 also comprises:
Judging unit, during for not receiving response message that other wireless devices in described local area network (LAN) send, detecting and whether receiving the data query bag including the second physical address that in described local area network (LAN), other wireless devices send; And, when receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
Described determining unit, if be also less than described second physical address for described first physical address, then the wireless device at described determination module place is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
When there being wireless opening of device in WLAN (wireless local area network), transmitting element sends the data query bag including native physical address, can send with the form of broadcast, the wireless device that in such local area network (LAN), other are opened can receive, such as UDP (UserDatagramProtocol, User Datagram Protoco (UDP)) form broadcast, described packet is udp broadcast bag.If now do not receive any return information, then illustrate and now only have in local area network (LAN) a wireless device to open, then determining unit determines that this wireless device is as time server, when the follow-up wireless device having other is opened, the transmission of data query bag can be carried out equally, so now, the above-mentioned wireless device as time server just can send response message to other wireless devices, oneself is exactly time server to inform.If there is multiple stage wireless device to open in WLAN (wireless local area network) simultaneously, the data query bag including native physical address that the transmitting element that then every platform wireless device all can receive the wireless device that other open simultaneously sends, now, the multiple physical address received and the physical address of oneself all contrast by each wireless device, determining unit using wireless device maximum for physical address as time server, other wireless device is as Time-Client end, such as, after the judging unit of a certain wireless device carries out the contrast of physical address, confirm that the physical address of the machine is less than the physical address of other equipment, then determine that the machine is Time-Client end, the first packet is sent to time server, after the judging unit of another wireless device carries out the contrast of physical address, confirm that the physical address of the machine is greater than other wireless device, then determine that the machine is as time server, after receiving the first packet sent as the wireless device of Time-Client end, the second packet is replied to it.
With reference to shown in Fig. 2 to Fig. 4, for wireless device is by the schematic diagram of broadcast mode determination time server, after wireless device A starts, the transmitting element of wireless device A can send data query bag by udp broadcast, to check in local area network (LAN) whether life period server.If this wireless device A does not receive any response and do not receive the udp broadcast data query bag of other wireless devices yet, wireless device A just becomes time server.If there is the wireless device B as time server in local area network (LAN), then can receive the response of wireless device B, then wireless device A becomes Time-Client end, and prepares to carry out time synchronized with the wireless device B as time server.
Start when there being several wireless devices simultaneously, such as wireless device A and wireless device B start, capital outwardly inquires in local area network (LAN) whether there is other times server, wireless device A and wireless device B can enter arbitration mechanism and held consultation this time, in the present embodiment, with physical address for comparing criterion, physical address maximum as time server, other are as Time-Client end.After negotiation completes, carry out the time synchronized between the wireless device A of local area network (LAN) and wireless device B.
It should be noted that, in the present embodiment, about the comparison of the size of physical address, compare from first, if first identical, then compare second, by that analogy, wherein, if a certain position is letter, then letter is converted into numeral, such as, the corresponding numeral 1 of letter A, the corresponding numeral 2 of B, until the corresponding numeral 26 of zed, in other embodiments, also after the letter in physical address can being converted into numeral, numeral on each is added and obtains digital summation, numeral summation is maximum, then physical address is maximum, the wireless device of its correspondence is as time server.
For the ease of distinguishing as the wireless device of time server and the wireless device as Time-Client end in the description of following examples, first wireless device of the following stated is the wireless device at sending module 20 place, and the second wireless device is the wireless device as Time-Client end.
Below there to be the first wireless device A and the second wireless device B to be described in local area network (LAN), determined that the first wireless device A is Time-Client end, the second wireless device B is as time server.
Sending module 20 as the first wireless device A of Time-Client end sends the first packet, the current system time of the machine is included in this first packet, i.e. very first time point T1, second wireless device B is after receiving the first packet, obtain very first time point T1, and record the system time of the second wireless device B when receiving this first packet, as the second time point T2.Then the second wireless device B replys the second packet immediately to the first wireless device A, and records described second wireless device B and send the second packet to the system time of the first wireless device A, as the second time point T3.Wherein the second packet comprises very first time point T1, the second time point T2, and send the time point T3 of this second packet, it should be noted that, the form of above-mentioned first packet and the second packet can be determined according to data transfer mode, such as, if with UDP (UserDatagramProtocol, User Datagram Protoco (UDP)) form broadcast, described packet is udp broadcast bag, in other embodiments, also can send by other forms of packet, such as, the form of load time stamp after data packing is sent data.
Acquisition module 30, during for receiving described second packet, obtains the 4th time point receiving described second packet;
Computing module 40, for calculate according to described very first time point, described second time point, described 3rd time point and described 4th time point and as time server described wireless device between time difference, using the wireless device according to synchronous described sending module place of described time difference and system time as the described wireless device of time server.
When first wireless device A receives the second packet of the second wireless device B reply, acquisition module 30 obtains and receives the 4th time point T4 of the second packet, device A according to T1, T2, T3, T4 according to the time difference between following formulae discovery first wireless device A and the second wireless device B:
To=(T2-T1+T3-T4)/2
Be understandable that, when there being multiple wireless device in local area network (LAN), obtain all in the manner described above as the computing module 40 of each the first wireless device of Time-Client end and as time server the second wireless device between time difference, wherein, there be positive and negative dividing time difference, if the time difference is positive number, then the time of description time client is slower than the time of time server, if the time difference is negative, then the time of description time client is faster than time of time server, after getting the time difference, first wireless device can store this time difference, and calculate the correct system plays time when audio and video playing according to the reproduction time of setting and time difference, such as a certain wireless device and as time server wireless device between time difference be+5s, the system time of this wireless device 5s slow relative to the reference time is described, and default synchronously plays music when 19:00, so this wireless device can start to play music when system time is 18:55, music is play with the second wireless device synchronizes as time server to reach, in other examples, wireless device also comprises adjusting module, for described adjustment System time time difference that basis calculates.
With reference to shown in Fig. 5, be the time flow schematic diagram of the present embodiment, the sending module 20 of Time-Client end device A by the machine present system time (900) by udp broadcast to time server equipment B, be T1=900 by this time mark; Time server equipment B can receive the udp broadcast bag that Time-Client end device A sends over time, and suppose that the transmission time is 2, then time server equipment B receives the time of this udp broadcast bag for being labeled as T2=1002; This time, time server equipment B can reply a udp broadcast bag immediately to Time-Client end device A, the content of this udp broadcast bag comprises T1, T2, T3, wherein T3 is that time server equipment B replys udp broadcast bag to time during Time-Client end device A, usual time server equipment B can reply udp broadcast bag immediately to A, so the time of this step very short, supposes T3=1003 here; Time-Client end device A can receive the udp broadcast bag that time server equipment B sends over time, is T4, supposes that the transmission time is also 2, then T4=905 by the timing definition that Time-Client end device A receives this udp broadcast bag.Then according to above-mentioned formula, the computing module 40 of wireless device A calculates To=100.
The present embodiment using the second wireless device in local area network (LAN) as time server, in local area network (LAN), determine that a wireless device is as time server, using the system time of this wireless device as the reference time, other wireless device is as Time-Client end, to the first Packet Generation of point of the current very first time be included to time server, time server sends the second packet to Time-Client end, second packet includes very first time point, receive the second time point of the first packet and send the 3rd time point of the second packet, when Time-Client termination receives above-mentioned second packet, obtain the 4th time point receiving the second packet, and according to above-mentioned very first time point, second time point, 3rd time point and the 4th time point calculate the time difference between time server and Time-Client end, like this, just can according to above-mentioned time difference adjustment reproduction time when wireless device is play, achieve between multiple wireless device and can synchronously play.
Further, the first embodiment based on the clock synchronization system between wireless device of the present invention proposes the second embodiment.In the present embodiment:
Computing module 40, also for according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judges whether described delay duration is greater than preset duration;
Sending module 20, if also grow up in described preset duration for described Delay time, then sends the first packet comprising point of the current very first time, until described delay duration is less than or equal to described preset duration to the wireless device as time server.
In the present embodiment, in order to promote the accuracy of time synchronized, computing module 40 first calculates the difference of the time that the first packet and the second packet take in transmitting procedure, namely postpones duration, postpones duration by following formulae discovery:
Td=(T2-T1)-(T3-T4)
Above-mentioned embodiment, Td=0 is obtained according to this formulae discovery, because this execution mode supposes in the ideal situation, therefore the time that each wireless device transmission packet takies is identical, and the Td value therefore obtained is zero, but implements in the process of the method in reality, due to the impact of the factors such as network environment, often have the time difference in transfer of data, causing postponing duration is not zero, and this numerical value is often larger.
It should be noted that, after going out Td by above-mentioned formulae discovery, take absolute value, namely postpone duration be on the occasion of, judge whether the delay duration Td calculated is greater than preset duration, wherein, postpone the difference that duration is the duration that the duration that takies of first data transmission process and the second transmission of data packets take, if Td is less than or equal to preset duration, then think that obtaining the time difference is effective value, if Td is greater than preset duration, then think that the time difference that the first packet and the second packet take in the process of transmission is larger, cause the time difference accuracy that obtains lower, cause the precision of time synchronized lower, now, sending module 20 resends the first packet, until the delay duration obtained is less than preset duration, further increase the precision of time synchronized.
These are only the preferred embodiments of the present invention; not thereby the scope of the claims of the present invention is limited; every utilize specification of the present invention and accompanying drawing content to do equivalent structure or equivalent flow process conversion; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.

Claims (10)

1. the method for synchronizing time between wireless device, is characterized in that, the method for synchronizing time between described wireless device comprises:
Determine between wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end;
Described Time-Client end sends the first packet comprising point of the current very first time to described time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet;
When described Time-Client termination receives described second packet, obtain the 4th time point receiving described second packet;
Described Time-Client end calculates the time difference between described Time-Client end and described time server, with the system time according to synchronous described Time-Client end of described time difference and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point.
2. the method for synchronizing time between wireless device according to claim 1, it is characterized in that, described Time-Client end calculates the time difference between described Time-Client end and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point, before the step of the system time according to synchronous described Time-Client end of described time difference and described time server, the method for synchronizing time between described wireless device also comprises step:
Described Time-Client end according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judges whether described delay duration is greater than preset duration;
If described Delay time is grown up in described preset duration, then Time-Client end re-executes the step sending the first packet comprising point of the current very first time to described time server, until the delay duration calculated is less than or equal to described preset duration.
3. the method for synchronizing time between wireless device according to claim 1 and 2, it is characterized in that, described Time-Client end calculates the time difference between described Time-Client end and described time server according to described very first time point, described second time point, described 3rd time point and described 4th time point, after the step of the system time according to synchronous described Time-Client end of described time difference and described time server, the method for synchronizing time between described wireless device also comprises step:
Described Time-Client end is according to described adjustment System time time difference calculated.
4. the method for synchronizing time between wireless device according to claim 1, it is characterized in that, determine between described wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) all comprise as the step of Time-Client end:
Each described wireless device in WLAN (wireless local area network) sends the data query bag including the first physical address, and wherein, described first physical address is the native physical address of the wireless device sending described data query bag;
When described wireless device receives the response message of other wireless devices transmission in described local area network (LAN), then using sending the wireless device of described response message as time server, send the wireless device of the wireless device of described data query bag as Time-Client end.
5. the method for synchronizing time between wireless device according to claim 4, it is characterized in that, each described wireless device in described WLAN (wireless local area network) is after unlatching, after broadcast packet contains the step of data query bag of the physical address of the machine, the method for synchronizing time between described wireless device also comprises:
When described wireless device does not receive the response message of other wireless devices transmission in described local area network (LAN), detect and whether receive the data query bag including the second physical address that in described local area network (LAN), other wireless devices send;
When receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
If described first physical address is less than described second physical address, then described wireless device is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
6. the clock synchronization system between wireless device, is characterized in that, the clock synchronization system between described wireless device comprises multiple stage wireless device, and described wireless device comprises:
Determination module, for determining between the wireless device in WLAN (wireless local area network) that a wireless device is as time server, other wireless devices in described WLAN (wireless local area network) are all as Time-Client end
Sending module, for sending the first packet comprising point of the current very first time to the wireless device as time server, for described time server after receiving described first packet, the second packet is sent to described Time-Client end, wherein, include point of the described very first time in described second packet, the second time point that described time server receives described first packet and send the 3rd time point of described second packet;
Acquisition module, during for receiving described second packet, obtains the 4th time point receiving described second packet;
Computing module, for calculate according to described very first time point, described second time point, described 3rd time point and described 4th time point and as time server described wireless device between time difference, using the wireless device according to synchronous described sending module place of described time difference and system time as the described wireless device of time server.
7. the clock synchronization system between wireless device according to claim 6, it is characterized in that, described computing module, also for according to described very first time point, described second time point, described 3rd time point, described 4th time point and described time difference computing relay duration, and judge whether described delay duration is greater than preset duration;
Described sending module, if also grow up in described preset duration for described Delay time, then sends the first packet comprising point of the current very first time, until described delay duration is less than or equal to described preset duration to the wireless device as time server.
8. the clock synchronization system between the wireless device according to claim 6 or 7, is characterized in that, described wireless device also comprises:
Adjusting module, for described adjustment System time time difference that basis calculates.
9. the clock synchronization system between wireless device according to claim 8, is characterized in that, described determination module comprises:
Transmitting element, for sending the data query bag including the first physical address, wherein, described first physical address is the physical address of the wireless device at described sending module place;
Determining unit, for when receiving the response message that other wireless devices in described local area network (LAN) send, then will send the wireless device of described response message as time server, the wireless device at described transmitting element place is as Time-Client end.
10. the clock synchronization system between wireless device according to claim 9, is characterized in that, described determination module also comprises:
Judging unit, during for not receiving response message that other wireless devices in described local area network (LAN) send, detecting and whether receiving the data query bag including the second physical address that in described local area network (LAN), other wireless devices send; And, when receive that other wireless devices in described local area network (LAN) send include the data query bag of the second physical address time, judge whether described first physical address is greater than described second physical address;
Described determining unit, if be also less than described second physical address for described first physical address, then the wireless device at described determination module place is as Time-Client end, and wireless device corresponding to described second physical address is as time server.
CN201510961306.8A 2015-12-17 2015-12-17 Time synchronization method and system among wireless devices Pending CN105530698A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510961306.8A CN105530698A (en) 2015-12-17 2015-12-17 Time synchronization method and system among wireless devices

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510961306.8A CN105530698A (en) 2015-12-17 2015-12-17 Time synchronization method and system among wireless devices

Publications (1)

Publication Number Publication Date
CN105530698A true CN105530698A (en) 2016-04-27

Family

ID=55772593

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510961306.8A Pending CN105530698A (en) 2015-12-17 2015-12-17 Time synchronization method and system among wireless devices

Country Status (1)

Country Link
CN (1) CN105530698A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107770569A (en) * 2016-08-18 2018-03-06 北京光子互动科技有限公司 Multimedia synchronous broadcast method, apparatus and system
CN108451547A (en) * 2017-02-20 2018-08-28 深圳市理邦精密仪器股份有限公司 Processing method, device and the system of fetal heart sound data
CN109547946A (en) * 2018-11-02 2019-03-29 南京中感微电子有限公司 A kind of voice data communication method
CN110768312A (en) * 2018-07-25 2020-02-07 Oppo广东移动通信有限公司 Charging control method and device, storage medium and wireless charging equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102035613A (en) * 2009-09-28 2011-04-27 华为技术有限公司 Method, device and network system for realizing time synchronization
CN102111258A (en) * 2009-12-25 2011-06-29 华为技术有限公司 Clock synchronization method, equipment and system
CN104244399A (en) * 2014-09-15 2014-12-24 歌尔声学股份有限公司 Wireless device time synchronizing method, wireless devices and wireless communication system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102035613A (en) * 2009-09-28 2011-04-27 华为技术有限公司 Method, device and network system for realizing time synchronization
CN102111258A (en) * 2009-12-25 2011-06-29 华为技术有限公司 Clock synchronization method, equipment and system
CN104244399A (en) * 2014-09-15 2014-12-24 歌尔声学股份有限公司 Wireless device time synchronizing method, wireless devices and wireless communication system

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107770569A (en) * 2016-08-18 2018-03-06 北京光子互动科技有限公司 Multimedia synchronous broadcast method, apparatus and system
CN108451547A (en) * 2017-02-20 2018-08-28 深圳市理邦精密仪器股份有限公司 Processing method, device and the system of fetal heart sound data
CN108451547B (en) * 2017-02-20 2021-04-13 深圳市理邦精密仪器股份有限公司 Fetal heart sound data processing method, device and system
CN110768312A (en) * 2018-07-25 2020-02-07 Oppo广东移动通信有限公司 Charging control method and device, storage medium and wireless charging equipment
CN110768312B (en) * 2018-07-25 2021-07-16 Oppo广东移动通信有限公司 Charging control method and device, storage medium and wireless charging equipment
CN109547946A (en) * 2018-11-02 2019-03-29 南京中感微电子有限公司 A kind of voice data communication method

Similar Documents

Publication Publication Date Title
US9667370B2 (en) Communication device with peer-to-peer assist to provide synchronization
US9742514B2 (en) Method, apparatus, and system for generating timestamp
CN111147907B (en) Method, device and system for synchronously playing multiple intelligent terminals and intelligent terminal
EP2288070B1 (en) Time synchronizing method, device and system of master clock side and slave clock side in synchronous network
CN102027699B (en) Data transfer method and system for loudspeakers in a digital sound reproduction system
US8730867B2 (en) Clock synchronization aid device for communication station(s) of a wireless network, and associated clock synchronization device
CN105530698A (en) Time synchronization method and system among wireless devices
CN102457371B (en) Time synchronization method and related equipment and system
US9026831B2 (en) Synchronous control system including a master device and a slave device, and synchronous control method for controlling the same
JP5419129B2 (en) COMMUNICATION SYSTEM AND SYNCHRONIZATION METHOD, BASE STATION DEVICE
JP6527289B2 (en) Time synchronization method, sensor accommodating terminal, and sensor network system
CN109565466B (en) Lip sound synchronization method and device among multiple devices
CN110120846B (en) Clock synchronization method and system
CN105577349A (en) Airborne network IEEE1588 protocol master-slave clock port synchronization method
EP2538689A1 (en) Adaptive media delay matching
JP2007184687A (en) Propagation delay time measuring method, synchronization method, and wireless lan system
CN104243079A (en) Microsecond clock synchronization method for real-time Ethernet
CN105634716A (en) Airborne network IEEE1588 protocol slave clock port synchronization method
JP3159055B2 (en) Communications system
WO2013155944A1 (en) Boundary clock, transparent clock, and method for clock transmission
CN108737006A (en) A kind of method for synchronizing time, client and computer readable storage medium
CN115865246A (en) Time synchronization device, system and method
WO2018177320A1 (en) Clock processing method, access network device and terminal device
EP3868043B1 (en) Wireless audio synchronization
WO2015172398A1 (en) Method and apparatus for acquiring packet transmission delay

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20160427

RJ01 Rejection of invention patent application after publication