A private communication protocol testing method, system, device and medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2026-08-11
AI Technical Summary
但目前对于私有通信协议,常无法找到现成的测试程序,同时,当通信双方分开进行开发时,可能存在开发时间差,导致其中一方的通信功能已开发完成,而另一方未开发完成的情况,或身边没有对端设备时,将无法智能且及时对通信功能进行测试,上述问题有待解决
Smart Images

Figure CN117880156B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer communications, and in particular to a method, system, device and medium for testing proprietary communication protocols. Background Technology
[0002] The Internet of Things (IoT) is a complex network system composed of multiple devices. Different devices use a wide variety of communication protocols. Some devices use public communication protocols, such as Modbus, OPC UA, BACnet, and MQTT, while others use custom-developed proprietary communication protocols.
[0003] For public communication protocols, numerous ready-made test programs are available in the industry, allowing developers to easily test the communication functions of their systems after completion. However, for proprietary communication protocols, readily available test programs are often unavailable. Furthermore, when the two parties developing the communication protocols separately, there may be a development time lag, resulting in situations where one party's communication function is completed while the other's is not, or when there is no readily available equipment on the other end, intelligent and timely testing of the communication function becomes impossible. These issues need to be addressed. Summary of the Invention
[0004] To enable intelligent and timely testing of communication functions and improve the versatility and timeliness of communication protocol testing, this application provides a proprietary communication protocol testing method, system, device, and medium, employing the following technical solution:
[0005] Firstly, this application provides a method for testing a proprietary communication protocol, including:
[0006] Obtain the control request frame and create an object model based on the parsed control request frame;
[0007] A virtual device is created by simulating the data storage inside the physical device using a physical model.
[0008] Obtain private protocol information, convert the private protocol information into a format that matches the virtual device, obtain input information, input the input information into the virtual device for testing, and write a behavior flowchart for the virtual device based on the input information.
[0009] Preferably, the specific steps for creating a virtual device based on the data storage within the physical model simulation device are as follows:
[0010] The virtual device is obtained by acquiring data from the simulated device in the physical model and establishing several independent data storage areas based on the data.
[0011] Preferred options also include:
[0012] A visualization page is provided, on which the object model ID, virtual device ID, virtual device IP, and virtual device port of the object model used by the virtual device are configured in advance.
[0013] Preferably, the specific steps for converting the private protocol information into a format that matches the virtual device are as follows:
[0014] The bytes representing the device address in the private protocol information are combined into an integer, the integer is converted into a string, and then the string is matched with the virtual device ID.
[0015] Preferred options also include:
[0016] The string and the matching virtual device ID are encapsulated into the format required by the virtual device input to obtain the input information.
[0017] Preferably, the specific steps for inputting the input information into the virtual device for testing are as follows:
[0018] Obtain the input information, perform targeted input based on the virtual device ID matched by the input information, and then write the corresponding values recorded in the input information into the variables to obtain the writing status of several variables in the virtual device ID.
[0019] Preferably, the input information is a JSON message.
[0020] Secondly, this application provides a private communication protocol testing system, comprising:
[0021] Object Model Management Module: Used to obtain control request frames and create object models based on the parsed control request frames;
[0022] Virtual Device Management Module: Used to create virtual devices by simulating the internal data storage of devices based on the object model;
[0023] Data processing flow construction module: used to obtain private protocol information, convert the private protocol information into a format that matches the virtual device, obtain input information, input the input information into the virtual device for testing, and write a behavior flow diagram for the virtual device based on the input information.
[0024] Thirdly, this application provides a private communication protocol testing device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the private communication protocol testing method as described above.
[0025] Fourthly, this application provides a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the private communication protocol testing method as described above when running.
[0026] In summary, compared with the prior art, the beneficial effects of the technical solution provided in this application include at least the following:
[0027] This application creates an object model by sending control request frames from a host computer, and then creates a virtual device based on the object model. This allows for the construction of a system that enables engineers to more effectively verify the communication functions of devices during the testing phase, even when the devices lack the conditions to meet the private protocol communication requirements. After obtaining the private protocol information, the system performs format conversion and debugging to obtain input information. Based on the input information, further calculations are performed on the data processing behavior designed for the virtual device to obtain a behavior flowchart describing the behavior logic of data processing within the virtual device. The input information is then input into the virtual device for testing. This allows for the creation of device object model objects and virtual device objects, and the establishment of an independent data storage area for each virtual device. It simulates the data storage situation within the device to support private protocol communication testing when no existing device is available. This intelligent and timely testing of communication functions improves the versatility and timeliness of communication protocol testing. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating a private communication protocol testing method as described in an embodiment of this application.
[0029] Figure 2 This is a schematic diagram of a private communication protocol testing system as described in an embodiment of this application.
[0030] Explanation of reference numerals in the attached figures:
[0031] 1. Object model management module; 2. Virtual device management module; 3. Data processing workflow construction module. Detailed Implementation
[0032] The following combination Figures 1-2 The present application will be described in further detail below. The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting.
[0033] Reference Figure 1 The method for testing a proprietary communication protocol involved in this application specifically includes:
[0034] Step S1: Obtain the control request frame and create an object model based on the parsed control request frame;
[0035] Step S2: Create a virtual device based on the data storage inside the device simulated by the physical model;
[0036] Step S3: Obtain private protocol information, convert the private protocol information into a format that matches the virtual device, obtain input information, and input the input information into the virtual device for testing;
[0037] Step S4: Create a behavior flowchart for the virtual device based on the input information.
[0038] Specifically, when an untested host computer communicating using a proprietary protocol needs to undergo communication testing, it sends a control request frame to the system. Upon receiving the control request frame, the system uses a streaming visualization component-based method to quickly construct a virtual slave device communicating using the proprietary protocol, assisting the host computer in testing the communication protocol functionality. First, an object model is constructed, and then a virtual device is created based on the object model. This allows for the construction of a virtual device that enables engineers to more effectively verify the communication functionality of existing devices, even when the conditions for proprietary protocol communication are not met. After obtaining the proprietary protocol information, format conversion and debugging are required to obtain the input information. Based on the input information, further calculations are performed on the data processing behavior designed for the virtual device to obtain a behavior flowchart describing the behavior logic of data processing within the virtual device. The input information is then fed into the virtual device for testing, enabling the creation of device object models and virtual device objects. An independent data storage area is established for each virtual device to simulate the data storage situation within the device, supporting private protocol communication testing when no existing device is available. This provides the virtual device with functions such as "data calculation, encapsulation, and transmission," and ultimately sends communication responses to external devices. The intelligent and timely testing of communication functions improves the versatility and timeliness of communication protocol testing.
[0039] The construction of the object model is completed by the object model management module. The object model is the entity model in the Internet of Things described using TSL. The object model is also called the product model or data template. The object model management subsystem only defines the names of variables or constants that a certain type of device has, and does not fill in the values of variables or constants.
[0040] As one implementation method, the specific steps for creating a virtual device based on the data storage within the physical model simulation device are as follows:
[0041] The virtual device is obtained by acquiring data from the simulated device in the physical model and establishing several independent data storage areas based on the data.
[0042] A visualization page is provided, on which the object model ID, virtual device ID, virtual device IP, and virtual device port of the object model used by the virtual device are configured in advance.
[0043] Specifically, the construction of virtual devices is completed by the virtual device management module. The object model management module and the virtual device management module allow engineers to create device object model objects and virtual device objects, and establish an independent data storage area for each virtual device. This enables read and write operations on virtual devices within the flowchart, simulating the internal data storage of the device, and supporting private protocol communication testing when no existing device is available.
[0044] The module that acquires control request frames is the data receiving component in the data processing flow construction module. After acquiring the control request frame, the data parsing component parses the data output by the data receiving component, and the result is then used by the conditional branch processing component to determine whether the current frame is a control request frame. If it is, the data format conversion component is called.
[0045] As one implementation method, the specific steps for converting private protocol information into a format compatible with the virtual device are as follows:
[0046] The bytes representing the device address in the private protocol information are combined into an integer, the integer is converted into a string, and then the string is matched with the virtual device ID.
[0047] The string and the matching virtual device ID are encapsulated into the format required by the virtual device input to obtain the input information.
[0048] Specifically, the data format conversion component matches the string with the virtual device ID. It combines the bytes of data in the `dev addr` field, representing the device address, into an integer, converts it into a string, and renames it to `devaddr fusion`. The data in `dev addr fusion` will then be equivalent to the virtual device's `dev id`, i.e., the virtual device ID. Since different data are stored in different registers, this decision provides different exit points for different register addresses to operate on different variables. Therefore, the result obtained by the data format conversion component is then used by the conditional branching component to determine its destination.
[0049] The conditional branch processing component outputs the result to the function component, which then encapsulates the data into the format required by the virtual device data writing component's input, preparing the data for writing to the virtual device.
[0050] As one implementation method, the specific steps for inputting input information into a virtual device for testing are as follows:
[0051] Obtain the input information, perform targeted input based on the virtual device ID matched by the input information, and then write the corresponding values recorded in the input information into the variables to obtain the writing status of several variables in the virtual device ID.
[0052] Specifically, the virtual device variables are modified according to the input information through the virtual device data writing component. With the help of the overall system architecture, three modules and multiple core components, the private communication protocol data processing flow, object model creation and virtual device construction can be simulated in a visual component manner.
[0053] In another implementation, when a virtual device needs to actively construct data frames to send data to a host computer, and the data is actively sent from the slave device to the host computer, but there is currently a host computer device that has not undergone communication testing, and there is no readily available slave device, the system of this application embodiment can be used to quickly construct a virtual slave device according to the frame format of a proprietary protocol, and actively send data to the host computer to test the host computer's data frame parsing function.
[0054] Specifically, a trigger signal is sent periodically by a timed triggering component; in this embodiment, it is triggered once every 5 seconds. The virtual device data reading component reads the data required by the specified virtual device, such as "water level." The data encapsulation component encapsulates the water level data into a data frame. The function component combines the multiple data generated by the data generation component with the water level data, calculates the total data length in bytes, and constructs a new message format. The data synthesis component synthesizes the several data sets, outputs the synthesized data, and then sends it to the host computer through the data output module.
[0055] The virtual device reads data from its own object model table.
[0056] Reference Figure 2 This application provides a private communication protocol testing system, which includes:
[0057] Object Model Management Module 1: Used to obtain control request frames and create object models based on the parsed control request frames;
[0058] Virtual Device Management Module 2: Used to create virtual devices by simulating the data storage inside the device based on the object model;
[0059] Data processing flow construction module 3: It is used to obtain private protocol information, convert the private protocol information into a format that matches the virtual device, obtain input information, input the input information into the virtual device for testing, and write behavior flowcharts and data processing logic for the virtual device based on the input information.
[0060] Specifically, the object model management module is used to define, generate, and manage object models for a class of devices, ultimately generating a globally unique object model object. In the visualization page, the data point names for a particular type of device can be pre-configured, such as temperature, humidity, and pressure, and read / write permissions for each data point must be set. A unique object model ID also needs to be entered, allowing the virtual device management module to reference the target object model.
[0061] The Virtual Device Management module is used to create virtual devices. When no existing device is available but private protocol communication testing is required, this module can be used to construct a virtual device to simulate data storage within a physical device. Each virtual device requires specifying its object model during creation, using an object model ID. Specifying the object model indicates that the virtual device contains the data described in the target object model. This module will establish an independent data storage area for each virtual device based on the information in the object model to simulate the internal data storage of the device. Subsequently, the virtual device read / write interface provided by this module can be used to read and write data to the virtual device within the test system flowchart. The object model ID, virtual device ID, virtual device IP, and virtual device port information can be pre-configured on the visualization page. The "Virtual Device ID" is unique; each virtual device is unique.
[0062] The data processing workflow construction module provides drag-and-drop components and their configuration functions, as well as inter-component connection and interaction capabilities. This module allows for the construction of private protocol communication workflows through visual configuration software and low-code programming. By encapsulating commonly used essential functions of the communication system into independently schedulable modular components, it enables the rapid and flexible construction of private protocol processing workflows. The drag-and-drop components provided within this module include virtual device read / write components, data generation components, data synthesis components, data parsing components, data sending components, data receiving components, conditional branch processing components, function components, and timed triggering components.
[0063] The data receiving component receives data sent from the peer, outputting the received data as a JSON array, including the peer's interface information. The input to this component is the data sent from the peer. The output is a JSON array representing the received data and the peer's interface information, such as {"recv_data":[xx,xx,xx...],"opposite_info":{"ip":"xxx.xxx.xxx.xxx","port":10001}}. Here, `recv_data` is a freely configurable key for the raw data, and the array stores the received data from the peer in bytes. When using TCP or UDP communication, the peer's IP and port information are recorded in the `opposite_info` object. The local interface information can be configured in the configuration options. Depending on the communication method, such as TCP, UDP, or serial port, the corresponding IP / Port or serial port path can be set. By configuring these options, the data receiving component can receive data sent from the peer, output it as a JSON array, and record the peer's interface information.
[0064] The data parsing component is used to extract a specified subset of data from a character array containing data. It supports two parsing methods: extracting data based on byte indices and extracting data based on identifiers.
[0065] The input to this component is a JSON array carrying data, such as {"payload":[11,22,33,44]}. The output is a truncated data fragment, represented as a JSON array, such as {"data_fragment":[22,33]}, where [22,33] is the data extracted from the input [11,22,33,44].
[0066] In the configuration options, you can set the new key name for the truncated data and the target data key position to specify the location of the data to be parsed. You also need to select the data truncation method. One method is based on byte indices: this method extracts data from a specified range within the data array based on the set start and end byte indices. This method is suitable when the total data length is known. Another method is based on identifiers: this method identifies the entered header and tail identifiers and extracts the data between them. This method is suitable when the total data length is unknown but the header and tail identifiers are known. By configuring these options, the data parsing component can extract a specified subset of data from the data array as needed and output the truncated data fragment. This facilitates further data processing and analysis.
[0067] The data sending component is used to send data to the peer in bytes. This component supports three interface protocols: TCP, UDP, and serial port. Its input is JSON-formatted data containing the data to be sent, and its output is the data sent to the peer in bytes. Configurable information in the component includes the interface protocol, whether it's TCP or UDP, and whether it's a serial port protocol. The interface protocol selected is TCP, UDP, or serial port for data transmission. For TCP / UDP, the peer IP address, peer port, and local port need to be configured. For serial port, the serial port path needs to be configured. Based on these configuration options, the data sending component can send data to the specified peer.
[0068] The data generation component is a module used to automatically generate data. It generates data based on pre-configured information and rules and outputs it in JSON array format. This component is often used to provide dynamic data for various parts of data frames in a test system. Each time the component is triggered, the data changes based on the previous iteration. The input to this component can be any input source with triggering properties. The output is data generated according to pre-configured information and rules, represented as key-value pairs, such as {"data_name":data}, where "data_name" is the key name specified by the configuration, and data represents the value of a variable. In the configuration options, you can set the key name of the generated data for naming the output data. Here are some configuration options: Fixed Value: Enter a fixed value as the generated data. Recursive Order Value: Generate a series of recursive data based on the set initial value, minimum value, maximum value, increment or decrement method, and data type. You can choose whether to generate data in a loop. Specified Order Value: Generate data sequentially according to the order entered. You can enter one or more data values, and one or more arrays are also supported. Free Random Values: Generates random data that meets specified conditions based on initial, minimum, and maximum values, as well as data type. You can choose whether to generate data cyclically. Random Ordered Values: Similar to specifying ordered values, but the output order is random. By configuring these options, the data generation component can automatically output data that conforms to rules according to requirements, providing dynamic data support for the testing system.
[0069] The data format conversion component is a component that converts input data into a specified format or type and outputs formatted data. Supported conversion types include, but are not limited to: character array to string; string to character array; integer to multibyte data and store in an array; multibyte data to integer; floating-point number to 4-byte data and store in an array; and four-byte data to floating-point. The component takes JSON-formatted data as input, such as {"data_before":305419896}. The output is the converted data in JSON format, for example, converting an integer to four-byte data {"data_after":[0x12,0x34,0x56,0x78]}. By configuring these options, the data format conversion component can convert input data into a specified format or type as needed and output formatted data. This facilitates the conversion and processing between different data types.
[0070] Functional components are used within the built-in programming system, providing a programming window to freely process data input into the component or to supplement undefined functionalities within the system. They support constant or variable declarations, arithmetic operations, logical operations, common functions, JSON parsing or construction, increasing the system's flexibility and extensibility. The component can use the output of any preceding component as its input source. The output is a formatted JSON message. The configuration options allow setting three functionalities: Initialization function: This code executes only the first time the component runs. Initialization operations can be performed here, or it can be left blank. Main function: This code executes every time the component is triggered. Specific functional logic can be implemented here, including constant or variable declarations, arithmetic operations, logical operations, calling common functions, JSON parsing or construction, etc. Termination function: This code executes when the component stops running. Cleanup operations can be performed here, or it can be left blank.
[0071] The data composition component is a component that can sequentially combine data from multiple input channels into a single set of data. This component supports multi-channel input, each channel can carry data, and the input must be in JSON array format. For example, channel 1 input: {"data_name1":[0x12,0x34]}, channel 2 input: {"data_name2":[0x56,0x78]}. The output is a character array that is sequentially merged from all channels into a single character array and output in JSON array format. For example, {"composed_data":[0x12,0x34,0x56,0x78]}, the data is composed of data from channel 1 and channel 2. In the configuration options, the following options can be set: Key Name of the Composite Data: Specifies the key name used in the output of the composite data. Add Input Channel Button: Clicking this button adds an input channel, which will need to be configured later. Channels are numbered sequentially, and the data will be composed according to the channel order during the final synthesis. Target Data Key Position: Specifies the source of the data participating in the synthesis operation. By configuring these options, the data synthesis component can sequentially combine data from multiple input channels into a single set of data and output it as a JSON array. This allows for convenient integration and processing of data from multiple channels.
[0072] The conditional branching component provides conditional judgment and branching functionality. It allows adding multiple judgment conditions, each corresponding to an independent exit point. When the value of a specified target data key meets a certain condition, the component sends the input data to the corresponding exit point. The input is a JSON formatted content carrying the data to be judged. The output is the same as the input. The component allows setting the following options: Target data key position: used as the left-hand side of the logical judgment; Add judgment condition and exit button: clicking this button adds a judgment condition and exit point, which then needs to be configured; Allows setting multiple judgment conditions, each corresponding to an exit point; Logical judgment operators and their right-hand sides: Supports, but is not limited to, commonly used logical judgment operators, such as equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to, empty, etc. The right-hand side of the judgment must also be entered, which can come from dynamically input content. By configuring these options, the conditional branching component can judge the value of the target data key based on specified conditions and send the input data to the corresponding exit point that meets the condition. This allows for convenient branching processing of data based on different conditions.
[0073] The Virtual Device Data Reading Component is a dedicated component for reading data from the object model table corresponding to a virtual device. This component can read specified data from the object model table of a specified device based on the input configuration information. The input is JSON formatted data with request target information. The following information can be configured in the input: Target Device ID: Specifies which device's data to read. Tag Name: Specifies which data to read. Multiple tag names can be configured to read multiple data sets at once. The output is the data read from the target device's object model. The returned data is represented in JSON format, containing the device ID and the specific data value. By configuring these options, the Virtual Device Data Reading Component can read specified data from the object model table of a specified device based on the input configuration information and return the read data. If the input message contains `dev_id` and `tags` fields, the content in the input message is used as the configuration information; if the input does not contain special fields, the default configuration items filled in directly in the component are used.
[0074] The Virtual Device Write component is specifically designed for writing data to virtual devices. This component can write specified data to a designated virtual device based on the input configuration information. The input is JSON data with write request information. The following information can be configured in the input: Target device ID: Specifies which virtual device to write data to. Tag name and value to be written: Specifies which variable to write what value to. Multiple tag names and their corresponding values can be configured to write multiple data items at once. The output is feedback on the write result. The returned data is in JSON format, containing the device ID and the write status of each tag. If the input message includes `dev_id` and `tags` fields, the content in the input message will be used as the configuration information; if the input does not have special fields, the default configuration items filled in directly in the component will be used.
[0075] The timed trigger component will output the current time periodically according to the set time interval. The output of this component can be used as a trigger signal to enter the input of other components.
[0076] This application provides a private communication protocol testing device, including a memory and a processor. The memory stores a computer program, and the processor is configured to run the computer program to perform the private communication protocol testing method as described above.
[0077] This application provides a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the private communication protocol testing method described above when running.
[0078] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the device and product described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0079] In the several embodiments provided in this application, it should be understood that the disclosed methods, systems, apparatus and program products can be implemented in other ways.
[0080] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0081] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for testing a proprietary communication protocol, characterized in that, include: Obtain the control request frame and create an object model based on the parsed control request frame; A virtual device is created by simulating the data storage inside the physical device using a physical model. Obtain private protocol information, convert the private protocol information into a format that matches the virtual device, obtain input information, input the input information into the virtual device for testing, and write a behavior flowchart for the virtual device based on the input information; The specific steps for converting the private protocol information into a format matching the virtual device are as follows: consolidating the bytes representing the device address in the private protocol information into an integer, converting the integer into a string, and then matching the string with the virtual device ID; and The string and the matching virtual device ID are encapsulated into the format required by the virtual device input to obtain the input information.
2. The private communication protocol testing method according to claim 1, characterized in that, The specific steps for creating a virtual device based on the data storage within the simulated device using a physical model are as follows: The virtual device is obtained by acquiring data from the simulated device in the physical model and establishing several independent data storage areas based on the data.
3. The private communication protocol testing method according to claim 2, characterized in that, Also includes: A visualization page is provided, on which the object model ID, virtual device ID, virtual device IP, and virtual device port of the object model used by the virtual device are configured in advance.
4. The private communication protocol testing method according to claim 1, characterized in that, The specific steps for inputting the input information into the virtual device for testing are as follows: Obtain the input information, perform targeted input based on the virtual device ID matched by the input information, and then write the corresponding values recorded in the input information into the variables to obtain the writing status of several variables in the virtual device ID.
5. The private communication protocol testing method according to claim 1, characterized in that, The input information is a JSON message.
6. A proprietary communication protocol testing system, characterized in that, include: Object Model Management Module: Used to obtain control request frames and create object models based on the parsed control request frames; Virtual Device Management Module: Used to create virtual devices by simulating the internal data storage of devices based on the object model; The data processing flow construction module is used to acquire private protocol information, convert it into a format matching the virtual device, obtain input information, input the input information into the virtual device for testing, and write a behavior flowchart for the virtual device based on the input information. Specifically, the steps for converting the private protocol information into a format matching the virtual device are: consolidating the bytes representing the device address in the private protocol information into an integer, converting the integer into a string, and then matching the string with the virtual device ID; and... The string and the matching virtual device ID are encapsulated into the format required by the virtual device input to obtain the input information.
7. A proprietary communication protocol testing device, characterized in that, It includes a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the proprietary communication protocol testing method according to any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the private communication protocol testing method according to any one of claims 1-5 at runtime.
Citation Information
Patent Citations
Testing method and testing device based on communication protocol
CN105577463A