swaplink implemented in Python.
Swaplinks builds a random peer-to-peer unstructured overlay, in which each node’s degree is proportional to its desired degree capacity. Then, uses random walks over the generated random graph to do random node sampling.
It gives quite-precise control over both the probability that a node is selected and the overhead of visited nodes when executing peer sampling.
It is efficient, scalable, robust and simple, while limiting tuning-knobs to just the 'desired-load'.
from swaplink import Swaplink
def callback(neighbors):
...
async def main():
host = "127.0.0.1"
port = 5678
num_links = 5 # relative load on your node
boostrap_nodes = [("127.0.0.1", 7777)]
network = Swaplink(host, port)
await network.join(num_links, boostrap_nodes)
random_node = await network.select()
neighbors = network.list_neighbours(callback)
...
await network.leave()
- Swaplink paper - Vivek Vishnumurthy and Paul Francis. On heterogeneous over-lay construction and random node selection in unstructured p2pnetworks. InProc. IEEE Infocom, 2006.
- Swaplink evaluation paper - V. Vishnumurthy and P. Francis. A Comparison of Structured andUnstructured P2P Approaches to Heterogeneous Random Peer Selection.InProceedings of the USENIX Annual Technical Conference, pages 1–14, 2007.