SNMP GET snmpexception when response in V1 has trailing data bytes when using SharpSnmp

326 Views Asked by At

A SharpSnmpLib SNMP V1 GET snmpexception is thrown when querying a certain vendor equipment located in remote networks. Other software like iReasoning MIB Browser, SNMPB, or SnmpSharpNet work OK on the same OID and equipment.

The error varies even though the equipment is the same and the OID the same but located in a different network. It seems like a Data segment is added to the end of the UDP packet. One one piece of equipment the error message might be: "BER end of file", and on another identical piece of equipment, the error message is "unsupported data type:34", or "unsupported data type:115" and so on. Many different data types found on the same OID but from different pieces of equipment.

The error occurs in the project source file "MessageFactory.cs" in the ParseMessage routine. If I catch the error and continue the program works OK. I ignore the error for the trailing portion of data bytes that are not properly parsed.

MessageFactory.cs ParseMessage error

The wireshark packets are also shown below:

Wireshark capture of SNMP GET where BER end of file occurs

And here is another error on another piece of exact same SNMP device and OID, just different IP address.

Another error with same equipment and same OID

It seems like the trailing Data portion causes the API to throw an error because it does not recognize it as valid variable. Yet other software packages handle this without seeming error messages. I will have to modify the source code for Sharp SNMP to use the API unless finding a better solution. My modification involves catching the error and moving on. The first variable in the loop is already found and produces the proper value. The error occurs when continuing on from the first variable because the stream has not reached the end.

1

There are 1 best solutions below

1
On

use the form that has (message, start, length, registry) this works because it only reads from start to length and not the trailing problems