Packet Decoding

How to parse the data packet?

Hi,Mark B.
I need to catch packets out of the data analysis should be how to do it, thank you.

java.lang.NullPointerException: jmemory not initialized

I'm using jnetpcap1.2rc5 on a windows platform with Java 6 update 17

I'm writing a capture application to read offline captures that I've captured using jnetpcap on a seperate application. When loading the saved capture file i read the packets from the file as follows


/* capture packets using the Pcap object and pass to the packet capturer */
result = pCapturer.dispatch(100, bufHandler, "PacketCapturer");

and the code is packet is processed by the JBufferHandler

In the nextPacket method I scan for Ethernet and check if the packet is an IP packet with

public void nextPacket( PcapHeader pheader, JBuffer jbuffer, String t ){
....
/* scan the packet to determine what data it contains */
pkt.scan( Ethernet.ID );

/* check if it is an IP packet */
if ( pkt.hasHeader( ip ) ) {
....
}

When i try to get a value from the last captured packet i get the exception

Exception in thread "Thread-4" java.lang.NullPointerException: jmemory not initialized
at org.jnetpcap.nio.JMemory.size(JMemory.java:457)

I'm at a loss to understand why this happens and why only on the last captured packet. By using pkt.hasHeader(ip), doesnt the IP data get scanned and decoded? and shouldn't it be available for reading right away?

Any help in understanding this would be appreciated.

Thanks
Shaheen

About read Audio from capture file

Hi All!!

i was looking for the Trhead http://jnetpcap.com/node/195, and i try to use the code showed there but unsucessfuly.. the program read the flows and make the "AU" files, but there are not audible ... y decode wih wireshark and i cant to get the audio file..

u cant help me to idetify what im doing wrong?

thank u Smile

This is my code...


package com.tpmex.jsniffer;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jnetpcap.Pcap;
import org.jnetpcap.PcapBpfProgram;
import org.jnetpcap.PcapTask;
import org.jnetpcap.packet.JPacket;
import org.jnetpcap.packet.JRegistry;
import org.jnetpcap.packet.PcapPacket;
import org.jnetpcap.packet.PcapPacketHandler;
import org.jnetpcap.protocol.voip.Rtp;
import org.jnetpcap.protocol.voip.Sdp;
import org.jnetpcap.protocol.voip.Sip;

import org.jnetpcap.protocol.voip.SipHandler;

/**
 * @author Mark Bednarczyk
 * @author Sly Technologies, Inc.
 */
public class decode    {



public static void main(String[] args) {
        try {
            new decode().SKIP_testRtpAudioExtract();
        } catch (IOException ex) {
            Logger.getLogger(decode.class.getName()).log(Level.SEVERE, null, ex);
        }
}



public static Iterable getIterable(final String file) {
		return new Iterable() {

			public Iterator iterator() {
				return getPcapPacketIterator(file, 0, Integer.MAX_VALUE);
			}

		};
	}




	public static Iterator getPcapPacketIterator(final String file,
			final int start, final int end) {
		return getPcapPacketIterator(file, start, end, null);
	}

Decoded .au file from undecoded Rtp Packets getPayload()

Hi,

I followed the below discussion
http://jnetpcap.org/node/195/

I got .au file but its not playing in Windows media player.
I know that getPayload() method will return undecoded packets, how to decode that packet and how will get ".au" audio file from that Payload raw data.

Can you please help me for the same.

Regards,
Gomathi.K

How to decode undecoded packet which we get from getPayload method from PcapPacket?

Hi,

How to decode and get the .au audio file from undecoded packtes which i got from getPayload() method.

Regards,
Gomathi.K