Communication protocol automatic analysis and test data generation method and system

By parsing unstructured protocol documents through a large language model, generating structured data and automatically generating test data, it solves the problem that existing tools are unable to adapt to new protocols and non-standardized documents, and realizes efficient and accurate communication protocol testing.

CN120675913APending Publication Date: 2025-09-19SICHUAN HONGMEI INTELLIGENT TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510965954.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-14
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing communication protocol parsing tools only support the parsing of known protocols and cannot adapt to new protocols or non-standardized documents. Test data generation requires manual calculation of checksums, which makes it difficult to cover all situations. Manual calculation is prone to errors and time-consuming.

Method used

The system uses a large language model to parse unstructured protocol documents, identify fixed and variable fields, generate structured data, and automatically generate test data to cover boundary value, abnormal value, and random value scenarios. It dynamically calculates the checksum and fills it into the original message to form a complete test message and generate a standardized test data set.

Benefits of technology

It improves the accuracy and efficiency of communication protocol parsing, reduces manual intervention, improves test coverage and accuracy, supports multiple verification algorithms and document formats, and adapts to different protocol requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120675913A_ABST
    Figure CN120675913A_ABST
Patent Text Reader

Abstract

The invention discloses a communication protocol automatic analysis and test data generation method and system, and the method comprises the steps: analyzing an unstructured protocol document, recognizing a fixed field and a variable field in the document, and outputting structured data; automatically generating test data based on the structured data, dynamically calculating a checksum according to a specified check algorithm type in the structured data, and filling the checksum into the original message to form a complete test message; and generating a standardized test data set according to the complete test message. According to the method, manual intervention is not needed from document analysis to test data generation, the analysis efficiency is improved, and most protocol scenes are covered through the boundary value, the abnormal value and the orthogonal combination strategy. The method supports various document formats, data types and verification algorithms, adapts to protocol standards of different industries, facilitates problem positioning and regression testing through standardized output documents, and reduces the maintenance cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication protocol testing technology, and in particular to a method and system for automatic communication protocol parsing and test data generation. Background Art

[0002] A communication protocol is a set of rules and agreements adhered to by both communicating parties to ensure the correct transmission of data. Its core definition encompasses three elements: syntax, semantics, and timing. Common classifications include inter-system protocols, intra-system protocols, and network protocols. By standardizing data formats, connection methods, and transmission timing, these protocols address key issues such as device interoperability, data accuracy, and communication efficiency, making them an indispensable component of modern communication systems.

[0003] Communication protocol parsing is the process of extracting, translating, and verifying specific protocol fields within communication data. Its core goal is to transform raw bit streams into understandable information. The parsing process typically includes data capture, protocol identification, field extraction, and semantic verification. Common tools include Wireshark and Scapy.

[0004] However, existing tools, such as Wireshark, only support parsing known protocols and are unable to adapt to new protocols or non-standardized documents. Test data generation requires manual checksum calculation, which is difficult to cover all cases, is error-prone, and time-consuming. Summary of the Invention

[0005] To solve the problem that existing communication protocol parsing tools only support parsing of known protocols and cannot adapt to new protocols or non-standardized documents, test data generation requires manual calculation of checksums, which is difficult to cover all situations, and manual calculation is prone to errors and time-consuming.

[0006] The first aspect of the present application provides a method for automatic parsing of a communication protocol and generating test data, comprising the steps of:

[0007] Parse unstructured protocol documents using a large language model, identify fixed and variable fields in the document, and output structured data, where the structured data includes field classification, value rules, and protocol metadata;

[0008] Based on the structured data, test data is automatically generated, where the test data covers boundary value, abnormal value and random value scenarios, and the original message is output in hexadecimal format;

[0009] Dynamically calculating a checksum according to the checksum algorithm type specified in the structured data, and filling the checksum into the original message to form a complete test message;

[0010] A standardized test data set is generated according to the complete test message, wherein the test data set includes the complete test message, field value descriptions, and checksum calculation details.

[0011] In a feasible implementation, the step of parsing the unstructured protocol document using a large language model includes:

[0012] Use OCR technology to extract text and table content from PDF or Word documents;

[0013] Semantic analysis is performed through a large language model based on the Transformer architecture to identify the fixed values ​​of the fixed fields and the data types, value ranges, and constraints of the variable fields.

[0014] In a feasible implementation, the step of automatically generating test data based on the structured data includes:

[0015] Distinguishing between decimal and binary values ​​for the variable field;

[0016] For the decimal value, boundary value analysis is used to generate a min value, a max value, and a ±1 out-of-bounds value, and equivalence class division is used to generate an intermediate value;

[0017] For the binary values, when the values ​​are not mutually exclusive, all 0s or all 1s are generated; when the values ​​are mutually exclusive, 8 combinations are generated with each position being 1 and the rest being 0s;

[0018] Adopting abnormal combination strategies to generate conflicting values ​​that violate the protocol logic;

[0019] The test data are combined using an orthogonal test combination algorithm to ensure that each value is covered at least once.

[0020] In a feasible implementation, the step of dynamically calculating the checksum according to the checksum algorithm type specified in the structured data includes:

[0021] Dynamically load the CRC16 or XOR algorithm according to the check algorithm identifier, calculate the check bit and fill it into the original message.

[0022] In a feasible implementation, the step of generating a standardized test data set according to the complete test message includes:

[0023] Formatting the complete test message into a use case format, wherein the use case format includes: a use case name, the original message in hexadecimal format, field value descriptions, and checksum calculation details, wherein the use case name is a unique identifier for identifying the test scenario;

[0024] The field value description is matched one-to-one with the byte content of the original message by position.

[0025] Another aspect of the present application provides a communication protocol automatic parsing and test data generation system, the system being used to implement any of the above-mentioned communication protocol automatic parsing and test data generation methods, comprising: a protocol parsing and structured data output module, a dynamic test data generation module, an intelligent checksum calculation module, and a system output module, wherein the protocol parsing and structured data output module, the dynamic test data generation module, the intelligent checksum calculation module, and the system output module are communicatively connected in sequence;

[0026] The protocol parsing and structured data output module is configured to input an unstructured protocol document, identify fixed fields and variable fields through an artificial intelligence model, and output structured data;

[0027] The dynamic test data generation module is configured to receive the structured data, automatically generate test data covering boundary values, abnormal values ​​and random values, and output hexadecimal original messages;

[0028] The intelligent checksum calculation module is configured to dynamically calculate a checksum based on a checksum algorithm type in the structured data and fill it into the original message to form a complete test message;

[0029] The system output module is configured to generate a standardized test data set according to the complete test message, where the standardized test data set includes the complete test message, field value descriptions, and checksum details.

[0030] In a feasible implementation, the protocol parsing and structured data output module includes: an OCR unit and a large language model unit;

[0031] The OCR unit is used to extract text and table content from PDF or Word documents;

[0032] The large language model unit is used to perform semantic analysis based on the Transformer architecture and output structured data in JSON format.

[0033] In a feasible implementation, the dynamic test data generation module includes: a value generation unit and a combination algorithm unit;

[0034] The value generating unit is used to generate boundary values, abnormal values ​​and random values;

[0035] The combination algorithm unit combines test data using an orthogonal test combination algorithm.

[0036] In a feasible implementation, the intelligent verification and calculation module includes: an algorithm loading unit and a calculation unit;

[0037] The algorithm loading unit dynamically loads CRC16 or XOR algorithm;

[0038] In a feasible implementation, the system output module includes: a typesetting unit;

[0039] The typesetting unit is configured to:

[0040] Generate a use case name for each of the test data sets;

[0041] Converting the complete test message into a hexadecimal original message format;

[0042] Generate a field value description that corresponds one-to-one with the original message byte content by position;

[0043] Additional checksum calculation details, indicating the algorithm type and results;

[0044] Output the standardized test dataset.

[0045] The communication protocol automated parsing and test data generation method and system provided in this application deeply integrates a large language model with protocol testing. It breaks through the limitations of regular matching or manual parsing, and realizes intelligent parsing of unstructured protocol documents through the semantic understanding ability of a large language model. It also supports the automated processing of complex scenarios such as mixed Chinese or table layouts, industry term abbreviations, etc. The accuracy of fixed field recognition is greatly improved, and the efficiency is also improved. It reduces the repetitive work of test engineers and improves the value of personnel work. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] The accompanying drawings are incorporated into and constitute a part of this specification, illustrate embodiments consistent with the implementation of the present invention, and together with the description, serve to explain the principles of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the implementation of the present invention. For those skilled in the art, other drawings can be derived from these drawings without inventive effort.

[0047] Figure 1 This is a flow chart of a method for automatic communication protocol parsing and test data generation, as shown in an exemplary embodiment of the present application;

[0048] Figure 2 is a schematic diagram of a process for automatically generating test data according to an exemplary embodiment of the present application;

[0049] Figure 3 It is an architectural diagram of a communication protocol automatic parsing and test data generation system shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0050] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the present invention will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to provide a thorough understanding of the implementation of the example embodiments of the present invention.

[0051] Current communication protocol analysis faces two core issues: First, tools like Wireshark only support the analysis of known protocols. When dealing with proprietary or emerging protocols, they lack a signature library and can only display raw data, requiring manual reverse engineering, which is time-consuming and relies on expert experience. Second, checksum calculations are highly manual, and due to the significant differences in algorithms between different protocols, manual calculations are prone to errors and lack coverage for all test scenarios, resulting in low test efficiency and time-consuming troubleshooting. These two issues severely restrict the flexibility of protocol analysis and test reliability.

[0052] To solve the above problems, refer to Figure 1 As shown, an embodiment of the present application provides a method for automatic communication protocol parsing and test data generation, the steps comprising:

[0053] S100: Parse unstructured protocol documents using a large language model, identify fixed fields and variable fields in the document, and output structured data, where the structured data includes field classification, value selection rules, and protocol metadata.

[0054] Specifically, an unstructured protocol document (such as a PDF, Word, or text file) is input and semantically analyzed using a large language model (such as GPT-4 or ERNIE). Based on the Transformer architecture, the model classifies the field descriptions in the document, distinguishing between fixed and variable fields. Fixed fields include protocol headers and fixed identifiers, while variable fields include data length and payload.

[0055] This step overcomes the limitations of traditional expression parsing, adapting to complex document structures and accurately extracting field value rules and constraints. Traditional manual parsing of protocol documents is inefficient and error-prone, especially when dealing with unstructured documents, making it difficult to extract key information. This step automates parsing through semantic understanding using a large language model, improving accuracy and efficiency.

[0056] S200: Based on structured data, test data is automatically generated. The test data covers boundary value, abnormal value and random value scenarios, and the original message is output in hexadecimal format.

[0057] The parsing results are output in JSON format, including field classification (fixed / variable), value rules (such as data type and range), and protocol metadata (such as protocol version and validation algorithm type). This step provides standardized input for subsequent test data generation, ensuring that field rules can be directly processed by the program.

[0058] S300: dynamically calculating a checksum according to the checksum algorithm type specified in the structured data, and filling the checksum into the original message to form a complete test message.

[0059] The generated test data is assembled into hexadecimal raw messages according to the protocol format to ensure that the test cases cover key scenarios, improve test coverage, and reduce the workload of manually designing use cases.

[0060] S400: Generate a standardized test data set based on the complete test message. The test data set includes the complete test message, field value descriptions, and checksum calculation details.

[0061] Specifically, the checksum of the original message is dynamically calculated based on the checksum algorithm specified in the structured data (such as CRC16). For example, if the original message is AA55040000000000, the CRC16 checksum is calculated to be B4C7, and B4C7 is recorded in the test data set. This automatically adapts to the checksum requirements of different protocols, avoids manual calculation errors, and improves message legitimacy.

[0062] As can be seen from the above steps, this embodiment of the application replaces manual parsing with a large language model, improving efficiency while reducing errors. The method automatically generates boundary values, outliers, and random values ​​to ensure the integrity of test cases and supports multiple verification algorithms to adapt to different protocol requirements. The output test dataset uses a unified test data format to facilitate team collaboration and automated test execution.

