Efficient UDP (User Datagram Protocol) data receiving method
Through the built-in protocol stack, the user space and network card space interface is established, the UDP data is mapped to the link layer, and the data is distributed using the data blockchain table buffer, which solves the problem of low data processing efficiency caused by hardware platform restrictions in the existing technology, and realizes the implementation of the low data processing efficiency Efficient UDP data reception and processing.
Patent Information
- Application Number
- CN202411487633.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-24
AI Technical Summary
When processing high-bit rate data, the limitations of hardware platforms lead to low data processing efficiency, especially on platforms such as smart TVs that do not support virtual network cards, data copying and protocol stack processing increase CPU and memory usage. Causes response delay and application instability.
Through the built-in protocol stack, the UDP data in the user space is mapped to the link layer of the network card space, and the buffer of the same size of the data blockchain list is used to distribute UDP data, and the UDP data is distributed. Pass it directly to the application layer to avoid intermediate protocol stack processing.
It reduces memory bandwidth and CPU usage, reduces the overhead of data copying and protocol stack processing, improves data processing efficiency, and is suitable for various hardware platforms, especially smart TVs and other devices that do not support virtual network cards.
Smart Images

Figure CN119450115A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data receiving, and in particular to an efficient UDP data receiving method. Background Art
[0002] As 4K live broadcast and on-demand services become more and more popular, the transmission bandwidth is getting higher and higher, and the amount of data processed is getting larger and larger. In particular, some operators have also started pilot promotion of 8K live broadcast services, which puts forward higher requirements for high-bitrate data processing performance. How to achieve high-speed data processing based on current hardware capabilities and reduce the requirements for hardware platforms is a problem that must be faced.
[0003] On some Linux systems, user space memory is mapped to the memory space of the network card driver to implement a similar data receiving solution. The shortcomings of the existing technology are mainly from the perspective of data receiving method:
[0004] 1. The virtual network card technology that comes with the operating system is only supported by most Linux platforms, and some platforms without tailoring functions do not even support it;
[0005] 2. Although data reception can be achieved through a virtual network card on the Linux system, there is no similar operation permission on the Android system;
[0006] 3. Smart TVs have operating systems provided by various manufacturers, and basically do not support external virtual network card access, which is not universal. However, the proportion of smart TVs is increasing.
[0007] In terms of data processing:
[0008] 1. Currently, mainstream data reception is to build UDP sockets. To receive data from the network card, the data needs to go from the link layer to the application layer. The intermediate data needs to be processed by the protocol stack. The message header is stripped layer by layer from the initial Ethernet frame, and finally the effective load is filled into the memory space of the socket, waiting for the application to access it. In the middle, there are multiple data copies and message processing, which consume memory and CPU time slices. Especially for high-speed data processing, the memory bandwidth and CPU share will be greatly increased. For many hardware platforms with low performance, high-speed data services are basically impossible;
[0009] 2. The large amount of CPU and memory occupied also squeezes the normal operation of other applications, causing delays in user operation responses and even causing unstable application operation. Summary of the invention
[0010] The present invention provides an efficient UDP data receiving method to solve the problems raised in the background technology.
[0011] An efficient UDP data receiving method, comprising:
[0012] S1: Establish access permissions between the user space interface and the network card space interface through its own protocol stack;
[0013] S2: Based on the access rights, map the UDP data in the user space to the link layer in the network card space;
[0014] S3: Distributing UDP data using a buffer in the form of a linked list of data blocks of the same size at the link layer;
[0015] S4: Deliver the UDP data according to the distribution of the UDP data and deliver it to the application layer.
[0016] Preferably, before S1, the method further includes:
[0017] Parsing the built-in protocol stack to obtain multiple protocol layers, and obtaining the protocol function of each protocol layer;
[0018] Determine configuration parameters for each protocol layer based on the protocol function, and optimize the configuration parameters based on the relationship between the protocol layers to obtain target configuration parameters;
[0019] Based on the target configuration parameters, the native protocol stack is added to the UDP data receiving platform.
[0020] Preferably, in S1, establishing access rights between the user space interface and the network card space interface through the built-in protocol stack includes:
[0021] A user model is established based on the user space interface, a storage space model is established based on the network card space interface, and a dedicated language for access rights is established based on the user model and the storage space model;
[0022] Based on the access permission-specific language, create protocol permissions corresponding to the built-in protocol stack;
[0023] Based on the protocol permissions, access permissions are established between the user space interface and the network card space interface.
[0024] Preferably, in S2, based on the access permission, mapping the UDP data in the user space to the link layer of the network card space includes:
[0025] Acquire a first memory heap in the user space, acquire a second memory heap in the network card space, match the first memory heap with the second memory heap, and obtain a memory heap matching relationship;
[0026] Based on the memory heap matching relationship, access information is established, and the UDP data in the user space is mapped to the link layer of the network card space through the access permission according to the access information.
[0027] Preferably, in S3, distributing UDP data using a buffer in a data block linked list manner of consistent size at the link layer includes:
[0028] Configure the maximum transmission unit and 20 bytes for each data block, and form a data block linked list with all configured data blocks;
[0029] Divide the UDP data of the link layer mapped to the network card space into multiple Ethernet frames according to the transmission amount of the maximum transmission unit, and match the Ethernet frames to the data blocks in the data block linked list in sequence;
[0030] After receiving the Ethernet frame, the data block identifies the data block length, valid data length and data offset in the block in sequence in the last 8 bytes of the data block based on the data content of the Ethernet frame;
[0031] After the data block completes data distribution, the data block is returned to the data block linked list for data distribution of the new Ethernet frame.
[0032] Preferably, in S4, the UDP data is transmitted according to the distribution of the UDP data and transmitted to the application layer, including:
[0033] According to the distribution of UDP data, set the buffer circulation strategy;
[0034] According to the loop strategy, the UDP data at the link layer is sequentially delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
[0035] Preferably, the buffer circulation strategy is set according to the distribution of UDP data, including:
[0036] Obtain an initial data block queue corresponding to the distribution of UDP data, and obtain a first queue position and a tail queue position of the initial data block queue;
[0037] Obtaining the first data block at the first queue position, and obtaining the UDP header of the first data block, and determining whether the data in the first data block is unicast or multicast data based on the UDP header;
[0038] If yes, the first data block is transferred to the user processing data list to wait for processing, and after the first data block completes the user data processing task, the first data block is recirculated to the tail queue position of the buffer, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged again, processed and circulated;
[0039] Otherwise, the first data block is recirculated to the tail queue position of the buffer through the built-in protocol stack, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged, processed and circulated again.
[0040] Preferably, the UDP data at the link layer is sequentially transferred to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer according to the cyclic strategy, including:
[0041] Obtaining data processing tasks of UDP data at the network layer, transport layer, session layer, presentation layer and application layer, and determining the UDP data processing operation at each layer based on the data processing tasks and according to the loop strategy;
[0042] The UDP data processing operations of each layer are sequentially organized into an operation sequence, and according to the operation sequence, the UDP data at the link layer is successively delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
[0043] Preferably, the method further includes: obtaining data access requirements, and accessing and displaying UDP data based on the data access requirements, specifically:
[0044] Based on the data access requirements and in combination with access rights, determine interface information that meets the requirements, and establish association information between the interface information;
[0045] Based on the association information, determine the interface mapping characteristics of the UDP data, and establish an access mapping path for the UDP data according to the interface mapping characteristics;
[0046] Mapping the UDP data to the access network card space based on the access mapping path;
[0047] Obtaining data display requirements from the data access requirements, and determining the data volume and data processing characteristics of data transmission based on the data display requirements;
[0048] Based on the data volume and data processing characteristics, design the transmission rules between the adjacent layers of the network layer, transport layer, session layer, presentation layer and application layer;
[0049] Based on the transfer rule, determining specific strategy parameters in the buffer's circulation strategy to obtain a target circulation strategy;
[0050] The UDP data is transmitted according to the target loop strategy, and the UDP data is displayed according to the transmission result.
[0051] Preferably, based on the transfer rule, determining specific strategy parameters in the buffer's circulation strategy to obtain a target circulation strategy includes:
[0052] Acquire data mapping features and data processing task information at each layer, protocol stack information and data transfer mapping information from the transfer rule;
[0053] Determine task processing parameters in a loop strategy based on the data processing task information, determine protocol stack parameters in a loop strategy based on the protocol stack information, and determine mapping parameters in a loop strategy based on the data transfer mapping information;
[0054] A target cycle strategy is obtained based on the task processing parameters, protocol stack parameters and mapping parameters.
[0055] Compared with the prior art, the present invention has achieved the following beneficial effects:
[0056] Through the built-in protocol stack, access rights between the user space interface and the network card space interface are established. When the built-in protocol stack is used, it has a universal adaptability principle and is not limited by the Android system. It is particularly suitable for USB network cards. For the access rights, UDP data in the user space is mapped to the link layer of the network card space. The link layer and the application layer share memory. The link layer data uses the memory space pre-allocated by the application layer during the filling process, avoiding the process of copying the driver data to the kernel space after reading, and then copying it from the kernel space to the link layer again. At the same time, it also avoids the socket buffer memory copy from the link layer to the user space, reducing the memory bandwidth occupancy. In the link layer, a buffer in the form of a data block linked list of the same size is used to distribute UDP data. The UDP data is transmitted according to the distribution of the UDP data and transmitted to the application layer. When the shared memory block is constructed, data description information is filled. In the process of data transmission, the description information can be directly used to access the data. At the same time, the use of the circular buffer also improves the memory usage efficiency and reduces the additional memory overhead. The data directly reaches the application layer from the link layer without going through the layer-by-layer message processing of the protocol stack in the middle, reducing the processing burden of the protocol stack and reducing the CPU occupancy.
[0057] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in this application document.
[0058] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0060] Figure 1 This is a flow chart of an efficient UDP data receiving method in an embodiment of the present invention;
[0061] Figure 2 A hierarchical diagram of data transmission of UDP data in the network card space interface according to an embodiment of the present invention;
[0062] Figure 3 4 is a structural diagram of a buffer in an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0064] Embodiment 1:
[0065] The embodiment of the present invention provides an efficient UDP data receiving method, such as Figure 1 As shown, including:
[0066] S1: Establish access permissions between the user space interface and the network card space interface through its own protocol stack;
[0067] S2: Based on the access rights, map the UDP data in the user space to the link layer in the network card space;
[0068] S3: Distributing UDP data using a buffer in the form of a linked list of data blocks of the same size at the link layer;
[0069] S4: Deliver the UDP data according to the distribution of the UDP data and deliver it to the application layer.
[0070] In this embodiment, it has its own protocol stack, supports protocols such as DNS, ARP, ICMP, IGMP, supports HTTP transmission, and supports user memory mapping to link layer reading and writing to solve the differences in each system and access rights issues.
[0071] In this embodiment, if Figure 2 As shown in the figure, UDP data is transmitted in the network card space interface, from the link layer through the network layer, transport layer, session layer, presentation layer and application layer.
[0072] In this embodiment, the structure of the buffer is as follows Figure 3 As shown, each data block Ethernet frame data is transmitted cyclically.
[0073] In this embodiment, the buffer for receiving data adopts a linked list of data blocks of the same size to fill the waiting filling queue. The space allocated to each data block during design is the maximum MTU+20 bytes (to facilitate expansion and reserve block record information). When a complete Ethernet frame is received, it is called back to the user space. When it is passed to the application, it is only necessary to mark the length of the memory block and the valid data length and the data offset in the last 8 bytes of each memory block in turn, so that the application can accurately locate the valid data position and the valid data length, which is convenient for the application to access the data and can reuse this memory. When the user finishes processing the data, the memory block can be returned to the waiting filling data queue, thereby completing the cyclic reception and distribution of data while reducing data copying.
[0074] In this embodiment, because only the head and tail nodes of the queue need to be processed during the data processing process, the use of spin locks can reduce blocking. At the same time, because the data is not passed through the protocol stack to the application layer, the data interaction is completed directly through the circular buffer, which greatly reduces the processing overhead of the protocol stack and reduces CPU occupancy. Because memory copies are reduced, limited memory bandwidth can also be utilized.
[0075] The beneficial effects of the above design scheme are as follows: through the built-in protocol stack, the access rights between the user space interface and the network card space interface are established. When the built-in protocol stack is used, it has a universal adaptability principle and is not limited by the Android system. It is particularly suitable for USB network cards. For the access rights, the UDP data in the user space is mapped to the link layer of the network card space. The link layer and the application layer share memory. The link layer data uses the memory space pre-allocated by the application layer during the filling process, avoiding the process of copying the driver data to the kernel space after reading and then copying it from the kernel space to the link layer again. At the same time, it also avoids the socket buffer memory copy from the link layer to the user space, reducing the memory bandwidth occupancy. In the link layer, a buffer in the form of a data block linked list of the same size is used to distribute UDP data. The UDP data is transmitted according to the distribution of the UDP data and transmitted to the application layer. When the shared memory block is constructed, the data description information is filled. In the data transmission process, the description information can be directly used to access the data. At the same time, the use of the circular buffer also improves the memory usage efficiency and reduces the additional memory overhead. The data directly reaches the application layer from the link layer without the layer-by-layer message processing of the protocol stack in the middle, reducing the processing burden of the protocol stack and reducing the CPU occupancy.
[0076] Embodiment 2:
[0077] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method, before S1, further comprising:
[0078] Parsing the built-in protocol stack to obtain multiple protocol layers, and obtaining the protocol function of each protocol layer;
[0079] Determine configuration parameters for each protocol layer based on the protocol function, and optimize the configuration parameters based on the relationship between the protocol layers to obtain target configuration parameters;
[0080] Based on the target configuration parameters, the native protocol stack is added to the UDP data receiving platform.
[0081] The beneficial effects of the above design scheme are: by parsing the built-in protocol stack, multiple protocol layers are obtained, and the protocol function of each protocol layer is obtained, based on the protocol function, the configuration parameters of each protocol layer are determined, based on the relationship between the protocol layers, the configuration parameters are optimized to obtain the target configuration parameters, based on the target configuration parameters, the built-in protocol stack is added to the UDP data receiving platform, supporting user memory mapping to link layer reading and writing to solve the differences in their respective systems and access rights issues.
[0082] Embodiment 3:
[0083] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method. In S1, access rights between the user space interface and the network card space interface are established through a built-in protocol stack, including:
[0084] A user model is established based on the user space interface, a storage space model is established based on the network card space interface, and a dedicated language for access rights is established based on the user model and the storage space model;
[0085] Based on the access permission-specific language, create protocol permissions corresponding to the built-in protocol stack;
[0086] Based on the protocol permissions, access permissions are established between the user space interface and the network card space interface.
[0087] The beneficial effects of the above design scheme are: by establishing a user model based on the user space interface, establishing a storage space model based on the network card space interface, and establishing a dedicated language for access rights based on the user model and the storage space model. Based on the dedicated language for access rights, protocol rights corresponding to the built-in protocol stack are created, and based on the protocol rights, access rights between the user space interface and the network card space interface are established, so as to realize direct mapping of the user space memory to the network card layer link data reception to reduce data copying.
[0088] Embodiment 4:
[0089] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method, wherein in S2, based on the access permission, the UDP data in the user space is mapped to the link layer of the network card space, including:
[0090] Acquire a first memory heap in the user space, acquire a second memory heap in the network card space, match the first memory heap with the second memory heap, and obtain a memory heap matching relationship;
[0091] Based on the memory heap matching relationship, access information is established, and the UDP data in the user space is mapped to the link layer of the network card space through the access permission according to the access information.
[0092] The beneficial effect of the above design scheme is: based on the memory heap matching relationship, access information is established, and the UDP data in the user space is mapped to the link layer of the network card space according to the access information through the access rights, thereby directly mapping the user space memory to the network card layer link data reception to reduce data copying.
[0093] Embodiment 5:
[0094] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method, wherein in S3, a buffer in a data block linked list manner of a consistent size is used at the link layer to distribute UDP data, including:
[0095] Configure the maximum transmission unit and 20 bytes for each data block, and form a data block linked list with all configured data blocks;
[0096] Divide the UDP data of the link layer mapped to the network card space into multiple Ethernet frames according to the transmission amount of the maximum transmission unit, and match the Ethernet frames to the data blocks in the data block linked list in sequence;
[0097] After receiving the Ethernet frame, the data block identifies the data block length, valid data length and data offset in the block in sequence in the last 8 bytes of the data block based on the data content of the Ethernet frame;
[0098] After the data block completes data distribution, the data block is returned to the data block linked list for data distribution of the new Ethernet frame.
[0099] The beneficial effect of the above design scheme is: by configuring the maximum transmission unit and 20 bytes for each data block, all the configured data blocks are formed into a data block linked list, the UDP data of the link layer mapped to the network card space is divided into multiple Ethernet frames according to the transmission amount of the maximum transmission unit, and the Ethernet frames are matched to the data blocks in the data block linked list in sequence. After the data block receives the Ethernet frame, the data block length, the valid data length and the data offset within the block are sequentially identified in the last 8 bytes of the data block based on the data content of the Ethernet frame. After the data block completes data distribution, the data block is returned to the data block linked list for data distribution of the new Ethernet frame, which allows the application to accurately locate the valid data position and the valid data length, facilitates the application to access the data, and can reuse this memory. After the user completes the data processing, the memory block can be returned to the waiting data queue, thereby completing the cyclic reception and distribution of data while reducing data copying.
[0100] Embodiment 6:
[0101] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method, wherein in S4, the UDP data is transmitted according to the distribution of the UDP data and transmitted to the application layer, including:
[0102] According to the distribution of UDP data, set the buffer circulation strategy;
[0103] According to the loop strategy, the UDP data at the link layer is sequentially delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
[0104] The beneficial effect of the above design scheme is as follows: by setting the buffer's loop strategy according to the distribution of UDP data, according to the loop strategy, the UDP data at the link layer is sequentially transmitted to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer. Because only the head and tail nodes of the queue need to be processed during the data processing process, the use of spin locks can reduce blocking. At the same time, because the data is not transmitted to the application layer through the protocol stack, the data interaction is completed directly through the loop buffer, which greatly reduces the processing overhead of the protocol stack, reduces the CPU occupancy, and also reduces the memory copy, so that the limited memory bandwidth can be utilized.
[0105] Embodiment 7:
[0106] Based on Example 6, the embodiment of the present invention provides an efficient UDP data receiving method, wherein the buffer circulation strategy is set according to the distribution of UDP data, including:
[0107] Obtain an initial data block queue corresponding to the distribution of UDP data, and obtain a first queue position and a tail queue position of the initial data block queue;
[0108] Obtaining the first data block at the first queue position, and obtaining the UDP header of the first data block, and determining whether the data in the first data block is unicast or multicast data based on the UDP header;
[0109] If yes, the first data block is transferred to the user processing data list to wait for processing, and after the first data block completes the user data processing task, the first data block is recirculated to the tail queue position of the buffer, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged again, processed and circulated;
[0110] Otherwise, the first data block is recirculated to the tail queue position of the buffer through the built-in protocol stack, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged, processed and circulated again.
[0111] The beneficial effect of the above design is that during the data processing process, only the head and tail nodes of the queue need to be processed, and the use of spin locks can reduce blocking. At the same time, because the data is not passed through the protocol stack to the application layer, the data interaction is completed directly through the circular buffer, which greatly reduces the processing overhead of the protocol stack and reduces CPU occupancy. Because memory copies are reduced, limited memory bandwidth can also be utilized.
[0112] Embodiment 8:
[0113] Based on Example 6, the embodiment of the present invention provides an efficient UDP data receiving method, wherein according to the cyclic strategy, the UDP data at the link layer is sequentially transmitted to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer, including:
[0114] Obtaining data processing tasks of UDP data at the network layer, transport layer, session layer, presentation layer and application layer, and determining the UDP data processing operation at each layer based on the data processing tasks and according to the loop strategy;
[0115] The UDP data processing operations of each layer are sequentially organized into an operation sequence, and according to the operation sequence, the UDP data at the link layer is successively delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
[0116] The beneficial effects of the above design are: the link layer data access mechanism is completed based on the data access of the virtual network card and the built-in protocol stack, the data is processed cyclically in a shared memory manner, and the detected target data is not processed by the protocol stack, and the data load is sent directly from the link layer to the application layer for processing.
[0117] Embodiment 9:
[0118] Based on Example 1, the embodiment of the present invention provides an efficient UDP data receiving method, further comprising: obtaining data access requirements, and accessing and displaying UDP data based on the data access requirements, specifically:
[0119] Based on the data access requirements and in combination with access rights, determine interface information that meets the requirements, and establish association information between the interface information;
[0120] Based on the association information, determine the interface mapping characteristics of the UDP data, and establish an access mapping path for the UDP data according to the interface mapping characteristics;
[0121] Mapping the UDP data to the access network card space based on the access mapping path;
[0122] Obtaining data display requirements from the data access requirements, and determining the data volume and data processing characteristics of data transmission based on the data display requirements;
[0123] Based on the data volume and data processing characteristics, design the transmission rules between the adjacent layers of the network layer, transport layer, session layer, presentation layer and application layer;
[0124] Based on the transfer rule, determining specific strategy parameters in the buffer's circulation strategy to obtain a target circulation strategy;
[0125] The UDP data is transmitted according to the target loop strategy, and the UDP data is displayed according to the transmission result.
[0126] The beneficial effect of the above design scheme is: by further determining the specific parameter settings in the data reception, transmission and display process based on the data access requirements, the target cycle strategy is obtained, the UDP data is transmitted according to the target cycle strategy, and the display result of the UDP data is based on the transmission result, so as to ensure the efficiency and accuracy of data reception and display.
[0127] Embodiment 10:
[0128] Based on Example 9, the embodiment of the present invention provides an efficient UDP data receiving method, which determines the specific policy parameters in the buffer's loop policy based on the transmission rule to obtain a target loop policy, including:
[0129] Acquire data mapping features and data processing task information at each layer, protocol stack information and data transfer mapping information from the transfer rule;
[0130] Determine task processing parameters in a loop strategy based on the data processing task information, determine protocol stack parameters in a loop strategy based on the protocol stack information, and determine mapping parameters in a loop strategy based on the data transfer mapping information;
[0131] A target cycle strategy is obtained based on the task processing parameters, protocol stack parameters and mapping parameters.
[0132] The beneficial effect of the above design scheme is: by further determining the specific parameter settings in the data reception, transmission and display process based on the data access requirements, the target cycle strategy is obtained, the UDP data is transmitted according to the target cycle strategy, and the display result of the UDP data is based on the transmission result, so as to ensure the efficiency and accuracy of data reception and display.
[0133] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention belong to the scope of this application document and its equivalent technology, the present invention is also intended to include these changes and variations.
Claims
1. An efficient UDP data receiving method, characterized in that: include: S1: Establish access permissions between the user space interface and the network card space interface through its own protocol stack; S2: Based on the access rights, map the UDP data in the user space to the link layer in the network card space; S3: at the link layer, a buffer in the form of a linked list of data blocks of the same size is used to distribute UDP data; S4: Deliver the UDP data according to the distribution of the UDP data and deliver it to the application layer.
2. An efficient UDP data receiving method according to claim 1, characterized in that: Before S1, it also includes: Parsing the built-in protocol stack to obtain multiple protocol layers, and obtaining the protocol function of each protocol layer; Determine configuration parameters for each protocol layer based on the protocol function, and optimize the configuration parameters based on the relationship between the protocol layers to obtain target configuration parameters; Based on the target configuration parameters, the native protocol stack is added to the UDP data receiving platform.
3. An efficient UDP data receiving method according to claim 1, characterized in that: In S1, the access rights between the user space interface and the network card space interface are established through the built-in protocol stack, including: Establish a user model based on the user space interface, establish a storage space model based on the network card space interface, and establish a dedicated language for access rights based on the user model and the storage space model; Based on the access permission-specific language, create protocol permissions corresponding to the built-in protocol stack; Based on the protocol permissions, access permissions are established between the user space interface and the network card space interface.
4. The efficient UDP data receiving method according to claim 1, characterized in that: In S2, based on the access permission, mapping the UDP data in the user space to the link layer of the network card space includes: Acquire a first memory heap in the user space, acquire a second memory heap in the network card space, match the first memory heap with the second memory heap, and obtain a memory heap matching relationship; Based on the memory heap matching relationship, access information is established, and the UDP data in the user space is mapped to the link layer of the network card space through the access permission according to the access information.
5. The efficient UDP data receiving method according to claim 1, characterized in that: In S3, the link layer uses a buffer in a data block linked list manner with the same size to distribute UDP data, including: Configure the maximum transmission unit and 20 bytes for each data block, and form a data block linked list with all configured data blocks; Divide the UDP data of the link layer mapped to the network card space into multiple Ethernet frames according to the transmission amount of the maximum transmission unit, and match the Ethernet frames to the data blocks in the data block linked list in sequence; After receiving the Ethernet frame, the data block identifies the data block length, valid data length and data offset in the block in sequence in the last 8 bytes of the data block based on the data content of the Ethernet frame; After the data block completes data distribution, the data block is returned to the data block linked list for data distribution of the new Ethernet frame.
6. The efficient UDP data receiving method according to claim 1, characterized in that: In S4, the UDP data is transmitted according to the distribution of the UDP data and transmitted to the application layer, including: According to the distribution of UDP data, set the buffer circulation strategy; According to the loop strategy, the UDP data at the link layer is sequentially delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
7. An efficient UDP data receiving method according to claim 6, characterized in that: The buffer circulation strategy is set according to the distribution of UDP data, including: Obtain an initial data block queue corresponding to the distribution of UDP data, and obtain a first queue position and a tail queue position of the initial data block queue; Obtaining the first data block at the first queue position, and obtaining the UDP header of the first data block, and determining whether the data in the first data block is unicast or multicast data based on the UDP header; If yes, the first data block is transferred to the user processing data list to wait for processing, and after the first data block completes the user data processing task, the first data block is recirculated to the tail queue position of the buffer, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged again, processed and circulated; Otherwise, the first data block is recirculated to the tail queue position of the buffer through the built-in protocol stack, the initial data block queue is offset to the first queue position, and the new first data block corresponding to the first queue position is judged, processed and circulated again.
8. An efficient UDP data receiving method according to claim 6, characterized in that: According to the loop strategy, the UDP data at the link layer is sequentially transferred to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer, including: Obtaining data processing tasks of UDP data at the network layer, transport layer, session layer, presentation layer and application layer, and determining the UDP data processing operation at each layer based on the data processing tasks and according to the loop strategy; The UDP data processing operations of each layer are sequentially organized into an operation sequence, and according to the operation sequence, the UDP data at the link layer is successively delivered to the network layer, the transport layer, the session layer, the presentation layer, and finally to the application layer.
9. An efficient UDP data receiving method according to claim 1, characterized in that: Also includes: Obtain data access requirements, and access and display UDP data based on the data access requirements, specifically: Based on the data access requirements and in combination with access rights, determine interface information that meets the requirements, and establish association information between the interface information; Based on the association information, determine the interface mapping characteristics of the UDP data, and establish an access mapping path for the UDP data according to the interface mapping characteristics; Mapping the UDP data to the access network card space based on the access mapping path; Obtaining data display requirements from the data access requirements, and determining the amount of data to be transferred and data processing characteristics based on the data display requirements; Based on the data volume and data processing characteristics, design the transmission rules between adjacent layers of the network layer, transport layer, session layer, presentation layer and application layer; Based on the transfer rule, determining specific strategy parameters in the buffer's circulation strategy to obtain a target circulation strategy; The UDP data is transmitted according to the target loop strategy, and the UDP data is displayed according to the transmission result.
10. An efficient UDP data receiving method according to claim 9, characterized in that: Based on the transfer rule, specific policy parameters in the buffer circulation strategy are determined to obtain a target circulation strategy, including: Acquire data mapping features and data processing task information at each layer, protocol stack information and data transfer mapping information from the transfer rule; Determine task processing parameters in a loop strategy based on the data processing task information, determine protocol stack parameters in a loop strategy based on the protocol stack information, and determine mapping parameters in a loop strategy based on the data transfer mapping information; A target cycle strategy is obtained based on the task processing parameters, protocol stack parameters and mapping parameters.
Citation Information
Patent Citations
UDP data package transmission method
CN101217464A
Zero copy message reception method and system
CN102402487A
Data packet processing method and device and storage medium
CN110855610A
Implementation method and device of lightweight network protocol stack
CN115665267A
Data transmission method and apparatus, network device, and storage medium
WO2022105884A1