Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
5918093
feat: Minor tweaks and update deps.
supernomad Feb 15, 2026
6342f69
feat: network and runtime interfaces
supernomad Feb 15, 2026
7ad232d
feat: temp
supernomad Feb 16, 2026
88383a3
feat: temp
supernomad Feb 16, 2026
4f8801b
feat: UDP is working!
supernomad Feb 17, 2026
0308aa8
feat: temp
supernomad Feb 17, 2026
ae752e2
fix: fixed cargo.toml
supernomad Feb 18, 2026
b64241d
feat: fragment
supernomad Feb 20, 2026
7d6e328
feat: udp refactor
supernomad Feb 20, 2026
a551090
feat: 10Mpps udp
supernomad Feb 20, 2026
014804c
feat: rfc compliant udp
supernomad Feb 21, 2026
de119e2
feat: display and some changes.
supernomad Feb 22, 2026
f977928
feat: TCP fully working albeit slow as mollases.
supernomad Feb 22, 2026
46fb069
feat: tiny cleanup.
supernomad Feb 22, 2026
fd20a2e
feat: small changes to naming.
supernomad Feb 22, 2026
4ac2bf7
fix: error handling in fill processing.
supernomad Mar 1, 2026
6b5d3ba
feat: just commiting.
supernomad Mar 1, 2026
74cc1fd
feat: Ripped out all of TCP it was complicating things.
supernomad Mar 1, 2026
0af607a
feat: Revamp of pmtu + neighbor handling
supernomad Mar 1, 2026
3575e6b
feat: Cleanup and hardening of icmp + ip handling.
supernomad Mar 1, 2026
9602d4e
feat: Removed XDP out of wire module decoupling the logic.
supernomad Mar 1, 2026
ab6f4e1
feat: Moved all checksumming to single module for centralized impleme…
supernomad Mar 1, 2026
3fb0623
feat: Revamped UDP.
supernomad Mar 2, 2026
d26d7df
feat: Use coarsetime for faster timestamps.
supernomad Mar 2, 2026
124e778
feat: Checksum offload.
supernomad Mar 2, 2026
b3fe822
feat: Fixing frame handling in local rt.
supernomad Mar 2, 2026
a34cac7
feat: break out ethernet protocol handling.
supernomad Mar 2, 2026
bae63a5
feat: Minor cleanup
supernomad Mar 2, 2026
ecd10f3
feat: cleanup imports and cohesiveness
supernomad Mar 2, 2026
82ea339
feat: cleanup and udp client/server examples.
supernomad Mar 2, 2026
dbd61cd
fix: Remove attempt at breaking down tcp rfc.
supernomad Mar 6, 2026
109580c
docs: TCP data transfer design for established connections
supernomad Mar 7, 2026
56dce27
docs: TCP data transfer implementation plan
supernomad Mar 7, 2026
db82337
feat(tcp): add RingBuffer skeleton with new/capacity/available/free_s…
supernomad Mar 7, 2026
a9b1546
feat(tcp): RingBuffer write and read with wrap-around
supernomad Mar 7, 2026
893a2d6
feat(tcp): RingBuffer write_at, peek_at, advance, commit
supernomad Mar 7, 2026
76caa37
feat(tcp): add data transfer state to TCB — ring buffers, cwnd, RTT
supernomad Mar 7, 2026
f093ea4
feat(tcp): SegmentBuilder::build_data() for data segments
supernomad Mar 7, 2026
972d9aa
feat(tcp): process_established() receive path with in-order and OOO h…
supernomad Mar 7, 2026
bde4dbb
test(tcp): out-of-order segment reassembly test
supernomad Mar 7, 2026
1b67faf
feat(tcp): poll_send() builds data segments from send buffer
supernomad Mar 7, 2026
0ee77a0
feat(tcp): TcpStream::write() and read() futures
supernomad Mar 7, 2026
7fb4709
feat(tcp): data retransmission — RTO + fast retransmit on 3 dup ACKs
supernomad Mar 7, 2026
459fa90
feat(tcp): integrate poll_send into runtime loop
supernomad Mar 7, 2026
0c281a1
feat(tcp): RTT estimation per RFC 6298 updates RTO on ACK
supernomad Mar 7, 2026
31f4c32
test(tcp): comprehensive frame accounting through data transfer
supernomad Mar 7, 2026
d4c46df
docs: TCP connection teardown design (FIN/TIME-WAIT)
supernomad Mar 7, 2026
5b9423a
docs: TCP connection teardown implementation plan (9 tasks)
supernomad Mar 7, 2026
bd538ae
feat(tcp): TCB teardown fields, TcpEvent::RemoteClose, TcpConfig time…
supernomad Mar 7, 2026
c3aecd8
feat(tcp): SegmentBuilder::build_fin_ack for graceful close
supernomad Mar 7, 2026
59de46a
feat(tcp): handle FIN in Established state → CloseWait transition
supernomad Mar 7, 2026
4bbc2bb
feat(tcp): poll_send sends FIN after draining send buffer
supernomad Mar 7, 2026
7fee937
feat(tcp): rewrite TcpStream::close() for graceful FIN, add read() EOF
supernomad Mar 7, 2026
a00c6fc
feat(tcp): process_teardown for FinWait1 and FinWait2 states
supernomad Mar 7, 2026
12ef0dd
feat(tcp): process_teardown for Closing, LastAck, TimeWait, CloseWait
supernomad Mar 7, 2026
4ad210d
feat(tcp): evict_stale removes expired TIME-WAIT connections
supernomad Mar 7, 2026
691b0bd
test(tcp): full active and passive close lifecycle integration tests
supernomad Mar 7, 2026
ff8652d
docs: TCP echo examples design for end-to-end validation
supernomad Mar 7, 2026
805139a
docs: TCP echo examples implementation plan
supernomad Mar 7, 2026
d3424a2
feat: add TCP echo server example
supernomad Mar 7, 2026
392c42b
feat: add TCP echo client example
supernomad Mar 7, 2026
8629a17
docs: TCP delayed ACK + Nagle algorithm design
supernomad Mar 7, 2026
47b2299
docs: TCP delayed ACK + Nagle implementation plan
supernomad Mar 7, 2026
36705e8
feat: add delayed ACK and Nagle fields to TCB and TcpConfig
supernomad Mar 7, 2026
eee3cb4
feat: implement delayed ACK for TCP
supernomad Mar 7, 2026
c125ebe
feat: implement Nagle algorithm with TCP_NODELAY support
supernomad Mar 7, 2026
0bfef80
feat: add TcpStream::set_nodelay() API
supernomad Mar 7, 2026
ab2424d
docs: TCP socket API completeness design (half-close, keep-alive, lin…
supernomad Mar 7, 2026
4774da5
docs: add TCP socket API completeness implementation plan
supernomad Mar 7, 2026
36304d1
feat(tcp): add keep-alive and linger fields to Tcb and TcpConfig
supernomad Mar 7, 2026
28c704d
feat(tcp): implement half-close shutdown()
supernomad Mar 7, 2026
1592cbd
feat(tcp): reset keep-alive timer on data activity
supernomad Mar 7, 2026
7d3e395
feat(tcp): implement keep-alive probes in poll_timers
supernomad Mar 7, 2026
39e8bd6
feat(tcp): implement SO_LINGER in initiate_close and poll_send
supernomad Mar 7, 2026
9cfa47b
feat(tcp): add keepalive and linger socket API methods
supernomad Mar 7, 2026
8ea2af8
test(tcp): add integration tests for half-close, keep-alive, and linger
supernomad Mar 7, 2026
eba4de7
fix(tcp): reset keep-alive probes on duplicate ACK responses
supernomad Mar 7, 2026
765377b
feat: temp
supernomad Mar 7, 2026
8c6d5e3
feat: clippy satisfied
supernomad Mar 7, 2026
be16024
docs: TCP reliability & performance design
supernomad Mar 7, 2026
581d12e
docs: TCP reliability & performance implementation plan
supernomad Mar 7, 2026
d20f7e2
fix: apply window scaling to incoming seg_wnd and outgoing rcv_wnd
supernomad Mar 7, 2026
8ff0387
fix: use advertised_window() for all outgoing segments
supernomad Mar 7, 2026
22be4c2
feat: add segment acceptability checks per RFC 9293
supernomad Mar 7, 2026
0be89a6
feat: add timestamp, SACK permitted, and SACK block option parsing/wr…
supernomad Mar 7, 2026
c8a706d
feat: add timestamp, SACK, and persist timer TCB fields
supernomad Mar 7, 2026
3147222
feat: negotiate timestamps and SACK permitted in SYN/SYN-ACK
supernomad Mar 7, 2026
7aab639
feat: include timestamps in data/ACK segments, implement RTTM
supernomad Mar 7, 2026
13ff11a
feat(tcp): implement zero-window probing with persist timer
supernomad Mar 7, 2026
d22399d
feat(tcp): send SACK blocks in duplicate ACKs for OOO data
supernomad Mar 7, 2026
d971e9c
feat(tcp): parse received SACK blocks and maintain sender scoreboard
supernomad Mar 7, 2026
294c9b6
fix(tcp): prefix unused server_iss variables in SACK tests
supernomad Mar 7, 2026
01b2d15
feat(tcp): selective retransmit using SACK scoreboard
supernomad Mar 7, 2026
eb1e62c
feat(tcp): zero-copy send path with peek_slices and build_data_from_s…
supernomad Mar 7, 2026
42cd4cc
fix(tcp): make PAWS stale test deterministic regardless of uptime
supernomad Mar 7, 2026
d804bd8
docs: add TCP correctness/ECN/socket API design and Phase 6 impl plan
supernomad Mar 7, 2026
8a93a1d
fix: Fixed clippy lints
supernomad Mar 7, 2026
db5794e
docs: add TCP correctness/ECN/socket API implementation plan
supernomad Mar 7, 2026
864c858
feat(tcp): set PSH flag on last data segment in burst
supernomad Mar 7, 2026
6928262
feat(ipv6): count dropped TCP fragments instead of silent discard
supernomad Mar 7, 2026
6577e85
feat(tcp): add ECN fields to TCB and TcpConfig
supernomad Mar 7, 2026
e1df2b7
feat(tcp): negotiate ECN in SYN/SYN-ACK handshake (RFC 3168)
supernomad Mar 7, 2026
b5d382a
feat(tcp): set ECT(0) on outgoing data, detect CE on incoming (RFC 3168)
supernomad Mar 7, 2026
e3ac879
feat(tcp): ECN congestion signaling with ECE/CWR flags (RFC 3168)
supernomad Mar 7, 2026
c418a6e
feat(tcp): return Result from TcpStream read/write, surface Reset/Tim…
supernomad Mar 7, 2026
76a2965
test(tcp): verify simultaneous open reaches Established on both sides
supernomad Mar 7, 2026
892b9f2
docs: add TCP RFC 9293 compliance audit design
supernomad Mar 7, 2026
5b1aedf
docs: add TCP RFC 9293 compliance implementation plan
supernomad Mar 7, 2026
7d2dc57
fix(tcp): use recv_buffer.write() return value for rcv_nxt advancement
supernomad Mar 7, 2026
b2744d8
fix(tcp): only process FIN when all preceding data received
supernomad Mar 7, 2026
74cbdd7
fix(tcp): reorder RST check after sequence validation, add RFC 5961 c…
supernomad Mar 7, 2026
1526b99
fix(tcp): send challenge ACK for SYN in synchronized states (RFC 5961)
supernomad Mar 7, 2026
6cbc647
feat(tcp): retransmit FIN in FinWait1, Closing, and LastAck states
supernomad Mar 7, 2026
57d6789
fix(tcp): drop segments without ACK flag in synchronized states
supernomad Mar 7, 2026
39662c1
fix(tcp): send ACK and drop segment when SEG.ACK > SND.NXT
supernomad Mar 7, 2026
c1578f2
fix(tcp): guard window updates with SND.WL1/WL2 ordering check
supernomad Mar 8, 2026
de804dd
fix(tcp): process ACKs in CLOSE-WAIT for half-close data transfer
supernomad Mar 8, 2026
4e51e54
feat(tcp): implement SWS avoidance for sender and receiver (MUST-38, …
supernomad Mar 8, 2026
a9a558a
docs: add TCP congestion control and loss recovery design
supernomad Mar 8, 2026
a487980
docs: add TCP congestion control and loss recovery implementation plan
supernomad Mar 8, 2026
26acb2b
feat(tcp): add CubicState with slow start, loss, and RTO response
supernomad Mar 8, 2026
acd624f
feat(tcp): implement CUBIC congestion avoidance window function (RFC …
supernomad Mar 8, 2026
b38c646
feat(tcp): add SackRecovery with RFC 6675 IsLost, SetPipe, and entry/…
supernomad Mar 8, 2026
cb02f0c
feat(tcp): add PRR for smooth sending during recovery (RFC 6937)
supernomad Mar 8, 2026
fcd0b92
feat(tcp): add F-RTO spurious RTO detection (RFC 5682)
supernomad Mar 8, 2026
6070ced
refactor(tcp): replace cwnd/ssthresh/dup_ack_count with CubicState/Sa…
supernomad Mar 8, 2026
b81ef61
feat(tcp): integrate CUBIC into ACK processing, replacing inline Reno
supernomad Mar 8, 2026
ce46f46
feat(tcp): integrate RFC 6675 SACK recovery with PRR into fast retran…
supernomad Mar 8, 2026
be8b2b4
feat(tcp): integrate F-RTO into RTO path for spurious timeout detecti…
supernomad Mar 8, 2026
f775be3
feat(tcp): integrate Limited Transmit (RFC 3042) and PRR (RFC 6937) i…
supernomad Mar 8, 2026
caf58fe
feat(tcp): sync CUBIC MSS after negotiation and verify full test suite
supernomad Mar 8, 2026
3b39ad9
fix(tcp): guard PRR against div-by-zero and fix srtt/rttvar doc comments
supernomad Mar 8, 2026
096a827
docs: add TCP per-connection benchmarks design
supernomad Mar 8, 2026
7472ca1
docs: add TCP benchmarks implementation plan
supernomad Mar 8, 2026
f98c170
feat(bench): add skeleton criterion bench files for TCP throughput an…
supernomad Mar 8, 2026
a8e30a0
feat: wtf
supernomad Mar 8, 2026
06791d9
fix(tcp): cap cwnd at receiver window to prevent u32 overflow
supernomad Mar 8, 2026
273acbe
fix: remove benches
supernomad Mar 8, 2026
485bd24
feat: stuff
supernomad Mar 8, 2026
f771060
feat: plans
supernomad Mar 8, 2026
6613958
docs: TCP handler refactor design
supernomad Mar 8, 2026
c8e7c5a
docs: TCP handler refactor implementation plan
supernomad Mar 8, 2026
646aee9
refactor(tcp): extract listener.rs from mod.rs
supernomad Mar 8, 2026
308656d
refactor(tcp): extract connection.rs from mod.rs
supernomad Mar 8, 2026
d535173
refactor(tcp): extract transmit.rs from mod.rs
supernomad Mar 8, 2026
7fae1af
refactor(tcp): extract timers.rs from mod.rs
supernomad Mar 8, 2026
d1e6e0f
refactor(tcp): extract handler.rs from mod.rs
supernomad Mar 8, 2026
eb4133f
refactor(tcp): extract inbound.rs, mod.rs is now export shim
supernomad Mar 8, 2026
0abab8e
refactor(tcp): extract tests into categorized files
supernomad Mar 8, 2026
0d7eb3c
docs: add TCP performance optimization design
supernomad Mar 8, 2026
eac811d
docs: add TCP performance optimization implementation plan
supernomad Mar 8, 2026
386a22f
perf(tcp): pass cached now through IPv4/IPv6 dispatch to TCP
supernomad Mar 8, 2026
4073e59
refactor(tcp): rename process_*_with_now to process_*, remove wrappers
supernomad Mar 8, 2026
8cb041b
perf(tcp): pre-compute tsval once per segment, add Tcb::ts_option()
supernomad Mar 8, 2026
6e5a091
perf(tcp): pre-compute tsval in transmit and timer loops
supernomad Mar 8, 2026
52db2a0
perf(tcp): replace Vec allocations with stack arrays in hot paths
supernomad Mar 8, 2026
43706d9
perf(tcp): pass now into active-open constructor, eliminate 4x Instan…
supernomad Mar 8, 2026
8300696
docs: TCP throughput optimization design and implementation plan
supernomad Mar 8, 2026
face0fa
perf(tcp): consolidate option parsing into ParsedOptions struct
supernomad Mar 8, 2026
0a495db
perf(tcp): add fast-path for common established-state processing
supernomad Mar 8, 2026
a70fbc5
perf(tcp): add RingBuffer::transfer() and TcpStream::splice() for zer…
supernomad Mar 8, 2026
6758d82
perf(tcp): reorder Tcb fields for cache locality
supernomad Mar 8, 2026
19e3cec
perf(tcp): cache connection index in TcpStream to avoid linear scan
supernomad Mar 8, 2026
a7c343a
perf(tcp): extract cold paths to #[inline(never)] functions
supernomad Mar 8, 2026
b959532
feat: fixes.
supernomad Mar 9, 2026
637f0a0
feat: examples
supernomad Mar 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"enabledPlugins": {
"superpowers@claude-plugins-official": true
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
.terraform/
.terraform.lock.hcl
*.tfstate*
*.data
*.data.old
*.perf
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"rust-analyzer.cargo.features": "all",
"rust-analyzer.check.features": "all",
"remote.autoForwardPortsFallback": 0,
}
94 changes: 94 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

**VoidNet** is a high-performance, zero-copy AF_XDP networking library for Rust. It provides safe bindings to Linux's AF_XDP interface, enabling ultra-low latency packet processing by bypassing the kernel network stack. The library crate is named `libvoid` (crate name `voidnet`).

**Requirements:** Linux kernel >= 5.4, Rust >= 1.85 (2024 edition), root or CAP_NET_RAW + CAP_BPF, XDP-compatible NIC. Supported targets: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu.

**System dependencies:** `libbpf-dev libelf-dev libpcap-dev libmnl-dev linux-headers-$(uname -r)` and `clang` (for BPF compilation).

## Build Commands

```bash
cargo build # Build (default, no async features)
cargo build --all-features # Build with all async runtimes
cargo build --features tokio # Build with tokio support
cargo build --features smol # Build with smol support
cargo build --features local # Build with custom local executor

cargo test # Run sync integration tests
cargo test --features local # Run local executor tests
cargo test --features tokio # Run tokio tests
cargo test --features smol # Run smol tests
cargo test --all-features # Run all tests

cargo test --test sync # Run a specific test suite
cargo test --test sync test_name # Run a single test

cargo llvm-cov --all-features --workspace --codecov # Coverage report
```

## Feature Flags

- `async` — Enables futures-core/futures-util (base for all async features)
- `local` — Custom high-performance local executor (implies `async`)
- `smol` — Smol runtime integration (implies `async`)
- `tokio` — Tokio runtime integration (implies `async`)

## Architecture

### Module Structure

**`xdp/`** — Core AF_XDP abstraction (the heart of the library):
- `context/` — XDP program loading and interface attachment (`XdpContext`, `XdpContextBuilder`)
- `socket/` — AF_XDP socket I/O (`Socket`, `SocketRx`, `SocketTx`, `SocketBuilder`)
- `umem/` — Shared memory management (`Umem`, `UmemBuilder`, `FillQueue`, `CompletionQueue`)
- `frame/` — Packet frame buffers (`Frame`, `FrameBuffer` trait, `BasicFrameBuffer`)
- `program/` — BPF program and map management (`XdpProgram`, `AttachMode`)
- `ring/` — Ring buffer primitives (`Producer`, `Consumer`)
- `futures/` — Async runtime integrations, feature-gated (`tokio/`, `smol/`, `local/`)

**`net/`** — Protocol stack (currently being refactored on `runtime` branch):
- `wire/` — Wire format parsing (ethernet, ARP, IPv4/IPv6, ICMPv4/v6, UDP)
- `packet/` — Packet composition (`PacketReader`, `PacketWriter`)
- `handler/` — Protocol handlers (IPv4, IPv6, ICMPv4, ICMPv6, UDP)
- `socket/` — High-level socket abstractions (`UdpSocket`, `SharedQueue`)
- `neighbor.rs` — ARP neighbor resolution cache
- `pmtu.rs` — Path MTU discovery cache

**`rt/`** — High-level runtime utilities:
- `local.rs` — `LocalRuntimeBuilder` pre-configured packet processing pipeline with integrated protocol handlers
- `affinity.rs` — CPU affinity management
- `thread.rs` — Thread utilities
- `waker.rs` — No-op waker for the local executor

### Key Data Flow

Packets flow: NIC → XDP BPF program → XSKMAP → AF_XDP socket → shared UMEM frames → userspace processing. All via mmap'd shared memory with zero copies.

### Design Patterns

- **Builder pattern** on all major types (`XdpContextBuilder`, `SocketBuilder`, `UmemBuilder`)
- **Ownership tokens** (`UmemOwner`, `SocketOwner`) for resource lifetime safety
- **Split I/O** — `Socket` splits into independent `SocketRx` + `SocketTx`
- **Feature-gated compilation** — async code behind `cfg(feature = "...")` with zero cost for unused runtimes
- **Batch processing** — Frames processed in `FrameBuffer` collections, not individually

### BPF Kernel Program

`bpf/xdp_kern.c` is compiled at build time by `build.rs` using clang. It implements round-robin packet distribution across AF_XDP sockets via XSKMAP. The compiled object (`bpf/xdp_kern.o`) is gitignored.

### Testing Infrastructure

Integration tests use `xdp::test_utils::TestVethPair` to create virtual ethernet pairs. Tests spawn cross-thread packet exchange targeting 1M packets for throughput validation. Tests require root privileges — `.cargo/config.toml` configures `sudo -E` as the test runner for both x86_64 and aarch64 targets.

### Running Examples

```bash
cargo run --example sync-echo -- --if-name eth0 --queue 0
cargo run --example sync-rx -- --if-name eth0 --queue 0
cargo run --example tokio-rx --features tokio -- --if-name eth0 --queue 0
```
Loading
Loading