In SNMP, there are not many data types. Here we will discuss these data types, regardless of how they are actually encoded.
Integer
Although a variable is defined as an integer, it also has multiple forms. Some integer variables have no range restrictions, and some integer variables are defined as specific values (for example, the IP Forwarding flag only supports the two types when forwarding or when forwarding is not allowed ), some integer variables define a specific range (for example, UDP and TCP port numbers are from 0 to 65535 ).
Octerstring
0 or multiple 8-bit bytes. Each byte value ranges from 0 ~ In the range of 255. For this type of data and the next type of data encoding, the number of bytes of a string exceeds the length of the string. These strings do not end with null.
Displaystring
0 or multiple 8-bit bytes, but each byte must be an ascii code. In the MIB-II, all variables of this type cannot exceed 255 characters (0 characters are acceptable ).
Objectidentifier
Null
Indicates that the related variable has no value. For example, in the get or get-next operation, the variable value is null, because these values are still to be obtained by the Agent process.
IPaddress
Octerstring, which is 4 bytes in the network order. Each byte represents a field of the IP address.
Physaddress
Octerstring type, indicating the physical address (for example, the Ethernet physical address is 6 bytes in length ).
Counter
A non-negative integer that can be incremented from 0 to 232-1 (4294976295 ). After the maximum value is reached, the value is 0.
Gauge
A non-negative integer ranging from 0 to 4294976295 (or increased or decreased ). When the maximum value is reached, the system will be locked until it is reset. For example, tcpcurrestab in MiB is an example of this type of variable. It represents the number of TCP connections currently in the established or close_wait status.
Timeticks
The time counter increases progressively in 0.01 seconds, but different variables can have different increments. Therefore, when defining a variable of this type, you must specify the increment range. For example, the sysuptime variable in MiB is a variable of this type, which represents the length of time from the start of the Agent process, expressed as the number of 1% seconds.
Sequence
This data type is similar to the "structure" in the C programming language. A sequence contains 0 or more elements, and each element is another ASN.1 data type. For example, udpentry in MiB is a variable of this type. It indicates the number of UDP requests that are currently "activated" on the Agent process side ("activated" indicates that the requests are currently used by the application ). This variable contains two elements:
Udplocaladdress in the IPaddress type, indicating the IP address.
Udplocalport of the integer type, from 0 to 65535, indicates the port number.
Sequendeof
This is the definition of a vector, and all its elements have the same type. If each element has a simple data type, for example, an integer type, a simple vector (a one-dimensional vector) is obtained ). But we will see that when SNMP uses this data type, each element in its vector is a sequence (structure ). Therefore, it can be viewed as a two-dimensional array or table.