Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting Routing into (Peer Routing, Content Routing) #1

Open
jbenet opened this issue Mar 13, 2015 · 2 comments
Open

Splitting Routing into (Peer Routing, Content Routing) #1

jbenet opened this issue Mar 13, 2015 · 2 comments

Comments

@jbenet
Copy link
Member

jbenet commented Mar 13, 2015

Full p2p connectivity requires NAT traversal (including the possibility of relaying messages between peers, e.g. STUN, TURN), so no p2p networking layer can be complete without incorporating a notion of p2p message routing.

In IPFS, p2p routing is solely the responsibility of the "Routing" layer (e.g. a Kademlia DHT).

Distinction

The line between Network and Routing layers is blurred significantly, and thus we must clearly distinguish the two responsibilities of Routing:

  1. Peer Routing, for peer-to-peer discovery and connectivity
  2. Content Routing, for data storage, discovery, and retrieval

To make this distinction more concrete, this essentially means splitting the Routing interface:

type Routing interface {
  PutValue(Key, Value)
  GetValue(Key) Value

  PutProvider(Key)
  GetProviders(Key) []peer.ID

  FindPeer(peer.ID) peer.Addr
}

into:

type ContentRouting interface {
  PutValue(Key, Value)
  GetValue(Key) Value

  PutProvider(Key)
  GetProviders(Key) []peer.ID
}

type PeerRouting interface {
  FindPeer(peer.ID) peer.Addr
}

And allowing the Network layer to use PeerRouting. This cleanly
separates the layers and avoids confusion.

Important Routing Implementation Details

It should be noted that p2p content routing systems (beyond the context of ipfs) usually combine both Peer Routing and Content Routing. Consider, "Kademlia" which is the combination of "Kademlia Peer Routing" (address ring, buckets, xor distance, etc), and the "Kademlia DHT", which uses "Kademlia Peer Routing". From an implementation standpoint, it is much cleaner to think of the whole system.

Forcing implementors to completely separate these two components is difficult, and perhaps counter-productive. Thus IPFS implementations should be careful to make it possible for Routing layer implementations to solve both problems, and export two components, PeerRouting and ContentRouting. The Network layer can then be a client of the PeerRouting part.

@wanderer
Copy link
Member

@jbenet How is Peer Routing going to work for multiple Protocols? Lets say I create a new /hellowold Protocol and there are very few other peers. Is there any way to find peers by protocol?

@jbenet
Copy link
Member Author

jbenet commented Oct 27, 2015

@wanderer a policy like that could exist, but in most cases you'd check all your avail protocols till you get an answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants