如何配置DDS以使用多个网络接口?How do I configure DDS to work with multiple network interfaces?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/believe_s/article/details/81945252

最近在使用OpenDDS的时候遇到一个问题:存在多个虚拟网卡时,发布(订阅)端重新连接时会阻塞几分钟,在外网找到一篇与此相关的文章。

You cannot specify which NICs DDS will use to send data. You can restrict the NICs that DDS can use to receive data by configuring Participant properties in the QoS on the DataReader, but you cannot tell DDS to use one NIC or another to send the DataWriter data. Rather, the DataWriter will try to send data to all of the addresses that a DataReader announces when subscribing to data using the interfaces that the Operating System selects.

您无法指定DDS将用于发送数据的NIC。 您可以通过在DataReader上的QoS中配置Participant属性来限制DDS可用于接收数据的NIC,但您无法告诉DDS使用一个NIC或另一个NIC来发送DataWriter数据。 相反,DataWriter将尝试将数据发送到DataReader在使用操作系统选择的接口订阅数据时宣布的所有地址。

In other words, it is up to the routing table on the Operating System (OS) to decide which NICs are used to send the UDP/IP packets.

换句话说,由操作系统(OS)上的路由表决定使用哪些NIC来发送UDP / IP数据包。

For example:

  • DataReader1 is on a node with single NIC, IP address 10.30.1.100
  • DataReader2 is on a node with single NIC, IP address 10.10.100.120
  • DataReader3 is on a node with two NICs, IP addresses 10.30.1.101 and 10.10.100.121
  • The DataWriter1 is on a node with two NICs, IP addresses 10.30.1.191 and 10.10.100.188
  • The netmask for all networks is 255.255.255.0.
  • The DataWriter and DataReaders are for the same topic and have compatible QoS. Assume that the DataReaders are NOT subscribing to data using multicast.

例如:

  • DataReader1位于具有单个NIC的节点上,IP地址为10.30.1.100
  • DataReader2位于具有单个NIC的节点上,IP地址为10.10.100.120
  • DataReader3位于具有两个NIC的节点上,IP地址为10.30.1.101和10.10.100.121
  • DataWriter1位于具有两个NIC的节点上,IP地址为10.30.1.191和10.10.100.188
  • 所有网络的网络掩码是255.255.255.0。
  • DataWriter和DataReader用于相同主题并具有兼容的QoS。 假设DataReader不使用多播订阅数据。

In this scenario when DataWriter1 sends data to DataReader1, it will send a packet using the address 10.30.1.100. When sending data to DataReader2, it will send a packet using the address 10.10.100.120. When sending data to DataReader3, it will send 2 packets using the addresses 10.30.1.101 and 10.10.100.121.

在这种情况下,当DataWriter1向DataReader1发送数据时,它将使用地址10.30.1.100发送数据包。 向DataReader2发送数据时,它将使用地址10.10.100.120发送数据包。 向DataReader3发送数据时,它将使用地址10.30.1.101和10.10.100.121发送2个数据包。

The NIC used by the OS to send the data from DataWriter1 to a particular destination depends on the network routing table for the machine where DataWriter1 is running. Absent strange OS configurations, packets destined to the 10.30.1.x network should be sent through the NIC with address 10.30.1.191, and packets destined to the 10.10.100.x network should be sent through the NIC with address 10.10.100.188.

操作系统用于将数据从DataWriter1发送到特定目标的NIC取决于运行DataWriter1的计算机的网络路由表。 如果没有奇怪的操作系统配置,发往10.30.1.x网络的数据包应通过地址为10.30.1.191的NIC发送,发往10.10.100.x网络的数据包应通过地址为10.10.100.188的NIC发送。

For example, the routing table (use netstat -r to see the routing table, example below is output on Windows) may be:

例如,路由表(使用netstat -r查看路由表,以下示例在Windows上输出)可能是:
这里写图片描述
Which supports the scenario as described above.
这支持如上所述的场景。

Restricting interfaces on the DomainParticipant

With the Property DomainParticipantQos, you can modify the default
NICs that the DomainParticipant is allowed to use (or denied), for
example:

限制DomainParticipant上的接口
使用Property DomainParticipantQos,您可以修改允许DomainParticipant使用(或拒绝)的默认NIC,例如:

<participant_qos>
  <property>
    <value>
      <element>
        <name>dds.transport.UDPv4.builtin.parent.allow_interfaces</name>
        <value>192.168.0.1,192.168.1.2</value>
      </element>
      <element>
        <name>dds.transport.UDPv4.builtin.parent.deny_interfaces</name>
        <value>192.168.2.3 </value>
      </element>                   
    </value>
  </property>
</participant_qos>

How restricting interfaces on the DomainParticipant affect the DataReader Absent further configuration, a DataReader will only advertise the interfaces that its DomainParticipant has been allowed to use as addresses where it can receive data. So for example, if DataReader3’s participant is restricted to use only the NIC with IP address 10.10.100.121, then this will be the only NIC advertised by DataReader3 and therefore a DataWriter will only send data to the DataReader3 at address 10.10.100.121. However, the DataWriter may still use its 10.10.100.188 NIC when sending data to DataReader2, which is on the same subnet as DataReader3.

DomainParticipant上的限制接口如何影响DataReader如果没有进一步的配置,DataReader只会通告其DomainParticipant被允许用作可以接收数据的地址的接口。 因此,例如,如果DataReader3的参与者被限制为仅使用IP地址为10.10.100.121的NIC,那么这将是DataReader3通告的唯一NIC,因此DataWriter将仅将数据发送到地址10.10.100.121的DataReader3。 但是,在将数据发送到与DataReader3位于同一子网的DataReader2时,DataWriter仍可能使用其10.10.100.188 NIC。

How restricting interfaces on the DomainParticipant affect the DataWriter Restricting interfaces has no effect on DataWriters as far as unicast data is concerned. As mentioned earlier for unicast data, an application cannot control which NIC card is used by a DataWriter to send data. Generally speaking and independently of DDS, there is no way to control which interface IP data is sent at the application level. This is entirely controlled by the OS routing table.

就单播数据而言,限制DomainParticipant上的接口如何影响DataWriter限制接口对DataWriters没有影响。 如前面提到的单播数据,应用程序无法控制DataWriter使用哪个NIC卡发送数据。 一般而言,与DDS无关,无法控制在应用程序级别发送哪个接口IP数据。 这完全由OS路由表控制。

For multicast data, the DomainParticipant will only send out multicast packets using the interfaces that it’s been allowed to use.

对于组播数据,DomainParticipant将仅使用允许使用的接口发送组播数据包。

NOTE: by default, a DomainParticipant is only able to announce the first 4 interfaces that it finds as the default set of addresses to which other DomainParticipants should send it data.

注意:默认情况下,DomainParticipant只能宣告它找到的前4个接口作为其他DomainParticipants应向其发送数据的默认地址集。

Hope this helps clarify how DDS works with multiple NICs and the controls that users have.

希望这有助于阐明DDS如何与多个NIC以及用户拥有的控件配合使用。

原网站地址:https://community.rti.com/forum-topic/how-do-i-configure-dds-work-multiple-network-interfaces

****** 有对DDS技术了解,学习,开发和培训需求的,请加入QQ群:707895641(DDS专业技术辅导) ******

猜你喜欢

转载自blog.csdn.net/believe_s/article/details/81945252