Data sending method and device, data receiving method and device, electronic equipment and storage medium

By using preset transmission protocols and kernel bypass functions in near field communication scenarios, data transmission is bypassed by the TCP/IP protocol stack, the low throughput, high latency and high power consumption problems caused by the TCP/IP protocol in near field communication is solved, and more efficient data transmission is achieved.

CN119696631APending Publication Date: 2025-03-25BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311233407.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-21
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the near field communication scenario, the conservative flow control algorithm of the TCP/IP protocol causes serious network fluctuations, resulting in low data transmission throughput, high latency, and high device power consumption.

Method used

The data is encapsulated using a preset transmission protocol, and the kernel bypass function is realized through user-state and kernel-state SDKs, and data transmission is bypassed by the TCP/IP protocol stack.

Benefits of technology

Reduces device power consumption, reduces data transmission delay, and improves data transmission throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119696631A_ABST
    Figure CN119696631A_ABST
Patent Text Reader

Abstract

The invention relates to a data sending method and device, a data receiving method and device, electronic equipment and a storage medium. The method comprises: a first device encapsulates to-be-sent data based on a preset transmission protocol to obtain a first data packet, the preset transmission protocol being used for near field communication; the first data packet is sent to a first memory block through a first user mode SDK, and the first user mode SDK is an SDK used for achieving a kernel bypass function in a user mode of the first device; a first data packet is obtained from the first memory block through a first kernel mode SDK, the first data packet is sent to a first network card driver, and the first kernel mode SDK is an SDK used for achieving a kernel bypass function in a kernel mode of the first device; and sending the first data packet to the second device through the first network card drive. The data packet packaged by the first device based on the preset transmission protocol can be sent to the second device by bypassing the network protocol stack, so that the power consumption of the device is reduced, the data transmission delay is reduced, and the data transmission throughput is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data transmission, and in particular to a method and device for sending and receiving data, an electronic device and a storage medium. Background Art

[0002] TCP / IP (Transmission Control Protocol / Internet Protocol) is a communication protocol for computers connected to the Internet to communicate, and is not specifically designed for near-field communication. In the near-field communication scenario, the conservative flow control algorithm in TCP / IP causes serious network fluctuations (packet loss), resulting in low data transmission throughput and high data transmission latency. In addition, TCP / IP is relatively complex and has a lot of unnecessary processing, which leads to high device power consumption. Summary of the invention

[0003] In order to overcome the problems existing in the related art, the present disclosure provides a data sending and receiving method, device, electronic device and storage medium.

[0004] According to a first aspect of an embodiment of the present disclosure, a data sending method is provided, which is performed by a first device, and the method includes:

[0005] Based on a preset transmission protocol, encapsulating the data to be sent to obtain a first data packet, wherein the preset transmission protocol is used for near field communication;

[0006] Sending the first data packet to a first memory block through a first user-state software development kit SDK in the first device, where the first user-state SDK is an SDK in a user state of the first device for implementing a kernel bypass function;

[0007] Obtaining the first data packet from the first memory block through a first kernel state SDK in the first device, and sending the first data packet to a first network card driver in the first device, wherein the first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function;

[0008] The first data packet is sent to the second device through the first network card driver.

[0009] In some embodiments, after obtaining the first data packet from the first memory block through the first kernel-mode SDK in the first device and sending the first data packet to the first network card driver in the first device, the method further includes:

[0010] Update the first mapping relationship, in which the first port in the updated first mapping relationship corresponds to the first socket, the first port includes at least one of a first source port and a first destination port, the first source port is the port through which the first device sends the first data packet, the first destination port is the port through which the second device receives the first data packet, and the first socket is the socket corresponding to the first memory block.

[0011] In some embodiments, the method further comprises:

[0012] Receiving, through the first network card driver, a second data packet returned by the second device, where the second data packet corresponds to the first data packet;

[0013] Sending the second data packet to the first memory block through the first kernel state SDK;

[0014] The second data packet is obtained from the first memory block through the first user mode SDK.

[0015] In some embodiments, the second data packet carries a second port, the second port includes at least one of a second source port and a second destination port, the second source port is the same as the first destination port, the second destination port is the same as the first source port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet;

[0016] The sending the second data packet to the first memory block through the first kernel state SDK in the first device includes:

[0017] Determining, by the first kernel state SDK, a first socket corresponding to the second port according to a first mapping relationship, wherein the first mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is a port for the first device to send a data packet, the destination port is a port for the second device to receive a data packet, and the socket is a socket corresponding to a memory block for storing the data packet;

[0018] Send the second data packet to the first memory block corresponding to the first socket.

[0019] In some embodiments, the protocol format of the preset transmission protocol is: destination address, source address, protocol type, source port, destination port, preset header, data area; the preset header is used to indicate the flow control algorithm used for near field communication, and the preset header is different from the header of the transmission control protocol / Internet protocol TCP / IP.

[0020] According to a second aspect of an embodiment of the present disclosure, a data receiving method is provided, which is performed by a second device, and the method includes:

[0021] Receiving, by means of a second network card driver of the second device, a data packet sent by the first device;

[0022] Filtering a first data packet from received data packets through a second kernel state software development kit SDK of the second device, and sending the first data packet to a second memory block, wherein the first data packet is obtained by encapsulating based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol adopted by other data packets, and the second kernel state SDK is an SDK in the kernel state of the second device for implementing a kernel bypass function;

[0023] The first data packet is obtained from the second memory block through a second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function.

[0024] In some embodiments, filtering out the first data packet from the received data packets by the second kernel state SDK of the second device includes:

[0025] The first data packet is filtered out from the received data packets according to the protocol type through the second kernel-mode SDK, wherein different transmission protocols correspond to different protocol types.

[0026] In some embodiments, after obtaining the first data packet from the second memory block through the second user mode SDK of the second device, the method further includes:

[0027] Based on the preset transmission protocol, the first data packet is parsed to obtain parsed data.

[0028] In some embodiments, sending the first data packet to the second memory block through the second kernel state SDK of the second device includes:

[0029] Querying, through the second kernel state SDK, a second socket corresponding to the first data packet;

[0030] Send the first data packet to the second memory block corresponding to the second socket.

[0031] In some embodiments, the first data packet includes a first source port and a first destination port, the first source port is a port through which the first device sends the first data packet, the first destination port is a port through which the second device receives the first data packet, and querying a second socket corresponding to the first data packet through a second kernel state SDK of the second device includes:

[0032] Through the second kernel-state SDK, according to the second mapping relationship, the second socket corresponding to the first data packet is queried, the second mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is the port through which the first device sends a data packet, the destination port is the port through which the second device receives a data packet, and the socket is the socket corresponding to the memory block used to store the data packet.

[0033] In some embodiments, the method further comprises:

[0034] The third mapping relationship is updated, where the updated third mapping relationship includes the first source port and the corresponding second socket.

[0035] In some embodiments, after obtaining the first data packet from the second memory block through the second user mode SDK of the second device, the method further includes:

[0036] Acquire a second data packet, where the second data packet is a data packet corresponding to the first data packet;

[0037] Sending the second data packet to the second memory block through the second user state SDK;

[0038] Obtaining the second data packet from the second memory block through the second kernel state SDK, and sending the second data packet to the second network card driver;

[0039] The second network card driver sends the second data packet to the first device.

[0040] In some embodiments, obtaining the second data packet includes:

[0041] Acquire a third mapping relationship, where the third mapping relationship includes a source port of a received data packet and a corresponding socket, where the socket is a socket corresponding to a memory block for storing the data packet;

[0042] According to the third mapping relationship and the second socket corresponding to the second memory block, the second destination port in the second data packet is determined, the second destination port is the same as the first source port in the first data packet, and the first source port is the port through which the first device sends the first data packet.

[0043] According to a third aspect of an embodiment of the present disclosure, a data sending apparatus is provided, which is configured in a first device, and the apparatus includes:

[0044] A data encapsulation module is configured to encapsulate the data to be sent based on a preset transmission protocol to obtain a first data packet, wherein the preset transmission protocol is used for near field communication;

[0045] A user state processing module is configured to send the first data packet to a first memory block through a first user state software development kit SDK in the first device, where the first user state SDK is an SDK in the user state of the first device for implementing a kernel bypass function;

[0046] a kernel state processing module, configured to obtain the first data packet from the first memory block through a first kernel state SDK in the first device, and send the first data packet to a first network card driver in the first device, wherein the first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function;

[0047] The data sending module is configured to send the first data packet to the second device through the first network card driver.

[0048] In some embodiments, the apparatus further comprises:

[0049] A relationship update module is configured to update a first mapping relationship, in which the first port in the updated first mapping relationship corresponds to the first socket, the first port includes at least one of a first source port and a first destination port, the first source port is the port through which the first device sends the first data packet, the first destination port is the port through which the second device receives the first data packet, and the first socket is the socket corresponding to the first memory block.

[0050] In some embodiments, the apparatus further comprises:

[0051] a data receiving module, configured to receive, through the first network card driver, a second data packet returned by the second device, wherein the second data packet corresponds to the first data packet;

[0052] The kernel state processing module is further configured to send the second data packet to the first memory block through the first kernel state SDK;

[0053] The user state processing module is further configured to obtain the second data packet from the first memory block through the first user state SDK.

[0054] In some embodiments, the second data packet carries a second port, the second port includes at least one of a second source port and a second destination port, the second source port is the same as the first destination port, the second destination port is the same as the first source port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet;

[0055] The kernel state processing module is further configured as follows:

[0056] Determining, by the first kernel state SDK, a first socket corresponding to the second port according to a first mapping relationship, wherein the first mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is a port for the first device to send a data packet, the destination port is a port for the second device to receive a data packet, and the socket is a socket corresponding to a memory block for storing the data packet;

[0057] Send the second data packet to the first memory block corresponding to the first socket.

[0058] In some embodiments, the protocol format of the preset transmission protocol is: destination address, source address, protocol type, source port, destination port, preset header, data area; the preset header is used to indicate the flow control algorithm used for near field communication, and the preset header is different from the header of the transmission control protocol / Internet protocol TCP / IP.

[0059] According to a fourth aspect of an embodiment of the present disclosure, a data receiving apparatus is provided, which is configured in a second device, and the apparatus includes:

[0060] A data receiving module, configured to receive a data packet sent by the first device through a second network card driver of the second device;

[0061] a kernel state processing module, configured to filter out a first data packet from received data packets through a second kernel state software development kit SDK of the second device, and send the first data packet to a second memory block, wherein the first data packet is obtained by encapsulation based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol adopted by other data packets, and the second kernel state SDK is an SDK in the kernel state of the second device for implementing a kernel bypass function;

[0062] The user state processing module is configured to obtain the first data packet from the second memory block through the second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function.

[0063] In some embodiments, the kernel mode processing module is configured to:

[0064] The first data packet is filtered out from the received data packets according to the protocol type through the second kernel-mode SDK, wherein different transmission protocols correspond to different protocol types.

[0065] In some embodiments, the apparatus further comprises:

[0066] The data parsing module is configured to parse the first data packet based on the preset transmission protocol to obtain parsed data.

[0067] In some embodiments, the kernel mode processing module is configured to:

[0068] Querying, through the second kernel state SDK, a second socket corresponding to the first data packet;

[0069] Send the first data packet to the second memory block corresponding to the second socket.

[0070] In some embodiments, the first data packet includes a first source port and a first destination port, the first source port is a port through which the first device sends the first data packet, the first destination port is a port through which the second device receives the first data packet, and the kernel state processing module is configured as follows:

[0071] Through the second kernel-state SDK, according to the second mapping relationship, the second socket corresponding to the first data packet is queried, the second mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is the port through which the first device sends a data packet, the destination port is the port through which the second device receives a data packet, and the socket is the socket corresponding to the memory block used to store the data packet.

[0072] In some embodiments, the apparatus further comprises:

[0073] The relationship updating module is configured to update a third mapping relationship, wherein the updated third mapping relationship includes the first source port and the corresponding second socket.

[0074] In some embodiments, the apparatus further comprises:

[0075] a data packet acquisition module, configured to acquire a second data packet, where the second data packet is a data packet corresponding to the first data packet;

[0076] The user state processing module is further configured to send the second data packet to the second memory block through the second user state SDK;

[0077] The kernel state processing module is further configured to obtain the second data packet from the second memory block through the second kernel state SDK, and send the second data packet to the second network card driver;

[0078] The data sending module is configured to send the second data packet to the first device through the second network card driver.

[0079] In some embodiments, the data packet acquisition module is configured to:

[0080] Acquire a third mapping relationship, where the third mapping relationship includes a source port of a received data packet and a corresponding socket, where the socket is a socket corresponding to a memory block for storing the data packet;

[0081] According to the third mapping relationship and the second socket corresponding to the second memory block, the second destination port in the second data packet is determined, the second destination port is the same as the first source port in the first data packet, and the first source port is the port through which the first device sends the first data packet.

[0082] According to a fifth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0083] processor;

[0084] a memory for storing processor-executable instructions;

[0085] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure, or the processor is configured to execute the method as described in the second aspect of the embodiment of the present disclosure.

[0086] According to the sixth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure, or the electronic device is enabled to execute the method described in the second aspect of the embodiment of the present disclosure.

[0087] The above method of the present disclosure has the following beneficial effects:

[0088] According to the method provided by the embodiment of the present disclosure, in a near field communication scenario, the first device encapsulates the data to be sent based on a preset transmission protocol to obtain a first data packet, sends the first data packet to the first memory block through the first user state SDK, obtains the first data packet from the first memory block through the first kernel state SDK in the first device, sends the first data packet to the first network card driver, and finally sends the first data packet to the second device through the first network card driver, wherein the first user state SDK and the first kernel state SDK are both SDKs based on the kernel bypass function, therefore, the first data packet is transmitted through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to be sent to the second device, thereby reducing the power consumption of the device while reducing the data transmission delay and improving the data transmission throughput.

[0089] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0090] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0091] Figure 1 is a flow chart of a data sending method according to an exemplary embodiment;

[0092] Figure 2 is a flow chart of a data receiving method according to an exemplary embodiment;

[0093] Figure 3 is a flow chart of a method for sending and receiving data according to an exemplary embodiment;

[0094] Figure 4 is a flow chart showing another method for sending and receiving data according to an exemplary embodiment;

[0095] Figure 5 is an architecture diagram of a data transmission process according to an exemplary embodiment;

[0096] Figure 6 is a block diagram of a data sending device according to an exemplary embodiment;

[0097] Figure 7 is a block diagram of a data receiving device according to an exemplary embodiment;

[0098] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0099] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0100] In the related art, in order to use TCP / IP in a near-field communication scenario, TCP / IP is usually modified to make it more suitable for the near-field communication scenario by modifying the parameters of TCP / IP (for example, by modifying the parameters to make TCP / IP send or receive cached data). However, due to its own characteristics, the effect of the optimized TCP / IP in the near-field communication scenario is still poor, that is, there are still problems such as low data transmission throughput, high data transmission delay and high device power consumption.

[0101] The data sending method and the data receiving method provided in the embodiments of the present disclosure adopt a preset transmission protocol for near field communication, and perform data transmission by bypassing TCP / IP through a user-mode SDK (Software Development Kit) and a kernel-mode SDK for implementing a kernel bypass function, thereby reducing data transmission delay and improving data transmission throughput while reducing device power consumption.

[0102] The method provided by the embodiments of the present disclosure can be applied to a variety of scenarios, for example, screen projection scenarios under near field communication, file transfer scenarios, and other scenarios for cross-device data transmission under near field communication.

[0103] The method provided by the embodiment of the present disclosure is performed by a first device and a second device, both of which are electronic devices. The first device is a sender and the second device is a receiver, or the first device is a receiver and the second device is a sender, that is, for an electronic device, the electronic device can be a sender or a receiver. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a wearable device, a smart home device, etc.

[0104] Before introducing the data sending method and the data receiving method provided by the embodiments of the present disclosure, the keywords involved in the embodiments of the present disclosure are first introduced:

[0105] User state: When a process runs in the user space of the operating system, it is in user state.

[0106] Kernel state: When a process runs in the kernel space of the operating system, it is in kernel state.

[0107] Kernel bypass: Kernel bypass is to solve the performance problem between kernel state and user state under ultra-large concurrency. Kernel bypass can also be called network bypass or kernel network bypass.

[0108] Figure 1 is a flowchart of a data sending method according to an exemplary embodiment, which is executed by a first device, see Figure 1 , the method comprises the following steps:

[0109] Step S101: encapsulate the data to be sent based on a preset transmission protocol to obtain a first data packet, where the preset transmission protocol is used for near field communication.

[0110] The preset transmission protocol is a protocol for near field communication, and the data encapsulated based on the preset transmission protocol can bypass the network protocol stack (TCP / IP) during transmission. For example, the preset transmission protocol can be the O2o Simply Reliable Transmission Protocol (O2o-SRTP). The data to be sent can be any data, and the embodiments of the present disclosure do not limit the content of the data to be sent.

[0111] Step S102: Send a first data packet to a first memory block through a first user state SDK in a first device, where the first user state SDK is an SDK in a user state of the first device for implementing a kernel bypass function.

[0112] A first user state SDK is set in the user state of the first device. The first user state SDK is an SDK for implementing a kernel bypass function in the user state of the first device. The first user state SDK is used to send a data packet to a first memory block (). The first memory block uses a memory sharing (memory map, mmap) mechanism. The first memory block is a memory block that can be operated by both the user state and the kernel state of the first device. Therefore, for the user state and the kernel state, using the first memory block realizes "zero copy" when sending and / or receiving data.

[0113] Step S103, obtaining a first data packet from a first memory block through a first kernel state SDK in a first device, and sending the first data packet to a first network card driver in the first device, wherein the first kernel state SDK is an SDK in a kernel state of the first device for implementing a kernel bypass function.

[0114] A first kernel state SDK is set in the kernel state of the first device. The first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function. The first kernel state SDK is used to obtain data packets from the first memory block and send them to the first network card driver. When the first kernel state SDK obtains data packets from the first memory block, it does not need to pass through the network protocol stack, that is, it bypasses the network protocol stack and directly forwards the data packets from the first memory block to the first network driver.

[0115] Step S104: Send the first data packet to the second device through the first network card driver.

[0116] After receiving the data packet sent by the first kernel-mode SDK, the first network driver directly sends it to the second device.

[0117] According to the method provided by the embodiment of the present disclosure, in a near field communication scenario, the first device encapsulates the data to be sent based on a preset transmission protocol to obtain a first data packet, sends the first data packet to the first memory block through the first user state SDK, obtains the first data packet from the first memory block through the first kernel state SDK in the first device, sends the first data packet to the first network card driver, and finally sends the first data packet to the second device through the first network card driver, wherein the first user state SDK and the first kernel state SDK are both SDKs based on the kernel bypass function, therefore, the first data packet is transmitted through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to be sent to the second device, thereby reducing the power consumption of the device while reducing the data transmission delay and improving the data transmission throughput.

[0118] Figure 2 is a flow chart of a data receiving method according to an exemplary embodiment, which is executed by the second device, see Figure 2 , the method comprises the following steps:

[0119] Step S201: receiving a data packet sent by a first device through a second network card driver of a second device.

[0120] For the second device, the data packet sent by the first device is received through the second network driver. The data packet sent by the first device can be a data packet of any type, that is, the data packet sent by the first device can be a data packet obtained by encapsulating data based on any transmission protocol.

[0121] Step S202, through the second kernel state SDK of the second device, filter out the first data packet from the received data packets, and send the first data packet to the second memory block, the first data packet is encapsulated based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol used by other data packets. The second kernel state SDK is an SDK in the kernel state of the second device for implementing the kernel bypass function.

[0122] A second kernel state SDK is set in the kernel state of the second device. The second kernel state SDK is an SDK in the kernel state of the second device for implementing a kernel bypass function. The second kernel state SDK is used to filter out data packets encapsulated based on a preset transmission protocol from received data packets, and send the filtered data packets to the second memory block.

[0123] Due to the characteristics of the preset transmission protocol itself, the data packet encapsulated based on the preset transmission protocol can bypass the network transmission protocol during the transmission process. Therefore, it is necessary to first filter out the first data packet from the received data packet, and then send the first data packet to the second memory block. Among them, the second memory block uses a memory sharing mechanism, and the second memory block is a memory block that can be operated by both the user state and the kernel state of the second device. Therefore, for the user state and the kernel state, the use of the second memory block realizes "zero copy" when sending and / or receiving data.

[0124] Step S203: Obtain the first data packet from the second memory block through the second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing the kernel bypass function.

[0125] A second user state SDK is provided in the user state of the second device. The second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function. The second user state SDK is used to obtain a first data packet from a second memory block.

[0126] According to the method provided by the embodiment of the present disclosure, in a near field communication scenario, the second device receives a data packet sent by the first device through the second network card driver, and then screens out the first data packet from the received data packet through the second kernel state SDK, sends the first data packet to the second memory block, and finally obtains the first data packet from the second memory block through the second user state SDK. The second user state SDK and the second kernel state SDK are both SDKs based on the kernel bypass function. Therefore, after the second device receives the first data packet, it transmits the first data packet through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to transmit it to the second user state SDK, which reduces the power consumption of the device while reducing the data transmission delay and improving the data transmission throughput.

[0127] Figure 3 is a flowchart of a method for sending and receiving data according to an exemplary embodiment, which is executed by a first device and a second device, see Figure 3 , the method comprises the following steps:

[0128] Step S301: The first device encapsulates the data to be sent based on a preset transmission protocol to obtain a first data packet.

[0129] The preset transmission protocol is a protocol for near field communication, and the data encapsulated based on the preset transmission protocol can bypass the network protocol stack (TCP / IP) during transmission. For example, the preset transmission protocol can be the O2o Simply Reliable Transmission Protocol (O2o-SRTP). The data to be sent can be any data, and the embodiments of the present disclosure do not limit the content of the data to be sent.

[0130] In some embodiments, the protocol format of the preset transmission protocol is: destination address, source address, protocol type (type), source port, destination port, preset Header, data area. . Among them, the destination address is the destination address of the encapsulated data packet, the source address is the source address of the encapsulated data packet, the destination address and the source address are used for the second layer communication of the transmission link, the protocol type is used to distinguish the preset transmission protocol from other protocols, the source port is the port for sending the encapsulated data packet, the destination port is the port for receiving the encapsulated data packet, the preset Header is used to indicate the flow control algorithm used for near field communication, and the preset Header is different from the Header of the Transmission Control Protocol / Internet Protocol TCP / IP, and the data area is used to store specific business data. Optionally, the destination address and the source address are MAC (Media Access Control) addresses.

[0131] For example, the protocol format of the preset transmission protocol is shown in Table 1 below:

[0132] Table 1

[0133] In Table 1, the first row represents the destination address, source address, protocol type, source port, destination port, preset header, and bytes occupied by the data area in sequence.

[0134] In some embodiments, when any application installed on the first device needs to send data to the same application installed on the second device, the application in the first device encapsulates the data to be sent based on a preset transmission protocol to obtain a first data packet.

[0135] Step S302: The first device sends a first data packet to a first memory block through a first user mode SDK.

