首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Net if的定义 | 12. Definition of Agent Net 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时必须发送以下消息:

代码语言:javascript
复制
MasterAgent ! {snmp_pdu, Vsn, Pdu, PduMS, ACMData, From, Extra}
  • Vsn可以是'版本-1','版本-2'或'版本-3'。
  • Pdu是snmp_types.hrl中定义的SNMP PDU记录和SNMP请求。
  • PduMS是允许的最大响应Pdu的大小。 通常这是从snmpa_mpd:process_packet返回的(请参阅参考手册)。
  • ACMData是正在使用的访问控制模块使用的数据。 通常这是从snmpa_mpd:process_packet返回的(请参阅参考手册)。
  • 源是来源地址。
  • 额外是如果流程希望发送给代理的任何术语。 仪表功能可以通过调用snmp:current_net_if_data()来检索该术语。 当代理生成对请求的响应时,这些数据也会发送回网络。

以下消息用于报告已收到对请求的响应。代理可以发送的唯一请求是一个Inform-Request。

代码语言:javascript
复制
Pid ! {snmp_response_received, Vsn, Pdu, From}
  • Pid是等待请求响应的进程。send_pdu_req消息中指定了Pid (see below)
  • Vsn或者是'version-1''version-2',或'version-3'
  • Pdu 是收到的SNMP Pdu
  • From是来源Address

传入消息

本节介绍Net if进程必须能够接收的传入消息。

  • {snmp_response, Vsn, Pdu, Type, ACMData, To, Extra} 该消息作为对先前接收到的请求的响应而被发送到来自主代理的网络if处理。
代码语言:txt
复制
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`. 
代码语言:txt
复制
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
代码语言:txt
复制
-  `Type` is the `#pdu.type` of the original request. 
代码语言:txt
复制
-  `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). 
代码语言:txt
复制
-  `To` is the destination `Address` that comes from the `From` field in the corresponding `snmp_pdu` message previously sent to the MasterAgent.
代码语言:txt
复制
-  `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,该消息将从主代理发送。
代码语言:txt
复制
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`. 
代码语言:txt
复制
-  `ReqId` is the request id of the original request. 
代码语言:txt
复制
-  `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). 
代码语言:txt
复制
-  `Variable` is the name of an snmp counter that represents the error, e.g. `snmpInBadCommunityUses`. 
代码语言:txt
复制
-  `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} 当要发送陷阱时,该消息从主代理发送。
代码语言:txt
复制
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
代码语言:txt
复制
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
代码语言:txt
复制
-  `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. 
代码语言:txt
复制
-  `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`. 
代码语言:txt
复制
-  `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 。
代码语言:txt
复制
-  `Vsn` is either `'version-1'`, `'version-2'`, or `'version-3'`.
代码语言:txt
复制
-  `Pdu` is an SNMP PDU record (as defined in snmp\_types.hrl) with the SNMP response. 
代码语言:txt
复制
-  `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. 
代码语言:txt
复制
-  `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`. 
代码语言:txt
复制
-  `Pid` is a process identifier. 
代码语言:txt
复制
-  `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消息的有用功能

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com