Communication method and device based on wireless network simulator, equipment and storage medium

By using a wireless network emulator in the host, controlling the interaction between the WLAN interface and the target device, the problem that the virtual Wi-Fi solution cannot interact with the real device is solved, and the development and debugging of Wi-Fi connections and related functions is realized, improving development efficiency and flexibility.

CN120186030APending Publication Date: 2025-06-20BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311757271.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-19
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

Existing virtual Wi-Fi solutions cannot interact directly with real physical devices, limiting the functionality and flexibility of device development and testing.

Method used

By using a wireless network simulator in the host, the working mode of the wireless LAN WLAN interface to be controlled is determined, and the control instructions sent by the simulator are received to control the WLAN interface to interact with the target device.

Benefits of technology

It realizes Wi-Fi connection and communication between the emulator in the host and the actual device, and can be used to replace real devices to develop and debug Wi-Fi related functions, advance the time node of function development, reduce development risks and save costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120186030A_ABST
    Figure CN120186030A_ABST
Patent Text Reader

Abstract

The invention provides a communication method and device based on a wireless network simulator, equipment and a storage medium, and relates to the technical field of communication. The method comprises the following steps: determining a wireless working mode corresponding to a to-be-controlled first wireless local area network wlan interface; based on the first wlan interface, receiving a control instruction sent by a simulator; and controlling the first wlan interface according to the control command, so that the first wlan interface interacts with target equipment in the wireless working mode. Therefore, a user can carry out wifi connection and communication with actual equipment through the simulator in the host machine, the simulator can be used for replacing the actual equipment to carry out development and debugging of wifi strong correlation functions, the time node of function development can be advanced, the development risk can be reduced, and the cost can be saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of communication technologies, and in particular, to a communication method, apparatus, device, and storage medium based on a wireless network simulator. Background Art

[0002] Currently known virtual Wi-Fi solutions include the virt-wifi solution used in Android Studio and the hwsim solution implemented in the Linux kernel. The virt-wifi solution used in Android Studio is mainly used to simulate devices and perform Wi-Fi related development and testing. The hwsim solution in the Linux kernel is also a similar virtualization solution that can create multiple virtual Wi-Fi interfaces to simulate multiple independent Wi-Fi devices.

[0003] However, these virtualization solutions only support interaction operations with simulated devices and cannot directly interact with real physical devices. Summary of the Invention

[0004] The present disclosure provides a communication method, apparatus, device, and storage medium based on a wireless network simulator, aiming to at least solve one of the technical problems in the related art to some extent.

[0005] In a first aspect, the present disclosure provides a communication method based on a wireless network simulator, which is executed by a host computer. The method includes:

[0006] Determine the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled;

[0007] Based on the first WLAN interface, receive a control instruction sent by the simulator;

[0008] Control the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode.

[0009] In a second aspect, the present disclosure provides a communication apparatus based on a wireless network simulator, including:

[0010] A determination module, configured to determine the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled;

[0011] A receiving module, configured to receive a control instruction sent by the simulator based on the first WLAN interface;

[0012] An interaction module, configured to control the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode.

[0013] In a third aspect, the present disclosure provides an electronic device, including: a processor; a memory for storing instructions executable by the processor; wherein, the processor is configured to execute the instructions to implement a communication method based on a wireless network simulator.

[0014] In a fourth aspect, the present disclosure provides a computer-readable storage medium, which enables an electronic device to execute a communication method based on a wireless network simulator when instructions in the computer-readable storage medium are executed by a processor of the electronic device.

[0015] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, and the computer program is executed by a processor to implement a communication method based on a wireless network simulator.

[0016] In an embodiment of the present disclosure, the host first determines a wireless working mode corresponding to a first wireless local area network (WLAN) interface to be controlled, receives a control instruction sent by the simulator based on the first WLAN interface, and then controls the first WLAN interface according to the control command, so that the first WLAN interface interacts with a target device in the wireless working mode. Thus, the user can perform a Wi-Fi connection and communication with an actual device through the simulator in the host, can use the simulator to replace the real device for the development and debugging of Wi-Fi strongly related functions, can advance the time node of function development, reduce the development risk, and save costs.

[0017] Additional aspects and advantages of the present disclosure will be given in part in the following description, become apparent in part from the following description, or be learned through the practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.

[0019] Figure 1 is a schematic flowchart of a communication method based on a wireless network simulator shown according to a first embodiment of the present disclosure;

[0020] Figure 2 is a schematic flowchart of a communication method based on a wireless network simulator shown according to a second embodiment of the present disclosure;

[0021] Figure 3 is a schematic flowchart of another communication method based on a wireless network simulator shown according to a second embodiment of the present disclosure;

[0022] Figure 4 is a schematic flowchart of a communication method based on a wireless network simulator shown according to a third embodiment of the present disclosure;

[0023] Figure 5 is a schematic flowchart of another communication method based on a wireless network simulator shown in the third embodiment of the present disclosure;

[0024] Figure 6 is a data path topology in STA mode shown in the third embodiment of the present disclosure;

[0025] Figure 7 is a schematic flowchart of a communication method based on a wireless network simulator shown in the fourth embodiment of the present disclosure;

[0026] Figure 8 is a schematic flowchart of another communication method based on a wireless network simulator shown in the fourth embodiment of the present disclosure;

[0027] Figure 9 is a data path topology in AP mode shown in the fourth embodiment of the present disclosure;

[0028] Figure 10 is a schematic structural diagram of a communication device based on a wireless network simulator shown in the embodiment of the present disclosure;

[0029] Figure 11 shows a block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure.

[0030] Through the above-mentioned drawings, specific embodiments of the present disclosure have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. Detailed Embodiments

[0031] The embodiments of the present disclosure will be described in detail below. Examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the drawings are exemplary only for explaining the present disclosure and should not be construed as limiting the present disclosure. On the contrary, the embodiments of the present disclosure include all variations, modifications, and equivalents falling within the spirit and scope of the appended claims.

[0032] Figure 1 is a schematic flowchart of a communication method based on a wireless network simulator shown in the first embodiment of the present disclosure, which is executed by a host computer, as Figure 1 shown, the method includes:

[0033] S101: Determine the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled.

[0034] Among them, the wireless working mode can be an access point mode or a station mode, which is not limited herein.

[0035] In the embodiments of the present disclosure, the simulator can be a Real-Time Operating System (RTOS) simulator, which is a tool that can simulate the operation of RTOS on a computer. Without actual hardware devices, developers can use the RTOS simulator for software development, debugging, and testing of RTOS. For example, the RTOS simulator can be QEMU, Simics, Renode, etc., which is not limited herein.

[0036] Optionally, in the embodiments of the present disclosure, the simulator can simulate the operation of NuttX, such as QEMU, Simics, or Renode, etc., to simulate the operation of the NuttX operating system, which is not limited herein. Among them, NuttX is an open-source real-time operating system based on the POSIX standard. NuttX implements the API interface of the POSIX standard and has good real-time performance.

[0037] Among them, the wireless local area network (WLAN) interface refers to a device or interface used for connecting and exchanging data to communicate in a wireless network.

[0038] Among them, the first WLAN interface can be the WLAN interface to be controlled in the host, such as wlan0, wlan1, which is not limited herein. The number of the first WLAN interfaces can be one or more, which is not limited herein.

[0039] In the embodiments of the present disclosure, the host can be the host running the simulator.

[0040] Among them, the wireless working mode can be a working mode in a wireless network, such as the STA mode (Station Mode), the AP mode (Access Point Mode), or there can also be a Mesh (mesh) mode, a WDS (Wireless Distribution System) mode, which is not limited herein.

[0041] Among them, the STA mode is also called the client mode. In the STA mode, the host acts as a client of the wireless network, that is, a terminal device connected to the wireless network, relying on establishing a connection with an access point (AP), receiving signals from the AP, and sending data to it. The STA mode is suitable for devices such as smart phones, laptops, and tablets that need to access the Internet or communicate with other devices through a wireless network.

[0042] Among them, the AP mode is also called the hotspot mode. In the AP mode, the host acts as a wireless access point, providing wireless network access for other devices. It creates a local wireless network to which other devices can connect and communicate through it. The AP mode is applicable to devices such as routers and wireless base stations, responsible for managing and controlling the client devices connected to it, and providing network connection and Internet access.

[0043] S102: Receive a control instruction sent by the simulator based on the first wlan interface.

[0044] Optionally, if the wireless working modes corresponding to the first wlan interface are different, the ways for the simulator to send control instructions to the first wlan interface will also be different. For example, when the first wlan interface is in the STA mode and the AP mode respectively, the ways for the simulator to send control instructions will also be different.

[0045] Among them, the control instruction is used to control the first wlan interface to perform corresponding operations and make responses.

[0046] As a possible implementation method, the control command can be sent by the simulator to the first wlan interface of the host through the WAPI (Wireless API) application.

[0047] Among them, WAPI can be an application program for configuring and managing the wlan interface on NuttX.

[0048] S103: Control the first wlan interface according to the control command, so that the first wlan interface interacts with the target device in the wireless working mode.

[0049] Among them, the target device can be a device to be communicated or interacted with by the host after receiving the control instruction.

[0050] It should be noted that for different wireless working modes, the target devices with which the host interacts will also be different. For example, if the wireless working mode corresponding to the first wlan interface is the STA mode, then the host can be equivalent to a terminal device connected to the wireless network. At this time, the target device can be devices such as routers and wireless base stations, which are not limited here.

