1

I use a simple code from jpcap tutorial.

This my code.

public void capture1() throws IOException {
    int index = 0;
    NetworkInterface[] devices = JpcapCaptor.getDeviceList();
    JpcapCaptor captor = JpcapCaptor.openDevice(devices[index], 65535, true, 20);
    captor.processPacket(-1, new PacketPrinter());
    captor.close(); 
}

and

class PacketPrinter implements PacketReceiver {
    public void receivePacket(Packet packet) {
        System.out.println(packet +" mac :"+packet.datalink);
        //just print out a captured packet
    }
}

But I want to see the packet as a binary.
How can I do it?

VMAtm
  • 27,943
  • 17
  • 79
  • 125
  • 2
    If you want to print the data bytes as hex strings you could use `byte[] packet.data` as source. Iterate over the array and print every byte as it's hex string representation. – SubOptimal Apr 27 '15 at 13:02

0 Answers0