按照RFC1157的建议,给出SNMPv1的实现架构如图1所示。使用SNMP的网络中存在两种角色“management station”和“network element”,同一个设备能够既是Manager又是Element。两种角色上安装着各类属于特定SNMP Community的Application entity,每种SNMP Community使用同一个认证机制。html
图1 实现架构网络
SNMPv1使用UDP报文传输,主题框架使用ASN.1描述以下:(首先要说明一下 Oct String -- A variable-length sequence of octets)架构
RFC1157-SNMP DEFINITIONS ::= BEGIN
IMPORTS
ObjectName, ObjectSyntax, NetworkAddress, IpAddress, TimeTicks
FROM RFC1155-SMI;
-- top-level message
Message ::=
SEQUENCE {
version -- version-1 for this RFC
INTEGER {
version-1(0)
},
community -- community name
OCTET STRING,
data -- e.g., PDUs if trivial
ANY -- authentication is being used
}app
-- protocol data units
PDUs ::=
CHOICE {
get-request
GetRequest-PDU,
get-next-request
GetNextRequest-PDU,
get-response
GetResponse-PDU,
set-request
SetRequest-PDU,
trap
Trap-PDU
}
-- the individual PDUs and commonly used
-- data types will be defined later
END框架
Trap使用与通常PDU不一样的UDP端口号来标识。this
0 1 2 3.net
+ - - - - - + - - - - - - - - + - - - - - - + - - - - - - +代理
| version | community | PDU Type | Real Data |rest
+ - - - - - + - - - - - - - - + - - - - - - + - - - - - - +code
5种不一样PDU详细描述:
其中“GetRequest-PDU”、“GetNextRequest-PDU”、“SetRequest-PDU”和“Trap-PDU”是主动由SNMP application entity发起,交由SNMP protocol entity代理产生报文。惟有“GetResponse-PDU”是被动的在接收到“GetRequest-PDU”、“GetNextRequest-PDU”以及“SetRequest-PDU”后产生的。
The form of the GetRequest-PDU is: GetRequest-PDU ::= [0] IMPLICIT SEQUENCE { request-id RequestID, error-status -- always 0 ErrorStatus, error-index -- always 0 ErrorIndex, variable-bindings VarBindList }
The form of the GetNextRequest-PDU is:
GetNextRequest-PDU ::= [1] IMPLICIT SEQUENCE { request-id RequestID, error-status -- always 0 ErrorStatus, error-index -- always 0 ErrorIndex, variable-bindings VarBindList }
GetNextRequest的用法可能有点让人费解,不要紧,RFC1157 4.1.3.1节中有个例子,看了就懂了,还能顺便了解一下SNMP的使用方法。
The form of the GetResponse-PDU is
GetResponse-PDU ::= [2] IMPLICIT SEQUENCE { request-id RequestID, error-status ErrorStatus, error-index ErrorIndex, variable-bindings VarBindList }
只有当SNMP Agent 收到“GetRequest-PDU”、“GetNextRequest-PDU”以及“SetRequest-PDU”时才会产生。 SetRequest-PDU ::= [3] IMPLICIT SEQUENCE { request-id RequestID, error-status -- always 0 ErrorStatus, error-index -- always 0 ErrorIndex, variable-bindings VarBindList }
The form of the Trap-PDU is: Trap-PDU ::= [4] IMPLICIT SEQUENCE { enterprise -- type of object generating -- trap, see sysObjectID in [5] OBJECT IDENTIFIER, agent-addr -- address of object generating NetworkAddress, -- trap generic-trap -- generic trap type INTEGER { coldStart(0), warmStart(1), linkDown(2), linkUp(3), authenticationFailure(4), egpNeighborLoss(5), enterpriseSpecific(6) }, specific-trap -- specific code, present even INTEGER, -- if generic-trap is not -- enterpriseSpecific time-stamp -- time elapsed between the last TimeTicks, -- (re)initialization of the network -- entity and the generation of the trap variable-bindings -- "interesting" information VarBindList }
关于“Trap-PDU”要说明的是,Trap-PDU的目的地址怎样选定在协议中没有说明,是由应用决定的。