[0051] For example, if the wireless working mode corresponding to the first wlan interface is the STA mode, the control command can be to configure the parameters of the first wlan interface, establish a connection, and send data. Furthermore, the host can implement the interaction with the target device based on the first wlan interface, so that developers can test applications related to WiFi connection and data, which are not limited here.

[0052] In the embodiments of the present disclosure, the host first determines the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled, receives a control instruction sent by the simulator based on the first WLAN interface, and then controls the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode. Thus, the user can perform Wi-Fi connection and communication with the actual device through the simulator in the host, and can use the simulator to replace the real device for the development and debugging of Wi-Fi strongly related functions, which can advance the time node of function development, reduce development risks, and save costs.

[0053] Figure 2 is a schematic flowchart of a communication method based on a wireless network simulator according to the second embodiment of the present disclosure, as Figure 2 shown, the method includes:

[0054] S201: Simulate a corresponding second WLAN interface in the simulator based on the first WLAN interface.

[0055] Among them, the first WLAN interface can be a WLAN interface simulated by the host through the hwsim mechanism. The hwsim mechanism is a solution for simulating Wi-Fi implemented on Linux.

[0056] Among them, the second WLAN interface can be a WLAN interface simulated and mapped by the first WLAN interface in the simulator.

[0057] Specifically, when simulating a corresponding second WLAN interface in the simulator based on the first WLAN interface simulated by hwsim on the host, the virtual wireless interface on the host (such as the interface simulated by hwsim) can be mapped to the corresponding interface in the simulator. First, it is necessary to ensure that the hwsim virtual wireless interface on the host side has been created and configured and can work properly. Then, the corresponding interface simulation function or API can be found in the simulator, and the virtual wireless interface on the host side can be mapped to the simulator through these functions or APIs. Further, relevant configurations can be made to ensure that the interface in the simulator can communicate with the virtual wireless interface on the host side and has similar functions and performance. Finally, a corresponding second WLAN interface can be simulated in the simulator so that it can be accessed by the application program for corresponding testing and development work.

[0058] Optionally, the simulator can send a control instruction to the first WLAN interface through the second WLAN interface.

[0059] S202: Create a second virtual network interface of the bridge type and configure a network address translation (NAT) rule between the second virtual network interface and the Internet access port of the host.

[0060] Among them, the second virtual network interface can be used to bridge with the first virtual network interface and communicate with the external network.

[0061] It should be noted that by configuring the network address translation (NAT) rule between the second virtual network interface and the Internet access port of the host, the second virtual network interface can be enabled to communicate with the external network, and the first virtual network interface bridged with the second virtual network interface can also have the ability to communicate with the external network.

[0062] Among them, the NAT (Network Address Translation) rule plays an important role in packet transmission between different networks. It can convert the IP address in a private network into the IP address in the external network, thereby allowing the hosts in the private network to communicate with the external network. The NAT rule refers to the conversion rules defined in the NAT technology, and these rules determine how the packets in the private network are converted into the packets in the external network.

[0063] Optionally, when creating the second virtual network interface of the bridge type, the IP address of the second virtual network interface can be configured, and a corresponding tool can be used to assign an IP address, a subnet mask, and a gateway to the second virtual network interface.

[0064] It should be noted that by configuring the network address translation (NAT) rule between the second virtual network interface and the Internet access port of the host, NAT processing can be performed on the packets sent from the second virtual network interface, and their source addresses can be changed to the IP address of the Internet access port of the host.

[0065] S203: In response to receiving the simulator startup instruction, create a first virtual network interface, where the first virtual network interface corresponds one-to-one with the second WLAN interface.

[0066] Among them, the one-to-one correspondence between the first virtual network interface and the second WLAN interface indicates that the number of the first virtual network interface and the second WLAN interface is the same, and each first virtual network interface has a corresponding second WLAN interface.

[0067] For example, if there are 4 second WLAN interfaces, namely wlan0, wlan1, wlan2, and wlan3, then there are 4 corresponding first virtual network interfaces, namely tap0, tap1, tap2, and tap3, which are not limited here.

[0068] Among them, the first virtual network interface is a virtual network interface created on the host and is used for packet sending and receiving between the simulator and the second virtual network interface.

[0069] S204: Hang the first virtual network interface under the second virtual network interface.

[0070] For example, if there are 4 first virtual network interfaces, namely tap0, tap1, tap2, and tap3, and the second virtual network interface is nuttx0, then the tap interfaces (tap0, tap1, tap2, tap3) can be added under nuttx0.

[0071] S205: Establish a network path between the first virtual network interface and the second wlan interface.

[0072] Optionally, the packet reception and transmission of the first virtual network interface can be associated and bound with the packet reception and transmission of the corresponding second wlan interface, thereby establishing a data path between the second wlan interface and the first virtual network interface.

[0073] As a possible implementation, in the Linux system, the bridge-utils software package can be used to create and configure a network bridge to associate and bind the first virtual network interface and the second wlan interface.

