Data forwarding proxy method, electronic device, storage medium and program product
By establishing a kernel buffer pool at the network card driver level and establishing relationships with the CPU and applications, the application directly processes and forwards data packets, solving the problem of poor performance of data forwarding agents in the existing technology, and achieving more efficient data forwarding.
Patent Information
- Application Number
- CN202411902221.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-23
AI Technical Summary
In the existing layer seven data forwarding agent implementation, packet copying is required when data is transmitted from layer four to layer seven, resulting in poor network throughput performance and average response delay.
By establishing a kernel buffer pool for each network card queue at the network card driver level, and establishing correspondence between the kernel buffer pool, CPU and application, the application directly reads the data packets received by the protocol stack kernel buffer pool for processing and forwarding, avoiding memory copying.
Improves the throughput performance of the layer seven protocol stack proxy and shortens the average response delay.
Smart Images

Figure CN119766915A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a data forwarding proxy method, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] The existing seven-layer data forwarding agent implementation, whether based on kernel state + user state implementation or pure user state implementation, requires a copy of the message when the seven-layer protocol stack transfers data from the fourth layer to the seventh layer. After the user state processes the data, the data is copied to the socket, which leads to poor network throughput performance and long average response delay. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a data forwarding proxy method, an electronic device, a computer-readable storage medium, and a computer program product.
[0004] A first aspect of the present application provides a data forwarding agent method, the method comprising:
[0005] The network card driver establishes a kernel buffer pool for each network card queue, and establishes a corresponding relationship between the kernel buffer pool, CPU, and application program;
[0006] After receiving the data message from the network, the network card driver stores the data message in the designated kernel buffer pool space in the kernel buffer pool and reports it to the protocol stack;
[0007] The protocol stack parses and transmits the data message in the order of data link layer, network layer and transport layer;
[0008] The protocol stack transmits the specified kernel buffer pool space address to the application program, so that the application program operates the data message pointed to by the kernel buffer pool space address;
[0009] The application performs at least one operation of adding, modifying or deleting the data message;
[0010] The application writes the address of the kernel buffer pool space to the kernel and calls the protocol sending function to send the data message;
[0011] The kernel buffer pool is used to allocate a number of kernel buffer pool structures to store data according to the length of the actual data message, and the kernel buffer pool structures can form a linked list structure, and the address of the memory buffer pool space is represented by the address of the linked list structure.
[0012] In some embodiments, after receiving the data message from the network, the network card driver stores the data message into a designated kernel buffer pool space in the kernel buffer pool, including:
[0013] After receiving the data message, the network card driver receives the data message into the kernel buffer pool space specified by the kernel buffer pool through direct memory access or copying.
[0014] In some embodiments, the protocol stack parses and transmits the data message in the order of the link layer, the network layer, and the transport layer, including:
[0015] After parsing the data message in accordance with the data link layer, network layer and transport layer in turn, for the message that needs to be discarded, its corresponding kernel buffer pool structure space is released to the kernel buffer pool to which it belongs, or for the data message that needs to be transmitted to the local, it is placed on the socket's receive queue.
[0016] In some embodiments, the method further comprises:
[0017] The kernel buffer pool merging and fragment reassembly functions of the protocol stack are both disabled.
[0018] In some embodiments, the method further comprises:
[0019] The protocol stack notifies the opposite end to send a non-fragmented data message through an ICMP message.
[0020] In some embodiments, the application performs at least one of adding, modifying or deleting the data message, including:
[0021] When the application performs an operation of adding data, a new kernel buffer pool structure is allocated from the kernel buffer pool and added to the kernel buffer pool linked list;
[0022] When the application deletes data, the kernel buffer pool structure corresponding to the data is deleted;
[0023] When the application modifies data, if the length of the modified data is greater than the maximum length of the TCP message, a new kernel buffer pool structure is allocated to store the data that exceeds the maximum length of the TCP message.
[0024] In some embodiments, when the application performs a data deletion operation, deleting the kernel buffer pool structure corresponding to the data includes:
[0025] The kernel buffer pool structure corresponding to the data is deleted through a system call method, and the kernel buffer pool structure corresponding to the data is released to the kernel buffer pool to which it belongs.
[0026] A second aspect of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores executable instructions, and when the executable instructions are executed by the processor, the electronic device executes any one of the methods described above.
[0027] A third aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned data forwarding proxy methods is implemented.
[0028] A fourth aspect of the present application provides a computer program product, which includes a computer program. When the computer program is executed, the computer executes any of the above-mentioned data forwarding proxy methods.
[0029] The present application provides a data forwarding proxy method that can be used for the proxy of the seven-layer protocol stack. The data message received by the protocol stack kernel buffer pool is directly read by the application. After the application adds, deletes, and modifies the data message, the data message is sent to the protocol stack for forwarding, thereby avoiding memory copying, improving the throughput performance of the seven-layer protocol stack proxy, and shortening the average response delay. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A schematic diagram of the data forwarding proxy method flow in an embodiment of the present application;
[0031] Figure 2 A schematic diagram of the structure of a data forwarding proxy device according to an embodiment of the present application;
[0032] Figure 3 A schematic diagram of the correspondence between the network card queue, CPU, and process in an embodiment of the present application;
[0033] Figure 4 Schematic diagram showing the mapping of application space to the kernel buffer pool.
[0034] Reference numerals:
[0035] 1000, data forwarding agent device; 1001, kernel buffer pool creation module; 1002, kernel buffer pool allocation module; 1003, data message parsing and transmission module; 1004, data message address transmission module; 1005, data message processing module; 1006, data message sending module; 1100, bus; 1200, processor; 1300, memory; 1400, other circuits. DETAILED DESCRIPTION
[0036] Various aspects and features of the present application are described herein with reference to the accompanying drawings.
[0037] It should be understood that various modifications may be made to the embodiments of the present application. Therefore, the above description should not be considered as limiting, but only as an example of an embodiment. Other modifications within the scope and spirit of the present application will occur to those skilled in the art.
[0038] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.
[0039] These and other characteristics of the present application will become apparent from the following description of a preferred form of embodiment given as a non-limiting example with reference to the accompanying drawings.
[0040] It should also be understood that although the present application has been described with reference to some specific examples, those skilled in the art will be able to readily implement many other equivalent forms of the present application.
[0041] Figure 1 A schematic diagram of a data forwarding proxy method flow chart of an embodiment of the present application is shown as follows: Figure 1 As shown, the method includes:
[0042] S101, the network card driver establishes a kernel buffer pool for each network card queue, and establishes a corresponding relationship between the kernel buffer pool, the CPU, and the application program;
[0043] S102, after receiving the data message from the network, the network card driver stores the data message into the designated kernel buffer pool space in the kernel buffer pool and reports it to the protocol stack;
[0044] S103, the protocol stack parses and transmits the data message in the order of the link layer, the network layer, and the transport layer;
[0045] S104, the protocol stack transmits the specified kernel buffer pool space address to the application program, so that the application program operates the data message pointed to by the kernel buffer pool space address;
[0046] S105, the application performs at least one operation of adding, modifying or deleting the data message;
[0047] S106, the application writes the address of the kernel buffer pool space to the kernel and calls the protocol sending function to send the data message;
[0048] The kernel buffer pool is used to allocate a number of kernel buffer pool structures to store data according to the length of the actual data message. The number of kernel buffer pool structures can form a linked list structure, and the address of the memory buffer pool space is represented by the address of the linked list structure.
[0049] For ease of understanding, each of the above steps is described separately.
[0050] In the above step S101, the kernel buffer pool (skb pool), CPU, and application program establish a corresponding relationship, which can be combined with Figure 3 , Figure 3 The figure shows a schematic diagram of establishing a corresponding relationship between the kernel buffer pool, CPU, and application. Each queue of the multi-queue network card RSS is bound to a separate CPU core, and a separate process is bound to the CPU core. The process corresponds to the application. The figure only schematically shows the corresponding relationship between 3 network card queues, 3 CPU cores, and 3 processes. It should be noted that the number of network card queues, CPUs, and applications / processes is not limited to this, and can be other values. The mapping relationship between the kernel buffer pool, CPU, and application is realized, which, on the one hand, achieves the effect of improving performance, and on the other hand, makes it convenient for user-mode programs to map the kernel buffer pool.
[0051] Furthermore, the application program in the above step S101 is a user-mode program.
[0052] Since the kernel buffer pool has been created in step S101, the network card driver can receive data through the kernel buffer pool in step S102, thereby replacing the existing request from the slab memory.
[0053] Furthermore, in step S102, the kernel buffer pool structure puts the kernel buffer pool structure (sk_buf structure) and the fixed-length data together.
[0054] In the above step S103, the protocol stack needs to parse the data message in the order of the data link layer, the network layer, and the transport layer, and transmit the data message upward layer by layer according to the data link layer, the network layer, and the transport layer.
[0055] In the above step S104, the protocol stack transmits the specified kernel buffer pool space address to the application program, so that the application program operates the data message pointed to by the kernel buffer pool space address. Figure 4 A schematic diagram showing the mapping of application space to the kernel buffer pool is provided for explanation. Figure 4 In the process, each process corresponds to its own network card queue, and each network card queue corresponds to its own kernel buffer pool. By reading the file provided by the network card driver, the application (i.e. Figure 4 A portion of the space of each process shown in is mapped to the kernel buffer pool of the kernel, which is used for subsequent direct reading from the kernel buffer pool by the application. Here, the process and the CPU and the network card queue are bound one by one to avoid multi-core competition for the kernel buffer pool.
[0056] In the above step S104, the application program may operate the actual data pointed to by the kernel buffer through a function.
[0057] In the above step S105, the application performs at least one operation of adding, modifying or deleting the data message through the kernel buffer.
[0058] In the above step S106, in order to send messages of consistent size as much as possible during transmission, the mss (the maximum length of data messages allowed to be sent by the TCP protocol) on both sides of the data message can be adjusted to adapt to the commonly used modifications to the http proxy, such as inserting the x-forward-for request header without modifying the skb. Note that after the user-mode program sends the skb, it can no longer operate on these skb. For skb that is not sent in one time, it is necessary to wait for the write event and then resend it, which is no different from ordinary write. For the skb after the sending is completed, the application will perform a link removal operation to avoid repeated sending.
[0059] This application modifies the network card driver layer to create a kernel buffer pool for each network card receiving and sending queue to allow application mapping. This application provides a data forwarding proxy method suitable for the seven-layer protocol stack proxy, which directly reads the data message received by the protocol stack in the user state program, and the user state program adds, deletes, and modifies the data message, and then sends the data message to the protocol stack for forwarding, thereby avoiding memory copying, improving the throughput performance of the seven-layer protocol stack proxy, and shortening the average response delay.
[0060] In some embodiments, after receiving a data packet from the network, the network card driver stores the data packet in a designated kernel buffer pool space in the kernel buffer pool, including:
[0061] After receiving the data message, the network card driver receives the data message into the kernel buffer pool space specified by the kernel buffer pool through direct memory access or copying.
[0062] In some embodiments, the protocol stack parses and transmits the data message in the order of the link layer, the network layer, and the transport layer, including:
[0063] After parsing the data message in accordance with the data link layer, network layer and transport layer in turn, for the message that needs to be discarded, its corresponding kernel buffer pool structure space is released to the kernel buffer pool to which it belongs, or for the data message that needs to be transmitted to the local, it is placed on the socket's receive queue.
[0064] In some embodiments, the method further comprises:
[0065] The protocol stack's kernel buffer pool merging and fragment reassembly functions are disabled.
[0066] In some embodiments, the method further comprises:
[0067] The protocol stack notifies the peer to send non-fragmented data packets through ICMP messages. Since the protocol stack prohibits the fragment reassembly function, it is necessary to notify the peer to send data packets in the form of non-fragmented data packets. The ICMP message can be used to notify the peer so that the peer can send data packets in the form of non-fragmented data packets.
[0068] In some embodiments, the application performs at least one of adding, modifying or deleting the data message, including:
[0069] When the application performs an operation to add data, a new kernel buffer pool structure is allocated from the kernel buffer pool and added to the kernel buffer pool linked list;
[0070] When the application deletes data, the kernel buffer pool structure corresponding to the data is deleted;
[0071] When the application modifies data, if the length of the modified data is greater than the maximum length of the TCP message, a new kernel buffer pool structure is allocated to store the data that exceeds the maximum length of the TCP message.
[0072] In some embodiments, when the application performs a data deletion operation, deleting the kernel buffer pool structure corresponding to the data includes:
[0073] The kernel buffer pool structure corresponding to the data is deleted through a system call method, and the kernel buffer pool structure corresponding to the data is released to the kernel buffer pool to which it belongs.
[0074] According to one embodiment of the present application, the present application also provides an electronic device, which includes: a processor and a memory, wherein the memory stores executable instructions, and when the executable instructions are executed by the processor, the electronic device executes any one of the above methods.
[0075] In some embodiments, the memory may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or various devices including one or any combination of the above memories.
[0076] In some embodiments, executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.
[0077] As an example, executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).
[0078] By way of example, executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one site, or on multiple computing devices distributed across multiple sites and interconnected by a communication network.
[0079] In some embodiments, the electronic device may be any electronic device deployed in the network, such as a terminal device or a server. The terminal device may include a mobile phone, a tablet computer, a laptop computer, a desktop computer, various wearable devices, a smart TV, a vehicle-mounted device, or other electronic devices capable of implementing the above functions. The server may be a cloud server, an independent physical server, or a server cluster or distributed system composed of multiple physical servers. The server may also be a node server on a blockchain network.
[0080] The terminal device or server can be directly or indirectly connected to other devices through wired or wireless communication, and this application is not limited here. Optionally, the above-mentioned communication method uses standard communication technology and / or protocol. The Internet is usually the Internet, but it can also be any network, including but not limited to any combination of local area network (Local Area Network, LAN), metropolitan area network (Metropolitan Area Network, MAN), wide area network (Wide Area Network, WAN), mobile, wired or wireless network, private network or virtual private network. In some embodiments, the data exchanged through the network is represented by technologies and / or formats including Hyper Text Mark-up Language (Hyper Text Mark-up Language, HTML), Extensible Markup Language (Extensible Markup Language, XML), etc. In addition, conventional encryption technologies such as Secure Socket Layer (Secure Socket Layer, SSL), Transport Layer Security (Transport Layer Security, TLS), Virtual Private Network (Virtual Private Network, VPN), Internet Protocol Security (Internet Protocol Security, IPsec) can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies may be used to replace or supplement the above-mentioned data communication technologies.
[0081] Figure 2 A schematic diagram of the structure of a data forwarding proxy device according to an embodiment of the present application is shown. Figure 2 As shown, the device comprises:
[0082] The kernel buffer pool creation module 1001 is used to enable the network card driver to establish a kernel buffer pool for each network card queue, and to establish a corresponding relationship between the kernel buffer pool, the CPU, and the application program;
[0083] The kernel buffer pool allocation module 1002 stores the data message to the designated kernel buffer pool space in the kernel buffer pool and reports it to the protocol stack after the network card driver receives the data message from the network.
[0084] The data message parsing and transmission module 1003 is used to parse and transmit the data message in the order of the link layer, the network layer and the transport layer through the protocol stack;
[0085] The data message address transmission module 1004 is used to transmit the specified kernel buffer pool space address to the application program through the protocol stack, so that the application program can operate the data message pointed to by the kernel buffer pool space address;
[0086] The data message processing module 1005 is used to perform at least one of adding, modifying or deleting data messages through the application program;
[0087] The data message sending module 1006 is used for the bucket application to write the kernel buffer pool space address to the kernel and call the protocol sending function to send the data message;
[0088] The kernel buffer pool is used to allocate a number of kernel buffer pool structures to store data according to the length of the actual data message. The number of kernel buffer pool structures can form a linked list structure, and the address of the memory buffer pool space is represented by the address of the linked list structure.
[0089] It should be noted that the implementation details of each module of the data forwarding proxy device provided in the present application correspond to the data forwarding proxy method provided in the present application, and will not be described one by one here.
[0090] According to a computer-readable storage medium of at least one embodiment of the present application, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned data forwarding proxy methods is implemented. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the function can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media may include computer storage media and communication media, and may also include any medium that can transfer a computer program from one place to another. The storage medium may be any target medium that can be accessed by a computer.
[0091] In one possible implementation, a computer-readable storage medium may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that is intended to carry or store the required program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave) is used to transmit software from a website, server or other remote source, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVD), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included in the scope of computer-readable media.
[0092] According to a computer program product of at least one embodiment of the present application, the computer program product includes a computer program, and when the computer program is executed, the computer executes any of the above-mentioned data forwarding proxy methods.
[0093] Figure 2 An example diagram of a data forwarding proxy device using a hardware implementation of a processing system is shown. The device may include a corresponding module for executing each or several steps in the above flowchart. Therefore, each step or several steps in the above flowchart can be executed by a corresponding module, and the device may include one or more modules in these modules. The module may be one or more hardware modules specifically configured to execute the corresponding steps, or implemented by a processor configured to execute the corresponding steps, or stored in a computer-readable medium for implementation by a processor, or implemented by some combination.
[0094] The hardware structure can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application and overall design constraints of the hardware. The bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules together. The bus 1100 can also connect various other circuits 1400 such as peripherals, voltage regulators, power management circuits, external antennas, etc.
[0095] The bus 1100 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Component (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the figure only uses one connecting line, but does not mean that there is only one bus or one type of bus.
[0096] The processor 1200 may be a general purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof. The general purpose processor may be a microprocessor or any conventional processor.
[0097] Any process or method description in the flowchart or otherwise described herein can be understood as a module, fragment or portion of a code representing one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including performing the functions in a substantially simultaneous manner or in a reverse order according to the functions involved, which should be understood by a person skilled in the art of the technical field to which the embodiments of the present application belong. The processor performs the various methods and processes described above. For example, the method implementation in the present application can be implemented as a software program, which is tangibly contained in a machine-readable medium, such as a memory. In some embodiments, part or all of the software program can be loaded and / or installed via a memory and / or a communication interface. When the software program is loaded into the memory and executed by the processor, one or more steps in the method described above can be performed. Alternatively, in other embodiments, the processor can be configured to perform one of the above methods in any other appropriate manner (e.g., by means of firmware).
[0098] The logic and / or steps represented in the flowchart or otherwise described herein may be embodied in any readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from and execute instructions on an instruction execution system, apparatus, or device), or in combination with such instruction execution systems, apparatuses, or devices.
[0099] For the purposes of this specification, a "readable storage medium" may be any device that can contain, store, communicate, propagate or transmit a program for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples of readable storage media (a non-exhaustive list) include the following: an electrical connection with one or more wirings (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and editable read-only memory (EPROM or flash memory), a fiber optic device, and a portable read-only memory (CDROM). In addition, the readable storage medium may even be paper or other suitable medium on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a memory.
[0100] It should be understood that the various parts of the present application can be implemented by hardware, software or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0101] A person skilled in the art may understand that all or part of the steps of implementing the above-mentioned implementation method may be completed by instructing related hardware through a program, and the program may be stored in a readable storage medium, which, when executed, includes one or a combination of the steps of the implementation method.
[0102] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a readable storage medium. The storage medium may be a read-only memory, a disk or an optical disk, etc.
[0103] In the description of this specification, the description with reference to the terms "one embodiment / method", "some embodiments / methods", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment / method or example are included in at least one embodiment / method or example of the present application. In this specification, the schematic representations of the above terms are not necessarily the same embodiment / method or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments / methods or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments / methods or examples described in this specification and the features of the different embodiments / methods or examples, unless they are contradictory.
[0104] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0105] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present application, and are not intended to limit the scope of the present application. For those skilled in the art, other changes or modifications may be made based on the above disclosure, and these changes or modifications are still within the scope of the present application.
Claims
1. A data forwarding proxy method, characterized in that: The method comprises: The network card driver establishes a kernel buffer pool for each network card queue, and establishes a corresponding relationship between the kernel buffer pool, CPU, and application program; After receiving the data message from the network, the network card driver stores the data message in the designated kernel buffer pool space in the kernel buffer pool and reports it to the protocol stack; The protocol stack parses and transmits the data message in the order of the link layer, the network layer, and the transport layer; The protocol stack transmits the specified kernel buffer pool space address to the application program, so that the application program operates the data message pointed to by the kernel buffer pool space address; The application performs at least one operation of adding, modifying or deleting the data message; The application writes the address of the kernel buffer pool space to the kernel and calls the protocol sending function to send the data message; The kernel buffer pool is used to allocate a number of kernel buffer pool structures to store data according to the length of the actual data message, and the kernel buffer pool structures can form a linked list structure, and the address of the memory buffer pool space is represented by the address of the linked list structure.
2. The proxy method according to claim 1, wherein after receiving the data message from the network, the network card driver stores the data message into a designated kernel buffer pool space in the kernel buffer pool, comprising: After receiving the data message, the network card driver receives the data message into the kernel buffer pool space specified by the kernel buffer pool through direct memory access or copying.
3. According to the proxy method of claim 1, the protocol stack parses and transmits the data message in the order of data link layer, network layer and transport layer, including: After parsing the data message in accordance with the data link layer, network layer and transport layer in turn, for the message that needs to be discarded, its corresponding kernel buffer pool structure space is released to the kernel buffer pool to which it belongs, or for the data message that needs to be transmitted to the local, it is placed on the socket's receive queue.
4. The agent method according to claim 3, further comprising: The kernel buffer pool merging and fragment reassembly functions of the protocol stack are both disabled.
5. The agent method according to claim 4, further comprising: The protocol stack notifies the opposite end to send a non-fragmented data message through an ICMP message.
6. The proxy method according to claim 1, wherein the application performs at least one of adding, modifying or deleting the data message, comprising: When the application performs an operation of adding data, a new kernel buffer pool structure is allocated from the kernel buffer pool and added to the kernel buffer pool linked list; When the application deletes data, the kernel buffer pool structure corresponding to the data is deleted; When the application modifies data, if the length of the modified data is greater than the maximum length of the TCP message, a new kernel buffer pool structure is allocated to store the data that exceeds the maximum length of the TCP message.
7. The proxy method according to claim 4, wherein when the application performs a data deletion operation, the kernel buffer pool structure corresponding to the data is deleted, comprising: The kernel buffer pool structure corresponding to the data is deleted through a system call method, and the kernel buffer pool structure corresponding to the data is released to the kernel buffer pool to which it belongs.
8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores executable instructions, and when the executable instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data forwarding proxy method according to any one of claims 1 to 7 is implemented.
10. A computer program product, characterized in that The computer program product includes a computer program, and when the computer program is executed, the computer is enabled to execute the data forwarding agent method according to any one of claims 1 to 7.
Citation Information
Patent Citations
A transmission method for zero copy network packet
CN101150487A
Method and device for data transmission between protocol stack and application program
CN103905420A
Data communication method and system
CN110391999A
Data processing method and system
CN116781650A
Data transmission method and device, equipment and storage medium
CN117215978A