Data transmission method and apparatus, electronic device, and storage medium

By using a virtual network interface card and transparent transmission, the problem of data integrity during data transmission was solved, and complete data transmission from the application sending layer to the receiving end was achieved.

CN118474058BActive Publication Date: 2026-06-02广州视晟科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
广州视晟科技有限公司
Filing Date
2024-05-31
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In standard network transmission mode, some data is intercepted and filtered during data transmission, resulting in the receiving end being unable to receive the data completely, which fails to meet the data integrity requirements in the test environment.

Method used

Data is directly transmitted to the receiving end through the virtual network interface card, avoiding intermediate layer filtering and interception. The data is formatted, encapsulated, and transmitted using a pass-through method. Data processing is performed using the buffers of the virtual network interface card sending layer and the application sending layer to ensure data integrity.

Benefits of technology

It enables complete data transmission between the sending and receiving ends, avoiding filtering and interception by intermediate layers and ensuring data integrity during transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118474058B_ABST
    Figure CN118474058B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data transmission method and device, electronic equipment and storage medium, belonging to the technical field of data transmission. The method is applied to a sending end, and the sending end includes a virtual network card sending layer and an application sending layer. The method includes: obtaining candidate sending data of the application sending layer; the candidate sending data includes a candidate transmission mode and candidate transmission data; if the candidate transmission mode is a transparent transmission mode, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data; the formatted transmission data is written into a candidate virtual network card sending buffer of the virtual network card sending layer through a candidate application sending buffer, a write pointer and a candidate write address of the application sending layer to obtain a selected virtual network card sending buffer; and data of the selected virtual network card sending buffer is sent to a receiving end through a virtual network card interface, so that the receiving end receives data sent by the sending end to obtain application layer receiving data. The embodiments of the present application can ensure the integrity of data in the data transmission process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] During data transmission, the sending end packages the target data into selected data and passes it to the network layer through the operating system interface. The network layer then transmits the selected data to the receiving end via the TCP / IP protocol. The receiving end, after acquiring the selected data, parses it through the operating system interface to obtain the target data. In this standard network transmission mode, when the selected data from the sending end flows through the operating system interface to the network layer, some of it may be intercepted or filtered by the operating system's firewall, gateway, or other filters. This results in the selected data not reaching the receiving end completely, and the receiving end, after parsing the selected data, cannot obtain the complete target data. In some test environments, it is required that the data in the test scenario be collected completely, but the integrity of the data cannot be fully guaranteed under the standard network transmission mode. Therefore, how to ensure the integrity of data during data transmission has become an urgent problem to be solved. Summary of the Invention

[0003] The main objective of this application is to provide a data transmission method and apparatus, electronic device and storage medium, which aims to ensure the integrity of data during data transmission.

[0004] To achieve the above objectives, a first aspect of this application proposes a data transmission method applied at a sending end, the sending end comprising: a virtual network interface card (NIC) sending layer and an application sending layer; the method comprising:

[0005] Obtain candidate transmission data from the application transmission layer; wherein, the candidate transmission data includes: candidate transmission methods and candidate transmission data;

[0006] If the candidate transmission method is a preset transparent transmission method, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data; wherein, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer, and send the data of the virtual network card sending layer to the preset receiving end through a preset virtual network card interface;

[0007] The formatted transmission data is written to the candidate virtual network interface card (NIC) transmission buffer of the virtual NIC transmission layer through the candidate application transmission buffer of the application transmission layer, the preset write pointer, and the preset candidate write address, so as to obtain the selected virtual NIC transmission buffer.

[0008] The selected virtual network card transmit buffer data is sent to the receiving end through the virtual network card interface, so that the receiving end receives the data sent by the sending end and obtains the application layer received data.

[0009] In some embodiments, the step of writing the formatted transmission data into the candidate virtual network interface card (NIC) transmission buffer of the virtual NIC transmission layer through the candidate application transmission buffer of the application transmission layer, a preset write pointer, and a preset candidate write address to obtain the selected virtual NIC transmission buffer includes:

[0010] Construct structure data based on the formatted transmission data and the candidate write addresses;

[0011] Obtain the write operation status of the write pointer;

[0012] Based on the write working state, the structure data and the selected data length of the formatted transmission data are written into the candidate application sending buffer to obtain the selected application sending buffer;

[0013] The selected virtual network interface card (NIC) send buffer is obtained by copying data from the candidate NIC send buffer through the selected application send buffer.

[0014] In some embodiments, the sending end further includes a physical network interface card (NIC) sending layer, which includes a candidate NIC sending buffer; the step of sending data from the selected virtual NIC sending buffer to the receiving end through the virtual NIC interface includes:

[0015] The data in the selected virtual network card transmission buffer is written into the candidate physical network card transmission buffer through the virtual network card interface to obtain the selected physical network card transmission buffer.

[0016] The virtual network interface card (NIC) interface calls the physical NIC interface of the physical NIC transmission layer to send the data of the selected physical NIC transmission buffer to the receiving end.

[0017] In some embodiments, the step of writing the structure data and the selected data length of the formatted transmission data into the candidate application send buffer according to the write working state to obtain the selected application send buffer includes:

[0018] If the write working state is the write idle state, the structure data and the selected data length are written into the candidate application sending buffer to obtain the selected application sending buffer.

[0019] If the write operation status is busy, monitor the write operation status until it becomes idle, then write the structure data and the selected data length into the candidate application send buffer to obtain the selected application send buffer.

[0020] In some embodiments, the method further includes: pre-constructing the virtual network interface card, specifically including:

[0021] Obtain the preset device driver interface of the physical network card;

[0022] The device driver interface is configured according to a preset device configuration function to obtain candidate network interface cards.

[0023] Obtain the physical network card information of the physical network card, and configure the candidate network card interface for communication based on the physical network card information and the preset memory allocation interface to obtain the virtual network card interface.

[0024] In some embodiments, the step of configuring the candidate network interface based on the physical network interface information and a preset memory allocation interface to obtain the virtual network interface includes:

[0025] Based on the physical network card information, the physical network card and the candidate network card interface are connected for communication to obtain a network card communication channel; wherein, the candidate network card interface can control the physical network card according to the network card communication channel;

[0026] Based on the physical network card information, the physical network card and the memory request interface are memory-mapped to obtain a memory communication channel; wherein, the memory communication channel is the channel for data communication between the physical network card and the system memory;

[0027] The physical network card is configured according to the candidate network card interface, the network card communication channel, and the memory communication channel to obtain the virtual network card interface.

[0028] In some embodiments, the receiving end includes a virtual network interface card (NIC) receiving layer and an application receiving layer; receiving data sent by the sending end to obtain application layer received data includes:

[0029] The virtual network interface card (NIC) receives data sent by the sending end according to the virtual NIC receive buffer of the virtual NIC receive layer, and monitors the receive status of the virtual NIC receive buffer.

[0030] When the receiving status indicates that data reception is complete, a preset interrupt function is triggered;

[0031] The application receiving layer receives the interrupt function so that the application receiving layer can obtain the preset read operation status of the read pointer;

[0032] If the read working state is the read idle state, the data in the virtual network card receive buffer is read into the application layer receive buffer according to the application layer receive buffer to obtain the application layer received data.

[0033] To achieve the above objectives, a second aspect of this application provides a data transmission apparatus, the apparatus comprising:

[0034] The acquisition module is used to acquire candidate transmission data of the application sending layer; wherein, the candidate transmission data includes: candidate transmission mode and candidate transmission data;

[0035] An encapsulation module is used to format and encapsulate the candidate transmission data to obtain formatted transmission data if the candidate transmission method is a preset transparent transmission method; wherein, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer and send the data of the virtual network card sending layer to a preset receiving end through a preset virtual network card interface;

[0036] The first sending module is used to write the formatted transmission data into the candidate virtual network interface card (NIC) sending buffer of the virtual NIC sending layer through the candidate application sending buffer of the application sending layer, a preset write pointer, and a preset candidate write address, so as to obtain the selected virtual NIC sending buffer.

[0037] The second sending module is used to send the data of the selected virtual network card sending buffer to the receiving end through the virtual network card interface, so that the receiving end can receive the data sent by the sending end and obtain the application layer received data.

[0038] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0039] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0040] This application proposes a data transmission method, apparatus, electronic device, and storage medium. It acquires candidate transmission data from the application sending layer of the sending end. The candidate transmission data includes candidate transmission modes and candidate transmission data. When the candidate transmission mode is transparent, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data. This formatted data is then written to the candidate virtual network interface card (NIC) sending buffer of the virtual network interface card (NIC) layer through the candidate application sending buffer, write pointer, and candidate write address of the application sending layer. This results in a selected NIC sending buffer, allowing data from the application sending layer to be directly transparently transmitted to the NIC sending buffer. Data flowing from the application sending layer to the NIC layer does not require filtering or encapsulation by intermediate layers, avoiding data incompleteness caused by filtering or interception during intermediate layer flow. Furthermore, the data from the selected NIC sending buffer is sent to the receiving end through the NIC interface to obtain application layer received data, thus achieving complete data transmission between the sending and receiving ends. Attached Figure Description

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

[0042] Figure 2 This is a flowchart of a data transmission method provided in another embodiment of this application;

[0043] Figure 3 yes Figure 2 The flowchart of step S203 in the process;

[0044] Figure 4 yes Figure 1 The flowchart of step S103 in the process;

[0045] Figure 5 yes Figure 4 The flowchart of step S403 in the process;

