The foundational module providing core services and APIs for high-performance network packet capture and analysis systems. Built on Java's Foreign Function & Memory (Panama FFM) API for zero-allocation, native-speed packet processing.
Note: Requires JDK 22+ for full Panama FFM support. While FFM was available as preview in JDK 21, production-ready features require JDK 22 final release.
Core API serves as the foundational layer for a comprehensive network analysis ecosystem, providing essential services to 20+ specialized modules for packet capture, protocol analysis, and network monitoring. Designed for extreme performance scenarios requiring 100M+ packets per second throughput.
- Zero-allocation packet processing at 100M+ pps scale
- Pool-based memory management with lock-free operations
- Native memory integration via Panama Foreign Memory API
- Reference-counted lifecycle management with automatic cleanup
- Foreign Memory Integration - Java Panama FFM wrapper and utilities
- Native Memory Abstractions - High-level memory management APIs
- System Structure Bindings - mbuf and network structure wrappers
- Data Pipeline Framework - Stream processing infrastructure
- Configuration Management - Centralized settings and runtime config
- Utility Functions - Common operations and helper classes
- Tier 1: 100M+ pps (zero-allocation inline operations)
- Tier 2: 10M+ pps (pool-backed structural operations)
- Tier 3: 1M+ pps (full-featured editing and transformations)
core-api/
├── com.slytechs.jnet.core.api.foreign/ # Panama FFM integration
├── com.slytechs.jnet.core.api.format/ # Data formatting utilities
├── com.slytechs.jnet.core.api.memory/ # Memory management APIs
├── com.slytechs.jnet.core.api.memory.impl/ # Memory implementation classes
├── com.slytechs.jnet.core.api.time/ # Timestamp and timing utilities
├── com.slytechs.jnet.core.api.util/ # Common utility functions
└── com.slytechs.jnet.core.api.util.function/ # Functional programming utilities
// Primary memory interfaces
public interface MemoryView // Read-only access and navigation
public interface MemoryWindow // Bounds and positioning management
public interface MemoryRef // Reference counting and lifecycle
public interface Memory // Complete memory abstraction
// Performance-tiered editors
public interface MemoryInlineOperations // 100M+ pps, zero allocation
public interface MemoryStructuralEditor // 10M+ pps, pool-backed
public interface MemoryEditor // 1M+ pps, full-featuredAbstractMemory- Base implementation with reference countingMemoryWrapper- Zero-overhead immutable memory wrapperMemorySlice- Mutable data bounds managementMemoryBuffer- Poolable buffer with full operationsMemoryProxy- Zero-allocation rebindable memory accessMemoryPool- Lock-free pool management
// Create memory from native segment
MemorySegment segment = arena.allocate(2048);
Memory memory = Memory.of(segment);
// High-performance inline operations (100M+ pps)
MemoryInlineOperations inline = memory.inline();
inline.position(12)
.insertSpace(4) // VLAN tag space
.put((short) 0x8100) // VLAN TPID
.put((short) vlanId); // VLAN TCI// Lock-free memory pool
MemoryPool<MemoryBuffer> pool = new MemoryPool<>(
2048, // segment size
1000, // pool capacity
arena, // memory arena
MemoryBuffer::new // factory
);
// Automatic pool management
try (MemoryBuffer buffer = pool.allocate()) {
buffer.clear()
.put(ethernetHeader)
.insert(4).put(vlanTag) // Pool-backed insertion
.expand(payloadSize) // Dynamic expansion
.put(payload);
} // Auto-return to pool on close// Zero-allocation protocol layer access
MemoryProxy ethernetLayer = new MemoryProxy();
MemoryProxy ipLayer = new MemoryProxy();
// Bind to packet regions
ethernetLayer.bindMemory(packet, 0, 14); // Ethernet header
ipLayer.bindMemory(packet, 14, 20); // IP header
// Process without allocation
processEthernet(ethernetLayer);
processIp(ipLayer);| Operation Type | Target Performance | Allocation Strategy | Use Case |
|---|---|---|---|
| Inline Operations | 100M+ pps | Zero allocation | High-speed packet processing |
| Structural Editing | 10M+ pps | Pool-backed only | Dynamic packet construction |
| Full Editing | 1M+ pps | As needed | Complex transformations |
- Use appropriate performance tier based on throughput requirements
- Leverage memory pools for sustained high-performance scenarios
- Minimize object allocation in critical processing paths
- Reuse MemoryProxy instances for protocol layer processing
- Prefer inline operations for simple packet modifications
Core API is designed to support specialized network analysis modules:
- Packet Capture Modules - Raw packet acquisition and buffering
- Protocol Analyzers - Layer 2-7 protocol parsing and analysis
- Flow Analysis - Connection tracking and session analysis
- Security Modules - Intrusion detection and threat analysis
- Performance Monitoring - Network performance metrics and alerting
- Data Export - PCAP, JSON, and custom format output
- Java 22+ with full Panama FFM support
- Native memory access capabilities
- Linux/Windows/macOS platform support
Important: JDK 22 is required for production use. While Panama FFM was available as preview in JDK 21, the mature API features needed for high-performance packet processing require JDK 22's final implementation.
# Build with Maven
mvn clean compile
# Run tests
mvn test
# Package module
mvn packageLicensed under the Sly Technologies License. See LICENSE for details.
Core API is the foundation for a large-scale network analysis project. Contributions should focus on:
- Performance optimization in critical paths
- Memory safety and proper resource management
- API consistency across the module ecosystem
- Comprehensive testing especially for edge cases
See CONTRIBUTING.md for detailed guidelines.
Note: This module requires careful attention to memory management and performance characteristics. Always profile critical paths and validate memory cleanup in production scenarios.