Five SNMP protocol data units
SNMP specifies five protocol data units PDU (that is, SNMP Packets) for exchange between management processes and proxies.
Ø Get-Request: extract one or more parameter values from the Agent process (sent by the Network Management System)
Ø Get-next-Request: extract the next parameter value that follows the current parameter value from the Agent process (sent by the Network Management System)
Ø Set-Request: sets one or more parameter values of the proxy process (sent by the network management system)
Ø Get-response operation: return one or more parameter values. This operation is sent by the Agent process. It is the response operation of the first three operations (sent by the agent)
Ø Trap Operation: a message sent by the Agent process to notify the management process of some events (sent by the agent)
The preceding three operations are sent by the management process to the Agent process, and the following two operations are sent to the Agent process to simplify the process, the first three operations are Get, get-next, and set. Describes the five packet operations of SNMP. Note that the proxy process uses port 161 to receive get or set packets, while the management process uses port 162 to receive trap packets.
Parsing the data unit format of SNMP protocol
An SNMP packet consists of three parts: Public SNMP header, get/set header, trap header, and variable binding. Is an SNMP packet format encapsulated into UDP data packets.
Public SNMP first version
The version field is written to reduce the version number by 1. For SNMP (that is, SNMPv1), it should be written to 0.
Public Body
A community is a string, used as a plaintext password between a management process and a proxy process. It is commonly used with 6 characters "public ".
PDU type
Enter 0 ~ A number in 4, which corresponds to the following table.
PDU type
PDU type |
Name |
0 |
Get-Request |
1 |
Get-next-Request |
2 |
Get-Response |
3 |
Set-Request |
4 |
Trap |
GET/set first request identifier (Request ID)
This is an integer set by the management process. The proxy process also returns the request identifier when sending a get-Response Message. The management process can send get packets to many Proxies at the same time. All these packets are sent over UDP, which may be sent before arriving. The request identifier is set to enable the management process to identify which request message is returned for the response message.
Error status)
Enter 0 ~ A number in step 5 is described in the following table.
Error status description
Error status |
Name |
Description |
0 |
Noerror |
Everything is normal |
1 |
Toobig |
The proxy cannot load the answer into an SNMP message. |
2 |
Nosuchname |
The operation specifies a non-existent variable. |
3 |
Badvalue |
A set operation specifies an invalid value or invalid syntax. |
4 |
Readonly |
The management process tries to modify a read-only variable. |
5 |
Generr |
Some other errors |
Error Index)
When a nosuchname, badvalue, or readonly error occurs, the proxy process sets an integer in the response to indicate the offset of the variable with the error in the Variable list.
Trap first Enterprise)
Enter the object identifier of the network device of the trap packet. The object identifier must be a subtree under the enterprise node {1.3.6.1.4.1} in the object naming tree in figure 3.
Trap type
The formal name of this field is generic-trap, which is divided into seven types in Table 4.
Trap type description
Trap type |
Name |
Description |
0 |
Coldstart |
Proxy Initialization |
1 |
Warmstart |
The proxy is reinitialized. |
2 |
Linkdown |
An interface changes from working status to faulty status |
3 |
Linkup |
An interface changes from fault status to working status |
4 |
Authenticationfailure |
Packets with an invalid community are received from the SNMP management process. |
5 |
Egpneighborloss |
An EGP adjacent router becomes faulty. |
6 |
Enterprisespecpacific |
Use the following "specific code" to specify a proxy for custom events |
When the preceding Types 2, 3, and 5 are used, the first variable in the Variable Section after the message should mark the response interface.
Specific Code)
Specifies the time (if the trap type is 6) Customized by the proxy; otherwise, the value is 0.
Timestamp)
Specifies the time (in 10 ms) that has elapsed since the event reported by the proxy process initialization to the trap. For example, if the timestamp is 1908, it indicates that this time occurred ms after proxy initialization.
Variable binding (Variable-bindings)
Specifies the name and value of one or more variables. In the get or get-Next message, the value of the variable should be ignored.
Document: http://d.download.csdn.net/down/2982397/ddxkjddx