D
Dan
To all the gurus out there. I am writing a tool that
receives binary data from a network device. The data
arrives in a standard format which the vendor has
documented, e.g. byte 0 is the format version, 1-4 are
integers between 0 and 255, etc. At this point I just
want to format the data into something that can be read
by humans and write it to the console. I have seen some
other examples of how people acomplish this but none in
visual basic. There is a Perl example I ran across that
uses the unpack operation to change the binary data to
several strings. I have tried converting the data to a
string with different types of encoding. No luck with
that it just shows up as jibberish. I have included my
source so you can see what i'm after. Is there a
comperable operation to the Perl unpack or some little
hack routine that someone has written to make the binary
data useful? Thanks!
Dan
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Public Class NetFlowCollector
Private Shared UDPPort As Integer = 5000
Private Shared Sub StartListener()
Dim done As Boolean = False
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any,
0)
Dim UDPClient As New UdpClient(UDPPort)
Try
While Not done
Dim bytes As Byte() = UDPClient.Receive
(RemoteIpEndPoint)
Console.WriteLine(strData)
End While
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub
Public Overloads Shared Function Main(ByVal args() As
[String]) As Integer
Console.WriteLine("Listening for NetFlow data on UDP
{0}", UDPPort)
StartListener()
Return 0
End Function 'Main
End Class
receives binary data from a network device. The data
arrives in a standard format which the vendor has
documented, e.g. byte 0 is the format version, 1-4 are
integers between 0 and 255, etc. At this point I just
want to format the data into something that can be read
by humans and write it to the console. I have seen some
other examples of how people acomplish this but none in
visual basic. There is a Perl example I ran across that
uses the unpack operation to change the binary data to
several strings. I have tried converting the data to a
string with different types of encoding. No luck with
that it just shows up as jibberish. I have included my
source so you can see what i'm after. Is there a
comperable operation to the Perl unpack or some little
hack routine that someone has written to make the binary
data useful? Thanks!
Dan
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Public Class NetFlowCollector
Private Shared UDPPort As Integer = 5000
Private Shared Sub StartListener()
Dim done As Boolean = False
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any,
0)
Dim UDPClient As New UdpClient(UDPPort)
Try
While Not done
Dim bytes As Byte() = UDPClient.Receive
(RemoteIpEndPoint)
Console.WriteLine(strData)
End While
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Sub
Public Overloads Shared Function Main(ByVal args() As
[String]) As Integer
Console.WriteLine("Listening for NetFlow data on UDP
{0}", UDPPort)
StartListener()
Return 0
End Function 'Main
End Class