Data transmission method and device based on WiFi networking, equipment and medium
Patent Information
- Application Number
- CN202611335878.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而,由于网络拓扑的动态变化以及节点间路由选择的自主性,现有Mesh网络中难以对数据传输的跳转路径进行清晰、稳定的定义
[0014]在该技术方案中,可以避免两个节点相互连接对方AP模块,造成死循环问题。
Smart Images

Figure CN123021286A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of wireless network technology, and in particular to a data transmission method, apparatus, device and medium based on WiFi networking. Background Technology
[0002] With the rapid development of wireless communication technology, the flexibility and reliability of network architecture have become increasingly important. Wireless mesh networks (Mesh networks), as an emerging decentralized wireless network structure, have attracted widespread attention. Each node in a Mesh network can communicate directly with other nodes and transmit data to its destination via multiple paths. Unlike traditional star or mesh networks, each node in a Mesh network can act as a repeater, helping to transmit data to other nodes in the network, thereby improving network reliability and coverage. This unique network structure endows Mesh networks with high flexibility, reliability, and scalability, making them particularly suitable for building distributed, robust communication systems, demonstrating great potential in scenarios such as smart homes, industrial IoT, emergency communications, and applications requiring wide-area coverage.
[0003] However, due to the dynamic changes in network topology and the autonomy of routing choices between nodes, it is difficult to clearly and stably define the hop paths for data transmission in existing mesh networks. This uncertainty in paths leads to poor predictability of data transmission delays. Summary of the Invention
[0004] This application discloses a data transmission method, apparatus, device, and medium based on WiFi networking, which can clearly define the data transmission hop path in a Mesh network, and is conducive to more accurate prediction of data transmission latency.
[0005] In a first aspect, embodiments of this application provide a data transmission method based on WiFi networking. This method can be applied to a first node in a Mesh network or a device matching the first node (such as a chip or processor placed inside the first node). The Mesh network includes multiple nodes, wherein each node includes a site module and an access point module. The site module of each node is used to access an existing subnet and join a corresponding multicast group, and the access point module of each node is used to create a subnet and join a corresponding multicast group. The subnet accessed by the site module of the same node and the subnet created by the access point module belong to different subnets in the Mesh network. The method includes: receiving data packets; determining the source subnet of the data packets, wherein the source subnet is a first subnet accessed by a first site module or a second subnet created by a first access point module; wherein the first site module is a site module of a first node, and the first access point module is an access point module of a first node; if the source subnet of the data packets is the first subnet, and the destination address of the data packets is different from the multicast address of a first multicast group, then the data packets are forwarded to the first access point module through the first site module, and then forwarded to the site module of a second node accessing the second subnet through the first access point module; wherein the first multicast group is a multicast group joined by the first site module; if the source subnet of the data packets is the second subnet, and the destination address of the data packets is different from the multicast address of the second multicast group, then the data packets are forwarded to the first site module through the first access point module, and then forwarded to the access point module of a third node and / or the site module of a fourth node accessing the first subnet through the first site module; wherein the third node is a node used to create the first subnet, and the second multicast group is a multicast group joined by the first access point module.
[0006] In this technical solution, the data transmission hop path can be clearly defined in the Mesh network, which helps to more accurately predict data transmission latency.
[0007] In one possible implementation, for each subnet in the Mesh network, the IP address of the access point module within the subnet is a preset IP address in the first IP address set, and the IP address of the site module within the subnet is any IP address in the second IP address set; wherein, the IP addresses in the first IP address set are used to allocate to nodes within the subnet, and the second IP address set includes other IP addresses in the first IP address set besides the preset IP addresses.
[0008] In one possible implementation, the IP address of the first site module is used to indicate the level to which the first site module belongs in the Mesh network.
[0009] In this technical solution, by adopting a multi-level IP address encoding rule, the level to which the STA module of a node belongs can be intuitively represented by the IP address.
[0010] In one possible implementation, access point modules belonging to different nodes at the same level in a mesh network have the same IP address; while site modules belonging to different nodes at the same level in a mesh network have different IP addresses.
[0011] In one possible implementation, the specific method for determining the source subnet of the data packet can be: determining the IP address of the previous node through which the data packet passed; if the IP address of the previous node belongs to the same network segment as the IP address of the first site module, then the source subnet of the data packet is determined to be the first subnet; if the IP address of the previous node belongs to the same network segment as the IP address of the first access point module, then the source subnet of the data packet is determined to be the second subnet.
[0012] In one possible implementation, a subnet in a Mesh network is a WiFi network created by the access point module of a node. The WiFi networks created by the access point modules of different nodes in the Mesh network have the same network parameters; among them, the network parameters include one or more of the following: network identifier, password, and channel.
[0013] In one possible implementation, the method further includes: enabling a site mode via a first site module and an access point mode via a first access point module; in access point mode, creating a WiFi network via the first access point module, wherein the WiFi network created by the first access point module is a second subnet; determining a node filtering set for a first node, wherein the node filtering set for the first node includes the physical identifiers of at least one node connected to the first access point module; the at least one node includes a second node but excludes a third node; in site mode, searching for wireless signals via the first site module, wherein the node filtering set for the first node is used to exclude wireless signals from at least one node during the search process; based on the search results, accessing the access point module of a third node via the first site module; wherein the search results are used to indicate the strongest wireless signal strength between the first node and the third node; and, upon successful access to the access point module of the third node, sending the physical identifier of the first node to the third node via the first site module, so that the third node adds the physical identifier of the first node to its node filtering set.
[0014] This technical solution avoids the problem of two nodes connecting to each other's AP modules, which could lead to a dead loop.
[0015] Secondly, embodiments of this application provide a data transmission device based on WiFi networking, which includes units for implementing the method described in the first aspect.
[0016] Thirdly, embodiments of this application provide an electronic device, including a communication interface and at least one processor; the at least one processor is configured to run a computer program or instructions to perform the method described in the first aspect. The communication interface can be used to implement the functions of a STA module and an AP module.
[0017] In one possible implementation, the electronic device may further include a memory connected to the at least one processor; the memory is used to store computer programs or instructions; the at least one processor is specifically used to retrieve the computer programs or instructions from the memory and run the computer programs or instructions to perform the method described in the first aspect.
[0018] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program or computer instructions, which, when executed, cause an electronic device to perform the method described in the first aspect.
[0019] Fifthly, embodiments of this application provide a computer program product including a computer program or instructions, which, when executed on an electronic device, causes the electronic device to perform the method described in the first aspect. Attached Figure Description
[0020] Figure 1 This is a schematic diagram illustrating an application scenario applicable to an embodiment of this application; Figure 2 This is a flowchart illustrating a data transmission method based on WiFi networking provided in an embodiment of this application; Figure 3 This is a schematic diagram of a data packet transmission path provided in an embodiment of this application; Figure 4 This is provided by the embodiments of this application. Figure 1 A schematic diagram showing the IP addresses of the STA and AP modules of each node in the Mesh network. Figure 5 This is a schematic diagram of an IP address conflict provided in an embodiment of this application; Figure 6 This application provides a method for... Figure 5 The diagram shown is obtained after modifying the IP address. Figure 7 This is a schematic diagram illustrating how two nodes are interconnected via each other's AP modules, as provided in an embodiment of this application. Figure 8 This is a flowchart illustrating an exclusion method based on node physical identifiers provided in an embodiment of this application; Figure 9This is a schematic diagram of a scenario for an exclusion method based on node physical identifiers provided in an embodiment of this application; Figure 10 This is a schematic diagram of a data transmission device based on WiFi networking provided in an embodiment of this application; Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0021] The terms "first," "second," etc., used in the embodiments of this application are used to distinguish different objects, not to describe a specific order. "At least one" in the embodiments of this application refers to one or more, and "multiple" refers to two or more. "And / or" in the embodiments of this application describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B can be singular or plural.
[0022] In the embodiments of this application, "at least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent the following seven cases: a, b, c, a and b, a and c, b and c, a, b, and c. Each of a, b, and c can be an element or a set containing one or more elements.
[0023] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario applicable to an embodiment of this application. This application scenario may include multiple nodes used to build a mesh network. Figure 1 Taking a mesh network built with 14 nodes as an example, the 14 nodes are: node A (101), node B (102), node C (103), node D (104), node E (105), node F (106), node G (107), node H (108), node I (109), node J (110), node K (111), node L (112), node M (113), and node N (114). The connection relationship between the 14 nodes is as follows: Figure 1 As shown.
[0024] Each node used to build a mesh network can include a Station (STA) module and an Access Point (AP) module. The AP module can create subnets, broadcasting wireless signals and providing network access services for other nodes to connect to, thus extending the mesh network's coverage. The STA module can access existing subnets, allowing nodes to connect to other nodes (that have created the corresponding subnet) like ordinary wireless devices. Optionally, the STA module can also connect to other networks outside the mesh network (such as Wi-Fi networks). In other words, a node in a mesh network can act as a "hotspot" for other nodes to connect to, and also as a "client" to connect to other nodes or other networks. This dual role gives the mesh network strong self-organizing and self-healing capabilities.
[0025] In this embodiment, the subnet accessed by the STA module of the same node and the subnet created by the AP module belong to different subnets in the Mesh network. A subnet can be understood as a logically independent network segment created by the node's AP module, and this network segment has an independent IP address range. In this embodiment, the subnet accessed by the node's own STA module can be called the node's STA subnet, and the subnet created by the node's own AP module can be called the node's AP subnet.
[0026] In this embodiment, STA modules connected to different nodes within the same subnet are interconnected; that is, STA modules connected to different nodes within the same subnet can communicate directly. For example, Figure 1 As shown, both node B and node C are connected to the subnet created by node A's AP module through their own STA modules, and there is a connection between node B's STA module and node C's STA module. For example, Figure 1 As shown, both node D and node E are connected to the subnet created by the AP module of node B through their own STA modules. There is a connection between the STA module of node D and the STA module of node E.
[0027] In the embodiments of this application, each node used to build a Mesh network supports wireless network technology (i.e., WiFi) based on the IEEE 802.11 standard, and each node supports both STA mode and AP mode.
[0028] The Mesh networking in this embodiment does not require a dedicated Mesh protocol stack provided by a specific chip manufacturer. Each node can establish a corresponding subnet based on standard WiFi AP / STA communication capabilities, and forward data between the subnet accessed by the node's STA module and the subnet created by the AP module according to the networking and data forwarding rules stipulated in this embodiment. Therefore, even when different nodes use different WiFi chip platforms and all have corresponding AP / STA communication capabilities and implement the networking and data forwarding rules stipulated in this application, different nodes can still perform networking and data communication according to the above rules, thereby reducing the dependence of the networking scheme on a specific chip platform and improving the flexibility of hardware platform selection.
[0029] Taking a node in a mesh network as an example, this node operates in STA mode and can connect to the AP module of another node or to other networks via the STA module. When operating in AP mode, this node can broadcast signals via the AP module for other nodes to connect to. In this way, multiple nodes can form a mesh network based on WiFi. In this embodiment, each node in the mesh network can operate simultaneously in both AP and STA modes.
[0030] like Figure 1 As shown, nodes B and C are both connected to the AP module of node A through their own STA module, and the same applies to other nodes, which will not be elaborated here.
[0031] In one possible implementation, the STA module can be understood as the logical network interface card used by the node in STA mode, and the AP module can be understood as the logical network interface card used by the node in AP mode.
[0032] Taking the STA module, which allows nodes to connect to a WiFi network, as an example, in one possible implementation, Figure 1 The application scenarios shown can also include WiFi routers. For example... Figure 1 As shown, node A connects to the WiFi router via its own STA module to connect to the WiFi network.
[0033] In this embodiment, both the AP module and STA module of the same node have the ability to independently participate in multicast communication. Furthermore, the AP module of each node in the Mesh network can also be used to join corresponding multicast groups. That is, the AP module of each node in the Mesh network can not only provide wireless connectivity but also join one or more multicast groups as a member. The AP module receives multicast content by joining the corresponding multicast group.
[0034] In a mesh network, the STA module of each node can also be used to join corresponding multicast groups. This means that the STA module of each node in a mesh network can not only act as a "client" to connect to other nodes or other networks, but also join one or more multicast groups as a member. The STA module receives multicast content by joining the corresponding multicast group.
[0035] For example, taking a node in a Mesh network as an example, the STA module of the node can be used to join multicast group 1, and the AP module of the node can be used to join multicast group 2.
[0036] Multicast is a network data transmission method. Unlike unicast (one-to-one) and broadcast (one-to-all), multicast allows data packets to be sent to a specific group of devices in the network that have pre-registered their receiving interest (called a "multicast group"). Multicast can efficiently distribute the same data.
[0037] This application does not limit the form, number, or connection relationship of the nodes used to build a mesh network. For example, the form of the nodes used to build a mesh network may include, but is not limited to: mobile phones, computers, laptops, all-in-one computers, Internet of Things (IoT) devices, portable devices, wearable devices, or other devices.
[0038] It is understood that the application scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. Those skilled in the art will know that with the evolution of technology and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0039] The data transmission method based on WiFi networking proposed in this application embodiment is described below. This data transmission method based on WiFi networking can be executed by a first node, or by a device matched with the first node (such as a chip or processor located inside the first node). This application embodiment uses the execution of the data transmission method based on WiFi networking by the first node as an example for illustration. The first node can be... Figure 1 In the Mesh network shown, the STA module of the first node is called the first STA module, and the AP module of the first node is called the first AP module.
[0040] Please see Figure 2 , Figure 2 This is a flowchart illustrating a data transmission method based on WiFi networking, provided as an embodiment of this application. Figure 2 As shown, the data transmission method based on WiFi networking may include, but is not limited to, the following steps.
[0041] S201: The first node receives the data packet.
[0042] The first node can listen for data packets, receive the packets when they are detected, and execute S202. It continues listening when no data packets are detected.
[0043] The first node can listen to data packets from the first subnet (i.e., the subnet to which its own STA module is connected) and also listen to data packets from the second subnet (i.e., the subnet created by its own AP module).
[0044] In one possible implementation, the data packets monitored and received in this application embodiment can be data packets of a transport protocol that supports multicast. For example, the data packets monitored and received in this application embodiment can be User Datagram Protocol (UDP) data packets or data packets of other transport protocols that support multicast. In this application embodiment, each node can use data transmission protocols such as UDP to perform data communication according to the networking and data forwarding rules agreed upon in this application embodiment, thereby helping to reduce the dependence of the data transmission process on the dedicated Mesh communication mechanism provided by a specific WiFi chip platform. Among them, UDP supports broadcast and multicast. UDP is a simple, connectionless transport layer protocol that sits above the IP protocol. Compared with the Transmission Control Protocol (TCP), UDP provides a more lightweight data transmission service, does not guarantee the reliability and order of data, but has lower latency and overhead.
[0045] S202: The first node determines the source subnet of the data packet. The source subnet is either the first subnet accessed by the first STA module or the second subnet created by the first AP module.
[0046] After receiving a data packet, the first node can determine the source subnet of the packet. That is, it can determine whether the data packet comes from the first subnet or the second subnet, or more specifically, whether the data packet comes from the subnet accessed by the first node's own STA module or from the subnet created by the first node's own AP module. As mentioned above, the subnet accessed by the STA module of the same node and the subnet created by the AP module belong to different subnets in the Mesh network. Therefore, the first subnet and the second subnet are different subnets.
[0047] If the data packet originates from the first subnet, the first node can execute S203. If the data packet originates from the second subnet, the first node can execute S204.
[0048] In one possible implementation, the first node determines the source subnet of the data packet by: determining the IP address of the previous node the data packet passed through; if the IP address of the previous node belongs to the same network segment as the IP address of the first STA module, then the source subnet of the data packet is determined to be the first subnet; if the IP address of the previous node belongs to the same network segment as the IP address of the first AP module, then the source subnet of the data packet is determined to be the second subnet. After determining the IP address of the previous node the data packet passed through, the first node can use the subnet mask to distinguish whether the IP address belongs to the same network segment as the IP address of the first STA module or the IP address of the first AP module.
[0049] In one possible implementation, the IP address corresponding to each subnet in the mesh network can include a network address, a broadcast address, and a series of IP addresses that can be used by nodes within that subnet. The network address and broadcast address have special uses within the subnet and cannot be assigned to nodes within that subnet. Each subnet in the mesh network corresponds to a first set of IP addresses, which includes a series of IP addresses that can be used by nodes within that subnet.
[0050] In one possible implementation, for each subnet in the Mesh network, the IP address of the AP module within the subnet is a preset IP address from a first set of IP addresses, and the IP address of the STA module within the subnet is any IP address from a second set of IP addresses; wherein, the second set of IP addresses includes all IP addresses in the first set of IP addresses except for the preset IP addresses. In other words, for each subnet in the Mesh network, the IP address of the AP module within the subnet is a specific IP address from the first set of IP addresses corresponding to that subnet, while the IP address of the STA module within the subnet is any IP address from the first set of IP addresses corresponding to that subnet except for the specific IP address.
[0051] In one possible implementation, the preset IP address (specific IP address) can be fixed to the first IP address in the first IP address set corresponding to the subnet, and the IP address of the STA module in the subnet can be any IP address other than the first IP address in the first IP address set corresponding to the subnet. The IP address of the STA module can be randomly assigned.
[0052] Taking a subnet whose first set of IP addresses includes the following IP addresses: 192.168.1.1, 192.168.1.2, ..., 192.168.1.254, as an example, the default IP address could be 192.168.1.1. Taking a subnet whose first set of IP addresses includes the following IP addresses: 192.168.2.1, 192.168.2.2, ..., 192.168.2.254, as an example, the default IP address could be 192.168.2.1.
[0053] S203: If the destination address of the data packet is different from the multicast address of the first multicast group, the first node forwards the data packet to the first AP module through the first STA module, and then forwards the data packet to the STA module of the second node accessing the second subnet through the first AP module; wherein, the first multicast group is the multicast group joined by the first STA module.
[0054] The destination address of the data packet is the address used for multicast. Taking an IPv4 network as an example, the address used for multicast can be a Class D address, which is used to identify a multicast group.
[0055] If the first node determines that the data packet originates from the first subnet, it can also determine whether the packet's destination address differs from the multicast address of the first multicast group. If the packet's destination address matches the first multicast group's address, it means the packet is intended for a member of the first multicast group, and the first node can parse and process the packet at the application layer. If the packet's destination address differs from the first multicast group's address, it means the packet is not intended for a member of the first multicast group, and the first node needs to forward the packet to other nodes.
[0056] The data packet is transmitted via multicast within the first subnet. Since the STA module of the first node has received the data packet, it indicates that other nodes connected to the first subnet have also received it. Therefore, the first node does not need to forward the data packet to the first subnet, but rather needs to forward it to another subnet (i.e., the second subnet). Because the AP module and STA module of the first node do not belong to the same subnet, the AP module of the first node cannot receive the data packet through the first subnet and needs to forward it through the STA module. The first node forwards the data packet to the first AP module through the first STA module. Furthermore, the first AP module can forward the data packet to the second subnet. Specifically, the first AP module can forward the data packet to the STA module of the second node connected to the second subnet. The second node can include all or some of the nodes connected to the second subnet.
[0057] Taking the first node as Figure 1 Taking node H as an example, and the first subnet being a subnet created by the AP module of node D, assuming that the AP module of node D sends data packet 'a' to the STA module of node H, and the destination address of data packet 'a' is different from the multicast address of the first multicast group, the STA module of node H can forward data packet 'a' to the AP module of node H. Furthermore, the AP module of node H can forward data packet 'a' to the STA modules of nodes K and L. In this case, the second node includes nodes K and L.
[0058] S204: If the destination address of the data packet is different from the multicast address of the second multicast group, the first node forwards the data packet to the first STA module through the first AP module, and forwards the data packet to the AP module of the third node and / or the STA module of the fourth node connected to the first subnet through the first STA module; wherein, the third node is the node used to create the first subnet, and the second multicast group is the multicast group joined by the first AP module.
[0059] If the first node determines that the data packet originates from the second subnet, it can also determine whether the packet's destination address differs from the multicast address of the second multicast group. If the packet's destination address matches the second multicast group's address, it means the packet is intended for a member of the second multicast group, and the first node can parse and process the packet at the application layer. If the packet's destination address differs from the second multicast group's address, it means the packet is not intended for a member of the second multicast group, and the first node needs to forward the packet to other nodes.
[0060] The data packet is transmitted via multicast within the second subnet. Since the AP module of the first node received the data packet, it indicates that other nodes connected to the second subnet also received it. Therefore, the first node does not need to forward the data packet to the second subnet, but rather to another subnet (i.e., the first subnet). Because the STA module and AP module of the first node are not in the same subnet, the STA module of the first node cannot receive the data packet through the second subnet and needs to forward it through the AP module of the first node. The first node forwards the data packet to the first STA module through the first AP module. Furthermore, the first STA module can forward the data packet to the first subnet. Specifically, the first STA module can forward the data packet to: the AP module of the node used to create the first subnet (i.e., the third node), and / or the STA module of the fourth node connected to the first subnet. The fourth node can include all or some of the nodes connected to the first subnet other than the first node. The forwarding process from the first STA module to the STA module of the fourth node is a forwarding process within the same subnet and can be sent point-to-point via the LAN UDP protocol.
[0061] Taking the first node as Figure 1 Taking node B as an example, and the second subnet being a subnet created by the AP module of node B, assuming that the STA module of node D sends data packet b to the AP module of node B, and the destination address of data packet b is different from the multicast address of the second multicast group, the AP module of node B can forward data packet b to the STA module of node B. Furthermore, the STA module of node B can forward data packet b to the AP module of node A and the STA module of node C. In this case, the third node is node A, and the fourth node includes node C.
[0062] Based on the original sending node of the data packet Figure 1 Node L in the data packet, and the target receiving node of the data packet is Figure 1 Taking node I as an example, the transmission path of this data packet can be as follows: Figure 3 As shown, Figure 3 The transmission path of the data packet is indicated by a bold dashed line.
[0063] As can be seen, the embodiments of this application clearly define the data transmission path in a mesh network, which is beneficial for more accurate prediction of data transmission latency. Furthermore, by employing the UDP multicast protocol for data transmission, the embodiments of this application ensure that data is simultaneously delivered to multiple nodes in the mesh network, enabling interconnection and communication between multiple nodes in the mesh network. Moreover, data transmission can be achieved through multiple paths, which helps improve the reliability of data transmission.
[0064] In one possible implementation, Figure 1 The mesh network shown can be created layer by layer, for example, Figure 1 After node A connects to the WiFi router via its own STA module, node A can create a subnet (e.g., subnet 1) through its own AP module. At this point, the Layer 0 subnet of the Mesh network is created. Then, Figure 1 After node B connects to subnet 1 via its own STA module, node B can create a subnet (such as subnet 2) through its own AP module. Meanwhile, Figure 1 After node C connects to subnet 1 via its STA module, node C can create a subnet (e.g., subnet 3) using its AP module. At this point, the first layer of the mesh network is created. Similarly, after the fourth layer of the mesh network is created, the desired subnet is achieved. Figure 1 The diagram shows a mesh network resembling a tree structure. As mentioned earlier, after multiple nodes form a mesh network through their own STA and AP modules, the UDP multicast protocol can be used to enable data transmission between the subnets within the mesh network.
[0065] In one possible implementation, the IP address of the first STA module can be used to indicate the level to which the first STA module belongs in the Mesh network, and can also be used to uniquely identify the first STA module.
[0066] For example, Figure 1 The IP addresses of the STA and AP modules of each node in the shown Mesh network can be as follows: Figure 4 As shown. Figure 4 In the example, the IP address of the STA module of node B is 192.168.1.4, and the IP address of the STA module of node C is 192.168.1.5, which are used to indicate that the STA modules of node B and node C belong to the first layer of the Mesh network. Figure 4 In the example, the IP address of the STA module of node D is 192.168.2.2, and the IP address of the STA module of node E is 192.168.2.3, which indicates that the STA modules of node D and node E belong to the second layer of the Mesh network. Figure 4 In the diagram, the IP address of the STA module of node A is x, indicating that the IP address of the STA module of node A is assigned by the WiFi router.
[0067] By employing a multi-level IP address encoding rule, the level to which a node's STA module belongs can be intuitively represented by its IP address. It's important to note that each IP address in the hierarchical address represents the IP address of a node's STA module, not the IP address of that node's AP module. It should also be noted that... Figure 4 The IP addresses of the nodes in the illustrated mesh network are for illustrative purposes only. In a real implementation, the IP addresses can be... Figure 4 The results are different.
[0068] In one possible implementation, the statement described above that "the subnet accessed by the STA module of the same node and the subnet created by the AP module belong to different subnets in the Mesh network" can also be understood as: the subnet accessed by the STA module of the same node and the subnet created by the AP module belong to different levels of subnets, and subnets of different levels are allocated in different network segments, that is, the IP addresses of the STA module and the AP module of the same node belong to different network segments.
[0069] IP address conflicts can be avoided by dividing IP address segments into hierarchical segments. An IP address conflict can occur when the IP address of a STA module on the same node is in the same network segment as the IP address of an AP module. This can lead to the STA module's IP address being identical to the IP address of a STA module on another node in a subnet connected to the AP module on that node. A diagram illustrating an IP address conflict can be shown below. Figure 5 As shown, Figure 5 If the IP address of the STA module of node a is 192.168.5.2, and the IP address of the STA module of node b is also 192.168.5.2, then when device a sends data to the STA module of device b through its AP module, the AP module of device a may mistakenly identify 192.168.5.2 as its own address, leading to data transmission failure. By dividing IP address ranges hierarchically, IP address conflicts can be avoided. Figure 5 After modifying the IP address shown, you can get Figure 6 The diagram shown is as follows. Figure 6 As shown, the IP address of the STA module of node a is in a different network segment than the IP address of the AP module, which avoids IP address conflicts.
[0070] In one possible implementation, within a mesh network, AP modules belonging to different nodes at the same level share the same IP address. For example... Figure 4 As shown, the IP address of the AP modules of nodes B and C, both belonging to Layer 1, is 192.168.2.1. In one possible implementation, in a mesh network, the IP addresses of the STA modules of different nodes belonging to the same layer are different. For example... Figure 4 As shown, the IP addresses of the STA modules of nodes B and C, which both belong to the first layer, are different. The IP address of the STA module of node B is 192.168.1.4, and the IP address of the STA module of node C is 192.168.1.5.
[0071] In one possible implementation, a subnet within a mesh network is a WiFi network created by the AP module of a single node. The network parameters of the WiFi networks created by the AP modules of different nodes in the mesh network are identical. These network parameters can include, but are not limited to, one or more of the following: network identifier, password, and channel. In other words, all nodes in the mesh network can use the same network parameters in AP mode. The network identifier can be a Service Set Identifier (SSID) or an Extended Service Set Identifier (ESSID). The SSID is the identifier for the WLAN network, used to distinguish different WLAN networks. The ESSID is an abstract concept, representing the common wireless network name shared by multiple wireless routers.
[0072] In one possible implementation, all nodes in the Mesh network, in STA mode, can actively scan all nearby access points (APs) and record the wireless signal strength between themselves and each AP. Then, in STA mode, all nodes in the Mesh network can connect to an AP based on their recorded wireless signal strength. In another possible implementation, nodes can choose to connect to the AP with the strongest wireless signal, which helps improve data transmission efficiency and reduce transmission latency. The wireless signal strength can be characterized by a Received Signal Strength Indicator (RSSI) or other parameters.
[0073] In one possible implementation, within a mesh network, two nodes might connect to each other's access points (APs), potentially causing an infinite loop. A diagram illustrating this connection could be shown below. Figure 7 As shown. Figure 7 As shown, node a connects to node b's AP module via the STA module, and node b connects to node a's AP module via the STA module.
[0074] To address this issue, this application employs an exclusion method based on node physical identifiers. Please refer to [link / reference]. Figure 8 , Figure 8 This is a flowchart illustrating the exclusion method based on node physical identifiers. This embodiment of the application uses the example of the exclusion method being executed by the first node. The exclusion method based on node physical identifiers may include, but is not limited to, the following steps: S801: The first node starts STA mode through the first STA module and starts AP mode through the first AP module.
[0075] When the first node powers on, it can begin executing the initialization process. This initialization process may include initializing the WiFi module. Initializing the WiFi module may include simultaneously enabling STA mode and AP mode.
[0076] S802: When the first node is in AP mode, it creates a WiFi network through the first AP module. The WiFi network created by the first AP module is the second subnet.
[0077] For details regarding S802, please refer to the previous description; it will not be repeated here.
[0078] S803: The first node determines the node filtering set of the first node, which includes the physical identifiers of M nodes connected to the first AP module; wherein the M nodes include the second node but do not include the third node.
[0079] Where M is a positive integer.
[0080] After the first node creates a WiFi network, it can record the physical identifiers of M nodes that connect to its own AP module (i.e., the first AP module) and add the physical identifiers of the M nodes to the first node's node filter set. The first node's node filter set can include at least the physical identifier of the second node, but does not include the physical identifier of the third node.
[0081] A node's physical identifier is used to uniquely identify a node. In one possible implementation, the node's physical identifier may include, but is not limited to, the Basic Service Set Identifier (BSSID) and the Media Access Control (MAC) address. When nodes have the same SSID, different nodes can be distinguished by their BSSID.
[0082] In one possible implementation, the physical identifiers of the M nodes can be sent separately by each node to the first node; that is, the first node can receive its own physical identifier from each of the M nodes. For example, if the M nodes include node 1 and node 2, node 1 can send its physical identifier to the first node, and node 2 can send its physical identifier to the first node.
[0083] Taking the first node as Figure 7 Taking node b in the example, as Figure 7 As shown, node a connects to node b's AP module through the STA module. Therefore, node b's node filtering set includes node a's physical identifier (such as BSSID).
[0084] S804: In STA mode, the first node searches for wireless signals through the first STA module. The node filtering set of the first node is used to exclude wireless signals from M nodes during the search process.
[0085] The STA module of the first node (i.e., the first STA module) excludes wireless signals from M nodes during the search process. This means that when the first STA module connects to nearby APs, it filters and excludes APs from M nodes based on the node filtering set. In other words, the first STA module does not connect to AP modules from M nodes.
[0086] This method avoids the problem of two nodes connecting to each other's AP modules, which could cause a dead loop.
[0087] S805: Based on the search result, the first node accesses the AP module of the third node through the first STA module; wherein, the search result is used to indicate the strongest wireless signal strength between the first node and the third node.
[0088] The search result is used to record the wireless signal strength between the first node and other nodes attempting to connect, excluding the M nodes. Based on the search result, the first node can choose to connect to the AP of the node with the strongest wireless signal, which helps improve data transmission efficiency and reduce transmission latency. The wireless signal strength can be characterized by RSSI or other parameters.
[0089] A scenario illustration of the exclusion method based on node physical identifiers can be seen as follows: Figure 9 As shown, node a connects to node b's AP module via its STA module. Node a can send its BSSID to node b's AP module through its STA module. Node b adds node a's BSSID to its node filtering set. When node b's STA module connects to nearby APs, it filters and excludes node a's AP based on the node filtering set; that is, node b's STA module does not connect to node a's AP module. Node b's STA module connects to the AP module of node c, which has the strongest RSSI. In this case, the first node can be... Figure 9 In the context of node b, the second node can be... Figure 9 In the context of node 'a', the third node can be... Figure 9 Node c in the middle.
[0090] S806: When the first node successfully connects to the AP module of the third node, it sends the physical identifier of the first node to the third node through the first STA module, so that the third node adds the physical identifier of the first node to the node filtering set of the third node.
[0091] like Figure 9 As shown, when node b successfully connects to the AP module of node c, it sends the physical identifier (such as BSSID) of node b to the AP module of node c through the STA module. This allows node c to add the physical identifier of node b to the node filtering set of node c, thus preventing node c from connecting to the AP module of node b.
[0092] In one possible implementation, when the first node is a node in the Mesh network, it can store relevant attribute parameters, which may include, but are not limited to, the information shown in Table 1.
[0093] Table 1
[0094] In one possible implementation, when the first node acts as a node in the Mesh network and as an AP to implement the AP module function, the relevant attribute parameters it possesses may include, but are not limited to, the information shown in Table 2.
[0095] Table 2
[0096] In another possible implementation, when the first node acts as a node in the Mesh network and as an AP to implement the AP module function, the relevant attribute parameters it possesses may include, but are not limited to, the information shown in Table 3.
[0097] Table 3
[0098] In one possible implementation, when the first node acts as a node in the Mesh network and as an STA to implement the STA module function, the relevant attribute parameters it possesses may include, but are not limited to, the information shown in Table 4.
[0099] Table 4
[0100] In one possible implementation, the UDP packets transmitted in the Mesh network may include multicast packets and unicast packets. Multicast packets can be used for nodes to exchange their respective attribute parameters; the transmission period for multicast packets can be 10 seconds or other durations, which are not limited in this application. Unicast packets can be used by the STA module of a node to report information to the access AP module; the transmission period for unicast packets can be 10 seconds or other durations, which are not limited in this application.
[0101] In one possible implementation, the first node can multicast beacon frames to synchronize its information relative to the entire mesh network with other nodes. In this way, any node can obtain information about all nodes in the mesh network. The beacon frame is a periodically sent control frame.
[0102] In one possible implementation, UDP packets transmitted via multicast in a mesh network can be configured with a Time To Live (TTL) field. This prevents UDP packets from propagating indefinitely within the mesh network. The TTL is decremented by 1 each time the packet is forwarded through a node, and the packet is discarded when it reaches 0.
[0103] In one possible implementation, the first node can determine the TTL of its UDP packets based on the maximum number of nodes in the mesh network and / or the maximum network layer of the mesh network; alternatively, the first node can determine the TTL of its UDP packets based on the total number of nodes in the mesh network and / or the total network layer of the mesh network. This limits the number of times the UDP packet can be forwarded. The maximum number of nodes in the mesh network and the maximum network layer of the mesh network can be set by default or modified by the user.
[0104] In one possible implementation, the maximum number of nodes in a mesh network can be determined as follows: Assuming each node in a mesh network has at most C child nodes, and L represents the number of levels, then the maximum number of nodes in each level is as follows: Level 0 (root node): 1 node.
[0105] Level 1: C nodes.
[0106] Level 2: C 2 Each node.
[0107] Level L: C L Each node.
[0108] Therefore, the maximum number of nodes Z in a Mesh network is: Z = 1 + C + C 2 +C 3 +......C L The expression for the maximum number of nodes Z in a mesh network can be approximated as: ,in
[0109] In one possible implementation, the first node can encrypt the data packet using an encryption algorithm when generating the data packet.
[0110] This application does not limit the encryption algorithm. For example, the encryption algorithm may include AES (Advanced Encryption Standard) or other encryption algorithms. AES is a symmetric encryption algorithm, meaning that encryption and decryption use the same key. The steps for the first node to encrypt UDP packets using AES are as follows: S1: Generate a random AES key.
[0111] S2: Encrypt the data using the AES algorithm and AES key.
[0112] S3: Send the encrypted data via UDP. Correspondingly, other nodes, upon receiving the UDP data packets sent by the first node, can decrypt the UDP data packets using the same key and initialization vector.
[0113] Optionally, the first node can also generate an initialization vector and send the encrypted data and the initialization vector together via UDP. AES has several operating modes, such as ECB (Electronic Codebook), CBC (Cipher Block Chaining), and CTR (Counter). For CBC mode, an initialization vector is required. The initialization vector can be randomly generated and must remain consistent during encryption and decryption.
[0114] AES Block Size: AES is a block cipher algorithm where each block has a fixed size (e.g., 128 bits, or 16 bytes). Regardless of the length of the original data, the length of the encrypted data must be an integer multiple of the block size. The initialization vector is usually the same length as the block size.
[0115] If the length of the original data is not an integer multiple of the block size, the first node needs to be padded. Common padding methods include PKCS#7 padding, which adds extra bytes to the end of the data to make the data length meet the block size requirement. The length of the padding bytes depends on the length of the original data, but it will increase the size by at most one block size.
[0116] For example, suppose the original data is 20 bytes long and encrypted using AES in CBC mode. Since 20 bytes is not a multiple of 16 bytes, 12 bytes of padding are needed, making the total length 32 bytes. The initialization vector is 16 bytes, so the UDP packet length is 48 bytes, 28 bytes longer than the original data length.
[0117] Please see Figure 10 , Figure 10 This is a schematic diagram of a data transmission device based on WiFi networking provided in an embodiment of this application. Figure 10 As shown, the WiFi-based data transmission device 100 includes a communication unit 1001 and a processing unit 1002. The WiFi-based data transmission device 100 can execute the relevant steps of the first node in the aforementioned method embodiments.
[0118] Communication unit 1001 is used to receive data packets; The processing unit 1002 is used to determine the source subnet of the data packet, wherein the source subnet is either the first subnet accessed by the first site module or the second subnet created by the first access point module; wherein the first site module is the site module of the first node and the first access point module is the access point module of the first node. The communication unit 1001 is further configured to, if the source subnet of the data packet is the first subnet and the destination address of the data packet is different from the multicast address of the first multicast group, forward the data packet to the first access point module through the first site module, and forward the data packet to the site module of the second node accessing the second subnet through the first access point module; wherein, the first multicast group is the multicast group joined by the first site module. The communication unit 1001 is further configured to, if the source subnet of the data packet is the second subnet and the destination address of the data packet is different from the multicast address of the second multicast group, forward the data packet to the first site module through the first access point module, and forward the data packet to the access point module of the third node and / or the site module of the fourth node that is connected to the first subnet through the first site module; wherein, the third node is the node used to create the first subnet, and the second multicast group is the multicast group joined by the first access point module.
[0119] Specifically, in this case, the operations performed by the communication unit 1001 and the processing unit 1002 can be referred to the description of the first node in the foregoing method embodiments, and will not be repeated here.
[0120] Please see Figure 11 , Figure 11 This is a schematic diagram of the structure of an electronic device 110 provided in an embodiment of this application, which can be used to implement the function of the first node in the above method embodiment. The electronic device 110 may include at least one processor 1101 and a communication interface 1102. Optionally, the electronic device 110 may also include a memory 1103. Figure 11 The components shown by the dashed lines are optional components, meaning that electronic device 110 may not include them. Figure 11 The component shown by the dashed line.
[0121] At least one processor 1101, communication interface 1102, and memory 1103 can be connected via bus 1104 or other means. The bus is in... Figure 11 The connections between other components are shown in bold lines only and are not intended to be limiting. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, Figure 11 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0122] The coupling in this application embodiment is an indirect coupling or communication connection between devices, units, or modules, which can be electrical, mechanical, or other forms, used for information interaction between devices, units, or modules. This application embodiment does not limit the specific connection medium between the at least one processor 1101, communication interface 1102, and memory 1103.
[0123] The communication interface 1102 can be used to implement the functions of the STA module and the AP module.
[0124] Memory 1103 may include read-only memory and random access memory, and provides instructions and data to at least one processor 1101. A portion of memory 1103 may also include non-volatile random access memory.
[0125] At least one processor 1101 may be a Central Processing Unit (CPU), but it may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor; optionally, at least one processor 1101 may also be any conventional processor.
[0126] In one example, when the electronic device adopts Figure 11 When in the form shown, Figure 11 At least one processor 1101 in the above method embodiment can execute the method executed by the first node.
[0127] In one possible implementation, memory 1103 is used to store computer programs or instructions; at least one processor 1101 is used to invoke the computer programs or instructions stored in memory 1103 to perform the steps executed by the first node in the method embodiment.
[0128] In the embodiments of this application, the methods provided in the embodiments of this application can be implemented by running a computer program (including program code) capable of performing the steps involved in the above-described methods on a general-purpose computing device, such as a computer, which includes processing elements and storage elements such as a CPU, random access memory (RAM), and read-only memory (ROM). The computer program can be recorded on, for example, a computer-readable recording medium, loaded into an electronic device through the computer-readable recording medium, and run therein.
[0129] Based on the same inventive concept, the principles and beneficial effects of the devices and electronic devices provided in the embodiments of this application in solving the problem are similar to the principles and beneficial effects of solving the problem at the first node in the method embodiments of this application. Please refer to the principles and beneficial effects of the method embodiments. For the sake of brevity, they will not be repeated here.
[0130] This application also provides a computer-readable storage medium storing a computer program or computer instructions, which is adapted to be loaded by an electronic device and execute the method provided in the above-described method embodiments.
[0131] This application also provides a computer program product containing a computer program or instructions, which, when run on an electronic device, causes the electronic device to perform the method provided in the above-described method embodiments.
[0132] Regarding the modules / units included in the various devices and products described in the above embodiments, they can be software modules / units, hardware modules / units, or a combination of both. For example, for various devices and products applied to or integrated into a chip, all of their modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits; for various devices and products applied to or integrated into a chip module, all of their modules / units can be implemented using hardware methods such as circuits, and different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The implementation is achieved through a software program that runs on a processor integrated within the chip module. The remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into electronic devices, each of their modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components within the electronic device. Alternatively, at least some modules / units can be implemented using a software program that runs on a processor integrated within the electronic device, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits.
[0133] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0134] In the above embodiments, the descriptions of each embodiment have their own emphasis, and any multiple embodiments can be used in combination. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0135] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.
[0136] The modules in the device of this application embodiment can be merged, divided, and deleted according to actual needs.
[0137] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by program instructions and related hardware. The program instructions can be stored in a computer-readable storage medium, which may include: flash drive, ROM, RAM, disk or optical disk, etc.
[0138] The above-disclosed embodiments are merely one example of this application and only a part of the embodiments of this application. They should not be construed as limiting the scope of this application.
Claims
1. A data transmission method based on WiFi networking, characterized in that, The method is applied to a first node in a wireless mesh network, wherein the wireless mesh network includes multiple nodes, wherein each node includes a station module and an access point module, the station module of each node is used to access an existing subnet and join a corresponding multicast group, and the access point module of each node is used to create a subnet and join a corresponding multicast group, wherein the subnet accessed by the station module of the same node and the subnet created by the access point module belong to different subnets in the wireless mesh network; the method includes: Receive data packets; The source subnet of the data packet is determined, wherein the source subnet is a first subnet accessed by the first site module or a second subnet created by the first access point module; wherein the first site module is the site module of the first node, and the first access point module is the access point module of the first node. If the source subnet of the data packet is the first subnet, and the destination address of the data packet is different from the multicast address of the first multicast group, then the data packet is forwarded to the first access point module through the first site module, and the data packet is forwarded to the site module of the second node accessing the second subnet through the first access point module; wherein, the first multicast group is the multicast group joined by the first site module. If the source subnet of the data packet is the second subnet, and the destination address of the data packet is different from the multicast address of the second multicast group, then the data packet is forwarded to the first site module through the first access point module, and the data packet is forwarded to the access point module of the third node and / or the site module of the fourth node connected to the first subnet through the first site module; wherein, the third node is the node used to create the first subnet, and the second multicast group is the multicast group joined by the first access point module.
2. The method according to claim 1, characterized in that, For each subnet in the wireless mesh network, the IP address of the access point module in the subnet is a preset IP address in the first IP address set, and the IP address of the site module in the subnet is any IP address in the second IP address set; wherein, the IP addresses in the first IP address set are used to allocate to the nodes in the subnet, and the second IP address set includes other IP addresses in the first IP address set besides the preset IP address.
3. The method according to claim 1, characterized in that, The IP address of the first site module is used to indicate the tier to which the first site module belongs in the wireless mesh network.
4. The method according to claim 3, characterized in that, In the wireless mesh network, access point modules belonging to different nodes at the same level have the same IP address; In the wireless mesh network, the IP addresses of station modules belonging to different nodes at the same level are different.
5. The method according to any one of claims 1-4, characterized in that, Determining the source subnet of the data packet includes: Determine the IP address of the previous node through which the data packet passed; If the IP address of the previous node and the IP address of the first site module belong to the same network segment, then the source subnet of the data packet is determined to be the first subnet; If the IP address of the previous node and the IP address of the first access point module belong to the same network segment, then the source subnet of the data packet is determined to be the second subnet.
6. The method according to any one of claims 1-4, characterized in that, A subnet in the wireless mesh network is a WiFi network created by the access point module of a node. The WiFi networks created by the access point modules of different nodes in the wireless mesh network have the same network parameters; wherein, the network parameters include one or more of the following: network identifier, password, and channel.
7. The method according to any one of claims 1-4, characterized in that, The method further includes: The site mode is enabled through the first site module, and the access point mode is enabled through the first access point module. In the access point mode, a WiFi network is created through the first access point module, and the WiFi network created by the first access point module is the second subnet; The node filtering set of the first node is determined, and the node filtering set of the first node includes the physical identifier of at least one node connected to the first access point module; the at least one node includes the second node, but does not include the third node; In the site mode, wireless signals are searched through the first site module, and the node filtering set of the first node is used to exclude wireless signals from the at least one node during the search process. Based on the search results, the access point module of the third node is accessed through the first site module; wherein, the search results are used to indicate the strongest wireless signal strength between the first node and the third node; If the access point module of the third node is successfully connected, the physical identifier of the first node is sent to the third node through the first site module, so that the third node adds the physical identifier of the first node to the node filter set of the third node.
8. A data transmission device based on WiFi networking, characterized in that, Includes a unit for performing the method as described in any one of claims 1-7.
9. An electronic device, characterized in that, It includes a communication interface and at least one processor, said at least one processor being used to run a computer program or instructions to perform the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program or computer instructions that, when executed by a processor, cause the method of any one of claims 1-7 to be performed.
