Question
January 21, 2008 at 03:13 AM
josh_chrisin

How to get meaningful header and data from the Packets captured using JPCAP

by josh_chrisin . Updated 18 years, 7 months ago

Hi,
This is Joshua. I have a problem with JPCAP. I get all packets using JPCAP library. Also i have installed winpcap.

Everything seems to be fine. but when i try to print the header and data of a packet, i get to see some junk characters. Guess its a machine language.

if(packet instanceof TCPPacket) {
TCPPacket tcpPacket = (TCPPacket)packet;
byte[] data = tcpPacket.getTCPData();
byte[] headdata = tcpPacket.getTCPHeader();
String srcHost = tcpPacket.getSourceAddress();
String dstHost = tcpPacket.getDestinationAddress();
String isoData = new String(data); //, “ISO-8859-1″
String isohead = new String(headdata);
System.out.println(srcHost+” -> ” + dstHost + “: ” + isohead + “######”+ isoData);
}

The header and data is some junk. Can you help me out? What is the reason for this? How do i get a meaningful header and data of the packet after identifying the packet as TCP, UDP or ICMP etc..

Thanks in advance,
Joshua

This discussion is locked

All Comments