Communication protocol multiplexing analysis method and device, equipment and storage medium

By designing branch expressions in communication protocols and using λ operators, the ambiguity problem in complex protocol parsing is solved, the completeness and efficiency of protocol parsing is achieved, and the processing of complex data flows and protocol frame parsing is supported.

CN120343117APending Publication Date: 2025-07-18CHENGDU AIRCRAFT INDUSTRY GROUP
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510497764.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The prior art has ambiguity problems when dealing with complex communication protocols with multiple reusable structures, and it is impossible to effectively parse the combination of multiple key values distributed at different locations in the protocol, and the existing methods lack forward reference capabilities and complex data flow processing capabilities.

Method used

The branch expression design and λ operator are adopted to perform protocol parsing through arithmetic operators, function operators and custom λ operators, including four steps: formal transformation, reference parsing, partial calculation and return result, to achieve completeness and progressive calculation of protocol parsing.

Benefits of technology

It realizes effective parsing of arbitrary protocol multiplexing, supports parsing frames by protocol, eliminates ambiguity, and has linear time complexity, and is affected by expressions and λ operator operands, which supports concurrent and vector instruction optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120343117A_ABST
    Figure CN120343117A_ABST
Patent Text Reader

Abstract

The invention discloses an analysis method, device and equipment for communication protocol multiplexing and a storage medium, and belongs to the technical field of automatic testing, and the method comprises the steps: S1, during protocol description, designing a branch expression for each protocol branch, inserting the branch expression, and configuring the branch expression with an arithmetic operator, a function operator and a self-defined lambda operator; and S2, during protocol analysis, identifying a branch expression and calculating and analyzing, which comprises four steps of form transformation, reference analysis, partial calculation and result return. The method is effective for multiplexing of any protocol, the completeness of protocol analysis is realized by introducing a lambda operator, the analysis process can be progressively calculated along with a data flow, and framing according to protocol analysis is supported, that is, as long as identifiable differences exist between protocols, ambiguity can be effectively eliminated, and protocol analysis is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automated testing, and particularly to a parsing method, device, equipment, and storage medium for communication protocol multiplexing. Background Art

[0002] When designing communication protocols, it often occurs that a certain byte, several bytes, a certain bit, or several bits in the protocol are multiplexed. For the receiving end, there is a problem of how to resolve ambiguity.

[0003] To accurately identify communication protocols, the current commonly used method is the key value discrimination method. By identifying the values of the multiplexed bytes or bits in the communication protocol, the corresponding protocol is selected. For example: there is a "command word" byte in the protocol. When it is 1, it represents Protocol 1, and when it is 2, it represents Protocol 2.

[0004] The above method is simple and practical, but it also has obvious disadvantages and cannot be applied to the following situations: that is, multiple key values are distributed at different positions in the protocol, and the final protocol selection depends on the combination of these key values.

[0005] To solve this problem, existing technical solutions use simple expressions containing multiple key values, and use the result of the expression as a new key value, and then use the key value discrimination method to achieve parsing. This method can support multiple key values, but its expression scheme is generally not complete, mainly manifested in two aspects: one is the lack of forward reference ability, that is, only the key values before the current key value can be referenced for calculation; the other is that only simple arithmetic operations can be performed and complex data streams cannot be processed.

[0006] In the prior art, Patent CN107306256A discloses a communication protocol parsing method based on string-type data. This patent is based on matching a determined protocol and does not involve the problem of communication protocol multiplexing. Patent CN113364732A discloses a vehicle terminal communication protocol parsing method and device. This patent involves protocol matching, but only selects through the identification bits of the protocol at the beginning, and there is no situation of multiplexing internal bytes or bits of the protocol. Patent CN107247678B discloses a programming method for CAN-LonWorks protocol conversion logic. Its application goal is to achieve flexible conversion between two specific underlying protocols. Since the problem it faces is only to assign values to each field of the target protocol, its expression only needs to support basic arithmetic operations, and the designed expression calculation tool also runs relatively independently. It itself constitutes a simple, non-branching description language to complete the assignment of each field of the target protocol and cannot be applied to the parsing scenario of protocol multiplexing. Summary of the Invention

