# SNMP Trap Packet Loss ## Q/As ### 1. 哪些config可以設定buffer * 參考 [rfc 3416](https://www.rfc-editor.org/rfc/rfc3416) 規範 > The maximum size of an SNMP message is limited to the minimum of: (1) the maximum message size which the destination SNMP entity can accept; and, (2) the maximum message size which the source SNMP entity can generate. 可以藉由修改 agent 或 manager 的 maximum messgae size 來限制 SNMP message 的 maximum size * 修改 `snmpd.conf` 檔案中的 `maxpacket` 變數 > snmpdv1 代理程式將傳輸的封包大小上限 (以位元組為單位)。 此變數可設定的下限為 300 個位元組。 可設定此變數的最大值為 56KB。 如果 maxpacket沒有 snmpd 項目,則會使用系統 Socket 預設層次。 > ~[IBM 說明文件](https://www.ibm.com/docs/zh-tw/aix/7.3?topic=files-snmpdconf-file) * 設定 snmp-agent 參數 ```shell > system-view > snmp-agent packet max-size [byte-count] ``` > ~[Configuring the Maximum Size of the SNMP Packet (HUAWEI)](https://support.huawei.com/enterprise/en/doc/EDOC1000018101/44ee0ba2/configuring-the-maximum-size-of-the-snmp-packet) > ~[snmp-agent packet max-size (HPE)](https://techhub.hpe.com/eginfolib/networking/docs/switches/3100-48/5998-7644r_nmm_cr/content/442453782.htm) ### 2. 造成udp掉封包的選項 (MTU)有哪些 (佐證) * Ethernet 的 [MTU](https://en.wikipedia.org/wiki/Maximum_transmission_unit#MTUs_for_common_media) 通常為 1500 bytes,觀察封包擷取檔,並沒有發現 snmp trap 封包的 PDU 大小 > MTU 的狀況。 * 論文 * UDP packet loss 相關論文多在探討無線通訊領域,也都注重網路拓樸、路徑等層面對封包丟失的影響。 * [Internet packet loss: measurement and implications for end-to-end QoS](https://ieeexplore.ieee.org/abstract/document/721868) * [An improved UDP protocol for video transmission over Internet-to-wireless networks](https://ieeexplore.ieee.org/abstract/document/944478) * SNMP packet loss 相關論文多在探討使用 SSH 等安全連線時的效能。 * [On the Impact of Security Protocols on the Performance of SNMP](https://ieeexplore.ieee.org/abstract/document/5702353) * 總之沒有找到相關的 * 可參考 <[linux 系统 UDP 丢包问题分析思路](https://cizixs.com/2018/01/13/linux-udp-packet-drop-debug/)> 這篇文章來分析,主要確認伺服器負載是否過高,以及 socket buffer size 的大小 * 分析 UDP checksum ![](https://hackmd.io/_uploads/BynQh8vN3.png) 發現並沒有內容丟失的問題,推估像下圖 ![](https://hackmd.io/_uploads/BytU2LDN2.png) Value Missing 的問題,應該是在發出封包前就出現了,而不是在傳輸過程中遺失的。 ## 解決方法 (增加穩定度) * 使用 UDP 本就有掉封包的風險,可改用基於 TCP 的 SNMP * 或者棄用 TRAP 改用一樣基於 UDP 但要求回應的 [INFORM](https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/snmp/configuration/xe-3se/3850/snmp-xe-3se-3850-book/nm-snmp-inf-req-review.pdf)