NECKLINK TRANSPORT PROTOCOL · PYNLTP v1.6.0 · MIT OPEN SOURCE

Loss-Healing Encrypted Transport Where TCP, MQTT & Raw ESP-NOW Break.

One unmodified "NL" (0x4E 0x4C) binary wire protocol combining GF(2^8) Cauchy Reed-Solomon forward error correction, 1-RTT X25519 + PSK ephemeral forward secrecy, ChaCha20-Poly1305 AEAD, built-in zero-dependency LZ4 compression, a 4.76 KB RAM MCU sensor profile, and zero-HOL-blocking priority Reflexes — running byte-identically over UDP/IP, 4G/5G CGNAT, satellite, and routerless 2.4 GHz ESP-NOW across Python, ANSI C99, ESP32/ESP8266, Node.js/TypeScript, and Java 11+.

Launch Live Wire Lab ↓
pip install --upgrade pynltp
Source & Benchmarks
Physical ESP32 + ESP8266 Mesh
100% @ 35% Loss
SHA-256 verified multi-KB files on off-grid 2.4 GHz ESP-NOW where Raw ESP-NOW drops to 0/3 from 10% loss.
Linux tc netem (1 MB JSONL)
6.93× vs TCP BBR
2.65 s vs 18.35 s at 20% loss (2.07× faster on clean 20 Mbit), cutting cellular wire bytes to 0.38–0.50× via LZ4.
Zero-Heap ANSI C99 Core
4.76 KB RAM
-DNLTP_TX_ONLY=1 sensor profile keeps full X25519 PFS, LZ4 + Cauchy FEC TX & bidirectional confirmed Reflexes.
Cross-Runtime Wire Parity
248 / 248 Passed
Full 4×4 live interop (Py ↔ C99 ↔ JS ↔ Java) + 18/18 Dual-NAT STUN punch & zero-key 4G CGNAT relay suite.

Run the Real NLTP v1.6.0 Engine Live in Your Browser

Two unmodified NLTPEndpoint state machines (the exact zero-dependency ES2022 wire engine verified in the 248/248 4-language test matrix) exchange real "NL" datagrams across a simulated lossy RF / 4G CGNAT channel below. Crank packet loss up to 35%, fire an urgent out-of-band Reflex mid-upload, or inject a forged packet.

ENGINE READY · REAL NLTPEndpoint (X25519 + ChaCha20-Poly1305 + GF(2^8) Cauchy FEC + LZ4)
12%
40 ms
Payload → LZ4 Wire
12,288 B → —
Frames TX / Dropped
0 / 0
Cauchy Parity RX
0 shards
Reflex / Spoof Blocked
0 ack · 0 blocked
End-to-End SHA-256
READY
NLTP v1.6.0 (Live Result) Click "Transmit Verified Stream" to measure real GF(2^8) recovery.
Raw ESP-NOW Behaviour At 12% frame loss: 0% multi-KB file delivery (no chunk repair).
TCP BBR / MQTT Behaviour Waits on multi-RTT retransmit backoff & stalls urgent commands behind send buffer.
LAST "NL" WIRE FRAME (HEX): 4e 4c 2b 80 · awaiting transmission...
VERIFIED STREAM SHA-256: —

One Unmodified "NL" Envelope Across UDP, CGNAT & L2 ESP-NOW

Every NLTP packet starts with 0x4E 0x4C ("NL") and runs the exact same zero-heap state machine whether carried inside an Internet UDP datagram, a 1-port CGNAT relay room, or an off-grid IEEE 802.11 ESP-NOW action frame.

ENCRYPTED WIRE FRAME (VERSION 2 · 20 B HEADER AAD + CIPHERTEXT + 16 B POLY1305 TAG)
"NL" Magic
2 B (0x4E 4C)
ver | pkt_type
1 B (v2 | 0x1..D)
flags
1 B (0x80 AEAD)
conn_id
4 B LE32
seq64 (Nonce)
8 B LE64
ts_ms
4 B LE32
Encrypted Shard / Reflex
192 B (v1) or 960 B (v2)
Poly1305 Tag
16 B (RFC 8439)
01 // ALGEBRAIC LOSS HEALING

GF(2^8) Cauchy Reed-Solomon

Slices payloads into k = 8 shard generations over GF(2^8) (0x11D). Any 8 distinct systematic or Cauchy parity shards solve the generation via Gauss-Jordan elimination (956 MB/s branchless gf_axpy in C99; zero-GF(2^8) fast-path on clean links).

02 // EPHEMERAL FORWARD SECRECY

1-RTT X25519 + PSK Sessions

100-byte HELLO_ACK fits inside a single 250 B ESP-NOW v1 frame, derives directional ChaCha20-Poly1305 keys, wipes ephemeral scalars immediately, and guards a 512-packet RFC 6479 replay window across 10% packet reordering.

03 // BUILT-IN TELEMETRY CODEC

Zero-Dependency LZ4 + Auto-Bypass

Compresses JSONL/CSV/NMEA logs 4×–20× at 1,164 MB/s before FEC slicing, automatically bypasses incompressible JPEGs/ZIPs (0 B inflation), and performs zero-heap in-place decompression on C99/Arduino MCUs.

04 // OUT-OF-BAND CONTROL

Priority Reflex Lane (send_reflex)

Urgent actuator commands (STOP, RESET) bypass multi-megabyte transfers with zero head-of-line blocking, emit cryptic twins, and retransmit with exponential backoff until PT_REFLEX_ACK confirms single delivery.

05 // CROSS-CHIP RADIO MESH

ESP8266 (v1) ↔ ESP32 (v2)

ESP8266 (80 KB SRAM) sends 242 B encrypted v1 frames that any ESP32 hub decodes automatically alongside 1,010 B v2 frames, bypassing ESP-NOW's 6–17 encrypted peer hardware table cap via payload AEAD + LRU eviction.

06 // CELLULAR & WAN TRAVERSAL

STUN Punch + Zero-Key 4G Relay

Queries RFC 5389 STUN on the live socket, punches NATs via TTL=2 probes, supports 0-RTT Wi-Fi ↔ 5G roaming by authenticated conn_id, and falls back to a 1-port UDP NLTPRelayHub that holds zero keys.

Measured on Physical ESP32 / ESP8266 Silicon & Linux 6.18 tc netem

Every benchmark log and test harness is committed under packages/nltp/results/ and packages/nltp/scripts/ — including links where kernel TCP BBR or raw ESP-NOW are faster.

Symmetric Link (1 MB AQMS JSONL Telemetry) NLTP 1.6.0 (C99 + X25519 + LZ4) NLTP 1.6.0 (Py + X25519 + LZ4) NLTP 1.6.0 (X25519 Raw) TCP BBR (Raw) QUIC ngtcp2 (Raw) kcptun FEC (Raw)
Clean (20 Mbit, 20 ms, 0% loss) 0.245 s (34.3 Mbps, 0.42× wire) 0.555 s (0.38× wire) 0.633 s (1.41×) 0.507 s (1.04×) 0.566 s (1.05×) 0.781 s (2.26×)
Moderate / 4G (10 Mbit, 100 ms, 5% loss) 0.642 s (13.1 Mbps, 0.44× wire) 0.842 s (0.41× wire) 1.350 s (1.31×) 1.645 s (1.11×) 1.420 s (1.11×) 1.577 s (1.78×)
Heavy Radio (5 Mbit, 200 ms, 10% loss) 1.516 s (5.53 Mbps, 0.47× wire) 1.735 s (0.46× wire) 2.893 s (1.46×) 3.728 s (1.18×) 3.198 s (1.18×) 3.254 s (1.68×)
Severe Loss (2 Mbit, 300 ms, 20% loss) 3.003 s (0.50× wire) 2.648 s (3.17 Mbps, 0.50× wire) 7.157 s (1.64×) 18.352 s (1.34×) 9.899 s (1.37×) 8.296 s (2.18×)
Incompressible 1 MB Random @ 20% Loss 6.68 s (C99 X25519) 6.84 s (Py X25519) 6.65 s (Plain) 11.90 s 16.09 s 8.12 s (UDT/SRT: 0/3)

