A general protocol data quick verification method and device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING PANDA HANDA TECH
- Filing Date
- 2026-05-19
- Publication Date
- 2026-08-07
AI Technical Summary
现有的协议数据验证通常依赖于专门开发的接口协议测试软件,这类软件与底层电气接口紧密耦合,开发周期长、成本高,且往往需要在通信协议获各方认可之后、软件合格性测试之前才能投入使用,难以在协议设计的早期阶段提供及时验证
Smart Images

Figure CN122533993A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication protocol testing and data verification technology, and in particular to a general method and apparatus for rapid verification of protocol data. Background Technology
[0002] A communication protocol is an agreement between devices in a communication system for transmitting various messages. This agreement has a specific structure, and protocol data is a set of numbers within this structure. Whether the protocol data conforms to the agreement can be verified by designing specialized interface protocol testing software. In the development of a communication system, rapid and accurate verification of protocol data is fundamental to ensuring correct interaction between devices. Existing protocol data verification typically relies on specially developed interface protocol testing software. This type of software is tightly coupled to the underlying electrical interface, has a long development cycle, is costly, and often can only be used after the communication protocol has been approved by all parties and before software qualification testing, making it difficult to provide timely verification in the early stages of protocol design. When faced with manpower shortages, schedule pressures, or cost constraints, and lacking dedicated interface protocol testing software, early verification and error detection of protocol data will be severely hampered.
[0003] Furthermore, existing methods suffer from the following typical drawbacks: The lack of a concise and universal means for formally representing and converting the protocol structure itself necessitates writing extensive dedicated code or using complex tools for each verification, resulting in poor versatility. For scenarios where certain fields in the protocol require exhaustive testing or boundary verification, existing tools struggle to flexibly specify the repetition of certain bits while keeping others unchanged, leading to low automation and impacting the comprehensiveness of the verification. When verifying audio signals, such as for digital audio interface protocols, generating analog audio signals for transceiver or load testing typically requires a separate signal generator or additional dedicated software development. It's difficult to directly generate matching protocol data and audio signals using a unified description method, increasing the complexity and cost of the verification system.
[0004] Therefore, there is an urgent need for a rapid protocol data verification method that can be independent of the characteristics of the underlying interface and has high versatility and flexibility to support diverse verification needs, from protocol structure description to data generation, reverse verification, traversal arrangement and audio signal description. Summary of the Invention
[0005] The purpose of this invention is to provide a universal, efficient, and accurate method and apparatus for rapid verification of protocol data, which can quickly verify interface protocols without developing dedicated interface testing software, thereby improving the efficiency of communication protocol development and testing.
[0006] The technical solution to achieve the objective of this invention is: a general method for rapid verification of protocol data, comprising the following steps:
[0007] Step 1: Obtain the protocol structure representation input through the editing interface. The protocol structure representation is used to describe the frame structure of the communication protocol, based on a preset data unit, and contains at least one data unit line; wherein each data unit line consists of at least one bit field item, the format of which is "bit field identifier: value". When the bit field identifier is a number, it indicates the number of bits in the bit field; when the bit field identifier is a name, it indicates a string parameter name; the value includes numerical values, characters, strings, and predefined automatically calculated strings.
[0008] Step 2: Parse the protocol structure representation, perform calculations on the automatically calculated string according to its definition and associated data to obtain the actual value, generate the expected protocol structure representation based on the actual value, and concatenate the values of each bit field item according to the data unit to generate protocol data;
[0009] Step 3: Reverse parse the protocol data to be verified according to the data unit and the bit width of the bit field identifier to obtain the reverse protocol structure representation;
[0010] Step 4: Compare the reverse protocol structure representation with the expected protocol structure representation, and verify the correctness of the protocol data based on the comparison results.
[0011] A general protocol data fast verification device, used to implement the general protocol data fast verification method, includes:
[0012] The human-computer interaction module is used to acquire the protocol structure representation input by the user. The protocol structure representation is based on a preset data unit and consists of at least one bit field item in the format "bit field identifier: value".
[0013] The forward conversion module is used to parse the protocol structure representation, perform automatic string calculation operations to generate the expected protocol structure representation, and concatenate the values of each field item according to the data unit to generate protocol data;
[0014] The reverse conversion module is used to reverse-parse the protocol data to be verified into a reverse protocol structure representation;
[0015] The comparison module is used to compare the reverse protocol structure representation with the expected protocol structure representation and output the verification result;
[0016] The traversal and audio generation module is used to perform multiple loops based on the traversal representation string to generate traversal protocol data, and to generate digital audio protocol data containing in-phase and quadrature signal sampling data based on the audio signal definition.
[0017] Compared with the prior art, the present invention has the following significant advantages: (1) The present invention constructs a concise protocol structure expression method based on the basic data unit of the protocol, and separates the human-computer interaction interface related to the underlying interface interaction and protocol semantics from the protocol data verification. It can be directly applied, thus avoiding the need to develop special testing software and improving the efficiency of protocol data verification; (2) It constructs a structure representation that meets the requirements of the protocol based on the protocol document in a freely editable manner. It can not only be quickly and flexibly converted into protocol data, but also accurately convert it bidirectionally with the protocol data, thereby verifying the correctness of the protocol data; (3) It can handle string protocol data including XML and JSON formats. It can perform two optional processing methods, strict or high fault tolerance, without relying on other XML or JSON processing software, which improves the efficiency of protocol data verification; (4) It can record multiple rows of data according to the specified header column and automatically perform column spacing calculation and row splitting and compression. It can construct protocol data that traverses the specified range through a concise and accurate description syntax. It can output in-phase and quadrature signal data or analog audio signals through a given signal function string containing time variables and sine or cosine functions. It realizes rich functions such as the minimum bit level editing input of protocol data, bidirectional conversion of protocol structure representation and protocol data, and comparison recording, and has high universality. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a general method for rapid verification of protocol data according to the present invention.
[0019] Figure 2 This is a typical structural diagram of the communication protocol in this invention.
[0020] Figure 3 This is an example diagram of a record file in this invention.
[0021] Figure 4 This is an example diagram of a record file in which the protocol data in this invention is compressed from one number per line to four numbers per line. Detailed Implementation
[0022] This invention provides a general method and apparatus for rapid verification of protocol data, addressing the problems of existing technologies where protocol verification relies on dedicated interface testing software, is tightly coupled with underlying interfaces, has long development cycles, and cannot be flexibly verified in early stages. This method can automatically generate protocol data and support reverse verification through a concise protocol structure description, independent of specific interface electrical characteristics. It also possesses the ability to iterate and arrange specified fields, describe audio signals using function expressions, and generate protocol data and analog audio signals. Therefore, even under constraints in personnel, cost, and schedule, it can still achieve rapid and comprehensive verification of protocol data, meeting diverse verification needs from early design verification and debugging testing to transceiver load testing.
[0023] This invention provides a general method for rapid verification of protocol data, comprising the following steps:
[0024] Step 1: Obtain the protocol structure representation input through the editing interface. The protocol structure representation is used to describe the frame structure of the communication protocol, based on a preset data unit, and contains at least one data unit line; wherein each data unit line consists of at least one bit field item, the format of which is "bit field identifier: value". When the bit field identifier is a number, it indicates the number of bits in the bit field; when the bit field identifier is a name, it indicates a string parameter name; the value includes numerical values, characters, strings, and predefined automatically calculated strings.
[0025] Step 2: Parse the protocol structure representation, perform calculations on the automatically calculated string according to its definition and associated data to obtain the actual value, generate the expected protocol structure representation based on the actual value, and concatenate the values of each bit field item according to the data unit to generate protocol data;
[0026] Step 3: Reverse parse the protocol data to be verified according to the data unit and the bit width of the bit field identifier to obtain the reverse protocol structure representation;
[0027] Step 4: Compare the reverse protocol structure representation with the expected protocol structure representation, and verify the correctness of the protocol data based on the comparison results.
[0028] As a specific example, in step 1, the data unit is 8 bits, 16 bits, or 32 bits; if the sum of the number of bits of all bit field entries in a data unit row is less than the data unit, the remaining bits are automatically filled with 0; the value supports input in decimal, hexadecimal, or binary form and is distinguished by suffix.
[0029] As a specific example, in step 1, the automatically calculated string includes:
[0030] The odd parity identifier "ODD" and the even parity identifier "EVEN" are used to perform parity calculations on the other bits of the data unit containing the odd parity identifier or the even parity identifier, and fill the result into the corresponding bit of the odd parity identifier or the even parity identifier.
[0031] The XOR check flag "XOR(start offset, end offset)" supports additionally specified byte order;
[0032] Cyclic Redundancy Check (CRC) flag "CRC(start offset, end offset)";
[0033] The data length identifier "Len(start offset, end offset)" supports displaying the length value byte by byte;
[0034] The serial number is identified by "SerNum" or "SN" and supports automatic incrementing, byte-by-byte display, and increment control.
[0035] The system includes the escape processing identifier "slip" and the start marker "begin", which are used to perform SLIP escaping or reverse deescaping on data within a specified range. The automatic calculations are all performed based on the data before escaping.
[0036] As a specific example, when processing protocols containing XML or JSON string formats, the bit-field items are described in the form of "parameter name: value"; the method further includes:
[0037] Provide a formatted XML or JSON string template, in which the position of the parameter to be dynamically populated is occupied by "[parse + parameter name]";
[0038] When generating protocol data, the parameter values in the protocol structure representation are filled into the corresponding placeholders to generate complete string protocol data;
[0039] During reverse parsing, the received string protocol data is compared with the formatted string template to extract the parameter names and corresponding values, thus forming a reverse protocol structure representation.
[0040] As a specific example, the comparison provides two modes: strict matching and high-tolerance matching. In strict mode, the entire string segment before and after the corresponding parsing position must be completely identical. In high-tolerance mode, only the first and last characters of the string at the position of the parsing parameter are matched.
[0041] As a concrete example, the method also includes the step of traversing the protocol data generation:
[0042] Obtain the traversal representation string, which is used to define the traversal of at least one bit range in the protocol data. The format of the traversal representation string includes a continuous bit range represented by "data sequence number [.bit sequence number]-data sequence number [.bit sequence number]", with multiple ranges connected by a separator.
[0043] Based on the traversal representation string and the data unit, determine the loop level of the multiple loops, the minimum and maximum value arrays of the range of change of each level, and the step size;
[0044] Execute multiple loops, generate a traversal value corresponding to the current traversal position in each loop, assign the traversal value to the corresponding bit of the protocol data, recalculate the affected automatic calculation items according to the protocol structure representation, and record the generated traversal protocol data.
[0045] As a specific example, when multiple bit ranges of the traversal represent the string definition overlapping, a prompt is issued and the user is allowed to choose whether to automatically merge the overlapping ranges; when recording traversal protocol data, the cumulative traversal count is selectively recorded before each data entry.
[0046] As a specific example, the method also includes the generation of digital audio protocol data:
[0047] The protocol structure representation includes bit field entries “I(x,y)” and “Q(x,y)”, where x represents the sampling point number and y represents the portion of the sampling point value in the y-th data unit;
[0048] The system receives the audio signal type selected by the user or a custom function expression, wherein the custom function expression is a string containing a time variable t, a sin function, a cos function, an arithmetic operator, and a constant.
[0049] Based on the audio signal type or a custom function expression, generate in-phase signal sample values, and perform a Hilbert transform on the in-phase signal to obtain quadrature signal sample values;
[0050] The sampled values of in-phase and quadrature signals are filled into the positions corresponding to "I(x,y)" and "Q(x,y)" in the protocol data according to the data unit and bit width.
[0051] As a specific example, it also includes generating record files using a standardized text file record class, which automatically calculates and adjusts the column width based on a preset header column, automatically splits the content of cells that exceed the column width into multiple rows, and compresses multiple protocol data into the same row for display according to the data unit.
[0052] The present invention also provides a general protocol data fast verification device, which is used to implement the general protocol data fast verification method, including:
[0053] The human-computer interaction module is used to acquire the protocol structure representation input by the user. The protocol structure representation is based on a preset data unit and consists of at least one bit field item in the format "bit field identifier: value".
[0054] The forward conversion module is used to parse the protocol structure representation, perform automatic string calculation operations to generate the expected protocol structure representation, and concatenate the values of each field item according to the data unit to generate protocol data;
[0055] The reverse conversion module is used to reverse-parse the protocol data to be verified into a reverse protocol structure representation;
[0056] The comparison module is used to compare the reverse protocol structure representation with the expected protocol structure representation and output the verification result;
[0057] The traversal and audio generation module is used to perform multiple loops based on the traversal representation string to generate traversal protocol data, and to generate digital audio protocol data containing in-phase and quadrature signal sampling data based on the audio signal definition.
[0058] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0059] Example
[0060] like Figure 1 As shown, this invention provides a general method for rapid verification of protocol data. It uses a concise descriptive method to represent a portion or all of the protocol structure, then converts it into protocol data. This protocol data can be used for example illustrations, debugging tools, testing software, etc., and can also be reverse-engineered into a protocol structure representation. Comparing this representation with the expected protocol structure representation verifies the correctness of the protocol data. Figure 1 The protocol data includes several parts: "Echoing Representation" describes the repeated arrangement of one or more specified ranges of bits in the protocol data, while undescribed bits remain unchanged (or change automatically if automatic calculations are involved); "Audio Signal Representation" describes the audio signal using a function expression, and the resulting protocol data can be used for digital audio interface verification, while the generated analog audio signal can be used for transceiver testing and load testing. Specifically, it includes the following parts:
[0061] (a) Representation and Conversion of Protocol Structure
[0062] The typical structure of a communication protocol is the frame structure of a single instruction, such as... Figure 2 As shown, the "frame header" typically contains fixed numbers to indicate a synchronization header; some protocols also include destination address, source address, length, timestamp, sequence number, etc. The "instruction information" typically contains an instruction identifier and instruction parameters; the parameter information may be "empty," and some protocols allow multiple instruction identifiers and instruction parameter pairs to exist in a single instruction. The "frame trailer" typically contains fixed numbers to indicate the end of the protocol information, but may only contain a checksum; some protocols also include instruction identifiers, etc. Frame headers and trailers are not mandatory; single-byte instructions may also be used.
[0063] The custom attributes of the protocol structure mean that directly following its defined structure will lose its versatility. In order to describe any protocol structure, based on the data units used by the protocol (8 bits, 16 bits, or 32 bits), the protocol structure is represented by one or more "Bit length / name: value" entries. When "Bit length / name" is a number, it indicates the bit field length. When it is a "name", it is used for processing XML and JSON format strings. The "value" is generally a number, but may also contain specific characters.
[0064] In the protocol structure representation editing mode, a specific string is used to represent the automatic calculation, and the corresponding value (number) is given in the expected protocol structure representation, for example:
[0065] "ODD" indicates that the protocol data is parity checked.
[0066] "XOR(0,-1)" means performing an XOR operation on the numbers from the 0th bit (representing the specified number itself) to the 1st bit before the check bit in the protocol data.
[0067] “CRC(1,-1)” means performing a cyclic redundancy check on the number from the first position of the protocol data to the first bit before the check bit. The parameters of the check function itself are provided by the interface for selection or customization. For example, “16,0x8005,0” means a 16-bit CRC with a polynomial of 0x8005 and no bit reversal.
[0068] Use "xxx" to represent the string xxx;
[0069] Use 'a' to represent the character 'a'. If the string contains a lot of content, you can directly use the file name containing its content, such as txt, XML, JSON, etc.
[0070] "Len(0,-2)" represents the number of elements from the 0th element to the second-to-last element;
[0071] “SerNum” represents an automatically incrementing serial number, etc. These specific strings are explained in Table 3. The representation of audio signal data will be explained in section (III) later.
[0072] After editing the protocol structure representation, it can be converted. The result of the conversion is a set of numbers, each number being the data unit used by the protocol. The data can be copied by spaces or commas for easy pasting into other testing software. Correspondingly, after having the protocol structure representation, a set of numbers can also be converted into the corresponding protocol structure representation. The two protocol structure representations should be completely consistent. For the SLIP protocol, the two protocol structure representations are the data before escaping, while the protocol data is the data after escaping. In the instruction information, "C0" is converted to "DB DC", and "DB" is converted to "DB DD". This invention provides a broad definition of the escaping range, which can be applied to the case of protocol nesting. See Table 3 for details. If they are inconsistent, it indicates that there is an error in the protocol structure or protocol data.
[0073] The following example uses a protocol conforming to the HB6096 bus interface to illustrate the expected protocol structure, protocol data, and its reverse-converted protocol structure. See Table 1 for details:
[0074] Table 1 Protocol Structure Representation and Protocol Data Example 1
[0075]
[0076]
[0077] Table 1 provides examples of how commonly used binary protocols in communication devices represent their protocol structure using "Bits:Value". If the "text" portion of the protocol's instruction information uses XML, JSON, or other encoding methods, it needs to be described using "Name:Value" format, as shown in Table 2.
[0078] Table 2 Protocol Structure Representation and Protocol Data Example 2
[0079]
[0080]
[0081] To facilitate the construction of protocol structures and the specification of ranges, specific strings can be used to replace concrete "values," as shown in Table 3. Examples of protocol data units are provided, using either 32 bits or 8 bits.
[0082] Table 3 Examples of specific strings representing protocol structures
[0083]
[0084]
[0085]
[0086]
[0087] In addition to providing copy and paste functions on the human-computer interaction interface, this invention develops a standardized text file record class for protocol structure representation editing input, protocol data, protocol structure converted from protocol data, expected protocol structure representation, and comparison results. It automatically generates a text record file with a set arrangement simply by defining the filename, header columns, and inputting the strings to be recorded in sequence. The spacing between each column is automatically calculated based on the header width and can be increased or decreased. It can automatically split into multiple lines and automatically compress the number of lines. When the file is too large, it is automatically recorded as a new file. It can not only be used directly for compiling protocol data test cases, but also used in office software to extract the required column information for secondary applications. This file record class can also be widely used in other automatic measurement and testing software, such as... Figure 3 As shown, the string "8:1111 1111 1111 1111 11111111 1111 1111b" was automatically split because its length as a single string exceeded the width of the corresponding column. It is now displayed on multiple lines in the file. For protocol data in units of 8, if the data is too long, the number of lines can be automatically compressed. Figure 4 The protocol data in the example is compressed from one number per line to four numbers per line.
[0088] (ii) Traversal representation and implementation of protocol data
[0089] Since protocol data verification often requires testing a continuously changing quantity, such as calling channel numbers (0-255) or detecting undefined instruction identifiers, it is necessary to construct a method to traverse all protocol data at specified locations for testing the software under test. The traversal representation in this invention uses strings in the form "data sequence number [.bit sequence number]-data sequence number [.bit sequence number]" or "data sequence number [.bit sequence number]" to define the order and range to be traversed. The sequence numbers all start from 0, and multiple strings are separated by semicolons, commas, or spaces. For example, if the data unit of a protocol is 8 bits, then "0.0-0.2, 1, 2-3.6" represents traversing bits 0 to 2 (3 bits) of the 0th byte, bits 8 (8 bits) of the 1st byte, bits 8 (8 bits) of the 2nd byte, and bits 6 (6 bits) of the 3rd byte. The traversal is performed by 7 bits, accumulating to 26 bits, which will construct 67,108,864 sets of protocol data. For example, if the data unit of a certain protocol is 32 bits, then "1-3" means that the traversal of the first to the third double word is 96 bits, and 79228162514264337593543950336 is the total number of traversals. In order to prevent miswriting of the traversal representation, this invention uses decimal long integer multiplication to calculate the total number of traversals and prompts the user whether to continue before the actual traversal.
[0090] The traversal is implemented by constructing a flexible and general multi-loop framework class. The main parameter of this class is one of the data units: 8 bits, 16 bits, and 32 bits. The core function is the multi-loop framework function, which traverses according to the parameters and calls back the traversal value to the traversal execution function. In the traversal execution function, the traversal value can be used to associate any data, including floating-point numbers, pointers, etc. This separates the traversal method, including the number of loops and the order, from the specific execution, and provides a general traversal framework. Each callback can generate one piece of protocol data. When all callbacks are completed, it means that the entire traversal of the protocol data is completed.
[0091] The flexibility of the loop hierarchy implied by the traversal representation requires that the multi-loop framework function must break through the preset and fixed loop hierarchy, range of variation and step size, that is, it must be extended to be dynamically variable. Therefore, the input parameters of the function are the loop hierarchy, range of variation and step size, as detailed in Table 4. These parameters are automatically calculated and obtained by the member functions of the multi-loop framework class according to the data unit and traversal representation.
[0092] Table 4. Description of Input Parameters for Multi-Loop Framework Functions
[0093]
[0094] Because the protocol may require verification calculations and escaping, as long as it does not conflict with the traversal position, the data after the traversal bit is changed will be re-verified and escaped according to the input protocol structure. The generated protocol data is recorded in "traversal data.txt", as shown in Table 5:
[0095] Table 5 Example 1 of traversing protocol data
[0096]
[0097] The protocol data traversed above comes from the protocol structure representation input, but it can also come directly from the protocol data. In this case, the traversal does not process the protocol structure representation; it simply traverses the specified positions of the protocol data. The generated protocol data is also recorded in "traversal data.txt", as shown in Table 6.
[0098] Table 6 Example 2 of traversing protocol data
[0099]
[0100] (III) Representation and Implementation of Audio Signal Data
[0101] Besides control protocols, data stream protocols are also commonly used in communication. A typical example is the digital audio transmission protocol. Digital audio transmission protocols typically transmit in-phase (I) and quadrature (Q) signals according to specified protocol data representations. This invention provides single-tone (1kHz), single-tone (1.6kHz), single-tone (1.2kHz), single-tone (2.8kHz), dual-tone (1kHz+1.6kHz), dual-tone (1kHz+1.2kHz), dual-tone (1kHz+2.8kHz), and others (300Hz-3.3kHz). The system offers multiple options, including single-tone and dual-tone options, which use common test frequencies (cosine signals). "Other" indicates that the frequency of the cosine signal is user-defined (in Hz). These cosine signals are used as in-phase signals I; by lagging their phase by 90°, the corresponding quadrature signal Q can be obtained. "Custom" allows users to represent signal functions using combinations of "t, sin, cos, pow, pi, +, -, *, / , 0~9,., (,)", which are then used as in-phase signals I. A Hilbert transform is then performed on these to obtain the quadrature signal Q. The protocol data, combined with variable parameters, can automatically generate audio signal transmission protocol data and write it to a file according to a specified duration. Alternatively, it can be used independently to control the computer sound card to continuously output analog audio signals at an 8kHz sampling rate and 16-bit precision.
[0102] Table 7 provides an example of a protocol structure representation and protocol data that uses the following expression as a user-defined function:
[0103]
[0104] Its user-defined function is:
[0105] “5000*(cos(2*pi*300*t)+cos(2*pi*100*t-pi / 2)) / (sin(2*pi*200*t)+sin(2*pi*300*t-pi / 2)+2.1)”, where pi is π, t represents the time variable, the sampling rate is set to 8kHz, and the I and Q values are represented by 16-bit linear two's complement, with a range of [-32767,+32767].
[0106] Table 7 Examples of Audio Signal Data Representation
[0107]
[0108] This invention constructs a concise protocol structure expression method based on the basic data unit of the protocol. It realizes rich functions such as editing input at the smallest bit level of protocol data, bidirectional conversion between protocol structure representation and protocol data, and comparison recording. It has high universality and completely separates the human-computer interaction interface related to the underlying interface and protocol semantics from the protocol data verification. It can be directly applied, thus eliminating the need to develop special testing software. Its innovations include the following: (1) It focuses precisely on the processing of protocol data, with built-in common calculation and escaping functions. It does not have the burden of additional human-computer interaction interface design and is naturally more efficient than designing dedicated protocol data verification software. It is both versatile and fast; (2) It can construct a structure representation that meets the requirements of the protocol based on the protocol document in a free editing manner. It can not only quickly and flexibly convert into protocol data, but also accurately convert into protocol data in both directions, thereby verifying the correctness of the protocol data; (3) It can perform two optional processing methods for string protocol data, including XML and JSON formats, without relying on other XML and JSON processing software; (4) It records multiple rows of data according to the specified header column and automatically calculates the column spacing and splits and compresses rows; (5) It constructs protocol data that traverses the specified range through a concise description syntax that is accurate to the bit; (6) It outputs in-phase and quadrature signal data or analog audio signals through a given signal function string containing time variables and sine or cosine functions.
[0109] This invention is mainly used for protocol data verification. It is applicable to early protocol verification, special cases where there is no protocol documentation but only source code, software debugging and manufacturing, as well as software testing and manufacturing. It can also be integrated into the design and development of dedicated testing software, which greatly improves the efficiency of communication protocol development and testing verification.
[0110] This invention, applied in engineering practice, allows users familiar with the protocol itself to quickly verify interface protocols such as serial ports, network ports, and avionics buses without developing dedicated interface testing software. The development time for dedicated interface protocol testing software is closely related to the number of instructions, parameters, and the complexity of the protocol itself, typically requiring hours to weeks to build the first usable version. Meanwhile, the underlying transmit / receive testing software for interfaces usually has publicly available general versions or is included with the interface adapter (even if dedicated transmit / receive testing software were to be developed, the workload would be minimal). This invention can directly work with these to verify the protocol, demonstrating its significant efficiency. Furthermore, for the design of the protocol itself, using this invention for "design and verification simultaneously" ensures the correctness of the protocol and avoids rework after release.
[0111] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A general method for rapid verification of protocol data, characterized in that, Includes the following steps: Step 1: Obtain the protocol structure representation input through the editing interface. The protocol structure representation is used to describe the frame structure of the communication protocol. It is based on a preset data unit and contains at least one data unit line. Each data unit line consists of at least one bit field item. The format of the bit field item is "bit field identifier: value". When the bit field identifier is a number, it indicates the number of bits in the bit field. When the bit field identifier is a name, it indicates the string parameter name. The value includes numerical values, characters, strings, and predefined automatically calculated strings. Step 2: Parse the protocol structure representation, perform calculations on the automatically calculated string according to its definition and associated data to obtain the actual value, and generate the expected protocol structure representation based on the actual value; The values of each bit field are concatenated according to the data unit to generate protocol data; Step 3: Reverse parse the protocol data to be verified according to the data unit and the bit width of the bit field identifier to obtain the reverse protocol structure representation; Step 4: Compare the reverse protocol structure representation with the expected protocol structure representation, and verify the correctness of the protocol data based on the comparison results.
2. The general protocol data fast verification method according to claim 1, characterized in that, In step 1, the data unit is 8 bits, 16 bits, or 32 bits; if the sum of the number of bits of all bit field entries in a data unit row is less than the data unit, the remaining bits are automatically filled with 0; the value can be input in decimal, hexadecimal, or binary form and is distinguished by a suffix.
3. The general protocol data rapid verification method according to claim 1, characterized in that, In step 1, the automatically calculated string includes: The odd parity identifier "ODD" and the even parity identifier "EVEN" are used to perform parity calculations on the other bits of the data unit containing the odd parity identifier or the even parity identifier, and fill the result into the bit corresponding to the odd parity identifier or the even parity identifier. The XOR check flag "XOR(start offset, end offset)" supports additionally specified byte order; Cyclic Redundancy Check (CRC) flag "CRC(start offset, end offset)"; The data length identifier "Len(start offset, end offset)" supports displaying the length value byte by byte; The serial number is identified by "SerNum" or "SN" and supports automatic incrementing, byte-by-byte display, and increment control. The system includes the escape processing identifier "slip" and the start marker "begin", which are used to perform SLIP escaping or reverse deescaping on data within a specified range. The automatic calculations are all performed based on the data before escaping.
4. The general protocol data fast verification method according to claim 1, characterized in that, When processing protocols containing XML or JSON string formats, the bit field entries are described in the form of "parameter name: value"; the method further includes: Provide a formatted XML or JSON string template, in which the position of the parameter to be dynamically populated is occupied by "[parse + parameter name]"; When generating protocol data, the parameter values in the protocol structure representation are filled into the corresponding placeholders to generate complete string protocol data; During reverse parsing, the received string protocol data is compared with the formatted string template to extract the parameter names and corresponding values, thus forming a reverse protocol structure representation.
5. The general protocol data rapid verification method according to claim 4, characterized in that, The comparison provides two modes: strict matching and high-tolerance matching. In strict mode, the entire string segment before and after the corresponding parsing position must be completely identical. In high-tolerance mode, only the first and last characters of the string at the position of the parsing parameter are matched.
6. The general protocol data fast verification method according to claim 1, characterized in that, The method also includes the step of traversing the generated protocol data: Obtain the traversal representation string, which is used to define the traversal of at least one bit range in the protocol data. The format of the traversal representation string includes a continuous bit range represented by "data sequence number [.bit sequence number]-data sequence number [.bit sequence number]", with multiple ranges connected by a separator. Based on the traversal representation string and the data unit, determine the loop level of the multiple loops, the minimum and maximum value arrays of the range of change of each level, and the step size; Execute multiple loops, generate a traversal value corresponding to the current traversal position in each loop, assign the traversal value to the corresponding bit of the protocol data, recalculate the affected automatic calculation items according to the protocol structure representation, and record the generated traversal protocol data.
7. The general protocol data fast verification method according to claim 6, characterized in that, When multiple bit ranges defined by the traversal string overlap, a prompt is issued and the user is allowed to choose whether to automatically merge the overlapping ranges; when recording traversal protocol data, the cumulative traversal count is selectively recorded before each data entry.
8. The general protocol data fast verification method according to claim 1, characterized in that, The method also includes the generation of digital audio protocol data: The protocol structure representation includes bit field entries "I(x,y)" and "Q(x,y)", where x represents the sampling point number and y represents the portion of the sampling point value in the y-th data unit; The system receives the audio signal type selected by the user or a custom function expression, wherein the custom function expression is a string containing a time variable t, a sin function, a cos function, an arithmetic operator, and a constant. Based on the audio signal type or a custom function expression, generate in-phase signal sample values, and perform a Hilbert transform on the in-phase signal to obtain quadrature signal sample values; The sampled values of in-phase and quadrature signals are filled into the positions corresponding to "I(x,y)" and "Q(x,y)" in the protocol data according to the data unit and bit width.
9. The general method for rapid verification of protocol data according to any one of claims 1 to 8, characterized in that, It also includes generating record files using a standardized text file record class, which automatically calculates and adjusts the column width based on a preset header column, automatically splits the content of cells that exceed the column width into multiple rows, and compresses multiple protocol data into the same row for display according to the data unit.
10. A universal protocol data rapid verification device, characterized in that, This device is used to implement the general protocol data fast verification method as described in claim 9, comprising: The human-computer interaction module is used to acquire the protocol structure representation input by the user. The protocol structure representation is based on a preset data unit and consists of at least one bit field item in the format "bit field identifier: value". The forward conversion module is used to parse the protocol structure representation, perform automatic string calculation operations to generate the expected protocol structure representation, and concatenate the values of each field item according to the data unit to generate protocol data; The reverse conversion module is used to reverse-parse the protocol data to be verified into a reverse protocol structure representation; The comparison module is used to compare the reverse protocol structure representation with the expected protocol structure representation and output the verification result; The traversal and audio generation module is used to perform multiple loops based on the traversal representation string to generate traversal protocol data, and to generate digital audio protocol data containing in-phase and quadrature signal sampling data based on the audio signal definition.