Retrieving int 4294967294

I’m trying to read Time Base Schedule Date Parameter from a device according to NTCIP 1201v03 using the OID 1.3.6.1.4.1.1206.4.2.6.3.3.2.1.4.2. The value stored in the device for that OID is 4294967294. I am able to read this value via command line using

snmpget -v1 -c “public” foo:161 1.3.6.1.4.1.1206.4.2.6.3.3.2.1.4.2

But when I try to read the same value using the code below, responseEvent.getResponse() object returns null.

PDU pdu = targetBuilder.pdu().type(PDU.GET)        
                       .contextName(CONTEXT_NAME)        
                       .oid(new OID("1.3.6.1.4.1.1206.4.2.6.3.3.2.1.4.2"))
                       .build();

ResponseEvent responseEvent = new SnmpBuilder().udp().v1()
    .build().send(pdu, targetBuilder.build());

return responseEvent.getResponse();

The code works fine with hundreds of OIDs including other instances of Time Base Schedule Date Parameter which store different values. I suspect the value 4294967294 being larger than an int in Java is the problem but still got no solutions for it.

Most likely, the agent providing the value does not correctly BER encode the unsigned 32bit integer value.

In SNMPv1 (what you seem to be using), Unsigned32 is not supported at all. But maybe the value is a Gauge instead?

In SNMP4J all unsigned 32 integer values are represented by long.

If the SMI type is compatible with SNMPv1, then the BER encoding done by the agent is most likely wrong. Such a value must be encoded as 5-bytes but sometimes encoded with longer length (i.e., length encoding methods using more byte for the length information).

To get more information on what is going wrong you can enable DEBUG logging in SNMP4J.

1 Like

Yep, just reached out to the vendor and found out they were using Integer32 instead of Unsigned32 as response type of this OID.