[0136] In some embodiments, a first socket is determined by a first user state SDK, each socket has a corresponding memory block, and then the first data packet is sent to the first memory block corresponding to the first socket by the first user state SDK. Optionally, at least one memory block using a memory sharing mechanism is preset and allocated, each memory block has a corresponding socket, and the first socket can be selected from at least one socket.

[0137] Step S303: The first device obtains a first data packet from the first memory block through the first kernel-state SDK, and sends the first data packet to the first network card driver.

[0138] Since the first memory block uses a memory sharing mechanism, the first data packet can be directly obtained from the first memory block through the first kernel state SDK, and after obtaining the first data packet, the first data packet is sent to the first network card driver. In addition, due to the characteristics of the preset transmission protocol, the network protocol stack can be directly bypassed, that is, when the first data packet is obtained through the first kernel state SDK, it does not need to be forwarded in the middle through the network protocol stack.

[0139] Step S304: The first device sends the first data packet to the second device through the first network card driver.

[0140] After the first network card driver receives the first data packet, the first device sends the first data packet to the second device through the first network card driver.

[0141] In some embodiments, a first mapping relationship is stored in the first device, and the first mapping relationship includes a port and a corresponding socket, and the port is at least one of the port through which the first device sends a data packet and the port through which the second device receives a data packet. Considering that if the second device returns corresponding data for the first data packet later, it is also necessary to return the data returned by the second device to the application corresponding to the first data packet in the original path, therefore, after sending the first data packet, the first mapping relationship is updated, and the first port corresponds to the first socket in the updated first mapping relationship, and the first port includes at least one of the first source port and the first destination port, the first source port is the port through which the first device sends the first data packet, the first destination port is the port through which the second device receives the first data packet, and the first socket is the socket corresponding to the first memory block. After the first mapping relationship is updated, when the data corresponding to the first data packet returned by the second device is subsequently received, the returned data can be sent to the first memory block corresponding to the first socket according to the first socket corresponding to the first port in the first mapping relationship.

[0142] Step S305: The second device receives the data packet sent by the first device through the second network card driver.

[0143] In the disclosed embodiment, since the first device also sends other data packets in addition to the first data packet to the second device, the second device receives the data packet sent by the first device through the second network card driver, which data packet includes the first data packet and other data packets, and then sends the data packet to the second kernel state SDK of the second device.

[0144] Step S306: The second device filters out the first data packet from the received data packets according to the protocol type through the second kernel state SDK.

[0145] In the disclosed embodiment, different transmission protocols correspond to different protocol types. Therefore, the protocol types in the data packets encapsulated based on different transmission protocols are different. Therefore, the first data packet is filtered out from the received data packets according to the protocol type through the second kernel state SDK.

[0146] In some embodiments, the second device calls a bpf program through a second kernel-mode SDK to filter out the first data packet from the received data packets according to a protocol type.

[0147] Step S307: The second device queries the second socket corresponding to the first data packet through the second kernel state SDK, and sends the first data packet to the second memory block corresponding to the second socket.

[0148] In the disclosed embodiment, after obtaining the first data packet, the first data packet needs to be saved in a memory block and then sent to the corresponding application. When determining the memory block, the corresponding memory block is determined according to the socket corresponding to the first data packet.

[0149] In some embodiments, the first data packet includes a first source port and a first destination port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet. Through the second kernel state SDK, according to the second mapping relationship, the second socket corresponding to the first data packet is queried, the second mapping relationship includes the port and the corresponding socket, the port includes at least one of the source port and the destination port, the source port is the port through which the first device sends the data packet, the destination port is the port through which the second device receives the data packet, and the socket is the socket corresponding to the memory block for storing the data packet. That is, according to the second mapping relationship, the socket corresponding to the first source port or the first destination port is determined to be the second socket.

[0150] In some embodiments, in order for the second device to send the first source port of the first data packet through the first device and return the data corresponding to the first data packet to the first device, it is also necessary to update the third mapping relationship. The updated third mapping relationship includes the first source port and the corresponding second socket, so that the destination port of the returned data can be determined subsequently according to the third preset relationship.

[0151] Step S308: The second device obtains the first data packet from the second memory block through the second user mode SDK.

[0152] Step S309: The second device parses the first data packet based on a preset transmission protocol to obtain parsed data.

[0153] After receiving the first data packet, the second device parses the data sent by the first device from the first data packet based on the preset transmission protocol and in accordance with the format of the preset transmission protocol.

[0154] According to the method provided by the embodiments of the present disclosure, in a near field communication scenario, the first user-state SDK, the first kernel-state SDK, the second user-state SDK, and the second kernel-state SDK are all SDKs based on the kernel bypass function. Therefore, the first data packet is transmitted through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to be sent to the second device. After the second device receives the first data packet, it transmits the first data packet through the kernel bypass, and can bypass the network protocol stack to be transmitted to the second user-state SDK. For the first device and the second device, during the data transmission process, while reducing the power consumption of the devices, the data transmission delay is reduced, and the data transmission throughput is improved.

[0155] In some embodiments, after the first device sends the first data packet to the second device, the second device returns a second data packet corresponding to the first data packet to the first device. The process of the second device receiving the second data packet by the first device is as follows: Figure 4 The example shown:

[0156] Figure 4 is a flowchart of a method for sending and receiving data according to an exemplary embodiment, which is executed by a first device and a second device, see Figure 4 , the method comprises the following steps:

[0157] Step S401: The second device obtains a second data packet, where the second data packet is a data packet corresponding to the first data packet.

[0158] The data carried in the second data packet is data corresponding to the data carried in the first data packet. For example, the data carried in the first data packet is a request, and the data carried in the second data packet may be a response corresponding to the request. Furthermore, the second data packet is also obtained by encapsulation based on a preset transmission protocol.

[0159] In some embodiments, a third mapping relationship is obtained, the third mapping relationship includes the source port of the received data packet and the corresponding socket, the socket is the socket corresponding to the memory block for storing the data packet; according to the third mapping relationship and the second socket corresponding to the second memory block, the second destination port in the second data packet is determined, the second destination port is the same as the first source port in the first data packet, the first source port is the port through which the first device sends the first data packet, so that the second device can send the first source port of the first data packet to the first device, and return the data corresponding to the first data packet to the first device. Optionally, the source port in the second data packet is the first destination port, that is, the second device can return the data corresponding to the first data packet to the first device through the first destination port of the first data packet.

[0160] Of course, in some embodiments, other methods may be used to determine the source port and the destination port of the second data packet, and the embodiments of the present disclosure are not limited to this.

[0161] Step S402: The second device sends a second data packet to a second memory block through a second user mode SDK.

[0162] Step S403: The second device obtains a second data packet from the second memory block through the second kernel-state SDK, and sends the second data packet to the second network card driver.

[0163] Step S404: The second device sends the second data packet to the first device through the second network card driver.

[0164] Step S405: The first device receives the second data packet returned by the second device through the first network card driver.

[0165] Step S406: The first device sends the second data packet to the first memory block through the first kernel state SDK.

[0166] Step S407: The first device obtains the second data packet from the first memory block through the first user mode SDK.

[0167] In some embodiments, the second data packet carries a second port, the second port includes at least one of a second source port and a second destination port, the second source port is the same as the first destination port, the second destination port is the same as the first source port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet. The second data packet is sent to the first memory block through the first kernel state SDK in the first device, including: determining the first socket corresponding to the second port through the first kernel state SDK according to the first mapping relationship, the first mapping relationship includes the port and the corresponding socket, the port includes at least one of the source port and the destination port, the source port is the port through which the first device sends the data packet, the destination port is the port through which the second device receives the data packet, the socket is the socket corresponding to the memory block for storing the data packet, and the second data packet is sent to the first memory block corresponding to the first socket.

[0168] The sending process of the second data packet in steps S402-S407 is the same as the above Figure 3 The sending process of the first data packet in the illustrated embodiment is similar and will not be described in detail here.

[0169] In some embodiments, during the data transmission and data reception process, the source port and the destination port need to be determined based on the first mapping relationship, the second mapping relationship, and the third mapping relationship. Figure 5 The architecture diagram of the data transmission process shown in the figure shows that the left side is the first device (sender) and the right side is the second device (receiver). For the first device, Figure 5 In the example, three sockets A_socket1, A_socket2 and A_socket3, and three source ports src port A1, src port A2 and srcport A3 are set. Bind_port(A) associates the monitored port with the socket, that is, the source ports src port A1, src port A2 and src port A3 are associated with A_socket1, A_socket2 and A_socket3 respectively, and the bpf_port_map (i.e., the first mapping relationship) after the first device updates is obtained. Then, the first device sends the data packet stored in the memory block corresponding to any A_socket to the second device through the source port src port A corresponding to the A_socket. For the second device, Figure 5In the example, three sockets B_socket1, B_socket2 and B_socket3, and three destination ports dst port B1, dst port B2 and dst port B3 are set, and each destination port is a port for receiving data agreed with the first device. After the second device receives the data packet through the destination port, it filters the data packet according to the protocol type through the bpf program, and determines the corresponding B_socket according to the dst port (that is, querying the dest_socket_map), and sends the filtered data packet to the memory block corresponding to the determined B_socket, wherein bind_port(B) associates the monitored port with the socket, that is, the destination ports src port B1, srcport B2 and src port B3 are associated with B_socket1, B_socket2 and B_socket3 respectively, and the updated dest_socket_map (that is, the second mapping relationship) of the second device is obtained. In addition, bpf_addr_map is updated through bpf program to store the correspondence between B_socket and the source port (remote_addr) corresponding to the received data packet, that is, the source port of the other end (the first device) is recorded.

[0170] Figure 6 is a block diagram of a data sending device according to an exemplary embodiment, which is configured in a first device, see Figure 6 , the device comprises:

[0171] The data encapsulation module 601 is configured to encapsulate the data to be sent based on a preset transmission protocol to obtain a first data packet, where the preset transmission protocol is used for near field communication;

[0172] The user state processing module 602 is configured to send the first data packet to the first memory block through a first user state software development kit SDK in the first device, where the first user state SDK is an SDK in the user state of the first device for implementing a kernel bypass function;

[0173] The kernel state processing module 603 is configured to obtain a first data packet from the first memory block through a first kernel state SDK in the first device, and send the first data packet to a first network card driver in the first device, where the first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function;

[0174] The data sending module 604 is configured to send the first data packet to the second device through the first network card driver.

[0175] In the apparatus provided by the embodiment of the present disclosure, in a near field communication scenario, the first device encapsulates the data to be sent based on a preset transmission protocol to obtain a first data packet, sends the first data packet to the first memory block through the first user state SDK, obtains the first data packet from the first memory block through the first kernel state SDK in the first device, sends the first data packet to the first network card driver, and finally sends the first data packet to the second device through the first network card driver, wherein the first user state SDK and the first kernel state SDK are both SDKs based on the kernel bypass function, therefore, the first data packet is transmitted through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to be sent to the second device, thereby reducing the power consumption of the device while reducing the data transmission delay and improving the data transmission throughput.

[0176] In some embodiments, the apparatus further comprises:

[0177] A relationship update module is configured to update a first mapping relationship, in which the first port in the updated first mapping relationship corresponds to the first socket, the first port includes at least one of a first source port and a first destination port, the first source port is a port for the first device to send a first data packet, the first destination port is a port for the second device to receive the first data packet, and the first socket is a socket corresponding to the first memory block.

[0178] In some embodiments, the apparatus further comprises:

[0179] A data receiving module is configured to receive a second data packet returned by the second device through the first network card driver, where the second data packet corresponds to the first data packet;

[0180] The kernel state processing module 603 is further configured to send the second data packet to the first memory block through the first kernel state SDK;

[0181] The user state processing module 602 is further configured to obtain a second data packet from the first memory block through the first user state SDK.

[0182] In some embodiments, the second data packet carries a second port, the second port includes at least one of a second source port and a second destination port, the second source port is the same as the first destination port, the second destination port is the same as the first source port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet;

[0183] The kernel mode processing module 603 is further configured to:

[0184] Determine, by the first kernel state SDK, a first socket corresponding to the second port according to a first mapping relationship, the first mapping relationship including a port and a corresponding socket, the port including at least one of a source port and a destination port, the source port is a port for the first device to send a data packet, the destination port is a port for the second device to receive a data packet, and the socket is a socket corresponding to a memory block for storing the data packet;

[0185] The second data packet is sent to the first memory block corresponding to the first socket.

[0186] In some embodiments, the protocol format of the preset transmission protocol is: destination address, source address, protocol type, source port, destination port, preset header, data area; the preset header is used to indicate the flow control algorithm used for near field communication, and the preset header is different from the header of the transmission control protocol / Internet protocol TCP / IP.

[0187] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0188] Figure 7 is a block diagram of a data receiving apparatus according to an exemplary embodiment, which is configured in the second device, see Figure 7 , the device comprises:

[0189] The data receiving module 701 is configured to receive a data packet sent by the first device through a second network card driver of the second device;

[0190] The kernel state processing module 702 is configured to filter out a first data packet from the received data packets through a second kernel state software development kit SDK of the second device, and send the first data packet to the second memory block, wherein the first data packet is obtained by encapsulating based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol adopted by other data packets, and the second kernel state SDK is an SDK for implementing a kernel bypass function in the kernel state of the second device;

[0191] The user state processing module 703 is configured to obtain the first data packet from the second memory block through the second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function.

[0192] In the apparatus provided by the embodiment of the present disclosure, in a near field communication scenario, the second device receives the data packet sent by the first device through the second network card driver, and then screens out the first data packet from the received data packet through the second kernel state SDK, sends the first data packet to the second memory block, and finally obtains the first data packet from the second memory block through the second user state SDK. The second user state SDK and the second kernel state SDK are both SDKs based on the kernel bypass function. Therefore, after the second device receives the first data packet, it transmits the first data packet through the kernel bypass, and can bypass the network protocol stack (TCP / IP) to transmit it to the second user state SDK, which reduces the power consumption of the device while reducing the data transmission delay and improving the data transmission throughput.

[0193] In some embodiments, the kernel mode processing module 702 is configured to:

[0194] The first data packet is screened out from the received data packets according to the protocol type through the second kernel state SDK, wherein different transmission protocols correspond to different protocol types.

[0195] In some embodiments, the apparatus further comprises:

[0196] The data parsing module is configured to parse the first data packet based on a preset transmission protocol to obtain parsed data.

[0197] In some embodiments, the kernel mode processing module 702 is configured to:

[0198] Querying the second socket corresponding to the first data packet through the second kernel state SDK;

[0199] The first data packet is sent to the second memory block corresponding to the second socket.

[0200] In some embodiments, the first data packet includes a first source port and a first destination port, the first source port is a port through which the first device sends the first data packet, and the first destination port is a port through which the second device receives the first data packet, and the kernel state processing module 702 is configured as follows:

[0201] Through the second kernel state SDK, according to the second mapping relationship, the second socket corresponding to the first data packet is queried, the second mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is the port through which the first device sends the data packet, the destination port is the port through which the second device receives the data packet, and the socket is the socket corresponding to the memory block used to store the data packet.

[0202] In some embodiments, the apparatus further comprises:

[0203] The relationship updating module is configured to update the third mapping relationship, where the updated third mapping relationship includes the first source port and the corresponding second socket.

[0204] In some embodiments, the apparatus further comprises:

[0205] A data packet acquisition module is configured to acquire a second data packet, where the second data packet is a data packet corresponding to the first data packet;

[0206] The user state processing module 703 is further configured to send the second data packet to the second memory block through the second user state SDK;

[0207] The kernel state processing module 702 is further configured to obtain a second data packet from the second memory block through a second kernel state SDK, and send the second data packet to a second network card driver;

[0208] The data sending module is configured to send the second data packet to the first device through the second network card driver.

[0209] In some embodiments, the data packet acquisition module is configured to:

[0210] Obtain a third mapping relationship, where the third mapping relationship includes a source port of the received data packet and a corresponding socket, where the socket is a socket corresponding to a memory block for storing the data packet;

[0211] According to the third mapping relationship and the second socket corresponding to the second memory block, the second destination port in the second data packet is determined, the second destination port is the same as the first source port in the first data packet, and the first source port is the port through which the first device sends the first data packet.

[0212] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0213] An embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the data sending method and the data receiving method in the above-mentioned embodiment.

[0214] Figure 8 is a block diagram of an electronic device 800 according to an exemplary embodiment.

[0215] Reference Figure 8, the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0216] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0217] The memory 804 is configured to store various types of data to support operations on the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0218] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0219] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0220] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0221] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0222] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the electronic device 800, the relative positioning of the components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0223] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0224] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0225] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0226] The embodiments of the present disclosure also provide a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the data sending method and the data receiving method in the above embodiments.

[0227] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed in this disclosure. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0228] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A data transmission method, characterized in that: Executed by a first device, the method includes: Based on a preset transmission protocol, encapsulating the data to be sent to obtain a first data packet, wherein the preset transmission protocol is used for near field communication; Sending the first data packet to a first memory block through a first user-state software development kit SDK in the first device, where the first user-state SDK is an SDK in a user state of the first device for implementing a kernel bypass function; Obtaining the first data packet from the first memory block through a first kernel state SDK in the first device, and sending the first data packet to a first network card driver in the first device, wherein the first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function; The first network card driver sends the first data packet to the second device.

2. The method according to claim 1, characterized in that After obtaining the first data packet from the first memory block through the first kernel-mode SDK in the first device and sending the first data packet to the first network card driver in the first device, the method further includes: Update the first mapping relationship, in which the first port in the updated first mapping relationship corresponds to the first socket, the first port includes at least one of a first source port and a first destination port, the first source port is the port through which the first device sends the first data packet, the first destination port is the port through which the second device receives the first data packet, and the first socket is the socket corresponding to the first memory block.

