SNMP protocol-based DO level control method and gateway device
Patent Information
- Application Number
- CN202610458680.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-08-18
AI Technical Summary
[0003]现有技术中,少有SNMP与DO结合用于远程控制的方案,且,需要用户手动编写SNMP报文解析代码、DO驱动代码,用户需要掌握底层协议与硬件开发知识,非专业人员难以部署
[0031] This invention is based on the Node-RED platform and a self-developed DO control plugin, enabling visual configuration without the need to write underlying code, allowing even non-professionals to quickly complete deployment;
Smart Images

Figure CN122601462A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial control technology, and more specifically, relates to a DO level control method and gateway device based on the SNMP protocol. Background Technology
[0002] DO (Digital Output) is a commonly used hardware control interface in industrial equipment and IoT terminals. By switching between high and low levels, it can control peripherals such as relays and sensors. SNMP (Simple Network Management Protocol) is a standard protocol for network device management and is widely used in equipment status monitoring. SNMP Trap is often used for event notification and alarm reporting.
[0003] In existing technologies, there are few solutions that combine SNMP and DO for remote control. Furthermore, users need to manually write SNMP message parsing code and DO driver code. Users need to master the underlying protocols and hardware development knowledge, making it difficult for non-professionals to deploy. Summary of the Invention
[0004] The main objective of this invention is to provide a DO level control method and gateway device based on the SNMP protocol, which is integrated, highly reliable, and easy to configure.
[0005] According to a first aspect of the present invention, a DO level control method based on the SNMP protocol is provided, comprising the following steps:
[0006] Step 1: Deploy the Node-RED platform and DO control plugin on the gateway. Use the DO control plugin to configure SNMP Agent listening parameters, SNMP OID mapping relationship with DO pins, and DO hardware parameters in a visual manner.
[0007] Step 2: The client generates an SNMP Trap message, which contains the target event OID. The Trap message is then sent to the gateway.
[0008] Step 3: The DO control plugin receives the Trap message, performs verification, extracts the target event OID from the message if the verification passes, and discards the message and records the exception log if the verification fails.
[0009] Step 4: After extracting the target event OID, determine the target DO pin according to the mapping relationship between the OID and the DO pin, send control commands to the DO pin, and read the actual execution status of the DO pin;
[0010] Step 5: Compare the control command with the actual execution status. If they match, generate a success feedback message and send it to the client via the SNMP Agent listening port. If they do not match, trigger the retry mechanism. If the retry count reaches the threshold and still fails, send an alarm message to the client and record the fault information.
[0011] In the above-mentioned DO level control method based on the SNMP protocol, in step 1, the SNMP Agent listening parameter configuration includes selecting the SNMP version, setting the community name and listening port;
[0012] The DO hardware parameter configuration includes selecting a DO hardware template.
[0013] In the above-described DO level control method based on the SNMP protocol, in step 2, the Trap message includes the SNMP version number, community name, and target event OID.
[0014] In the above-mentioned DO level control method based on the SNMP protocol, in step 3, when performing verification, version verification, authentication verification, and OID validity verification are performed in sequence.
[0015] Version verification: Verify whether the version number in the Trap message is consistent with the SNMP version in the SNMP Agent listening parameter configuration. Only if they are consistent is the verification considered successful.
[0016] Authentication verification: Verify whether the community name in the Trap message matches the community name in the SNMP Agent listening parameter configuration. Only if they match is the verification considered successful.
[0017] OID validity check: Verify whether the target event OID is in dotted decimal format, and determine whether the target event OID has been mapped and bound to the DO pin in the SNMP OID and DO pin mapping configuration. If the target event OID is in the correct format and has been bound, the OID validity check is considered to have passed.
[0018] In the above-mentioned DO level control method based on the SNMP protocol, the retry mechanism is configured in step 1. The retry mechanism configuration includes setting the retry number threshold, retry interval, and anti-jitter delay.
[0019] In the above-mentioned DO level control method based on the SNMP protocol, repeated triggering requests for the same target event OID are blocked during the retry process.
[0020] According to a second aspect of the present invention, a gateway device for implementing the method of the first aspect is provided, comprising a gateway body having a DO interface module;
[0021] The gateway is equipped with a Node-RED platform and a DO control plugin integrated into the platform. The DO control plugin includes a configuration module, an SNMP processing module, a DO control module, a reliability assurance module, and a visualization monitoring module.
[0022] Configuration module: Provides a visual operation interface for configuring SNMP Agent listening parameters, configuring the mapping relationship between SNMP OID and DO pins, and configuring DO hardware parameters;
[0023] SNMP processing module: Used to receive SNMP Trap messages sent by the client, perform verification, extract the target event OID from the message if the verification is successful, and discard the message if the verification fails.
[0024] DO control module: Based on the target event OID output by the SNMP processing module, match the corresponding DO pin, send control commands, and read the actual execution status of the DO pin;
[0025] Reliability assurance module: used to record exception logs; and to compare control commands with actual execution status. If they match, a success feedback message is generated and sent to the client. If they do not match, a retry mechanism is triggered. If the number of retries reaches the threshold and still fails, an alarm message is sent to the client and the fault information is recorded.
[0026] Visual monitoring module: Displays SNMP message reception status, current DO pin level, command execution results, and exception information in real time.
[0027] In the aforementioned gateway device, the configuration module has a built-in default template library, which includes multiple DO hardware templates. After selecting a DO hardware template, the DO pin list is automatically loaded for visual selection.
[0028] In the aforementioned gateway device, the configuration module is used to configure the retry mechanism.
[0029] In the aforementioned gateway device, the DO control module has built-in anti-jitter processing logic, which delays for 100-500ms after receiving the control command before reading the actual execution status of the DO pin.
[0030] One of the above-described technical solutions of the present invention has at least one of the following advantages or beneficial effects:
[0031] This invention is based on the Node-RED platform and a self-developed DO control plugin, enabling visual configuration without the need to write underlying code, allowing even non-professionals to quickly complete deployment;
[0032] At the same time, reliability is improved. Multiple checks, retry mechanisms, and anti-jitter processing reduce the false trigger rate and increase the execution success rate, meeting the reliability requirements of industrial control.
[0033] Furthermore, it supports multiple SNMP versions and multiple hardware platforms, and the OID and DO pins can be flexibly mapped, allowing it to adapt to the customized needs of different customers without modifying the core logic. Attached Figure Description
[0034] The present invention will be further described below with reference to the accompanying drawings and embodiments;
[0035] Figure 1 This is a flowchart of the DO level control method based on the SNMP protocol of the present invention. Detailed Implementation
[0036] Embodiments of the present invention 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 the present invention, and should not be construed as limiting the present invention.
[0037] In existing technologies, there are few solutions that combine SNMP and DO for remote control. Furthermore, users need to manually write SNMP message parsing code and DO driver code. Users need to master the underlying protocols and hardware development knowledge, making it difficult for non-professionals to deploy.
[0038] This application achieves integrated processing of SNMPTrap message reception, verification, parsing, and DO level control by deploying an integrated Node-RED platform and a self-developed DO control plugin on the gateway. Furthermore, it utilizes visual configuration, enabling flexible mapping of OID and DO pins without the need for low-level code development. This reduces the deployment difficulty for non-professionals and is suitable for various scenarios such as industrial equipment control and IoT terminal management.
[0039] Reference Figure 1 As shown, a DO level control method based on the SNMP protocol includes the following steps:
[0040] Step 1: Deploy the Node-RED platform and DO control plugin on the gateway. Use the DO control plugin to configure SNMP Agent listening parameters, SNMP OID mapping relationship with DO pins, and DO hardware parameters in a visual manner.
[0041] The DO control plugin is a self-developed plugin based on the Node-RED platform. The DO control plugin has a visual configuration interface. After installing the Node-RED platform on the industrial gateway and opening the Node-RED interface, you can drag and drop the DO control plugin node onto the canvas. Double-clicking the node will take you to the configuration interface, where you can then configure several aspects.
[0042] SNMP Agent listening parameter configuration requires selecting the SNMP version, setting the community name, and the listening port; for example, the SNMP version is v2c, the community name is "public", and the listening port is 162;
[0043] To configure DO hardware parameters, you need to select a DO hardware template, such as "EG5120", and then the DO pin list will be loaded automatically.
[0044] Configure the mapping relationship between SNMP OID and DO pin, and add mapping rules. For example, OID: .1.3.6.1.4.1.12345.1.0 is DO17 (high level), and OID: .1.3.6.1.4.1.12345.2.0 is DO17 (low level).
[0045] You can also configure a retry mechanism, setting the retry threshold, retry interval, and anti-jitter delay. For example, the retry threshold is 2, the retry interval is 200ms, and the anti-jitter delay is 100ms.
[0046] Step 2: The client generates an SNMP Trap message, which contains the target event OID. The Trap message is then sent to the gateway.
[0047] Generally, users generate Trap messages through a client according to their needs. A Trap message includes the SNMP version number, community name, and target event OID. For example, a Trap message could be:
[0048] snmptrap -v2c -c public 192.168.1.100 '' .1.3.6.1.4.1.12345.1.0;
[0049] Among them, the target event OID is unique and corresponds to the DO control;
[0050] The client then sends the data to the gateway's SNMP Agent listening port via the UDP protocol.
[0051] Step 3: The DO control plugin receives the Trap message, performs verification, extracts the target event OID from the message if the verification passes, and discards the message and records the exception log if the verification fails.
[0052] Specifically, the DO control plugin receives Trap messages through the SNMP Agent and then begins verification, performing version verification, authentication verification, and OID validity verification in sequence.
[0053] During version verification, the version number in the Trap message is checked to see if it matches the SNMP version in the SNMP Agent listening parameter configuration. Only if they match is the verification considered successful. The structure of Trap messages differs greatly between different SNMP versions. For example, v1Trap contains unique fields such as enterprise and agent-addr, while v2c Trap uses snmpTrapOID to replace these fields. If the versions are inconsistent, subsequent parsing of the message content will directly result in errors, and may even cause DO control plugin malfunctions.
[0054] Authentication verification checks whether the community name in the Trap message matches the community name in the SNMP Agent listening parameter configuration. Only if they match is the verification considered successful.
[0055] OID validity verification consists of two steps. The first step is to verify whether the target event OID is in dotted decimal format. The second step is to determine whether the target event OID has been mapped and bound to the DO pin in the SNMP OID and DO pin mapping configuration. If the target event OID is in the correct format and is bound, the OID validity verification is considered to have passed. If the target event OID is in the wrong format or is not bound, the OID validity verification is considered to have failed.
[0056] The target event OID will only be extracted from the message and the next step will be taken if the version verification, authentication verification, and OID validity verification all pass. If any one of the verifications fails, the message will be discarded and an exception log will be recorded.
[0057] Step 4: After extracting the target event OID, determine the target DO pin according to the mapping relationship between the OID and the DO pin, send control commands to the DO pin, and read the actual execution status of the DO pin;
[0058] Specifically, in the SNMP OID and DO pin mapping configuration, the mapping relationship between OID and DO pin can be known. After the DO control plug-in extracts the target event OID, it can query the DO pin mapped to the target event OID and the corresponding level state. For example, if the target event OID is ".1.3.6.1.4.1.12345.1.0", it can be found that it is mapped to the DO17 pin and is in a high level state.
[0059] Then, the DO control plugin sends a control command to the target DO pin, which is to send a high-level command to the DO17 pin;
[0060] After sending the control command, the DO control plugin reads the actual level of the target DO pin to determine whether the DO pin is high or low, thereby judging the actual execution state of the DO pin.
[0061] Step 5: Compare the control command with the actual execution status. If they match, generate a success feedback message and send it to the client through the SNMP Agent listening port. If they do not match, trigger the retry mechanism. If the retry count reaches the threshold and still fails, send an alarm message to the client and record the fault information.
[0062] Although a control command is sent to the DO pin, it cannot be guaranteed that the level of the DO pin will be adjusted to match the control command. Therefore, it is necessary to determine whether the actual execution state of the DO pin is consistent with the control command, so as to ensure that the DO pin is at the appropriate level.
[0063] If the control command is inconsistent with the actual execution state, a retry mechanism is triggered, which means resending the control command to the target DO pin. The retry mechanism is configured in step 1. For example, retry 2 times with a retry interval of 200ms. If the control command is consistent with the actual execution state during the retry, an execution success feedback message is generated. If the control command is still inconsistent with the actual execution state after 2 retries, the execution is judged to have failed, an alarm message is sent to the client and the fault information is recorded.
[0064] Furthermore, when reading the actual execution status, the system delays for 100ms after receiving the control command to avoid malfunctions caused by duplicate packets due to network jitter. When configuring the retry mechanism, the anti-jitter delay can be set, typically between 100 and 500ms.
[0065] During the retry process, repeated trigger requests for the same target event OID are blocked to avoid frequent switching of the DO pin; for example, trigger requests for the same target event OID must meet dual admission conditions:
[0066] First, the record of the target event OID has reached the set timeout period; second, the previous trigger request processing flow of the target event OID has been completed; if either condition is not met, the current trigger request of the target event OID will be rejected.
[0067] This application is based on the Node-RED platform and a self-developed DO control plugin, enabling visual configuration without the need to write underlying code, allowing even non-professionals to quickly complete deployment;
[0068] At the same time, reliability has been improved. Multiple checks, retry mechanisms, and anti-jitter processing have reduced the false trigger rate to below 0.1% and increased the execution success rate to 99.9%, meeting the reliability requirements of industrial control.
[0069] Furthermore, it supports multiple SNMP versions and multiple hardware platforms, and the OID and DO pins can be flexibly mapped, so that it can adapt to the customized needs of different customers without modifying the core logic.
[0070] Based on visual monitoring and complete log recording, the fault location time is reduced from hours to minutes, reducing maintenance costs and simplifying the maintenance process.
[0071] This application supports the parallel configuration of multiple sets of OID-DO mapping relationships;
[0072] For example, a single SNMP Trap message can trigger multiple DO pins to synchronously execute the same level control. That is, when a target event OID is bound to multiple DO pins, the DO control plugin will send the same level control command to all bound DO pins in parallel when the Trap message of that OID is received.
[0073] Alternatively, different target event OIDs may correspond to different control logics on the same DO pin, and multiple target event OIDs may be bound to the same DO pin, but with different level states, such as short-term high level or long-term high level.
[0074] In this way, the complexity of the client can be reduced. The client only needs to remember a few OIDs to control complex systems. All complex control logic can be predefined in the DO control plugin, and the client only needs to issue simple commands.
[0075] According to a second aspect of the present invention, a gateway device is provided, including a gateway body, the gateway body having a DO interface module, the gateway body and the DO interface module belonging to the hardware layer;
[0076] The software layer includes the Node-RED platform deployed in the gateway and the DO control plugin integrated into the platform. The DO control plugin includes a configuration module, an SNMP processing module, a DO control module, a reliability assurance module, and a visualization monitoring module.
[0077] Configuration module: Provides a visual operation interface for configuring SNMP Agent listening parameters, SNMP OID and DO pin mapping, DO hardware parameters, and retry mechanism.
[0078] SNMP Agent listening parameter configuration requires selecting the SNMP version, setting the community name, and the listening port;
[0079] DO hardware parameter configuration requires selecting a DO hardware template; specifically, there is a built-in default template library, which includes multiple DO hardware templates. After selecting a DO hardware template, the DO pin list is automatically loaded for visual selection, which facilitates subsequent mapping and binding.
[0080] Configure the mapping relationship between SNMP OID and DO pin, and manually add or delete mapping rules;
[0081] Configure the retry mechanism, setting the retry threshold, retry interval, and anti-jitter delay.
[0082] SNMP processing module: Based on the Node-RED snmp-trap node extension development, it is used to receive SNMP Trap messages sent by clients, perform verification, extract the target event OID in the message if the verification is successful, and discard the message if the verification fails.
[0083] During verification, version verification, authentication verification, and OID validity verification are performed.
[0084] During version verification, the version number in the Trap message is checked to see if it matches the SNMP version in the SNMP Agent listening parameter configuration. Only if they match is the verification considered successful. After identifying the message version, the corresponding parsing rules are adapted. Generally, SNMP versions include v1, v2, and v3.
[0085] For authentication verification, if the SNMP version is v1 or v2, the community name in the Trap message is checked to see if it matches the community name in the SNMPAgent listening parameter configuration. If they match, the verification is considered successful. If the SNMP version is v3, the authentication key and privacy key are checked.
[0086] OID validity verification consists of two steps. The first step is to verify whether the target event OID is in dotted decimal format. The second step is to determine whether the target event OID has been mapped and bound to the DO pin in the SNMP OID and DO pin mapping configuration. If the target event OID is in the correct format and is bound, the OID validity verification is considered to have passed. If the target event OID is in the wrong format or is not bound, the OID validity verification is considered to have failed.
[0087] It can also perform source IP validity verification, which determines whether the client IP is in the whitelist, allowing only clients in the whitelist to send packets and blocking unauthorized access.
[0088] DO control module: Based on self-developed driver logic, it supports direct call to the gateway's DO module interface. According to the target event OID output by the SNMP processing module, it matches the corresponding DO pin and sends control commands. That is, it maps the OID to the corresponding level control signal and reads the actual execution status of the DO pin to ensure the execution effect.
[0089] Furthermore, the DO control module has built-in anti-jitter processing logic, which delays for 100-500ms after receiving the control command before reading the actual execution status of the DO pin.
[0090] Reliability assurance module: Used to compare control commands with actual execution status. If they match, a success feedback message is generated and sent to the client. If they do not match, a retry mechanism is triggered. If the retry count reaches the threshold and the retry still fails, an alarm message is sent to the client and the fault information is recorded.
[0091] During the retry process, repeated triggering requests for the same target event OID are blocked to avoid frequent switching of the DO pin;
[0092] All message reception, verification, execution, and exception information are logged, and can be exported for traceability.
[0093] Visual monitoring module: Based on the Node-RED plugin node interface, it displays the SNMP message reception status, the current level of the DO pin, the command execution results and exception information in real time. It can intuitively determine whether the plugin is working properly, clearly know the current level of each bound DO pin, and count the number of message receptions, successful executions and exceptions. It will also display the 5 most recent core operation records.
[0094] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.
Claims
1. A DO level control method based on the SNMP protocol, characterized in that, Includes the following steps: Step 1: Deploy the Node-RED platform and DO control plugin on the gateway. Use the DO control plugin to configure SNMP Agent listening parameters, SNMP OID mapping relationship with DO pins, and DO hardware parameters in a visual manner. Step 2: The client generates an SNMP Trap message, which contains the target event OID. The Trap message is then sent to the gateway. Step 3: The DO control plugin receives the Trap message, performs verification, extracts the target event OID from the message if the verification passes, and discards the message and records the exception log if the verification fails. Step 4: After extracting the target event OID, determine the target DO pin according to the mapping relationship between the OID and the DO pin, send control commands to the DO pin, and read the actual execution status of the DO pin; Step 5: Compare the control command with the actual execution status. If they match, generate a success feedback message and send it to the client via the SNMPAgent listening port. If they do not match, trigger the retry mechanism. If the retry count reaches the threshold and still fails, send an alarm message to the client and record the fault information.
2. The DO level control method based on SNMP protocol according to claim 1, characterized in that, In step 1, the SNMP Agent listening parameter configuration includes selecting the SNMP version, setting the community name, and the listening port; The DO hardware parameter configuration includes selecting a DO hardware template.
3. The DO level control method based on SNMP protocol according to claim 2, characterized in that, In step 2, the Trap message includes the SNMP version number, community name, and target event OID.
4. The DO level control method based on the SNMP protocol according to claim 3, characterized in that, In step 3, during the verification process, version verification, authentication verification, and OID validity verification are performed sequentially. Version verification: Verify whether the version number in the Trap message is consistent with the SNMP version in the SNMP Agent listening parameter configuration. Only if they are consistent is the verification considered successful. Authentication verification: Verify whether the community name in the Trap message matches the community name in the SNMP Agent listening parameter configuration. Only if they match is the verification considered successful. OID validity check: Verify whether the target event OID is in dotted decimal format, and determine whether the target event OID has been mapped and bound to the DO pin in the SNMP OID and DO pin mapping configuration. If the target event OID is in the correct format and has been bound, the OID validity check is considered to have passed.
5. The DO level control method based on SNMP protocol according to claim 1, characterized in that, The retry mechanism is configured in step 1. The retry mechanism configuration includes setting the retry number threshold, retry interval, and anti-jitter delay.
6. The DO level control method based on SNMP protocol according to claim 1, characterized in that, During the retry process, duplicate triggering requests for the same target event OID are blocked.
7. A gateway device implementing the method of any one of claims 1-6, characterized in that, Includes a gateway body, which has a DO interface module; The gateway is equipped with a Node-RED platform and a DO control plugin integrated into the platform. The DO control plugin includes a configuration module, an SNMP processing module, a DO control module, a reliability assurance module, and a visualization monitoring module. Configuration module: Provides a visual operation interface for configuring SNMP Agent listening parameters, configuring the mapping relationship between SNMP OID and DO pins, and configuring DO hardware parameters; SNMP processing module: Used to receive SNMP Trap messages sent by the client, perform verification, extract the target event OID from the message if the verification is successful, and discard the message if the verification fails. DO control module: Based on the target event OID output by the SNMP processing module, match the corresponding DO pin, send control commands, and read the actual execution status of the DO pin; Reliability assurance module: used to record exception logs; and to compare control commands with actual execution status. If they match, a success feedback message is generated and sent to the client. If they do not match, a retry mechanism is triggered. If the number of retries reaches the threshold and still fails, an alarm message is sent to the client and the fault information is recorded. Visual monitoring module: Displays SNMP message reception status, current DO pin level, command execution results, and exception information in real time.
8. The gateway device according to claim 7, characterized in that, The configuration module has a built-in default template library, which includes multiple DO hardware templates. After selecting a DO hardware template, the DO pin list is automatically loaded for visual selection.
9. The gateway device according to claim 7, characterized in that, The configuration module is used to configure the retry mechanism.
10. The gateway device according to claim 7, characterized in that, The DO control module has built-in anti-jitter processing logic. After receiving the control command, it delays for 100-500ms before reading the actual execution status of the DO pin.