Luminarys / synapse

Synapse BitTorrent Daemon
https://synapse-bt.org
ISC License
855 stars 48 forks source link

Synapse creates a large number of connections at once #203

Open aereaux opened 4 years ago

aereaux commented 4 years ago

About every minute synapse creates a very large number of connections (several thousand). This causes my internet connection to lose packets and for the ping latency to jump to several seconds. Is there something I can configure in synapse to stop this from happening?

Luminarys commented 3 years ago

Hmm, it's not immediately clear as to why this could happen. Have you tried reducing max_open_socket and max_open_announces? Do you know what sort of connections these are (DNS, HTTP, UDP, Bittorrent)?

aereaux commented 3 years ago

I'm not very experienced at debugging network issues like this. Is the best way to tell what sort of connections they are using wireshark or tcpdump? I tried reducing the limits listed in the config file to 40 and 5 respectively, and it seems to shortened the duration of the interruption but not gotten rid of it.

Luminarys commented 3 years ago

My best guess is that this is peer connections. I think using wireshark should be informative, see if the connections opened use the bittorrent protocol and if there's a pattern in IP addresses being connected to. It might be possible that your tracker is returning many connections which Synapse is attempting to connect to in succession. Because we don't limit opened connections from tracker responses I would also check what the tracker response is and if it contains many peer IPs since this could be caused by a very large tracker response.

aereaux commented 3 years ago

Both of the torrents I have loaded are archlinux iso images that I got from magnet links. As far as I can tell, they don't have trackers. After some more experimentation, it looks like the traffic spike is from DHT, The traffic is all (or most?) UDP on the DHT port that is configured in my config, and it looks like it stops when I disable DHT (although that means I can't download anything). Is there some way I can limit this?

Luminarys commented 3 years ago

I see, DHT also makes sense as a culprit. As of right now there is no config on the number of peers returned from a response, this is something I'll add. For the time being, you can control the vector used by modifying this line to limit peers processed: https://github.com/Luminarys/synapse/blob/7785d5fa20da22c08bf640f1ed51233e6ad5f74c/src/control/mod.rs#L310