Skip to content

Broadcast-based LAN discovery

bornholdt requested to merge broadcast into master

This MRs adds a broadcast-based LAN discovery. It can be used to discover other nodes within the LAN when IP multicast functionality is not available.

The broadcast discovery is currently only usable by programmatically altering the ChannelPipeline.

Here is an example snippet:

// replace LocalNetworkDiscovery to switch from MULTICAST_ADDRESS to BROADCAST_ADDRESS
p.replace(LocalNetworkDiscovery.class, "local_network_discovery", new LocalNetworkDiscovery(
        config.getNetworkId(),
        config.getRemotePingInterval().toMillis(),
        config.getRemotePingTimeout().toMillis(),
        identity.getIdentityPublicKey(),
        identity.getProofOfWork(),
        BROADCAST_ADDRESS
));
// replace UdpServer to switch SO_BROADCAST from false to true
p.replace(UdpServer.class, "udp_server", new UdpServer(
        new Bootstrap().option(SO_BROADCAST, true),
        new InetSocketAddress(0)
));
// replace UdpMulticastServer with UdpBroadcastServer
p.replace(UdpMulticastServer.class, "udp_broadcast_server", new UdpBroadcastServer());

If you would like to test this, check out the broadcast-test branch and start a node through the CLI.

Edited by bornholdt

Merge request reports

Loading