Ratman client protocol

External applications can connect to the Ratman routing daemon via a Tcp socket connection (by default localhost:5852, but this can be changed via the user configuration). This page outlines the protocol in use for this connection.

If libratman SDK bindings exist for your language (currently only Rust) we highly recommend you use those instead of implementing the protocol from scratch.

Microframe

Messages in the Ratman client protocol use a very simple framing mechanism specific to Irdest called Microframe. Every Microframe message is split into a header and a body.

  • modes: u16: encode the message command and payload types
  • auth: Option<ClientAuth>: provide a previously registered auth token; field may be blank for initial connections
  • payload_size: u32: encode the length of the main payload, up to the configured server maximum

The mode field is split into two parts: the namespace and the method. A namespace specifies the internal API in use for a given command. Not all namespace-command combinations are valid. In libratman the mode is thus constructed as follows:

#![allow(unused)]
fn main() {
pub const fn make(ns: u8, op: u8) -> u16 {
    ((ns as u16) << 8) as u16 | op as u16
}
}

The following namespaces are available:

NameByte-offsetDescription
Intrinsic0x0For internal use only
Addr0x1Local addresses and keys
Contact0x2Address-specific contact book for external addresses and keys
Link0x3Hardware interfaces to connect to other Ratman instances
Peer0x4Other network participants without any relation metadata
Recv0x5Configure Ratman to receive a file
Send0x6Sending data to other peers and the network
Stream0x7Incoming streams namespace, separate from explicity receiving

The following methods are availble:

NameByte-offsetDescription
Create0x1Create a new resource locally
Destroy0x2Destroy an existing local resource permanently
Sub0x3Subscribe to a particular resource (currently only streams are supported)
Resub0x4Restore a previously held subscription after a router restart
Unsub0x5Unsubscribe from a previously subscribed resource
Up0x10Mark an existing resource as "up", which will start announcing it to the network. This could be an address or a pre-cached stream (file sharing)
Down0x11Mark an existing resource as "down", which will stop announcing it to the network, but not delete its local state
Add0x20Insert a new record into any data storage endpoint. This operation is indempotent (applying an operation for the second time is a no-op)
Delete0x21Delete a record from any data storage endpoint. This does not by default delete any associated data on disk (but can be opted into)
Modify0x22Modify an existing data storage record in place
List0x30List available records for a given namespace and storage endpoint
Query0x31Run a query for specific data in the storage engine
One0x32"One-to-one" mode when sending or receiving data, which locks a stream to a single destination address
Many0x33"One-to-many" mode when sending or receiving data, which allows message streams from and to multiple destination addresses
Status0x34Get status updates on various components. Currently only "Peer" and "Intrinsic" are supported

Since the microframe header can have various sizes it is length-prepended with a 4-byte integer. A full API protocol transmission thus looks as follows:

[ 4 byte header size ]
[ 2 byte mode indicator ]
[ 32 bytes auth token ][ 1 byte placeholder (0) ]
[ 4 byte payload length ]
[ N byte payload ]

Command payload encoding

The available commands are described in libratman/src/api/types. More documentation to be added. Please feel free to ask if you run into any issues or have general questions.