Clock alignment method and device, equipment and storage medium

By using CTS-to-Self frames and data frames to carry clock alignment information in the LAN, the problem of low clock synchronization accuracy of NTP protocol is solved, and the microsecond level clock alignment and network delay are reduced.

CN119483794APending Publication Date: 2025-02-18CHENGDU OPPO TELECOMM TECH CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311016163.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-11
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The existing NTP protocol has low accuracy in clock synchronization and cannot achieve high-precision device clock alignment within the LAN.

Method used

Clock synchronization between devices is achieved by sending CTS-to-Self frames and data frames carrying clock alignment information. The specific steps include the first WiFi device sending a CTS-to-Self frame and sending a data frame after a predetermined interval, and the second WiFi device receives these frames and sets a local clock according to the clock alignment information.

Benefits of technology

Microsecond-level clock alignment is achieved, reducing time deviations in data transmission and processing, thereby reducing network latency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119483794A_ABST
    Figure CN119483794A_ABST
Patent Text Reader

Abstract

The invention discloses a clock alignment method, device and equipment and a storage medium, and belongs to the field of clock alignment, and the method comprises the steps: transmitting a CTS-to-Self frame; and after a predetermined interval of the CTS-to-Self frame is sent, a data frame is sent, and the data frame carries clock alignment information. According to the method and the device, the CTS-to-Self frame and the data frame carrying the clock alignment information are sent, so that microsecond-level clock alignment can be realized between the two WIFI devices, the time deviation of data transmission and processing can be reduced, and the network delay is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of clock alignment, and in particular to a clock alignment method, apparatus, device and storage medium. Background Art

[0002] High-precision clocks are widely used in modern communications, industrial control, finance, scientific research and other fields. They are also used in mobile multi-device interconnection scenarios, such as audio and video synchronization, information positioning between multiple devices, etc.

[0003] Among the related technologies, the Network Time Protocol (NTP) technology is widely used on mobile devices, which is mainly synchronized through the Simple Network Time Protocol (SNTP) after the device is turned on and connected to the network. The NTP protocol supports a wide range of devices and operating systems, is easy to implement, and is suitable for most network clock synchronization application scenarios.

[0004] However, the clock synchronization accuracy of the NTP protocol is low, generally only reaching the millisecond level, and it is impossible to align devices in the local area network with high precision. Summary of the invention

[0005] The embodiment of the present application provides a clock alignment method, device, equipment and storage medium. The technical solution is as follows:

[0006] On the one hand, an embodiment of the present application provides a clock alignment method, the method being performed by a first WiFi device, the method comprising:

[0007] Send a CTS-to-Self frame;

[0008] After a predetermined interval of sending the CTS-to-Self frame, a data frame is sent, wherein the data frame carries clock alignment information.

[0009] On the other hand, an embodiment of the present application provides a clock alignment method, which is performed by a second WiFi device, and includes:

[0010] Receive CTS-to-Self frame;

[0011] After receiving the predetermined interval of the CTS-to-Self frame, receiving a data frame, the data frame carrying clock alignment information;

[0012] The local clock is set based on the calibration time indicated by the clock alignment information.

[0013] On the other hand, an embodiment of the present application provides a clock alignment device, the device comprising: a sending module;

[0014] The sending module is configured to send a CTS-to-Self frame;

[0015] The sending module is configured to send a data frame after a predetermined interval of sending the CTS-to-Self frame, wherein the data frame carries clock alignment information.

[0016] On the other hand, an embodiment of the present application provides a clock alignment device, the device comprising: a receiving module and a setting module;

[0017] The receiving module is configured to receive a CTS-to-Self frame;

[0018] The receiving module is configured to receive a data frame after receiving a predetermined interval of the CTS-to-Self frame, wherein the data frame carries the clock alignment information;

[0019] The setting module is configured to set the local clock based on the calibration time indicated by the clock alignment information.

[0020] On the other hand, an embodiment of the present application provides a first WiFi device, wherein the first WiFi device includes:

[0021] A processor; a transceiver connected to the processor;

[0022] a memory for storing executable instructions for the processor;

[0023] The processor is configured to load and execute the executable instructions to implement the clock alignment method performed by the first WiFi device as described above.

[0024] On the other hand, an embodiment of the present application provides a second WiFi device, wherein the second WiFi device includes:

[0025] A processor; a transceiver connected to the processor;

[0026] a memory for storing executable instructions for the processor;

[0027] The processor is configured to load and execute the executable instructions to implement the clock alignment method performed by the second WiFi device as described above.

[0028] On the other hand, an embodiment of the present application provides a computer-readable storage medium, in which executable instructions are stored. The executable instructions are loaded and executed by a processor to implement the clock alignment method as described above.

[0029] On the other hand, an embodiment of the present application provides a computer program product, which includes computer instructions, the computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the clock alignment method as described above.

[0030] On the other hand, an embodiment of the present application provides a computer program, which includes computer instructions. A processor of a computer device executes the computer instructions, so that the computer device performs the clock alignment method as described above.

[0031] The technical solution provided by the embodiments of the present application can at least bring the following beneficial effects:

[0032] This clock alignment method is a technology used to achieve clock synchronization between devices in a wireless network. Clock alignment information can be information contained in a data frame to help other devices synchronize their clocks after receiving the data frame. By sending CTS-to-Self frames and data frames carrying clock alignment information, microsecond-level clock alignment can be achieved between devices, which can help reduce time deviations in data transmission and processing, thereby reducing network latency. Description of the drawings:

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0034] Figure 1 A schematic diagram of a clock alignment system provided by an exemplary embodiment of the present application is shown;

[0035] Figure 2 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0036] Figure 3 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0037] Figure 4 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0038] Figure 5 A message interaction diagram of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0039] Figure 6 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0040] Figure 7 A message interaction diagram of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0041] Figure 8 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0042] Fig. 9 A message interaction diagram of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0043] Fig.10 A schematic diagram of a WiFi protocol stack provided by an exemplary embodiment of the present application is shown;

[0044] Fig.11 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0045] Fig.12 A message interaction diagram of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0046] Fig.13 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0047] Fig.14 A flowchart of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0048] Fig.15 A schematic diagram of a calibration process of a clock alignment method provided by an exemplary embodiment of the present application is shown;

[0049] Fig.16 A structural block diagram of a clock alignment device provided by an exemplary embodiment of the present application is shown;

[0050] Fig.17 A structural block diagram of a clock alignment device provided by an exemplary embodiment of the present application is shown;

[0051] Fig.18 A structural block diagram of a WiFi device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION

[0052] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0053] First, the relevant terms involved in this application are introduced:

[0054] First WiFi device: refers to a device with WiFi capability within a local area network that can calibrate the time of other devices.

[0055] Second WiFi device: refers to a device with WiFi capability in the local area network whose time is calibrated by the first WiFi device.

[0056] Short Interframe Space (SIFS): In 802.11 series wireless LANs, SIFS is the minimum interframe space. SIFS is a fixed value, and the duration of SIFS is usually 10 microseconds. Stations using SIFS have the highest priority for accessing wireless links. It is greater than or equal to the time required for a node to switch from the sending state to the receiving state and correctly decode, or the time required to switch from the receiving state to the sending state. The SIFS value specified in different standards is different.

[0057] WiFi: is a wireless networking technology that uses radio waves to transmit data, enabling devices to connect to the Internet or a local area network wirelessly. WiFi technology typically uses a wireless router to create a wireless local area network (WLAN), allowing multiple devices to communicate and share resources through WiFi signals.

[0058] WiFi protocol stack: refers to a set of protocols and software components used to implement WiFi communication functions. It includes multiple protocols such as the physical layer, data link layer, network layer, and transport layer, as well as corresponding drivers and application programming interfaces. The WiFi protocol stack is responsible for processing functions such as modulation and demodulation of wireless signals, data transmission, routing, and network connection to achieve wireless communication between devices.

[0059] Router: A network device used to forward data packets from one network to another. It is usually used to transfer data packets from a local area network to a wide area network or other networks. The router determines the forwarding path of the data packet based on the destination Internet Protocol (IP) address and the routing table.

[0060] Local Area Network (LAN): A LAN is a network established within a relatively small geographical area, such as a home, office, school, or enterprise. A LAN is usually composed of devices such as routers, switches, and network cables, and is used to connect computers and devices located in the same area. LANs have faster transmission speeds and lower latency.

[0061] Simple Network Time Protocol: A protocol used to synchronize time across a wide area network or a local area network, which generally achieves a clock synchronization accuracy of milliseconds. The clock alignment information in the embodiments of the present application can achieve a clock synchronization accuracy of microseconds.

[0062] Clock synchronization: refers to the process of adjusting multiple clock signals to the same starting point or the same phase. Clock alignment is usually used to ensure that the clock signals in different devices or systems are consistent at a specific time point or a specific phase so that they can work in coordination or perform synchronous operations.

[0063] Enhanced Distributed Channel Access (EDCA): This is a channel competition mechanism that helps high-priority messages enjoy priority transmission and more bandwidth. EDCA parameters distinguish the access channel capabilities of different priorities, thereby ensuring that channel resources are allocated according to data flow priority.

[0064] Figure 1 is a schematic diagram of a clock alignment system provided by an embodiment of the present application. Figure 1 , the clock alignment system includes a device 110 and a device 120. The device 110 may be a terminal device or a network device, and the device 120 may be a terminal device or a network device. This application does not limit this. This embodiment of the application is described by taking the first WiFi device 110 and the second WiFi device 120 as an example.

[0065] WiFi can provide wireless network connection, allowing mobile phones, tablet computers, wireless network cards and other devices to receive signals and connect to the Internet, so that devices can connect to the Internet wirelessly to achieve functions such as surfing the Internet and transmitting data. The first WiFi device 110 and the second WiFi device 120 in the embodiment of the present application are both devices with WiFi capabilities.

