SNMP uses a simple set of commands to set and retrieve values of objects in MIBs. There are three basic request types in SNMP: Set, Get and GetNext. The Basic SNMP protocol entity is referred to as a PDU, Protocol Data Unit. For the Set, Get and GetNext commands, a PDU consists of a VarBindList, requestType, requestId , errorStatus and errorIndex fields.
A VarBindList is an array of VarBinds. A portion of the snmp.h header file below shows the definition of a VarBindList as well as the definition for a PDU.
typedef struct { RFC1157VarBind *list; UINT len; } RFC1157VarBindList;
typedef struct { RFC1157VarBindList varBinds; AsnInteger requestType; AsnInteger requestId; AsnInteger errorStatus; AsnInteger errorIndex; } RFC1157Pdu;
The requestId helps managers correlate requests with responses. The IP address indicates the IP address of the device that is being managed . The request type is one of the three: Set, Get or GetNext.
Get and Set operations are only allowed on object instances. Obviously, multiple objects may be retrieved or modified in a single PDU. SNMP specifies that, when modifying objects, if one Set fails in a PDU, none of the Set operation should be applied.
The third SNMP request type is a GetNext. A GetNext request is slightly different from Get and Set operations. A VarBindList is still passed as the argument for the GetNext operation, but unlike Get and Set commands, the OIDs present in the GetNext VarBinds do not have to identify object instances. Instead, GetNext request s can specify any OID. The SNMP protocol specifies that when a GetNext request is issued to a particular agent, it will return the first value instrument by the receiving agent following the specified OID. In Figure 1.1, if the agent for the MIB pictured receives a request for 1.3.6.1 (iso.org.dod.internet), the agent must respond with the first OID supported in its MIB(s) that follows ( is lexicographically greater than) the supplied OID--in this case iso.org.dod.internet.private.enterprises.epilogue.toaster.manufacturer.0.
Traps are SNMP messages that originate from the agent to a preconfigured management station. They are used to notify management consoles of significant events. The PDU for a trap is slightly different from that of the other SNMP request types. Trap PDUs consist of a VarBindList, enterprise OID, the IP address of the sending agent, a genericTrap identifier, a specificTrap Identifier and a timeStamp. Typical usage of traps is notification of a service starting or stopping , notification of serious error conditions, and so on. Below is the data structure defined in snmp.h for a trap PDU. The VarBindList is the same as used in Get , GetNext and Set operations. The enterprise is the OID for the enterprise that this trap belongs to. In the case of the Toaster MIB this would be the OID for Epilogue (1.3.6.4.1.12). The agent address is the IP (or IPX) address of the agent. The Generic Trap identifies what kind of trap this is. It can be one of any of the following:
In the case of the Toaster DLL we would indicate SNMP_GENERICTRAP_ ENTERSPECIFIC. The specificTrap pertains to which of Enterprise traps this specific trap is. In other words, the trap ID is the combination of the enterprise OID, genericTrap and specificTrap values. For the Toaster MIB the specificTrap value would be 0.
typedef struct { RFC1157VarBindList varBinds; AsnObjectIdentifier enterprise; AsnNetworkAddress agentAddr; AsnInteger genericTrap; AsnInteger specificTrap; AsnTimeticks timeStamp; } RFC1157TrapPdu;
The timeStamp value is the time from the instant this agent was last initialized until the time this event occurred, in increments of 100ths of a second.