Network connection method and device, computer equipment, storage medium and program product

By creating wireless network devices at the native module layer of the virtual machine and building internal links, the problem of waste resources and poor universality when the virtual machine connects to the wireless network is solved, and efficient and universal wireless network connection is achieved.

CN119676295AActive Publication Date: 2025-03-21TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the prior art, when virtual machines connect to wireless networks, they need to modify the code of the architecture layer, resulting in reconfiguration after the version is upgraded, which wastes resources and poor versatility, affecting the normal use of some applications.

Method used

By creating a wireless network device at the native module layer of the virtual machine, establishing a link between the wireless network functional device and the wired network functional device, calling the first connection function of the wireless network device to realize communication with the external network device, and obtaining and establishing a wireless network connection.

Benefits of technology

While realizing wireless network connection of virtual machines, it saves configuration resources and is suitable for different versions of virtual machines. It has strong portability and universality, avoiding the need to reconfigure the network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119676295A_ABST
    Figure CN119676295A_ABST
Patent Text Reader

Abstract

The invention relates to a network connection method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: in response to a starting instruction, calling a driving program to create wireless network equipment in a virtual machine; the wireless network device comprises a wireless network function device and a wired network function device; calling an initialization function of the wireless network device, and indicating the wired network function device to establish a link between the wireless network function device and the wired network function device; calling a first connection function of the wireless network device, indicating the wireless network function device to communicate with an external network device based on a link between the wireless network function device and the wired network function device, and obtaining network connection information; and receiving network connection information sent by the wireless network equipment, and establishing wireless network connection with the wireless network equipment according to the network connection information. By adopting the method, wireless network connection of the virtual machine can be realized, and configuration resources are saved at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a network connection method, device, computer equipment, storage medium and program product. Background Art

[0002] In the field of communications, personal computer (PC) mobile operating system virtualization technology refers to running a virtual machine on a personal computer through 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 usage experience.

[0003] In the related art, when a virtual machine connects to a wireless network (WIFI), the code of the system architecture layer of the virtual machine is usually modified, connected, checked and other configuration operations are performed based on the version of the virtual machine to simulate the WIFI function. Once the version of the virtual machine is upgraded and the code of the virtual machine is changed, it needs to be reconfigured, resulting in a large amount of configuration resources being wasted when the virtual machine implements the WIFI function. Summary of the invention

[0004] Based on this, it is necessary to provide a network connection method, device, computer equipment, storage medium and program product that can realize wireless network connection of virtual machines while saving configuration resources in response to the above technical problems.

[0005] The present application provides a network connection method, which is applied to a virtual machine. The method comprises:

[0006] In response to the start instruction, calling a driver 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] Calling the initialization function of the wireless network device to instruct the wired network function device to establish a link between the wireless network function device and the wired network function device;

[0008] calling 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 a link between the wireless network function device and the wired network function device to obtain network connection information;

[0009] The network connection information sent by the wireless network device is received, and a wireless network connection is established with the wireless network device according to the network connection information.

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

[0011] A device creation module, configured to call a driver to create a wireless network device in a virtual machine in response to a startup instruction; the wireless network device includes a wireless network function device and a wired network function device;

[0012] An initialization configuration module, used to call the initialization function of the wireless network device and instruct the wired network function device to build a link between the wireless network function device and the wired network function device;

[0013] an information acquisition module, configured to call the first connection function of the wireless network device, instruct the wireless network function device to communicate with an external network device based on a link between the wireless network function device and the wired network function device, and acquire network connection information;

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

[0015] The present application also provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above network connection method when executing the computer program.

[0016] The present application also provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned network connection method are implemented.

[0017] The present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the above network connection method are implemented.

[0018] The above network connection method, device, computer equipment, storage medium and program product, in response to the startup instruction, call the driver 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; call the initialization function of the wireless network device, instruct the wired network function device to build a link between the wireless network function device and the wired network function device; call the first connection function of the wireless network device, instruct the wireless network function device to communicate with the external network device based on the link between the wireless network function device and the wired network function device, and 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 according to the network connection information. In this method, during the startup process of the virtual machine, the wireless network device is created in the native module layer of the virtual machine by executing the driver, and then the link between the wireless network function device inside the wireless network device and the wired network function device is built, providing communication conditions for the wireless network device to communicate with the external network device. On this basis, the first connection function of the wireless network device is called, so that the wireless network device communicates with the external network device based on the above-built link, receives the network connection information of the wireless network allocated by the external network device to the wireless network device, and opens the wireless network to the virtual machine to realize the wireless network connection of the virtual machine. For a virtual machine, a wireless network device is a driver device of the native module layer inside the virtual machine, and the wireless network released by the wireless network device is a real and available wireless network connection. In this way, when the virtual machine connects to the network, it connects by identifying the wireless network of the wireless network device, so that the entire wireless network connection process is implemented on the kernel of the virtual machine. This network connection method does not require modifying the code of the architecture layer, is non-invasive to the virtual machine, and can be applied to network connection scenarios of virtual machines of different versions. It has strong portability and versatility, avoids reconfiguring the network of virtual machines of different versions, and saves network configuration resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A diagram of an application environment of a network connection method in an embodiment;

[0020] Figure 2 A schematic diagram of a flow chart of a network connection method in an embodiment;

[0021] Figure 3 A schematic diagram of a link between a virtual machine and a physical network card of a host machine in one embodiment;

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

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

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

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

[0026] Figure 8 A signaling interaction diagram of a network connection method in NAT mode in an embodiment;

[0027] Fig. 9 A signaling interaction diagram of a network connection method in a bridge mode in an embodiment;

[0028] Fig.10 is a flowchart of a network connection method in another embodiment;

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

[0030] Fig.12 is an internal structure diagram of a computer device in one embodiment;

[0031] Fig.13 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0033] The network connection method provided in the embodiment of the present application can be applied to 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, and the virtual network card in the virtual machine 104 can communicate with an external network device through the physical network card 102 of the host machine, and the network devices in the external network device include but are not limited to routers, domain name resolution servers, etc.

[0034] Among them, the virtual machine 104 refers to a computer program or system isolated from the host machine's operating system. The virtual machine 104 can simulate a wifi device by modifying the virtual machine interface code, thereby simulating and deceiving the connectivity of the wireless network of the upper-level application of the virtual machine to achieve wireless network connection, such as an Android virtual machine.

[0035] It should be emphasized that Figure 1A virtual machine is used as an example for explanation. In actual application scenarios, the number of virtual machines can be one or more. Furthermore, when multiple virtual machines are included on the same physical server, each virtual machine corresponds to its own operating system and application program, and the operating environment, resources and network of each virtual machine are independent.

[0036] Before describing the network connection method for a virtual machine provided in the present application, the key terms involved in the present application are described first.

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

[0038] NAT mode: Network Address Translation, network address translation mode.

[0039] Frameworks layer: architecture layer.

[0040] Native layer: Native module layer.

[0041] Hook: Hook refers to various technologies that modify or extend the behavior of operating systems, applications, or other software components by intercepting function calls, message passing, and event passing between software modules. Code that handles intercepted function calls, events, and messages.

[0042] API: (Application Programming Interface) is a set of predefined functions that aims 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 LAN standard protocol developed by the IEEE 802 Standards Committee.

[0044] virtio: A standard paravirtualized IO device model.

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

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

[0047] Rtnetlink: An interface in the Linux kernel for managing and manipulating network devices and their properties. It is an extension of the netlink socket protocol specifically 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 above professional data, the technical background of this application is further explained.

[0051] In the field of communications, PC mobile operating system virtualization supports simulating one or more independent and complete computing systems on a personal computer, providing users with a cross-platform experience. Since the virtual machine needs 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 the related technology, in the PC Android virtualization scenario, to realize the wireless network connection of the virtual machine, it is usually necessary to hook, modify, obtain, connect, check the WIFI API of the Android Framework layer, and modify the corresponding return value. This is equivalent to modifying the interface code of the virtual machine to simulate and deceive the connectivity of the upper-level application WIFI, thereby realizing the simulation of the WIFI function.

[0053] However, since the wireless network connection in the related technology is implemented at the architecture layer and is strongly related to the code of the virtual machine, when the network code of the operating system in the virtual machine changes, the entire modification process also needs to be re-implemented to be compatible with the new system version. This configuration method has poor versatility and each configuration requires a large amount of configuration resources.

[0054] In addition, for applications on virtual machines, they are divided into first-category applications and second-category applications according to the different ways in which the applications determine the connectivity of the wireless network. Among them, the first-category application refers to the application that determines the connectivity of the wireless network through the system interface. For the first-category application, the configuration method in the relevant technology can be used to achieve the connection and use of the application. The second-category application refers to the application that determines the connectivity of the wireless network by searching for the driver device. If the driver device exists, it is determined that the wireless network is connected. If the driver device does not exist, it is determined that the wireless network is not connected, and the second-category application cannot be used normally. Since the second-category application does not determine the connectivity of the wireless network through the system interface, and the relevant technology only modifies the system interface, there is no underlying device driver. In this case, the second-category application will obtain the judgment result that the wireless network is not connected, and the normal use of the second-category application is not supported.

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

[0056] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0057] In one embodiment, Figure 2 As shown, a network connection method is provided, which is applied to Figure 1 A virtual machine in; the method comprising:

[0058] Step S202, in response to the start instruction, calling the driver 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] Among them, a virtual machine refers to a virtual machine that has been created and not started on a physical machine, including an architecture layer and a native module layer. The architecture layer provides a running environment for applications and is responsible for managing the memory and resources of the device. The native module layer includes multiple libraries, each of which provides an interface for a specific type of hardware or function, providing underlying hardware access and system function support. The network connection method provided in this application is triggered by the operating system of the architecture layer in the virtual machine and executed by the network device of the native module layer. By executing operations such as driver device creation and connection at the native module layer, the wireless network connection of the virtual machine is realized.

[0060] The startup command refers to the command triggered when the 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 automatically after the virtual machine is created.

[0061] In response to the startup instruction, the driver preset in the native module layer is called and executed, and the wireless network device wlan0 is created in the native module layer (kernel layer) of the virtual machine as the wireless network driver device inside the virtual machine. The wireless network device is used to realize the conversion from the wired network protocol to the wireless network protocol (80211 protocol), including the interface capabilities such as scanning, connecting, disconnecting, and obtaining status, corresponding to a preset connectable wireless network.

[0062] To achieve the conversion of network protocols, the wireless network device needs to first access the wired network, then convert the wired network into a wireless network, and then provide the wireless network to the operating system of the virtual machine to achieve the wireless network connection of the virtual machine. Based on different functions, the wireless network device includes a wireless network function device and a wired network function device. The wired network function device is used to connect the wireless network device and the wired network of the host machine to which the virtual machine belongs, and provide the wireless network function device with the network connection information of the wireless network. The wireless network function device is used to provide the received network connection information to the virtual machine system to achieve the wireless network connection.

[0063] When creating a wireless network device, it can be divided into two sub-steps: creating a wireless network functional device and creating a wired network functional device. The present application does not limit the execution order of the two sub-steps. It can be to create a wired network functional device first, and then create a wireless network functional device; it can also be to create a wireless network functional device first, and then create a wired network functional device; it can also be to create a wireless network functional device and a wired network functional device at the same time.

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

[0065] It should be understood that, for the operating system in the virtual machine, the wireless network functional device and the wired network functional device are a whole, that is, the operating system in the virtual machine communicates with the wireless network device to instruct the wireless network functional device or the wired network functional device in the wireless network device to execute steps matching the communication content. For the wireless network device, after creating the wireless network functional device and the wired network functional device, it is necessary to further configure the network to ensure the availability of the communication link inside the wireless network device.

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

[0067] In actual applications, when a wireless network device is created but not yet initialized, the initialization (Setup) function of the wireless network device is called, which is also used to instruct the wireless network device to bind the net_device_ops structure to the network function device operation pointer. The structure contains function functions such as opening the network device, stopping the wireless network device, and sending data packets.

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

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

[0070] In the wireless network connection process, the network connection information refers to the basic information required by the virtual machine to connect to the network, including but not limited to the wireless network name SSID, wireless network key, router IP address, device address, etc. The external network device in the embodiment of the present application refers to a network device that is outside the host machine to which the virtual machine belongs and provides network connection information services for the virtual machine, such as a router that provides data packet forwarding services, a server that provides the IP address of the router, etc.

[0071] The wireless network device corresponds to a preset wireless network. When the operating system of the virtual machine detects that a wireless network device has been created at the native module layer, the wireless network to be connected is also pre-defined. At this time, the first connection function of the wireless network device can be directly called to instruct the wireless network function 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 function device and the wired network function device. The physical network card then communicates with the external network device to obtain network connection information.

[0072] Exemplarily, a communication interface of a wireless network device is called 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 for obtaining network connection information based on the wireless network connection request, and 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 an external network device, the external network device parses and processes the request data packet to generate network connection information, and correspondingly, the external network device sends the network connection information to the wireless network function device via the physical network card and the wired network function device in turn, thereby completing two-way communication between the wireless network function device and the external network device.

[0073] Step S208: receiving the network connection information sent by the wireless network device, and establishing a wireless network connection with the wireless network device according to the network connection information.

[0074] Receiving the network connection information sent by the wireless network device means that the wireless network device supports the virtual machine connection with the wireless network corresponding 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 is connected to the wireless network, it can further verify the connection status of the wireless network, disconnect the wireless network, and so on.

[0076] In the above network connection method, during the startup process of the virtual machine, a wireless network device is created in the native module layer of the virtual machine by executing the driver, and then a link between the wireless network function device inside the wireless network device and the wired network function device is built, so that the wireless network device and the external network device communicate with each other. Provide communication conditions. On this basis, call the first connection function of the wireless network device so that the wireless network device communicates with the external network device based on the above-built link, receives the network connection information of the wireless network allocated by the external network device to the wireless network device, and opens the wireless network to the virtual machine to realize the wireless network connection of the virtual machine. For the virtual machine, the wireless network device is a driver device of the native module layer inside the virtual machine, and the wireless network released by the wireless network device is a real and available wireless network connection. In this way, when making a network connection, the wireless network of the wireless network device is connected by identifying the wireless network, so that the entire wireless network connection process is implemented on the kernel of the virtual machine. Such a network connection method does not need to modify the code of the architecture layer, is not invasive to the virtual machine, can be applied to the network connection scenarios of virtual machines of different versions, has strong portability and versatility, avoids the reconfiguration of the network of virtual machines of different versions, and saves network configuration resources.

[0077] The network identification logic of the operating system and upper-layer system applications in the virtual machine is: identify the network according to 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, the purpose of the network connection in the embodiment of the present application 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, etc., to avoid the virtual machine actively connecting to the wired mapping device. Below, the implementation method of modifying the name of the wired mapping device is described through an embodiment.

[0078] In one embodiment, the virtual machine includes a virtual network card, which is a wired mapping device of a host machine to which the virtual machine belongs in the virtual machine; before calling a driver to create a wireless network device in the virtual machine, it also includes:

[0079] The wired mapping device of the host machine in the virtual machine is turned off, and the name of the wired mapping device is modified; if the name of the wired mapping device is modified successfully, the wired mapping device is started.

[0080] See also Figure 3 , Figure 3 This is a schematic diagram of the link between the virtual machine and the host machine's physical network card. Figure 3 The virtual machine includes a virtual network card, which can be created by the virtual machine monitor vbox in the native module layer of the virtual machine, that is, the kernel layer, and specifically 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. The embodiment of the present application does not limit the mapping method of the wired network, such as NAT mode, bridge mode, etc.

[0081] After the virtual network card exists in the virtual machine and before the wireless network device is created, the name of the virtual network card (that is, the wired mapping device) is modified. The name of the wired mapping device before the modification is "eth0", and the name of the wired mapping device after the modification can be any name different from "eth0", such as "eeth0". In addition, it should be emphasized that in the field of communications, the name of the wired mapping device cannot be modified during operation, so it is necessary to shut down the wired mapping device before the name is modified, and then start the wired mapping device after the name is modified.

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

[0083] In another implementation scenario, the name modification program for the wired mapping device is independent of the driver program. In this scenario, in response to the startup instruction, the name modification program is first executed to implement 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 program is executed to create a 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, when the name of the wired mapping device is successfully modified, the wired mapping device is started. In this way, the name of the wired mapping device is modified without modifying the default network connection priority of the virtual machine, which can ensure that the virtual machine does not actively connect to the wired mapping device, thereby avoiding the wired mapping device from interfering with the wireless network device created in this embodiment.

[0085] Next, another implementation of modifying the network identification logic of the virtual machine is described: In one embodiment, the virtual machine includes a virtual network card, which is a wired mapping device of the host machine to which the virtual machine belongs in the virtual machine; before calling the driver to create a wireless network device in the virtual machine, it also includes:

[0086] Change the default value of the network connection from the name of the wired mapping device to the name of the wireless network of the wireless networking 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. In this way, the network identification logic of the virtual machine is modified without modifying the name of the wired mapping device. This can ensure that the virtual machine does not actively connect to the wired mapping device, thereby avoiding the wired mapping device interfering with the wireless network device created in this embodiment.

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

[0089] The modification of the name of the wired mapping device (virtual network card) in the above-mentioned embodiment is based on the virtual machine having created a virtual network card, and the virtual network card is mapped to the virtual machine based on the wired network of the host machine to which the virtual machine belongs. In the field of communications, the host machine's wired network can be mapped to the virtual machine in network address translation mode (NAT), bridged mode, etc. Based on this, the implementation method of mapping the host machine's wired network to the virtual machine is described below.

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

[0091] The switch device in the virtual monitor in the host machine converts the Internet Protocol address corresponding to the virtual network card to obtain the communication address for the virtual machine to communicate with the external network device; the switch device is also used to identify the data packet returned by the external network device to the virtual machine based on the communication address, and forward the data packet to the virtual machine;

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

