2
votes

I'm using net-snmp library (c/c++) to write the snmp trap sender. For basic object types, it's quite simple to add an object to the trap:


snmp_varlist_add_variable(notification_vars, MibName, length, MIBType, MIBValue, len);

Where 'MibName' being the OID, 'MIBValue' the value as a string and 'MIBType' the ASN type. Now, how to do this for an indexed table? Is there any support for this? How to add all the rows with their elements to the trap?

Or are there simpler alternatives to this?

1

1 Answers

1
votes

It is bad practice to send entire SNMP table within SNMP trap. Usually SNMP tables are pretty big in terms of number of OID instances. The problem is that SNMP uses UDP as transport protocol. SNMP allows PDUs sized up to the MTU of the network. The buffer should be as big as the largest anticipated packet, so it should probably correspond to the MTU, if possible. For example, Ethernet allows up to 1500 byte frame payloads.

So your PDU max size is usually up to 10 varbinds in average.

The common use case scenario here is to send out SNMP trap notifying the user that something has changed/happened. The user will need to fetch data from the table using Get-Next/Get-Bulk upon trap reception to get the details of this event.