The jNetWorks Public API is designed for simplicity, fluency, and performance. It provides a builder-style, type-safe interface for configuring capture sessions, creating streams, applying filters, and managing parallel processing — all while hiding the complexity of high-speed backends.
The core entry point is the Net interface.
Core Classes and Interfaces
Class/Interface
Purpose
Net
Main factory and session manager. Create streams, configure capture.
PacketStream
Untyped stream of raw Packet objects. Ideal for custom processing.
Fluent interface for selecting capture interfaces.
HashType
Flow distribution strategies (3-tuple, 5-tuple, etc.).
Creating a Net Session
try(Netnet=newPcapBackend()){// Development/testing// try (Net net = new DpdkBackend()) { // Production high-speed// try (Net net = new NtapiBackend()) { // Napatech SmartNIC // Your capture code here}
The same code works across all backends — switch with a single line.
// Create N named streams — ideal for CPU-core affinity
PacketStream[] streams = net.createPacketStreams("worker-%d", Runtime.getRuntime().availableProcessors());
net.capture(PortFilter.ethernet().up()) // Auto-select active Ethernet ports
.or(PortFilter.named("en0", "en1")) // Or explicitly list
.filter("tcp port 443") // Standard BPF syntax
.hash(HashType.HASH_5_TUPLE) // Load-balance flows across streams
.slice(128) // Capture only first 128 bytes (headers only)
.pipe(streams) // Send packets to your stream(s)
.apply(); // Activate configuration