最近因为项目的关系学习了许多SNMP协议方面的知识,想把它们做一个总结。其中这一部分,主要是涉及SNMP协议中通讯的最小协议单元数据PDU报文的格式。在SNMP协议中主要的操作有GET,GETNEXT,SET,TRAP等,每种操作都有对应的request和response格式,这些请求和回复的消息都称之为PDU。
1. 先来看一个SNMP v1 & v2c版本下的报文格式:由于v1 & v2c的安全机制是仅通过一个community string来验证工作的,所以报文格式也相对简单

- SNMP Version – It is an Integer that identifies the version of SNMP. For SNMPv1, it is 0.
- Community String – An Octet String that may contain a string used to add security to SNMP devices.
- SNMP PDU – The SNMP PDU (Protocol Data Unit) is used for communication between the SNMP enities.
2. 对于SNMP v3的话,由于安全机制增加了验证密钥,支持各种加密算法,而且可以根据user来配置不同的机制,所以报文格式一下子就变得复杂许多了:

- Version – It is an Integer that identifies the version of SNMP. For SNMPv3, it is 3.
- ID – This field contains the SNMP message identifier which is a unique ID associated with the message. The msgID field is different from the reqID field available in the PDU.
- Max Size – This field represents the maximum size of message which the requesting SNMP entity can accept.</