[0046] Figure 6 yes Figure 1 The flowchart of step S104 in the process;

[0047] Figure 7 yes Figure 1 The flowchart of step S104 in the process;

[0048] Figure 8 This is a schematic diagram of the structure of the data transmission device provided in the embodiments of this application;

[0049] Figure 9 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application;

[0050] Figure 10 This is a schematic diagram of constructing a virtual network interface card provided in an embodiment of this application;

[0051] Figure 11 This is a schematic diagram of the data transmission process provided in an embodiment of this application. Detailed Implementation

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

[0053] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0055] First, let's analyze some of the terms used in this application:

[0056] Virtual Network Interface Card (VNIC): A virtual network interface card (VNIC) is a component used for network virtualization that simulates the function of a physical network interface card (NIC), primarily for data pass-through. It allows data to be transferred between network devices without relying on a physical NIC. VNICs are typically used in Software-Defined Networking (SDN) or other virtualization environments, providing flexible network connectivity and data transmission capabilities through software configuration and management. VNICs can process and forward network packets by configuring network parameters such as MAC addresses and IP addresses. The VNIC is responsible for transmitting data packets from one network node to another, ensuring efficient data transmission and optimized utilization of network resources. In data pass-through applications, VNICs are commonly used to improve network performance, simplify network management, and enhance network security.

[0057] A Network Interface Card (NIC) is a hardware device used to connect a computer or other network devices to a network. A NIC provides a network interface for data transmission via wired or wireless means. NICs are installed on the computer motherboard and connect via interfaces such as PCI or PCIe. Their main functions include data transmission, network connectivity, address allocation, and protocol support. NICs are a key hardware component for enabling communication between devices and networks and are widely used in various devices requiring network connectivity, such as personal computers, servers, and printers.

[0058] During data transmission, the sending end packages the target data into selected data and passes it to the network layer through the operating system interface. The network layer then transmits the selected data to the receiving end via the TCP / IP protocol. The receiving end, after acquiring the selected data, parses it through the operating system interface to obtain the target data. In this standard network transmission mode, when the selected data arrives at the receiving end, it is parsed through the operating system interface. If some of the selected data is incomplete, the operating system will be unable to parse it correctly, and the incorrectly parsed selected data will be blocked by the operating system's firewall or gateway, preventing the receiving end from receiving the complete target data. In some test environments, it is required that the data in the test scenario be collected completely, but the integrity of the data cannot be fully guaranteed under the standard network transmission mode. Therefore, ensuring data integrity during data transmission becomes a pressing issue.

[0059] Based on this, embodiments of this application provide a data transmission method and apparatus, an electronic device, and a storage medium, aiming to ensure the integrity of data during data transmission.

[0060] This application provides a data transmission method, apparatus, electronic device, and storage medium, which are specifically described through the following embodiments. First, the data transmission method in the embodiments of this application is described.

[0061] The data transmission method provided in this application relates to the field of data transmission technology. The data transmission method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application implementing the data transmission method, but is not limited to the above forms.

[0062] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0063] Figure 1 This is an optional flowchart of the data transmission method provided in the embodiments of this application, applied to the sending end, which includes: a virtual network card sending layer and an application sending layer. Figure 1 The method may include, but is not limited to, steps S101 to S104.

[0064] Step S101: Obtain candidate transmission data from the application transmission layer; wherein, the candidate transmission data includes: candidate transmission mode and candidate transmission data;

[0065] Step S102: If the candidate transmission method is a preset transparent transmission method, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data; wherein, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer, and send the data of the virtual network card sending layer to the preset receiving end through the preset virtual network card interface.

[0066] Step S103: Write formatted transmission data into the candidate virtual network interface card (NIC) send buffer of the virtual network interface card (NIC) send layer using the candidate application send buffer of the application send layer, the preset write pointer, and the preset candidate write address, to obtain the selected virtual NIC send buffer.

[0067] Step S104: The data in the selected virtual network card transmit buffer is sent to the receiving end through the virtual network card interface, so that the receiving end receives the data sent by the sending end and obtains the application layer received data.

[0068] Please see Figure 2 In some embodiments, the data transmission method may include, but is not limited to, pre-constructing a virtual network interface card, specifically including steps S201 to S203:

[0069] Step S201: Obtain the preset device driver interface of the physical network card;

[0070] Step S202: Configure the device driver interface according to the preset device configuration function to obtain candidate network interface cards;

[0071] Step S203: Obtain the physical network card information of the physical network card, and configure the candidate network card interface for communication based on the physical network card information and the preset memory allocation interface to obtain the virtual network card interface.

