lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

Strange characters returned by Messenger.Get #243

Closed lextudio-support closed 3 hours ago

lextudio-support commented 3 hours ago

Hello, I have discovered a problem using the Messenger.Get function. I have written a function that given an OID and the host, returns the response as a string. With OID = "1.3.6.1.4.1.11.2.3.9.1.1.7.0" against a printer Samsung ML-4550, I usually have this value as return:

"MODEL:SAMSUNG ML 4550ND;CLASS:PRINTER;DESCRIPTION:SAMSUNG Network Printer;OS 1.10.11.86 07-30-2010; V3.03.03_SEI_1_1.02;"

but sometimes (+or- 30% of times) the function returns a string which is the above one, but trailed with strange characters: char(1), char(63), char(63), char(63). I have this problem only with this printer, so it might be an hardware problem, but the fact that there are these strange character suggests me that maybe the parser of the incoming message can have a bug. Below you can find the source code of my function (vb.net, sorry!):

''' <summary>
''' Get SNMP variable given address and oid
''' </summary>
''' <param name="host">IP address of the device</param>
''' <param name="oid">OID</param>
''' <returns>List of SNMP data</returns>
''' <remarks></remarks>
Private Function GetVariable(host As IPAddress, oid As String) As String
    Dim version As VersionCode = V1

    Dim receiver As Net.IPEndPoint = New Net.IPEndPoint(host, 161)

    Dim vList As New List(Of Variable)()
    Dim test As New Variable(New ObjectIdentifier(oid))
    vList.Add(test)

    Dim mylist As System.Collections.Generic.IList(Of Lextm.SharpSnmpLib.Variable) = Nothing
    mylist = Messenger.[Get](version, receiver, New OctetString("public"), vList, 3000)

    Dim res As String = ""
    For Each Vari As Variable In mylist
        res = res + Vari.Data.ToString()
    Next

    Return res
End Function

Original Reported Date: 2012-04-13T06:12:32.483-07:00 Planned For Release: Original CodePlex ID: 7233

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Only network packet captures can tell what was transferred on the wire. With them, we can easily tell if #SNMP interprets the packets correctly.

http://sharpsnmplib.codeplex.com/wikipage?title=600008&referringTitle=KB

Can you follow the above KB to capture packets when the problem occurs again?

Original Posted Date: 2012-04-13T19:21:52.413-07:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Set to Fixed as no further response is received.

Original Posted Date: 2012-04-30T05:50:54.47-07:00

lextudio-support commented 3 hours ago

Original Closed Date: 2013-06-09T00:48:15.183-07:00