Message segmentation parsing method, device, equipment and storage medium
The message is parsed in stages through the segmented parsing method, skipping unnecessary parsing stages, solving the problems of low versatility and slow parsing speed in the existing technology, and achieving efficient multi-type data packet parsing.
Patent Information
- Application Number
- CN202111242584.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-10-25
AI Technical Summary
The existing technology has low versatility when parsing multi-type data packets, resulting in a reduction in system parsing speed, and multiple parsing modules need to be added to adapt to different data types, which increases the amount of code development and parsing complexity.
Using the segmented parsing method, the header of the message is parsed in stages according to the parsing configuration information, skipping unnecessary parsing stages, using field parsing information and stage flow information to determine the next layer header type and offset address, and parsing the header step by step , until the maximum resolution stage is completed.
It improves the speed and versatility of data parsing, reduces the amount of code development, and avoids unnecessary parsing consumption. It is suitable for data packets carrying different types of headers.
Smart Images

Figure CN116033044B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network technology, and in particular to a message segmentation parsing method, device, equipment and storage medium. Background Art
[0002] For a multi-layer network structure, different layers perform different functions, and each layer is composed of many protocols. Correctly parsing data packets is an important part of data transmission. Whether it is data processing or data forwarding, it is necessary to parse the data packet and obtain the corresponding header information of the data packet, such as MAC (medium access control) address, Internet Protocol (IP) protocol, IP address, etc.
[0003] The current mainstream method for parsing data packets is to develop specific parsing modules based on the data type, where the data format and data length are fixed. If you need to process multiple types of data packets, you need to add multiple parsing modules. This type of parsing method has low versatility and is suitable for application scenarios with low data complexity. In addition, since the data that needs to be processed at each layer of this type of parsing method is a complete data packet, the length of the data that needs to be processed is long, which reduces the parsing speed of the system. It is not very flexible for communication systems with different data packet transmission types, which will greatly reduce the processing speed of system parsing. Summary of the invention
[0004] The embodiments of the present disclosure provide a method, apparatus, device and storage medium for segmentation parsing of a message.
[0005] The technical solution of the present disclosure is achieved as follows:
[0006] In a first aspect, a method for segmented parsing of a message is provided, wherein the message to be parsed includes: a header; the method includes:
[0007] According to the parsing configuration information, the header is parsed for the nth stage to obtain the parsing result for the nth stage, wherein when n is less than N, the parsing result for the nth stage includes: the header information parsed for the nth stage, the next layer header type to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum number of parsing stages for the header;
[0008] When the next-layer header type is not the header type parsed at the n+1 stage, skip the n+1 stage parsing of the header and proceed to the n+2 stage parsing;
[0009] When the next layer header type is a header type parsed at the n+1th stage, performing the n+1th stage parsing on the header according to the offset address;
[0010] When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0011] In the above technical solution, the parsing configuration information includes: field parsing information and stage flow information;
[0012] The performing an n-stage parsing on the header according to the parsing configuration information to obtain an n-stage parsing result includes:
[0013] According to the field parsing information of the nth stage and the type of the header to be parsed in the nth stage, the header field is parsed; wherein the header field includes: frame type, header length, header number and / or mask;
[0014] The stage flow information of the nth stage is queried according to the header domain field to determine the next layer header type to be parsed and the offset address of the next stage parsing.
[0015] In the above technical solution, the performing the n+1 stage parsing of the header according to the offset address includes:
[0016] When performing the parsing at the n+1th stage, matching the header field to be parsed contained in the header with the header field table at the n+1th stage;
[0017] If the header field to be parsed contained in the header is a valid field contained in the header field table in the (n+1)th stage, the content of the header field to be parsed contained in the header is parsed.
[0018] In the above technical solution, the method further comprises:
[0019] If the header field to be parsed contained in the header is an invalid field that is not included in the header field table in the n+1th stage, the parsing of the n+1th stage is stopped.
[0020] In the above technical solution, the method further comprises:
[0021] When the received data packet is larger than the processable packet length of the segmented parsing, the data packet is divided into multiple data segments according to the preset length;
[0022] Performing segmented parsing of the header starting from the first data segment;
[0023] The parsing results of the segmented parsing of the multiple data segments are concatenated to obtain the parsing result of the header.
[0024] In the above technical solution, when the next layer header type is a header type parsed at the n+1 stage, performing the n+1 stage parsing on the header according to the offset address includes:
[0025] When performing the n+1 stage parsing of this data segment, if it is determined that the field part to be parsed is located in the next data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed in combination with the current data segment and the next data segment.
[0026] In the above technical solution, the step of performing the n+1th stage analysis in combination with the current data segment and the next data segment includes:
[0027] Performing an n+1th stage parsing on the data segment according to the offset address, obtaining a first part of fields indicating a parsing result of the n+1th stage, and determining that the parsing of the n+1th stage is not completed;
[0028] After the next data segment enters the unparsed n+1th stage, according to the length of the first part of fields and the header length of the next layer header type, continue to parse the next data segment in the n+1th stage to obtain a second part of fields indicating the parsing result of the n+1th stage;
[0029] The second part of fields is concatenated onto the end of the first part of fields to obtain the parsing result of the n+1th stage.
[0030] In the above technical solution, when the next layer header type is a header type parsed at the n+1 stage, performing the n+1 stage parsing on the header according to the offset address includes:
[0031] When the n+1 stage parsing is performed on the current data segment, if it is determined that all the fields to be parsed are located in the current data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed on the current data segment to obtain the n+1 stage parsing result.
[0032] In a second aspect, a device for segmented parsing of a message is provided, wherein the message to be parsed includes: a header; the device includes a stage parsing module; the stage parsing module is used to:
[0033] According to the parsing configuration information, the header is parsed for the nth stage to obtain the parsing result for the nth stage, wherein when n is less than N, the parsing result for the nth stage includes: the header information parsed for the nth stage, the next layer header type to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum number of parsing stages for the header;
[0034] When the next-layer header type is not the header type parsed at the n+1 stage, skip the n+1 stage parsing of the header and proceed to the n+2 stage parsing;
[0035] When the next layer header type is a header type parsed at the n+1th stage, performing the n+1th stage parsing on the header according to the offset address;
[0036] When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0037] According to a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the segmented parsing method of the message described in any one of the first aspects are implemented.
[0038] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the message segmentation parsing method described in any one of the first aspects are implemented.
[0039] The message segmentation parsing method, apparatus, device and storage medium provided by the embodiments of the present disclosure perform an n-stage parsing on a header included in the message according to parsing configuration information to obtain an n-stage parsing result. When the type of the next layer header to be parsed included in the n-stage parsing result is not the type of the header parsed in the n+1-stage, skip the n+1-stage parsing of the header and enter the n+2-stage parsing. When the type of the next layer header to be parsed is the type of the header parsed in the n+1-stage, perform an n+2-stage parsing on the header according to the offset address of the next stage included in the n-stage parsing result. 1 stage parsing, and when the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, stop the current segmented parsing of the header. In this way, on the first hand, no matter which stages of the current message carries headers that can be parsed, they can be parsed. Therefore, a universal parsing method can be used at different stages for messages carrying different types of headers. In this way, when segmenting and parsing multiple types of data packets, there is no need to add multiple parsing modules, only one parsing module needs to be written, and the parsing code for each stage is the same, thereby reducing the amount of parsing code development and increasing versatility. On the second hand, when the header of the corresponding stage is not carried, the corresponding stage is skipped, saving the parsing cost of unnecessary stage headers. On the third hand, skipping the unnecessary parsing header stage can greatly improve the data parsing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A schematic diagram of a flow chart of a method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0041] Figure 2 Another schematic diagram of a flow chart of a method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0042] Figure 3 Another flowchart of the method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0043] Figure 4 A further flow chart of the method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0044] Figure 5 A further flow chart of the method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0045] Figure 6 A specific example flow chart of the method for segmented parsing of a message provided in an embodiment of the present disclosure;
[0046] Figure 7 A structural diagram of a segmented parsing device for a message provided in an embodiment of the present disclosure;
[0047] Figure 8 for Figure 7 A schematic diagram of the specific structure of the stage analysis module in the device shown;
[0048] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure. In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments can be arbitrarily combined with each other. The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. In addition, although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0050] It can be understood that the description of various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0051] When data is transmitted in the network, the data packet includes a header and a body. When the data packet reaches its destination, the data packet needs to be parsed out because it is processed and unpacked in the opposite order of each protocol layer.
[0052] The mainstream data parsing method often uses parsing modules with fixed data formats and data lengths to parse the header information of data packets. For example, according to the structure of Ethernet headers, ARP headers, ICMP headers, etc., corresponding parsing modules are written respectively. This type of parsing method has low versatility and is suitable for application scenarios with low data complexity.
[0053] In addition, according to the order of the seven-layer structure of open systems interconnection from low to high, the hierarchical parsing steps are performed on the data packet headers of the corresponding protocols in each layer in the header field of the network data message in turn, which can achieve the purpose of generalization. However, with the introduction of overlapping tunnel protocols such as VXLAN (virtual extensible local area network), virtual switching technologies such as OpenFlow and Open vSwitch (OVS), and QinQ technology, the complexity of the data plane in the network has increased dramatically, and the complexity of parsing and the difficulty of upgrading have increased. This parsing method can no longer meet the data header parsing of these complex application scenarios. For example, QinQ technology is based on the Ethernet protocol and will have multiple VLAN TAGs. This parsing method cannot be further parsed according to the protocol type.
[0054] In addition, since the data that needs to be processed at each layer of the above-mentioned parsing method includes all data packets, the length of data that needs to be processed at each stage is relatively long, which reduces the parsing speed of the system. It is not very flexible for communication systems with different data packet transmission types, which will greatly reduce the processing speed of system parsing.
[0055] To this end, the present disclosure provides a method for segmenting and parsing a message, see Figure 1 As shown, the segment parsing method of the message may include:
[0056] 101. According to the parsing configuration information, perform an n-stage parsing on the header included in the message to obtain an n-stage parsing result, wherein when n is less than N, the n-stage parsing result includes: the header information parsed in the n-stage, the next layer header type to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum number of parsing stages for the header.
[0057] The nth stage is used to parse the protocol header of the nth layer in the network layered architecture. According to the network layered architecture, the message can be parsed in stages from the outside to the inside. Each stage can parse multiple protocol headers. The layered methods of the network layered architecture include the OSI (Open System Interconnect) seven-layer model and the TCP / IP four-layer model.
[0058] Each stage is pre-configured with corresponding parsing configuration information, which is also called stage preset information. The parsing configuration information of each stage is stored in the stage preset information table. The parsing configuration information of the nth stage is used to perform the nth stage parsing on the header included in the message to obtain the nth stage parsing result.
[0059] The next layer header type refers to the protocol type of the next layer header. Here, it should be noted that the next layer header type to be parsed in the message included in the parsing result of the nth stage refers to the header type of any layer from the n+1th layer to the Nth layer in the message. For example, when the next layer header type is a header type that can be parsed by the n+2th layer, the message will not be processed after entering the n+1th stage and will directly flow to the n+2th stage for parsing.
[0060] The offset address of the next stage refers to the header offset of the next stage, which is used to point to the starting position of the next layer protocol header in the data packet.
[0061] It can be understood that the parsing result of the nth stage includes not only the next layer header type to be parsed in the message and the offset address of the next stage of parsing, but also the header information and key information of the nth layer. For example, for the Ethernet header, its key information includes the source MAC address and destination MAC address, etc.
[0062] It should be noted that, whenever a stage is parsed, the parsing result of the stage, such as the obtained header information and key information, is stored in the corresponding position, and then jumps to the next stage.
[0063] 102. When the next layer header type is not the header type parsed at the n+1 stage, the n+1 stage parsing of the header is skipped and the parsing at the n+2 stage is entered.
[0064] Specifically, when the next layer header type is not included in the stage preset information of the (n+1)th stage, it is determined that the next layer header type is not the header type parsed in the (n+1)th stage.
[0065] 103. When the next layer header type is the header type parsed at the n+1 stage, the header is parsed at the n+1 stage according to the offset address.
[0066] Specifically, when the next layer header type is included in the preset information table of the n+1th stage, it is determined that the next layer header type is the header type parsed in the n+1th stage.
[0067] 104. When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0068] The segmented parsing method of the message provided in the embodiment of the present disclosure skips the n+1 stage parsing of the header and enters the n+2 stage parsing when the next layer header type to be parsed included in the result of the nth stage parsing of the header is not the header type parsed in the n+1 stage.
[0069] One stage of parsing in the embodiment of the present disclosure may correspond to parsing of a layer of protocol of network transmission of a data packet.
[0070] If the message is transmitted according to the TCP / IP protocol, the message may contain at most 4 layers of protocols, namely, the application layer protocol, the transport layer protocol, the network layer protocol and the data link layer protocol. In this case, N may be equal to 4, that is, one stage corresponds to the header parsing of one layer.
[0071] A layer may include multiple different protocols, and the types of headers carried in the headers are different. For example, taking the transport layer as an example, the types of headers corresponding to this layer may include but are not limited to: TCP header and UDP header. Taking the network layer as an example, the types of packet headers corresponding to this layer may include but are not limited to: ICMP header, ARP header, RARP header.
[0072] When the next layer header type to be parsed is the header type parsed in the n+1th stage, the header is parsed in the n+1th stage according to the offset address of the next stage included in the parsing result of the nth stage, and when the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segmented parsing of the header is stopped. In this way, no matter which stage the current message carries headers that can be parsed, they can be parsed. Therefore, for messages carrying different types of headers, each stage can parse the message in a unified parsing method. In this way, when segmenting and parsing multiple types of data packets, there is no need to add multiple parsing modules, only one parsing module needs to be written, and the parsing code of each stage is the same, thereby reducing the amount of code development, increasing versatility, realizing universal data parsing, and greatly saving the logical resources of the system. In addition, since there is no need to process all the data contained in the message at each stage, the parsing speed of the data message can be greatly improved.
[0073] In one embodiment, the parsing configuration information includes: field parsing information and stage flow information.
[0074] The parsing configuration information of the nth stage includes: field parsing information and stage flow information of the nth stage.
[0075] The field parsing information of the nth stage includes: the header types that can be parsed in the nth stage and the header domain fields corresponding to each header type.
[0076] The phase flow information includes: the type of the next layer header to be parsed in the message and the offset address of the next stage. The phase flow information has a corresponding relationship with the header field.
[0077] It is understandable that the parsing configuration information may also include other configuration information, such as a header structure.
[0078] In this embodiment, the parsing configuration information of each stage, including the header type, the header field corresponding to each header type, and the stage flow information table, can be encapsulated into a function. This allows the user to call the upper-level software to modify the parsed header type and the number of parsing stages based on the application scenario, thereby achieving configurability and facilitating upgrades and iterations to meet the message parsing requirements of different applications.
[0079] like Figure 2 As shown, in the above step 101, performing the n-stage parsing on the header according to the parsing configuration information to obtain the n-stage parsing result may include:
[0080] 201. According to the field parsing information of the nth stage and the type of header to be parsed in the nth stage, parse the header field of the header; wherein the header field includes: frame type, header length, header number and / or mask.
[0081] The network transmission data is transmitted in frames, and different frame types are used to indicate the specific formats used by different protocol types in network transmission data, and different frame types have different offsets.
[0082] The header length refers to the protocol length, for example, the Ethernet header length is 14 bytes and the IPv4 header length is 20 bytes. The header number is used to uniquely identify the header type.
[0083] The mask is used to indicate the bits of the header field that need to be retained and / or the bits that need to be cleared.
[0084] It can be understood that, in actual application, the header field may only include the frame type and mask.
[0085] In an example, the preset header field fields corresponding to different header types are stored in a preset header field table. The preset header field table can be shown in Table 1 below.
[0086] Table 1: Preset header field table
[0087]
[0088]
[0089] The header field table shown in Table 1 includes the frame types that each protocol type may contain. In this way, for the application scenario of QinQ technology and the Layer 2 tunnel protocol in which the message carries two layers of VLAN Tags, multiple frame types can be set under each protocol type in the header field, and the offsets of different frame types are different.
[0090] In this embodiment, since the preset header field contains frame types that may be included in different protocol types, in this way, according to the characteristics of multiple VLAN TAGs of QinQ, each VLAN header can be obtained by setting multiple frame type fields in the preset header field. In this way, the use of frame types can further refine the parsing of data types, thereby performing subsequent parsing more accurately, which can meet the data header parsing of complex application scenarios using technologies such as QinQ.
[0091] Specifically, in step 201, according to the header field fields corresponding to each header type in the field parsing information of the nth stage, the header is parsed to obtain the header field fields corresponding to the header type to be parsed.
[0092] 202. Query the stage flow information of the nth stage according to the header field to determine the next layer header type to be parsed and the offset address of the next stage parsing.
[0093] In one example, the stage flow information of each stage is stored in a preset stage flow information table. The preset stage flow information table may be as shown in Table 2 below but is not limited to Table 2.
[0094] Table 2: Preset stage flow information table
[0095]
[0096] The stage flow information table shown in Table 2 includes the next layer header type of different header types, the offset address of the next stage, and the action flag bit of whether the current data segment is parsed. The action flag bit is 1, indicating that the current data segment is parsed, and the action flag bit is 0, indicating that the current data segment is not parsed. In this way, after obtaining the header field, the stage flow information corresponding to the header field can be found in the preset stage flow information table to obtain the next layer header type to be parsed, the offset address of the next stage, and the action flag bit of whether the current data segment is parsed.
[0097] In one embodiment, Figure 3 As shown, in the above step 103, performing the n+1 stage parsing of the header according to the offset address may include:
[0098] 301. When performing the parsing at the n+1 stage, the header field to be parsed contained in the header is matched with the header field table at the n+1 stage.
[0099] 302. If the header field to be parsed contained in the header is a valid field contained in the header field table in the (n+1)th stage, parse the content of the header field to be parsed contained in the header.
[0100] In this embodiment, when performing the n+1th phase of parsing, the header field to be parsed contained in the header can be compared with a preset header field table to determine whether the header field to be parsed matches a row of fields in the header field table. If so, the header field to be parsed is determined to be a valid field, otherwise, the header field to be parsed is determined to be an invalid field. When the header field to be parsed contained in the header is a valid field, the header is continued to be parsed to obtain the content of the header field to be parsed.
[0101] In one embodiment, continue to see Figure 3 As shown, the method may further include:
[0102] 303. If the header field to be parsed contained in the header is an invalid field that is not included in the header field table in the n+1th stage, the parsing in the n+1th stage is stopped.
[0103] In this embodiment, when it is determined that the header field to be parsed contained in the header is an invalid field, the parsing of the n+1 stage is stopped, and the process directly jumps to the n+2 stage for judgment.
[0104] In one embodiment, Figure 4 As shown, the method may further include:
[0105] 401, when the received data packet is larger than the processable packet length of the segmented parsing, the data packet is divided into multiple data segments according to preset lengths.
[0106] The processable message length may be the maximum length of the message header lengths corresponding to different message header types. Here, the processable message length is 64 bytes, but the embodiment of the present disclosure is not limited thereto.
[0107] Here, the preset length can be set according to actual application, for example, the preset length can be set to be the same as the processable message length.
[0108] 402, start parsing the header segment by segment from the first data segment.
[0109] Specifically, starting from the first data segment, execute steps 101 to 104 to perform segmented parsing of the header. When the parsing of the first data segment is completed, continue to perform segmented parsing of the header of the second data segment, and so on, until the header parsing of all data segments is completed.
[0110] 403, concatenate the parsing results of the segmented parsing of the multiple data segments to obtain the parsing result of the header.
[0111] Specifically, after all data segments of the data packet have completed the phased parsing in sequence, the parsing results of the phased parsing of each data segment can be spliced together to finally obtain the header parsing result of the data packet.
[0112] In the disclosed embodiment, the data packet is divided into multiple data segments of fixed length according to the processable message length of the segmented parsing, and each data segment is parsed in stages in turn. This can cope with complex protocol data packets with uncertain lengths and further speed up the data parsing speed.
[0113] In one embodiment, in the above step 103, when the next layer header type is a header type parsed at the n+1 stage, parsing the header at the n+1 stage according to the offset address may include:
[0114] When performing the n+1 stage parsing of this data segment, if it is determined that the field part to be parsed is located in the next data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed in combination with this data segment and the next data segment.
[0115] Specifically, when the n+1 stage parsing is performed on the current data segment, it is determined whether a part of the field to be parsed is located in the next data segment based on whether the sum of the header length of the next layer header type and the header offset is greater than the parsing length indicated by the field parsing information of the n+1 stage. When a part of the field to be parsed is located in the next data segment, it can be determined that the header to be parsed spans the current data segment and the next data segment.
[0116] When the sum of the header length and the header offset of the next layer header type is greater than the parsing length indicated by the field parsing information of the n+1th stage, it is determined that the field part to be parsed is located in the next data segment, that is, it is determined that the header information to be parsed is divided into this data segment and the next data segment.
[0117] When the sum of the header length of the next layer header type and the header offset is less than or equal to the parsing length indicated by the field parsing information of the (n+1)th stage, it is determined that all the fields to be parsed are located in the next data segment.
[0118] Due to data segmentation, the headers to be parsed at one stage may be located in different data segments. In this case, cross-segment parsing of the header parsing at this stage occurs.
[0119] In one embodiment, Figure 5 As shown, in the above steps, combining the current data segment and the next data segment to perform the n+1 stage analysis may include:
[0120] 501. Perform the n+1th stage parsing on the data segment according to the offset address, obtain the first part of the field indicating the result of the n+1th stage parsing, and determine that the n+1th stage parsing is not completed.
[0121] 502. After the next data segment enters the unfinished parsing stage (n+1), the next data segment is parsed in the n+1 stage according to the length of the first part of the fields and the header length of the next layer of header type, to obtain the second part of the fields indicating the parsing result of the n+1 stage.
[0122] Specifically, according to the difference between the header length of the next layer header type and the length of the first part of the fields, the next data segment is parsed in the n+1th stage to obtain the second part of the fields.
[0123] 503, concatenate the second part of fields to the end of the first part of fields to obtain the parsing result of the n+1th stage.
[0124] Specifically, the first part of the fields is shifted to the left, the second part of the fields is shifted to the right, and the second part of the fields after the right shift is spliced to the back of the first part of the fields after the left shift, so as to obtain a complete header parsing result.
[0125] In this embodiment, since the header information to be parsed is divided into the current data segment and the next data segment, the current data segment is first parsed for the n+1th stage to obtain the first part of the fields, and then after the next data segment enters the n+1th stage where the parsing is not completed, the next data segment is parsed for the n+1th stage to obtain the second part of the fields, and then the second part of the fields are spliced to the first part of the fields, so that the complete n+1th stage parsing result can be obtained.
[0126] In one embodiment, in the above step 103, when the next layer header type is a header type parsed at the n+1 stage, parsing the header at the n+1 stage according to the offset address may include:
[0127] When performing the n+1 stage parsing on this data segment, if it is determined that all the fields to be parsed are located in this data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed on this data segment to obtain the n+1 stage parsing result.
[0128] In this embodiment, when it is determined that all the fields to be parsed are located in the current data segment, only the current data segment needs to be parsed in the n+1th stage to obtain a complete parsing result in the n+1th stage.
[0129] In summary, in the embodiments of the present disclosure, after the data packet is segmented, the header may be cut. The length after the offset is obtained by adding the header length corresponding to the next layer of packet length type to be parsed plus the header offset. If the length after the header offset is greater than the length of the data segment, the header at this stage spans two data segments, and it is necessary to extract the header in combination with the next data segment. If there is no span, the header is directly extracted from the current data segment according to the header offset.
[0130] The message segmentation parsing method provided by the embodiment of the present disclosure will be explained below with reference to relevant specific examples.
[0131] See also Figure 6 As shown, Figure 6 A specific example flow chart of the method for segmented parsing of a message provided in an embodiment of the present disclosure. The method may include the following steps:
[0132] 1. When performing the n+1th stage parsing on this data segment, obtain the next layer header type to be parsed, the header offset, and the flag indicating whether the parsing of the previous stage is completed in the nth stage parsing result.
[0133] The flag bit of the nth stage indicates that the nth stage has completed the parsing, that is, the nth stage operation is Prev_Stg_Done, then the n+1th stage needs to start parsing. If the nth stage operation is Wait, in this case, the n+1th stage needs to wait, or if the nth stage operation is a null pointer instruction (NOP), then the n+1th stage does not need to do anything, just send the data packet without any parsing.
[0134] 2. Check whether the header type belongs to the header type parsed in the n+1 stage. If so, execute step 3; otherwise, enter the header parsing in the n+2 stage.
[0135] In each stage, multiple parseable header types are preset and numbered. The header types can be checked to see if they are the same as the ones parsed in the n+1 stage to determine whether to perform parsing in the n+1 stage. If the number is not the same as the one parsed in the n+1 stage, the process goes directly to the next stage without any processing.
[0136] 3. Calculate the header length of this header type.
[0137] Each header type is preset with a corresponding header length, and the header length of the header type is obtained according to the input header type.
[0138] 4. Combine the header length and header offset of the header type to determine whether the header type spans the data segment. If yes, go to step 5, otherwise go to step 6.
[0139] 5. Extract the header based on the header offset and in combination with the current data segment and the next data segment.
[0140] 6. Extract the header from the current data segment according to the header offset.
[0141] 7. Get the header field according to the header type and the extracted header.
[0142] 8. Check whether the header field is consistent with the preset header field table. If it is consistent, execute step 9; otherwise, discard the invalid header.
[0143] 9. Find the corresponding stage information table of stage n+2 according to the header field.
[0144] After obtaining the valid header domain field, search the corresponding stage flow information table to obtain the header type, header offset and flag of whether the current data segment has been parsed for the next stage.
[0145] Next, the message segmentation parsing method provided by the embodiment of the present disclosure will be described with reference to specific examples.
[0146] Assuming that the length of the data parsed in each stage is 64 bytes, take a data packet passing through Ethernet, IPv4 layer protocol and TCP layer protocol as an example, and parse the data packet layer by layer from the outside to the inside. The Ethernet layer may only pass through Ethernet, or it may pass through one VLAN or two VLANs. The network layer may include ARP, IPv4 and IPv6 protocols, and the transport layer may include ICMP, UDP, TCP and GRE protocols. There is different parsing configuration information for these protocols in the stage preset information table. The purpose of Ethernet layer parsing is to obtain the source MAC address and destination MAC address, the network layer header parsing is to obtain the source IP address and destination IP address, and the transport layer header parsing is to obtain the source port number and destination port number.
[0147] 1. Header parsing in phase 1
[0148] The data packet enters the first stage, and the header type of the first stage is initialized to be Ethernet, the header offset is 0, and the flag bit indicating whether the previous stage is parsed is 1. Specifically corresponding to the Ethernet protocol contained in the data packet, the content of the stage preset information table is set as shown in Table 3 below.
[0149] Table 3: Stage 1 Preset Information
[0150] stage Header Type Header length serial number Header Field Table Stage transfer information table Phase 1 Ethernet 14 0 As shown in Table 4 As shown in Table 5 below
[0151] Table 4: Ethernet header field
[0152]
[0153]
[0154] Table 5: Ethernet header phase flow information
[0155] Header Type Action flag Next Phase Header Type Next stage header offset Ethernet 1 IPv4 14
[0156] Among them, the header structure of the Ethernet header is shown in Table 6 below.
[0157] Table 6: Default Ethernet header structure
[0158]
[0159] After the first stage of header parsing, the Ethernet header of the data packet is obtained, and then the corresponding Ethernet frame type, source mac address and destination mac address are obtained according to the structure of the Ethernet header. According to the sum of the header offset 0 bytes and the length of the Ethernet header is 14 bytes, which is less than the packet length of 64 bytes, it is judged that the header does not cross the data segment, so when the Ethernet header parsing is completed, the action flag of the first stage is set to 1. The header type is input to the next stage as IPv4, the header offset is 14, and the flag bit of whether the previous stage parsing is completed is 1.
[0160] 2. Phase 2 Header Parsing
[0161] This stage will parse the IP header, specifically corresponding to the IP protocol contained in the data packet, and the content settings in the stage preset information table are shown in Table 7 below.
[0162] Table 7: Stage 2 Preset Information
[0163] stage Header Type Header length serial number Header Field Table Stage transfer information table Phase 2 IPv4 20 1 As shown in Table 8 below As shown in Table 9 below
[0164] Table 8: Header fields of the IPv4 header
[0165] Header Type Frame type[0] Mask[0] Frame type[0] Mask[0] Frame type[0] Mask[0] IPv4 IPv40 16'h00ff 0 0 0 0
[0166] Table 9: IPv4 header phase flow information
[0167] Header Type Action flag Next layer header type Next stage header offset IPv4 1 TCP 34
[0168] Among them, the header structure of the IPv4 header is shown in Table 10 below.
[0169] Table 10: Default IPv4 header structure
[0170]
[0171] After the second stage of header parsing, the IPv4 header of the data packet is obtained, and then the corresponding key information including the source IP address and the destination IP address is obtained according to the structure of the IPv4 header. According to the sum of the header offset of 14 bytes and the length of the Ethernet header of 34 bytes, which is less than the packet length of 64 bytes, it is judged that the header does not cross the data segment, so when the IPv4 header parsing is completed, the action flag of the second stage is set to 1. And the header type input to the next stage is TCP, the header offset is 34, and the flag bit of whether the previous stage parsing is completed is 1.
[0172] 3. Header parsing in stage 3
[0173] The third stage will parse the IP header, specifically corresponding to the IP protocol contained in the data packet. The content settings in the stage preset information table are shown in Table 11 below.
[0174] Table 11: Stage 3 Preset Information
[0175] Header Type Header length serial number Header Field Stage transfer information table TCP 20 5 As shown in Table 12 below As shown in Table 13 below
[0176] Table 12: Header fields of TCP header
[0177] Header Type Frame type[0] Mask[0] Frame type[0] Mask[0] Frame type[0] Mask[0] TCP 0 0 0 0 0 0
[0178] Note: The TCP header type header does not have a frame type.
[0179] Table 13: TCP header phase flow information
[0180] Header Type Action flag Next layer header type Next stage header offset TCP 1 load 54
[0181] Among them, the preset structure of the TCP header is shown in Table 14.
[0182] Table 14: Default TCP header structure
[0183]
[0184] After the header parsing in the third stage, the TCP header of the data packet is obtained, and then the corresponding key information including the source port number and the destination port number is obtained according to the structure of the TCP header. According to the sum of the header offset of 34 bytes and the length of the Ethernet header of 54 bytes, which is less than the packet length of 64 bytes, it is judged that the header does not cross the data segment, so when the Ethernet header parsing is completed, the action flag of the current stage is set to 1. And the header type is input to the next stage as payload, the header offset is 54, and the flag bit of whether the previous stage is parsed is 1.
[0185] When the payload is parsed, the header of the message will no longer be parsed, and the data flow will be directly transferred to the next stage until the last stage. After the data packet is parsed by the segment, the corresponding Ethernet header, IPv4 header and TCP header are obtained, and the key information source MAC address and destination MAC address, source IP address and destination IP address and source port number and destination port number are obtained, which is convenient for the subsequent forwarding and processing of data.
[0186] In one embodiment, a message segment parsing device is provided; the message to be parsed includes: a header; Figure 7 As shown, the device includes a phase analysis module 701; the phase analysis module 701 is used to:
[0187] According to the parsing configuration information, the header is parsed in the nth stage to obtain the parsing result in the nth stage, wherein when n is less than N, the parsing result in the nth stage includes: the header information parsed in the nth stage, the next layer header type to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum parsing stage number of the header;
[0188] If the next-layer header type is not the header type parsed in the n+1 stage, skip the n+1 stage parsing of the header and proceed to the n+2 stage parsing;
[0189] When the next layer header type is the header type parsed at the n+1 stage, the header is parsed at the n+1 stage according to the offset address;
[0190] When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0191] In one embodiment, the parsing configuration information includes: field parsing information and stage flow information;
[0192] The phase parsing module 701 is used to perform the nth phase parsing on the header according to the parsing configuration information to obtain the nth phase parsing result, including:
[0193] According to the field parsing information of the nth stage and the type of the header to be parsed in the nth stage, the header field is parsed; wherein the header field field includes: frame type, header length, header number and / or mask;
[0194] The stage flow information of the nth stage is queried according to the header field to determine the next layer header type to be parsed and the offset address of the next stage of parsing.
[0195] In one embodiment, the phase parsing module 701 is used to perform the n+1th phase parsing on the header according to the offset address, including:
[0196] When performing the parsing at the n+1 stage, the header field to be parsed contained in the header is matched with the header field table at the n+1 stage;
[0197] If the header field to be parsed contained in the header is a valid field contained in the header field table in the n+1th stage, the content of the header field to be parsed contained in the header is parsed.
[0198] In one embodiment, the phase parsing module 701 is further used to:
[0199] If the header field to be parsed contained in the header is an invalid field that is not included in the header field table in the n+1 stage, the parsing in the n+1 stage is stopped.
[0200] In one embodiment, the apparatus further includes a data partitioning module 700 and a result splicing module 702;
[0201] The data division module 700 is used to divide the data packet into multiple data segments according to preset lengths when the received data packet is larger than the processable packet length of the segmented parsing;
[0202] The phase parsing module 701 is used to perform segment parsing of the header starting from the first data segment;
[0203] The result splicing module 702 is used to splice the parsing results of the segmented parsing of multiple data segments to obtain the parsing result of the header.
[0204] In one embodiment, the stage parsing module 701 is used to perform the n+1 stage parsing on the header according to the offset address when the next layer header type is the header type parsed in the n+1 stage, including:
[0205] When performing the n+1 stage parsing of this data segment, if it is determined that the field part to be parsed is located in the next data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed in combination with this data segment and the next data segment.
[0206] In one embodiment, the phase parsing module 701 is used to perform the n+1th phase parsing in combination with the current data segment and the next data segment, including:
[0207] Perform the n+1th stage parsing on the data segment according to the offset address, obtain the first part of the field indicating the parsing result of the n+1th stage, and determine that the parsing of the n+1th stage is not completed;
[0208] After the next data segment enters the uncompleted parsing stage (n+1), the next data segment is parsed in the n+1 stage according to the length of the first part of the fields and the header length of the next layer of header type, to obtain the second part of the fields indicating the parsing result of the n+1 stage;
[0209] The second part of the fields is concatenated onto the first part of the fields to obtain the parsing result of the n+1th stage.
[0210] In one embodiment, the stage parsing module 701 is used to perform the n+1 stage parsing on the header according to the offset address when the next layer header type is the header type parsed in the n+1 stage, including:
[0211] When performing the n+1 stage parsing on this data segment, if it is determined that all the fields to be parsed are located in this data segment based on the offset address of the next stage parsing, the header length of the next layer header type and the parsing length indicated by the field parsing information of the n+1 stage, the n+1 stage parsing is performed on this data segment to obtain the n+1 stage parsing result.
[0212] Next, we will combine Figure 8 , further illustrating the stage parsing module in the segmented parsing device for the message provided in the embodiment of the present disclosure.
[0213] like Figure 8 As shown, the stage parsing module includes a pre-judgment unit, a header extraction unit and a next-stage information item extraction unit; wherein:
[0214] A prejudgment unit, used to judge whether the header type needs to be parsed, determine the header length corresponding to the header type to be parsed, and obtain a cross-field flag used to indicate whether it is necessary to perform header parsing across data segments, based on the header type, header offset, and previous stage parsing completion flag included in the input current stage parsing information, combined with the stage preset information corresponding to the current stage in the stage preset information table; wherein the stage preset information table is generated by receiving the user's message parsing configuration information, and the message parsing configuration information includes the header type that can be parsed at each stage, the header length corresponding to each header type, the header field corresponding to each header type, and the stage flow information table corresponding to each header field;
[0215] A header extraction unit, configured to extract the header according to the header length and the cross-field flag bit corresponding to the header type in the pre-judgment result when the pre-judgment result of the pre-judgment module indicates that the header type can be parsed, and obtain the header of the header type, the header domain field and the key information corresponding to the header;
[0216] The next stage information item extraction unit is used to extract the header type and header offset of the next stage included in the stage flow information table according to the header field fields obtained by the header extraction unit for the current stage and in combination with the header field fields in the stage preset information table, and give a flag to indicate whether the current parsing is completed.
[0217] It should be noted that: the message segmentation parsing device provided in the above embodiment only uses the division of the above program modules as an example when implementing the message segmentation parsing method. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the message segmentation parsing device is divided into different program modules to complete all or part of the processing described above. In addition, the device provided in the above embodiment and the embodiment of the corresponding method belong to the same concept, and its specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0218] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure; Fig. 9 As shown, the computer device 900 includes: a processor 901 and a memory 902 for storing a computer program that can be run on the processor; wherein the processor 901 performs the following operations when running the computer program:
[0219] According to the parsing configuration information, the header included in the message is parsed in the nth stage to obtain the parsing result of the nth stage, wherein when n is less than N, the parsing result of the nth stage includes: the header information parsed in the nth stage, the type of the next layer header to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum parsing stage number of the header;
[0220] If the next-layer header type is not the header type parsed in the n+1 phase, the n+1 phase parsing of the header is skipped and the parsing of the n+2 phase is entered;
[0221] When the next layer header type is the header type parsed at the n+1 stage, the header is parsed at the n+1 stage according to the offset address;
[0222] When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0223] In actual application, the computer device 900 may also include: at least one network interface 903. The various components in the computer device 900 are coupled together through a bus system 904. It is understood that the bus system 904 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Fig. 9In the figure, various buses are labeled as bus system 904. There may be at least one processor 901. The network interface 903 is used for wired or wireless communication between the computer device 900 and other devices.
[0224] The memory 902 in the embodiment of the present disclosure is used to store various types of data to support the operation of the computer device 900 .
[0225] The method disclosed in the above embodiment of the present disclosure can be applied to the processor 901, or implemented by the processor 901. The processor 901 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 901 or the instruction in the form of software. The above processor 901 may be a general processor, a digital signal processor (DSP, DiGital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 901 can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure. The general processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present disclosure can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined to execute. The software module can be located in a storage medium, which is located in the memory 902. The processor 901 reads the information in the memory 902 and completes the steps of the above method in combination with its hardware.
[0226] In an exemplary embodiment, the computer device 900 may be implemented by one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to execute the aforementioned method.
[0227] The embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored; when the computer-readable storage medium is applied to the message segment parsing method, the computer program is executed by a processor to perform the following operations:
[0228] According to the parsing configuration information, the header included in the message is parsed in the nth stage to obtain the parsing result of the nth stage, wherein when n is less than N, the parsing result of the nth stage includes: the header information parsed in the nth stage, the type of the next layer header to be parsed in the message, and the offset address of the next stage of parsing; wherein N is the maximum parsing stage number of the header;
[0229] If the next-layer header type is not the header type parsed in the n+1 phase, the n+1 phase parsing of the header is skipped and the parsing of the n+2 phase is entered;
[0230] When the next layer header type is the header type parsed at the n+1 stage, the header is parsed at the n+1 stage according to the offset address;
[0231] When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
[0232] In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0233] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.
[0234] In addition, all functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may be separately configured as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0235] A person skilled in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, etc. Various media that can store program codes.
[0236] Alternatively, if the above-mentioned integrated unit of the present disclosure is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present disclosure can essentially or in other words, the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods of each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0237] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0238] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0239] The above are only specific embodiments of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for segmenting and parsing a message. It is characterized in that The message to be parsed includes: a header; the method includes: When the received data packet is larger than the processable packet length of the segmented parsing, the data packet is divided into multiple data segments according to the preset length; Performing segmented parsing of the header starting from the first data segment; splicing the parsing results of the segmented parsing of the plurality of data segments to obtain the parsing result of the header; The segmented parsing of the header starting from the first data segment includes: According to the parsing configuration information, the header is parsed for the nth stage to obtain the parsing result for the nth stage, wherein when n is less than N, the parsing result for the nth stage includes: the header information parsed for the nth stage, the type of the next layer header to be parsed in the message, and the offset address of the next stage parsing; wherein N is the maximum parsing stage number of the header; the next layer header type represents the protocol type of the next layer header; When the next-layer header type is not the header type parsed at the n+1 stage, skip the n+1 stage parsing of the header and proceed to the n+2 stage parsing; When the next-layer header type is a header type parsed at the n+1th stage, the header is parsed at the n+1th stage according to the offset address; wherein, when the current data segment is parsed at the n+1th stage, if it is determined that the field part to be parsed is located in the next data segment according to the offset address parsed at the next stage, the header length of the next-layer header type and the parsing length indicated by the field parsing information of the n+1th stage, the current data segment is parsed at the n+1th stage according to the offset address to obtain the first part of the fields indicating the parsing result of the n+1th stage, and it is determined that the parsing of the n+1th stage is not completed; after the next data segment enters the n+1th stage where the parsing is not completed, According to the length of the first part of the fields and the header length of the next layer of header type, continue to perform the n+1th stage parsing on the next data segment to obtain the second part of the fields indicating the parsing result of the n+1th stage; splice the second part of the fields to the back of the first part of the fields to obtain the parsing result of the n+1th stage; when performing the n+1th stage parsing on the current data segment, if it is determined that all the fields to be parsed are located in the current data segment according to the offset address of the next stage parsing, the header length of the next layer of header type and the parsing length indicated by the field parsing information of the n+1th stage, perform the n+1th stage parsing on the current data segment to obtain the parsing result of the n+1th stage; When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the current segment parsing of the header is stopped.
2. The method according to claim 1, It is characterized in that The parsing configuration information includes: field parsing information and stage flow information; The performing an n-stage parsing on the header according to the parsing configuration information to obtain an n-stage parsing result includes: According to the field parsing information of the nth stage and the type of the header to be parsed in the nth stage, the header field is parsed; wherein the header field includes: frame type, header length, header number and / or mask; The stage flow information of the nth stage is queried according to the header domain field to determine the next layer header type to be parsed and the offset address of the next stage parsing.
3. The method according to claim 2, It is characterized in that The performing the n+1 stage parsing of the header according to the offset address includes: When performing the parsing at the n+1th stage, matching the header field to be parsed contained in the header with the header field table at the n+1th stage; If the header field to be parsed contained in the header is a valid field contained in the header field table in the (n+1)th stage, the content of the header field to be parsed contained in the header is parsed.
4. The method according to claim 3, It is characterized in that The method further comprises: If the header field to be parsed contained in the header is an invalid field that is not included in the header field table in the n+1th stage, the parsing of the n+1th stage is stopped.
5. A message segmentation parsing device, It is characterized in that The message to be parsed includes: a header; the device includes a stage parsing module, a data division module and a result splicing module; The data division module is used to: when the received data packet is larger than the processable message length of the segmented analysis, divide the data packet into multiple data segments according to the preset length; The result splicing module is used to: splice the parsing results of the segmented parsing of the plurality of data segments to obtain the parsing result of the header; The phase parsing module is used to perform segment parsing of the header starting from the first data segment, including: According to the parsing configuration information, the header is parsed for the nth stage to obtain the parsing result for the nth stage, wherein when n is less than N, the parsing result for the nth stage includes: the header information parsed for the nth stage, the type of the next layer header to be parsed in the message, and the offset address of the next stage parsing; wherein N is the maximum parsing stage number of the header; the next layer header type represents the protocol type of the next layer header; When the next-layer header type is not the header type parsed at the n+1th stage, skip the n+1th stage parsing of the header by the stage parsing module, and enter the n+2th stage parsing; when the next-layer header type is the header type parsed at the n+1th stage, execute the stage parsing module to perform the n+1th stage parsing of the header according to the offset address; wherein, when the n+1th stage parsing is performed on the current data segment, if it is determined that the field part to be parsed is located in the next data segment according to the offset address parsed at the next stage, the header length of the next-layer header type, and the parsing length indicated by the field parsing information of the n+1th stage, the current data segment is parsed at the n+1th stage according to the offset address, the first part of the fields indicating the parsing result of the n+1th stage is obtained, and the n+1th stage is determined. The parsing of the first phase is not completed; after the next data segment enters the uncompleted parsing phase, according to the length of the first part of the fields and the header length of the next layer of header type, continue to perform the n+1 phase parsing on the next data segment to obtain the second part of the fields indicating the parsing result of the n+1 phase; splice the second part of the fields to the back of the first part of the fields to obtain the parsing result of the n+1 phase; when the n+1 phase parsing of the current data segment is performed, if it is determined that all the fields to be parsed are located in the current data segment according to the offset address of the next phase parsing, the header length of the next layer of header type and the parsing length indicated by the field parsing information of the n+1 phase, the current data segment is parsed for the n+1 phase to obtain the parsing result of the n+1 phase; When the Nth stage parsing is completed or the first N-1 layer protocol parsing determines to skip the Nth stage parsing, the stage parsing module stops the current segment parsing of the header.
6. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the segmented parsing method of the message described in any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the message segmentation parsing method according to any one of claims 1 to 4 are implemented.
