CN115883681B - Message parsing method and device, electronic equipment and storage medium - Google Patents

Message parsing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115883681B
CN115883681B CN202310083400.2A CN202310083400A CN115883681B CN 115883681 B CN115883681 B CN 115883681B CN 202310083400 A CN202310083400 A CN 202310083400A CN 115883681 B CN115883681 B CN 115883681B
Authority
CN
China
Prior art keywords
message
module
protocol processing
protocol layer
processing unit
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
CN202310083400.2A
Other languages
Chinese (zh)
Other versions
CN115883681A (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.)
Tianyi Cloud Technology Co Ltd
Original Assignee
Tianyi Cloud Technology 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 Tianyi Cloud Technology Co Ltd filed Critical Tianyi Cloud Technology Co Ltd
Priority to CN202310083400.2A priority Critical patent/CN115883681B/en
Publication of CN115883681A publication Critical patent/CN115883681A/en
Application granted granted Critical
Publication of CN115883681B publication Critical patent/CN115883681B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The embodiment of the invention provides a message analysis method, a device, electronic equipment and a storage medium, which are applied to a message analysis module, wherein the message analysis module comprises a plurality of protocol processing units, and the method comprises the following steps: receiving a message to be analyzed, generating a table look-up request according to the message, matching the message with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table look-up request, generating a matched action table, extracting key information of the message, and stripping the message according to the length of a preset protocol layer in the action table to obtain data information of the message. According to the invention, a protocol processing unit is independently allocated for each layer of protocol, and the message is matched with the tcam rule table pre-configured by the target protocol processing unit in parallel according to the network protocol layer sequence pipeline processing, so that the data information of the message is stripped, the tcam rule table can be flexibly configured, and various protocols are supported, thereby realizing the line speed and high-efficiency message analysis.

Description

Message parsing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of data communication and provides a message analysis method, a message analysis device, electronic equipment and a storage medium.
Background
With the development of network technology, data flow is rapidly increased, and the traditional network message method based on the TCP/IP protocol stack of the CPU not only consumes a great deal of CPU resources and affects the performance of the CPU, so that in a cloud service system for processing big data, some work of a CPU core is unloaded into an intelligent network card to improve the performance of data processing and save the calculation cost of the CPU.
Currently, the main stream is to offload the network forwarding function and the storage part function of the CPU core to the intelligent network card, offload the forwarding flow table entry of the OVS (OpenVswitch, high quality virtual switch supporting multi-layer data forwarding) to the DDR of the intelligent network card plug-in, and the intelligent network card chip analyzes the key value of the lookup table, queries the flow table entry in the DDR to obtain the final destination of the message, which requires to accurately analyze the message information, otherwise, if the lookup table finds out the wrong result, the message forwarding error will be caused.
However, because the types of network protocol layers involved in the message are many, the current intelligent network card cannot enumerate various types of situations one by one, the first is that the circuit structure is very complex, on-chip resources are difficult to support, and the second is that resources are wasted because some protocol type application scenes are not involved. Therefore, for large-flow messages, the current intelligent network card has the problems of slower message analysis performance, low configuration flexibility and resource limitation of the hardware structure of the processing module, thereby influencing the message analysis performance.
Disclosure of Invention
The embodiment of the invention provides a message analysis method, a device, electronic equipment and a storage medium, which are used for realizing high-performance and linear speed processing of a message and achieving the purpose of efficiently analyzing the message.
In order to solve the above problems, in a first aspect, an embodiment of the present invention discloses a message parsing method, which is applied to a message parsing module shown in fig. 7, where the message parsing module includes a plurality of protocol processing units, and the method includes:
receiving a message to be analyzed, and generating a table look-up request according to the message;
according to the table lookup request, the message is matched with a tcam rule table pre-configured by a target protocol processing unit in parallel, a matched action table is generated, and key information of the message is extracted;
and stripping the message according to the length of a preset protocol layer in the action table to obtain the data information of the message.
Optionally, the receiving the message to be parsed and generating a table look-up request according to the message include:
processing the message according to the preset byte offset, and numbering the message;
based on the message number, generating a table look-up request to query a pre-configured tcam rule table, wherein the table look-up request comprises the message, the message number and a protocol layer type included in the message.
Optionally, the step of matching the message with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table lookup request to generate a matched action table, and extracting key information of the message includes:
matching a pre-configured tcam rule table of the target protocol processing unit according to the message, wherein the tcam rule table comprises a key value, a mask and a protocol layer type configured according to a network protocol layer type;
if the table lookup request information is matched with the tcam rule table, generating an action table comprising a matching result, and extracting key information of the message according to the action table;
otherwise, the message is transmitted to the next target protocol processing unit.
Optionally, the stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message includes:
stripping the key information from the message according to the length of a preset protocol layer in the action table;
transmitting the message from which the key information is stripped to the next target protocol processing unit;
and under the condition that the protocol layer information of the message is stripped, obtaining the data information of the message.
Optionally, before receiving the message to be parsed and generating the table look-up request according to the message, the method further includes:
determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message, and controlling the plurality of target protocol processing units to be started;
and according to the network protocol layer type, extracting bit width configuration is carried out on the plurality of target protocol processing units.
Optionally, after extracting the bit width configuration from the plurality of target protocol processing units according to the network protocol layer type, the method further includes:
configuring a tcam rule table for a plurality of target protocol processing units according to the network protocol layer type, wherein the tcam rule table is used for extracting message key information corresponding to the target processing units;
and configuring the protocol layer type of the next target protocol processing unit based on an action table generated by the tcam rule table.
Optionally, the stripping the message according to the length of the preset protocol layer in the action table, after obtaining the data information of the message, further includes:
generating a checksum of the data information according to the data information of the message;
and verifying the checksum to determine that the message analysis is effective, and sending the data information to a message editing module.
In a second aspect, the embodiment of the present invention further discloses a message parsing device, which is applied to a message parsing module, where the message parsing module includes a plurality of protocol processing units, and the device includes:
the message receiving module is used for receiving a message to be analyzed and generating a table look-up request according to the message;
the matching information module is used for parallelly matching the message with a tcam rule table pre-configured by a target protocol processing unit according to the table lookup request, generating a matched action table and extracting key information of the message;
and the message processing module is used for stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message.
Optionally, the message receiving module includes:
the first processing sub-module is used for processing the message according to the preset byte offset and numbering the message;
and the second processing sub-module is used for generating a table look-up request based on the message number to inquire a pre-configured tcam rule table, wherein the table look-up request comprises the message, the message number and the protocol layer type included in the message.
Optionally, the matching information module includes:
a matching sub-module, configured to match, according to the message, a tcam rule table configured in advance by the target protocol processing unit, where the tcam rule table includes a key value, a mask, and a protocol layer type configured according to a network protocol layer type;
A generating sub-module, configured to generate an action table including a matching result if the table lookup request information is matched with the tcam rule table, and extract key information of the message according to the action table;
and the first transmission sub-module is used for transmitting the message to the next target protocol processing unit.
Optionally, the message processing module includes:
the third processing sub-module is used for stripping the key information from the message according to the length of a preset protocol layer in the action table;
the second transmission sub-module is used for transmitting the message from which the key information is stripped to the next target protocol processing unit;
and the fourth processing sub-module is used for obtaining the data information of the message under the condition that the protocol layer information of the message is stripped.
Optionally, the apparatus further comprises:
the determining module is used for determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message and controlling the plurality of target protocol processing units to be enabled to be started;
and the first configuration module is used for carrying out bit width extraction configuration on the plurality of target protocol processing units according to the network protocol layer type.
Optionally, the apparatus further comprises:
the second configuration module is used for configuring a tcam rule table for a plurality of target protocol processing units according to the network protocol layer type, wherein the tcam rule table is used for extracting message key information corresponding to the target processing units;
and the third configuration module is used for configuring the protocol layer type of the next target protocol processing unit based on the action table generated by the tcam rule table.
Optionally, the apparatus further comprises:
the generation module is used for generating a checksum of the data information according to the data information of the message;
and the message sending module is used for determining that the message analysis is effective through verifying the checksum and sending the data information to the message editing module.
In a third aspect, an embodiment of the present invention further discloses an electronic device, including:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the message parsing method described above.
In a fourth aspect, the present invention further discloses a computer readable storage medium storing a computer program, where the computer program is executed by a processor to implement the above-mentioned method for parsing a message.
The embodiment of the invention has the following advantages:
the message analysis method provided by the embodiment of the invention is applied to a message analysis module, wherein the message analysis module comprises a plurality of protocol processing units, a table look-up request is generated according to a message by receiving the message to be analyzed, a message is matched with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table look-up request, a matched action table is generated, key information of the message is extracted, the message is stripped according to the length of a preset protocol layer in the action table, and data information of the message is obtained. The invention distributes a protocol processing unit for each layer of protocol separately, processes according to the network protocol layer sequence pipeline, does not need to buffer the message, saves the register resource in the module, can meet the high performance requirement, matches the message with the pre-configured tcam rule table of the target protocol processing unit in parallel, strips out the data information of the message, thereby realizing the line speed and high efficiency message analysis, and can flexibly configure the register and the tcam rule table in the module, achieve the purpose of analyzing various protocol messages, avoid repeatedly modifying hardware codes and shorten the development period.
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 in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating steps of a message parsing method according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method of step 102 of the message parsing method provided in the embodiment of the present invention in FIG. 1;
FIG. 3 is a second flowchart illustrating a method for parsing a message according to an embodiment of the present invention;
FIG. 4 is a third flowchart illustrating a method for parsing a message according to an embodiment of the present invention;
FIG. 5 is a flowchart of a method for parsing a message according to an embodiment of the present invention;
FIG. 6 is a block diagram of a message parsing apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a message parsing device according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. 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.
Referring to fig. 1, one of the step flowcharts of the message parsing method provided by the embodiment of the present invention is shown and applied to a message parsing module shown in fig. 7, where the message parsing module includes a plurality of protocol processing units, and the method may include:
step 101, receiving a message to be analyzed, and generating a table look-up request according to the message.
In the embodiment of the invention, in order to realize the message processing performance with high line speed and high efficiency, based on the tcam quick look-up concept, an OVS basic architecture is adopted to analyze the message, wherein the OVS basic architecture consists of a message analysis module, a matching module and a message editing module, and concretely, referring to the schematic diagram of the message analysis module shown in fig. 7, the embodiment is applied to the message analysis module, the message analysis module comprises a plurality of protocol processing units, and the message analysis module is divided into a plurality of protocol processing units, each protocol processing unit completes the processing of one layer of protocol, and each protocol processing unit is connected in series, so that the analysis processing of the whole message is completed in a flow line.
It should be noted that, the message parsing module is configured to find the destination, the action, and finally send the message to the message editing module for editing and forwarding according to the key information extracted from the message. It should be noted that, the message parsing is implemented based on the tcam fast table look-up concept, where each protocol processing unit of the message parsing module is stacked by a logic circuit, and no buffer is needed, and two clock processing ends are fixed.
Specifically, the message parsing module receives a message to be parsed, firstly, the content of the message is offset according to a byte as a unit to make a number, for example, the first byte of the message starts, the number is 0, the next byte is 1, and so on. And forming a table look-up request by the serial number of the last step, the message corresponding to the backward offset two bytes and the cur_type protocol layer type of the protocol processing unit of the message analysis module, and inquiring a pre-configured tcam rule table when judging that the protocol layer type is legal in the current protocol processing unit.
Specifically, in some embodiments, step 101 receives a message to be parsed, and generates a table look-up request according to the message, which may include the following steps:
Firstly, carrying out message numbering on a message according to preset byte offset processing;
in this embodiment, the preset bytes may be determined according to a message format of the protocol processing unit, and in this embodiment, the preset bytes are illustrated by taking 2 bytes as examples, which are merely specific examples, and the preset bytes of the message offset may be set as other parameters in an actual use process, which is not described in detail herein. The present embodiment does not limit the number of the message, and in the actual use process, the number of the message may be any identifier capable of uniquely indicating the message.
And secondly, based on the message number, generating a table lookup request to inquire a pre-configured tcam rule table, wherein the table lookup request comprises a message, a message number and a protocol layer type included in the message.
Step 102, according to the table lookup request, the message is matched with a tcam rule table pre-configured by the target protocol processing unit in parallel, a matched action table is generated, and key information of the message is extracted.
In the embodiment of the invention, a tcam rule table pre-configured by a target protocol processing unit is matched according to a table lookup request and a message. The tcam rule table includes a key value configured according to a network protocol layer type, a mask, and a protocol layer type. If the table lookup request information is matched with the tcam rule table, generating an action table comprising a matching result, and extracting key information of the message according to the action table. If the table lookup request information is not matched with the tcam rule table, the message is transmitted to the next target protocol processing unit.
It should be noted that, a TCAM (ternary content-address memory) is a special high-speed memory, and can search out data in a single clock cycle. The saved table entries are very flexible in length requirement, key table entries with arbitrary length can be saved in the same TCAM chip, each table entry in the TCAM rule table is saved in the form of < address and mask >, and the address and mask occupy W bits respectively on the assumption that the length of the address key ranges from 1 to W. For an entry of key length Y (1. Ltoreq.Y. Ltoreq.W), its first Y bits of the mask are 1, while the remaining W-Y bits are 0, and its last W-Y bits of the address may be 0 or 1.
In this embodiment, a target protocol processing unit corresponding to a message to be analyzed is determined in a message analysis module, an input interface of each protocol processing unit has a register configuration interface, a message input interface, a tcam rule configuration interface, a protocol layer type input interface of a previous protocol processing unit, a key information input interface, and an output interface has a message output interface, a structure table of key information extracted by message analysis, and a protocol layer type of a next protocol processing unit.
Specifically, in response to the table lookup request, a key value key, a mask msk and a protocol layer type cur_type in a tcam rule are read, wherein the mask supports bit level, and cur_type is the protocol layer type analyzed by the current target protocol processing unit. Inquiring the information of a pre-configured tcam rule table through the message and the message number, and obtaining the action table of the rule if the information hits. The action table includes the protocol type of the next target protocol processing unit, the length of the current protocol layer, and the offset and length of key information of the message to be extracted, and four key fields are extracted at maximum, if more extraction is needed, the bit width of the action can be widened, and flexible configuration can be realized.
If the table lookup request information is matched with the tcam rule table, extracting key information of the message according to the offset and the length of key information in the action table which is generated to be matched, sequentially placing the key information into a queue with a byte bit width according to the sequence of arrangement, transmitting the key information to a next target protocol processing unit, and if the table lookup request information is not matched with the tcam rule table, filling 0 in the queue, and transmitting the message to the next target protocol processing unit.
And 103, stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message.
In this embodiment, the message is stripped according to the preset protocol layer length of the target protocol processing unit in the action table, and the remaining message part is transmitted to the next target protocol processing unit for processing. Each target protocol processing unit independently processes one layer of protocol, and after the protocol layer processing is finished, the content of the current protocol layer is stripped and sent to the next target protocol processing unit to process the protocol of the next layer. If the current target protocol processing unit encounters an unidentified protocol type, the message is transmitted to the following target protocol processing unit without processing, and the whole target protocol processing unit connected in series is finished by analogy until the analysis is finished, so that the line speed processing is achieved.
Specifically, in some embodiments, step 103 strips the message according to the length of the preset protocol layer in the action table to obtain the data information of the message, and may include the following steps:
firstly, stripping key information from a message according to the length of a preset protocol layer in an action table;
secondly, transmitting the message from which the key information is stripped to a next target protocol processing unit;
Finally, under the condition that the protocol layer information of the message is stripped, the data information of the message is obtained.
The message analysis method provided by the embodiment of the invention is applied to a message analysis module, wherein the message analysis module comprises a plurality of protocol processing units, a table look-up request is generated according to a message by receiving the message to be analyzed, a message is matched with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table look-up request, a matched action table is generated, key information of the message is extracted, the message is stripped according to the length of a preset protocol layer in the action table, and data information of the message is obtained. The invention distributes a protocol processing unit for each layer of protocol separately, processes according to the network protocol layer sequence pipeline, does not need to buffer the message, saves the register resource in the module, can meet the high performance requirement, matches the message with the pre-configured tcam rule table of the target protocol processing unit in parallel, strips out the data information of the message, thereby realizing the line speed and high efficiency message analysis, and can flexibly configure the register and the tcam rule table in the module, achieve the purpose of analyzing various protocol messages, avoid repeatedly modifying hardware codes and shorten the development period.
Specifically, referring to fig. 2, fig. 2 is a flowchart of a method of step 102 of a message parsing method provided in the embodiment of the present invention, where step 102 matches a message with a tcam rule table pre-configured by a target protocol processing unit in parallel according to a table lookup request, generates a matched action table, extracts key information of the message, and includes:
step 1021, matching a pre-configured tcam rule table of the target protocol processing unit according to the message.
The tcam rule table includes a key value configured according to a network protocol layer type, a mask, and a protocol layer type.
Step 1022, if the table lookup request information is matched with the tcam rule table, generating an action table including a matching result, and extracting key information of the message according to the action table.
Step 1023, otherwise, the message is transmitted to the next target protocol processing unit.
In the steps 1021-1023, after obtaining the table look-up request of the message to be analyzed, the tcam rule table pre-configured by the target protocol processing unit is matched according to the table look-up request and the message content. The tcam rule table includes a key value configured according to a network protocol layer type, a mask, and a protocol layer type. If the table lookup request information is matched with the tcam rule table, generating an action table comprising a matching result, and extracting key information of the message according to the action table; if the table lookup request information is not matched with the tcam rule table, the message is transmitted to the next target protocol processing unit. It should be noted that, the target protocol processing unit can flexibly configure the tcam rule table and the register enabling switch based on the general configuration register resource and 32 tcam rule resources, so as to make the tcam rule table and the register enabling switch be two-layer, three-layer or other custom protocol processing units, and implement a message covering most protocol types, thereby avoiding the problem of modifying hardware codes for supporting a certain protocol, shortening the development period, and saving time and resource cost.
Referring to fig. 3, a second step flowchart of a message parsing method provided by an embodiment of the present invention is shown, where the method may include:
step 104, determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message, and controlling the plurality of target protocol processing units to be started.
In this embodiment, the message parsing module is initialized first, the initialization information is configured through the register, and a plurality of target protocol processing units corresponding to the protocol layer type are determined according to the protocol layer information of the message, and it should be noted that, in the message parsing module, one register is used to control the enabling of the plurality of protocol processing units, only if global enabling is started, the message parsing module can have authority to participate in querying the tcam rule table, and if global enabling is not started, the message parsing module directly transmits the message from the protocol processing unit, so in this embodiment, the plurality of target protocol processing units are controlled to enable according to the determined plurality of target protocol processing units, and the protocol layer parsing processing of the message is facilitated.
And 105, extracting bit width configuration for a plurality of target protocol processing units according to the network protocol layer type.
Specifically, according to the type of the network protocol layer, the extracted bit width is configured for the multiple target protocol processing units, because according to the network protocol, the bit width required to be extracted by each protocol layer is different, if the bit width is designed according to the maximum bit width, for example, sip+dip of IPV6 is 256 bits, resource waste can be caused, meanwhile, the large bit width can cause difficulty in convergence of chip timing, that is, the extracted bit width is very necessary for the multiple target protocol processing units, and key information extracted by each target protocol processing unit is put into a queue so as to be convenient for message editing and forwarding.
Step 101, receiving a message to be analyzed, and generating a table look-up request according to the message.
Step 102, according to the table lookup request, the message is matched with a tcam rule table pre-configured by the target protocol processing unit in parallel, a matched action table is generated, and key information of the message is extracted.
And 103, stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message.
Steps 101 to 103 are not repeated again with reference to the foregoing.
In this embodiment, the specific execution positions of steps 104 and 105 are not limited, and in this embodiment, steps 104 and 105 are executed as an example before step 101 for the sake of understanding. In the actual use process, steps 104 and 105 may also be completed as one step, and each case will not be described in detail herein.
Specifically, step 105 may further include, after extracting the bit width configuration from the plurality of target protocol processing units according to the network protocol layer type:
according to the network protocol layer type, configuring a tcam rule table for a plurality of target protocol processing units, wherein the tcam rule table is used for extracting message key information corresponding to the target processing units;
And configuring the protocol layer type of the next target protocol processing unit based on the action table generated by the tcam rule table.
By way of example, the configuration procedure is: if the message to be analyzed is a seven-tuple (SMAC, DMAC, SIP, DIP, IP _ PROTOCOL, SP, DP), the number of message layers is four, namely a MAC layer, an IP layer, a TCP layer and a message load layer. Firstly, initializing configuration is carried out, and enabling switches for configuring a target protocol processing unit stage1, a target protocol processing unit stage2, a target protocol processing unit stage3 and a target protocol processing unit stage10 are determined to be opened, and other enabling switches are determined to be closed. Stage1 processes mac layer related information, configures bit width of extracted key information, and the extracted bit width can be configured to 96 bits due to the need of extracting smac and dmac. Similarly, stage2 processes IP layer related information, and since it is ipv4, the tag extraction bit width is set to 72 bits. Stage3 processes tcp layer information and configures the extraction bit width to be 32 bits. The Stage10 can automatically calculate the checksum of the message data information without any configuration.
The tcam rule table is then configured: the Stage1 custom MAC TYPE is MAC_TYPE, the cur_type input by Stage1 is fixed to MAC_TYPE, the protocol layer TYPE cur_type of the tcam rule table is configured to MAC_TYPE, and corresponding msk is filled with 0.Key0 fills 0x0800, offset is configured to be 6, corresponding to msk position 0, other keys 1, 2, 3 fill 0xffff, corresponding to msk each bit 1, indicating no concern. IPV4_TYPE is filled in n xt_type in the action table, head_len is 14, rsp0_offset is filled in 0, rsp1_offset is filled in 6, and the rest is filled in 0xff to indicate invalidation, so that smac/dmac can be extracted. Similarly, stage2 configuration will correspond to extracting SIP, DIP, IP _PROTOCOL and Stage3 configuration will correspond to extracting SP, DP.
On the basis of achieving the beneficial effects of the first embodiment, the embodiment of the invention can flexibly configure the register and the tcam rule table in the module, achieves the purpose of analyzing various protocol messages, avoids repeatedly modifying hardware codes, shortens the development period, and simultaneously facilitates the subsequent transfer of IC streaming. And moreover, a common modularized design style of IC design is adopted, and a complex network protocol is processed in a grading manner according to a network protocol layer, so that the maintenance and multiplexing are convenient.
Referring to fig. 4, a third step flowchart of a message parsing method provided by an embodiment of the present invention is shown, where the method may further include:
step 101, receiving a message to be analyzed, and generating a table look-up request according to the message.
Step 102, according to the table lookup request, the message is matched with a tcam rule table pre-configured by the target protocol processing unit in parallel, a matched action table is generated, and key information of the message is extracted.
And 103, stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message.
Steps 101 to 103 are not repeated again with reference to the foregoing.
And 106, generating a checksum of the data information according to the data information of the message.
In this embodiment, the message parsing module is divided into a plurality of protocol processing units, each protocol processing unit completes processing of a layer of protocol, and the plurality of protocol processing units are connected in series, so that the whole message is processed in a pipeline. The determined target protocol processing unit is used for processing analysis of a network protocol layer, when the last target protocol processing unit is reached, data information of a message is obtained, and according to the data information of the message, a checksum of the data information is generated, so that when a packet editing module at the back of the intelligent network card recalculates the udp/tcp checksum, the whole packet does not need to be cached for calculation, and a certain acceleration effect is achieved.
And step 107, determining that the message analysis is effective by verifying the checksum, and sending the data information to a message editing module.
On the basis of achieving the beneficial effects of the first embodiment, the embodiment of the invention confirms that the message analysis is effective by verifying the checksum of the message data information, sends the data information to the message editing module for editing and forwarding, realizes that a plurality of protocol processing units analyze the network message at the same time and obtain the message analysis result, does not need to wait for a single line, greatly reduces the processing time delay, obviously improves the analysis speed of the network message, and meanwhile, the analysis of the subsequent message is not influenced by the error in the network message in the application, and has higher system fault tolerance.
Referring to fig. 5, a flowchart of a method for parsing a message according to an embodiment of the present invention is shown, where the method may include:
step 201, preprocessing the message to generate a message number.
Specifically, preprocessing a message, and offsetting the content of the message according to a byte as a unit to make a number, for example, the first byte of the message is numbered 0, the next byte is numbered 1, and the like to generate a message number.
Step 202, according to the table lookup request, inquiring a pre-configured tcam rule table.
Specifically, the message corresponding to the last step of numbering and backward shifting two bytes, and the cur_type protocol layer type of the protocol processing unit of the message analysis module form a table lookup request, and the table lookup request queries a pre-configured tcam rule table under the condition that the protocol layer type is judged to be legal in the current protocol processing unit.
Step 203, determining whether the message and the tcam rule table are matched.
Specifically, according to the table lookup request and the message content, a tcam rule table pre-configured by the target protocol processing unit is matched. The tcam rule table includes a key value configured according to a network protocol layer type, a mask, and a protocol layer type. If the table lookup request information is matched with the tcam rule table, entering a step 204, generating an action table comprising a matching result, and extracting key information of the message according to the action table; otherwise, if the table lookup request information is not matched with the tcam rule table, the step 206 is entered, and the message is transmitted to the next target protocol processing unit.
Step 204, generating a matched action table, and extracting key information of the message.
In this embodiment, the message and the message number are used to query the pre-configured information of the tcam rule table, and if the information matches the hit, the action table of the rule is generated. The action table includes the protocol type of the next target protocol processing unit, the length of the current protocol layer, and the offset and length of the key information of the message to be extracted.
And 205, stripping the message to obtain the data information of the message.
Specifically, the message is stripped according to the length of a preset protocol layer of the target protocol processing unit in the action table, and the rest message part is transmitted to the next target protocol processing unit for processing.
Step 206, the message is transmitted to the next target protocol processing unit.
The message analysis method provided by the embodiment of the invention is applied to a message analysis module, wherein the message analysis module comprises a plurality of protocol processing units, a table look-up request is generated according to a message by receiving the message to be analyzed, a message is matched with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table look-up request, a matched action table is generated, key information of the message is extracted, the message is stripped according to the length of a preset protocol layer in the action table, and data information of the message is obtained. The invention distributes a protocol processing unit for each layer of protocol separately, processes according to the network protocol layer sequence pipeline, does not need to buffer the message, saves the register resource in the module, can meet the high performance requirement, matches the message with the pre-configured tcam rule table of the target protocol processing unit in parallel, strips out the data information of the message, thereby realizing the line speed and high efficiency message analysis, and can flexibly configure the register and the tcam rule table in the module, achieve the purpose of analyzing various protocol messages, avoid repeatedly modifying hardware codes and shorten the development period.
Referring to fig. 6, a block diagram of a device of a message parsing device provided by an embodiment of the present invention is applied to a message parsing module shown in fig. 7, where the message parsing module includes a plurality of protocol processing units, and the device includes:
the message receiving module 301 is configured to receive a message to be parsed, and generate a table look-up request according to the message;
the matching information module 302 is configured to match the message with a tcam rule table preset by the target protocol processing unit in parallel according to the table lookup request, generate a matched action table, and extract key information of the message;
and the message processing module 303 is configured to strip the message according to a preset protocol layer length in the action table, so as to obtain data information of the message.
Further, the receiving message module 301 includes:
the first processing sub-module is used for processing the message according to the preset byte offset and numbering the message;
and the second processing sub-module is used for generating a table look-up request based on the message number to inquire a pre-configured tcam rule table, wherein the table look-up request comprises the message, the message number and the protocol layer type included in the message.
Further, the matching information module 302 includes:
A matching sub-module, configured to match, according to the message, a tcam rule table configured in advance by the target protocol processing unit, where the tcam rule table includes a key value, a mask, and a protocol layer type configured according to a network protocol layer type;
a generating sub-module, configured to generate an action table including a matching result if the table lookup request information is matched with the tcam rule table, and extract key information of the message according to the action table;
and the first transmission sub-module is used for transmitting the message to the next target protocol processing unit.
Further, the message processing module 303 includes:
the third processing sub-module is used for stripping the key information from the message according to the length of a preset protocol layer in the action table;
the second transmission sub-module is used for transmitting the message from which the key information is stripped to the next target protocol processing unit;
and the fourth processing sub-module is used for obtaining the data information of the message under the condition that the protocol layer information of the message is stripped.
Further, the device further comprises:
the determining module is used for determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message and controlling the plurality of target protocol processing units to be enabled to be started;
And the first configuration module is used for carrying out bit width extraction configuration on the plurality of target protocol processing units according to the network protocol layer type.
Further, the device further comprises:
the second configuration module is used for configuring a tcam rule table for a plurality of target protocol processing units according to the network protocol layer type, wherein the tcam rule table is used for extracting message key information corresponding to the target processing units;
and the third configuration module is used for configuring the protocol layer type of the next target protocol processing unit based on the action table generated by the tcam rule table.
Further, the device further comprises:
the generation module is used for generating a checksum of the data information according to the data information of the message;
and the message sending module is used for determining that the message analysis is effective through verifying the checksum and sending the data information to the message editing module.
According to the message analysis device provided by the embodiment of the invention, the message to be analyzed is received, the table lookup request is generated according to the message, the message is matched with the tcam rule table preset by the target protocol processing unit in parallel according to the table lookup request, the matched action table is generated, the key information of the message is extracted, the message is stripped according to the length of the preset protocol layer in the action table, and the data information of the message is obtained. The invention distributes a protocol processing unit for each layer of protocol separately, processes according to the network protocol layer sequence pipeline, does not need to buffer the message, saves the register resource in the module, can meet the high performance requirement, matches the message with the pre-configured tcam rule table of the target protocol processing unit in parallel, strips out the data information of the message, thereby realizing the line speed and high efficiency message analysis, and can flexibly configure the register and the tcam rule table in the module, achieve the purpose of analyzing various protocol messages, avoid repeatedly modifying hardware codes and shorten the development period.
The embodiment of the present invention further provides an electronic device, as shown in fig. 8, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 perform communication with each other through the communication bus 404,
a memory 403 for storing a computer program;
the processor 401, when executing the program stored in the memory 403, may implement the following steps:
receiving a message to be analyzed, generating a table look-up request according to the message, matching the message with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table look-up request, generating a matched action table, extracting key information of the message, and stripping the message according to the length of a preset protocol layer in the action table to obtain data information of the message.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where instructions are stored, which when executed on a computer, cause the computer to perform the method for parsing a message according to any one of the embodiments above.
In yet another embodiment of the present invention, a computer program product containing instructions that, when executed on a computer, cause the computer to perform the method of message parsing according to any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it is further noted that 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 terminal 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 terminal. 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 terminal device comprising the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The above detailed description of the method, the device, the electronic device and the storage medium for message parsing provided by the invention applies specific examples to illustrate the principle and the implementation of the invention, and the above description of the examples is only used for helping to understand the method and the core idea of the invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (11)

1. The message parsing method is characterized by being applied to a message parsing module, wherein the message parsing module comprises a plurality of protocol processing units, and the method comprises the following steps:
Receiving a message to be analyzed, generating a table look-up request according to the message, and comprising: processing the message according to preset byte offset, carrying out message numbering, and generating a table look-up request based on the message numbering to inquire a pre-configured tcam rule table, wherein the table look-up request comprises the message, the message numbering and a protocol layer type included in the message;
according to the table lookup request, the message is matched with a tcam rule table pre-configured by a target protocol processing unit in parallel, a matched action table is generated, key information of the message is extracted, and the action table comprises a protocol type of a next target protocol processing unit;
stripping the message according to the length of a preset protocol layer in the action table to obtain the data information of the message, wherein the method comprises the following steps: and stripping the key information from the message according to the length of a preset protocol layer in the action table, transmitting the message stripped with the key information to a next target protocol processing unit, and obtaining the data information of the message under the condition that the protocol layer information stripping of the message is completed.
2. The method of claim 1, wherein the step of matching the message with a tcam rule table pre-configured by a target protocol processing unit in parallel according to the table lookup request to generate a matched action table, and extracting key information of the message comprises:
Matching a pre-configured tcam rule table of the target protocol processing unit according to the message, wherein the tcam rule table comprises a key value, a mask and a protocol layer type configured according to a network protocol layer type;
if the table lookup request information is matched with the tcam rule table, generating an action table comprising a matching result, and extracting key information of the message according to the action table;
otherwise, the message is transmitted to the next target protocol processing unit.
3. The method of claim 1, wherein the receiving the message to be parsed, before generating the lookup request according to the message, further comprises:
determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message, and controlling the plurality of target protocol processing units to be started;
and according to the network protocol layer type, extracting bit width configuration is carried out on the plurality of target protocol processing units.
4. The method according to claim 3, wherein after extracting the bit width configuration from the plurality of target protocol processing units according to the network protocol layer type, further comprising:
configuring a tcam rule table for a plurality of target protocol processing units according to the network protocol layer type, wherein the tcam rule table is used for extracting message key information corresponding to the target protocol processing units;
And configuring the protocol layer type of the next target protocol processing unit based on an action table generated by the tcam rule table.
5. The method of claim 1, wherein the stripping the message according to the length of the preset protocol layer in the action table to obtain the data information of the message further comprises:
generating a checksum of the data information according to the data information of the message;
and verifying the checksum to determine that the message analysis is effective, and sending the data information to a message editing module.
6. A message parsing apparatus, applied to a message parsing module, where the message parsing module includes a plurality of protocol processing units, the apparatus includes:
the message receiving module is used for receiving a message to be analyzed, generating a table look-up request according to the message, and comprises: the first processing sub-module is used for processing the message according to preset byte offset and carrying out message numbering, and the second processing sub-module is used for generating a table look-up request based on the message numbering to inquire a pre-configured tcam rule table, wherein the table look-up request comprises the message, the message numbering and a protocol layer type included in the message;
The matching information module is used for parallelly matching the message with a tcam rule table pre-configured by a target protocol processing unit according to the table lookup request, generating a matched action table, and extracting key information of the message, wherein the action table comprises a protocol type of a next target protocol processing unit;
the message processing module is configured to strip the message according to a length of a preset protocol layer in the action table to obtain data information of the message, where the message processing module includes: the third processing sub-module is used for stripping the key information from the message according to the length of a preset protocol layer in the action table; the second transmission sub-module is used for transmitting the message from which the key information is stripped to the next target protocol processing unit; and the fourth processing sub-module is used for obtaining the data information of the message under the condition that the protocol layer information of the message is stripped.
7. The apparatus of claim 6, wherein the match information module comprises:
a matching sub-module, configured to match, according to the message, a tcam rule table configured in advance by the target protocol processing unit, where the tcam rule table includes a key value, a mask, and a protocol layer type configured according to a network protocol layer type;
A generating sub-module, configured to generate an action table including a matching result if the table lookup request information is matched with the tcam rule table, and extract key information of the message according to the action table;
and the first transmission sub-module is used for transmitting the message to the next target protocol processing unit.
8. The apparatus of claim 6, wherein the apparatus further comprises:
the determining module is used for determining a plurality of target protocol processing units corresponding to the protocol layer type according to the protocol layer information of the message and controlling the plurality of target protocol processing units to be enabled to be started;
and the first configuration module is used for carrying out bit width extraction configuration on the plurality of target protocol processing units according to the network protocol layer type.
9. The apparatus of claim 8, wherein the apparatus further comprises:
the second configuration module is used for configuring a tcam rule table for a plurality of target protocol processing units according to the network protocol layer type, wherein the tcam rule table is used for extracting message key information corresponding to the target protocol processing units;
and the third configuration module is used for configuring the protocol layer type of the next target protocol processing unit based on the action table generated by the tcam rule table.
10. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the steps of the message parsing method according to any one of claims 1 to 5 when executing the program stored in the memory.
11. A readable storage medium, wherein a computer program is stored on the readable storage medium, which when executed by a processor, implements the steps of the message parsing method according to any one of claims 1 to 5.
CN202310083400.2A 2023-02-08 2023-02-08 Message parsing method and device, electronic equipment and storage medium Active CN115883681B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310083400.2A CN115883681B (en) 2023-02-08 2023-02-08 Message parsing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310083400.2A CN115883681B (en) 2023-02-08 2023-02-08 Message parsing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115883681A CN115883681A (en) 2023-03-31
CN115883681B true CN115883681B (en) 2023-06-23

Family

ID=85760874

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310083400.2A Active CN115883681B (en) 2023-02-08 2023-02-08 Message parsing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115883681B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116156026B (en) * 2023-04-20 2023-07-04 中国人民解放军国防科技大学 RMT-supporting parser, reverse parser, parsing method and switch
CN117938987B (en) * 2024-03-25 2024-06-18 天津布尔科技有限公司 Protocol gateway applied to Internet of vehicles and control method thereof

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1585379A (en) * 2004-05-25 2005-02-23 华中科技大学 Rapid analyzing method for data pack
CN109672669A (en) * 2018-12-03 2019-04-23 国家计算机网络与信息安全管理中心 The filter method and device of traffic messages
CN113691486A (en) * 2020-05-19 2021-11-23 中移(成都)信息通信科技有限公司 Message modification method, device, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10341242B2 (en) * 2016-12-13 2019-07-02 Oracle International Corporation System and method for providing a programmable packet classification framework for use in a network device
CN115088239A (en) * 2019-12-13 2022-09-20 马维尔以色列(M.I.S.L.)有限公司 Hybrid fixed/programmable header parser for network devices
CN111277612B (en) * 2020-05-08 2020-08-07 常州楠菲微电子有限公司 Network message processing strategy generation method, system and medium
CN112732241B (en) * 2021-01-08 2022-04-01 烽火通信科技股份有限公司 Programmable analyzer under multistage parallel high-speed processing and analysis method thereof
CN112929281B (en) * 2021-02-04 2023-01-10 恒安嘉新(北京)科技股份公司 Message processing method, device and equipment of network equipment based on FPGA

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1585379A (en) * 2004-05-25 2005-02-23 华中科技大学 Rapid analyzing method for data pack
CN109672669A (en) * 2018-12-03 2019-04-23 国家计算机网络与信息安全管理中心 The filter method and device of traffic messages
CN113691486A (en) * 2020-05-19 2021-11-23 中移(成都)信息通信科技有限公司 Message modification method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于FPGA的低功耗高速网络报文解析系统设计;杨斌;电子技术与软件工程;全文 *
基于TCAM的高速报文过滤卡设计;李洪兰等;科学技术与工程;全文 *