3. The method according to claim 1, characterized in that The method further comprises: Receiving, through the first network card driver, a second data packet returned by the second device, where the second data packet corresponds to the first data packet; Sending the second data packet to the first memory block through the first kernel state SDK; The second data packet is obtained from the first memory block through the first user mode SDK.

4. The method according to claim 3, characterized in that The second data packet carries a second port, the second port includes at least one of a second source port and a second destination port, the second source port is the same as the first destination port, the second destination port is the same as the first source port, the first source port is the port through which the first device sends the first data packet, and the first destination port is the port through which the second device receives the first data packet; The sending the second data packet to the first memory block through the first kernel state SDK in the first device includes: Determining, by the first kernel state SDK, a first socket corresponding to the second port according to a first mapping relationship, wherein the first mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is a port for the first device to send a data packet, the destination port is a port for the second device to receive a data packet, and the socket is a socket corresponding to a memory block for storing the data packet; Send the second data packet to the first memory block corresponding to the first socket.

5. The method according to any one of claims 1 to 4, characterized in that: The protocol format of the preset transmission protocol is: destination address, source address, protocol type, source port, destination port, preset header, and data area; the preset header is used to indicate a flow control algorithm for near field communication, and the preset header is different from the header of the transmission control protocol / Internet protocol TCP / IP.

6. A data receiving method, characterized in that: Executed by a second device, the method includes: Receiving, by means of a second network card driver of the second device, a data packet sent by the first device; Filtering a first data packet from received data packets through a second kernel state software development kit SDK of the second device, and sending the first data packet to a second memory block, wherein the first data packet is obtained by encapsulating based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol adopted by other data packets, and the second kernel state SDK is an SDK in the kernel state of the second device for implementing a kernel bypass function; The first data packet is obtained from the second memory block through a second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function.

7. The method according to claim 6, characterized in that The filtering out the first data packet from the received data packets by the second kernel state SDK of the second device includes: The first data packet is filtered out from the received data packets according to the protocol type through the second kernel-mode SDK, wherein different transmission protocols correspond to different protocol types.

8. The method according to claim 7, characterized in that After obtaining the first data packet from the second memory block through the second user mode SDK of the second device, the method further includes: Based on the preset transmission protocol, the first data packet is parsed to obtain parsed data.

9. The method according to claim 6, characterized in that The sending the first data packet to the second memory block through the second kernel state SDK of the second device includes: Querying, through the second kernel state SDK, a second socket corresponding to the first data packet; Send the first data packet to the second memory block corresponding to the second socket.

10. The method according to claim 9, characterized in that The first data packet includes a first source port and a first destination port, the first source port is a port through which the first device sends the first data packet, and the first destination port is a port through which the second device receives the first data packet, and querying a second socket corresponding to the first data packet through a second kernel state SDK of the second device includes: Through the second kernel-state SDK, according to the second mapping relationship, the second socket corresponding to the first data packet is queried, the second mapping relationship includes a port and a corresponding socket, the port includes at least one of a source port and a destination port, the source port is the port through which the first device sends a data packet, the destination port is the port through which the second device receives a data packet, and the socket is the socket corresponding to the memory block used to store the data packet.

11. The method according to claim 10, characterized in that The method further comprises: The third mapping relationship is updated, where the updated third mapping relationship includes the first source port and the corresponding second socket.

12. The method according to claim 6, characterized in that After obtaining the first data packet from the second memory block through the second user mode SDK of the second device, the method further includes: Acquire a second data packet, where the second data packet is a data packet corresponding to the first data packet; Sending the second data packet to the second memory block through the second user state SDK; Obtaining the second data packet from the second memory block through the second kernel state SDK, and sending the second data packet to the second network card driver; The second network card driver sends the second data packet to the first device.

13. The method according to claim 12, characterized in that The obtaining of the second data packet comprises: Acquire a third mapping relationship, where the third mapping relationship includes a source port of a received data packet and a corresponding socket, where the socket is a socket corresponding to a memory block for storing the data packet; According to the third mapping relationship and the second socket corresponding to the second memory block, the second destination port in the second data packet is determined, the second destination port is the same as the first source port in the first data packet, and the first source port is the port through which the first device sends the first data packet.

14. A data sending device, characterized in that: Configured in a first device, the apparatus comprises: A data encapsulation module is configured to encapsulate the data to be sent based on a preset transmission protocol to obtain a first data packet, wherein the preset transmission protocol is used for near field communication; A user state processing module is configured to send the first data packet to a first memory block through a first user state software development kit SDK in the first device, where the first user state SDK is an SDK in the user state of the first device for implementing a kernel bypass function; a kernel state processing module, configured to obtain the first data packet from the first memory block through a first kernel state SDK in the first device, and send the first data packet to a first network card driver in the first device, wherein the first kernel state SDK is an SDK in the kernel state of the first device for implementing a kernel bypass function; The data sending module is configured to send the first data packet to the second device through the first network card driver.

15. A data receiving device, characterized in that: The device is configured in a second device, and includes: A data receiving module, configured to receive a data packet sent by the first device through a second network card driver of the second device; a kernel state processing module, configured to filter out a first data packet from received data packets through a second kernel state software development kit SDK of the second device, and send the first data packet to a second memory block, wherein the first data packet is obtained by encapsulation based on a preset transmission protocol, and the preset transmission protocol is different from the transmission protocol adopted by other data packets, and the second kernel state SDK is an SDK in the kernel state of the second device for implementing a kernel bypass function; The user state processing module is configured to obtain the first data packet from the second memory block through the second user state SDK of the second device, where the second user state SDK is an SDK in the user state of the second device for implementing a kernel bypass function.

16. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 5, or the processor is configured to execute the method according to any one of claims 6 to 13.

17. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as described in any one of claims 1 to 5, or the electronic device is enabled to execute the method as described in any one of claims 6 to 13.