A message processing method and system, a special processor and a computer storage medium
By generating a message index table and using the relative address of the message header and the memory address to generate index information, the problem of repeated creation of metadata in traditional network processing chips is solved, achieving more efficient data processing and encapsulation, and improving programmability and portability.
Patent Information
- Application Number
- CN202311687178.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-08
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-12-08
AI Technical Summary
Traditional network processing chips require defining separate metadata structures for each stage when processing network packets, resulting in poor programmability, portability, and flexibility, as well as low performance and space efficiency.
By generating a message index table, index information is generated using the relative address of the message header and the memory address, enabling cross-stage data processing, reducing the repeated creation and modification of metadata, and using the message index table for data acquisition and encapsulation.
It improves the programmability, portability, and flexibility of network processing pipelines, reduces performance overhead, and simplifies metadata management.
Smart Images

Figure CN117544709B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a message processing method, system, special processing, and computer storage medium. Background Technology
[0002] A network processor (NP) is a programmable device specifically designed for various tasks in the communications field, such as packet processing, protocol analysis, route lookup, voice / data aggregation, firewalls, and QoS. Internally, a network processor typically consists of several microcode processors and several hardware coprocessors. Multiple microcode processors operate in parallel within the network processor, with the processing flow controlled by pre-programmed microcode.
[0003] The processing flow is generally divided into three parts: Parser (message parsing stage), Match-Action (message processing stage), and Deparser (message encapsulation stage). The Parser is responsible for parsing the message header, the Match-Action is responsible for matching and processing the data parsed by the Parser, and the Deparser re-serializes and encapsulates the packet metadata into a packet before transmitting it on the output link.
[0004] In traditional implementations, these three stages are handled by different microcode processors. Typically, a data structure, or metadata, needs to be defined for each stage to process the corresponding data between stages and send the processed results to the next stage. Since the specific processing business and the data types served by the network processor are different, the metadata corresponding to each stage is not fixed and needs to be customized and extended according to different application requirements. This results in poor programmability, portability, and flexibility, as well as large space consumption and poor performance. Summary of the Invention
[0005] In view of this, the present disclosure provides a message processing method, system, dedicated processor, and computer storage medium, which can effectively solve the problems of poor programmability, portability, and flexibility caused by the traditional practice of creating metadata separately according to different business needs when network processing chips perform message processing tasks, as well as the low performance and space efficiency caused by multiple creation and destruction.
[0006] The first aspect of this disclosure provides a message processing method for a network processing pipeline in a network processing unit of a dedicated data processor, comprising:
[0007] The corresponding header index information is generated based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space. The relative address includes the offset address of the first and second parts of the corresponding packet header or the physical memory address of the corresponding packet header in the first storage space.
[0008] The message index table is obtained from the second storage space. The message header is obtained from the first storage space according to the message header index information in the message index table. The obtained message header is processed using the existing processing mechanism. When the processing involves modifying the relative address of the message header, the index information of the message header in the message index table is modified synchronously.
[0009] The modified message index table is obtained from the second storage space, and the message header is obtained from the first storage space and encapsulated according to the message header index information in the message index table.
[0010] In some embodiments of this disclosure, the index information of the message header includes the memory offset address and offset of the message header in the first storage space, and the message index table includes a message information array segment;
[0011] The step of generating a message index table based on the index information and saving it to the second storage space includes:
[0012] Add the memory offset address and offset of the message header in the first storage space as an element of the message information array segment to the message index table;
[0013] The step of retrieving the message header from the first storage space based on the message header index information in the message index table includes:
[0014] Iterate through each element in the message information array segment, and obtain the memory offset address and offset of the corresponding message header in the first storage space from each element. Based on the memory offset address and offset of the message header in the first storage space, obtain the message header corresponding to each message header from the first storage space.
[0015] In some embodiments of this disclosure, the message index table includes a global information segment, which includes a message length information field, a message header length information field, and a message payload offset address field.
[0016] The step of generating the corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space includes:
[0017] Calculate the data length of all message headers and the message length; write the message header length into the message header length information field; and write the message length into the message length information field; and
[0018] Write the relative address of the data portion corresponding to the message in the first storage space into the load offset address field;
[0019] The step of obtaining the modified message index table from the second storage space and retrieving the message header from the first storage space for encapsulation based on the message header index information in the message index table includes:
[0020] The length of the message payload is calculated based on the data length of the message header and the message length; the payload data of the message is obtained based on the relative address in the payload offset address field and the length of the message payload; and
[0021] The message header is obtained based on the memory offset address and offset of the message header in the first storage space from the message header index information;
[0022] The message is repackaged into a new message based on the message payload data and the message header.
[0023] In some embodiments of this disclosure, the message index table includes a message header extension offset field;
[0024] The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes:
[0025] If a new header is added during the processing of the header, the new header is stored at the end of the header storage area corresponding to the first storage space, and the relative address of the new header data in the first storage space is written into the header extended offset address field.
[0026] In some embodiments of this disclosure, the message index table further includes a message header flag field, which corresponds one-to-one with the message header;
[0027] Generate corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space, including:
[0028] When generating the index information of the corresponding message header, the flag field of the message header is set to a first predetermined value;
[0029] The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes:
[0030] When processing the packet header, the packet header flag field corresponding to the packet header that is not used in subsequent processing stages of the network processing pipeline is set to a second predetermined value to indicate that the packet header does not need to be used; and / or
[0031] Set the header flag field corresponding to the header used in the subsequent processing stage of the network processing pipeline from the second predetermined value to the first predetermined value;
[0032] The modified message index table is retrieved from the second storage space, and the message header is retrieved from the first storage space and encapsulated according to the message header index information in the message index table, including:
[0033] Before retrieving the index information of the corresponding message header from the message index table, it is first determined whether the value of the message header flag field corresponding to the message header is a first predetermined value. If the value of the flag field is the first predetermined value, the index information of the message header is retrieved. If the value of the flag field is not the first predetermined value, the message header is skipped and encapsulation processing of subsequent message headers is performed.
[0034] In some embodiments of this disclosure, generating a message index table based on the index information and saving it to a second storage space includes:
[0035] Obtain a preset message header information configuration table, generate a message index table based on the message header information in the message header information configuration table, and fill the corresponding index information into the message index table in the order of the message header information configuration table according to the message headers defined in the message index table.
[0036] In some embodiments of this disclosure, generating a message index table based on the index information and saving it to a second storage space further includes:
[0037] Generate a header flag field with corresponding bit length based on the number and order of headers in the preset header information configuration table;
[0038] If the corresponding message header is used in a subsequent processing stage of the network processing pipeline, the position corresponding to the same order of the message header flag segment is set to a first predetermined value according to the order of the message header in the message header information configuration table; otherwise, it is set to a second predetermined value.
[0039] A second aspect of this disclosure also proposes a message processing system for a network processing pipeline in a network processing unit of a dedicated data processor, the pipeline including a message parsing stage, a message processing stage, and a message encapsulation stage, comprising:
[0040] The message parsing module is used to generate corresponding message header index information based on the relative address of the message header parsed by the network processing unit and stored in the first storage space, wherein the relative address includes the offset address of the first and second parts of the corresponding message header or the physical memory address of the corresponding message header in the first storage space.
[0041] The message processing module is used to obtain the message index table from the second storage space, obtain the message header from the first storage space according to the message header index information in the message index table, process the obtained message header using an existing processing mechanism, and synchronously modify the index information of the message header in the message index table when the processing involves modifying the relative address of the message header.
[0042] The message encapsulation module is used to obtain the modified message index table from the second storage space, and to obtain the message header from the first storage space for encapsulation according to the message header index information in the message index table.
[0043] A third aspect of this disclosure also proposes a dedicated data processor, comprising:
[0044] A memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the message processing method described in any of the above embodiments.
[0045] A fourth aspect of the present invention also provides a computer storage medium storing computer program code, which, when executed by a processor, causes the processor to perform a message processing method as described in any of the above embodiments.
[0046] The message processing method provided in this disclosure generates a message index table based on the message header of received network data, which can be used at various stages of the network processing pipeline. This allows each stage to retrieve the data being processed at that stage through the message index table, eliminating the need to set different metadata structures for each stage. This method is simple, efficient, and offers good programmability, portability, and flexibility. Compared to traditional implementations that only require building metadata once and can be used at all stages of the entire network processing pipeline, this method requires significantly less performance. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0048] Figure 1 A schematic diagram of a conventional message processing procedure is provided according to an embodiment of the present disclosure;
[0049] Figure 2 This is a flowchart illustrating a message processing method according to an embodiment of the present disclosure;
[0050] Figure 3 This is a schematic diagram of the structure of a network packet according to an embodiment of the present disclosure;
[0051] Figure 4 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0052] Figure 5 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0053] Figure 6 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0054] Figure 7 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0055] Figure 8 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0056] Figure 9 This is a schematic diagram of a message index table structure provided according to an embodiment of the present disclosure;
[0057] Figure 10 A schematic diagram of the structure of a message processing system provided according to one embodiment of this disclosure;
[0058] Figure 11 To implement such Figure 2 The diagram shows the structure of a dedicated data processor for the message processing method. Detailed Implementation
[0059] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0060] The specific implementation of the embodiments of this application will be further described below with reference to the accompanying drawings.
[0061] This disclosure aims to address the issue that traditional network processing chips require defining metadata for each stage in multiple processing flows when handling network packets, such as... Figure 1 As shown, traditional packet parsing methods generally consist of three stages: packet parsing, packet processing, and packet encapsulation. Traditional implementations require customization and extension based on different application needs, and typically save the corresponding network data at each stage before defining the corresponding metadata. For example... Figure 1 The first, second, and third metadata in the protocol are used only within their respective stages. Different processing flows within each stage retrieve the corresponding message data based on the metadata for processing. Three metadata definitions are required for each stage, and for different application scenarios, the content of the metadata needs to be redefined based on the message header content of that application scenario, requiring the redevelopment of corresponding functions to achieve customized hardware acceleration. Therefore, traditional implementations suffer from poor programmability, portability, and flexibility, and also consume significant space, incur performance losses, and the repeated development and definition of corresponding metadata mechanisms leads to low development efficiency.
[0062] like Figure 2 As shown, the first aspect of this disclosure provides a message processing method for a network processing pipeline in a network processing unit of a dedicated data processor. The pipeline includes a message parsing stage, a message processing stage, and a message encapsulation stage, comprising:
[0063] Step S1: Generate corresponding packet header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space, wherein the relative address includes the offset address of the first and second parts of the corresponding packet header or the physical memory address of the corresponding packet header in the first storage space.
[0064] Step S2: Obtain the message index table from the second storage space, obtain the message header from the first storage space according to the message header index information in the message index table, process the obtained message header using the existing processing mechanism, and synchronously modify the index information of the message header in the message index table when the processing involves modifying the relative address of the message header.
[0065] Step S3: Obtain the modified message index table from the second storage space, and obtain the message header from the first storage space for encapsulation according to the message header index information in the message index table.
[0066] In some embodiments of this disclosure, the first storage space refers to the storage space for storing message data, which may be a high-speed memory such as memory or cache.
[0067] The message header refers to the header portion of a message, typically located at the beginning of the message. It's the header that encapsulates the message at different network layers, specifically as follows: Figure 3 As shown, Figure 3 In application scenarios, messages include HTTP headers, TCP headers, IP headers, and Frame headers, corresponding to the application layer, transport layer, network layer, and data link layer, respectively. It should be noted that the content of the message headers encapsulated in the message differs depending on the network environment.
[0068] A relative address refers to the offset information of the corresponding message header when it is stored in the message data or in the first storage space. That is, the position of the corresponding message header within the message header data. This position is generally described by how many binary bits the header is offset from. Furthermore, the relative address varies depending on the reference point. For example, if the header's first data is used as the reference point, the corresponding offset address is represented in decimal, indicating how much the corresponding data is offset from the header. In some embodiments of this disclosure, the relative address is represented by the memory address of the corresponding message data in memory, which is the address "relative" to the header. For example, memory address 0x0000 represents the starting position of memory, and subsequent memory addresses such as 0x03E8 represent data space 1000 bits away from 0x0000. Therefore, in the disclosed embodiments, if the relative address uses the header's first data as the reference point, subsequent data access requires calculating the actual memory address using the header's first data before reading the data from memory. If a relative address is referenced to the first memory address, there is no need for repeated calculations; data can be read directly from memory using the existing memory address.
[0069] For example, in the case of Figure 3 In the message structure shown, the offset address of the HTTP header is 0, the offset address of the TCP header is the length of the HTTP header (assuming the HTTP header length is 100, then the offset address of the TCP header is 100), and the offset address of the IP header is the sum of the lengths of the HTTP and TCP headers (assuming the TCP header length is 50, then the offset address of the IP header is 100 + 50, which is 150). Subsequent headers follow the same pattern.
[0070] The index information contains the relative address of the message header, which is used to find the identifier information of the message header at the corresponding position in the message.
[0071] A message index table is a data structure composed of index information of all message headers, mainly including the index information of each message header. In some embodiments of this disclosure, it also includes the address of the corresponding message in the first storage space.
[0072] In some embodiments of this disclosure, in step S1, during the message parsing stage, after receiving a message, the network processor parses the message to obtain a clearly structured message data consisting of a message payload (the part of the network message that carries network data) and a message header containing one or more message headers, and saves it to the first storage space.
[0073] Further, based on the structure of the message header and its corresponding relative address, the index information of each type of message header is determined, and the index information of multiple message headers is merged according to a predetermined structure to generate a message index table. Then, the message index table is saved to the second storage space.
[0074] In step S2, during the message processing stage, the message index table is obtained from the second storage space, and the corresponding message header index information is obtained from the message index table according to the needs of message processing. The corresponding message header is then obtained from the first storage space for processing based on the message header index information.
[0075] Specifically, with Figure 3 Taking the shown message structure as an example, if the TCP header needs to be processed during the message processing stage, and the offset address of the TCP header is the total length of the HTTP header, and the TCP message length is 50, then the storage space for the message header is located in the first storage space. Starting from the first bit, data is read after an offset of 100 bits, and 50 bits are read consecutively to obtain the content of the TCP header. Further processing is then carried out according to the predetermined procedure. If the header content is modified during processing, the corresponding modification information is rewritten into the storage space corresponding to the TCP header in the first storage space, from 100 to 150, based on the internal structure of the TCP header.
[0076] Furthermore, if the message header is deleted or added during message processing, causing the address of the message header in the first storage space to change, then after deleting the data of the message header in the first storage space, the index information corresponding to the deleted message header in the message index table in the first storage space will be cleared or modified.
[0077] Furthermore, if a new message header is added during message processing, an index is generated for it based on the relative address of the added message header in the first storage space and added to the message index table.
[0078] In step S3, during the message encapsulation stage, the message index table of the message to be encapsulated is also obtained from the second storage space, and the corresponding message header is obtained from the first storage space according to the index information of each message header contained in the message index table and re-encapsulated into new message data.
[0079] In some embodiments of this disclosure, the index information of the message header includes the memory offset address and offset of the message header in the first storage space, and the message index table includes a message information array segment;
[0080] The step of generating a message index table based on the index information and saving it to the second storage space includes:
[0081] Based on the identification information of the corresponding message header, the memory offset address and offset of the message header in the first storage space are used as an array, and the array is added to the message index table as an element of the message information array segment;
[0082] The step of retrieving the message header from the first storage space based on the message header index information in the message index table includes:
[0083] Iterate through each element in the message information array segment, and obtain the memory offset address and offset of the corresponding message header in the first storage space from each element. Based on the memory offset address and offset of the message header in the first storage space, obtain the message header corresponding to each message header from the first storage space.
[0084] In some embodiments of this disclosure, the index information of the message header includes the memory offset address and offset of the message header in the first storage space. The memory offset address and offset of the message header are then used as a data entry in the message index table, specifically as follows: Figure 4 As shown. Figure 4 Each row in the array represents an array, where each element includes the header ID, memory offset address, and header length. The header ID is the identifier corresponding to the header, the memory offset address is the starting address of the header in the first memory space (which can be a physical memory address, such as 0x00000000), and the header length is the length of the header.
[0085] When generating the message index table, the actual memory starting address corresponding to the message header in the first storage space, the message header length, and the message header number are added as a single element to the message index table.
[0086] Furthermore, when retrieving the message header through the message index table, each array in the message index table can be directly traversed. Each array represents the index information of a message header, and the corresponding message header is retrieved from the specified memory region based on the memory offset address and message header length in each array. For example, if the offset address of a message header is 0x00002000 and the message length is 128, then the message header can be obtained by directly reading 128 bits consecutively starting from 0x00002000. By adding the memory offset address to the message header index information, the reading of the message header can be accelerated in subsequent uses.
[0087] In some embodiments of this disclosure, the message index table includes a global information segment, which includes a message length information field, a message header length information field, and a message payload offset address field.
[0088] The step of generating the corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space includes:
[0089] Calculate the data length of all message headers and the message length; write the message header length into the message header length information field; and write the message length into the message length information field; and
[0090] Write the relative address of the data portion corresponding to the message in the first storage space into the load offset address field;
[0091] The step of obtaining the modified message index table from the second storage space and retrieving the message header from the first storage space for encapsulation based on the message header index information in the message index table includes:
[0092] The length of the message payload is calculated based on the data length of the message header and the message length; the payload data of the message is obtained based on the relative address in the payload offset address field and the length of the message payload; and
[0093] The message header is obtained based on the memory offset address and offset of the message header in the first storage space from the message header index information;
[0094] The message is repackaged into a new message based on the message payload data and the message header.
[0095] In some embodiments of this disclosure, such as Figure 5 As shown, the message index table includes a global information segment, which consists of a message length information field, a message header length information field, and a message payload offset address field, wherein:
[0096] The message length field indicates the total length of the message data, which is initially the total length of the original message parsed; the message header length field indicates the total length of the message header; and the message payload offset address field indicates the offset address corresponding to the data portion of the current message.
[0097] Furthermore, when generating the message index table, the data length of all message headers and the total length of the message are calculated. The data length of all message headers is written into the message header length information field of the message index table, and the total length of the message is written into the message length information field.
[0098] Furthermore, in some embodiments of this disclosure, the relative offset address of the data portion of the message in memory relative to the entire message is written into the message payload offset address field. For example, assuming the total message length is 10000 bits and the message header occupies 2000 bits, then the relative offset address of the message data portion is 2000. Therefore, the value of the message payload offset address field should be 2000.
[0099] Furthermore, in some embodiments of this disclosure, the starting address of the memory address of the data portion of the message in the memory storage area is used as the offset address and saved to the offset address field of the message payload. For example, assuming the message header length is 2000 and it starts storing from memory address 0x0000, the corresponding memory address of the message data portion should be hexadecimal 0x7D0, and 0x7D0 is written to the message payload offset address field. In this way, when accessing the data portion subsequently, the content of the message data portion can be quickly obtained based on the actual memory address, realizing that the offset information only needs to be calculated once and then directly used in subsequent implementations.
[0100] Furthermore, if the relative address of the payload is a relative address referenced to the first part of the packet header, when encapsulating network data, the actual memory address of the first part of the payload data is obtained by adding the relative address in the payload offset address field to the actual memory address of the first part of the packet header. For example, as in the example above, assuming the relative address is 2000 and the actual memory address of the packet header is 0x0000, then the actual memory address of the payload is 0x7D0 (2000 in hexadecimal).
[0101] If the relative address of the load is referenced to the actual memory address of the load, then the relative address is used directly when encapsulating network data. For example, if the relative address in the load offset address field is 0x7D0, then the actual memory address is also 0x7D0.
[0102] Furthermore, the length of the message header and the message length are obtained from the message header length information field and the message length information field, respectively. The length of the payload data is obtained by subtracting the data length of the message header from the message length. Then, data of the corresponding length is read from the actual memory address of the payload in memory.
[0103] Furthermore, based on the relative cheap address and offset in the index information of each message header, the corresponding message header is obtained from the first storage space, and the message header and message payload are encapsulated into new message data according to the existing encapsulation method.
[0104] In some embodiments of this disclosure, the message index table includes a message header extension offset field;
[0105] The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes:
[0106] If a new header is added during the processing of the header, the new header is stored at the end of the header storage area corresponding to the first storage space, and the relative address of the new header data in the first storage space is written into the header extended offset address field.
[0107] In some embodiments of this disclosure, such as Figure 6 As shown, the message index table includes a message header extension offset field, which is used to mark newly added message headers. If a new message header needs to be added during message header processing, after adding the new message header to the end of the message area in the first storage space, the relative address of the new message header is added to the extension offset address field. As before, the relative address also includes a memory offset address with the beginning and end of the message as a reference, or a real memory address with the starting address of the actual memory as a reference. Therefore, the message header extension offset field will also depend on the specific method of the relative address. Based on the message header extension offset field, when multiple new message headers need to be added, the end of the message storage area can be quickly found according to the relative address in the extension offset field, and the newly generated message header can be written directly from the address pointed to by the message header extension offset field, without having to determine the writing point of the new message header based on the previous message headers.
[0108] In some embodiments of this disclosure, the message index table further includes a message header flag field, which corresponds one-to-one with the message header;
[0109] Generate corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space, including:
[0110] When generating the index information of the corresponding message header, the flag field of the message header is set to a first predetermined value;
[0111] The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes:
[0112] When processing the packet header, the packet header flag field corresponding to the packet header that is not used in subsequent processing stages of the network processing pipeline is set to a second predetermined value to indicate that the packet header does not need to be used; and / or
[0113] Set the header flag field corresponding to the header used in the subsequent processing stage of the network processing pipeline from the second predetermined value to the first predetermined value;
[0114] The modified message index table is retrieved from the second storage space, and the message header is retrieved from the first storage space and encapsulated according to the message header index information in the message index table, including:
[0115] Before retrieving the index information of the corresponding message header from the message index table, it is first determined whether the value of the message header flag field corresponding to the message header is a first predetermined value. If the value of the flag field is the first predetermined value, the index information of the message header is retrieved. If the value of the flag field is not the first predetermined value, the message header is skipped and encapsulation processing of subsequent message headers is performed.
[0116] In some embodiments of this disclosure, such as Figure 7 As shown, the message index table also includes a message header flag field. This flag field corresponds one-to-one with the message header and is part of the message's index information, used to identify whether the message header is valid. Specifically, when generating the message header index information, if the corresponding message header is parsed from the original message, the value of the flag field of that corresponding message header is set to 1. That is, in cases such as... Figure 3 In the message structure shown, the flags for the parsed TCP header, HTTP header, IP header, and data link layer header are set to 1. If no HTTP header is parsed, the flag in the index information corresponding to the HTTP header is set to 0.
[0117] Furthermore, if, during subsequent message processing, message headers that are not used in subsequent processing and need to be discarded are set to 0 in the corresponding flag field of the message index table.
[0118] Furthermore, during message encapsulation, after obtaining the modified message index table from the message processing stage, it first checks whether the flag field of each corresponding message header in the message index table is 1. If it is 1, it means that the message header is valid, i.e., it is needed during encapsulation. The system then continues to find the relative address corresponding to the message header from the message index table and retrieves the corresponding data based on the relative address. If it is 0, it means that the message header does not need to be encapsulated into the message header during re-encapsulation, so the system skips this message header and executes the reading of other subsequent message headers.
[0119] Furthermore, after obtaining all message headers and message payloads from the message index table, the messages are re-encapsulated using a predetermined encapsulation method.
[0120] In some embodiments of this disclosure, generating a message index table based on the index information and saving it to a second storage space includes:
[0121] Obtain a preset message header information configuration table, generate a message index table based on the message header information in the message header information configuration table, and fill the corresponding index information into the message index table in the order of the message header information configuration table according to the message headers defined in the message index table.
[0122] In some embodiments of this disclosure, the structure and size of the message index table can be preset; that is, a general-purpose message index table that can contain multiple message headers can be set. The order of the index information of each message header in the message index table is fixed, and when a corresponding network packet is parsed, the index information of the message headers present in the network packet header is directly added to the corresponding area in the message index table according to the position of the message header in the message index table. For message headers that do not exist in the network packet header, their positions in the message index table are left empty.
[0123] In some embodiments of the present invention, such as Figure 8 As shown, Figure 8 In the message information digital segment, the order of each message header is fixed, and each line represents the index information of a message header. For a specific network message, the header flag is set to 1 if a certain type of header exists in the message header, and set to 0 if no header exists. For example, using... Figure 3 Taking a network message as an example, if the network message contains an HTTP header, a TCP header, and an IP header, then the corresponding three headers are as follows: Figure 8 The message header flags in the message index table shown are all 1.
[0124] It should be noted that, Figure 8 This is merely an illustrative example of the message index table structure, showing only a message index table with 5 message headers. It does not imply that it is limited to 5 message headers. Specific message header information configuration tables can be configured according to actual scenario needs. A corresponding message index table can be generated based on the message information configuration table.
[0125] Furthermore, when it is necessary to retrieve the corresponding message header from the message index table, the message header information in the message information array segment is retrieved directly according to the sorting of the corresponding message headers in the message header information configuration table, using an index-based approach. For example, Figure 8 The IP header shown is sorted by 3. The sorting in computer programming starts from 0. The sorting by 3 corresponds to the index of 2. When using the IP header, you can directly obtain the IP header by table[2]. Here, table represents the packet index table.
[0126] In some embodiments of this disclosure, generating a message index table based on the index information and saving it to a second storage space further includes:
[0127] Generate a header flag field with corresponding bit length based on the number and order of headers in the preset header information configuration table;
[0128] If the corresponding message header is used in a subsequent processing stage of the network processing pipeline, the position corresponding to the same order of the message header flag segment is set to a first predetermined value according to the order of the message header in the message header information configuration table; otherwise, it is set to a second predetermined value.
[0129] In some embodiments of this disclosure, such as Figure 9 As shown, based on the number of headers in the preset header information configuration table, a corresponding header flag is set. This header flag is no longer a 1-bit data; its data length depends on the number of headers. Furthermore, each bit of the header flag corresponds to a header in the header information configuration table in a predetermined order. For example, in the above embodiment, using... Figure 8 and Figure 3 The corresponding network packet contains three headers: HTTP header, TCP header, and IP header. Normally, the header flags for each header are located in the index information. However, in this example, the header flags are binary numbers of a certain length, based on... Figure 3 The message has a value of 01011. That is, the first bit indicates a non-existent header, the second bit indicates an IP header, the third bit indicates a non-existent header, the fourth bit indicates a TCP header, and the fifth bit indicates an HTTP header. Based on this design, when retrieving the header through the packet index table, each bit in the header flags is directly traversed; if it is 1, it is indexed sequentially; if it is 0, it is skipped. Specifically, still using... Figure 3 Taking the network packet structure shown as an example, by simply accessing the packet header flags, we can obtain table[1], table[3], and table[4] without traversing the elements in the packet header information array segment. This is used to quickly obtain the corresponding data.
[0130] It should be noted that, compared to Figure 8 The packet index table shown places the packet header flag in the global information segment and represents it as a binary number of a certain length. This changes the original two-dimensional access mechanism, which involved traversing the information array segments and then each index in each array segment, to simply determining which bit in the packet header flag data is 1 to determine if the corresponding index is valid. Changing from two-dimensional to one-dimensional access effectively improves the packet header lookup speed and significantly reduces network data processing time in environments with large amounts of network data.
[0131] like Figure 10As shown, a second aspect of this disclosure also proposes a message processing system for a network processing pipeline in a network processing unit of a dedicated data processor. The pipeline includes a message parsing stage, a message processing stage, and a message encapsulation stage, comprising:
[0132] The message parsing module 1001 is used to generate corresponding message header index information based on the relative address of the message header parsed by the network processing unit and stored in the first storage space, and to generate a message index table based on the index information and save it to the second storage space.
[0133] The message processing module 1002 is used to obtain the message index table from the second storage space, obtain the message header from the first storage space according to the message header index information in the message index table, process the obtained message header using an existing processing mechanism, and synchronously modify the index information of the message header in the message index table when the processing involves modifying the relative address of the message header.
[0134] The message encapsulation module 1003 is used to obtain the modified message index table from the second storage space, and to obtain the message header from the first storage space for encapsulation according to the message header index information in the message index table.
[0135] In some embodiments of this disclosure, the index information of the message header includes the memory offset address and offset of the message header in the first storage space, and the message index table includes a message information array segment;
[0136] Message parsing module 1001 is also used for:
[0137] Add the memory offset address and offset of the message header in the first storage space as an element of the message information array segment to the message index table;
[0138] The message processing module 1002 is further configured to: traverse each element in the message information array segment, obtain the memory offset address and offset of the corresponding message header in the first storage space from each element, and obtain the message header corresponding to each message header from the first storage space according to the memory offset address and offset of the message header in the first storage space.
[0139] In some embodiments of this disclosure, the message index table includes a global information segment, which includes a message length information field, a message header length information field, and a message payload offset address field.
[0140] Message parsing module 1001 is also used for:
[0141] Calculate the data length of all message headers and the message length; write the message header length into the message header length information field; and write the message length into the message length information field; and
[0142] Write the relative address of the data portion corresponding to the message in the first storage space into the load offset address field;
[0143] The message encapsulation module 1003 is further configured to: calculate the length of the message payload based on the data length of the message header and the message length; and obtain the message payload data based on the relative address in the payload offset address field and the length of the message payload; and
[0144] The message header is obtained based on the memory offset address and offset of the message header in the first storage space from the message header index information;
[0145] The message is repackaged into a new message based on the message payload data and the message header.
[0146] In some embodiments of this disclosure, the message index table includes a message header extension offset field;
[0147] Message processing module 1002 is also used for:
[0148] If a new header is added during the processing of the header, the new header is stored at the end of the header storage area corresponding to the first storage space, and the relative address of the new header data in the first storage space is written into the header extended offset address field.
[0149] In some embodiments of this disclosure, the message index table further includes a message header flag field, which corresponds one-to-one with the message header;
[0150] Message parsing module 1001 is also used for:
[0151] When generating the index information of the corresponding message header, the flag field of the message header is set to a first predetermined value;
[0152] Message processing module 1002 is also used for:
[0153] When processing the packet header, the packet header flag field corresponding to the packet header that is not used in subsequent processing stages of the network processing pipeline is set to a second predetermined value to indicate that the packet header does not need to be used; and / or
[0154] Set the header flag field corresponding to the header used in the subsequent processing stage of the network processing pipeline from the second predetermined value to the first predetermined value;
[0155] The message encapsulation module 1003 is further configured to: before obtaining the index information of the corresponding message header from the message index table, determine whether the value of the message header flag field corresponding to the message header is a first predetermined value; if the value of the flag field is the first predetermined value, obtain the index information of the message header; if the value of the flag field is not the first predetermined value, skip the message header and perform encapsulation processing on subsequent message headers.
[0156] In some embodiments of this disclosure, the message parsing module 1001 is further configured to:
[0157] Obtain a preset message header information configuration table, generate a message index table based on the message header information in the message header information configuration table, and fill the corresponding index information into the message index table in the order of the message header information configuration table according to the message headers defined in the message index table.
[0158] In some embodiments of this disclosure, the message parsing module 1001 is further configured to:
[0159] Generate a header flag field with corresponding bit length based on the number and order of headers in the preset header information configuration table;
[0160] If the corresponding message header is used in a subsequent processing stage of the network processing pipeline, the position corresponding to the same order of the message header flag segment is set to a first predetermined value according to the order of the message header in the message header information configuration table; otherwise, it is set to a second predetermined value.
[0161] The message processing method provided in this disclosure generates a message index table based on the message header of received network data, which can be used at various stages of the network processing pipeline. This allows each stage to retrieve the data being processed at that stage through the message index table, eliminating the need to set different metadata structures for each stage. This method is simple, efficient, and offers good programmability, portability, and flexibility. Compared to traditional implementations that only require building metadata once and can be used at all stages of the entire network processing pipeline, this method requires significantly less performance.
[0162] The following reference Figure 11 This describes a dedicated data processor 500 according to an embodiment of the present disclosure. Figure 11 The dedicated data processor 500 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0163] Figure 11The dedicated data processor 500 shown may include, but is not limited to, at least one processing unit 510, at least one storage unit 520, and a bus 530 connecting different system components (including the storage unit 520 and the processing unit 510). The storage unit 520 stores program code that can be executed by the processing unit 510, causing the processing unit 510 to perform the steps described in the above description of the exemplary methods according to various exemplary embodiments of the present invention.
[0164] Storage unit 520 may include a readable medium in the form of a volatile storage unit, such as random access memory (RAM) 5201 and / or cache memory 5202, and may further include a read-only memory (ROM) 5203.
[0165] Storage unit 520 may also include a program / utility 5204 having a set (at least one) program module 8205, such program module 5205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0166] Bus 530 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0167] The dedicated data processor 500 can also communicate with one or more external devices 600 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable users to interact with the dedicated data processor 500, and / or any device that enables the dedicated data processor 500 to communicate with one or more other computing devices (e.g., routers, modems, etc.). This communication can be performed via input / output (I / O) interface 550. Furthermore, the dedicated data processor 500 can also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 560. As shown, network adapter 560 communicates with other modules of the dedicated data processor 500 via bus 530. It should be understood that, although not shown in the figures, the dedicated data processor 500 can be implemented using other hardware and / or software modules, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0168] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0169] In exemplary embodiments of this disclosure, a computer program medium is also provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the methods described in the above method embodiments.
[0170] According to one embodiment of this disclosure, a program product for implementing the methods in the above-described method embodiments is also provided. This program product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0171] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0172] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0173] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0174] Program code for performing the operations of this invention can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0175] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0176] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.
[0177] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this disclosure.
[0178] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.
[0179] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.
[0180] The methods described in the embodiments of this application can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code downloaded over a network that is originally stored in a remote recording medium or a non-transitory machine-readable medium and will be stored in a local recording medium. Thus, the methods described herein can be stored as software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the checksum generation method described herein. Furthermore, when a general-purpose computer accesses code used to implement the checksum generation method shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for executing the checksum generation method shown herein.
[0181] Those skilled in the art will recognize that the units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0182] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.
Claims
1. A message processing method for a network processing pipeline in a network processing unit of a network data processor, characterized in that, include: Based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space, the corresponding packet header index information is generated, and a packet index table is generated and stored in the second storage space based on the index information. The relative address includes the offset address of the first and second parts of the corresponding packet header or the physical memory address of the corresponding packet header in the first storage space. The message index table is obtained from the second storage space, and the message header is obtained from the first storage space according to the message header index information in the message index table. The obtained message header is processed using a preset processing mechanism, and the index information of the message header in the message index table is modified synchronously when the relative address of the message header is modified during the processing. The modified message index table is obtained from the second storage space, and the message header is obtained from the first storage space and encapsulated according to the message header index information in the message index table.
2. The method according to claim 1, characterized in that, The message header index information includes the memory offset address and offset of the message header in the first storage space, and the message index table includes a message information array segment; The step of generating a message index table based on the index information and saving it to the second storage space includes: Add the memory offset address and offset of the message header in the first storage space as an element of the message information array segment to the message index table; The step of retrieving the message header from the first storage space based on the message header index information in the message index table includes: Iterate through each element in the message information array segment, obtain the memory offset address and offset of the corresponding message header in the first storage space from each element, and obtain the message header corresponding to each message header from the first storage space according to the memory offset address and offset of the message header in the first storage space.
3. The method according to claim 1, characterized in that, The message index table includes a global information segment, which includes a message length information field, a message header length information field, and a message payload offset address field. The step of generating the corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space includes: Calculate the data length of all message headers and the message length; write the message header length into the message header length information field; and write the message length into the message length information field; and Write the relative address of the data portion corresponding to the message in the first storage space into the load offset address field; The step of obtaining the modified message index table from the second storage space and retrieving the message header from the first storage space for encapsulation based on the message header index information in the message index table includes: The length of the message payload is calculated based on the data length of the message header and the message length; the payload data of the message is obtained based on the relative address in the payload offset address field and the length of the message payload; and The message header is obtained based on the memory offset address and offset of the message header in the first storage space from the message header index information; The message is repackaged into a new message based on the message payload data and the message header.
4. The method according to claim 1, characterized in that, The message index table includes a message header extension offset field; The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes: If a new header is added during the processing of the header, the new header is stored at the end of the header storage area corresponding to the first storage space, and the relative address of the new header data in the first storage space is written into the header extended offset address field.
5. The method according to claim 1, characterized in that, The message index table also includes a message header flag field, which corresponds one-to-one with the message header; Generate corresponding header index information based on the relative address of the packet header parsed by the network processing unit and stored in the first storage space, including: When generating the index information of the corresponding message header, the flag field of the message header is set to a first predetermined value; The process of using existing processing mechanisms to process the obtained packet header, and synchronously modifying the index information of the packet header in the packet index table when the processing involves modifying the relative address of the packet header, includes: When processing the message header, the message header flag field corresponding to the message header that is not used in the subsequent processing stage of the network processing pipeline is first set to a second predetermined value to indicate that the message header does not need to be used. Then, the header flag field corresponding to the header used in the subsequent processing stage of the network processing pipeline is changed from the second predetermined value to the first predetermined value; The modified message index table is retrieved from the second storage space, and the message header is retrieved from the first storage space and encapsulated according to the message header index information in the message index table, including: Before retrieving the index information of the corresponding message header from the message index table, it is first determined whether the value of the message header flag field corresponding to the message header is a first predetermined value. If the value of the flag field is the first predetermined value, the index information of the message header is retrieved. If the value of the flag field is not the first predetermined value, the message header is skipped and encapsulation processing of subsequent message headers is performed.
6. The method according to claim 1, characterized in that, The step of generating a message index table based on the index information and saving it to the second storage space includes: Obtain a preset message header information configuration table, construct a storage structure for a message index table based on the message header information in the message header information configuration table, and fill the corresponding index information into the constructed message index table in the order of the message header information configuration table.
7. The method according to claim 6, characterized in that, The step of generating a message index table based on the index information and saving it to the second storage space further includes: Generate a header flag field with corresponding bit length based on the number and order of headers in the preset header information configuration table; If the corresponding message header is used in a subsequent processing stage of the network processing pipeline, the position of the message header flag field corresponding to the same sorting in the message header information configuration table is set to a first predetermined value; otherwise, it is set to a second predetermined value.
8. A message processing system for a network processing pipeline in a network processing unit of a network data processor, characterized in that, include: The message parsing module is used to generate corresponding message header index information based on the relative address of the message header parsed by the network processing unit and stored in the first storage space, and to generate a message index table based on the index information and save it to the second storage space. The relative address includes the offset address of the first and second parts of the corresponding message header and the message header or the physical memory address of the corresponding message header in the first storage space. The message processing module is used to obtain the message index table from the second storage space. The message index table is generated by the message parsing module and stored in the second storage space. The module obtains the message header from the first storage space according to the message header index information in the message index table, processes the obtained message header using a preset processing mechanism, and synchronously modifies the message header index information in the message index table when the processing involves modifying the relative address of the message header. The message encapsulation module is used to obtain the modified message index table from the second storage space, and to obtain the message header from the first storage space for encapsulation according to the message header index information in the message index table.
9. A network-specific data processor, characterized in that, include: A memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the functionality as claimed in claim 1. The message processing method described in any one of the 7.
10. A computer storage medium, characterized in that, The computer storage medium stores computer program code, which, when executed by a processor, causes the processor to perform the actions described in claim 1.
7. The message processing method described in any one of the following.
Citation Information
Patent Citations
Forwarding table writing method and device and message forwarding method and device
CN102857414A
Method and device for managing data index in storage system
CN111241090A
