0

I want to save a captured packet in TCPDump format. I'm using Java with JPCap library. However, I'm not able to use JpcapWriter.writePacket() function, it gives me a JVM error. This is the code that is causing the JVM error: captor=JpcapCaptor.openDevice(interfaceList[interfaceNumber], 65535, true, 20); captor.setFilter("ip and tcp",true);

JpcapWriter writer=JpcapWriter.openDumpFile(captor,"pass.txt");

for(int i=0;i<10;i++){
      //capture a single packet
      Packet packet=captor.getPacket();
      //save it into the opened file
      writer.writePacket(packet);

    }
writer.close();

Any other way to save it into a file in TCPformat?

Shubham Saini
  • 738
  • 3
  • 8
  • 18

1 Answers1

0

Can you explain how you are calling the method for writing packet. The normal way I used to write packets is

JpcapCaptor captor=JpcapCaptor.openDevice(device[index], 65535, false, 20);
JpcapWriter writer=JpcapWriter.openDumpFile(captor,"filename");
for(int i=0;i<10;i++){
  Packet packet=captor.getPacket();
    writer.writePacket(packet);
 }
writer.close();

It save TCPDump Format Packets.

MouseCrasher
  • 453
  • 1
  • 5
  • 14