Network connectivity methods, devices, computer equipment, storage media, and software products

By creating wireless network devices at the native module layer of the virtual machine, the problems of resource waste and poor versatility caused by code modifications in virtual machine wireless network connections are solved, enabling cross-version wireless network connections, saving configuration resources and supporting all applications.

CN119676295BActive Publication Date: 2025-10-31TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510123532.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-10-31
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

In existing technologies, virtual machine wireless network connections require modification of the architecture layer code, resulting in a waste of a lot of configuration resources during version upgrades and poor compatibility with different versions, affecting the normal use of some applications.

Method used

Create a wireless network device in the native module layer of the virtual machine, and communicate with external network devices through the link between the wireless network function device and the wired network function device to obtain and establish a wireless network connection, thus avoiding modification of the architecture layer code.

Benefits of technology

It achieves universality and portability of wireless network connectivity, saves configuration resources, supports network connections for different versions of virtual machines, avoids redundant configuration, and ensures normal operation of all applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119676295B_ABST
    Figure CN119676295B_ABST
Patent Text Reader

Abstract

This application relates to a network connection method, apparatus, computer device, storage medium, and program product. The method includes: responding to a startup command, invoking a driver to create a wireless network device in a virtual machine; the wireless network device includes a wireless network function device and a wired network function device; invoking the initialization function of the wireless network device, instructing the wired network function device to establish a link between the wireless network function device and the wired network function device; invoking the first connection function of the wireless network device, instructing the wireless network function device to communicate with an external network device based on the link between the wireless network function device and the wired network function device, and obtain network connection information; receiving the network connection information sent by the wireless network device, and establishing a wireless network connection with the wireless network device based on the network connection information. This method enables wireless network connection in a virtual machine while saving configuration resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and in particular to a network connection method, apparatus, computer equipment, storage medium, and program product. Background Technology

[0002] In the field of communications, personal computer (PC) mobile operating system virtualization technology refers to running a virtual machine on a personal computer using virtualization technology, simulating a complete operating environment on the PC, allowing users to install and run system applications on the PC, and providing users with a cross-platform user experience.

[0003] In related technologies, when a virtual machine connects to a wireless network (Wi-Fi), the configuration operations, such as modifying, connecting, and checking the virtual machine's system architecture layer code, are typically based on the virtual machine's version to simulate Wi-Fi functionality. Once the virtual machine version is upgraded, the virtual machine's code changes, requiring reconfiguration, which wastes a lot of configuration resources when the virtual machine implements Wi-Fi functionality. Summary of the Invention

[0004] Therefore, it is necessary to provide a network connection method, device, computer equipment, storage medium, and program product that can realize virtual machine wireless network connection while saving configuration resources, in order to address the above-mentioned technical problems.

[0005] This application provides a network connection method applied to a virtual machine. The method includes:

[0006] In response to the startup command, the driver is invoked to create a wireless network device in the virtual machine; the wireless network device includes a wireless network function device and a wired network function device;

[0007] The initialization function of the wireless network device is invoked to instruct the wired network function device to establish a link between the wireless network function device and the wired network function device;

[0008] The first connection function of the wireless network device is invoked, instructing the wireless network function device to communicate with external network devices based on the link between the wireless network function device and the wired network function device to obtain network connection information;

[0009] Receive the network connection information sent by the wireless network device, and establish a wireless network connection with the wireless network device based on the network connection information.

[0010] This application also provides a network connection device. The device includes:

[0011] The device creation module is used to call the driver to create a wireless network device in a virtual machine in response to a startup command; the wireless network device includes a wireless network function device and a wired network function device;

[0012] An initialization configuration module is used to call the initialization function of the wireless network device and instruct the wired network function device to establish a link between the wireless network function device and the wired network function device.

[0013] The information acquisition module is used to invoke the first connection function of the wireless network device, instructing the wireless network device to communicate with external network devices based on the link between the wireless network device and the wired network device to acquire network connection information;

[0014] A network connection module is used to receive network connection information sent by the wireless network device and establish a wireless network connection with the wireless network device based on the network connection information.

[0015] This application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the network connection method described above.

[0016] This application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the above-described network connection method.

[0017] This application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the above-described network connection method.

[0018] The aforementioned network connection method, apparatus, computer equipment, storage medium, and program product, in response to a startup command, invoke a driver to create a wireless network device within a virtual machine. The wireless network device includes both a wireless network function device and a wired network function device. The initialization function of the wireless network device is invoked, instructing the wired network function device to establish a link between the wireless network function device and the wired network function device. The first connection function of the wireless network device is invoked, instructing the wireless network function device to communicate with external network devices based on the link between the wireless network function device and the wired network function device, obtaining network connection information. The method receives network connection information sent by the wireless network device and establishes a wireless network connection with the wireless network device based on the network connection information. In this method, during the virtual machine startup process, a wireless network device is created at the native module layer of the virtual machine by executing a driver. Then, a link is established between the wireless network function device and the wired network function device within the wireless network device, providing communication conditions for communication between the wireless network device and external network devices. Based on this, the first connection function of the wireless network device is invoked, enabling the wireless network device to communicate with external network devices based on the established link, receive network connection information of the wireless network allocated to the wireless network device by the external network device, and open the wireless network to the virtual machine, thus realizing the virtual machine's wireless network connection. For virtual machines, the wireless network device is a driver device within the native module layer of the virtual machine, and the wireless network released by the wireless network device is a real and usable wireless network connection. Thus, when the virtual machine establishes a network connection, it identifies the wireless network device's wireless network and connects accordingly. This makes the entire wireless network connection process implemented at the virtual machine kernel level. This network connection method does not require modification of the architecture layer code, is non-intrusive to the virtual machine, and can be applied to network connection scenarios of different virtual machine versions. It has strong portability and versatility, avoids reconfiguring the network for different virtual machine versions, and saves network configuration resources. Attached Figure Description

[0019] Figure 1 This is a diagram illustrating the application environment of a network connection method in one embodiment.

[0020] Figure 2 This is a flowchart illustrating a network connection method in one embodiment;

[0021] Figure 3 This is a schematic diagram of the link between the virtual machine and the host machine's physical network card in one embodiment;

[0022] Figure 4 This is a schematic diagram of the communication link between the virtual network card in the virtual machine and the physical network card of the host machine in one embodiment;

[0023] Figure 5This is a schematic diagram of the communication link between the virtual network card in the virtual machine and the physical network card of the host machine in another embodiment;

[0024] Figure 6 This is a schematic diagram of an interface for connecting to a wireless network in one embodiment;

[0025] Figure 7 This is a schematic diagram of the network connection information interface in one embodiment;

[0026] Figure 8 This is a signaling interaction diagram of a network connection method in NAT mode in one embodiment;

[0027] Figure 9 This is a signaling interaction diagram of a network connection method in bridging mode in one embodiment;

[0028] Figure 10 This is a flowchart illustrating a network connection method in another embodiment;

[0029] Figure 11 This is a structural block diagram of a network connection device in one embodiment;

[0030] Figure 12 This is an internal structural diagram of a computer device in one embodiment;

[0031] Figure 13 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0033] The network connection method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, the physical network card 102 of the host machine communicates with the virtual machine 104. The virtual machine 104 includes a virtual network card, which can communicate with external network devices through the physical network card 102 of the host machine. These external network devices include, but are not limited to, routers and domain name resolution servers.

[0034] Virtual machine 104 refers to a computer program or system that is isolated from the host machine's operating system. Virtual machine 104 can simulate a Wi-Fi device by modifying the virtual machine interface code, thereby simulating and deceiving the connectivity of the wireless network of the upper-layer application of the virtual machine to achieve wireless network connection, such as Android virtual machine.

[0035] It needs to be emphasized that, Figure 1This explanation uses a single virtual machine as an example. In real-world applications, there can be one or more virtual machines. Furthermore, when multiple virtual machines reside on the same physical server, each virtual machine has its own operating system and applications, and each virtual machine's operating environment, resources, and network are independent.

[0036] Before describing the network connection method for the virtual machine provided in this application, the key terms involved in this application will be explained first.

[0037] WIFI: Wireless Network, a wireless local area network technology based on the IEEE 802.11 standard.

[0038] NAT mode: Network Address Translation.

[0039] Frameworks layer: Architecture layer.

[0040] Native layer: Native module layer.

[0041] Hook: A hook refers to various techniques that modify or extend the behavior of an operating system, application, or other software components by intercepting function calls, message passing, and event passing between software modules. It involves code that processes the intercepted function calls, events, and messages.

[0042] API (Application Programming Interface) is a set of predefined functions designed to provide applications and developers with the ability to access a set of routines based on certain software or hardware.

[0043] 80211 protocol: A wireless local area network standard protocol developed by the IEEE 802 standards committee.

[0044] virtio: A standard semi-virtualized I / O device model.

[0045] virtio-net: The virtio network device implementation in the virtio specification.

[0046] Netlink: A mechanism provided by the Linux kernel for communication between kernel and user-space processes.

[0047] Rtnetlink: An interface in the Linux kernel used to manage and manipulate network devices and their properties. It is an extension of the netlink socket protocol specifically designed for routing and network device-related operations.

[0048] net_device_ops: A structure in the Linux kernel that defines a series of operation functions for network devices.

[0049] SSID: Service Set Identifier, used to identify different Wi-Fi subnets.

[0050] Based on the explanation of the aforementioned professional data, the technical background of this application will be further explained.

[0051] In the field of communications, PC mobile operating system virtualization supports the simulation of one or more independent and complete computing systems on a personal computer, providing users with a cross-platform experience. Since virtual machines need to access internet resources during use, such as downloading software and updating the system, it is necessary to ensure that the virtual machine has internet access permissions.

[0052] Taking PC Android virtualization as an example, in related technologies, to achieve wireless network connection of the virtual machine in the PC Android virtualization scenario, it is usually necessary to hook and modify the API for obtaining, connecting to, and checking WIFI in the Android Framework layer and modify the corresponding return values. Essentially, it is to simulate and deceive the upper-layer application's WIFI connectivity by modifying the virtual machine's interface code, thereby realizing the simulation of WIFI function.

[0053] However, since wireless network connectivity in related technologies is implemented at the architecture layer and is strongly dependent on the virtual machine's code, when the network code of the operating system in the virtual machine changes, the entire modification process also needs to be reimplemented to ensure compatibility with the new system version. This configuration method has poor universality and requires a lot of configuration resources each time.

[0054] Furthermore, applications running on virtual machines are categorized into two types based on their method of determining wireless network connectivity: Type 1 applications determine wireless network connectivity through the system interface. For Type 1 applications, the configuration methods described in relevant technologies can be used to connect and function. Type 2 applications determine wireless network connectivity by searching for the driver device. If the driver device exists, the wireless network is considered connected; if not, it is considered disconnected, and Type 2 applications cannot function properly. Because Type 2 applications do not use the system interface to determine wireless network connectivity, and the relevant technologies only modify the system interface without providing the underlying device driver, Type 2 applications may conclude that the wireless network is not connected, thus hindering their normal operation.

[0055] In summary, considering the numerous problems of poor universality, waste of network configuration resources, and impact on the normal use of some applications on virtual machines in the wireless network implementation methods of related technologies, this application provides a network connection method, device, computer equipment, storage medium, and program product to achieve wireless network connection for virtual machines while saving configuration resources and supporting the normal use of various applications.

[0056] The technical solution of this application and how it solves the above-mentioned technical problems will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.

[0057] In one embodiment, such as Figure 2 As shown, a network connection method is provided, which is applied to Figure 1 The virtual machine in the process; the method includes:

[0058] In step S202, in response to the startup command, the driver is invoked to create a wireless network device in the virtual machine; the wireless network device includes a wireless network function device and a wired network function device.

[0059] Here, a virtual machine refers to a virtual machine created but not started on a physical machine, comprising an architecture layer and a native module layer. The architecture layer provides a runtime environment for applications and is responsible for managing device memory and resources. The native module layer includes multiple libraries, each providing an interface for a specific type of hardware or function, offering access to low-level hardware and support for system functions. The network connection method provided in this application is triggered by the operating system in the architecture layer of the virtual machine and executed by the network device in the native module layer. By performing driver device creation and connection operations in the native module layer, a wireless network connection for the virtual machine is achieved.

[0060] The startup command refers to the command triggered when a created virtual machine is started for the first time. It can be triggered by double-clicking the command, by opening the command prompt and executing the virtual machine startup command, or it can be triggered automatically after the virtual machine is created.

[0061] In response to the startup command, the pre-defined driver in the native module layer is invoked and executed, creating a wireless network device wlan0 in the virtual machine's native module layer (kernel layer) as the wireless network driver device inside the virtual machine. The wireless network device implements the conversion from wired network protocols to wireless network protocols (80211 protocol), including interface capabilities such as scanning, connecting, disconnecting, and obtaining status, corresponding to a pre-defined connectable wireless network.

[0062] To achieve network protocol conversion, wireless network devices need to first connect to a wired network, then convert the wired network to a wireless network, and finally provide the wireless network to the virtual machine's operating system, thus enabling the virtual machine's wireless network connection. Based on different functions, wireless network devices include wireless network function devices and wired network function devices. Wired network function devices connect the wireless network device to the wired network of the virtual machine's host machine, providing the wireless network connection information to the wireless network function device. The wireless network function device then provides the received network connection information to the virtual machine system, enabling the wireless network connection.

[0063] Creating a wireless network device can be divided into two sub-steps: creating a wireless network function device and creating a wired network function device. This application does not restrict the execution order of the two sub-steps. The wired network function device can be created first, followed by the wireless network function device; the wireless network function device can be created first, followed by the wired network function device; or the wireless network function device and the wired network function device can be created simultaneously.

[0064] Step S204: Invoke the initialization function of the wireless network device to instruct the wired network device to establish a link between the wireless network device and the wired network device.

[0065] It should be understood that, for the operating system within a virtual machine, the wireless network function device and the wired network function device are treated as a single unit. That is, the operating system communicates with the wireless network device to instruct either the wireless network function device or the wired network function device within the wireless network device to perform steps matching the communication content. For the wireless network device, after creating the wireless network function device and the wired network function device, further network configuration is required to ensure the availability of communication links within the wireless network device.

[0066] After the driver creates the wireless network device, the initialization function of the wireless network device is actively invoked to instruct the wired network function device in the wireless network device to establish a link between the wireless network function device and the wired network function device.

[0067] In practical applications, when a wireless network device is created but not yet initialized, the initialization (Setup) function of the wireless network device is called. It is also used to instruct the wireless network device to bind the net_device_ops structure to the network function device operation pointer. This structure contains function calls for opening the network device, stopping the wireless network device, and sending data packets.

[0068] It should be noted that the wireless network function device and the wired network function device are a whole. When a link is established between the wireless network function device and the wired network function device, the device address of the wireless network function device is the same as that of the wired network function device.

[0069] Step S206: Invoke the first connection function of the wireless network device, instructing the wireless network device to communicate with external network devices based on the link between the wireless network device and the wired network device to obtain network connection information.

[0070] During the wireless network connection process, network connection information refers to the basic information required for the virtual machine to establish a network connection, including but not limited to the wireless network name (SSID), wireless network key, router IP address, and device address. In this embodiment, the external network device refers to a network device located outside the virtual machine's host machine that provides network connection information services to the virtual machine, such as a router providing packet forwarding services or a server providing the router's IP address.

[0071] A wireless network device corresponds to a preset wireless network. When the virtual machine's operating system detects that a wireless network device has been created in the native module layer, it also pre-determines the wireless network to be connected. At this time, the first connection function of the wireless network device can be directly called to instruct the wireless network device to communicate with the physical network card of the host machine to which the virtual machine belongs based on the link between the wireless network device and the wired network device. Then, the physical network card communicates with the external network device to obtain network connection information.

