Skip to content

JaskRendix/ldpc-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LDPC Rust

A Rust implementation of CCSDS LDPC decoding algorithms originally prototyped in the DelfiSpace LDPC‑Simulation project.
The codebase replaces the original Python/C++ scripts with a single, memory‑safe, deterministic Rust library.
All decoding operations use fixed‑size arrays, checked indexing, and embedded CCSDS parity‑check matrices.

The implementation covers:

  • hard‑decision decoders: Gallager‑A, Gallager‑B, WBF, MWBF, NWBF
  • soft‑decision decoders: SPA and Min‑Sum in the LLR domain
  • CCSDS matrices: 128×256 and 256×512
  • BER simulation tools
  • an Axum HTTP microservice
  • benchmarks for hard‑ and soft‑decision decoders
  • a test suite for correctness, safety, and randomized trials

The structure of the CCSDS reference algorithms is preserved.
Hard‑decision decoders behave as defined in the literature; Gallager‑B, MWBF, NWBF, and SPA provide reliable correction behavior across all bit positions.
WBF is included for completeness but does not guarantee convergence for every single‑bit error on the CCSDS matrices.


Context: Why Rust

The original DelfiSpace repository mixes Python control logic with C++ decoding kernels.
Porting the algorithms to Rust consolidates the implementation into a single, safe binary and removes:

  • Python loop overhead
  • C++ pointer arithmetic
  • manual memory management
  • ad‑hoc threading scripts

Rust provides deterministic memory safety and predictable performance, which is useful for LDPC decoding workloads that evaluate thousands of parity‑check equations per iteration.
The SPA and Min‑Sum decoders benefit from Rust’s ability to run tight numerical loops without garbage‑collection pauses or undefined behavior.


Project Layout

src/
  bitarray.rs
  ldpc_decoder.rs
  spa_decoder_llr.rs
  matrices/
    h_128_256.rs
    h_256_512.rs
    mod.rs
  server_router.rs

src/bin/
  ber_spa.rs
  bench.rs
  server.rs

tests/
  ldpc_tests.rs
  server_tests.rs

Cargo.toml
README.md

Running Tests

cargo test

BER Simulation

The SPA/Min‑Sum decoder can generate BER curves for the CCSDS 256×512 code.
Output is (snr_db, ber) pairs in CSV format.

cargo run --release --bin ber_spa > ber_spa_256_512.csv

Benchmarks

cargo run --release --bin bench

Reports total time, average time per trial, and throughput.


Axum Microservice

A small HTTP service exposes the decoders for external tools.

Start:

cargo run --bin server

Health check:

curl http://localhost:8080/health

Bit‑Flip Decode

curl -X POST http://localhost:8080/decode/bitflip \
     -H "Content-Type: application/json" \
     -d '{"cw":[...], "iterations":10}'

SPA Decode

curl -X POST http://localhost:8080/decode/spa \
     -H "Content-Type: application/json" \
     -d '{"cw":[...], "snr_db":1.0, "iterations":10}'

Docker

Build:

docker build -t ldpc-server .

Run:

docker run -p 8080:8080 ldpc-server

This setup uses only the Dockerfile.
Prometheus, Grafana, and docker‑compose have been removed.


Reference

This project is based on the CCSDS LDPC decoding algorithms and the DelfiSpace LDPC‑Simulation project:

https://github.com/DelfiSpace/LDPC-Simulation

The Rust version removes pointer‑level edge cases and undefined behavior present in the original C++ implementation while keeping the algorithmic structure and matrix definitions consistent with CCSDS specifications.

About

Rust implementation of CCSDS LDPC decoders (128×256, 256×512). Includes Gallager, WBF/MWBF/NWBF, SPA/Min‑Sum, BER tools, benchmarks, and an Axum microservice. Modern Rust port of the original DelfiSpace LDPC‑Simulation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors