Data transmission method and device, electronic equipment and storage medium

By creating two VLAN interfaces on the WiFi chip driver layer, the problem of limited functionality in WiFi Direct mode is solved, enabling flexibility in accessing the Internet during P2P data transmission.

CN121793166APending Publication Date: 2026-04-03VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-02
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

When electronic devices transmit data via WiFi Direct, the WiFi module is only used for data transmission, resulting in limited functionality, poor flexibility, and inability to access the Internet simultaneously.

Method used

Two VLAN interfaces are created on the WiFi chip driver layer: one for internet connection and the other for P2P direct transmission. These two interfaces enable simultaneous internet access and P2P data transmission.

Benefits of technology

Maintaining stable internet access while conducting P2P data transmission enhances the flexibility of data transmission methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121793166A_ABST
    Figure CN121793166A_ABST
Patent Text Reader

Abstract

The invention discloses a data transmission method and device, electronic equipment and a storage medium, and belongs to the technical field of electronics. The method comprises the following steps: under the condition that first electronic equipment initiates a wireless fidelity (WiFi) direct connection request to second electronic equipment, creating a first virtual local area network (VLAN) interface and a second VLAN interface on a virtual network interface layer through a WiFi chip driving layer of the first electronic equipment; and transmitting the network data packet to the Internet through the first VLAN interface, and transmitting the user data packet to the second electronic equipment through the second VLAN interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of electronic technology, specifically relating to a data transmission method, apparatus, electronic device, and storage medium. Background Technology

[0002] As the storage capacity of electronic devices continues to increase, users need to transfer large amounts of user data from their old devices to their new ones using data migration tools. These tools typically employ Wireless Fidelity (WiFi Direct) technology to establish a high-speed peer-to-peer (P2P) transmission channel for transferring user data.

[0003] However, when electronic devices transmit data via WiFi Direct, they need to exclusively use the radio frequency resources of the WiFi module to maintain the P2P transmission channel, resulting in the WiFi module being used solely for data transmission, making its function relatively limited. Thus, the current data transmission method lacks flexibility. Summary of the Invention

[0004] The purpose of this application is to provide a data transmission method, apparatus, electronic device, storage medium, and program product that enables electronic devices to access the Internet when transmitting data via WiFi Direct mode, thereby improving the flexibility of the data transmission method.

[0005] In a first aspect, embodiments of this application provide a data transmission method, which includes: when a first electronic device initiates a WiFi direct connection request to a second electronic device, creating a first virtual local area network (VLAN) interface and a second VLAN interface in the virtual network interface layer through the WiFi chip driver layer of the first electronic device; transmitting network data packets to the Internet through the first VLAN interface, and transmitting user data packets to the second electronic device through the second VLAN interface.

[0006] Secondly, embodiments of this application provide a data transmission apparatus, comprising an execution module and a transmission module. The execution module is configured to, when a first electronic device initiates a WiFi direct connection request to a second electronic device, create a first VLAN interface and a second VLAN interface at the virtual network interface layer through the WiFi chip driver layer of the first electronic device. The transmission module is configured to transmit network data packets to the Internet through the first VLAN interface created by the execution module, and to transmit user data packets to the second electronic device through the first VLAN interface created by the execution module.

[0007] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0008] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0009] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0010] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0011] In this embodiment, when the first electronic device initiates a WiFi direct connection request to the second electronic device, a first VLAN interface and a second VLAN interface can be created at the virtual network interface layer through the WiFi chip driver layer of the first electronic device. Then, network data packets are transmitted to the Internet through the first VLAN interface, and user data packets are transmitted to the second electronic device through the second VLAN interface. In this solution, since two VLAN interfaces can be directly generated on the WiFi chip driver layer of the first electronic device, that is, two independent network interfaces are virtually created on the WiFi chip of the first electronic device—one for connecting to the Internet and the other for P2P direct transmission with the second electronic device. Through these two network interfaces, the first electronic device can access the Internet through the first VLAN interface while transmitting data with the second electronic device through the second VLAN interface, thus maintaining stable Internet access while performing P2P data transmission. This allows the electronic device to access the Internet while transmitting data in WiFi direct connection mode, improving the flexibility of the data transmission method. Attached Figure Description

[0012] Figure 1 This is a schematic diagram of the architecture of the data transmission method provided in the embodiments of this application;

[0013] Figure 2 This is a flowchart of the data transmission method provided in the embodiments of this application;

[0014] Figure 3 This is a schematic diagram illustrating the process of monitoring data packets provided in an embodiment of this application;

[0015] Figure 4 A schematic diagram illustrating the execution process of the data transmission method provided in the embodiments of this application;

[0016] Figure 5 This is a schematic diagram of the data transmission device provided in an embodiment of this application;

[0017] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;

[0018] Figure 7 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0021] The terms "at least one," "at least one," etc., in this application refer to any one, any two, or a combination of two or more of the included objects. For example, at least one of a, b, and c can mean: "a," "b," "c," "a and b," "a and c," "b and c," and "a, b, and c," where a, b, and c can be single or multiple. Similarly, "at least two" refers to two or more, and its meaning is similar to that of "at least one."

[0022] The following explains some concepts and terms involved in the data transmission method, apparatus, and electronic device provided in the embodiments of this application.

[0023] The system framework of the data transmission method provided in the embodiments of this application will be described exemplarily below with reference to the accompanying drawings.

[0024] Figure 1 A schematic diagram of the architecture of the data transmission method provided in this application embodiment is shown, including an application layer, a system framework layer, and a kernel layer. Wherein:

[0025] I. The application layer includes WiFi Direct applications and whitelisted applications, among which:

[0026] 1. WiFi Direct is an application used for P2P communication with a target Internet Protocol (IP) address. A socket is bound to a P2P interface, ensuring that all data packets sent and received by the socket are transmitted through this specific P2P interface.

[0027] 2. The whitelist includes the application package names of applications that are frequently interacted with by users. Sockets use default routes to ensure that network requests from these applications are sent through the sockets, and these sockets use the system's default routes to determine the transmission path of data packets.

[0028] II. The system framework layer includes a user network behavior monitoring module, which is used to monitor user network connection requests.

[0029] III. The kernel layer, such as the Linux kernel layer, includes the network protocol stack, dynamic bandwidth scheduler, traffic control (TC) subsystem, virtual network interface layer, physical WiFi driver layer (mac80211), and hardware-level WiFi chip. Among these:

[0030] 1. The network protocol stack, also known as the IP layer, includes policy routing and a traffic classifier, among which:

[0031] (1) Policy routing is a policy-based routing and forwarding mechanism that allows network administrators to determine the forwarding path of data packets based on specific policies or rules, rather than simply matching the longest prefix of the destination IP address. This can be specifically implemented through routing rules. In Linux systems, policy routing is typically configured and managed using the `ip rule` and `iproute` commands. This includes packets from whitelisted applications and packets destined for P2P peers.

[0032] (2) The traffic classifier is used to distribute data packets to the corresponding virtual interface queues based on the tags.

[0033] 2. The dynamic bandwidth scheduler is a kernel module, also known as a network monitoring service module or user space monitoring service. It listens for status commands from user space services, dynamically modulates traffic controller rules, detects and identifies data packets from specific applications, triggers corresponding actions, and dynamically adjusts the bandwidth of net-vir0 / P2P-vir0 through the kernel scheduler. The kernel scheduler is part of the operating system kernel and is responsible for managing and allocating system resources, including CPU time, memory, and network bandwidth. In this embodiment, the kernel scheduler can implement dynamic bandwidth modulation by calling the interfaces of the TC subsystem, such as TC queue discipline (qdisc).

[0034] 3. The TC subsystem is a set of tools in the Linux kernel used to manage and control network traffic, including bandwidth allocation, traffic shaping, and priority settings. For example, one specific implementation of TrafficController in Linux is the Linux TC subsystem. The TC subsystem can use the Hierarchical Token Bucket (HTB) algorithm to control the bandwidth of two virtual network interfaces. Specific settings could be "HTB for net-vir0, rate: 25mbit" and "HTB for P2P-vir0, rate: 75mbit," where:

[0035] (1) "HTB for net-vir0, rate: 25mbit" means "Hierarchical token bucket algorithm is used for the net-vir0 interface, bandwidth: 25 megabits per second". This indicates that the HTB algorithm is used for flow control on the virtual network interface named net-vir0, and its maximum bandwidth (rate) is set to 25 megabits per second (Mbit / s). This interface is used for ordinary Internet traffic, such as web browsing and email sending and receiving. Limiting the bandwidth to 25 Mbit / s ensures that these routine tasks have sufficient network resources without consuming too much bandwidth, thus leaving room for other critical tasks.

[0036] (2) "HTB for P2P-vir0, rate: 75mbit" means "Hierarchical token bucket algorithm is used for P2P-vir0 interface, bandwidth: 75 megabits per second". This indicates that the HTB algorithm is used to control the flow of the net-vir0 interface for the virtual network interface named P2P-vir0, setting its maximum bandwidth to 75 Mbit / s. This interface is specifically used for P2P data transmission, such as file sharing and large-scale data synchronization. The higher bandwidth allocation can ensure the efficiency and speed of P2P transmission and meet the needs of large-scale data exchange.

[0037] 4. The virtual network interface layer includes the virtual interface net-vir0 and the virtual interface P2P-vir0, where net-vir0 is used for the networking channel and P2P-vir0 is used for the transmission channel.

[0038] 5. The physical WiFi driver layer and the hardware layer WiFi chip share the same physical channel. Data transmission is achieved through time-division multiplexing technology, allowing the same Wi-Fi chip to alternately carry net-vir0 and P2P-vir0 frames, ensuring no conflict at the physical layer.

[0039] The data transmission method, apparatus, electronic device, storage medium, and program product provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.

[0040] The embodiments of this application can be applied to scenarios where electronic devices need to connect to the Internet when transmitting data.

[0041] The data transmission method provided in this application will be illustrated below using a specific scenario from an embodiment of this application.

[0042] Specifically, a user has just purchased a new smartphone and plans to migrate a large amount of data from their old phone to the new one. The user expects a high-speed, stable connection between the two phones to quickly complete the data transfer during the migration process. Simultaneously, the user also wants the new phone to maintain a stable internet connection during the migration to perform other online activities, such as checking emails, browsing the web, or receiving instant messages.

[0043] It should be noted that the above scenarios are merely illustrative examples of possible applications of the embodiments of this application. In actual implementation, the embodiments of this application can also be applied to any possible scenarios requiring data transmission, and the embodiments of this application are not limited here.

[0044] This application provides a data transmission method, apparatus, electronic device, storage medium, and program product. Because two VLAN interfaces can be directly generated on the WiFi chip driver layer of the first electronic device—that is, two independent network interfaces are virtually created on the WiFi chip of the first electronic device—one for connecting to the Internet and the other for P2P direct connection transmission with the second electronic device, the first electronic device can access the Internet through the first VLAN interface while transmitting data with the second electronic device via the second VLAN interface. This allows for stable Internet access while performing P2P data transmission. Thus, the electronic device can access the Internet while transmitting data via WiFi direct connection mode, improving the flexibility of the data transmission method.

[0045] The data transmission method provided in this application can be executed by a data transmission device, which can be an electronic device, or a functional module or functional entity within an electronic device. The following description uses an electronic device as an example to illustrate the technical solution provided in this application.

[0046] Figure 2 A flowchart of a data transmission method provided in an embodiment of this application is shown, such as... Figure 1 As shown, the data transmission method provided in this application embodiment may include the following steps 201 and 202.

[0047] Step 201: When the first electronic device initiates a WiFi direct connection request to the second electronic device, the first electronic device creates a first VLAN interface and a second VLAN interface in the virtual network interface layer through the WiFi chip driver layer of the first electronic device.

[0048] In some embodiments of this application, the first electronic device can be a data transmitter and the second electronic device can be a data receiver.

[0049] In some embodiments of this application, the aforementioned WiFi direct connection request is used to request the establishment of a P2P wireless connection so as to enable efficient data transmission between two electronic devices.

[0050] In some embodiments of this application, the aforementioned WiFi direct connection request refers to a connection request based on WiFi Direct technology. WiFi Direct technology allows electronic devices to establish direct P2P wireless connections without the need for traditional wireless routers. Under this connection, electronic devices can transmit data quickly and efficiently.

[0051] In some embodiments of this application, the aforementioned WiFi chip is a core component of the wireless network device, responsible for handling the transmission and reception of wireless signals. The WiFi chip driver layer is part of the operating system kernel and is responsible for direct interaction with the WiFi chip hardware. Operations at this layer enable low-level control of the WiFi chip, including creating virtual interfaces and allocating bandwidth. Figure 1 As shown, the WiFi chip driver layer is... Figure 1 In the physical WiFi driver layer, the first electronic device creates a virtual interface net-vir0 and a virtual interface p2p-vir0 on the physical WiFi driver layer of the first electronic device, forming a virtual network interface layer.

[0052] In some embodiments of this application, bandwidth refers to the maximum amount of data that a network link or channel can transmit per unit time, typically measured in bits per second (bit / s), megabits per second (Mbit / s), or bytes per second (Byte / s). Bandwidth is one of the important indicators for measuring network performance, as it determines the speed and efficiency of data transmission. Different WiFi chips have different bandwidths, and the bandwidth capability of a WiFi chip is determined by its hardware design and communication protocol. In embodiments of this application, the first electronic device can divide the bandwidth of the WiFi chip into two virtual data transmission channels to achieve parallel processing of data transmission and network access.

[0053] In some embodiments of this application, the aforementioned VLAN is a virtual network technology used to divide a physical network into multiple logical networks. In the embodiments of this application, creating two VLAN interfaces is to virtualize two independent network channels on the same WiFi chip, one for networking and the other for data transmission.

