ocaml-scc — CCSDS Synchronization and Channel Coding#
Pure OCaml implementation of the CCSDS Synchronization and Channel Coding sublayer per CCSDS 131.0-B (TM) and CCSDS 231.0-B (TC).
Overview#
The SCC sublayer sits between the Physical Layer and the Data Link Protocol sublayer. It handles frame synchronization and forward error correction:
Space Packet / TC Frame / TM Frame
|
+----------v-----------+
| Data Link Protocol | ocaml-tc, ocaml-tm, ocaml-aos, ...
+-----------+-----------+
|
+----------v-----------+
| Synchronization & | ** this package **
| Channel Coding (SCC) |
+-----------+-----------+
|
Physical Layer (RF)
Modules#
Synchronization (Scc.Sync)#
| Module | Standard | Description |
|---|---|---|
Scc.Sync.Cltu |
231.0-B | CLTU encode/decode with BCH(63,56) |
Scc.Sync.Asm |
131.0-B | ASM marker (0x1ACFFC1D) insert/detect |
Scc.Sync.Cltu_sync |
231.0-B | Stream parser for CLTU extraction |
Scc.Sync.Asm_sync |
131.0-B | Stream parser for ASM-framed data |
Channel Coding (Scc.Coding)#
| Module | Standard | Description |
|---|---|---|
Scc.Coding.Randomizer |
131.0-B §9 | LFSR pseudo-random sequence |
Scc.Coding.Reed_solomon |
131.0-B §4 | RS(255,223) with interleaving I=1..8 |
Scc.Coding.Convolutional |
131.0-B §3 | Rate 1/2, K=7 (G1=0x79, G2=0x5B) |
Scc.Coding.Turbo |
131.0-B §6 | Parallel concatenated + BCJR/MAP |
Scc.Coding.Ldpc |
131.0-B §7 | Belief propagation decoder |
The generic algorithms live in standalone packages (ocaml-reed-solomon,
ocaml-viterbi, ocaml-turbo, ocaml-ldpc). This package provides the
CCSDS-specific parameterizations.
Installation#
Install with opam:
opam install scc scc-eio
If opam cannot find the packages, they may not yet be released in the public
opam-repository. Add the overlay repository, then install them:
opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
opam update
opam install scc scc-eio
Usage#
(* TC uplink: frame -> CLTU. *)
let uplink tc_frame = Scc.Sync.Cltu.encode tc_frame
(* TM downlink: randomize + RS encode + convolutional encode. *)
let downlink frame =
let r = Scc.Coding.Randomizer.create () in
Scc.Coding.Randomizer.apply r frame 0 (Bytes.length frame);
let codeword = Scc.Coding.Reed_solomon.encode ~interleave:I5 frame in
Scc.Coding.Convolutional.encode codeword
(* Stream parsing: extract CLTUs from raw bytes. *)
let feed_cltus state raw_bytes =
let new_state, result = Scc.Sync.Cltu_sync.feed state raw_bytes in
(new_state, result)
Eio Transport (scc-eio)#
The scc-eio package provides Eio flow-based send/recv:
let serve ~source ~sink ~process_tc tm_frame =
(* Receive CLTU-framed TC from a raw byte stream. *)
(match Scc_eio.Cltu.recv source with
| Ok frame -> process_tc frame
| Error `Closed -> ()
| Error (`Transport _) -> Fmt.epr "transport error@."
| Error (`Error msg) -> Fmt.epr "decode error: %s@." msg);
(* Send ASM-framed TM. *)
match Scc_eio.Asm.send sink tm_frame with
| Ok () -> ()
| Error (`Error msg) -> Fmt.epr "send error: %s@." msg