[0072] For example, the communication interface of the wireless network device is invoked to send a first connection request to the wireless network device, instructing the wireless network function device in the wireless network device to generate a request data packet to obtain network connection information based on the wireless network connection request. Then, based on the established link, the request data packet is sent to the wired network function device. The wired network function device sends the request data packet to the physical network card of the host machine to which the virtual machine belongs. The physical network card sends the request data packet to the external network device. The external network device parses and processes the request data packet to generate network connection information. Correspondingly, the external network device sends the network connection information to the wireless network function device in sequence through the physical network card and the wired network function device, thus completing the bidirectional communication between the wireless network function device and the external network device.

[0073] Step S208: Receive network connection information sent by the wireless network device, and establish a wireless network connection with the wireless network device based on the network connection information.

[0074] Receiving network connection information sent by a wireless network device means that the wireless network device supports virtual machine connections to the network connection information. In this case, a wireless network connection between the virtual machine and the wireless network device can be automatically established.

[0075] After the operating system connects to the wireless network, it can further verify the connection status of the wireless network, disconnect the wireless network, and perform other operations.

[0076] In the aforementioned network connection method, during the virtual machine's startup process, a wireless network device is created at the virtual machine's native module layer by executing a driver. Then, a link is established between the wireless network function device and the wired network function device within the wireless network device, providing communication conditions for communication between the wireless network device and external network devices. Based on this, the first connection function of the wireless network device is invoked, enabling the wireless network device to communicate with external network devices based on the established link. It receives network connection information for the wireless network allocated by the external network device and exposes this wireless network to the virtual machine, thus realizing the virtual machine's wireless network connection. For the virtual machine, the wireless network device is a driver device at the virtual machine's native module layer, and the wireless network released by the wireless network device is a real and usable wireless network connection. In this way, during network connection, the connection is established by identifying the wireless network device's wireless network, making the entire wireless network connection process implemented at the virtual machine kernel. This network connection method does not require modification of the architecture layer code, is non-intrusive to the virtual machine, and can be applied to network connection scenarios of different versions of virtual machines. It has strong portability and versatility, avoids reconfiguring the network for different versions of virtual machines, and saves network configuration resources.

[0077] The network identification logic of the operating system and upper-layer system applications in the virtual machine is as follows: the network is identified based on the device name of the network device, and the device with the default device name "eth0" has the highest network priority. This device is the wired mapping device of the host machine to which the virtual machine belongs in the virtual machine. However, in this embodiment, the purpose of the network connection is for the virtual machine to connect to the wireless network of the wireless network device, rather than the default wired mapping device. In this case, it is necessary to take a series of measures, such as modifying the network identification logic of the virtual machine, and / or modifying the name of the wired mapping device, to prevent the virtual machine from actively connecting to the wired mapping device. The following is an example of how to modify the name of the wired mapping device.

[0078] In one embodiment, the virtual machine includes a virtual network interface card (NIC), which is a wired mapping device of the host machine to which the virtual machine belongs within the virtual machine; before calling the driver to create a wireless network device in the virtual machine, the method further includes:

[0079] Disable the wired mapping device on the host machine within the virtual machine, and then rename the wired mapping device. If the name of the wired mapping device is successfully changed, then start the wired mapping device.

[0080] Please see Figure 3 , Figure 3 This is a schematic diagram of the link between the virtual machine and the host machine's physical network interface card. Figure 3 The virtual machine includes a virtual network adapter, which can be created by the virtual machine monitor (VBox) at the native module layer of the virtual machine, i.e., the kernel layer. Specifically, it maps the wired network (PC network) of the host machine to which the virtual machine belongs to the wired mapping device in the native module layer of the virtual machine. This application does not limit the mapping method of the wired network, such as NAT mode, bridged mode, etc.

[0081] After a virtual network adapter exists in the virtual machine but before creating a wireless network device, the name of the virtual network adapter (i.e., the wired mapping device) needs to be changed. The original name of the wired mapping device is "eth0," and the new name can be any name different from "eth0," such as "eeth0." It's important to note that in the communications field, the name of a wired mapping device cannot be changed while it's running. Therefore, you must shut down the wired mapping device before changing its name and then restart it afterward.

[0082] In one implementation scenario, the name modification program for the wired mapping device can be embedded in the driver. The driver includes a name modification program and a device creation program. In this scenario, in response to the startup command, the name modification program in the driver is called to first shut down the wired mapping device, then modify the name of the wired mapping device, for example, changing the name of the wired mapping device from "eth0" to "eeth0", and finally start the renamed wired mapping device; then the device creation program in the driver is called to create the wireless network device.

[0083] In another implementation scenario, the name modification program for the wired mapping device is independent of the driver. In this scenario, in response to the startup command, the name modification program is executed first to perform a series of actions, including shutting down the wired mapping device, modifying the name of the wired mapping device, and starting the renamed wired mapping device; then the driver is executed to create the wireless network device.

[0084] In the above embodiment, before calling the driver to create a wireless network device in the virtual machine, the wired mapping device of the host machine in the virtual machine is first closed, and then the name of the wired mapping device is modified. Then, if the name of the wired mapping device is successfully modified, the wired mapping device is started. This method of modifying the name of the wired mapping device without modifying the default network connection priority of the virtual machine can ensure that the virtual machine does not actively connect to the wired mapping device and avoid the wired mapping device interfering with the wireless network device created in this embodiment.

[0085] The following describes another implementation method for modifying the network identification logic of the virtual machine: In one embodiment, the virtual machine includes a virtual network interface card (NIC), which is a wired mapping device of the host machine to which the virtual machine belongs within the virtual machine; before calling the driver to create a wireless network device in the virtual machine, the following is also included:

[0086] Change the default network connection name from the wired mapping device name to the wireless network name of the wireless network device.

[0087] In the above embodiment, the default value of the network connection is changed from the name of the wired mapping device to the name of the wireless network of the wireless network device. This way, the virtual machine network identification logic is modified without changing the name of the wired mapping device, which can ensure that the virtual machine does not actively connect to the wired mapping device and avoid the wired mapping device interfering with the wireless network device created in this embodiment.

[0088] The above two embodiments illustrate how to modify the network identification logic of the virtual machine and how to modify the name of the wired mapping device, respectively. In practical applications, they can be used as two parallel methods, one of which can be selected for use, or they can be used as two serial implementation steps simultaneously to ensure that the virtual machine does not actively connect to the wired mapping device and avoid the wired mapping device from interfering with the wireless network device created in this embodiment.

[0089] The modification of the name of the wired mapping device (virtual network adapter) in the aforementioned embodiments is based on the premise that a virtual network adapter has already been created in the virtual machine, and the virtual network adapter is based on the wired network of the host machine to which the virtual machine belongs, mapped to the virtual machine. In the field of communication, the method of mapping the host machine's wired network to the virtual machine can be Network Address Translation (NAT), bridged mode, etc. Based on this, the implementation method of mapping the host machine's wired network to the virtual machine will be described below.

[0090] In one embodiment, the mapping method of the wired mapping device in the virtual machine by the host machine includes any of the following:

[0091] The switching device in the virtual monitor of the host machine translates the Internet Protocol address corresponding to the virtual network card to obtain the communication address for communication between the virtual machine and external network devices; the switching device is also used to identify the data packets returned by the external network devices to the virtual machine based on the communication address and forward the data packets to the virtual machine;

[0092] The router corresponding to the host machine assigns an Internet Protocol (IP) address to the virtual network card that matches the network segment of the host machine, and determines the IP address as the communication address for the virtual machine to communicate with external network devices.

[0093] Taking an Android virtual machine as an example, before explaining the mapping method, let's first clarify the purpose of the mapping: In a PC Android virtualization scenario, mapping the host machine's wired network to the virtual machine means that the virtual machine has an internal network and the ability to communicate with external network devices. Based on this, the basis for successfully mapping the host machine's wired network can be understood as: the virtual network card in the virtual machine corresponds to a communication address that supports communication with external network devices.

[0094] The first mapping method: The host machine's wired network is mapped to the virtual machine via a virtual network monitor, resulting in a virtual network adapter. For details on this mapping scenario, please refer to [link to documentation / reference]. Figure 4 , Figure 4 This is a diagram illustrating communication between a virtual network adapter in a virtual machine and a physical network adapter on the host machine. Figure 4 In this process, the virtual network interface card (NIC) sends a request packet to the switch. The switch translates the virtual NIC's internal Internet Protocol address (internal IP address) carried in the request packet into the IP address of the host machine's physical NIC (external IP address). Furthermore, the host machine's physical NIC forwards the request packet from the virtual NIC to the external network device, enabling communication between the virtual NIC and the external network device. Conversely, the external network device processes the request packet, obtaining a response packet. The external network device sends the response packet to the host machine's physical NIC, which then sends the response packet to the switch. The switch translates the external IP address carried in the response packet into an internal IP address and returns the response packet content to the virtual NIC corresponding to the internal IP address, thus enabling communication between the external network device and the virtual NIC. In this way, by using the switch to translate the virtual NIC's address, the host machine's physical NIC address is used as the communication address between the virtual NIC and the external network device, achieving bidirectional communication between them. In the NAT mode described above, the virtual machine and the host machine have different IP addresses, which can avoid IP conflicts and insufficient IPs, making it suitable for scenarios with a large number of users.

[0095] The second mapping method involves bridging the host machine's wired network to the virtual machine. The host machine's network segment refers to a range of IP addresses; devices within the same segment can communicate directly without a router. In this embodiment, an IP address is assigned to the virtual network interface card (NIC) from the set of IP addresses covered by the host machine's network segment, ensuring that the virtual NIC and the host machine are on the same network segment. Since the host machine can communicate directly with external network devices via its physical NIC, the virtual NIC, being on the same network segment as the host machine, can also communicate directly with external network devices via its physical NIC. For details on this mapping scenario, please refer to [link to relevant documentation]. Figure 5 , Figure 5 This is a diagram illustrating communication between a virtual network adapter in a virtual machine and a physical network adapter on the host machine. Figure 5 In this bridging mode, the virtual network adapter sends a request packet to the host machine's physical network adapter. The host machine's physical network adapter then forwards the request packet to the external network device. Correspondingly, the external network device processes the request packet, generates a response packet, and sends the response packet back to the host machine's physical network adapter. The host machine's physical network adapter then sends the response packet back to the virtual network adapter. In this way, based on the host machine's network segment, the virtual network adapter is assigned an independent IP address that supports direct communication with external network devices, enabling bidirectional communication between the external network device and the virtual network adapter. In this bridging mode, the virtual machine and the host machine share the same IP address network segment, which will occupy IP addresses in the host machine's network segment. To avoid IP conflicts and insufficient IP addresses due to a large number of users, this mode is typically used in scenarios with a small number of users.

[0096] In summary, in practical applications, the first NAT mode can be used for wired network mapping of the host machine when the number of virtual machine users is greater than or equal to the user threshold, and the second bridging mode can be used for wired network mapping of the host machine when the number of virtual machine users is less than the user threshold.

[0097] The above embodiments provide two mapping methods for mapping the wired network of the host machine to the virtual machine. One method is to use the switch device in the virtual monitor of the host machine to convert the address of the virtual network card, and use the address of the physical network card of the host machine as the communication address for the virtual network card to communicate with external network devices, so as to realize bidirectional communication between the external network devices and the virtual network card. The other method is to use the router corresponding to the host machine to assign an Internet Protocol address to the virtual network card that matches the network segment of the host machine, and use the Internet Protocol address as the communication address for the virtual machine to communicate with external network devices, so as to realize bidirectional communication between the external network devices and the virtual network card. The above two different mapping methods are suitable for the implementation of virtual machine internal network access in different application scenarios, improving the scenario applicability and flexibility of virtual machine network connection methods.

[0098] The virtual machine's wireless network switch can be turned on by default during startup. This allows the virtual machine's operating system to promptly detect the wireless network device after it's created, quickly invoke the device's first connection function, obtain the wireless network access provided by the device, and establish a wireless network connection. The following section explains the scenarios for invoking the first connection function.

[0099] In one embodiment, invoking the first connection function of the wireless network device includes:

[0100] Turn on the virtual machine's wireless network switch, invoke the wireless network device's scanning function, instruct the wireless network device to return the wireless network information of the wireless network device; receive the wireless network information sent by the wireless network device; invoke the first connection function of the wireless network device corresponding to the wireless network information.

[0101] If the virtual machine's wireless network switch is turned on, and the presence of a wireless network driver device in the native module layer is detected periodically or in real time, then, once the wireless network device is created, if the presence of a wireless network device in the native module layer is detected, the operating system in the virtual machine will trigger a scan request. In response to the scan request, the network device in the kernel layer, such as the processor, will call the scanning function of the wireless network device and instruct the wireless network function device in the wireless network device to return the wireless network information of the wireless network function device.

[0102] The wireless network information includes Service Set Identifier (SSID), signal strength, whether the network is encrypted, encryption method, frequency, Basic Service Set Identifier (BSSID), network access performance and capabilities, etc.

[0103] After receiving the wireless network information returned by the wireless network device, the connection function interface of the wireless network device is invoked to send a connection request for the wireless network corresponding to the wireless network information to the wireless network device, so as to instruct the wireless network function device in the wireless network device to return network connection information.

[0104] In this embodiment, the difference between wireless network information and network connection information is that wireless network information is the response result of the scanning function, used to describe the basic information of the wireless network, excluding the IP address of the wireless network; network connection information is the response result of the connection function after scanning, used for virtual machines to connect to the wireless network, including the IP address of the wireless network, gateway and other connection information, and may also include wireless network information.

[0105] Please see Figure 6 , Figure 6 This is a screenshot showing the interface where the virtual machine turns on the wireless network, performs a network scan, and connects to the wireless network. Figure 6The example uses the wireless network name "AbcWifi". Figure 6 The interface shown can also display information such as network preference settings, the number of saved networks, and data usage. Figure 7 for Figure 6 This is a schematic diagram showing the network connection information, assuming a connection to the existing wireless network. Figure 7 The network connection information displayed includes the wireless network's signal strength, frequency, security, and whether automatic connection is supported.

[0106] In the above embodiment, the virtual machine's wireless network switch is turned on, and the scanning function of the wireless network device is invoked to promptly detect the wireless network information of the wireless network device. The first connection function of the wireless network device corresponding to the wireless network information is invoked. Since the wireless network information is preset when the wireless network device is created, the wireless network device can respond to the scanning function more quickly and return the scanning results to the virtual machine's operating system, thereby improving the invocation speed of the first connection function.

[0107] In another implementation scenario, since the wireless network device has a pre-configured wireless network, the operating system in the virtual machine obtains the wireless network information simultaneously when it scans the wireless network device. Based on this, the operating system can directly trigger a connection request to actively connect to the wireless network device's pre-configured wireless network without waiting for the wireless network device to return wireless network information.

[0108] For example, invoking the first connection function of the wireless network device includes: turning on the wireless network switch of the virtual machine and then invoking the first connection function of the wireless network device. In this way, after turning on the wireless network switch, it can directly connect to the preset wireless network without waiting for the scan results to be returned, further optimizing the connection efficiency of the entire wireless network.

[0109] During the network connection implementation process, the purpose of calling the first connection function is to allow the wireless network device to return network connection information. The wireless network device communicates with external network devices based on the links between the wireless network device and the wired network device, the wired network device and the virtual network interface card (NIC), the virtual NIC and the physical NIC, and the physical NIC and the external network device. The link between the virtual NIC and the physical NIC can be established via NAT mode; for specific implementation details, please refer to the previous embodiments for the example... Figure 4 As explained, the link between the virtual network interface card (NIC) and the physical NIC can be established through bridging mode. For details on the implementation, please refer to the previous embodiments. Figure 5 Explanation.

[0110] The following example illustrates how... Figure 4In the scenario shown where the link between the virtual network card and the physical network card is established through NAT mode, the implementation method of the virtual machine calling the first connection function of the wireless network device, the wireless network device communicating with external network devices, and obtaining network connection information is explained.

[0111] In one embodiment, invoking the first connection function of the wireless network device instructs the wireless network function device to communicate with an external network device based on the link between the wireless network function device and the wired network function device to obtain network connection information, including:

[0112] The system invokes the first connection function of the wireless network device, instructing the wireless network device to generate a request data packet for wireless network connection. Based on the link, it forwards the request data packet to the wired network device, then forwards it via the virtual network card to the switch device on the host machine to which the virtual machine belongs. The switch device translates the address of the request data packet, and the address-translated request data packet interacts with the external network device through the host machine's physical network card. It also receives network connection information sent by the wireless network device; this network connection information is returned from the external network device to the wireless network device via the switch device.

[0113] The first connection function interface of the wireless network device is invoked to send a network connection request to the wireless network device. The wireless network device generates request data packets based on the network connection request. There are usually multiple request data packets, which are sent to different external network devices. The wireless network device forwards the request data packets to the wired network device based on the link between the wireless network device and the wired network device. The wired network device forwards the request data packets to the virtual network interface card (NIC) based on the link between the NIC and the switch device. The switch device converts the sending address of the request data packets, which is the internal address of the virtual NIC, to the address of the physical NIC. The physical NIC then sends the address-converted request data packets to the corresponding external network devices. Each external network device parses and processes the request data packets it receives to generate network connection information. Accordingly, the external network device sends the network connection information to the switch device through the physical network card. The switch device translates the recipient address in the network connection information to determine the virtual network card. Then, the switch device sends the network connection information to the virtual network card. The virtual network card forwards the network connection information to the wired network function device. The wired network function device returns the network connection information to the wireless network function device. The wireless network function device returns the network connection information to the operating system.

[0114] Taking a virtual machine as an example of the Android system, such as Figure 8 As shown, Figure 8In a scenario where the host machine's wired network is mapped to the Android virtual machine using NAT mode, the signaling interaction diagram for the network connection method includes:

[0115] In step S801, the Android system sends a network connection request to the wireless network device.

[0116] Step S802: The wireless network function device generates a request data packet based on the network connection request.

[0117] In step S803, the wireless network function device sends a request packet to the switch device based on the links between the wireless network function device and the wired network function device, the wired network function device and the virtual network card, and the virtual network card and the switch device.

[0118] In step S804, the switch device translates the internal network address of the wireless network device carried in the request data packet to obtain the address-translated request data packet.

[0119] In step S805, the switch device sends the address-translated request data packet to the corresponding external network device through the host's physical network card.

[0120] In step S806, the external network device parses and processes the received request data packet to generate network connection information.

[0121] Step S807: Send network connection information to the switch device through the host machine's physical network card.

[0122] In step S808, the switch device translates the recipient address in the network connection information and identifies the recipient of the network connection information as a virtual network card.

[0123] In step S809, the switch device sequentially sends network connection information to the wireless network function device through the link between the switch device and the virtual network card, the link between the virtual network card and the wired network function device, and the link between the wired network function device and the wireless network function device.

[0124] In step S810, the wireless network device returns network connection information to the Android system.

[0125] In the above embodiments, in the scenario where the wired network of the host machine is mapped to the virtual machine using address translation mode, the first connection function of the wireless network device is invoked, instructing the wireless network device to interact with data packets based on the links between the wireless network device and the wired network device, the wired network device and the virtual network card, the virtual network card and the switch device, the switch device and the physical network card, and the physical network card and the external network device. The implementation logic is clear and easy to deploy in various physical machines.

[0126] The following example illustrates how... Figure 5 In the scenario where the link between the virtual network card and the physical network card is established through bridging mode, the implementation method of the virtual machine calling the first connection function of the wireless network device, the wireless network device communicating with external network devices, and obtaining network connection information is explained.

[0127] In one embodiment, invoking the first connection function of the wireless network device instructs the wireless network function device to communicate with an external network device based on the link between the wireless network function device and the wired network function device to obtain network connection information, including:

[0128] The system invokes the first connection function of the wireless network device, instructing the wireless network device to generate a request data packet for wireless network connection. Based on the link, it forwards the request data packet to the wired network device. Through the virtual network card, it forwards the request data packet received by the wired network device to the physical network card of the host machine to which the virtual machine belongs. Communication with external network devices is achieved through the physical network card. The system also receives network connection information sent by the wireless network device. The network connection information is returned by the external network device to the wireless network device through the virtual network card.

[0129] The operating system in the virtual machine sends network connection requests to the wireless network device by calling its communication interface. The wireless network device generates multiple request packets based on these requests, each sent to a different external network device. The wireless network device forwards these request packets to the wired network device via its link with the wired network device. The wired network device then forwards the packets to the virtual network interface card (NIC) via its link with the virtual NIC. The virtual NIC then forwards the packets to the physical NIC via its link with the physical NIC. The physical NIC parses each request packet, identifies the corresponding external network device, and sends it to that device. Each external network device then parses and processes the received request packets to generate network connection information. The external network device then sends this information to the virtual NIC via the physical NIC. The virtual NIC forwards the information to the wired network device, which returns the information to the wireless network device. Finally, the wireless network device returns the network connection information to the virtual machine's operating system.

[0130] Continuing with the example of an Android system using a virtual machine, such as Figure 9 As shown, Figure 9 In a scenario where the host machine's wired network is mapped to the Android virtual machine using bridging mode, the signaling interaction diagram for the network connection method includes:

[0131] In step S901, the Android system sends a network connection request to the wireless network device.

[0132] Step S902: The wireless network function device generates a request data packet based on the network connection request.

[0133] In step S903, the wireless network function device sends a request packet to the virtual network card based on the link between the wireless network function device and the wired network function device, and the link between the wired network function device and the virtual network card.

[0134] In step S904, the virtual network card, through the host physical network card, instructs the physical network card to determine the receiving device of the request data packet and sends the request data packet to the corresponding network device.

[0135] In step S905, the external network device parses and processes the received request data packet to generate network connection information.

[0136] In step S906, the external network device sends network connection information to the virtual network card through the host machine's physical network card.

[0137] In step S907, the virtual network card sends network connection information to the wireless network function device through the link between the virtual network card and the wired network function device, and the link between the wired network function device and the wireless network function device.

[0138] Step S908: The wireless network device sends network connection information to the Android system.

[0139] In the above embodiments, when the wired network of the host machine is mapped to the Android virtual machine using a bridging method, the first connection function of the wireless network device is invoked, instructing the wireless network device to interact with data packets based on the links between the wireless network device and the wired network device, the wired network device and the virtual network card, the virtual network card and the physical network card, and the physical network card and the external network device. This makes the logic clear and easy to deploy in various physical machines.

[0140] Communication between a wireless network device and an external network device can be understood as the sending and receiving of data packets. The communication conditions at least include that the internal link of the wireless network device is connected and available. The preceding embodiments described the steps for creating the link and using it for data packet exchange. Next, through an embodiment, the implementation steps for the link to support data packet transmission in the scenario after link creation and before link use will be described.

[0141] In one embodiment, before invoking the first connection function of the wireless network device to instruct the wireless network function device to communicate with an external network device based on the link between the wireless network function device and the wired network function device to obtain network connection information, the method further includes:

[0142] The second connection function of the wireless network device is invoked, instructing the wireless network device to invoke the link creation function of the wired network device. The link creation function is used to instruct the wired network device to create a network connection between the wireless network device and the wired network device based on the link.

[0143] The operating system in the virtual machine calls the communication interface of the wireless network device to send a second connection request to the wireless network device, invokes the second connection function of the wireless network device, and instructs the wireless network function device in the wireless network device to invoke the link creation function (Newlink) of the wired network function device. The link creation function is used to instruct the wired network function device to bind the wired network function device and the wireless network function device based on the link, so that the data between the wireless network function device and the wired network function device can be communicated to support data interaction between the two devices.

[0144] It is important to emphasize that after creating a link between the wired network function device and the wireless network function device in the wireless network device, instructing the wireless network function device to call the link creation function of the wired network function device, thereby establishing a network link between the devices, is equivalent to the wireless network function device activating the link between the two devices to facilitate the subsequent transmission of data packets between the wireless network function device and the wired network function device.