[0054] In some embodiments of this application, the first electronic device can create a virtual networking channel through a first VLAN interface and a virtual data transmission channel through a second VLAN interface.

[0055] In some embodiments of this application, the aforementioned virtual networking channel is a virtual channel created through the first VLAN interface, used for the first electronic device to connect to the Internet, ensuring that the first electronic device can still access the Internet normally during data transmission.

[0056] In some embodiments of this application, the aforementioned virtual data transmission channel is a virtual channel created through a second VLAN interface, used for data transmission between the first electronic device and the second electronic device.

[0057] In some embodiments of this application, when a user needs to transfer data between electronic devices, a first electronic device that needs to send data can initiate a WiFi direct connection request to a second electronic device that needs to receive data. For example, when a user gets a new mobile phone and needs to transfer a large amount of user data from the old phone to the new phone, the user can use a data transfer application on the old phone to operate the old phone to initiate a WiFi direct connection request to the new phone.

[0058] In some embodiments of this application, the first electronic device can create virtual network interfaces, namely a first VLAN interface and a second VLAN interface. Specifically, the first electronic device can create a virtual WiFi interface in the operating system kernel, above the driver layer of the physical WiFi chip. This virtual interface can be recognized as an available network connection by upper-layer applications. Taking a Linux system as an example, the first electronic device can utilize the mac80211 framework and netdevice interface of the Linux kernel. When a direct WiFi connection is initiated through a data transmission application, the system does not directly use the wlan0 physical interface, but instead calls a kernel module to create two virtual VLAN interfaces.

[0059] ①P2P-vir0: This is the second VLAN interface, used for WiFi direct data transmission channel;

[0060] ②net-vir0: This is the first VLAN interface, used for user network access.

[0061] The following pseudocode example illustrates the method for creating a virtual interface:

[0062] / / Pseudocode example: Kernel module initialization section

[0063] struct net_device *P2P_virt_dev; / / P2P virtual device, used for data transmission channels

[0064] struct net_device *net_virt_dev; / / Network virtual device used for networking.

[0065] / / Create a virtual interface

[0066] `P2P_virt_dev = mac80211_create_virtual_device(phy_dev, "P2P-vir0",VLAN_PROTO_P2P);` / / Calls the mac80211 function to create a virtual device for P2P communication. `phy_dev` is the physical device, `"P2P-vir0"` is the virtual device name, and `VLAN_PROTO_P2P` specifies the protocol type to use.

[0067] net_virt_dev = mac80211_create_virtual_device(phy_dev, "net-vir0",VLAN_PROTO_INTERNET);

[0068] / / Configure queue rules, initial bandwidth weights: P2P-vir0: 75%, net-vir0: 25%

[0069] tc_qdisc_add(P2P_virt_dev, "htb", rate="75m"); / / Adds a queue rule based on the HTB algorithm to the P2P virtual device, setting the bandwidth limit to 75% to reserve more bandwidth for P2P transmission.

[0070] tc_qdisc_add(net_virt_dev, "htb", rate="25m"); / / Adds a queue rule based on the HTB algorithm to the network virtual device, setting the bandwidth limit to 25% to reserve some bandwidth for network connections.

[0071] End of pseudocode example.

[0072] In some embodiments of this application, the electronic device can divide the total bandwidth of the physical WiFi channel into two virtual channels:

[0073] a. Virtual data transmission channel: This can be simply called the transmission channel. It is used for direct WiFi data transmission between the first electronic device and the second electronic device, and it occupies most of the bandwidth, such as 70%-80% in the initial state.

[0074] b. Virtual Networking Channel: This can be simply called the networking channel. It is used as a WiFi access point for the first electronic device to connect to the Internet, occupying a small portion of the bandwidth, such as 20%-30% in the initial state.

[0075] In some embodiments of this application, the first electronic device may set the transmission rate of the virtual data transmission channel to be greater than the transmission rate of the virtual network channel to ensure high priority of data transmission; or, the first electronic device may also set the transmission rate of the virtual network channel to be greater than the transmission rate of the virtual data transmission channel to optimize network access efficiency and improve the user's network experience.

[0076] Step 202: The first electronic device transmits network data packets to the Internet through the first VLAN interface and transmits user data packets to the second electronic device through the second VLAN interface.

[0077] In some embodiments of this application, the aforementioned network data packets are data packets whose destination address is a server on the Internet, such as data packets generated by web browsing, email sending, instant messaging, etc.

[0078] In some embodiments of this application, the aforementioned user data packet refers to a data packet whose destination address is the P2P peer IP address of the second electronic device, such as photos, videos, contact information, chat logs, etc.

[0079] In some embodiments of this application, the electronic device can establish a routing table based on source address or label using traffic policy routing technology, such as the Linux ip rule and ip route commands. The electronic device can then use this routing table to label and route all traffic destined for the P2P peer IP to P2P-vir0, route other traffic destined for the default gateway to net-vir0, and route IP packets destined for the Internet to the network channel.

[0080] In some embodiments of this application, `ip rule` is a command used to manage IP routing tables. It can determine which routing table a data packet should be forwarded using based on specific conditions, such as the packet's source address, destination address, protocol type, and tags. `ip route` is a command used to manage routing tables and can be used to add, delete, or modify routing entries in the routing table.

[0081] In some embodiments of this application, routing rules are a set of decision logic, a specific implementation of policy-based routing, used to determine how data packets are forwarded in the network. These rules determine which routing table to use for forwarding based on various attributes of the data packets, such as source address, destination address, protocol type, and tags.

[0082] In some embodiments of this application, a routing table is a data structure used to store forwarding path information for various destination addresses in the network. Each routing table contains multiple routing entries, and each entry specifies the next-hop address or interface to reach a specific destination address.

[0083] This application provides a data transmission method, apparatus, electronic device, storage medium, and program product. Because two VLAN interfaces can be directly generated on the WiFi chip driver layer of the first electronic device—that is, two independent network interfaces are virtually created on the WiFi chip of the first electronic device—one for connecting to the Internet and the other for P2P direct connection transmission with the second electronic device, the first electronic device can access the Internet through the first VLAN interface while transmitting data with the second electronic device via the second VLAN interface. This allows for stable Internet access while performing P2P data transmission. Thus, the electronic device can access the Internet while transmitting data via WiFi direct connection mode, improving the flexibility of the data transmission method.

[0084] In some embodiments of this application, the "electronic device transmits network data packets to the Internet through the first VLAN interface" in step 202 above can be implemented by step 202a below, and the "transmits user data packets to the second electronic device through the second VLAN interface" in step 202 above can be implemented by step 202b below.

[0085] Step 202a: The first electronic device routes network data packets to the first VLAN interface and transmits network data packets to the Internet through the first VLAN interface.

[0086] In some embodiments of this application, the first electronic device may add a first tag to the data packet destined for the first address in the data packet to be transmitted.

[0087] In some embodiments of this application, the aforementioned data packet to be transmitted refers to a data packet that the first electronic device is prepared to send, including user data packets and network data packets.

