0
$\begingroup$

I applied this solution for selecting specific networks interfaces for ros2 to use, but when specified, it still seems to end up using other interfaces.

Setup

I have two devices. Network settings device A are as follows:

bart@bart-P5820T:~$ ifconfig

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 131.180.28.166  netmask 255.255.252.0  broadcast 131.180.31.255
        inet6 fe80::f881:a604:f3b0:b324  prefixlen 64  scopeid 0x20<link>
        ether 74:86:e2:1a:21:1b  txqueuelen 1000  (Ethernet)
        RX packets 31179297  bytes 14758626983 (14.7 GB)
        RX errors 0  dropped 2027  overruns 0  frame 0
        TX packets 3011538  bytes 872962723 (872.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0x92200000-92220000  

enp5s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 28:87:ba:d9:5b:1e  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 5246377  bytes 2907198674 (2.9 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5246377  bytes 2907198674 (2.9 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlx3460f9925488: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.8  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::4444:efb:d9b5:637f  prefixlen 64  scopeid 0x20<link>
        ether 34:60:f9:92:54:88  txqueuelen 1000  (Ethernet)
        RX packets 152104  bytes 64119040 (64.1 MB)
        RX errors 0  dropped 133830  overruns 0  frame 0
        TX packets 171853  bytes 94039339 (94.0 MB)
        TX errors 0  dropped 3 overruns 0  carrier 0  collisions 0

I made ros2networkinterfaces.xml according to this suggestion and specified the (wlan) interface that I intend to use for ros communication. Contents of this file on device A:

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <transport_descriptors>
        <transport_descriptor>
            <transport_id>CustomUDPTransport</transport_id>
            <type>UDPv4</type>
            <interfaceWhiteList>
                <address>wlx3460f9925488</address>
            </interfaceWhiteList>
        </transport_descriptor>
    </transport_descriptors>
    <participant profile_name="CustomUDPTransportParticipant">
        <rtps>
            <userTransports>
                <transport_id>CustomUDPTransport</transport_id>
            </userTransports>
        </rtps>
    </participant>
</profiles>

I made .bashrc export the fastrtps default profile parameter. Fresh terminals yield:

bart@bart-P5820T:~$ echo $FASTRTPS_DEFAULT_PROFILES_FILE
/home/bart/ros2networkwhitelist.xml

On all devices, RMW implementation is set to fastrtps

echo $RMW_IMPLEMENTATION 
rmw_fastrtps_cpp

Device A and B are both ubuntu with ros2 foxy and they can ping eachother.

All devices have their firewall disabled:

sudo ufw status
[sudo] password for user: 
Status: inactive

The problem:

Using "ros2 multicast receive" and "ros2 multicast send" on both devices show that they can see eachother, albeit through the unwanted interface (eno1 ethernet instead of specified wlx3460f9925488 wireless). Behaviour is similar when sending either directions.

ros2 multicast receive 
Waiting for UDP multicast datagram...
Received from 131.180.28.166:46296: 'Hello World!'

I would expect ros to now only use the specified interface (through 192.168.xx.xx) to look for other ros nodes/entities, but its not. Any tips, or suggested steps to further investigate this are welcome.

$\endgroup$
1
  • $\begingroup$ I think in the interfacewhitelist you should use interface instead of address as you are using a name not an IP. If it works will make this an answer. Good luck $\endgroup$
    – martimorta
    Commented Jan 29 at 13:27

1 Answer 1

1
$\begingroup$

The problem seems to consist of multiple parts:

  • I put the interface name under the 'address' field
  • ROS foxy does not seem to support whitelisting per interface
  • ros2 multicast commands seem to not respond to the network configuration as normal nodes or other commands (such as ros2 topic echo) do.

So according to the docs you can specify whitelists per address or interface.

My solution

In ROS2 Foxy my devices were able to specify per IP address (not per interface name) with the following:

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <transport_descriptors>
        <transport_descriptor>
            <transport_id>CustomTcpTransportWhitelistAddress</transport_id>
            <type>TCPv4</type>
            <interfaceWhiteList>
                <address>192.168.1.8</address>
                <address>192.168.1.6</address>
                <address>192.168.1.5</address>
            </interfaceWhiteList>
        </transport_descriptor>
    </transport_descriptors>
    <participant profile_name="CustomTcpTransportWhitelistAddressParticipant">
        <rtps>
            <useBuiltinTransports>false</useBuiltinTransports>
            <userTransports>
                <transport_id>CustomTcpTransportWhitelistAddress</transport_id>
            </userTransports>
        </rtps>
    </participant>
</profiles>

Problems with whitelisting per interface

Whitelisting per interface (instead of per address, as shown above) threw the following error:

ros2 run turtlesim turtle_teleop_key 
2024-01-30 14:18:47.363 [XMLPARSER Error] Invalid element found into 'interfaceWhiteList'. Name: interface -> Function parseXMLCommonTransportData
2024-01-30 14:18:47.363 [XMLPARSER Error] Error parsing transports -> Function parseXMLTransportsProf
2024-01-30 14:18:47.363 [XMLPARSER Error] Error parsing profile's tag transport_descriptors -> Function parseProfiles
2024-01-30 14:18:47.363 [XMLPARSER Error] Transport Node not found. Given ID: CustomTcpTransportWhitelistAddress -> Function getXMLTransports
2024-01-30 14:18:47.363 [XMLPARSER Error] Error parsing participant profile -> Function parseXMLParticipantProf
2024-01-30 14:18:47.363 [XMLPARSER Error] Error parsing profile's tag participant -> Function parseProfiles
2024-01-30 14:18:47.363 [XMLPARSER Error] Error parsing '/home/bart/ros2networkwhitelist.xml' -> Function loadXMLFile

Perhaps this is since im using Foxy with rmw_fastrtps_cpp version 1.3.2, whereas the whitelisting per interface feature has been integrated recently in this PR, part of the v2.13.0 milestone.

ros2 multicast seems ignore the network settings:

ros2 multicast did not throw any errors when I purposely made bracket typos while ros2 run <node> or ros2 topic cli commands did encounter errors while loading the configuration file.

also, ros2 multicast did not seem to respond to the network settings, when nodes and ros2 topic list commands worked properly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.