0

I am building a GUI to capture packets through Ethernet.

I want pass the received packet in the form of Byte[] and its length through a function for its further processing (to extract various information about Ethernet, IPv4 and UDP protocols). so i want to ask in which format packet is captured by pcapdot.net i.e. byte[] or any other format.

Packet packet;
do
{
    PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out packet);
    switch (result)
    {
        case PacketCommunicatorReceiveResult.Timeout:
            // Timeout elapsed
            continue;
        case PacketCommunicatorReceiveResult.Ok:
            Console.WriteLine(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + " length:" +
                              packet.Length);
            **ParseData(packet,packet.Length);**// **I WANT TO CALL THIS FUNCTION**
            break;
        default:
            throw new InvalidOperationException("The result " + result + " shoudl never be reached here");
    }
} while (true);
rkt_167
  • 7
  • 3

1 Answers1

0

You can just call the Buffer property of the Packet class.

So basically:

ParseData(packet.Buffer,packet.Length);
brickner
  • 6,595
  • 3
  • 41
  • 54