[0072] Steps S201 to S203 as shown in the embodiments of this application involve obtaining the device driver interface of the physical network card and configuring the device driver interface according to the device configuration function to realize the custom configuration and custom use of the physical network card, obtaining candidate network card interfaces, and configuring the candidate network card interfaces according to the physical network card information, memory allocation interface and device configuration function to obtain virtual network card interfaces, thereby establishing a connection channel between the physical network card, virtual network card and operating system, enabling mutual data transmission.

[0073] In step S201 of some embodiments, a physical network interface card (NIC) is a hardware device used to connect a computer or other network device to a network. Each physical NIC has a separate device driver interface, which is a software interface used for communication between the operating system and the hardware device.

[0074] In step S202 of some embodiments, the device driver function is a function for data exchange, including a data sending function, a data receiving function, a device connection function, an interrupt function, a timing function, a registration function, and a startup function. The device driver interface is configured through the device configuration function, thereby realizing the custom configuration and custom use of the physical network card.

[0075] In one embodiment, the device driver interface is npc i_dev, which includes many function interfaces. The function interfaces do not provide the operating logic of the physical network card. The device driver interface npc i_dev is implemented using the PX IE library, and the function interfaces in npc i_dev, including the DeviceOpen() interface, SendData() interface, and RecvData() interface, are implemented to configure the physical network card and obtain candidate network card interfaces.

[0076] Please see Figure 3 In some embodiments, step S203 may include, but is not limited to, steps S301 to S303:

[0077] Step S301: Connect the physical network card and the candidate network card interface to establish a communication channel based on the physical network card information; wherein, the candidate network card interface can control the physical network card according to the network card communication channel.

[0078] Step S302: Based on the physical network card information, perform memory mapping between the physical network card and the memory request interface to obtain a memory communication channel; wherein, the memory communication channel is the channel for data communication between the physical network card and the system memory;

[0079] Step S303: Configure the physical network card according to the candidate network card interface, network card communication channel and memory communication channel to obtain the virtual network card interface.

[0080] In the embodiments of this application, steps S301 to S303 involve establishing a communication connection between the physical network card and the candidate network card interface based on the physical network card information to obtain a network card communication channel; performing memory mapping between the physical network card and the memory allocation interface based on the physical network card information to obtain a memory communication channel; and finally configuring the physical network card based on the candidate network card interface, the network card communication channel, and the memory communication channel to obtain a virtual network card interface. This establishes a connection channel between the physical network card, the virtual network card, and the operating system, enabling data transmission between them.

[0081] In step S301 of some embodiments, the physical network interface card (NIC) information refers to the number and serial number of the physical NICs. Each physical NIC has a unique identifier, and each unique identifier uniquely corresponds to a physical NIC. The candidate NIC interface establishes a communication connection based on the unique identifier of each physical NIC. For a physical NIC, the corresponding physical NIC is first determined based on the unique identifier. Then, the device base address of the physical NIC is obtained through the DeviceOpen() function. A communication connection between the candidate NIC interface and the physical NIC is established through the device base address. Finally, a communication connection between the candidate NIC and each physical NIC is established by traversing all unique identifiers.

[0082] In step S302 of some embodiments, the memory allocation interface is the operating system's memory operation interface. First, the operating system allocates a memory space through the memory allocation interface and transmits the address of the memory space to the physical network card, so that the physical network card can directly access the system memory without going through the operating system's CPU, which improves the transmission efficiency. Based on the physical network card information, the physical network card and the memory allocation interface are memory-mapped to establish a memory communication channel, so that the physical network card can communicate directly with the system memory.

[0083] In step S303 of some embodiments, the candidate network interface configures the physical network card through the network card communication channel, sets the parameters of the physical network card, such as transmission rate and master-slave mode, and configures the memory communication channel to the corresponding physical network card to obtain the virtual network interface, thereby realizing the communication connection between the virtual network interface, the physical network card and the system memory.

[0084] Steps S101 to S104 of this embodiment involve obtaining candidate transmission data from the application transmission layer of the sending end. The candidate transmission data includes candidate transmission modes and candidate transmission data. When the candidate transmission mode is transparent transmission mode, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data. This formatted data is then written to the candidate virtual network interface card (NIC) transmission buffer of the virtual network interface card (NIC) layer via the candidate application transmission buffer, write pointer, and candidate write address of the application transmission layer. This results in a selected NIC transmission buffer, allowing the application transmission layer data to be directly transparently transmitted to the NIC transmission buffer. Data flowing from the application transmission layer to the NIC layer does not require filtering or encapsulation by intermediate layers, preventing data incompleteness caused by filtering or interception during intermediate layer flow. Furthermore, the data from the selected NIC transmission buffer is sent to the receiving end via the NIC interface to obtain application layer received data, thus achieving complete data transmission between the sending and receiving ends.

