rmw_fastrtps icon indicating copy to clipboard operation
rmw_fastrtps copied to clipboard

Specifying interfaceWhitelist does not work

Open rty813 opened this issue 11 months ago • 7 comments

ROS2 Version: Humble

I have two hosts, each with two interconnected network interfaces: eth0 and edge0. I want them to communicate via the eth0 interface rather than the edge0. However, after specifying the interfaceWhiteList, traffic still flows through both network interfaces simultaneously.


NICs information:

Host1(Pub) Host2(Sub)
eth0 192.168.3.11/24 192.168.3.112/24
edge0 10.1.233.165/16 10.1.123.79/16

Publisher's fastrtps xml:

<?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>192.168.3.11</address>
                <address>127.0.0.1</address>
            </interfaceWhiteList>
        </transport_descriptor>
    </transport_descriptors>

    <participant profile_name="CustomUDPTransportParticipant">
        <rtps>
            <useBuiltinTransports>false</useBuiltinTransports>
            <userTransports>
                <transport_id>CustomUDPTransport</transport_id>
            </userTransports>
        </rtps>
    </participant>
</profiles>

tcpdump -i edge0 udp:

......
15:28:26.397300 IP 10.1.233.165.46534 > 10.1.123.79.7410: UDP, length 68
15:28:26.400399 IP 10.1.233.165.46534 > 10.1.123.79.7410: UDP, length 68
15:28:26.403855 IP 10.1.233.165.46534 > 10.1.123.79.7410: UDP, length 68
15:28:26.408088 IP 10.1.233.165.46534 > 10.1.123.79.7410: UDP, bad length 20652 > 1256
15:28:26.411637 IP 10.1.233.165 > 10.1.123.79: udp
15:28:36.577914 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:36.778463 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:36.979111 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:37.178606 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:37.379147 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:37.579511 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:37.780080 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:37.980124 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:38.022211 IP 10.1.233.165.46534 > 10.1.123.79.7410: UDP, length 392
15:28:38.028020 IP 10.1.233.165.34813 > 239.255.0.1.7400: UDP, length 392
15:28:38.180172 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
15:28:38.380327 IP 10.1.233.165.46534 > 10.1.123.79.7411: UDP, length 360
......

tcpdump -i eth0 udp:

......
15:32:59.227396 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:32:59.427499 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:32:59.627599 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:32:59.828124 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:33:00.028431 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:33:00.228654 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
15:33:00.429054 IP 192.168.3.11.46534 > 192.168.3.112.7411: UDP, length 360
......

rty813 avatar Jan 20 '25 07:01 rty813

@rty813 In order for the participant configuration to be taken into account, the profile should have is_default_profile="true" attribute.

<participant profile_name="CustomUDPTransportParticipant" is_default_profile="true">

MiguelCompany avatar Jan 20 '25 09:01 MiguelCompany

@MiguelCompany Adding is_default_profile did indeed fix the issue. However, I'm encountering a new problem now. If I specify initialPeerList, the communication between both sides fails, but if I remove it, the communication works fine. What could be the reason for this?

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
    <participant profile_name="CustomUDPTransportParticipant" is_default_profile="true">
        <rtps>
            <builtin>
                <metatrafficUnicastLocatorList>
                    <locator/>
                </metatrafficUnicastLocatorList>
                <initialPeersList>
                    <locator>
                        <udpv4>
                            <address>192.168.3.11</address>
                            <address>192.168.3.112</address>
                        </udpv4>
                    </locator>
                </initialPeersList>
            </builtin>
        </rtps>
    </participant>
</profiles>

rty813 avatar Jan 21 '25 02:01 rty813

There's another issue. When both UDP and SHM are enabled on the same host, how does Fast RTPS choose between them? I see that both are transmitting data.

rty813 avatar Jan 21 '25 03:01 rty813

@rty813 In order for the participant configuration to be taken into account, the profile should have is_default_profile="true" attribute.

<participant profile_name="CustomUDPTransportParticipant" is_default_profile="true">

I tested it, and now the XML configuration seems to be effective, but there is still some traffic going through the edge0 network interface. If I keep only 127.0.0.1 in the whitelist, I can ensure that no messages are sent through edge0. However, if I add the IP of eth0, the messages are forwarded through both eth0 and edge0 simultaneously.