[0093] Taking the virtual machine as an Android virtual machine as an example, before explaining the mapping method, the purpose of mapping is first explained: in the PC Android virtualization scenario, the host machine's wired network is mapped to the virtual machine, which means that the virtual machine has a network inside and has the ability to communicate with external network devices. Based on this, the basis for the successful mapping of 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: Use the virtual monitor in the host machine to map the host machine's wired network to the virtual machine to obtain a virtual network card. In this mapping scenario, see Figure 4 , Figure 4 This is a schematic diagram of the communication between the virtual network card in the virtual machine and the physical network card of the host machine. Figure 4 In the embodiment, the virtual network card sends a request data packet to the switch device, and the switch device converts the internal Internet Protocol address (internal IP address) of the virtual network card carried in the request data packet into the IP address (external IP address) of the physical network card of the host machine. Furthermore, the request data packet sent by the virtual network card is sent to the external network device through the physical network card of the host machine, so as to realize the communication between the virtual network card and the external network device. Correspondingly, the external network device processes the request data packet to obtain a response data packet, and the external network device sends the response data packet to the physical network card of the host machine. The physical network card of the host machine sends the response data packet to the switch device, and the switch device converts the external IP address carried in the response data packet into the internal IP address, and returns the content of the response data packet to the virtual network card corresponding to the internal IP address, so as to realize the communication between the external network device and the virtual network card. In this way, by converting the address of the virtual network card by the switch device, the address of the physical network card of the host machine is used as the communication address for the virtual network card to communicate with the external network device, so as to realize the two-way communication between the external network device and the virtual network card. In the above NAT mode, the IP addresses of the virtual machine and the host machine are different, which can avoid IP conflicts and insufficient IP addresses. It is suitable for scenarios with a large number of users.

[0095] The second mapping method: bridge the wired network of the host machine to the virtual machine. The network segment of the host machine refers to an IP address range. Devices in the same network segment can communicate directly without router forwarding. In the embodiment of the present application, an IP address is assigned to the virtual network card from the set of IP addresses covered by the network segment of the host machine, so that the virtual network card and the host machine are in the same network segment. Since the host machine can communicate directly with external network devices through the physical network card, the virtual network card in the same network segment as the host machine can also communicate directly with external network devices through the physical network card. In this mapping scenario, please refer to Figure 5 , Figure 5 This is a schematic diagram of the communication between the virtual network card in the virtual machine and the physical network card of the host machine. Figure 5 In the process, the virtual network card sends a request data packet to the physical network card of the host machine, and the physical network card of the host machine sends the request data packet to the external network device. Correspondingly, the external network device processes the request data packet to obtain a response data packet. The external network device sends the response data packet to the physical network card of the host machine, and the physical network card of the host machine sends the response data packet to the virtual network card. In this way, based on the network segment of the host machine, an independent IP address that supports direct communication with the external network device is allocated to the virtual network card, thereby realizing two-way communication between the external network device and the virtual network card. In the above-mentioned bridging mode, the virtual machine and the host machine have the same IP address network segment, which will occupy the IP of the host machine's network segment. In order to avoid IP conflicts and insufficient IPs caused by too many users, it is usually used in scenarios with a small number of users.

[0096] In summary, in actual application, when the number of users of the virtual machine is greater than or equal to the user threshold, the first NAT mode can be used to map the wired network of the host machine. When the number of users of the virtual machine is less than the user threshold, the second bridge mode can be used to map the wired network of the host machine.

[0097] In the above embodiment, two mapping methods of mapping the wired network of the host machine to the virtual machine are provided. One is a method of converting the address of the virtual network card through the switch device in the virtual monitor in the host machine, and using the address of the physical network card of the host machine as the communication address for the virtual network card to communicate with the external network device, thereby realizing two-way communication between the external network device and the virtual network card. The other is a method of assigning an Internet Protocol address that matches the network segment of the host machine to the virtual network card through the router corresponding to the host machine, and determining the Internet Protocol address as the communication address for the virtual machine to communicate with the external network device, thereby realizing two-way communication between the external network device and the virtual network card. The above two different mapping methods are suitable for the realization of internal access network of virtual machines in different application scenarios, thereby improving the scenario applicability and flexibility of the network connection method of the virtual machine.

[0098] The wireless network switch of the virtual machine can be turned on by default during the startup process. In this way, after the wireless network device is created in the virtual machine, the operating system of the virtual machine can promptly perceive the wireless network device, quickly call the first connection function of the wireless network device, obtain the wireless network provided by the wireless network device, and establish a wireless network connection. Next, the scenario of calling the first connection function is described.

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

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

[0101] Turn on the wireless network switch of the virtual machine, and periodically or in real time detect whether there is a wireless network driver device in the native module layer. Then, when the wireless network device is created, it is detected that there is a wireless network device in the native module layer, and the operating system in the virtual machine triggers a scan request. The network device in the kernel layer, such as the processor, responds to the scan request and calls the scan function of the wireless network device, instructing the wireless network function device in the wireless network device to return the wireless network information of the wireless network function device.

[0102] Among them, 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 called to send a connection request for the wireless network corresponding to the wireless network information to the wireless network device to instruct the wireless network function device in the wireless network device to return the network connection information.

[0104] In an embodiment of the present application, the difference between wireless network information and network connection information is that the wireless network information is the response result of the scanning function, which is used to describe the basic information of the wireless network and does not include the IP address of the wireless network; the network connection information is the response result of the connection function after scanning, which is used for the virtual machine to connect to the wireless network, including the IP address, gateway and other connection information of the wireless network, and may also include wireless network information.

[0105] See also Figure 6 , Figure 6 The wireless network switch is turned on for the virtual machine. The virtual machine performs network scanning and connects to the wireless network. Figure 6In the example, the wireless network name is "AbcWifi". Figure 6 The interface shown can also display information such as network preferences, number of saved networks, and traffic consumption. Figure 7 for Figure 6 A schematic diagram of the interface showing network connection information based on the wireless network that has been connected. Figure 7 The displayed network connection information includes the signal strength, frequency, security, whether automatic connection is supported, etc. of the wireless network.

[0106] In the above embodiment, the wireless network switch of the virtual machine is turned on, and the scanning function of the wireless network device is called to timely perceive the wireless network information of the wireless network function device of the wireless network, and the first connection function of the wireless network device corresponding to the wireless network information is called. 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 result to the operating system of the virtual machine to improve the calling speed of the first connection function.

[0107] In another implementation scenario, since the wireless network device is pre-set with a wireless network, the operating system in the virtual machine simultaneously obtains the wireless network information while scanning the wireless network device. Based on this, there is no need to wait for the wireless network device to return the wireless network information. The operating system can directly trigger a connection request to actively connect to the wireless network preset by the wireless network device.

[0108] Exemplarily, calling the first connection function of the wireless network device includes: turning on the wireless network switch of the virtual machine, and calling the first connection function of the wireless network device. In this way, after turning on the wireless network switch, the preset wireless network can be directly connected without waiting for the scan result to be returned before connecting, further optimizing the connection efficiency of the entire wireless network.

[0109] In the process of realizing the network connection, the purpose of calling the first connection function is for the wireless network device to return the network connection information, and the wireless network device realizes the communication with the external network device based on the link between the wireless network function device and the wired network function device, the link between the wired network function device and the virtual network card, the link between the virtual network card and the physical network card, and the link between the physical network card and the external network device. Among them, the link between the virtual network card and the physical network card can be established through the NAT mode. For the specific implementation method, please refer to the above embodiment for Figure 4 The link between the virtual network card and the physical network card can be established through the bridge mode. For specific implementation methods, please refer to the above embodiment for Figure 5 Description.

[0110] The following is an example. Figure 4In the scenario shown, in which the link between the virtual network card and the physical network card is established through the NAT mode, the first connection function of the wireless network device is called on the virtual machine, and the wireless network device communicates with the external network device to obtain the implementation method of network connection information.

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

[0112] Call the first connection function of the wireless network device, instruct the wireless network function device to generate a request data packet for the wireless network connection, forward the request data packet to the wired network function 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, convert 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 the address conversion; receive the network connection information sent by the wireless network device; the network connection information is returned to the wireless network device by the external network device through the switch device.

[0113] The first connection function interface of the wireless network device is called to send a network connection request to the wireless network device. The wireless network function device generates a request data packet based on the network connection request. The number of request data packets is usually multiple, which are sent to different external network devices accordingly. The wireless network function device forwards the request data packet to the wired network function device based on the link between the wireless network function device and the wired network function device. The wired network function device forwards the request data packet to the virtual network card based on the link between the wired network function device and the virtual network card. The virtual network card forwards the request data packet to the switch device based on the link between the virtual network card and the switch device. The switch device converts the sending address of the request data packet, that is, the internal address of the virtual network card, into the address of the physical network card, and sends the request data packet after the address conversion to the external network device corresponding to each request data packet through the physical network card. Each external network device parses and processes the request data packet received by itself to generate network connection information. Correspondingly, the external network device sends the network connection information to the switch device through the physical network card. The switch device converts the recipient address in the network connection information and determines 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] Take the Android system as an example. Figure 8 As shown, Figure 8The signaling interaction diagram of the network connection method in the scenario where the host machine's wired network is mapped to the Android virtual machine in NAT mode includes:

[0115] Step S801: The Android system sends a network connection request to a wireless network device.

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

[0117] Step S803: The wireless network function device sends a request data packet to the switch device based on the link between the wireless network function device and the wired network function device, the link between the wired network function device and the virtual network card, and the link between the virtual network card and the switch device.

[0118] Step S804: the switch device converts the intranet address of the wireless network device carried in the request data packet to obtain a request data packet after the address conversion.

[0119] Step S805: the switch device sends the request data packet after the address translation to the corresponding external network device through the physical network card of the host machine.

[0120] 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 physical network card of the host machine.

[0122] Step S808: The switch device converts the receiver address in the network connection information, and identifies that the receiver of the network connection information is a virtual network card.

[0123] Step S809: The switch device sends the 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] Step S810: The wireless network function device returns network connection information to the Android system.

[0125] In the above embodiment, in the scenario where the wired network of the host machine is mapped to the virtual machine using the address translation mode, the first connection function of the wireless network device is called to instruct the wireless network function device to interact with data packets based on the link between the wireless network function device and the wired network function device, the link between the wired network function device and the virtual network card, the link between the virtual network card and the switch device, the link between the switch device and the physical network card, and the link between the physical network card and the external network device, so as to achieve clear and explicit logic and easy deployment in various physical machines.

[0126] The following is an example. Figure 5 In the scenario shown, in which the link between the virtual network card and the physical network card is established through the bridge mode, the first connection function of the wireless network device is called on the virtual machine, and the wireless network device communicates with the external network device to obtain the implementation method of network connection information.

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

[0128] Call the first connection function of the wireless network device, instruct the wireless network function device to generate a request data packet for the wireless network connection, forward the request data packet to the wired network function device based on the link, forward the request data packet received by the wired network function device to the physical network card of the host machine to which the virtual machine belongs through the virtual network card, and realize communication with the external network device through the physical network card; receive the network connection information sent by the wireless network device; the network connection information is returned to the wireless network device by the external network device through the virtual network card.

[0129] The operating system in the virtual machine sends a network connection request to the wireless network device by calling the communication interface of the wireless network device. The wireless network function device generates a request data packet based on the network connection request. The number of request data packets is usually multiple and sent to different external network devices accordingly. The wireless network function device forwards the request data packet to the wired network function device based on the link between the wireless network function device and the wired network function device. The wired network function device forwards the request data packet to the virtual network card based on the link between the wired network function device and the virtual network card. The virtual network card forwards the request data packet to the physical network card based on the link between the virtual network card and the physical network card. The physical network card parses each request data packet, determines the external network device of each request data packet, and sends each request data packet to the external network device corresponding to each request data packet. Each external network device parses and processes the request data packet received by itself to generate network connection information. Accordingly, the external network device sends the network connection information to the virtual network card through the physical 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, and the wireless network function device returns the network connection information to the operating system of the virtual machine.

[0130] Let's continue to use the Android system as an example. Fig. 9 As shown, Fig. 9 The signaling interaction diagram of the network connection method in the scenario where the host machine's wired network is mapped to the Android virtual machine in bridge mode includes:

[0131] Step S901: The Android system sends a network connection request to a wireless network device.

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

[0133] Step S903: the wireless network function device sends the request data 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] Step S904: The virtual network card instructs the physical network card through the host machine's physical network card to determine a receiving device for the request data packet, and sends the request data packet to the corresponding network device.

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

[0136] Step S906: The external network device sends network connection information to the virtual network card through the physical network card of the host machine.

[0137] Step S907: The virtual network card sends the 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 function device sends network connection information to the Android system.

[0139] In the above embodiment, in the scenario where the wired network of the host machine is mapped to the Android virtual machine in a bridging manner, the first connection function of the wireless network device is called to instruct the wireless network function device to interact with data packets based on the link between the wireless network function device and the wired network function device, the link between the wired network function device and the virtual network card, the link between the virtual network card and the physical network card, and the link between the physical network card and the external network device, so as to achieve clear and explicit logic and easy deployment in various physical machines.

[0140] The communication between a wireless network device and an external network device can be understood as the sending and receiving of data packets, and the communication conditions at least include that the internal link of the wireless network device is connected and in an available state. The above embodiments describe the steps of creating a link and using the link to interact with data packets. Next, through an embodiment, the implementation steps of the link supporting the data packet transmission function in the scenario after the link is created and before the link is used are described.

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

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

[0143] The operating system in the virtual machine calls the communication interface of the wireless network device, sends a second connection request to the wireless network device, calls the second connection function of the wireless network device, and instructs the wireless network function device in the wireless network device to call 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 with the wireless network function device based on the link, so that data between the wireless network function device and the wired network function device are connected to each other to support data interaction between the two devices.

[0144] It should be emphasized 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 to establish a network link between the devices is equivalent to the wireless network function device activating the link between the wired network function device and the wireless network function device to facilitate the subsequent transmission of data packets between the wireless network function device and the wired network function device.

[0145] In the above embodiment, 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, which is equivalent to activating the link function between the wireless network function device and the wired network function device in the wireless network device, and provides communication conditions for subsequent link-based data packet transmission between the wireless network function device and the wired network function device, so that the wireless network device can smoothly obtain network connection information, thereby improving the efficiency of the virtual machine receiving the network connection information returned by the wireless network device.

[0146] On the basis that the virtual machine has been connected to the wireless network provided by the wireless network device, the virtual machine can periodically detect the network status of the wireless network at a preset time interval, evaluate the current wireless network quality, and then execute a network connection plan that matches the evaluation result, such as continuing to connect to the wireless network, disconnecting the wireless network, etc.

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

[0148] The state acquisition function of the wireless network device is called to instruct the wireless network function device to report the network state of the wireless network corresponding to the virtual machine; and the network state of the wireless network sent by the wireless network device is received.

[0149] The network status refers to the status attribute information describing the wireless network in 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 transmitted data packets, the number of data packets that failed to be transmitted, etc.

[0150] Call the communication interface of the wireless network device, send a status acquisition request to the wireless network device, and instruct the wireless network function device in the wireless network device to package the network status of its corresponding wireless network and return it 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 subsequent network connection plans according to the network status, such as disconnecting the wireless network, issuing an indication that the wireless network signal strength is weak, etc.

[0151] In an achievable application scenario, the network state may be attribute information of the wireless network detected in real time by the wireless network function device. After receiving the network state of the wireless network, the virtual machine compares the reference network state with the received network state to obtain a quantitative value of the difference between the current network state and the reference network state.

[0152] For example, the absolute values ​​of the data in the reference network state and the data in the current network state under the same quantitative index are obtained to obtain the corresponding absolute value sets under multiple groups of quantitative indicators, and then each absolute value in the absolute value set is normalized, and the mean of the normalized absolute values ​​is calculated to obtain the difference quantitative value between the current network state and the reference network state.

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

[0154] In another possible application scenario, the network state can be the attribute information of the wireless network detected in real time by the wireless network function device, and the difference quantization value obtained by comparing the reference network state with the network state, after receiving the difference quantization value, the virtual machine compares the difference quantization value with the preset difference quantization threshold, if the difference quantization value is less than the difference quantization threshold, then continue to maintain the connection with the wireless network, if the difference quantization value is greater than the difference quantization threshold, then send out the indication information of the weak signal strength of the wireless network. The method of obtaining the difference quantization value in this application scenario and the comparison basis are consistent with the content in the above application scenario, and the specifics can be found in the description of the above application scenario, which will not be repeated here.

[0155] In the above embodiment, the status acquisition function of the wireless network device is called to instruct the wireless network function device to report the network status of the wireless network corresponding to the virtual machine, and the network status of the wireless network sent by the wireless network device is received to perceive the change of the network status of the wireless network, and then execute the network connection action matching the current network status to determine the service availability of the virtual machine.

[0156] It can be seen from the above embodiments that the network quality can be evaluated according to the received network status, and the network connection can be disconnected when the network quality is poor. Next, the implementation method of network disconnection is described through an embodiment. Then in one embodiment, the method further includes:

[0157] Call the network disconnection 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, send a network disconnection request to the wireless network device, instruct the wireless network function device to perform a data cleaning operation, and clear 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] Call the communication interface of the wireless network device, send a network disconnection request to the wireless network device, and also 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 cleaning step of the wireless network functional device and the link unbinding step of the wired network functional device can be executed in parallel or in series. In addition, in the case of series execution, there is no restriction on the execution order of the data cleaning step and the link unbinding step, for example, the data cleaning step of the wireless network functional device is performed first, and then the link unbinding is performed by the wired network functional device, or the link unbinding is performed first by the wired network functional device, and then the data cleaning step of the wireless network functional device is performed.

[0161] In the above embodiment, the network disconnection function of the wireless network device is called to instruct the wireless network function device to clean up the associated data between the wireless network device and the wireless network 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 initialize the device resources of the wired network function device, restore the wireless network device to the initial state originally created, clean up the cached data of the wireless network device, and improve the operating speed and performance of the wireless network device.

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

[0163] In response to the shutdown instruction, calling a network disconnection function of the wireless network device;

[0164] In response to the shutdown instruction of the wireless network, a network disconnection function of the wireless network device is called.

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

[0166] In response to a shutdown instruction, the communication interface of the wireless network device is called 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 process; 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 process.

[0167] The wireless network shutdown instruction may be automatically triggered when the virtual machine detects that the network connection quality of the current wireless network is poor, for example, the packet loss rate is greater than a preset packet loss rate threshold, and the transmission rate is less than a preset transmission rate threshold.

[0168] In response to a shutdown instruction of the wireless network, the communication interface of the wireless network device is called 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 process; 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 process.

