How to use specific network interface

11 posts / 0 new
Last post
Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15
How to use specific network interface

Hi everybody,
I've two network cards on my PC and I want my application use a specific network interface (or two instances using different network interfaces with different IP addresses).
For example my network interfaces have the same subnet and IPs: 10.180.60.10 and 10.180.60.17.

I want to run my application using the network card with IP address 10.180.60.17, so I've tryed to configure via QoS XML, like this:

<dds>
  <qos_library name="test">
    <qos_profile name="UDPv4_properties">
      <participant_qos>
        <property>   
          <value>
            <element>
              <name>dds.transport.UDPv4.builtin.parent.deny_interfaces</name>
              <value>10.180.60.10</value>
            </element>
            <element>
              <name>dds.transport.UDPv4.builtin.parent.allow_interfaces</name>
              <value>10.180.60.17</value>
            </element>            
          </value>
        </property>
      </participant_qos>
    </qos_profile>
  </qos_library>
</dds>

But my application use always the network interface with IP address 10.180.60.10! (looking on the Windows Task Manager) I've tryed to use this QoS file with RTI Shape Demo with same issue.

(Using NDDS 5.0)

Thanks!

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 hours ago
Joined: 06/02/2010
Posts: 602

I think this may explain what is happening:

Your profile is not tagged to be the default one to use by the application.  In other words you did not use the tag is_default_qos="true" when defining the QoS profile. Because of this it will not be used when a new DomainParticipant is created unless you specify it explictly, e.g. using the DomainParticipantFactoy::create_participant_with_profile operation.

Alternatively you could specify the UDPv4_properties profile to be the default one using these syntax when you define it in the XML file:

        <qos_profile name="UDPv4_properties" is_default_qos="true">

Gerardo

Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15

Thanks Gerardo,
I've set is_default_qos as you said, but the RTI Shape Demo use always the same interface (10.180.60.10).

I'm simply using a square publisher selecting the "UDPv4_properties" profile and watching the Network Windows Task Manager...

If I try to set as allow_interfaces a wrong address (for example 10.180.60.18, I've no interface with this address) I get an error "No interface found...", so It's using the right profile...

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 hours ago
Joined: 06/02/2010
Posts: 602

Hi,

Oh I see.  You are trying to restrict the interfaces used to send network traffic, not to receive traffic. Is this right?

If that is the case then you cannot do this with the DDS QoS. The DDS Transport configuration only controls the interfaces that are used to receive UDP/IP traffic (which are the ones the applicaton opens "listen" sockets on and announces via discovery). It does not control the interfaces used to send UDP/IP traffic.

The interfaces used to send information are determined by the Operating System (in your case WIndows).  RTI DDS just opens an unbound socket when we send information via UDP on that socket it is the operating system network routing table that decides which Interface to use. This is normally controlled by the underlying IP protocols.

You can probably configure your routing tables at the operating-system level to control which interface will be used for specific network destinations/masks. Or at least a preference. But I doubt you can do that for a single application. It will likely affect everything that is running in your computer.

I am curious why the selection that that the Operating System network stack is doing is not the right one for you. Perhaps I knew a little more of what you are trying to do something else would come to mind...

Gerardo

Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15

Yes, I want to control the interface used to send traffic.I think the OS simply select the best interface between the availables...

Routing table doesn't help me to link a specific application to a specific network interface.

So, is there no way to set the interface to use from an application to send traffic (also using system properties)?
Thanks a lot Gerardo.

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 hours ago
Joined: 06/02/2010
Posts: 602
You cannot configure the interface used to send data using the RTI DDS QoS.

However, depending on your platform, you should be able to configure it at the operating-system/IP-routing level.

For example in Linux you can use the command (executed as administrator):

ip route add 192.168.1.0/24 dev eth0
To specify that all packets sent to the network 192.168.1.* are sent via the eth0 interface.
Take a look at this HOWTO on Linux routing configuration for additional details.

Gerardo

Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15

Thanks Gerardo,
I think I cannot solve with routing because all my applications have to communicate with the same set of addresses, but using different network interfaces!

For example:

  • appA (ip 10.180.60.10 eth0) on Host1
  • appB (ip 10.180.60.17 eth1) on Host1
  • appC (ip 10.180.60.14 eth0) on Host2

Every application have to communicate with each other but if I run appA and appB (on the same host node) they will use the same network interface to communicate (with the same IP address).

appA and appB have to communicate also with appC, if I set a route to Host2 with eth0 all the traffic for Host2 will flow through eth0 (traffic from appA and appB, so always with the same IP address)!

The only solution I found is to use Virtual Machines. With VM I can "choose" the network interface, but I think this workaround is too expensive for this kind of problem...

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 hours ago
Joined: 06/02/2010
Posts: 602

Could you explain the reason why you are trying to do this? In general appliatiosn would not care which interface is used to send, they just want the operating system to pick the best...   From your questions it is clear this is not what you want, but if you explain what ultimately you want to do maybe I can suggest other ways to get there.

Out of curiosity. Do you know if there is a way to even control this using the socket API? What Operating System are you runnign on?  I searched a little and I did not see anything obvious in the socket API.  If there was a way, then it would be possible to add a configuration property to the transport to make it do what you want.

Gerardo

Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15

OK, I use my applications with a network emulator where I have different virtual nodes mapped to real nodes (real PC with different IP addresses).

I have to execute different instances of the same application on different virtual nodes. I don't want to use a real PC for every virtual node, so I tryed to use different network interfaces from the same PC and run different instances of the same application using different (source) IP addresses. This way the emulator can analyze the traffic flows from every single application (from every single virtual node with different IP address).


Generally in sockets you can specify an IP address to use as local_address with bind() function. When you have several network interfaces sometimes can be useful to choose one of them for your transmissions.

For example if I had a system with 2 different kind of interfaces, wireless and a wired connection. Maybe I want to change between them during the execution due to a fault or simply I want to choose between them through a configuration file.

Thanks a lot for your attention!

Steve

Gerardo Pardo's picture
Offline
Last seen: 3 weeks 3 hours ago
Joined: 06/02/2010
Posts: 602

Hello,

I understand now. Thank you for the explanation.

You are right... Of course  bind() could do it!  I got so used to seeing INADDR_ANY specified for the IP addresses of send sockets that it didn't even catch my eye... 

Therefore what you want should be quite possible... The question is how and when...

The best would probably be to add an additional property to the UDP transport configuration to specify that outgoing inteface so you can specify it to the DomainParticipant alogn with other transport configuration properties. As an engineer this makes the most sense to me.

Alternatively a custom UDP Transport Plugin could be implemented and pluggled using the Pluggable Transport API present in RTI Connext DDS. From some quick inspection it would seem that this cannot be easily done as a 'facade' that delegates to the exiting UDP transport which would imply that there would be significant code duplication with the existing plugin.

I will add an RFE (request for enhancement) for this feature.  I searched and I am not aware that we have it in our near-future plans. Given your need I would recommend you get in touch with our field support (sales@rti.com) to see if there is a way we can help you via feature acceleration, consulting, making available some source code for the plugins, etc.

Gerardo

 
Offline
Last seen: 11 years 8 months ago
Joined: 01/07/2013
Posts: 15

Thanks a lot Gerardo, I'll wait for news...


Steve