Also Published As

Publication number Publication date
CN115883681A (en) 2023-03-31

Similar Documents

Publication Publication Date Title
CN115883681B (en) Message parsing method and device, electronic equipment and storage medium
CN108768866B (en) Cross-card forwarding method and device for multicast message, network equipment and readable storage medium
US7599364B2 (en) Configurable network connection address forming hardware
WO2016029684A1 (en) Packet processing and forwarding device and method, and computer storage medium
WO2016107122A1 (en) Method and device for converting between rapidio packet and ethernet packet
EP3657742A1 (en) Method and apparatus for processing modified packet
CN111614580B (en) Data forwarding method, device and equipment
US20220393908A1 (en) Message Encapsulation Method and Apparatus, and Message Decapsulation Method and Apparatus
CN113612801B (en) EPA gateway equipment and EPA cross-network communication method
CN114827292A (en) Industrial heterogeneous protocol high-speed conversion optimization processing method and system
CN103986714B (en) Bus marco network insertion AVB networks are acted on behalf of into implementation method and device
CN110677314B (en) Network interface testing method, system, electronic device and storage medium
CN105515995A (en) Message processing method and apparatus, and flow table generation method and apparatus
CN110535747B (en) Message processing device and method
WO2014146571A1 (en) Network processor, and network processor-based packet preprocessing method and device
CN114079634B (en) Message forwarding method and device and computer readable storage medium
CN107241236B (en) Forwarding information base table item detection method, detection equipment and network equipment
CN114978986A (en) Data transmission method, device and storage medium
CN105704023B (en) Message forwarding method and device of stacking system and stacking equipment
Khattak et al. TOSwitch: Programmable and high-throughput switch using hybrid switching chips
CN105450527B (en) The method and device for handling message, sending information, receiving information
US10205664B2 (en) System and method for routing
CN112910783B (en) Message forwarding method and device and distributed equipment
US11882039B1 (en) UDF-based traffic offloading methods and systems
CN116074404A (en) Parsing device, message parsing method, forwarding chip and network equipment

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
CP02 Change in the address of a patent holder

Address after: 100007 room 205-32, floor 2, building 2, No. 1 and No. 3, qinglonghutong a, Dongcheng District, Beijing

Patentee after: Tianyiyun Technology Co.,Ltd.

Address before: 100093 Floor 4, Block E, Xishan Yingfu Business Center, Haidian District, Beijing

Patentee before: Tianyiyun Technology Co.,Ltd.

CP02 Change in the address of a patent holder