Getting Started
1. Add the Dependency
<dependency>
<groupId>com.slytechs.sdk</groupId>
<artifactId>jnetworks-sdk</artifactId>
<version>3.0.0</version>
</dependency>2. Activate License (Commercial Features Only)
Net.activateLicense("your-commercial-key"); // Optional for libpcap3. Basic Single-Stream Capture
import com.slytechs.sdk.jnetworks.Net;
import com.slytechs.sdk.jnetworks.PacketStream;
import com.slytechs.sdk.jnetworks.pcap.PcapBackend;
import com.slytechs.sdk.protocol.core.Packet;
try (Net net = new PcapBackend()) {
PacketStream stream = net.createPacketStream("main");
net.capture("en0") // Capture from interface en0
.filter("tcp port 80") // Optional BPF filter
.pipe(stream) // Send packets to our stream
.apply();
while (stream.isActive()) {
Packet packet = stream.take();
System.out.printf("Captured %d bytes (wirelen=%d)%n",
packet.capLength(), packet.wireLength());
stream.release(packet); // Always release when done
}
} catch (Exception e) {
e.printStackTrace();
}4. Multi-Core Parallel Processing (Recommended)
5. Typed Protocol Streams (Zero Manual Parsing)
Next Steps
Last updated