Question Locked

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

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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

2 replies

by seanferd

from the program, not captured data, it looks to me. All that stuff is labels for the data that is meant to be captured.

No idea on how to get the output to print properly.

This discussion is closed to new replies.