nova-net: General-purpose reliable UDP with C99 hot path and Haskell protocol logic

[ bsd3, game, library, network ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0
Change log CHANGELOG.md
Dependencies base (>=4.19 && <5), bytestring (>=0.11 && <0.13), containers (>=0.6 && <0.8), deepseq (>=1.4 && <1.6), mtl (>=2.2 && <2.4), network (>=3.1 && <3.3), stm (>=2.5 && <2.6), transformers (>=0.5 && <0.7) [details]
Tested with ghc ==9.8.4
License BSD-3-Clause
Author Devon Tomlin
Maintainer devon.tomlin@novavero.ai
Uploaded by aoinoikaz at 2026-03-15T22:35:22Z
Category Network, Game
Home page https://github.com/Novavero-AI/nova-net
Bug tracker https://github.com/Novavero-AI/nova-net/issues
Source repo head: git clone https://github.com/Novavero-AI/nova-net -b main
Distributions
Downloads 5 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2026-03-15 [all 1 reports]

Readme for nova-net-0.3.0.0

[back to package description]

nova-net

General-Purpose Reliable UDP

C99 hot path. Haskell protocol brain. Any platform with a C compiler.

CI Hackage Haskell C99 License


What is nova-net?

A general-purpose reliable UDP networking library. C99 handles the hot path (serialization, send/recv, ack processing, crypto). Haskell handles the protocol logic (connection state machines, congestion control, replication). Successor to gbnet-hs.

  • C99 hot path — packet serialization, CRC32C (hardware-accelerated), ChaCha20-Poly1305 AEAD, ring buffers, fragmentation, message batching. Zero heap allocation on the hot path.
  • Haskell protocol brain — connection state machines, handshake orchestration, congestion control, replication. Pure, testable, correct-by-construction.
  • Unsafe FFI boundary — flat scalar arguments, no Storable marshalling. Just a function pointer jump.
  • Any platform — C99 core compiles everywhere. Link from Haskell, Swift, Kotlin, Python, Zig, anything.
  • Effect abstractionMonadNetwork typeclass enables pure deterministic testing with no real sockets.
  • Zero external crypto deps — ChaCha20-Poly1305 implemented from scratch (RFC 8439). CRC32C with SSE4.2/ARMv8 hardware acceleration and software fallback.

Architecture

┌─────────────────────────────────────────────┐
│           User Application                  │
├─────────────────────────────────────────────┤
│  Haskell Protocol Brain (38 modules)        │
│  Peer, Connection, Channel, Reliability,    │
│  Congestion, Handshake, Migration,          │
│  Replication, TestNet, Simulator            │
├─────────────────────────────────────────────┤
│  FFI Boundary (unsafe ccall, flat args)     │
│  NovaNet.FFI.{Packet,CRC32C,Seq,...}        │
├─────────────────────────────────────────────┤
│  C99 Hot Path (13 modules)                  │
│  nn_packet  nn_crc32c  nn_seq  nn_rtt       │
│  nn_fragment  nn_batch  nn_crypto           │
│  nn_bandwidth  nn_congestion                │
│  nn_ack_process  nn_siphash  nn_random      │
│  nn_wire  nn_ffi                            │
└─────────────────────────────────────────────┘

C99 Modules

Module Purpose
nn_wire.h Little-endian helpers, byte swap, buffer bounds (header-only)
nn_packet 9-byte packet header (68-bit wire format, 8 packet types)
nn_crc32c CRC32C integrity — SSE4.2, ARMv8 CRC hardware accel, software fallback
nn_seq Sequence numbers (wraparound-safe), 256-entry ring buffers, ACK bitfield, loss window
nn_rtt Jacobson/Karels RTT estimation (RFC 6298)
nn_ack_process ACK bitfield processing against sent buffer and loss window
nn_congestion Dual-layer: AIMD bandwidth + CWND packet window
nn_fragment Fragment header (6 bytes LE), message splitting
nn_batch Message batching/unbatching (count + length-prefixed)
nn_crypto ChaCha20-Poly1305 AEAD (RFC 8439, from scratch, constant-time tag comparison)
nn_bandwidth Sliding window bandwidth tracker
nn_siphash SipHash-2-4 for HMAC cookies
nn_random OS CSPRNG (getentropy/arc4random_buf/BCryptGenRandom)
nn_ffi Flat-argument FFI entry points for Haskell

Features

  • 68-bit packet headers (4-bit type + 16-bit seq + 16-bit ack + 32-bit ack bitfield)
  • 5 delivery modes (Unreliable, UnreliableSequenced, ReliableUnordered, ReliableOrdered, ReliableSequenced)
  • Dual-layer congestion control (binary mode + TCP New Reno window)
  • ChaCha20-Poly1305 AEAD encryption with anti-replay nonce tracking
  • Hardware-accelerated CRC32C (SSE4.2 on x86, ARMv8 CRC on aarch64)
  • Jacobson/Karels RTT estimation with adaptive retransmit
  • Large message fragmentation and reassembly
  • Connection migration
  • Delta compression, interest filtering, priority accumulation, snapshot interpolation
  • All multi-byte wire fields are little-endian

Status

Feature complete. Builds clean with -Werror on Linux, macOS, and Windows.


Build & Test

Requires GHCup with GHC >= 9.8.

cabal build                              # Build library
cabal test                               # Run all tests
cabal build --ghc-options="-Werror"      # Warnings as errors
cabal bench                              # Run benchmarks

Contributing

cabal test && cabal build --ghc-options="-Werror"

BSD-3-Clause · Novavero AI