Question Locked

How to Read Network Packet Data in Simple English Form using jpcap

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

hi,

I am using jpcap to capture network packets, I am successfully able to capture the packets from network but the problem is the data in the packets are in machine language and I could not understand it.
e.g [B@2f32927

I am developing a firewall kind of software in java and need to keep the log of all the packets, speciall their data types and data.
Can somebody pleeeeeeeeeeeeeeeease help me out here that is, how to convert the machine data of packet to simple english like data??

The operating system I am working on is windows.

11 replies

by toivo talikka

If you are using jpcap from jpcap.sourceforge.net, it seems to have a "tool for visualizing network traffic". In addition, it has an API, including a library of network packet types and protocols. For example, the package
net.sourceforge.jpcap.net includes the interface ICMPFields which lists all the fields in the ICMP packet, including the start position and the field length.

According to the documentation, the package net.sourceforge.net.client contains "sample 'client' applications which utilize the services provided by classes in the capture package." That might be the best place to start to do research in the the source code.

by zahida.akhtar

Hi Toivo Talikka,

Thanks for your help, I tried to follow the solutions you provide but again facing the problems. I downloaded the both .tar and .zip files of jpcap from sourceforge site (previously using jpcap not from this site). .Zip files for windows just containing the .jar files and .tar file contains the whole package and I found the client application in that package. From the make file in each folder of .tar package I figured this package is for Linux. Anyways I still try to run the client application, 1. seperatly making the project, 2. within the package. All from command prompt after reading the readme files and ofcourse setting up the java home path. But it gives the error which looks like.
CaptureTool, exception in main thread, no class defination found.
When I tried it running after making the complete seperate project and copy past the code in that project's files then it gives the linker error.

Any ways thats from the solution you suggested. I write a little code myself prevously whose output is something like this.
Packet Captured Length:62
Packet Data :[B@89ae9e
Packet DataLink :jpcap.packet.EthernetPacket@1270b73 01:00:01:00:00:00->e8:33:20:00:01:00 (2048)
Packet Header :[B@60aeb0
Packet Length :62
Timestamp Sec :1170088339
Timestamp MSec :675781
Dest Mac Address:[B@16caf43

Now as you can see fields are actually containing the machine language values. I must have to convert it in normal english language to display, specially the data contents.

Can you or somebody else pleeeeeeeeeeeeeease help me in this regards,
One most importantly my OS is WindowsXP so please keep it in mind while suggesting any solution.

Zahida

by kanesh_san

Hi, If you dont mine, May i know/see/verify your code briefly?

Reply Soon.

Thank you,

by gokerozturk

my friend i am from turkey and i have same senior project building java firewall
please help me if you were succeed.
thanks a lot

by kishore.rjkmr

if you have a jpcap setup please forward it to my address kishore.rjkmr@gmail.com

by rahimraja

HI Zahida!!!!!!
Packets received will be in bytes ya..
You should convert it into String...Use the code below

Packet p=new Packet();
byte[] b=captor.getPacket();
String data="";
for(int i=0;i

by pkcblue

This works fine but gives a lot of details,and the actual body of message seems to be missing.I want only the body part of message and content of only chat packets(which are not encrypted in n/w usually) is sufficient.Please help..

by rajgurung777

Hi there Zahida akhtar.... if i am right... whoever you are... i saw your problem are you using jpcap...? if so use this tricks to get the data readable form... i too had the same problem so i could help you ... if you want to share than lets help each other....
you an mail me in rajgurung777@gmail.com
and hope we can help each other....

Arrays.toString(packet.data)
or ...
String s = new String(packet.data)

need more explanation about these commands you can write to me in my mailing id ...
i think together we can help each other more than the net....
cos i m also doing a project something like yours...
Raj G.

by balajipawar.8785

Hey hi thr...

can u plz send me the code for capturing the packet plzzzzzzzzz plzzzzzzzzzz
my email id id balajipawar.8785@gmail.com

thank u...

by ruchiru

String str = " "+captor.getPacket();
System.out.println(str);

This discussion is closed to new replies.