Intelligent protocol conversion method and device, electronic equipment and storage medium
By building a protocol general knowledge graph and large language model, the benchmark conversion program is automatically generated, which solves the problems of poor flexibility and low reliability of protocol conversion in the existing technology, and achieves efficient and accurate multi-protocol interoperability.
Patent Information
- Application Number
- CN202510825244.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-09-05
AI Technical Summary
The existing protocol conversion technology has poor flexibility, high workload and low reliability, making it difficult to adapt to protocol standards changes and achieve efficient and accurate interoperability between different protocols.
By building a protocol general knowledge graph, combining a large language model, the benchmark conversion program is automatically generated, and the customized reconstruction of the protocol conversion logic is realized, including the fusion of the knowledge graph pattern layer and the data layer, and a general knowledge expression system that supports interoperability between multiple protocols is generated.
Improves the efficiency, scalability and accuracy of protocol conversion, reduces manual intervention, and enhances the automation and controllability of conversion programs.
Smart Images

Figure CN120602571A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer and artificial intelligence technology, and in particular to a protocol intelligent conversion method, device, electronic device and storage medium. Background Art
[0002] Currently, with the rapid development of the information society, the scale and complexity of information exchange between various systems and devices has increased significantly. Communication protocols between information systems, network devices, and application platforms are becoming increasingly diverse, resulting in a multitude of standards and difficulties in standardization. These protocols often utilize different data formats, message specifications, and communication mechanisms. Due to historical evolution, vendor differences, and the specific requirements of application scenarios, information between different protocols cannot be directly communicated, resulting in numerous "information silos" and significantly hindering the effective sharing and utilization of data resources.
[0003] Protocol conversion is an important technical means to achieve information interoperability between different protocols or message standards. It involves converting the message format and data content of one protocol into the corresponding format of another protocol to achieve smooth data exchange between heterogeneous systems.
[0004] Existing protocol conversion technologies are mostly implemented in a pre-defined manner, that is, based on manual analysis of the correspondence between protocol fields, specific code programs are written to implement message conversion between different protocols. This traditional method has many drawbacks:
[0005] (1) Poor flexibility: When the protocol standard changes or a new protocol standard emerges, the conversion program must be manually modified;
[0006] (2) Heavy workload: Manually writing conversion programs is labor-intensive, and the update cost is high and delayed;
[0007] (3) Low reliability: Manually written conversion programs are easily affected by human factors, which leads to errors in the conversion process. Summary of the Invention
[0008] The main purpose of the embodiments of the present invention is to provide a protocol intelligent conversion method, device, electronic device and storage medium, which improves the efficiency, scalability and accuracy of conversion between protocols.
[0009] One aspect of the present invention provides a protocol intelligent conversion method, comprising:
[0010] Determine the protocol common knowledge base based on the protocol standard document;
[0011] According to the protocol standard document, determine the knowledge graph model layer and the knowledge graph data layer, perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer to obtain the knowledge graph of the general domain of the protocol;
[0012] Determining a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to represent a general process of protocol conversion;
[0013] Reconstructing the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program;
[0014] The source protocol is converted by the second reference conversion program to obtain a protocol conversion result.
[0015] According to the protocol intelligent conversion method, a protocol general knowledge base is determined based on the protocol standard document to obtain:
[0016] Collect protocol standard documents, which include structured, semi-structured and unstructured data;
[0017] According to the protocol type, the protocol standard documents are stored in a document database to obtain a protocol general knowledge base, which includes professional terms, basic definitions, rules and relationships between protocols.
[0018] According to the protocol intelligent conversion method, determining the knowledge graph model layer includes:
[0019] Determine the hierarchical relationship of the protocol ontology class based on the core class and its subclasses, where the core class includes protocol functions, message standards, payloads, fields, and field values;
[0020] The object attributes and data attributes of the class are determined according to the hierarchical relationship of the protocol ontology class. The knowledge graph pattern layer is obtained according to the protocol ontology class, the object attributes and the data attributes of the class. The knowledge graph pattern layer is used to characterize the relationship between entity objects of different classes.
[0021] According to the protocol intelligent conversion method, determining the knowledge graph data layer includes:
[0022] Entities are extracted from the protocol general knowledge base, and the knowledge graph model layer is filled with entities to obtain a knowledge graph data layer.
[0023] According to the protocol intelligent conversion method, the knowledge graph model layer and the knowledge graph data layer are fused to obtain a knowledge graph for the general domain of the protocol, including:
[0024] The knowledge graph pattern layer and the knowledge graph data layer are fused using anchor point alignment, graph merging and extended support; the anchor point alignment maps similar functional protocols in different protocols to common semantic nodes; the graph merging merges repeated or semantically overlapping common semantic nodes; the extended support integrates new protocols according to the pattern structure of existing protocols.
[0025] According to the protocol intelligent conversion method, a first benchmark conversion program is determined based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to characterize the general process of protocol conversion, including:
[0026] Obtaining the source protocol and the target protocol, parsing the structure information of the source protocol and the target protocol, wherein the structure information includes structure abstract data, protocol fields, and protocol types;
[0027] Perform field mapping on the protocol fields of the source protocol and the target protocol, where field mapping includes structure mapping, field name alignment, data type matching, and conversion rule identification;
[0028] Generate data mapping and processing rules based on the protocol fields of the source protocol and the target protocol, where the data mapping and processing rules include type conversion rules, encoding / decoding rules, field combination and splitting rules, and conditional conversion rules;
[0029] Performing logic conversion from the source protocol to the target protocol message format, where the conversion logic includes executing the generated conversion rules to implement the target protocol data structure output, missing field completion, error handling and data verification, and conversion log recording;
[0030] An input-output comparison mechanism and a protocol validity check are performed on the conversion result from the source protocol to the target protocol to obtain a first benchmark conversion program.
[0031] According to the protocol intelligent conversion method, the first benchmark conversion program is reconstructed using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program, including:
[0032] The protocol general knowledge base and the protocol general domain knowledge graph are used as knowledge support for retrieval enhancement generation, and the first benchmark conversion program is used as an example to perform reconstruction processing of the prompt word project to obtain a second benchmark conversion program.
[0033] Another aspect of an embodiment of the present invention provides a protocol intelligent conversion device, including:
[0034] The first module is used to determine a protocol general knowledge base according to the protocol standard document;
[0035] The second module is used to determine the knowledge graph model layer and the knowledge graph data layer according to the protocol standard document, and perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer to obtain the knowledge graph of the general domain of the protocol;
[0036] A third module is configured to determine a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to characterize a general process of protocol conversion;
[0037] A fourth module is configured to reconstruct the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program;
[0038] The fifth module is used to perform conversion processing on the source protocol through the second benchmark conversion program to obtain a protocol conversion result.
[0039] Another aspect of an embodiment of the present invention provides an electronic device, including a processor and a memory;
[0040] The memory is used to store programs;
[0041] The processor executes the program to implement the method described above.
[0042] Embodiments of the present invention further disclose a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the method described above.
[0043] The beneficial effects of the present invention are as follows: a top-down approach is adopted according to the protocol document to execute the filling of the mode layer and the data layer and the graph fusion to obtain the knowledge graph of the general domain of the protocol; through entity extraction and graph fusion, the semantic barriers between different protocols are broken through, and a general knowledge expression system supporting interoperability between multiple protocols is established; by analyzing the common processes in the protocol conversion tasks and combining the knowledge graph with the protocol semantic knowledge deposited in the knowledge base, a benchmark conversion program structure framework with universality, scalability and reconfigurability is obtained, which enhances the automation, accuracy and controllability of the conversion program generation; by integrating RAG technology and prompt word engineering, the constructed protocol knowledge base, knowledge graph and benchmark conversion program are used to realize automatic customized reconstruction of the protocol conversion logic, thereby improving the efficiency, scalability and accuracy of conversion between protocols. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:
[0045] Figure 1 It is a flowchart of the protocol intelligent conversion method according to an embodiment of the present invention.
[0046] Figure 2 Schematic diagram of constructing a universal knowledge base according to an embodiment of the present invention.
[0047] Figure 3 This is the protocol general domain knowledge graph construction process of an embodiment of the present invention.
[0048] Figure 4 It is a hierarchical relationship diagram of the ontology class in an embodiment of the present invention.
[0049] Figure 5 Schematic diagram of the protocol ontology architecture of an embodiment of the present invention.
[0050] Figure 6 This is a schematic diagram of the CoAP protocol resource acquisition function message standard according to an embodiment of the present invention.
[0051] Figure 7 This is a standard diagram of the HTTP protocol resource acquisition function message in an embodiment of the present invention.
[0052] Figure 8 This is a schematic diagram of the knowledge graph fusion of an embodiment of the present invention.
[0053] Figure 9 2 is a schematic diagram of a benchmark conversion procedure according to an embodiment of the present invention.
[0054] Figure 10 2 is a schematic diagram of the overall protocol intelligent conversion analysis framework of an embodiment of the present invention.
[0055] Figure 11 Schematic diagram of a protocol intelligent conversion device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. In the subsequent description, suffixes such as "module," "component," or "unit" used to represent elements are used solely to facilitate the description of the present invention and have no specific meaning in themselves. Therefore, "module," "component," or "unit" may be used interchangeably. "First," "second," and the like are used solely to distinguish technical features and should not be construed as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features. In this subsequent description, the consecutive numbering of method steps is for ease of review and understanding. In conjunction with the overall technical solution of the present invention and the logical relationship between the various steps, adjusting the order of implementation of the steps does not affect the technical effects achieved by the technical solution of the present invention. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and should not be construed as limiting the present invention.
[0057] Explanation of terms:
[0058] LLM, Large Language Model, large language model.
[0059] JSON, JavaScript Object Notation, JavaScript object notation.
[0060] XML, eXtensible Markup Language, extensible markup language.
[0061] ASN.1, Abstract Syntax Notation One.
[0062] HTML, HyperText Markup Language, Hypertext Markup Language.
[0063] YMAL, YAML Ain't Markup Language, YAML is not a markup language (used for data serialization)
[0064] CoAP, Constrained Application Protocol, constrained application protocol.
[0065] HTTP, HyperText Transfer Protocol, Hypertext Transfer Protocol.
[0066] HTTPS, HyperText Transfer Protocol Secure, secure hypertext transfer protocol.
[0067] SNMP, Simple Network Management Protocol, Simple Network Management Protocol.
[0068] OPC UA, OPC Unified Architecture, an open platform communication protocol with unified architecture.
[0069] MQTT, Message Queuing Telemetry Transport, message queue telemetry transport protocol.
[0070] Modbus, Modbus, a serial communication protocol.
[0071] TCP, Transmission Control Protocol, Transmission Control Protocol.
[0072] UDP, User Datagram Protocol, User Datagram Protocol.
[0073] TLS, Transport Layer Security, Transport Layer Security Protocol.
[0074] DTLS, Datagram Transport Layer Security, Datagram Transport Layer Security Protocol.
[0075] RAG, Retrieval-Augmented Generation, retrieval-augmented generation.
[0076] refer to Figure 1 The protocol intelligent conversion method flow diagram shown includes but is not limited to steps S100 to S500:
[0077] S100: Determine a protocol general knowledge base according to the protocol standard document.
[0078] In some embodiments, protocol data is collected, where the protocol data includes structured, semi-structured, and unstructured data; the protocol data is stored in a document database according to the protocol type to obtain a general protocol knowledge base.
[0079] refer to Figure 2 The general knowledge base construction diagram shown in the figure is as follows: Figure 2As shown: Documents related to each protocol are collected, including structured (such as JSON, XML), semi-structured (such as HTML web pages, YAML) and unstructured data (such as PDF standard description documents), and then classified and organized according to protocol type. Document database storage is used to provide support for the design and customized reconstruction of benchmark conversion programs. The protocol general knowledge base mainly covers three types of core information: professional terminology, basic definitions and rules, and relationships between protocols.
[0080] In some embodiments, CoAP and HTTP are two application layer protocols, primarily used for data communication between devices. However, their design goals and application scenarios are different. Taking CoAP and HTTP protocols as examples, the core information in the knowledge base is shown in Tables 1 to 3 below:
[0081] Table 1 Professional terms
[0082]
[0083] Table 2 Basic definitions and rules
[0084]
[0085] Table 3 Relationship between protocols
[0086]
[0087]
[0088] S200, according to the protocol standard document, determine the knowledge graph model layer and the knowledge graph data layer, perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer, and obtain the protocol general domain knowledge graph.
[0089] refer to Figure 3 The protocol general domain knowledge graph construction process shown includes ontology learning (knowledge graph model layer), entity learning (knowledge graph data layer) and knowledge graph fusion.
[0090] In some embodiments, the logical structure of the protocol general domain knowledge graph consists of a schema layer and a data layer. The schema layer is the core layer of the knowledge graph, located above the data layer, and serves as the knowledge framework for constructing the entities and relationships of the knowledge graph. The data layer stores specific knowledge, using "entity-relationship-entity" triples and "entity-attribute-attribute value" entity and attribute value pairs as the basic representation of knowledge.
[0091] In some embodiments, the knowledge required for protocol conversion mostly comes from protocol-related documents, which requires high professionalism and accuracy of the relevant knowledge, and a knowledge graph is constructed in a top-down manner.
[0092] In some embodiments, the knowledge graph construction process includes:
[0093] refer to Figure 3 The process begins by determining the design scope of the protocol ontology, designing it based on experience and knowledge of protocol conversion, and modeling the knowledge graph schema layer, providing a data framework for entity extraction and population. Entities are then extracted from the data source, relationships between entities are determined based on the data framework, and the knowledge graph data layer is populated to establish a protocol-level knowledge graph. Finally, the knowledge graphs of various protocols are integrated based on protocol functionality to construct a "general domain knowledge graph for protocols." The specific process is as follows:
[0094] (1) Unified data source: raw data input
[0095] For protocol A and its related document data, the input sources include: unstructured / semi-structured data: such as PDF instruction documents, HTML manuals, XML / YAML configuration snippets, etc., mainly including information such as protocol design ideas, functional descriptions, standards and field specifications; structured data: such as data dictionaries, interface definition files (such as OpenAPI, Protobuf), test samples, etc., providing field names, format constraints, legal values and other information. The above multi-source heterogeneous data will be used as the original material input for the construction of the knowledge graph.
[0096] (2) Ontology Learning: Knowledge Graph Model Layer
[0097] In some embodiments, the ontology emphasizes the structured modeling of concepts and their relationships, rather than focusing on the description of specific instances or attribute values. As the core skeleton of the protocol-level knowledge graph, the ontology architecture defines the semantic associations between entities and constitutes the pattern layer of the graph. In order to establish a standardized knowledge expression system, the design boundaries and core content of the ontology need to be clarified. The protocol conversion process involves information mapping and interaction between heterogeneous protocols. Therefore, when constructing the hierarchical system of the ontology, the organization and hierarchical relationship of key concepts such as protocol functions, message standards, field definitions and their payload data should be comprehensively considered.
[0098] In some embodiments, reference Figure 4 The hierarchical relationship diagram of the ontology class shown in the figure shows the five core classes of the embodiment of the present invention: Protocol Function, Message Standard, Payload, Fields, and Value. It can be understood that the core class can be further refined into more subclasses. The hierarchical structure of the ontology class is as follows: Figure 4 shown.
[0099] In some embodiments, for the hierarchical relationship of the ontology class, the Protocol Function class abstractly describes the message behavior target, such as "resource acquisition", "status update", "event reporting", etc. The Message Standard class describes the standard message format corresponding to the function in the protocol, such as the GET / POST message structure. The Payload class is used to describe the payload data information in the message, including the data type and structure. The Field class is the basic data unit in the message, such as the Header field, the Token field, etc. The Value class describes the value specification of the field, such as "200OK", "application / json", etc.
[0100] In some embodiments, the attributes of the ontology class can be divided into object attributes and data attributes. Object attributes are used to describe the relationship between classes. The present invention designs the relationship between four ontology classes. As shown in the table, the object attributes of the ontology class are mainly reflected in the inclusion relationship. For example, the object attribute "has_message" can be established between the Protocol Function class and the Message Standard class to indicate the message standard (single message, nested message and message queue) corresponding to the protocol function. The object attribute "has_payload" can be established between the Message Standard class and the Payload class to indicate the inclusion relationship between the message standard and the payload. The object attribute "has_field" can be established between the Message Standard class and the Field class to indicate which fields the message standard includes. The Field class can establish the object attribute "has_value" with the Value class to indicate which values the field includes.
[0101] In some embodiments, the present invention can ultimately obtain the protocol ontology by defining the protocol ontology class, the object attributes of the class, and the data attributes. Figure 5 The protocol ontology architecture diagram shown in the figure shows that the protocol ontology class and its object attributes constitute the protocol ontology architecture. As the model layer of the knowledge graph, the protocol ontology architecture standardizes the relationship between entity objects of different classes and guides the learning of knowledge graph entities.
[0102] (3) Entity learning: knowledge graph data layer, i.e. data layer filling
[0103] In some embodiments, entity learning is based on the ontology architecture modeled by the knowledge graph pattern layer, extracting specific entities from the data source to populate the knowledge graph. Figure 6 The CoAP protocol resource acquisition function message standard diagram shown in the figure, and the reference Figure 7The standard diagram of the HTTP protocol resource acquisition function message shown in the figure takes the "resource acquisition (Get)" function of CoAP and HTTP protocols as an example. The content filled in the entity is as follows Figure 5 and Figure 6 shown.
[0104] ④Graph fusion: building a common knowledge graph for protocols
[0105] In some embodiments, the model layer modeling and data layer filling complete the construction of the protocol-level knowledge graph. To support the conversion between multiple protocols, the fusion layer uses "protocol function" as an anchor point to fuse the various protocol-level knowledge graphs and construct a general-domain knowledge graph for the protocol. The fusion strategy mainly includes: anchor point alignment (using protocol function as an anchor point to map similar protocol functions in different protocols to general semantic nodes), graph merging (merging the knowledge graphs of various protocols, merging duplicate or semantically overlapping general semantic nodes, and building a unified identification system) and extension support (supporting dynamic access to new protocols in the future, rapid integration based on existing pattern structures, and improving system maintainability).
[0106] In some embodiments, taking the acquisition of protocol function resources as an example, the fused knowledge graph is obtained as follows Figure 8 The schematic diagram of knowledge graph fusion is shown.
[0107] S300, determining a first benchmark conversion program based on a protocol general knowledge base and a protocol general domain knowledge graph, wherein the first benchmark conversion program is used to represent a general process of protocol conversion.
[0108] It can be understood that the first benchmark conversion program is a program template with a universal structure and extensibility, which provides a structured starting point for the conversion task between different protocols, while the second benchmark conversion program requires domain expertise provided by the knowledge base and knowledge graph to be reconstructed.
[0109] In some embodiments, reference Figure 9 The following diagram shows a benchmark conversion program. A benchmark conversion program is a program template with a universal structure and extensibility. It can serve as a model or skeleton, providing a structured starting point for conversion tasks between different communication protocols. The functions of the benchmark conversion program include:
[0110] Provide a standard format and framework for subsequent conversion programs generated from large models.
[0111] Clarify the common processes required for message conversion across protocols.
[0112] Linked with the knowledge graph, it facilitates the automation of entity alignment, field mapping, and conversion logic generation.
[0113] like Figure 9As shown, the benchmark conversion program should include five core modules: protocol parsing module, field mapping module, conversion rule generation module, conversion execution module and verification module.
[0114] The benchmark conversion program,the protocol parsing module is responsible for parsing the structural information of the,source protocol and the target protocol, including the source,and target protocol structure abstraction (XML / JSON / ASN.1 and other,formats), the source and target protocol fields and type information,extraction.
[0115] The field mapping module is responsible for completing the mapping between the source protocol and the target protocol fields, including structure mapping (message nesting structure, message queue, etc.), field name alignment (through knowledge base, knowledge graph entity similarity, alias, description matching) and data type matching and conversion rule identification.
[0116] The conversion rule generation module is responsible for generating data mapping and processing rules from the source protocol to the target protocol, including type conversion rules (such as integer to floating point, time format conversion), encoding / decoding rules (Base64, compressed fields, etc.), field combination and splitting rules (merging fields, generating multiple fields into one field) and conditional conversion rules (based on field value judgment).
[0117] The conversion execution module is responsible for actually executing the conversion logic and completing the conversion of the message format from the source protocol to the target protocol, including executing the generated conversion rules to implement the output of the target protocol data structure, completing missing fields, error handling and data verification, and conversion log recording.
[0118] The verification module is responsible for verifying the correctness of the conversion results, including input-output comparison mechanism (unit testing framework) and protocol legitimacy check (according to the target protocol specification).
[0119] In some embodiments, taking Python as an example, a partial framework of the benchmark conversion program is shown in the following code example, which includes abstracting each part into an interface / base class, and the specific protocol conversion tasks inherit and implement the details.
[0120] (1) Protocol parser base class (protocol_parser_base.py)
[0121]
[0122] Protocol parser base class: responsible for parsing the structural information of the source protocol and the target protocol,
[0123] Including structure abstraction (such as XML / JSON / ASN.1 and other formats), field path, field type and other extraction.
[0124]
[0125] Parse the protocol definition and extract field path and type information
[0126]
[0127] (2) Conversion rule generator base class (rule_generator_base.py)
[0128]
[0129] Conversion rule generator base class: Based on the field mapping results, generates types including type conversion, encoding / decoding,
[0130] Conversion rules including field merging and splitting, conditional judgment and other logic.
[0131]
[0132] (3) Sample driver script (run_demo.py)
[0133]
[0134]
[0135] S400 , reconstructing the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program.
[0136] In some embodiments, the protocol general knowledge base and the protocol general domain knowledge graph are used as knowledge support for retrieval enhancement generation, and the first benchmark conversion program is used as an example to perform reconstruction processing of the prompt word engineering to obtain the second benchmark conversion program.
[0137] In some embodiments, based on the prompt word engineering, the large model can customize and reconstruct the first benchmark conversion program according to the conversion requirements between specific protocols, and accurately generate an efficient conversion program that supports conversion between specific protocols.
[0138] In order to achieve the goal of automatic customized reconstruction, the prompt words must meet the following requirements: clarify the conversion requirements (for example, protocol A→protocol B); introduce a general protocol knowledge base and a general protocol domain knowledge graph; introduce the first benchmark conversion program output target as structured, executable conversion program code.
[0139] By using prompt word examples, the large language model is guided to automatically reconstruct the baseline conversion program in the protocol conversion task, generating customized, efficient, and executable protocol conversion code:
[0140] S500: Perform conversion processing on the source protocol through a second reference conversion program to obtain a protocol conversion result.
[0141] In some embodiments, examples of prompt words include:
[0142] You are a large language model expert proficient in protocol conversion and program synthesis. Your task is to generate an executable conversion program code to accurately convert message data conforming to protocol A into the format and semantics of protocol B.
[0143] ###Conversion Task
[0144] Input: Original message data that conforms to the structure of protocol A
[0145] Output: Target message data that complies with the structure specification of protocol B
[0146] Objective: Complete the data structure conversion and semantic mapping of protocol A → protocol B, and generate complete conversion program code
[0147] ###Knowledge Resources
[0148] You can use the following structured knowledge support for reasoning and generation:
[0149] 1. General protocol knowledge base: describes the professional terms, basic definitions, rules of each protocol and the relationship between protocols.
[0150] 2. General knowledge graph of protocols: including information such as protocol message standards, fields, values, and payloads based on protocol function mapping.
[0151] 3. Benchmark conversion program template: A general protocol conversion process framework has been implemented, including five modules: protocol parsing module, field mapping module, conversion rule generation module, conversion execution module and verification module.
[0152] Your Task
[0153] Based on the above knowledge resources, please complete the following objectives:
[0154] 1. Use the knowledge base and knowledge graph to infer the field structure and semantic correspondence between protocol A and protocol B.
[0155] 2. Based on the baseline conversion program, complete customized reconstruction and supplement the protocol with unique field parsing and conversion logic.
[0156] 3. Output a piece of executable protocol conversion program code with clear structure, correct logic and complete functions.
[0157] Output requirements
[0158] 1. The output content is a complete and executable program code (Python language is recommended).
[0159] 2. The code should be reconstructed based on the benchmark conversion program, including the following: protocol parsing logic (supporting structure abstraction and field and type extraction of protocol A / B), field mapping logic (supporting structure mapping, field name alignment, data type matching and conversion rule identification), conversion rule logic (including field merging / splitting, encoding conversion, conditional mapping, etc.), conversion execution logic (implementing the complete process from input to target protocol format) and output verification logic (verifying whether the result structure conforms to the protocol B specification).
[0160] 3. All modules should be structured and organized with good readability and scalability.
[0161] 4. Do not output explanations, prompts or non-code content, only output complete code.
[0162] In some embodiments, reference Figure 10 The overall protocol intelligent conversion analysis framework shown is a schematic diagram, which includes:
[0163] (1) Modeling of the pattern layer (ontology learning): Based on the knowledge requirements of the protocol conversion task, the protocol ontology structure is designed, and five core ontology classes (protocol function, message standard, payload, field, field value) and semantic relationships between classes (such as has_message, has_payload, has_field, has_value) are defined to build a unified pattern layer knowledge framework; Data layer filling (entity learning): Based on the pattern layer structure, specific entities and attribute values are automatically extracted from multi-source protocol documents to generate structured knowledge triples (such as "field A has_value B") to form a protocol-level knowledge graph covering the semantic details of the protocol; Graph fusion to build a general graph: With "protocol function" as the anchor point, multiple protocol knowledge graphs are integrated, the semantic nodes between abstract protocols are unified, semantic alignment and concept merging are achieved, and finally a "protocol general domain knowledge graph" with cross-protocol general expression capabilities is built.
[0164] (2) Based on the graph-driven benchmark conversion program, the general process of protocol conversion is abstracted: by analyzing the common processes in the protocol conversion tasks and combining the knowledge graph with the protocol semantic knowledge accumulated in the knowledge base, a benchmark conversion program framework with universality, scalability and reconfigurability is constructed.
[0165] The program framework includes five core modules: protocol parsing module, field mapping module, conversion rule generation module, conversion execution module and verification module, which constitute the general execution process of protocol conversion tasks:
[0166] Protocol parsing module: Automatically parses the structural information of the source protocol and the target protocol, including message formats (such as JSON, XML, ASN.1) and field data types, laying the foundation for subsequent field mapping.
[0167] Field mapping module: Utilizes entity similarity, alias relationships, field types and other information in the knowledge graph to achieve cross-protocol field name alignment, structure matching and data type conversion rule identification.
[0168] Conversion rule generation module: Based on field mapping, automatically generates data conversion rules including type conversion, field combination / splitting, conditional processing, etc.
[0169] Conversion execution module: Based on the above rules, it completes the data conversion and structural reorganization between the source protocol and the target protocol, supports missing field completion, fault tolerance mechanism and conversion log recording.
[0170] Verification module: Verifies the semantic consistency and protocol compliance of the conversion results to ensure that the generated message meets the target protocol standard.
[0171] (3) Generate programs using a large language model to achieve automatic customized reconstruction of the protocol conversion program: Integrating RAG (retrieval-augmented generation) technology with prompt word engineering, using the previously built protocol knowledge base, knowledge graph, and benchmark conversion program, we achieve automatic customized reconstruction of the protocol conversion logic. The core process is as follows:
[0172] Enhanced Knowledge Assistance (RAG): This leverages an external knowledge system comprised of a common protocol knowledge graph and knowledge base to enhance the generation process of large language models. Before generation, the model automatically retrieves key information such as the protocol's structure, semantic mappings, and field definitions to ensure the generated logic is semantically accurate and compliant with protocol specifications.
[0173] Benchmark program template reference: The pre-designed general benchmark conversion program is used as a structured prompt input model to provide a standard conversion process skeleton, including modules such as parsing, mapping, rule generation, execution and verification, providing a structural reference for customized program generation.
[0174] Prompt word engineering-driven: High-quality prompt words are constructed based on inputs such as protocol pairs (source protocol, target protocol), conversion targets, and key field information, guiding the large language model to accurately understand the requirements of the conversion task.
[0175] Automatic program generation and reconstruction: Based on structural templates and domain knowledge, the large language model independently completes protocol field parsing, conversion rule construction and logic filling, and automatically generates conversion programs that can efficiently support message conversion between specific protocols.
[0176] Figure 11FIG1 is a diagram of a protocol intelligent conversion and analysis device according to an embodiment of the present invention. The device includes a first module 1110 , a second module 1120 , a third module 1130 , a fourth module 1140 and a fifth module 1150 .
[0177] The first module is used to determine a general protocol knowledge base based on the protocol standard document. The second module is used to determine a knowledge graph model layer and a knowledge graph data layer based on the protocol standard document, and perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer to obtain a general protocol domain knowledge graph. The third module is used to determine a first benchmark conversion program based on the general protocol knowledge base and the general protocol domain knowledge graph, where the first benchmark conversion program is used to represent the general protocol conversion process. The fourth module is used to reconstruct the first benchmark conversion program using a large language model based on the general protocol knowledge base and the general protocol domain knowledge graph to obtain a second benchmark conversion program. The fifth module is used to perform conversion processing on the source protocol using the second benchmark conversion program to obtain a protocol conversion result.
[0178] Exemplarily, with the cooperation of the first to fifth modules in the device, the embodiment device can implement any of the aforementioned protocol intelligent conversion methods, namely, determining a protocol general knowledge base based on the protocol standard document; determining a knowledge graph pattern layer and a knowledge graph data layer based on the protocol standard document, and performing knowledge graph fusion on the knowledge graph pattern layer and the knowledge graph data layer to obtain a protocol general domain knowledge graph; determining a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to characterize the general process of protocol conversion; reconstructing the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program; performing conversion processing on the source protocol through the second benchmark conversion program to obtain a protocol conversion result. The beneficial effects of the present invention are as follows: a top-down approach is adopted according to the protocol document to execute the filling of the mode layer and the data layer and the graph fusion to obtain the knowledge graph of the general domain of the protocol; through entity extraction and graph fusion, the semantic barriers between different protocols are broken through, and a general knowledge expression system supporting interoperability between multiple protocols is established; by analyzing the common processes in the protocol conversion tasks and combining the knowledge graph with the protocol semantic knowledge deposited in the knowledge base, a benchmark conversion program structure framework with universality, scalability and reconfigurability is obtained, which enhances the automation, accuracy and controllability of the conversion program generation; by integrating RAG technology and prompt word engineering, the constructed protocol knowledge base, knowledge graph and benchmark conversion program are used to realize automatic customized reconstruction of the protocol conversion logic, thereby improving the efficiency, scalability and accuracy of conversion between protocols.
[0179] An embodiment of the present invention further provides an electronic device, the electronic device including a processor and a memory;
[0180] The memory stores a program;
[0181] The processor executes the program to perform the aforementioned protocol intelligent conversion method; the electronic device has the function of carrying and running the protocol intelligent conversion software system provided by the embodiment of the present invention, such as a personal computer, a minicomputer, a main frame, a workstation, a network or distributed computing environment, a separate or integrated computer platform, or communicating with a charged particle tool or other imaging device, etc.
[0182] An embodiment of the present invention further provides a computer-readable storage medium, wherein the storage medium stores a program, and the program is executed by a processor to implement the protocol intelligent conversion method as described above.
[0183] In some optional embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided in an exemplary manner for the purpose of providing a more comprehensive understanding of the technology. The disclosed method is not limited to the operation and logic flow presented herein. Optional embodiments are contemplated in which the order of the various operations is changed and the sub-operations described as a part of a larger operation are performed independently.
[0184] An embodiment of the present invention further discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the computer device to perform the aforementioned intelligent protocol conversion method.
[0185] Furthermore, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise indicated, one or more of the functions and / or features described may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It will also be understood that a detailed discussion of the actual implementation of each module is not necessary for understanding the present invention. More specifically, given the properties, functions, and internal relationships of the various functional modules in the devices disclosed herein, the actual implementation of the module will be understood within the ordinary skill of an engineer. Therefore, a person skilled in the art using ordinary skill will be able to implement the present invention set forth in the claims without undue experimentation. It will also be understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0186] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0187] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a computer-readable medium can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0188] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering, or processing in another suitable manner as necessary, and then stored in a computer memory.
[0189] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0190] Throughout this specification, references to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" indicate that the specific features, structures, materials, or characteristics described in conjunction with that embodiment or example are included in at least one embodiment or example of the present invention. In this specification, schematic representations of these terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
[0191] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the claims and their equivalents.
[0192] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A protocol intelligent conversion method, characterized in that: include: Determine the protocol common knowledge base based on the protocol standard document; According to the protocol standard document, determine the knowledge graph model layer and the knowledge graph data layer, perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer to obtain the knowledge graph of the general domain of the protocol; Determining a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to represent a general process of protocol conversion; Reconstructing the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program; The source protocol is converted by the second reference conversion program to obtain a protocol conversion result.
2. The protocol intelligent conversion method according to claim 1, characterized in that: The protocol general knowledge base is determined according to the protocol standard document to obtain: Collect protocol standard documents, which include structured, semi-structured and unstructured data; According to the protocol type, the protocol standard documents are stored in a document database to obtain a protocol general knowledge base, which includes professional terms, basic definitions, rules and relationships between protocols.
3. The protocol intelligent conversion method according to claim 1, characterized in that: Determining the knowledge graph model layer includes: Determine the hierarchical relationship of the protocol ontology class based on the core class and its subclasses, where the core class includes protocol functions, message standards, payloads, fields, and field values; The object attributes and data attributes of the class are determined according to the hierarchical relationship of the protocol ontology class. The knowledge graph pattern layer is obtained according to the protocol ontology class, the object attributes and the data attributes of the class. The knowledge graph pattern layer is used to characterize the relationship between entity objects of different classes.
4. The protocol intelligent conversion method according to claim 3, characterized in that: Determining the knowledge graph data layer includes: Entities are extracted from the protocol general knowledge base, and the knowledge graph model layer is filled with entities to obtain a knowledge graph data layer.
5. The protocol intelligent conversion method according to claim 1, characterized in that: The knowledge graph model layer and the knowledge graph data layer are fused to obtain a knowledge graph for the general domain of the protocol, including: The knowledge graph pattern layer and the knowledge graph data layer are fused using anchor point alignment, graph merging and extended support; the anchor point alignment maps similar functional protocols in different protocols to common semantic nodes; the graph merging merges repeated or semantically overlapping common semantic nodes; the extended support integrates new protocols according to the pattern structure of existing protocols.
6. The protocol intelligent conversion method according to claim 1, characterized in that: The determining of a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to characterize a general process of protocol conversion, includes: Obtaining the source protocol and the target protocol, parsing the structure information of the source protocol and the target protocol, wherein the structure information includes structure abstract data, protocol fields, and protocol types; Perform field mapping on the protocol fields of the source protocol and the target protocol, where field mapping includes structure mapping, field name alignment, data type matching, and conversion rule identification; Generate data mapping and processing rules based on the protocol fields of the source protocol and the target protocol, where the data mapping and processing rules include type conversion rules, encoding / decoding rules, field combination and splitting rules, and conditional conversion rules; Performing logic conversion from the source protocol to the target protocol message format, where the conversion logic processing includes executing the generated conversion rules to implement the target protocol data structure output, missing field completion, error handling and data verification, and conversion log recording; An input-output comparison mechanism and a protocol validity check are performed on the conversion result from the source protocol to the target protocol to obtain a first benchmark conversion program.
7. The protocol intelligent conversion method according to claim 1, characterized in that: The first benchmark conversion program is reconstructed using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program, including: The protocol general knowledge base and the protocol general domain knowledge graph are used as knowledge support for retrieval enhancement generation, and the first benchmark conversion program is used as an example to perform reconstruction processing of the prompt word project to obtain a second benchmark conversion program.
8. A protocol intelligent conversion device, characterized in that: include: The first module is used to determine a protocol general knowledge base according to the protocol standard document; The second module is used to determine the knowledge graph model layer and the knowledge graph data layer according to the protocol standard document, and perform knowledge graph fusion on the knowledge graph model layer and the knowledge graph data layer to obtain the knowledge graph of the general domain of the protocol; A third module is configured to determine a first benchmark conversion program based on the protocol general knowledge base and the protocol general domain knowledge graph, wherein the first benchmark conversion program is used to characterize a general process of protocol conversion; A fourth module is configured to reconstruct the first benchmark conversion program using a large language model based on the protocol general knowledge base and the protocol general domain knowledge graph to obtain a second benchmark conversion program; The fifth module is used to perform conversion processing on the source protocol through the second benchmark conversion program to obtain a protocol conversion result.
9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store programs; The processor executes the program to implement the protocol intelligent conversion method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores a program, and the program is executed by a processor to implement the protocol intelligent conversion method according to any one of claims 1 to 7.
Citation Information
Cited By
Data communication method and device, storage medium and electronic equipment
CN121056530A