最近在使用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專業技術輔導) ******