[0066] In some embodiments, the first WiFi device 110 can support a variety of current and future WLAN standards of the 802.11 family, such as 802.11be, 802.11ax, 802.11ac, 802.11n, 802.11g, 802.11b and 802.11a. The first WiFi device 110 can calibrate the clocks of other devices in the local area network. The first WiFi device 110 is a device for calibrating other devices. After obtaining the current system time, the first WiFi device 110 constructs a data packet containing clock alignment information and sends it to the second WiFi device 120.

[0067] In some embodiments, the second WiFi device 120 may be a mobile phone, tablet computer, e-book reader, laptop computer, multimedia player, wearable device, personal computer (PC), desktop computer, television, virtual reality (VR) device, wireless device in industrial control (Industrial Control), set-top box, vehicle communication device, etc. that supports Wi-Fi technology. The second WiFi device 120 is a device to be calibrated. After receiving the clock alignment information sent by the first WiFi device 110, the second WiFi device 120 sets the local clock to complete the time calibration. The first WiFi device 110 and the second WiFi device 120 communicate with each other through a wireless network.

[0068] The following describes the clock alignment method provided in the embodiments of the present application.

[0069] Figure 2 A flowchart of a clock alignment method provided by some embodiments of the present application is shown. Taking the method executed by a first WiFi device as an example, the method includes at least some of the following steps:

[0070] Step 210: Send a CTS-to-Self frame;

[0071] In the embodiment of the present application, the first WiFi device sends a CTS-to-Self frame to the second WiFi device.

[0072] The CTS-to-Self frame carries a duration field, which is used to indicate the estimated remaining duration of this transmission process, which is used to transmit data frames. The CTS-to-self frame is a control frame in WiFi communication, used to confirm before sending data in a wireless LAN network. It informs other devices that the first WiFi device will send data within a specified time, thereby ensuring that the process will not be interrupted by other devices.

[0073] In some embodiments, when the first WiFi device is ready to transmit data, it will perform network allocation vector (NAV) distribution by sending a CTS-to-Self frame, which notifies other terminals that they must wait for the data frame exchange to complete. The second WiFi device that hears the CTS-to-Self frame will set the NAV timer according to the provided value.

[0074] Step 220: After a predetermined interval of sending a CTS-to-Self frame, a data frame is sent, where the data frame carries clock alignment information.

[0075] The first WiFi device sends a data frame to the second WiFi device after a predetermined interval of sending a CTS-to-Self frame, where the data frame carries clock alignment information.

[0076] The predetermined interval of the CTS-to-Self frame refers to the time interval that the first WiFi device needs to wait after sending the CTS-to-Self frame and before sending the data frame. The predetermined interval here is set to SIFS, which is a fixed value, generally 10 microseconds.

[0077] In an optional example, the first WiFi device obtains the current system time when generating the data frame. The current system time refers to the time in the system of the first WiFi device. The first WiFi device uses the current system time as clock alignment information to generate the data frame, and sends the data frame after a predetermined interval of sending the CTS-to-Self frame.

[0078] In summary, in the method provided in this embodiment, the clock alignment information refers to data used to synchronize the clocks of the first WiFi device and the second WiFi device in the communication system. The clocks of different devices may have certain differences, which may cause time offset or asynchrony in data transmission. In order to ensure the correct transmission of data, the clocks of the devices need to be synchronized. The clock alignment information is transmitted in the form of a data frame. The first WiFi device puts the time information in the data frame and transmits it to the second WiFi device. The second WiFi device sets the local clock according to the clock alignment information in the data frame.

[0079] Figure 3 A flowchart of a clock alignment method provided by some embodiments of the present application is shown. Taking the method executed by a second WiFi device as an example, the method includes at least some of the following steps:

[0080] Step 310: Receive a CTS-to-Self frame;

[0081] The second WiFi device receives the CTS-to-Self frame. The second WiFi device is a device with WiFi capability in the local area network and can receive calibration from other devices.

[0082] Step 320: After receiving a predetermined interval of a CTS-to-Self frame, receiving a data frame, the data frame carrying clock alignment information;

[0083] The second WiFi device receives a data frame after receiving a predetermined interval of a CTS-to-Self frame, and the data frame carries clock alignment information. The first WiFi device embeds the clock alignment information in the data frame, and the second WiFi device uses the clock alignment information for clock synchronization after receiving the data frame.

[0084] In some embodiments, the second WiFi device first listens to the channel to listen for incoming control frames or data frames. Once the CTS-to-Self frame is received, the second WiFi device knows that the first WiFi device is ready to send data frames. After a predetermined interval of receiving CTS-to-Self frames, the second WiFi device is ready to receive data frames.

[0085] In some embodiments, the data frame carries clock alignment information, and the second WiFi device extracts the clock alignment information from the data frame. The clock alignment information may include data for clock synchronization of the first WiFi device. The second WiFi device uses the clock alignment information extracted from the data frame to perform clock synchronization. By comparing with the local clock of the second WiFi device, the second WiFi device can adjust its own clock to keep it synchronized with the clock of the first WiFi device, which helps to ensure the accuracy and reliability of data transmission.

[0086] Step 330: Set the local clock based on the calibration time indicated by the clock alignment information.

[0087] The second WiFi device sets the local clock according to the calibration time indicated by the clock alignment information in the data frame.

