|
SourceForge Jpcap | |||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
net.sourceforge.jpcap.capture | Provides an interface for capturing packets and a layer of abstraction around libpcap, a portable native system library for capturing network packets. |
net.sourceforge.jpcap.client | Provides sample 'client' applications which utilize the services provided by classes in the capture package. |
net.sourceforge.jpcap.net | Provides a hierarchical inheritance-based library of network packet types and protocols. |
net.sourceforge.jpcap.util | Provides utility classes used by the jpcap packages. |
The SourceForge Jpcap package provides a complete, Java-like interface to the libpcap and, where available, Winpcap native libraries.
It features:
PacketCapture
is the central class used for packet capture operations.
To capture packets, a user application must implement either the
RawPacketListener
or PacketListener
interface
and then register with an instance of PacketCapture using either the
PacketDispatcher.addRawPacketListener(net.sourceforge.jpcap.capture.RawPacketListener)
or
PacketDispatcher.addPacketListener(net.sourceforge.jpcap.capture.PacketListener)
method.
After registering, the application must use the PacketCapture.open(net.sourceforge.jpcap.capture.CaptureDevice, boolean)
method
to attach to a network interface, and then call the
PacketCapture.capture(int)
method to start receiving packets.
The procedure is relatively straightforward.
In this directory is also a
simple command-line application which captures a raw packet and exits.
The test stub can be invoked using the command:
java net.sourceforge.jpcap.capture.CaptureTest
PacketFactory
, and/or by providing a custom PacketFactory.properties
file.
When capturing packets, the system returns the most specific instance of an object recognizable by the system. For example, using the PacketListener interface, if a packet is captured which can be recognized as IP protocol, but not discernable as ICMP, TCP or UDP, then the system will return an instance of IPPacket.
If it can be ascertained that a packet is a specific protocol, like TCP, then the system will send a TCPPacket. The user application can always cast a specific packet object, like TCPPacket, up to a more generic instance like IPPacket or EthernetPacket.
The tool can be invoked using the command:
See the target 'test' in jpcap.client/makefile.
java net.sourceforge.pcap.client.CaptureTool
The simulator can be enabled by editing properties/tool.properties.
JWinPcap
class.
PacketOutputStream
class.
PacketOutputStream
class.
PacketFactory
class has been made customizable and extensible,
to allow the application to provide its own Packet classes for protocols of interest. It is hoped
that such classes will be contributed to the project where possible.
RARP packets are now correctly returned as instances of ARPPacket, not EthernetPacket.
A large number of setXXX() methods have been added to the packet classes so as to support sending of ARP, RARP, and ICMP packets. However no setXXX() methods has been added to support the sending of TCP or UDP packets, as this is redundant.
CaptureDevice
class: this
encapsulates a usable capture device that can have more than one IP address, and can have
either IPv4 or IPv6 addresses, or both.
This class is accessed via the PacketCapture.lookupCaptureDevices()
and
PacketCapture.findCaptureDevice()
methods.
The
PacketCapture.lookupDevices()
and
PacketCapture.findDevice()
methods no longer return devices that aren't 'up'.
PacketCapture
class
Note: The abolition of the public native methods introduces a source and binary incompability. We thought long and hard about this, but we concluded:
|
Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008. | |||||||||
PREV NEXT | FRAMES NO FRAMES |