Message parsing method, electronic device and readable storage medium

By using a cursor to locate the data area of ​​the panel in the parsing of the message, and analyze the data based on the data analysis parameter, it solves the problem of low analysis efficiency caused by the non -continuous cache section, and achieves efficient panel analysis.

WO2025020375A1PCT designated stage expired Publication Date: 2025-01-30PENG CHENG LAB

Patent Information

Application Number
PCT/CN2023/133036
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-07-25
Filing Date
2023-11-21
Publication Date
2025-01-30

Smart Images

  • Figure CN2023133036_30012025_PF_FP_ABST
    Figure CN2023133036_30012025_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present application are a message parsing method, an electronic device and a readable storage medium. The message parsing method comprises: acquiring the remaining parsing length of a message to be parsed; if it is detected that the message header length of said message is less than the remaining parsing length, acquiring a data parsing parameter of a cache segment where the current cursor of said message is located; and according to the data parsing parameter, parsing target data of the cache segment where the current cursor is located, and parsing said message by means of moving the current cursor in said message, so as to obtain a message parsing result.
Need to check novelty before this filing date? Find Prior Art

Description

Message parsing method, electronic device, and readable storage medium

[0001] Related applications

[0002] This application claims priority to Chinese patent application No. 202310927288.6 filed on July 25, 2023, the entire contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of data processing technology, and in particular to a message parsing method, an electronic device, and a readable storage medium. Background Art

[0004] When performing high-throughput data exchanges such as file transfers or video message transmission, jumbo frames with payloads exceeding 1500 bytes are usually used for transmission. When the system needs to support both jumbo frames and non-jumbo frames, parsing the messages transmitted by jumbo frames becomes a pressing issue.

[0005] Currently, due to memory cost considerations, continuous memory is usually not allocated for caching jumbo frames. Therefore, when parsing a message, it is usually necessary to parse the data packets stored in multiple discontinuous cache segments. However, since the discontinuous cache segments are difficult to locate the exact location where the message data is stored, it is easy to repeatedly write parsing code for message parsing. Therefore, the current message parsing efficiency is low.

[0006] Summary of the Invention

[0007] The main purpose of this application is to provide a message parsing method, an electronic device and a readable storage medium, aiming to solve the technical problem of low parsing efficiency of message parsing in the prior art.

[0008] To achieve the above objectives, the present application provides a message parsing method, which includes:

[0009] Get the remaining parsing length of the message to be parsed;

[0010] If it is detected that the message header length of the message to be parsed is less than the remaining parsing length, obtaining the data parsing parameter of the cache segment where the current cursor of the message to be parsed is located;

[0011] According to the data parsing parameters, the target data in the cache segment where the current cursor is located is parsed, and the message to be parsed is parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0012] To achieve the above-mentioned purpose, the present application further provides a message parsing device, the message parsing device comprising:

[0013] The acquisition module is used to obtain the remaining parsing length of the message to be parsed;

[0014] a detection module, configured to obtain data parsing parameters of a cache segment where a current cursor of the message to be parsed is located if it is detected that the message header length of the message to be parsed is less than the remaining parsing length;

[0015] The parsing module is used to parse the target data in the cache segment where the current cursor is located according to the data parsing parameters, and parse the message to be parsed by moving the current cursor in the message to be parsed to obtain a message parsing result.

[0016] The present application also provides an electronic device, which includes: at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the message parsing method as described above.

[0017] The present application also provides a computer-readable storage medium, on which is stored a program for implementing the message parsing method. When the program of the message parsing method is executed by a processor, the steps of the message parsing method as described above are implemented.

[0018] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned message parsing method when executed by a processor.

[0019] The present application provides a message parsing method, an electronic device and a readable storage medium, that is, obtaining the remaining parsing length of a message to be parsed; if it is detected that the message header length of the message to be parsed is less than the remaining parsing length, obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located; according to the data parsing parameters, parsing the target data of the cache segment where the cursor is located, and parsing the message to be parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0020] When parsing a message to be parsed, the present application can obtain the remaining parsing length of the message to be parsed to detect whether the message header length of the message to be parsed is less than the remaining parsing length. If it is detected that the message header length is less than the remaining parsing length, that is, there is still a data area in the message to be parsed that needs to be parsed, then the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located are obtained, and then the target data of the cache segment where the current cursor is located is directly parsed according to the data parsing parameters. Then, by moving the current cursor in the message to be parsed, the data of each cache segment of the message to be parsed can be parsed, and finally the message parsing result can be obtained, thereby achieving the purpose of quickly locating a cache segment of multiple discontinuous cache segments of the message to be parsed through the movable cursor of the message to be parsed, and parsing the target data cached on the cache segment.

[0021] Since the current cursor can be moved within the message to be parsed, when parsing the message to be parsed, it is only necessary to traverse and move the current cursor to each cache segment that caches the message to be parsed, that is, quickly locate the cache segment that caches the target data of the message to be parsed, and then parse the target data cached on the cache segment. Therefore, the purpose of quickly parsing the message to be parsed cached in discontinuous cache segments is achieved.

[0022] Based on this, the present application locates the data area that needs to be parsed in the message to be parsed by using the current cursor, and then parses the data area that needs to be parsed according to the data parsing parameters, and parses all the data that needs to be parsed in the message to be parsed by arbitrarily moving the current cursor in the message to be parsed, that is, the data area that needs to be parsed is accurately located by the current cursor. Instead of repeatedly writing the parsed message to locate the data that needs to be parsed stored in the discontinuous cache segment. Therefore, it overcomes the technical defect that it is difficult to locate the exact location of the stored message data due to the discontinuous cache segment, which leads to the situation where the parsing code is easily rewritten to perform message parsing, thereby improving the parsing efficiency of the message. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0025] FIG1 is a flow chart of a message parsing method according to a first embodiment of the present application;

[0026] FIG2 is a schematic diagram of the structure of a message to be parsed in the message parsing method provided in Example 1 of the present application;

