Mission Operations Message Abstraction Layer (CCSDS 521.0-B-1)
README.md

mal #

The Mission Operations Message Abstraction Layer (MAL) of CCSDS 521.0-B-2 in OCaml.

Overview #

A mission control system talks to many services, on the ground and on board the spacecraft. Without a shared layer, each service defines its own messages and its own transport. The CCSDS Mission Operations framework instead specifies every service in terms of MAL, a standard set of interaction patterns and data types that sits between the consumer of a service and its provider. The same service can then run over different transports.

MAL has six interaction patterns: Send, Submit, Request, Invoke, Progress and Pub-Sub. Each one fixes the sequence of typed messages that the consumer and the provider exchange, and this package supports all six.

The package implements the abstract layer only: the message header, the interaction patterns and their stages, the error codes, a service registry and dispatcher, and the signature of a transport. It has neither the standard's binary encoding nor any transport binding such as MAL/TCP/IP. Message bodies are opaque strings, and the only transport is an in-memory one meant for tests.

Installation #

Install with opam:

$ opam install mal

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 mal

Usage #

let run () =
  (* Create an in-memory transport for testing *)
  let provider = Mal.Mem_transport.v "mal:provider" in
  let consumer = Mal.Mem_transport.v "mal:consumer" in
  (* Build a Request message *)
  let tid = Mal.next_transaction_id () in
  let msg =
    Mal.header
      ~uri_from:"mal:consumer" ~uri_to:"mal:provider"
      ~interaction_type:Mal.Request ~stage:Mal.Request_stage
      ~transaction_id:tid ~area:1 ~service:1 ~operation:1
      ~body:"ping" ()
  in
  (* Send and dispatch *)
  let _ = Mal.Mem_transport.send consumer msg in
  (match Mal.Mem_transport.recv provider with
   | Ok received -> Printf.printf "Got: %s\n" received.Mal.body
   | Error code -> Fmt.pr "Error: %a\n" Mal.pp_error_code code);
  Mal.Mem_transport.close provider;
  Mal.Mem_transport.close consumer

API Overview #

  • The interaction patterns are Send, Submit, Request, Invoke, Progress and Pub_sub.
  • The data types are blob, identifier, uri, time, fine_time and duration.
  • header builds a message header with its routing metadata: URIs, QoS, session and transaction identifier.
  • register_area, register_handler and dispatch form the service registry.
  • Transport is the signature of a transport binding (send, recv, close), and Mem_transport the in-memory one.
  • next_transaction_id and validate_stage are helpers.

References #

Licence #

ISC License. See LICENSE.md for details.