[0063] In some embodiments of the present application, in step S100, the step of parsing the unstructured protocol document using the large language model specifically includes the following steps:

[0064] S110: Uses OCR technology to extract text and table content from PDF or Word documents.

[0065] For PDF or Word documents, first use OCR technology (such as Tesseract or Adobe OCR) to extract text and table content. For example, when a table in an agreement document describes field rules, OCR converts the table into structured text.

[0066] By processing agreement documents in non-text formats (such as scanned documents or encrypted PDFs), the content can be analyzed by subsequent models.

[0067] S120: Perform semantic analysis using a large language model based on the Transformer architecture to identify the fixed values ​​of fixed fields and the data types, value ranges, and constraints of variable fields.

[0068] Input the OCR-extracted text into a large language model based on the Transformer architecture (such as BERT or GPT-3.5). The model can parse the fields through the following steps:

[0069] Fixed field identification: Mark fields (such as headers) whose descriptions contain keywords such as "fixed" and "default value".

[0070] Variable field analysis: Extract data types (such as uint16), value ranges (such as 1-1024), and constraints (such as "must be an even number").

[0071] This step accurately extracts field rules through semantic understanding, solving the problem that traditional keyword matching cannot handle complex descriptions.

[0072] In this example, OCR technology expands the method's support for scanned and encrypted documents. A large language model is employed to understand field meanings through context, reducing misinterpretations. It also automatically identifies implicit rules, further improving the accuracy of test data generation.

[0073] In some embodiments of the present application, reference Figure 2 As shown, in step S200, the step of automatically generating test data based on structured data further includes:

[0074] S210: Distinguish between decimal and binary values ​​for variable fields.

[0075] Specifically, according to the datatype field in the structured data, decimal and binary variable fields are distinguished, and test data generation strategies are customized for different types of fields.

[0076] S220: For the decimal value, boundary value analysis is used to generate the min value, the max value and the ±1 out-of-bounds value, and equivalence class division is performed to generate the intermediate value.

[0077] For example, it generates minimum values ​​(1), maximum values ​​(1024), and out-of-range values ​​(0, 1025), and generates intermediate values ​​within the legal range (such as 512). Exception values ​​are non-numeric inputs, such as the string "abc," or out-of-range values, such as -1.

[0078] This step covers typical error scenarios for decimal fields and verifies the protocol's fault tolerance for abnormal input.

[0079] S230: For binary values, when the values ​​are not mutually exclusive, generate all 0s or all 1s; when the values ​​are mutually exclusive, generate 8 combinations in which each position is 1 and the rest are 0s.

[0080] Specifically, non-mutually exclusive bits generate all 0s (0x00) and all 1s (0xFF), while mutually exclusive bits generate combinations where each bit is set to 1 (e.g., 0x01, 0x02, ..., 0x80). This step can test the independent function and combinational logic of each bit in the binary field.

[0081] S240: Adopting an abnormal combination strategy to generate conflicting values ​​that violate the protocol logic.

[0082] Setting mutually exclusive binary bits (such as 0x03) and conflicting values ​​such as mismatched decimal and binary field lengths can further verify the protocol's ability to handle illegal combinations.

[0083] S250: Use the orthogonal test combination algorithm to combine the test data to ensure that each value is covered at least once.

[0084] Use an orthogonal array to combine test data, ensuring that every value for each field appears at least once. For example, for three fields (A, B, C), generate nine test cases to cover all combinations. This achieves high coverage with a limited number of test cases, balancing test efficiency and effectiveness.

[0085] In this embodiment, by distinguishing between decimal and binary fields, the relevance of test data is further improved. Furthermore, by proactively generating illegal combinations, protocol logic vulnerabilities can be exposed, facilitating their timely discovery and correction. Orthogonal testing reduces redundant use cases, improving test efficiency.

[0086] In some embodiments of the present application, in step S300, the checksum of the type of checksum algorithm specified in the structured data is dynamically calculated, including:

[0087] S310: Dynamically load the CRC16 or XOR algorithm according to the check algorithm identifier, calculate the check digit, and fill it into the original message.

