Previous Table of Contents Next


2.3.1 Types and Values

A type is a class of data. It defines the data structure that the machine needs in order to understand and process information. The SMI defines three types: Primitive, Constructor, and Defined. ASN.1 defines several Primitive types (also known as Simple types), including INTEGER, OCTET STRING, OBJECT IDENTIFIER, and NULL. By convention, types begin with an uppercase letter. (ASN.1 also defines the four types listed here as reserved character sequences, and therefore represents them entirely in uppercase.) Constructor types (also known as Aggregate types) generate lists and tables. Defined types are alternate names for either simple or complex ASN.1 types and are usually more descriptive. Examples of SNMP-defined types include IpAddress, which represents a 32-bit Internet address, and TimeTicks, which is a time-stamp.

The value quantifies the type. In other words, once you know the type, such as INTEGER or OCTET STRING, the value provides a specific instance for that type. For example, a value could be an entry in a routing table. By convention, values begin with lowercase letters.

Some applications allow only a subset of the possible type values. A subtype specification indicates such a constraint. The subtype specification appears after the type and shows the permissible value or values, called the subtype values, in parentheses. For example, if an application uses an INTEGER type and the permissible values must fit within an 8-bit field, the possible range of values must be between 0 and 255. You would express this as:

    INTEGER (0..255)

The two periods (..) are the range separator and indicate the validity of any integer value between 0 and 255.

2.3.2 Macros

Annex J of ISO 8824-1 defines a macro notation that allows you to extend the ASN.1 language. By convention, a macro reference (or macro name) appears entirely in uppercase letters.

For example, MIB definitions make extensive use of the ASN.1 macro, OBJECT-TYPE (originally defined in RFC 1155 and now replaced by the definition in RFC 1212 [2-9]). The first object in MIB-II is a system description (sysDescr). RFC 1213 uses the OBJECT-TYPE macro to define sysDescr, as follows:

         sysDescr OBJECT-TYPE
            SYNTAX  DisplayString (SIZE (0..255))
            ACCESS  read-only
            STATUS  mandatory
            DESCRIPTION
     “A textual description of the entity. This value should
     include the full name and version identification of the
     system’s hardware type, software operating-system, and
     networking software. This must contain only printable ASCII
     characters.”
           ::= { system 1 }

Thus, one concise package defines the object sysDescr. Section 2.4.1 explores the details of the OBJECT-TYPE macro (SYNTAX, ACCESS, and so on). Note that the range notation (0..255) specifies the permissible size of the DisplayString type, which in this case is between 0 and 255.

2.3.3 Modules

ASN.1 also collects descriptions into convenient groups, called modules. For example, the remote monitoring (RMON) MIB is a discrete unit that is also part of MIB-II.

The module starts with a module name, such as RMON-MIB. Module names must begin with an uppercase letter. The BEGIN and END statements enclose the body of the module. The body may contain IMPORTS, which are the names of types, values, and macros, and the modules in which they are declared. In the following example, the first line after IMPORTS specifies that the Counter type, which will be used in this MIB module, is from another MIB module, RFC1155-SMI.

Following is the header section of the RMON MIB (from RFC 1757), which represents a MIB module. Comment lines within ASN.1 syntax begin with a double hyphen (--):

    RMON-MIB DEFINITIONS ::= BEGIN
       IMPORTS
          Counter                FROM RFC1155-SMI
          DisplayString          FROM RFC1158-MIB
          mib-2                  FROM RFC1213-MIB
          OBJECT-TYPE            FROM RFC-1212
          TRAP-TYPE              FROM RFC-1215;
    -- Remote Network Monitoring MIB
       rmon    OBJECT IDENTIFIER ::= { mib-2 16 }

       -- textual conventions
              .
              .
              .


    END

In the preceding example, you can see the OBJECT IDENTIFIER value notation for RMON. Section 2.6 discusses this notation in detail, but for now simply note that the value of RMON is the sixteenth defined object under the mib-2 object tree. The curly brackets ({}) indicate the beginning and end of a list—in this case a list of the OBJECT IDENTIFIER values defining RMON.

2.3.4 Summary of ASN.1 conventions

In summary, ASN.1 makes distinctions between uppercase and lowercase letters, as follows:

Item Convention

Types Initial uppercase letter
Values Initial lowercase letter
Macros All uppercase letters
Modules Initial uppercase letter
ASN.1 keywords All uppercase letters

The ASN.1 keywords that are frequently used within SNMP are BEGIN, CHOICE, DEFINED, DEFINITIONS, END, EXPORTS, IDENTIFIER, IMPORTS, INTEGER, NULL, OBJECT, OCTET, OF, SEQUENCE, and STRING.

ASN.1 also gives special meanings to certain characters:

Item Name

- Signed number
-- Comment
::= Assignment (defined as)
| Alternation (options of a list)
{ } Starts and ends a list
[ ] Starts and ends a tag
( ) Starts and ends a subtype expression
.. Indicates a range

The sections that follow emphasize some of these special characters. Philip Gaudett’s paper, “A Tutorial on ASN.1” [2-10], provides a good summary of this notation.

2.4 Details of ASN.1—Objects and Types

The previous discussion provided an overview of ASN.1. This section focuses on the ASN.1 objects and data types used within the Internet Network Management framework. Where possible, I will provide examples derived from the SMI (RFC 1155), the Concise MIB Definitions (RFC 1212), and MIB-II (RFC 1213) documents.


Previous Table of Contents Next