Data transmission method, data transmission system and electronic equipment
By using the XDP module in WLAN P2P connection to bypass the network protocol stack to process the packet header and send it directly to the application layer, the problem of high WLAN P2P data transmission overhead is solved, and data transmission efficiency and CPU resource utilization are improved.
Patent Information
- Application Number
- CN202411760191.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-30
- Publication Date
- 2025-08-05
AI Technical Summary
In the wireless local area network point-to-point connection (WLAN P2P) mode, the transmission overhead generated during data transmission is high, affecting the data transmission efficiency.
When establishing a WLAN P2P connection between electronic devices, the data packet headers of the service data packets are extracted through the XDP module to avoid generating network layer and transmission layer headers, and directly sending the data packets to the application layer, and using the XDP interface to bypass the network protocol stack for data transmission.
It reduces the transmission overhead caused by packet header data, improves the transmission efficiency of data packets and the utilization rate of CPU processing resources, and improves the user experience.
Smart Images

Figure CN120434832A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communications, and in particular to a data transmission method, a data transmission system, and an electronic device. Background Art
[0002] With the continuous development of wireless communication technology, electronic devices can communicate with each other through wireless local area network peer-to-peer (WLAN P2P) connections to achieve data transmission. During the process of electronic devices transmitting data through WLAN P2P, they need to go through the network protocol stack for layer-by-layer processing.
[0003] However, the WLAN P2P method is a flexible and efficient communication method. Therefore, how to reduce the transmission overhead generated during data transmission and thereby improve the data transmission efficiency between electronic devices is an urgent problem to be solved. Summary of the Invention
[0004] The embodiments of the present application provide a data transmission method, a data transmission system, and an electronic device for reducing the transmission overhead generated during the data transmission process to further improve the data transmission efficiency.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, a data transmission method is provided, which is applied to a first electronic device, the first electronic device including an application layer, an XDP module, and a network card. In this method, when a WLAN P2P connection is established between the first electronic device and a second electronic device, the second electronic device receives a first service data packet from the first electronic device. The second electronic device can then extract a data packet header of the first service data packet through the XDP module. The data packet header of the first service data packet does not include a network layer header and / or a transport layer header. The XDP module of the second electronic device can then send the first service data packet to the application layer of the second electronic device.
[0007] In the embodiment of the present application, since the first service data packet does not include a network layer header and / or a transport layer header, it indicates that the first service data packet is not a traditional network protocol stack data packet. This can reduce the high transmission overhead caused by the inclusion of a network layer header and a transport layer header in the first service data packet, thereby improving the transmission efficiency of the first service data packet and thereby enhancing the user experience.
[0008] In a possible implementation of the first aspect, when a WLAN P2P connection is established between a first electronic device and a second electronic device, the method further includes: an application layer of the first electronic device configuring target identification information in a first service data packet. Subsequently, the application layer of the first electronic device sends the first service data packet configured with the target identification information to an XDP module of the first electronic device.
[0009] In an embodiment of the present application, if a WLAN P2P connection is established between a first electronic device and a second electronic device, the application layer of the first electronic device can configure target identification information in a first service data packet. This facilitates the second electronic device's ability to determine whether the first service data packet needs to pass through the network protocol stack, providing a basis for subsequently determining the data transmission path for the first service data.
[0010] In a possible implementation of the first aspect, the above-mentioned first electronic device also includes an XDP interface, and the process of the application layer of the first electronic device sending the first business data packet can specifically include: the application layer of the first electronic device sends the first business data packet to the XDP module of the first electronic device through the XDP interface of the first electronic device.
[0011] In an embodiment of the present application, the application layer of the first electronic device can send a first service data packet to the XDP module via the XDP interface. This allows the first service data packet to bypass the network protocol stack for data transmission, thereby reducing the CPU processing resource usage caused by the addition of other header data (such as transport layer headers and network layer headers) when the first service data packet passes through the network protocol stack, thereby improving the utilization of CPU processing resources.
[0012] In a possible implementation of the first aspect, the XDP interface of the first electronic device is a socket of the XDP address family, and the process of the application layer of the first electronic device sending the first service data packet through the XDP interface of the first electronic device may specifically include: the application layer of the first electronic device directing the first service data packet to the socket of the XDP address family. Thereafter, the socket of the XDP address family sends the first service data packet to the XDP module of the first electronic device.
[0013] In an embodiment of the present application, the application layer of the first electronic device can enable the first business data packet to quickly reach the XDP module by directing the first business data packet to the socket of the XDP address family, thereby accelerating the transmission efficiency of the first business data packet.
[0014] In a possible implementation of the first aspect, the first service data packet generated by the application layer of the first electronic device skips processing by the network protocol stack in the first electronic device and is transmitted from the application layer of the first electronic device to the XDP module of the first electronic device.
[0015] In an embodiment of the present application, the first business data packet can bypass the network protocol stack for data transmission, reducing the situation where CPU processing resources are occupied due to the addition of other packet header data (such as transport layer header and network layer header) when the first business data packet passes through the network protocol stack, thereby improving the utilization rate of CPU processing resources.
[0016] In a possible implementation of the first aspect, the method further includes: if a WLAN P2P connection is not established between the first electronic device and the second electronic device, the application layer of the first electronic device may send a second service data packet to the network protocol stack of the first electronic device. Subsequently, the network protocol stack of the first electronic device may send the second service data packet to the XDP module of the first electronic device. The second service data packet includes a network layer header and a transport layer header. Subsequently, the XDP module of the first electronic device may send the second service data packet to the network interface card of the first electronic device. Subsequently, the network interface card of the first electronic device sends the second service data packet to the second electronic device.
[0017] In an embodiment of the present application, if a WLAN P2P connection is not established between the first electronic device and the second electronic device, the application layer of the first electronic device will not configure the target identification information in the service data packet. That is, the second service data packet does not include the target identification information. In addition, the second service data packet needs to be processed by the network protocol stack before it can be sent to the second electronic device. That is, the second service data packet sent to the second electronic device includes the network layer header and transport layer header added by the network protocol stack. This allows the second electronic device to determine the transmission path of the second service data packet based on the network layer header and transport layer header in the second service data packet, achieve accurate transmission of the second service data packet, and thereby improve the transmission efficiency of the second service data packet.
[0018] In a possible implementation of the first aspect, an XDP module is located in the kernel space of a first electronic device, and an application layer is located in the user space of the first electronic device. When a WLAN P2P connection is established between the first electronic device and a second electronic device, the method further includes: the first electronic device sending negotiation information to the second electronic device. Thereafter, the first electronic device receives negotiation response information from the second electronic device. The negotiation response information is used to indicate whether the first electronic device and the second electronic device can perform data transmission. Thereafter, if the negotiation response information indicates that the first electronic device and the second electronic device can perform data transmission, the user space of the first electronic device may configure the XDP module in the kernel space.
[0019] In this embodiment of the present application, if the negotiation response information indicates that the first electronic device and the second electronic device are capable of data transmission, it indicates that the WLAN direct connection function in the first electronic device and the WLAN direct connection function in the second electronic device both support XDP capabilities. Therefore, the user space of the first electronic device can configure the XDP module in the kernel space to enable the XDP module to determine the data transmission path of the service data packet, thereby providing a basis for the subsequent accurate transmission of the service data packet.
[0020] In a possible implementation of the first aspect, the process of configuring the XDP module in the kernel space by the user space of the first electronic device may specifically include: the user space of the first electronic device loads the XDP program into the kernel space of the first electronic device. The XDP program is used to enable the XDP module in the kernel space to determine the data transmission path of the service data packet. Afterwards, the user space of the first electronic device attaches the XDP program to the XDP module located in the kernel space. Afterwards, the user space of the first electronic device creates an XDP interface and initializes the XDP interface. Afterwards, the user space of the first electronic device binds the XDP interface to the XDP module. The binding is used to enable the XDP module to call the XDP interface to send service data packets to the application layer located in the user space.
[0021] In the embodiments of the present application, by attaching the XDP program to the XDP module, the kernel-space XDP module can determine the data transmission path for service data packets. Furthermore, by binding the XDP interface to the XDP module, the XDP module can call the XDP interface to send service data packets to the application layer in user space. This provides a foundation for subsequent data transmission.
[0022] In a possible implementation of the first aspect, the XDP interface is a socket of the XDP address family, and the above-mentioned process of initializing the XDP interface in the user space may specifically include: the user space applies for a user memory UMEM. The user memory is used to store service data packets received or sent by the socket of the XDP address family. Afterwards, the user space configures the user memory and registers the user memory to the socket of the XDP address family. Afterwards, the user space creates a fill ring and a completion ring in the kernel space, and receives the fill ring and completion ring mapped by the kernel space. The fill ring is used to transfer the UMEM frame in the user memory from the user space to the kernel space, and the completion ring is used to transfer the UMEM frame from the kernel space to the user space. Afterwards, the user space creates a sending ring and a receiving ring in the kernel space, and receives the sending ring and receiving ring mapped by the kernel space. The sending ring is used to send service data packets, and the receiving ring is used to receive service data packets.
[0023] In an embodiment of the present application, the configuration of the XDP interface is achieved by configuring the corresponding user memory in the socket of the XDP address family, and creating a fill ring, a completion ring, a sending ring and a receiving ring, providing a basis for the subsequent transmission of service data packets.
[0024] In a second aspect, the present application also provides a data transmission method, which is applied to a second electronic device, the second electronic device including an XDP module and an application layer. In this method, a WLAN P2P connection is established between the second electronic device and the first electronic device. The second electronic device then receives a first service data packet from the first electronic device. The second electronic device then extracts the data packet header of the first service data packet through the XDP module. The data packet header of the first service data packet does not include a network layer header and / or a transport layer header. The XDP module of the second electronic device then sends the first service data packet to the application layer of the second electronic device.
[0025] In an embodiment of the present application, if the data packet header of the first business data packet does not include a network layer header and / or a transport layer header, it means that the first business data packet is not a traditional network protocol stack data packet. Therefore, the XDP module of the second electronic device can determine that the business data packet does not need to pass through the network protocol stack, that is, the XDP module of the second electronic device can directly send the first business data packet to the application layer. In this way, the first business data packet can bypass the network protocol stack for data transmission, reducing the situation where the CPU processing resources are occupied due to the first business data packet passing through the network protocol stack, thereby improving the utilization rate of the CPU processing resources.
[0026] In a possible implementation manner of the second aspect, the identification information in the preset field in the data packet header of the first service data packet indicates a target packet header, and the target packet header does not include a network layer packet header and / or a transport layer packet header.
[0027] In an embodiment of the present application, by determining whether the identification information in the preset field in the data packet header indicates the target packet header, it is determined whether the first business data packet needs to be transmitted through the network protocol stack, thereby improving the transmission accuracy of the first business data packet.
[0028] In a possible implementation manner of the second aspect, the data packet header of the first service data packet does not comply with the byte rules of the network layer header and / or the byte rules of the transport layer header.
[0029] In the embodiment of the present application, by determining whether the data packet header conforms to the byte rules of the network layer header and / or the byte rules of the transport layer header, it is determined whether the data packet header includes the network layer header and / or the transport layer header, thereby determining whether the first service data packet needs to be transmitted through the network protocol stack. In this way, the transmission accuracy of the first service data packet can be improved.
[0030] In a possible implementation manner of the second aspect, the data packet header of the first service data packet includes target identification information configured in the first service data packet by an application layer of the first electronic device.
[0031] In an embodiment of the present application, if the data packet header of the first service data packet includes the target identification information configured in the first service data packet by the application layer of the first electronic device, it indicates that the first service data packet has not passed through the network protocol stack of the first electronic device. Therefore, the second electronic device does not need to transmit the first service data packet through the network protocol stack, that is, the first service data packet can bypass the network protocol stack for data transmission. In this way, the situation where the CPU processing resources are occupied due to the first service data packet passing through the network protocol stack can be reduced, thereby improving the utilization rate of the CPU processing resources.
[0032] In a possible implementation of the second aspect, the above-mentioned second electronic device also includes an XDP interface. The process of the XDP module of the above-mentioned second electronic device sending the first business data packet can specifically include: the XDP module of the second electronic device sends the first business data packet to the application layer of the second electronic device through the XDP interface.
[0033] In the embodiment of the present application, the XDP module of the second electronic device can send the first service data packet to the application layer via the XDP interface. This allows the first service data packet to bypass the network protocol stack for data transmission, reducing the CPU processing resource usage caused by the first service data packet passing through the network protocol stack, thereby improving the utilization of CPU processing resources.
[0034] In a possible implementation of the second aspect, the XDP interface of the second electronic device is a socket of the XDP address family, and the process of the XDP module of the second electronic device sending the first service data packet through the XDP interface of the second electronic device may specifically include: the XDP module of the second electronic device directing the first service data packet to the socket of the XDP address family. Thereafter, the socket of the XDP address family sends the first service data packet to an application layer of the second electronic device.
[0035] In an embodiment of the present application, the XDP module of the second electronic device can enable the first business data packet to quickly reach the application layer by directing the first business data packet to the socket of the XDP address family, thereby accelerating the transmission efficiency of the first business data packet.
[0036] In a possible implementation of the second aspect, the first service data packet received by the second electronic device skips processing by the network protocol stack in the second electronic device and is transmitted from the XDP module of the second electronic device to the application layer of the second electronic device.
[0037] In an embodiment of the present application, the first business data packet can bypass the network protocol stack for data transmission, reducing the situation where the CPU processing resources are occupied due to the first business data packet passing through the network protocol stack, and improving the utilization rate of the CPU processing resources.
[0038] In a possible implementation of the second aspect, the second electronic device further includes a network protocol stack, and the method further includes: the second electronic device receives a second service data packet from the first electronic device. Thereafter, the second electronic device extracts a data packet header from the second service data packet using an XDP module. The data packet header of the second service data packet includes a network layer header and a transport layer header. Thereafter, the XDP module of the second electronic device transmits the second service data packet to an application layer of the second electronic device via the network protocol stack.
[0039] In this embodiment of the present application, if the second service data packet received by the second electronic device includes a network layer header and a transport layer header, this indicates that the first electronic device passed through the network protocol stack during the transmission of the second service data packet. Therefore, the XDP module of the second electronic device also needs to send the second service data packet to the application layer of the second electronic device through the network protocol stack. This allows for precise determination of the transmission path, improving the transmission accuracy of the second service data packet and, in turn, improving the transmission efficiency of the second service data packet.
[0040] In a possible implementation of the second aspect, the XDP module is located in the kernel space of the first electronic device, and the application layer is located in the user space of the first electronic device. When a WLAN P2P connection is established between the second electronic device and the first electronic device, the method further includes: the second electronic device receives negotiation information from the first electronic device. Thereafter, the second electronic device sends negotiation response information to the first electronic device. The negotiation response information is used to indicate whether the first electronic device and the second electronic device can perform data transmission. At the same time, when the negotiation response information indicates that the first electronic device and the second electronic device can perform data transmission, the user space of the second electronic device can configure the XDP module in the kernel space.
[0041] In this embodiment of the present application, if the negotiation response information indicates that the first electronic device and the second electronic device are capable of data transmission, it indicates that the WLAN direct connection function in the first electronic device and the WLAN direct connection function in the second electronic device both support XDP capabilities. Therefore, the user space of the second electronic device can configure the XDP module in the kernel space to enable the XDP module to determine the data transmission path of the service data packet, thereby providing a basis for the subsequent accurate transmission of the service data packet.
[0042] In a possible implementation of the second aspect, the process of configuring the XDP module in the kernel space by the user space of the second electronic device may specifically include: the user space of the second electronic device loads the XDP program into the kernel space of the second electronic device. The XDP program is used to enable the XDP module in the kernel space to determine the data transmission path of the service data packet. Afterwards, the user space of the second electronic device attaches the XDP program to the XDP module located in the kernel space. Afterwards, the user space of the second electronic device creates an XDP interface and initializes the XDP interface. Afterwards, the user space of the second electronic device binds the XDP interface to the XDP module. The binding is used to enable the XDP module to call the XDP interface to send service data packets to the application layer located in the user space.
[0043] In the embodiments of the present application, by attaching the XDP program to the XDP module, the kernel-space XDP module can determine the data transmission path for service data packets. Furthermore, by binding the XDP interface to the XDP module, the XDP module can call the XDP interface to send service data packets to the application layer in user space. This provides a foundation for subsequent data transmission.
[0044] In a possible implementation of the second aspect, the XDP interface is a socket of the XDP address family, and the above-mentioned process of initializing the XDP interface in the user space may specifically include: the user space applies for a user memory UMEM. The user memory is used to store service data packets received or sent by the socket of the XDP address family. Afterwards, the user space configures the user memory and registers the user memory to the socket of the XDP address family. Afterwards, the user space creates a fill ring and a completion ring in the kernel space, and receives the fill ring and completion ring mapped by the kernel space. The fill ring is used to transfer the UMEM frame in the user memory from the user space to the kernel space, and the completion ring is used to transfer the UMEM frame from the kernel space to the user space. Afterwards, the user space creates a sending ring and a receiving ring in the kernel space, and receives the sending ring and receiving ring mapped by the kernel space. The sending ring is used to send service data packets, and the receiving ring is used to receive service data packets.
[0045] In an embodiment of the present application, the configuration of the XDP interface is achieved by configuring the corresponding user memory in the socket of the XDP address family, and creating a fill ring, a completion ring, a sending ring and a receiving ring, providing a basis for the subsequent transmission of service data packets.
[0046] In a third aspect, the present application provides a data transmission system, which includes a first electronic device and a second electronic device, wherein the first electronic device is used to execute the method described in the first aspect above, and the second electronic device is used to execute the method described in the second aspect above.
[0047] In a fourth aspect, the present application provides an electronic device, which is a first electronic device and a second electronic device, wherein the electronic device includes an application layer, a network card, an XDP module, a memory, and one or more processors; the application layer, the network card, the XDP module, the memory, and the processor are coupled; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device executes the method described above.
[0048] In a fifth aspect, the present application provides a computer-readable storage medium comprising computer instructions, which, when executed on an electronic device, enables the electronic device to execute the method described above.
[0049] In a sixth aspect, the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the method described above.
[0050] In the seventh aspect, a chip is provided, comprising: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method as described above.
[0051] Among them, the beneficial effects that can be achieved by the data transmission system described in the third aspect, the electronic device described in the fourth aspect, the computer-readable storage medium described in the fifth aspect, the computer program product described in the sixth aspect, and the chip described in the seventh aspect provided above can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A schematic diagram of an interface for setting WLAN and mobile data functions provided in an embodiment of the present application;
[0053] Figure 2 A schematic diagram of two electronic devices communicating via a WLAN or cellular network provided in an embodiment of the present application;
[0054] Figure 3 A schematic diagram of a communication between multiple electronic devices via a trust ring provided in an embodiment of the present application;
[0055] Figure 4 A schematic diagram of an interface for setting the WLAN direct connection function provided in an embodiment of the present application;
[0056] Figure 5 A schematic diagram of two electronic devices communicating via a WLAN direct connection network provided in an embodiment of the present application;
[0057] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0058] Figure 7 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0059] Figure 8 A flowchart of a data transmission method provided in an embodiment of the present application;
[0060] Figure 9 A flowchart of a data transmission method provided in an embodiment of the present application;
[0061] Figure 10 A flowchart of another data transmission method provided in an embodiment of the present application;
[0062] Figure 11 A schematic diagram of a process for configuring data transmission parameters between a first mobile phone and a second mobile phone provided in an embodiment of the present application;
[0063] Figure 12 A schematic diagram of a data transmission process provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] The technical solutions in the embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0065] References to "one embodiment" or "some embodiments" etc. described in this specification mean that the specific features, structures or characteristics described in conjunction with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in another way. The term "connected" includes direct and indirect connections, unless otherwise stated. "First" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0066] In the embodiments of this application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.
[0067] In some embodiments, a communication connection can be established between electronic devices to achieve data transmission. That is, when a communication connection is established between two electronic devices, the two electronic devices can perform data transmission.
[0068] It should be noted that when two electronic devices transmit business data packets, they need to be processed layer by layer through the network protocol stack in the kernel state (or kernel space). That is, when a sending device (or a first electronic device) transmits a business data packet to a receiving device (or a second electronic device), the sending device will generate a transport layer header and a network layer header in sequence. Afterwards, when the receiving device receives the business data packet, the transport layer header, and the network layer header transmitted by the sending device, the receiving device will delete the transport layer header and the network layer header in sequence to obtain the business data packet, thereby realizing the data transmission function.
[0069] Specifically, when the above-mentioned business data packet passes through the transport layer of the sending device, the network protocol stack located in the kernel state of the sending device will generate a transport layer header. In addition, when the business data packet passes through the network layer of the sending device, the network protocol stack located in the kernel state of the sending device will generate a network layer header. Afterwards, the sending device can package the transport layer header, the network layer header, and the business data packet to obtain the target data packet, and send the target data packet to the receiving device. Afterwards, when the receiving device receives the target data packet transmitted by the sending device, if the target data packet passes through the network layer of the receiving device, the network protocol stack located in the kernel state of the receiving device will delete the network layer header. At the same time, if the target data packet passes through the transport layer of the receiving device, the network protocol stack located in the kernel state of the receiving device will delete the transport layer header so that the application layer of the receiving device can obtain the business data packet.
[0070] In one implementation, a communication connection can be established between two electronic devices via a wireless local area network (WLAN) or a cellular network. A wireless local area network transmits data via wireless signals provided by a WIFI hotspot or router. A cellular network is equivalent to a mobile network, which transmits data via mobile signals. That is, in response to a user's activation operation for a WLAN, the electronic device can activate the wireless communication function; and / or, in response to a user's activation operation for a mobile network, the electronic device can activate the mobile communication function. For example, see Figure 1As shown, taking one of the two electronic devices as a mobile phone as an example, the mobile phone displays a notification bar interface. The notification bar interface includes a "WLAN" control 1A and a "Mobile Network" control 1B. Subsequently, if the user clicks the "WLAN" control 1A in the notification bar interface, the mobile phone can enable the wireless communication function, that is, the mobile phone can transmit data via the wireless signal provided by the WIFI hotspot or router. If the user clicks the "Mobile Network" control 1B in the notification bar interface, the mobile phone can enable the mobile communication function, that is, the mobile phone can transmit data via the mobile signal of the cellular modem.
[0071] The following will be combined Figure 2 The data transmission system shown introduces a process of two electronic devices communicating via a WLAN or cellular network.
[0072] like Figure 2 As shown, the above-mentioned data transmission system may include an electronic device 200A, an electronic device 200B and a server 300. The server 300 establishes a communication connection with the electronic device 200A and the electronic device 200B via a WLAN or a cellular network, so that a communication connection is established between the electronic device 200A and the electronic device 200B. When a communication connection is established between the electronic device 200A and the electronic device 200B, if the electronic device 200A is a sending device and the electronic device 200B is a receiving device, the electronic device 200A generates a driver layer header, a network layer header and a transport layer header in the process of transmitting a service data packet (payload) to the electronic device 200B. The driver layer header is used to characterize Ethernet (ETH). The network layer header is used to characterize the Internet protocol (IP) address and port number. The transport layer header is used to characterize the transmission control protocol (TCP) and / or the user datagram protocol (UDP). Afterwards, the electronic device 200A may package the driver layer header, the network layer header, the transport layer header, and the service data packet and send them to the server 300 , so that the server 300 can transmit the service data packet to the electronic device 200B.
[0073] It can be understood that the above-mentioned server 300 can be the server of the application to which the above-mentioned business data packet belongs, or it can be a server of multiple applications integrated in electronic device 200A and electronic device 200B, etc. As long as the server can support the data transmission function of the application to which the business data packet belongs, there is no specific limitation.
[0074] In another implementation, two or more electronic devices can also be connected to each other through a trust ring. The trust ring refers to a trust relationship established when two or more electronic devices log in to the same account and are in the same wireless local area network. That is to say, when two or more electronic devices log in to the same account and the Bluetooth switches and WIFI switches of the two or more electronic devices are both on, if the distance between the two or more electronic devices is close, the two or more electronic devices can be interconnected through the device discovery process, and the two or more interconnected electronic devices constitute a trust ring. Afterwards, any electronic device in the trust ring can view all terminal devices included in the trust ring. In addition, any electronic device in the trust ring can transmit data to other electronic devices in the trust ring.
[0075] For example, Figure 3 As shown, the Figure 3 The data transmission system shown in a may include a laptop 110, a mobile phone 120, and a tablet computer 130. When a trust ring connection is established between the laptop 110, the mobile phone 120, and the tablet computer 130, the mobile phone 120 in the trust ring may display Figure 3 The trust ring interface shown in b is shown in Figure 1. This trust ring interface can include all electronic devices in the trust ring, namely, the local device ball 1201, the laptop device ball 1101, and the tablet device ball 1301. In other words, the trust ring interface of each electronic device in the trust ring can display all electronic devices in the trust ring. Subsequently, in response to a click on any device ball in the trust ring interface, the mobile phone 120 can transmit data with the electronic device corresponding to the selected device ball.
[0076] In another implementation, two electronic devices can communicate with each other through a WLAN peer-to-peer (P2P) network, that is, the two electronic devices can communicate with each other through WIFI through a WLAN P2P connection. Among them, WLAN P2P connection, also known as WLAN Direct, is a wireless local area network technology used to enable electronic devices to communicate directly, that is, no server is required for data transmission. Afterwards, when WLAN P2P is established between two electronic devices, the two electronic devices can transmit data to achieve functions such as file transfer, screen projection, and call flow. Among them, file transfer can include file sharing, device cloning, file migration, etc. Call flow refers to transferring an ongoing call from one electronic device to another electronic device to achieve seamless connection and efficient use between multiple devices.
[0077] For example, Figure 4 As shown, two electronic devices are taken as an example, namely mobile phone A and mobile phone B. Mobile phone A displays Figure 4 The WLAN direct connection interface shown in (a) of FIG. The WLAN direct connection interface includes a name control of mobile phone B. Afterwards, in response to the first user clicking the name control of mobile phone B in the WLAN direct connection interface, mobile phone A may send a connection request to mobile phone B to establish a WLAN direct connection. Afterwards, when mobile phone B receives the connection request sent by mobile phone A to establish a WLAN direct connection, mobile phone B may display the following information: Figure 4 The connection prompt interface shown in (b) of FIG. The connection prompt interface includes connection request prompt information, a "Cancel" control, and a "Connect" control. Afterwards, in response to the second user clicking the "Connect" control in the connection prompt interface, mobile phone B can send a connection consent indication to mobile phone A. Afterwards, when mobile phone A receives the connection consent indication sent by mobile phone B, mobile phone A can display the following Figure 4 In the Wi-Fi Direct interface shown in (c), phone A displays "Connected" in the name control of phone B, confirming the Wi-Fi Direct connection. Afterward, phones A and B can transfer files to each other for file sharing, cloning between devices, and file migration.
[0078] The following will be combined Figure 5 The data transmission system shown introduces a process of two electronic devices communicating via a WLAN P2P network.
[0079] like Figure 5 As shown, the above-mentioned data transmission system may include an electronic device 200A and an electronic device 200B. Among them, the electronic device 200A and the electronic device 200B establish a communication connection through a WLAN P2P network, so that the electronic device 200A and the electronic device 200B can directly transmit data. In the case of establishing a communication connection between the electronic device 200A and the electronic device 200B, if the electronic device 200A is a sending device and the electronic device 200B is a receiving device, the electronic device 200A will still generate an Ethernet header, a network layer header and a transport layer header in the process of transmitting a business data packet (payload) to the electronic device 200B. Afterwards, the electronic device 200A can package the Ethernet header, the network layer header, the transport layer header and the business data packet and send them to the electronic device 200B to realize data transmission.
[0080] In reality, during data transmission over a WLAN P2P network, a physical communication channel is directly established between electronic devices 200A and 200B, enabling point-to-point transmission of service data packets. This means that during the transmission of service data packets, there is no need for a server located between electronic devices 200A and 200B, and no need to generate transport and network layer headers. In other words, in a WLAN P2P scenario, the transport and network layer headers generated by the kernel-mode network protocol stack of electronic device 200A are redundant data.
[0081] In some embodiments of the present application, the target data packet transmitted by the sending device is subject to the capacity limit of the maximum transmission unit (MTU). In other words, the maximum data size of the target data packet transmitted by the sending device is fixed. Therefore, the larger the data size of the transport layer header and the network layer header, the higher the transmission overhead of the sending device for the transport layer header and the network layer header, which in turn affects the transmission efficiency of the service data packet.
[0082] Furthermore, the kernel-mode network protocol stack consumes CPU processing resources on the sending device during the generation of the transport and network layer headers, resulting in wasted performance on the sending device. Furthermore, the kernel-mode network protocol stack consumes CPU processing resources on the receiving device during the generation of the transport and network layer headers, resulting in wasted performance on the receiving device.
[0083] Therefore, in order to reduce the transmission overhead of service data packets while improving the utilization of CPU processing resources, an embodiment of the present application provides a data transmission method. In this method, when a WLAN P2P connection is established between a first electronic device and a second electronic device, the application layer of the first electronic device can send a first service data packet to the XDP module of the first electronic device. The first service data packet does not include a network layer header and / or a transport layer header. Thereafter, the XDP module of the first electronic device can send the first service data packet to the network card of the first electronic device. Thereafter, the network card of the first electronic device can send the first service data packet to the second electronic device.
[0084] In the embodiment of the present application, since the first service data packet does not include a network layer header and / or a transport layer header, it indicates that the first service data packet is not a traditional network protocol stack data packet. This can reduce the high transmission overhead caused by the inclusion of a network layer header and a transport layer header in the first service data packet, thereby improving the transmission efficiency of the first service data packet and thereby enhancing the user experience.
[0085] In addition, in order to improve the utilization of CPU processing resources, an embodiment of the present application also provides a data transmission method. In this method, when a WLAN P2P connection is established between a first electronic device and a second electronic device, the second electronic device receives a first service data packet from the first electronic device. Afterwards, the second electronic device can extract the data packet header of the first service data packet through the XDP module. The data packet header of the first service data packet does not include a network layer header and / or a transport layer header. Afterwards, the XDP module of the second electronic device can send the first service data packet to the application layer of the second electronic device.
[0086] In an embodiment of the present application, if the data packet header of the first business data packet does not include a network layer header and / or a transport layer header, it means that the first business data packet is not a traditional network protocol stack data packet. Therefore, the XDP module of the second electronic device can determine that the business data packet does not need to pass through the network protocol stack, that is, the XDP module of the second electronic device can directly send the first business data packet to the application layer. In this way, the first business data packet can bypass the network protocol stack for data transmission, reducing the situation where the CPU processing resources are occupied due to the first business data packet passing through the network protocol stack, thereby improving the utilization rate of the CPU processing resources.
[0087] In some examples, the electronic device in the embodiments of the present application can be a mobile phone, a tablet computer, a smart watch, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) or virtual reality (VR) device, etc., which has a WLAN direct connection function. The embodiments of the present application do not impose any special restrictions on the specific form of the electronic device.
[0088] For example, Figure 6 Schematic diagram of the structure of the electronic device 200 is shown. Figure 6As shown, the electronic device 200 may include a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 211, a power management module 212, a battery 213, an antenna 1, an antenna 2, a mobile communication module 240, a wireless communication module 250, an audio module 270, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display screen 294, and a subscriber identification module (SIM) card interface 295, etc.
[0089] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 200. In other embodiments of the present application, the electronic device 200 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0090] The processor 210 may include one or more processing units. For example, the processor 210 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0091] In some embodiments, the electronic device 200 can implement the data transmission method provided in this application through the processor 210.
[0092] The wireless communication function of the electronic device 200 can be implemented through the antenna 1, the antenna 2, the mobile communication module 240, the wireless communication module 250, the modem processor and the baseband processor.
[0093] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 200 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0094] The mobile communication module 250 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 200. The mobile communication module 250 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 250 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 250 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 250 can be set in the processor 210. In some embodiments, at least some of the functional modules of the mobile communication module 250 can be set in the same device as at least some of the modules of the processor 210.
[0095] The mobile communication module 250 can be used to transmit data. That is, the electronic device 200 can establish a communication connection with a cellular network through the mobile communication module to achieve data transmission.
[0096] In some embodiments of the present application, the mobile communication module may also be referred to as a cellular module, and the two may be described interchangeably.
[0097] The modem processor (modem) in the mobile communication module may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker, a receiver, etc.) or displays an image or video through the display screen 294. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 210 and be set in the same device as the mobile communication module 250 or other functional modules.
[0098] The wireless communication module 260 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (WIFI) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. applied to the electronic device 200. The wireless communication module 260 can be one or more devices integrating at least one communication processing module. The wireless communication module 260 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 210. The wireless communication module 260 can also receive the signal to be sent from the processor 210, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2. In some embodiments, at least some functional modules of the wireless communication module 260 can be set in the processor 210.
[0099] In some cases, the wireless communication module 260 may include a WIFI module. The WIFI module is used to transmit data, that is, the electronic device 200 can establish a WLAN connection with other devices through the WIFI module to achieve data transmission.
[0100] In other cases, the wireless communication module 260 may also include a network interface card (NIC), which is a hardware device that connects the electronic device to the network. In some embodiments, the NIC can be used to send or receive target data packets. For example, the target data packet can be a service data packet of any application in the electronic device 200.
[0101] In some embodiments, antenna 1 of electronic device 200 is coupled to mobile communication module 250 , and antenna 2 is coupled to wireless communication module 260 , so that electronic device 200 can communicate with the network and other devices through wireless communication technology.
[0102] Electronic device 200 implements display functionality through a GPU, display screen 294, and an application processor. A GPU is a microprocessor for image processing that connects display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 210 may include one or more GPUs that execute program instructions to generate or modify display information.
[0103] The display screen (or screen) 294 is used to display images, videos, etc. In some embodiments, the electronic device 200 may include one or N display screens 294, where N is a positive integer greater than 1. In an embodiment of the present application, the display screen 294 can be used to display a preview interface and a shooting interface in video recording mode.
[0104] For example, the software system of the electronic device 200 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. Taking the system as an example, the software structure of the electronic device 200 is exemplified.
[0105] Figure 7 FIG2 is a system structure block diagram of an electronic device 200 according to an embodiment of the present application. It can be understood that the electronic device 200 may include a first electronic device 200A and a second electronic device 200B.
[0106] A layered architecture divides the system into several layers, each with clear roles and divisions of labor. Layers communicate with each other via software interfaces. In some embodiments, the Linux system is divided into two layers: user space and kernel space, from top to bottom. User space and kernel space are two modes or states of the operating system (OS). Kernel space is often referred to as the privileged state, while user space is often referred to as the unprivileged state.
[0107] like Figure 7 As shown, the user space may include an application layer. The application layer may include all applications installed in the electronic device. The application is used to receive corresponding service data packets to implement data transmission functions.
[0108] In some embodiments, the user space may further include a control plane module, as well as virtual machine (VM) and container modules. The control plane module is configured to accept, discover, route, and connect connection requests. The connection request may be a request for a WLAN direct connection. The VM and container modules are configured to isolate each application in the electronic device.
[0109] The kernel space is where the OS manages key resources and provides the entry point for service data packets required by applications in the user space. This kernel space can include the network card driver module, the network protocol stack, and the target address family.
[0110] The network card driver module may include an express data path (XDP) module and a structure (build sk_buff) module. The XDP module is used to determine whether the data packet header in the service data packet meets the preset transmission conditions, thereby determining the transmission path of the service data packet.
[0111] In some embodiments, when the XDP module receives a business data packet obtained by the network card in the hardware layer, it can determine whether the data packet header in the business data packet meets the preset transmission conditions. If the data packet header in the business data packet meets the preset transmission conditions, it means that the business data packet is not a traditional network protocol stack data packet, that is, the data packet header in the business data packet does not include a transport layer header and / or a network layer header. Therefore, the XDP module can directly send the business data packet as a first business data packet to the target protocol family, so that the business data packet can bypass the network protocol stack. If the data packet header in the business data packet does not meet the preset transmission conditions, it means that the business data packet is a traditional network protocol stack data packet, that is, the data packet header in the business data packet includes a transport layer header and a network layer header. Therefore, the XDP module can send the business data packet as a second business data packet to the network protocol stack to facilitate the data transmission function.
[0112] The preset transmission condition may include identification information in a preset field in a data packet header of the service data packet indicating that the data packet header is a target packet header, and / or the data packet header of the first service data packet does not conform to the byte rules of the network layer packet header and / or the byte rules of the transport layer packet header. The target packet header does not include the network layer packet header and / or the transport layer packet header.
[0113] The network protocol stack is used to send the above-mentioned service data packets to the application program adapted for the service data packets in the user space. The network protocol stack may include a queuing and forwarding module, an IP layer protocol processing module, a transport layer protocol processing module, an address family for network communication (AF_INET), raw sockets (AF_RAW), and virtual devices. The queuing and forwarding module refers to the process in which a service data packet waits for forwarding, that is, the process in which a service data packet waits for data transmission. The IP layer protocol processing module is used to parse the IP address and port number from the network layer header in the service data packet. The transport layer protocol processing module is used to parse the protocol type from the transport layer header in the service data packet. This protocol type may include TCP and UDP. AF_INET is a socket type for the IPv4 network protocol, which is used to specify the address family for network communication. In other words, AF_INET can indicate that an electronic device uses the IPv4 network protocol for communication. AF_RAW is used to enable direct communication between the network layer and the application program, that is, without going through the transport layer. A virtual device is used to transform a physical device (ie, an electronic device) into several logical devices, thereby enabling multiple processes to share the physical device simultaneously.
[0114] In some embodiments, when the network protocol stack receives the above-mentioned business data packet, it can pass the business data packet through the queuing forwarding module, IP layer protocol processing module, transport layer protocol processing module and AF_INET address family in sequence, so that the user space application can receive the business data packet.
[0115] The target address family is the XDP address family (AF_XDP), which is used to send service data packets directly to applications in user space that are compatible with the service data packets. In some embodiments, upon receiving the service data packets, the target address family can directly send the service data packets to the application that is compatible with the service data packets using the socket type corresponding to the XDP address family, thereby implementing data transmission.
[0116] In some embodiments, the above Figure 7 The hardware layer in the kernel space may include hardware resources that the kernel space depends on. For example, the hardware layer may include a network card. The network card may be used to send or receive service data packets.
[0117] In some embodiments, as Figure 7As shown, in response to the data transmission operation, the user space of the first electronic device can configure the target identification information in the first business data packet of the application. Afterwards, the user space of the first electronic device can execute step a to direct the first business data packet configured with the target identification information to the target address family (i.e., the AF_XDP address family) of the first electronic device. Afterwards, the target address family of the first electronic device can execute step b to send the first business data packet to the XDP module in the network card driver module of the first electronic device. Afterwards, the XDP module of the first electronic device can execute step c to send the first business data packet to the network card of the first electronic device. Afterwards, the network card of the first electronic device can execute step d to send the first business data packet to the network card of the second electronic device.
[0118] When the network card of the second electronic device receives the service data packet, it can execute step e to trigger the XDP module in the network card driver module of the second electronic device to receive the service data packet. Afterwards, when the XDP module of the second electronic device receives the service data packet, it can determine whether the data packet header in the service data packet meets the preset transmission conditions. Afterwards, when the data packet header in the service data packet meets the preset transmission conditions, the XDP module can execute step f to direct the service data packet as the first service data packet to the target address family (i.e., AF_XDP address family) of the second electronic device. Afterwards, the target address family of the second electronic device can execute step g to send the first service data packet to the application in the user space of the second electronic device to realize the data transmission function.
[0119] If the data packet header in the service data packet does not meet the preset transmission conditions, the XDP module may treat the service data packet as a second service data packet and execute step h to send the second service data packet to the structure module. Subsequently, upon receiving the second service data packet, the structure module may execute step i to send the second service data packet to the network protocol stack. Subsequently, upon receiving the second service data packet, the network protocol stack may sequentially pass the second service data packet through the queuing and forwarding module, the IP layer protocol processing module, the transport layer protocol processing module, and the AF_INET address family in the network protocol stack. The queuing and forwarding module is configured to allow the service data packet to wait for data transmission. The IP layer protocol processing module is configured to parse the network layer header in the service data packet to obtain the IP address and port number. The transport layer protocol processing module is configured to parse the transport layer header in the service data packet to identify the protocol type included in the transport layer header. The AF_INET address family is used to send the second service data packet to the application in user space to implement data transmission. That is, when the AF_INET address family in the network protocol stack receives the service data packet, the network protocol stack may execute step j to send the second service data packet to the application in the user space of the second electronic device.
[0120] It is understandable that Figure 7 The layers in the illustrated structure and the components contained in each layer do not constitute a specific limitation on the electronic device 200, i.e., a mobile phone. In other embodiments of the present application, the structure may include more or fewer layers than shown, and each layer may include more or fewer components, and this application does not limit this.
[0121] The data transmission method of the embodiment of the present application can be applied to the scenario of data transmission between electronic devices. For example, in the WLAN direct connection scenario, operations such as file transfer, screen projection, and call flow are performed. The following example will take the electronic device as a mobile phone, that is, the sending device is the first mobile phone, and the receiving device is the second mobile phone as an example to illustrate the method of the embodiment of the present application. Specifically, Figure 8 As shown, the data transmission method may include S700 to S704.
[0122] S700: A WLAN P2P connection is established between the first mobile phone and the second mobile phone.
[0123] In some cases, before the first mobile phone and the second mobile phone perform data transmission, the first mobile phone and the second mobile phone need to establish a WLAN P2P connection. For example, the first mobile phone can establish a WLAN P2P connection with the second mobile phone in the WLAN direct connection interface.
[0124] For example, Figure 4In the WLAN direct connection interface shown in (c), the first mobile phone is mobile phone A and the second mobile phone is mobile phone B. When mobile phone A displays the WLAN direct connection interface, if the word "Connected" is displayed in the name control of mobile phone B, it means that mobile phone A and mobile phone B have established a WLAN P2P connection, that is, mobile phone A and mobile phone B can transmit data.
[0125] S701: In response to a data transmission operation, a second mobile phone receives a service data packet from a first mobile phone.
[0126] The above-mentioned data transmission operation is used to trigger the first mobile phone to transfer data to the second mobile phone. Exemplarily, the data transmission operation may include a file transfer operation, a screen projection operation, and a call transfer operation, etc., as long as it is an operation that requires data transmission, and there is no specific limitation. The file transfer operation may include a device cloning operation, a data migration operation, a file sharing operation, etc. The data transmission operation will be introduced below in conjunction with the application scenario of the technical solution of this application.
[0127] Exemplarily, taking the above-mentioned data transmission operation as an example of a file sharing operation, in the file sharing business scenario, the file sharing operation can be used to trigger the first mobile phone to perform a file sharing operation on the second mobile phone. In the file sharing business scenario, the first mobile phone responds to the user's selection operation on the file displayed on the first mobile phone and determines the selected file as the target file. Afterwards, the first mobile phone can display the identification information (such as the name) of at least one available mobile phone in response to the user's trigger operation (such as a click operation) on the file sharing control displayed on the first mobile phone. Afterwards, the first mobile phone receives the user's click operation on the name of the second mobile phone displayed on the first mobile phone (equivalent to a data transmission operation), indicating that the first mobile phone needs to transfer the target file of the first mobile phone to the second mobile phone based on the WIFI connection. Then, as a response to the data transmission operation, the first mobile phone can configure the target identification information in the first business data packet of the application to which the target file belongs.
[0128] It should be noted that the above-mentioned file sharing business scenario is only an example. The technical solution introduced in this application can also be applied to scenarios where WIFI connection is required between other devices to transmit data. Accordingly, the data transmission operation can also be used to trigger the first mobile phone to perform other types of operations, which is not limited by this application.
[0129] Specifically, after detecting the above-mentioned data transmission operation, the first mobile phone can generate a service data packet and send the service data packet to the second mobile phone, that is, the second mobile phone can receive the service data packet from the first mobile phone. Among them, the service data packet is a data packet generated during the operation of the target application. The service data packet may include a data packet header and a payload. The data packet header can be used to characterize the transmission information of the service data packet. The payload is also called a packet body, which is used to characterize the actual data content to be transmitted. For example, taking the transmission of a picture as an example, the packet body can be used to characterize the data content corresponding to the picture.
[0130] In one exemplary embodiment, the data packet header may include target identification information. This target identification information is used to indicate that a WLAN P2P connection has been established between the first mobile phone and the second mobile phone. In another example, the data packet header may also include a network layer header and / or a transport layer header. It is understood that if the data packet header includes a network layer header and / or a transport layer header, it indicates that the service data packet to which the data packet header belongs has passed through the network protocol stack of the first mobile phone.
[0131] S702: The second mobile phone determines whether the service data packet meets the preset transmission condition.
[0132] In some embodiments, after the second mobile phone receives the service data packet from the first mobile phone, the second mobile phone can determine whether the service data packet meets the preset transmission conditions. If the service data packet meets the preset transmission conditions, it means that the service data packet is not a traditional network protocol stack data packet, that is, the data packet header of the service data packet does not include a transport layer header and / or a network layer header. Therefore, the second mobile phone can execute S703 to improve the transmission efficiency of the service data packet. If the service data packet does not meet the preset transmission conditions, it means that the service data packet is a traditional network protocol stack data packet, that is, the data packet header includes a transport layer header and a network layer header. Therefore, the second mobile phone can execute S704 to achieve accurate transmission of the service data packet.
[0133] In one implementation, the preset transmission condition may include identifying information in a preset field in the data packet header of the service data packet, indicating that the target packet header is a target packet header. The target packet header does not include a network layer header and / or a transport layer header. The identifying information may be a target number. For example, the target number 25 may be set at the fourth byte position of the data packet header. In other words, as long as the fourth byte position in the data packet header corresponds to the target number 25, the second mobile phone can determine that the service data packet meets the preset transmission condition.
[0134] In another implementation, the above-mentioned preset transmission condition may also include that the data packet header of the service data packet does not conform to all byte rules in the byte rule library. The byte rule library may include at least one byte rule. The byte rules include but are not limited to the byte rules of the network layer header, the byte rules of the transport layer header, etc. For example, the byte rule library includes the byte rules of the network layer header, and the byte rules of the network layer header are to set the target number to 45 at the third byte position of the header. If the data packet header of the service data packet is 11 12 13 15 17 46, it means that the number corresponding to the third byte position of the header is 13, which is not the target number 45. The second mobile phone can determine that the service data packet does not meet the preset transmission condition.
[0135] S703: The second mobile phone sends the service data packet as a first service data packet to the target application, wherein the first service data packet is a data packet that does not include a network layer header and / or a transport layer header.
[0136] Specifically, after determining that the service data packet meets the preset transmission conditions, the second mobile phone can send the service data packet as a first service data packet to the target application. The first service data packet is a data packet that does not include a network layer header and / or a transport layer header, and the target application is an application at the application layer that is compatible with the service data packet.
[0137] In some embodiments, the second mobile phone can send the first service data packet to the target application in the application layer of the second mobile phone through the target address family, thereby completing the reception operation of the first service data packet. The target address family is the XDP address family (AF_XDP), which is used to send the first service data packet directly to the target application. In this way, the first service data packet can bypass the network protocol stack for data transmission, reducing the CPU processing resource occupation caused by the first service data packet passing through the network protocol stack, and improving the utilization of CPU processing resources.
[0138] Specifically, the second mobile phone can send the first service data packet to the target application in the application layer through the socket type corresponding to AF_XDP, thereby accelerating the transmission efficiency of the first service data packet.
[0139] S704: The second mobile phone sends the service data packet as a second service data packet to the target application, wherein the second service data packet is a data packet including a network layer header and a transport layer header.
[0140] Specifically, after determining that the service data packet does not meet the preset transmission condition, the second mobile phone can send the service data packet as a second service data packet to the target application, wherein the second service data packet is a data packet including a network layer header and a transport layer header.
[0141] In some embodiments, the second mobile phone can send a second service data packet to a target application in the application layer of the second mobile phone through a network protocol stack, thereby completing the reception operation of the second service data packet. The network protocol stack may include a queuing and forwarding module, an IP layer protocol processing module, a transport layer protocol processing module, and an AF_INET address family. That is, the second mobile phone can sequentially pass the second service data packet through the queuing and forwarding module, the IP layer protocol processing module, the transport layer protocol processing module, and the AF_INET address family in the network protocol stack. The queuing and forwarding module is used to allow the second service data packet to wait for data transmission. The IP layer protocol processing module is used to parse the network layer header in the second service data packet to obtain the IP address and port number. The transport layer protocol processing module is used to parse the transport layer header in the second service data packet to distinguish the protocol type included in the transport layer header. The AF_INET address family is used to send the second service data packet to the application in user space to implement the transmission function of the second service data packet.
[0142] In one implementation, when receiving a service data packet sent by the first mobile phone, the second mobile phone can determine the data type of the service data packet according to the data packet header in the service data packet, thereby realizing the transmission function of the service data packet. Figure 7 The structure shown and Figure 9 The data transmission process shown in FIG. 1 details how the XDP module in the second mobile phone detects the data packet header in the first service data packet to implement the data transmission process.
[0143] S8001. In response to a data transmission operation, a user space of a first mobile phone configures target identification information in a first service data packet of an application layer.
[0144] In one implementation, when a WLAN P2P connection is established between a first mobile phone and a second mobile phone, if the first mobile phone detects a data transmission operation, the user space of the first mobile phone may configure target identification information in a first service data packet. The user space includes an application layer. The application layer may include a target application, which is the application corresponding to the data transmission operation. For example, if the data transmission operation is for any image in a gallery application, the first mobile phone may determine that the target application is the gallery application.
[0145] In some embodiments, the target identification information may be a packet header pre-set according to a preset byte rule. The preset setting requirement may be that identification information in a preset field in the packet header of the first service data packet indicates the target packet header. The target packet header does not include a network layer header and / or a transport layer header. The identification information may be a target number.
[0146] In other embodiments, the target identification information may be any data packet header of the first service data packet that does not conform to all byte rules in a byte rule library. The byte rule library may include at least one byte rule. The byte rule includes, but is not limited to, byte rules for network layer headers and transport layer headers.
[0147] In another implementation, when a WLAN P2P connection is not established between the first mobile phone and the second mobile phone, if the first mobile phone detects a data transmission operation, the mobile phone can directly generate a second service data packet, that is, the target identification information can be configured in the second service data packet at the application layer.
[0148] S8002. The user space sends a first service data packet to the kernel space of the first mobile phone.
[0149] Specifically, after the first service data packet is configured with target identification information, the user space may send the first service data packet configured with target identification information to the kernel space of the first mobile phone. The kernel space may include a network card driver module and a target address family. The network card driver module may include an XDP module. The target address family is the AF_XDP address family. The AF_XDP address family includes a socket (i.e., socket s1). The socket is respectively connected to the XDP module and the application layer. The socket is an interface for interaction between the application layer and the XDP module, that is, the socket is used to complete data transmission between the application layer and the XDP module.
[0150] In one implementation, the user space may send the first service data packet configured with the target identification information to the XDP module in the kernel space through a socket of the AF_XDP address family.
[0151] S8003. When the kernel space receives the first service data packet sent by the user space, the kernel space sends the first service data packet to the network card of the first mobile phone.
[0152] Specifically, after the kernel space receives the first service data packet sent by the user space, the kernel space can send the first service data packet to the network card in the hardware layer of the first mobile phone, so that the network card of the second mobile phone can subsequently receive the first service data packet.
[0153] S8004. When the network card of the first mobile phone receives the first service data packet sent by the kernel space, the network card of the first mobile phone sends the first service data packet to the network card of the second mobile phone.
[0154] S8005. When the network card of the second mobile phone receives the first service data packet sent by the network card of the first mobile phone, the network card of the second mobile phone sends the first service data packet to the XDP module in the kernel space of the second mobile phone.
[0155] Specifically, after receiving the first service data packet sent by the network card of the first mobile phone, the network card of the second mobile phone can send the first service data packet to the kernel space of the second mobile phone. The kernel space of the second mobile phone has the same structure as the kernel space of the first mobile phone. That is, the kernel space of the second mobile phone can include a network card driver module and a target address family. The network card driver module can include an XDP module. The target address family is the AF_XDP address family. The AF_XDP address family includes a socket (i.e., socket s1).
[0156] In one implementation, the network card of the second mobile phone can send the first service data packet to the XDP module in the kernel space of the second mobile phone, so that the XDP module can determine whether the data packet header in the first service data packet includes a network layer header and / or a transport layer header.
[0157] S8006. When receiving the first service data packet sent by the network card of the second mobile phone, the XDP module in the kernel space extracts data from the first service data packet to obtain a data packet header.
[0158] Specifically, after receiving the first service data packet sent by the network card of the second mobile phone, the XDP module in the kernel space of the second mobile phone can extract data from the first service data packet to obtain a data packet header.
[0159] In some embodiments, the XDP module may directly obtain (or extract) the data packet header from the first service data packet.
[0160] S8007. The XDP module in the kernel space determines whether the data packet header meets the preset transmission conditions.
[0161] The preset transmission conditions may include identification information in a preset field in the data packet header indicating a target packet header, and / or the data packet header not conforming to byte rules of a network layer packet header and / or byte rules of a transport layer packet header. The target packet header does not include a network layer packet header and / or a transport layer packet header.
[0162] In some embodiments, after obtaining the aforementioned data packet header, the XDP module can determine whether the data packet header meets preset transmission conditions. If the data packet header meets the preset transmission conditions, it indicates that the service data packet to which the data packet header belongs is not a traditional network protocol stack data packet, that is, the data packet header does not include a transport layer header and / or a network layer header. Therefore, the XDP module can determine the service data packet to which the data packet header belongs as a first service data packet and execute S8008 to send the first service data packet to the target application via the target address family in kernel space. If the data packet header does not meet the preset transmission conditions, it indicates that the service data packet to which the data packet header belongs is a traditional network protocol stack data packet, that is, the data packet header includes a transport layer header and a network layer header. Therefore, the XDP module can determine the service data packet to which the data packet header belongs as a second service data packet and send the second service data packet to the target application via the network protocol stack in kernel space.
[0163] S8008. When the data packet header meets the preset transmission conditions, the XDP module in the kernel space sends the first service data packet to the application layer in the user space of the second mobile phone.
[0164] Specifically, after determining that the data packet header meets the preset transmission conditions, the XDP module can send the first service data packet to the application layer in the user space of the second mobile phone through the target address family in the kernel space of the second mobile phone, where the target address family is the AF_XDP address family.
[0165] In one implementation, the XDP module can send the first service data packet to the application layer in the user space of the second mobile phone via a socket in the AF_XDP address family. This allows the first service data packet to bypass the network protocol stack for data transmission, reducing the CPU processing resource usage caused by the first service data packet passing through the network protocol stack and improving CPU processing resource utilization.
[0166] The above describes how the XDP module in the second mobile phone detects the data packet header in the first service data packet to realize the data transmission process. Figure 7 The structure shown and Figure 10 The data transmission process shown continues to introduce how the XDP module in the second mobile phone detects the data packet header in the second service data packet to implement the data transmission process.
[0167] S1001. In response to a data transmission operation, a user space of a first mobile phone generates a second service data packet of an application layer.
[0168] In one implementation, when a WLAN P2P connection is not established between the first mobile phone and the second mobile phone, if the first mobile phone detects a data transmission operation, the mobile phone can directly generate a second service data packet, that is, the target identification information can be configured in the second service data packet at the application layer.
[0169] S1002. The user space sends a second service data packet to the kernel space of the first mobile phone.
[0170] Specifically, after generating the above-mentioned first service data packet, the user space can send the second service data packet to the kernel space of the first mobile phone. The kernel space may include a network protocol stack and a network card driver module. The network card driver module may include an XDP module. The network protocol stack may include an IP layer protocol processing module, a transport layer protocol processing module, and an AF_INET address family. The AF_INET address family may include a second socket. The second socket is respectively connected to the network protocol stack and the application layer. The second socket is an interface for interaction between the application layer and the network protocol stack, that is, the second socket is used to complete data transmission between the application layer and the network protocol stack.
[0171] In one implementation, the user space may send the second service data packet to the XDP module in the kernel space through the AF_INET address family of the network protocol stack.
[0172] It should be noted that if the second service data packet passes through the network protocol stack, a transport layer header and a network layer header will be added when passing through the network protocol stack. That is, the data packet header of the second service data packet includes a transport layer header and a network layer header.
[0173] S1003. When the kernel space receives the second service data packet sent by the user space, the kernel space sends the second service data packet to the network card of the first mobile phone.
[0174] Specifically, after the kernel space receives the second service data packet sent by the user space, the kernel space can send the second service data packet to the network card in the hardware layer of the first mobile phone, so that the network card of the second mobile phone can subsequently receive the second service data packet.
[0175] S1004. When the network card of the first mobile phone receives the second service data packet sent by the kernel space, the network card of the first mobile phone sends the second service data packet to the network card of the second mobile phone.
[0176] S1005 , when the network card of the second mobile phone receives the second service data packet sent by the network card of the first mobile phone, the network card of the second mobile phone sends the second service data packet to the XDP module in the kernel space of the second mobile phone.
[0177] Specifically, after receiving the second service data packet sent by the network card of the first mobile phone, the network card of the second mobile phone may send the second service data packet to the kernel space of the second mobile phone. The kernel space of the second mobile phone has the same structure as the kernel space of the first mobile phone. That is, the kernel space of the second mobile phone may include a network protocol stack and a network card driver module. The network card driver module may include an XDP module. The network protocol stack may include an IP layer protocol processing module, a transport layer protocol processing module, and an AF_INET address family. The AF_INET address family may include a second socket.
[0178] In one implementation, the network card of the second mobile phone can send a second service data packet to the XDP module in the kernel space of the second mobile phone, so that the XDP module can determine whether the data packet header in the second service data packet includes a network layer header and / or a transport layer header.
[0179] S1006. When receiving the second service data packet sent by the network card of the second mobile phone, the XDP module in the kernel space extracts data from the second service data packet to obtain a data packet header.
[0180] Specifically, after receiving the second service data packet sent by the network card of the second mobile phone, the XDP module in the kernel space of the second mobile phone can extract data from the second service data packet to obtain a data packet header.
[0181] In some embodiments, the XDP module may directly obtain (or extract) the data packet header from the second service data packet.
[0182] S1007. The XDP module in the kernel space determines whether the data packet header meets the preset transmission conditions.
[0183] The preset transmission conditions may include identification information in a preset field in the data packet header indicating a target packet header, and / or the data packet header not conforming to byte rules of a network layer packet header and / or byte rules of a transport layer packet header. The target packet header does not include a network layer packet header and / or a transport layer packet header.
[0184] In some embodiments, after obtaining the above-mentioned data packet header, the XDP module can determine whether the data packet header meets the preset transmission conditions. If the data packet header meets the preset transmission conditions, it means that the business data packet to which the data packet header belongs is not a traditional network protocol stack data packet, that is, the data packet header does not include a transport layer header and / or a network layer header. Therefore, the XDP module can determine the business data packet to which the data packet header belongs as a first business data packet and send the first business data packet to the target application via the target address family in the kernel space. If the data packet header does not meet the preset transmission conditions, it means that the business data packet to which the data packet header belongs is a traditional network protocol stack data packet, that is, the data packet header includes a transport layer header and a network layer header. Therefore, the XDP module can determine the business data packet to which the data packet header belongs as a second business data packet and execute S1008 to send the second business data packet to the target application via the network protocol stack in the kernel space.
[0185] S1008. When the data packet header does not meet the preset transmission condition, the XDP module in the kernel space sends the second service data packet to the network protocol stack in the kernel space of the second mobile phone.
[0186] Specifically, after determining that the data packet header does not meet the preset transmission conditions, the XDP module can send the second service data packet to the network protocol stack in the kernel space of the second mobile phone. It will be understood that if the data packet header does not meet the preset transmission conditions, it indicates that the data packet header may include a transport layer header and a network layer header, which means that the second service data packet needs to be processed by the IP layer protocol processing module and the transport layer protocol processing module of the network protocol stack. Therefore, the XDP module can send the second service data packet to the network protocol stack.
[0187] S1009 . Upon receiving the second service data packet sent by the XDP module in the kernel space, the network protocol stack in the kernel space processes the second service data packet to obtain a target data packet.
[0188] Specifically, after receiving the second service data packet sent by the XDP module, the network protocol stack may process the second service data packet to obtain a target data packet, wherein the target data packet is the second service data packet excluding the transport layer header and the network layer header.
[0189] In one implementation, the network protocol stack may delete the protocol header information in the second service data packet, wherein the protocol header information may include a network layer header and / or a transport layer header.
[0190] The network protocol stack may include a queue forwarding module, an IP layer protocol processing module, a transport layer protocol processing module, and an AF_INET address family. The AF_INET address family may include a second socket. The second socket is respectively connected to the network protocol stack and the application layer. The second socket is an interface for interaction between the application layer and the network protocol stack, that is, the second socket is used to complete data transmission between the application layer and the network protocol stack.
[0191] In some embodiments, when the queuing and forwarding module in the network protocol stack receives the above-mentioned second business data packet, if the second business data packet is the first in the arrangement order, the queuing and forwarding module can send the second business data packet to the IP layer protocol processing module. Thereafter, when the IP layer protocol processing module receives the second business data packet sent by the queuing and forwarding module, it can process the network layer header in the second business data packet to obtain a second business data packet that does not include the network layer header. Thereafter, the IP layer protocol processing module can send the second business data packet that does not include the network layer header to the transport layer protocol processing module. Thereafter, when the transport layer protocol processing module receives the second business data packet that does not include the network layer header sent by the network layer protocol processing module, it can process the transport layer header in the second business data packet to obtain a second business data packet that does not include the transport layer header and the network layer header, that is, obtain the target data packet.
[0192] S1010. The network protocol stack in the kernel space sends a target data packet to the application layer in the user space of the second mobile phone.
[0193] Specifically, after obtaining the target data packet, the network protocol stack can send the target data packet to the application layer of the user space through the second socket of the AF_INET address family, thereby achieving accurate transmission of the first service data packet.
[0194] In one implementation, before data is transmitted between the first mobile phone and the second mobile phone, the first mobile phone and the second mobile phone need to load the program corresponding to the XDP module and create a first socket of the target address family so that the first mobile phone and the second mobile phone can transmit data. Figure 7 The structure shown and Figure 11 The parameter configuration process shown in FIG. 1 details how to configure the data transmission parameters of the first mobile phone and the second mobile phone during the data transmission process.
[0195] S9001: In response to a start-up operation of a WLAN direct connection function, a first mobile phone establishes a WLAN P2P connection with a second mobile phone.
[0196] In one implementation, upon detecting an activation operation of the WLAN direct connection function, the first mobile phone may establish a WLAN P2P physical link with the second mobile phone to achieve a WLAN P2P connection. The activation operation of the WLAN direct connection function may be a user connection operation for a device associated with any name control in the WLAN direct connection interface of the first mobile phone, or may be a default connection operation of the first mobile phone, i.e., the first mobile phone may be connected to the second mobile phone by default, etc., without limitation.
[0197] S9002. The user space of the first mobile phone sends negotiation information to the user space of the second mobile phone.
[0198] Specifically, when a WLAN P2P connection is established between a first mobile phone and a second mobile phone, the user space of the first mobile phone can send negotiation information to the user space of the second mobile phone. The negotiation information may include at least one of the software version, key, and session-specific number (identification, ID) of the above-mentioned WLAN direct connection function. The software version is used to indicate whether the WLAN direct connection function supports XDP capability, that is, whether the WLAN direct connection function can transmit data through the XDP module. The key is a parameter for encrypting the negotiation information, that is, the key enables the user space of the second mobile phone to decrypt the negotiation information, so that the user space of the second mobile phone can detect the software version of the WLAN direct connection function in the negotiation information. The session ID is the ID name corresponding to the negotiation information, which is used to prevent the user space of the second mobile phone from repeatedly receiving the negotiation information.
[0199] S9003. Upon receiving the negotiation information sent by the user space of the first mobile phone, the user space of the second mobile phone sends a negotiation reply message to the user space of the first mobile phone.
[0200] Among them, the above-mentioned negotiation reply information is used to indicate whether the first mobile phone can perform data transmission with the second mobile phone. The negotiation reply information may include that the WLAN direct connection function in the first mobile phone and the WLAN direct connection function in the second mobile phone both support XDP capability. That is to say, if the WLAN direct connection function in the first mobile phone and the WLAN direct connection function in the second mobile phone both support XDP capability, the negotiation reply information may indicate that the first mobile phone can perform data transmission with the second mobile phone. If the WLAN direct connection function in the first mobile phone and / or the WLAN direct connection function in the second mobile phone do not support XDP capability, the negotiation reply information may indicate that the first mobile phone cannot perform data transmission with the second mobile phone.
[0201] In some embodiments, the user space of the second mobile phone can decrypt the software version of the WLAN direct connection function based on the key in the negotiation information to obtain the software version of the WLAN direct connection function. The user space of the second mobile phone can then perform a version check on the software version of the WLAN direct connection function to obtain a version check result for the WLAN direct connection function in the first mobile phone. The version check result for the WLAN direct connection function in the first mobile phone may include whether the software version of the WLAN direct connection function in the first mobile phone is an XDP-capable software version. The user space of the second mobile phone can then generate negotiation response information based on the version check result for the WLAN direct connection function in the first mobile phone and the version check result for the WLAN direct connection function in the second mobile phone.
[0202] Specifically, in the case where the software version of the WLAN direct connection function in the first mobile phone is a software version with XDP capability, if the software version of the WLAN direct connection function in the second mobile phone is also a software version with XDP capability, the user space of the second mobile phone can generate a negotiation response message indicating that both the WLAN direct connection function in the first mobile phone and the WLAN direct connection function in the second mobile phone support XDP capability. If the software version of the WLAN direct connection function in the second mobile phone is not a software version with XDP capability, the user space of the second mobile phone can generate a negotiation response message indicating that the WLAN direct connection function in the second mobile phone does not support XDP capability. In the case where the software version of the WLAN direct connection function in the above-mentioned first mobile phone is not a software version with XDP capability, the user space of the second mobile phone can generate a negotiation response message indicating that the WLAN direct connection function in the first mobile phone does not support XDP capability.
[0203] In some cases, when the negotiation response information is generated, the user space of the second mobile phone may return the negotiation response information to the user space of the first mobile phone, so that the user space of the first mobile phone can determine whether data can be transmitted with the second mobile phone.
[0204] S9004: When the negotiation response information indicates that the first mobile phone can perform data transmission with the second mobile phone, the user space loads the XDP program into the kernel space for the first mobile phone and the second mobile phone.
[0205] In some embodiments, after the negotiation response information indicates that the first mobile phone is capable of data transmission with the second mobile phone, the user space of the first mobile phone can configure the XDP module in the kernel space, thereby enabling the XDP module to determine the data transmission path of the service data packet, that is, to determine whether the service data packet is transmitted to the application layer via the XDP interface or via the network protocol stack. The service data packet can be the first service data packet or the second service data packet.
[0206] Specifically, the user space of the first mobile phone can load the XDP program into the kernel space of the first mobile phone, and the user space of the second mobile phone can load the XDP program into the kernel space of the second mobile phone. Among them, the XDP program is an extended Berkeley Packet Filter (eBPF) program. The eBPF program can be used to determine whether the data packet header of the business data packet meets the preset transmission conditions, and after determining that the data packet header of the business data packet meets the preset transmission conditions, the business data packet is sent as a first business data packet to the target address family, and after determining that the data packet header of the business data packet does not meet the preset transmission conditions, the business data packet is sent as a second business data packet to the network protocol stack. The eBPF program can also be used to transmit business data packets.
[0207] In one implementation, user space can load an XDP program written in user space into kernel space by calling the bpf_load_program() function. After the XDP program is loaded, user space can generate a file descriptor (fd) indicating that the XDP program has been loaded successfully, so that the user space can clearly understand the loading result of the XDP program.
[0208] S9005. The user space binds the XDP program to the XDP module.
[0209] Specifically, after the XDP program is loaded into kernel space, user space can bind the XDP program to the XDP module, enabling the XDP module to run the XDP program. That is, the XDP module can use the XDP program to determine whether the data packet header of the service data packet meets the preset transmission conditions.
[0210] In one implementation, the user space may bind the loaded XDP program to the XDP module by calling the bpf_set_link_xdp_fd() function, so that the XDP program can be attached to the XDP module.
[0211] S9006. User space creates a socket for the target address family.
[0212] Specifically, after the XDP program is bound to the XDP module, the user space can create a socket of the target address family, where the target address family is the AF_XDP address family.
[0213] S9007. The user space applies for user memory.
[0214] Specifically, after the socket of the AF_XDP address family is created, the user space can apply for user memory (UMEM). The user memory is a virtual continuous memory area used to store service data packets received or sent by the first socket. The total storage length corresponding to the user memory is fixed, that is, the total storage length is pre-set.
[0215] In one implementation, the user space may apply for the user memory by calling the mmap() function.
[0216] S9008. The user space configures the user memory and registers the user memory to the socket of the target address family.
[0217] Specifically, after applying for the user memory, the user space may configure the user memory and register the configured user memory with the socket of the target address family.
[0218] In some embodiments, the user space may control the starting address, total storage length, size of the heap memory, etc. The heap memory is a memory area that allows the application layer to be dynamically allocated and used during operation.
[0219] In one implementation, the user space may configure the user memory by calling the setsockopt() function, and register the configured user memory to the socket of the target address family to implement the storage function of the service data packet.
[0220] S9009. The user space creates a fill ring and a completion ring in the kernel space.
[0221] Specifically, user space can create a fill ring and a completion ring in kernel space by calling the setsockopt() function. The fill ring and completion ring are two rings in user memory. The fill ring is used to pass UMEM frames from user space to kernel space, causing it to pass the address corresponding to the UMEM frame to the receive ring (rx ring). The completion ring is used to pass UMEM frames from kernel space to user space.
[0222] S9010. The kernel space maps the fill ring and the completion ring into the user space.
[0223] Specifically, after creating the fill ring and completion ring in kernel space, kernel space can map the fill ring and completion ring into user space. Mapping refers to mapping the address space of the fill ring and completion ring into user space so that user space applications can directly access the fill ring and completion ring.
[0224] In one implementation, the kernel space may map the fill ring and the completion ring into the user space by calling the mmap() function.
[0225] S9011. The user space creates a sending ring and a receiving ring in the kernel space.
[0226] Specifically, user space can create a receive ring and a transmit ring (rx ring) in kernel space by calling the setsockopt() function. The receive ring and transmit ring belong to two rings in the first socket. The receive ring is used to receive service data packets, and the transmit ring is used to send service data packets.
[0227] S9012. The kernel space maps the sending ring and the receiving ring to the user space.
[0228] Specifically, after the sending ring and the receiving ring are created in the kernel space, the kernel space can map the sending ring and the receiving ring to the user space.
[0229] In one implementation, the kernel space may map the sending ring and the receiving ring to the user space by calling the mmap() function.
[0230] S9013. The user space binds the socket of the target address family to the XDP module.
[0231] Specifically, the user space may bind the created socket of the target address family to the XDP module by calling the bind() function, so that the XDP module can call the socket of the target address family for data transmission.
[0232] In some embodiments, user space can bind a socket of a target address family to any queue in the XDP module to obtain a queue corresponding to the socket in the XDP module. Subsequently, upon receiving a first service data packet, the socket can send the first service data packet to the queue corresponding to the socket to implement data transmission.
[0233] The above describes how the second mobile phone transmits the first service data packet to the application layer. The following will continue to introduce a process for implementing data transmission between the first mobile phone and the second mobile phone. Figure 12As shown, this process may specifically include: when establishing a WLAN P2P connection between a first mobile phone and a second mobile phone, if the network card of the first mobile phone receives a first service data packet, the first service data packet may be sent to the network card of the second mobile phone. The first service data packet is a data packet that does not include a network layer header and a transport layer header. Subsequently, upon receiving the first service data packet sent by the network card of the first mobile phone, the network card of the second mobile phone sends the first service data packet to the XDP module of the second mobile phone. The XDP module of the second mobile phone can then skip the network protocol stack and directly send the first service data packet to the application layer via the XDP address family, thereby enabling data transmission between mobile phones.
[0234] An embodiment of the present application also provides a computer storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes the various functions or steps executed by the first computer or the second computer in the above-mentioned embodiment.
[0235] An embodiment of the present application further provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the functions or steps executed by the first computer or the second computer in the above embodiment.
[0236] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0237] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0238] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0239] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0240] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0241] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A data transmission method, characterized in that: Applied to a first electronic device, the first electronic device includes an application layer, an XDP module, and a network card, the method includes: When a wireless local area network (WLAN) P2P connection is established between the first electronic device and the second electronic device, the application layer of the first electronic device sends a first service data packet to the XDP module of the first electronic device; wherein the first service data packet does not include a network layer header and / or a transport layer header; The XDP module of the first electronic device sends the first service data packet to the network card of the first electronic device; The network card of the first electronic device sends the first service data packet to the second electronic device.
2. The method according to claim 1, characterized in that In the case where a wireless local area network (WLAN) P2P connection is established between the first electronic device and the second electronic device, the method further includes: The application layer of the first electronic device configures target identification information in the first service data packet; The application layer of the first electronic device sends a first service data packet to the XDP module of the first electronic device, including: The application layer of the first electronic device sends a first service data packet configured with the target identification information to the XDP module of the first electronic device.
3. The method according to claim 1 or 2, characterized in that The first electronic device further includes an XDP interface, and the application layer of the first electronic device sends a first service data packet to the XDP module of the first electronic device, including: The application layer of the first electronic device sends the first service data packet to the XDP module of the first electronic device through the XDP interface of the first electronic device.
4. The method according to claim 3, characterized in that The XDP interface of the first electronic device is a socket of the XDP address family, and the application layer of the first electronic device sends the first service data packet to the XDP module of the first electronic device through the XDP interface of the first electronic device, including: The application layer of the first electronic device directs the first service data packet to the socket of the XDP address family; The socket of the XDP address family sends the first service data packet to the XDP module of the first electronic device.
5. The method according to any one of claims 1 to 4, characterized in that The first service data packet generated by the application layer of the first electronic device skips the processing of the network protocol stack in the first electronic device and is transmitted from the application layer of the first electronic device to the XDP module of the first electronic device.
6. The method according to claim 5, characterized in that The method further comprises: In a case where a WLAN P2P connection is not established between the first electronic device and the second electronic device, the application layer of the first electronic device sends a second service data packet to the network protocol stack of the first electronic device; The network protocol stack of the first electronic device sends the second service data packet to the XDP module of the first electronic device; wherein the second service data packet includes a network layer header and a transport layer header; The XDP module of the first electronic device sends the second service data packet to the network card of the first electronic device; The network card of the first electronic device sends the second service data packet to the second electronic device.
7. The method according to any one of claims 1 to 6, characterized in that The XDP module is located in the kernel space of the first electronic device, the application layer is located in the user space of the first electronic device, and when a wireless local area network (WLAN) P2P connection is established between the first electronic device and the second electronic device, the method further includes: The first electronic device sends negotiation information to the second electronic device; The first electronic device receives negotiation response information from the second electronic device, wherein the negotiation response information is used to indicate whether the first electronic device and the second electronic device can perform data transmission; When the negotiation response information indicates that the first electronic device and the second electronic device can perform data transmission, the user space of the first electronic device loads the XDP program into the kernel space of the first electronic device; wherein the XDP program is used to enable the XDP module in the kernel space to determine a data transmission path for the service data packet; The user space of the first electronic device attaches the XDP program to the XDP module located in the kernel space; The user space of the first electronic device creates an XDP interface and initializes the XDP interface; The user space of the first electronic device binds the XDP interface to the XDP module; wherein the binding is used to enable the XDP module to call the XDP interface to send the service data packet to the application layer located in the user space.
8. The method according to claim 7, characterized in that The XDP interface is a socket of the XDP address family, and the user space initializes the XDP interface, including: The user space applies for a user memory UMEM; wherein the user memory is used to store service data packets received or sent by the socket of the XDP address family; The user space configures the user memory and registers the user memory to the socket of the XDP address family; The user space creates a fill ring and a completion ring in the kernel space, and receives the fill ring and the completion ring mapped by the kernel space; wherein the fill ring is used to transfer the UMEM frame in the user memory from the user space to the kernel space, and the completion ring is used to transfer the UMEM frame from the kernel space to the user space; The user space creates a sending ring and a receiving ring in the kernel space, and receives the sending ring and the receiving ring mapped by the kernel space; wherein the sending ring is used to send the business data packet, and the receiving ring is used to receive the business data packet.
9. A data transmission method, characterized in that: Applied to a second electronic device, the second electronic device includes an XDP module and an application layer, and the method includes: Establishing a WLAN P2P connection between the second electronic device and the first electronic device; The second electronic device receives a first service data packet from the first electronic device; The second electronic device extracts the data packet header of the first service data packet through the XDP module; wherein the data packet header of the first service data packet does not include a network layer header and / or a transport layer header; The XDP module of the second electronic device sends the first service data packet to the application layer of the second electronic device.
10. The method according to claim 9, characterized in that The identification information in the preset field in the data packet header of the first service data packet indicates a target packet header, and the target packet header does not include a network layer packet header and / or a transport layer packet header; and / or, The data packet header of the first service data packet does not comply with the byte rule of the network layer packet header and / or the byte rule of the transport layer packet header.
11. The method according to claim 9 or 10, characterized in that The data packet header of the first service data packet includes target identification information configured in the first service data packet by the application layer of the first electronic device.
12. The method according to any one of claims 9 to 11, characterized in that The second electronic device further includes an XDP interface, and the XDP module of the second electronic device sends the first service data packet to the application layer of the second electronic device, including: The XDP module of the second electronic device sends the first service data packet to the application layer of the second electronic device through the XDP interface.
13. The method according to claim 12, characterized in that The XDP interface of the second electronic device is a socket of the XDP address family, and the XDP module of the second electronic device sends the first service data packet to the application layer of the second electronic device through the XDP interface, including: The XDP module of the second electronic device directs the first service data packet to the socket of the XDP address family; The XDP module of the second electronic device sends the first service data packet to the application layer of the second electronic device through the socket of the XDP address family.
14. The method according to any one of claims 9 to 13, characterized in that The first service data packet received by the second electronic device skips the processing of the network protocol stack in the second electronic device and is transmitted from the XDP module of the second electronic device to the application layer of the second electronic device.
15. The method according to any one of claims 9 to 14, characterized in that The second electronic device further includes a network protocol stack, and the method further includes: The second electronic device receives a second service data packet from the first electronic device; The second electronic device extracts the data packet header of the second service data packet through the XDP module; wherein the data packet header of the second service data packet includes a network layer header and a transport layer header; The XDP module of the second electronic device sends the second service data packet to the application layer of the second electronic device through the network protocol stack.
16. A data transmission system, characterized in that: The data transmission system includes a first electronic device and a second electronic device, wherein the first electronic device is used to execute the data transmission method according to any one of claims 1 to 8, and the second electronic device is used to execute the data transmission method according to any one of claims 9 to 15.
17. An electronic device, characterized in that: The electronic devices are a first electronic device and a second electronic device, and the electronic devices include an application layer, a network card, an XDP module, a memory, and one or more processors; the application layer, the network card, the XDP module, the memory, and the processor are coupled; the memory is used to store computer program code, and the computer program code includes computer instructions; when the processor executes the computer instructions, the electronic device performs the method according to any one of claims 1 to 8, or the electronic device performs the method according to any one of claims 9 to 15.
18. A computer-readable storage medium, characterized in that The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute the method according to any one of claims 1 to 8 or the method according to any one of claims 9 to 15.
19. A computer program product, characterized in that The method comprises computer instructions, which, when executed on an electronic device, enable the electronic device to execute the method according to any one of claims 1 to 8 or the method according to any one of claims 9 to 15.
Citation Information
Patent Citations
Data transmission method, equipment and system
CN102056235A
Voice data transmission method and device, equipment and storage medium
CN113726719A
Network data packet processing method and device, electronic equipment and storage medium
CN115714679A
Message processing method, device and system, storage medium and chip system
CN116471631A
Communication method, device and communication system
CN119011706A