[0088] This step is to dynamically load the corresponding algorithm class through the reflection mechanism based on the verification algorithm type field in the structured data.

[0089] The CRC16 algorithm is a cyclic redundancy check (CRC) algorithm used to detect errors in data transmission or storage. It verifies data integrity by calculating the CRC value (a 16-bit checksum) of the data. The CRC16 algorithm is fast and suitable for real-time data transmission scenarios. It can detect most common transmission errors, such as single-bit errors, double-bit errors, odd-number-of-bit errors, and burst errors.

[0090] The XOR algorithm is a basic bitwise operation that performs a bitwise exclusive OR operation on two binary numbers. In the field of data verification and encryption, the XOR algorithm is often used for simple data verification and encryption operations. The XOR algorithm is also simple to implement and has fast calculation speed.

[0091] This embodiment dynamically loads CRC16 or XOR algorithm calculation according to the check algorithm identifier to ensure that the checksum calculation is consistent with the protocol specification.

[0092] Finally, the calculated checksum is converted into a hexadecimal string and appended to the end of the original message to generate a complete message that complies with the protocol specification, ensuring that both communicating parties can correctly verify data integrity.

[0093] This embodiment supports multi-protocol verification requirements through a dynamic loading mechanism, strictly follows the polynomials and initial values ​​defined by the protocol, avoids manual implementation errors, and seamlessly connects the check bit filling with test data generation to reduce manual intervention.

[0094] In some embodiments of the present application, in step S400, the step of generating a standardized test data set according to a complete test message includes:

[0095] S410: Format the complete test message into a use case format. The use case format includes: the use case name, the original message in hexadecimal format, field value descriptions, and checksum calculation details. The use case name is a unique identifier that identifies the test scenario. This step provides a structured test document to facilitate testers to quickly understand the purpose of the use case.

[0096] S420: Match the field value descriptions with the byte contents of the original message one by one by position. This can help locate message parsing errors and improve debugging efficiency.

[0097] This embodiment specifies a use case format, ensuring that each case contains complete context, facilitating problem reproduction. Furthermore, the structured presentation of field descriptions and messages reduces manual review costs. Furthermore, the formatted output can be directly imported into the test framework for automated execution.

[0098] In another aspect of the present application, a communication protocol automatic parsing and test data generation system is provided, which is used to implement the communication protocol automatic parsing and test data generation method provided in the above embodiment. The system includes four modules: protocol parsing and structured data output module, dynamic test data generation module, intelligent checksum calculation module, and system output module. Figure 3 As shown in the figure, the system architecture starts with a protocol parser module that receives unstructured document input; a dynamic test data generation module that processes structured data; an intelligent checksum calculation module that adds check digits; and a system output module that generates standardized data sets. This architecture ensures high efficiency and scalability.

[0099] Among them, the protocol parsing and structured data output module is used to input unstructured documents and output corresponding JSON format structured data. The JSON format structured data includes field classification, value rules, protocol metadata, etc., and the parsing results are passed to the dynamic test data generation module through a JSON file.

[0100] Specifically, in some embodiments, the protocol parsing and structured data output module includes: an OCR unit and a large language model unit.

[0101] The OCR unit is used to extract text and table content from PDF or Word documents. It can also convert scanned or encrypted documents into analyzable text streams.

[0102] The large language model unit performs semantic analysis based on the Transformer architecture and outputs structured data in JSON format. Specifically, the large language model unit receives the text stream output by OCR through the API interface, analyzes the text stream, extracts field rules, and converts them into JSON.

[0103] The protocol parsing and structured data output module uses multimodal deep learning technology to achieve intelligent parsing of protocol documents. After extracting text and table content from PDF or Word documents using OCR technology, semantic analysis is performed using a pre-trained large language model based on the Transformer architecture (such as DeepSeek-V3). The model uses an attention mechanism to identify fixed fields in the document (such as protocol headers and reserved bits) and mark their fixed values. It also analyzes the data type, value range, and constraints of variable fields. The parsing results are converted into a standard JSON format through post-processing, including field classification, value selection rules, and protocol metadata, and output to a visualization interface for manual verification.