[0088] In some embodiments of this application, the first address mentioned above is the physical address of the second electronic device. For example, the first address can be the Media Access Control Address (MAC) or IP address of the second electronic device.

[0089] In some embodiments of this application, the first marker is used to identify that the destination address of the data packet is the physical address of the second electronic device, such as a MAC address or an IP address, so as to route these data packets to the virtual data transmission channel.

[0090] In some embodiments of this application, the first tag mentioned above may be a packet tag set using tools such as iptables or nftables, for example, using a MARK target to set a specific tag value for the packet.

[0091] In some embodiments of this application, the first marker is a marker value used to identify data packets and to distinguish between user data packets and network data packets.

[0092] In some embodiments of this application, the first electronic device needs to classify the data packets before preparing to send them, based on the destination address of the data packets. If the destination address of the data packets is the physical address of the second electronic device, i.e., the first address, then these data packets are considered user data packets and need to be sent to the second electronic device.

[0093] In some embodiments of this application, the first electronic device may add a specific tag, namely the first tag, to all data packets sent to the first address.

[0094] In some embodiments of this application, the first electronic device needs to classify data packets before preparing to send them, based on whether the data packets carry a first tag. If the data packets do not carry a first tag, they are considered network data packets and need to be sent to the Internet through a virtual networking channel.

[0095] In some embodiments of this application, the first electronic device can configure routing rules using the ip rule and ip route commands to ensure that all data packets without the first tag are sent through the net-vir0 interface.

[0096] In some embodiments of this application, if the data packet does not carry a first tag, the first electronic device can determine that the data packet is a network data packet, and then, through a traffic classifier, according to the routing rules configured by the ip rule and ip route commands, route the data packet to the first VLAN interface, and transmit the data packet to the Internet through a virtual networking channel.

[0097] Step 202b: The first electronic device routes the user data packet to the second VLAN interface and transmits the user data packet to the second electronic device through the first VLAN interface.

[0098] In some embodiments of this application, if the data packet to be transmitted carries a first tag, the first electronic device can determine that the data packet is a user data packet, and then, through a traffic classifier, route the data packet to the second VLAN interface according to the routing rules configured by the ip rule and ip route commands, and transmit the data packet to the second electronic device through a virtual data transmission channel.

[0099] In this way, electronic devices can configure routing rules to enable network data packets to reliably access the Internet through virtual networking channels, and user data packets to be efficiently transmitted to a second electronic device through virtual data transmission channels. This achieves precise routing of different types of data packets, allowing network resources to be rationally allocated and efficiently utilized, ensuring a good network experience for users while maintaining efficient data transmission.

[0100] In some embodiments of this application, after step 201 above, the data transmission method provided in this application further includes the following step 301.

[0101] Step 301: During the process of monitoring the data packets to be transmitted through the network monitoring service module, when the data packets of the first application or the first data packet are detected, the first electronic device modifies the rate of the second VLAN interface to the first rate and modifies the rate of the first VLAN interface to the second rate through the kernel scheduler.

[0102] In some embodiments of this application, the first data packet is a data packet generated in response to a user interaction operation.

[0103] In some embodiments of this application, the first application mentioned above is an application in a whitelist within the first electronic device. An application in the whitelist refers to an application predefined by the user or system and allowed preferential access to the network.

[0104] In some embodiments of this application, the aforementioned rate refers to the bandwidth size, the aforementioned first rate is a new rate set by the kernel scheduler for the second VLAN interface to reduce the bandwidth occupied by data transmission, and the aforementioned second rate is a new rate set by the kernel scheduler for the first VLAN interface to increase the bandwidth occupied by networking.

[0105] In some embodiments of this application, the first electronic device can adjust the rate of the virtual networking channel, i.e., the network connection rate, by modifying the rate of the first VLAN interface. The first electronic device can adjust the rate of the virtual data transmission channel, i.e., the data transmission rate, by modifying the rate of the second VLAN interface.

[0106] In some embodiments of this application, when the first electronic device begins transmitting data packets through the virtual networking channel and the virtual data transmission channel, the virtual networking channel and the virtual data transmission channel have an initial transmission rate. The initial transmission rate can be user-set or the default rate of the electronic device; for example, the initial transmission rate of the virtual networking channel can be 25% of the total bandwidth, and the initial transmission rate of the virtual data transmission channel can be 75% of the total bandwidth. Alternatively, the initial transmission rate of the virtual networking channel can be 5% of the total bandwidth, and the initial transmission rate of the virtual data transmission channel can be 95% of the total bandwidth.

[0107] In some embodiments of this application, during the transmission of data packets through a virtual networking channel and a virtual data transmission channel, the first electronic device can monitor the data packets to be transmitted through a network monitoring service module.

[0108] In some embodiments of this application, the aforementioned monitoring refers to the real-time detection and analysis of network traffic and data packet transmission by the network monitoring service module, with the aim of obtaining the current status information of the network so that the system can make corresponding adjustments and optimizations based on this information.

[0109] In some embodiments of this application, during the process of the first electronic device transmitting data packets through the virtual networking channel and the virtual data transmission channel, the first electronic device can detect each data packet transmitted through the virtual networking channel (and the virtual data transmission channel), collect detailed information about the data packets, such as the size of the data packets, transmission rate, source address, destination address, etc., and identify the packet name of the data packets, i.e., the application to which they belong.

[0110] In some embodiments of this application, during the transmission of data packets by the first electronic device through the virtual networking channel and the virtual data transmission channel, the background service module in the operating system monitors in real time whether the user has any active network connection requests. Specifically, in the Android system, a NetworkMonitorService system service is created. This service utilizes the trafficController module in the Network Daemon (Netd) or directly uses the Extended Berkeley Packet Filter (eBPF) program in kernel mode to filter and statistically analyze data packets. This is achieved by listening to socket creation, Domain Name System (DNS) query requests, and network activities of specific applications, such as social applications, browser applications, and email applications, through hook functions.

[0111] In this way, electronic devices can use the network monitoring service module to monitor the data packet transmission in the virtual networking channel and the virtual data transmission channel in real time, thereby dynamically sensing the network status and user behavior, and providing data support for subsequent bandwidth adjustments.

[0112] In some embodiments of this application, when the first electronic device monitors the data packets to be transmitted through the network monitoring service module, and the first electronic device detects data packets belonging to the first application in the whitelist or data packets generated in response to user interaction through the network monitoring service module, the first electronic device can confirm that the user needs to connect to the network. Then, it can dynamically adjust the bandwidth allocation of the virtual channel through the kernel scheduler, modify the rate of the virtual data transmission channel to the first rate to reduce the bandwidth occupied by data transmission, and modify the rate of the virtual network channel to the second rate to increase the bandwidth occupied by network connection.

[0113] For example, assuming a total bandwidth of 100 Mbit / s, when the first electronic device begins monitoring data packets to be transmitted through the network monitoring service module, the transmission rate of the virtual data transmission channel is 95 Mbit / s, and the transmission rate of the virtual networking channel is 5 Mbit / s. At this time, the first electronic device, through the network monitoring service module, detects data packets belonging to the first application in the whitelist, triggering the first electronic device to dynamically adjust the bandwidth allocation of the virtual channels through the kernel scheduler. The rate of the virtual data transmission channel is modified to 75 Mbit / s (the first rate), and the rate of the virtual networking channel is modified to 25 Mbit / s (the second rate) to facilitate internet access.

[0114] In some embodiments of this application, when active network activity by a user is detected: the system maintains or appropriately increases the bandwidth percentage of the network channel, for example, keeping it at or increasing it to 25%, to ensure smooth network access. The transmission channel then uses the remaining bandwidth for data transmission.

[0115] In this way, electronic devices can monitor network traffic in real time through the network monitoring service module, and when application data packets in the whitelist are detected, the kernel scheduler can dynamically adjust the bandwidth allocation of the virtual channel to improve the speed of the virtual networking channel. Thus, during data transmission, electronic devices can intelligently allocate bandwidth resources according to the user's real-time networking needs, ensuring that the user's networking needs can be met and improving the user's networking experience.

[0116] In some embodiments of this application, after step 301 above, the data transmission method provided in this application further includes the following step 401.

[0117] Step 401: If no data packet or first data packet of the first application is detected within the first preset time period, the first electronic device modifies the rate of the second VLAN interface to the third rate and the rate of the first VLAN interface to the fourth rate through the kernel scheduler.

[0118] In some embodiments of this application, the third rate is greater than the first rate, and the fourth rate is less than the second rate.

[0119] In some embodiments of this application, the aforementioned first preset duration is a time threshold used to determine whether the current network is idle. The aforementioned first preset duration can be the default setting of the electronic device or a user-defined setting. For example, the aforementioned first preset duration can be 10 seconds. The specific duration can be determined according to actual usage needs, and this application embodiment does not impose any limitations.

[0120] In some embodiments of this application, the third rate is a new rate set by the kernel scheduler for the second VLAN interface to increase the bandwidth occupied by data transmission, and the fourth rate is a new rate set by the kernel scheduler for the first VLAN interface to reduce the bandwidth occupied by networking.

[0121] In some embodiments of this application, when the first electronic device monitors the data packets to be transmitted through the network monitoring service module, if the first electronic device does not detect any data packets belonging to the first application in the whitelist within a first preset time period through the network monitoring service module, the first electronic device can confirm that the user does not need to connect to the network. Then, it can dynamically adjust the bandwidth allocation of the virtual channel through the kernel scheduler, modify the rate of the virtual data transmission channel to the third rate, and modify the rate of the virtual network channel to the fourth rate.

[0122] For example, assuming a total bandwidth of 100 Mbit / s, during the process of the first electronic device monitoring data packets to be transmitted through the network monitoring service module, the transmission rate of the virtual data transmission channel is 75 Mbit / s, and the transmission rate of the virtual networking channel is 25 Mbit / s. Assuming a first preset duration of 10 seconds, the first electronic device continuously listens for data packets belonging to the first application in the whitelist through the network monitoring service module. If no data packets of the first application are detected after 10 seconds, the first electronic device can dynamically adjust the bandwidth allocation of the virtual channels through the kernel scheduler, modifying the rate of the virtual data transmission channel to 95 Mbit / s (the third rate) and the rate of the virtual networking channel to 5 Mbit / s (the fourth rate) to accelerate data transmission.

[0123] In some embodiments of this application, when inactive user network activity is detected (i.e., network idle), the underlying kernel scheduler temporarily and dynamically allocates idle bandwidth from the virtual network channel to the virtual data transmission channel. For example, the bandwidth allocation of the virtual data transmission channel can be increased from 75% to 95% or even higher, thereby greatly accelerating the data transmission process. Once the monitoring module detects a user's network request again, the system immediately returns the bandwidth resources to the virtual network channel.

[0124] In this way, electronic devices can monitor network traffic in real time through the network monitoring service module, and if no application data packets from the whitelist are detected within a first preset time period, the kernel scheduler can dynamically adjust the bandwidth allocation of the virtual channel to improve the speed of the virtual data transmission channel. Thus, during data transmission, electronic devices can intelligently allocate bandwidth resources when the user does not have a network connection requirement, thereby improving the efficiency of data transmission.

[0125] In some embodiments of this application, the data transmission method provided in this application further includes the following step 501.

[0126] Step 501: During the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface, the first electronic device performs a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface through the kernel scheduler within a second preset time period.

[0127] In some embodiments of this application, the aforementioned second preset duration is a time threshold, representing the time required to gradually adjust the bandwidth. For example, the second preset duration can be 100-300 milliseconds (ms). The specific duration can be determined based on actual usage requirements, and this application does not impose any limitations.

[0128] In some embodiments of this application, the incremental adjustment operation is a method for dynamically adjusting bandwidth, which means adjusting the bandwidth gradually over a preset time period, rather than completing it all at once, in order to avoid network problems caused by drastic bandwidth changes.

[0129] In some embodiments of this application, the dynamic bandwidth adjustment performed by the electronic device can be a smooth switch. To avoid TCP session interruption caused by drastic bandwidth changes, the scheduler of the electronic device can adopt a gradual adjustment strategy, gradually completing the bandwidth reallocation within a few hundred milliseconds, such as 100-300ms.

[0130] In some embodiments of this application, during the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface, the first electronic device can calculate the difference between the current rate and the target rate, and calculate the adjustment step size for each step according to a second preset time period. Within the second preset time period, the first electronic device can gradually adjust the rate according to the calculated step size through the kernel scheduler, for example, adjusting once every 10 milliseconds, until the target rate is reached, ensuring that the rate adjustment is smooth.

[0131] In this way, when the first electronic device modifies the rate of the virtual interface through the kernel scheduler, the rate can be adjusted gradually over a preset time period, rather than all at once. This gradual adjustment operation ensures smooth rate changes, avoids network problems caused by drastic bandwidth changes, such as session interruptions or network congestion, and improves the stability of data transmission.

[0132] like Figure 1 As shown in the illustration, this application provides a data transmission system including a WiFi chip driver layer and a virtual network interface layer. Specifically: the WiFi chip driver layer is used to create a first Virtual Local Area Network (VLAN) interface and a second VLAN interface in the virtual network interface layer when a first electronic device initiates a Wi-Fi direct connection request to a second electronic device. The virtual network interface layer is used to transmit network data packets to the Internet through the first VLAN interface and to transmit user data packets to the second electronic device through the second VLAN interface.

[0133] In some embodiments of this application, the data transmission system provided in this application further includes a system kernel layer, which contains a network protocol stack. Specifically: the system kernel layer is used to route network data packets to a first VLAN interface in the virtual network interface layer via the network protocol stack. The system kernel layer is also used to route user data packets to a second VLAN interface in the virtual network interface layer via the network protocol stack.