[0088] In some embodiments, after receiving the data frame, the second WiFi device extracts the clock alignment information from it, uses the clock alignment information to compare with its own local clock, and adjusts the local clock to keep synchronization with the clock of the first WiFi device. In this way, the local clock of the second WiFi device can be calibrated according to the clock of the first WiFi device, thereby ensuring that during the data transmission process, the first WiFi device and the second WiFi device can communicate based on the same time standard.

[0089] In summary, the method provided in this embodiment enables the second WiFi device to perform clock synchronization when receiving a data frame, thereby ensuring the accuracy and reliability of the data. Clock synchronization is very important for wireless communication because there may be slight differences in the clocks between devices without a physical connection. Using the clock alignment information in the data frame, the second WiFi device can perform compensation and synchronization so that the data can be received and processed at the correct time point. This can effectively improve the performance and stability of the Wi-Fi network.

[0090] Figure 4 A flowchart of a clock alignment method provided by some embodiments of the present application is shown. Taking the method performed by a first WiFi device and a second WiFi device as an example, the method includes at least some of the following steps:

[0091] Step 401: The first WiFi device sends a CTS-to-Self frame to the second WiFi device;

[0092] Combined with reference Figure 5 The first WiFi device first uses the EDCA mechanism to compete for the channel and sends a CTS-to-self frame; after waiting for the SIFS interval, the first WiFi device sends a data frame to the second WiFi device. The first WiFi device sends the CTS-to-Self frame first, which can avoid the first WiFi device and other devices sending data to the second device at the same time, thereby reducing collisions and improving network performance.

[0093] For other characteristics of the CTS-to-Self frame, please refer to the relevant description in step 210 and will not be repeated here.

[0094] Step 402: The first WiFi device sends a data frame to the second WiFi device;

[0095] The first WiFi device sends a data frame after a predetermined interval SIFS of sending a CTS-to-Self frame, where the data frame carries clock alignment information.

[0096] Step 403: Set the local clock based on the calibration time indicated by the clock alignment information.

[0097] Combined with reference Figure 5 After the data packet is sent, the second WiFi device sets the local time according to the time t1 carried by the data frame, and t2 is the time for actually setting the local clock, and the set time is t1. At this time, there is still a certain error of several microseconds to tens of microseconds between the first WiFi device and the second WiFi device. For example, it takes a certain amount of time for the first WiFi device to prepare to generate a data packet, and this time cannot be ignored.

[0098] To reduce this error, the first WiFi device can send CTS-to-Self frames and data frames multiple times in a cycle:

[0099] Figure 6 A schematic flow chart of a clock alignment method provided in some embodiments of the present application is shown, taking the method executed by a first WiFi device and a second WiFi device as an example.

[0100] like Figure 6As shown, after the second WiFi device sets the local clock for the first time based on the calibration time indicated by the clock alignment information, the first WiFi device will continue to send CTS-to-Self frames to the second WiFi device, and cyclically execute steps 401, 402 and 403 to set the local clock.

[0101] Combined with reference Figure 7 The first WiFi device sends CTS-to-Self frames and data frames to the second WiFi device in a loop for multiple times to calibrate the second WiFi device. The second WiFi device will continuously update the clock and will update the alignment information if it finds a clock faster than the current clock. Otherwise, it will not update and set the calibration time of the most recent update as the local clock.

[0102] In summary, in the method provided in this embodiment, the first WiFi device sends a CTS-to-Self frame to the second WiFi device, and sends a data frame after a predetermined interval. The data frame carries clock alignment information. The second WiFi device sets the local clock based on the calibration time indicated by the clock alignment information. This clock synchronization method can achieve microsecond level clock synchronization.

[0103] Figure 8 A flowchart of a clock alignment method provided by some embodiments of the present application is shown. Taking the method performed by a first WiFi device and a second WiFi device as an example, the method includes at least some of the following steps:

[0104] Step 801: The first WiFi device sends a CTS-to-Self frame to the second WiFi device;

[0105] Combined with reference Fig. 9 Before sending data to the second WiFi device, the first WiFi device first sends a CTS-to-Self frame. The purpose of sending the CTS-to-Self frame is to clear the wireless channel before the data frame is transmitted, so as to avoid the first WiFi device and other devices from sending data to the second WiFi device at the same time, so as to enable the devices in the wireless LAN to share the channel more effectively and improve the performance of data transmission.

[0106] For other characteristics of the CTS-to-Self frame, please refer to the relevant description in step 210 and will not be repeated here.

[0107] Step 802: The first WiFi device obtains the current system time when generating a data frame;

[0108] The current system time refers to the time in the first WiFi device system.

[0109] In an optional example, when generating a data frame, the first WiFi device calls a time function interface of the operating system through the WiFi protocol stack to obtain the current system time.

[0110] Among them, the WiFi protocol stack is a protocol stack located at the physical layer.

[0111] Fig.10 A schematic diagram of a TCP / IP protocol stack is shown. The TCP / IP protocol stack reference model is divided into five layers: application layer, transport layer, network layer, link layer and physical layer.

[0112] Combined with reference Fig.10 , Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are two protocols with different service qualities in the transport layer. The main function of the transport layer is to establish end-to-end connections, transmit data from one host to another host, and ensure that data is transmitted in order, reliably, and correctly. IP belongs to the network layer and is the core of the entire TCP / IP protocol stack. Its main function is to forward data packets from source to destination between different networks. In a local area network, the link layer is divided into two sublayers, namely the Logical Link Control (LLC) layer and the Media Access Control (MAC) layer. The MAC layer is responsible for the encapsulation / unloading of data frames, frame addressing and identification, frame reception and transmission, link management, and frame error control. The LLC layer is mainly used for data transmission. It acts as an interface between the network layer and the Media Access Control (MAC) sublayer in the data link layer. The physical layer is used to establish the most basic physical connection between devices. Its main function is to convert binary bit streams into electrical signals and specify a series of characteristics such as media type, interface type, standard level, data rate, maximum transmission distance, etc.

[0113] The embodiment of the present application uses the bottom layer WiFi protocol stack of the TCP / IP protocol stack, which has the advantages of being lower-level and more efficient compared to other protocols. In the WiFi protocol stack, the physical layer is located at the bottom layer of the entire protocol stack and is the interface between the first WiFi device and the wireless channel. The physical layer in the WiFi protocol stack plays a key role in connecting the first WiFi device and the wireless channel.

[0114] In an optional example, when a data frame is generated, the struct timespec function interface of the Linux-like operating system is called through the WIFI protocol stack to obtain the current system time.

[0115] By calling the struct timespec function interface of the Linux-like operating system, the clock alignment information of the current system time can be obtained. When generating a data frame, the time alignment information can be inserted into the data frame, and the current system time can be used as a field of the data frame. In this way, the second WiFi device can obtain the sending time of the data frame by parsing the data frame, providing more time-related information, which is helpful for the analysis of the data packet.

[0116] Step 803: Use the current system time as clock alignment information to generate a data frame;

[0117] In some embodiments, the first WiFi device uses the acquired current system time as clock alignment information to generate a data frame. By adding the clock alignment information to the data frame, the first WiFi device and the second WiFi device can be synchronized in time, thereby achieving better timing control.

[0118] In some embodiments, the clock alignment information of the data frame can help the second WiFi device to accurately parse the data and ensure that the data is correctly decoded and restored.

[0119] Step 804: The first WiFi device sends a data frame to the second WiFi device;

[0120] The first WiFi device sends a data frame after a predetermined interval of sending a CTS-to-Self frame.

[0121] In some embodiments, if the current channel is idle, the first WiFi device will send a CTS-to-Self frame. Once the CTS-to-Self frame is successfully sent, the first WiFi device will wait for a short period of time SIFS and then send a data frame.

[0122] Step 805: The second WiFi device obtains the estimated remaining time carried by the CTS-to-Self frame;

[0123] Combined with reference Fig. 9 The estimated remaining duration carried by the CTS-to-Self frame is the duration field set by the first WiFi device in the CTS-to-Self frame. The second WiFi device sets the NAV duration of its own NAV timer according to the duration field carried by the CTS-to-Self frame. The NAV duration starts from sending the CTS-to-Self frame and ends when the data packet carrying the clock alignment information is sent.

[0124] When the first WiFi device sends a CTS-to-Self frame, it calculates an expected data transmission duration, and then uses the duration as the NAV duration of the NAV timer of the second WiFi device. Other devices remain silent during the NAV duration so that the first WiFi device will not be disturbed when sending data.

[0125] Step 806: Calculate the difference between the estimated remaining time and the predetermined interval;

[0126] Combined with reference Fig. 9 The predetermined interval refers to the time interval that the first WiFi device needs to wait after sending the CTS-to-Self frame and before sending the data frame. The predetermined interval here is set to SIFS. SIFS is a fixed value, generally 10 microseconds.

[0127] The estimated remaining time refers to the NAV time set in CTS-to-Self.

[0128] The difference between the estimated remaining time and the predetermined interval is NAV-SIFS, which is the time taken by the first WiFi device to send a data frame to the second WiFi device.

[0129] Step 807: Calculate the sum of the time and the difference carried by the clock alignment information as the calibration time indicated by the clock alignment information;

[0130] Combined with reference Fig. 9 In some embodiments, the first device sends a data packet to the second WiFi device, and the data packet carries clock alignment information. Ideally, the first WiFi device immediately sends a data frame to the second WiFi device after a predetermined interval, and the time at this time is t3. t3 is in the data packet. After receiving the data packet, the second WiFi device immediately sets t3 as the local clock. However, in actual situations, it takes a certain amount of time for the second WiFi device to obtain t3, and this time cannot be ignored; it also takes a certain amount of time for the first WiFi device to call the time function interface of the operating system through the WiFi protocol stack to obtain the current system time, and it also takes a certain amount of time for the first WiFi device to prepare to generate a data packet, and these times are also not negligible. Therefore, in actual situations, the time of obtaining the current system is earlier than the moment t3. The moment of obtaining the current system time is t1, and t2 is the time when the second WiFi device sets the local clock.

[0131] Step 808: When the calibration time indicated by the clock alignment information is earlier than the current time of the local clock, the local clock is set based on the calibration time indicated by the clock alignment information.

[0132] In some embodiments, the second WiFi device obtains the clock alignment information sent by the first WiFi device, makes adjustments based on the difference between the calibration time indicated by the clock alignment information and the current local clock, and sets the local clock according to the calibration time.

[0133] In summary, the method provided in this embodiment generates a data frame by calling the time function interface of the operating system through the WiFi protocol stack when generating a data frame, and using the current system time as the clock alignment information; calculating the difference between the estimated remaining time NAV and the predetermined interval SIFS, and using the sum of the time carried by the clock alignment information and the above difference as the calibration time indicated by the clock alignment information, which can reduce the error of time synchronization and enable the first WiFi device and the second WiFi device to achieve more accurate clock synchronization.

[0134] Fig.11 A flowchart of a clock alignment method provided in some embodiments of the present application is shown.

[0135] In order to improve the clock synchronization accuracy between the first WiFi device and the second WiFi device, the above steps 801-808 may be repeatedly performed.

[0136] Combined with reference Fig.12 The first WiFi device sends CTS-to-Self frames and data frames to the second WiFi device in a loop for multiple times to calibrate the second WiFi device. The second WiFi device will continuously update the clock. If it finds that there is clock alignment information that is faster than the current clock, it will update it. Otherwise, it will not update it and set the calibration time of the most recent update as the local clock.

[0137] Based on Figure 8 In an optional embodiment, Fig.13 A schematic diagram of a clock alignment method provided by an exemplary embodiment of the present application is shown, and the method can be applied to a second WiFi device. In this embodiment, step 807 is replaced by step 807-1:

[0138] Step 807-1: Calculate the sum of the time and the difference carried by the clock alignment information, and add the preset time offset, where the time offset is used to indicate at least one of the time when the first WiFi device prepares the data packet and the time when the second WiFi device parses the data packet after receiving the data packet, as the calibration time indicated by the clock alignment information.

[0139] The time carried by the clock alignment information is t1, and the difference is the difference between the estimated remaining time NAV duration set by the first WiFi device in CTS-to-Self and the predetermined interval SIFS.

[0140] In some embodiments, the time offset value is very small, and a high clock synchronization can be achieved without considering the time offset value. In order to achieve more accurate clock synchronization, the time offset value can be predicted in advance in the laboratory. The time offset is a pre-set value. The time offset is used to indicate at least one of the time when the first WiFi device prepares the data packet and the time when the second WiFi device parses the data packet after receiving the data packet. At this time, the second WiFi device sets the local clock t2≈t1+(NAV-SIFS)+time offset.

[0141] Fig.14 A flowchart of a clock alignment method provided in some embodiments of the present application is shown.

[0142] In order to improve the clock synchronization accuracy between the first WiFi device and the second WiFi device, the above steps 801-808 can be repeatedly performed. The first WiFi device repeatedly sends CTS-to-Self frames and data frames to the second WiFi device to calibrate the second WiFi device. The second WiFi device will continuously update the clock. If it finds that there is clock alignment information faster than the current clock, it will update it. Otherwise, it will not update it and set the calibration time of the most recent update as the local clock.

[0143] In summary, in the method provided by this embodiment, the first WiFi device obtains the current system time when generating a data frame, and uses the current system time as clock alignment information to generate a data frame; by adding a preset time offset to the clock alignment information, the first WiFi device and the second WiFi device can achieve more accurate clock synchronization. It should be noted that in the above steps, the step of calculating the calibration time can also be performed by the first WiFi device, and in this case, the calibration time is carried in the data packet instead of the current system time.

[0144] Fig.15 A schematic diagram of a calibration process of an embodiment of the present application is shown. Fig.15 , the first WiFi device and the second WiFi device first update the time through SNTP before calibration; the first WiFi device initiates calibration, at this time the first WiFi device is equivalent to a software site, the second WiFi device is equivalent to an access point, and the second WiFi device will be connected to the first WiFi device; the first WiFi device first constructs a CTS-to-Self packet in the WiFi protocol stack, and constructs and sends a data packet after a predetermined interval, the data packet carries clock alignment information, the second WiFi device receives the data packet, and sets the clock according to the clock alignment information in the data packet.

[0145] In summary, the method provided in this embodiment calibrates the time of devices with WiFi capabilities through clock synchronization in a local area network. The clock alignment information can be information contained in the data frame to help other devices perform clock synchronization after receiving the data frame. By sending CTS-to-Self frames and data frames carrying clock alignment information, relatively accurate clock synchronization can be achieved between devices, which can help reduce the time deviation of data transmission and processing, thereby reducing network delays.

[0146] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0147] Please refer to Fig.16 , which shows a block diagram of a clock alignment device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned clock alignment method example, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be the server introduced above, or it can be set in the server. Fig.16 As shown, the device may include: a sending module 1601, an acquiring module 1602 and a generating module 1603;

[0148] The sending module 1601 is used to send a CTS-to-Self frame;

