MicroRTI
MicroRTI is an implementation of HLA 4, the High Level Architecture of IEEE Std 1516-2025 (Framework and
Rules), IEEE Std 1516.1-2025 (Federate Interface Specification) and IEEE Std 1516.2-2025 (Object Model
Template), in Rust: a Run-Time Infrastructure (the server microrti) and a federate client library. The
two talk to each other over the standard HLA Federate Protocol (clause 12.13 of IEEE 1516.1), on TCP, TLS,
WebSocket and secure WebSocket, so each of them is meant to work with the other side of any HLA 4 product
that speaks the protocol.
Crates
| Crate | What it is |
|---|---|
microrti-proto | the protobuf messages of the Federate Protocol (Annex D), generated with prost |
microrti-core | exceptions, logical time, constants shared by everything |
microrti-encoding | HLA data encoding: basic types, strings, arrays, records, variant records, and with the feature fom a FOM-driven codec |
microrti-fom | FOM module parser (OMT DIF XML), module merging, the merged FDD |
microrti-fedpro | the Federate Protocol: framing, sessions with resume, the four transports |
microrti-engine | the RTI itself: a synchronous, deterministic state machine without I/O |
microrti | the binary microrti: the engine behind Federate Protocol listeners |
microrti-client | the federate side: RtiAmbassador and FederateAmbassador in Rust; the feature embedded adds an RTI inside the federate’s process |
microrti-cli | the operator tool microrti-cli (cargo install microrti-cli) and the library it is made of, for any RTI that serves the Federate Protocol |
microrti-examples | example federates (chat, restaurant) and the interoperability scenario |
docs/ARCHITECTURE.md describes how they fit together, docs/CONTRIBUTING.md the rules of the
repository.
Quick start
Rust 1.88 or later is needed. Four terminals:
# 1. the RTI, on the default Federate Protocol port
cargo run -p microrti --bin microrti -- --listen tcp://127.0.0.1:15164
# 2. and 3. two chat federates: type a line in one, read it in the other; Ctrl-D or Ctrl-C leaves
cargo run -p microrti-examples --bin chat -- --name alice
cargo run -p microrti-examples --bin chat -- --name bob
# 4. the monitor: who joins and leaves, and every line said, decoded with the FOM the RTI gives out
cargo run -p microrti-cli -- monitor ChatThe chat federates create the federation execution with the FOM module
crates/microrti-examples/fom/Chat.xml. The tools read the FOM back from the RTI (the MOM attribute
HLAcurrentFDD), or from the files given with --fom.
More to try, each with --help:
cargo run -p microrti-examples --bin restaurant -- demo # self-checking run of the Restaurant sample FOM
cargo run -p microrti-cli -- list # federation executions of the RTI
cargo run -p microrti-cli -- members Chat
cargo run -p microrti-cli -- send Chat Communication \
Sender=operator 'Message=lunch is ready'
cargo run -p microrti-cli -- ping && echo the RTI is upThe RTI address of every tool is --rti: tcp://host[:port] (default tcp://localhost:15164),
tls://, ws://host[:port][/path] or wss://. --tls-trust-anchors FILE validates the certificate of
the RTI, --password sends HLAplainTextPassword credentials (the tools also read MICRORTI_PASSWORD).
An RTI that does not require authorization refuses any password (IEEE 1516.1-2025, 12.5): leave both out
for such an RTI.
Configuring the RTI
microrti reads its RTI initialization data (RID) from a TOML file; command line options take precedence.
microrti check-config FILE validates a file and prints the effective settings, and
crates/microrti/microrti.example.toml documents every key.
# microrti.toml: start with `microrti --config microrti.toml`
log_level = "info"
# Federate Protocol timeouts (Table 31), in seconds: when a silent session becomes inactive, and when an
# inactive session is purged and its federate is lost for the federation execution. An idle federate
# sends a heartbeat every FED_INT_HEART (60 s by default, Table 32), so rti_timeout_heart must be well
# above that: at 60, idle sessions would keep turning inactive and resuming.
rti_timeout_heart = 180
rti_timeout_purge = 300
# Federation saves (IEEE 1516.1-2025, 4.1.2): one file per save in this directory, read back by Request
# Federation Restore, also after the RTI was stopped and started again. Without this key, saves are
# kept in memory and are lost when the RTI stops.
save_directory = "/var/lib/microrti/saves"
# The certificate of the tls and wss listeners (or `tls_self_signed = true` for encryption only).
tls_certificate_chain = "certs/rti-chain.pem"
tls_private_key = "certs/rti-key.pem"
[[listener]]
transport = "tcp"
address = "0.0.0.0:15164"
[[listener]]
transport = "tls"
address = "0.0.0.0:15165"
[[listener]]
transport = "wss"
address = "0.0.0.0:8443"
[authorization]
enabled = true
password_env = "MICRORTI_PASSWORD"A federate in thirty lines
crates/microrti-examples/examples/minimal_federate.rs joins the chat room of the quick start, says
hello and prints what it hears for ten seconds
(cargo run -p microrti-examples --example minimal_federate):
//! A whole federate in about thirty lines of code: joins the chat room, says hello and prints what it hears for a while.
//! Usage: `cargo run -p microrti-examples --example minimal_federate [RTI address] [seconds]`
use std::time::{Duration, Instant};
use microrti_client::{
Callback, CallbackFn, CallbackModel, FomModule, ParameterHandleValueMap, ResignAction,
};
use microrti_client::{
RtiAmbassador, RtiConfiguration, RtiResult, decode_hla_unicode_string, encode_hla_unicode_string,
};
fn main() -> RtiResult<()> {
let address = std::env::args().nth(1).unwrap_or_else(|| "tcp://localhost:15164".to_owned());
let seconds = std::env::args().nth(2).and_then(|text| text.parse().ok()).unwrap_or(10.0);
let (queue, callbacks) = std::sync::mpsc::channel();
let federate_ambassador = CallbackFn::new(move |callback: Callback| queue.send(callback).or(Ok(())));
let rti = RtiAmbassador::new();
let configuration = RtiConfiguration::new().with_rti_address(address);
rti.connect_with_configuration(federate_ambassador, CallbackModel::Evoked, &configuration)?;
let _ =
rti.create_federation_execution("Chat", &FomModule::content("Chat.xml", microrti_examples::CHAT_FOM));
rti.join_federation_execution("minimal", "Chat")?;
let communication = rti.get_interaction_class_handle("Communication")?;
let sender = rti.get_parameter_handle(&communication, "Sender")?;
let message = rti.get_parameter_handle(&communication, "Message")?;
rti.publish_interaction_class(&communication)?;
rti.subscribe_interaction_class(&communication)?;
let hello = [(sender.clone(), "minimal"), (message.clone(), "hello from thirty lines of Rust")];
let hello: ParameterHandleValueMap =
hello.into_iter().map(|(k, v)| (k, encode_hla_unicode_string(v))).collect();
rti.send_interaction(&communication, &hello, b"")?;
let end = Instant::now() + Duration::from_secs_f64(seconds);
while Instant::now() < end {
rti.evoke_callback(Duration::from_millis(100))?;
for callback in callbacks.try_iter() {
if let Callback::ReceiveInteraction { parameter_values: said, .. } = callback {
let text = |handle| said.get(handle).and_then(|value| decode_hla_unicode_string(value).ok());
println!("<{}> {}", text(&sender).unwrap_or_default(), text(&message).unwrap_or_default());
}
}
}
rti.resign_federation_execution(ResignAction::NoAction)?;
let _ = rti.destroy_federation_execution("Chat"); // refused while others are in the room: fine
rti.disconnect()
}Every service a federate invokes is one blocking method of RtiAmbassador, named after its Federate
Protocol message; callbacks arrive through the FederateAmbassador trait or, as here, as values of the
Callback enum. chat (crates/microrti-examples/src/bin/chat.rs) is the same federate grown up:
object instances for the participants, both callback models, a clean exit on Ctrl-C. Beyond the services
of the standard, the library can end a connection at any moment (RtiAmbassador::close), bound the wait
for the RTI (RtiAmbassador::with_call_timeout) and tell how many callbacks an evocation delivered
(evoke_callback_counted); the documentation of the crate lists these extensions.
State of the implementation
The RTI implements every service of clauses 4 to 10 of IEEE 1516.1-2025 (federation, declaration, object,
ownership, time and data distribution management, support services) and the Management Object Model of
clause 11, over all four transports with session resume. It reads, checks and merges FOM modules and
encodes data as IEEE 1516.2-2025 prescribes (the OMT DIF, the MIM, the merging rules of clause 7 and
Annex C, the data representations of 4.14). A federate gives a FOM module by content or by a file:,
http: or https: URL that the RTI reads itself, by default wherever it leads: restrict it when the RTI
is reachable from outside a trusted network (crates/microrti/README.md).
The rules of IEEE 1516-2025 that bear on an RTI were checked
against the code; the others bind federations and federates. Federation save and restore covers the whole
state, MOM included. docs/COMPLIANCE.md lists every service with its status and
the tests that name it; it is a text search over the tree, not a certificate.
What has been checked, and how:
- The test suite (about 1 800 tests) drives the engine through its public API and the server over the four transports. Each clause was audited against the text of the standard, and the audit tests were then checked by breaking the engine on purpose.
- A third-party open-source client of the Federate Protocol, written in Java, passes the scripted
scenarios of
interop/pitch-fedproon TCP, TLS, WebSocket and secure WebSocket, with both callback models. Besides the base scenario (about 25 services, one object and one interaction class), its optional groups cover time management, synchronization points, save and restore, ownership, data distribution management, much of the MOM, and more of declaration and object management. Over TCP, its sessions resumed after the connections of both federates were reset in the middle of a run. - The C++ variant of that client passes the scenarios of
interop/pitch-fedpro-cppover TCP, the only transport it implements: time management, synchronization points, ownership, part of the MOM, and a chat between its federates and those of this repository. - The Rust client of this repository passes the 24 steps of
interop/other-rti(connect to destroy, with ownership, time management, a synchronization point, save and restore and data distribution management) against MicroRTI, and the same scenario ran successfully against one other RTI that serves the Federate Protocol.
What is not established:
- No formal conformance test has been run. MicroRTI is not certified: the “HLA Conforming” label needs publicly available results certified by a recognized authority (IEEE 1516.1 clause 13).
- The third-party client scenarios use two federates at most and leave out, among others, a save at a
logical time, retraction, Next Message Request, Flush Queue Request, update rate reduction and
authorization (the list is in
interop/pitch-fedpro/README.md). Against the other RTI, session resume, TLS, WebSocket, more than two federates and authorization were not tried. - The points of the MOM that the standard leaves open, and the choices made, are listed in
crates/microrti-engine/README.md(section “MOM: what the standard leaves open, and what is not verified”). - Logical time: the two standard time types of IEEE 1516.1 12.4,
HLAinteger64TimeandHLAfloat64Time. A federation cannot supply a logical time implementation of its own, which 4.1.5 allows. - Connect completes the connection whatever additional settings the RTI side cannot parse (IEEE
1516.1-2025, 4.2), with one deliberate exception on the federate side: over
tls://andwss://, when no trust anchors are set in code, aTLS_*line that cannot be used (an unknown key such asTLS_TRUST_ANCHOR, an empty value) fails Connect withConnectionFailed, since it may be the trust anchors written wrong and connecting would silently drop the validation of the RTI certificate (12.13.5.1). - The 14 read services of the switches of clause 10 answer during a save, as their clauses say (10.34.3
and 10.34.5, and the same subclauses of the other thirteen), whereas the official Java and C++ APIs
declare
SaveInProgressfor them. - Federation saves outlive the RTI only when its RID names a
save_directory; by default they are kept in memory, as an RTI embedded in a federate (microrti-client, featureembedded) keeps them. A file holds the snapshot format of the version that wrote it: a save written by a version with another snapshot format is refused by Request Federation Restore, there is no migration. A file ends with a checksum: one damaged after it was written is refused as well, and the log ofmicrortisays why. - On macOS,
micrortirefuses to listen on a port that another program already serves on an overlapping address (127.0.0.1:15164 while 0.0.0.0:15164 is taken, or the reverse), but it cannot tell when a wildcard address is asked for while another program listens on the same port of a specific, non-loopback address: both then listen and each receives part of the connections. Linux refuses all these cases by itself. - The engine runs behind one lock; the 20-federate load test (
crates/microrti-examples/tests/load.rs) reaches about 6 500 interactions sent per second in a release build on a laptop.
Licence
MicroRTI is licensed under the Apache License, Version 2.0: see LICENSE.
The protobuf files in proto/ and the MIM, schemas and sample FOM modules in fom/ are IEEE material,
reprinted with permission from IEEE 1516.1-2025 and IEEE 1516.2-2025 under the royalty-free licence stated
in each file; the Rust API derives from the IEEE 1516.1-2025 APIs. See NOTICE.