overexchange
overexchange

Reputation: 1

Query on snmp trap size

In our application, buffer is allocated to receive snmp trap which is:

unsigned char buffer[65536 - 60 - 8];

But these numbers tell me about the IP packet header, footer and total length.

Can you please explain, why do we need this size of buffer for snmp trap?

Upvotes: 1

Views: 3041

Answers (1)

Jolta
Jolta

Reputation: 2725

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.

Edit: Ok, here is the formal definition from RFC 3416:

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.

I interpreted that to be related to the MTU of the network, but of course, if the packets are re-assembled properly after fragmentation, there is no problem in receiving even larger traps.

Maybe, if you are asking "why is the number 65536 in my code", you should ask the person who wrote it?

Upvotes: 3

Related Questions