[0007] The present invention aims to solve the ambiguity problem in parsing complex communication protocols with multiple reuse structures in the prior art, and proposes a parsing method, device, equipment and storage medium for communication protocol reuse. Through the solution of the present invention, as long as there are recognizable differences between protocols, the ambiguity can be effectively eliminated and protocol parsing can be achieved.

[0008] In order to achieve the above invention purpose, the technical solution of the present invention is as follows: A parsing method for communication protocol reuse, comprising the following steps: Step S1, when describing the protocol, design a branch expression for each protocol branch and insert it; Step S2, when parsing the protocol, identify the branch expression and calculate the parsing.

[0009] Further, the branch expression is equipped with three types of operators: arithmetic operators, function operators, and custom λ operators; the arithmetic operators include basic operators that can perform integer data operations and are usually written as specific symbols; the function operators include multiple operators that provide specific data operations; the λ operator is expressed as an operand and a λ calculus function.

[0010] Further, the function operators include: bitRange(begin, end, bitSize): It means that from the begin position to the end position, every bitSize bits are regarded as an integer and constructed as an array for return; the begin position is in bits and includes this position; the end position is in bits and does not include this position; byteRange(begin, end, byteSize): It means that from the begin position to the end position, every byteSize bytes are regarded as an integer and constructed as an array for return; the begin position is in bytes and includes this position; the end position is in bytes and does not include this position; valueOf(position, bitSize): It means starting from the position position, regarding bitSize bits as an integer and returning this integer value; the position position is in bits and includes this position; bitsOf(variable): It means obtaining the number of bits of the variable variable in the internal data; positionOf(variable): It means obtaining the position of the variable variable in the internal data, counted by bits.

[0011] Further, each λ operator includes four elements from front to back in writing: an operand list, an operator name, a parameter list, and a calculus expression; the first element is the operand, and the latter three elements constitute the λ calculus function.

[0012] Further, the λ operators include iterate, map, sort, filter, sum, and reduce.

[0013] Further, the recognition of the branch expression and its calculation and parsing include four steps: formal transformation, reference parsing, partial calculation, and result return: The formal transformation step refers to transforming the expression into reverse Polish notation to form an expression calculation stack; The reference parsing step means that after the formal transformation, the top operand and operator on the stack in the expression are scanned. For those involving variables, their reference ranges are automatically checked. If data that cannot be calculated currently is referenced, the current calculation is skipped and waiting for the next trigger after receiving more data; if the reference parsing finds that the data is complete, the variable is dereferenced and the specific value is filled in; The partial calculation step means that when all the top operands on the stack have been replaced with specific values, the top operand and operator on the current stack are popped for calculation; The result return step means that the result data already on the top of the stack is popped and returned to the caller of the expression; after the result is returned, the stack should be empty.

[0014] Further, the formal transformation is completed at one time when sent to the executor; the reference parsing and partial calculation are triggered with the receipt of new connotative data in the communication.

[0015] Further, in the formal transformation step, for each λ operator, a reverse Polish notation calculation stack is independently established for its expression; each expression corresponds to n + 1 calculation stacks, where n is the number of λ operators in the expression, including the nested λ operators in the λ operator; during calculation, the operands and operators are taken out one by one from the top of the stack for calculation, and the calculation result at the top of the stack is the operand of the next stack operator.

[0016] Further, when all the top operands on the stack have been replaced with specific values, for arithmetic operators and λ operators, enter the partial calculation step; for function operators, first perform semantic dependency checking, that is, establish its dependent variable table according to the semantics, and then scan whether these variables are within the computable range. When the dependent variable table of the function operator is complete, then enter the partial calculation step; for the case where there is only one operand and no operator in the stack, jump to the result return step.

[0017] Further, in the partial calculation step, the calculation of popping the top operand and operator on the current stack includes: For arithmetic operators and function operators, calculate directly according to semantics; For λ operators, take the calculation stack constructed in the form transformation step and recursively call the expression calculation; After the calculation at the top of the stack is completed, push the calculation result onto the stack and jump to the reference resolution step.

[0018] The present invention also proposes a parsing device for communication protocol multiplexing, including: A protocol description module for designing and inserting branch expressions for each protocol branch; A protocol parsing module for identifying branch expressions and performing calculation and parsing.

[0019] Further, the protocol description module equips the branch expressions with three types of operators: arithmetic operators, function operators, and custom λ operators; the arithmetic operators include basic operators that can perform integer data operations and are usually written as specific symbols; the function operators include multiple operators that provide specific data operations; the λ operator is expressed as an operand and a λ calculus function.

[0020] Further, the protocol parsing module specifically includes: A form transformation unit for transforming the expression into reverse Polish notation to form an expression calculation stack; A reference resolution unit for scanning the operand and operator at the top of the stack in the expression after form transformation. For those involving variables, automatically check their reference ranges. If data that cannot be calculated currently is referenced, skip the current calculation and wait for the next trigger after receiving more data; if it is found through reference resolution that the data is complete, dereference the variable and fill in the specific value; A partial calculation unit for calculating by popping the operand and operator at the current top of the stack when all the operands at the top of the stack have been replaced with specific values; A result return unit for popping the result data already at the top of the stack and returning it to the caller of the expression.

[0021] The present invention also proposes a parsing device for communication protocol multiplexing, including: A memory for storing computer programs; A processor for implementing the steps in a parsing method for communication protocol multiplexing as described above when executing the computer program.

[0022] The present invention also proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in a parsing method for communication protocol multiplexing as described above are implemented.

[0023] In summary, the present invention has the following advantages: 1. The method of the present invention is effective for any protocol multiplexing. By introducing the λ operator, the completeness of protocol parsing is achieved. The parsing process can be calculated progressively with the data stream, and it supports frame division according to protocol parsing. That is, as long as there are recognizable differences between protocols, ambiguity can be effectively eliminated and protocol parsing can be realized; 2. The method of the present invention only requires the use of expressions and does not need to be written as code instructions. It is independent of the programming language and can be embedded in the protocol description language, including graphical protocol description languages; it can also be simply degraded to support key-value discrimination algorithms and simple expression calculation algorithms; 3. The present invention mainly supports complex semantics through λ calculus. λ calculus is actually equivalent to a Turing machine and can realize all functions of imperative languages. Therefore, as long as the correct expressions are written, this algorithm can parse all multiplexed protocols; 4. The method of the present invention only needs to scan the connotative data once with the receiving process. Its time complexity regarding the length of the connotative data is linear; in terms of space complexity, the depth of its calculation stack is a constant determined by the expression, and the space complexity of the operands of its λ operator is linear regarding the data length; 5. Since this algorithm is expressed as a descriptive language and only describes the semantics without restricting the solution method, methods such as concurrency and vector instructions can be fully optimized during operation without violating the semantics. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is the overall method framework of the present invention; Figure 2 is the calculation logic flowchart of the expression; Figure 3 is the logic flowchart of the formal transformation step; Figure 4 is the logic flowchart of the reference parsing step Figure 5 is the logic flowchart of the partial calculation step. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] To more clearly illustrate the present invention, the following further describes the present invention in combination with preferred embodiments and drawings. Those skilled in the art should understand that the content specifically described below is illustrative rather than restrictive, and should not be used to limit the protection scope of the present invention.

[0026] To solve the ambiguity problem during the parsing of complex communication protocols containing multiple reuse structures, the present invention provides a parsing method for communication protocol multiplexing.

[0027] For the convenience of scheme description, the meanings of the following terms appearing in the present invention are explained: Connotative data: The data at the session layer (defined according to the seven-layer OSI model) transmitted within the channel. This data constitutes protocol packets. For example, in serial communication, the connotative data includes the data words it transmits, but does not include transport layer data such as start bits and stop bits.

[0028] Denotative data: Other information outside the connotative data, usually derived from data below the session layer, such as the length of the data packet, source address, source port, destination port, etc. It also includes additional information of the connotative data, such as the byte position where the variable is located.

[0029] Constant: A directly given literal value is called a constant. Such as 1, 100, etc.

[0030] Variable: Whether it is connotative data or denotative data, it can be decomposed into several units with specific meanings. In the protocol description language, names are given to these units, and they become variables. For example, the first two bytes in the connotative data are called "protocol header", which is a variable.

[0031] Array: A special constant or variable that contains a group of data and can access the data through an integer subscript.

[0032] Expression: By performing calculations on constants and variables through operators, a definite value is obtained. Here, the expression is basically the same as the expression in general programming languages.

[0033] Branch: In the protocol description language, each multiplexed protocol is represented as a branch. Each branch has a corresponding branch expression. If the expression evaluates to non-zero, then this branch is selected, that is, the data packet is parsed as the corresponding protocol. There can be multiple branches in a protocol description file, and the protocol description language itself does not determine whether they are mutually exclusive relationships, which is completely determined by the branch expression.

[0034] The overall method framework of the present invention is as Figure 1 shown. The present invention proposes an algorithm that is effective for any protocol multiplexing. By introducing the λ operator, the completeness of protocol parsing is achieved. The parsing process can be calculated progressively with the data stream and supports frame division according to protocol parsing. That is, as long as there are recognizable differences between protocols, ambiguities can be effectively eliminated and protocol parsing can be achieved.

[0035] The algorithm of the present invention is embedded in the protocol description language. When describing a protocol, an expression needs to be written for each protocol branch. During protocol parsing, if this expression evaluates to a non-zero value, it means that the corresponding branch is selected, the ambiguity is eliminated, and the algorithm ends. That is, the main steps of the present invention include 2: Step 1: When describing the protocol, design and insert the branch expression; Step 2: When parsing the protocol, identify the expression and calculate the parsing.

[0036] It should be noted that in digital communication, all data are presented as binary numbers with a finite number of bits, and they can always be uniquely mapped to an integer. Therefore, only integers are considered as the only data type here to simplify the description of the algorithm. This simplification is only for the convenience of expression and does not mean that the algorithm cannot handle data such as floating-point numbers and strings.

[0037] The advantages of this parsing method are as follows: 1. Since only expressions are required in protocol description and there is no need to write code instructions, it is independent of programming languages and can be embedded in protocol description languages, including graphical protocol description languages.

[0038] 2. This algorithm can be simply degraded to support key-value discrimination algorithms and simple expression calculation algorithms.

[0039] 3. This algorithm mainly supports complex semantics through lambda calculus. Lambda calculus is actually equivalent to a Turing machine and can implement all functions of imperative languages. As long as the correct expressions are written, this algorithm can parse all multiplexed protocols.

[0040] 4. For the algorithm described in the present invention, only one scan of the connotative data is required along with the receiving process, and its time complexity regarding the length of the connotative data is linear, that is, level.

[0041] 5. In terms of space complexity, the depth of its calculation stack is a constant determined by the expression. The space complexity of the operands of its lambda operator is linear with respect to the data length, that is, level.

[0042] 6. Since this algorithm is expressed as a descriptive language and only describes semantics without restricting the solution method, methods such as concurrency and vector instructions can be fully optimized during operation without violating the semantics.

[0043] Embodiment 1 The following details the steps of a parsing method for communication protocol multiplexing proposed by the present invention.

[0044] Step 1: Design and insertion of expressions The core element of an expression is an operator. In theory, all expression calculations can be completed only with AND, OR, and NOT operators. However, this is very inconvenient and inefficient in engineering practice. Therefore, this algorithm equips the expression with three types of operators: arithmetic operators, function operators, and lambda operators.

[0045] 1) Arithmetic operators Arithmetic operators can perform integer data operations and are usually written as specific symbols. These include: addition (+), subtraction (-), multiplication (*), remainder (%) division ( / ), bitwise AND (&), bitwise OR (|), exclusive OR (^), bitwise complement (~), logical AND (&&), logical OR (||), logical NOT (!), left shift (<<), right shift (>>), equality (==), inequality (!=), less than (<), greater than (>), less than or equal to (<=), greater than or equal to (>=), etc. There are also parentheses (()) for changing precedence and square brackets ([]) for subscript operations. Basically, the same symbols and precedence as in the C programming language are used.

[0046] 2) Function operators Provide some specific data operations, especially for deriving extrinsic data. As a convenience, they are also used to provide some specific algorithms, such as the calculation of cyclic redundancy checks.

[0047] Those important for algorithm completeness include: bitRange(begin, end, bitSize): From the begin position (in bits, including this position) to the end position (in bits, not including this position), every bitSize bits form an integer and are constructed as an array and returned.

[0048] byteRange(begin, end, byteSize): From the begin position (in bytes, including this position) to the end position (in bytes, not including this position), every byteSize bytes form an integer and are constructed as an array and returned.

[0049] valueOf(position, bitSize): Starting from the position position (in bits, including this position), consider bitSize bits as an integer and return this integer value.

[0050] bitsOf(variable): Obtain the number of bits of the variable variable in the intrinsic data.

[0051] positionOf(variable): Obtain the position (in bits) of the variable variable in the intrinsic data.

[0052] 3) λ operators λ operators are custom operators mainly used for processing arrays. They are expressed as operands and λ-calculus functions. Each λ operator, in writing, includes four elements from front to back: the operand list, the operator name, the parameter list, and the calculus expression. The first element is the operand, and the last three elements form the λ-calculus function. The main λ operators include: Iterate: For example, the following expression iterates over the array {1, 2}, and the result is a new array {2, 4}: {1, 2} iterate(x) => x * 2; Map: Mapping is similar to iteration, but it does not guarantee the calculation order. For example, the following expression maps the array {0, 0, 0}, and the result is a new array {1, 2, 3}: {0, 0, 0} map(x, i) => i; Sort: For example, the following expression sorts the array {1, 3, 2} in ascending order, and the result is a new array {1, 2, 3}: {1, 3, 2} sort(x, y) => x < y; Filter: For example, the following expression filters the array {1, 2, 3}, and the result is a new array {1, 3}: {1, 2, 3} filter(x) => x % 2 != 0; Sum: For example, the following expression sums the array {1, 2, 3} with 0 as the initial value, and the result is 6: ({1, 2, 3}, 0) sum(x, y) => x + y; Reduce: Reduction is similar to summation, but it does not guarantee the calculation order. For example, the following expression multiplies the array {1, 2, 3} with 1 as the initial value, and the result is 6: ({1, 2, 3}, 1) reduce(x, y) => x * y; In addition, there are also λ operators such as adjacency and combination, which will not be elaborated one by one.

[0053] It should be noted that: The insertion position of the expression of this invention patent does not need to be specified and can be inserted into any position of the communication protocol description file. The determination of the expression depends on Step 2.

[0054] Step 2: Identification and calculation of the expression Multiple methods can be used for the identification of the expression. For example, special marker bits can be added to the expression.

[0055] The following introduces the calculation method of the expression: There are two modes of bus communication: datagram and virtual link. Virtual link usually adopts data stream, and the implicit data needs to complete protocol parsing to extract the protocol frame. In datagram, there may be a situation where the message frame and the protocol frame are not strictly corresponding. For example, multiple message frames may be required to express a protocol frame. Therefore, the calculation of the expression cannot assume that the protocol frame has been received and segmented. Its calculation method is gradual as the implicit data is received.

[0056] The expression is evaluated as Figure 2 As shown in the figure, it includes four steps: form transformation, reference resolution, partial calculation and return result. The form transformation is completed once when it is sent to the executor; reference resolution and partial calculation are triggered when the communication receives new connotation data.

[0057] 1) Form transformation When writing expressions, they are usually written in a natural language style to facilitate human reading. When it comes to execution, in order to facilitate machine calculation, it is converted into reverse Polish notation when sent to the executor, forming an expression calculation stack. When calculating, the operands and operators are taken out from the top of the stack one by one for calculation. The calculation result at the top of the stack is the operand of the next stack operator. The specific execution process is as follows: Figure 3 shown.