[0104] The following provides an operation example of the protocol parsing and structured data output module, where fixed_headers represents fixed bits, data_fields represents variable data bits, and type:bitfield represents bit-level operations.

[0105]

[0106]

[0107] The protocol parsing and structured data output module of this embodiment supports non-electronic documents through the OCR unit, expands the scope of application of the system, understands complex descriptions through a large language model, reduces manual verification costs, and uses JSON to output a unified format for easy processing by subsequent modules.

[0108] The dynamic test data generation module is used to receive structured data, generate test data and assemble it into hexadecimal original messages, and pass the generated original messages to the intelligent checksum calculation module through memory sharing.

[0109] In some embodiments, the dynamic test data generation module includes: a value generation unit and a combination algorithm unit.

[0110] The value generation unit is used to generate boundary values, outliers, and random values. Specifically, NumPy can be used to generate random values, using Latin hypercube sampling to ensure uniform distribution. Custom functions can be integrated to generate out-of-bounds values ​​(such as min-1 and max+1). The value generation unit also generates test data for decimal and binary fields.

[0111] The combination algorithm unit uses an orthogonal test combination algorithm to combine test data, and can combine the generated test data into a use case set.

[0112] The dynamic test data generation module generates comprehensive test cases based on the orthogonal analysis method. The system first parses the field definitions in the structured data in JSON format, distinguishes between decimal and binary for variable fields, and uses boundary value analysis, equivalence class partitioning, and abnormal combination strategies to generate a set of candidate values. For each data bit, when it is a decimal value, according to the value range, the boundary value and an intermediate value are taken as the test data range. When it is a binary value, if it is not mutually exclusive, it takes two values ​​of all 0 and all 1. If it is mutually exclusive, that is, it can be 0 at the same time, but not 1 at the same time, then 8 types of data, that is, 8-bit binary numbers, are taken, each bit is 1 alone, and the rest are 0.

[0113] The dynamic test data generation module then uses a combinatorial testing algorithm based on orthogonal testing to combine all the data use cases. This orthogonal testing method ensures that every value is covered at least once, improving test efficiency while ensuring test quality. The final output test data set includes a variety of test scenarios, including normal values, boundary values, and outliers. Each use case is accompanied by detailed field value descriptions.

[0114] The following is a partial example for demonstration:

[0115] Description: DATA3:2+DATA5:-18+DATA12 are all 0

[0116] Message (hexadecimal)

[0117] 0x55,0xAA,0x01, #Fixed header + main protocol command

[0118] 0x66,0x00,0x52, #DATA3(2℃),DATA4(0),DATA5(-18℃)

[0119] 0x0F,0x0A,0x0A, #DATA6(0.5),DATA7(0.0),DATA8(0.0)

[0120] 0x00,0x00,0x10, #DATA9(xxxxbit4=1),DATA10,DATA11

[0121] 0x00,0x00,0x00, #DATA12,DATA13

[0122] 0x00,0x00,0x00, #DATA14-DATA16

[0123] 0x00,0x00,0x00, #DATA17-DATA19

[0124] 0x00,0x00,0x03, #DATA20-DATA22 (strong signal)

[0125] Description: DATA3:8+DATA5:-32+DATA12 are all 1

[0126] Message (hexadecimal)

[0127] 0x55,0xAA,0x01, #Fixed header + main protocol command

[0128] 0x66,0x00,0x52, #DATA3(2℃),DATA4(0),DATA5(-18℃)

[0129] 0x0F,0x0A,0x0A, #DATA6(0.5),DATA7(0.0),DATA8(0.0)

[0130] 0x00,0x00,0x10, #DATA9(xxxxbit4=1),DATA10,DATA11

[0131] 0xFF,0x00,0x00, #DATA12,DATA13

[0132] 0x00,0x00,0x00, #DATA14-DATA16

[0133] 0x00,0x00,0x00, #DATA17-DATA19

[0134] 0x00,0x00,0x03, #DATA20-DATA22 (strong signal)

