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

feat: content routing overview #292

Merged
merged 7 commits into from
Feb 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion content/concepts/content-routing/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,56 @@ description: "Learn about Noise in libp2p."
weight: 218
---

Coming soon!
## Overview

Content routing refers to the process of directing data to its intended recipient within a
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
P2P network. In a traditional client-server network, routing is a straightforward process
because a central authority manages the flow of data. However, in a P2P network, there is
no central authority, so routing becomes more complex.

One of the main challenges of content routing in P2P networks is scalability. As the number
of peers in a network increases, the number of possible routes for data to travel also increases.
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
This can lead to a situation where the routing table becomes excessively large and difficult to
manage.

Another challenge is fault tolerance. In a centralized network, if the central server goes down,
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
the entire network goes down. In a P2P network, if a peer goes down, the network can still
function, but losing that peer can create a bottleneck and make routing more difficult.

In general, specific characteristics of P2P networks complicate this process, including:

- The lack of universal orchestration that a central server can provide when
querying and retrieving content.
- Not having a central directory that contains information about reaching every peer
in the network.
- The presence of high node churn.
- Creating a resilient, scalable, and optimal routing protocol that is resistant to
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
- Resistance against Sybil attacks.
- Forward compatibility.

## Content Routing in libp2p

libp2p provides a set of modules for different network-level functionality, including
a content routing interface.

```shell
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
interface ContentRouting {
Provide(CID, bool) error
FindProviders(CID) [Multiaddr]
}
```

In libp2p, content routing is based on a
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
[Distributed Hash Table (DHT) called Kademlia](../introduction/protocols/kaddht.md). Kademlia assigns
each piece of content a unique identifier and stores the content on the peer whose identifier is
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
closest to the content's identifier. This allows for efficient routing, reducing the number of possible
routes. The content router is simply an index of the peer serving the content of interest,
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
and a DHT is used to maintain a P2P index. More information can be found in the
[Kad-DHT content routing document](kaddht.md).

{{< alert icon="" context="note">}}
While there are different design approaches for a content routing protocol, such as
Kademlia DHT, DNS, and BitTorrent trackers, the libp2p
salmad3 marked this conversation as resolved.
Show resolved Hide resolved
documentation will focus on a DHT-based approach that implements the content routing
interface: Kad-DHT-libp2p.
{{< /alert >}}