chapter eleven

11 Building a P2P node with Async Rust

 

This chapter covers

  • Introduction to peer-to-peer networks
  • Understanding the core architecture of libp2p networking
  • Exchanging ping commands between peer nodes
  • Discovering peers in a p2p network

In the previous chapter we covered the basics of async programming in general, and how to write async code with Rust. In this chapter we’ll build a few simple examples of p2p applications using a low-level P2P networking library and asynchronous programming using Rust.

But why learn about P2P?

P2P is a networking technology that enables sharing of various computing resources such as CPU, network bandwidth and storage across different computers. P2P is today a very commonly used method for sharing files (such as music, images and other digital media) between users online. Bittorrent and Gnutella are examples of popular file sharing p2p apps. They do not rely on a central server or an intermediary to connect multiple clients. And most importantly, they make use of users' computers as both clients and servers, thus offloading computations away from a central server. How do p2p networks operate and how are they different?

Let’s delve into the foundational concepts behind peer-to-peer networks.

11.1 Introduction to peer-to-peer networks

11.2 Understanding the core architecture of libp2p networking

11.2.1 Peer ids and Key Pairs

11.2.2 Multiaddresses

11.2.3 Swarm and network behaviour

11.3 Exchanging ping commands between peer nodes

11.4 Discovering peers

11.5 Summary

11.6 References