[0027] FIG3 is a schematic diagram of a cache data access class interface of the message parsing method provided in Example 1 of the present application;

[0028] FIG4 is a schematic diagram of the composition of a cursor of the message parsing method provided in Example 1 of the present application;

[0029] FIG5 is a schematic diagram of the structure of a data packet of the message parsing method provided in Example 1 of the present application;

[0030] FIG6 is a schematic diagram of a cursor movement interface of the message parsing method provided in Example 1 of the present application;

[0031] FIG7 is a flow chart of a message parsing method according to the second embodiment of the present application;

[0032] FIG8 is a schematic diagram of a message truncation class interface of the message parsing method provided in Example 2 of the present application;

[0033] FIG9 is a schematic diagram of the structure of a message parsing device provided in Example 3 of the present application;

[0034] FIG10 is a schematic diagram of the structure of an electronic device provided in Example 4 of the present application.

[0035] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0036] To make the above-mentioned purposes, features, and advantages of the present application more clearly understood, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of this application.

[0037] Example 1

[0038] First, it should be understood that, under normal circumstances, when a system needs to support both jumbo frames and non-jumbo frames, due to memory cost considerations, the system cannot allocate a continuous memory to store jumbo frames. If the specific content of the data packet stored in the discontinuous memory needs to be quickly parsed or accessed at this time, it will result in additional runtime overhead and memory copying. If the above means are not used, the packet parsing process will be too long due to the problem of difficult to accurately locate the discontinuous memory. Therefore, there is an urgent need for a method to improve the parsing efficiency of packet parsing.

[0039] The present application provides a message parsing method. In the first embodiment of the message parsing method of the present application, referring to FIG1 , the message parsing method includes:

[0040] Step S10, obtaining the remaining parsing length of the message to be parsed;

[0041] Step S20: If it is detected that the message header length of the message to be parsed is less than the remaining parsing length, then obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located;

[0042] Step S30 , parsing the target data in the cache segment where the current cursor is located according to the data parsing parameters, and parsing the message to be parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0043] In this embodiment, it should be noted that although FIG1 shows a logical sequence, in some cases, the steps shown or described may be performed in a different order than shown here. The message parsing method is applied to a message parsing device, and the message parsing device is deployed with a communication system that supports jumbo frame transmission, such as a high-speed base station system or a high-speed core network system of mobile communications. The high-speed base station system or the high-speed core network system usually uses kernel bypass technology and a DPDK (Data Plane Development Kit) library to process message data in user mode. For example, in the DPDK library, referring to FIG1 , FIG1 is a schematic diagram showing the storage of jumbo frames in a memory buffer, wherein multiple storage data blocks such as A1, A2, and An are applied for jumbo frames. For any storage data block, its NEXT pointer points to the next storage data block, and then from the outside to the inside, an Ethernet header is constructed, an IP header is constructed, and a UDP header is constructed. Then, the internal payload message is filled. After processing, the total length of the message is finally calculated. The fields within sum, however, since the message obtained by this processing method will be distributed on discontinuous memory, the subsequent message parsing cannot be as simple as the message on continuous memory. Therefore, the embodiment of the present application abstracts the cache segment for storing message data and the cursor pointing to a byte index value in the cache segment, wherein the morphological characteristics of the cache segment are not restricted, and the cursor can move freely back and forth on the cache segment. Since the message is composed of multiple discontinuous cache segments, any byte of the stored message data can be located by moving the cursor, that is, the cursor can point to bytes on each cache segment.

[0044] In addition, it should be noted that the message to be parsed is used to represent the message waiting to be parsed, wherein the message to be parsed may be specifically composed of a message header and a data area. The message header may be specifically determined by the communication transmission protocol of the Ethernet, and the communication transmission protocol may be specifically TCP / IP (Transmission Control Protocol / Internet Protocol), UDP (User Datagram Protocol) or ICMP (Internet Control Message Protocol). Protocol, Internet Control Message Protocol), the message to be parsed carries a cursor and is stored in multiple non-continuous cache segments before parsing. The remaining parsing length is used to represent the remaining length of the data waiting for parsing. Since the cursor is mobile and the message to be parsed can be parsed from the outside to the inside (from front to back) or from the inside to the outside (from back to front), for a certain time step, the remaining parsing length is determined by the byte pointed to by the current time step cursor and the first byte of the data parsed. Specifically, it can be the total length of bytes from the byte pointed to by the cursor to the end byte of the message to be parsed or the total length of bytes from the byte pointed to by the cursor to the first byte of the message to be parsed. Total length, refer to Figure 2, Figure 2 is a structural diagram of the message to be parsed, wherein X is the message to be parsed, B1, B2 and B3 are different non-continuous cache segments, for a certain cache segment 10, the byte pointed to by the cursor P divides the cache segment into two major areas, namely the accessible cache segment header space 11 and the accessible cache segment space 12, wherein the accessible cache segment space contains the byte pointed to by the cursor of the cache segment and all bytes after the cursor, and the accessible cache segment header space contains all bytes before the cursor of the cache segment. If the message to be parsed is parsed from the outside to the inside, d1 represents the remaining parsing length, that is, the total byte length from the byte pointed to by the current cursor to the end byte of the message to be parsed.

[0045] In addition, it should be noted that since the message to be parsed carries a message header, and the message header does not contain actual user data or business data, in the process of parsing the message, it is necessary to detect the length relationship between the remaining parsing length and the message header length after each piece of data is parsed. If it is detected that the message header of the message to be parsed is greater than or equal to the remaining parsing length, it indicates that there is no data to be parsed in the message to be parsed, that is, the message to be parsed has been parsed. When it is detected that the message header of the message to be parsed is less than the remaining parsing length, the data parsing parameters are obtained through the corresponding cache data access class interface, and the data parsing parameters are used to parse the message data. , specifically, it can be the address of the cursor and the length of the accessible cache segment space, wherein the cache data access class interface includes a read-only accessible cache segment access interface (API_chunk) and a readable and writable accessible cache segment access interface (API_chunk_mut), both of which have no input parameters. The returned data parsing parameters are used to parse the target data, that is, the message data cached in the cache segment. Referring to Figure 3, Figure 3 is a schematic diagram of the cache data access class interface, wherein the shaded part is the target data. If the read-only accessible cache segment access interface is used, only the target data can be read. If the readable and writable access cache segment access interface is used, the target data can be read and written.

[0046] In addition, it should be noted that the cursor is used to represent the index value pointing to the byte of the message to be parsed, and can be specifically composed of the cache segment head address (buf_addr), the cache segment length (buf_len), the accessible cache segment starting address (chunk_addr) and the accessible cache segment length (chunk_len), wherein the cache segment head address is a pointer used to point to the first address of the cache segment, the cache segment length is integer data used to represent the length of the cache segment, the accessible cache address is a pointer that points to the byte where the cursor is located, and the accessible cache segment length is integer data that represents the length from the beginning of the cursor to the end of the cache segment where the cursor is located. Refer to Figure 4, Figure 4 is a schematic diagram showing the composition of the cursor.

[0047] In addition, it should be noted that, with reference to Figure 5, Figure 5 is a structural diagram of a data packet. The constituent elements of the data (message data packet) that need to be parsed are the descriptor header (head_PD), the current descriptor (cur_PD), the cumulative length of the accessed cache segments (segs_len), the starting address of the accessible cache segment (chunk_addr) and the accessible cache segment length (chunk_len), wherein the accessible cache segment length is the length of the accessible cache space, the descriptor header is a pointer that points to the descriptor (PD) of the first cache segment storing the message, and can be used to traverse all cache segments storing the message, the current descriptor is a pointer that specifically points to the descriptor of the cache segment where the cursor is located, the cumulative length of the accessed cache segments is integer data, specifically the sum of the lengths of the first cache segment storing the message to the cache segment where the cursor is located, and the accessible cache segment length is an integer data. The starting address of the cache segment is a pointer, which indicates the address of the byte where the cursor is located. The accessible cache segment length is an integer data, which indicates the length from the cursor to the end of its cache segment. Among them, the accessible cache segment length and the cumulative length of the accessed cache segments can be used to represent the target data. For any cache segment of the cache message, it can be composed of the cache address (buf_addr), cache length (buf_len), total length (total_len) and next address (next_PD). ​​Among them, the cache address is a pointer pointing to the first address of the cache segment, the cache length is an integer data used to represent the specific length of the cache segment, and the total length is an integer data used to represent the total length of the message. Among them, only the total length of the descriptor header has practical significance, and the total length of the other descriptors is meaningless. The next address is a pointer pointing to the PD of the next cache segment.

[0048] As an example, steps S10 to S30 include: obtaining the remaining length of the message to be parsed waiting for data parsing; if it is detected that the message header length of the message to be parsed is less than the remaining length waiting for data parsing, obtaining the address of the cursor of the cache segment where the current cursor of the message to be parsed is located and the length of the accessible cache segment space; according to the address of the cursor and the length of the accessible cache segment space, parsing the target data of the cache segment where the current cursor is located, and parsing the message to be parsed by moving the current cursor in the message to be parsed to obtain a message parsing result.

[0049] In an implementable manner, if it is detected that the message header length of the message to be parsed is greater than or equal to the remaining parsing length, a message parsing result indicating that the message parsing is completed is obtained.

[0050] The message parsing result includes a first message parsing result and a second message parsing result, and the step of moving the current cursor within the message to be parsed to parse the message to be parsed to obtain the message parsing result includes:

[0051] Step A10, after the current cursor moves by the data length of the target data, detecting whether the moved current cursor is located within the message to be parsed;

[0052] Step A20: If yes, then update the cursor parameters of the current cursor according to the data length to obtain an updated current cursor;

[0053] Step A30: Using the updated current cursor as the current cursor, and returning to the step of obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located and subsequent steps until the first message parsing result is obtained, wherein the first message parsing result is used to indicate that the parsing of the message to be parsed is complete;

[0054] Step A40: If not, the parsing error information of the message to be parsed is used as the second message result.

[0055] In this embodiment, it should be noted that when the cursor is controlled to move within the message to be parsed, the cursor can be controlled to move with any data length. However, in order to ensure the effectiveness of parsing the data each time the cursor is moved, at the same time, taking into account the message parsing efficiency, the current cursor can always be moved with the data length of the target data to parse the remaining parsing length, wherein the moving method can specifically be a forward moving method or a backward moving method, and after the movement, it can be detected whether the cursor is still located in the message to be parsed according to the address of the cursor. The message parsing result includes a first message parsing result and a second message parsing result. The first message parsing result is used to indicate that the parsing of the message to be parsed is completed, and the second message result is used to indicate that the parsing of the message to be parsed is wrong. After the current cursor moves, it indicates that the parsing of the corresponding data has been completed, and then for the current cursor that is still in the new position in the message to be parsed, the cursor parameters need to be updated.

[0056] As an example, steps A10 to A40 include: after the current cursor moves the data length of the target data, detecting whether the moved current cursor is located in the message to be parsed; if it is detected that the moved current cursor is located in the message to be parsed, then according to the data length, the cursor parameters of the current cursor are updated to obtain an updated current cursor; the updated current cursor is used as the current cursor, and the step of obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located and subsequent steps are returned to execute until the first message parsing result is obtained; if it is detected that the moved current cursor is not located in the message to be parsed, then a parsing error message of the message to be parsed is generated, and the parsing error message is used as the second message result, wherein the parsing error message can specifically be "message parsing error".

[0057] When parsing a message to be parsed, the embodiment of the present application moves the current cursor carried by the message to be parsed based on the data length of the target data, and then detects whether the current cursor after the move is within the message to be parsed. If the current cursor after the move is within the message to be parsed, the cursor parameters are first updated after the move to locate the current position and state of the cursor, and then the step of obtaining the data parsing parameters for target parsing is repeated until all data to be parsed of the remaining parsing length is parsed, and finally the first message parsing result of the message to be parsed is obtained, that is, in the process of parsing the message to be parsed, both the parsing effectiveness and the parsing efficiency are taken into account.

