A protocol consistency test method, system, storage medium and computing device
By judging the protocol type and selecting corresponding plug-ins for syntax and semantic consistency testing, the problem of the lack of universality of existing testing methods is solved, and comprehensive consistency testing of different protocols is achieved, which improves testing efficiency and accuracy.
Patent Information
- Application Number
- CN202111030339.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-03
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2041-09-03
AI Technical Summary
The existing protocol consistency testing methods are mainly aimed at MMS, and there is a lack of common methods to test the consistency of different protocols such as autonomous controllable communication service protocols.
By judging the type of protocol to be tested, selecting the corresponding preset protocol plug-in for syntax consistency testing, and parsing the device configuration file and interactive messages for semantic consistency testing, realizing a general protocol consistency testing method.
The syntax and semantic consistency test of different protocols is implemented, and a general testing method is provided to improve the testing efficiency and accuracy.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a protocol consistency test method, system, storage medium and computing equipment, and belongs to the field of power system automation. Background Art
[0002] At present, the communication of substation control layer in China is mapped to MMS. The MMS development kit relies heavily on foreign paid software packages, which makes the core technology controlled by others. In addition, the MMS design is complex, resulting in low transmission and development efficiency. In response to the above problems, State Grid Corporation organized and designed an independent and controllable communication service protocol to achieve complete independent control of the IEC61850 communication protocol stack.
[0003] The autonomous controllable communication service protocol adopts the ASN.1 compression encoding rules to enhance the efficiency of encoding and decoding and data transmission. The autonomous controllable communication service protocol is based on the IEC 61850-7-2 standardized abstract communication service interface syntax definition, and at the same time expands the association negotiation service interface to ensure the communication security between the client and the server, and make up for the server's support service to the main station.
[0004] Before the protocol is put into practical engineering, it needs to be tested for consistency. The current consistency testing method is mainly aimed at MMS, and there is no universal consistency testing method. Summary of the invention
[0005] The present invention provides a protocol consistency test method, system, storage medium and computing device, which solve the problems disclosed in the background technology.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0007] A protocol consistency testing method, comprising:
[0008] Determine the type of protocol to be tested;
[0009] Select a preset protocol plug-in that matches the type and perform a syntax consistency test on the protocol; wherein a protocol syntax consistency test method is defined in the protocol plug-in;
[0010] Parse the configuration file of the protocol device under test and perform semantic consistency test on the device interaction messages.
[0011] The types of protocols to be tested include autonomous and controllable communication service protocols and / or communication service protocols that need to be mapped to MMS.
[0012] The protocol plug-in includes an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in. The autonomous and controllable communication service protocol plug-in defines an autonomous and controllable communication service protocol syntax consistency test method, and the MMS protocol plug-in defines an MMS protocol syntax consistency test method.
[0013] The specific process of the autonomous and controllable communication service protocol syntax consistency test method can be:
[0014] Generate ASN.1 files based on the autonomous and controllable communication service protocol and the preset data conversion relationship;
[0015] Call Python to encode and decode the data in the ASN.1 file and perform syntax consistency test.
[0016] The data conversion relationship is as follows:
[0017] The sequence in the autonomous and controllable communication service protocol is converted into dict, sequence of is converted into list, choice is converted into tuple, VisibleString is converted into str, and UTCTime is converted into datetime.
[0018] Parse the configuration file of the protocol device to be tested and perform semantic consistency test on the device interaction messages. The specific process can be:
[0019] Parse the configuration file of the protocol device to be tested and obtain the semantics in the configuration file;
[0020] Parse device interaction messages and obtain the semantics in the interaction messages;
[0021] Compare the semantics in the configuration file with the semantics in the interaction message and perform a semantic consistency test.
[0022] A protocol consistency testing system, comprising:
[0023] Judgment module: judge the type of the protocol to be tested;
[0024] Syntax test module: selects a preset protocol plug-in that matches the type and performs a syntax consistency test on the protocol; wherein a protocol syntax consistency test method is defined in the protocol plug-in;
[0025] Semantic test module: parses the configuration file of the protocol device under test and performs semantic consistency test on the device interaction messages.
[0026] The types of protocols to be tested include autonomous and controllable communication service protocols and / or communication service protocols that need to be mapped to MMS.
[0027] The protocol plug-in includes an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in. The autonomous and controllable communication service protocol plug-in defines an autonomous and controllable communication service protocol syntax consistency test module, and the MMS protocol plug-in defines an MMS protocol syntax consistency test module.
[0028] The autonomous and controllable communication service protocol syntax consistency test module includes:
[0029] ASN.1 file generation module: Generates ASN.1 files based on the autonomous and controllable communication service protocol and the preset data conversion relationship;
[0030] Call the encoding and decoding module: Call asn1tools in Python to encode and decode the data in the ASN.1 file and perform syntax consistency test.
[0031] The data conversion relationship is as follows:
[0032] The sequence in the autonomous and controllable communication service protocol is converted into dict, sequence of is converted into list, choice is converted into tuple, VisibleString is converted into str, and UTCTime is converted into datetime.
[0033] The semantic testing module includes:
[0034] Configuration file parsing module: parses the configuration file of the protocol device to be tested and obtains the semantics in the configuration file;
[0035] Message parsing module: parses device interaction messages and obtains the semantics in the interaction messages;
[0036] Comparison test module: compares the semantics in the configuration file with the semantics in the interaction message to perform semantic consistency test.
[0037] It also includes a state sequence module, which obtains the device state sequence containing the communication service interface.
[0038] A computer-readable storage medium storing one or more programs, wherein the one or more programs include instructions, which when executed by a computing device, cause the computing device to perform a protocol conformance testing method.
[0039] A computing device includes one or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing a protocol consistency testing method.
[0040] The beneficial effects achieved by the present invention are as follows: the present invention sets the syntax consistency test methods of different protocols into protocol plug-ins, selects the protocol plug-in according to the protocol type, performs syntax consistency test, and performs semantic consistency test based on the parsing results of the device configuration file, thereby realizing a universal consistency test method. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a flow chart of the method of the present invention;
[0042] Figure 2 It is a specific flow chart of the method of the present invention;
[0043] Figure 3 It is a module diagram of the system of the present invention. DETAILED DESCRIPTION
[0044] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0045] like Figure 1 As shown, a protocol consistency testing method comprises the following steps:
[0046] Step 1, determine the type of protocol to be tested;
[0047] Step 2, selecting a preset protocol plug-in that matches the type and performing a syntax consistency test on the protocol; wherein a protocol syntax consistency test method is defined in the protocol plug-in;
[0048] Step 3: parse the configuration file of the protocol device to be tested and perform semantic consistency test on the device interaction messages.
[0049] The above method sets the syntax consistency test methods of different protocols into protocol plug-ins, selects the protocol plug-in according to the protocol type, performs syntax consistency test, and performs semantic consistency test based on the device configuration file parsing result, thereby realizing a universal consistency test method.
[0050] At present, there are two main communication protocols for substations in China. One is an autonomous and controllable communication service protocol developed domestically, and the other is a communication service protocol that needs to be mapped to MMS. Therefore, the types of protocols to be tested in step 1 include autonomous and controllable communication service protocols and / or communication service protocols that need to be mapped to MMS.
[0051] Before performing the protocol consistency test, the syntax consistency test methods of the above two protocols are encapsulated into different protocol plug-ins, and a preset protocol plug-in matching the type is selected, that is, an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in is selected, and the corresponding test method is run.
[0052] The autonomous and controllable communication service protocol plug-in defines an autonomous and controllable communication service protocol syntax consistency test method, and the MMS protocol plug-in defines an MMS protocol syntax consistency test method.
[0053] The MMS protocol syntax consistency test method is an existing method, as follows:
[0054] 1) Perform MMS mapping first, that is, map the traffic protocol to MMS;
[0055] 2) Perform BER encoding and decoding and syntax consistency test.
[0056] Currently, MMS consistency testing is mainly implemented using the cross-platform language QT, python scripts, and dynamic link libraries; MMS mapping and BER encoding and decoding encapsulation are implemented to implement the MMS protocol plug-in. The python script library is reused through the software framework of the protocol plug-in to realize the logical call of the test case script.
[0057] The autonomous and controllable communication service protocol is different from other protocols. It does not need to consider mapping to MMS. The implementation mainly considers the encoding and decoding of syntax. Based on this, the third-party library asn1tools in Python can be used to implement the underlying service protocol development. The error reasons returned in the application library are used to perform syntax consistency testing. The specific steps are as follows:
[0058] S1) Generate an ASN.1 file according to the autonomous and controllable communication service protocol and the preset data conversion relationship;
[0059] There are a large number of data structures in the autonomous and controllable communication service protocol, which need to be converted. The specific conversion rules are shown in Table 1:
[0060] Table 1 Data structure conversion rules
[0061]
[0062] As can be seen from the above table, the sequence in the autonomous and controllable communication service protocol is converted into dict (dictionary), sequence of is converted into list (list), choice is converted into tuple (tuple), VisibleString (string) is converted into str, and UTCTime (Coordinated Universal Time) is converted into datetime, so that an ASN.1 file is generated according to the autonomous and controllable communication service protocol. The data types in the ASN.1 file are the data types required by python, which is convenient for subsequent encoding and decoding.
[0063] S2) calling asn1tools in Python to encode and decode the data in the ASN.1 file and perform syntax consistency test;
[0064] asn1tools can implement syntax testing. When encoding or decoding fails, it will return Ecoderror / Decoderror and the reason for the failure.
[0065] After the protocol plug-in is built, perform a protocol consistency test, such as Figure 2 As shown, first select the corresponding protocol plug-in according to the type of protocol to be tested, and perform a syntax consistency test according to the method in the protocol plug-in. If the syntax consistency test passes, obtain the configuration file (i.e., CID file) of the device using the protocol, parse the CID file, obtain the semantics in the CID file, parse the device interaction message (interaction message between the device and the simulator), obtain the semantics in the interaction message, compare the semantics in the CID file with the semantics in the interaction message, and perform a semantic consistency test.
[0066] The above method realizes a general consistency test method by selecting different protocol plug-ins by protocol type.
[0067] The corresponding tool of the above method, namely the protocol consistency test system, includes:
[0068] Judgment module: judges the type of the protocol to be tested; the type of the protocol to be tested includes an autonomous and controllable communication service protocol and / or a communication service protocol that needs to be mapped to MMS.
[0069] Syntax test module: selects a preset protocol plug-in that matches the type and performs a syntax consistency test on the protocol; wherein a protocol syntax consistency test method is defined in the protocol plug-in.
[0070] The protocol plug-in includes an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in. The autonomous and controllable communication service protocol plug-in defines an autonomous and controllable communication service protocol syntax consistency test module, and the MMS protocol plug-in defines an MMS protocol syntax consistency test module.
[0071] The autonomous and controllable communication service protocol syntax consistency test module includes:
[0072] ASN.1 file generation module: Generates ASN.1 files based on the autonomous and controllable communication service protocol and the preset data conversion relationship;
[0073] The data conversion relationship is as follows:
[0074] The sequence in the autonomous and controllable communication service protocol is converted into dict, sequence of is converted into list, choice is converted into tuple, VisibleString is converted into str, and UTCTime is converted into datetime.
[0075] Call the encoding and decoding module: Call asn1tools in Python to encode and decode the data in the ASN.1 file and perform syntax consistency test.
[0076] Semantic test module: parses the configuration file of the protocol device under test and performs semantic consistency test on the device interaction messages.
[0077] The semantic testing module includes:
[0078] Configuration file parsing module: parses the configuration file of the protocol device to be tested and obtains the semantics in the configuration file;
[0079] Message parsing module: parses device interaction messages and obtains the semantics in the interaction messages;
[0080] Comparison test module: compares the semantics in the configuration file with the semantics in the interaction message to perform semantic consistency test.
[0081] Specific structure such as Figure 3 As shown, it includes a test case module, a real-time test information printing module, a state sequence module, a configuration file parsing module, a test report module, a message parsing module and a client.
[0082] The test case module abstracts the test cases and service interfaces for protocol testing reuse. The test case scripts are open and shared. Users can perform secondary development and design of test cases based on the highly abstract function interface according to their needs. The test case library is extended and designed based on the IEC 61850Ed2.0 consistency test cases, and the same type of test cases can be reused. The above judgment module, syntax test module and comparison test module are all integrated in the test case module.
[0083] The real-time test information printing module no longer simply prints the test process information, but combines the test step description with the test process information to facilitate rapid location of test problems.
[0084] The state sequence module is different from the output state sequence in the traditional tester. The communication service interface is added to the output sequence. That is, the state sequence module obtains the device state sequence containing the communication service interface. Based on this design, some open-loop test cases can be flexibly implemented.
[0085] The configuration file parsing module is a module included in the semantic testing module. It is not only used for configuration file parsing, but also for verifying configuration files. On the premise of generating a model tree, the paths and data types in the model file are classified according to the configuration parameter requirements to achieve fast retrieval of configuration parameters.
[0086] The test report module automatically inserts the test process log and test error information into the test report template to realize automatic generation of the test report.
[0087] The message parsing module is a module included in the semantic testing module, which implements message parsing.
[0088] The clients include MMS client and autonomous controllable communication service protocol client. At the same time, multi-threaded design is used to enable at least 16 clients to run concurrently, and different services can be run concurrently according to the needs of test cases.
[0089] A computer-readable storage medium storing one or more programs, wherein the one or more programs include instructions, which when executed by a computing device, cause the computing device to perform a protocol conformance testing method.
[0090] A computing device includes one or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing a protocol consistency testing method.
[0091] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0092] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0093] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0094] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0095] The above are merely embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention are included in the scope of the claims of the present invention to be approved.
Claims
1. A protocol consistency testing method, characterized in that: include: Determine the type of protocol to be tested; Select a preset protocol plug-in that matches the type and perform a syntax consistency test on the protocol; wherein a protocol syntax consistency test method is defined in the protocol plug-in; Parse the configuration files of the protocol device to be tested and perform semantic consistency tests on the device interaction messages; in, The types of protocols to be tested include autonomous controllable communication service protocols and / or communication service protocols that need to be mapped to MMS; The protocol plug-in includes an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in; the MMS protocol plug-in defines an MMS protocol syntax consistency test method; the autonomous and controllable communication service protocol plug-in defines an autonomous and controllable communication service protocol syntax consistency test method; The specific process of the syntax consistency test method of the autonomous and controllable communication service protocol is as follows: according to the autonomous and controllable communication service protocol and the preset data conversion relationship, an ASN.1 file is generated, and asn1tools in Python is called to encode and decode the data in the ASN.1 file to perform syntax consistency test; The data conversion relationship is: the sequence in the autonomous and controllable communication service protocol is converted into dict, the sequence of is converted into list, the choice is converted into tuple, the VisibleString is converted into str, and the UTCTime is converted into datetime.
2. A protocol consistency testing method according to claim 1, characterized in that: Parse the configuration file of the protocol device to be tested and perform semantic consistency test on the device interaction messages. The specific process is as follows: Parse the configuration file of the protocol device to be tested and obtain the semantics in the configuration file; Parse device interaction messages and obtain the semantics in the interaction messages; Compare the semantics in the configuration file with the semantics in the interaction message and perform a semantic consistency test.
3. A protocol consistency testing system, characterized in that: include: Judgment module: judge the type of the protocol to be tested; Syntax test module: selects a preset protocol plug-in that matches the type and performs a syntax consistency test on the protocol; wherein the protocol plug-in defines a protocol syntax consistency test method; wherein, Semantic test module: parses the configuration file of the protocol device to be tested and performs semantic consistency test on the device interaction messages; The types of protocols to be tested include autonomous and controllable communication service protocols and / or communication service protocols that need to be mapped to MMS; The protocol plug-in includes an autonomous and controllable communication service protocol plug-in and / or an MMS plug-in; an MMS protocol syntax consistency test module is defined in the MMS protocol plug-in; an autonomous and controllable communication service protocol plug-in includes an autonomous and controllable communication service protocol syntax consistency test module; The autonomous and controllable communication service protocol syntax consistency test module includes: ASN.1 file generation module: generates ASN.1 files according to the autonomous and controllable communication service protocol and the preset data conversion relationship; calls the encoding and decoding module: calls asn1tools in Python to encode and decode the data in the ASN.1 file and perform syntax consistency tests; The data conversion relationship is: the sequence in the autonomous and controllable communication service protocol is converted into dict, the sequence of is converted into list, the choice is converted into tuple, the VisibleString is converted into str, and the UTCTime is converted into datetime.
4. A protocol consistency testing system according to claim 3, characterized in that: The semantic testing module includes: Configuration file parsing module: parses the configuration file of the protocol device to be tested and obtains the semantics in the configuration file; Message parsing module: parses device interaction messages and obtains the semantics in the interaction messages; Comparison test module: compares the semantics in the configuration file with the semantics in the interaction message to perform semantic consistency test.
5. A protocol consistency testing system according to claim 3, characterized in that: It also includes a state sequence module, which obtains the device state sequence containing the communication service interface.
6. A computer-readable storage medium storing one or more programs, characterized in that: The one or more programs include instructions which, when executed by a computing device, cause the computing device to perform any one of the methods according to claims 1 to 2.
7. A computing device, characterized in that include: One or more processors, one or more memories, and one or more programs, wherein the one or more programs are stored in the one or more memories and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing any of the methods according to claims 1 to 2.
Citation Information
Patent Citations
Testing method and system based on message
CN102694701A
Method and device for detecting data messages
CN103516703A