0

I am trying to send udp packets with multicast and receive them with jpcap. The multicast code works and when I sniff with wireshark I receive all the packets which i want to have. But my jpcap code does not work, I get this exception:

Exception in thread "main" java.lang.InstantiationException: jpcap.packet.DatalinkPacket
    at jpcap.JpcapCaptor.getPacket(Native Method)
    at Receiver.Receiver.main(Receiver.java:54)

This is my Code:

    NetworkInterface[] devices = JpcapCaptor.getDeviceList();

    int index = 0;

    JpcapCaptor captor=JpcapCaptor.openDevice(devices[index], 60000, true, 20);
    //captor.setFilter("udp", true);

    for(int i=0;i<1000;i++){
          //capture a single packet and print it out
          Packet pac = captor.getPacket();
          System.out.println(pac);        


        }

The Network Interface works perfectly in wireshark. When I run the Code without captor.setFilter() I get the exception . Sometimes I get 1-2 times "null" before the exception, so it seems like there are several packets which let my program crash (e.g beacons). When I set a filter, like "udp", I get no exception but every time "null" because no packet is captured.

My Network Interface is a Wifi Adapter which runs in Monitor Mode, so it captures all packets which it receives.

If you dont know an answer, could you tell me if there are other librarys like jpcap which can do the same? I found nothing else. Or would you say that I better should use another language for this (C#)? I really just want to capture the packets and write them to a file, so I will just use the language in which this is working best. I would really appreciate your help.

Ephisray
  • 3
  • 5
  • You will need to provide the *complete* stack trace, but also tell us which of the three (at least) versions of JPcap you are using. – user207421 Oct 07 '13 at 01:12
  • @EJP the line where the Exception occures is there where captor.getPacket() is called. I am using the jpcap version of www.eden.rutgers.edu (jpcap 0.7). – Ephisray Oct 07 '13 at 11:23
  • That's not a complete stack trace, is it? THere should be another exception underneath what you've posted, that says what the underlying cause was. – user207421 Oct 08 '13 at 04:39
  • @EJP I only get this one exception, no other. I am not sure what is a "stack trace"? The Exception? There is really no other exception. – Ephisray Oct 08 '13 at 16:06

0 Answers0