ros2_node_impl_ws/ is the nested workspace that contains the ROS 2 node implementations used by this repository.
Running colcon build in this directory builds the packages under src/, after which you can source install/ and launch each node with ros2 run. At the moment, all node implementations are collected in src/ros2_perf_multihost_nodes/.
Main roles of each directory:
src/: directory for ROS 2 packagessrc/ros2_perf_multihost_nodes/: package containing Publisher, Subscriber, and Intermediate nodes, plus message definitions and CLI option handlingbuild/,install/,log/: workspace artifacts generated bycolcon buildlogs/: optional destination for runtime logs when--log-diris specified
The Publisher node sends messages to the configured topics at a fixed interval.
- It can handle multiple topics at the same time.
- Payload size and publish period can be configured independently for each topic.
- If an execution time is specified, publishing stops automatically after that duration and the node shuts down.
- If
--log-diris set, publish history and metadata are written to files.
The Subscriber node subscribes to the configured topics and records receive timestamps.
- It can subscribe to multiple topics at the same time.
- If an execution time is specified, the node shuts down automatically after that duration.
- If
--log-diris set, receive history and metadata are written to files.
The Intermediate node combines Publisher and Subscriber behavior.
- Use
--topic-names-subto specify subscribed topics. - Use
--topic-names-pubto specify published topics. - It can act as subscriber-only, publisher-only, or both.
- If the same topic name appears on both the publish and subscribe sides, the node can be used as a relay for received messages.
- If
--log-diris set, transmit and receive history plus metadata are written to files.
You can inspect the launch options for each node with --help.
Example:
ros2 run ros2_perf_multihost_nodes publisher_node --help
ros2 run ros2_perf_multihost_nodes subscriber_node --help
ros2 run ros2_perf_multihost_nodes intermediate_node --helpMain options are shown below.
| Option | Short | Description | Default |
|---|---|---|---|
| --node-name | - | Node name (required) | - |
| --eval-time | - | Evaluation time in seconds | 60 |
| --log-dir | - | Log output directory | unset |
| --qos-history | - | QoS history: KEEP_LAST / KEEP_ALL | KEEP_LAST |
| --qos-depth | - | QoS depth, effective only with KEEP_LAST | 1 |
| --qos-reliability | - | QoS reliability: RELIABLE / BEST_EFFORT | RELIABLE |
These node executables receive one QoS setting per process launch. When a
topology JSON file defines qos as an array for QoS sweep experiments, the
future converter or runner should iterate over that array and pass one QoS case
at a time to these options.
Example topology-side QoS sweep input:
{
"qos": [
{
"history": "KEEP_LAST",
"depth": 1,
"reliability": "RELIABLE"
},
{
"history": "KEEP_LAST",
"depth": 1,
"reliability": "BEST_EFFORT"
},
{
"history": "KEEP_ALL",
"reliability": "RELIABLE"
}
],
"hosts": []
}The runner is expected to translate each element as follows:
| JSON key | Node option | Note |
|---|---|---|
| history | --qos-history | KEEP_LAST or KEEP_ALL |
| depth | --qos-depth | Used only when history is KEEP_LAST |
| reliability | --qos-reliability | RELIABLE or BEST_EFFORT |
For KEEP_ALL cases, depth may be omitted from the JSON because the node
ignores depth when --qos-history KEEP_ALL is used.
| Option | Short | Description | Default |
|---|---|---|---|
| --topic-names | - | Topic names (required, repeatable) | - |
| --size | -s | Payload size in bytes | 64 bytes |
| --period | -p | Publish period in milliseconds | 100 ms |
| Option | Short | Description | Default |
|---|---|---|---|
| --topic-names-pub | - | Published topic names (repeatable) | - |
| --topic-names-sub | - | Subscribed topic names (repeatable) | - |
| --size | -s | Payload size in bytes when topic-names-pub is specified |
64 bytes when topic-names-pub is specified |
| --period | -p | Publish period in milliseconds when topic-names-pub is specified |
100 ms when topic-names-pub is specified |
If --log-dir is omitted, no log files or metadata files are created. Leave it unset when you only want a functional run without log collection.
When --log-dir is set, each node creates <node_name>_log/ under that directory and writes log files plus metadata.txt there.
Basic layout:
<log_dir>/
<node_name>_log/
metadata.txt
<topic_name>_log.txt
For Intermediate nodes, publish-side and subscribe-side logs use separate file names.
<log_dir>/
<node_name>_log/
metadata.txt
<topic_name>_pub_log.txt
<topic_name>_sub_log.txt
metadata.txt stores metadata such as node name, node type, topic names, payload size, and period. Each log file stores the index and timestamp of each sent or received message.
If logging is unnecessary, omit --log-dir. In that case, no log directory or metadata file is created.
Example for ROS 2 Jazzy:
source /opt/ros/jazzy/setup.bash
cd ros2_node_impl_ws
colcon build --packages-select ros2_perf_multihost_nodes
source install/setup.bashPublisher example:
ros2 run ros2_perf_multihost_nodes publisher_node \
--node-name pub1 \
--topic-names topic1 \
--size 64 \
--period 100 \
--qos-history KEEP_LAST \
--qos-depth 1 \
--qos-reliability RELIABLESubscriber example:
ros2 run ros2_perf_multihost_nodes subscriber_node \
--node-name sub1 \
--topic-names topic1 \
--qos-history KEEP_LAST \
--qos-depth 1 \
--qos-reliability RELIABLEIntermediate example:
ros2 run ros2_perf_multihost_nodes intermediate_node \
--node-name relay1 \
--topic-names-pub topic_out \
--topic-names-sub topic_in \
--size 64 \
--period 100 \
--qos-history KEEP_LAST \
--qos-depth 1 \
--qos-reliability RELIABLEAdd --log-dir when you want to save logs.
ros2 run ros2_perf_multihost_nodes publisher_node \
--node-name pub1 \
--topic-names topic1 \
--size 64 \
--period 100 \
--log-dir logsTo start all three nodes (Publisher, Subscriber, and Intermediate) at once with a single command, use the launch file below. The arguments for each node are fixed to match the ros2 run examples above, without --log-dir:
ros2 launch ros2_perf_multihost_nodes all_nodes_readme.launch.pyTo start a single node with configurable arguments, use the dedicated launch file for each node type:
ros2 launch ros2_perf_multihost_nodes publisher.launch.py \
node_name:=pub1 \
topic_names:=topic1 \
size:=64 \
period:=100
ros2 launch ros2_perf_multihost_nodes subscriber.launch.py \
node_name:=sub1 \
topic_names:=topic1
ros2 launch ros2_perf_multihost_nodes intermediate.launch.py \
node_name:=relay1 \
topic_names_pub:=topic_out \
topic_names_sub:=topic_in \
size:=64 \
period:=100