[0074] S206: In response to receiving a control instruction, the host obtains target data from the second wlan interface in the emulator based on the first virtual network interface, and forwards the target data to the second virtual network interface.

[0075] Among them, the target data can be a data packet to be transmitted, which is not limited here.

[0076] It should be noted that since a network path is established between the first virtual network interface and the second wlan interface, the first virtual network interface can obtain target data from the second wlan interface in the emulator. Since the first virtual network interface is hung under the second virtual network interface, the first virtual network interface can forward the target data to the second virtual network interface.

[0077] S207: Based on the NAT rule, transmit the target data from the second virtual network interface to the Internet interface of the host.

[0078] Optionally, the IP forwarding function can be enabled on the host to allow the host to forward the received target data to other network interfaces. Since the network address translation (NAT) rule has been configured between the second virtual network interface and the Internet interface of the host, the NAT rule can be used to process the target data received from the second virtual network interface and forward it to the Internet interface of the host. In this way, the target data can enter the external network connected to the host.

[0079] Figure 3The figure is a flowchart of another communication method based on a wireless network simulator shown in the second embodiment of the present disclosure. As Figure 3 shown, SIM represents the simulator, HOST represents the host computer, and the SIM issues control commands through WAPI. Among them, wlan0 and wlan1 in the SIM are the second wlan interfaces, wlan0 and wlan1 in the HOST are the first wlan interfaces, tap1 and tap2 are the first virtual network interfaces, nuttx0 is the second virtual network interface, and eth0 in the HOST is the Internet access port of the host computer. wlan0 and wlan1 in the SIM can forward control commands to the wlan interfaces at the HOST end through wpa_cli / hostapd_cli. The data of the wlan interfaces in the SIM can be forwarded to nuttx0 through tap1 / tap2 via the network stack of the simulator, and then interact with the external network through eth0. The wlan interfaces at the HOST end are the wlan interfaces simulated by hwsim, and eth0 in the SIM is the name of the Ethernet interface in the simulator. The HOST forwards the network data Data of eth0 in the simulator through tap0.

[0080] In the embodiment of the present disclosure, the host computer first simulates the corresponding second wlan interface in the simulator based on the first wlan interface, then creates a second virtual network interface of the bridge type, configures a network address translation NAT rule between the second virtual network interface and the Internet access port of the host computer, hangs the first virtual network interface under the second virtual network interface, and in response to receiving a simulator startup instruction, creates the first virtual network interface, where the first virtual network interface and the second wlan interface correspond one by one, establishes a network path between the first virtual network interface and the second wlan interface, the host computer, in response to receiving a control instruction, based on the first virtual network interface, obtains target data from the second wlan interface in the simulator, and forwards the target data to the second virtual network interface, and finally, based on the NAT rule, transmits the target data from the second virtual network interface to the Internet access port of the host computer. Thus, a data path between the second virtual network interface and the first virtual network interface can be established, ensuring the ability of the simulator to transmit data to and from the external network through the second virtual network interface and the first virtual network interface.

[0081] Figure 4 is a schematic flowchart of a communication method based on a wireless network simulator shown in the third embodiment of the present disclosure. As Figure 4 shown, the method includes:

[0082] S301: Determine the wireless working mode corresponding to the first wireless local area network wlan interface to be controlled.

[0083] It should be noted that the specific implementation manner of step S301 can refer to the above embodiments and will not be elaborated here.

[0084] S302: If the wireless working mode is the STA mode, based on the first wlan interface, receive the control command sent by the simulator through the wireless local area network client command line tool wpa_cli.

[0085] It should be noted that if the wireless working mode is the STA mode, the simulator can send a control command to the first wlan interface through wpa_cli.

[0086] Among them, wpa_cli is a command line tool used to interact with wpa_supplicant (wifi protected access supplicant) in the Linux system. wpa_supplicant is an open source software used to support the WPA and 802.1x standards, and it provides the function of connecting and managing wireless networks on the Linux system.

[0087] In the embodiments of the present disclosure, by using the wpa_cli command line tool, interact with and control wpa_supplicant, and send various control instructions to configure and manage the wireless network connection. For example, wpa_cli can be used to scan available wireless networks, connect to a specific network, disconnect, obtain the connection status, set the security authentication method, etc.

[0088] Specifically, when receiving the control command sent by the simulator through wpa_cli based on the first wlan interface, it is first necessary to determine that wpa_supplicant is installed in the host and is in a running state. The first wlan interface can be the control interface of wpa_supplicant. For example, the control command can be commands such as "scan", "add_network", "set_network", "enable_network", etc., which are not limited here.

[0089] Specifically, after receiving the control command, the host can make corresponding responses based on the control command and wpa_supplicant, such as configuring the network, disconnecting, reconnecting, etc., which are not limited here.

[0090] S303: Determine that the target device is a router, and determine the first wlan interface as the Internet access port of the host.