[0134] In some embodiments of this application, the data transmission system provided in this application further includes a system kernel layer, which contains a dynamic bandwidth scheduler and a kernel scheduler. Specifically: the system kernel layer is used to monitor data packets or first data packets of a first application through the dynamic bandwidth scheduler, wherein the first data packet is a data packet generated in response to a user interaction operation. The system kernel layer is also used to, when the dynamic bandwidth scheduler detects data packets or first data packets of the first application, modify the rate of the second VLAN interface to a first rate and modify the rate of the first VLAN interface to a second rate through the kernel scheduler. The first application is an application in a whitelist within the first electronic device.

[0135] In some embodiments of this application, the aforementioned system kernel layer is further configured to, when the dynamic bandwidth scheduler does not detect data packets or the first data packet of the first application within a first preset time period, modify the rate of the second VLAN interface to a third rate and the rate of the first VLAN interface to a fourth rate via the kernel scheduler. The third rate is greater than the first rate, and the fourth rate is less than the second rate.

[0136] In some embodiments of this application, the above-mentioned system kernel layer is further configured to perform a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface within a second preset time period during the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface.

[0137] In some embodiments of this application, not all network activities are considered "user-initiated behavior" when determining user network activity. The system maintains a whitelist containing application package names that are frequently interacted with by the user. A "user network activity" is determined only when an application in the whitelist generates an uplink request, such as a Transmission Control Protocol Synchronize (TCP SYN) packet or a DNS query. The system continuously monitors the network; if no uplink requests from whitelist applications are displayed within a certain period, such as 10 seconds, the network is considered "idle."

[0138] For example, Figure 3 This is a diagram illustrating the process of monitoring data packets. (For example...) Figure 3 As shown, the process of monitoring data packets includes the following steps 601 to 606.

[0139] Step 601: The electronic device starts the user space monitoring service.

[0140] In some embodiments of this application, electronic devices can monitor and manage data packets by registering eBPF hooks / Netlink listeners, etc.

[0141] Step 602: The user space monitoring service continuously listens for SYN packets sent by applications in the whitelist.

[0142] Step 603: The user space monitoring service can determine whether the number of detected SYN packets within the current time window is greater than 0.

[0143] If the number of detected SYN packets within the current time window is greater than 0, proceed to step 604; otherwise, proceed to step 605.

[0144] Step 604: Set the status to user active (USER_ACTIVE).

[0145] Step 605: Set the status to network idle (NETWORK_IDLE).

[0146] Step 606: Instruct the kernel scheduler to adjust the bandwidth via Input / Output Control (IOCTL).

[0147] The following pseudocode example illustrates the method for adjusting the transmission rate of the virtual channel:

[0148] / / Pseudocode example: bandwidth scheduler static void bandwidth_scheduler_callback(intevent) { / / Defines the bandwidth scheduler callback function, the event parameter indicates the event type

[0149] switch (event) { / / Branch the process based on the event type

[0150] case EVENT_USER_ACTIVE: / / If the event indicates user activity, ensure network channel bandwidth.

[0151] tc_qdisc_change(net_virt_dev, "htb", rate="25m"); / / Sets the bandwidth for the virtual networking channel, ensuring it has 25% bandwidth.

[0152] tc_qdisc_change(P2P_virt_dev, "htb", rate="75m"); / / Sets the bandwidth for the virtual data transfer channel, allowing it to use 75% of the remaining bandwidth.

[0153] break

[0154] case EVENT_NETWORK_IDLE: / / / / If the event is network idle, the network channel bandwidth will be allocated to the transmission channel.

[0155] tc_qdisc_change(net_virt_dev, "htb", rate="5m"); / / Reduces the bandwidth of the virtual networking channel to the minimum guaranteed 5%.

[0156] tc_qdisc_change(P2P_virt_dev, "htb", rate="95m"); / / Increases the bandwidth of the virtual data transfer channel to 95%.

[0157] break

[0158] }}

[0159] End of pseudocode example.

[0160] In some embodiments of this application, after the data transmission task is completed, the kernel module executes the following in sequence: delete the policy routing rule, remove TC qdisc, and unregister and destroy the created virtual network interfaces P2P-vir0 and net-vir0, so that the WiFi module returns to normal working mode.

[0161] This application relates to the field of electronic device data transmission technology, and aims to provide a method and system for maintaining network connectivity during WiFiDirect data transmission. This invention achieves the coexistence of data transmission and network access by creating parallel, dynamically adjustable transmission and networking channels at the system's underlying layer. It also intelligently allocates bandwidth resources based on the user's real-time network behavior, thereby minimizing transmission time while ensuring an unaffected user network experience. Specific improvements include:

[0162] 1. Create a virtual network channel on the physical WiFi chip driver layer: use time division multiplexing technology to divide WiFi radio frequency resources, open up an independent network channel for the first device, and allocate 1 / 4 to 1 / 3 of the original bandwidth.

[0163] 2. Intelligent Network Bandwidth Recovery and Switching: A user network behavior awareness mechanism is added to monitor the user's network activity in real time. When continuous inactivity is detected for more than a preset timeout, such as a 10-second threshold, the virtual network channel bandwidth is automatically switched to the data transmission channel. When the user resumes activity, the system smoothly switches the bandwidth back to the network channel within 300ms to ensure a seamless user experience.

[0164] Figure 4 This is a schematic diagram illustrating the execution process of the data transmission method provided in an embodiment of this application. Figure 4 As shown, the data transmission method provided in this application embodiment may include the following steps 10 to 15.

[0165] Step 10: The electronic device creates a virtual network interface on the driver layer of the WiFi chip.

[0166] Step 11: The electronic device divides the total bandwidth of the physical WiFi channel into a transmission channel and a networking channel.

[0167] Step 12: Electronic devices monitor users' internet access behavior through the network monitoring service module.

[0168] Step 13: When active network activity is detected, the electronic device maintains or appropriately increases the bandwidth ratio of the network channel through the kernel scheduler.

[0169] Step 14: When no active network activity is detected from the user, the electronic device allocates the idle bandwidth of the network channel to the transmission channel through the kernel scheduler.

[0170] Step 15: After the data transmission task is completed, the electronic device deletes the policy routing rules, removes the TC qdisc, and unregisters and destroys the virtual network interface through the kernel module, so that the WiFi module returns to normal working mode.

[0171] based on Figure 1 The system architecture shown is used to provide a detailed exemplary description of the execution process of the data transmission method provided in the embodiments of this application:

[0172] (1) When the first electronic device sends its WiFi Direct connection request through the WiFi Direct application, the application layer binds the WiFi Direct application to the P2P interface to ensure that data packets are transmitted through this interface, while the whitelisted applications use the default route. The physical WiFi driver layer creates two VLAN interfaces, net-vir0 and p2p-vir0. net-vir0 is used for virtual networking channels, and p2p-vir0 is used for virtual data transmission channels. The TC subsystem mounts two HTB settings: net-vir0 rate=25 Mbit / s and p2p-vir0 rate=75 Mbit / s. Policy routing injects rules to route different data packets to different interfaces. The framework layer registers eBPF hooks through the network monitoring service module to count the SYN packets of whitelisted apps in real time. During data transmission, user data packets are marked, while network data packets are not marked. The traffic classifier routes marked user data packets to p2p-vir0 and unmarked network data packets to net-vir0 according to the routing rules.

