Main command: mads
The standard installers provide a main command:
madsInline help is available with
mads --help:Options
-iand-pare useful to check the installation
A framework for distributed agents
University of Trento
2025-Jul-07
stands for Multi-Agent Distributed System
MADS aims at being as transparent as possible w.r.t. the underlying network.
The same MADS network could run
And everything in between…
To maximize flexibility and scalability, MADS networks are broker-based
MADS uses ZeroMQ as the underlying communication layer:
Agents are the building blocks of a MADS network. They can be:
Agents can be implemented in any programming language that supports ZeroMQ, but MADS provides C++ API that abstracts ZeroMQ intricacies.

Using MADS API, agents can be implemented as:

Tip
Easy to remember: https://git.new/mads!
How do we use it in practice?
madsThe standard installers provide a main command: mads
Inline help is available with mads --help:
Options -i and -p are useful to check the installation
mads sub commands can be obtained as:> mads
Available mads subcommands:
filter (wraps mads-filter)
worker (wraps mads-worker)
command (wraps mads-command)
image (wraps mads-image)
feedback (wraps mads-feedback)
logging (wraps mads-logging)
plugin (wraps mads-plugin)
source (wraps mads-source)
bridge (wraps mads-bridge)
sink (wraps mads-sink)
dealer (wraps mads-dealer)
python (wraps mads-python)
logger (wraps mads-logger)
broker (wraps mads-broker)
ini (internal)
service (internal)mads source or mads-sourcemads-source onlymads executableman mads-source)broker> mads broker
Reading settings from /Users/p4010/usr/local/etc/mads.ini [broker]
Binding broker frontend (XSUB) at tcp://*:9090
Binding broker backend (XPUB) at tcp://*:9091
Binding broker shared settings (REP) at tcp://*:9092
Timecode FPS: 25
Settings are provided via tcp://127.0.0.1:9092
CTRL-C to immediate exit
Type P to pause, R to resume, I for information, Q to clean quit, X to restart and reload settingstcp://127.0.0.1:9092) as a command line argumentpublishtimecode: the time when the data was produced as a multiple of a fixed timestep (e.g. 40ms). Measured in seconds from last midnight (local time)timestamp: an ISO 8601 timestamp of the datahostname: the hostname of the machine that produced the datalogger for logging messageslogger is designed to store data into a MongoDB databasepublish)timecode (a fixed timestep in ms), timestamp (and ISO 8601 time), and hostnamehdf5_writer.plugin is a MADS sink that stores data in an HDF5 file"key1.subkey2.subsubkey3" corresponds to JSON fields data["key1"]["subkey2"]["subsubkey3"]timestamp, timecode, and hostname are automatically recorded into separate datasetsNote
The plugin is available on https://github.com/MADS-Net/hdf5_plugin
rerunner.plugin is a MADS sink that streams data to Rerun.iotopic.message.field.value
Automate it!
On Linux machine only, MADS provides a service file generator that can be used to run MADS agents as system services, automatically active on boot
Procedure:
mads source -s tcp://mads-broker.local:9092 -n my_datasourcemads service my_datasource source -s tcp://mads-broker.local:9092 -n my_datasource; this prints a possible systemctl file for a service called my_datasource.servicesudo: this installs the service on the system dirsudo systemctl enable my_datasource.serviceOr, please, make it easy!
Solution: MADS plugins
mads source: provides information to the network (e.g. by reading sensors)mads filter: processes data received from the network and sends it to other agentsmads sink: consumes data from the network and performs actions based on it (e.g. by writing to a file)mads plugin command to create a plugin templatemads pluginmads plugin command creates a plugin template in the current directoryCMakeLists.txt file and a src directory with the plugin source codeCMakeLists.txtclass My_sourcePlugin : public Source<json> {
public:
// Implement the actual functionality here
return_type get_output(json &out,
std::vector<unsigned char> *blob = nullptr) override {
// Your logic to fill 'out' with data
// optionally use 'blob' for binary content
}
// Run only once upon start
void set_params(void const *params) override {
// Optional: handle parameters passed to the plugin
// This can be used to configure the plugin at runtime
}
private:
// custom fields here
};
// Macro that does the magic of allowing dlopen to work
INSTALL_SOURCE_DRIVER(My_sourcePlugin, json)find_package calls in CMakeLists.txtmain() function: beside each plugin, a one-shot executable is provided (and compiled) that can be used to test the plugin logic without the need of a MADS networkPlugins can be loaded Over-The-Air (OTA) by the mads source, mads filter, and mads sink commands
If the INI file contains an entry like this:
then that file (on the broker filesystem!) is sent to my_source agents when they connect to the broker
This allows to have all plugins in a single location, and to update them without having to manually copy them to each agent machine
MADS can be also use for dispatching parallel computations on HPC clusters
Suppose that you want to explore a large domain of parameters for a simulation to perform sensitivity analysis or parameters optimization:
In MADS, there are two special agents for this purpose: dealer and worker
dealer: receives the computational payloads (simulation input) from a suitable source agent, and dispatches them to the workersworker: receives the computational payloads and uses a custom plugin to process them (of type filter), then sends the results back to the brokerIdeally, the worker plugin is launched in \(n\) instances on a Kubernetes cluster; each instance loads the computational plugin OTA from the broker
Starting from v2.0.0, MADS supports authentication and encryption over the network
mads command can create the public/private keypair for a device
MADS — https://mads-net.github.io