Communication via LAN rather than just internet

I incidentally discovered Secure Scuttlebutt upon following an IPFS update. One aspect caught my attention while reading a description of how it works: The application can supposedly propagate updates even if you aren’t connected to the internet at all. This is achieved via LAN: If you’re disconnected from your ISP but connected to one or more other computers by say a router, entries you post are transferred to those computers locally… then if any device in the network gets online sooner than you or can forward the information to other devices that can, the update spreads faster than if you waited for the initial computer to get back online.

I find this approach beautiful and ingenious! Which is why I just have to ask whether IPFS is going to support anything similar. Will go-ipfs and / or js-ipfs have the capability of using Local Area Connections additional to just an internet connection, basically allowing other devices to act as intermediaries?

Here’s a practical example of how I envision this working: Let’s say that my computer is X, the computer of my next door neighbor is Y, and the computer of a neighbor in a nearby apartment block is Z. X can communicate with Y via LAN cable, Y can communicate with Z via WiFi. I want to publish an update to the network, but I discover that the internet just went down in my block. Rather than waiting for my net to come back up, the following chain of events will instead occur: The IPFS daemon on my computer (X) realizes it can’t contact other IPFS nodes over the internet, so it only looks for one in my LAN… it quickly discovers that my next door neighbor (Y) has an IPFS daemon, so it publishes my update to their node locally. After noticing that there’s been an update in the network, the IPFS node on computer Y tries to pass it further on, but because internet is down in the whole building it too can’t connect to the internet… so it does the same as my computer and continues to scan across its local networks. It detects that the computer of the neighbor down the street (Z) is connected via WiFi, so it passes the update onto its IPFS daemon. Since internet is not down in the apartment block where computer Z is located, its IPFS daemon now closes the gap and spreads it to other nodes worldwide.

In this hypothetical scenario, I was able to send data throughout IPFS without even having an internet connection, thanks to being reachable by neighbors that were themselves connected to the internet or a larger network. While in everyday life it’s uncommon to run into this particular scenario, imagine how many people this can still help in the right circumstances! Several advantages to LAN include:

  • Users who can’t get an internet connection may be able to still use IPFS if they’re part of a LAN in which any device has internet. While this situation is less common it’s not neglectable.
  • Updates throughout IPFS may happen sooner thus the network is more efficient. You may dump an update to another device, which may then connect to the internet sooner than your device gets to… thus the update reaches the world more quickly overall.
  • This would decrease bandwidth requirements for Internet Service Providers even further, as computers can also transfer files directly rather than just through the pipe provided by your ISP.

IPFS nodes can and do already communicate with each other on a LAN without an internet connection and nodes can act as relays (though I think that might currently be disabled by default).

What is an “update” in this context?

1 Like

This is very good to hear, thank you! So if say my home router contains two computers, one on the IP and the other on, their IPFS daemons will be able to communicate out-of-the-box through LAN as they would over the internet? Also does IPFS know to prefer fast LAN connections over internet when given a pathing choice, in order to reduce bandwidth usage with your ISP?

File updates are obviously not a problem, each file has an immutable hash so there’s no risk of a conflict. In this case I was pondering what happens if a local network updates an IPNS or filename or directory, which then conflicts with an update in another network. However someone clarified me on Reddit that timestamps are used to always determine the latest change, so a conflict shouldn’t be the case here either.

IPFS node use MDNS (Multicast DNS) to find other nodes on the LAN.

1 Like

As far as I know, this is not currently how it works. I don’t know what the latest is on how the bitswap algorithm works since I think there’ve been some changes recently – or maybe they’re still in progress.

That’s awesome to hear. Folks on Reddit told me that LAN couldn’t be supported as the trackers on which nodes announce themselves rely on an internet connection, and in lack of an alternative I was tempted to agree with that. I haven’t heard of MDNS until now, but from a quick description it sounds like just what it would require.

Thanks. It would be nice if IPFS nodes knew how to transfer data from another node via different connections simultaneously, so if another computer is connected both via LAN and internet it transfers data through both for maximum efficiency (including multiple LAN and / or internet connections combined).

When a connection is attempted. the swarm/switch module will simultaneously send a “connect” to all known multi addresses The first (e.g. the fastest) to respond wins.