Mark has posted 1 posts at DZone. View Full User Profile

jNetPcap Version 1.2 RC1

  • submit to reddit
Open Source

jNetPcap is a true java wrapper around the native libpcap and winpcap libraries, exposing all of their functions and structures. Through the use of java's JNI API, methods are proxied and structures are peered with their java cousins. I stress the "all" exported functions fact, to point out that no other java library does this today and that is how jNetPcap differentiates itself, among other things.

Some Features:

  • No packet data copies - passed by reference into java as a direct nio byte buffer
  • Provides "all" libpcap functions and structures - very few exceptions that just did not make sense in java
  • Also comes with all WinPcap extensions
  • Packets are now fully decoded and provide compile-time type safety for accessing header fields
  • Produce human readable textual output from packets or XML using supplied formatters
  • Tune kernel buffers and behavior from java
  • Transmit at link layer with any size sendqueues
  • Remote captures
  • Allows the kernel to gather statistics much more efficiently
  • LGPL licensed - source in SVN on

    Some note worthy methods: 
  •  openLive - opens a live capture from network interface
  • openOffline - opens a capture file
  • findAllDevsEx - extended version of Pcap.findAllDevs which allows you to not only find network interfaces, but also PCAP files. This can be done locally or remotely.
  • liveDump - which can dump captured packets to a savefile automatically at the kernel level.
  • sendQueueTransmit - and related method, which allow raw packets to be sent in bulk, efficiently.
  • setMinToCopy, setMode and setBuf - allow tweaking of kernel buffers and enable/disable statistical captures
  • offlineFilter - ability to apply the BPF filter on your own packets without a capture
  • setSampling - changes the mode of the capture where only samples of a capture are retruend. packets 
  • statEx - extended statistics that include counters on RPCAP remote connection

Home page:


Published at DZone with permission of its author, Mark Bednarczyk.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Mark Bednarczyk replied on Sat, 2008/12/06 - 12:06pm

An update to 1.2.rc1 has been released.

 jNetPcap 1.2.rc2 is now available for download. The update fixes numerous issues found and RC1. It also adds missing Ip4 options and all ICMP types to the protocol definitions.

 You can download from here:


And project website:

Mark Bednarczyk replied on Mon, 2008/12/22 - 7:44am

1.2.rc3 is now available. RC3 fixes a couple of serious bugs. Adds support for adding custom headers and adding them at runtime. The header definition classes also received a little make over making them easier to write. Created lots of documentation on usage including a user guide:

Comment viewing options

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