[0058] The cursor parameters include a cache segment identifier of the cache segment where the cursor is located, a cache space length of the cache segment where the cursor is located, and a byte address pointed to by the cursor in the cache segment where the cursor is located. The step of updating the cursor parameters of the current cursor according to the data length to obtain the updated current cursor includes:

[0059] Step B10: if it is detected according to the data length that the current cursor moves within the cache segment, then an updated current cursor is obtained by updating the cache space length and the byte address;

[0060] Step B20: If it is detected according to the data length that the current cursor moves within the cache segment, an updated current cursor is obtained by updating the cache space length and the byte address.

[0061] In this embodiment, it should be noted that the cache space length is used to characterize the space length of the accessible cache segment space, and the cache segment identifier is used to characterize the descriptive symbol of the cache segment. Due to the different data lengths of the target data and the limited space length of the accessible cache segment space of the cache segment, the current cursor may move between segments or within a segment during the movement process. When moving within a segment, since the cache segment where the current cursor and the current cursor after the movement are located have not changed, there is no need to update the descriptive symbol of the cache segment. When moving between segments, since the cache segment where the cursor is located has changed, it is necessary to update the descriptive symbol of the cache segment where the cursor is located. Among them, controlling the movement of the current cursor can be implemented based on the cursor movement class interface. The cursor movement class interface includes the cursor forward movement interface API_advance and the cursor backward movement interface API_move_back. The input parameter of the cursor forward movement interface is the forward movement distance, and its function is to control the cursor to move forward a certain distance. The input parameter of the cursor backward movement interface is the forward movement distance. The number is the distance moved backward, and its function is to control the cursor to move backward a certain distance. Referring to Figure 6, Figure 6 is a schematic diagram of the cursor movement class interface. The upper layer does not need to care whether the cursor moves within the cache segment or between cache segments. Whether the cursor moves within the cache segment or between cache segments can be determined by the movement amplitude under the data length. In the basic interface set by the message parsing device, a cache length query class interface is also provided, wherein the cache length query class interface may specifically include API_headroom and API_remaining. API_headroom has no input parameters, and it returns the length from the first address of the cache segment where the cursor is located to the position of the cursor, and the total length in bytes from the first address of the cache segment where the cursor is located to the byte pointed to by the cursor in the cache segment. API_remaining has no input parameters, and it returns the length from the tail of the message to the position of the cursor, that is, the total length in bytes from the byte pointed to by the cursor in the cache segment to the tail byte of the message.

[0062] As an example, steps B10 to B20 include: if it is detected based on the data length that the current cursor moves within the cache segment, then the updated current cursor is obtained by updating the cache space length and the byte address; if it is detected based on the data length that the current cursor moves within the cache segment, then the updated current cursor is obtained by updating the cache segment identifier, the cache segment space length and the byte address.

[0063] Before the step of updating the cursor parameters of the current cursor according to the data length to obtain the updated current cursor, the message parsing method further includes:

[0064] Step C10: obtaining a first length difference between the parsed length of the cache segment of the message to be parsed and the cache space length of the cache segment where the current cursor is located, and obtaining a second length difference between the parsed length of the cache segment and the cache segment length of the cache segment where the current cursor is located;

[0065] Step C20, detecting whether the second length difference is smaller than a third length difference between the first length difference and the data length;

[0066] Step C30: If it is less than, it is determined that the current cursor moves within the cache segment.

[0067] As an example, steps C10 to C30 include: subtracting the cache segment parsing length of the message to be parsed from the cache space length of the cache segment where the current cursor is located to obtain a first length difference, and subtracting the cache segment parsing length from the cache segment length of the cache segment where the current cursor is located to obtain a second length difference, wherein the cache segment length and the cache space length can be obtained through a basic class interface query, and the cache segment parsing length is used to represent the sum of the lengths of the cache segments that have been parsed in the message to be parsed. For example, in an implementable manner, assuming that the message to be parsed is parsed from the outside to the inside, the cache segment parsing length is the sum of the lengths from the first cache segment storing the message to the cache segment where the current cursor is located; detecting whether the second length difference is less than the third length difference between the first length difference and the data length; if it is detected that the second length difference is less than the third length difference, determining that the current cursor moves within the cache segment; if it is detected that the second length difference is greater than or equal to the third length difference, determining that the current cursor moves between the cache segments.

[0068] In one practicable manner, the process of detecting the cursor movement type (movement within a cache segment or movement between cache segments) when the current cursor moves backward is as follows: input the length of the backward movement, calculate the length of the current cursor and the target cursor, the length of the current cursor is equal to segs_len-chunk_len, the length of the target cursor is equal to the length of the current cursor minus the length to be moved backward, and then by judging whether the length of the target cursor is less than 0, it is detected whether the current cursor after the move is located in the message to be parsed. If it is less than 0, an error is reported, that is, it is not located in the message to be parsed. If it is greater than 0, it is judged whether the buf_len of segs_len minus cur_PD is less than the length of the target cursor (in Determine whether the current cursor moves backward within the cache segment or between cache segments). For different types of backward movement, different cursor parameters will be updated accordingly, that is, when moving between cache segments, segs_len will be updated to segs_len minus buf_len of cur_PD, and cur_PD will point to the previous PD in the cache list. Then, the cursor parameters that will also be updated when moving within the cache segment will be updated, that is, chunk_len will be updated to segs_len minus the length of the target cursor, and chunk_addr will be updated to buf_addr of cur_PD plus buf_len of cur_PD minus chunk_len.

[0069] Before the step of updating the cursor parameters of the current cursor according to the data length to obtain the updated current cursor, the message parsing method further includes:

[0070] Step D10: obtaining a fourth length difference between the parsed length of the cache segment of the message to be parsed and the cache space length of the cache segment where the current cursor is located, and obtaining a first length sum between the fourth length difference and the data length;

[0071] Step D20, detecting whether the parsed length of the cache segment is greater than the first length and value;

[0072] Step D30: If it is greater than, it is determined that the current cursor moves between the cache segments;

[0073] Step D40: If it is less than or equal to, it is determined that the current cursor moves within the cache segment.

[0074] As an example, steps D10 to D40 include: subtracting the cache segment parsing length of the message to be parsed from the cache space length of the cache segment where the current cursor is located to obtain a fourth length difference, and summing the cache segment parsing length and the data length to obtain a first length sum value; detecting whether the cache segment parsing length is greater than the first length sum value; if it is detected that the cache segment parsing length is greater than the first length sum value, determining that the current cursor moves between the cache segments; if it is detected that the cache segment parsing length is less than or equal to the first length sum value, determining that the current cursor moves within the cache segment where it is located.

[0075] In one implementable manner, the process of moving the current cursor forward to detect the cursor movement type (movement within the cache segment or movement between cache segments) is as follows: input the forward movement length, calculate the length of the current cursor and the target cursor, the length of the current cursor is equal to segs_len minus chunk_len, the length of the target cursor is equal to the length of the current cursor plus the length to be moved forward, and then by judging whether the length of the target cursor is greater than the total_len of head_PD, it is detected whether the current cursor after the movement is located in the message to be parsed. If the former is less than or the latter, an error is reported, that is, it is not located in the message to be parsed. If the former is greater than the latter, it is judged whether segs_len is greater than the length of the target cursor (to determine whether the current cursor is moving backward within the cache segment or within the cache segment). Move backward between cache segments), for different forward movement types, different cursor parameters will be updated accordingly, that is, when moving between cache segments, segs_len will be updated to segs_len minus buf_len of cur_PD, and cur_PD will point to the next PD in the cache list, and then the cursor parameters that will also be updated when moving within the cache segment will be updated, that is, chunk_len will be updated to segs_len minus the length of the target cursor, and chunk_addr will be updated to buf_addr of cur_PD plus buf_len of cur_PD minus chunk_len. Among them, compared with the backward movement parsing message, the forward movement parsing message has a better anti-mistake effect because it is parsed from the outside to the inside.

[0076] An embodiment of the present application provides a message parsing method, namely, obtaining the remaining parsing length of a message to be parsed; if it is detected that the message header length of the message to be parsed is less than the remaining parsing length, obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located; according to the data parsing parameters, parsing the target data of the cache segment where the cursor is located, and parsing the message to be parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0077] When parsing a message to be parsed, the embodiment of the present application can obtain the remaining parsing length of the message to be parsed to detect whether the message header length of the message to be parsed is less than the remaining parsing length. If it is detected that the message header length is less than the remaining parsing length, that is, there is still a data area in the message to be parsed that needs to be parsed, then the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located are obtained, and then according to the data parsing parameters, the target data of the cache segment where the current cursor is located is directly parsed, and then by moving the current cursor in the message to be parsed, the data of each cache segment of the message to be parsed can be parsed, and finally the message parsing result can be obtained, thereby achieving the purpose of quickly locating a cache segment of multiple discontinuous cache segments of the message to be parsed through the movable cursor of the message to be parsed, and parsing the target data cached on the cache segment.

[0078] Since the current cursor can be moved within the message to be parsed, when parsing the message to be parsed, it is only necessary to traverse and move the current cursor to each cache segment that caches the message to be parsed, that is, quickly locate the cache segment that caches the target data of the message to be parsed, and then parse the target data cached on the cache segment. Therefore, the purpose of quickly parsing the message to be parsed cached in discontinuous cache segments is achieved.

[0079] Based on this, the present application locates the data area that needs to be parsed in the message to be parsed by using the current cursor, and then parses the data area that needs to be parsed according to the data parsing parameters, and parses all the data that needs to be parsed in the message to be parsed by arbitrarily moving the current cursor in the message to be parsed, that is, the data area that needs to be parsed is accurately located by the current cursor. Instead of repeatedly writing the parsed message to locate the data that needs to be parsed stored in the discontinuous cache segment. Therefore, it overcomes the technical defect that it is difficult to locate the exact location of the stored message data due to the discontinuous cache segment, which leads to the situation where the parsing code is easily rewritten to perform message parsing, thereby improving the parsing efficiency of the message.

[0080] Example 2

[0081] Further, referring to FIG7 , in another embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above description and will not be described in detail. On this basis, before the step of obtaining the remaining parsed length of the message to be parsed, the message parsing method further includes:

[0082] Step E10, obtaining the accessible cache segment header space of the cache segment where the current cursor is located;

[0083] Step E20: If it is detected that the accessible cache segment header space is smaller than the message header length of the message to be parsed, then after shifting the message header length, at least one message cache segment in the preset message cache segment group is selected as the message cache space;

[0084] Step E30: Cache the target data of the message to be parsed into the message cache space.

[0085] In this embodiment, it should be noted that before parsing the message to be parsed, the message to be parsed needs to be constructed in advance and stored in the corresponding message cache space. Based on the above, the embodiment of the present application is provided with a cursor forward movement interface (API_advance), a cursor backward movement interface (API_move_back), a read-only accessible cache segment access interface (API_chunk), a read-write accessible cache segment access interface (API_chunk_mut), an accessible cache header length query interface (API_headroom), a remaining length query interface (API_remaining) and a tail truncation interface (API_trimoff) and other basic class interfaces when parsing and constructing the message. Then, through interface calls and algorithm logic, a message to be parsed with a cursor stored in multiple non-continuous cache segments can be constructed, wherein the API_headroom return value is chunk_addr minus buf_addr of cur_PD, and the API_remaining return value is total_len of head_PD minus segs_len plus chunk_len.

