Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Support loopback adapter with external adapters
24-09-2014, 09:15 PM
Post: #1
Support loopback adapter with external adapters
I have a scenario where I would like the device stack to send discovery announcements on the loopback adapter as well as on external adapters. From looking at the code in OsNetworkListAdapters, this doesn't seem to be possible.

Is there a reason for this limitation? The scenario is that I want a server and a local (internal) control point running on the same machine. The local (internal) control point will access its local server only, so it shouldn't be sending M-SEARCH requests out across the network. The server should be accessible to both its local (internal) control point and external control points.

Is there any technical reason why ohNet shouldn't be able to support this scenario?
Find all posts by this user
25-09-2014, 08:00 AM
Post: #2
RE: Support loopback adapter with external adapters
There's no reason why this can't be supported. A device stack can run on all subnets already; all we need is a way to instruct the device list to include loopback in its subnet list.

InitialisationParams::SetIncludeLoopbackNetworkAdapter() in the core (C++) API should do this. It isn't exposed via language bindings but it'd be easy to do this. I'll get this done in the next couple of days.
Find all posts by this user
25-09-2014, 08:25 AM
Post: #3
RE: Support loopback adapter with external adapters
(25-09-2014 08:00 AM)simonc Wrote:  There's no reason why this can't be supported. A device stack can run on all subnets already; all we need is a way to instruct the device list to include loopback in its subnet list.

InitialisationParams::SetIncludeLoopbackNetworkAdapter() in the core (C++) API should do this. It isn't exposed via language bindings but it'd be easy to do this. I'll get this done in the next couple of days.

Thanks very much! When I was looking at the code in OsNetworkListAdapters, I had missed the possibility of the aUseLoopback parameter having the value 2.

This API change wil be very useful because it opens up the possibility of using ohNet for local interprocess communication as well as network communication.
Find all posts by this user
25-09-2014, 08:52 AM
Post: #4
RE: Support loopback adapter with external adapters
That turned out to be straightforward... I've committed this locally now. The new API in Java is InitParams.setIncludeLoopbackNetworkAdapter(). It'll hopefully be on github this evening.
Find all posts by this user
14-10-2014, 09:14 AM
Post: #5
RE: Support loopback adapter with external adapters
(25-09-2014 08:52 AM)simonc Wrote:  That turned out to be straightforward... I've committed this locally now. The new API in Java is InitParams.setIncludeLoopbackNetworkAdapter(). It'll hopefully be on github this evening.

I have noticed that this isn't working on Mac. Looking at the code in the Posix version of OsNetworkListAdapters, I see the lines

Code:
#ifdef PLATFORM_MACOSX_GNU
    aUseLoopback = 0;
#endif

This overrides the user-specified setting from setIncludeLoopBackNetworkAdapter(). What is the reason for this?
Find all posts by this user
14-10-2014, 03:30 PM
Post: #6
RE: Support loopback adapter with external adapters
(14-10-2014 09:14 AM)simoncn Wrote:  I have noticed that this isn't working on Mac. Looking at the code in the Posix version of OsNetworkListAdapters, I see the lines

Code:
#ifdef PLATFORM_MACOSX_GNU
    aUseLoopback = 0;
#endif

This overrides the user-specified setting from setIncludeLoopBackNetworkAdapter(). What is the reason for this?

I think this has been in for years because of unpredictable behaviour when we first tried running tests on Mac. I'll have a go at removing it and see what happens.

To gather data from different systems, it'd be helpful if you could try this too. If you're able to do this, can you remove that #if block then run

python AllTests.py

on your Mac please?
Find all posts by this user
14-10-2014, 04:05 PM
Post: #7
RE: Support loopback adapter with external adapters
(14-10-2014 03:30 PM)simonc Wrote:  To gather data from different systems, it'd be helpful if you could try this too. If you're able to do this, can you remove that #if block then run

python AllTests.py

on your Mac please?

I got the error

make: dmcs: No such file or directory

What is dmcs and how do I build it?
Find all posts by this user
15-10-2014, 09:01 AM
Post: #8
RE: Support loopback adapter with external adapters
(14-10-2014 04:05 PM)simoncn Wrote:  I got the error

make: dmcs: No such file or directory

What is dmcs and how do I build it?

dmcs is the mono C# compiler. If you don't have mono installed, you can pass the --native flag to the test script:

python AllTests.py --native
Find all posts by this user
15-10-2014, 09:46 AM
Post: #9
RE: Support loopback adapter with external adapters
(14-10-2014 09:14 AM)simoncn Wrote:  
(25-09-2014 08:52 AM)simonc Wrote:  That turned out to be straightforward... I've committed this locally now. The new API in Java is InitParams.setIncludeLoopbackNetworkAdapter(). It'll hopefully be on github this evening.

I have noticed that this isn't working on Mac. Looking at the code in the Posix version of OsNetworkListAdapters, I see the lines

Code:
#ifdef PLATFORM_MACOSX_GNU
    aUseLoopback = 0;
#endif

This overrides the user-specified setting from setIncludeLoopBackNetworkAdapter(). What is the reason for this?

TestDviDiscovery fails for me when I remove the above code. I wondered whether the IP_MULTICAST_LOOP sockopt in OsNetworkSocketMulticastAddMembership was related; changing this had no effect.

I'm tempted to say that this means we can't safely run on loopback on Mac. I'm quite happy to change this if you can spot changes elsewhere that'd persuade the tests to pass.
Find all posts by this user
15-10-2014, 09:59 AM (This post was last modified: 15-10-2014 10:49 AM by simoncn.)
Post: #10
RE: Support loopback adapter with external adapters
(15-10-2014 09:01 AM)simonc Wrote:  dmcs is the mono C# compiler. If you don't have mono installed, you can pass the --native flag to the test script:

python AllTests.py --native

This didn't work. I got the same problem with dmcs not being found.

(15-10-2014 09:46 AM)simonc Wrote:  TestDviDiscovery fails for me when I remove the above code. I wondered whether the IP_MULTICAST_LOOP sockopt in OsNetworkSocketMulticastAddMembership was related; changing this had no effect.

I'm tempted to say that this means we can't safely run on loopback on Mac. I'm quite happy to change this if you can spot changes elsewhere that'd persuade the tests to pass.

I suspect this is related to the IP_MULTICAST_IF socket option. See this page, specifically this part:

For hosts with multiple interfaces, each multicast transmission is sent from the primary network interface. The IP_MULTICAST_IF option overrides the default for subsequent transmissions from a given socket:

struct in_addr addr;
setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr));


The primary interface would be the external interface, so all sockets (even those bound to the loopback interface) would send multicast transmissions from the external interface. To fix this, it would be necessary to make the above call for each outgoing multicast socket in addition to binding the socket.

When I have a bit of spare time, I'll do an experiment to see if my interpretation of how this works is correct.
Find all posts by this user


Forum Jump: