按照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的目的地址怎樣選定在協議中沒有說明,是由應用決定的。