I’m testing setting up a “private” IPFS network through the use of a custom DHT protocol id (like OpenBazaar). Using IPTB, my goal is to run 100 nodes, connect them in a ring shape (i to i+1) and benchmark the speed of DHT requests.
My problem is that once two neighbors get connected, they both connect to each other’s peers, etc. So I end up with every peer connected to each other. I tried to circumvent that by tweaking the ConnectionManager (low low/high water, low grace period) but nodes still keep about a third of the total number of peers as connected peers. I assume this is coming from the DHT that protects nodes for routing, as mentioned here.
Is there an easy way to reduce peer connection to manual peering (
ipfs swarm connect or
iptc connect i i+1) only? This is just for testing, not for production (obviously this is not a behavior we want in prod).
I don’t think the DHT is going to work at all in a ring-shape. To do a dht lookup you need to be able to open a direct connection to any other node, potentially.
Indeed, the ring-shape network would not make sense as soon as the first DHT lookup starts, but my goal would be to start from that network shape and measure the performance of the overall DHT request, including the peer connections at every lookup round.
Step 0: Ring-shape network within 100 peers (node 0 is connected to node 1 and node 99)
ipns name publish on node 0 => node 0 starts to connect to many peers
Step 2: Measure the perf of the overall DHT PUT request
Hence my need for limiting the initial connection between peers.
I don’t understand why you would spend time measuring something in a convoluted way that is not how it wants to work.
The kad-dht nodes will attempt to stay connected and keep a balanced number of peers in their k-buckets. You can measure how long it takes to fill-in the buckets upon starting, you can measure how long it takes to make a lookup with a fresh node vs a non-fresh node, but why go through the hassle of forcing an arbitrary starting state and then dropping that limitation. In a 100 peer network everyone can be connected to everyone anyways.
Also, see https://docs.testground.ai/ which can facilitate what you want, or similar things at least.