[0135] The dynamic test data generation module can cover all key scenarios through the value generation unit, thereby improving test coverage; by combining algorithm units, orthogonal experiments are used to reduce the number of use cases and balance efficiency and effectiveness.

[0136] The intelligent checksum calculation module is used to dynamically calculate the checksum based on the checksum algorithm type in the structured data and fill it into the original message to form a complete test message.

[0137] In some embodiments, the intelligent checksum calculation module includes: an algorithm loading unit and a calculation unit.

[0138] The algorithm loading unit dynamically loads the CRC16 algorithm or the XOR algorithm through Python's reflection mechanism. The calculation unit uses the CRC16 algorithm to optimize calculation speed using a table lookup method, or uses the XOR algorithm to achieve efficient calculation through bit operations to calculate the check digits and fill the message.

[0139] The intelligent checksum calculation module uses the dynamic loading mechanism of the algorithm loading unit to support the rapid expansion of new algorithms, so that errors in the implementation of a single algorithm do not affect the operation of other algorithms. The calculation unit also uses bit operations to optimize the checksum calculation speed.

[0140] The system output module is used to generate a standardized test data set based on a complete test message. The standardized test data set includes a complete test message, field value descriptions, and checksum details.

[0141] In some embodiments, the system output module includes a typeset unit.

[0142] The typesetting unit is used to generate a use case name for each test data set (such as MODBUS-RTU_TC001), convert the complete test message into the original hexadecimal message format, and then generate a field value description that corresponds to the original message byte content by position. Finally, it adds the checksum calculation details and describes the algorithm type and results.

[0143] An example is:

[0144] Use case name: MODBUS-RTU_TC001.

[0145] Message: AABB 010000FF 008B84.

[0146] Field description: protocol header (fixed: AABB), function code (01), data field (0000FF00), CRC16 (8B84).

[0147] Through the typesetting unit, the system output module can generate test documents that are ready for publication, supporting version control and sharing. Standardized templates ensure consistent document structure across all use cases. Key information is presented in tables or code blocks, facilitating manual review.

[0148] According to the above embodiments, the method and system for automated communication protocol parsing and test data generation provided by this application are as follows: the user uploads a protocol document in PDF or Word format to the protocol parsing and structured data output module. The system extracts field rules and generates structured data through OCR and a large language model. The dynamic test data generation module generates test cases covering boundary values ​​and outliers based on the rules. The intelligent checksum calculation module calculates the checksum. Finally, the system output module generates a standardized document containing the complete message, field descriptions, and checksum details.

[0149] The method and system for automated communication protocol parsing and test data generation provided in this application eliminates the need for manual intervention from document parsing to test data generation, improving parsing efficiency. By leveraging boundary value, outlier, and orthogonal combination strategies, they cover most protocol scenarios. They also support a variety of document formats, data types, and validation algorithms, adapting to different industry protocol standards. Standardized output documents facilitate problem location and regression testing, reducing maintenance costs.

[0150] This application solves the technical pain points of low parsing efficiency, incomplete use case design, and error-prone verification calculations in traditional protocol testing by combining large language model technology with automated algorithms, providing an efficient and reliable solution for communication protocol testing.

[0151] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the disclosure of the specification and examples. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in this disclosure.

Claims

1. A method for automatic analysis of communication protocols and generation of test data, characterized in that: Including steps: Parse unstructured protocol documents using a large language model, identify fixed and variable fields in the document, and output structured data, where the structured data includes field classification, value rules, and protocol metadata; Based on the structured data, test data is automatically generated, where the test data covers boundary value, abnormal value and random value scenarios, and the original message is output in hexadecimal format; Dynamically calculating a checksum according to the checksum algorithm type specified in the structured data, and filling the checksum into the original message to form a complete test message; A standardized test data set is generated according to the complete test message, wherein the test data set includes the complete test message, field value descriptions, and checksum calculation details.

2. The method for automatic communication protocol analysis and test data generation according to claim 1, characterized in that: The step of parsing the unstructured protocol document using the large language model includes: Use OCR technology to extract text and table content from PDF or Word documents; Semantic analysis is performed through a large language model based on the Transformer architecture to identify the fixed values ​​of the fixed fields and the data types, value ranges, and constraints of the variable fields.

3. The method for automatic communication protocol analysis and test data generation according to claim 1, characterized in that: The step of automatically generating test data based on the structured data includes: Distinguishing between decimal and binary values ​​for the variable field; For the decimal value, boundary value analysis is used to generate a min value, a max value, and a ±1 out-of-bounds value, and equivalence class division is used to generate an intermediate value; For the binary values, when the values ​​are not mutually exclusive, all 0s or all 1s are generated; when the values ​​are mutually exclusive, 8 combinations are generated with each position being 1 and the rest being 0s; Adopting abnormal combination strategies to generate conflicting values ​​that violate the protocol logic; The test data are combined using an orthogonal test combination algorithm to ensure that each value is covered at least once.

4. The method for automatic communication protocol analysis and test data generation according to claim 1, characterized in that: The step of dynamically calculating the checksum according to the check algorithm type specified in the structured data includes: Dynamically load the CRC16 or XOR algorithm according to the check algorithm identifier, calculate the check bit and fill it into the original message.

5. The method for automatic communication protocol analysis and test data generation according to claim 1, characterized in that: The step of generating a standardized test data set according to the complete test message includes: Formatting the complete test message into a use case format, wherein the use case format includes: a use case name, the original message in hexadecimal format, field value descriptions, and checksum calculation details, wherein the use case name is a unique identifier for identifying the test scenario; The field value description is matched one-to-one with the byte content of the original message by position.

6. A communication protocol automated parsing and test data generation system, the system being used to implement the communication protocol automated parsing and test data generation method according to any one of claims 1 to 5, characterized in that: include: A protocol parsing and structured data output module, a dynamic test data generation module, an intelligent checksum calculation module, and a system output module, wherein the protocol parsing and structured data output module, the dynamic test data generation module, the intelligent checksum calculation module, and the system output module are communicatively connected in sequence; The protocol parsing and structured data output module is configured to input an unstructured protocol document, identify fixed fields and variable fields through an artificial intelligence model, and output structured data; The dynamic test data generation module is configured to receive the structured data, automatically generate test data covering boundary values, abnormal values ​​and random values, and output hexadecimal original messages; The intelligent checksum calculation module is configured to dynamically calculate a checksum based on a checksum algorithm type in the structured data and fill it into the original message to form a complete test message; The system output module is configured to generate a standardized test data set according to the complete test message, where the standardized test data set includes the complete test message, field value descriptions, and checksum details.

7. The communication protocol automatic parsing and test data generation system according to claim 6, characterized in that: The protocol parsing and structured data output module includes: an OCR unit and a large language model unit; The OCR unit is used to extract text and table content from PDF or Word documents; The large language model unit is used to perform semantic analysis based on the Transformer architecture and output structured data in JSON format.

8. The communication protocol automatic parsing and test data generation system according to claim 7, characterized in that: The dynamic test data generation module includes: a value generation unit and a combination algorithm unit; The value generating unit is used to generate boundary values, abnormal values ​​and random values; The combination algorithm unit combines test data using an orthogonal test combination algorithm.

9. The communication protocol automatic parsing and test data generation system according to claim 6, characterized in that: The intelligent verification and calculation module includes: an algorithm loading unit and a calculation unit; The algorithm loading unit dynamically loads CRC16 or XOR algorithm; The calculation unit calculates the check digit and fills the message.

10. The communication protocol automatic parsing and test data generation system according to claim 6, characterized in that: The system output module includes: a typesetting unit; The typesetting unit is configured to: Generate a use case name for each of the test data sets; Converting the complete test message into a hexadecimal original message format; Generate a field value description that corresponds one-to-one with the original message byte content by position; Additional checksum calculation details, indicating the algorithm type and results; Output the standardized test dataset.

Citation Information

Cited By

  • Protocol conformance testing method and system based on artificial intelligence

    CN121357064A

  • Method for testing Internet of Vehicles protocol

    CN121619267A

  • A test method of a vehicle networking protocol

    CN121619267B