[0086] In addition, it should be noted that during the message construction process, since the message header does not carry actual data, a cache area needs to be set for the message header. Under normal circumstances, since the cache header length is greater than or equal to the message header length of the message to be parsed, the data can be directly cached at the position of the current cursor, that is, the message header is stored in the accessible cache segment header space of the cache segment, and the message data is stored in the accessible cache segment space of the cache segment. When the accessible cache segment header space is less than the message header length of the message to be parsed, the position of the current cursor needs to be moved to ensure that the message header is cached in the accessible cache segment header space of the cache segment. The preset message cache segment group has multiple message cache segments. During the construction of the message to be parsed, the current cursor can traverse each message cache segment that needs to store message data.

[0087] As an example, steps E10 to E30 include: obtaining the accessible cache segment header space of the cache segment where the current cursor is located by calling the accessible cache header length query interface; if it is detected that the cache segment header space is smaller than the message header length of the message to be parsed, then after moving the message header length, selecting at least one message cache segment in the preset message cache group as the message cache space; caching the target data of the message to be parsed into the message cache space.

[0088] In one feasible method, taking the construction of the UDP message header as an example: call API_headroom to query the accessible cache segment header space; determine whether the length of the accessible cache segment header space is less than the length of the UDP message header; if it is less, end; if it is not less, call API_move_back to move the cursor backward by the length of the UDP message header; call API_chunk_mut to obtain a readable and writable chunk; automatically set the UDP message length, whose length is equal to the remaining length plus the length of the UDP message header, and set the values ​​of each field at the same time.

[0089] Wherein, after the step of caching the target data of the message to be parsed in the message cache space, the message parsing method further includes:

[0090] Step F10, obtaining the length of the buffer space to be truncated;

[0091] Step F20: If it is detected that the length of the buffer space to be truncated is less than or equal to the free buffer length of the message buffer space, then when the length of the buffer space to be truncated is less than the buffer segment length of the truncated buffer segment of the message buffer space, the length of the buffer space to be truncated is truncated in the truncated buffer segment, and the buffer segment length of the truncated buffer segment and the total message length of the message to be parsed are updated;

[0092] Step F30: If it is detected that the length of the buffer space to be truncated is greater than the free buffer length, truncation error information of the message to be parsed is generated.

[0093] In this embodiment, it should be noted that due to the different amounts of message data in the messages to be parsed, the accessible cache segment space for the last cache segment storing the message data may be greater than the data length, and a truncation operation is required to ensure the parsing efficiency and accuracy in the subsequent message parsing process. Referring to Figure 8, Figure 8 is a schematic diagram of the message truncation class interface, wherein 21 is the length of the cache space to be truncated, the length of the cache space to be truncated is the length of the space in the cache segment waiting to be truncate, the free cache length is used to characterize the length of the cache space for uncached message data, and the truncated cache segment is used to characterize the cache segment where the truncation operation is performed, and then according to the length relationship between the length of the cache space to be truncated and the free cache length, it is ensured that the truncation operation will not affect the cached message data, and it needs to be updated after the truncation is completed.

[0094] As an example, steps F10 to F30 include: obtaining the length of the cache space to be truncated; if it is detected that the length of the cache space to be truncated is less than or equal to the free cache length of the message cache space, then when the length of the cache space to be truncated is less than the cache segment length of the truncated cache segment of the message cache space, the length of the cache space to be truncated is truncated in the truncated cache segment, and the cache segment length of the truncated cache segment and the total message length of the message to be parsed are updated; if it is detected that the length of the cache space to be truncated is greater than the free cache length, a truncation error message of the message to be parsed is generated, wherein the truncation error message can specifically be "valid data is truncated".

[0095] In one practicable embodiment, the process for truncating the length of the buffer space to be truncated is as follows: input the tail truncation length; call API_remaining, which returns the remaining length; determine whether the truncation length is greater than the remaining length; if so, terminate the process. Otherwise, execute the following: determine whether the truncation length is greater than the buf_len of the last PD. If so, terminate the process. Otherwise, execute the following: subtract the truncation length from the buf_len of the last PD, and subtract the truncation length from the total_len of the head_PD.

[0096] Wherein, after the step of truncating the length of the buffer space to be truncated in the truncated buffer segment, the message parsing method further includes:

[0097] Step G10, detecting whether the current cursor of the message to be parsed is in the truncated cache segment;

[0098] Step G20: If the cache is in the truncated cache segment, update the cache space length of the truncated cache segment.

[0099] In this embodiment, it should be noted that since the current cursor is dynamic, if the cache segment where the current cursor is located has cache space truncation, the corresponding cache segment space length needs to be updated to avoid parsing errors in subsequent messages to be parsed.

[0100] As an example, steps G10 to G20 include: detecting whether the current cursor of the message to be parsed is in the truncated cache segment; if it is detected that the current cursor of the message to be parsed is in the truncated cache segment, updating the cache space length of the truncated cache segment, wherein the updating method can be either the cache space length of the cache segment minus the cache space length to be truncated, or the cache space length of the cache segment minus the partial length of the cache space length to be truncated.

[0101] The embodiment of the present application provides a method for constructing a message to be parsed, that is, obtaining the accessible cache segment header space of the cache segment where the current cursor is located; if it is detected that the accessible cache segment header space is smaller than the message header length of the message to be parsed, then after moving the message header length, at least one message cache segment in a preset message cache segment group is selected as the message cache space; and the target data of the message to be parsed is cached in the message cache space. When constructing a message to be parsed, the embodiment of the present application can obtain the accessible cache segment header space of the cache segment where the current cursor is located, and then if it is detected that the accessible cache segment header space is smaller than the message header length of the message to be parsed, that is, the message header of the message to be parsed cannot be completely cached in the accessible cache segment header space of the cache segment, then after moving the message header length, at least one message cache segment in a preset message cache segment group is selected as the message cache space, and finally the target data of the message to be parsed is cached in the message cache space, so as to ensure that the target data of the message to be parsed is completely cached in the accessible cache segment space of the cache segment, thereby laying the foundation for high-speed parsing of the message to be parsed.

[0102] Example 3

[0103] The present application also provides a message parsing device. Referring to FIG. 9 , the message parsing device includes:

[0104] The acquisition module 101 is used to obtain the remaining parsing length of the message to be parsed;

[0105] The detection module 102 is configured to obtain data parsing parameters of a cache segment where a current cursor of the message to be parsed is located if it is detected that the message header length of the message to be parsed is less than the remaining parsing length;

[0106] The parsing module 103 is configured to parse the target data in the cache segment where the current cursor is located according to the data parsing parameters, and parse the message to be parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0107] In one embodiment, the message parsing result includes a first message parsing result and a second message parsing result, and the parsing module 103 is further configured to:

[0108] After the current cursor moves by the data length of the target data, detecting whether the moved current cursor is located within the message to be parsed;

[0109] If yes, then update the cursor parameters of the current cursor according to the data length to obtain an updated current cursor;

[0110] Using the updated current cursor as the current cursor, and returning to the step of obtaining the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located and subsequent steps until the first message parsing result is obtained, wherein the first message parsing result is used to indicate that parsing of the message to be parsed is complete;

[0111] If not, the parsing error information of the message to be parsed is used as the second message result.

[0112] In one embodiment, the cursor parameters include a cache segment identifier of the cache segment where the cursor is located, a cache space length of the cache segment where the cursor is located, and a byte address pointed to by the cursor in the cache segment where the cursor is located. The parsing module 103 is further configured to:

[0113] If it is detected according to the data length that the current cursor moves within the cache segment, then an updated current cursor is obtained by updating the cache space length and the byte address;

[0114] If it is detected according to the data length that the current cursor moves between the cache segments, an updated current cursor is obtained by updating the cache segment identifier, the cache space length and the byte address.

[0115] In one embodiment, the message parsing device is further configured to:

[0116] Obtaining a first length difference between a parsed length of a cache segment of the message to be parsed and a cache space length of the cache segment where the current cursor is located, and obtaining a second length difference between the parsed length of the cache segment and a cache segment length of the cache segment where the current cursor is located;

[0117] detecting whether the second length difference is less than a third length difference between the first length difference and the data length;

[0118] If it is less than, it is determined that the current cursor moves within the cache segment;

[0119] If it is greater than or equal to, it is determined that the current cursor moves between the cache segments.

[0120] In one embodiment, the message parsing device is further configured to:

[0121] Obtaining a fourth length difference between the parsed length of the cache segment of the message to be parsed and the cache space length of the cache segment where the current cursor is located, and obtaining a first length sum value between the fourth length difference and the data length;

[0122] Detecting whether the parsed length of the cache segment is greater than the first length and value;

[0123] If it is greater than, it is determined that the current cursor moves between the cache segments;

[0124] If it is less than or equal to, it is determined that the current cursor moves within the cache segment.

[0125] In one embodiment, the message parsing device is further configured to:

[0126] Get the accessible cache segment header space of the cache segment where the current cursor is located;

[0127] If it is detected that the accessible cache segment header space is smaller than the message header length of the message to be parsed, then after shifting the message header length, at least one message cache segment in the preset message cache segment group is selected as the message cache space;

[0128] Cache the target data of the message to be parsed into the message cache space.

[0129] In one embodiment, the message parsing device is further configured to:

[0130] Get the length of the cache space to be truncated;

[0131] If it is detected that the length of the buffer space to be truncated is less than or equal to the free buffer length of the message buffer space, then when the length of the buffer space to be truncated is less than the buffer segment length of the truncated buffer segment of the message buffer space, the length of the buffer space to be truncated is truncated in the truncated buffer segment, and the buffer segment length of the truncated buffer segment and the total message length of the message to be parsed are updated;

[0132] If it is detected that the length of the buffer space to be truncated is greater than the free buffer length, truncation error information of the message to be parsed is generated.

[0133] The message parsing device provided in this application utilizes the message parsing method of the aforementioned embodiment to resolve the technical issue of low message parsing efficiency. Compared to the prior art, the message parsing device provided in this application embodiment has the same beneficial effects as the message parsing method provided in the aforementioned embodiment. Other technical features of the message parsing device are the same as those disclosed in the aforementioned embodiment and are not further elaborated here.

[0134] Example 4

[0135] An embodiment of the present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message parsing method in the above-mentioned embodiment one.

[0136] Reference is now made to Figure 10, which illustrates a schematic diagram of an electronic device suitable for implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, data communication products such as routers, switches, and gateway devices, as well as fixed terminals such as digital TVs and desktop computers. The electronic device illustrated in Figure 10 is merely an example and should not limit the functionality or scope of use of the embodiments of the present disclosure.

[0137] As shown in Figure 10, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. Various programs and data required for the operation of the electronic device are also stored in the RAM 1004. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus.

[0138] Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, a magnetic tape, hard disk, etc.; and communication devices 1009. The communication devices can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or have instead.

[0139] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network via the communication device 1009, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0140] The electronic device provided in this application employs the message parsing method of the above-described embodiment to solve the technical problem of low message parsing efficiency. Compared with the prior art, the beneficial effects of the electronic device provided in the embodiment of this application are the same as those of the message parsing method provided in the above-described embodiment, and the other technical features of the electronic device are the same as those disclosed in the above-described embodiment, and are not further described here.

[0141] It should be understood that various parts of the present disclosure can be implemented with hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in an appropriate manner.

[0142] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

[0143] Example 5

[0144] This embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon, and the computer-readable program instructions are used to execute the message parsing method in the above embodiment.

[0145] The computer-readable storage medium provided in the embodiment of the present application can be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. A more specific example of a computer-readable storage medium can include, but is not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present embodiment, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by an instruction execution system, a system or a device or used in combination therewith. The program code contained in the computer-readable storage medium can be transmitted with any appropriate medium, including but not limited to: an electric wire, an optical cable, RF (radio frequency), etc., or any suitable combination thereof.

[0146] The computer-readable storage medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0147] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device: obtains the remaining parsing length of the message to be parsed; if it is detected that the message header length of the message to be parsed is less than the remaining parsing length, obtains the data parsing parameters of the cache segment where the current cursor of the message to be parsed is located; according to the data parsing parameters, parses the target data of the cache segment where the current cursor is located, and parses the message to be parsed by moving the current cursor within the message to be parsed to obtain a message parsing result.

