- Tutorials
- API Examples
- User Guide
- Ch 1 - The Basics
- Ch 2 - libpcap
- 2.1 - The Main libpcap API Overview
- 2.2 - Getting a List of Interfaces
- 2.3 - Opening a Network Interface for Capture
- 2.4 - Opening offline capture
- 2.5 - Setting a packet filter
- 2.6 - Reading one packet at a time
- 2.7 - Reading multiple packets with dispatch loops
- 2.8 - Dumping captured packet to an offline file
- 2.9 - Transmitting packets
- 2.10 - Close Pcap and PcapDumper handles
- Ch 3 - Packet Decoding
- Ch 4 - Internals
- Ch 5 - Protocols
- Ch 6 - Native API
Java package: org.jnetpcap
If you have a file with captured packets in it in one of the support libpcap file format, you can open an offline pcap capture using
Pcap.openOffline() call. The call opens up the file for reading packets and when successful returns an instance of Pcap object. This is similar as discussed in previous section but the pcap instance is not bound to any network interface, but to the file.
String fname = "myfile.pcap";
Pcap pcap = Pcap.openOffline(fname, errbuf);
if (pcap == null) {
System.err.printf("Error while opening device for capture: "
+ errbuf.toString());
return;
}
»
Printer-friendly- Login or register to post comments
Send via Email
PDF Convert