[0149] The sending module 1601 is used to send a data frame after a predetermined interval of sending a CTS-to-Self frame, where the data frame carries clock alignment information.

[0150] In an optional embodiment, the sending module 1601 is used to send a data frame after a predetermined interval of sending a CTS-to-Self frame.

[0151] In some embodiments, the device further includes an acquisition module 1602 .

[0152] In an optional embodiment, the acquisition module 1602 is used to acquire the current system time when generating a data frame.

[0153] In an optional embodiment, the acquisition module 1602 is used to call the time function interface of the operating system through the WIFI protocol stack to acquire the current system time when generating the data frame.

[0154] In an optional embodiment, the acquisition module 1602 is used to call the struct timespec function interface of the operating system Linux class system through the WIFI protocol stack to acquire the current system time when generating the data frame.

[0155] In some embodiments, the device further includes a generating module 1603 .

[0156] In an optional embodiment, the generating module 1603 is used to generate a data frame by using the current system time as the clock alignment information.

[0157] In some embodiments, the sending module 1601 is configured to repeatedly send a CTS-to-Self frame;

[0158] In some embodiments, the sending module 1601 is used to send a data frame after repeatedly sending a CTS-to-Self frame at a predetermined interval, and the data frame carries clock alignment information.

[0159] Please refer to Fig.17 , which shows a block diagram of a clock alignment device provided by an embodiment of the present application. The device has the function of implementing the above-mentioned clock alignment method example, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be the server introduced above, or it can be set in the server. Fig.17 As shown, the device may include: a receiving module 1701, a setting module 1702, an acquisition module 1703 and a calculation module 1704;

[0160] The receiving module 1701 is used to receive a CTS-to-Self frame;

[0161] The receiving module 1701 is used to receive a data frame after a predetermined interval of receiving a CTS-to-Self frame, where the data frame carries clock alignment information;

[0162] The setting module 1702 is used to set the local clock based on the calibration time indicated by the clock alignment information.

[0163] In an optional embodiment, the setting module 1702 is used to set the local clock based on the calibration time indicated by the clock alignment information when the calibration time indicated by the clock alignment information is earlier than the current time in the local clock.

[0164] In some embodiments, the device further includes an acquisition module 1703 .

[0165] In an optional embodiment, the acquisition module 1703 is used to obtain the estimated remaining time carried by the CTS-to-Self frame;

[0166] In some embodiments, the device also includes a computing module 1704 .

[0167] In an optional embodiment, the calculation module 1704 is used to calculate the difference between the estimated remaining time and the predetermined interval;

[0168] In an optional embodiment, the calculation module 1704 is used to calculate the sum of the time and the difference carried by the clock alignment information as the calibration time indicated by the clock alignment information.

[0169] In some embodiments, the receiving module 1701 is configured to repeatedly receive CTS-to-Self frames;

[0170] In some embodiments, the receiving module 1701 is used to receive a data frame after repeatedly receiving a CTS-to-Self frame at a predetermined interval, and the data frame carries clock alignment information.

[0171] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0172] Please refer to Fig.18 , which shows a structural block diagram of a first WiFi device or a second WiFi device provided in an embodiment of the present application. The first WiFi device or the second WiFi device can be used to implement the clock alignment method provided in the above embodiment. Specifically:

[0173] The first WiFi device or the second WiFi device 1800 includes a central processing unit (CPU) 1801, a system memory 1804 including a random access memory (RAM) 1802 and a read-only memory (ROM) 1803, and a system bus 1805 connecting the system memory 1804 and the central processing unit 1801. The first WiFi device or the second WiFi device 1800 also includes a basic input / output system (I / O system) 1806 for facilitating information transmission between various components in the computer device, and a large-capacity storage device 1807 for storing an operating system 1813, application programs 1814, and other program modules 1815.

[0174] The basic input / output system 1806 includes a display 1808 for displaying information and an input device 1809 such as a mouse and a keyboard for user inputting information. The display 1808 and the input device 1809 are connected to the central processing unit 1801 through an input / output controller 1810 connected to the system bus 1805. The basic input / output system 1806 may also include an input / output controller 1810 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1810 also provides output to a display screen, a printer, or other types of output devices.

