Packet analysis method and device

By parsing and storing UDP packets using a pre-defined frame message parsing table, key-value data is obtained and a dictionary structure is formed. This solves the problem of low parsing efficiency for multiple types of UDP packets in existing technologies and achieves efficient packet data processing.

CN115801927BActive Publication Date: 2025-11-28CRSC URBAN RAIL TRANSIT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211457115.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-16
Publication Date
2025-11-28
Estimated Expiration
2042-11-16

Smart Images

  • Figure CN115801927B_ABST
    Figure CN115801927B_ABST
Patent Text Reader

Abstract

The application provides a message analysis method and device, the message analysis method comprises the following steps: when a plurality of clients and a plurality of servers communicate messages, determining message data to be analyzed; based on a preset frame message analysis table, analyzing frame messages to obtain key-value data corresponding to the frame messages; storing the key-value data corresponding to the frame messages in the message data to obtain a dictionary data structure. The method disclosed by the application realizes message data analysis by extracting the key-value data of the frame messages and the frame type of the frame messages to form a new data structure, thereby improving the efficiency of analyzing, classifying and storing a plurality of different types of message data.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication technology, in particular to a message analysis method and device. BACKGROUND

[0002] In the field of rail transit signal communication, UDP (User Datagram Protocol) has the characteristics of small delay, high real-time performance, etc., and is widely used in message data transmission.

[0003] In related technologies, when a client or a server receives multiple different types of UDP messages from other clients or servers, and the messages contain multiple types of messages, the original UDP message analysis program needs to be modified multiple times to analyze or store the multiple types of message information, which is low in efficiency. SUMMARY

[0004] The present application provides a message analysis method to solve the defects of low efficiency and long processing period in analyzing or storing multiple types of message information in the prior art, thereby improving the processing efficiency of multiple types of messages.

[0005] The present application provides a message analysis method, comprising:

[0006] When multiple clients and multiple servers communicate messages, determine the message data to be analyzed, wherein the message data to be analyzed includes multiple frame messages;

[0007] Based on a preset frame message analysis table, analyze the frame message to obtain the key-value data corresponding to the frame message, wherein the frame message analysis table includes multiple ordered identification information, the number of the multiple ordered identification information is determined based on the data length of the frame message, and the multiple ordered identification information is used to indicate the category of the frame data;

[0008] Store the key-value data corresponding to the frame message in the message data to obtain a dictionary data structure. According to the message analysis method provided by the present application, the frame message includes a frame header and frame data, the identification information includes an identification serial number and an identification value, and each identification serial number corresponds to multiple identification values;

[0009] The frame message is analyzed based on the preset frame message analysis table to obtain the key-value data corresponding to the frame message, comprising:

[0010] Starting from the position of the frame header, sequentially fill multiple identification serial numbers into the data structure corresponding to the frame data to obtain the outer key data corresponding to the frame message;

[0011] The target identification value corresponding to the multiple identification serial numbers is found based on the frame message analysis table, and the target identification value is one of the multiple identification values;

[0012] The key-value data corresponding to the frame message is obtained based on the outer key data and the target identification value.

[0013] According to the message analysis method provided by the application, the key-value data corresponding to the frame message is stored in the message data to obtain a dictionary data structure, which comprises:

[0014] The key-value data corresponding to each frame message is stored in the frame type structure of the frame message respectively to obtain the dictionary data structure.

[0015] According to the message analysis method provided by the application, the identification value comprises at least one of a number, a letter or a combination of a number and a letter.

[0016] According to the message analysis method provided by the application, after obtaining the dictionary data structure of the message data, the method further comprises:

[0017] The dictionary data structure is stored in a data cluster corresponding to a message queue.

[0018] The application further provides a message analysis device, which comprises:

[0019] The confirmation module is used to determine the message data to be analyzed when multiple clients and multiple servers communicate with each other, and the message data to be analyzed comprises multiple frame messages.

[0020] The first processing module is used to analyze the frame messages based on a preset frame message analysis table to obtain the key-value data corresponding to the frame messages, the frame message analysis table comprises multiple identification information arranged in order, the number of the multiple identification information arranged in order is determined based on the data length of the frame message, and the multiple identification information arranged in order is used to indicate the category of the frame data.

[0021] The second processing module is used to store the key-value data corresponding to the frame messages in the message data to obtain a dictionary data structure.

[0022] According to the message analysis device provided by the application, the device further comprises:

[0023] The third processing module is used to store the dictionary data structure in a data cluster corresponding to a message queue after obtaining the dictionary data structure of the message data.

[0024] The application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the packet analysis method according to any one of the above when executing the program.

[0025] The application further provides a non-transitory computer readable storage medium, which stores a computer program, wherein the computer program is executable on a processor to implement the packet analysis method according to any one of the above.

[0026] The application further provides a computer program product, comprising a computer program, wherein the computer program is executable on a processor to implement the packet analysis method according to any one of the above.

[0027] The packet analysis method and device provided by the application obtain the key-value data of each frame message through the position information of the frame message in the packet data and the data length of each message, and add the key-value data to the frame type structure of each frame message to form a new dictionary structure of values; the key-value data of the frame message and the frame type of the frame message are extracted to form a new data structure, thereby improving the efficiency of analyzing, classifying and storing packet data of various types. BRIEF DESCRIPTION OF DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the present application or prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0029] Figure 1 is one of the flowcharts of the packet analysis method provided by the application;

[0030] Figure 2 is a structure diagram of the frame message provided by the application;

[0031] Figure 3 is a structure diagram of the frame message analysis table provided by the application;

[0032] Figure 4 is another flowchart of the packet analysis method provided by the application;

[0033] Figure 5 is a structure diagram of the packet analysis device provided by the application;

[0034] Figure 6 is a structure diagram of the electronic device provided by the application. DETAILED DESCRIPTION

[0035] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below in combination with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the protection scope of the present application.

[0036] The present application will be described below in combination with Figures 1-4 The packet analysis method of the present application is described.

[0037] Figure 1 One of the flowcharts of the packet analysis method provided by the present application is shown in the figure, and the packet analysis method comprises the following steps.

[0038] In step 110, when multiple clients and multiple servers communicate with each other through packets, determine the packet data to be analyzed, and the packet data to be analyzed comprises multiple frame messages.

[0039] In this step, the packet data to be analyzed can be a UDP packet or a packet constructed based on other communication protocols.

[0040] In this embodiment, the sending end of the packet data can be one client or a client cluster comprising multiple clients, for example, the client cluster is Client i (i=1, 2, 3, 4…), and correspondingly, the receiving end of the packet data can be one server or a server cluster comprising multiple servers, for example, the server cluster can be Server i (i=1, 2, 3, 4…).

[0041] In this embodiment, when Client 1 receives UDP packets from Server 2 and Server 3 at the same time, the packet data type of Server 2 is TYPE2, and the packet type of Server 3 is TYPE3, and the format of the packet data is as follows:

[0042] Other data+TYPE2-frame 1 message-frame 2 message-frame 3 message-…-frame n message.

[0043] Among them, other data-TYPE2 is the packet header of the packet data, and the format of each frame message is as follows:

[0044] Target identifier-source-type-length-frame data.

[0045] Wherein, the target identifier represents the receiving end address information, the source represents the sending end address information, the type represents the message type, the length is the frame data length of the message data, the counter is a counter value, and the frame data represents the frame message contained in the message data; the target identifier, the source, the type and the length each occupy one byte, and the bit number is 8; the frame data length can be adjusted, for example, the frame data bit number is 8*8 bits.

[0046] Figure 2 is a structural schematic diagram of the frame message provided by the application, in Figure 2 In the embodiment shown, the target identifier of the first frame message (corresponding to frame 1) in the message data sent by Server2 to Client1 is assumed to be the number 0xE0 of Client1; the source occupies one byte, which is assumed to be the number 0x81 of Server2 here; the type occupies one byte, which represents the type of frame 1 message, and is assumed to be 0x01; the length occupies one byte, which represents the byte length occupied by the following frame data, and is assumed to be 0x08.

[0047] In step 120, the frame message is parsed based on a preset frame message parsing table to obtain key-value data corresponding to the frame message; the frame message parsing table includes a plurality of ordered arrangement identifier information, the number of the plurality of ordered arrangement identifier information is determined based on the data length of the frame message, and the plurality of ordered arrangement identifier information is used to indicate the category of the frame data.

[0048] In this step, the frame message in the message data can have a plurality of different identifier information, for example, when the frame data length is 8 bytes, at least 20 kinds of identifier information can be saved, the bit position occupied by each kind of identifier information is at least 1 and at most 8, and the identifier value corresponding to the 1 and 0 limited combination is given.

[0049] In this embodiment, the initial positions corresponding to different identifier information of the frame message can be the first positions where the frame headers of a plurality of frame messages in the message data appear, for example, since the composition of the message data includes a message header and frame messages, each frame message includes a target identifier, a source, a type, a length and frame data, wherein the initial position of the target identifier can be recorded as 0, that is, the bit position corresponding to the target identifier is 0, since the target identifier occupies 1 byte in the message data, the information amount contained is 8 bits, and the initial position corresponding to the source can be recorded as 8, the position distance between the initial position of the target identifier and the original initial position is the number of bits contained by the target identifier.

[0050] In this step, the information amount of the frame message can be the number of bits contained by the frame message.

[0051] In this step, the key-value data corresponding to the frame message is determined by the target identification value in the identification information, for example, for the frame message with the frame type of 0xE001, the corresponding key-value data can be the combination of "identification information 1: numerical or string type value", for example, "identification information 1: 1", "identification information 2: 5", "identification information 3: hello" or "identification information 20: 2".

[0052] In some embodiments, before the frame message in the packet data is parsed, the frame message type is checked first, and whether the target identification is for the current client cluster and whether the type of the corresponding frame message is the type required to be parsed is determined through the combination of the target identification and the frame message type.

[0053] Step 130, storing the key-value data corresponding to the frame message in the packet data to obtain a dictionary data structure.

[0054] In this step, the parsed key-value data can be stored under the frame type of the corresponding frame message to obtain a new frame storage structure.

[0055] In some embodiments, the new frame storage structure generated after the original packet data is parsed can be a dictionary data structure of values.

[0056] In this embodiment, after each frame message in the packet data is parsed according to the above parsing rule, the parsed frame message is stored in the structure corresponding to the frame type of each frame message to obtain a value dictionary of the packet data.

[0057] Figure 3 is a schematic diagram of the frame message type provided by the application, in Figure 3 In the embodiment shown, the frame type corresponds to 1 byte, contains 8 bits, the frame data length is assumed to be 8 bytes, and can be used to save the data of identification information 1-identification information 20. The bit position occupied by each type of identification information is at least 1 and at most 8, and the value is a limited combination of 1 and 0.

[0058] According to the packet parsing method provided by the application, the position information of the frame message in the packet data and the data length of each message are used to obtain the frame type of each frame message, and the frame type is added to the structure corresponding to the frame type of each frame message to form a new value dictionary structure. This method extracts the frame message to form a new data structure with the original frame message to realize the packet data parsing, which improves the efficiency of parsing and storing various types of packet data.

[0059] In some embodiments, the frame message includes a frame header and frame data, the identification information includes identification serial numbers and identification values, each identification serial number corresponds to multiple identification values; the frame message is parsed based on a preset frame message parsing table to obtain key-value data corresponding to the frame message, including: taking the position of the frame header as a starting position, sequentially filling the multiple identification serial numbers to a data structure corresponding to the frame data to obtain outer key data of the frame message; determining a target identification value corresponding to the multiple identification serial numbers based on the frame message parsing table, the target identification value being one of the multiple identification values; based on the outer key data and the target identification value, obtaining the key-value data corresponding to the frame message.

[0060] In this embodiment, each frame message in the packet data can be provided with multiple identification information according to data length, each identification information including identification serial numbers and multiple identification values, for example, one identification information of the frame message can be set as "identification information 1, value 1:0001, value 2:0010, value 3:0011".

[0061] In this embodiment, the target identification value is one of the multiple identification values contained in each identification information, for example, the target identification value of the frame message is 2 (corresponding to 0010).

[0062] In this embodiment, when Client 1 receives a packet data from Server 2, first identifies that the packet header is TYPE2, and then starts packet parsing, sequentially parses frame 1 message, frame 2 message, frame 3 message, etc., before parsing each frame message, frame message type checking is performed first, through the combination of the target identification and the type, it is judged whether the target identification is Client 1 and whether the frame type is the type required to be parsed; after the frame type checking is passed, according to the frame message parsing rule, the parsing is started according to the bit starting position of each frame message and the occupied bit position number, the frame message parsing rule is as follows:

[0063] "target identification": {"start": 0, "length": 8},

[0064] "source": {"start": 8, "length": 8},

[0065] "type": {"start": 16, "length": 8},

[0066] "length": {"start": 24, "length": 8},

[0067] "0xE001": {"identification information 1": {"start": 32, "length": 4},

[0068] "identification information 2": {"start": 36, "length": 4},

[0069] "Identification information 3": {"start": 40, "length": 2},

[0070] "Identification information 4": {"start": 42, "length": 2}},

[0071] "0xE002": {"Identification information 1": {"start": 32, "length": 2},

[0072] "Identification information 2": {"start": 34, "length": 4},

[0073] "Identification information 3": {"start": 38, "length": 4},

[0074] "Identification information 4": {"start": 42, "length": 2.

[0075] Wherein, start represents the starting bit, length represents the occupied bit number, "target identification" is located in the first byte of the frame header, occupies 8 bit, and the corresponding start is 0 and length is 8; "source" is located in the second byte of the frame header, occupies 8 bit, the corresponding start is 8 and length is 8; "type" is located in the third byte of the frame header, occupies 8 bit, the corresponding start is 16 and length is 8; "length" is located in the fourth byte of the frame header, occupies 8 bit, the corresponding start is 24 and length is 8; the frame data starts from the fifth byte, the start of the identification information 1 is 32 and the length is determined by the bit number occupied by the identification information 1, the start of other identification information is determined by the bit where the identification information is located, and the start of the identification information n is equal to the start of the identification information n-1 plus the length of the identification information n-1.

[0076] According to the packet analysis method provided by the application, the analysis mode of each frame message in the packet data is determined through the preset frame message analysis table, so as to obtain the key-value data of the frame message. The analysis mode has strong scalability. If a new packet type, frame message or identification information needs to be added, the frame message analysis rule can be modified directly by modifying the frame message analysis table, thereby reducing the program development amount.

[0077] In some embodiments, the key-value data corresponding to the frame message is stored in the packet data to obtain a dictionary data structure, including: storing the key-value data corresponding to each frame message in the frame type structure of the frame message respectively to obtain the dictionary data structure.

[0078] In this embodiment, the frame type structure of the frame message is used to indicate the category information of the frame message.

[0079] In this embodiment, the key-value data corresponding to each frame message is respectively stored in the frame type structure of the frame message, to form a new data structure.

[0080] Figure 4 is the second flowchart of the message analysis method provided by the application, in the embodiment shown in Figure 4 In the embodiment shown in the figure, the client receiving end (corresponding to Client1) receives the message sent by the server cluster, first determines that the message type (corresponding to TYPE2) is a type to be analyzed, specifically, according to the content of the n frame messages in the message data, respectively check whether the target identifier contained in each frame message matches the Client1 type, and whether the frame type is the same as the preset type, in the case that the target identifier matches the Client1 type, and the frame type is the same as the preset type, each frame message is analyzed to obtain a new data structure composed of each frame type and the corresponding key-value data (corresponding to frame 1, …, n type + identifier information: value), that is, a dictionary data composed of key-value data (identifier information: value) and frame message type, to obtain the updated message data.

[0081] According to the message analysis method provided by the application, the key-value of the frame message in the message data is extracted, and the frame type corresponding to the frame message is used to form a new structure data, so that the analysis method of the frame message is convenient and efficient, and the development and debugging of subsequent applications are facilitated.

[0082] In some embodiments, the message data to be analyzed includes multiple, determining the message data to be analyzed, including: determining the target message data, the target message data is one of the multiple message data to be analyzed.

[0083] It can be understood that the UDP message data generated by different types of clients or servers also includes multiple, each message contains data of multiple types of messages, and before the message data is analyzed, the type of the message data to be analyzed needs to be determined.

[0084] In this embodiment, Client1 can receive UDP messages sent by Server2 and Server3, the message data type of Server2 is TYPE2, the message type of Server3 is TYPE3, and after Client1 identifies that the message header contains the type information of TYPE2, the frame messages in the message data corresponding to TYPE2 are analyzed.

[0085] According to the message analysis method provided by the application, the message data of each type is classified by checking the type of the message data, and the analysis efficiency of the message data of multiple types is improved.

[0086] In some embodiments, the identification value includes at least one of a number, a letter, or a combination of a number and a letter.

[0087] In this embodiment, the identification information corresponding to each frame message can include multiple identification serial numbers, each identification serial number corresponds to multiple identification values, and the content of the identification value can be customized according to actual user requirements, in order to distinguish the types of different frame messages.

[0088] Optionally, the identification value under one identification serial number can be a number or a string type value, for example, the identification value can be 1, hello, etc.

[0089] According to the message analysis method provided by the application, the types of different frame messages are distinguished by setting multiple types of identification values for the frame message, and the accuracy of message analysis is improved.

[0090] In some embodiments, after obtaining the dictionary data structure of the message data, the method further includes: storing the dictionary data structure in a data cluster corresponding to the message queue.

[0091] In this embodiment, the dictionary data structure is stored in the message queue, and the data can be directly analyzed or modified by using a message queue management tool, which is more intuitive and efficient than analyzing original UDP messages, and is more convenient for upper layer application development and debugging.

[0092] In Figure 4 In the embodiment shown, after obtaining the dictionary data of the identification information and values of the frame message, the dictionary data is stored in the message queue.

[0093] According to the message analysis method provided by the application, the value dictionary data structure is used for upper layer application development and debugging, and the management efficiency of the sending data cluster is improved.

[0094] The message analysis device provided by the application is described below, and the message analysis device described below can be mutually corresponding and referred to the message analysis method described above.

[0095] Figure 5 is a structural schematic diagram of the message analysis device provided by the application, as Figure 5 The application also provides a message analysis device, which includes a confirmation module 510, a first processing module 520, and a second processing module 530.

[0096] The confirmation module 510 is configured to determine the message data to be parsed when a plurality of clients and a plurality of servers perform message communication, and the message data to be parsed includes a plurality of frame messages.

[0097] The first processing module 520 is configured to parse the frame message based on a preset frame message parsing table to obtain key-value data corresponding to the frame message, the frame message parsing table includes a plurality of ordered identification information, the number of the plurality of ordered identification information is determined based on the data length of the frame message, and the plurality of ordered identification information is used to indicate the category of the frame data.

[0098] The second processing module 530 is configured to store the key-value data corresponding to the frame message in the message data to obtain a dictionary data structure.

[0099] According to the message parsing device provided by the application, the key-value data of each frame message is obtained through the position information of the frame message in the message data and the data length of each message, and the key-value data is added to the structure corresponding to the frame type of each frame message to form a new value dictionary structure. The new data structure is formed by extracting the key-value data of the frame message and the frame type of the frame message, which improves the efficiency of parsing, classifying and storing various types of message data.

[0100] According to the message parsing device provided by the application, the device further includes:

[0101] The third processing module is configured to store the dictionary data structure in the data cluster corresponding to the message queue after obtaining the dictionary data structure of the message data.

[0102] According to the message parsing device provided by the application, the value dictionary data structure is used for upper-layer application development and debugging, which improves the management efficiency of the sending data cluster.

[0103] Figure 6 An example of an entity structure diagram of an electronic device is shown in FIG. 1. Figure 6As shown, the electronic device can include a processor 610, a communications interface 620, a memory 630, and a communications bus 640, wherein the processor 610, the communications interface 620, and the memory 630 complete mutual communication through the communications bus 640. The processor 610 can invoke a logical instruction in the memory 630 to execute a packet parsing method, the method including: determining to-be-parsed packet data when a plurality of clients and a plurality of servers perform packet communication, the to-be-parsed packet data including a plurality of frame messages; based on a preset frame message parsing table, parsing the frame messages to obtain key-value data corresponding to the frame messages, the frame message parsing table including a plurality of ordered arrangement identification information, a quantity of the plurality of ordered arrangement identification information being determined based on a data length of the frame messages, and the plurality of ordered arrangement identification information being used to indicate a category of frame data; and storing the key-value data corresponding to the frame messages in the packet data to obtain a dictionary data structure.

[0104] In addition, the logical instruction in the memory 630 described above can be implemented in the form of a software functional unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various program code storage media.

[0105] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer readable storage medium, and the computer program is executable by a processor to enable a computer to perform the message analysis method provided by any of the above methods, the method comprising: determining to-be-analyzed message data when a plurality of clients and a plurality of servers perform message communication, the to-be-analyzed message data comprising a plurality of frame messages; analyzing the frame messages based on a preset frame message analysis table to obtain key-value data corresponding to the frame messages, the frame message analysis table comprising a plurality of sequentially arranged identification information, the number of the plurality of sequentially arranged identification information being determined based on a data length of the frame messages, and the plurality of sequentially arranged identification information being used to indicate a category of the frame data; and storing the key-value data corresponding to the frame messages in the message data to obtain a dictionary data structure.

[0106] In yet another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, and the computer program is executable by a processor to implement the message analysis method provided by any of the above methods, the method comprising: determining to-be-analyzed message data when a plurality of clients and a plurality of servers perform message communication, the to-be-analyzed message data comprising a plurality of frame messages; analyzing the frame messages based on a preset frame message analysis table to obtain key-value data corresponding to the frame messages, the frame message analysis table comprising a plurality of sequentially arranged identification information, the number of the plurality of sequentially arranged identification information being determined based on a data length of the frame messages, and the plurality of sequentially arranged identification information being used to indicate a category of the frame data; and storing the key-value data corresponding to the frame messages in the message data to obtain a dictionary data structure.

[0107] The apparatus embodiments described above are merely illustrative, wherein the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Part or all of the modules can be selected to achieve the purpose of the present embodiment scheme according to actual needs. Those skilled in the art can understand and implement it without creative labor.

[0108] Those skilled in the art can clearly understand the technical solutions of the various embodiments from the above description of the embodiments, and the various embodiments can be implemented by means of software with the necessary general hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0109] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A message parsing method, characterized in that, include: When multiple clients communicate with multiple servers via messages, the message data to be parsed is determined, and the message data to be parsed includes multiple frame messages; The format of each message frame includes: The sequence number is: Target Identifier-Source-Type-Length-Frame Data; where Target Identifier represents the receiver's address information, Source represents the sender's address information, Type represents the type of frame message, and Length represents the length of the frame data in bytes; the message data to be parsed is UDP message data; the sender of the UDP message data is a client cluster including multiple clients, and the receiver of the UDP message data is a server cluster including multiple servers. The frame message is parsed based on a preset frame message parsing table to obtain the key-value data corresponding to the frame message. The frame message parsing table includes multiple ordered identifiers. The number of ordered identifiers is determined based on the data length of the frame message. The ordered identifiers are used to indicate the category of the frame data. The key-value data corresponding to the frame message is stored under the frame type of the corresponding frame message to obtain a new frame storage structure. The new frame storage structure is a dictionary data structure of values. The frame message includes a frame header and frame data. The identification information includes an identification number and an identification value. Each identification number corresponds to multiple identification values. The frame message is parsed based on a preset frame message parsing table to obtain the key-value data corresponding to the frame message, including: Starting from the position of the frame header, the multiple identifier numbers are sequentially filled into the data structure corresponding to the frame data to obtain the outer key data of the frame message; Based on the frame message parsing table, the target identifier value corresponding to the plurality of identifier sequence numbers is determined, and the target identifier value is one of the plurality of identifier values; Based on the outer key data and the target identifier value, the key-value data corresponding to the frame message is obtained.

2. The message parsing method according to claim 1, characterized in that, The identifier value includes at least one of numbers, letters, or a combination of numbers and letters.

3. The message parsing method according to any one of claims 1-2, characterized in that, After obtaining the dictionary data structure of the message data, the method further includes: The dictionary data structure is stored in the data cluster corresponding to the message queue.

4. A message parsing apparatus, employing the message parsing method as described in claim 1, characterized in that, include: The confirmation module is used to determine the message data to be parsed when multiple clients communicate with multiple servers. The message data to be parsed includes multiple frame messages. The format of each message frame includes: target identifier-source-type-length-frame data; where the target identifier represents the receiver's address information, the source represents the sender's address information, the type represents the type of the frame message, and the length represents the byte length of the frame data; the message data to be parsed is UDP message data; the sender of the UDP message data is a client cluster including multiple clients, and the receiver of the UDP message data is a server cluster including multiple servers. The first processing module is used to parse the frame message based on a preset frame message parsing table to obtain key-value data corresponding to the frame message. The frame message parsing table includes multiple ordered identifiers. The number of the multiple ordered identifiers is determined based on the data length of the frame message. The multiple ordered identifiers are used to indicate the category of the frame data. The second processing module is used to store the key-value data corresponding to the frame message under the frame type of the corresponding frame message to obtain a new frame storage structure. The new frame storage structure is a dictionary data structure of values. The frame message includes a frame header and frame data. The identification information includes an identification number and an identification value. Each identification number corresponds to multiple identification values.

5. The message parsing apparatus according to claim 4, characterized in that, The device further includes: The third processing module is used to store the dictionary data structure in the data cluster corresponding to the message queue after obtaining the dictionary data structure of the message data.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the message parsing method as described in any one of claims 1 to 3.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the message parsing method as described in any one of claims 1 to 3.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the message parsing method as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Message parsing method, message packaging method, devices, and message processing system

    CN108243168A

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

    CN110012002A

  • Message forwarding method and device, vehicle-mounted network system and readable storage medium

    CN114827290A