[0085] In step S101 of some embodiments, the sending end is the initiator of data transmission. The application sending layer refers to the software part that directly provides various application services, such as a web browser, application software, file transfer tool, or email. Candidate transmission data is the data sent outward in the application sending layer. Candidate transmission data includes candidate transmission modes and candidate transmission data. The candidate transmission mode is the data received by the receiving end. The candidate transmission modes include transparent transmission mode and standard mode. The standard mode sends the candidate transmission data to the receiving end according to the traditional network transmission method.

[0086] In step S102 of some embodiments, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer and send the data of the virtual network card sending layer to the preset receiving end through the preset virtual network card interface; when the candidate transmission method is the transparent transmission method, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data.

[0087] It should be noted that the candidate transmission method can also be the standard method. When the candidate transmission method is the standard method, the standard computer data transmission method is used to transmit the data to the receiving end.

[0088] It should be noted that when transmitting data, users can choose between transparent transmission or standard mode as the candidate transmission method.

[0089] Please see Figure 4 In some embodiments, step S103 may include, but is not limited to, steps S401 to S404:

[0090] Step S401: Construct structure data based on formatted transmission data and candidate write addresses;

[0091] Step S402: Obtain the write operation status of the write pointer;

[0092] Step S403: Write the selected data length of the structure data and formatted transmission data into the candidate application sending buffer according to the write working status to obtain the selected application sending buffer;

[0093] Step S404: Copy data to the candidate virtual network card send buffer by selecting the application send buffer to obtain the selected virtual network card send buffer.

[0094] Steps S401 to S404 as shown in the embodiments of this application involve constructing structure data based on formatted transmission data and candidate write addresses, and writing the structure data and the selected data length of the formatted transmission data into the candidate application sending buffer according to the write working state of the write pointer, thereby obtaining the selected application sending buffer. Finally, the selected application sending buffer is used to copy data to the candidate virtual network card sending buffer, thereby obtaining the selected virtual network card sending buffer. This enables data to be directly transmitted from the application layer to the network card layer without going through an intermediate layer, thus avoiding data filtering or parsing by the intermediate layer.

[0095] In step S401 of some embodiments, candidate transmission data is written into the memory space corresponding to a preset data write address, and the data write address is used as a structure to transmit data.

[0096] In step S402 of some embodiments, the write pointer is a pointer used to control and track the data write position. It is used to control the write position and timing of the structure transmission data written to the candidate application send buffer. Using the write pointer to write data can manage the data storage of the candidate application send buffer and avoid buffer overflow. At the same time, the write pointer can prevent the overwriting of previously written data.

[0097] Please see Figure 5 In some embodiments, step S403 includes, but is not limited to, steps S501 to S502:

[0098] Step S501: If the write working state is the write idle state, write the structure data and the selected data length into the candidate application send buffer to obtain the selected application send buffer.

[0099] Step S502: If the write working state is busy, monitor the write working state until it becomes idle, write the structure data and the selected data length into the candidate application send buffer to obtain the selected application send buffer.

[0100] In steps S501 to S502 of this embodiment, when the write working state is write idle, the structure data and the selected data length are written to the candidate application send buffer to obtain the selected application send buffer. When the write working state is write busy, the write working state is monitored until it becomes write idle, and the structure data and the selected data length are written to the candidate application send buffer to obtain the selected application send buffer. When the write pointer is in write busy, meaning data is being written to the candidate application send buffer, writing the structure data and the selected data length to the candidate application send buffer at this time would cause data overwriting. Therefore, by checking the write working state of the write pointer, the structure data and the selected data length are ensured to be correctly written to the candidate application send buffer.

[0101] In step S501 of some embodiments, when the write working state is write idle state, indicating that no other data is currently being written to the candidate application send buffer, the structure data and the selected data length are written to the candidate application send buffer to obtain the selected application send buffer. Simultaneously, the base address of the structure data written to the candidate application send buffer is recorded, and the structure data can be retrieved from the selected application send buffer based on the base address and the selected data length.

[0102] In step S502 of some embodiments, when the write working state is in the write busy state, it indicates that data is being written to the candidate application send buffer. If the structure data and the selected data length are written to the candidate application send buffer at this time, it will cause data overwriting. Therefore, the write working state is monitored until the write working state becomes the write idle state, and the structure data and the selected data length are written to the candidate application send buffer to obtain the selected application send buffer.

[0103] In step S404 of some embodiments, the selected application sending buffer is a buffer at the application sending layer, and the candidate virtual network card sending buffer is a buffer at the network card layer. The selected application sending buffer includes structure data, the base address when the structure data is stored, and the selected data length of the structure data. The structure data is determined from the selected application sending buffer according to the base address and the selected data length, and the structure data is retrieved and transmitted to the candidate virtual network card sending buffer to obtain the selected virtual network card sending buffer.

[0104] Please see Figure 6 In some embodiments, the transmitting end further includes a physical network interface card (NIC) transmitting layer, which includes a candidate NIC transmitting buffer. Step S104 includes, but is not limited to, steps S601 to S602:

[0105] Step S601: Write the data of the selected virtual network card's transmit buffer into the candidate physical network card's transmit buffer through the virtual network card interface to obtain the selected physical network card's transmit buffer;

[0106] Step S602: Call the physical network card interface of the physical network card transmission layer through the virtual network card interface to send the data of the selected physical network card transmission buffer to the receiving end.

[0107] In the embodiments of this application, steps S601 to S602 involve writing data from the selected virtual network card transmit buffer into the candidate physical network card transmit buffer through the virtual network card interface, obtaining the selected physical network card transmit buffer, and calling the physical network card interface of the physical network card transmit layer through the virtual network card interface to send the data from the selected physical network card transmit buffer to the receiving end, thereby realizing the transmission of data from the virtual network card layer to the receiving end.

[0108] In step S601 of some embodiments, the candidate physical network card transmission buffer is the buffer when the physical network card transmits data. The data of the selected virtual network card transmission buffer is extracted through the virtual network card interface and transmitted to the candidate physical network card transmission buffer to obtain the selected physical network card transmission buffer.

[0109] In step S602 of some embodiments, the physical network card interface is the data transmission interface of the physical network card transmission layer. The physical network card interface is called through the virtual network card interface, and the data of the selected physical network card transmission buffer is sent to the receiving end, thereby realizing the transmission of the selected physical network card transmission buffer to the receiving end.

[0110] Please see Figure 7 In some embodiments, the receiving end includes a virtual network interface card (NIC) receiving layer and an application receiving layer, and step S104 may include, but is not limited to, steps S701 to S704:

[0111] Step S701: Receive data sent by the sending end according to the virtual network card receive buffer of the virtual network card receive layer, and monitor the receive status of the virtual network card receive buffer;

[0112] Step S702: When the receiving status is "data reception complete", a preset interrupt function is triggered;

[0113] Step S703: The application receiving layer receives the interrupt function so that the application receiving layer can obtain the preset read working state of the read pointer;

[0114] Step S704: If the read working state is the read idle state, read the data from the virtual network card receive buffer according to the application layer receive buffer of the application receiving layer to obtain the application layer received data.

[0115] Steps S701 to S704 of this application embodiment involve receiving data sent by the sending end according to the virtual network card receive buffer of the virtual network card receive layer, and monitoring the receive status of the virtual network card receive buffer. When the data reception is complete, a preset interrupt function is triggered so that the application receive layer obtains the preset read working status of the read pointer. When the read working status is read idle, the data in the virtual network card receive buffer is read according to the application layer receive buffer of the application receive layer to obtain the application layer received data, thereby completing the transparent reception of data by the receiving end. Data is directly received from the virtual network card receive layer to the application layer, avoiding the parsing and filtering of data by the intermediate layer, and realizing the complete transmission of data.

[0116] In step S701 of some embodiments, the sending end sends data to the receiving end's physical network card through the physical network card, receives data from the receiving end's physical network card according to the virtual network card receive buffer, and monitors the receiving progress of the virtual network card receive buffer, thereby realizing the reception of data by the virtual network card receive layer in the receiving end.

[0117] In step S702 of some embodiments, the interrupt function is an operating system-level function used by the operating system to generate an interrupt. When the receiving status is that the data reception is complete, the interrupt function is triggered to notify the application layer to obtain data from the virtual network card receiving layer.

[0118] In step S703 of some embodiments, the read pointer is a pointer used to control and track the data read position, and to control the read / write state of the application layer receive buffer. When the read working state is read busy, it indicates that data is being retrieved from the virtual network interface card receive buffer and written to the application layer receive buffer. When the read working state is read idle, it indicates that no data is being migrated from the virtual network interface card receive buffer to the application layer receive buffer.

[0119] In step S704 of some embodiments, when the read working state is the read idle state, the data in the virtual network card receive buffer is taken out and copied to the application layer receive buffer of the application receive layer to complete the transparent reception of data. The receiving end directly receives data from the virtual network card receive layer to the application layer, avoiding the parsing and filtering of data by the intermediate layer, and realizing the complete transmission of data.

[0120] Please see Figure 10 In some embodiments, the specific process of pre-constructing the virtual network interface card (NIC) structure includes: first, obtaining the device driver interface npc i_dev of the physical NIC; then, configuring the candidate NIC according to preset device configuration functions, including but not limited to DeviceOpen(), SendData(), and RecvData(), to obtain a non-standard network port, i.e., the candidate NIC interface. Next, establishing a communication connection between the candidate NIC interface and the physical NIC based on the physical NIC information, including the number of NICs and their IDs. Using the DeviceOpen() function to open the physical NIC according to the ID, and obtaining the corresponding device operation base address, a communication connection is established based on the device operation base address to obtain the NIC communication channel. Then, the memory allocation interface requests memory from the sending end's operating system and maps it to the physical NIC's memory, enabling the physical NIC to directly use the allocated memory. Finally, setting the NIC parameters, such as transmission rate and master / slave mode, completes the NIC configuration, ultimately obtaining the virtual NIC interface.

[0121] Please see Figure 11The system retrieves candidate transmission data from the application sending layer. When the candidate transmission mode in the candidate transmission data is pass-through, it formats and encapsulates the candidate transmission data and writes it to the memory space corresponding to the preset write address TxPhyMem, thus completing the construction of the candidate transmission data and obtaining formatted data. Then, based on the write working state of the write pointer, it writes the structure data and the selected length of the formatted transmission data to Tx_ringbuf, which is the candidate application sending buffer. The Tx_ringbuf after data writing is used as the selected application sending buffer. Then, it copies data to the buffer of the virtual network interface card layer at the sending end through the selected application sending buffer, that is, it copies data to the candidate virtual network interface card sending buffer. The buffer of the virtual network interface card layer at the sending end after data copying is used as the selected application sending buffer. The data is then sent to the receiving end by calling the physical network interface card layer through the virtual network interface card interface. This allows data to flow from the application sending layer to the virtual network interface card layer without going through the filtering, encapsulation, and parsing of the intermediate layer, avoiding data incompleteness caused by filtering or interception when data flows through the intermediate layer. When the physical network interface card (NIC) receives data at the receiving end, it copies the data to the virtual NIC. After the copy is complete, a preset interrupt function is triggered, and the data is written to Rx_ringbuf according to the working state of the read pointer. The application layer retrieves the data from Rx_ringbuf, completing the transparent transmission and reception of the data.

[0122] Please see Figure 8 This application also provides a data transmission apparatus that can implement the above-described data transmission method. The apparatus includes:

[0123] The acquisition module 801 is used to acquire candidate transmission data from the application sending layer; wherein, the candidate transmission data includes: candidate transmission mode and candidate transmission data;

[0124] The encapsulation module 802 is used to format and encapsulate the candidate transmission data to obtain formatted transmission data if the candidate transmission mode is a preset transparent transmission mode; wherein, the transparent transmission mode is to directly write the candidate transmission data into the virtual network card sending layer and send the data of the virtual network card sending layer to the preset receiving end through the preset virtual network card interface.

[0125] The first sending module 803 is used to write formatted transmission data into the candidate virtual network interface card (NIC) sending buffer of the virtual NIC sending layer through the candidate application sending buffer of the application sending layer, the preset write pointer and the preset candidate write address, so as to obtain the selected virtual NIC sending buffer.

[0126] The second sending module 804 is used to send data from the selected virtual network card sending buffer to the receiving end through the virtual network card interface, so that the receiving end can receive the data sent by the sending end and obtain the application layer received data.

[0127] The specific implementation of this data transmission device is basically the same as the specific embodiment of the data transmission method described above, and will not be repeated here.

[0128] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described data transmission method. This electronic device can be any smart terminal, including tablet computers, in-vehicle computers, etc.

[0129] Please see Figure 9 , Figure 9 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0130] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0131] The memory 902 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 using the data transmission method of the embodiments of this application.

[0132] The input / output interface 903 is used to implement information input and output;

[0133] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0134] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);

[0135] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.

[0136] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described data transmission method.

[0137] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0138] The data transmission method, data transmission device, electronic device, and storage medium provided in this application embodiment obtain candidate transmission data from the application transmission layer of the sending end. The candidate transmission data includes candidate transmission modes and candidate transmission data. When the candidate transmission mode is a transparent transmission mode, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data. This formatted data is then written to the candidate virtual network interface card (NIC) transmission buffer of the virtual NIC layer through the candidate application transmission buffer, write pointer, and candidate write address of the application transmission layer, resulting in a selected NIC transmission buffer. This allows data from the application transmission layer to be directly transparently transmitted to the NIC transmission buffer of the NIC layer. Data flowing from the application transmission layer to the NIC layer does not require filtering or encapsulation by intermediate layers, avoiding data incompleteness caused by filtering or interception during intermediate layer flow. Furthermore, the data from the selected NIC transmission buffer is sent to the receiving end through the NIC interface to obtain application layer received data, thus achieving complete data transmission between the sending and receiving ends.

