Connection relationship establishment method and device, and storage medium
By cyclically sending and determining broadcast packets on search devices in Wi-Fi networks, the problem of excessive time-consuming traditional search mechanisms is solved, and faster connection recovery between devices is achieved.
Patent Information
- Application Number
- CN202411832144.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-22
AI Technical Summary
In Wi-Fi networks, the traditional management frame search mechanism causes the connection recovery between devices to take too long, mainly because the search device needs to wait for a response after sending a broadcast request, which may lead to a missed response packet.
By performing the transmission and determination step on the search device: sending a broadcast packet with initial channel information on multiple channels, and determining whether a response packet is received within a preset time period, if not received, cyclically sending and determining until a response packet is received.
This method ensures that the search device can receive the response of the searched device in a timely manner and will not miss the reply because both parties are not on the same channel, thereby reducing the search time and solving the problem that the search mechanism takes too long.
Smart Images

Figure CN119865871A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart home technology, and more specifically, to a method and device for establishing a connection relationship, and a storage medium. Background Art
[0002] In wireless communication technology, especially Wi-Fi networks, real-time connection and fast recovery capabilities between devices are key to ensuring network stability and user experience. However, when the communication link between Wi-Fi devices is suddenly interrupted, the traditional management frame search mechanism becomes the main bottleneck in the process of restoring the connection. This mechanism requires the search device to send management frames (such as probe requests) on multiple available channels to find each other, and after each request is sent, the search device needs to wait for a period of time on the channel where the management frame is sent to receive a possible response.
[0003] However, after sending a broadcast request, it is possible that the response packet of the searched device has not yet arrived, while the searching device has already switched channels, causing the response packet to be missed by the searching device. This uncertainty makes it difficult for the searching device to effectively complete the interaction of requests and responses on each channel, thereby prolonging the overall time for communication recovery.
[0004] In view of the problem that the search mechanism in the related art takes too long, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a method and device for establishing a connection relationship, and a storage medium, so as to at least solve the problem that the search mechanism in the related art is too time-consuming.
[0006] According to an embodiment of the present application, a method for establishing a connection relationship is provided, which is applied to a search device, and includes: executing a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2...M in sequence, and M is the number of channels corresponding to the search device; executing a determining step: switching the channel of the search device to the initial channel, and determining whether a response packet sent by the searched device is received within a preset time length, wherein the initial channel is a channel corresponding to the initial channel information; if the response packet sent by the searched device is not received within the preset time length, looping the sending step and the determining step until a response packet sent by the searched device is received; and establishing a connection relationship between the search device and the searched device according to the response packet.
[0007] In an exemplary embodiment, before determining whether a response packet sent by the searched device is received within a preset time length, the method also includes: obtaining interference information and a transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, a signal-to-interference ratio; inputting the interference information and the transmission rate into a first preset model so that the first preset model outputs the preset time length, wherein the first preset model is trained through machine learning using multiple groups of first data, and each group of the multiple groups of first data includes: sample interference information and a sample transmission rate, and a time length corresponding to the sample interference information and the sample transmission rate.
[0008] In an exemplary embodiment, establishing a connection relationship between the search device and the searched device based on the response packet includes: determining a first networking preference value of the searched device carried in the response packet, and determining a second networking preference value of the search device; determining a first size relationship between the first networking preference value and the second networking preference value; and establishing a connection relationship between the search device and the searched device based on the first size relationship.
[0009] In an exemplary embodiment, a connection relationship between the searching device and the searched device is established based on the response packet, including: when the first size relationship indicates that the first networking preference value is greater than the second networking preference value, sending a first networking request to the searched device to establish a connection relationship between the searching device and the searched device; when the first size relationship indicates that the first networking preference value is less than or equal to the second networking preference value, receiving a second networking request sent by the searched device to establish a connection relationship between the searching device and the searched device.
[0010] According to another embodiment of the embodiments of the present application, a method for establishing a connection relationship is provided, which is applied to a searched device, including: receiving a broadcast packet sent by a search device on a channel where the searched device is located; parsing the broadcast packet to obtain initial channel information of the search device carried in the broadcast packet; switching the channel of the searched device to an initial channel, and periodically sending a response packet on the initial channel, so that the search device establishes a connection relationship between the search device and the searched device according to the response packet, wherein the initial channel is a channel corresponding to the initial channel information.
[0011] In an exemplary embodiment, periodically sending a response packet on the initial channel includes: obtaining interference information and a transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, a signal-to-interference ratio; inputting the interference information and the transmission rate into a second preset model so that the second preset model outputs a cycle duration, wherein the second preset model is trained by machine learning using multiple groups of second data, and each group of the multiple groups of second data includes: sample interference information and a sample transmission rate, and a cycle duration corresponding to the sample interference information and the sample transmission rate; and periodically sending a response packet on the initial channel according to the cycle duration.
[0012] In an exemplary embodiment, before periodically sending a response packet on the initial channel, the method further includes: determining a second networking preference value of the searched device carried in the broadcast packet, and determining a first networking preference value of the searching device; determining a first size relationship between the first networking preference value and the second networking preference value; and establishing a connection relationship between the searching device and the searched device based on the first size relationship.
[0013] According to another embodiment of the embodiment of the present application, a device for establishing a connection relationship is also provided, which is applied to a search device, including: a sending module, used to execute a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2...M in sequence, and M is the number of channels corresponding to the search device; a first determination module, used to switch the channel of the search device to the initial channel, and determine whether a response packet sent by the searched device is received within a preset time length, wherein the initial channel is a channel corresponding to the initial channel information; a second determination module, used to, if a response packet sent by the searched device is not received within a preset time length, repeatedly execute the sending step until a response packet sent by the searched device is received; an establishment module, used to establish a connection relationship between the search device and the searched device according to the response packet.
[0014] According to another embodiment of the embodiments of the present application, a device for establishing a connection relationship is also provided, which is applied to a searched device, including: a receiving module, used to receive a broadcast packet sent by a search device on a channel where the searched device is located; a parsing module, used to parse the broadcast packet to obtain initial channel information of the search device carried in the broadcast packet; a sending module, used to switch the channel of the searched device to an initial channel, and periodically send a response packet on the initial channel, so that the search device establishes a connection relationship between the search device and the searched device according to the response packet, wherein the initial channel is a channel corresponding to the initial channel information.
[0015] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the method for establishing the connection relationship when running.
[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for establishing the connection relationship through the computer program.
[0017] In the embodiment of the present application, a sending step is performed: a broadcast packet is sent on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ... M in sequence, and M is the number of channels corresponding to the search device; a determining step is performed: the channel of the search device is switched to the initial channel, and it is determined whether a response packet sent by the searched device is received within a preset time length, wherein the initial channel is the channel corresponding to the initial channel information; if the response packet sent by the searched device is not received within the preset time length, the sending step and the determining step are executed repeatedly until the response packet sent by the searched device is received; a connection relationship between the search device and the searched device is established according to the response packet; in the embodiment of the present application, the search device will poll and send broadcast packets on each channel to establish communication between the two parties. After sending each broadcast packet, the search device will immediately return to its initial channel and wait for a reply from the searched device. This ensures that the searching device can receive the response of the searched device in time while sending the request, and will not fail to receive a reply because both parties are not on the same channel, thereby reducing the search time. The above technical solution solves the problem of the search mechanism taking too long. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 It is a hardware environment diagram of a method for establishing a connection relationship according to an embodiment of the present application;
[0021] Figure 2 is a flow chart (I) of a method for establishing a connection relationship according to an embodiment of the present application;
[0022] Figure 3 is a flow chart (II) of a method for establishing a connection relationship according to an embodiment of the present application;
[0023] Figure 4 It is a timing diagram of a method for establishing a connection relationship in the related art;
[0024] Figure 5 is a timing diagram of a method for establishing a connection relationship according to an embodiment of the present application;
[0025] Figure 6 is a structural block diagram of a device for establishing a connection relationship according to an embodiment of the present application (I);
[0026] Figure 7 This is a structural block diagram (II) of a device for establishing a connection relationship according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to one aspect of an embodiment of the present application, a method for establishing a connection relationship is provided. The method for establishing a connection relationship is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (Intelligence House) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above-mentioned method for establishing a connection relationship can be applied to Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.
[0030] The network may include but is not limited to at least one of the following: wired network, wireless network. The wired network may include but is not limited to at least one of the following: wide area network, metropolitan area network, local area network, and the wireless network may include but is not limited to at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing device, a smart dishwasher, a smart projection device, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart fresh air device, a smart kitchen and bathroom device, a smart bathroom device, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification device, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.
[0031] In this embodiment, a method for establishing a connection relationship is provided, which is applied to a search device, and the search device may be the above-mentioned terminal device. Figure 2 1 is a flow chart of a method for establishing a connection relationship according to an embodiment of the present application (I), the flow includes the following steps:
[0032] Step S202, executing a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device;
[0033] In step S202, the search device sends a broadcast packet with its initial channel information on the Nth channel. This step is the beginning of the search process. The search device attempts to establish contact with the searched device on multiple channels (from 1 to M) by broadcasting, where M represents the number of all channels that the search device can access.
[0034] Step S204, executing a determination step: switching the channel of the search device to an initial channel, and determining whether a response packet sent by the search device is received within a preset time period, wherein the initial channel is a channel corresponding to the initial channel information;
[0035] After sending the broadcast packet, the search device immediately returns to its initial channel. Unlike the traditional method in which the search device stays on the current channel and waits for a response after sending the broadcast packet, in the embodiment of the present application, the search device quickly returns to the initial channel. The search device waits for a preset time on the initial channel to determine whether a response packet from the searched device is received. This solves the problem of missed responses caused by the device not waiting on the correct channel in the traditional method.
[0036] Step S206, when no response packet sent by the searched device is received within a preset time period, the sending step and the determining step are executed in a loop until a response packet sent by the searched device is received;
[0037] If the search device does not receive a response packet within the preset time, it will loop through steps S202 and S204 again. That is, the search device will continue to send broadcast packets on the next channel, and then quickly return to the initial channel to wait for a response. This loop process will continue until the search device successfully receives a response packet from the searched device, or all channels have been searched.
[0038] Step S208: establishing a connection relationship between the searching device and the searched device according to the response packet.
[0039] Once the searching device receives a response packet from the searched device on the initial channel, it establishes a connection relationship with the searched device based on the information in the response packet, such as the MAC address, signal strength, etc.
[0040] Through the above steps, the sending step is performed: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2...M in sequence, and M is the number of channels corresponding to the search device; performing the determination step: switching the channel of the search device to the initial channel, and determining whether a response packet sent by the searched device is received within a preset time length, wherein the initial channel is the channel corresponding to the initial channel information; in the case where the response packet sent by the searched device is not received within the preset time length, the sending step and the determination step are executed repeatedly until the response packet sent by the searched device is received; establishing a connection relationship between the search device and the searched device according to the response packet; in the embodiment of the present application, the search device will poll and send broadcast packets on each channel to establish communication between the two parties. After sending each broadcast packet, the search device will immediately return to its initial channel and wait for a reply from the searched device. This ensures that the searching device can receive the response of the searched device in time while sending the request, and will not fail to receive a reply because both parties are not on the same channel, thereby reducing the search time. The above technical solution solves the problem of the search mechanism taking too long.
[0041] Optionally, before determining whether a response packet sent by the searched device is received within a preset time length, it also includes: obtaining interference information and a transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, a signal-to-interference ratio; inputting the interference information and the transmission rate into a first preset model so that the first preset model outputs the preset time length, wherein the first preset model is trained through machine learning using multiple groups of first data, and each group of the multiple groups of first data includes: sample interference information and a sample transmission rate, and a time length corresponding to the sample interference information and the sample transmission rate.
[0042] In the method of this embodiment, a dynamic preset duration mechanism is introduced, which adjusts the time that the search device waits for the response packet on the initial channel based on the interference information and transmission rate of the current channel. Specifically:
[0043] Before the searching device prepares to wait for the response packet of the searched device on the initial channel, it first needs to obtain the environmental information of the current initial channel, including interference information (such as background noise, signal-to-interference ratio) and the transmission rate of the channel. This information can reflect the signal quality and transmission efficiency of the current channel.
[0044] The importance of interference information lies in the fact that it is used to evaluate the availability of channels and the clarity of signals. The higher the background noise and signal-to-interference ratio, the more interference there is on the channel, the signal transmission may not be so stable, and the success rate of receiving response packets may be reduced. The transmission rate reflects the data transmission capacity of the channel.
[0045] The acquired environmental information is then input into the first preset model. The model is trained with multiple sets of first data, each set of data including sample interference information (such as background noise, signal-to-interference ratio), sample transmission rate, and the optimal waiting time corresponding to these sample data. During the training process, the model learns the optimal time strategy for the search device to wait for the response packet on the initial channel under different channel environments (interference level and transmission rate).
[0046] Through the preset duration output by the first preset model, the search device can dynamically adjust the waiting time for receiving the response packet according to the actual situation of the current channel. If the interference information of the current channel shows that the channel is crowded or the signal quality is poor, the model may output a longer preset duration to ensure that the search device has enough time to receive the response packet that may arrive. Conversely, if the interference information and transmission rate of the channel indicate that the channel environment is good, the model may output a shorter preset duration to reduce unnecessary waiting time and speed up the search process.
[0047] In the embodiment of the present application, the waiting time can be dynamically adjusted according to the change of the channel environment, which improves the intelligence and adaptability of the mechanism. By reasonably setting the waiting time, the search failure caused by too long or too short waiting time can be reduced, thereby ensuring the response reception success rate while speeding up the recovery speed of the connection between devices.
[0048] Optionally, establishing a connection relationship between the searching device and the searched device based on the response packet includes: determining a first networking preference value of the searched device carried in the response packet, and determining a second networking preference value of the searching device; determining a first size relationship between the first networking preference value and the second networking preference value; and establishing a connection relationship between the searching device and the searched device based on the first size relationship.
[0049] When the search device successfully receives the response packet sent by the searched device, it will parse the response packet and extract the first network preference value of the searched device. The network preference value refers to the device's preference for various factors (such as network coverage, signal strength, transmission rate, battery life, network load, etc.) when networking, which can be used to evaluate the suitability of the device as a network node.
[0050] The search device will also determine its own second networking preference value. By comparing its own networking preference value with that of the other party, the search device can make a better connection decision. Afterwards, the search device will compare the first networking preference value and the second networking preference value to determine the first size relationship between them, and then evaluate the networking compatibility and degree of optimization between the two devices. For example, if the second networking preference value of the search device is significantly higher than the first networking preference value of the searched device, it means that the search device performs better on certain key network performance indicators and is therefore more suitable as the dominant party of the connection.
[0051] Finally, based on the first size relationship, the searching device will decide how to establish a connection relationship with the searched device.
[0052] In the embodiment of the present application, by comparing the networking preference values of the devices, the devices can make more intelligent connection decisions, optimize the network structure, and improve network performance. The optimized connection strategy can reduce network delays, increase data transmission speed and stability, and thus enhance the user's wireless network experience.
[0053] In an exemplary embodiment, a connection relationship between the searching device and the searched device is established based on the response packet, including: when the first size relationship indicates that the first networking preference value is greater than the second networking preference value, sending a first networking request to the searched device to establish a connection relationship between the searching device and the searched device; when the first size relationship indicates that the first networking preference value is less than or equal to the second networking preference value, receiving a second networking request sent by the searched device to establish a connection relationship between the searching device and the searched device.
[0054] In the embodiment of the present application, the establishment of the connection relationship between devices further incorporates the comparison logic of the networking preference value to achieve a more optimized network structure and performance. Specifically, when the search device receives the response packet of the searched device and parses the first networking preference value from it, it compares it with its own second networking preference value and determines the initiator and receiver of the connection request based on the comparison result. Specifically:
[0055] The search device will send the first networking request to the searched device to establish a connection between the two parties. That is, the search device is superior to the searched device in terms of networking capability or performance, and is suitable for playing a more active or critical network role. For example, the search device may have stronger signal transmission capabilities, a larger network coverage, a higher data transmission rate, or a more stable power supply, which together constitute its higher networking preference value. By actively sending a networking request by the search device, it can ensure that the network connection is established more stably and efficiently, while making full use of the advantageous resources of the search device.
[0056] When the first networking preference value is less than or equal to the second networking preference value, the search device will switch to receiving mode and prepare to receive the second networking request sent by the searched device. That is, the searched device is at least equivalent to the search device in terms of networking capability or performance, or even better, and is therefore more suitable for initiating a connection request. For example, the searched device may have better signal reception sensitivity, a more energy-efficient operating mode, lower network latency, or a better network management strategy, factors that make its networking preference value no lower than that of the search device. When the searched device sends a networking request and is received by the search device, the two parties can establish a connection in a more compatible manner to ensure efficient operation of the network and reasonable allocation of resources.
[0057] By comparing the networking preference values, the device can dynamically select the most appropriate connection initiator, avoiding the limitations of fixed role allocation. The establishment of connections between devices is based on the comparison of performance and preference values, which is conducive to the overall improvement of network performance, including data transmission speed, stability, energy efficiency, etc. By allowing devices with higher networking preference values to actively initiate connections, it is possible to achieve a reasonable allocation of network resources and avoid low-performance devices from bearing excessive network loads. Enhanced flexibility: When establishing a connection, devices can flexibly adjust their roles according to the real-time performance status, improving the adaptability and flexibility of the network.
[0058] Optionally, in some cases, if the networking preference values of two devices are similar or equal, the searching device and the searched device may adopt a balancing strategy to ensure that both parties can obtain a good network experience, for example, determining whether the searching device or the searched device is the active initiator based on the device role.
[0059] Specific implementation methods of “determining the active initiator of networking when the networking preference values of two devices are not much different or are equal” may include the following:
[0060] When a device is started or joins a network, it is assigned a role based on its function and network configuration. For example, some devices may be preset as the "center" or "key" node of the network, responsible for maintaining the integrity and stability of the network, and these devices have a higher priority to become the initiator of the network.
[0061] Based on the results of the network status assessment, the device can dynamically adjust its role. For example, if the searched device finds that its connection quality with the network has suddenly dropped, while the signal strength and connection stability of the searching device are relatively high, the searched device may actively transform into the initiator of the network to try to reestablish or optimize the network connection.
[0062] Devices can set role priorities, for example, the preset network "center" node has a higher priority for initiating networking. When the network status changes, the device will determine whether it should be the initiator of networking based on the role priority.
[0063] Use network protocols (such as Wi-Fi's 802.11k / v / r or Mesh network protocols) to support the exchange of role and status information between devices. For example, a device can include its role information and current network status when sending or receiving management frames, and the receiver can determine whether it should be the initiator of the network based on this information.
[0064] In some cases, devices may allow users to manually configure their roles and states to respond to specific network requirements or environmental changes. For example, if a user finds that network performance is poor, they may manually set a device as the initiator of networking to try to improve network conditions.
[0065] Through the above method, the device can intelligently determine whether it should be the initiator of networking to optimize the network recovery and reconstruction process, thereby not only improving the stability and performance of the network, but also enhancing the adaptability and intelligence of the device in the network.
[0066] In this embodiment, a method for establishing a connection relationship is provided, which is applied to a searched device. The searched device may be a device other than the book searching device in the above terminal device. Figure 3 : is a flow chart (II) of a method for establishing a connection relationship according to an embodiment of the present application, and the flow includes the following steps:
[0067] Step S302: receiving a broadcast packet sent by a searching device on a channel where the searched device is located;
[0068] Step S304: parsing the broadcast packet to obtain the initial channel information of the search device carried in the broadcast packet;
[0069] Step S306: Switch the channel of the searched device to the initial channel, and periodically send response packets on the initial channel so that the searching device establishes a connection relationship between the searching device and the searched device according to the response packets, wherein the initial channel is the channel corresponding to the initial channel information.
[0070] Through the above steps, the broadcast packet sent by the search device on the channel where the searched device is located is received; the broadcast packet is parsed to obtain the initial channel information of the search device carried in the broadcast packet; the channel of the searched device is switched to the initial channel, and a response packet is periodically sent on the initial channel, so that the search device establishes a connection relationship between the search device and the searched device according to the response packet, wherein the initial channel is the channel corresponding to the initial channel information; in the embodiment of the present application, the searched party stays in its initial channel to listen to the broadcast packet of the search party, and will not actively listen to each channel. After receiving the broadcast packet, the searched party switches to the initial channel of the search party to send a response packet. After sending the request broadcast packet, it will return to its initial channel to wait for a period of time (for receiving the reply of the searched party), and then go to the next channel to continue sending the request packet. This ensures that the searched party can efficiently receive the request of the search party, reduces unnecessary channel switching time, and adopts the above technical solution to solve the problem of too long search mechanism.
[0071] In an exemplary embodiment, periodically sending a response packet on the initial channel includes: obtaining interference information and a transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, a signal-to-interference ratio; inputting the interference information and the transmission rate into a second preset model so that the second preset model outputs a cycle duration, wherein the second preset model is trained by machine learning using multiple groups of second data, and each group of the multiple groups of second data includes: sample interference information and a sample transmission rate, and a cycle duration corresponding to the sample interference information and the sample transmission rate; and periodically sending a response packet on the initial channel according to the cycle duration.
[0072] In the embodiment of the present application, before sending a response packet, the searched device will first obtain the interference information and transmission rate of the current initial channel. Interference information includes background noise, signal-to-interference ratio, etc., which reflect the signal quality and environmental conditions of the channel; while the transmission rate evaluates the data transmission capacity of the channel. The purpose of collecting this information is to better evaluate the communication environment of the current channel, so as to provide data support for optimizing the response packet sending strategy.
[0073] The searched device inputs the obtained interference information and transmission rate into the second preset model. The model is trained by multiple sets of second data, each set of data containing sample interference information, sample transmission rate and the corresponding optimal cycle duration. Through the machine learning algorithm, the model can learn the most suitable response packet sending cycle under different interference and transmission rate conditions.
[0074] Based on the input current channel conditions, the second preset model will output a cycle duration, suggesting that the searched device periodically send response packets on the initial channel with this duration. This cycle duration is dynamically adjusted, which means that it will change according to changes in the channel environment to ensure that the response packets are sent neither too frequently, resulting in a waste of channel resources, nor too sparsely, causing the search device to wait for a long time.
[0075] Finally, the searched device will follow the cycle duration output by the model and send response packets regularly on the initial channel.
[0076] In the embodiment of the present application, the sending period of the response packet is dynamically adjusted through a machine learning model, so that the searched device can better adapt to the interference and transmission conditions of the current channel, and improve the success rate of receiving the response packet. It avoids excessive sending of response packets when the channel environment is not good, reduces the waste of network resources, and maintains the sending frequency of response packets when the channel environment is good, thereby improving the search efficiency. The dynamically adjusted cycle length can reduce the loss or delay of response packets caused by changes in the channel environment, and improve the stability and reliability of the wireless network connection.
[0077] In an exemplary embodiment, before periodically sending a response packet on the initial channel, the method further includes: determining a second networking preference value of the searched device carried in the broadcast packet, and determining a first networking preference value of the searching device; determining a first size relationship between the first networking preference value and the second networking preference value; and establishing a connection relationship between the searching device and the searched device based on the first size relationship.
[0078] In order to better understand the process of establishing the above-mentioned connection relationship, the implementation method flow of establishing the above-mentioned connection relationship is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present application.
[0079] The process of establishing the connection relationship in the prior art is as follows: Figure 4 As shown, Figure 4 is a timing diagram of a method for establishing a connection relationship in the related art, such as Figure 4 As shown, the specific steps are as follows:
[0080] Step 1: The searcher starts a management frame search;
[0081] Step 2: The searched party starts management frame search monitoring;
[0082] Step 3: The searcher switches to channel 1;
[0083] Step 4: The searcher sends a broadcast packet and waits;
[0084] Step 5: The searcher switches to the channel searcher channel;
[0085] Step 6: The searcher works on the channel searcher channel;
[0086] Step 7: The searcher switches to channel 6;
[0087] Step 8: The searcher sends a broadcast packet and waits;
[0088] Step 9: The searcher switches to the channel searcher channel;
[0089] Step 10: The searcher works on the channel searcher channel;
[0090] Step 11: The searcher switches to the channel of the searched party;
[0091] Step 12: The searcher sends a broadcast packet and waits;
[0092] Step 13: The searched party receives the broadcast packet and sends a corresponding response packet;
[0093] Step 14: The searcher receives the response packet;
[0094] Step 15: The searcher stops the management frame search;
[0095] Step 16: The searcher switches to the channel searcher channel.
[0096] That is, in the related art, first, the searcher will send a broadcast request packet on a certain channel and stay on the channel for a period of time to wait for the response packet returned by the searched party. If the searched party happens to be within the range of the channel, it will send a unicast response packet. At this time, if the searcher still stays on the current channel and does not leave, it can successfully receive the response packet and stop further management frame search operations. However, if the searched party is not on the channel, the searcher will leave the channel and return to its initial channel after waiting for a preset time. Subsequently, the searcher will switch to the next channel, send a broadcast request packet again, and repeat this process until it receives the response packet from the searched party.
[0097] Therefore, the traditional management frame search mechanism may cause long communication interruptions between devices due to the long search process. Such long interruptions not only affect the overall performance of the wireless network, but may also cause problems such as data loss and service delays.
[0098] In this embodiment, a method for establishing a connection relationship is provided. Figure 5 is a timing diagram of a method for establishing a connection relationship according to an embodiment of the present application, such as Figure 5 As shown, the specific steps are as follows:
[0099] Step 1: The searcher starts a management frame search;
[0100] Step 2: The searched party starts management frame search monitoring;
[0101] Step 3: The searcher switches to channel 1;
[0102] Step 4: The searcher sends a broadcast packet;
[0103] Step 5: The searcher switches to the channel searcher channel;
[0104] Step 6: The searcher works and waits on the channel searcher channel;
[0105] Step 7: The searcher switches to channel 6;
[0106] Step 8: The searcher sends a broadcast packet;
[0107] Step 9: The searcher switches to the channel searcher channel;
[0108] Step 10: The searcher works and waits on the channel searcher channel;
[0109] Step 11: The searcher switches to the channel of the searched party;
[0110] Step 12: The searcher sends a broadcast packet;
[0111] Step 13: The searcher switches to the channel searcher channel;
[0112] Step 14: The searcher works and waits on the channel searcher channel;
[0113] Step 15: The searched party receives the broadcast packet;
[0114] Step 16: The searched party switches to the searcher channel and sends a corresponding response packet;
[0115] Step 17: The searcher receives the response packet;
[0116] Step 18: The searcher stops the management frame search.
[0117] In the embodiment of the present application, after the management frame search is started, since the searcher and the searched party do not know the channel on which the other party is located, the searcher will poll and send broadcast packets on each channel to establish communication between the two parties. After sending each broadcast packet, the searcher will immediately return to its initial channel and wait for the reply from the searched party. This mechanism ensures that the searcher can receive the response from the searched party in a timely manner while sending a request, and will not fail to receive a reply because the two parties are not on the same channel, thereby reducing the search time;
[0118] The searched party stays in its initial channel to listen to the searcher's broadcast packets, and will not actively go to each channel to listen. After the searcher sends the request broadcast packet, it will return to its initial channel to wait for a while (to receive the searched party's reply), and then go to the next channel to continue sending request packets. This mechanism ensures that the searched party can efficiently receive the searcher's request and reduces unnecessary channel switching time;
[0119] When the searcher sends a broadcast packet, it will carry its initial channel information. When the searched party receives the searcher's broadcast packet on its initial channel, it will go to the channel notified by the searcher to send a response packet. At the same time, the searched party will determine whether it needs to re-network to ensure the stability and reliability of the network; dynamically adjust the search parameters such as scanning interval and channel dwell time according to the actual communication situation to adapt to different network environments, further improving the search efficiency and communication recovery speed.
[0120] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.
[0121] Figure 6 1 is a structural block diagram of a device for establishing a connection relationship according to an embodiment of the present application (I); Figure 6 As shown, it is applied to search equipment, including:
[0122] The sending module 62 is used to perform a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device;
[0123] A first determination module 64 is used to switch the channel of the search device to an initial channel and determine whether a response packet sent by the search device is received within a preset time period, wherein the initial channel is a channel corresponding to the initial channel information;
[0124] A second determining module 66 is used to loop through the sending step if no response packet sent by the searched device is received within a preset time period until a response packet sent by the searched device is received;
[0125] The establishing module 68 is used to establish a connection relationship between the searching device and the searched device according to the response packet.
[0126] Through the above device, a sending step is performed: a broadcast packet is sent on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2...M in sequence, and M is the number of channels corresponding to the search device; a determining step is performed: the channel of the search device is switched to the initial channel, and it is determined whether a response packet sent by the searched device is received within a preset time length, wherein the initial channel is the channel corresponding to the initial channel information; if the response packet sent by the searched device is not received within the preset time length, the sending step and the determining step are executed repeatedly until the response packet sent by the searched device is received; a connection relationship between the search device and the searched device is established according to the response packet; in the embodiment of the present application, the search device will poll and send broadcast packets on each channel to establish communication between the two parties. After sending each broadcast packet, the search device will immediately return to its initial channel and wait for a reply from the searched device. This ensures that the searching device can receive the response of the searched device in time while sending the request, and will not fail to receive a reply because both parties are not on the same channel, thereby reducing the search time. The above technical solution solves the problem of the search mechanism taking too long.
[0127] In an exemplary embodiment, the second determination module 66 is used to obtain the interference information and transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, signal-to-interference ratio; the interference information and the transmission rate are input into a first preset model so that the first preset model outputs the preset duration, wherein the first preset model is trained by machine learning using multiple groups of first data, and each group of first data in the multiple groups of first data includes: sample interference information and sample transmission rate, and the duration corresponding to the sample interference information and the sample transmission rate.
[0128] In an exemplary embodiment, a module 68 is established to determine a first networking preference value of the searched device carried in the response packet, and to determine a second networking preference value of the search device; to determine a first size relationship between the first networking preference value and the second networking preference value; and to establish a connection relationship between the search device and the searched device based on the first size relationship.
[0129] In an exemplary embodiment, a module 68 is established to send a first networking request to the searched device to establish a connection relationship between the search device and the searched device when the first size relationship indicates that the first networking preference value is greater than the second networking preference value; and to receive a second networking request sent by the searched device to establish a connection relationship between the search device and the searched device when the first size relationship indicates that the first networking preference value is less than or equal to the second networking preference value.
[0130] Figure 7 is a structural block diagram of a device for establishing a connection relationship according to an embodiment of the present application (II); Figure 7 As shown, it is applied to the searched device, including:
[0131] A receiving module 72, configured to receive a broadcast packet sent by a searching device on a channel where the searched device is located;
[0132] A parsing module 74, configured to parse the broadcast packet to obtain initial channel information of the search device carried in the broadcast packet;
[0133] The sending module 76 is used to switch the channel of the searched device to the initial channel, and periodically send a response packet on the initial channel so that the searching device establishes a connection relationship between the searching device and the searched device according to the response packet, wherein the initial channel is the channel corresponding to the initial channel information.
[0134] In an exemplary embodiment, a sending module 76 is used to obtain interference information and a transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, signal-to-interference ratio; the interference information and the transmission rate are input into a second preset model so that the second preset model outputs a cycle duration, wherein the second preset model is trained by machine learning using multiple groups of second data, and each group of second data in the multiple groups of second data includes: sample interference information and sample transmission rate, and the cycle duration corresponding to the sample interference information and the sample transmission rate; a response packet is periodically sent on the initial channel according to the cycle duration.
[0135] In an exemplary embodiment, the above-mentioned device also includes: a determination module, used to determine the second networking preference value of the searched device carried in the broadcast packet, and determine the first networking preference value of the search device; determine a first size relationship between the first networking preference value and the second networking preference value; and establish a connection relationship between the search device and the searched device based on the first size relationship.
[0136] An embodiment of the present application further provides a storage medium, which includes a stored program, wherein the program executes any of the above methods when it is run.
[0137] Optionally, in this embodiment, the storage medium may be configured to store program codes for executing the following steps:
[0138] S1, executing a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device;
[0139] S2, executing a determination step: switching the channel of the search device to an initial channel, and determining whether a response packet sent by the search device is received within a preset time period, wherein the initial channel is a channel corresponding to the initial channel information;
[0140] S3, when no response packet sent by the searched device is received within a preset time period, the sending step and the determining step are executed in a loop until a response packet sent by the searched device is received;
[0141] A connection relationship between the searching device and the searched device is established according to the response packet.
[0142] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0143] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0144] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0145] S1, executing a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device;
[0146] S2, executing a determination step: switching the channel of the search device to an initial channel, and determining whether a response packet sent by the search device is received within a preset time period, wherein the initial channel is a channel corresponding to the initial channel information;
[0147] S3, when no response packet sent by the searched device is received within a preset time period, the sending step and the determining step are executed in a loop until a response packet sent by the searched device is received;
[0148] A connection relationship between the searching device and the searched device is established according to the response packet.
[0149] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0150] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.
[0151] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.
[0152] The embodiments of the present application also provide a computer program, which 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 performs the steps in any one of the above method embodiments.
[0153] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0154] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0155] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for establishing a connection relationship, characterized in that: Applicable to search devices, including: Execute a sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device; Execute a determination step: switch the channel of the search device to an initial channel, and determine whether a response packet sent by the search device is received within a preset time, wherein the initial channel is a channel corresponding to the initial channel information; If no response packet sent by the searched device is received within a preset time period, the sending step and the determining step are executed in a loop until a response packet sent by the searched device is received; A connection relationship between the searching device and the searched device is established according to the response packet.
2. The method for establishing a connection relationship according to claim 1, characterized in that: Establishing a connection relationship between the searching device and the searched device according to the response packet includes: Determine a first network preference value of the searched device carried in the response packet, and determine a second network preference value of the search device; Determine a first magnitude relationship between the first networking preference value and the second networking preference value; A connection relationship between the searching device and the searched device is established according to the first size relationship.
3. The method for establishing a connection relationship according to claim 2, characterized in that: Establishing a connection relationship between the searching device and the searched device according to the response packet includes: When the first size relationship indicates that the first networking preference value is greater than the second networking preference value, sending a first networking request to the searched device to establish a connection relationship between the search device and the searched device; When the first size relationship indicates that the first networking preference value is less than or equal to the second networking preference value, a second networking request sent by the searched device is received to establish a connection relationship between the search device and the searched device.
4. The method for establishing a connection relationship according to claim 1, characterized in that: Before determining whether a response packet sent by the search device is received within a preset time period, the method further includes: Obtain interference information and transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, signal-to-interference ratio; The interference information and the transmission rate are input into a first preset model so that the first preset model outputs the preset duration, wherein the first preset model is trained through machine learning using multiple groups of first data, and each group of first data in the multiple groups of first data includes: sample interference information and sample transmission rate, and the duration corresponding to the sample interference information and the sample transmission rate.
5. A method for establishing a connection relationship, characterized in that: Applicable to the searched device, including: receiving a broadcast packet sent by a searching device on a channel where the searched device is located; Parsing the broadcast packet to obtain initial channel information of the search device carried in the broadcast packet; Switch the channel of the searched device to the initial channel, and periodically send a response packet on the initial channel, so that the searching device establishes a connection relationship between the searching device and the searched device according to the response packet, wherein the initial channel is a channel corresponding to the initial channel information.
6. The method for establishing a connection relationship according to claim 5, characterized in that: Periodically sending a response packet on the initial channel, including: Obtain interference information and transmission rate of the initial channel, wherein the interference information includes at least one of the following: background noise, signal-to-interference ratio; Inputting the interference information and the transmission rate into a second preset model so that the second preset model outputs a cycle duration, wherein the second preset model is trained by machine learning using multiple sets of second data, and each set of second data in the multiple sets of second data includes: sample interference information and a sample transmission rate, and a cycle duration corresponding to the sample interference information and the sample transmission rate; A response packet is periodically sent on the initial channel according to the period duration.
7. The method for establishing a connection relationship according to claim 5, characterized in that: Before periodically sending the response packet on the initial channel, the method further includes: Determine a second network preference value of the searched device carried in the broadcast packet, and determine a first network preference value of the search device; Determine a first magnitude relationship between the first networking preference value and the second networking preference value; A connection relationship between the searching device and the searched device is established according to the first size relationship.
8. A device for establishing a connection relationship, characterized in that: Applicable to search devices, including: A sending module, used to execute the sending step: sending a broadcast packet on the Nth channel, wherein the broadcast packet carries the initial channel information of the search device, wherein N is 1, 2, ..., M in sequence, and M is the number of channels corresponding to the search device; A first determination module is used to switch the channel of the search device to an initial channel and determine whether a response packet sent by the search device is received within a preset time period, wherein the initial channel is a channel corresponding to the initial channel information; The second determining module is used to loop the sending step until a response packet sent by the searched device is received if no response packet sent by the searched device is received within a preset time period; the establishing module is used to establish a connection relationship between the searching device and the searched device according to the response packet.
9. A device for establishing a connection relationship, characterized in that: Applicable to the searched device, including: A receiving module, configured to receive a broadcast packet sent by a searching device on a channel where the searching device is located; a parsing module, configured to parse the broadcast packet to obtain initial channel information of the searching device carried in the broadcast packet; A sending module is used to switch the channel of the searched device to an initial channel, and periodically send a response packet on the initial channel so that the searching device establishes a connection relationship between the searching device and the searched device according to the response packet, wherein the initial channel is a channel corresponding to the initial channel information.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 7 when executed.