Hiding Complexity with SNMP
SNMP provides a means for accessing device data in a standard manner. This is accomplished by using a simple message-based protocol and a text-based MIB. The managed objects of interest are defined in the MIB. Listing 1 illustrates an example of retrieving data from an SNMP-based device using the network management system at the bottom of Figure 1.
Listing 1 Determining the Number of Interfaces On a Device
Patterns\Facade>Debug\façade.exe GET MyHostPC public .iso.org.dod.internet.mgmt.mib-2.interfaces.ifNumber.0 SNMP Operation Type GET MIB Object Instance = interfaces.ifNumber.0 Type and Value = INTEGER 3
In Listing 1, we see a program called façade.exe that is passed four command-line parameters (we'll look at these in a moment) and returns the number of interfaces on the platform in question. The last line tells us that the platform in question (MyHostPC in this case; it can be any IP address or DNS name) has three network interfaces.
The parameters passed to façade.exe include the following:
The program modea GET in this case, or a read of platform data
The address for the SNMP requestan IP address or DNS name
The SNMP community namea clear text password
The required managed objectthis is termed an object ID (or OID)
We're actually looking under the hood of network management here because the mechanism of interface retrieval is usually part of a discovery process. In discovery, the management system attempts to uncover the details of the devices for which it is responsible. Some vendor products provide automatic discovery, whereas others require substantial manual input.
It is also possible to run façade.exe in other modes: GETNEXT, SET, WALK, and TRAP. (This source code is discussed extensively in reference [1]). We'll look at the source code for façade.exe a little later in the article.