- OCaml 55%
- C 44%
- Shell 1%
fsr #
CCSDS Frame Security Report (FSR) for OCaml.
A spacecraft protected by the CCSDS Space Data Link Security protocol
(SDLS) tells the ground whether it accepted the last frame
through a 32-bit status word, the Frame Security Report, sent back in
the Operational Control Field. The Operational Control Field is an optional
4-octet field at the end of a TM, AOS or USLP transfer frame that carries a
report from the spacecraft to the ground. Its first bit, the Control Word Type,
is 0 for a Communications Link Control Word (CLCW), the report that acknowledges
telecommand frames, and 1 for other reports, of which the FSR is one. The word
carries a persistent alarm, three flags for the last frame (bad sequence number,
bad MAC, bad security association), the frame's Security Parameter Index and the
low 8 bits of its anti-replay sequence number. The Security Parameter Index
(SPI) is the 16-bit number in a frame's security header that names the security
association, the keys and algorithms, protecting it; the anti-replay sequence
number is a counter the sender increments for every frame, so the receiver can
refuse a frame it has already seen. fsr encodes and decodes that word as
specified in CCSDS 355.1-B-1 section 4.2, and keeps the alarm's
persistence rule in one update function: Fsr.update sets the three flags
from the frame it records, overwriting the previous frame's, and sets the alarm
when any of them is set; the alarm then stays set across later good frames until
Fsr.reset_alarm clears it.
Installation #
Install with opam:
$ opam install fsr
If opam cannot find the package, it may not yet be released in the
public opam-repository. Add the overlay repository, then install
it:
$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install fsr
Usage #
Encode a clean report, then round-trip through the 32-bit wire format:
# let fsr =
Fsr.v ~alarm:false ~bad_sn:false ~bad_mac:false ~bad_sa:false
~spi:0x0042 ~arsn_lsb:0x7b in
let word = Fsr.encode fsr in
Result.map (fun r -> (r.Fsr.spi, r.Fsr.arsn_lsb)) (Fsr.decode word)
- : (int * int, [ `Invalid_version of int | `Not_fsr ]) result = Ok (66, 123)
update records the flags of one frame and raises the persistent
alarm if any of them is set:
# let fsr =
Fsr.initial
|> Fsr.update ~bad_mac:true ~spi:0x0042 ~arsn_lsb:0x01 in
(Fsr.has_error fsr, fsr.alarm)
- : bool * bool = (true, true)
decode rejects words that are not an FSR. A Control Word Type of 0
marks a CLCW:
# Fsr.decode 0l
- : (Fsr.t, [ `Invalid_version of int | `Not_fsr ]) result = Error `Not_fsr
License #
ISC. See LICENSE.md.