Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct encoding for SNMP type Unsigned32?

I'm writing an SNMP agent and the MIB definition includes an OID of type Unsigned32.

The Unix implementation of the agent uses Net-SNMP and sets the OID as type ASN_UNSIGNED, since it doesn't have an ASN_UNSIGNED32. When I look at the GET response with Wireshark, it decodes it as a "Gauge32" value. That makes sense at first sight, because according to RFC 1902 Unsigned32 and Gauge32 are the same.

The Windows implementation is based on Windows' SnmpAPI.lib and sets the OID as ASN_UNSIGNED32 and when I look at the GET response with Wireshark, it decodes it as "Unsigned32". That looks even better to me.

How come the 2 implementations produce different results on the wire ?

Which is the correct version and how can I manage to get the same from both implementations ?

like image 509
Gene Vincent Avatar asked May 25 '12 14:05

Gene Vincent


2 Answers

It turns out Net-SNMP is using the current RFC 1902 encoding where Unsigned32 and Gauge32 are identical, while Windows uses the obsolete RFC 1442 encoding where Unsigned32 and Gauge32 had different encodings.

like image 136
Gene Vincent Avatar answered Sep 30 '22 22:09

Gene Vincent


If you save the Wireshark capture on Windows and then open it in Wireshark on Unix. Then you may see what is the type it shows. Unsigned32 and Gauge32 are interchangeable defined by the standard, so there should be no different at all in all SNMP implementation. On the wire, it should transfer the same bytes.

like image 44
Lex Li Avatar answered Sep 30 '22 23:09

Lex Li