[0145] In the above embodiments, calling the second connection function of the wireless network device instructs the wireless network device to call the link creation function of the wired network function device to establish a network connection between the wireless network function device and the wired network function device. This is equivalent to activating the link function between the wireless network function device and the wired network function device in the wireless network device, providing communication conditions for subsequent data packet transmission between the wireless network function device and the wired network function device based on the link. This allows the wireless network device to successfully obtain network connection information, thereby improving the efficiency of the virtual machine in receiving network connection information returned by the wireless network device.

[0146] Once the virtual machine is connected to the wireless network provided by the wireless network device, the virtual machine can periodically check the network status of the wireless network at preset time intervals, evaluate the current wireless network quality, and then execute a network connection scheme that matches the evaluation results, such as continuing to connect to the wireless network or disconnecting from the wireless network.

[0147] In one embodiment, the method further includes:

[0148] Call the wireless network device status acquisition function to instruct the wireless network device to report the network status of the wireless network corresponding to the virtual machine; receive the network status of the wireless network sent by the wireless network device.

[0149] Among them, network status refers to the status attribute information describing the wireless network during a preset time period, including but not limited to the strength of the wireless network, the transmission rate of the wireless network, the total number of data packets transmitted, and the number of data packets that failed to be transmitted.

[0150] The communication interface of the wireless network device is invoked to send a status acquisition request to the wireless network device, instructing the wireless network function device in the wireless network device to package and return the network status of its corresponding wireless network to the virtual machine. At this time, the virtual machine receives the network status of the wireless network sent by the wireless network device and formulates a subsequent network connection plan based on the network status, such as disconnecting the wireless network or sending an indication that the wireless network signal strength is weak.

[0151] In one feasible application scenario, network status can be attribute information of the wireless network detected in real time by the wireless network function device. After receiving the network status of the wireless network, the virtual machine compares the received network status with a reference network status to obtain a quantified value of the difference between the current network status and the reference network status.

[0152] For example, by obtaining the absolute values ​​of the data in the reference network state and the data in the current network state under the same quantitative index, a set of absolute values ​​corresponding to multiple quantitative indices is obtained. Then, the absolute values ​​in the absolute value set are normalized, and the mean of the normalized absolute values ​​is calculated to obtain the quantitative value of the difference between the current network state and the reference network state.

[0153] Furthermore, after calculating the difference quantization value, the difference quantization value is compared with a preset difference quantization threshold. The difference quantization threshold is the quantization value of the lower limit of network quality supported by the virtual machine. If the difference quantization value is less than the difference quantization threshold, it indicates that the current wireless network quality meets the connection requirements, and the connection with the wireless network is maintained. If the difference quantization value is greater than the difference quantization threshold, it indicates that the current wireless network quality cannot meet the connection requirements, and an indication message of weak wireless network signal strength is issued, instructing the virtual machine to prioritize higher priority applications when network resources are limited.

[0154] In another feasible application scenario, the network status can be the attribute information of the wireless network detected in real time by the wireless network function device. The difference quantization value is obtained by comparing the reference network status with the actual network status. After receiving the difference quantization value, the virtual machine compares it with a preset difference quantization threshold. If the difference quantization value is less than the threshold, the connection with the wireless network is maintained; if the difference quantization value is greater than the threshold, an indication of weak wireless network signal strength is issued. The method of obtaining the difference quantization value in this application scenario and the comparison criteria are consistent with those in the above application scenarios, which will not be repeated here.

[0155] In the above embodiments, the status acquisition function of the wireless network device is invoked to instruct the wireless network device to report the network status of the wireless network corresponding to the virtual machine. The network status of the wireless network sent by the wireless network device is received to sense the change in the network status of the wireless network, and then a network connection action matching the current network status is executed to determine the service availability of the virtual machine.

[0156] As can be seen from the foregoing embodiments, network quality can be assessed based on the received network status, and the network connection can be disconnected when the network quality is poor. Next, an embodiment will be used to illustrate the implementation of network disconnection. In one embodiment, the method further includes:

[0157] Invoke the network disconnect function of the wireless network device, instruct the wireless network function device to clean up the associated data between the wireless network device and the wireless network device, and instruct the wired network function device to unbind the link between the wireless network function device and the wired network function device, and initialize the device resources of the wired network function device.

[0158] Call the communication interface of the wireless network device to send a network disconnection request to the wireless network device, instructing the wireless network function device to perform a data cleanup operation, clearing the data packets generated and transmitted by the wireless network function device during the current wireless network connection process, such as request data packets, wireless network information, network connection information and other data.

[0159] It calls the communication interface of the wireless network device to send a network disconnection request to the wireless network device. It is also used to instruct the wired network function device to perform link unbinding processing, initialize the device resources of the wired network function device, and clear the data packets transmitted by the wired network function device during the current wireless network connection process, such as wireless network information, network connection information and other data.

[0160] It should be understood that the data cleanup step of the wireless network function device and the link unbinding step of the wired network function device can be executed in parallel or sequentially. Furthermore, in the case of sequential execution, there is no restriction on the execution order of the data cleanup step and the link unbinding step; for example, the data cleanup step of the wireless network function device can be performed first, followed by the link unbinding step of the wired network function device, or vice versa.

[0161] In the above embodiments, the network disconnection function of the wireless network device is invoked to instruct the wireless network function device to clean up the associated data of the wireless network device and the wireless network function device, and to instruct the wired network function device to unbind the link between the wireless network function device and the wired network function device, initialize the device resources of the wired network function device, restore the wireless network device to the initial state it was originally created, clean up the cache data of the wireless network device, and improve the operating speed and performance of the wireless network device.

[0162] The foregoing embodiments illustrate the implementation of the network disconnection function. In a communication scenario, network disconnection can be initiated when the wireless network quality is poor, or in response to a shutdown command for a virtual machine. In one embodiment, invoking the network disconnection function of the wireless network device includes any of the following methods:

[0163] In response to a power-off command, the network disconnect function of the wireless network device is invoked;

[0164] In response to a command to shut down the wireless network, the network disconnect function of the wireless network device is invoked.

[0165] The shutdown command can be triggered by a shutdown request for the virtual machine or by a shutdown request for the host machine to which the virtual machine belongs.

[0166] In response to the power-off command, the communication interface of the wireless network device is invoked to send a network disconnection request to the wireless network device, instructing the wireless network device to clear the data packets generated and transmitted during the current wireless network connection; and instructing the wired network device to perform link unbinding processing, initialize the device resources of the wired network device, and clear the data packets transmitted by the wired network device during the current wireless network connection.

[0167] The command to shut down the wireless network can be automatically triggered when the virtual machine detects that the network connection quality of the current wireless network is poor, such as when the packet loss rate is greater than a preset packet loss rate threshold or the transmission rate is less than a preset transmission rate threshold.

[0168] In response to the wireless network shutdown command, the communication interface of the wireless network device is invoked to send a network disconnection request to the wireless network device, instructing the wireless network function device to clear the data packets generated and transmitted by itself during the current wireless network connection; and instructing the wired network function device to perform link unbinding processing, and initialize the device resources of the wired network function device, and clear the data packets transmitted by the wired network function device during the current wireless network connection.

[0169] In the above embodiments, in response to a shutdown command or a wireless network shutdown command, the network disconnection function of the wireless network device is invoked, instructing the wireless network device to perform data cleanup and clear its cache. This is equivalent to reconfiguring the network and assigning a new IP address to the wireless network device every time the virtual machine is started, thereby enhancing the security of the wireless network. Furthermore, device initialization can eliminate configuration errors during the wireless network device setup process, resolve network faults, and improve the reliability of the wireless network connection solution.

[0170] In one embodiment, the virtual machine includes an architecture layer and a native module layer. The architecture layer includes an operating system, and the native module layer includes a virtual network interface card (NIC). The virtual NIC is a wired network mapping device that maps the wired network of the host machine to the virtual machine via NAT mode. Under this architecture, a network connection method is provided, applied to the network devices in the native module layer of the virtual machine, such as... Figure 10 As shown, it includes:

[0171] Step S1001: Disable the wired mapping device of the host machine in the virtual machine and modify the name of the wired mapping device.

[0172] Step S1002: If the name of the wired mapping device is successfully modified, start the wired mapping device.

[0173] Step S1003: In response to the startup command, a wireless network device is created in the native module layer of the virtual machine; the wireless network device includes a wireless network function device and a wired network function device.

[0174] Step S1004: Invoke the initialization function of the wireless network device to instruct the wired network device to establish a link between the wireless network device and the wired network device.

[0175] Step S1005: Turn on the virtual machine's wireless network switch, call the second connection function of the wireless network device, and instruct the wireless network device to call the link creation function of the wired network device. The link creation function is used to instruct the wired network device to create a network connection between the wireless network device and the wired network device based on the link.

[0176] Step S1006: In response to the network connection request, the first connection function of the wireless network device is invoked, instructing the wireless network device to generate a request data packet for wireless network connection. The request data packet is sent to the corresponding external network device through the host's physical network card. The external network device parses and processes the request data packet and returns network connection information.

[0177] Optionally, the first connection function of the wireless network device is invoked, instructing the wireless network device to generate a request data packet for wireless network connection, forwarding the request data packet to the wired network device based on the link, forwarding the request data packet to the switch device of the host machine to which the virtual machine belongs through the virtual network card, translating the address of the request data packet through the switch device, sending the address-translated request data packet to the external network device through the physical network card of the host machine, and instructing the external network device to return network connection information.

[0178] Optionally, the first connection function of the wireless network device is invoked, instructing the wireless network device to generate a request data packet for wireless network connection, forwarding the request data packet to the wired network device based on the link, forwarding the request data packet to the physical network card of the host machine to which the virtual machine belongs through the virtual network card, sending the request data packet to the external network device through the physical network card of the host machine, and instructing the external network device to return network connection information.

[0179] Step S1007: Receive network connection information sent by the wireless network device, and establish a wireless network connection with the wireless network device based on the network connection information.

[0180] Step S1008: Invoke the status acquisition function of the wireless network device, instructing the wireless network device to report the network status of the wireless network corresponding to the virtual machine.

[0181] Step S1009: Receive the network status of the wireless network sent by the wireless network device.

[0182] In step S1010, in response to the power-off command, the network disconnection function of the wireless network device is invoked, instructing the wireless network function device to clean up the associated data between the wireless network device and the wireless network device, and instructing the wired network function device to unbind the link between the wireless network function device and the wired network function device, and initialize the device resources of the wired network function device.

[0183] In the above embodiments, during the virtual machine startup process, a wireless network device is created at the virtual machine's native module layer by executing a driver. Then, a link is established between the wireless network function device and the wired network function device within the wireless network device, providing communication conditions for communication between the wireless network device and external network devices. Based on this, the first connection function of the wireless network device is invoked, enabling the wireless network device to communicate with external network devices based on the established link, receive network connection information allocated by the external network device, and open this wireless network to the virtual machine, thus realizing the virtual machine's wireless network connection. In this way, by implementing a connectable wireless network device at the kernel level, the virtual machine's wireless network connection is achieved, meeting the network access requirements of system applications on the virtual machine. Furthermore, this wireless network connection method is non-intrusive to the virtual machine system, can quickly achieve compatibility with different system versions, and saves network configuration resources.

[0184] In one embodiment, the network connection method is applied in an Android system version upgrade scenario. Each time the Android system version is upgraded, the following steps are executed: In response to a startup command, the driver creates a wireless network device at the native module layer and establishes a wireless network connection with the device; in response to a shutdown command, the data and resources of the wireless network device are cleaned up. If the Android system version is upgraded M times, where M is an integer greater than 1, then the driver needs to be executed M times, creating M wireless network devices and establishing M wireless network connections to support network access for applications on the Android system. In this way, a connectable Wi-Fi device is implemented at the kernel level, ensuring that the entire Android system network connection implementation is completed at the kernel driver layer without any modification to the Android system architecture. This minimizes intrusion into the Android source code and enables rapid compatibility with different Android versions.

[0185] In one specific embodiment, the network connection method can be applied to scenarios where a physical machine includes multiple virtual machines. Each virtual machine, during its startup process, needs to execute the following steps: in response to a startup command, it executes a driver to create a wireless network device at the native module layer and establishes a wireless network connection with the wireless network device; in response to a shutdown command, it cleans up the data and device resources of the wireless network device. If the physical machine includes N virtual machines, each virtual machine needs to execute the above steps once during its startup process, assigning N independent IP addresses to the wireless network devices in the N virtual machines to support the coexistence of each virtual machine on the same physical machine and their independent operation.

[0186] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0187] Based on the same inventive concept, this application also provides a network connection device for implementing the network connection method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more network connection device embodiments provided below can be found in the limitations of the network connection method described above, and will not be repeated here.

[0188] In one embodiment, such as Figure 11 As shown, a network connection device is provided, including: a device creation module 1101, an initialization configuration module 1102, an information acquisition module 1103, and a network connection module 1104, wherein:

[0189] The device creation module 1101 is used to call the driver to create a wireless network device in a virtual machine in response to a startup command; the wireless network device includes wireless network function devices and wired network function devices;

[0190] The initialization configuration module 1102 is used to call the initialization function of the wireless network device and instruct the wired network function device to establish a link between the wireless network function device and the wired network function device.

[0191] Information acquisition module 1103 is used to call the first connection function of the wireless network device, instructing the wireless network device to communicate with external network devices based on the link between the wireless network device and the wired network device to obtain network connection information;

[0192] The network connection module 1104 is used to receive network connection information sent by the wireless network device and establish a wireless network connection with the wireless network device based on the network connection information.

[0193] In one embodiment, the virtual machine includes a virtual network interface card (NIC), which is a wired mapping device of the host machine to which the virtual machine belongs within the virtual machine; the network connection device further includes:

[0194] The name modification module is used to disable the wired mapping device of the host machine in the virtual machine, modify the name of the wired mapping device, and start the wired mapping device if the name modification is successful.

[0195] In one embodiment, the mapping method of the wired mapping device in the virtual machine by the host machine includes any of the following:

[0196] The switching device in the virtual monitor of the host machine translates the Internet Protocol address corresponding to the virtual network card to obtain the communication address for communication between the virtual machine and external network devices; the switching device is also used to identify the data packets returned by the external network devices to the virtual machine based on the communication address and forward the data packets to the virtual machine;

[0197] The router corresponding to the host machine assigns an Internet Protocol (IP) address to the virtual network card that matches the network segment of the host machine, and determines the IP address as the communication address for the virtual machine to communicate with external network devices.

[0198] In one embodiment, the information acquisition module 1103 includes:

[0199] The switch activation unit is used to activate the wireless network switch of the virtual machine, invoke the scanning function of the wireless network device, and instruct the wireless network function device to return the wireless network information of the wireless network function device.

[0200] The information receiving unit is used to receive wireless network information sent by the wireless network device;

[0201] The function call unit is used to call the first connection function of the wireless network device corresponding to the wireless network information.

[0202] In one embodiment, the information acquisition module 1103 is further configured to invoke the first connection function of the wireless network device, instruct the wireless network device to generate a request data packet for wireless network connection, forward the request data packet to the wired network device based on the link, forward the request data packet to the switch device of the host machine to which the virtual machine belongs through the virtual network card, translate the address of the request data packet through the switch device, and interact with the external network device through the physical network card of the host machine after address translation; receive network connection information sent by the wireless network device; the network connection information is returned by the external network device to the wireless network device through the switch device.

[0203] In one embodiment, the information acquisition module 1103 is further configured to invoke the first connection function of the wireless network device, instruct the wireless network device to generate a request data packet for wireless network connection, forward the request data packet to the wired network device based on the link, forward the request data packet received by the wired network device to the physical network card of the host machine to which the virtual machine belongs through the virtual network card, realize communication with the external network device through the physical network card; receive network connection information sent by the wireless network device; the network connection information is returned by the external network device to the wireless network device through the virtual network card.

[0204] In one embodiment, the network connectivity device further includes:

[0205] The link creation module is used to invoke the second connection function of the wireless network device, instructing the wireless network device to invoke the link creation function of the wired network device. The link creation function is used to instruct the wired network device to create a network connection between the wireless network device and the wired network device based on the link.

[0206] In one embodiment, the network connectivity device further includes:

[0207] The status acquisition module is used to call the status acquisition function of the wireless network device, instruct the wireless network device to report the network status of the wireless network corresponding to the virtual machine; and to receive the network status of the wireless network sent by the wireless network device.

[0208] In one embodiment, the network connectivity device further includes:

[0209] The network disconnect module is used to invoke the network disconnect function of the wireless network device, instruct the wireless network device to clean up the associated data between the wireless network device and the wired network device, and instruct the wired network device to unbind the link between the wireless network device and the wired network device, and initialize the device resources of the wired network device.

[0210] In one embodiment, the network disconnect module is further configured to invoke the network disconnect function of the wireless network device in response to a power-off command; or, in response to a wireless network shutdown command, invoke the network disconnect function of the wireless network device.

[0211] During the virtual machine's startup process, the aforementioned network connection device creates a wireless network device at the virtual machine's native module layer by executing a driver. It then establishes a link between the wireless network function device and the wired network function device within the wireless network device, providing communication conditions for communication between the wireless network device and external network devices. Based on this, the first connection function of the wireless network device is invoked, enabling the wireless network device to communicate with external network devices based on the established link. It receives network connection information for the wireless network allocated to it by the external network device and exposes this wireless network to the virtual machine, thus enabling the virtual machine's wireless network connection. For the virtual machine, the wireless network device is a driver device at the native module layer, and the wireless network released by the device is a real and usable wireless network connection. Essentially, when the virtual machine establishes a network connection, it does so by recognizing the wireless network device's wireless network. In other words, the entire wireless network connection process is implemented at the virtual machine's kernel level. This network connection method requires no modification to the architecture layer code, is non-intrusive to the virtual machine, and can be applied to network connection scenarios of different versions of virtual machines. It has strong portability and versatility, avoids reconfiguring the network for different versions of virtual machines, and saves network configuration resources.

[0212] Each module in the aforementioned network connection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0213] In one embodiment, a computer device is provided, which may be a server. One or more virtual machines can be installed on the server. The server's resources, such as processors, memory, and storage, are divided into multiple virtual machine instances. Each virtual machine instance can independently run an operating system and applications, thereby effectively utilizing the server's computing and storage capabilities and reducing hardware resource waste. The server's internal structure diagram can be as follows: Figure 12As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores network connection data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a network connection method.

[0214] In one embodiment, a computer device is provided, which may be a terminal on which one or more virtual machines can be installed. The operating systems of different virtual machines are isolated from each other, supporting flexible switching and use between different systems, and rapidly implementing multi-system testing and development processes. The internal structure diagram of the terminal can be as follows: Figure 13 As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a network connectivity method. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0215] Those skilled in the art will understand that Figure 12 and Figure 13The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0216] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0217] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.

[0218] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0219] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0220] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0221] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0222] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A network connection method, characterized in that, Applied to virtual machines; the method includes: In response to the startup command, the driver is invoked to create a wireless network device in the virtual machine; the wireless network device includes a wireless network function device and a wired network function device; The initialization function of the wireless network device is invoked to instruct the wired network function device to establish a link between the wireless network function device and the wired network function device; The first connection function of the wireless network device is invoked, instructing the wireless network function device to communicate with external network devices based on the link between the wireless network function device and the wired network function device to obtain network connection information; Receive the network connection information sent by the wireless network device, and establish a wireless network connection with the wireless network device based on the network connection information.

2. The method according to claim 1, characterized in that, The virtual machine includes a virtual network interface card (NIC), which is a wired mapping device of the host machine to which the virtual machine belongs in the virtual machine; Before the driver is invoked to create a wireless network device in the virtual machine, the following is also included: The host machine's wired mapping device in the virtual machine is disabled, and the name of the wired mapping device is modified. If the name of the wired mapping device is successfully modified, start the wired mapping device.

3. The method according to claim 2, characterized in that, The mapping method of the wired mapping device in the virtual machine by the host machine includes any of the following: The switch device in the virtual monitor of the host machine converts the Internet Protocol address corresponding to the virtual network card to obtain the communication address for communication between the virtual machine and the external network device; the switch device is also used to identify the data packets returned by the external network device to the virtual machine based on the communication address, and forward the data packets to the virtual machine; The router corresponding to the host machine assigns an Internet Protocol (IP) address to the virtual network card that matches the network segment of the host machine, and determines the IP address as the communication address for the virtual machine to communicate with the external network device.

4. The method according to claim 1, characterized in that, The invocation of the first connection function of the wireless network device includes: Turn on the wireless network switch of the virtual machine, invoke the scanning function of the wireless network device, and instruct the wireless network device to return the wireless network information of the wireless network device; Receive the wireless network information sent by the wireless network device; Invoke the first connection function of the wireless network device corresponding to the wireless network information.

5. The method according to claim 1, characterized in that, The step of invoking the first connection function of the wireless network device, instructing the wireless network function device to communicate with external network devices based on the link between the wireless network function device and the wired network function device, and to obtain network connection information, includes: The first connection function of the wireless network device is invoked to instruct the wireless network function device to generate a request data packet for wireless network connection. Based on the link, the request data packet is forwarded to the wired network function device. The request data packet is forwarded to the switch device of the host machine to which the virtual machine belongs through the virtual network card. The address of the request data packet is translated by the switch device. The address-translated request data packet is then used to interact with the external network device through the physical network card of the host machine. The network connection information sent by the wireless network device is received; the network connection information is returned to the wireless network device by the external network device through the switch device.

6. The method according to claim 1, characterized in that, The step of invoking the first connection function of the wireless network device, instructing the wireless network function device to communicate with external network devices based on the link between the wireless network function device and the wired network function device, and to obtain network connection information, includes: The first connection function of the wireless network device is invoked, instructing the wireless network function device to generate a request data packet for wireless network connection. The request data packet is forwarded to the wired network function device based on the link. The request data packet received by the wired network function device is forwarded to the physical network card of the host machine to which the virtual machine belongs through the virtual network card. Communication with the external network device is realized through the physical network card. The network connection information sent by the wireless network device is received; the network connection information is returned to the wireless network device by the external network device through the virtual network card.

7. The method according to claim 1, characterized in that, Before invoking the first connection function of the wireless network device and instructing the wireless network device to communicate with an external network device based on the link between the wireless network device and the wired network device to obtain network connection information, the method further includes: The second connection function of the wireless network device is invoked, instructing the wireless network device to invoke the link creation function of the wired network device. The link creation function is used to instruct the wired network device to create a network connection between the wireless network device and the wired network device based on the link.

8. The method according to claim 1, characterized in that, The method further includes: Invoke the status acquisition function of the wireless network device, instructing the wireless network device to report the network status of the wireless network corresponding to the virtual machine; Receive the network status of the wireless network sent by the wireless network device.

9. The method according to claim 1, characterized in that, The method further includes: The network disconnect function of the wireless network device is invoked to instruct the wireless network function device to clean up the associated data of the wireless network device and the wired network function device, and to instruct the wired network function device to unbind the link between the wireless network function device and the wired network function device, and to initialize the device resources of the wired network function device.

10. The method according to claim 9, characterized in that, The invocation of the network disconnection function of the wireless network device includes any of the following methods: In response to a power-off command, the network disconnect function of the wireless network device is invoked; In response to the shutdown command of the wireless network, the network disconnection function of the wireless network device is invoked.

11. A network connection device, characterized in that, The device includes: The device creation module is used to call the driver to create a wireless network device in a virtual machine in response to a startup command; the wireless network device includes a wireless network function device and a wired network function device; An initialization configuration module is used to call the initialization function of the wireless network device and instruct the wired network function device to establish a link between the wireless network function device and the wired network function device. The information acquisition module is used to invoke the first connection function of the wireless network device, instructing the wireless network device to communicate with external network devices based on the link between the wireless network device and the wired network device to acquire network connection information; A network connection module is used to receive network connection information sent by the wireless network device and establish a wireless network connection with the wireless network device based on the network connection information.

12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 10.

13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 10.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Virtual base station establishment method and device

    CN103906068A

  • Method using computer with WiFi module and second networking module as external computing unit

    CN104636298A