jNetPcap is a java library that is a wrapper around the popular OpenSource libpcap from tcpdump.org and WinPcap folks. What makes this library unique is that it is a comprehensive wrapper around the entire libpcap library. jNetPcap uses the same style of API as libpcap. For those that are already familiar with the native API, will be able to utilize jNetPcap with minimal effort. If you are looking for a bit higher API level, that is more object oriented and provides packet decoding, we recommend jNetStream Project built on top of jNetPcap.

jNetPcap API Examples

Here are a bunch of examples that demonstrate various capabilities of the library. If you are familiar with C libpcap API you will notice a lot of similarities and should have no trouble picking up the java API on your own. All the "libpcap" concepts stay exactly the same.

jNetPcap 1.1 preped for release

I'm working on the next release 1.1 of jNetPcap. There haven't been ANY BUGs reported in 1.0 which is great although I did find one myself and fixed and documented.

The release improves the build scripts and documentation. It also adds support for Linux and Debian/Ubuntu (.rpm and .deb).

I will also be updating in detail installation and building instructions from source for each platform. Linux and win32 build fine already and what I'm working on is the debian/ubuntu builds.

The new release of jNetPcap will also allow jNetStream to be released for the same platforms.

Website moving

I've secured a dedicated server to host jnetpcap website. The website will be moving to http://www.jnetpcap.org (also .com and .net) within next 2 weeks. The old website address will redirect to new website once everything is up and running. The main SF project page website address will be updated to point to new address.

The dedicated server will improve user experience tremendously. I will also enable account creation on the website and a user forum. I will close the sf.net forums as they are very cumbersome, hard to reply to and quote code.

The sister project http://jnetstream.sf.net

jNetStream v3 alpha 1 released! (Sister project)

If you are looking for a full featured decoder that enhances the basic jNetPcap capture functionality, jNetStream is it. Just released the 3rd version of jNetStream library that provides full decoding capabilities. jNetStream live capture feature is based on jNetPcap and provides a user friendly interface (higher level) for capturing packets from live network interfaces. Version 3 also adds sophisticated decoding and editing capabilities to packets and capture files. You can slice and dice any of the supported formats in anyway you'd like. Performance is unmatched, with capabilities to read several million packets per second from capture files, all in java. The library utilizes memory mapping and provides a lean API for unmatched performance.

jNetPcap 1.0 Production Released!

We have finally, after many months of testing, reached production status for jNetPcap. There have been 4 prior beta released over the course of nearly a year. From the start, the library originally contained many different jUnit test cases to validate its functionality. This ensured that from the first release of jNetPcap, the library was very stable and working correctly. There were of course a few bugs here and there and even a major one which was quickly fixed in beta 2.

This is a major milestone in this project. The documentation and download links have been updated from this website.

So far so good

I haven't heard of any issues from anyone on the latests beta 4 release. I did find 1 error with the way that isInjectSupported() is handled on linux. It returns the wrong boolean value. Easy fix.

Other than that, the only thing left is to address the libpcap prereqs so that inject and sendPacket on linux are supported. So given these facts, I believe we can proceed to production status in a few weeks.

I'm planning a release of jNetStream software in about 3 weeks, and I will plan on coordinating the jNetPcap 1.0 production release to coincide at the same time. Unless of course, something major is discovered with jNetPcap, which may require another beta release and testing, but I'm in an optimistic mood and lets hope nothing major comes up.

jNetPcap 1.0 beta 4 released!

This release adds support for linux, adds a few new features and fixes some bugs. This pretty much completes the entire libpcap and winpcap API. I can still take requests for something special to be added to the official API, but the API is now stabilizing and I will be relunctant to change any of the core or WinPcap APIs after this next release.

The linux RPM also includes javadocs.

Added methods:

  • Pcap.inject
  • Pcap.isInjectSupported
  • Pcap.isSendPacketSupported
  • Pcap.lookupDev
  • Pcap.lookupNet
  • PcapInteger class

Build scripts were enhanced to support both linux and win32 platforms. On linux a RPM package is built.

pcap_sendpack and pcap_inject

Libpcap now contains 2 methods, pcap_packetsend and pcap_inject that are part of the API. So I'm adding the second pcap_inject, as the first is already in jNetPcap API. Also these are optional methods and dependent on the platform. I'm also adding the is*Supported for each of them. This will allow a runtime check if which one is supported by native live libpcap on any given platform.

This is a little screwy, but that's the way it is defined in libpcap. Both these will exist in the core Pcap class starting in 1.0 beta 4 release

Linux package compiled and working

I got the linux package compiled and working. I'm in the process of testing everything out. The build scripts still need some work, but atleast I can run the jUnit testcases and examples (with root privileges of course.)

The interface names come up, actually suprizingly much differently on linux, but the API handles it OK. The examples though are a little naive and pick the wrong interface by default, so will have to fix that. And probably allow the user to manually choose the interface.

jNetPcap 1.0 beta 3 released!

This is an important release. It adds all the possible functions and structures that libpcap and winpcap has to offer. All the Java functions and peering classes with their native cousins are now available. New WinPcap extension in java sub package org.jnetpcap.winpcap provides additional features available only through WinPcap.