Previous | Table of Contents | Next |
The values for these subidentifiers are encoded and placed within the Value field. Bit 8 of each octet indicates whether or not that octet is the last in the series of octets required to fully describe the value. If Bit 8 = 1, at least one octet follows; Bit 8 = 0 indicates the last (or only) octet. Bits 7 through1 of each octet encode subidentifiers. Using an example from the MIB-II object tree, the System group, assume that an OBJECT IDENTIFIER has a value of
{ iso org(3) dod(6) internet(1) mgmt(2) mib-2 (1) 1 }
From the object tree (also discussed below), this is represented by
{ 1 3 6 1 2 1 1 }
Using the values of X = 1 and Y = 3, and the expression above for the first subidentifier value,
(1 * 40) + 3 = 43
This results in the first subidentifier value of 43, the second subidentifier value of 6, the third subidentifier value of 1, and so on. The first value (43) needs 6 bits, or one octet, for encoding (00101011). The second value (6) needs 3 bits for encoding (110), and requires only one octet. Subsequent values also require one octet. As you can see in Figure 2-8, the encoding becomes: Type field = 06H (OBJECT IDENTIFIER, tag = 6); Length field = 06H, and Value field = 2B 06 01 02 01 01 H.
Figure 2-8. Encoding for OBJECT IDENTIFIER type, Value = { 1 3 6 1 2 1 1 }
The NULL type is a placeholder that communicates the absence of information. For example, when a manager requests the value of a variable, it uses the NULL type as a placeholder in the position where the agent will fill in the response.
Encoding for the NULL type is a primitive. The Type field = 05H, and the Length field = 00H. The Value field is empty (no value octets), as shown in Figure 2-9.
Figure 2-9. Encoding for the NULL type, Value = NULL
Recall from the discussion in Section 2.4.3 that the SEQUENCE type is a list of ASN.1 types. A SEQUENCE value is always encoded in Constructed form. The variable bindings used within the SNMP messages provide a good example of SEQUENCE. The variable bindings (or VarBind) pair an object name with its value, which is transmitted inside the Value field, as shown in Figure 2-3. SNMP (RFC 1157, page 32) defines the VarBind:
VarBind ::= SEQUENCE { name ObjectName value ObjectSyntax } VarBindList ::= SEQUENCE OF VarBind
As this syntax shows, the VarBind is a SEQUENCE (pairing) of a name and a value, and the VarBindList is a list of names and values.
Although this is getting ahead of the sequence of our SMI, MIB, and SNMP story, Ill provide an example. Suppose you need the system description for a particular object whose name is sysDescr. To obtain the system description, the manager transmits an SNMP GetRequest to the agent asking for the value of object sysDescr. The agent responds with an SNMP GetResponse message containing the value, such as Retix Local Ethernet Bridge Model 2265M. The VarBind associates the object (sysDescr) and its value (Retix ), as shown in Figure 2-10.
Figure 2-10. Encoding for the SEQUENCE type, a Variable Binding (VarBind)
The first Type field (30H) indicates a Constructed type, with Tag = 16 (SEQUENCE). The first Length field contains 33H, indicating that 51 Value octets follow. The BER are then applied for every type in the SEQUENCE. The first sequence identifies a Primitive type with Tag = 6 (OBJECT IDENTIFIER) and Length = 08H. The Value field contains the numeric representation of the sysDescr object {1.3.6.1.2.1.1.1.0}. The second sequence identifies a Primitive type with Tag = 4 (OCTET STRING), and Length = 27H (39 decimal). The second Value field represents the value of the object sysDescr (Retix Local Bridge ). If youve got a calculator, look at the total length of the encoding. Sequence #1 contains 10 octets (1 from the type field + 1 from the length + 8 from the value). Sequence #2 contains 41 octets (1 + 1 + 39). Sequence #1 plus Sequence #2 (10 + 41) equals the value of the first Length field (51 octets).
The SEQUENCE-OF type value is encoded in Constructed form in the same way as the SEQUENCE type.
The discussion now moves to the application class of encodings. You can find these in Section 2.7, The Concise SMI Definition, as tagged types. Since they are all application Class (01), Primitive (P/C = 0) encodings, with tag numbers between 0 and 4, the Type fields will range from 40 to 44H (see Figures 2-11 through 2-14).
Figure 2-11. Encoding for the IpAddress type, Value = 128.150.161.8
Figure 2-12. Encoding for the Counter type, Value = 190105
Figure 2-13. Encoding for the Gauge type, Value = 32
Figure 2-14. Encoding for the TimeTicks type, Value = 263691156
The SMI defines the IpAddress type. The IpAddress carries a 32-bit IP address, which is represented in four octets. Jumping to the discussion of MIBs in Chapter 3, the IP group contains objects that relate to the IP process on a router or host. An object called IpAdEntAddr identifies the IP address that subsequent information is related to. To encode the IpAdEntAddr (see Figure 2-11), the Type field is set to 40H (application class, Primitive, Tag = 0). The Length field = 4, representing the four octets in the IP address. The Value field contains four contents octets, which convey the IP address in dotted decimal notation. For the address shown in the example [128.150.161.8], the first octet in the Value field contains the binary equivalent of 128 (10000000), the second the binary equivalent of 150, and so on.
A Counter type (also defined in the SMI) represents a nonnegative integer that increases monitonically to a maximum of 4,294,967,295, and then wraps around to zero. The ICMP Group uses many counters to record message statistics. One object, icmpInMsgs, records the number of messages that the ICMP process on a router or host has received. A sample encoding (see Figure 2-12) would have a Type field = 41H, representing application class, primitive encoding, and Tag = 1. The Value (190,105) requires three octets. The Length field is, therefore, 03H, and the Value field contains 02 E6 99H, representing the 190,105 messages.
Previous | Table of Contents | Next |