Sending and capturing packets via all devices and not having to set destination mac manually [WINDOWS]

I want to capture and send packets and all is well except for two things:
1. I want to use all devices at once for capturing and sending. I read that there is such kind of method for Linux but I'm developing under Windows, so is there an equivalent way of doing so?
2. I create my packet to send from a hexdump and so the destination mac in the Ethernet-Header is already set. Is there a possibility of setting the corresponding mac of the IP I provide automatically by the device or do I have to set it in my code manually? This seems very annoying and I don't want to start ARP requests myself.

I can provide code on request to Smile
I'm using jNetPcap 1.3

New to jNetpcap and Java :)


I am trying to create a protocol analyzer. I have created a separate header (which is more or less of type Ethernet) and registered the same.

My header class Abcd.class (Abcd protocol) looks like:

import java.util.Arrays;

import org.jnetpcap.packet.JHeader;
import org.jnetpcap.packet.annotate.Field;
import org.jnetpcap.packet.annotate.Header;
import org.jnetpcap.protocol.JProtocol;

public class Abcd extends JHeader{

public static final int ID = JProtocol.ETHERNET_ID;

@Field(offset = 0 * BYTE, length = 6 * BYTE, format = "#mac#")
public byte[] destination() {
return getByteArray(0, 6);

@Field(offset = 6 * BYTE, length = 6 * BYTE, format = "#mac#")
public byte[] source() {
return getByteArray(6, 6);

@Field(offset = 12 * BYTE, length = 2 * BYTE, format = "%x")
public int type() {
return getUShort(12);

public String toString() {
return "Abcd [destination()=" + Arrays.toString(destination())
+ ", source()=" + Arrays.toString(source()) + "]";

I am using nextPacket method to get the destination and source address. It looks like

pcap.loop(Pcap.LOOP_INFINATE, new JPacketHandler() {
final Abcd abcd = new Abcd();
public void nextPacket(JPacket packet, StringBuilder errbuf)

System.out.println(" Frame" + packet.getFrameNumber());

System.out.println("ABCD packet found");
System.out.println("Buffer" + packet.getTotalSize());
System.out.println("Header count"+ packet.getHeaderCount());

System.out.println("ethernet header::"+abcd.destination());


The gist is I am getting Null Pointer exception as below:

Exception in thread "main" java.lang.NullPointerException
at org.jnetpcap.nio.JBuffer.check(Unknown Source)
at org.jnetpcap.nio.JBuffer.getByteArray(Unknown Source)
at org.jnetpcap.nio.JBuffer.getByteArray(Unknown Source)
at com.jnetpcap.Rpbe.destination(Rpbe.java:17)

is there an API call to check the jnetpcap version?

The title says it all - since there are some API changes between 1.3 and 1.4 when it comes to parsing protocols over TCP, and I want to support both versions, as long as 1.4 is not "official".


Red5 and - Exception caught no jnetpcap in java.library.path


I have a problem installing jnetpcap on red5 to capture packets. What ever I tried I get this error:

Exception caught no jnetpcap in java.library.path

I tried everything I could. It dose work if I try without red5 Application and I capture packets, but when I install my class witch capture packets in red5 I get exception error.

Please help Sad

DisposableGC: IllegalStateException in 1.4.r1425-1.rhel5.x86_64 on CentOS6.4

I am using JnetPcap 1.4.r1425-1.rhel5.x86_64 on a CentOS6.4. I am handling packets coming through a infinite loop in a live capture and I see the following exception. I came across a thread http://jnetpcap.com/node/798 and it said this bug has been fixed. Not sure if it has come back in the 1.4 version I am using. Any help is greatly appreciated!

Exception in thread "DisposableGC" java.lang.IllegalStateException: g0:: size < 0 :: culprit=JMemoryReference[prev=null, next=null]
at org.jnetpcap.nio.LinkSequence.remove(Unknown Source)
at org.jnetpcap.nio.DisposableGC.sortGenerations(Unknown Source)
at org.jnetpcap.nio.DisposableGC.drainRefQueueLoop(Unknown Source)
at org.jnetpcap.nio.DisposableGC$2.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
Exception in thread "main" java.lang.OutOfMemoryError
at org.jnetpcap.Pcap.loop(Native Method)
at org.jnetpcap.Pcap.loop(Unknown Source)
at adjuggler.fp.poc.CaptureFPData.main(CaptureFPData.java:75)


Syndicate content