[0091] It should be noted that if the wireless working mode is the STA mode, the router can be used as the target device for interaction. Since the first WLAN interface is determined as the Internet access port of the host, the network connection will be through this first WLAN interface thereafter.

[0092] It should be noted that the user can select the HWSIM (Hardware Simulation) mode or the RNC (Real Network Card) mode according to their own needs.

[0093] Among them, in the HWSIM mode, the pure virtual first WLAN interface (HOST-WLAN) can be controlled, and in the RNC mode, the first WLAN interface (HOST-WLAN) of the real wireless network card can be controlled.

[0094] S304: Control the first WLAN interface based on the control command to perform the first interaction with the router.

[0095] Among them, the first interaction includes data transmission operations and / or network connection operations.

[0096] Optionally, after the first WLAN interface is configured, a relevant application program can be used for debugging, so that the first WLAN interface performs the first interaction with the router. Among them, the first interaction can include operations such as establishing a connection with a real wireless router, sending data packets, receiving responses, etc., which are not limited here.

[0097] It should be noted that in this scenario, the wireless network interface (the first WLAN interface) of the host is configured in the station (STA) mode. In the STA mode, the first WLAN interface can be connected to a real wireless router or access point and can be like a real Wi-Fi device. When the first WLAN interface is configured in the STA mode, it can play the role of a client and connect to an existing wireless network, such as a real router. In this way, the host can access the Internet through this router like a real Wi-Fi device.

[0098] By connecting the simulator to the first WLAN interface in the STA mode on the host, the interaction with the real wireless router can be controlled and simulated, and then the scenarios that need to interact with the real wireless router and test the Wi-Fi connection and related applications can be debugged.

[0099] Figure 5 This is the flowchart of another communication method based on a wireless network simulator shown in the third embodiment of the present disclosure. As Figure 5As shown, SIM represents the simulator, HOST represents the host computer, and SIM sends control commands via WAPI. Among them, wlan0 in SIM is the second WLAN interface, wlan0 in HOST is the first WLAN interface, tap1 is the first virtual network interface, nuttx0 is the second virtual network interface, and wlan0 in HOST is designated as the Internet access port of the host computer. The wlan0 in SIM can forward control commands to the wlan interface on the HOST side via wpa_cli. The data of the wlan interface in SIM can be forwarded to nuttx0 via the network stack of the simulator through tap1, and then interact with the external network via wlan0 in HOST. eth0 in SIM is the name of the Ethernet interface in the simulator. The HOST forwards the network data Data of eth0 in the simulator via tap0.

[0100] Figure 6 A data path topology in the STA mode is shown, as Figure 6 shown. In the STA mode, the HOST-WLAN interface (the first WLAN interface) can be designated as the Internet access port of the HOST to receive the data transmitted by Nuttx0 (the second virtual network interface). Nuttx0 is of the Bridge type. Alternatively, the data transmitted by Nuttx0 can also be received based on HOST-ETH (the Internet access port of the host computer). Among them, first, the data obtained from SIM-WLAN (the second WLAN interface) of the simulator can be forwarded to Nuttx0 by HOST-TAP (the second virtual network interface), and then Nuttx0 transmits the data to HOST-WLAN or HOST-ETH, thus realizing the data path in the STA mode.

[0101] In the embodiments of the present disclosure, first, the wireless working mode corresponding to the first wireless local area network wlan interface to be controlled is determined. Then, if the wireless working mode is the station STA mode, based on the first wlan interface, the control command sent by the simulator via the wireless local area network client command line tool wpa_cli is received. Then, it is determined that the target device is a router, and the first wlan interface is determined as the Internet access port of the host computer. Finally, the first wlan interface is controlled based on the control command to perform the first interaction with the router. Thus, the simulator forwards the control instruction via wpa_cli to control the first wlan interface in the STA mode on the host computer side, and the first wlan interface can be designated as the interface for the host computer to access the Internet, thereby achieving the effect of the simulator managing the physical network card to interact with the real router, which is applicable to the scenario of debugging applications related to both wifi connection and data that need to interact with the real wireless router.

[0102] Figure 7It is a schematic flowchart of a communication method based on a wireless network simulator shown in the fourth embodiment of the present disclosure. As Figure 7 shown, the method includes:

[0103] S401: Determine the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled.

[0104] It should be noted that for the specific implementation manner of step S401, reference can be made to the above embodiments and will not be elaborated here.

[0105] S402: If the wireless working mode is the access point (AP) mode, based on the first WLAN interface, receive the control command sent by the simulator through the wireless local area network access point command line tool hostapd_cli.

[0106] It should be noted that if the wireless working mode is the access point (AP) mode, the simulator can send a control command to the first WLAN interface through hostapd_cli.