[0169] In the above embodiment, in response to a shutdown instruction or a wireless network shutdown instruction, the network disconnection function of the wireless network device is called to instruct the wireless network device to clean up data and clear the cache of the wireless network device, which is equivalent to reconfiguring the network each time the virtual machine is started, and assigning a new IP address to the wireless network device to enhance the security of the wireless network. In addition, device initialization can also eliminate configuration errors in the wireless network device setting process, solve network failures, and improve the reliability of the wireless network connection solution.

[0170] In one embodiment, a 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 card. The virtual network card is a wired mapping device that maps the wired network of the host machine to which the virtual machine belongs to the virtual machine to the virtual machine through a NAT mode. Under this architecture, a network connection method is provided, which is applied to a network device of a native module layer in a virtual machine, such as Fig.10 As shown, including:

[0171] Step S1001, shut down the wired mapping device of the host machine in the virtual machine, and modify the name of the wired mapping device.

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

[0173] Step S1003, in response to the start instruction, a wireless network device is created in the native module layer in the virtual machine; the wireless network device includes a wireless network function device and a wired network function device.

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

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

[0176] Step S1006, in response to the network connection request, call the first connection function of the wireless network device, instruct the wireless network function device to generate a request data packet for the wireless network connection, send the request data packet to the corresponding external network device through the physical network card of the host machine, and the external network device parses and processes the request data packet and returns the network connection information.

[0177] Optionally, the first connection function of the wireless network device is called to instruct the wireless network function device to generate a request data packet for the wireless network connection, the request data packet is forwarded to the wired network function device based on the link, 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 converted through the switch device, the request data packet after the address conversion is sent to the external network device through the physical network card of the host machine, and the external network device is instructed to return the network connection information.

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

[0179] Step S1007: receiving network connection information sent by the wireless network device, and establishing a wireless network connection with the wireless network device according to the network connection information.

[0180] Step S1008: calling a status acquisition function of a wireless network device to instruct the wireless network function device to report a network status of the wireless network corresponding to the virtual machine.

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

[0182] Step S1010, in response to the shutdown instruction, calling the network disconnection function of the wireless network device, 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 embodiment, during the startup process of the virtual machine, a wireless network device is created in the native module layer of the virtual machine by executing the driver, and then a link is established between the wireless network function device inside the wireless network device and the wired network function device, providing communication conditions for the wireless network device to communicate with the external network device. On this basis, the first connection function of the wireless network device is called so that the wireless network device can communicate with the external network device based on the above established link, receive the network connection information of the wireless network allocated by the external network device to the wireless network device, and open the wireless network to the virtual machine to realize the wireless network connection of the virtual machine. In this way, by realizing a connectable wireless network device on the kernel, the wireless network connection of the virtual machine is realized, and the network access requirements of the system application on the virtual machine are met. In addition, the above wireless network connection method is not invasive to the virtual machine system, can be quickly compatible with different versions of systems, and save network configuration resources.

[0184] In one embodiment, the network connection method is applied to the Android system version upgrade scenario. Each time the Android system version is upgraded, the following process steps are executed: in response to the startup instruction, the driver is executed to create a wireless network device at the native module layer, and a wireless network connection is established with the wireless network device. In response to the shutdown instruction, the data and device resources of the wireless network device are cleaned up. If the Android system version is upgraded M times, M is an integer greater than 1, it is necessary to execute the driver M times, create M wireless network devices, and achieve M wireless network connections to support network access for applications on the Android system. In this way, a connectable WIFI device is implemented on the kernel, so that the implementation scheme of the entire Android system network connection is completed in the kernel driver layer without any modification to the architecture layer of the Android system. It is less invasive to the Android source code and can be quickly compatible with different versions of Android systems.

[0185] In a specific embodiment, the network connection method can be applied to a scenario where a physical machine includes multiple virtual machines. During the startup process, each virtual machine needs to execute the following process steps: in response to the startup instruction, execute the driver to create a wireless network device at the native module layer and establish a wireless network connection with the wireless network device, and in response to the shutdown instruction, clean 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 the startup process, and allocate 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 various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0187] Based on the same inventive concept, the embodiment of the present application also provides a network connection device for implementing the network connection method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more network connection device embodiments provided below can refer to the limitations on the network connection method above, and will not be repeated here.

[0188] In one embodiment, Fig.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 the virtual machine in response to the startup instruction; the wireless network device includes a wireless network function device and a wired network function device;

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

[0191] The information acquisition module 1103 is used to call the first connection function of the wireless network device, instruct the wireless network function device to communicate with the external network device based on the link between the wireless network function device and the wired network function device, and acquire 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 according to the network connection information.

[0193] In one embodiment, the virtual machine includes a virtual network card, which is a wired mapping device of a host machine to which the virtual machine belongs in the virtual machine; the network connection device also includes:

[0194] The name modification module is used to close the wired mapping device of the host machine in the virtual machine and modify the name of the wired mapping device; when the name of the wired mapping device is successfully modified, the wired mapping device is started.

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

[0196] The switch device in the virtual monitor in the host machine converts the Internet Protocol address corresponding to the virtual network card to obtain the communication address for the virtual machine to communicate with the external network device; the switch device is also used to identify the data packet returned by the external network device to the virtual machine based on the communication address, and forward the data packet to the virtual machine;

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

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

[0199] A switch-on unit, used to turn on the wireless network switch of the virtual machine, call 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] An information receiving unit, used for receiving wireless network information sent by a wireless network device;

[0201] The function calling 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 also used to call the first connection function of the wireless network device, instruct the wireless network function device to generate a request data packet for the wireless network connection, forward the request data packet to the wired network function 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, convert 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 the address conversion; receive the network connection information sent by the wireless network device; the network connection information is returned to the wireless network device by the external network device through the switch device.

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

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

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

[0206] In one embodiment, the network connection 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 function device to report the network status of the wireless network corresponding to the virtual machine; and receive the network status of the wireless network sent by the wireless network device.

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

[0209] The network disconnection module is used to call the network disconnection function of the wireless network device, instruct the wireless network function device to clean up the associated data of 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.

[0210] In one embodiment, the network disconnection module is further used to call the network disconnection function of the wireless network device in response to a shutdown instruction; or, in response to a shutdown instruction of the wireless network, call the network disconnection function of the wireless network device.

[0211] During the startup process of the virtual machine, the network connection device creates a wireless network device in the native module layer of the virtual machine by executing the driver, and then builds a link between the wireless network function device inside the wireless network device and the wired network function device, providing communication conditions for the wireless network device to communicate with the external network device. On this basis, the first connection function of the wireless network device is called, so that the wireless network device communicates with the external network device based on the above-built link, receives the network connection information of the wireless network allocated by the external network device to the wireless network device, and opens the wireless network to the virtual machine to realize the wireless network connection of the virtual machine. For the virtual machine, the wireless network device is a driver device of the native module layer inside the virtual machine, and the wireless network released by the wireless network device is a real and available wireless network connection, which is equivalent to the virtual machine connecting to the network by identifying the wireless network of the wireless network device, that is, the entire wireless network connection process is implemented on the kernel of the virtual machine. Such a network connection method does not need to modify the code of the architecture layer, is not invasive to the virtual machine, can be applied to the network connection scenarios of virtual machines of different versions, has strong portability and versatility, avoids the reconfiguration of the network of virtual machines of different versions, and saves network configuration resources.

[0212] Each module in the above network connection device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0213] In one embodiment, a computer device is provided, which may be a server. One or more virtual machines may be installed on the server. The server resources, such as processor, memory, storage, etc., are divided into multiple virtual machine instances. Each virtual machine instance may independently run an operating system and application programs, thereby effectively utilizing the computing and storage capabilities of the server and reducing hardware resource waste. The internal structure diagram of the server may be as follows: Fig.12As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store network connection data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a network connection method is implemented.

[0214] In one embodiment, a computer device is provided, which may be a terminal. One or more virtual machines may be installed on the terminal. The operating systems of different virtual machines are isolated from each other, and flexible switching and use between different systems are supported to quickly implement multi-system testing and development processes. The internal structure diagram of the terminal may be as follows: Fig.13 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a network connection method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0215] Those skilled in the art will understand that Fig.12 and Fig.13The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0216] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0217] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

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

[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, stored data, displayed data, 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 relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0220] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium 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), magnetoresistive 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. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0221] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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 above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A network connection method, characterized in that: Applied to a virtual machine; the method comprises: In response to the start instruction, calling a driver 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; Calling the initialization function of the wireless network device to instruct the wired network function device to establish a link between the wireless network function device and the wired network function device; calling 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 a link between the wireless network function device and the wired network function device to obtain network connection information; The network connection information sent by the wireless network device is received, and a wireless network connection is established with the wireless network device according to the network connection information.

2. The method according to claim 1, characterized in that The virtual machine includes a virtual network card, which is a wired mapping device of a host machine to which the virtual machine belongs in the virtual machine; Before the calling driver to create a wireless network device in the virtual machine, the method further includes: Turning off the wired mapping device of the host machine in the virtual machine, and modifying the name of the wired mapping device; When the name of the wired mapping device is modified successfully, the wired mapping device is started.

3. The method according to claim 2, characterized in that The mapping method of the wired mapping device of the host machine in the virtual machine includes any one of the following: The switch device in the virtual monitor in the host machine converts the Internet Protocol address corresponding to the virtual network card to obtain a communication address for the virtual machine to communicate with the external network device; the switch device is also used to identify the data packet returned by the external network device to the virtual machine based on the communication address, and forward the data packet to the virtual machine; The router corresponding to the host machine allocates an Internet Protocol address matching the network segment of the host machine to the virtual network card, and determines the Internet Protocol 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 calling of the first connection function of the wireless network device includes: Turning on the wireless network switch of the virtual machine, calling the scanning function of the wireless network device, and instructing the wireless network function device to return the wireless network information of the wireless network function device; Receiving the wireless network information sent by the wireless network device; The first connection function of the wireless network device corresponding to the wireless network information is called.

5. The method according to claim 1, characterized in that The calling of 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 a link between the wireless network function device and the wired network function device to obtain network connection information includes: calling the first connection function of the wireless network device, instructing the wireless network function device to generate a request data packet for wireless network connection, forwarding the request data packet to the wired network function device based on the link, forwarding the request data packet to a switch device of a host machine to which the virtual machine belongs through a virtual network card, converting an address of the request data packet through the switch device, and interacting the request data packet after the address conversion with the external network device through a 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 by the external network device to the wireless network device through the switch device.

6. The method according to claim 1, characterized in that The calling of 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 a link between the wireless network function device and the wired network function device to obtain network connection information includes: calling the first connection function of the wireless network device, instructing the wireless network function device to generate a request data packet for wireless network connection, forwarding the request data packet to the wired network function device based on the link, forwarding the request data packet received by the wired network function device to the physical network card of the host machine to which the virtual machine belongs through the virtual network card, and realizing communication with the external network device through the physical network card; Receive the 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.

7. The method according to claim 1, characterized in that Before calling 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 a link between the wireless network function device and the wired network function device to obtain network connection information, the method further includes: The second connection function of the wireless network device is called to instruct the wireless network function device to call the link creation function of the wired network function device, wherein the link creation function is used to instruct the wired network function device to create a network connection between the wireless network function device and the wired network function device based on the link.

8. The method according to claim 1, characterized in that The method further comprises: Calling a status acquisition function of the wireless network device to instruct the wireless network function device to report a 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 comprises: Call the network disconnection 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.

10. The method according to claim 9, characterized in that The calling of the network disconnection function of the wireless network device includes any one of the following methods: In response to the shutdown instruction, calling a network disconnection function of the wireless network device; In response to the shutdown instruction of the wireless network, a network disconnection function of the wireless network device is called.

11. A network connection device, characterized in that: The device comprises: A device creation module, configured to call a driver to create a wireless network device in a virtual machine in response to a startup instruction; the wireless network device includes a wireless network function device and a wired network function device; An initialization configuration module, used to call the initialization function of the wireless network device and instruct the wired network function device to build a link between the wireless network function device and the wired network function device; an information acquisition module, configured to call the first connection function of the wireless network device, instruct the wireless network function device to communicate with an external network device based on a link between the wireless network function device and the wired network function device, and acquire network connection information; The network connection module is used to receive the network connection information sent by the wireless network device and establish a wireless network connection with the wireless network device according to 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, the steps of the method according to any one of claims 1 to 10 are implemented.

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

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

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

  • Automatic dial-up networking method, and host, wireless module and terminal device

    WO2023197669A1