[0173] (2) When a data packet of a whitelisted application is detected, the network monitoring service module notifies the kernel scheduler to call the interface of the TC subsystem to increase the rate of the virtual networking channel corresponding to net-vir0 and decrease the rate of the virtual data transmission channel corresponding to p2p-vir0.

[0174] (3) If no data packets of whitelisted applications are detected within the first preset time period, the network monitoring service module notifies the kernel scheduler to call the interface of the TC subsystem to reduce the rate of the virtual networking channel corresponding to net-vir0 and increase the rate of the virtual data transmission channel corresponding to p2p-vir0.

[0175] (4) After the file transfer is completed, the kernel scheduler deletes the policy routing rules, unregisters the eBPF hook, removes the HTB mounted on the TC subsystem, destroys the two VLAN interfaces, and the Wi-Fi chip returns to normal working mode.

[0176] In this way, electronic devices can establish dual virtual channels on the same Wi-Fi chip, and use HTB policy routing and eBPF for bandwidth scheduling to achieve parallel file transfer and Internet access without the need for additional radio frequency or external network card. This software-based approach breaks through the physical limitation of network disconnection in Wi-Fi direct connection mode, significantly improving the network communication flexibility of electronic devices in data migration scenarios.

[0177] This application's embodiments can effectively solve the problem of network availability of old devices during multi-device data migration. Users can continue to use network-connected apps for web browsing during WiFi Direct data transmission, and transmission efficiency is improved. Through a dynamic bandwidth reclamation mechanism, the overall data transmission time can be shortened. Specifically:

[0178] 1. Seamless user experience: When users are migrating large amounts of data, their old mobile phones can still access the Internet normally, solving the core pain point of "internet disconnection during data transfer".

[0179] 2. Intelligent transmission efficiency: Through dynamic bandwidth scheduling, transmission is accelerated at full speed when users are not using the network, significantly shortening the overall waiting time.

[0180] 3. System-level implementation with good compatibility: This solution is mainly implemented at the operating system kernel and driver layer, which is transparent to upper-layer applications. It does not require modification of existing data transmission applications and has good universality and compatibility.

[0181] 4. High efficiency in resource utilization: Fully utilize the potential of physical WiFi channels and avoid idle and wasteful bandwidth resources.

[0182] Each of the above-described method embodiments, or various possible implementations of each method embodiment, can be executed individually or in combination of any two or more. The specific implementation can be determined according to actual usage requirements, and this application does not impose any restrictions on this.

[0183] The data transmission method provided in this application can be executed by a data transmission device. This application uses a data transmission device executing the data transmission method as an example to illustrate the data transmission device provided in this application.

[0184] Figure 5 A schematic diagram of a possible structure of a data transmission apparatus involved in some embodiments of this application is shown. For example... Figure 5 As shown, the data transmission device 70 may include an execution module 71 and a transmission module 72.

[0185] The execution module 71 is used to create a first VLAN interface and a second VLAN interface in the virtual network interface layer through the WiFi chip driver layer of the first electronic device when the first electronic device initiates a WiFi direct connection request to the second electronic device.

[0186] The aforementioned transmission module 72 is used to transmit network data packets to the Internet through the first VLAN interface created by the execution module 71, and to transmit user data packets to the second electronic device through the second VLAN interface created by the execution module 71.

[0187] In one possible implementation, the transmission module 72 is specifically used to route network data packets to the first VLAN interface and transmit the network data packets to the Internet through the first VLAN interface. The transmission module 72 is also specifically used to route user data packets to the second VLAN interface and transmit the user data packets to the second electronic device through the second VLAN interface.

[0188] In one possible implementation, the execution module 71 is further configured to, while monitoring data packets to be transmitted via the network monitoring service module, modify the rate of the second VLAN interface to the first rate and the rate of the first VLAN interface to the second rate via the kernel scheduler when a data packet of the first application or the first data packet is detected. The first data packet is a data packet generated in response to a user interaction operation. The first application is an application in the whitelist of the first electronic device.

[0189] In one possible implementation, the execution module 71 is further configured to, after modifying the rate of the second VLAN interface to the first rate and the rate of the first VLAN interface to the second rate, if no data packets of the first application or the first data packet are detected within a first preset time period, modify the rate of the second VLAN interface to the third rate and the rate of the first VLAN interface to the fourth rate via the kernel scheduler. The third rate is greater than the first rate, and the fourth rate is less than the second rate.

[0190] In one possible implementation, the execution module 71 is further configured to perform a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface by the kernel scheduler within a second preset time period during the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface.

[0191] This application provides a data transmission device that can directly generate two VLAN interfaces on the WiFi chip driver layer of the data transmission device. This means that two independent network interfaces are virtually created on the WiFi chip of the data transmission device: one for connecting to the Internet and the other for P2P direct connection with a second electronic device. Through these two network interfaces, the data transmission device can simultaneously transmit data with the second electronic device via the second VLAN interface and access the Internet via the first VLAN interface, thus maintaining stable Internet access while performing P2P data transmission. This allows the electronic device to access the Internet while transmitting data via WiFi direct connection, improving the flexibility of the data transmission method.

[0192] The data transmission device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the specific device.

[0193] The data transmission device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0194] The data transmission device provided in this application embodiment can implement the various processes implemented in the above method embodiments, and will not be described again here to avoid repetition.

[0195] Optionally, such as Figure 6As shown, this application embodiment also provides an electronic device 1000, including a processor 1001 and a memory 1002. The memory 1002 stores a program or instructions that can run on the processor 1001. When the program or instructions are executed by the processor 1001, they implement the various steps of the above-described data transmission method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0196] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0197] Figure 7 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0198] The electronic device 100 includes, but is not limited to, components such as: radio frequency unit 101, network module 102, audio output unit 103, input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, and processor 110.

[0199] Those skilled in the art will understand that the electronic device 100 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 110 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 7 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0200] The processor 110 is configured to create a first VLAN interface and a second VLAN interface in the virtual network interface layer through the WiFi chip driver layer of the first electronic device when the first electronic device initiates a WiFi direct connection request to the second electronic device.

[0201] The aforementioned radio frequency unit 101 is used to transmit network data packets to the Internet through the first VLAN interface and to transmit user data packets to the second electronic device through the second VLAN interface.

[0202] Optionally, the aforementioned radio frequency unit 101 is specifically used to route network data packets to the first VLAN interface and transmit network data packets to the Internet through the first VLAN interface. The aforementioned radio frequency unit 101 is also specifically used to route user data packets to the second VLAN interface and transmit user data packets to the second electronic device through the second VLAN interface.

[0203] Optionally, the processor 110 is further configured to, during the process of monitoring data packets to be transmitted through the network monitoring service module, modify the rate of the second VLAN interface to the first rate and the rate of the first VLAN interface to the second rate via the kernel scheduler when a data packet of the first application or the first data packet is detected. The first data packet is a data packet generated in response to a user interaction operation. The first application is an application in the whitelist of the first electronic device.

