network programming - Exception when trying to read packets with jpcap (java.lang.InstantiationException) -
i trying send udp packets multicast , receive them jpcap. multicast code works , when sniff wireshark receive packets want have. jpcap code not work, exception:
exception in thread "main" java.lang.instantiationexception: jpcap.packet.datalinkpacket @ jpcap.jpcapcaptor.getpacket(native method) @ receiver.receiver.main(receiver.java:54)
this 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 single packet , print out packet pac = captor.getpacket(); system.out.println(pac); }
the network interface works in wireshark. when run code without captor.setfilter() exception . 1-2 times "null" before exception, seems there several packets let program crash (e.g beacons). when set filter, "udp", no exception every time "null" because no packet captured.
my network interface wifi adapter runs in monitor mode, captures packets receives.
if dont know answer, tell me if there other librarys jpcap can same? found nothing else. or better should use language (c#)? want capture packets , write them file, use language in working best. appreciate help.
Comments
Post a Comment