ModSnmp Manual - Modbus OID Settings
SNMP uses OIDs (Object Identifiers) to refer to its variables, whereas the Modbus protocol uses addresses. SNMP and Modbus also use different types for their variables.
The Modbus OIDs panels enable you to set up mappings from the OIDs and types used in SNMP messages to the addresses and types used in Modbus messages.
The SNMP manager that you are using will also need to know about any OIDs and SNMP types that you configure here. This is done using a MIB file.
The Modbus protocol uses four different types of variable: Holding Registers, Input Registers, Coils and Discrete Inputs.
Each of these variable types has its own address range, using addresses that are integers in the range 0 to 65535.
Holding Registers and Input Registers are normally 16-bit variables, although ModSnmp supports extensions of the Modbus protocol that allow 32-bit and 64-bit variables. Holding Registers may be read or written, whereas Input Registers are read-only.
Coils and Discrete Inputs are 1-bit variables. Coils may be read or written, whereas Discrete Inputs are read-only.
The Modbus protocol places no interpretation on the values of its variables (they are simply bit-patterns to be transported in Modbus messages), although they are typically treated as integers.
Modbus also uses "slave identifiers" (also known as "slave addresses" or "unit identifiers") to distinguish between multiple slaves that share the same communications interface (serial line or IP address). Each slave can have its own Holding Registers, Input Registers, Coils and Discrete Inputs.
To fully identify a variable in Modbus, you have to specify the interface, the slave identifier, the type (Holding Register, ...), and the address.
SNMP has several types of variable, and it does
place interpretations on the values of the variables.
For example, the types TimeTicks and Integer32
are both 32-bits in size, but have different interpretations.
The OctetString types is an exception - it is
specifically provided as an uninterpreted type (although it is often
used to represent text).
The Opaque type is also uninterpreted, but
is now deprecated - see RFC 2578.
SNMP uses a single address range for all its variables, independent of their types. The variables are addressed using OIDs (Object Identifiers), which are sequences of integers. For example, the "System Name" variable is addressed using the OID "1.3.6.1.2.1.1.5.0".
SNMP distinguishes between "scalar" variables, which are individual variables, and "tabular" variables, which are variables that are elements in tables. The last integer in an OID is called the "instance identifier". For tabular variables, the instance identifier is the index of the table row containing the variable. For scalar variables, the instance identifier is always zero.
ModSnmp uses a table to map SNMP OIDs to Modbus addresses. This table is displayed in the Modbus OIDs panel (Figure 8, “Modbus OIDs panel”).
Each entry in this table maps a contiguous group of variables.
For tabular SNMP variables, the SNMP variables in the group must be in the same SNMP table and have consecutive instance identifiers. The corresponding Modbus variables must have the same address, type and size, and have consecutive addresses.
For scalar SNMP variables, the group must consist of a single variable with a zero instance indentifier.
Normally, all the OIDs in the Modbus-OID table would start with the same sequence of numbers. To simplify the table entries, you can enter this common sequence in the OID Prefix field, and then just use the end of the OID in the individual entries. For example, in Figure 8, “Modbus OIDs panel”, the first entry is actually for the OID 1.3.6.1.4.1.34171.2.1.1.2.
To add an entry to the table, use the Add Entry panel.
To edit an entry in the table, use the Edit Entry panel.
Modbus OID entries can be deleted from the table using the Modbus OIDs panel:
To delete an entry, select the entry and the click the Delete button.
To delete several entries, select them by clicking on them while holding down the control key, and then click the Delete button.
To delete all the entries, click the Delete All button.
You can select which columns are displayed in the table using the → menu item.
The Add Entry panel (Figure 9, “Add Modbus OID Entry panel”) enables you to add an entry to the Modbus-OID table.
Each entry in the Modbus-OID table maps a contiguous group of variables.
To add an entry to the table, enter the following data and then click Apply:
Description. Optionally enter a description of the OID. This is displayed in the Modbus OIDs Display panel, but is not used by ModSnmp in any other way.
OID. Enter the SNMP OID of the group of variables to be mapped. The OID should not include the instance identifier. The OID that you enter here will be combined with the prefix defined in the Modbus OIDs panel to form the complete OID to be mapped.
First Instance. For a group of tabular SNMP variables, enter the SNMP instance identifier of the first variable in the group. For a scalar SNMP variable, enter 0.
Number. Enter the number of variables (SNMP instances) in the group. For a scalar variable, enter 1. The number should not exceed the number of variables actually supported by the Modbus slave. SNMP managers often "walk" through tables, and this will generate Modbus errors if the number is too large.
-
SNMP Type. Select the SNMP type to be used in responses to SNMP requests.
ModSnmp supports the following SNMP types:
Table 2. SNMP types SNMP type Description Integer32 An Integer32 is a signed 32-bit integer (i.e. in the range -2147483648 to 2147483647 decimal). The INTEGER type used in SNMPv1 is identical to Integer32. Unsigned32 An Unsigned32 is an unsigned 32-bit integer (i.e. in the range 0 to 4294967295 decimal). Note that the Gauge32 type referred to in RFC 2578 is indistinguishable from Unsigned32. Counter32 A Counter32 is an unsigned 32-bit integer (i.e. in the range 0 to 4294967295 decimal) that monotonically increases until it reaches a maximum value of 4294967295, when it wraps around and starts increasing again from zero. TimeTicks A TimeTicks is an unsigned 32-bit integer (i.e. in the range 0 to 4294967295 decimal) that represents a time interval in hundredths of a second. Counter64 A Counter64 is an unsigned 64-bit integer (i.e. in the range 0 to 18446744073709551615 decimal) that monotonically increases until it reaches a maximum value of 18446744073709551615, when it wraps around and starts increasing again from zero. OctetString An OctetString is arbitrary binary or textual data. If you select OctetString, the Modbus value will be sent in the SNMP response as a sequence of bytes, most significant byte first. You should also select OctetString if your SNMP manager requires the "Bits construct" referred to in RFC 2578 (RFC 3416 explains that the Bits construct is actually encoded as an OctetString). Float This is not a genuine SNMP type. It is provided by ModSnmp as a means of transporting floating-point values via SNMP (SNMP does not have a floating-point type). If you select Float, ModSnmp will interpret the Modbus value as floating-point, convert it to a UTF-8 text string, and return it to the SNMP manager as an OctetString. Opaque An Opaque is arbitrary data. If you select Opaque, the Modbus value will be sent in the SNMP response as a sequence of bytes, most significant byte first. Note that Opaque is now deprecated (see RFC 2578), and is provided in ModSnmp only for backward-compatibility. Use OctetString instead if you can. SNMP does not have 16-bit types, so you will normally have to select one of the 32-bit types for transferring values of 16-bit Holding or Input registers.
You can use any type except Float for transferring Coils and Discrete Inputs. You should set the Modbus Size to the number of Coils or Discrete Inputs that you want to transfer in each SNMP instance.
Interface. Select the Modbus interface to be used to communicate with the Modbus slave.
Slave ID. Enter the Modbus slave identifier. The Slave ID is what is called the "slave address" in the original Modbus specification, and is called the "unit identifier" in the Modbus/TCP specification. It should be in the range 1 to 255. The serial specification limits the range of slave identifiers to 1 to 247, for no apparent reason. The Modbus/TCP implementation guide suggests that Modbus/TCP slaves that can be uniquely identified by their IP address should use slave identifier 255.
-
Modbus Size. If you have selected Holding Register or Input Register as the Modbus Type, you should select the register size in bits (16, 32 or 64). If you selected Float as the SNMP Type, you must select 32 or 64. Note that 32-bit and 64-bit register sizes are non-standard.
If you have selected Coils or Discrete Inputs as the Modbus Type, you should select or enter the number of Coils or Discrete Inputs that you want to transfer in each SNMP instance.
Address. Enter the Modbus address of the first variable in the group. Subsequent variables in the group will have consecutive addresses, unless you are using 32-bit or 64-bit Modbus registers and have selected Word Registers in the Modbus panel.
Writable. Deselect the Writable checkbox to prevent SNMP managers writing to the Modbus registers.
A Modbus OID definition can be edited using the Edit Modbus OID Entry panel (Figure 10, “Edit Modbus OID Entry panel”).
Use the Select Entry drop-down list to select the Modbus OID entry to be edited, change the values as required, and click Apply to save the changes.