[0107] Among them, hostapd_cli is a command line tool for interacting with Hostapd. Through hostapd_cli, control instructions can be sent to Hostapd, and information about the status of the wireless access point can be obtained. Hostapd is open-source software for creating and managing wireless access points (APs). It can transform the wireless network card equipped on a computer or an embedded device into a wireless access point, thereby allowing other wireless devices to connect and access the network.

[0108] It should be noted that the simulator forwards the control instruction to the first WLAN interface on the host side through hostapd_cli, thereby controlling the first WLAN interface in the AP mode on the host side. Specifically, first, it is necessary to run with the first WLAN interface as an access point (AP), and it is necessary to install and configure the Hostapd software and set it to run a wireless access point on the first WLAN interface. The configuration file contains parameters of the wireless network, such as the network name (SSID), encryption type, password, etc. After that, the Hostapd can be started using the configuration file to create a wireless access point on the first WLAN interface. Then the simulator can be connected and hostapd_cli can be started to connect the simulator to the newly created wireless network, and then hostapd_cli can be started on the host to connect to the Hostapd instance. If hostapd_cli successfully connects to the Hostapd instance, the control command sent by the simulator through hostapd_cli can be received.

[0109] S403: Determine that the target device is the device that has established a connection with the host, and attach the first WLAN interface under the second virtual network interface.

[0110] Specifically, the target device can be the device connected to the first WLAN interface of the host.

[0111] Specifically, the first WLAN interface can be added under the second virtual network interface.

[0112] Among them, the specific description of the second virtual network interface can refer to the above embodiments and will not be elaborated here.

[0113] S404: Based on the control command, control the second interaction between the target device and the second WLAN interface of the simulator, where the operations corresponding to the second interaction include at least one of the following: turning on the hotspot, turning off the hotspot, configuring network parameters, and transmitting data.

[0114] As a possible implementation, the control command can be used to send an instruction to the target device to configure the network parameters of the second WLAN interface, such as setting the IP address, subnet mask, gateway, etc. This can ensure that the second WLAN interface and the target device are in the same network, thus achieving interconnection and interoperability.

[0115] As another possible implementation, through the control command, an instruction can be sent to the target device to enable the target device to transmit data on the second WLAN interface, which can be sending data to the target device or receiving data from the target device. It can achieve a more realistic situation of controlling and managing the WLAN interface in the AP mode on the simulator, and is applicable to the situation where it is necessary to turn on the hotspot and debug applications related to connection and data interaction.

[0116] Figure 8 This is the flowchart of another communication method based on a wireless network simulator shown in the fourth embodiment of the present disclosure. As Figure 8As shown, SIM represents the simulator, HOST represents the host, and the SIM sends control commands via WAPI. Among them, wlan0 in the SIM is the second wlan interface, wlan0 in the HOST is the first wlan interface, tap1 is the first virtual network interface, nuttx0 is the second virtual network interface, and eth0 in the HOST is the Internet access port of the host. The wlan0 in the SIM can forward control commands to the wlan interface on the HOST side through hostapd_cli. The data of the wlan interface in the SIM can be forwarded to nuttx0 via the network stack of the simulator through tap1, and then through eth0 in the HOST, enabling the wlan0 interface of the SIM to communicate with the device connected to the wlan0 of the HOST. eth0 in the SIM is the name of the Ethernet interface in the simulator. The HOST transmits the network data Data of the eth0 in the simulator through tap0.

[0117] Figure 9 A data path topology in AP mode is shown, as Figure 9 shown. In AP mode, first, the data obtained from the SIM-WLAN (second WLAN interface) of the simulator can be forwarded by the HOST-TAP (second virtual network interface) to Nuttx0 (first virtual network interface), and then Nuttx0 transmits the data to the HOST-WLAN (first WLAN interface) or HOST-ETH (Internet access port of the host), thus realizing the data path in AP mode.

[0118] In the embodiments of the present disclosure, first, the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled is determined. Then, if the wireless working mode is the access point (AP) mode, based on the first WLAN interface, a control command sent by the simulator through the wireless local area network access point command line tool hostapd_cli is received, and the target device is determined to be the device that has established a connection with the host. Then, the first WLAN interface is attached under the second virtual network interface. After that, based on the control command, the target device and the second WLAN interface of the simulator are controlled to perform a second interaction, where the operations corresponding to the second interaction include at least one of the following: turning on the hotspot, turning off the hotspot, configuring network parameters, and transmitting data. Thus, by attaching the first WLAN interface under the second virtual network interface, communication between the second WLAN interface and the device connected to the first WLAN interface can be realized, and control and management of the first WLAN interface in the AP mode can be achieved. This scenario is applicable to situations where a hotspot needs to be turned on and applications related to connection and data interaction are debugged, enabling developers to test and debug applications related to WiFi connection and data transmission. By using the hostapd_cli tool, the simulator can control the first WLAN interface in the AP mode on the host side, including operations such as turning on the hotspot, configuring network parameters, and sending data. This scenario is very useful for developing and debugging applications that rely on WiFi connection and data transmission, providing a convenient way to simulate interactions with a real wireless router and enabling the turning on of the hotspot for debugging connection and data interaction applications.

[0119] Figure 10 It is a structural block diagram of a communication device based on a wireless network simulator provided by the embodiments of the present disclosure.

[0120] As Figure 10 shown, the communication device 800 based on the wireless network simulator may include:

[0121] A determination module 810, configured to determine the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled;

[0122] A receiving module 820, configured to receive a control instruction sent by the simulator based on the first WLAN interface;

[0123] An interaction module 830, configured to control the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode.

[0124] Optionally, the receiving module is specifically configured to:

[0125] If the wireless working mode is the station (STA) mode, receive the control command sent by the simulator through the wireless local area network client command line tool wpa_cli,

[0126] Or,

[0127] If the wireless working mode is the access point AP mode, receive the control command sent by the simulator through the wireless local area network access point command line tool hostapd_cli.

[0128] Optionally, the determining module 810 is further configured to:

[0129] Based on the first wlan interface, simulate a corresponding second wlan interface in the simulator,

[0130] wherein the simulator issues the control instruction to the first wlan interface through the second wlan interface.

[0131] Optionally, the receiving module further includes:

[0132] A receiving unit, configured to create a first virtual network interface in response to receiving a simulator startup instruction, wherein the first virtual network interface corresponds one-to-one with the second wlan interface;

[0133] An establishing unit, configured to establish a network path between the first virtual network interface and the second wlan interface.

[0134] Optionally, the device further includes:

[0135] A creating module, configured to create a second virtual network interface of the bridging type and configure a network address translation NAT rule between the second virtual network interface and the Internet access port of the host;

[0136] A hanging module, configured to hang the first virtual network interface under the second virtual network interface.

[0137] Optionally, the device further includes:

[0138] A forwarding module, configured to, in response to the host receiving the control instruction, obtain target data from the second wlan interface in the simulator based on the first virtual network interface, and forward the target data to the second virtual network interface;

[0139] A transmitting module, configured to transmit the target data from the second virtual network interface to the Internet access port of the host based on the NAT rule.

[0140] Optionally, the interaction module is specifically configured to:

[0141] If the wireless working mode is the STA mode, determine that the target device is a router, and determine the first wlan interface as the Internet access port of the host;

[0142] Control the first WLAN interface based on the control command to perform a first interaction with the router.

[0143] The first interaction includes data transmission operations and / or network connection operations.

[0144] Optionally, the interaction module is specifically configured to:

[0145] If the wireless working mode is the AP mode, determine that the target device is a device that has established a link with the host, and attach the first WLAN interface under the second virtual network interface.

[0146] Based on the control command, control the target device and the second WLAN interface of the simulator to perform a second interaction.

[0147] Among them, the operations corresponding to the second interaction include at least one of the following:

[0148] Turn on the hotspot, turn off the hotspot, configure network parameters, and transmit data.

[0149] In the embodiments of the present disclosure, the host first determines the wireless working mode corresponding to the first wireless local area network (WLAN) interface to be controlled, receives a control instruction sent by the simulator based on the first WLAN interface, and then controls the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode. Thus, the user can perform a Wi-Fi connection and communication with the actual device through the host, and can use the simulator to replace the real device for the development and debugging of Wi-Fi strongly related functions, which can advance the time node of function development, reduce the development risk, and save costs.

[0150] According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0151] Figure 11 The block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure is shown. Figure 11 The shown electronic device 12 is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.

[0152] As Figure 11 shown, the electronic device 12 is presented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a memory 28, and a bus 18 connecting different system components (including the memory 28 and the processing unit 16).

[0153] Bus 18 represents one or more of several types of bus architectures, including a memory bus or memory controller, a peripheral bus, an Accelerated Graphics Port, a processor, or a local bus using any of the various bus architectures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnection (PCI) bus.

[0154] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and nonvolatile media, removable and non-removable media.

[0155] Memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and / or cache 32. Electronic device 12 may further include other removable / non-removable, volatile / nonvolatile computer system storage media. By way of example only, storage system 34 may be used for reading and writing on non-removable, nonvolatile magnetic media ( Figure 11 not shown, typically referred to as a "hard disk drive"). Although Figure 11 not shown in, a disk drive for reading and writing on removable nonvolatile disks (such as "floppy disks"), and an optical disk drive for reading and writing on removable nonvolatile optical disks (such as: Compact Disc Read Only Memory (CD-ROM), Digital Video Disc Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 through one or more data media interfaces. Memory 28 may include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the various embodiments of the present disclosure.

[0156] A program / utility 40 having a set (at least one) of program modules 42 can be stored, for example, in a memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules 42 generally execute the functions and / or methods in the embodiments described in this disclosure.

[0157] The electronic device 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22. Moreover, the electronic device 12 can also communicate with one or more networks (such as a Local Area Network (LAN), a Wide Area Network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0158] The processing unit 16 executes various functional applications and data processing by running programs stored in the memory 28, such as implementing the methods mentioned in the foregoing embodiments.

[0159] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of this disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0160] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of the present disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0161] Any process or method description represented in a flowchart or described otherwise herein may be understood to represent code for an executable instruction including one or more steps for implementing a customized logic function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations where functions may be executed not in the order shown or discussed, including in a substantially simultaneous manner according to the functions involved or in a reverse order, which should be understood by those skilled in the art to which the embodiments of the present disclosure pertain.

[0162] The logic and / or steps represented in a flowchart or described otherwise herein, for example, may be considered as a sequenced list of executable instructions for implementing a logical function, and may be specifically implemented in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection portion having one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable medium on which the program can be printed, as the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpretation, or other appropriate processing as necessary, and then stored in a computer memory.

[0163] It should be understood that various parts of the present disclosure can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one of the following techniques known in the art or a combination thereof can be used: discrete logic circuits having logic gate circuits for implementing logic functions on data signals, application specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0164] Those of ordinary skill in the art can understand that all or part of the steps carried by the method of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0165] In addition, in each of the various embodiments of the present disclosure, the functional units can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. When the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0166] The above-mentioned storage medium can be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.

Claims

1. A communication method based on a wireless network simulator, characterized in that, Executed by a host computer, the method includes: Determine the wireless working mode corresponding to the first Wireless Local Area Network (WLAN) interface to be controlled; Based on the first WLAN interface, receive a control instruction sent by a simulator; Control the first WLAN interface according to the control command, so that the first WLAN interface interacts with a target device in the wireless working mode.

2. The method according to claim 1, characterized in that, The receiving the control instruction sent by the simulator includes: If the wireless working mode is the Station (STA) mode, receive the control command sent by the simulator through the Wireless LAN client command line tool (wpa_cli); Or, If the wireless working mode is the Access Point (AP) mode, receive the control command sent by the simulator through the Wireless LAN access point command line tool (hostapd_cli).

3. The method according to claim 1, characterized in that, Before determining the wireless working mode corresponding to the first WLAN interface to be controlled, it further includes: Based on the first WLAN interface, simulate a corresponding second WLAN interface in the simulator; wherein, the simulator issues the control instruction to the first WLAN interface through the second WLAN interface.

4. The method according to claim 1, characterized in that, Before receiving the control instruction sent by the simulator based on the first WLAN interface, it further includes: In response to receiving a simulator startup instruction, create a first virtual network interface, where the first virtual network interface corresponds one-to-one with the second WLAN interface; Establish a network path between the first virtual network interface and the second WLAN interface.

5. The method according to claim 4, characterized in that, It further includes: Create a second virtual network interface of the bridge type, and configure a Network Address Translation (NAT) rule between the second virtual network interface and the Internet access port of the host computer; Hang the first virtual network interface under the second virtual network interface.

6. The method according to claim 5, characterized in that, It further includes: The host computer, in response to receiving the control instruction, based on the first virtual network interface, obtains target data from the second WLAN interface in the simulator, and forwards the target data to the second virtual network interface; Based on the NAT rule, transmit the target data from the second virtual network interface to the Internet access port of the host computer.

7. The method according to claim 1, characterized in that, The controlling the first WLAN interface according to the control command, so that the first WLAN interface interacts with a target device in the wireless working mode includes: If the wireless working mode is the STA mode, determine that the target device is a router, and determine the first WLAN interface as the Internet access port of the host computer; Control the first WLAN interface based on the control command to perform a first interaction with the router; The first interaction includes data transmission operations and / or network connection operations.

8. The method according to claim 1, characterized in that, The controlling the first WLAN interface according to the control command, so that the first WLAN interface interacts with a target device in the wireless working mode includes: If the wireless working mode is the AP mode, determine that the target device is a device that has established a link with the host computer, and hang the first WLAN interface under the second virtual network interface; Based on the control command, control a second WLAN interface of the target device and the simulator to perform a second interaction. Among them, the operations corresponding to the second interaction include at least one of the following: Turn on the hotspot, turn off the hotspot, configure network parameters, and transmit data.

9. A communication device based on a wireless network simulator, characterized in that, It includes: A determination module, configured to determine a wireless working mode corresponding to a first Wireless Local Area Network (WLAN) interface to be controlled. A receiving module, configured to receive a control instruction sent by the simulator based on the first WLAN interface. An interaction module, configured to control the first WLAN interface according to the control command, so that the first WLAN interface interacts with the target device in the wireless working mode.

10. An electronic device, characterized in that, It includes: A processor and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by the processor, they are used to implement the method according to any one of claims 1-8.