Net if的定义 | 12. Definition of Agent Net if
12 代理网络的定义IF
图12.1: 代理Net的目的IF
网络接口(Net if)进程将SNMP PDU传递给主代理,并从主代理接收SNMP PDU。Net if进程最常见的行为是从网络接收字节,将它们解码为SNMP PDU,并将其发送给主代理。当主代理处理PDU时,它向Net if过程发送响应PDU,该过程将PDU编码为字节并将字节传输到网络上。
但是,这种简单的行为可以通过多种方式进行修改。例如,网络if进程可以对字节应用某种加密/解密方案,或充当代理过滤器,该代理过滤器将一些数据包发送给代理代理,并将一些数据包发送给主代理。
也可以编写自己的Net if过程。默认的Net if进程在模块中实现snmpa_net_if
,它使用UDP作为传输协议,即传输域transportDomainUdpIpv4
和/或transportDomainUdpIpv6
。
本节介绍如何编写Net if进程。
12.1强制功能
Net if进程必须实现SNMP代理network interface behaviour
。
12.2消息
“ 消息
”部分描述了强制性消息
,如果必须发送并且能够接收,该消息
必须是Net。
在本节中,Address字段是一个{Domain,Addr}元组,其中Domain是transportDomainUdpIpv4或transportDomainUdpIpv4,Addr是{IpAddr,IpPort}元组。
传出消息
Net如果从网络接收到针对MasterAgent的SNMP PDU时必须发送以下消息:
MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra}
- Vsn可以是'版本-1','版本-2'或'版本-3'。
以下消息用于报告已收到对请求的响应。代理可以发送的唯一请求是一个Inform-Request。
Pid ! {snmp_response_received, Vsn, Pdu, From}
Pid
是等待请求响应的进程。send_pdu_req
消息中指定了Pid
(see below)
。
传入消息
本节介绍Net if进程必须能够接收的传入消息。
{snmp_response, Vsn, Pdu, Type, ACMData, To, Extra}
该消息作为对先前接收到的请求的响应而被发送到来自主代理的网络if处理。
- `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
- `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response.
- `Type` is the `#pdu.type` of the original request.
- `ACMData` is data used by the Access Control Module in use. Normally this is just sent to `snmpa_mpd:generate_response_message` (see Reference Manual).
- `To` is the destination `Address` that comes from the `From` field in the corresponding `snmp_pdu` message previously sent to the MasterAgent.
- `Extra` is the term that the Net if process sent to the agent when the request was sent to the agent.
{discarded_pdu, Vsn, ReqId, ACMData, Variable, Extra}
如果由于某种原因决定放弃pdu,该消息将从主代理发送。
- `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
- `ReqId` is the request id of the original request.
- `ACMData` is data used by the Access Control Module in use. Normally this is just sent to `snmpa_mpd:generate_response_message` (see Reference Manual).
- `Variable` is the name of an snmp counter that represents the error, e.g. `snmpInBadCommunityUses`.
- `Extra` is the term that the Net if process sent to the agent when the request was sent to the agent.
{send_pdu, Vsn, Pdu, MsgData, To, Extra}
当要发送陷阱时,该消息从主代理发送。
- `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
- `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response.
- `MsgData` is the message specific data used in the SNMP message. This value is normally sent to `snmpa_mpd:generate_message/4`. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information.
- `To` is a list of `{Address, SecData}` tuples i.e the destination addresses and their corresponding security parameters. This value is normally sent to `snmpa_mpd:generate_message/4`.
- `Extra` is any term that the notification sender wishes to pass to the Net if process when sending a notification (see [`send notification`](snmpa#send_notification2) for more info).
{send_pdu_req, Vsn, Pdu, MsgData, To, Pid, Extra}
当请求被发送时,该消息从主代理发送。代理可以发送的唯一请求是Inform-Request。net if进程需要记住请求ID和Pid,并且收到请求ID的响应时,使用snmp_response_received
消息将其发送到Pid 。
- `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
- `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response.
- `MsgData` is the message specific data used in the SNMP message. This value is normally sent to `snmpa_mpd:generate_message/4`. In SNMPv1 and SNMPv2c, this message data is the community string. In SNMPv3, it is the context information.
- `To` is a list of `{Address, SecData}` tuples i.e the destination addresses and their corresponding security parameters. This value is normally sent to `snmpa_mpd:generate_message/4`.
- `Pid` is a process identifier.
- `Extra` is any term that the notification sender wishes to pass to the Net if process when sending a notification (see [`send notification`](snmpa#send_notification2) for more info).
注意
由于Net if进程负责编码和解码SNMP消息,因此它还必须更新MIB-II中的SNMP组中的相关计数器。 为此,可以使用模块snmpa_mpd中的函数(有关更多详细信息,请参见参考手册,部分snmp,模块snmpa_mpd)。
在模块snmp_pdus
中还有一些用于编码和解码SNMP消息的有用功能