[0058] For each λ operator, a reverse Polish notation calculation stack is independently established for its expression.

[0059] Each expression corresponds to n+1 computation stacks, where n is the number of lambda operators in the expression, including lambda operators nested in lambda operators.

[0060] 2) Reference resolution like Figure 4 As shown in the figure, after the form transformation, the operands and operators at the top of the stack in the expression are scanned. If variables are involved, their reference scope is automatically checked. If data that cannot be calculated at the moment is referenced (such as connotation data that has not been received, etc.), the current calculation is skipped and the next step is triggered after receiving more data. If the reference resolution finds that the data is complete, the variable is dereferenced and filled with the specific value.

[0061] When all top operands have been replaced with concrete values: For arithmetic operators and the lambda operator, proceed to the "Stack Top Calculation" step.

[0062] For function operators, semantic dependency checking is required. That is, a dependency variable table is established based on semantics, and then these variables are scanned to check if they are within the computable range. For example, for the valueOf function described above, it depends on the connotative data position specified by its operand. Then, this function operator is not computable until this connotative data is received. After the dependency variable table of the function operator is complete, the "top-of-stack calculation" step is entered.

[0063] For the case where there is no operator on the stack and only one operand, jump to the "return result" step.

[0064] 3) Top-of-stack calculation As Figure 5 shown, pop the operand and operator at the current top of the stack and perform the calculation.

[0065] For arithmetic operators and function operators, just calculate directly according to semantics.

[0066] For the λ operator, take the calculation stack constructed in its "formal transformation" and recursively call the expression calculation. Here, for λ operators such as iteration and derivation, it may be possible to optimize by calling vector calculation instructions according to the calculation environment.

[0067] After the top-of-stack calculation is completed, push the calculation result onto the stack. Jump to the "reference resolution" step.

[0068] 4) Return result At this time, the result data is already at the top of the stack. Pop the data at the top of the stack and return it as the result to the caller of the expression. After returning the result, the stack should be empty.

[0069] Embodiment 2 Based on the same inventive concept, an embodiment of the present invention further provides a parsing device for communication protocol multiplexing, including a protocol description module and a protocol parsing module. The protocol description module is used to design and insert branch expressions for each protocol branch; the protocol parsing module is used to identify the branch expressions and perform calculation and parsing.

[0070] Further, the protocol description module equips the branch expressions with three types of operators: arithmetic operators, function operators, and custom λ operators; the arithmetic operators include basic operators that can perform integer data operations and are usually written as specific symbols; the function operators include multiple operators that provide specific data operations; the λ operator is expressed as an operand and a λ calculus function. The contents included in each type of operator are the same as those in Embodiment 1 and will not be elaborated here.

[0071] Further, the protocol parsing module specifically includes a formal transformation unit, a reference resolution unit, a partial calculation unit, and a result return unit.

[0072] The form transformation unit is used to transform the expression into Reverse Polish Notation (RPN) to form an expression calculation stack. Specifically, for each λ operator, the form transformation unit independently constructs an RPN calculation stack for its expression. Each expression corresponds to n + 1 calculation stacks, where n is the number of λ operators in the expression, including nested λ operators within the λ operators. During calculation, the operands and operators are retrieved one by one from the top of the stack for calculation, and the calculation result at the top of the stack serves as the operand for the next stack operator.

[0073] The reference resolution unit is used to scan the operand and operator at the top of the stack in the expression after form transformation. Whenever a variable is involved, its reference range is automatically checked. If it references data that cannot be calculated currently, the current calculation is skipped and waiting for the next trigger after receiving more data. If the reference resolution finds that the data is complete, the variable is dereferenced and the specific value is filled in.

[0074] The partial calculation unit is used to calculate by popping the operand and operator at the current top of the stack when all the operands at the top of the stack have been replaced with specific values. Specifically, for arithmetic operators and λ operators, the partial calculation unit can directly enter the calculation. For function operators, semantic dependency checking is first performed, that is, a dependency variable table is established according to the semantics, and then it is scanned whether these variables are within the computable range. When the dependency variable table of the function operator is complete, the calculation is then entered. For the case where there is no operator in the stack and only one operand, the result is returned.

[0075] Further, the partial calculation unit calculates by popping the operand and operator at the current top of the stack, including: For arithmetic operators and function operators, calculate directly according to the semantics; For λ operators, take the calculation stack constructed in the form transformation step and recursively call the expression calculation; After the calculation at the top of the stack is completed, the calculation result is pushed onto the stack and jumps to the reference resolution step.

[0076] The result return unit is used to pop the result data already at the top of the stack and return it to the caller of the expression.

[0077] The functions and roles of the above-described modules and units correspond one by one to the steps involved in the parsing method of Embodiment 1, and will not be elaborated here.

[0078] Embodiment 3 Based on the same inventive concept, the present invention also proposes a parsing device for communication protocol multiplexing, including: A memory for storing a computer program; A processor for implementing the steps in a parsing method for communication protocol multiplexing as described in Embodiment 1 above when executing the computer program.

[0079] Preferably, the computer program may be divided into one or more modules / units, and the one or more modules / units are stored in the memory and executed by the processor to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program in the device.

[0080] The processor may be a central processing unit, or may also be other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor. The processor is the control center of the device and connects various parts of the device through various interfaces and circuits.

[0081] The memory mainly includes a program storage area and a data storage area. Among them, the program storage area may store an operating system, application programs required for at least one function, etc., and the data storage area may store relevant data, etc. In addition, the memory may be a high-speed random access memory, or may also be a non-volatile memory, such as a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, etc., or the memory may also be other volatile solid-state storage devices.

[0082] Embodiment 4 The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in a parsing method for multiplexing communication protocols as described in Embodiment 1 above are implemented.

[0083] The computer storage medium may be a tangible medium that may contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.

[0084] The above are only the preferred embodiments of the present invention, and do not impose any formal limitations on the present invention. Any simple modifications and equivalent changes made to the above embodiments based on the technical essence of the present invention all fall within the protection scope of the present invention.

Claims

1. A parsing method for communication protocol multiplexing, characterized in that, It includes the following steps: Step S1: When describing the protocol, design a branch expression for each protocol branch and insert it; Step S2: When parsing the protocol, identify the branch expression and calculate the parsing.

2. The parsing method for multiplexing communication protocols according to claim 1, wherein The branch expression is equipped with three types of operators: arithmetic operators, function operators, and custom λ operators; the arithmetic operators include basic operators that can perform integer data operations and are usually written as specific symbols; the function operators include multiple operators that provide specific data operations; the λ operator is expressed as an operand and a λ calculus function.

3. The parsing method for multiplexing communication protocols as claimed in claim 2, characterized in that, The function operators include: bitRange(begin, end, bitSize): It means that from the begin position to the end position, every bitSize bits form an integer and are constructed as an array for return; the begin position is in bits and includes this position; the end position is in bits and does not include this position; byteRange(begin, end, byteSize): It means that from the begin position to the end position, every byteSize bytes form an integer and are constructed as an array for return; the begin position is in bytes and includes this position; the end position is in bytes and does not include this position; valueOf(position, bitSize): It means starting from the position, regarding bitSize bits as an integer and returning this integer value; the position is in bits and includes this position; bitsOf(variable): It means obtaining the number of bits of the variable variable in the connotative data; positionOf(variable): It means obtaining the position of the variable variable in the connotative data, counted by bits.

4. The parsing method for multiplexing communication protocols according to claim 2, wherein, Each λ operator includes four elements from front to back in writing: an operand table, an operator name, a parameter table, and a calculus expression; the first element is the operand, and the last three elements form the λ calculus function.

5. The parsing method for multiplexing communication protocols according to claim 2 or 4, characterized in that, The λ operators include iterate, map, sort, filter, sum, and reduce.

