SNMP Inform Requests

SNMP Inform Requests


Description

The SNMP Inform Requests feature allows routers to send inform requests to SNMP managers.

Routers can send notifications to SNMP managers when particular events occur. For example, an agent router might send a message to a manager when the agent router experiences an error condition.

SNMP notifications can be sent as traps or inform requests. Traps are unreliable because the receiver does not send any acknowledgment when it receives a trap. The sender cannot determine if the trap was received. However, an SNMP manager that receives an inform request acknowledges the message with an SNMP response PDU. If the manager does not receive an inform request, it does not send a response. If the sender never receives a response, the inform request can be sent again. Thus, informs are more likely to reach their intended destination.

Because they are more reliable, informs consume more resources in the router and in the network. Unlike a trap, which is discarded as soon as it is sent, an inform request must be held in memory until a response is received or the request times out. Also, traps are sent only once, while an inform may be retried several times. The retries increase traffic and contribute to a higher overhead on the network. Thus, traps and inform requests provide a trade-off between reliability and resources. If it is important that the SNMP manager receives every notification, use inform requests. On the other hand, if you are concerned about traffic on your network or memory in the router and you do not need to receive every notification, use traps.

through illustrate the differences between traps and inform requests.

In , the agent router successfully sends a trap to the SNMP manager. Although the manager receives the trap, it does not send any acknowledgment to the agent. The agent has no way of knowing that the trap reached its destination.

Figure 1 Trap Sent to SNMP Manager Successfully

In , the agent router successfully sends an inform request to the manager. When the manager receives the inform request, it sends a response back to the agent. Thus, the agent knows that the inform request successfully reached its destination. Notice that, in this example, twice as much traffic is generated as in ; however, the agent is sure that the manager received the notification.

Figure 2 Inform Request Sent to SNMP Manager Successfully

In , the agent sends a trap to the manager, but the trap does not reach the manager. Since the agent has no way of knowing that the trap did not reach its destination, the trap is not sent again. The manager never receives the trap.

Figure 3 Trap Unsuccessfully Sent to SNMP Manager

In , the agent sends an inform request to the manager, but the inform request does not reach the manager. Since the manager did not receive the inform request, it does not send a response. After a period of time, the agent will resend the inform request. The second time, the manager receives the inform request and replies with a response. In this example, there is more traffic than in ; however, the notification reaches the SNMP manager.

Figure 4 Inform Request Unsuccessfully Sent to SNMP Manager

### SNMP Inform 功能及使用方法 SNMP (Simple Network Management Protocol) 中的 `inform` 是一种增强型的通知机制,用于网络管理系统(NMS)与被管理设备之间的通信。相比于传统的 `trap`,`inform` 提供了确认机制,从而提高了可靠性。 #### 1. **Inform 的功能** `InformRequest` 是 SNMPv2c 和 SNMPv3 中引入的一种通知形式,其主要特点是发送方在发出通知后等待接收方的响应。如果未收到确认,则可以重新发送通知[^2]。这种特性使得 `inform` 更适合于需要高可靠性的场景。 - **区别于 Trap**: - `Trap`: 不需要确认,一旦发送即完成。 - `Inform`: 发送后需等待对方返回确认消息 (`Response`),若无确认则重发。 - **适用场景**: 当需要确保 NMS 收到告警信息时,优先选用 `inform` 而不是 `trap`。 --- #### 2. **Inform 的工作流程** 以下是 `inform` 工作的一般流程: 1. 网络设备向 NMS 发送一条带有唯一 ID 的 `InformRequest` 报文。 2. 如果 NMS 成功接收到该请求并处理完毕,则回复一个包含相同 ID 的 `Response` 报文给设备。 3. 若设备未能及时收到确认(超时),它将按照预设策略重新发送 `InformRequest`。 此过程显著提升了数据传输的成功率和稳定性[^3]。 --- #### 3. **Inform 的使用方法** ##### (1)命令行方式 通过 Net-SNMP 工具包中的 `snmpinform` 命令可以直接测试或模拟发送 `inform` 请求。语法如下所示: ```bash snmpinform -v VERSION -c COMMUNITY HOST PORT OID VALUE ``` 其中: - `-v VERSION`: 指定使用的 SNMP 版本(如 v2c 或 v3)。 - `-c COMMUNITY`: 对应社区字符串(仅适用于 v2c)。 - `HOST`: 接收方地址。 - `PORT`: 默认端口通常为 162。 - `OID`: 表示要报告的对象标识符。 - `VALUE`: 关联的具体数值。 例如,下面的例子演示如何向 localhost 上运行的服务提交一个简单的整数类型的 inform: ```bash snmpinform -v2c -c public 127.0.0.1 162 .1.3.6.1.4.1.8072.2.3.0.1 i 42 ``` 上述命令表示设置对象 `.1.3.6.1.4.1.8072.2.3.0.1` 的值为整数 `42` 并将其作为 inform 请求发送出去。 --- ##### (2)编程接口调用 对于更复杂的集成需求,开发者可利用 Python 的 `pysnmp` 库或其他语言对应的 SNMP SDK 实现程序化控制下的 inform 操作。以下是一个基于 pysnmp 的简单实例代码片段: ```python from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), CommunityData('public'), UdpTransportTarget(('localhost', 162)), ContextData(), 'inform', NotificationType(ObjectIdentity('SNMPv2-MIB', 'coldStart'))) ) if errorIndication: print(errorIndication) else: for varBind in varBinds: print(f"{varBind.prettyPrint()}") ``` 在此脚本里,“coldStart”事件被封装成 inform 形式的通告传递至本地监听器。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值