[0175] The mass storage device 1807 is connected to the central processing unit 1801 via a mass storage controller (not shown) connected to the system bus 1805. The mass storage device 1807 and its associated computer-readable storage medium provide non-volatile storage for the first WiFi device or the second WiFi device 1800. That is, the mass storage device 1807 may include a computer-readable storage medium (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.

[0176] Without loss of generality, the computer-readable storage medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable storage instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically Erasable Programmable Read-Only Memory (EEPROM), flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, cassette, tape, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 1804 and mass storage device 1807 can be collectively referred to as memory.

[0177] The memory stores one or more programs, and the one or more programs are configured to be executed by one or more central processing units 1801. The one or more programs contain instructions for implementing the above-mentioned method embodiments. The central processing unit 1801 executes the one or more programs to implement the methods provided by the above-mentioned method embodiments.

[0178] According to various embodiments of the present application, the first WiFi device or the second WiFi device 1800 can also be connected to a remote first WiFi device or a second WiFi device on a network through a network such as the Internet for operation. That is, the first WiFi device or the second WiFi device 1800 can be connected to the network 1812 through a network interface unit 1811 connected to the system bus 1805, or the network interface unit 1811 can be used to connect to other types of networks or remote first WiFi devices or second WiFi device systems (not shown).

[0179] The memory further includes one or more programs, which are stored in the memory and include steps for performing the method provided in the embodiment of the present application and executed by the first WiFi device or the second WiFi device.

[0180] In an exemplary embodiment, a non-transitory computer-readable storage medium is further provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the clock alignment method described above is implemented.

[0181] In an exemplary embodiment, a computer program product is also provided. When the computer program product is executed by a processor, it is used to implement the above clock alignment method.

[0182] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.

[0183] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A clock alignment method, characterized in that: The method is performed by a first wireless network WiFi device, and the method includes: Send spontaneous confirmation frame CTS-to-Self; After a predetermined interval of sending the CTS-to-Self frame, a data frame is sent, wherein the data frame carries clock alignment information.

2. The method according to claim 1, characterized in that The step of sending a data frame after a predetermined interval of sending the CTS-to-Self frame comprises: When generating the data frame, obtaining the current system time; Using the current system time as the clock alignment information to generate the data frame; The data frame is sent after a predetermined interval of sending the CTS-to-Self frame.

3. The method according to claim 2, characterized in that When generating the data frame, obtaining the current system time includes: When the data frame is generated, the time function interface of the operating system is called through the WiFi protocol stack to obtain the current system time.

4. The method according to claim 3, characterized in that When generating the data frame, calling the time function interface of the operating system through the WiFi protocol stack to obtain the current system time includes: When the data frame is generated, the struct timespec function interface of the operating system Linux class system is called through the WiFi protocol stack to obtain the current system time.

5. The method according to any one of claims 1 to 4, characterized in that: The CTS-to-Self frame carries a duration field, and the duration field is used to indicate the estimated remaining duration of this transmission process, and the current transmission process is used to transmit the data frame.

6. The method according to claim 3 or 4, characterized in that: The WiFi protocol stack is a protocol stack located at the physical layer.

7. A clock alignment method, characterized in that: The method is performed by a second WiFi device, and the method includes: Receive CTS-to-Self frame; After receiving the predetermined interval of the CTS-to-Self frame, receiving a data frame, the data frame carrying clock alignment information; The local clock is set based on the calibration time indicated by the clock alignment information.

8. The method according to claim 7, characterized in that The step of setting the local clock based on the calibration time indicated by the clock alignment information includes: In a case where the calibration time indicated by the clock alignment information is earlier than the current time in the local clock, the local clock is set based on the calibration time indicated by the clock alignment information.

9. The method according to claim 7 or 8, characterized in that: The CTS-to-Self frame carries a duration field, where the duration field is used to indicate the estimated remaining duration of this transmission process, where this transmission process is used to transmit the data frame; The method further comprises: Obtaining the estimated remaining time carried by the CTS-to-Self frame; Calculating the difference between the estimated remaining time and the predetermined interval; The sum of the time carried by the clock alignment information and the difference is calculated as the calibration time indicated by the clock alignment information.

10. A clock alignment device, characterized in that: The device comprises: a sending module; The sending module is configured to send a CTS-to-Self frame; The sending module is configured to send a data frame after a predetermined interval of sending the CTS-to-Self frame, wherein the data frame carries clock alignment information.

11. A clock alignment device, characterized in that: The device comprises: a receiving module and a setting module; The receiving module is configured to receive a CTS-to-Self frame; The receiving module is configured to receive a data frame after receiving a predetermined interval of the CTS-to-Self frame, wherein the data frame carries the clock alignment information; The setting module is configured to set the local clock based on the calibration time indicated by the clock alignment information.

12. A first WiFi device, characterized in that: The first WiFi device includes: A processor; a transceiver connected to the processor; a memory for storing executable instructions for the processor; The processor is configured to load and execute the executable instructions to implement the clock alignment method performed by the first WiFi device as described in any one of claims 1 to 6.

13. A second WiFi device, characterized in that: The second WiFi device includes: A processor; a transceiver connected to the processor; a memory for storing executable instructions for the processor; The processor is configured to load and execute the executable instructions to implement the clock alignment method performed by the second WiFi device as described in any one of claims 7 to 9.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores executable instructions, which are loaded and executed by a processor to implement the clock alignment method performed by the first WiFi device as described in any one of claims 1 to 6, or the clock alignment method performed by the second WiFi device as described in any one of claims 7 to 9.

15. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the clock alignment method performed by the first WiFi device as described in any one of claims 1 to 6, or the clock alignment method performed by the second WiFi device as described in any one of claims 7 to 9.

16. A computer program, characterized in that The computer program includes computer instructions, and a processor of a computer device executes the computer instructions, so that the computer device performs the clock alignment method performed by the first WiFi device as described in any one of claims 1 to 6, or the clock alignment method performed by the second WiFi device as described in any one of claims 7 to 9.