SNMP PDU Format总结

本文概述了SNMP协议中的PDU结构,包括不同版本的SNMP中Version、Community String、SNMP PDU等字段,以及SNMPv3的安全特性如Flags、Security Model、User Name和Security Parameters等。此外,还提到了PDU类型的定义,如GET、GETNEXT、SET和TRAP操作的Request ID、Error Status等相关信息。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

最近因为项目的关系学习了许多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.
  • Flags – This field contains the message security level. 0 – message is authenticated, 1 – message uses privacy, 2 – a report PDU is expected for the message
  • Security Model – This field indicates the security model used to generate the message. When USM is used, it has a value of 3
  • Engine ID – This field has the SNMPEngineID of the authoritative SNMP entity involved in the transaction. When a request PDU is generated from an SNMP engine, the remote peer (agent for Get request and manager for Trap request) is the authoritative SNMP entity.
  • Engine Boots – This field has the snmpEngineBoots value of the authoritative SNMP entity involved in the transaction
  • Engine Time – This field has the snmpEngineTime value of the authoritative SNMP entity involved in the transaction
  • User Name – This field contains the principal who originated the request.
  • Security Parameters – This field contains the security parameters that are security model dependent. It contains the authentication parameters and the privacy parameters for USM.
  • Context Engine ID – Within an administrative domain, the contextEngineID uniquely identifies an SNMP entity that may realize an instance of a context with a particular contextName.
  • Context Name – A contextName is used to name a context. Each contextName must be unique within an SNMP entity.
  • PDU – The SNMP PDU (Protocol Data Unit) is used for communication between the SNMP entities.
3. 那么SNMP PDU内部又是什么样子呢?
  • PDU Type- Specifies the type of PDU
  • Request ID- Associates SNMP requests with responses.
  • Error Status- Indicates one of a number of errors and error types. It is set only in Response PDU, for rest it is set as 0.
  • Error Index- Associates an error with a particular object instance. It is set only in Response PDU, for rest it is set as 0.
  • Variable Bindings- Each variable binding associates a particular object instance with its current value. For Get and GetNext requests, the value is ignored.
4. 除此之外,SNMP Trap是一种特殊的消息,它是由SNMP agent 发给一个或者多个SNMP manager station的一种通知,用于报告终端设备的状态。它的报文又是什么样子呢?
  • PDU Type- Specifies the type of PDU
  • Enterprise – Identifies the management enterprise under whose registration authority the trap was defined.
  • Agent address– IP address of the agent
  • Generic trap type– Used to identiy the generic trap. There are six types of generic traps.
  • Specific trap type– Used to identify a specifictrap.
  • Time Stamp– Value of the sysUpTime mib object

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值