I'm working on my first P2P app using C# core and gRPC and I'm finding it difficult to understand the concepts of how nodes find each other and build a routing table.

For my design I'd like to only have nodes and no listener/directory/discovery servers.

I'll have a list of a few "known nodes" that can start off the chain of finding and connecting to peers but can't figure out a workflow for it.


1) How are ID's assigned to each node?

2) How does peer discovery work?

- Known node is running and is the only node on the network.
- New node connects to known node and requests full peer list?
- Connect to each peer on the list?

3) Since each node is a client and a server, does there needs to be 2 connections between each node?

  • 2
    Are all these nodes on the same local network? or are they meant to find each other across the internet? – Peter M Jun 6 '18 at 13:43
  • @PeterM Across the internet – user3953989 Jun 6 '18 at 13:47
  • 2
    You might start by researching the Torrent protocol. The .torrent file has metadata about what is being downloaded and an initial list of peers. – Berin Loritsch Jun 6 '18 at 19:39

You have to know someone to get in the club.

When you download p2p software it has a list of known stable peers. So long as one of them is up it'll give you the latest list of peers. Baring that you can always start your own p2p network by distributing a connection string to your friends.

There's plenty of complexity you can add to that to load balance and such but this is essentially how peers find peers. The software jump starts it and after that it's word of mouth.

Well, unless you go around port scanning. But that's a bit rude.

  • "Well, unless you go around port scanning. But that's a bit rude.": I laughed. Thanks! Specially because port scanning was my first thought. – Machado Jun 6 '18 at 13:44
  • Thanks! This makes sense but I'm trying to understand the part where you say "it'll give you the list of peers". Does that mean every peer in the entire network or just their connected peers? I'd imagine passing around an entire list would be a headache. – user3953989 Jun 6 '18 at 13:49
  • @user3953989 You connect to me I tell you the peers I know about that you're interested in. That might not be every peer I've ever seen. It might only be peers that I know have what you're looking for today. Whether those peers are connected to me is completely irrelevant to you when you're trying to connect to them yourself. – candied_orange Jun 6 '18 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.