CN114979307A - Communication protocol analysis method, intelligent terminal and storage medium - Google Patents
Communication protocol analysis method, intelligent terminal and storage medium Download PDFInfo
- Publication number
- CN114979307A CN114979307A CN202210411347.XA CN202210411347A CN114979307A CN 114979307 A CN114979307 A CN 114979307A CN 202210411347 A CN202210411347 A CN 202210411347A CN 114979307 A CN114979307 A CN 114979307A
- Authority
- CN
- China
- Prior art keywords
- frame
- field
- definition
- data
- expression
- 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
Links
- 238000004891 communication Methods 0.000 title claims abstract description 73
- 238000004458 analytical method Methods 0.000 title abstract description 17
- 230000014509 gene expression Effects 0.000 claims abstract description 127
- 238000000034 method Methods 0.000 claims description 49
- 230000004044 response Effects 0.000 claims description 10
- 238000012423 maintenance Methods 0.000 abstract description 3
- 230000006870 function Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 9
- 230000003993 interaction Effects 0.000 description 8
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 238000007726 management method Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/22—Parsing or analysis of headers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/18—Multiprotocol handlers, e.g. single devices capable of handling multiple protocols
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
Abstract
The application discloses a communication protocol analysis method, an intelligent terminal and a storage medium, wherein the communication protocol analysis method comprises the following steps: acquiring a data frame and a frame format description file; the frame format description file comprises frame definitions, the frame definitions comprise frame field definitions, and the frame field definitions comprise frame field length expressions and frame field decoding expressions; calculating the length of the frame field defined by the frame field according to the length expression of the frame field; analyzing the data frame into frame field data based on the length of the frame field; the frame field data is parsed into first human readable language data according to a frame field decoding expression. By the scheme, the analysis method of the communication protocol can effectively realize automatic matching, and can analyze and decode various frame data communication protocols, so that the time for software developers to adapt to the communication protocol can be shortened, and the problems of software and hardware communication can be quickly assisted and positioned for product maintenance and debugging personnel.
Description
Technical Field
The present application relates to the field of internet technologies, and in particular, to an analysis method for a communication protocol, an intelligent terminal, and a storage medium.
Background
In a network application system, modules are indispensable for interaction, and data exchange is performed through different transmission modes and different communication protocols to realize different service functions. In this process, a data communication protocol, such as the same language, defines rules for communication between modules. The modules are divided in terms of granularity, can be used as subsystems in an application system to perform internal interaction with other subsystems in the same application, and can also be used as external interface modules of the application system to perform external interaction with other applications. In such different application scenarios, the modules have different requirements for data interaction, different requirements for security and stability of data transmission, and different rules for defining data interaction, so that a plurality of data communication protocols are generated.
However, in order to verify the functions and performance of the application system, data analysis needs to be performed on messages transmitted between systems, but most of the current applications are to customize a set of analysis modes for a certain protocol, and the current applications have no generality and expansibility, so that the communication debugging and detection difficulty is increased. In addition, the existing method capable of analyzing and storing various data is usually realized by using an object-oriented programming language, and a step of verifying the data is not required, so that the data cannot be directly identified and interpreted by a user.
Disclosure of Invention
The technical problem mainly solved by the application is to provide a communication protocol analysis method, an intelligent terminal and a storage medium, so as to solve the problems that the communication protocol analysis method in the prior art is not universal and expansibility, and cannot be directly identified and interpreted by a user.
In order to solve the above problem, a first aspect of the present application provides a method for parsing a communication protocol, where the method for parsing a communication protocol includes: acquiring a data frame and a frame format description file; the frame format description file comprises frame definitions, the frame definitions comprise frame field definitions, and the frame field definitions comprise frame field length expressions and frame field decoding expressions; calculating the length of the frame field defined by the frame field according to the length expression of the frame field; analyzing the data frame into frame field data based on the length of the frame field; the frame field data is parsed into first human readable language data according to a frame field decoding expression.
The frame definition further includes a frame check expression, and after the step of obtaining the data frame and the frame format description file, and before the step of calculating the frame field length defined by the frame field according to the frame field length expression, the method further includes: detecting whether a frame check expression is established; in response to the frame check expression being established, performing the step of calculating a frame field length defined by the frame field according to the frame field length expression.
The method comprises the steps of obtaining a frame format description file, wherein the frame format description file comprises a frame definition list and a frame definition name list, the frame definition list comprises at least one frame definition, the frame definition also comprises a frame definition name, the frame definition name of the at least one frame definition is respectively stored in the frame definition name list, and after the step of obtaining the data frame and the frame format description file, before the step of detecting whether a frame check expression is established, the method further comprises the following steps: sequentially storing the data frames to a set storage queue according to the acquisition sequence; looking up each frame definition based on the frame definition name list; the step of detecting whether the frame check expression is true comprises the following steps: detecting whether a frame check expression defined by each frame is established; and in response to the establishment of the frame check expression for the currently detected frame definition, performing a step of calculating a frame field length for the frame field definition from the frame field length expression.
The analysis method of the communication protocol further comprises the following steps: and in response to the fact that the frame checking expression of the currently detected frame definition does not work, dequeuing the data frame currently stored in the set storage queue by one byte of data, and acquiring the data frame by one byte again to store the acquired data frame in the set storage queue, and performing the step of searching each frame definition based on the frame definition name list.
The analysis method of the communication protocol further comprises the following steps: and responding to the fact that the frame checking expressions defined by each frame are all not established, dequeuing all the data frames currently stored in the set storage queue, and acquiring the data frames again to execute the step of sequentially storing the data frames to the set storage queue according to the acquisition sequence.
Wherein the frame field definition further includes a frame field definition name, and further includes, after the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression: storing the frame field definition name, the frame field length, and the first human readable language data to a result set.
Wherein, after the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression, further comprising: detecting whether the frame field definition comprises a subframe definition list or not; the subframe definition list comprises subframe definitions, the subframe definitions comprise subframe field definitions, and the subframe field definitions comprise subframe field length expressions and subframe field decoding expressions; in response to the frame field definition comprising a subframe definition list, calculating a subframe field length of the subframe field definition according to a subframe field length expression of the subframe definition; analyzing the data frame into subframe field data based on the length of the subframe field; the sub-frame field data is parsed into second human-readable language data according to the sub-frame field decoding expression.
Wherein, after the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression, further comprising: detecting whether a frame field definition comprises a bit field definition list; the bit field definition list comprises bit field definitions, and the bit field definitions comprise bit field length expressions and bit field decoding expressions; in response to the frame field definition comprising a list of bit field definitions, calculating a bit field length of the bit field definition from a bit field length expression of the bit field definition; parsing the data frame into bit field data based on the bit field length; parsing the bit field data into third human-readable language data according to the bit field decoding expression.
In order to solve the above problem, a second aspect of the present application provides an intelligent terminal, where the intelligent terminal includes a memory and a processor coupled to each other, and the processor is configured to execute program instructions stored in the memory to implement the method for parsing a communication protocol according to the first aspect.
In order to solve the above problem, a third aspect of the present application provides a computer-readable storage medium on which program instructions are stored, the program instructions, when executed by a processor, implementing the method for parsing a communication protocol of the first aspect.
The invention has the beneficial effects that: different from the situation of the prior art, the analysis method of the communication protocol provided by the application can calculate the frame field length defined by the frame field according to the frame field length expression in the frame format description file when the data frame and the frame format description file are obtained, so that the data frame is analyzed into the frame field data based on the frame field length, and the frame field data is analyzed into the first human readable language data according to the frame field decoding expression, thereby effectively realizing automatic matching, analyzing and decoding a plurality of frame data communication protocols, directly identifying and reading by a user, and shortening the time for a software developer to adapt to the communication protocol; and for product maintenance and debugging personnel, the positioning of software and hardware communication can be rapidly assisted.
Drawings
FIG. 1 is a schematic flow chart diagram illustrating a first embodiment of a method for parsing a communication protocol according to the present application;
FIG. 2 is a flowchart illustrating a second embodiment of a method for parsing a communication protocol according to the present application;
FIG. 3 is a flow chart illustrating a third embodiment of a method for parsing a communication protocol according to the present application;
FIG. 4 is a flowchart illustrating a fourth embodiment of a method for parsing a communication protocol according to the present application;
FIG. 5 is a schematic flow chart diagram illustrating a fifth embodiment of a method for parsing a communication protocol according to the present application;
FIG. 6 is a software interface diagram of an embodiment of a method for parsing a communication protocol according to the present application;
FIG. 7 is a block diagram of an embodiment of a smart terminal according to the present application;
FIG. 8 is a block diagram of an embodiment of a computer-readable storage medium of the present application.
Detailed Description
In order to make the technical problems solved, the technical solutions adopted, and the technical effects achieved by the present application clearer, the technical solutions of the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein may be combined with other embodiments.
Referring to fig. 1, fig. 1 is a flowchart illustrating a first embodiment of a method for parsing a communication protocol according to the present application. Specifically, the method may include the steps of:
s11: and acquiring a data frame and a frame format description file.
It can be understood that, in order to enable data interaction between different modules in network application using different communication protocols to be smoothly performed, when original interactive data, that is, data frames, is acquired at a data relay end, that is, a processing end that forwards data and performs communication protocol conversion, or a data receiving end, the original interactive data needs to be analyzed through a preset processing program to identify which communication protocol is specifically used.
The frame format description file can be understood as an operation program file and a characteristic information file for carrying out communication protocol analysis on the data frame, so that the data frame can be analyzed according to a specific processing flow and a specific framework through the frame format description file.
Specifically, the communication protocol processing terminal obtains data frames sent by other intelligent devices or other functional modules inside the intelligent device, and calls corresponding frame format description files stored locally or in a database, or receives frame format description files input by a user correspondingly.
The frame format description file specifically comprises a frame definition, and the frame definition further comprises a frame field definition, and the frame field definition further comprises a frame field length expression and a frame field decoding expression.
It should be noted that the frame field length expression can be used to calculate the byte length defined by the frame field; and the frame field decoding expression is used to decode the frame field definition into a human readable language.
Optionally, the communication protocol processing terminal may be specifically one of any reasonable intelligent terminals such as a server, a computer, a tablet computer, a smart phone, and a smart watch, which is not limited in this application.
S12: and calculating the length of the frame field defined by the frame field according to the length expression of the frame field.
The frame field length expression may be specifically understood as a function or a program capable of calculating a frame field definition byte length, so that when the data frame and the frame format description file are acquired, the frame field length defined by the frame field can be calculated according to the frame field length expression.
S13: the data frame is parsed into frame field data based on the frame field length.
It can be understood that after the frame field length defined by the frame field is obtained by calculation, the data frame can be decomposed into frame field data with a specific byte length according to the frame field length, so as to facilitate the subsequent analysis processing.
S14: the frame field data is parsed into first human readable language data according to a frame field decoding expression.
Further, the frame field decoding expression may also be understood as an operation program capable of parsing the frame field data into the first human readable language data, so that after the frame field data is obtained, the frame field data may be parsed into the first human readable language data according to the frame field decoding expression, so as to be directly recognized by a user, and the original data content of the data frame and the adopted communication protocol thereof may be interpreted.
According to the scheme, the data frame is analyzed into the frame field data based on the frame field length by calculating the frame field length defined by the frame field, and the frame field data is analyzed into the first human readable language data according to the frame field decoding expression, so that automatic matching can be effectively realized, and a plurality of frame data communication protocols are analyzed and decoded; the data frame is decoded into human readable language, so that the data frame can be directly identified by a user and the original data content of the data frame is read out, and the time for a software developer to adapt to a communication protocol is shortened; and for product maintenance and debugging personnel, the positioning of the problems in the aspect of software and hardware communication can be rapidly assisted.
Further, in an embodiment, the frame field definition further includes a frame field definition name, and after the step S14, the method may further include: storing the frame field definition name, the frame field length, and the first human readable language data to a result set.
It is understood that the result set may be a local configuration storage location, or a storage table in a database. And in order to facilitate subsequent searching, calling and processing, the frame field length and the first human readable language data can be obtained, and the frame field definition name, the frame field length and the first human readable language data can be stored to the result set in a set association mode according to the corresponding frame field definition name.
In another embodiment, the frame definition may further include a frame definition description word and a frame field definition list, and the frame field definition list includes one or more frame field definitions; the frame field definition may further include a frame field descriptor to facilitate more complete parsing of the data frame.
Referring to fig. 2, fig. 2 is a flowchart illustrating a second embodiment of a method for parsing a communication protocol according to the present application. The method for analyzing the communication protocol in this embodiment is a flowchart of a detailed embodiment of the method for analyzing the communication protocol in fig. 1, and includes the following steps:
s21: and acquiring a data frame and a frame format description file.
S21 is the same as S11 in fig. 1, and please refer to S11 and the related text description, which are not repeated herein.
S22: and detecting whether the frame check expression is established.
It can be understood that the frame definition further includes a frame check expression for determining whether the currently acquired data frame belongs to a data type capable of being parsed by the frame format description file, so as to improve parsing efficiency.
Specifically, after the data frame and the frame format description file are acquired, whether a frame check expression in the frame format description file is established or not is detected.
If the frame check expression is true, S23 is executed, and if the frame check expression is not true, it indicates that there is not enough expression for the expression to execute, or the currently acquired data frame cannot be parsed, and a next data frame needs to be acquired, that is, S21 is executed again until the frame check expression is true.
S23: and calculating the length of the frame field defined by the frame field according to the length expression of the frame field.
S24: the data frame is parsed into frame field data based on the frame field length.
S25: the frame field data is parsed into first human readable language data according to a frame field decoding expression.
S23, S24, and S25 are the same as S12, S13, and S14 in fig. 1, and please refer to S12, S13, and S14 and their related text descriptions, which are not described herein again.
Referring to fig. 3, fig. 3 is a flowchart illustrating a third embodiment of a method for parsing a communication protocol according to the present application. The method for analyzing the communication protocol in this embodiment is a flowchart of a detailed embodiment of the method for analyzing the communication protocol in fig. 2, and includes the following steps:
s31: and acquiring a data frame and a frame format description file.
S31 is the same as S21 in fig. 2, and please refer to S21 and the related text description, which are not repeated herein.
S32: and sequentially storing the data frames to a set storage queue according to the acquisition sequence.
The frame format description file further comprises a frame definition list and a frame definition name list, the frame definition list specifically comprises at least one frame definition, the frame definition further comprises a frame definition name, and the frame definition names of the at least one frame definition are specifically stored in the frame definition name list respectively.
The communication protocol processing terminal is pre-configured with a set storage queue, and the set storage queue may be specifically a first-in first-out queue, so that after the data frames are acquired, the data frames can be sequentially stored in the set storage queue according to the acquisition order.
S33: each frame definition is looked up based on a list of frame definition names.
Specifically, for each frame definition name in the list of frame definition names to be detected, the frame definition corresponding to each frame definition name is found in turn.
S34: and detecting whether a frame check expression defined by each frame is established.
Further, after each frame definition is found, the frame check expressions in the frame definition can be sequentially executed to detect whether the frame check expression of each frame definition is true.
It is understood that the frame check expression may specifically be a defined function for accessing the set storage queue, and the function accepts a positive integer as a parameter, where the positive integer represents an index of the set storage queue, and the function is capable of returning the byte content corresponding to the index, that is, the content of the several bytes in the queue, and if the accessed index is larger than the size of the set storage queue, it is determined that there is not enough data for the frame check expression to execute. In this way, whether the frame check expression defined by each frame is established can be sequentially detected.
It should be noted that the frame field length expression mentioned in this embodiment needs to be written in a syntax structure specified by an expression implementation manner, for example, if Lua (scripting language) programming language is used, the frame field length expression needs to be written in the syntax of the Lua programming language, and the frame field expression can specifically calculate and return a result (length, boolean value, or character string) by calling an access function of the set storage queue as a parameter.
Wherein, if there is a frame definition for which the frame check expression is true, traversing the frame field definition list to perform S36 for each corresponding frame field definition, and if the frame check expression is not true, performing S35.
S35: and dequeuing the data frame currently stored in the set storage queue by one byte of data, and acquiring the data frame of one byte again to store the acquired data frame to the set storage queue.
Understandably, if the frame check expression is not true, the frame check expression indicates that there is not enough expression for the expression to execute, and the data frame needs to be stored in the set storage queue continuously; or, the currently acquired data frame cannot be analyzed, and the currently stored data frame of the set storage queue needs to be dequeued by one byte of data, and the data frame of one byte is acquired again, so that the data frame acquired again is stored in the set storage queue.
S36: and calculating the length of the frame field defined by the frame field according to the length expression of the frame field.
S37: the data frame is parsed into frame field data based on the frame field length.
S38: the frame field data is parsed into first human readable language data according to a frame field decoding expression.
S36, S37, and S38 are the same as S23, S24, and S25 in fig. 2, and please refer to S23, S24, and S25 and their related text descriptions, which are not described herein again.
Further, in an embodiment, the step S35 may specifically include: when the frame check expressions defined by each frame are not satisfied, dequeuing all the data frames currently stored in the set storage queue, and acquiring the data frames again to execute S32 again.
Referring to fig. 4, fig. 4 is a flowchart illustrating a fourth embodiment of a method for parsing a communication protocol according to the present application. The resource quota management method of this embodiment is a schematic flow diagram of a detailed embodiment of the resource quota management method in fig. 1, and includes the following steps:
s41: and acquiring a data frame and a frame format description file.
S42: and calculating the length of the frame field defined by the frame field according to the length expression of the frame field.
S43: the data frame is parsed into frame field data based on the frame field length.
S44: the frame field data is parsed into first human readable language data according to a frame field decoding expression.
S41, S42, S43, and S44 are the same as S11, S12, S13, and S14 in fig. 1, and please refer to S11, S12, S13, S14 and their associated text descriptions, which are not repeated herein.
S45: it is detected whether the frame field definition includes a subframe definition list.
It can be understood that, during the data interaction process, there are usually also situations of nested sub-data frames, that is, frames can also be nested in a frame field, and in order to ensure the smooth proceeding of data interaction, for the communication protocol analysis of the data frame, it is also necessary to recursively detect the sub-frames contained in each frame field.
Wherein the subframe definition list includes subframe definitions including one or more subframe field definitions including a subframe field length expression and a subframe field decoding expression.
Likewise, the subframe field length expression can be used to calculate the byte length of the subframe field definition; and a subframe field decoding expression is used to decode the subframe field definition into a human readable language.
Specifically, after the frame field data is parsed into the first human readable language data, it is further detected whether the frame field definition includes a subframe definition list.
Wherein if the frame field definition includes the subframe definition list, S47 is performed, and if the frame field definition does not include the subframe definition list, S46 is performed.
S46: storing the frame field definition name, the frame field length, and the first human readable language data to a result set.
It can be understood that when it is determined that the frame field definition does not include the sub-frame definition list, it can be determined that no nested frame exists in the currently received data frame, and therefore, the frame field definition name, the frame field length, and the first human readable language data are directly stored in the result set.
S47: and calculating the length of the subframe field defined by the subframe field according to the length expression of the subframe field defined by the subframe.
The subframe field length expression may be specifically understood as a function or a program capable of calculating a subframe field definition byte length, so that when a data frame and a frame format description file are obtained, a subframe field length defined by a subframe field may be calculated according to the subframe field length expression.
S48: and resolving the data frame into subframe field data based on the subframe field length.
It can be understood that after the length of the subframe field defined by the subframe field is obtained by calculation, the data frame can be decomposed into the subframe field data with the specific byte length according to the length of the subframe field, so as to facilitate the subsequent analysis processing.
S49: the sub-frame field data is parsed into second human-readable language data according to the sub-frame field decoding expression.
Specifically, the subframe field decoding expression may also be understood as an operation program capable of parsing the subframe field data into the second human-readable language data, so that after the subframe field data is obtained, the subframe field data may be parsed into the second human-readable language data according to the subframe field decoding expression, so as to be directly recognized by a user, and the original data content of the data frame and the communication protocol adopted by the data frame may be interpreted.
Further, in an embodiment, the subfield definition further includes a subfield definition name, and after the above S49, the subfield definition may further specifically include: storing the sub-field definition name, the sub-frame field length, and the second human-readable language data to a result set.
Referring to fig. 5, fig. 5 is a flowchart illustrating a fifth embodiment of a method for parsing a communication protocol according to the present application. The method for analyzing the communication protocol in this embodiment is a flowchart of a detailed embodiment of the method for analyzing the communication protocol in fig. 1, and includes the following steps:
s51: and acquiring a data frame and a frame format description file.
S52: and calculating the length of the frame field defined by the frame field according to the length expression of the frame field.
S53: the data frame is parsed into frame field data based on the frame field length.
S54: the frame field data is parsed into first human readable language data according to a frame field decoding expression.
S51, S52, S53 and S54 are the same as S11, S12, S13 and S14 in fig. 1, and for details, refer to S11, S12, S13 and S14 and their related text descriptions, which are not repeated herein.
S55: it is checked whether the frame field definition includes a list of bit field definitions.
It is understood that in the data exchange process, there are usually also some Bit fields further contained in the frame field, that is, some frame fields contain one or more Bit fields, these Bit fields are represented by less than 1 byte, and the length is represented by using a Bit (Bit), for example, on or off, a 0 or 1 of 1 Bit can be used for representation.
Wherein the list of bit field definitions includes one or more bit field definitions including a bit field length expression and a bit field decoding expression.
In another embodiment, the bit field definition may further include a bit field name and a bit field descriptor to facilitate more complete parsing of the data frame.
Likewise, the bit field length expression can be used to calculate a bit field length value (in bits) for a bit field definition; and a subframe field decoding expression is used to decode the subframe field definition into a human readable language.
Specifically, after parsing the frame field data into the first human readable language data, it is further detected whether the frame field definition includes a list of bit field definitions.
Wherein if the frame field definition includes the bit field definition list, S57 is performed, and if the frame field definition does not include the bit field definition list, S56 is performed.
S56: storing the frame field definition name, the frame field length, and the first human readable language data to a result set.
It can be understood that when it is determined that the frame field definition does not include the bit frame definition list, it is able to determine the bit field not included in the frame field corresponding to the currently received data frame, and therefore it is only necessary to directly store the frame field definition name, the frame field length, and the first human readable language data in the result set.
S57: and calculating the bit field length defined by the bit field according to the bit field length expression defined by the bit field.
The bit field length expression may be specifically understood as a function or a program capable of calculating a bit field definition bit field length value, so that when the data frame and the frame format description file are obtained, the bit field length defined by the bit field can be calculated according to the bit field length expression.
S58: the data frame is parsed into bit field data based on the bit field length.
It can be understood that after the bit field length defined by the bit field is calculated, the data frame can be decomposed into bit field data of a specific bit field length according to the bit field length, so as to facilitate the subsequent analysis processing.
S59: parsing the bit field data into third human-readable language data according to the bit field decoding expression.
Still further, the bit field decoding expression may also be understood as an operation program capable of parsing the bit field data into third human readable language data, so that after the bit field data is obtained, the bit field data may be parsed into the third human readable language data according to the bit field decoding expression, so as to be directly recognized by a user, and the original data content of the data frame and the communication protocol adopted by the data frame may be interpreted.
Further, in an embodiment, the bit field definition further includes a bit field definition name, and after S59, the method may further include: storing the bitfield definition name, the bitfield length, and the third human-readable language data to a result set.
Referring to fig. 6, fig. 6 is a software interface diagram of an embodiment of a method for parsing a communication protocol according to the present application.
Specifically, after a first-in first-out storage queue is constructed, the communication protocol processing terminal can receive a frame format description file input by a user, where the frame format description file specifically includes a frame definition list and a frame definition name list. And the frame definition list comprises one or more frame definitions, and each frame definition further comprises a frame definition name, a frame definition description word, a frame check expression and a frame field definition list.
Wherein the frame field definition list further comprises one or more frame field definitions, and each frame field definition comprises a frame field definition name, a frame field descriptor, a frame field length expression, and a frame field decoding expression.
Further, when a data frame to be analyzed by a communication protocol is acquired, the data frame can be sequentially stored in a first-in first-out storage queue to be processed by using a software interface as shown in fig. 6.
Wherein, the lower part of fig. 6 shows the original data frame, the left side of the upper part shows the tree-type list of the frame field, and the right side is the content of the result set in the selected frame field.
The fifo storage queue may be a fifo queue having 11 bytes, so that when dequeuing 9 bytes, the byte index of the original index 10 becomes 1, and when parsing the subframe format, the start position is designated as the offset of the current frame field.
The frame format description file may specifically be a section of the following program:
{
"$schema":"./frame.json",
"init":"function sum(from,to)result=0;fori=from,to,1do result=result+byte(i)end;return result;end",
"frames":["mcu_report"],
"definitions":[
{
"name":"mcu_report",
description, MCU reporting structure,
"validator":"return byte(l)==0xAA and byte(2)==0xAA and sum(l,30)==((byte(31)<<8)|byte(32))",
"fields":[
{
"namen":"start—ofjrame",
"description": frame header ",
"bytes":2
},
{
"name". data-package "
Description, data packet,
"bytes":28,
"frames":["heater_data_report","boiler_data_report"]
},
{
"name":"checksum",
"description": check sum ",
"bytes":2
}
]
}
referring to fig. 7, fig. 7 is a schematic diagram of a framework of an embodiment of an intelligent terminal according to the present application. The intelligent terminal 61 comprises a memory 611 and a processor 612, which are coupled to each other, and the processor 612 is configured to execute the program instructions stored in the memory 611, so as to implement the steps of any one of the embodiments of the parsing method of the communication protocol.
In one specific implementation scenario, the intelligent terminal 61 may include, but is not limited to: any reasonable intelligent terminal such as a server, a computer, a tablet computer, a smart phone and a smart watch is not limited in the application.
In particular, the processor 612 is configured to control itself and the memory 611 to implement the steps of any of the above-described embodiments of the video display method. Processor 612 may also be referred to as a CPU (Central Processing Unit). The processor 612 may be an integrated circuit chip having signal processing capabilities. The Processor 612 may also be a general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Additionally, the processor 612 may be commonly implemented by integrated circuit chips.
Referring to fig. 8, fig. 8 is a block diagram illustrating an embodiment of a computer-readable storage medium according to the present application. The computer readable storage medium 71 stores program instructions 711 executable by the processor, the program instructions 711 for implementing the steps of any of the above-described embodiments of the parsing method for the communication protocol.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is merely one type of logical division, and an actual implementation may have another division, for example, a unit or a component may be combined or integrated with another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some interfaces, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on network elements. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, and various media capable of storing program codes.
Claims (10)
1. A method for parsing a communication protocol, the method comprising:
acquiring a data frame and a frame format description file; the frame format description file comprises a frame definition, the frame definition comprises a frame field definition, and the frame field definition comprises a frame field length expression and a frame field decoding expression;
calculating the length of the frame field defined by the frame field according to the length expression of the frame field;
parsing the data frame into frame field data based on the frame field length;
parsing the frame field data into first human readable language data according to the frame field decoding expression.
2. The method for parsing a communication protocol according to claim 1, wherein the frame definition further includes a frame check expression, and after the step of obtaining the data frame and the frame format description file and before the step of calculating the frame field length defined by the frame field according to the frame field length expression, further includes:
detecting whether the frame check expression is established;
and responding to the establishment of the frame check expression, and executing the step of calculating the frame field length defined by the frame field according to the frame field length expression.
3. The method according to claim 2, wherein the frame format description file includes a frame definition list and a frame definition name list, the frame definition list includes at least one frame definition, the frame definition further includes a frame definition name, the frame definition names of at least one frame definition are respectively stored in the frame definition name list, and after the step of acquiring the data frame and the frame format description file, before the step of detecting whether the frame check expression holds, the method further includes:
sequentially storing the data frames to a set storage queue according to an acquisition sequence;
looking up each said frame definition based on said list of frame definition names;
the step of detecting whether the frame check expression holds includes:
detecting whether the frame check expression defined by each frame is established;
and in response to the currently detected establishment of the frame check expression for the frame definition, performing the step of calculating the frame field length for the frame field definition according to the frame field length expression.
4. The method for parsing a communication protocol according to claim 3, further comprising:
in response to that the frame check expression of the currently detected frame definition does not hold, dequeuing the data frame currently stored in the set storage queue by one byte of data, and acquiring the data frame by one byte again, so as to store the acquired data frame in the set storage queue, and performing the step of searching each frame definition based on the frame definition name list.
5. The method for parsing a communication protocol according to claim 3, further comprising:
and in response to that the frame check expressions defined by each frame are all not satisfied, dequeuing all the data frames currently stored in the set storage queue, and acquiring the data frames again to execute the step of sequentially storing the data frames to the set storage queue according to the acquisition sequence.
6. The parsing method of communication protocol as claimed in claim 1, wherein the frame field definition further comprises a frame field definition name, and further comprising, after the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression:
storing the frame field definition name, the frame field length, and the first human readable language data to a result set.
7. The method for parsing a communication protocol according to claim 1, wherein the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression is followed by further comprising:
detecting whether the frame field definition comprises a subframe definition list; wherein the subframe definition list comprises subframe definitions including subframe field length expressions and subframe field decoding expressions;
in response to the frame field definition comprising the subframe definition list, calculating a subframe field length of the subframe field definition according to the subframe field length expression of the subframe definition;
analyzing the data frame into subframe field data based on the subframe field length;
parsing the subframe field data into second human-readable language data according to the subframe field decoding expression.
8. The method for parsing a communication protocol according to claim 1, wherein the step of parsing the frame field data into the first human readable language data according to the frame field decoding expression is followed by further comprising:
detecting whether the frame field definition comprises a list of bit field definitions; wherein the bit field definition list comprises bit field definitions including bit field length expressions and bit field decoding expressions;
in response to the frame field definition comprising the list of bit field definitions, calculating a bit field length for the bit field definition from the bit field length expression for the bit field definition;
parsing the data frame into bit field data based on the bit field length;
parsing the bit field data into third human-readable language data according to the bit field decoding expression.
9. An intelligent terminal, characterized in that the intelligent terminal comprises a memory and a processor coupled with each other, the processor is used for executing the program instructions stored in the memory to realize the parsing method of the communication protocol according to any one of claims 1-8.
10. A computer-readable storage medium having stored thereon program instructions, which when executed by a processor, implement a method of parsing a communication protocol according to any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210411347.XA CN114979307B (en) | 2022-04-19 | 2022-04-19 | Analysis method of communication protocol, intelligent terminal and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210411347.XA CN114979307B (en) | 2022-04-19 | 2022-04-19 | Analysis method of communication protocol, intelligent terminal and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114979307A true CN114979307A (en) | 2022-08-30 |
CN114979307B CN114979307B (en) | 2024-07-26 |
Family
ID=82977229
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210411347.XA Active CN114979307B (en) | 2022-04-19 | 2022-04-19 | Analysis method of communication protocol, intelligent terminal and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114979307B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115297001A (en) * | 2022-10-08 | 2022-11-04 | 湖南恩智测控技术有限公司 | Multi-port multi-protocol communication method and board card |
Citations (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040205228A1 (en) * | 2003-03-06 | 2004-10-14 | Rose Kenneth M. | Apparatus and method for detecting tiny fragment attacks |
CN101330446A (en) * | 2007-06-21 | 2008-12-24 | 中兴通讯股份有限公司 | Analysis method for enhancing protocol layer frame of special transmission channel |
WO2009125664A1 (en) * | 2008-04-08 | 2009-10-15 | 株式会社日立製作所 | Communication protocol processing circuit, communication protocol processing method, and communication terminal |
CN106254381A (en) * | 2016-09-12 | 2016-12-21 | 全球能源互联网研究院 | Protocol analysis method, device and comprise the Layer2 switching system of protocol analysis device |
CN106941501A (en) * | 2017-04-26 | 2017-07-11 | 田潇河 | A kind of data communications method and device |
CN109510686A (en) * | 2018-09-13 | 2019-03-22 | 红色江山(湖北)导航技术有限公司 | A kind of general binary stream data conversion treatment method |
CN109687939A (en) * | 2018-12-10 | 2019-04-26 | 上海华兴数字科技有限公司 | Engineering mechanical device communication means, system and carrying communication protocol |
CN109739747A (en) * | 2018-12-13 | 2019-05-10 | 西安现代控制技术研究所 | A kind of general analytic method of serial communication information protocol |
CN110012031A (en) * | 2019-04-26 | 2019-07-12 | 中国电子科技集团公司第二十九研究所 | Data message is general to automatically parse method and storage method |
CN110351281A (en) * | 2019-07-15 | 2019-10-18 | 珠海格力电器股份有限公司 | Universal data frame analysis method, device and equipment |
CN110704356A (en) * | 2019-09-25 | 2020-01-17 | 天津津航计算技术研究所 | Universal serial port data analyzing method |
CN111190851A (en) * | 2019-12-11 | 2020-05-22 | 深圳市优必选科技股份有限公司 | Analysis method, device, equipment and medium for variable length protocol |
CN111741019A (en) * | 2020-07-28 | 2020-10-02 | 常州昊云工控科技有限公司 | Communication protocol analysis method and system based on field description |
CN112118232A (en) * | 2020-08-25 | 2020-12-22 | 通号城市轨道交通技术有限公司 | Message protocol analysis method and device |
CN112235302A (en) * | 2020-10-15 | 2021-01-15 | 天津津航计算技术研究所 | Protocol analysis method suitable for multiple buses |
CN113824731A (en) * | 2021-09-30 | 2021-12-21 | 深圳市卓翼科技股份有限公司 | Serial port protocol frame analysis method and device and computer readable storage medium |
CN114205407A (en) * | 2021-12-16 | 2022-03-18 | 北京润科通用技术有限公司 | Method and device for analyzing pulse code modulation telemetry data |
WO2022062946A1 (en) * | 2020-09-24 | 2022-03-31 | 华为技术有限公司 | Data coding method, data decoding method, and communication device |
-
2022
- 2022-04-19 CN CN202210411347.XA patent/CN114979307B/en active Active
Patent Citations (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040205228A1 (en) * | 2003-03-06 | 2004-10-14 | Rose Kenneth M. | Apparatus and method for detecting tiny fragment attacks |
CN101330446A (en) * | 2007-06-21 | 2008-12-24 | 中兴通讯股份有限公司 | Analysis method for enhancing protocol layer frame of special transmission channel |
WO2009125664A1 (en) * | 2008-04-08 | 2009-10-15 | 株式会社日立製作所 | Communication protocol processing circuit, communication protocol processing method, and communication terminal |
CN106254381A (en) * | 2016-09-12 | 2016-12-21 | 全球能源互联网研究院 | Protocol analysis method, device and comprise the Layer2 switching system of protocol analysis device |
CN106941501A (en) * | 2017-04-26 | 2017-07-11 | 田潇河 | A kind of data communications method and device |
CN109510686A (en) * | 2018-09-13 | 2019-03-22 | 红色江山(湖北)导航技术有限公司 | A kind of general binary stream data conversion treatment method |
CN109687939A (en) * | 2018-12-10 | 2019-04-26 | 上海华兴数字科技有限公司 | Engineering mechanical device communication means, system and carrying communication protocol |
CN109739747A (en) * | 2018-12-13 | 2019-05-10 | 西安现代控制技术研究所 | A kind of general analytic method of serial communication information protocol |
CN110012031A (en) * | 2019-04-26 | 2019-07-12 | 中国电子科技集团公司第二十九研究所 | Data message is general to automatically parse method and storage method |
CN110351281A (en) * | 2019-07-15 | 2019-10-18 | 珠海格力电器股份有限公司 | Universal data frame analysis method, device and equipment |
CN110704356A (en) * | 2019-09-25 | 2020-01-17 | 天津津航计算技术研究所 | Universal serial port data analyzing method |
CN111190851A (en) * | 2019-12-11 | 2020-05-22 | 深圳市优必选科技股份有限公司 | Analysis method, device, equipment and medium for variable length protocol |
CN111741019A (en) * | 2020-07-28 | 2020-10-02 | 常州昊云工控科技有限公司 | Communication protocol analysis method and system based on field description |
CN112118232A (en) * | 2020-08-25 | 2020-12-22 | 通号城市轨道交通技术有限公司 | Message protocol analysis method and device |
WO2022062946A1 (en) * | 2020-09-24 | 2022-03-31 | 华为技术有限公司 | Data coding method, data decoding method, and communication device |
CN112235302A (en) * | 2020-10-15 | 2021-01-15 | 天津津航计算技术研究所 | Protocol analysis method suitable for multiple buses |
CN113824731A (en) * | 2021-09-30 | 2021-12-21 | 深圳市卓翼科技股份有限公司 | Serial port protocol frame analysis method and device and computer readable storage medium |
CN114205407A (en) * | 2021-12-16 | 2022-03-18 | 北京润科通用技术有限公司 | Method and device for analyzing pulse code modulation telemetry data |
Non-Patent Citations (1)
Title |
---|
冯春倩: "基于MQTT的物联网设备接入及网络通信方法的研究", 《中国优秀硕士学位论文全文数据库 信息科技辑》, 15 December 2018 (2018-12-15) * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115297001A (en) * | 2022-10-08 | 2022-11-04 | 湖南恩智测控技术有限公司 | Multi-port multi-protocol communication method and board card |
CN115297001B (en) * | 2022-10-08 | 2022-12-16 | 湖南恩智测控技术有限公司 | Multi-port multi-protocol communication method and board card |
Also Published As
Publication number | Publication date |
---|---|
CN114979307B (en) | 2024-07-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11995145B2 (en) | Accurate and efficient recording of user experience, GUI changes and user interaction events on a remote web document | |
CN110445860B (en) | Message sending method, device, terminal equipment and storage medium | |
CN107015948B (en) | Log information formatting method and system | |
CN114500690B (en) | Interface data processing method and device, electronic equipment and storage medium | |
CN110753050B (en) | Method and device for generating protocol document, computer storage medium and electronic equipment | |
CN113835902A (en) | Data processing method and device, computer equipment and storage medium | |
CN114710224A (en) | Frame synchronization method and device, computer readable medium and electronic device | |
CN110888791A (en) | Log processing method, device, equipment and storage medium | |
CN114979307B (en) | Analysis method of communication protocol, intelligent terminal and storage medium | |
CN116346961B (en) | Financial message processing method and device, electronic equipment and storage medium | |
CN108460044B (en) | Data processing method and device | |
CN112883088B (en) | Data processing method, device, equipment and storage medium | |
CN111049813B (en) | Message assembling method, message analyzing method, message assembling device, message analyzing device and storage medium | |
CN116781586A (en) | gRPC flow analysis method, device, equipment and medium | |
CN113852610B (en) | Message processing method, device, computer equipment and storage medium | |
CN111552907A (en) | Message processing method, device, equipment and storage medium | |
CN108809900B (en) | Framework and method for unified resource access | |
CN116506291B (en) | Method and device for analyzing configuration content of network equipment of power system | |
CN112671822B (en) | Service request processing method, device, storage medium, server and system | |
CN113821750B (en) | Page data processing method and system, electronic equipment and readable storage medium | |
CN110191095B (en) | Data processing method and terminal equipment | |
CN118590568A (en) | Message processing method, device, program product and medium for someip protocol | |
CN117640752A (en) | SWIFT standard-based message matching method, device and equipment | |
CN117873436A (en) | Printing method, printing system, electronic device and storage medium | |
CN115033410A (en) | Abnormal link tracking method, system, gateway 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 |