CN114679504A - UDP message parsing method and device and computer equipment - Google Patents

UDP message parsing method and device and computer equipment Download PDF

Info

Publication number
CN114679504A
CN114679504A CN202210583875.3A CN202210583875A CN114679504A CN 114679504 A CN114679504 A CN 114679504A CN 202210583875 A CN202210583875 A CN 202210583875A CN 114679504 A CN114679504 A CN 114679504A
Authority
CN
China
Prior art keywords
target
analysis
parsing
analyzed
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210583875.3A
Other languages
Chinese (zh)
Other versions
CN114679504B (en
Inventor
不公告发明人
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Shulian Cloud Computing Technology Co ltd
Original Assignee
Chengdu Shulian Cloud Computing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Shulian Cloud Computing Technology Co ltd filed Critical Chengdu Shulian Cloud Computing Technology Co ltd
Priority to CN202210583875.3A priority Critical patent/CN114679504B/en
Publication of CN114679504A publication Critical patent/CN114679504A/en
Application granted granted Critical
Publication of CN114679504B publication Critical patent/CN114679504B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/164Adaptation or special uses of UDP protocol
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Abstract

The application provides a UDP message parsing method, a UDP message parsing device and computer equipment, and relates to the technical field of communication. The method comprises the following steps: receiving selection operation input by a user, and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules; receiving a UDP message to be analyzed from the target receiving address; and analyzing the UDP message according to the target analysis rule to obtain an analysis result. According to the UDP message analysis scheme provided by the application, different analysis rules are configured to analyze different types of UDP messages, an analysis program does not need to be modified, the analysis rules are completely self-defined, in addition, different receiving addresses can be configured to receive the UDP messages, the analysis work is simpler and more convenient, and the flexibility of the analysis work is improved.

Description

UDP message parsing method and device and computer equipment
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a UDP packet parsing method, apparatus, and computer device.
Background
At present, the parsing of UDP (User Datagram Protocol) messages is mostly completed by a special UDP message parsing program, and one UDP message parsing program correspondingly parses one type of UDP message.
Disclosure of Invention
In order to solve the above problems, the present application provides a UDP packet parsing method, apparatus, and computer device, which can implement parsing of different types of UDP packets by configuring different parsing tasks.
In order to achieve the purpose, the following technical scheme is adopted in the application:
in a first aspect, an embodiment of the present application provides a UDP packet parsing method, where the method includes:
receiving selection operation input by a user, and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules;
receiving a UDP message to be analyzed from the target receiving address;
and analyzing the UDP message according to the target analysis rule to obtain an analysis result.
In a specific embodiment, the step of generating each parsing task includes:
receiving name setting operation input by a user, and generating a corresponding resolution task name according to the name setting operation;
receiving an address setting operation input by a user, and generating a receiving address corresponding to the analysis task name according to the address setting operation;
receiving rule setting operation input by a user, and generating an analysis rule corresponding to the analysis task name according to the rule setting operation;
and receiving a saving operation input by a user, and generating the analysis task corresponding to the analysis task name, the receiving address and the analysis rule according to the saving operation.
In a specific implementation manner, the target parsing rule includes a target parsing parameter and a target field set, and the parsing the UDP packet according to the target parsing rule includes:
judging whether the start mark of the UDP message is the same as the preset start mark of the target analysis rule or not;
and if the starting mark of the UDP message is the same as the preset starting mark of the target analysis rule, analyzing the UDP message according to the target analysis parameters and/or the target field set.
In a specific implementation manner, the parsing the UDP packet according to the target parsing parameter includes:
determining a target section to be analyzed of the UDP message according to the target analysis parameter;
determining a storage mode of the target segment to be analyzed according to the target analysis parameters, wherein the storage mode comprises a large-end mode and a small-end mode;
when the storage mode of the target segment to be analyzed is the big-end mode, judging that the coding form of the target segment to be analyzed is an original code form or a complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the target segment to be analyzed according to the target analysis parameters;
if the coding mode of the target section to be analyzed is the complementary code mode, converting the target section to be analyzed in the complementary code mode into the target section to be analyzed in the original code mode, and analyzing the target section to be analyzed in the original code mode according to the target analysis parameters;
or, when the storage mode of the target segment to be analyzed is the small-end mode, converting the target segment to be analyzed in the small-end mode into the target segment to be analyzed in the large-end mode to obtain a corrected target segment, and judging whether the coding form of the target segment to be analyzed is the original code form or the complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the corrected target segment according to the target analysis parameters;
and if the coding mode of the target section to be analyzed is the complementary code form, converting the corrected target section into a corrected target section in an original code form, and analyzing the corrected target section in the original code form according to the target analysis parameters.
In a specific implementation manner, the type of the target parsing parameter includes a BIT type, and the parsing the target segment to be parsed according to the target parsing parameter includes:
if the type of the target analysis parameter is a BIT type, judging whether the target analysis parameter configures a target analysis format;
if the target analysis parameter configures the target analysis format, analyzing the target segment to be analyzed according to the target analysis format;
and if the target analysis format is not configured for the target analysis parameter, analyzing the target section to be analyzed according to a default analysis format.
In a specific implementation manner, the target field set includes a plurality of target parsing parameters, and the parsing step of the UDP packet according to the target field set includes:
and analyzing the UDP message according to the target analysis parameters in the target field set.
In a specific implementation manner, after the step of parsing the UDP packet according to the target parsing rule, the method further includes:
judging whether the target analysis parameters are configured with data conversion formulas or not;
if the target analysis parameter configures the data conversion formula, performing data conversion on the analysis result according to the data conversion formula to obtain a conversion result;
if the target analysis parameter is not configured with the data conversion formula, not performing data conversion on the analysis result;
judging whether the target analysis parameter is configured with a decimal retention condition or not;
if the decimal number reserving condition is configured for the target analysis parameter, reserving a preset number of decimal digits for the analysis result or the conversion result;
if the decimal retention condition is not configured for the target analysis parameter, two decimal places are retained for the analysis result or the conversion result;
judging whether the target analysis parameter is configured with a data dictionary or not;
if the target analysis parameter configures the data dictionary, performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result;
and if the target analysis parameter is not configured with the data dictionary, not performing data replacement on the analysis result or the conversion result.
In a specific embodiment, the step of performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result includes:
judging whether target initial data with the same value as the analysis result or the conversion result exists in the plurality of initial data;
if the target initial data exists, replacing the analysis result or the conversion result with final data corresponding to the target initial data;
and if the target initial data does not exist, replacing the analysis result or the conversion result.
In a second aspect, an embodiment of the present application provides a UDP packet parsing apparatus, where the apparatus includes:
the acquisition module is used for receiving selection operation input by a user and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules;
a receiving module, configured to receive a UDP packet to be parsed from the target receiving address;
and the analysis module is used for analyzing the UDP message according to the target analysis rule to obtain an analysis result.
In a third aspect, an embodiment of the present application provides a computer device, where the computer device includes a memory and a processor, where the memory stores a computer program, and the computer program executes, when the processor runs, the UDP packet parsing method according to the first aspect.
Compared with the prior art, the method has the following beneficial effects:
according to the UDP message parsing method, the UDP message parsing device and the computer equipment provided by the embodiment, the selection operation input by the user is received, the corresponding target parsing tasks are obtained from the plurality of parsing tasks in the parsing task library according to the selection operation, the target parsing tasks comprise target receiving addresses and target parsing rules, the UDP messages to be parsed are received through the target receiving addresses, and the UDP messages are parsed according to the target parsing rules to obtain the parsing results. Different analysis rules are configured to analyze different types of UDP messages, an analysis program does not need to be modified, the analysis rules are completely self-defined, in addition, different receiving addresses can be configured to receive the UDP messages, the analysis work is simpler and more convenient, and the flexibility of the analysis work is improved.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings required to be used in the embodiments will be briefly described below, and it should be understood that the following drawings only illustrate some embodiments of the present invention, and therefore should not be considered as limiting the scope of the present invention. Like components are numbered similarly in the various figures.
Fig. 1 shows a flow diagram of a UDP packet parsing method according to an embodiment of the present application;
fig. 2 shows a schematic structural diagram of a UDP packet parsing apparatus according to an embodiment of the present application.
Summary of reference numerals:
UDP message parsing device-200; an acquisition module-201; a receiving module-202; and a resolving module-203.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.
The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
Hereinafter, the terms "including", "having", and their derivatives, which may be used in various embodiments of the present invention, are only intended to indicate specific features, numbers, steps, operations, elements, components, or combinations of the foregoing, and should not be construed as first excluding the existence of, or adding to, one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing.
Furthermore, the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present invention belong. The terms (such as terms defined in a commonly used dictionary) will be construed to have the same meaning as the contextual meaning in the related art and will not be construed to have an idealized or overly formal meaning unless expressly so defined in various embodiments of the present invention.
Example 1
The embodiment provides a UDP message parsing method. The UDP packet parsing method provided in this embodiment is described below with reference to fig. 1.
Referring to fig. 1, the UDP packet parsing method provided in this embodiment includes the following steps:
step S101, receiving a selection operation input by a user, and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules.
Specifically, the UDP packet parsing method provided in this embodiment is implemented based on a BS (Browser/Server) structure, where the BS structure is also referred to as a Browser/Server architecture. In specific implementation, the server end completes the analysis of the UDP message, and the specific analysis process may be to set a UDP message analysis system at the server end in advance. The user can access the UDP message parsing system through the browser to complete the parsing work of the UDP message. The browsers with the search function may all be used to access the UDP packet parsing system, which is not limited herein.
The UDP packet is widely used for data transmission of various real-time applications, such as audio/video communication, games, industrial internet applications, and the like. The types of UDP messages generated by different applications during data transmission are different, which is particularly indicated by differences in message structures and contents. Therefore, different parsing methods are required to parse UDP packets of different applications.
In this embodiment, corresponding parsing tasks are set in advance for UDP messages generated by different application programs, and the parsing tasks are stored in a designated database in the server, where the designated database may be defined as a parsing task library. When a user determines that the UDP message of the selected target application program needs to be analyzed, the user firstly accesses the UDP message analysis system through the browser and selects an analysis task in the UDP message analysis system. The user selected analysis task corresponds to the selected target application program, the analysis task can be defined as a target analysis task, the UDP message analysis system receives the target analysis task selected by the user, and the UDP message of the target application program is analyzed by calling the target analysis task.
The target analysis task comprises a preset receiving address and an analysis rule, and the process of analyzing the UDP message of the target application program through the target analysis task comprises the following steps: and after receiving the UDP message of the target application program, analyzing the UDP message of the target application program by an analysis rule preset by the target analysis task, wherein the analysis rule can be defined as a target analysis rule.
In this embodiment, corresponding parsing tasks are set for different application programs in advance, and when a UDP packet of a selected application program needs to be parsed, only the corresponding parsing task needs to be selected, and the UDP packet parsing system calls the parsing task to complete subsequent parsing, so that the UDP packet parsing is simpler and more convenient, and the flexibility of the UDP packet parsing is also improved.
Step S102, receiving UDP message to be analyzed from the target receiving address.
Specifically, before the target parsing task parses the UDP packet of the selected target application, a target receiving address needs to be set, and a specific setting process may be that a user accesses the UDP packet parsing system through a browser, and adds the target receiving address to the target parsing task in the UDP packet parsing system. The transmission mode based on the UDP message may be a unicast mode or a multicast mode, and correspondingly, the destination receiving address may also be a unicast address or a multicast address. In specific implementation, the target receiving address includes an IP address and a port number, and receiving the UDP packet of the specific target application can be realized by setting the specific IP address and the port number.
For example, when a UDP packet of a selected video application needs to be parsed, an IP address and a port number of the video application transmitting the UDP packet may be set as a target receiving address, i.e., the UDP packet of the video application may be received through the IP address and the port number.
Step S103, analyzing the UDP message according to the target analysis rule to obtain an analysis result.
Specifically, after receiving the UDP message of the target application program, the UDP message of the target application program is parsed according to a target parsing rule preset by the target parsing task. The target analysis rule presets a plurality of analysis parameters, and each analysis parameter respectively corresponds to a section of content in a UDP message of a target application program. After the analysis is finished, the analysis result corresponding to each analysis parameter is stored in each corresponding column in the data table so that the user can consult the data table conveniently. The data table is stored in a database of the server and used for storing the analysis results of the UDP messages, each analysis rule corresponds to one data table, that is, the analysis results of the UDP messages corresponding to each analysis rule are stored in the data table corresponding to the analysis rule.
For example, for a selected video application, a corresponding parsing rule is set for the UDP packet of the video application according to the pre-acquired UDP packet structure and content information of the video application. The analysis rule comprises a plurality of analysis parameters, each analysis parameter respectively and correspondingly analyzes a section of content in the UDP message of the video application program, the UDP message of the video application program can be analyzed through the plurality of analysis parameters, and after the analysis is finished, the analysis result is automatically stored in the corresponding data table.
In a specific embodiment, the step of generating each parsing task includes:
receiving name setting operation input by a user, and generating a corresponding resolution task name according to the name setting operation;
receiving an address setting operation input by a user, and generating a receiving address corresponding to the analysis task name according to the address setting operation;
receiving rule setting operation input by a user, and generating an analysis rule corresponding to the analysis task name according to the rule setting operation;
and receiving a saving operation input by a user, and generating the analysis task corresponding to the analysis task name, the receiving address and the analysis rule according to the saving operation.
Specifically, the parsing task is preset by the user, and the setting mode may be that the user accesses the message parsing system through the browser, and sets the parsing task in the message parsing system. The setting process of the analysis task comprises the step of setting an analysis task name, wherein the analysis task name is used for inquiring the corresponding analysis task. The name of the analysis task can be consistent with the name of the selected application program, so that the analysis task for analysis can be quickly selected when the UDP message of the selected application program needs to be analyzed subsequently.
After the name of the analysis task is set, the setting process of the analysis task further comprises setting a receiving address, wherein the receiving address is used for receiving the UDP message of the application program corresponding to the analysis task. The setting manner of the receiving address may refer to the specific content of step S102, and is not described herein again to avoid repetition.
After the receiving address is set, the setting process of the analysis task further comprises setting an analysis rule, namely selecting one analysis rule corresponding to the analysis task from a plurality of preset analysis rules and adding the analysis rule to the analysis task. Specifically, the user may preset the corresponding parsing rule according to UDP messages of different applications, so as to set the parsing task quickly, for example, the parsing rule for parsing the UDP messages of the video application may be set, the parsing rule for parsing the UDP messages of the game application may also be set, and the like, which is not limited herein.
And storing the setting results corresponding to the setting operations to generate an analysis task, repeating the operation process to generate a plurality of analysis tasks, and storing the generated plurality of analysis tasks in an analysis task library to deal with the analysis work of UDP messages of different application programs.
In a specific implementation manner, the target parsing rule includes a target parsing parameter and a target field set, and the parsing the UDP packet according to the target parsing rule includes:
judging whether the start mark of the UDP message is the same as the preset start mark of the target analysis rule or not;
and if the starting mark of the UDP message is the same as the preset starting mark of the target analysis rule, analyzing the UDP message according to the target analysis parameters and/or the target field set.
Specifically, the setting process of the parsing rule includes: the name of the analysis rule is set and used for searching the corresponding analysis rule, and the name of the analysis rule can be set to be related to the corresponding analysis task, so that the corresponding analysis rule can be quickly selected when the analysis task is set.
And presetting start marks for the analysis rule according to the acquired UDP message structure and the content information, wherein each start mark consists of a byte start position and identification content. The byte start position may be set to any one byte position in the UDP packet, for example, the byte start position may be set to the 4 th byte, the 6 th byte, and the like. The identification content may be set as a content corresponding to a preset byte length in the UDP packet, where the byte length is in bytes. For example, the identification content may be set to "AB" as the content represented by 2 bytes in the UDP packet, or the identification content may be set to "student" as the content represented by 4 bytes in the UDP packet. Therefore, the start flag may be set to a content corresponding to a certain preset byte length in the UDP packet. For example, the start flag may be set to indicate that the content represented by the 2 th bytes from 4 th to 5 th in the UDP packet is "AB", or the start flag may also be set to indicate that the content represented by the 4 th bytes from 6 th to 9 th in the UDP packet is "student", and the like, and may be set according to actual needs, which is not limited herein.
In the analysis rule, at least one start flag may be set, a plurality of start flags may be set, and a relationship of "and" or "may be set between the plurality of start flags. By setting the start flag, the received UDP message can be filtered to screen out the UDP message to be analyzed. Since the length of the UDP packet is variable, an "end flag" may also be set in order to better filter the received UDP packet. The difference from the start flag is that the byte start position of the end flag does not need to be set, and is fixed as the last byte of the UDP message. Therefore, the end flag only needs to be set to the corresponding identification content, and similarly, a plurality of end flags may be set. The setting process of the ending flag may refer to the setting process of the starting flag, and is not described herein again to avoid repetition. In addition, a data length interval may be set to filter the received UDP packet, that is, when the total length of the received UDP packet is less than or equal to the data length interval, the UDP packet is parsed. For example, the data length interval may be set to 100 bytes, and if the total length of the received UDP packet is 80 bytes, the analysis is performed, and if the total length of the received UDP packet is 120 bytes, the analysis is not performed.
After the start flag, the end flag, and the data length interval of the UDP packet are set, an analysis parameter and a field set for analyzing the UDP packet need to be added to the analysis rule. The parsing parameters and the field sets are respectively used for parsing corresponding contents of the UDP packet, and the contents of the UDP packet parsed by the parsing parameters and the field sets can be defined as UDP packet blocks, that is, one parsing parameter and one field set respectively parse one UDP packet block correspondingly.
The analysis parameters are preset by a user, and the setting process of the analysis parameters comprises the following steps:
(1) and setting a parameter name, wherein the parameter name is used as a field name of the data table, namely as a column name in the data table. For example, the parameter name may be set to "name", "gender", "age", etc., and when the parameter name of a certain resolution parameter is set to "name", a "name" column is generated in the data table for storing the resolution result of the resolution parameter.
(2) And a remark is set and used for introducing the analysis parameters, so that a user can better understand the meaning of each analysis parameter when looking up the data table.
(3) The quantization unit, which is a unit for analyzing the parameter, is set to be displayed at the header of the data table after setting, for example, if the parameter name is set to "gender", the quantization unit may be set to "male" or "female".
(4) Setting an encoding form, where the encoding form includes an original code form and a complement form, and setting according to the UDP packet block analyzed corresponding to the analysis parameter, for example, if the encoding form of the UDP packet block analyzed corresponding to the analysis parameter is the original code form, the encoding form of the analysis parameter may be set to the original code form, and if the encoding form of the UDP packet block analyzed corresponding to the analysis parameter is the complement form, the encoding form of the analysis parameter may be set to the complement form.
(5) And setting a storage mode, wherein the storage mode comprises a big-end mode and a small-end mode, wherein the big-end mode means that high bytes of data are stored in a low address of the memory, and low bytes of data are stored in a high address of the memory. Conversely, the small-end mode means that the high bytes of data are stored in the high address of the memory and the low bytes of data are stored in the low address of the memory. The storage mode is also set according to the UDP packet block that is parsed corresponding to the parsing parameter, for example, if the storage mode of the UDP packet block that is parsed corresponding to the parsing parameter is a big-end mode, the storage mode of the parsing parameter may be set to a big-end mode, and if the storage mode of the UDP packet block that is parsed corresponding to the parsing parameter is a small-end mode, the storage mode of the parsing parameter may be set to a small-end mode.
(6) The type is set, the parsing parameter includes a basic type and a BIT type, wherein the basic type is a basic type in the exponent data structure, and includes CHAR (character), SHORT (SHORT integer), INT (integer), LONG (LONG integer), UCHAR (unsigned character), USHORT (unsigned SHORT integer), UINT (unsigned integer), ULONG (unsigned LONG integer), FLOAT (single floating point number) and DOUBLE (DOUBLE floating point number). When the parsing parameter is set to the basic type, parsing is performed in units of bytes, and the byte length of each basic type is a fixed length, for example, INT (integer) is 4 bytes, LONG (integer) is 8 bytes, and the like. The specific selection of the basic type may be determined according to the UDP packet block analyzed corresponding to the analysis parameter, for example, if the UDP packet block analyzed corresponding to the analysis parameter is a LONG type, the type of the analysis parameter may be set to a LONG type. Correspondingly, the length of the byte of the UDP message block analyzed correspondingly by the analysis parameter with the type of LONG is 8 bytes, and the rest is analogized in the same way.
In the present embodiment, when the parsing parameter is set to BIT type, the parsing is performed in units of BITs, i.e., representing binary BITs, hereinafter simply referred to as BITs, 1 byte being equal to 8 BITs. Therefore, when the parsing parameter is set to the BIT type, it is necessary to set the byte length of the parsing parameter, and for example, the byte length of the parsing parameter may be set to 1 byte or 2 bytes, etc. The byte length of the UDP message block which is analyzed correspondingly to the analysis parameter can be determined according to the set byte length.
Since the parsing parameter is parsed in units of BITs when the type of the parsing parameter is a BIT type, a BIT start position and a BIT end position of the parsing parameter may be set, and when the parsing parameter parses the corresponding UDP packet block, the BIT start position and the BIT end position indicate that a BIT is parsed from a BIT within the byte length of the UDP packet block. I.e. the bit start position and the bit end position, are used to determine a certain piece of data within the byte length of the UDP block of packets to be parsed. And if the analysis parameter does not set the bit start position and the bit end position, analyzing all bits in the byte length of the UDP message block by default.
When the parsing parameter is a BIT type, the parsing format of the parsing parameter may also be set, for example, when the UDP packet needs to be parsed into a BCD (Binary-Coded default) code, the parsing format may be set such that a pair of middle brackets represents one processing unit, and two numbers in the middle brackets are denoted by ": spaced apart, with the two middle brackets being spaced apart by ". times.. For example, when setting the byte length of the BIT type to 2 bytes, i.e., 16 BITs, the processing unit that resolves to the BCD code may set: [15:8] [7:0], which means that the upper 8 bits are resolved into one number, the lower 8 bits are resolved into one number, and the numbers are connected with one another. A plurality of processing units can be arranged, and the delimiters can be customized among the processing units. If the parsing parameter does not set the parsing format, all bits within the byte length are parsed together by default.
For example, if the UDP packet block to be analyzed is 0X0102, the corresponding bits are: 0000000100000010. when the UDP packet block is analyzed according to the processing unit "[ 15:8] - [7:0 ]", the analysis result of the upper 8 bits "00000001" is 1, and the analysis result of the lower 8 bits "00000010" is 2, so that the final analysis result of the UDP packet is 1.2. If the parsing format is not set, the parsing parameters are parsed together according to the default format "[ 15:0 ]", i.e. 16 bits "0000000100000010", and the parsing result of the UDP packet block is 258.
(7) And setting a byte starting position, wherein the byte starting position represents a byte position at which the analysis parameter starts to be analyzed in the UDP message. Therefore, according to the byte start position of the analysis parameter and the byte length of the analysis parameter, the UDP packet block that is analyzed by the analysis parameter can be determined. For example, if the byte start position set by the parsing parameter is 4, and the byte length set by the parsing parameter is 5, it indicates that the UDP packet block parsed by the parsing parameter corresponds to all contents included in the 4 th to 8 th bytes in the UDP packet.
The byte start position may be automatically generated, that is, when the parsing parameter is set, the byte start position of the currently set parsing parameter may be calculated according to the sum of the byte start position and the byte length of each previously set parsing parameter.
In addition, the byte start position can also be set by self, for example, the input number 4 indicates that the current parsing parameter starts to parse from the 4 th byte in the UDP message. The byte start position may also be set as the relative position of the previous parsing parameter, for example, the parsing end position of the previous parsing parameter in the UDP message is the 6 th byte, and if the contents of the 4 th bytes from 7 th to 10 th do not need to be parsed, the byte start position of the current parsing parameter may be set to "+ 4" to indicate the parsing end position relative to the previous parsing parameter. The current parsing parameter will skip 4 bytes, i.e. skip 4 bytes from 7 th to 10 th, and start parsing from 11 th byte. Through the setting of the relative position, the UDP message content which does not need to be analyzed can be flexibly eliminated, and the analysis efficiency is improved.
After the byte start position is set by self-definition, whether the position is crossed or not can be checked during storage setting, and if the position is crossed, an error prompt can be given. For example, the UDP packet block analyzed corresponding to the previous analysis parameter is from 6 th byte to 10 th byte in the UDP packet, if the byte start position of the current parameter is set to 8, an intersection is generated, and at this time, if the current setting is saved, an error prompt is given, and modification is required.
(8) Setting four arithmetic operation expressions for the analytic parameters to analyze the analytic results of the analytic parametersAnd (6) converting. For example, if the analysis parameter name is a, the four arithmetic expressions can be set to (a + 1)
Figure SYM_220523145340001
And (a-2) ÷ 100, which means that the analysis result corresponding to the analysis parameter is converted by the four arithmetic expressions to obtain a required result. After the four arithmetic expressions are set, whether the four arithmetic expressions are correct or not can be verified during storage.
(9) And setting decimal place reserving conditions, and reserving decimal places of preset number for the analysis result or the converted result by setting the decimal place reserving conditions if the analysis result obtained after analyzing the corresponding UDP message block by the analysis parameters has multi-digit decimal and the analysis result generates multi-digit decimal after being converted by the four arithmetic expressions. If the decimal place number reserving condition is not set, two decimal places are reserved by default, and the reservation of the decimal place number is rounded.
(10) And setting a data dictionary, selecting one data dictionary from a plurality of preset data dictionaries, and replacing the analysis result or the converted result. For example, if the number 1 in the selected data dictionary corresponds to a man, and the data dictionary is arranged in the analysis parameter, and the value corresponding to the analysis result or the converted result after the analysis of the analysis parameter is 1, the analysis result or the converted result is replaced with the man. Through the arrangement of the data dictionary, the flexible conversion of the UDP message analysis result is achieved, so that different requirements are met.
According to the preset process of the analysis parameters, when the UDP message of the selected application program needs to be analyzed, a plurality of analysis parameters can be set according to the structure and content information of the UDP message of the application program, which are obtained in advance, and are respectively used for analyzing a corresponding UDP message block, so that the analysis of the whole UDP message is realized. The analysis parameters can be set by self according to requirements, so that the flexibility of UDP message analysis work is improved.
In this embodiment, the field set is also preset by the user, and the setting process of the field set includes:
the byte start position of the field set is set, and the byte start position of the field set functions as the byte start position of the resolution parameters. I.e. the byte start position of the field set, is used to determine the byte position where each field set starts parsing in the UDP packet. The field set comprises a plurality of analysis parameters, and the analysis of the corresponding UDP message blocks through the field set is realized by respectively analyzing the corresponding UDP message blocks through each analysis parameter included in the field set, namely the sum of the UDP message blocks analyzed by each analysis parameter is the UDP message block analyzed by the field set. And analyzing the UDP message blocks corresponding to the analysis parameters according to the sequence set in the field set, so as to realize the analysis of the UDP message blocks corresponding to the field set.
Each analysis parameter in the field set needs to be preset, and the difference from the setting process of the analysis parameters is that: the byte start position of the resolution parameter set in the field set is the start position of the resolution parameter in the field set, not the start position in the UDP message. For example, a byte start position of a certain parsing parameter in a field set is 5, in this case, if the byte start position of the field set is 4, a byte start position of the parsing parameter in the entire UDP message is 9, and so on. For the rest of the setting processes of each analysis parameter in the field set, please refer to the setting process of the analysis parameter, which is not described herein again to avoid repetition.
It should be noted that, when there is duplicate content in the UDP packet to be parsed, a field set may be set for parsing. For example, if the UDP packet content to be analyzed is the class, gender, and age of the student, the field set consisting of the analysis parameters for analyzing the class, the gender, and the age may be set. The name of the field set can be set as student information for judging the resolving object of the field set. The class, gender and age of a student can be obtained by analyzing the field set.
When field set parsing is selected, the number of cycles may be set for performing field set parsing for a preset number of times. For example, if the UDP packet includes information about class, gender, and age of 10 students, the cycle number of the field set may be set to 10, so as to analyze the class, gender, and age of 10 students, and analyze the repeated content in the UDP packet through the field set, thereby improving the analysis efficiency.
In addition, the number of cycles of the field set may also be set as an analysis result of a certain analysis parameter, for example, when a plurality of UDP messages including student information need to be analyzed, the number of students included in the plurality of UDP messages may be inconsistent. At this time, if there is a UDP packet block including the information of the number of students in the UDP packet, during parsing, an parsing parameter for parsing the information of the number of students may be set, and a parsing result of the parsing parameter is set as a cycle count of the field set, so that when parsing a plurality of UDP packets including the information of students, it is not necessary to individually set a cycle count corresponding to each UDP packet for the field set, and the parsing operation is more convenient.
In this embodiment, when performing UDP packet parsing, first, it is determined whether a start flag of the UDP packet is the same as a preset start flag of the target parsing rule, that is, according to a content of a certain preset byte length indicated by the preset start flag of the parsing rule, the start flag is compared with an actual content indicated by a corresponding preset byte length in the UDP packet, if the two are the same, a subsequent parsing operation is performed on the UDP packet, and if the two are not the same, the UDP packet is not parsed, and the setting of the start flag realizes filtering of the received UDP packet.
The content corresponding to the start flag of the UDP packet is obtained by parsing the parsing parameter, for example, a parsing parameter for parsing the start flag of the UDP packet may be set, where a byte start position of the parsing parameter is set to be the same as a byte start position in the start flag preset by the parsing rule, and a byte length of the parsing parameter is set to be the same as a preset byte length corresponding to the start flag preset by the parsing rule. For the other setting steps, please refer to the related content of the analysis parameter, which is not described herein again to avoid repetition. Analyzing the start mark of the UDP message by the set analysis parameters, comparing the obtained analysis result, namely the actual content of the start mark of the UDP message with the content corresponding to the start mark preset by the analysis rule, analyzing the UDP message if the actual content of the start mark of the UDP message is the same as the content of the start mark preset by the analysis rule, and not analyzing the UDP message if the actual content of the start mark of the UDP message is different from the content of the start mark preset by the analysis rule.
In the above example, for setting the start flag to filter the received UDP packet, in practical application, the UDP packet may be filtered by setting the start flag and the end flag in the parsing rule, or by setting a combination of the start flag and the data length interval, and the like, which is not limited herein.
When a certain UDP message is determined to be analyzed, corresponding analysis parameters and field sets can be set according to the structure and content information of the pre-acquired UDP message, and the set analysis parameters and field sets are added into an analysis rule, so that the actual analysis work can be completed through the analysis rule.
In a specific implementation manner, the parsing the UDP packet according to the target parsing parameter includes:
determining a target section to be analyzed of the UDP message according to the target analysis parameter;
determining a storage mode of the target segment to be analyzed according to the target analysis parameters, wherein the storage mode comprises a large-end mode and a small-end mode;
when the storage mode of the target segment to be analyzed is the big-end mode, judging that the coding form of the target segment to be analyzed is an original code form or a complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the target segment to be analyzed according to the target analysis parameters;
if the coding mode of the target section to be analyzed is the complementary code mode, converting the target section to be analyzed in the complementary code mode into the target section to be analyzed in the original code mode, and analyzing the target section to be analyzed in the original code mode according to the target analysis parameters;
or, when the storage mode of the target segment to be analyzed is the small-end mode, converting the target segment to be analyzed in the small-end mode into the target segment to be analyzed in the large-end mode to obtain a corrected target segment, and judging whether the coding form of the target segment to be analyzed is the original code form or the complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the corrected target segment according to the target analysis parameters;
and if the coding mode of the target section to be analyzed is the complementary code form, converting the corrected target section into a corrected target section in an original code form, and analyzing the corrected target section in the original code form according to the target analysis parameters.
Specifically, when the UDP packet parsing system parses the UDP packet, first, a UDP packet block parsed by the parsing parameter according to the byte start position and the byte length preset by the parsing parameter is determined, and the UDP packet block may be defined as a target segment to be parsed.
In this embodiment, the UDP packet parsing system defaults to parse the UDP packet by using the storage mode as the big-end mode and the encoding form as the original code form, so after determining the UDP packet block parsed by the parsing parameter, it is further required to determine the storage mode and the encoding form of the UDP packet block in the UDP packet, and perform subsequent conversion processing based on the determination.
According to the setting process of the analysis parameters, the storage mode and the coding form of the UDP packet block in the UDP packet are the same as the preset storage mode and the preset coding form of the analysis parameters corresponding to the UDP packet block. Therefore, the UDP packet parsing system may determine, according to the storage mode and the encoding format of the parsing parameter, the storage mode and the encoding format of the UDP packet block corresponding to the parsing parameter in the UDP packet.
In this embodiment, first, a storage mode of the UDP packet block in the UDP packet is determined, so as to perform processing for converting the UDP packet block into the small-end mode and the large-end mode. Then determining the coding form of the UDP message block in the UDP message, and performing the processing of converting the complementary code form into the original code form on the UDP message block or the UDP message block converted into the big-end mode, wherein the specific process comprises the following steps:
when the storage mode of the UDP message block is the big-end mode, the UDP message block does not need to be processed by converting the small-end mode into the big-end mode. At this time, the coding form of the UDP message block in the UDP message is directly determined. And if the coding form of the UDP message block in the UDP message is the original code form, directly analyzing the UDP message block according to the corresponding analysis parameters to obtain an analysis result. If the coding form of the UDP message block in the UDP message is the complement form, firstly converting the UDP message block in the complement form into the UDP message block in the original code form according to a preset rule, and then analyzing the UDP message block in the original code form according to the corresponding analysis parameters to obtain an analysis result.
When the storage mode of the UDP packet block in the UDP packet is the small-end mode, the UDP packet block in the small-end mode is converted into the UDP packet block in the large-end mode according to a preset conversion rule, and the UDP packet block converted into the large-end mode may be defined as a correction target segment. Then, the coding form of the UDP message block in the UDP message is determined. And if the coding form of the UDP message block in the UDP message is the original code form, directly analyzing the correction target section according to the corresponding analysis parameters to obtain an analysis result. If the coding form of the UDP message block in the UDP message is a complementary code form, converting the correction target section into a correction target section in an original code form according to a preset rule, and analyzing the correction target section in the original code form according to the corresponding analysis parameters to obtain an analysis result.
In a specific implementation manner, the type of the target parsing parameter includes a BIT type, and the parsing the target segment to be parsed according to the target parsing parameter includes:
if the type of the target analysis parameter is a BIT type, judging whether the target analysis parameter configures a target analysis format;
if the target analysis parameter configures the target analysis format, analyzing the target segment to be analyzed according to the target analysis format;
and if the target analysis format is not configured for the target analysis parameter, analyzing the target section to be analyzed according to a default analysis format.
Specifically, the type of the parsing parameter includes a basic type and a BIT type, and in the process of parsing the UDP packet, when the type of the parsing parameter is the BIT type, it needs to be determined whether the parsing parameter is in a preset parsing format. For example, in the setting process of the analysis parameters, when the type of the analysis parameters is a BIT type, the UDP packet may be analyzed into the BCD code by setting the analysis format, and at this time, the UDP packet block corresponding to the analysis parameters is analyzed according to the preset processing unit. For a specific parsing process, please refer to the above example of parsing the UDP packet into the BCD code, and details are not repeated herein in order to prevent repetition. In this embodiment, the parsing of the UDP packet into the parsing format corresponding to the BCD code may be defined as one type of the target parsing format, and in addition, other types of target parsing formats may be set to meet the actual requirement for parsing the UDP packet, and the type of the target parsing format is not limited herein. And when the type of the analysis parameter is a BIT type, if the analysis parameter does not set an analysis format, analyzing the UDP message block corresponding to the analysis parameter according to a default analysis format, wherein the default analysis format indicates that all BITs of the UDP message block are analyzed together.
By setting the analysis format for the analysis parameters, different requirements during UDP message analysis can be met, and the flexibility of UDP message analysis is improved.
In a specific implementation manner, the target field set includes a plurality of target parsing parameters, and the parsing step of the UDP packet according to the target field set includes:
and analyzing the UDP message according to the target analysis parameters in the target field set.
Specifically, when the field set is used for parsing, the parsing is substantially implemented by respectively parsing the corresponding UDP packet block through each parsing parameter set in the field set, the parsing order of each parsing parameter is the sequence in which each parsing parameter is set in the field set, and for a specific parsing process, reference is made to the description of the parsing process of the parsing parameters, which is not repeated here to avoid repetition.
Through the setting of the field set, the UDP message including the repeated content can be analyzed, so that the analysis work is more flexible and simpler.
In a specific implementation manner, after the step of parsing the UDP packet according to the target parsing rule, the method further includes:
judging whether the target analysis parameters are configured with data conversion formulas or not;
if the target analysis parameter configures the data conversion formula, performing data conversion on the analysis result according to the data conversion formula to obtain a conversion result;
if the target analysis parameter is not configured with the data conversion formula, not performing data conversion on the analysis result;
judging whether the target analysis parameter is configured with a decimal retention condition or not;
if the decimal number reserving condition is configured for the target analysis parameter, reserving a preset number of decimal digits for the analysis result or the conversion result;
if the decimal retention condition is not configured for the target analysis parameter, two decimal places are retained for the analysis result or the conversion result;
judging whether the target analysis parameter is configured with a data dictionary or not;
if the target analysis parameter configures the data dictionary, performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result;
and if the target analysis parameter is not configured with the data dictionary, not performing data replacement on the analysis result or the conversion result.
Specifically, after the corresponding UDP packet blocks are respectively analyzed through the analysis parameters and the field sets, the subsequent processing may be performed on the obtained analysis results. According to actual requirements, a specific processing mode may be to convert the analysis result by setting four arithmetic expressions, where the four arithmetic expressions may be defined as a data conversion formula. The result of the analysis result converted by the four arithmetic expressions can be defined as the conversion result.
The processing method may also be that a condition for retaining the decimal place is set in advance for the analysis parameter, a preset number of decimal places are retained for the analysis result or the conversion result according to a rounding principle, and if the condition for retaining the decimal place is not set, two decimal places are retained for both the analysis result or the conversion result according to the rounding principle.
The processing mode can also be that a data dictionary is set for the analysis parameters in advance, the analysis result or the conversion result is replaced according to the data dictionary, and the replaced data is stored in the data table.
By the processing mode, the flexible processing of the analysis result can be realized so as to meet the analysis requirement of the user.
In a specific embodiment, the step of performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result includes:
judging whether target initial data with the same value as the analysis result or the conversion result exists in the plurality of initial data;
if the target initial data exists, replacing the analysis result or the conversion result with final data corresponding to the target initial data;
and if the target initial data does not exist, replacing the analysis result or the conversion result.
Specifically, the setting of the data dictionary includes setting a data dictionary name for recognition of the dictionary, and the data dictionary name may be set to correspond to a name of the parsing parameter, so that the corresponding data dictionary can be quickly selected when the data dictionary is set for the parsing parameter. After the data dictionary name is set, the setting of the data dictionary further comprises setting dictionary items, wherein the dictionary items can be multiple, and each dictionary item comprises 'original data' and 'corresponding data'.
The original data is used for matching with the analysis result or the conversion result, and if the values of the original data and the analysis result are the same, the analysis result or the conversion result is replaced with corresponding data corresponding to the original data. For example, the gender data dictionary may include two dictionary entries, one including the original data 1 and the corresponding data male, and the other including the original data 2 and the corresponding data female. The analysis result or the conversion result is replaced with a male when the value of the analysis result or the conversion result is 1, and is replaced with a female when the value of the analysis result or the conversion result is 2.
By setting the data dictionary, the analysis result or the conversion result can be replaced to obtain a result adapted to the data table, for example, if the analysis parameter is used for analyzing gender, the obtained analysis result or the conversion result can be replaced by gender male or female for better reference.
According to the UDP message analyzing method provided by the embodiment, different types of UDP messages are analyzed by configuring different analyzing rules, an analyzing program does not need to be modified, the analyzing rules are completely customized, in addition, different receiving addresses can be configured to receive the UDP messages, the analyzing work is simpler and more convenient, and the flexibility of the analyzing work is improved.
Example 2
Referring to fig. 2, the UDP packet parsing apparatus 200 includes an obtaining module 201, a receiving module 202, and a parsing module 203.
In this embodiment, the obtaining module 201 is configured to: receiving selection operation input by a user, and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules;
the receiving module 202 is configured to: receiving a UDP message to be analyzed from the target receiving address;
the parsing module 203 is configured to: and analyzing the UDP message according to the target analysis rule to obtain an analysis result.
In an embodiment, the obtaining module 201 is specifically configured to: receiving name setting operation input by a user, and generating a corresponding resolution task name according to the name setting operation;
receiving an address setting operation input by a user, and generating a receiving address corresponding to the analysis task name according to the address setting operation;
receiving rule setting operation input by a user, and generating an analysis rule corresponding to the analysis task name according to the rule setting operation;
and receiving a saving operation input by a user, and generating the analysis task corresponding to the analysis task name, the receiving address and the analysis rule according to the saving operation.
In an embodiment, the parsing module 203 is specifically configured to: judging whether the start mark of the UDP message is the same as the preset start mark of the target analysis rule or not;
and if the starting mark of the UDP message is the same as the preset starting mark of the target analysis rule, analyzing the UDP message according to the target analysis parameters and/or the target field set.
In an embodiment, the parsing module 203 is further specifically configured to: determining a target section to be analyzed of the UDP message according to the target analysis parameter;
determining a storage mode of the target segment to be analyzed according to the target analysis parameters, wherein the storage mode comprises a large-end mode and a small-end mode;
when the storage mode of the target segment to be analyzed is the big-end mode, judging that the coding form of the target segment to be analyzed is an original code form or a complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the target segment to be analyzed according to the target analysis parameters;
if the coding mode of the target section to be analyzed is the complementary code mode, converting the target section to be analyzed in the complementary code mode into the target section to be analyzed in the original code mode, and analyzing the target section to be analyzed in the original code mode according to the target analysis parameters;
or, when the storage mode of the target segment to be analyzed is the small-end mode, converting the target segment to be analyzed in the small-end mode into the target segment to be analyzed in the large-end mode to obtain a corrected target segment, and judging whether the coding form of the target segment to be analyzed is the original code form or the complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the corrected target segment according to the target analysis parameters;
and if the coding mode of the target section to be analyzed is the complementary code form, converting the corrected target section into a corrected target section in an original code form, and analyzing the corrected target section in the original code form according to the target analysis parameters.
In an embodiment, the parsing module 203 is further specifically configured to: if the type of the target analysis parameter is a BIT type, judging whether the target analysis parameter configures a target analysis format;
if the target analysis parameter configures the target analysis format, analyzing the target segment to be analyzed according to the target analysis format;
and if the target analysis format is not configured for the target analysis parameter, analyzing the target section to be analyzed according to a default analysis format.
In an embodiment, the parsing module 203 is further specifically configured to: and analyzing the UDP message according to the target analysis parameters in the target field set.
In an embodiment, the parsing module 203 is further configured to: judging whether the target analysis parameters are configured with data conversion formulas or not;
if the target analysis parameter configures the data conversion formula, performing data conversion on the analysis result according to the data conversion formula to obtain a conversion result;
if the target analysis parameter is not configured with the data conversion formula, not performing data conversion on the analysis result;
judging whether the target analysis parameter is configured with a decimal retention condition or not;
if the decimal place reserving condition is configured for the target analysis parameter, reserving a preset number of decimal places for the analysis result or the conversion result;
if the decimal retention condition is not configured for the target analysis parameter, two decimal places are retained for the analysis result or the conversion result;
judging whether the target analysis parameter is configured with a data dictionary or not;
if the target analysis parameter configures the data dictionary, performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result;
and if the target analysis parameter is not configured with the data dictionary, not performing data replacement on the analysis result or the conversion result.
In an embodiment, the parsing module 203 is further specifically configured to: judging whether target initial data with the same value as the analysis result or the conversion result exists in the plurality of initial data;
if the target initial data exists, replacing the analysis result or the conversion result with final data corresponding to the target initial data;
and if the target initial data does not exist, replacing the analysis result or the conversion result.
The specific functions of the UDP packet parsing apparatus 200 provided in this embodiment may refer to the specific implementation process of the UDP packet parsing method in embodiment 1, which is not described in detail herein.
The UDP packet parsing apparatus provided in this embodiment can parse different types of UDP packets by configuring different parsing rules, without modifying parsing procedures and completely defining the parsing rules, and in addition, different receiving addresses can be configured to receive the UDP packets, so that parsing is simpler and more convenient, and the flexibility of parsing is improved.
Example 3
The embodiment provides a computer device, where the computer device includes a memory and a processor, where the memory stores a computer program, and the computer program executes the UDP packet parsing method according to embodiment 1 when the processor runs.
The computer device provided in this embodiment may implement the UDP packet parsing method described in embodiment 1, and is not described herein again to avoid repetition.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative and, for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, each functional module or unit in each embodiment of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention.

Claims (10)

1. A UDP message parsing method is characterized by comprising the following steps:
receiving selection operation input by a user, and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules;
receiving a UDP message to be analyzed from the target receiving address;
and analyzing the UDP message according to the target analysis rule to obtain an analysis result.
2. The UDP packet parsing method according to claim 1, wherein the step of generating each parsing task includes:
receiving name setting operation input by a user, and generating a corresponding analysis task name according to the name setting operation;
receiving an address setting operation input by a user, and generating a receiving address corresponding to the analysis task name according to the address setting operation;
receiving rule setting operation input by a user, and generating an analysis rule corresponding to the analysis task name according to the rule setting operation;
and receiving a saving operation input by a user, and generating the analysis task corresponding to the analysis task name, the receiving address and the analysis rule according to the saving operation.
3. The UDP packet parsing method of claim 1, wherein the target parsing rule includes a target parsing parameter and a target field set, and the parsing the UDP packet according to the target parsing rule includes:
judging whether the start mark of the UDP message is the same as the preset start mark of the target analysis rule or not;
and if the starting mark of the UDP message is the same as the preset starting mark of the target analysis rule, analyzing the UDP message according to the target analysis parameters and/or the target field set.
4. The UDP packet parsing method according to claim 3, wherein the parsing the UDP packet according to the target parsing parameter includes:
determining a target section to be analyzed of the UDP message according to the target analysis parameter;
determining a storage mode of the target segment to be analyzed according to the target analysis parameters, wherein the storage mode comprises a large-end mode and a small-end mode;
when the storage mode of the target segment to be analyzed is the big-end mode, judging that the coding form of the target segment to be analyzed is an original code form or a complementary code form;
if the coding form of the target section to be analyzed is the original code form, analyzing the target section to be analyzed according to the target analysis parameters;
if the coding form of the target section to be analyzed is the complementary code form, converting the target section to be analyzed in the complementary code form into a target section to be analyzed in the original code form, and analyzing the target section to be analyzed in the original code form according to the target analysis parameters;
or, when the storage mode of the target segment to be analyzed is the small-end mode, converting the target segment to be analyzed in the small-end mode into the target segment to be analyzed in the large-end mode to obtain a corrected target segment, and judging whether the coding form of the target segment to be analyzed is the original code form or the complementary code form;
if the coding form of the target segment to be analyzed is the original code form, analyzing the corrected target segment according to the target analysis parameters;
and if the coding form of the target segment to be analyzed is the complementary code form, converting the corrected target segment into a corrected target segment in an original code form, and analyzing the corrected target segment in the original code form according to the target analysis parameters.
5. The UDP packet parsing method according to claim 4, wherein the type of the target parsing parameter includes a BIT type, and the parsing the target segment to be parsed according to the target parsing parameter includes:
if the type of the target analysis parameter is a BIT type, judging whether the target analysis parameter configures a target analysis format;
if the target analysis parameter configures the target analysis format, analyzing the target segment to be analyzed according to the target analysis format;
and if the target analysis format is not configured for the target analysis parameter, analyzing the target section to be analyzed according to a default analysis format.
6. The UDP packet parsing method of claim 3, wherein the target field set includes a plurality of target parsing parameters, and the parsing the UDP packet according to the target field set includes:
and analyzing the UDP message according to the target analysis parameters in the target field set.
7. The UDP packet parsing method according to claim 3, wherein after the step of parsing the UDP packet according to the target parsing rule, the method further comprises:
judging whether the target analysis parameters are configured with data conversion formulas or not;
if the target analysis parameter configures the data conversion formula, performing data conversion on the analysis result according to the data conversion formula to obtain a conversion result;
if the target analysis parameter is not configured with the data conversion formula, not performing data conversion on the analysis result;
judging whether the target analysis parameter is configured with a decimal retention condition or not;
if the decimal number reserving condition is configured for the target analysis parameter, reserving a preset number of decimal digits for the analysis result or the conversion result;
if the decimal retention condition is not configured for the target analysis parameter, two decimal places are retained for the analysis result or the conversion result;
judging whether the target analysis parameter is configured with a data dictionary or not;
if the target analysis parameter configures the data dictionary, performing data replacement on the analysis result or the conversion result according to the data dictionary to obtain a replacement result;
and if the target analysis parameter is not configured with the data dictionary, not performing data replacement on the analysis result or the conversion result.
8. The UDP packet parsing method of claim 7, wherein the data dictionary includes a plurality of initial data and final data corresponding to each initial data, and the step of performing data replacement on the parsing result or the conversion result according to the data dictionary to obtain a replacement result includes:
judging whether target initial data with the same value as the analysis result or the conversion result exists in the plurality of initial data;
if the target initial data exists, replacing the analysis result or the conversion result with final data corresponding to the target initial data;
and if the target initial data does not exist, replacing the analysis result or the conversion result.
9. A UDP packet parsing apparatus, comprising:
the acquisition module is used for receiving selection operation input by a user and acquiring corresponding target analysis tasks from a plurality of analysis tasks in an analysis task library according to the selection operation, wherein the target analysis tasks comprise target receiving addresses and target analysis rules;
the receiving module is used for receiving a UDP message to be analyzed from the target receiving address;
and the analysis module is used for analyzing the UDP message according to the target analysis rule to obtain an analysis result.
10. A computer arrangement comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, performs the UDP message parsing method of any one of claims 1-8.
CN202210583875.3A 2022-05-27 2022-05-27 UDP message parsing method and device and computer equipment Active CN114679504B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210583875.3A CN114679504B (en) 2022-05-27 2022-05-27 UDP message parsing method and device and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210583875.3A CN114679504B (en) 2022-05-27 2022-05-27 UDP message parsing method and device and computer equipment

Publications (2)

Publication Number Publication Date
CN114679504A true CN114679504A (en) 2022-06-28
CN114679504B CN114679504B (en) 2022-09-06

Family

ID=82080773

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210583875.3A Active CN114679504B (en) 2022-05-27 2022-05-27 UDP message parsing method and device and computer equipment

Country Status (1)

Country Link
CN (1) CN114679504B (en)

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6078924A (en) * 1998-01-30 2000-06-20 Aeneid Corporation Method and apparatus for performing data collection, interpretation and analysis, in an information platform
US20040148415A1 (en) * 2003-01-24 2004-07-29 Mistletoe Technologies, Inc. Reconfigurable semantic processor
CN103475907A (en) * 2013-09-23 2013-12-25 珠海迈科电子科技有限公司 Multi-screen control method and device
CN104717209A (en) * 2015-02-10 2015-06-17 京信通信技术(广州)有限公司 RTP message recognition method and device thereof
CN105429963A (en) * 2015-11-04 2016-03-23 北京工业大学 Invasion detection analysis method based on Modbus/Tcp
CN107704265A (en) * 2017-09-30 2018-02-16 电子科技大学 A kind of configurable rule generating method of service-oriented stream
CN107908632A (en) * 2017-07-26 2018-04-13 上海壹账通金融科技有限公司 Site file processing method, device, site file processing platform and storage medium
CN108519965A (en) * 2018-03-15 2018-09-11 链家网(北京)科技有限公司 Data analysis method and device
CN109842656A (en) * 2017-11-28 2019-06-04 厦门雅迅网络股份有限公司 Car networking method of servicing, the car networking gateway system of the compatible multi-protocols of intelligence
CN109842629A (en) * 2019-03-03 2019-06-04 北京立思辰安科技术有限公司 The implementation method of custom protocol based on protocol analysis frame
CN110012002A (en) * 2019-03-29 2019-07-12 深圳智链物联科技有限公司 Message parsing method, device and server, computer readable storage medium
CN112702313A (en) * 2020-12-01 2021-04-23 深圳市紫光同创电子有限公司 High-speed UDP data transmission system and method
CN112788000A (en) * 2020-12-28 2021-05-11 安徽百诚慧通科技有限公司 UDP data packet analysis method, system and storage medium
US20210326175A1 (en) * 2020-04-16 2021-10-21 Tom Herbert Parallelism in serial pipeline processing
WO2021252423A1 (en) * 2020-06-08 2021-12-16 Liquid-Markets-Holdings, Incorporated Hardware-based transaction exchange

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6078924A (en) * 1998-01-30 2000-06-20 Aeneid Corporation Method and apparatus for performing data collection, interpretation and analysis, in an information platform
US20040148415A1 (en) * 2003-01-24 2004-07-29 Mistletoe Technologies, Inc. Reconfigurable semantic processor
CN103475907A (en) * 2013-09-23 2013-12-25 珠海迈科电子科技有限公司 Multi-screen control method and device
CN104717209A (en) * 2015-02-10 2015-06-17 京信通信技术(广州)有限公司 RTP message recognition method and device thereof
CN105429963A (en) * 2015-11-04 2016-03-23 北京工业大学 Invasion detection analysis method based on Modbus/Tcp
CN107908632A (en) * 2017-07-26 2018-04-13 上海壹账通金融科技有限公司 Site file processing method, device, site file processing platform and storage medium
CN107704265A (en) * 2017-09-30 2018-02-16 电子科技大学 A kind of configurable rule generating method of service-oriented stream
CN109842656A (en) * 2017-11-28 2019-06-04 厦门雅迅网络股份有限公司 Car networking method of servicing, the car networking gateway system of the compatible multi-protocols of intelligence
CN108519965A (en) * 2018-03-15 2018-09-11 链家网(北京)科技有限公司 Data analysis method and device
CN109842629A (en) * 2019-03-03 2019-06-04 北京立思辰安科技术有限公司 The implementation method of custom protocol based on protocol analysis frame
CN110012002A (en) * 2019-03-29 2019-07-12 深圳智链物联科技有限公司 Message parsing method, device and server, computer readable storage medium
US20210326175A1 (en) * 2020-04-16 2021-10-21 Tom Herbert Parallelism in serial pipeline processing
WO2021252423A1 (en) * 2020-06-08 2021-12-16 Liquid-Markets-Holdings, Incorporated Hardware-based transaction exchange
CN112702313A (en) * 2020-12-01 2021-04-23 深圳市紫光同创电子有限公司 High-speed UDP data transmission system and method
CN112788000A (en) * 2020-12-28 2021-05-11 安徽百诚慧通科技有限公司 UDP data packet analysis method, system and storage medium

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
JSYHELLO: ""TCP、UDP通信 Big或Little Edian字节顺序(大小端)问题的解决"", 《HTTPS://BLOG.CSDN.NET/JSYHELLO/ARTICLE/DETAILS/7284577》 *
TINGSHUN LI ET AL: ""The analysis and implementation of UDP-based cross-platform data transmission"", 《2012 2ND INTERNATIONAL CONFERENCE ON CONSUMER ELECTRONICS, COMMUNICATIONS AND NETWORKS (CECNET)》 *
佚名: ""TCP、UDP数据包大小的限制"", 《HTTPS://WWW.CSDN.NET/TAGS/MTTAGGXSODM3MDYTYMXVZWO0O0OO0O0O.HTML》 *
春哥笔记: ""UDP介绍"", 《HTTPS://BLOG.CSDN.NET/CHENGFENGWENALAN/ARTICLE/DETAILS/84496477》 *
王雄英等: "一种适用于多种通信环境的网络管理协议的设计与实现", 《无线电工程》 *

Also Published As

Publication number Publication date
CN114679504B (en) 2022-09-06

Similar Documents

Publication Publication Date Title
CN110932822B (en) Data encoding method, data decoding method, device, equipment and storage medium
CN106407201B (en) Data processing method and device and computer readable storage medium
CN109460219B (en) Method for quickly serializing interface control file
US20110219357A1 (en) Compressing source code written in a scripting language
CN108108436B (en) Data storage method and device, storage medium and electronic equipment
CN111090417A (en) Binary file analysis method, device, equipment and medium
CN112995199B (en) Data encoding and decoding method, device, transmission system, terminal equipment and storage medium
US11581903B2 (en) Data compression method and apparatus, computer-readable storage medium, and electronic device
CN110554877A (en) JSON data analysis method, device, equipment and storage medium
CN114679504B (en) UDP message parsing method and device and computer equipment
CN113467777A (en) Path identification method, device and system
CN113630125A (en) Data compression method, data encoding method, data decompression method, data encoding device, data decompression device, electronic equipment and storage medium
CN112784535A (en) Algorithm for intelligently converting JSON (Java Server object notation) and XML (extensible markup language) format data into traditional data table format
CN112887451A (en) Domain name resolution method and device and computer equipment
CN110427277B (en) Data verification method, device, equipment and storage medium
CN111355821A (en) Connection code generation method, device, electronic device and storage medium
CN111368508A (en) Data processing method, device, equipment and medium
CN111177182A (en) Data query method and device, storage medium and electronic equipment
CN115630614A (en) Data transmission method, device, electronic equipment and medium
CN114936227A (en) Data verification method, data verification system, electronic device and storage medium
CN115695589A (en) Method, system, device and medium for automatically generating CAN message analysis code
CN114070470A (en) Encoding and decoding method and device
CN108614805B (en) Method and system for displaying color expression using QML, server and medium
CN106933826B (en) Data preprocessing method and device
CN113825166B (en) Base station testing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant