SNMPv1/SNMPv2c
SNMPv1/SNMPv2c Packet Format
As shown in Figure 1-3, an SNMPv1/SNMPv2c packet is composed of the version, community name, and SNMP Protocol Date Unit (PDU) fields.
The fields in an SNMPv1/SNMPv2c packet are as follows:
Version: specifies the SNMP version. The value for SNMPv1 is 0 and for SNMPv2c is 1.
- Community name: used in the authentication of agents and NMSs. The community name is a character string and can be defined by users. There are two types of community names: read and write.
- Read community names are used for the GetRequest and GetNextRequest operations.
- Write community names are used for the Set operation.
- SNMPv1/SNMPv2c PDU: includes the PDU type, request ID, and binding variable list.
- The SNMPv1 PDU includes GetRequest PDU, GetNextRequest PDU, SetRequest PDU, Response PDU, and Trap PDU.
- The SNMPv2c PDU inherits the fields of SNMPv1 PDU and introduces the GetBulkRequest PDU.
For simplification, the SNMP operations are described as the Get, GetNext, Set, Response, Trap, and GetBulk operations.
SNMPv1/SNMPv2c Operations
As shown in Table 1-1, SNMPv1/SNMPv2c defines six types of operations for exchanging information between the NMS and agents.
Operation |
Description |
---|---|
Get |
Retrieves one or several variables from the MIB of the agent process. |
GetNext |
Retrieves the next variables in alphabetic order from the MIB of the agent process. |
Set |
Sets one or several variables in the MIB of the agent process. |
Response |
Returns one or several variables. The agent performs this operation in response to the GetRequest, GetNextRequest, SetRequest, and GetBulkRequest operations. Upon receiving a Get or Set request from the NMS, the agent queries or modifies the variables in the MIB, and returns variables to the NMS. |
Trap |
Notifies the NMS of a fault or event occurring on a managed device. This operation is performed by the agent. |
GetBulk |
Queries variables on managed devices in a batch. This operation is performed by the NMS. |
Working Mechanisms of SNMPv1/SNMPv2c
Get
In this example, the NMS intends to use the read community name public to obtain the value of the sysContact object on a managed device. The procedure is as follows:- The NMS sends a GetRequest packet to the agent. The fields in the packet are as follows:
- Version: SNMP version that the NMS is using
- Community name: public
- PDU type: Get
- MIB object: sysContact
The agent authenticates the SNMP version and community name in the packet. When authentication is successful, the agent encapsulates the sysContact value into the PDU of a response packet and sends the response packet to the NMS. If the agent fails to obtain the sysContact value, the agent returns an error message to the NMS.
GetNext
In this example, the NMS intends to use the community name public to obtain the value of the sysName object (next to sysContact) on a managed device. The procedure is as follows:- The NMS sends a GetNextRequest packet to the agent. The fields in the packet are as follows:
- Version: SNMP version that the NMS is using
- Community name: public
- PDU type: GetNext
- MIB object: sysContact
The agent authenticates the SNMP version and community name in the packet. When authentication is successful, the agent encapsulates the sysName value into the PDU of a response packet and sends the response packet to the NMS. If the agent fails to obtain the sysName value, the agent returns an error message to the NMS.
Set
In this example, the NMS intends to use the read community name private to set the sysName object on a managed device to HUAWEI. The procedure is as follows:- The NMS sends a SetRequest packet to the agent. The fields in the packet are as follows:
- Version: SNMP version that the NMS is using
- Community name: private
- PDU type: Set
- MIB object: sysContact
- Expected MIB object value: HUAWEI
The agent authenticates the SNMP version and community name in the packet. When authentication is successful, the agent sets the sysContact object to the expected value and sends a response packet to the NMS. If the setting fails, the agent returns an error message to the NMS.
Trap
Trap is a spontaneous activity of a managed device. The Trap operation is not a basic operation that the NMS performs on the managed device. If a trap triggering condition is met, a managed device sends a trap to the NMS to notify the NMS of the exception. For example, when a managed device completes a hot start, the agent sends a warmStart trap to the NMS.
The agent sends a trap to the NMS only when a module on the managed device meets the trap triggering condition. This mechanism reduces management information exchange between the NMS and managed devices.
GetBulk
A GetBulk operation is equal to consecutive GetNext operations. You can set the number of GetNext operations to be included in one GetBulk operation.