Previous Table of Contents Next


2.4.1 Defining Objects in the MIBs

A MIB contains the objects to be managed. The OBJECT-TYPE macro defines these objects in a standard format that is consistent across various public and private MIBs. (Chapter 3 will discuss MIBs in greater detail.) The MIB-II ASN.1 definitions (RFC 1213, page 48) appear as follows:

     tcpInSegs OBJECT-TYPE
           SYNTAX  Counter
           ACCESS  read-only
           STATUS  mandatory
           ::= { tcp 10 }

In English, this ASN.1 definition means: This defines an object named tcpInSegs that contains Counter information. The Counter type is a nonnegative number that increases monotonically. (Section 2.4.4 discusses counters, which is a defined type.) This object is read-only and is mandatory for all managed devices that support its parent, mib-2.tcp. When a management protocol accesses this object, it uses the name { tcp 10 }, which identifies the tenth defined object within the tcp group. (Section 2.6 provides more detail on how the SMI names manage objects.)

2.4.2 Primitive (Simple) Types

To maintain SNMP’s simplicity, the Internet SMI uses a subset of the ASN.1 data types. These are divided into two categories, the Primitive types and Constructor types (see Section 2.4.3). Primitive data types (also called Simple types) include INTEGER, OCTET STRING, OBJECT IDENTIFIER, and NULL. The following examples come from MIB-II (RFC 1213). You may also want to refer to Section 2.7, “The Concise SMI Definition,” and locate the Primitive types under the SimpleSyntax definition.

INTEGER is a Primitive type with distinguished (or unique) values that are positive and negative whole numbers, including zero. The INTEGER type has two special cases. The first is the enumerated integer type, in which the objects have a specific, nonzero number such as 1, 2, or 3. The second, the integer-bitstring type, is used for short bit strings such as (0..127) and displays the value in hexidecimal. An example of INTEGER would be:

    ipDefaultTTL   OBJECT-TYPE
          SYNTAX    INTEGER
          ACCESS    read-write
          STATUS    mandatory
          DESCRIPTION
                   “The default value inserted into the
                   Time-To-Live field of the IP header of
                   datagrams originating at this entity, whenever
                   a TTL value is not supplied by the transport
                   layer protocol.”
          ::= { ip 2 }

The OCTET STRING is a Primitive type whose distinguished values are an ordered sequence of zero, one, or more octets. SNMP uses three special cases of the OCTET STRING type: the DisplayString, the octetBitstring, and the PhysAddress. In the DisplayString, all of the octets are printable ASCII characters. The octetBitstring is used for bit strings that exceed 32 bits in length. (TCP/IP frequently includes 32-bit fields. This quantity is a typical value for the internal word width of various processors—hosts and routers—within the Internet.) MIB-II defines the PhysAddress and uses it to represent media (or Physical layer) addresses.

An example of the use of a DisplayString would be:

    sysContact    OBJECT-TYPE
           SYNTAX  DisplayString (SIZE (0..255))
           ACCESS  read-write
           STATUS  mandatory
           DESCRIPTION
                   “The textual identification of the contact
                   person for this manage node, and information on
                   how to contact this person.”
           ::= { system 4 }

Note that the subtype indicates that the permissible size of the DisplayString is between 0 and 255 octets.

The OBJECT IDENTIFIER is a type whose distinguishing values are the set of all object identifiers allocated according to the rules of ISO 8824-1. The ObjectName type, a special case that SNMP uses, is restricted to the object identifiers of the objects and subtrees within the MIB, as for example:

    ipRouteInfo    OBJECT-TYPE
           SYNTAX   OBJECT IDENTIFIER
           ACCESS   read-only
           STATUS   mandatory
           DESCRIPTION
                   “A reference to MIB definitions specific
                   to the particular routing protocol responsible
                   for this route, as determined by the value
                   specified in the route’s ipRouteProto
                   value. If this information is not present, its
                   value should be set to the OBJECT IDENTIFIER
                   { 0 0 }, which is a syntactically
                   valid object identifier, and any conforming
                   implementation of ASN.1 and BER must be able to
                   generate and recognize this value.”

          ::= { ipRouteEntry 13 }

NULL is a type with a single value, also called null. The null serves as a placeholder, but is not currently used for SNMP objects. (You can see NULL used as a placeholder in the variable bindings field of the SNMP GetRequest PDU. The NULL is assigned to be the value of the unknown variable, that is, the value the GetRequest PDU seeks. For more information see Section 4.3.)

Section 2.5.3 discusses the Primitive types and their encodings in more detail.

2.4.3 Constructor (Structured) Types

The Constructor types, SEQUENCE and SEQUENCE OF, define tables and rows (entries) within those tables. By convention, names for table objects end with the suffix Table, and names for rows end with the suffix Entry. The following discussion defines the Constructor types. The example comes from MIB-II.

SEQUENCE is a Constructor type defined by referencing a fixed, ordered, list of types. Some of the types may be optional, and all may be different ASN.1 types. Each value of the new type consists of an ordered list of values, one from each component type. The SEQUENCE as a whole defines a row within a table. Each entry in the SEQUENCE specifies a column within the row.

SEQUENCE OF is a Constructor type that is defined by referencing a single existing type; each value in the new type is an ordered list of zero, one, or more values of that existing type. Like SEQUENCE, SEQUENCE OF defines the rows in a table; unlike SEQUENCE, SEQUENCE OF only uses elements of the same ASN.1 type.


Previous Table of Contents Next