This example demonstrates how to check for and use various API version specific 'pcap' library functions. 'pcap' library, from tcpdump.org team, is evolving and typically adds new function calls to its public API every year. This creates a problem for jnetpcap library integrators as some needed functionality may or may not be present on various client systems. Operating system package installers can typically check for pre-requisite package requirements and make sure that minimum versions of 'pcap' library are installed first before jnetpcap package can be installed. However most users of jnetpcap prefer to use ZIP or TAR format, which does not provide dependency checking mechanism and its up to the user or JVM to resolve and report problems are runtime. Java is also platform independent and writing the code once and run anywhere is a bit more tricky to accomplish when you have such native library dependencies.
jNetPcap version 1.4 introduces a new "native library" management package which facilitates additional checks and information about the state of the loaded native libraries. It allows very specific checks, at runtime, for native symbols without causing exceptions or errors. The library package is exposed through a small set of methods in the Pcap class. These methods make it convenient and easy to check if specific 'pcap' library functionality exists at runtime on any platform, client and even with specific runtime setup.
Latest beta 4 update being tested:
| Test# | Packets/sec (1000s) | bits/s (Millions) | PcapPacket | General Scan | Tcp-only Scan | Copy | Peer | Notes |
| 1 | 102 | 235 | yes | yes | no | yes | no | |
| 2 | 100 | 229 | no | yes | no | yes | no | PcapPacket reused |
| 3 | 628 | 1,438 | yes | no | no | yes | no | |
| 4 | 100 | 229 | no | yes | no | yes | no | Extra new Object(){}; |
| 5 | 825 | 1,850 | no | no | no | yes | no | |
| 6 | 114 | n/a | no | yes | no | no | yes | |
| 7 | 3,500 | n/a | no | no | no | no | yes | |
| 8 | 1,290 | 677 | no | no | yes | yes | yes | copy tcp payload only |
| 9 | 1,050 | 2,280 | no | no | yes | yes | yes | copy all packets |