WinPCAP

8 replies [Last post]
somayeh
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 07/09/2010
Printer-friendlySend via EmailPDF Convert

Hello everyone
I need to read some winpcap file using jnetpcap. I captured my desired traffic by wireshark and i need to read them. can you tell me which classes does support that?
yours

somayeh
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 07/09/2010
JNP vs JNS

Guys
Do I need JnetStream for reading offline captured file? or can I use jNetPcap?

Mark B.
Mark B.'s picture
User offline. Last seen 5 hours 9 min ago. Offline
Joined: 03/22/2008
Hi and welcome. jNetPcap can

Hi and welcome.

jNetPcap can read "offline" files, you do not need jNetStream for that purpose. The process for reading offline files is nearly identical to this example. The only difference is that your code needs to use Pcap.openOffline method, instead of Pcap.openLive.

Sly Technologies, Inc.
R&D

Mark B.
Mark B.'s picture
User offline. Last seen 5 hours 9 min ago. Offline
Joined: 03/22/2008
I should add, that since you

I should add, that since you are reading a file, you can also skip the step in the example where it discovers the "list of devices" which are only needed for Pcap.openLive method.

Sly Technologies, Inc.
R&D

somayeh
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 07/09/2010
Can not open

Thanks Mark.
But in Windows do I need anything to be able to open a file?

Here is your code:

String fname = "myfile.pcap";
Pcap pcap = Pcap.openOffline(fname, errbuf);

Where my file should be located? I wrote Pcap pcap = Pcap.openOffline("C:\myfile.pcap", errbuf);
but it can not find it.

Do I need to call any extra method for Windows?

Mark B.
Mark B.'s picture
User offline. Last seen 5 hours 9 min ago. Offline
Joined: 03/22/2008
You need specify a full path

You need specify a full path to the file. If you go into "windows exlorere" under windows, copy/paste the path from the window as your path into Pcap.openOffline.

Sly Technologies, Inc.
R&D

somayeh
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 07/09/2010
Path definition

Sorry I can not understand what you mean. I specified the whole path. I dont know what you mean by copy/paste the windows explorer into openoffline.
Can you please guide me.
Regards

somayeh
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 07/09/2010
that is exactly C:\ then i

that is exactly C:\
then i replaced my file there
C:\myfile.pcap
then i provide this address Pcap pcap = Pcap.openOffline("C:\myfile.pcap",errbuf);
but it says doesnt exist such directory/file

Mark B.
Mark B.'s picture
User offline. Last seen 5 hours 9 min ago. Offline
Joined: 03/22/2008
A backslash to java is an

A backslash to java is an escape sequence. You need to provide a '\\' so it comes out in the end as a single \.

Sly Technologies, Inc.
R&D

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.