Industrial network protocol test control method, device, equipment and medium
By using the user-space protocol stack and Python plugin scripts of the industrial network protocol testing system, real-time filtering of response content and dynamic modification of protocol fields in industrial network testing are realized, solving the problem of insufficient test coverage in existing technologies and improving the flexibility and reliability of testing.
Patent Information
- Application Number
- CN202511948723.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-02-13
AI Technical Summary
Existing industrial network testing equipment cannot achieve real-time filtering of response content, dynamic modification of protocol fields, and dynamic reconstruction of service authentication responses required by industrial simulation scenarios, resulting in insufficient test coverage.
An industrial network protocol testing system is adopted, which parses response messages layer by layer through the user-space protocol stack and uses Python plugin scripts for dynamic processing, including field modification and redundant data filtering. Combined with memory operations and network graphical user interface interaction, it achieves efficient test process control.
It improves the dynamic processing capability and reliability of testing, shortens the test case development time, reduces maintenance costs, and meets the diverse testing needs of industrial scenarios.
Smart Images

Figure CN121530893A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of industrial network testing, and in particular to an industrial network protocol test control method, a corresponding device, an electronic device, and a computer readable storage medium. BACKGROUND
[0002] With the popularity of the industrial internet in the fields of intelligent manufacturing, energy, and rail transportation, industrial network testing is upgrading from "basic functional verification" to "complex scenario simulation", and the demand for "traffic dynamic processing" is increasingly urgent. Typical scenarios include:
[0003] First, when testing a device operation and maintenance Web platform that uses a "username + password + dynamic Token" dual authentication mechanism, it is necessary to generate Token expiration, permission mismatch, malicious tampering, and other abnormalities in real time through dynamic response reconstruction to verify the reliability and security of the entire authentication link.
[0004] Second, when testing industrial HTTP ecological collaboration capabilities, it is necessary to dynamically modify the server response to "200 OK request success" or "500 Server Internal Error server internal error" according to the client request path, parameters, and server resource state, rather than returning "500 Server Internal Error server internal error" for all requests.
[0005] Third, when testing Modbus firewall, it is necessary to dynamically change the fixed function code 0x03 (read register) to 0x06 (write register) according to the real-time register state of the device under test (such as whether it is occupied), simulate illegal requests triggered by operation permission changes during operation, and verify the firewall's interception of illegal operations.
[0006] Fourth, when testing PLC and host computer communication, it is necessary to filter redundant state register fields in the response in real time and only keep key control signals such as motor speed and valve opening, simulating the data transmission simplification requirements in the real generation environment.
[0007] The above requirements all rely on "real-time, customized traffic dynamic processing capabilities", that is, real-time modification of traffic content, synchronization of associated fields (such as Modbus cyclic redundancy check code, data field length), and feedback of processing results to hardware execution according to test requirements.
[0008] Current industrial network test equipment has realized the basic protocol analysis function, but there is a significant technical fault in dynamic processing capability, only supporting "flow playback" and "fixed parameter flow generation", and cannot realize the needs of "real-time filtering of response content, dynamic modification of protocol field, dynamic response reconstruction of service authentication" required by industrial simulation scene; in high-end manufacturing scenarios, often due to the inability to simulate complex protocol exceptions, resulting in insufficient test coverage.
[0009] In summary, to adapt to the fact that the industrial network test in the prior art cannot realize the needs of real-time filtering of response content, dynamic modification of protocol field, dynamic response reconstruction of service authentication required by industrial simulation scene, and in high-end manufacturing scenarios, often due to the inability to simulate complex protocol exceptions, resulting in insufficient test coverage and other problems, the applicant made corresponding exploration to solve the problem. SUMMARY
[0010] The purpose of the present application is to solve the above problems and provide an industrial network protocol test control method, a corresponding device, an electronic device and a computer readable storage medium.
[0011] To meet the various purposes of the present application, the present application adopts the following technical solutions:
[0012] An industrial network protocol test control method proposed to adapt to one of the purposes of the present application, comprising:
[0013] The industrial network protocol test system obtains the to-be-tested traffic corresponding to the to-be-tested industrial control protocol, and sends the to-be-tested traffic to a target device to trigger the target device to return a response message;
[0014] The flow sending and receiving module captures the response message returned by the target device, and parses the Ethernet header, Internet Protocol header and transport layer header of the response message layer by layer by a user mode protocol stack, extracts each layer protocol field containing source address, target address, port number and sequence number, wherein the user mode protocol stack runs in the user space of the operating system, supports direct operation of operating system underlying memory data and does not need kernel mode copy;
[0015] The dynamic processing module calls the conditional judgment logic in the Python plug-in script to judge whether dynamic processing is needed for the response message, and if dynamic processing is needed, stores the parsed application layer payload into the variable storage area corresponding to the current flow, wherein the variable storage area supports storing the message memory pointer of the application layer payload to perform coherent operation on the data of different stages of the same session, and multiple sessions are parallel without interference;
[0016] The application layer load is modified in the field and redundant data filtering operation based on preset data dynamic processing interface function calling custom processing logic, and the associated fields containing check code and data length are automatically updated. After the processing result of the application layer load is verified by the preset data verification interface function, the processed response message is sent to the target device by the preset message sending interface function, and after the test flow is executed, the cache data of the variable storage area corresponding to the current flow and the session context information are cleaned up by the preset data release interface function.
[0017] The program instruction sequence of the current flow is checked whether it has been executed completely, if yes, the network port, the cache data of the variable storage area corresponding to the current flow and the session context information are released by the client or server management module, the network indicators including byte number, concurrent connection number, network delay and packet loss number are received by the data statistical module, and the network graphical user interface interaction layer or the command line interface interaction layer is fed back to the user.
[0018] Optionally, before the step of obtaining the to-be-tested traffic corresponding to the to-be-tested industrial control protocol and sending the to-be-tested traffic to the target device to trigger the target device to return a response message, the industrial network protocol test system further comprises the steps of:
[0019] determining a to-be-tested industrial control protocol type, obtaining a to-be-tested field, test parameters and a Python plug-in script corresponding to the to-be-tested industrial control protocol, wherein the Python plug-in script contains dynamic processing rules and conditional judgment logic corresponding to the to-be-tested industrial control protocol, and the test parameters include basic attributes, data structure parameters and transmission control parameters of the to-be-tested industrial control protocol;
[0020] generating a JSON configuration file according to the Python plug-in script, and storing the test parameters, the to-be-tested field, the Python plug-in script and the JSON configuration file to a memory ring buffer;
[0021] The data processing layer reads the JSON configuration file and the associated to-be-tested field and Python plug-in script from the memory ring buffer, and the application layer processing module parses the role definition, network address information and stream processing logic of the industrial network protocol test system to generate application layer data, wherein the network address information includes IP address, port number and MAC address;
[0022] The user-mode protocol stack performs transport layer encapsulation and network layer encapsulation on the application layer data to generate to-be-tested traffic containing complete protocol headers and application layer data.
[0023] Optionally, the step of dynamically processing the application layer payload based on the preset data dynamic processing interface function, performing field modification and redundant data filtering operations, and automatically updating associated fields including check codes and data lengths comprises:
[0024] The application layer payload obtained by parsing the user-mode protocol stack is processed by calling the dynamic processing rule of the Python plug-in script customized according to the industrial control protocol to be tested through the preset data dynamic processing interface function, so as to perform protocol field modification and redundant data filtering operations.
[0025] When performing the field modification and redundant data filtering operations, the associated fields including check codes and data lengths corresponding to the application layer payload are automatically updated synchronously to ensure that the frame structure of the application layer payload after dynamic processing conforms to the industrial control protocol to be tested, wherein the check code is updated in real time by calculating the modified data field, and the data length is adjusted synchronously according to the number of valid data bytes after filtering.
[0026] Optionally, the step of verifying the processing result of the application layer payload by the preset data verification interface function comprises:
[0027] The processing result of the application layer payload processed by the data dynamic processing interface function is verified by the preset data verification interface function.
[0028] If the parameter of the data verification interface function is not empty, the application layer payload processing result stored in the variable storage area corresponding to the parameter is displayed; if the parameter of the data dynamic processing interface function viewed by the data verification interface function is empty, all internal cache contents related to the application layer payload in the variable storage area are listed to complete the debugging and verification of the application layer payload processing result.
[0029] Optionally, the processed response message is sent to the target device by the preset message sending interface function, and after the test process is completed, the cache data of the variable storage area is cleaned by the preset data release interface function, and the step comprises:
[0030] The response message corresponding to the application layer payload processed by the data dynamic processing interface function and verified by the data verification interface function without error is sent to the target device by the preset message sending interface function.
[0031] After the corresponding test process is completed, the cache data of the variable storage area is cleaned by the preset data release interface function, if the parameter of the data release interface function is not empty, the cache content of the variable storage area corresponding to the parameter is cleaned, and if the parameter of the data release interface function is empty, all internal cache contents of the variable storage area are cleaned to avoid memory leakage in a high-concurrency test scenario.
[0032] Optionally, the program instruction sequence of the current flow is checked whether it has been executed completely, if it has been executed completely, the client or server management module releases the network port, the cache data corresponding to the current flow in the variable storage area and the session context information, the data statistics module receives the network indicators including the byte number, the concurrent connection number, the network delay and the packet loss number, and the step of feeding back to the user through the network graphical user interface interaction layer or the command line interface interaction layer, including:
[0033] After completing the dynamic processing and sending of the application layer load, or performing data volume statistics on the response message, it is checked whether the program instruction sequence corresponding to the current flow has been executed completely; if it is determined that it has been executed completely, the server or client management module performs a protocol layer disconnection operation on the current network connection, and sequentially releases the network port associated with the flow, the session-level variable storage area corresponding to the current flow and the session context information, wherein the session context information includes a Token value, a register state and a connection state.
[0034] At the same time, the data statistics module real-time statistics the network indicators including the port received byte number, the concurrent connection number, the network delay and the packet loss number corresponding to the current flow, and feeds back the statistics results to the user in real time through the network graphical user interface interaction layer or the command line interface interaction layer.
[0035] Optionally, the target device includes a programmable logic controller, a Modbus firewall, a dual authentication Web platform or an industrial HTTP server.
[0036] An industrial network protocol test control device is provided to adapt to another purpose of the present application, comprising:
[0037] A response message determination module is set to obtain the to-be-tested traffic corresponding to the to-be-tested industrial control protocol by the industrial network protocol test system, and send the to-be-tested traffic to the target device to trigger the target device to return a response message.
[0038] A protocol field extraction module is set to capture the response message returned by the target device by the traffic sending and receiving module, and parse the Ethernet header, the Internet protocol header and the transport layer header of the response message layer by layer by a user mode protocol stack, and extract the protocol fields of each layer including the source address, the target address, the port number and the sequence number, wherein the user mode protocol stack runs in the user space of the operating system, supports direct operation of the underlying memory data of the operating system and does not need kernel mode copy.
[0039] The application layer payload storage module is configured to call the condition judgment logic in the Python plugin script of the dynamic processing module to determine whether the response message needs to be dynamically processed. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current stream. The variable storage area supports storing the message memory pointer of the application layer payload to perform coherent operations on data at different stages of the same session, and multiple sessions do not interfere with each other when running in parallel.
[0040] The traffic dynamic processing module is configured to call custom processing logic based on a preset data dynamic processing interface function to modify fields and filter redundant data in the application layer payload. At the same time, it automatically updates the associated fields containing the checksum and data length. After verifying the processing result of the application layer payload through a preset data verification interface function, the processed response message is sent to the target device by a preset message sending interface function. After the test process is completed, the cached data in the variable storage area is cleared through a preset data release interface function.
[0041] The network metrics statistics module is configured to check whether the program instruction sequence of the current stream has been fully executed. If it has been fully executed, the client or server management module releases the cached data and session context information corresponding to the current stream in the network port and variable storage area. The data statistics module receives network metrics including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command line interface interaction layer.
[0042] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the industrial network protocol test control method described in this application.
[0043] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the industrial network protocol test control method, which, when invoked by a computer, executes the steps included in the corresponding method.
[0044] Compared to existing technologies, this application addresses the shortcomings of existing technologies in industrial network testing, such as the inability to achieve real-time filtering of response content, dynamic modification of protocol fields, and dynamic response reconstruction of service authentication required for industrial simulation scenarios. It also addresses the issue of insufficient test coverage in high-end manufacturing scenarios due to the inability to simulate complex protocol anomalies. This application includes, but is not limited to, the following beneficial effects:
[0045] Firstly, it has stronger dynamic processing capabilities: Existing technologies cannot adjust core fields in real time. This application achieves this through "Python plugin functions + memory operations". Through plugin functions such as data dynamic processing interface functions, data verification interface functions, message sending interface functions, and data release interface functions, the processing logic can be flexibly defined. Direct memory operations eliminate the copying and reconstruction steps, break through the limitations of static configuration, and can simulate dynamic anomalies such as parameter errors and insufficient resources in industrial scenarios.
[0046] Secondly, the test reliability is higher: Existing technologies are prone to errors when manually synchronizing associated fields, have limited test scenario coverage, and are difficult to simulate dynamic interactions in real networks. The plug-in function of this application can directly modify any protocol field in memory, and in conjunction with the variable pool, it can achieve automatic synchronization of associated fields, such as automatically updating the data length after modifying the Modbus response and recalculating the cyclic redundancy check code.
[0047] Thirdly, it offers better scalability and adaptability: Existing technologies suffer from closed architectures, making customization difficult, secondary development reliant on vendor support, and test case maintenance costs high. This application utilizes standardized Python plugin interface functions, allowing test logic to be managed independently in script form; its modular architecture enables functional expansion without modifying the core code. This application significantly reduces test case development time from weeks to hours, substantially lowering the overall lifecycle maintenance cost and meeting the diverse testing needs of industrial scenarios. Attached Figure Description
[0048] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0049] Figure 1 This is a flowchart illustrating the industrial network protocol testing and control method in an embodiment of this application.
[0050] Figure 2 This is a flowchart of the industrial network protocol test control method in the embodiments of this application;
[0051] Figure 3 This is an exemplary network architecture diagram of the industrial network protocol test and control system in the embodiments of this application;
[0052] Figure 4 This is a schematic diagram of memory variable management in an embodiment of this application;
[0053] Figure 5 This is a schematic block diagram of the industrial network protocol testing and control device in the embodiments of this application;
[0054] Figure 6 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0055] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0056] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0057] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0058] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDA (Personal Digital Assistant) that may include a radio frequency receiver, pager, internet / intranet access, web browser, notepad, calendar, and / or GPS (Global Positioning System) receiver; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0059] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0060] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0061] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0062] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0063] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0064] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0065] Please see Figure 1 as well as Figure 2 In one embodiment of the industrial network protocol test control method of this application, the method includes:
[0066] Step S10: The industrial network protocol testing system obtains the test traffic corresponding to the industrial control protocol to be tested, and sends the test traffic to the target device to trigger the target device to return a response message;
[0067] Please see Figure 3The role of the industrial network protocol testing system can be defined as a client or a server, etc. The industrial network protocol testing system can obtain the test traffic corresponding to the industrial control protocol to be tested, and send the test traffic to the target device to trigger the target device to return a response message; wherein, the target device includes a programmable logic controller (PLC), a Modbus firewall, a dual-authentication web platform or an industrial HTTP server, etc.
[0068] In some embodiments, the industrial network protocol testing system includes a network graphical user interface (WebGUI) interaction layer or a command line interface (CLI) interaction layer, a resource pool layer, and a data processing layer. The data processing layer includes an application layer processing module, a user-space protocol stack, a server or client management module, a traffic sending and receiving module, and a data statistics module, etc.
[0069] Furthermore, the WebGUI or CLI interaction layer serves as the entry point for user operation and visualization. Users can directly select predefined traffic models through the WebGUI or CLI interaction layer. These predefined traffic models contain all parameters for traffic generation and a "command 1 → command 2 → command 3" streaming processing logic, and key parameters of the model can also be edited. The system supports writing standardized Python plugin scripts via the CLI to define dynamic processing flows. Simultaneously, the system provides a file upload function, supporting the uploading of configuration files for custom traffic models and dynamic processing flow scripts. During testing, the WebGUI or CLI interaction layer receives data returned from the resource pool layer and displays the port connection status, network quality indicators of the test port, and sent / received data packet information in real time through the Web interface, providing users with intuitive feedback.
[0070] Furthermore, the resource pool layer serves as a data bus, acting as an intermediary bridge between the WebGUI or CLI interaction layer and the data processing layer. It manages the memory ring buffer and session resources. The resource pool layer stores dynamic processing scripts and configuration files issued by the WebGUI or CLI interaction layer, ensuring data integrity and real-time performance during cross-layer transmission. It manages session contexts such as Modbus session token values, register states, and connection states, providing a unified resource access interface for the data processing layer. It enables efficient data transfer, sending configurations and dynamic processing scripts to the user-space protocol stack of the data processing layer, while simultaneously sending statistical results from the data processing layer back to the WebGUI or CLI interaction layer, including throughput, concurrency, and packet loss.
[0071] Furthermore, the data processing layer is the core of the entire system's data processing and is implemented using a C-Python hybrid architecture. The application layer processing module is responsible for parsing and generating application layer data for each protocol. It can construct various network protocol application layer data based on predefined JSON scripts. It also supports in-depth parsing of application layer payloads, such as extracting function codes, register data, token fields, etc.
[0072] The user-space protocol stack, including a user-space TCP protocol stack or a user-space IP protocol stack, executes a complete TCP state machine process in user space, including the reception, out-of-order reordering, and retransmission control of industrial control messages. Its built-in dynamic processing module is the core of the system's flexibility, used to load, interpret, and execute user-provided Python plugin scripts. It directly accesses message data in the system's underlying memory (e.g., the C layer) without copying it, and sends the processed data directly from the system's underlying memory (e.g., the C layer), greatly improving efficiency. It supports allocating a dedicated variable storage area for each industrial control flow object, used to pass and save context data during multiple interactions within the same flow. Through this module, users can inject custom dynamic processing logic without modifying or recompiling the C / C++ core engine, achieving fine-grained control over traffic content and behavior.
[0073] The server or client management module is responsible for managing the lifecycle of network connections, adapting to the high concurrency requirements of industrial scenarios. It acts as a client or server based on traffic configuration files, handling connection initialization, three-way handshake establishment, maintenance, and normal four-way handshake termination. It supports managing a large number of industrial control sessions simultaneously, with each session maintaining its own independent context. When a connection times out or the target device disconnects, it automatically releases session resources such as variable storage areas and port numbers to prevent memory leaks.
[0074] The traffic sending and receiving module, as the execution engine of the data plane, is responsible for efficiently and accurately sending and receiving raw data frames on the physical network interface: it sends the processed industrial control messages directly to the physical network card through the user-space protocol stack, supports precise control of the sending rate and frame interval, and meets the high-performance testing requirements of industrial scenarios; it captures the industrial control response messages returned by the target device through the network card interface accelerated by the field-programmable gate array (FPGA) and sends them directly to the user-space protocol stack for parsing, avoiding kernel-space copy delay.
[0075] The data statistics module calculates network metrics for the transmission and reception traffic of each port, including the cumulative number of bytes sent or received, the number of new connections per second (CPS), the number of concurrent connections, the real-time transmission or reception bandwidth, the network latency (RTT), and the cumulative number of packet losses.
[0076] In some embodiments, before the industrial network protocol testing system acquires the test traffic corresponding to the industrial control protocol under test and sends the test traffic to the target device to trigger the target device to return a response message, the following steps are included:
[0077] Step S101: Determine the type of industrial control protocol to be tested, and obtain the fields to be tested, test parameters and Python plugin scripts corresponding to the industrial control protocol to be tested. The Python plugin script contains dynamic processing rules and condition judgment logic corresponding to the industrial control protocol to be tested. The test parameters include the basic attributes, data structure parameters and transmission control parameters of the industrial control protocol to be tested.
[0078] Specifically, the first step is to determine the specific type of the industrial control protocol to be tested, such as Modbus, Industrial HTTP, OPC UA, etc. This is the prerequisite for subsequent field matching, script adaptation, and traffic encapsulation, ensuring that all configurations are consistent with the protocol specifications.
[0079] Extract the key core fields of the protocol, such as Modbus function code and register address, Industrial HTTP Token field and response status code, etc., as fields to be detected in subsequent dynamic processing;
[0080] The test parameters include the basic attributes, data structure parameters, and transmission control parameters of the industrial control protocol under test. The basic attributes of the industrial control protocol under test include protocol type, transport layer port or frame priority, etc.; the data structure parameters include function code, operation type, data length, register start address, etc.; and the transmission control parameters include transmission rate, frame interval or burst count, etc.
[0081] The Python plugin script is a customized script written by the user through the WebGUI / CLI interaction layer. This script is the core carrier for implementing dynamic processing and has two built-in key logics, including dynamic processing rules (such as protocol field modification, redundant data filtering logic, etc.) and condition judgment logic (such as triggering dynamic processing if the register address in the response message is 0x0001 and the status field is marked as occupied; triggering abnormal response generation logic if the validity period of the Token field in the response message is <30s, etc.). Custom test logic can be embedded without modifying the system core engine.
[0082] Step S102: Generate a JSON configuration file according to the Python plugin script, and store the test parameters, the field to be detected, the Python plugin script and the JSON configuration file in a memory circular buffer;
[0083] The system automatically parses the core information (protocol type, role definition, streaming processing logic, etc.) in the Python plugin script and generates a standardized JSON configuration file. The JSON format is lightweight and easy to parse, and can be quickly recognized by the application layer processing module of the data processing layer, avoiding the complexity of direct script parsing.
[0084] Test parameters, fields to be tested, Python plugin scripts, and JSON configuration files are uniformly stored in a memory circular buffer in the resource pool layer. This memory circular buffer serves as a cross-layer data bus, ensuring that data is transmitted between the interaction layer and the processing layer without loss and with low latency, while also providing a unified resource access interface for the data processing layer.
[0085] Step S103: The data processing layer reads the JSON configuration file and associated fields to be detected and Python plugin scripts from the memory ring buffer. The application layer processing module parses the JSON configuration file, network address information and streaming processing logic of the industrial network protocol testing system to generate application layer data. The network address information includes IP address, port number and MAC address.
[0086] The data processing layer reads the JSON configuration file and associated fields to be tested and Python plugin scripts from the memory circular buffer. The application layer processing module completes the parsing. The core parsing targets include three types of key information: the role definition of the industrial network protocol testing system (client or server, specified by script or configuration), network address information (IP address, port number, MAC address, clearly identifying communication), and the "command 1 → command 2 → command 3" style streaming processing logic.
[0087] Based on the parsing results, the application layer processing module follows the standard frame format of the industrial control protocol under test (such as Modbus / TCP request format, industrial HTTP response format, etc.), integrates the test parameters and fields to be tested into it, and generates structured application layer data. This application layer data is the core content of the traffic under test, ensuring that it can be recognized as real industrial traffic by the target device after subsequent encapsulation.
[0088] Step S104: The user-space protocol stack performs transport layer encapsulation and network layer encapsulation on the application layer data to generate test traffic containing complete protocol headers and application layer data.
[0089] The user-space protocol stack is encapsulated layer by layer in the order of "application layer → transport layer → network layer". First, the application layer data is encapsulated by the transport layer (supporting TCP / UDP / SCTP protocols, adding fields such as source port number or destination port number, sequence number, etc.), and then the network layer is encapsulated (supporting IPv4 or IPv6 protocols, adding fields such as source IP address or destination IP address, TTL value, etc.).
[0090] Complete traffic generation: The final generated test traffic contains a complete structure of protocol header (transport layer header + network layer header) + application layer data, which fully complies with the specifications of the industrial control protocol under test. This design ensures that the target device can treat it as real industrial traffic after receiving it, laying the foundation for triggering response messages and realizing dynamic processing.
[0091] Step S20: The traffic sending and receiving module captures the response message returned by the target device. The user-space protocol stack parses the Ethernet header, Internet Protocol header and transport layer header of the response message layer by layer, and extracts the protocol fields of each layer containing the source address, destination address, port number and sequence number. The user-space protocol stack runs in the operating system user space, supports direct access to the underlying memory data of the operating system and does not require kernel-space copying.
[0092] The industrial network protocol testing system acquires the test traffic corresponding to the industrial control protocol to be tested, sends the test traffic to the target device to trigger the target device to return a response message, and then the traffic sending and receiving module captures the response message returned by the target device. The user-space protocol stack parses the Ethernet header, Internet Protocol header and transport layer header of the response message layer by layer, and extracts the protocol fields of each layer containing source address, destination address, port number and sequence number. The user-space protocol stack runs in the operating system user space, supports direct access to the underlying memory data of the operating system and does not require kernel-space copying.
[0093] The response message is captured by the traffic sending and receiving module in the industrial network protocol testing system. This traffic sending and receiving module uses an FPGA-accelerated network card interface as its hardware foundation. The FPGA (Field Programmable Gate Array) can directly interface with the physical network interface, skipping the "kernel-mode forwarding" link in the traditional architecture, and directly capturing the industrial control response message returned by the target device. This avoids the data copy delay between kernel mode and user mode, perfectly adapting to the stringent real-time requirements of industrial testing (such as millisecond-level response capture in PLC communication testing).
[0094] The captured response message is not processed by the complex kernel layer, but is directly sent to the user-space TCP / IP protocol stack of the data processing layer, ensuring the integrity of the message data and transmission efficiency, and saving time for the subsequent parsing process.
[0095] The parsing operation is performed by the user-space TCP protocol stack or the user-space IP protocol stack. The user-space TCP protocol stack or the user-space IP protocol stack is a core component of the data processing layer, running in the operating system user space (rather than the traditional kernel space). It directly accesses the underlying memory data of the operating system without the need for kernel-space copying. During the parsing process, it can directly access the original data of the packet in the underlying memory without copying the data from kernel space to user space. This improves parsing efficiency and avoids the loss or damage that may occur during the data copying process. This is also one of the key features that distinguishes this application from the prior art.
[0096] Furthermore, the parsing operation strictly follows the order of "Ethernet header → Internet Protocol header (IP header) → Transport layer header (TCP / UDP header)" to ensure that the protocol fields of each layer are completely extracted. Among them, the Ethernet header parsing is to extract the source MAC address and the destination MAC address, clarify the physical link transmission identifier of the packet, and provide a basis for subsequent link layer verification.
[0097] The Internet Protocol header (IP header) is parsed to extract the source IP address and destination IP address, determine the network layer transmission path of the packet, and associate the session context (such as matching the IP identifier of the corresponding test session).
[0098] The transport layer header (TCP / UDP header) is parsed to extract the source port number, destination port number, and sequence number, clarifying the end-to-end communication identifier and data transmission order of the message, avoiding subsequent processing errors caused by out-of-order delivery or packet loss, and providing an index for the association of session-level variable storage areas (such as locating the variable storage area of the corresponding stream by port number).
[0099] On the one hand, the legality of message transmission is verified by parsing layer by layer (such as whether the field format conforms to the specifications of the industrial control protocol under test), so as to prevent illegal frames from entering the subsequent processing flow. On the other hand, the extracted protocol fields of each layer will serve as the basis for judgment of the dynamic processing module. The dynamic processing module needs to combine these fields (such as the session corresponding to the port number and the interaction stage corresponding to the sequence number) and the application layer payload to determine whether dynamic processing operations such as protocol field modification and redundant data filtering need to be performed.
[0100] As can be seen from step S20 above, compared with the limitations of existing technologies where the original traffic modification mode relies on fixed frame templates and the standardized configuration mode only supports static parameters, this step S20 achieves high real-time and high-reliability interaction from request to response by combining dynamically generated traffic, FPGA accelerated capture, and user-space protocol stack parsing, providing a feasible premise for subsequent dynamic processing. The protocol fields extracted during the parsing process are not only the basis for dynamic processing, but also the foundation for the data statistics module to calculate network indicators (such as counting packet loss of specific devices based on IP address and calculating network latency based on sequence number), ensuring the integrity of the test process and the accuracy of data feedback, and ultimately improving the flexibility, authenticity, and coverage of the test.
[0101] Step S30: The dynamic processing module calls the condition judgment logic in the Python plugin script to determine whether the response message needs to be dynamically processed. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current stream. The variable storage area supports storing the message memory pointer of the application layer payload so as to perform coherent operations on data at different stages of the same session, and multiple sessions do not interfere with each other when running in parallel.
[0102] The traffic sending and receiving module captures the response message returned by the target device. The user-space protocol stack parses the Ethernet header, Internet Protocol header, and transport layer header of the response message layer by layer, extracting the protocol fields of each layer, including source address, destination address, port number, and sequence number. The dynamic processing module calls the conditional judgment logic in the Python plugin script to determine whether the response message needs to be dynamically processed. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current flow. The variable storage area supports storing the message memory pointer of the application layer payload to perform coherent operations on data at different stages of the same session, and multiple sessions do not interfere with each other when running in parallel. The application layer payload refers to the core business data contained in the network packet at the application layer (the highest layer of the OSI seven-layer model), which is the actual communication content of the industrial control protocol under test. For example, in the Modbus protocol, the application layer payload includes function code, register address, data length, register data, and checksum, etc.
[0103] Specifically, the traffic sending and receiving module captures the response message returned by the target device. The user-space protocol stack parses the Ethernet header, Internet Protocol header, and transport layer header of the response message layer by layer, extracting the protocol fields of each layer, including source address, destination address, port number, and sequence number. After this is completed, the dynamic processing module of the data processing layer loads and calls the preset condition judgment logic in the Python plugin script. This Python plugin script is a customized script written or uploaded by the user through the WebGUI / CLI interaction layer. It has built-in judgment rules adapted to the industrial control protocol under test, such as "if the register address in the response message is 0x0001 and the status field is marked as 'occupied', then dynamic processing is triggered" and "if the validity period of the Token field in the response message is <30s, then abnormal response generation logic is triggered". The judgment criteria are directly related to the parsed protocol fields of each layer and the subsequently extracted application layer payload, ensuring that the judgment logic is strongly bound to the test scenario.
[0104] The core function of the judgment logic is to distinguish between scenarios that require dynamic processing and those that do not. If dynamic processing is not required, the data statistics module will only perform data volume statistics (such as updating the cumulative number of bytes received) on the response message, without storing the data, and will directly jump to the subsequent process of checking whether the program instructions have been executed, to ensure testing efficiency. If dynamic processing is required, the next step is to enter the application layer payload storage stage to prepare for subsequent customized processing.
[0105] Furthermore, when the response message is dynamically processed, the system stores the parsed application layer payload in the variable storage area corresponding to the current flow. This variable storage area is a core component of the user-defined variable pool, exclusively allocated to each industrial control flow object, and possesses several key features, including support for memory pointer storage, session-level isolation, and context association. Specifically, support for memory pointer storage means that the message memory pointer of the application layer payload can be directly stored without copying the complete data, enabling coherent operations on data at different stages of the same session (e.g., the subsequent `process_data` function can directly access the payload data in memory through the pointer for modification, and the modified `write_data` function can directly obtain the updated data through the same pointer). Session-level isolation means that the variable storage area is strongly bound to the session; during multi-session parallel testing, the stored data of each flow is independent, avoiding cross-session data interference, meeting the high-concurrency testing requirements of industrial scenarios. Context association means that the storage area can synchronously associate with session context information (such as Token value, register status, and connection status), providing complete context data support for subsequent dynamic processing (e.g., modifying function codes based on stored register status).
[0106] Furthermore, by storing data in a dedicated variable storage area, on the one hand, application layer payload data can be temporarily retained, providing operation objects for subsequent dynamic processing such as protocol field modification and redundant data filtering; on the other hand, through memory pointer association and session isolation design, processing efficiency and stability of multi-session testing can be balanced.
[0107] Step S40: Based on the preset data dynamic processing interface function call, the custom processing logic is called to modify the fields and filter redundant data of the application layer payload. At the same time, the associated fields containing the check code and data length are automatically updated. After the processing result of the application layer payload is verified by the preset data verification interface function, the processed response message is sent to the target device by the preset message sending interface function. After the test process is completed, the cached data of the variable storage area is cleared by the preset data release interface function.
[0108] The dynamic processing module calls the conditional judgment logic in the Python plugin script to determine whether dynamic processing of the response message is required. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current stream. Based on the preset data dynamic processing interface function, the custom processing logic is called to modify fields and filter redundant data in the application layer payload. At the same time, the associated fields containing the checksum and data length are automatically updated. After the processing result of the application layer payload is verified by the preset data verification interface function, the processed response message is sent to the target device by the preset message sending interface function. After the test process is completed, the cached data in the variable storage area is cleared by the preset data release interface function. The data dynamic processing interface function is represented as process_data(cbvar,var); the data verification interface function is represented as review_data(invar); the message sending interface function is represented as write_data(invar); and the data release interface function is represented as erase_data(invar).
[0109] In some embodiments, the steps of calling custom processing logic based on a preset data dynamic processing interface function to modify fields and filter redundant data on the application layer payload, while automatically updating associated fields containing checksums and data length, include:
[0110] Step S41: By calling the dynamic processing rules of the custom Python plugin script that matches the industrial control protocol to be tested through the preset data dynamic processing interface function, the application layer payload obtained by parsing the user-space protocol stack is modified with protocol fields and redundant data is filtered.
[0111] Step S42: When performing the field modification and redundant data filtering operations, the associated fields containing the checksum and data length corresponding to the application layer payload are updated synchronously and automatically to ensure that the frame structure corresponding to the dynamically processed application layer payload conforms to the industrial control protocol specification under test. The checksum is calculated and updated in real time by the modified data field, and the data length is adjusted synchronously according to the number of effective data bytes after filtering.
[0112] Specifically, in process_data(cbvar,var), cbvar is used to specify the name of the custom function in the Python plugin script (such as filterRegisterData), and var specifies the name of the variable to store the processing result (such as mydata, the processing result is directly stored in the corresponding location of the variable storage area for subsequent interface calls).
[0113] The core function of `process_data(cbvar,var)` is to call the custom processing logic in the Python plugin script to perform two types of core operations on the application layer payload in the variable storage area. These operations include protocol field modification and redundant data filtering. The protocol field modification includes changing the Modbus fixed function code 0x03 to 0x06, dynamically generating an HTTP 500 exception response code, etc. The redundant data filtering includes filtering redundant status register fields in the programmable logic controller (PLC) response, retaining only key control signals such as motor speed and valve opening.
[0114] The data dynamic processing interface function is deeply integrated with the user-space protocol stack. During the processing, it automatically updates the associated fields synchronously. For example, after modifying the Modbus data field, it automatically recalculates the CRC checksum; after filtering redundant data, it synchronously adjusts the data length field in the MBAP header to ensure that the processed message frame structure conforms to the protocol specification, thus solving the pain point of existing technologies that require manual synchronization of associated fields.
[0115] In a further embodiment, the step of verifying the processing result of the application layer payload through a preset data verification interface function includes:
[0116] Step S401: Verify the processing result of the application layer load after being processed by the data dynamic processing interface function through the preset data verification interface function;
[0117] Step S402: If the parameter of the data verification interface function is not empty, the application layer load processing result stored in the variable storage area corresponding to the parameter is displayed; if the parameter of the data verification interface function is empty, all internal cache contents related to the application layer load in the variable storage area are listed to complete the debugging and verification of the application layer load processing result.
[0118] Specifically, `review_data(invar)` is the result verification interface. Its core function is to verify the processing effect of `process_data(cbvar,var)` and prevent illegal packets from being sent to the target device. If the parameter `invar` is not empty (e.g., `review_data(mydata)`), it displays the application layer payload processing result stored in the variable. Users can check whether field modifications have taken effect, whether redundant data has been completely filtered, and whether related fields have been updated synchronously through the WebGUI / CLI interactive layer. If the parameter `invar` is empty, it lists all cached content in the variable storage area, making it easier to locate data anomalies during the processing.
[0119] In a further embodiment, the processed response message is sent to the target device by a preset message sending interface function. After the test process is completed, the step of clearing the cached data in the variable storage area through a preset data release interface function includes:
[0120] Step S4001: Send the response message corresponding to the application layer payload, which has been processed by the data dynamic processing interface function and verified by the data verification interface function, to the target device through the preset message sending interface function;
[0121] Step S4002: After the corresponding test process is completed, the cached data of the variable storage area is cleared through the preset data release interface function. If the parameter of the data release interface function is not empty, the cached content of the variable storage area corresponding to the parameter is cleared. If the parameter of the data release interface function is empty, all internal cached content of the variable storage area is cleared to avoid memory leaks in high-concurrency test scenarios.
[0122] Specifically, write_data(invar) is the response message sending interface. Its core function is to send the verified processed message to the target device, directly reading the processing result corresponding to var in the variable storage area (such as write_data(mydata)), without secondary copying. It leverages the advantage of the user-space protocol stack to directly access the underlying memory data of the operating system, thereby improving sending efficiency. The interface is linked with the traffic sending and receiving module, sending messages through the FPGA-accelerated network card interface to avoid kernel-space copy delays and ensure the real-time performance required in industrial scenarios (such as millisecond-level PLC communication).
[0123] Furthermore, erase_data(invar) is a memory management interface whose core function is to prevent memory leaks in high-concurrency scenarios. If the parameter invar in erase_data(invar) is not empty, the cached data corresponding to that variable is cleared; if the parameter invar in erase_data(invar) is empty, all internal cached content in the variable storage area is cleared (but variables that have been saved using var are not cleared; developers need to explicitly clear the variable content, otherwise it will lead to memory consumption).
[0124] The explicit memory management mechanism described above ensures that the cached resources in the variable storage area are released in a timely manner after a single test process is completed, supporting the stable operation of the system under long-term, high-concurrency conditions.
[0125] Step S50: Check whether the program instruction sequence of the current stream has been fully executed. If it has been fully executed, the client or server management module releases the cached data and session context information corresponding to the current stream in the network port and variable storage area. The data statistics module receives network indicators including the number of bytes, the number of concurrent connections, network latency and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command line interface interaction layer.
[0126] Based on the preset data dynamic processing interface function call, custom processing logic is invoked to modify fields and filter redundant data on the application layer payload. At the same time, the associated fields containing checksums and data lengths are automatically updated. After the processing result of the application layer payload is verified by the preset data verification interface function, the processed response message is sent to the target device by the preset message sending interface function. After the test process is completed, the cached data in the variable storage area is cleared by the preset data release interface function. Then, it is checked whether the program instruction sequence of the current stream has been completely executed. If it has been completed, the client or server management module releases the network port, the cached data corresponding to the current stream in the variable storage area, and the session context information. The data statistics module receives network indicators including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command line interface interaction layer.
[0127] In some embodiments, it is checked whether the program instruction sequence of the current stream has been fully executed. If it has been fully executed, the client or server management module releases the network port, the cached data corresponding to the current stream in the variable storage area, and the session context information. The data statistics module receives network metrics including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses. The steps of feeding back feedback to the user through the network graphical user interface interaction layer or the command-line interface interaction layer include:
[0128] Step S501: After completing the dynamic processing and transmission of the application layer payload, or performing data volume statistics on the response message, check whether the program instruction sequence corresponding to the current flow has been fully executed; if it is determined that it has been fully executed, the server or client management module performs a protocol layer disconnection operation on the current network connection, and releases the network port associated with the flow, the session-level variable storage area corresponding to the current flow, and the session context information in an orderly manner, wherein the session context information includes the Token value, register status, and connection status;
[0129] Step S502: Simultaneously, the data statistics module performs real-time statistics on network metrics such as the number of bytes received by the port corresponding to the current stream, the number of concurrent connections, network latency, and the number of packet losses, and provides real-time feedback to the user through the network graphical user interface interaction layer or the command-line interface interaction layer.
[0130] Specifically, the system checks whether the program instruction sequence of the current stream has been fully executed. If it has not been fully executed, it indicates that there are still test instructions. The system then jumps to the next step of the current network stream to generate the next response message based on the predefined stream processing flow and the original or dynamically processed previous response message. The dynamic processing result is used as the core parameter to ensure the continuity between the new message and the historical processing logic, and to meet the testing requirements of complex interaction scenarios.
[0131] If all test instructions in the current stream's program instruction sequence have been executed, it indicates that there are no test instructions. The process then jumps to the server or client management module to perform an ordered protocol layer disconnection operation on the current network connection, fully releasing resources such as the network port number, cached data corresponding to the stream in the variable storage area, and session context information, ensuring that there is no memory leak or resource occupation residue.
[0132] Meanwhile, the data statistics module provides real-time statistics on network metrics such as the number of bytes received at the port corresponding to the current stream, the number of concurrent connections, network latency, and packet loss, and provides real-time feedback to the user through the network graphical user interface or command-line interface.
[0133] In some embodiments, the memory management and logical operations of the data processing layer are illustrated by taking "modifying the data field and cyclic redundancy check (CRC) of the Modbus response message" as an example.
[0134] Please see Figure 4 The system maintains a fixed-size array of variables $v[0..63] in memory, which is represented in the diagram as a series of contiguous storage units. This design aims to provide deterministic memory allocation, avoid fragmentation, and meet the stability and real-time requirements of industrial-grade testing.
[0135] Each array element is a structure containing fields such as data_ptr, data_len, and var_name. Data_ptr is a pointer to the actual data storage location; data_len is the length of the currently stored data; and var_name is the variable identifier associated with that storage location.
[0136] After the raw Modbus protocol response message returned by the programmable logic controller (PLC) under test is captured, it is temporarily stored in the system's temporary memory buffer. The raw message data field contains redundant spare register values, which need to be filtered. Its contents are as follows:
[0137] First, the MBAP header (7 bytes): 0x0001 (Transaction ID), 0x0000 (Protocol ID), 0x0007 (Length), 0x01 (Unit ID).
[0138] Secondly, PDU (6 bytes): 0x03 (function code), 0x0001 (register address), 0x0003 (number of registers), 0x1234 (cyclic redundancy check code).
[0139] The system's underlying layer (C layer) calls the Python plugin, which first allocates or locates a storage slot for the variable name 'mydata' in the memory pool. In this embodiment, it is mapped to $v[2].
[0140] Meanwhile, the system's underlying layer (C layer) points to a temporary memory buffer through the memory view object "pMem", allowing Python scripts to directly manipulate the raw Modbus data in the C layer without performing data copying.
[0141] The system's underlying (C layer) calls the Python plugin function `filterRegisterData`, which is represented as: `process_data(cbvar='filterRegisterData',var='mydata')`.
[0142] Furthermore, the function filterRegisterData performs the following processing logic, which includes:
[0143] Firstly, data field filtering: directly access the C-level buffer through the memory view object "pMem" to remove redundant spare register values in the Modbus response, such as filtering from "0x0001 0x0002 0x0003" to "0x0001 0x0002".
[0144] Secondly, the associated field is updated: the cyclic redundancy check code of the filtered data field is automatically calculated, such as 0x1234 being updated to 0x5678, and the "length" field in the MBAP header is updated from 0x0007 to 0x0006 to ensure compliance with the Modbus protocol specification.
[0145] Third, the processed result data is stored (or only updated) in the physical storage location $v[2] corresponding to the variable 'mydata'. It can be sent to the target device via write_data('mydata') or the processing result can be verified via review_data('mydata').
[0146] The modified response message is represented as follows:
[0147] MBAP header (7 bytes): 0x0001 (Transaction ID), 0x0000 (Protocol ID), 0x0006 (Data Length Update), 0x01 (Unit ID)
[0148] PDU (5 bytes): 0x03 (function code), 0x0001 (register address), 0x0002 (data length update, only two registers are retained), 0x5678 (cyclic redundancy check update).
[0149] As can be seen from the above embodiments, compared with the prior art, this application addresses the shortcomings of the prior art in industrial network testing, such as the inability to achieve real-time filtering of response content, dynamic modification of protocol fields, and dynamic response reconstruction of service authentication required by industrial simulation scenarios, as well as the problem of insufficient test coverage in high-end manufacturing scenarios due to the inability to simulate complex protocol anomalies. This application includes, but is not limited to, the following beneficial effects:
[0150] Firstly, it has stronger dynamic processing capabilities: Existing technologies cannot adjust core fields in real time. This application achieves this through "Python plugin functions + memory operations". Through plugin functions such as data dynamic processing interface functions, data verification interface functions, message sending interface functions, and data release interface functions, the processing logic can be flexibly defined. Direct memory operations eliminate the copying and reconstruction steps, break through the limitations of static configuration, and can simulate dynamic anomalies such as parameter errors and insufficient resources in industrial scenarios.
[0151] Secondly, the test reliability is higher: Existing technologies are prone to errors when manually synchronizing associated fields, have limited test scenario coverage, and are difficult to simulate dynamic interactions in real networks. The plug-in function of this application can directly modify any protocol field in memory, and in conjunction with the variable pool, it can achieve automatic synchronization of associated fields, such as automatically updating the data length after modifying the Modbus response and recalculating the cyclic redundancy check code.
[0152] Thirdly, it offers better scalability and adaptability: Existing technologies suffer from closed architectures, making customization difficult, secondary development reliant on vendor support, and test case maintenance costs high. This application utilizes standardized Python plugin interface functions, allowing test logic to be managed independently in script form; its modular architecture enables functional expansion without modifying the core code. This application significantly reduces test case development time from weeks to hours, substantially lowering the overall lifecycle maintenance cost and meeting the diverse testing needs of industrial scenarios.
[0153] Please see Figure 5An industrial network protocol testing and control device provided for one of the purposes of this application includes a response message determination module 1100, a protocol field extraction module 1200, an application layer payload storage module 1300, a traffic dynamic processing module 1400, and a network indicator statistics module 1500. The system includes a response message determination module 1100, configured to allow the industrial network protocol testing system to acquire the test traffic corresponding to the industrial control protocol under test, and send the test traffic to the target device to trigger the target device to return a response message. A protocol field extraction module 1200 is configured to allow the traffic sending and receiving module to capture the response message returned by the target device, and the user-space protocol stack to parse the Ethernet header, Internet Protocol header, and transport layer header of the response message layer by layer, extracting protocol fields including source address, destination address, port number, and sequence number. The user-space protocol stack runs in the operating system user space, supporting direct access to the operating system's underlying memory data without kernel-space copying. An application layer payload storage module 1300 is configured to allow the dynamic processing module to call conditional judgment logic in a Python plugin script to determine whether dynamic processing of the response message is required. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current flow. The variable storage area supports storing the application layer payload's message memory pointer for the same session. Data from different stages is processed sequentially, and multiple sessions can run in parallel without interference. The traffic dynamic processing module 1400 is configured to call custom processing logic based on a preset data dynamic processing interface function to modify fields and filter redundant data in the application layer payload. It also automatically updates associated fields containing checksums and data lengths. After verifying the processing result of the application layer payload through a preset data verification interface function, the processed response message is sent to the target device by a preset message sending interface function. After the test process is completed, the cached data in the variable storage area is cleared through a preset data release interface function. The network metric statistics module 1500 is configured to check whether the program instruction sequence of the current flow has been fully executed. If it has been completed, the client or server management module releases the network port, the cached data corresponding to the current flow in the variable storage area, and the session context information. The data statistics module receives network metrics including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command-line interface interaction layer.
[0154] Based on any embodiment of this application, please refer to Figure 6 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 6The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database may store control information sequences. When the computer-readable instructions are executed by the processor, the processor can implement an industrial network protocol test control method. The processor of the computer device provides computing and control capabilities to support the operation of the entire computer device. The memory of the computer device may store computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor can execute the industrial network protocol test control method of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0155] In this embodiment, the processor is used to execute... Figure 5 The specific functions of each module are defined within the device, and the memory stores the program code and various data required to execute these modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the industrial network protocol test and control device of this application, and the server can call the server's program code and data to execute the functions of all modules.
[0156] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the industrial network protocol test control method described in any embodiment of this application.
[0157] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the industrial network protocol test control method described in any embodiment of this application.
[0158] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0159] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. An industrial network protocol testing and control method, characterized in that, include: The industrial network protocol testing system acquires the test traffic corresponding to the industrial control protocol to be tested, and sends the test traffic to the target device to trigger the target device to return a response message; The traffic sending and receiving module captures the response message returned by the target device. The user-space protocol stack parses the Ethernet header, Internet Protocol header and transport layer header of the response message layer by layer, and extracts the protocol fields of each layer containing source address, destination address, port number and sequence number. The user-space protocol stack runs in the operating system user space, supports direct access to the underlying memory data of the operating system and does not require kernel-space copying. The dynamic processing module calls the conditional judgment logic in the Python plugin script to determine whether the response message needs to be dynamically processed. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current stream. The variable storage area supports storing the message memory pointer of the application layer payload to perform coherent operations on data at different stages of the same session, and multiple sessions do not interfere with each other when running in parallel. Based on the preset data dynamic processing interface function call, the custom processing logic is called to modify the fields and filter redundant data of the application layer payload. At the same time, the associated fields containing the check code and data length are automatically updated. After the processing result of the application layer payload is verified by the preset data verification interface function, the processed response message is sent to the target device by the preset message sending interface function. After the test process is completed, the cached data of the variable storage area is cleared by the preset data release interface function. Check whether the program instruction sequence of the current stream has been fully executed. If it has been fully executed, the client or server management module releases the cached data and session context information corresponding to the current stream in the network port and variable storage area. The data statistics module receives network metrics including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command line interface interaction layer.
2. The industrial network protocol testing and control method according to claim 1, characterized in that, Before the step of the industrial network protocol testing system acquiring the test traffic corresponding to the industrial control protocol under test and sending the test traffic to the target device to trigger the target device to return a response message, the following steps are included: Determine the type of industrial control protocol to be tested, and obtain the fields to be tested, test parameters, and Python plugin scripts corresponding to the industrial control protocol to be tested. The Python plugin scripts contain dynamic processing rules and condition judgment logic corresponding to the industrial control protocol to be tested. The test parameters include the basic attributes, data structure parameters, and transmission control parameters of the industrial control protocol to be tested. A JSON configuration file is generated based on the Python plugin script, and the test parameters, the fields to be detected, the Python plugin script, and the JSON configuration file are stored in a memory circular buffer. The data processing layer reads the JSON configuration file and associated fields to be tested and Python plugin scripts from the memory circular buffer. The application layer processing module parses the JSON configuration file, network address information and streaming processing logic of the industrial network protocol testing system to generate application layer data. The network address information includes IP address, port number and MAC address. The user-space protocol stack performs transport layer encapsulation and network layer encapsulation on the application layer data to generate test traffic containing complete protocol headers and application layer data.
3. The industrial network protocol testing and control method according to claim 1, characterized in that, Based on the preset data dynamic processing interface function call to custom processing logic, the steps include modifying fields and filtering redundant data in the application layer payload, and automatically updating associated fields containing checksums and data lengths, including: By calling the dynamic processing rules of the custom Python plugin script that matches the industrial control protocol to be tested through the preset data dynamic processing interface function, the application layer payload obtained by parsing the user-space protocol stack is subjected to protocol field modification and redundant data filtering operations. When performing the field modification and redundant data filtering operations, the associated fields containing the checksum and data length corresponding to the application layer payload are synchronously and automatically updated to ensure that the frame structure corresponding to the dynamically processed application layer payload conforms to the industrial control protocol specification under test. The checksum is calculated and updated in real time by the modified data field, and the data length is synchronously adjusted according to the number of effective data bytes after filtering.
4. The industrial network protocol testing and control method according to claim 1, characterized in that, The steps for verifying the processing result of the application layer payload through a preset data verification interface function include: The processing result of the application layer load after being processed by the data dynamic processing interface function is verified through the preset data verification interface function; If the parameter of the data verification interface function is not empty, the application layer load processing result stored in the variable storage area corresponding to the parameter is displayed; if the parameter of the data verification interface function is empty, all internal cache contents related to the application layer load in the variable storage area are listed to complete the debugging and verification of the application layer load processing result.
5. The industrial network protocol testing and control method according to claim 1, characterized in that, The process involves sending the processed response message to the target device via a preset message sending interface function. After the test process is completed, the process also includes clearing the cached data in the variable storage area via a preset data release interface function. The response message corresponding to the application layer payload, which has been processed by the data dynamic processing interface function and verified by the data verification interface function, is sent to the target device through the preset message sending interface function. After the corresponding test process is completed, the cached data in the variable storage area is cleared through the preset data release interface function. If the parameter of the data release interface function is not empty, the cached content of the variable storage area corresponding to that parameter is cleared. If the parameter of the data release interface function is empty, all internal cached content in the variable storage area is cleared to avoid memory leaks in high-concurrency test scenarios.
6. The industrial network protocol testing and control method according to claim 1, characterized in that, The system checks whether the entire sequence of program instructions for the current stream has been executed. If it has, the client or server management module releases the network port, the cached data corresponding to the current stream in the variable storage area, and the session context information. The data statistics module receives network metrics including the number of bytes, concurrent connections, network latency, and packet loss. The steps for providing feedback to the user through the network graphical user interface or command-line interface include: After completing the dynamic processing and transmission of the application layer payload, or performing data volume statistics on the response message, check whether the program instruction sequence corresponding to the current flow has been fully executed. If it is determined that it has been fully executed, the server or client management module performs a protocol layer disconnection operation on the current network connection, and releases the network port associated with the flow, the session-level variable storage area corresponding to the current flow, and the session context information in an orderly manner. The session context information includes the Token value, register status, and connection status. Meanwhile, the data statistics module provides real-time statistics on network metrics for the current stream, including the number of bytes received at the port, the number of concurrent connections, network latency, and the number of packet losses. The statistical results are then fed back to the user in real time through the network graphical user interface or command-line interface.
7. The industrial network protocol testing and control method according to any one of claims 1 to 6, characterized in that, The target device includes a programmable logic controller, a Modbus firewall, a dual-authentication web platform, or an industrial HTTP server.
8. An industrial network protocol testing and control device, characterized in that, include: The response message determination module is configured to allow the industrial network protocol testing system to acquire the test traffic corresponding to the industrial control protocol under test, and send the test traffic to the target device to trigger the target device to return a response message. The protocol field extraction module is configured to capture the response message returned by the target device by the traffic sending and receiving module. The user-space protocol stack parses the Ethernet header, Internet Protocol header and transport layer header of the response message layer by layer to extract the protocol fields of each layer, including source address, destination address, port number and sequence number. The user-space protocol stack runs in the operating system user space and supports direct access to the underlying memory data of the operating system without kernel-space copying. The application layer payload storage module is configured to call the condition judgment logic in the Python plugin script of the dynamic processing module to determine whether the response message needs to be dynamically processed. If dynamic processing is required, the parsed application layer payload is stored in the variable storage area corresponding to the current stream. The variable storage area supports storing the message memory pointer of the application layer payload to perform coherent operations on data at different stages of the same session, and multiple sessions do not interfere with each other when running in parallel. The traffic dynamic processing module is configured to call custom processing logic based on a preset data dynamic processing interface function to modify fields and filter redundant data in the application layer payload. At the same time, it automatically updates the associated fields containing the checksum and data length. After verifying the processing result of the application layer payload through a preset data verification interface function, the processed response message is sent to the target device by a preset message sending interface function. After the test process is completed, the cached data in the variable storage area is cleared through a preset data release interface function. The network metrics statistics module is configured to check whether the program instruction sequence of the current stream has been fully executed. If it has been fully executed, the client or server management module releases the cached data and session context information corresponding to the current stream in the network port and variable storage area. The data statistics module receives network metrics including the number of bytes, the number of concurrent connections, network latency, and the number of packet losses, and provides feedback to the user through the network graphical user interface interaction layer or the command line interface interaction layer.
9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.