yggdrasil-network / yggdrasil-go

An experiment in scalable routing as an encrypted IPv6 overlay network
https://yggdrasil-network.github.io
Other
3.48k stars 239 forks source link

Yggdrasil doesn't take the shortest path when transferring files to/from nodes on the same LAN. #1022

Open styromaniac opened 1 year ago

styromaniac commented 1 year ago

I expect files to transfer like they would if LAN IP addresses were used instead, not going through the ISP and back to the same LAN again. This is a huge performance bottleneck.

I'm using the latest F-Droid release of Yggdrasil on Android by Yggdrasil Developers and Yggdrasil for Debian.

neilalexander commented 1 year ago

You'll need to provide more details about how the nodes are connected and what those links are like, otherwise it's impossible to tell what's going on.

styromaniac commented 1 year ago

Pardon me. I don't know exactly what you mean.

neilalexander commented 1 year ago

Well, what peerings are set up between the nodes in question?

Do you have two nodes peering to the same internet node? Do you have multicast peerings enabled (and are they being discovered correctly and showing in yggdrasilctl getPeers)? Or are the LAN nodes statically peered to each other through some other means? Or are the LAN nodes just not peered with each other at all?

Are the LAN links Wi-Fi or cabled, are they the same subnet/broadcast domain, are there routers or firewalls in the way anywhere that would prevent two LAN nodes from peering with each other?

styromaniac commented 1 year ago

Well, what peerings are set up between the nodes in question?

Do you have two nodes peering to the same internet node? Do you have multicast peerings enabled (and are they being discovered correctly and showing in yggdrasilctl getPeers)? Or are the LAN nodes statically peered to each other through some other means? Or are the LAN nodes just not peered with each other at all?

They are currently using the same public peer: tcp://kusoneko.moe:9002. The results are the same when they're not using the same public peer. I don't have multicast peering enabled. I don't know how multicast peering works anyway. The nodes are not statically peered to one-another.

Are the LAN links Wi-Fi or cabled, are they the same subnet/broadcast domain, are there routers or firewalls in the way anywhere that would prevent two LAN nodes from peering with each other?

Wi-Fi. I'm not sure what is meant by subnet/broadcast domain. I don't have firewalls on either device. I don't believe the routers I've tested on have any blocking measures since I've been able to use the LAN IP addresses for faster transfer speeds. There is no device isolation enabled in the routers.

neilalexander commented 1 year ago

They are currently using the same public peer: tcp://kusoneko.moe:9002. The results are the same when they're not using the same public peer. I don't have multicast peering enabled. I don't know how multicast peering works anyway. The nodes are not statically peered to one-another.

If you haven't peered the LAN devices to each other manually and you haven't got multicast peering enabled, then those two LAN nodes basically have zero knowledge of each other. As a result, traffic will go via the public peer because that's the only possible path they know of.

Either enable multicast peerings on both nodes (by using the MulticastInterfaces configuration option) so that they will discover and peer with each other automatically, or peer them together statically (using Listen and Peers) so that there's a fast path available that doesn't leave the LAN.

styromaniac commented 1 year ago

Can you give me example snippets of a properly set yggdrasil.conf?

neilalexander commented 1 year ago

For example, on your Debian node:

  MulticastInterfaces:
  [
    {
      Regex: .*
      Beacon: true
      Listen: true
      Port: 0
      Priority: 0
    }
  ]

On your Android node, make sure "Discoverable over multicast" and "Search for multicast peers" are enabled in the Peers settings.

styromaniac commented 1 year ago

For example, on your Debian node:

  MulticastInterfaces:
  [
    {
      Regex: .*
      Beacon: true
      Listen: true
      Port: 0
      Priority: 0
    }
  ]

On your Android node, make sure "Discoverable over multicast" and "Search for multicast peers" are enabled in the Peers settings.

I have that exact same configuration on my Debian node and on the Android node the settings have been enabled by default and unchanged. To be sure my Debian node is the exact same, not only did I compare using my own eyes, but I also used ctrl+f and pasted the snippet from my yggdrasil conf into the browser to find it. The whole snippet highlights green on Firefox.

I should add that I was wrong about not having multicasting enabled.

styromaniac commented 1 year ago

Did you read my edit to my prior comment?

styromaniac commented 1 year ago

In all fairness to you, it's most likely because my phone is a Samsung, because ZeroNetX and Chrome have bugs exclusive to Samsung phones.

turretkeeper commented 1 year ago

Do you have a firewall enabled on your Debian PC? You may need to open a port for Yggdrasil beacons to actually work.

styromaniac commented 1 year ago

Do you have a firewall enabled on your Debian PC? You may need to open a port for Yggdrasil beacons to actually work.

The firewall hadn't been on.

turretkeeper commented 1 year ago

Can you ping/nmap your phone from your desktop?

styromaniac commented 1 year ago

Can you ping/nmap your phone from your desktop?

Yes. It goes through the internet though. I've used ping6, cURL, and a few other applications (that I don't remember the names of, except maybe nmap as well) to check for reachability and have used wget and a custom site mirroring application to download my site. I'm not using any applications alike another at the same time, but one at a time.

I know that it's going through the internet because it's significantly slower at downloading files from my phone than when I use the LAN IP address. I've interchanged between the Yggdrasil IP address and the LAN IP address many times and noticed the speed difference every time.

turretkeeper commented 1 year ago

Have you considered setting the connection up as a traditional peer over LAN? It won't get down to the root cause of the problem, but it will solve your issue.

styromaniac commented 1 year ago

Have you considered setting the connection up as a traditional peer over LAN? It won't get down to the root cause of the problem, but it will solve your issue.

I haven't. I would like an example of this. I'm away from my apartment without my laptop, so I don't know if your solution would be obvious to me.

turretkeeper commented 1 year ago

Something like having your computer have tls://0.0.0.0:10040 as one of its listen addresses, and your phone attempt to connect to tls://192.168.1.25:10040 via an entry in its Peers list.