Note: On uncompressed 1 MB random binary over a 0% loss clean 20 Mbit link, kernel TCP BBR finishes in 0.50 s (1.04× wire bytes) vs 0.58–0.63 s for NLTP; on warm 64 KB sessions NLTP 1.6.0 finishes in 0.052 s vs 0.093 s TCP BBR (1.79× faster).

One Wire Protocol Across Python, ESP32/ESP8266, C99, Node.js & Java

Send from a 4.76 KB RAM C99/Arduino microcontroller over ESP-NOW or 4G CGNAT and receive directly in Python, Node.js, or Java 11+ with verified end-to-end SHA-256 receipts.

Python 3.9+ · pip install --upgrade pynltp
from nltp import NLTPServer, NLTPClient, generate_nltp_key

key = generate_nltp_key()  # 256-bit pre-shared key (derives fresh 1-RTT X25519 session keys)

with NLTPServer(("0.0.0.0", 9000), save_dir="./inbox", psk=key) as server:
    with NLTPClient(("127.0.0.1", 9000), psk=key, max_tx_kbps=20_000) as client:
        # 1. Priority out-of-band reflex command (0 head-of-line blocking)
        seq = client.send_reflex("STOP_ACTUATOR")
        assert client.wait_reflex_ack(seq, timeout=3.0)

        # 2. LZ4-compressed + GF(2^8) Cauchy FEC stream with SHA-256 receipt
        receipt = client.send_bytes(b'{"pm25":14.2,"so2":3.1}\n' * 200, compress=True)
        assert receipt["verified_sha256"] is True

When to Use NLTP — and When Standard Protocols Win

NLTP is engineered specifically for lossy wireless, off-grid MCU, and CGNAT links. Here is where NLTP excels and where you should keep using MQTT, TCP BBR, or raw ESP-NOW.

Use NLTP v1.6.0 When:

  • Lossy RF, Cellular Edge, Marine, or Satellite Links (2–35% loss): Shipping binary sensor batches, JSONL/CSV logs, snapshots, or OTA firmware without TCP/MQTT retransmit stalls.
  • Routerless ESP32 / ESP8266 Meshes: You need multi-KB encrypted files over 2.4 GHz ESP-NOW, cross-chip v1 ↔ v2 interop, or unlimited encrypted sensor peers.
  • 4G/5G Carrier CGNAT Traversal: Connecting field gateways directly to Python, C99, Node.js, or Java without VPNs, TLS cert churn, or heavyweight cloud brokers.
  • NLTP + MQTT Together: Use NLTP on the lossy wireless first mile (Sensor → Gateway/Ingest) and fan verified payloads out to MQTT inside your cloud backend.

Stick With MQTT / TCP BBR / Raw ESP-NOW When:

  • Cloud Pub/Sub Topic Routing (a/+/c) on Clean Wi-Fi: Use MQTT — topic wildcards, retained state, and 1-to-10,000 subscriber fan-out are MQTT's purpose-built domain.
  • Clean Wired/Wi-Fi Server Transfers (>= 10 MB): Kernel TCP BBR and QUIC are 12–27% faster on uncompressed clean links and send fewer wire bytes (1.04× vs NLTP's 1.22–1.60× FEC overhead).
  • Coin-Cell <= 250 B Unconfirmed Sensor Pings: Raw ESP-NOW wakes and fires a single frame in ~1–3 ms with zero handshake state when occasional drops are acceptable.
Security & Safety Disclosure: Always generate keys via nltp gen-key (a weak passphrase hashed once with SHA-256 can be brute-forced offline). Ephemeral X25519 + PSK forward secrecy protects past recorded sessions if a PSK is later leaked, but any holder of an unrotated fleet PSK can authenticate new sessions until the key is rotated. NLTP's portable crypto implementations have not undergone an independent third-party cryptographic audit, and software Reflex commands must never be the sole safety interlock on physical machinery.