6. The parsing method for multiplexing communication protocols according to claim 2, characterized in that, The identifying the branch expression and calculating the parsing includes four steps: form transformation, reference parsing, partial calculation, and returning the result: The form transformation step means transforming the expression into reverse Polish notation to form an expression calculation stack; The reference parsing step means that after the form transformation, scan the operand and operator at the top of the stack in the expression. Whenever a variable is involved, automatically check its reference range. If it references data that cannot be calculated currently, skip this calculation and wait for the next trigger after receiving more data; if the reference parsing finds that the data is complete, dereference the variable and fill in the specific value; The partial calculation step means that when all the operands at the top of the stack have been replaced with specific values, pop the operand and operator at the current top of the stack for calculation; The returning the result step means popping the result data that has been at the top of the stack and returning it to the caller of the expression; After returning the result, the stack should be empty.

7. The parsing method for multiplexing communication protocols as described in claim 6, characterized in that, The format transformation is completed once when it is sent to the executor; reference resolution and partial calculations are triggered when new content data is received during communication.

8. The parsing method for multiplexing communication protocols according to claim 6, wherein, In the form transformation step, for each λ operator, a reverse Polish notation calculation stack is independently established for its expression; each expression corresponds to n+1 calculation stacks, where n is the number of λ operators in the expression, including λ operators nested in λ operators; during calculation, operands and operators are taken out one by one from the top of the stack downwards for calculation, and the calculation result at the top of the stack is the operand of the next stack operator.

9. The parsing method for multiplexing communication protocols according to claim 6, wherein When all the top operands of the stack have been replaced with specific values, for arithmetic operators and lambda operators, enter the partial calculation step; for function operators, first perform a semantic dependency check, that is, establish its dependent variable table according to the semantics, and then scan whether these variables are within the computable range. When the dependent variable table of the function operator is complete, enter the partial calculation step; if there is no operator in the stack and there is only one operand, jump to the return result step.

10. The parsing method for communication protocol multiplexing according to claim 6, characterized in that, In some calculation steps, the calculation of the operand and operator popping the current stack top includes: For arithmetic operators and function operators, they are calculated directly according to semantics; For the lambda operator, take the computation stack constructed in the form transformation step and recursively call the expression computation; After the top of the stack is calculated, the calculation result is pushed into the stack and the reference resolution step is jumped to.

11. A parsing device for multiplexing communication protocols, characterized in that, include: The protocol description module is used to design and insert branch expressions for each protocol branch; The protocol parsing module is used to identify branch expressions and calculate the parsing.

12. The parsing device for multiplexing communication protocols according to claim 11, characterized in that, The protocol description module equips branch expressions with three types of operators: arithmetic operators, function operators and custom λ operators; the arithmetic operators include basic operators that can perform integer data operations and are usually written as specific symbols; the function operators include multiple operators that provide specific data operations; the λ operator is expressed as an operand and a λ calculus function.

13. The parsing device for multiplexing communication protocols according to claim 12, characterized in that, The protocol analysis module specifically includes: A form conversion unit, used to convert an expression into a reverse Polish form to form an expression calculation stack; The reference parsing unit is used to scan the operands and operators at the top of the stack in the transformed expression. If a variable is involved, its reference scope is automatically checked. If the data that cannot be calculated at the moment is referenced, the calculation is skipped and the next step is triggered after receiving more data. If the reference parsing finds that the data is complete, the variable is dereferenced and filled with the specific value. Some calculation units are used to calculate the operands and operators popped from the current stack when all the top operands have been replaced with specific values; The result return unit is used to pop the result data already on the top of the stack and return it to the caller of the expression.

14. A parsing device for multiplexing communication protocols, characterized in that, include: Memory for storing computer programs; A processor, used to implement the steps in the communication protocol multiplexing parsing method as described in any one of claims 1 to 10 when executing the computer program.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the communication protocol multiplexing parsing method as described in any one of claims 1 to 10 are implemented.

Citation Information

Patent Citations

  • A Programming Method for CAN-LonWorks Protocol Conversion Logic

    CN107247678B

  • Communication protocol analysis method based on character string type data

    CN107306256A

  • Vehicle-mounted terminal communication protocol analysis method and device

    CN113364732A