current xml:

<?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>192.168.3.112</address>
                <address>127.0.0.1</address>
            </interfaceWhiteList>
        </transport_descriptor>
    </transport_descriptors>

    <participant profile_name="CustomUDPTransportParticipant" is_default_profile="true">
        <rtps>
            <useBuiltinTransports>false</useBuiltinTransports>
            <userTransports>
                <transport_id>CustomUDPTransport</transport_id>
            </userTransports>
        </rtps>
    </participant>
</profiles>

some traffic log:

15:53:16.774441 IP 192.168.3.112.48183 > 192.168.3.11.7410: UDP, length 252
15:53:16.846314 IP 192.168.3.112.48183 > 10.1.233.165.7410: UDP, length 252
15:53:19.495888 IP 192.168.3.11.54471 > 192.168.3.112.7410: UDP, length 392
15:53:19.774495 IP 192.168.3.112.48183 > 192.168.3.11.7410: UDP, length 252
15:53:19.838977 IP 192.168.3.112.48183 > 10.1.233.165.7410: UDP, length 252
15:53:22.496013 IP 192.168.3.11.54471 > 192.168.3.112.7410: UDP, length 392
15:53:22.774601 IP 192.168.3.112.48183 > 192.168.3.11.7410: UDP, length 252
15:53:22.848379 IP 192.168.3.112.48183 > 10.1.233.165.7410: UDP, length 252

rty813 avatar Jan 21 '25 07:01 rty813

If you want to use the same XML in both hosts, put all the addresses you want to whitelist, i.e.:

            <interfaceWhiteList>
                <address>192.168.3.11</address>
                <address>192.168.3.112</address>
                <address>127.0.0.1</address>
            </interfaceWhiteList>

MiguelCompany avatar Jan 21 '25 09:01 MiguelCompany

In ROS 2 Jazzy, you can also whitelist interface names:

            <interfaceWhiteList>
                <interface>eth0</interface>
                <interface>lo</interface>
            </interfaceWhiteList>

MiguelCompany avatar Jan 21 '25 09:01 MiguelCompany

If you want to use the same XML in both hosts, put all the addresses you want to whitelist, i.e.:

            <interfaceWhiteList>
                <address>192.168.3.11</address>
                <address>192.168.3.112</address>
                <address>127.0.0.1</address>
            </interfaceWhiteList>

I didn't use the same XML for both hosts, although I did try adding both IPs, but there is still traffic being transmitted through the edge0 network card.

rty813 avatar Jan 21 '25 09:01 rty813

@rty813 In order for the participant configuration to be taken into account, the profile should have is_default_profile="true" attribute.

<participant profile_name="CustomUDPTransportParticipant" is_default_profile="true">

Hi, I am also working on specifc the DDS to use the ethernet interface only. The reason is that my ubuntu 22 system have a wifi chip MT7929 which is currently not being supported by the kernel. I would like to ensure all the ROS2 communication is going via the ethernet not the WiFi interface. From the document https://fast-dds.docs.eprosima.com/en/latest/fastdds/transport/interfaces.html#ifaces-config, there is no line is_default_profile="true". Should we still put this in the line?

TZECHIN6 avatar May 24 '25 11:05 TZECHIN6

Should we still put this in the line?

Yes. You should use the is_default_profile="true" to configure whitelist in ROS 2.

It is mentioned in Fast DDS documentation specific for ROS 2: https://fast-dds.docs.eprosima.com/en/latest/fastdds/ros2/ros2_configure.html#creating-ros-contexts-and-nodes

cferreiragonz avatar May 26 '25 06:05 cferreiragonz

@cferreiragonz thanks for the tips. One more question, if I only setting the whitelist, RMW_FASTRTPS_USE_QOS_FROM_XML=1 this line does not needed right?

TZECHIN6 avatar May 26 '25 07:05 TZECHIN6

One more question, if I only setting the whitelist, RMW_FASTRTPS_USE_QOS_FROM_XML=1 this line does not needed right?

Correct. That environment variable is not needed when configuring the whitelist.

cferreiragonz avatar May 26 '25 08:05 cferreiragonz

The previous test result was wrong. After retesting, it works fine. Close the issue

rty813 avatar Jul 01 '25 11:07 rty813