[0148] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0149] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0150] The modules involved in the embodiments described in this disclosure may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.

[0151] The computer-readable storage medium provided in this application stores computer-readable program instructions for executing the above-described message parsing method, thereby resolving the technical problem of low message parsing efficiency. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this embodiment of the application are the same as those of the message parsing method provided in the above-described embodiment, and are not further elaborated here.

[0152] Example 6

[0153] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned message parsing method when executed by a processor.

[0154] The computer program product provided by this application solves the technical problem of low efficiency in message parsing. Compared with the prior art, the beneficial effects of the computer program product provided by the embodiment of this application are the same as those of the message parsing method provided by the above embodiment, and will not be repeated here.

[0155] The above are merely optional embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.

Claims

1. A message parsing method, wherein: The message parsing method comprises: Get the remaining parsing length of the message to be parsed; If it is detected that the message header length of the message to be parsed is less than the remaining parsing length, obtaining the data parsing parameter of the cache segment where the current cursor of the message to be parsed is located; According to the data parsing parameters, the target data of the cache segment where the current cursor is located is parsed, and the message to be parsed is parsed by moving the current cursor in the message to be parsed to obtain a message parsing result.

2. The message parsing method according to claim 1, wherein: The message parsing result includes a first message parsing result and a second message parsing result, The step of parsing the message to be parsed by moving the current cursor in the message to be parsed to obtain a message parsing result comprises: After the current cursor moves by the data length of the target data, detecting whether the moved current cursor is located within the message to be parsed; If yes, then update the cursor parameter of the current cursor according to the data length to obtain an updated current cursor; The updated current cursor is used as the current cursor, and the step of obtaining the data parsing parameter of the cache segment where the current cursor of the message to be parsed is located and subsequent steps are returned until the first message parsing result is obtained, wherein the first message parsing result is used to indicate that the parsing of the message to be parsed is completed; If not, the parsing error information of the message to be parsed is used as the second message result.

3. The message parsing method according to claim 2, wherein: The cursor parameters include the cache segment identifier of the cache segment where the cursor is located, the cache space length of the cache segment where the cursor is located, and the byte address pointed to by the cursor in the cache segment where the cursor is located. The step of updating the cursor parameter of the current cursor according to the data length to obtain the updated current cursor comprises: If it is detected according to the data length that the current cursor moves within the cache segment, then the updated current cursor is obtained by updating the cache space length and the byte address; If it is detected according to the data length that the current cursor moves between the cache segments, the updated current cursor is obtained by updating the cache segment identifier, the cache space length and the byte address.

4. The message parsing method according to claim 3, wherein: Before the step of updating the cursor parameter of the current cursor according to the data length to obtain the updated current cursor, the message parsing method further includes: Obtaining a first length difference between a parsed length of a cache segment of the message to be parsed and a cache space length of the cache segment where the current cursor is located, and obtaining a second length difference between the parsed length of the cache segment and a cache segment length of the cache segment where the current cursor is located; Detecting whether the second length difference is less than a third length difference between the first length difference and the data length; If it is less than, it is determined that the current cursor moves within the cache segment; If it is greater than or equal to, it is determined that the current cursor moves between the cache segments.

5. The message parsing method according to claim 3, wherein: Before the step of updating the cursor parameter of the current cursor according to the data length to obtain the updated current cursor, the message parsing method further includes: Obtain a fourth length difference between the parsing length of the cache segment of the message to be parsed and the cache space length of the cache segment where the current cursor is located, and obtain a first length sum value between the fourth length difference and the data length; Detecting whether the cache segment parsing length is greater than the first length and value; If it is greater, it is determined that the current cursor moves between the cache segments; If it is less than or equal to, it is determined that the current cursor moves within the cache segment.

6. The message parsing method according to claim 1, wherein: Before the step of obtaining the remaining parsing length of the message to be parsed, the message parsing method further includes: Get the accessible cache segment header space of the cache segment where the current cursor is located; If it is detected that the accessible cache segment header space is smaller than the message header length of the message to be parsed, then after moving the message header length, at least one message cache segment in the preset message cache segment group is selected as the message cache space; The target data of the message to be parsed is cached in the message cache space.

7. The message parsing method according to claim 6, wherein: After the step of caching the target data of the message to be parsed into the message cache space, the message parsing method further includes: Get the length of the cache space to be truncated; If it is detected that the length of the buffer space to be truncated is less than or equal to the free buffer length of the message buffer space, then when the length of the buffer space to be truncated is less than the buffer segment length of the truncated buffer segment of the message buffer space, the length of the buffer space to be truncated is truncated in the truncated buffer segment, and the buffer segment length of the truncated buffer segment and the total message length of the message to be parsed are updated; If it is detected that the length of the buffer space to be truncated is greater than the free buffer length, truncation error information of the message to be parsed is generated.

8. The message parsing method according to claim 7, wherein: After the step of truncating the length of the to-be-truncated cache space by the truncated cache segment, the message parsing method further comprises: Detecting whether the current cursor of the message to be parsed is in the truncated cache segment; If it is in the truncated cache segment, the cache space length of the truncated cache segment is updated.

9. An electronic device, wherein: The electronic device comprises: at least one processor; a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the message parsing method described in any one of claims 1 to 7.

10. A computer-readable storage medium, wherein: The computer-readable storage medium stores a program for implementing the message parsing method, and the program for implementing the message parsing method is executed by a processor to implement the steps of the message parsing method as claimed in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Message processing equipment and method

    CN108055202A

  • Message analysis method, system and device and computer readable storage medium

    CN110381051A

  • Network message analysis method and device

    CN115277880A

  • Network message analysis method and device

    CN115277881A

  • Message analysis method, electronic equipment and readable storage medium

    CN116980501A

Cited By

  • Airplane message analysis method and device

    CN120475088A