CN115988108B - Data packet processing method, system, storage medium and electronic equipment - Google Patents

Data packet processing method, system, storage medium and electronic equipment Download PDF

Info

Publication number
CN115988108B
CN115988108B CN202310266109.9A CN202310266109A CN115988108B CN 115988108 B CN115988108 B CN 115988108B CN 202310266109 A CN202310266109 A CN 202310266109A CN 115988108 B CN115988108 B CN 115988108B
Authority
CN
China
Prior art keywords
data
packet
frame
adjustment
control field
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310266109.9A
Other languages
Chinese (zh)
Other versions
CN115988108A (en
Inventor
刘伟
徐亚明
郭巍
张德闪
张灿
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Inspur Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Electronic Information Industry Co Ltd filed Critical Inspur Electronic Information Industry Co Ltd
Priority to CN202310266109.9A priority Critical patent/CN115988108B/en
Publication of CN115988108A publication Critical patent/CN115988108A/en
Application granted granted Critical
Publication of CN115988108B publication Critical patent/CN115988108B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The application provides a data packet processing method, a system, a storage medium and electronic equipment, and relates to the field of data processing, comprising the following steps: acquiring a network packet and extracting data information in the network packet; filling a control field in the data information, and executing data offset on the network packet to enable the address where the network packet is located to be a byte alignment address, so as to obtain an adjustment data packet; and sending the adjustment data packet to a receiving queue of the host, and informing the host in an interrupt mode so that the host calls an interrupt processing function to process the adjustment data packet. The method and the device realize the data format preprocessing of the service data in the network packet, are convenient for the service data to be directly accessed at the host side, avoid the influence of cache line access difficulty on the access of the service data caused by the confusion of the data format, and improve the access performance of the service data.

Description

Data packet processing method, system, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of data processing, and in particular, to a method, a system, a storage medium, and an electronic device for processing a data packet.
Background
With the rapid development of technologies such as big data, artificial intelligence, cloud services and the like, networks are also developing to high-bandwidth and novel transmission systems, and bandwidths are continuously evolving from 50Gbps to 100Gbps and 400 Gbps. The demands of business applications based on these technologies, which vary from time to time, such as mass computing, mass data storage, virtual machines, containers, etc., place tremendous stress on the CPU of the computing node of the electronic device infrastructure. Conventional network processing flows are not suitable for service processing in such high-bandwidth scenarios, because the performance of the processor is improved slowly due to the gradual failure of moore's law, and the processing capacity is relatively ineffective in coping with the improvement of network bandwidth, which becomes a bottleneck for service data processing.
The current technology can completely offload the protocol stack processing of network packets into the network card through RDMA (Remote Direct Memory Access, remote direct data access). However, RDMA design is itself designed for high performance and low latency, and there is a severe requirement on the network (network does not lose packets), otherwise the performance degradation will be significant; while the upper layer applications need to use new API interfaces.
Disclosure of Invention
The purpose of the application is to provide a data packet processing method, a system, a storage medium and electronic equipment, which enable a reconstructed adjustment data packet to adapt to service access by analyzing and reconstructing a network packet, thereby improving the efficiency of an application program for accessing service data.
In order to solve the above technical problems, the present application provides a data packet processing method, including:
acquiring a network packet and extracting data information in the network packet;
filling a control field in the data information, and executing data offset on the network packet to enable the address where the network packet is located to be a byte alignment address, so as to obtain an adjustment data packet;
and sending the adjustment data packet to a receiving queue of the host, and informing the host in an interrupt mode so that the host calls an interrupt processing function to process the adjustment data packet.
Optionally, acquiring the network packet and extracting the data information in the network packet includes:
acquiring a network packet;
extracting the Ethernet frame type in the network packet;
judging whether the Ethernet frame type is an IPv4 frame or not;
if yes, extracting the total length of the Ethernet frame;
performing frame type judgment on the IPv4 frame:
if the IPv4 frame is a UDP frame, extracting the frame length of the UDP frame;
and if the IPv4 frame is a TCP frame, extracting the segment length and the head length of the TCP frame.
Optionally, before filling the control field in the data information, the method further includes:
calculating and generating a control field;
if the network packet is the UDP frame, calculating and generating a control field according to the frame length of the UDP frame;
if the network packet is the TCP frame, a control field is calculated and generated according to the segment length and the header length of the TCP frame.
Optionally, the method further comprises:
the host registers the interrupt handling function in a driver.
Optionally, the adjusting data packet is sent to a receiving queue of a host, and the host is notified with an interrupt, so that after the host calls an interrupt processing function to process the adjusting data packet, the method further includes:
the host analyzes the adjustment data packet to obtain a control field;
adjusting variables in a preset data structure body according to the control field, and reconstructing the preset data structure body; the preset data structure body is used for upper layer protocol stack processing.
Optionally, before adjusting the variable in the preset data structure according to the control field, the method further includes:
and writing and registering a data processing function, wherein the data processing function is used for analyzing the adjustment data packet and reconstructing the preset data structure body.
Optionally, the reconstructing the preset data structure includes:
correspondingly transmitting the first byte of the adjustment data packet to a buffer head, and simultaneously enabling a head pointer of the preset data structure body to point to the buffer head; the buffer header maintains byte alignment in a memory address;
taking the data and the data tail in the preset data structure body as a data area;
taking the tail end in the preset data structure body as the tail part of a buffer area;
the reconstructed preset data structure body consists of the buffer zone head part, the data zone and the buffer zone tail part.
Optionally, if the adjustment data packet does not need to be executed across cache lines, executing data offset on the network packet, and making an address where the network packet is located be a byte aligned address, the obtaining the adjustment data packet includes:
if the adjustment data packet is less than or equal to 64 bytes, the frame format of the adjustment data packet is a control field+an Ethernet frame; the Ethernet frame comprises Ethernet, IP, a transmission layer frame header and service data;
if the adjustment data packet is greater than 64 bytes, the frame format of the adjustment data packet is the control field + padding field + the ethernet frame.
Optionally, if the adjustment data packet needs to be executed across cache lines, executing data offset on the network packet, and making an address where the network packet is located be a byte aligned address, the obtaining the adjustment data packet includes:
the adjustment data packet includes the control field, the padding field, the ethernet, the IP, the transport layer header, and the service data; wherein the control field, the padding field, the ethernet, the IP, and the transport layer header total 64 bytes or 128 bytes.
Optionally, the service data is aligned according to 61 bytes, and the position of the control field is calculated according to the frame type of the adjustment data packet.
Optionally, calculating the position of the control field according to the frame type of the adjustment data packet includes:
if the frame type of the adjustment data packet is a TCP data packet, the position of the control field is 64×num-6-14-frame length+service data length-header data length;
if the frame type of the adjustment data packet is a UDP data packet, the position of the control field is 64 x num-6-14-frame length+UDP data packet length-8;
wherein num is the sum of the control field and the header data length.
Optionally, filling a control field in the data information, performing data offset on the network packet, so that an address where the network packet is located is a byte alignment address, and after obtaining the adjustment data packet, further including:
adding a data pointer, a tail pointer and a tail pointer to the adjustment data packet; the data pointer points to a header.
The application also provides a data packet processing system, which comprises:
the network packet acquisition module is used for acquiring a network packet and extracting data information in the network packet;
the network packet adjusting module is used for filling a control field in the data information, executing data offset on the network packet, enabling the address where the network packet is located to be a byte alignment address, and obtaining an adjusting data packet;
and the network packet sending module is used for sending the adjustment data packet to a receiving queue of the host and informing the host in an interrupt mode so that the host can call an interrupt processing function to process the adjustment data packet.
The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as described above.
The application also provides an electronic device comprising a memory in which a computer program is stored and a processor which when calling the computer program in the memory implements the steps of the method as described above.
The application provides a data packet processing method, which comprises the following steps: acquiring a network packet and extracting data information in the network packet; filling a control field in the data information, and executing data offset on the network packet to enable the address where the network packet is located to be a byte alignment address, so as to obtain an adjustment data packet; and sending the adjustment data packet to a receiving queue of the host, and informing the host in an interrupt mode so that the host calls an interrupt processing function to process the adjustment data packet.
According to the method and the device, after the network packet is obtained, the data information is extracted from the network packet, so that the control field is filled into the network packet according to the extracted data information, and therefore the data migration is carried out on the network packet, the data format preprocessing of the service data in the network packet is realized, the service data is conveniently and directly accessed at a host side, the problem that the access of the service data is influenced due to the fact that the cache line access is difficult due to the disorder of the data format is avoided, and the access performance of the service data is improved.
The application further provides a data packet processing system, a storage medium and an electronic device, which have the beneficial effects and are not described herein.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings may be obtained according to the provided drawings without inventive effort to a person skilled in the art.
Fig. 1 is a flowchart of a data packet processing method according to an embodiment of the present application;
fig. 2 is a schematic diagram of an ethernet frame structure according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating a reconstruction process of a preset data structure according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an original frame format according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a non-cacheline frame format provided in an embodiment of the present application;
FIG. 6 is a schematic diagram of a frame format for cross-cache line processing according to an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a reconstructed default data structure according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a packet processing system according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The protocol stack processing of network packets can currently be fully offloaded into the network card via RDMA. However, RDMA design is designed for high performance and low delay, and has severe requirements on the network, namely network packet loss is forbidden, otherwise, performance degradation is very large; while the upper layer applications need to use new API interfaces.
In order to solve the technical defects, the method and the device respectively improve the speed of accessing business data by the data copy and the application layer by performing bottom optimization on the network packet in the aspect of memory alignment, and improve the processing performance of the application program in a high-bandwidth scene on the premise of unchanged upper layer interfaces. In this application, the application layer only needs to apply for the memory address aligned with 64 bytes, and no special modification is needed. While using standard network protocols on network transmissions, independent of the particular network.
Referring to fig. 1, fig. 1 is a flowchart of a data packet processing method according to an embodiment of the present application, where the method includes:
s101: acquiring a network packet and extracting data information in the network packet;
the execution body of the embodiments of the present application may be any device or component capable of implementing data processing, including but not limited to an FPGA or other electronic device.
In this step, the network packet is first acquired, and the data information in the network packet is extracted, which is not limited herein as to how to acquire the network packet, but it should be noted that the network packet is mainly the network data packet transmitted to the host. Meanwhile, the data information to be extracted in this step is not limited, and is mainly service data and data formats in network packets, including but not limited to a protocol field in an ethernet frame header, an ip length field, and a length field in tcp/udp. Referring to fig. 2, fig. 2 is a schematic diagram of an ethernet frame structure provided in the embodiment of the present application, and taking the example shown in fig. 2 as an example, header information such as a MAC header, data information such as TCP/UDP data, and the like can be obtained.
In addition, when extracting the data information, different extraction modes can be adopted according to different types of networks. In one possible manner, the process may comprise the steps of:
S1A: acquiring a network packet;
S1B: extracting the Ethernet frame type in the network packet;
S1C: judging whether the Ethernet frame type is an IPv4 frame or not; if yes, entering S1D;
S1D: extracting the total length of the Ethernet frame;
S1E: performing frame type judgment on the IPv4 frame:
if the IPv4 frame is a UDP frame, extracting the frame length of the UDP frame;
and if the IPv4 frame is a TCP frame, extracting the segment length and the head length of the TCP frame.
Taking the FPGA as an execution main body as an example, the FPGA can keep the state of waiting for receiving the packet, can extract the corresponding Ethernet frame type when receiving the network packet, and further extracts the total length of the IP frame and judges the frame type based on the total length of the IP frame if the network packet is an IPv4 frame. If the IPv4 frame is a UDP frame, extracting the frame length of the UDP frame; if the IPv4 frame is a TCP frame, extracting the segment length and the head length of the TCP frame. The corresponding control field may thereafter be calculated for each frame type. If the frame is not an IPv4 frame, the control field may be generated by adopting a calculation mode corresponding to other ethernet frame types, which is not limited herein by way of example.
S102: filling a control field in the data information, and executing data offset on the network packet to enable the address where the network packet is located to be a byte alignment address, so as to obtain an adjustment data packet;
this step requires filling a control field in the network packet, where the control field is used to indicate the offset position, and may also contain other control information.
It will be readily appreciated that the present embodiment defaults to generating the control field prior to performing the step, i.e., filling in the control field. Of course, there may be corresponding differences in the manner in which the control field is calculated for different frame types. For example, if the network packet is a UDP frame, the control field is calculated and generated based on the frame length of the UDP frame. If the network packet is a TCP frame, a control field is calculated and generated according to the segment length and the head length of the TCP frame.
The purpose of performing the data offset is to change the address where the network packet is located to a byte aligned address, thereby obtaining an adjustment data packet. For example, the address where the network packet is located may be changed to a 64 byte aligned address.
S103: and sending the adjustment data packet to a receiving queue of the host, and informing the host in an interrupt mode so that the host calls an interrupt processing function to process the adjustment data packet.
After the adjustment data packet is obtained, the adjustment data packet may be sent to a receiving queue of the host, or the adjustment data packet may be transmitted to a receiving buffer of the host in a Dma transmission manner. Dma transfers are where the Dma controller copies data from one address space to another address space and the handling process does not require processor involvement.
According to the embodiment of the application, after the network packet is obtained, the data information is extracted from the network packet, so that the control field is filled into the network packet according to the extracted data information, and the data migration is carried out on the network packet, so that the data format preprocessing of the service data in the network packet is realized, the service data is conveniently and directly accessed at a host side, the problem that the access of the service data is influenced due to the difficulty in accessing a cache line caused by the disorder of the data format is avoided, and the access performance of the service data is improved.
On the basis of the above embodiment, the host side needs to process the adjustment packet after receiving the adjustment packet. The processing of the data packets may be adjusted in the buffer by an interrupt handling function. For this purpose, the host can register in advance in the drive an interrupt handling function, which is responsible for the preprocessing of the adjustment packets, and can also be used for implementing the construction in the default data structure and the invocation of the default data structure handling function.
The host can analyze the adjustment data packet to obtain a control field, adjust the variable in the preset data structure body according to the control field, and reconstruct the preset data structure body, wherein the preset data structure body is used for upper protocol stack processing in the host.
It is easy to understand that before adjusting the variables in the preset data structure according to the control field, the data processing function may be written and registered first, and the data processing function is used to parse the adjustment data packet and reconstruct the preset data structure.
The method for reconstructing the default data structure is not limited here, but one possible way is as follows:
the first step, correspondingly transmitting a first byte of an adjustment data packet to the head of a buffer area, and simultaneously presetting a head pointer of a data structure body to point to the head of the buffer area; the buffer header maintains byte alignment in the memory address;
secondly, taking data and a data tail in a preset data structure body as a data area;
thirdly, taking the tail end in the preset data structure body as the tail part of the buffer area;
the reconstructed preset data structure body consists of a buffer area head part, a data area and a buffer area tail part.
The purpose of reconstructing the preset data structure body is to make the reconstructed preset data structure body conform to the memory access rule so as to realize the memory alignment processing of the service data. Specifically, referring to fig. 3, fig. 3 is a schematic diagram illustrating a reconstruction process of a preset data structure provided in the embodiment of the present application, in fig. 3, sk_buff is taken as a preset data structure, where sk_buff is a data structure including the most critical and core data in a protocol stack, such as header information, data length, etc. of a received or transmitted data packet, where many member variables may be used by each subsystem in a network code. The user mode protocol stack and the kernel protocol stack have similar structures, and generally, the sk_buff structure is transmitted between the layers of protocols, and is operated by adding a protocol head and moving a pointer instead of copying the sk_buff structure, so that the working efficiency of the CPU is greatly improved. In this embodiment, after parsing the control field, the header data position in the sk_buff structure is readjusted, and the common protocol stack processing flow may be entered after the adjustment.
In fig. 3, the first byte of the adjustment packet is correspondingly transferred to the buffer header, and the memory address where the buffer header is located is typically 4096 bytes aligned. While the head pointer of sk_buff may be made to point to this location fixed. And data and tail, namely data and data tail are correspondingly adjusted to be data areas, and meanwhile, the tail is taken as the tail of a buffer area. Thus, the reconstruction of the preset data structure body can be realized.
In addition, when performing data migration on the network packet, different adjustments may be performed according to whether to perform cross-cache line, and the specific procedure may be as follows:
if the adjustment data packet does not need to be executed across the cache line, executing data offset on the network packet, enabling the address where the network packet is located to be a byte aligned address, and obtaining the adjustment data packet includes:
if the adjustment data packet is less than or equal to 64 bytes, adjusting the frame format of the data packet to be a control field plus an Ethernet frame; the Ethernet frame comprises Ethernet, IP, a transmission layer frame header and service data;
if the adjustment data packet is larger than 64 bytes, the frame format of the adjustment data packet is control field + padding field + ethernet frame.
If the adjustment data packet needs to be executed across cache lines, executing data offset on the network packet, making the address where the network packet is located be a byte aligned address, and obtaining the adjustment data packet includes:
the adjustment data packet includes a control field, a padding field, ethernet, IP, transport layer header, and traffic data. Wherein the control field, padding field, ethernet, IP and transport layer header total 64 bytes or 128 bytes.
Referring to fig. 4 to fig. 6, fig. 4 is a schematic diagram of an original frame format provided by an embodiment of the present application, fig. 5 is a schematic diagram of a non-cacheline frame format provided by an embodiment of the present application, and fig. 6 is a schematic diagram of a cacheline processing frame format provided by an embodiment of the present application;
in fig. 4, the original frame format includes a control field and an ethernet frame. If the header data+network packet frame length is 64 bytes or less, it may adjust the frame format as shown in fig. 4. If the header data + network packet frame size is greater than 64 bytes, then the padding field needs to be included, as shown in fig. 5.
If the cross-cache line processing is required, and the control field+ethernet header+ip header+tcp/UDP header is not greater than 64 bytes, the control field, padding field, ethernet, IP and transport layer header need to be made 64 bytes or 128 bytes in total, so that 1 cache line or 2 cache lines can be occupied.
It should be noted that, the service data is aligned according to 61 bytes, and the position of the control field is calculated according to the frame type of the adjustment data packet, specifically:
if the frame type of the adjustment data packet is a TCP data packet, the position of the control field is 64×num-6-14-frame length+service data length-header data length;
if the frame type of the adjustment data packet is a UDP data packet, the position of the control field is 64 x num-6-14-frame length+UDP data packet length-8;
wherein num is the sum of the control field and the header data length.
On the basis of the above embodiment, as a preferred embodiment, a control field is filled in the data information, and a data offset is performed on the network packet, so that the address where the network packet is located is a byte alignment address, and after an adjustment data packet is obtained, a data pointer, a tail pointer and a tail pointer may be further added to the adjustment data packet; the data pointer points to a header.
Referring to fig. 7, fig. 7 is a schematic diagram of a reconstructed preset data structure provided in an embodiment of the present application, and as can be seen from fig. 7, a data pointer, a tail pointer and a tail pointer are added to point to a header, a data tail and a tail of the reconstructed preset data structure, respectively.
Referring to fig. 8, a description will be given below of a packet processing system according to an embodiment of the present application, and the packet processing system described below and the packet processing method described above may be referred to correspondingly.
The network packet acquisition module is used for acquiring a network packet and extracting data information in the network packet;
the network packet adjusting module is used for filling a control field in the data information, executing data offset on the network packet, enabling the address where the network packet is located to be a byte alignment address, and obtaining an adjusting data packet;
and the network packet sending module is used for sending the adjustment data packet to a receiving queue of the host and informing the host in an interrupt mode so that the host can call an interrupt processing function to process the adjustment data packet.
Based on the foregoing embodiments, as a preferred embodiment, the network packet obtaining module is a module for executing the following steps:
acquiring a network packet;
extracting the Ethernet frame type in the network packet;
judging whether the Ethernet frame type is an IPv4 frame or not;
if yes, extracting the total length of the Ethernet frame;
performing frame type judgment on the IPv4 frame:
if the IPv4 frame is a UDP frame, extracting the frame length of the UDP frame;
and if the IPv4 frame is a TCP frame, extracting the segment length and the head length of the TCP frame.
Based on the above embodiment, as a preferred embodiment, further comprising:
the control field generation module is used for calculating and generating a control field; if the network packet is the UDP frame, calculating and generating a control field according to the frame length of the UDP frame; if the network packet is the TCP frame, a control field is calculated and generated according to the segment length and the header length of the TCP frame.
Based on the above embodiment, as a preferred embodiment, further comprising:
and the first function registration module is applied to the host and used for registering the interrupt processing function in the drive.
Based on the above embodiment, as a preferred embodiment, further comprising:
the data reconstruction module is used for analyzing the adjustment data packet to obtain a control field; adjusting variables in a preset data structure body according to the control field, and reconstructing the preset data structure body; the preset data structure body is used for upper layer protocol stack processing.
Based on the above embodiment, as a preferred embodiment, further comprising:
and the second function registration module is used for writing and registering a data processing function, and the data processing function is used for analyzing the adjustment data packet and reconstructing the preset data structure body.
Based on the above embodiments, as a preferred embodiment, the data reconstruction module includes:
a first reconstruction unit, configured to correspondingly transmit a first byte of the adjustment data packet to a buffer header, and at the same time, the header pointer of the preset data structure points to the buffer header; the buffer header maintains byte alignment in a memory address;
a second reconstruction unit, configured to take the data and the data tail in the preset data structure body as a data area;
a third reconstruction unit, configured to use an end in the preset data structure body as a buffer tail;
the reconstructed preset data structure body consists of the buffer zone head part, the data zone and the buffer zone tail part.
Based on the above embodiments, as a preferred embodiment, if the adjustment packet does not need to be executed across cache lines, the network packet adjustment module is a module for executing the following steps:
if the adjustment data packet is less than or equal to 64 bytes, the frame format of the adjustment data packet is a control field+an Ethernet frame; the Ethernet frame comprises Ethernet, IP, a transmission layer frame header and service data;
if the adjustment data packet is greater than 64 bytes, the frame format of the adjustment data packet is the control field + padding field + the ethernet frame.
Based on the above embodiment, as a preferred embodiment, further comprising:
a control field position calculation module, configured to calculate a position of the control field according to the frame type of the adjustment packet; wherein the service data is aligned in 61 bytes.
Based on the above embodiments, as a preferred embodiment, the control field position calculation module is configured to perform the following steps:
if the frame type of the adjustment data packet is a TCP data packet, the position of the control field is 64×num-6-14-frame length+service data length-header data length;
if the frame type of the adjustment data packet is a UDP data packet, the position of the control field is 64 x num-6-14-frame length+UDP data packet length-8;
wherein num is the sum of the control field and the header data length.
Based on the above embodiment, as a preferred embodiment, further comprising:
the pointer configuration unit is used for adding a data pointer, a tail pointer and a tail pointer to the adjustment data packet; the data pointer points to a header.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed, implements the steps provided by the above embodiments. The storage medium may include: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The application also provides an electronic device, which may include a memory and a processor, where the memory stores a computer program, and the processor may implement the steps provided in the foregoing embodiments when calling the computer program in the memory. Of course the electronic device may also include various network interfaces, power supplies, etc.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. The system provided by the embodiment is relatively simple to describe as it corresponds to the method provided by the embodiment, and the relevant points are referred to in the description of the method section.
Specific examples are set forth herein to illustrate the principles and embodiments of the present application, and the description of the examples above is only intended to assist in understanding the methods of the present application and their core ideas. It should be noted that it would be obvious to those skilled in the art that various improvements and modifications can be made to the present application without departing from the principles of the present application, and such improvements and modifications fall within the scope of the claims of the present application.
It should also be noted that in this specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Claims (15)

1. A method of packet processing, comprising:
acquiring a network packet and extracting data information in the network packet; the data information comprises service data and a data format;
filling a control field in the data information, and executing data offset on the network packet to enable the address where the network packet is located to be a byte alignment address, so as to obtain an adjustment data packet;
and sending the adjustment data packet to a receiving queue of the host, and informing the host in an interrupt mode so that the host calls an interrupt processing function to process the adjustment data packet.
2. The data packet processing method according to claim 1, wherein acquiring a network packet and extracting data information in the network packet comprises:
acquiring a network packet;
extracting the Ethernet frame type in the network packet;
judging whether the Ethernet frame type is an IPv4 frame or not;
if yes, extracting the total length of the Ethernet frame;
performing frame type judgment on the IPv4 frame:
if the IPv4 frame is a UDP frame, extracting the frame length of the UDP frame;
and if the IPv4 frame is a TCP frame, extracting the segment length and the head length of the TCP frame.
3. The data packet processing method according to claim 2, further comprising, before filling a control field in the data information:
calculating and generating the control field;
if the network packet is the UDP frame, calculating and generating the control field according to the frame length of the UDP frame;
and if the network packet is the TCP frame, calculating and generating the control field according to the segment length and the head length of the TCP frame.
4. The method of packet processing according to claim 1, further comprising:
the host registers the interrupt handling function in a driver.
5. The method according to claim 1 or 4, wherein the sending the adjustment packet to a receiving queue of a host and notifying the host with an interrupt so that the host calls an interrupt handling function to process the adjustment packet further comprises:
the host analyzes the adjustment network packet to obtain the control field;
adjusting variables in a preset data structure body according to the control field, and reconstructing the preset data structure body; the preset data structure body is used for upper layer protocol stack processing.
6. The method according to claim 5, further comprising, before adjusting the variable in the preset data structure according to the control field:
and writing and registering a data processing function, wherein the data processing function is used for analyzing the adjustment data packet and reconstructing the preset data structure body.
7. The method of claim 6, wherein reconstructing the predetermined data structure comprises:
correspondingly transmitting the first byte of the adjustment data packet to a buffer head, and simultaneously enabling a head pointer of the preset data structure body to point to the buffer head; the buffer header maintains byte alignment in a memory address;
taking the data and the data tail in the preset data structure body as a data area;
taking the tail end in the preset data structure body as the tail part of a buffer area;
the reconstructed preset data structure body consists of the buffer zone head part, the data zone and the buffer zone tail part.
8. The method of claim 1, wherein if the adjustment packet does not need to be executed across a cache line, performing a data offset on the network packet, and making the address of the network packet be a byte aligned address, obtaining the adjustment packet includes:
if the adjustment data packet is less than or equal to 64 bytes, the frame format of the adjustment data packet is a control field+an Ethernet frame; the Ethernet frame comprises Ethernet, IP, a transmission layer frame header and service data;
if the adjustment data packet is greater than 64 bytes, the frame format of the adjustment data packet is the control field + padding field + the ethernet frame.
9. The method of claim 8, wherein if the adjustment packet needs to be executed across cache lines, the adjustment packet includes the control field, the padding field, the ethernet, the IP, the transport layer header, and the traffic data; wherein the control field, the padding field, the ethernet, the IP, and the transport layer header total 64 bytes or 128 bytes.
10. The data packet processing method according to claim 8 or 9, characterized by further comprising:
calculating the position of the control field according to the frame type of the adjustment data packet; wherein the service data is aligned in 61 bytes.
11. The method of claim 10, wherein calculating the position of the control field based on the frame type of the adjustment packet comprises:
if the frame type of the adjustment data packet is a TCP data packet, the position of the control field is 64×num-6-14- (frame length-service data length) -header data length;
if the frame type of the adjustment data packet is a UDP data packet, the position of the control field is 64 x num-6-14- (frame length-UDP data packet length) -8;
wherein num is the sum of the control field and the header data length.
12. The method of claim 1, wherein filling a control field in the data information, and performing data offset on the network packet to make an address where the network packet is located be a byte aligned address, and further comprising, after obtaining the adjusted data packet:
adding a data pointer, a tail pointer and a tail pointer to the adjustment data packet; the data pointer points to a header.
13. A data packet processing system, comprising:
the network packet acquisition module is used for acquiring a network packet and extracting data information in the network packet; the data information comprises service data and a data format; the network packet adjusting module is used for filling a control field in the data information, executing data offset on the network packet, enabling the address where the network packet is located to be a byte alignment address, and obtaining an adjusting data packet;
and the network packet sending module is used for sending the adjustment data packet to a receiving queue of the host and informing the host in an interrupt mode so that the host can call an interrupt processing function to process the adjustment data packet.
14. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the data packet processing method according to any of claims 1-12.
15. An electronic device comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the steps of the data packet processing method according to any of claims 1-12 when the computer program in the memory is invoked by the processor.
CN202310266109.9A 2023-03-20 2023-03-20 Data packet processing method, system, storage medium and electronic equipment Active CN115988108B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310266109.9A CN115988108B (en) 2023-03-20 2023-03-20 Data packet processing method, system, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310266109.9A CN115988108B (en) 2023-03-20 2023-03-20 Data packet processing method, system, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN115988108A CN115988108A (en) 2023-04-18
CN115988108B true CN115988108B (en) 2023-06-02

Family

ID=85968574

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310266109.9A Active CN115988108B (en) 2023-03-20 2023-03-20 Data packet processing method, system, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115988108B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107483370A (en) * 2017-09-14 2017-12-15 电子科技大学 A kind of method in FC transmission over networks IP and CAN business

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7423975B2 (en) * 2002-03-05 2008-09-09 Broadcom Corporation Method, apparatus and computer program product for performing data packet classification
CN1305276C (en) * 2004-01-15 2007-03-14 中兴通讯股份有限公司 Method and system for immediately processing real time media stream data packets
RU2466506C2 (en) * 2006-12-15 2012-11-10 Телефонактиеболагет Лм Эрикссон (Пабл) IMPROVED MAC-d MULTIPLEXING IN UTRAN HSDPA WIRELESS NETWORKS
CN101247266B (en) * 2008-03-21 2011-05-25 深圳市国人射频通信有限公司 Method for processing data in Ethernet
US9544247B2 (en) * 2013-03-15 2017-01-10 Innovasic, Inc. Packet data traffic management apparatus
CN114189569B (en) * 2020-08-31 2024-03-26 华为技术有限公司 Data transmission method, device and system
CN115529637A (en) * 2021-06-24 2022-12-27 华为技术有限公司 Communication method, communication device and communication system
US20220116325A1 (en) * 2021-12-22 2022-04-14 Intel Corporation Packet format adjustment technologies

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107483370A (en) * 2017-09-14 2017-12-15 电子科技大学 A kind of method in FC transmission over networks IP and CAN business

Also Published As

Publication number Publication date
CN115988108A (en) 2023-04-18

Similar Documents

Publication Publication Date Title
KR100289520B1 (en) Client/server communication system
US10241830B2 (en) Data processing method and a computer using distribution service module
US6594701B1 (en) Credit-based methods and systems for controlling data flow between a sender and a receiver with reduced copying of data
EP1228438B1 (en) System and method for managing connections between clients and a server
US8713180B2 (en) Zero-copy network and file offload for web and application servers
US9264495B2 (en) Apparatus and methods for handling network file operations over a fibre channel network
KR19980703862A (en) Method and apparatus for reducing data using transmission control protocol and computer program product
JP6289092B2 (en) Information processing apparatus, control method thereof, and computer program
US20070263629A1 (en) Techniques to generate network protocol units
WO2023005773A1 (en) Message forwarding method and apparatus based on remote direct data storage, and network card and device
CN108600053B (en) Wireless network data packet capturing method based on zero copy technology
DE112005001364T5 (en) Processing receive log data units
US20110280243A1 (en) TCP/IP Offload Device
CN113064846A (en) Zero-copy data transmission method based on Rsockets protocol
CN102546612A (en) Remote procedure call implementation method based on remote direct memory access (RDMA) protocol in user mode
WO2004017173A2 (en) One shot rdma having a 2-bit state
CN115988108B (en) Data packet processing method, system, storage medium and electronic equipment
CN111404986B (en) Data transmission processing method, device and storage medium
CN111586040B (en) High-performance network data receiving method and system
CN115549858A (en) Data transmission method and device
CN113572575A (en) Self-adaptive data transmission method and system
CN113965433A (en) Method for realizing multi-network aggregation
US20140074897A1 (en) Information processing apparatus, storage medium, and control method
US7729368B2 (en) Network buffer caching
CN112019450A (en) Inter-device streaming communication

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant