A method for hot loading industrial control protocol analysis and control
By loading a feature library containing the industrial control protocol parsing and identification code into the industrial control equipment and using a dynamic library interface to parse the industrial control messages, the problem of fixed code in the existing industrial control protocol parsing module is solved, and flexible addition and control of industrial control protocols is realized.
Patent Information
- Application Number
- CN202211430821.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2042-11-15
AI Technical Summary
In existing technologies, the code for the industrial control protocol parsing module is fixed. Adding a new industrial control protocol requires modifying the entire module, restarting the system, or changing the device image, which makes the operation cumbersome and inflexible.
By acquiring the feature library of the encapsulated industrial control protocol parsing and identification code, the feature library is loaded into the industrial control equipment using a dynamic library, and the industrial control messages are parsed and controlled through the interface of the dynamic library, thus avoiding the need to restart the module and the system.
It enables the identification and control of new industrial control protocols without restarting the industrial control protocol parsing module or system, thus improving the flexibility and efficiency of industrial control protocol parsing.
Smart Images

Figure CN115941818B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of industrial control protocol loading, in particular to a method for hot loading of industrial control protocol analysis and control. BACKGROUND
[0002] With the development of information technology, industrial control systems gradually move towards openness, interconnection and universality. Many industrial control protocols gradually run on industrial Ethernet. Among them, the types of industrial control protocols are various, and many are private protocols designed by industrial equipment manufacturers and not publicly disclosed. These all bring great challenges to the deep analysis of industrial control protocols.
[0003] The traditional implementation method of deep analysis of industrial control protocols is to hard-code the deep analysis process of a certain industrial control protocol into the industrial control protocol analysis module after fully understanding and mastering the industrial control protocol. When the corresponding industrial control protocol message enters the deep analysis process, the message will be parsed according to the previously hard-coded industrial control protocol deep analysis process.
[0004] However, since the code hard-coded into the industrial control protocol analysis is fixed, when a new industrial control protocol is added, the entire analysis module needs to be modified, the analysis module needs to be restarted or the system needs to be restarted, or even the device version image needs to be replaced. SUMMARY
[0005] The method for hot loading of industrial control protocol analysis and control provided by the present application can solve the problem in the prior art that since the code hard-coded into the industrial control protocol analysis is fixed, when a new industrial control protocol is added, the entire analysis module needs to be modified, the analysis module needs to be restarted or the system needs to be restarted, or even the device version image needs to be replaced.
[0006] The first aspect of the present application provides a method for hot loading of industrial control protocol analysis and control, comprising:
[0007] obtaining a feature library, wherein the feature library encapsulates an analysis identification code of an industrial control protocol;
[0008] uploading the feature library to an industrial control device according to a preset target path and sending a loading instruction to the industrial control device, wherein the industrial control device comprises an industrial control protocol analysis module;
[0009] the industrial control protocol analysis module loads the feature library from the target path in response to the loading instruction;
[0010] the industrial control protocol analysis module analyzes an industrial control message based on the analysis identification code in the feature library;
[0011] the industrial control device controls the industrial control message according to the analysis result of the industrial control message.
[0012] In an implementation, the step of loading the feature library from the target path by the industrial protocol analysis module in response to the loading instruction comprises:
[0013] The industrial protocol analysis module establishes a dynamic library and an interface of the dynamic library, wherein the interface is used at least for the industrial protocol analysis module to query industrial protocols currently supported by the feature library for analysis;
[0014] The dynamic library numbers the industrial protocols of the feature library.
[0015] In an implementation, the step of uploading the feature library to the industrial control device according to a preset target path and sending a loading instruction to the industrial control device comprises:
[0016] The feature library is uploaded to the industrial control device through the target path based on a transmission mode of http or ftp;
[0017] The loading instruction is sent to the industrial protocol analysis module.
[0018] In an implementation, the step of loading the feature library from the target path by the industrial protocol analysis module in response to the loading instruction comprises:
[0019] The industrial protocol analysis module sets a global function pointer to a null value in response to the loading instruction, wherein the global function pointer is used to indicate a location of the interface of the dynamic library;
[0020] The industrial protocol analysis module opens the dynamic library according to a system call function of the dynamic library and reassigns a value to the global function pointer, so that the industrial protocol analysis module calls the interface of the dynamic library according to the re-assigned global function pointer.
[0021] In an implementation, the step of analyzing the industrial control message by the industrial protocol analysis module based on the analysis identification code in the feature library comprises:
[0022] The industrial protocol analysis module calls the interface of the dynamic library to analyze the industrial control message;
[0023] The industrial protocol analysis module receives the analysis result returned by the dynamic library, wherein the analysis result comprises an industrial protocol number corresponding to the industrial control message, an analysis result memory block, and a size of the memory block.
[0024] In an implementation, the step of analyzing the industrial control message by the industrial protocol analysis module based on the analysis identification code in the feature library further comprises:
[0025] The industrial control protocol analysis module sends at least one rule information to the dynamic library through an interface of the dynamic library, wherein each rule information at least includes a rule template name, an industrial control protocol number, a number of target fields, and a matching rule of the target fields;
[0026] The dynamic library saves rule information with the same rule template name under the same rule template to obtain a rule chain corresponding to each rule template.
[0027] In an implementable embodiment, the step of the industrial control protocol analysis module analyzing the industrial control packet based on the analysis identification code in the feature library includes:
[0028] The industrial control protocol analysis module calls an interface of the dynamic library to send matching information to the dynamic library, wherein the matching information includes a rule template name and the analysis result;
[0029] The dynamic library determines a target rule template according to the rule template name, matches the analysis result by traversing a rule chain of the target rule template, and forwards or discards the industrial control packet according to the matching result.
[0030] The second aspect of the present application provides a system for hot loading industrial control protocol analysis and control, including the method for hot loading industrial control protocol analysis and control described above, including:
[0031] An acquisition unit is configured to acquire a feature library, wherein the feature library encapsulates an analysis identification code of an industrial control protocol;
[0032] A transmission unit is configured to upload the feature library to an industrial control device according to a preset target path, and send a loading instruction to the industrial control device, wherein the industrial control device includes an industrial control protocol analysis module;
[0033] A response unit is configured to cause the industrial control protocol analysis module to load the feature library from the target path in response to the loading instruction;
[0034] An identification unit is configured to cause the industrial control protocol analysis module to analyze an industrial control packet based on the analysis identification code in the feature library;
[0035] A control unit is configured to cause the industrial control device to control the industrial control packet according to an analysis result of the industrial control packet.
[0036] The third aspect of the present application provides an electronic device, including:
[0037] A processor;
[0038] A memory for storing executable instructions of the processor;
[0039] read the executable instructions from the memory and execute the instructions to implement the method for hot loading and controlling industrial control protocol analysis and control.
[0040] The fourth aspect of the present application provides a computer readable storage medium having computer program instructions stored thereon, the program instructions being executed by a processor to implement the steps of the method for hot loading and controlling industrial control protocol analysis and control.
[0041] The method for hot loading and controlling industrial control protocol analysis and control has the beneficial effect that the analysis identification code of the industrial control protocol is encapsulated in the feature library, and the feature library is uploaded to the industrial control device according to the target path. The industrial control protocol analysis module in the industrial control device loads the feature library in response to the received loading instruction. After the loading is completed, the industrial control protocol analysis module analyzes the industrial control message by using the analysis identification code in the feature library. This method can realize the identification and control of the newly added industrial control protocol without restarting the industrial control protocol analysis module or the system, and without replacing the version image of the industrial control device. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the drawings needed in the description of the specific embodiments or the prior art will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0043] Figure 1 The flowchart of the method for hot loading and controlling industrial control protocol analysis and control of the present application;
[0044] Figure 2 The flowchart of uploading the feature library to the industrial control device in the method for hot loading and controlling industrial control protocol analysis and control of the present application;
[0045] Figure 3 The flowchart of numbering the industrial control protocol in the method for hot loading and controlling industrial control protocol analysis and control of the present application;
[0046] Figure 4 The flowchart of setting the global function pointer in the method for hot loading and controlling industrial control protocol analysis and control of the present application;
[0047] Figure 5 The flowchart of the industrial control protocol analysis module calling the interface of the dynamic library to return the analysis result in the method for hot loading and controlling industrial control protocol analysis and control of the present application;
[0048] Figure 6A timing diagram of a method for hot loading of an industrial control protocol analysis and control according to the present application;
[0049] Figure 7 A flowchart of establishing rule information of a method for hot loading of an industrial control protocol analysis and control according to the present application;
[0050] Figure 8 A rule diagram of a method for hot loading of an industrial control protocol analysis and control according to the present application;
[0051] Figure 9 A flowchart of controlling an industrial control protocol of a method for hot loading of an industrial control protocol analysis and control according to the present application. DETAILED DESCRIPTION
[0052] The technical solutions of the present application will be described in detail below with reference to the embodiments. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0053] In order to facilitate the technical solutions of the application, the following first describes some concepts related to the present application.
[0054] The feature library is a data warehouse. Based on the set features, data, protocols, etc. with the features are collected in the same library, which facilitates the calling of data and protocols and the unified management.
[0055] http is Hyper Text Transportation Protocol, which is used to transmit files on the World Wide Web.
[0056] ftp is File Transportation Protocol, which is used to upload and download files between FTP servers and client computers in the network using TCP. Files can be copied from one host to another.
[0057] The memory block is a continuous memory segment that carries a number of value parts at runtime. Different memory blocks may have different sizes, depending on the size of the value parts they carry.
[0058] Referring to Figures 1 to 9 The first aspect of the present application provides a method for hot loading of an industrial control protocol and control, which comprises:
[0059] As shown in Figure 1 S100: obtaining a feature library.
[0060] The feature library encapsulates the analysis identification code of the industrial control protocol.
[0061] When the industrial control protocol is used, the industrial control protocol needs to be parsed, and then the parsed content is used to parse the industrial control protocol message. The feature library encapsulates the analysis identification code corresponding to the industrial control protocol, which facilitates the analysis of the industrial control protocol by the analysis identification code. In addition, since there are many types of industrial control protocols, the analysis identification codes of multiple industrial control protocols can be integrated in the feature library to facilitate the analysis of different types of industrial control protocols.
[0062] It should be noted that the analysis identification code in the feature library can be increased as needed to cope with subsequent updates or upgrades of the industrial control protocol. The feature library with increased analysis identification codes needs to be reacquired.
[0063] S200: Upload the feature library to the industrial control device according to the preset target path, and send a loading instruction to the industrial control device.
[0064] The industrial control device includes an industrial control protocol analysis module, which is used to analyze the industrial control message.
[0065] It should be noted that the industrial control protocol analysis module can be arranged in the industrial control device or externally connected to the industrial control device. The industrial control protocol analysis module analyzes the industrial control message required by the industrial control device.
[0066] When the feature library is uploaded to the industrial control device, a loading instruction is sent to the industrial control device to load the feature library, so that the industrial control protocol analysis identification code in the feature library can be called to analyze the industrial control message when the industrial control message is interpreted.
[0067] As shown in Figure 2 , specifically, uploading the feature library to the industrial control device includes steps S201 and S202.
[0068] S201: Based on the transmission mode of http or ftp, the feature library is uploaded to the industrial control device through the target path.
[0069] The target path can be the network address of the industrial control device. The feature library is transmitted from a server (the server can also be a computer device with http or ftp transmission mode) to the industrial control device by using the transmission mode of http or ftp.
[0070] It should be noted that the feature library can also be transmitted from the server to the industrial control device by other transmission protocols, or directly copied into the industrial control device using an external storage device.
[0071] S202: Send a loading instruction to the industrial control protocol analysis module.
[0072] Wherein, the feature library is transmitted to the industrial control device, and a loading instruction is sent to the industrial control protocol analysis module, so that the industrial control protocol analysis module can load the feature library.
[0073] Specifically, the process of upgrading the feature library first uploads the feature library file to the specified path through http or ftp. Then, through signal processing, a signal is sent to the industrial control protocol analysis module to inform the industrial control protocol analysis module to reload the feature library. Next, the industrial control protocol analysis module loads the new feature library after receiving the signal.
[0074] It should be noted that the loading instruction can be transmitted to the industrial control device together with the feature library. When the feature library is not transmitted, the loading instruction is in a dormant state. The loading instruction sends a loading instruction to the industrial control protocol analysis module in response to the information that the feature library upload is complete. The server can also send a loading instruction to the industrial control protocol analysis module after the feature library is uploaded.
[0075] S300: The industrial control protocol analysis module loads the feature library from the target path in response to the loading instruction.
[0076] Wherein, the industrial control protocol analysis module loads the feature library from the target path after receiving the loading instruction, so that the industrial control protocol analysis module can parse the industrial control message by calling the analysis identification code of the industrial control protocol in the feature library when receiving the industrial control message.
[0077] It should be noted that since the feature library encapsulates multiple analysis identification codes of industrial control protocols, the industrial control protocols need to be numbered, including steps S301 and S302.
[0078] As shown in Figure 3 S301: The industrial control protocol analysis module establishes a dynamic library and an interface of the dynamic library.
[0079] Wherein, the interface is used at least for the industrial control protocol analysis module to query the industrial control protocols currently supported by the feature library for analysis.
[0080] Specifically, the dynamic library can reduce memory and also reduce page swapping. The dynamic library is relatively independent, and changing the feature library will not affect the interface of the dynamic library, that is, when the feature library needs to be reloaded, it will not affect the interface of the dynamic library, reducing the workload caused by loading the feature library.
[0081] S302: The dynamic library numbers the industrial control protocols of the feature library.
[0082] Wherein, in order to facilitate the industrial protocol analysis module to call the industrial protocol of the feature library through the interface of the dynamic library. Namely, the industrial protocol analysis module numbers the industrial protocol of the feature library through the interface of the dynamic library, so as to facilitate the industrial protocol analysis module to query the industrial protocol according to the number.
[0083] As shown in Figure 4 , it should be noted that the global function pointer setting of the dynamic library interface includes steps S303 to S304.
[0084] S303: The industrial protocol analysis module sets the global function pointer to be empty in response to the loading instruction.
[0085] Wherein, the global function pointer is used to indicate the interface position of the dynamic library. After the loading instruction, the industrial protocol analysis module first sets the global function pointer to be empty, so as to avoid using the original analysis identification code to analyze the industrial message.
[0086] S304: The industrial protocol analysis module opens the dynamic library according to the system call function of the dynamic library, and reassigns the global function pointer, so that the industrial protocol analysis module calls the interface of the dynamic library according to the reassignment of the global function pointer.
[0087] Wherein, the industrial protocol analysis module loads the feature library according to the loading instruction, and after loading is completed, opens the new feature library according to the system call function of the dynamic library, and reassigns the global function pointer on the basis of setting the global function pointer to be empty, so as to complete the action of the global function pointer calling the interface of the dynamic library, so as to facilitate the industrial protocol analysis module to use the new interface to process the industrial message.
[0088] S400: The industrial protocol analysis module analyzes the industrial message based on the analysis identification code in the feature library.
[0089] Wherein, after the industrial protocol analysis module receives the industrial message forwarding request of the industrial device, the industrial message is analyzed by using the analysis identification code in the feature library, and when the industrial message analysis is successful, it can be judged whether the file to be forwarded by the industrial device can be forwarded.
[0090] As shown in Figure 5 , it should be noted that the industrial protocol analysis module calling the interface of the dynamic library returns the analysis result includes steps S401 and S402.
[0091] S401: The industrial protocol analysis module calls the interface of the dynamic library to analyze the industrial message.
[0092] The industrial control protocol analysis module parses the industrial control message through the interface of the dynamic library.
[0093] S402: The industrial control protocol analysis module receives the analysis result returned by the dynamic library, and the analysis result includes the industrial control protocol number corresponding to the industrial control message, the analysis result memory block, and the size of the memory block.
[0094] The dynamic library returns the analysis result after receiving the industrial control message analysis request from the industrial control protocol analysis module. The analysis result includes the industrial control protocol number, the analysis result memory block, and the size of the memory block. The industrial control device determines whether to continue forwarding the industrial control protocol according to the analysis result obtained by the industrial control protocol analysis module.
[0095] As shown in Figure 6 , the dynamic library returns the analysis result as follows:
[0096]
[0097] Where id represents the industrial control protocol number, "id": 15 represents the industrial control protocol number 15; result represents the analysis result, "result": "0x8000000001" represents that the analysis result is located in the memory block 0x8000000001; result_len represents the size of the memory block, "result_len": 128 represents that the size of the memory block is 128.
[0098] As shown in Figure 7 , it should also be noted that the industrial control protocol analysis module issues rule information to the dynamic library through the interface of the dynamic library, so that the industrial control protocol analysis module can judge whether it matches the rule information when sending the industrial control message analysis request. The rule information establishment includes steps S403 and S404.
[0099] S403: The industrial control protocol analysis module issues at least one rule information to the dynamic library through the interface of the dynamic library.
[0100] Each rule information includes at least a rule template name, an industrial control protocol number, a number of target fields, and a matching rule of the target field.
[0101] The industrial control protocol analysis module sets the rule information and saves the rule information in the feature library through the interface. The rule information set by the industrial control protocol analysis module can be understood as pre-set rule information. When the feature library returns the analysis result, the industrial control protocol analysis module can compare the analysis result with the pre-set rule information.
[0102] S404: The dynamic library saves the rule information with the same rule template name under the same rule template to obtain the rule chain corresponding to each rule template.
[0103] In the rule information, the dynamic library integrates the industrial control protocol number and fields issued by the industrial control protocol analysis module, and then defines the parameters according to different protocol numbers to specify the meaning of different parameters.
[0104] As shown in Figure 6 , for example, for the GOOSE protocol, the content of the industrial control protocol number and field issued by the industrial control protocol analysis module is:
[0105]
[0106] In the rule information, template represents the rule template, "template": "test1" represents that the rule template is test1; id represents the industrial control protocol number, "id": 15 represents that the industrial control protocol number is 15; param_cnt represents the number of target fields, "param_cnt": 2 represents that the number of target fields is 2; param represents the target field matching parameter, "param": ["abc", "123"] represents that the target field matching parameter gocbref (control block reference name) is abc and the appid (application number) is 123.
[0107] In the dynamic library, the parameter definition for the rule information with the industrial control protocol number 15 is that the industrial control message with gocbref as abc and appid as 123 is allowed to pass, and other industrial control messages are rejected.
[0108] Each rule information is saved under a rule template, and each rule template can configure multiple rule information. For example, each rule template can configure 2000 rule information, and a total of 16 rule templates can be configured.
[0109] As shown in Figure 8 , the rule information configured by each rule template forms a rule chain. In order to call and match in subsequent steps.
[0110] As shown in Figure 9 , finally, it needs to be noted that the industrial control protocol deep analysis module needs to control the industrial control protocol, including steps S405 and S406.
[0111] S405: The industrial control protocol analysis module calls the interface of the dynamic library to send matching information to the dynamic library.
[0112] The matching information includes a rule template name and a parsing result. The industrial control protocol parsing module sends a request for the matching information to the dynamic library based on the parsing result returned by the dynamic library. The dynamic library returns a parsing result based on the request. The parsing result can be compared with the pre-set rule information.
[0113] As shown in Figure 6 , the industrial control protocol parsing module sends a request for the matching information to the dynamic library, for example:
[0114]
[0115] The template represents a rule template, "template":"test1" indicates that the rule template is test1. The id represents an industrial control protocol number, "id":15 indicates that the industrial control protocol number is 15. The result represents a parsing result, "result":"0x8000000001" indicates that the parsing result is located in a memory block 0x8000000001. The result_len represents the size of the memory block, "result_len":128 indicates that the size of the memory block is 128.
[0116] S406: The dynamic library determines a target rule template based on the rule template name, traverses a rule chain of the target rule template to match the parsing result, and forwards or discards the industrial control packet based on the matching result.
[0117] The dynamic library first determines a target rule template included in the matching information sent by the industrial control protocol parsing module based on the parsing result returned by the dynamic library. The rule chain is traversed under the target rule template to match the result. If the matching is successful, it is considered that the rule information allows forwarding. Otherwise, the result is returned.
[0118] S500: The industrial control device controls the industrial control packet based on the parsing result of the industrial control packet.
[0119] The industrial control protocol parsing module feeds back the parsing result of the industrial control packet to the industrial control device. The industrial control device controls the industrial control packet based on the feedback parsing result. The control includes continuing forwarding or stopping forwarding.
[0120] As shown in Figure 6 and Figure 8 , the method for hot loading industrial control protocol parsing and control includes the following steps. A feature library encapsulating a plurality of industrial control protocol parsing identification codes is obtained. A dynamic library numbers each industrial control protocol supported by the feature library and provides an interface for an industrial control protocol parsing module to query the types of currently supported protocols.
[0121] The industrial control protocol analysis module receives the signal, vacates all interfaces, and prevents the use of the old interface (sets the global function pointer to null).
[0122] The newly loaded feature library is opened, the dynamic library is opened using a system call function, the global function pointer is re-assigned, and the industrial control protocol analysis module can use the new interface to process the industrial control message.
[0123] The industrial control protocol analysis module establishes rule information, which at least includes the rule template name, the industrial control protocol number, the number of target fields, and the matching rules of the target fields.
[0124] The rule information is sent to the dynamic library and stored in the feature library. The feature library classifies and stores the rule information issued by the industrial control protocol analysis module. Rule information with the same rule template name is saved in the same rule template. The rule information in a rule template forms a rule chain. When the rule needs to be used, the rule chain of the rule template is traversed.
[0125] When the industrial control device wants to forward the industrial control message, it needs to parse the industrial control message. In this case, the industrial control device first sends the industrial control message to the industrial control protocol analysis module, then sends the industrial control message payload to the dynamic library by the industrial control protocol analysis module, and finally parses the industrial control message by the feature library and returns the analysis result to the industrial control protocol analysis module. The analysis result includes the protocol number, the memory address containing the analysis result, and the memory size.
[0126] The industrial control protocol analysis module matches the analysis result of the industrial control message with the rule information pre-set in the feature library. It should be noted that the analysis result sent by the industrial control protocol analysis module to the feature library includes the rule template name, the protocol number, the field number, and the field content, all of which are strings. That is, the analysis result sent by the industrial control protocol analysis module to the feature library is not exactly the same as the analysis result returned by the feature library to the industrial control protocol analysis module.
[0127] When the dynamic library receives the analysis result containing the template name, the protocol number, the field number, and the field content sent by the industrial control protocol analysis module, it first matches the rule template. When the rule template matching is successful, it matches the protocol number and the field number with the rule chain under the rule template. The dynamic library traverses the rule chain of the rule template and matches the protocol number and the field number. When the matching is successful, the field content is allowed to be forwarded.
[0128] The industrial control device controls the industrial control message according to the analysis result of the industrial control message, such as forwarding or discarding.
[0129] The industrial control protocol analysis module opens a dynamic library file of a preset target path, loads an interface function to be used, and needs to have corresponding functions, specifically, Figure 9 The interface functions of the industrial control protocol analysis module are respectively represented by icf_show_proto, icf_proto_parse, icf_proto_match, and icf_proto_set_rule.
[0130] The icf_show_proto displays a list of currently supported industrial control protocols, and the returned content includes a protocol number and a rule template name.
[0131] The icf_proto_parse takes an industrial control message payload as an input parameter, and returns a protocol number, a memory address containing a parsing result, and a memory size.
[0132] The icf_proto_match takes the parsing result returned by the icf_proto_parse and a rule template name to be matched as input parameters, and returns an industrial control message forwarding state (allowed or rejected).
[0133] The icf_proto_set_rule takes a rule template name, a protocol number, a field number, and field content as input parameters, where the field content is a string.
[0134] It should be noted that, Figure 6 The timing of icf_proto_set_rule and icf_proto_parse in the above embodiment can be interchanged.
[0135] Based on the above content, the dynamic library parses the industrial control message payload, obtains the fields to be controlled, saves the field values to a memory block, and returns the memory address and the memory block with the protocol number to the industrial control protocol analysis module. The fields to be controlled and the fields in the rule information need to correspond, and this logic is set in the dynamic library. The industrial control protocol analysis module abstracts this logic into parameters.
[0136] In this embodiment, when the industrial control device transmits and receives industrial control messages, the industrial control message may be transmitted by other devices. In this case, the industrial control message needs to be parsed to be recognized by the industrial control device, and the industrial control protocol analysis module plays a role in parsing the industrial control message. Since there are many types of industrial control protocols, and the industrial control protocol is updated over time, if the parsing identification code of the industrial control protocol is compiled into the industrial control protocol analysis module, the parsing identification code will be fixed in the industrial control protocol analysis module. When facing newly added industrial control protocols, the code in the entire industrial control protocol analysis module needs to be modified, and the analysis module needs to be restarted or the system needs to be restarted, or even the image of the device needs to be replaced.
[0137] For the above reasons, the feature library encapsulating the parsing identification code of the industrial control protocol is uploaded to the industrial control device, and the parsing identification code of the industrial control protocol in the feature library is called by the industrial control protocol parsing module using the dynamic library, so that the parsing of the industrial control protocol can also be realized. When the parsing identification code of the industrial control protocol needs to be updated or increased, a new feature library can be loaded. In addition, the interface of the dynamic library does not need to be changed because the name, parameters, return value type and calling convention in the dynamic library inside the industrial control protocol parsing module do not change. Therefore, the global function pointer is only assigned a null value to avoid calling the old interface of the industrial control message. After the feature library is loaded, the global function pointer is re-assigned, so that the parsing module or the system does not need to be restarted, and the image of the device does not need to be replaced, thereby realizing hot loading of the industrial control protocol parsing and control.
[0138] The second aspect of the present application provides a system for hot loading of industrial control protocol parsing and control, which comprises any one of the methods for hot loading of industrial control protocol parsing and control described above, and comprises:
[0139] An acquisition unit is configured to acquire a feature library, wherein the feature library encapsulates a parsing identification code of an industrial control protocol;
[0140] A transmission unit is configured to upload the feature library to an industrial control device according to a preset target path, and send a loading instruction to the industrial control device, wherein the industrial control device comprises an industrial control protocol parsing module;
[0141] A response unit is configured to load the feature library from the target path by the industrial control protocol parsing module in response to the loading instruction;
[0142] An identification unit is configured to parse an industrial control message based on the parsing identification code in the feature library by the industrial control protocol parsing module;
[0143] A control unit is configured to control the industrial control message according to the parsing result of the industrial control message by the industrial control device.
[0144] The third aspect of the present application provides an electronic device, which comprises:
[0145] A processor;
[0146] A memory for storing processor-executable instructions;
[0147] The processor is configured to read the executable instructions from the memory and execute the instructions to implement the method for hot loading of industrial control protocol parsing and control described above.
[0148] The fourth aspect of the present application provides a computer-readable storage medium having computer program instructions stored thereon, wherein the program instructions are executed by a processor to implement the steps of the method for hot loading of industrial control protocol parsing and control described above.
[0149] The above embodiments only express specific implementation manners of the present application, which are described in a more specific and detailed manner, but cannot be understood as a limitation on the patent scope of the present application. It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, which all belong to the protection scope of the present application.
Claims
1. A method for hot-loading industrial control protocol parsing and control, characterized in that, The methods include: Obtain a feature library, wherein the feature library encapsulates the parsing and identification code of industrial control protocols; According to the preset target path, the feature library is uploaded to the industrial control equipment, and a loading command is sent to the industrial control equipment, wherein the industrial control equipment includes an industrial control protocol parsing module; In response to the loading command, the industrial control protocol parsing module reloads the feature library from the target path; The industrial control protocol parsing module establishes a dynamic library and an interface for the dynamic library. The interface is at least used by the industrial control protocol parsing module to query the industrial control protocols currently supported for parsing by the feature library. The industrial control protocol parsing module assigns numbers to the industrial control protocols in the feature library through the interface of the dynamic library; In response to the loading command, the industrial control protocol parsing module sets the global function pointer to a null value, wherein the global function pointer is used to indicate the interface location of the dynamic library; The industrial control protocol parsing module opens the dynamic library according to the system call function of the dynamic library and reassigns the global function pointer, so that the industrial control protocol parsing module calls the interface of the dynamic library according to the reassigned global function pointer; The industrial control protocol parsing module calls the interface of the dynamic library and parses the industrial control message based on the parsing identification code in the feature library; The industrial control protocol parsing module receives the parsing result returned by the dynamic library. The parsing result includes the industrial control protocol number corresponding to the industrial control message, the parsing result memory block, and the size of the memory block. The industrial control protocol parsing module sends at least one rule information to the dynamic library through the interface of the dynamic library. Each rule information includes at least a rule template name, an industrial control protocol number, a number of target fields, and a matching rule for the target fields. The dynamic library stores rule information with the same rule template name under the same rule template to obtain a rule chain corresponding to each rule template. The industrial control protocol parsing module calls the interface of the dynamic library to send matching information to the dynamic library, wherein the matching information includes the rule template name and the parsing result; the dynamic library determines the target rule template according to the rule template name, traverses the rule chain of the target rule template to match the parsing result, and forwards or discards the industrial control message according to the matching result; The industrial control equipment controls the industrial control message based on the parsing result of the industrial control message.
2. The method for hot-loading industrial control protocol parsing and control according to claim 1, characterized in that, The step of uploading the feature library to the industrial control device according to the preset target path and sending a loading command to the industrial control device includes: Based on HTTP or FTP transmission methods, the feature database is uploaded to the industrial control equipment through the target path; Send a loading command to the industrial control protocol parsing module.
3. A system for hot-loading industrial control protocol parsing and control, characterized in that, The method for hot-loading industrial control protocol parsing and control as described in claim 1 or 2 includes: An acquisition unit is used to acquire a feature library, wherein the feature library encapsulates the parsing and identification code of the industrial control protocol; A transmission unit is used to upload the feature library to an industrial control device according to a preset target path, and send a loading command to the industrial control device, wherein the industrial control device includes an industrial control protocol parsing module; A response unit is provided for the industrial control protocol parsing module to load the feature library from the target path in response to the loading instruction. The industrial control protocol parsing module establishes a dynamic library and an interface for the dynamic library. The interface is used at least for the industrial control protocol parsing module to query the industrial control protocols currently supported for parsing by the feature library. The dynamic library assigns numbers to the industrial control protocols in the feature library. The identification unit is used by the industrial control protocol parsing module to parse the industrial control message based on the parsing identification code in the feature library; The control unit is used by the industrial control equipment to control the industrial control message based on the parsing result of the industrial control message.
4. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the hot-loading industrial control protocol parsing and control method as described in claim 1 or 2.
5. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the program instructions are executed by the processor, they implement the steps of the hot-loading industrial control protocol parsing and control method as described in claim 1 or 2.
Citation Information
Patent Citations
Industrial control equipment identification method and system based on rule matching and deep learning
CN111506599A
Industrial control equipment auditing method, device and equipment and readable storage medium
CN113301049A
Industrial control safety protection method and device
CN114139133A