Packet Decoding

1.3.b4 almost ready

The beta 4 release is nearly ready. The memory footprint of a running jNetPcap based application is much better.

Beta 4 does away with old way of finalizing objects using the common Object.finalize method, which gets called when object is no longer referenced and is about to be cleaned up. This was the place where certain native memory related jNetPcap objects, would perform their cleanup, releasing native resources. This approach has many issues which are discussed in this Sun/Oracle and several other articles.

Pass RawEhternet Packet Handle directly from C to JnetPcap

Is it possible to pass a Packet handle captured by C code to be directly passed to JNetPcap for processing?

java.lang.NullPointerException: JBuffer not initialized

Hello,

I create a new protocol that SCTP. I listen live data actually multiple interfaces, at any time (generally in 5-100 seconds) get a Exception that below. I am sure that call SctpPacket.init() function before start to listen interface. Have you got any idea, what is the problem?

Thanks

Exception in thread "DeviceMonitor_3" java.lang.NullPointerException: JBuffer not initialized
        at org.jnetpcap.nio.JBuffer.getUByte(Native Method)
        at org.jnetpcap.protocol.network.Ip4.type(Unknown Source)
        at org.jnetpcap.protocol.network.Ip4.decodeHeader(Unknown Source)
        at org.jnetpcap.packet.JHeader.decode(Unknown Source)
        at org.jnetpcap.packet.JPacket.getHeaderByIndex(Unknown Source)
        at org.jnetpcap.packet.JPacket.getHeader(Unknown Source)
        at org.jnetpcap.packet.JPacket.getHeader(Unknown Source)
        at org.jnetpcap.packet.structure.AnnotatedBinding.isBound(Unknown Source)
        at org.jnetpcap.packet.JHeaderScanner.scanAllBindings(Unknown Source)
        at org.jnetpcap.packet.JHeaderScanner.scanHeader(Unknown Source)
        at org.jnetpcap.Pcap.loop(Native Method)
        at org.jnetpcap.Pcap.loop(Unknown Source)
        at xyz.run(DeviceMonitor.java:81)

My new SCTP protocol binding code parts is below

@Header
public class SctpPacket extends JHeader {
    public static final int HEADER_LEN        = 12;
    public static final int HEADER_LEN_AS_BIT = HEADER_LEN * 8;


    public static void init() {
        try {
            JRegistry.register(SctpPacket.class);
            logger.debug("Registered successfully");
        } catch (Exception e) {
            logger.error("Sctp Header Registration exception", e);
        }
    }


    @Field(offset = 0, length = HEADER_LEN_AS_BIT, description = "headerMe")
    public byte[] header() {
        return super.getByteArray(0, HEADER_LEN);
    }

    public byte[] payload() {

Dump packet to byte array instead of file

Hi,
I can write dump file using "dump" function of "PcapDumper" class with respect to libpcap file format. I can open this file using wireshark. Now, I want to get byte array of dump file (same with file) instead of writing file. Is it available with standart API. If not, What is the best solution ? (In my opiniton create a libpcap file header, and append data can be a ugly solution).

Thanks,

Video packet not decode as RTP

Hi All,

I am just writing a simple program to read the offline RTP packets and display the payload type and sequence number. I am successfully getting the ouput if the payload type is audio & static payload (i.e. G711a or G711u). But, no output if the packets are H.264 (dynamic payload type = 126). Here is the part of code.

JPacket packet.getHeader(rtp);

if (packet.hasHeader(rtp)) {

System.out.println(rtp.type() + "," + rtp.sequence());
}

I would appreciate, if you can shed me some light. Thanks in advance.

PS: Wireshark RTP Analysis shows the perfect the report for both of my audio & video streams. So, offline capture file seems ok.