Skip to content

Handle discovery where multiple LAN interfaces exist #104

@eode

Description

@eode

My network arrangement:
modem->wireless bridge a->wireless bridge b->rpi qos & automation->wifi/lan bridge->clients, including hs300.

For the purposes of this discussion, we can simplify that to:
modem->rpi->wifi->hs300

When discovery occurs, from what I can tell, an arbitrary interface (the first interface, linked to the modem) on the rpi is selected. This means the wrong network gets the broadcast packet (which would need to go out via wifi).

This is a known issue, as discussed here, and it can be resolved as discussed in the previous link and here. Also useful is this article about selecting interfaces in linux vs windows

The crux of it is basically:

sockets = []

if windows:
    for address in AF_INET addresses:
        sockets.append(<a new socket, bound to that address>)

if linux/osx:
    for index, interface in socket.if_nameindex():
        sockets.append(<a new socket, bound to that interface>)

for socket in sockets:
    <do discovery>

Obviously, there are additional considerations in the actual coding. Also, there are some ugly convolutions on Windows -- specifically, although you can select the interface to use by binding one of its IP addresses, there's no nice way to get a list of IP addresses. This may mean a module dependency such as netifaces.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions