roscon2024_workshop

Exercise 5 - Discovery via UDP multicast

Even if not enabled by default in rmw_zenoh, Zenoh can be configured for discovery over UDP multicast in several aspects:

[!WARNING] If your host runs MacOS, your Docker probably doesn’t router the multicast traffic, even if the container is using the --net host option. Therefore you won’t be able to participate to this exercise.

Routers discovery

Each attendee will run 1 container with the Zenoh router and a publisher and a subscriber on the same topic. The routers will be configured to discover each other over UDP multicast and to automatically connect to each other.

multicast-discovery-routers

Configuration

Edit your zenoh_confs/ROUTER_CONFIG.json5 again to:

Run

Now you can run the following commands in your container:

Bonus

Try running rmw_zenoh Nodes without any router in 2 different configurations:

  1. the Nodes shall only discover the other Nodes running on the same host
  2. the Nodes shall discover all Nodes running in the LAN
Solution 1

multicast-discovery-nodes-localhost/>

* Copy the file `zenoh_confs/DEFAULT_RMW_ZENOH_SESSION_CONFIG.json5` as `zenoh_confs/SESSION_CONFIG.json5` * Edit `zenoh_confs/SESSION_CONFIG.json5` and just set `scouting.multicast.enabled` to `true` as such: ```json5 multicast: { /// Whether multicast scouting is enabled or not enabled: true, /// ... } ``` * Then run: * `ZENOH_SESSION_CONFIG_URI=/ros_ws/zenoh_confs/SESSION_CONFIG.json5 ros2 topic pub /chatter std_msgs/msg/String "data: Hello from "` * `ZENOH_SESSION_CONFIG_URI=/ros_ws/zenoh_confs/SESSION_CONFIG.json5 ros2 topic echo /chatter` </details>
Solution 2

multicast-discovery-nodes-multihosts/>

With previous configuration the Nodes on different hosts didn't discover each other because they're configure to listen for incoming connections only on the localhost interface. To enable inter-hosts discovery and connection, we need to change this. * Edit the same `zenoh_confs/SESSION_CONFIG.json5` and set the `listen.endpoints` configuration as such: ```json5 listen: { endpoints: [ "tcp/[::]:0" ], }, ``` Here `[::]` means any IPv6 or IPv4 interface, and `0` means the OS will choose an available port number. * Then run: * `ZENOH_SESSION_CONFIG_URI=/ros_ws/zenoh_confs/SESSION_CONFIG.json5 ros2 topic pub /chatter std_msgs/msg/String "data: Hello from "` * `ZENOH_SESSION_CONFIG_URI=/ros_ws/zenoh_confs/SESSION_CONFIG.json5 ros2 topic echo /chatter` </details> --- [Next exercise ➡️](/roscon2024_workshop/exercises/ex-6.html)