[0204] Optionally, the processor 110 is further configured to, after modifying the rate of the second VLAN interface to the first rate and the rate of the first VLAN interface to the second rate, if no data packets of the first application or the first data packet are detected within a first preset time period, modify the rate of the second VLAN interface to the third rate and the rate of the first VLAN interface to the fourth rate via the kernel scheduler. The third rate is greater than the first rate, and the fourth rate is less than the second rate.

[0205] In one possible implementation, the processor 110 is further configured to perform a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface by the kernel scheduler within a second preset time period during the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface.

[0206] This application provides an electronic device that can directly generate two VLAN interfaces on the WiFi chip driver layer of a first electronic device. This means two independent network interfaces are virtually created on the WiFi chip of the first electronic device: one for connecting to the Internet and the other for P2P direct connection with a second electronic device. Through these two network interfaces, the first electronic device can access the Internet through the first VLAN interface while simultaneously transmitting data with the second electronic device via the second VLAN interface. This allows for stable Internet access while performing P2P data transmission. Thus, the electronic device can access the Internet while transmitting data in WiFi direct connection mode, improving the flexibility of the data transmission method.

[0207] The electronic device provided in this application embodiment can implement all the processes implemented in the above method embodiments and achieve the same technical effects. To avoid repetition, it will not be described again here. The beneficial effects of the various implementation methods in this embodiment can be found in the beneficial effects of the corresponding implementation methods in the above method embodiments. To avoid repetition, it will not be described again here.

[0208] It should be understood that, in this embodiment, the input unit 104 may include a graphics processing unit (GPU) 1041 and a microphone 1042. The GPU 1041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 106 may include a display panel 1061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0209] The memory 109 can be used to store software programs and various data. The memory 109 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 109 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 109 in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.

[0210] Processor 110 may include one or more processing units; optionally, processor 110 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 110.

[0211] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described data transmission method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0212] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0213] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above data transmission method embodiments and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0214] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0215] This application provides a computer program product that is stored in a storage medium and executed by at least one processor to implement the various processes described in the above-described data transmission method embodiments, and achieves the same technical effects. To avoid repetition, further details are omitted here.

[0216] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0217] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0218] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A data transmission method, characterized in that, Applied to a first electronic device, including: When the first electronic device initiates a Wi-Fi direct connection request to the second electronic device, a first virtual local area network (VLAN) interface and a second VLAN interface are created at the virtual network interface layer through the WiFi chip driver layer of the first electronic device. The network data packets are transmitted to the Internet through the first VLAN interface, and the user data packets are transmitted to the second electronic device through the second VLAN interface.

2. The method according to claim 1, characterized in that, The transmission of network data packets to the Internet through the first VLAN interface includes: The network data packets are routed to the first VLAN interface and transmitted to the Internet through the first VLAN interface; The transmission of user data packets to the second electronic device via the second VLAN interface includes: The user data packet is routed to the second VLAN interface and transmitted to the second electronic device through the second VLAN interface.

3. The method according to claim 1, characterized in that, The method further includes: Upon detecting a data packet from the first application or a first data packet, the kernel scheduler modifies the rate of the second VLAN interface to the first rate and modifies the rate of the first VLAN interface to the second rate. The first data packet is a data packet generated in response to a user interaction operation. The first application is an application that is whitelisted in the first electronic device.

4. The method according to claim 3, characterized in that, After modifying the speed of the second VLAN interface to the first speed and the speed of the first VLAN interface to the second speed, the method further includes: If no data packet of the first application or the first data packet is detected within a first preset time period, the kernel scheduler modifies the rate of the second VLAN interface to the third rate and modifies the rate of the first VLAN interface to the fourth rate. The third rate is greater than the first rate, and the fourth rate is less than the second rate.

5. The method according to claim 3 or 4, characterized in that, The method further includes: During the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface, within a second preset time period, the kernel scheduler performs a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface.

6. A data transmission system, characterized in that, The data transmission system, applied to a first electronic device, includes: a WiFi chip driver layer and a virtual network interface layer; The WiFi chip driver layer is used to create a first virtual local area network (VLAN) interface and a second VLAN interface in the virtual network interface layer when the first electronic device initiates a wireless fidelity WiFi direct connection request to the second electronic device. The virtual network interface layer is used to transmit network data packets to the Internet through the first VLAN interface and to transmit user data packets to the second electronic device through the second VLAN interface.

7. The system according to claim 6, characterized in that, The data transmission system also includes a system kernel layer, which contains a network protocol stack. The system kernel layer is used to route the network data packets to the first VLAN interface in the virtual network interface layer through the network protocol stack; The system kernel layer is used to route the user data packets to the second VLAN interface in the virtual network interface layer through the network protocol stack.

8. The system according to claim 6, characterized in that, The data transmission system also includes a system kernel layer, which contains a dynamic bandwidth scheduler and a kernel scheduler; The system kernel layer is used to listen to the data packets or first data packets of the first application through the dynamic bandwidth scheduler, wherein the first data packet is a data packet generated in response to user interaction operations; The system kernel layer is also used to modify the rate of the second VLAN interface to the first rate and the rate of the first VLAN interface to the second rate when the dynamic bandwidth scheduler detects the data packet of the first application or the first data packet. The first application is an application that is whitelisted in the first electronic device.

9. The system according to claim 8, characterized in that, The system kernel layer is also used to modify the rate of the second VLAN interface to the third rate and the rate of the first VLAN interface to the fourth rate when the dynamic bandwidth scheduler does not detect the data packet of the first application or the first data packet within a first preset time period. The third rate is greater than the first rate, and the fourth rate is less than the second rate.

10. The system according to claim 8 or 9, characterized in that, The system kernel layer is also used to perform a gradual adjustment operation on the rate of the first VLAN interface or the second VLAN interface through the kernel scheduler within a second preset time period during the process of the kernel scheduler modifying the rate of the first VLAN interface or the second VLAN interface.

11. A data transmission device, characterized in that, Applied to a first electronic device, the device includes: an execution module and a transmission module; The execution module is used to create a first virtual local area network (VLAN) interface and a second VLAN interface in the virtual network interface layer through the WiFi chip driver layer of the first electronic device when the first electronic device initiates a WiFi direct connection request to the second electronic device. The transmission module is used to transmit network data packets to the Internet through the first VLAN interface created by the execution module, and to transmit user data packets to the second electronic device through the second VLAN interface created by the execution module.

12. The apparatus according to claim 11, characterized in that, The transmission module is specifically used to route the network data packets to the first VLAN interface and transmit the network data packets to the Internet through the first VLAN interface; The transmission module is specifically used to route the user data packet to the second VLAN interface and transmit the user data packet to the second electronic device through the second VLAN interface.

13. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the data transmission method as described in any one of claims 1 to 5.

14. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the data transmission method as described in any one of claims 1 to 5.