[0139] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0140] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0141] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0142] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0143] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0144] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0145] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0146] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0147] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0148] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, 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. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0149] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A data transmission method, characterized in that, Applied to a sending end, the sending end includes: a virtual network interface card (NIC) sending layer and an application sending layer; the method includes: Obtain candidate transmission data from the application transmission layer; wherein, the candidate transmission data includes: candidate transmission methods and candidate transmission data; If the candidate transmission method is a preset transparent transmission method, the candidate transmission data is formatted and encapsulated to obtain formatted transmission data; wherein, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer, and send the data of the virtual network card sending layer to the preset receiving end through a preset virtual network card interface; Construct structure data based on the formatted transmission data and preset candidate write addresses; Get the preset write operation status of the write pointer; Based on the write working state, the structure data and the selected data length of the formatted transmission data are written into the candidate application sending buffer of the application sending layer to obtain the selected application sending buffer. The selected virtual network interface card (NIC) send buffer is obtained by copying data from the candidate NIC send buffer of the NIC send layer through the selected application send buffer. The selected virtual network card transmit buffer data is sent to the receiving end through the virtual network card interface, so that the receiving end receives the data sent by the sending end and obtains the application layer received data.

2. The method according to claim 1, characterized in that, The sending end further includes a physical network interface card (NIC) sending layer, which includes a candidate physical NIC sending buffer; the step of sending data from the selected virtual NIC sending buffer to the receiving end through the virtual NIC interface includes: The data in the selected virtual network card transmission buffer is written into the candidate physical network card transmission buffer through the virtual network card interface to obtain the selected physical network card transmission buffer. The virtual network interface card (NIC) interface calls the physical NIC interface of the physical NIC transmission layer to send the data of the selected physical NIC transmission buffer to the receiving end.

3. The method according to claim 1, characterized in that, The step of writing the structure data and the selected data length of the formatted transmission data into the candidate application sending buffer of the application sending layer according to the write working state to obtain the selected application sending buffer includes: If the write working state is the write idle state, the structure data and the selected data length are written into the candidate application sending buffer to obtain the selected application sending buffer. If the write operation status is busy, monitor the write operation status until it becomes idle, then write the structure data and the selected data length into the candidate application send buffer to obtain the selected application send buffer.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: pre-constructing the virtual network interface card, specifically including: Obtain the preset device driver interface of the physical network card; The device driver interface is configured according to a preset device configuration function to obtain candidate network interface cards. Obtain the physical network card information of the physical network card, and configure the candidate network card interface for communication based on the physical network card information and the preset memory allocation interface to obtain the virtual network card interface.

5. The method according to claim 4, characterized in that, The step of configuring the candidate network interface based on the physical network card information and a preset memory allocation interface to obtain the virtual network interface includes: Based on the physical network card information, the physical network card and the candidate network card interface are connected to form a communication channel; wherein, the candidate network card interface can control the physical network card according to the network card communication channel; Based on the physical network interface card (NIC) information, a memory mapping is performed between the physical NIC and the memory request interface to obtain a memory communication channel; wherein, the memory communication channel is the channel for data communication between the physical NIC and the system memory; The physical network card is configured according to the candidate network card interface, the network card communication channel, and the memory communication channel to obtain the virtual network card interface.

6. The method according to claim 1, characterized in that, The receiving end includes a virtual network interface card (NIC) receiving layer and an application receiving layer; receiving data sent by the sending end to obtain application layer received data includes: The virtual network interface card (NIC) receives data sent by the sending end according to the virtual NIC receive buffer of the virtual NIC receive layer, and monitors the receive status of the virtual NIC receive buffer. When the receiving status indicates that data reception is complete, a preset interrupt function is triggered; The application receiving layer receives the interrupt function so that the application receiving layer can obtain the preset read operation status of the read pointer; If the read working state is the read idle state, the data in the virtual network card receive buffer is read into the application layer receive buffer according to the application layer receive buffer to obtain the application layer received data.

7. A data transmission device, characterized in that, The device is applied to a sending end, which includes a virtual network interface card (NIC) sending layer and an application sending layer; the device includes: The acquisition module is used to acquire candidate transmission data of the application sending layer; wherein, the candidate transmission data includes: candidate transmission mode and candidate transmission data; An encapsulation module is used to format and encapsulate the candidate transmission data to obtain formatted transmission data if the candidate transmission method is a preset transparent transmission method; wherein, the transparent transmission method is to directly write the candidate transmission data into the virtual network card sending layer and send the data of the virtual network card sending layer to a preset receiving end through a preset virtual network card interface; The first sending module is used to construct structure data according to the formatted transmission data and the preset candidate write address; obtain the write working state of the preset write pointer; write the structure data and the selected data length of the formatted transmission data into the candidate application sending buffer of the application sending layer according to the write working state to obtain the selected application sending buffer; and copy data to the candidate virtual network card sending buffer of the virtual network card sending layer through the selected application sending buffer to obtain the selected virtual network card sending buffer. The second sending module is used to send the data of the selected virtual network card sending buffer to the receiving end through the virtual network card interface, so that the receiving end can receive the data sent by the sending end and obtain the application layer received data.

8. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the data transmission method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the data transmission method according to any one of claims 1 to 6.