Peer-to-Peer (P2P) Networking


How to use the slides - Full screen (new tab)
Slides Content
--- title: Peer-to-Peer (P2P) Networking description: Peer-to-Peer (P2P) networking for web3 builders ---

Peer-to-Peer Networking


Introduction/Agenda

  • History of p2p networks
  • Discuss the network layer and network conditions that blockchains operate on(Mostly)
  • Talk about traditional web2 network overlays pros vs cons with web3 network overlays
  • Discuss attacks and how to address along with the underlying threat model

ARPANET

  • First operational packet-switching network
  • Developed in the late 1960s by DARPA(The Defense Advanced Research Projects Agency)
  • Laid the foundation for the modern internet

Notes:

Total Information Awareness (TIA): In the early 2000s, DARPA initiated the TIA program aimed at developing technologies for mass surveillance and data analysis. The project raised concerns about privacy and civil liberties, eventually leading to its cancellation in 2003 due to public outcry.


Packet Switching

  • Mode of data transmission in which a message is broken into a number of parts that are sent independently(Packets)
  • Packets are sent over whatever route is optimal
  • Packets are reassembled at the destination

Packet Switching

Notes:

Mention that headers contain some addressing, destination information, and ordering typically depending


Packet Switching


Packet Switching


Packet Switching


Packet Switching


Peer-to-Peer (P2P) Networks

  • P2P is a decentralized form of network structure
  • Unlike client-server model, all nodes (peers) are equal participants
  • Data is shared directly between systems without a central server
  • Peers contribute resources, including bandwidth, storage space, and processing power

Historical P2P applications

Notes:

Napster, Limewire


Napster

  • Launched in 1999, popular P2P platform
  • Central server for indexing, P2P for transfers
  • Shutdown in 2001 due to legal issues

Notes:

Napster's story is closely tied with the band Metallica. In 2000, Metallica discovered that a demo of their song "I Disappear" was being circulated via Napster before its official release. This led to Metallica filing a lawsuit against Napster for copyright infringement. Napster had to comply by banning hundreds of thousands of users from their platform who were sharing Metallica's music. This was a turning point in digital copyright law and played a significant role in Napster's eventual shutdown in 2001.


Napster Setup


Napster Setup


Napster Setup


Napster Setup


Gnutella(Limewire)

  • Each node serves as both a client and a server no central server
  • Query all connected nodes for files
  • Gain peer connections to the network via Bootnodes
  • Ordered to shutdown in 2010 by United States Court

Notes:

  • Check local filestore for file and if it is not available, forward the request to all connected peers.
  • Gnutella generates a significant amount of network traffic by flooding the network with requests.

Client-Server vs Peer-to-Peer (P2P) Networks

Client-Server Network P2P Network
Structure Centralized: One or more central servers control the network Decentralized: All nodes (peers) participate equally
Data Flow Server provides data to clients Peers directly share data with each other
Resource Management Servers manage resources and control access Peers contribute resources including bandwidth, storage space, and processing power
Scalability Can be limited by server capacity Highly scalable due to the distribution of resources
Security Centralized security measures, single point of failure Potential for some security issues, malware(Depending on how it is implemented)

Centralized vs Decentralized Networks

Notes:

Talk about how when a partition happens in P2P vs Centralized. In p2p, only one node needs to have a full copy in order for the file to be able to be distributed across the network.


Centralized vs Decentralized Networks


Centralized vs Decentralized Networks


Centralized vs Decentralized Networks


Advantages to Decentralized Networks

  • No privileged nodes
  • Less bottlenecks with bandwidth
  • DOS resistant
  • No centralized infrastructure necessary (Except internet for now...)

Notes:

  1. No single node or nodes (CDN) have access to all of the content or files or is critical for operating the network. Each node has a copy of the data.
  2. No central node carrying all of the load of traffic. Block production and Block peering/importing can be mentioned here.
  3. Difficult to overload the network or DOS (Not a single node is privileged).
  4. Although many nodes are run on Centralized cloud compute platforms, they don't have to be (Typically).

Difficulties or Disadvantages

  • Since it is permissionless, a node can share malicious resources
  • Latency
  • Difficult to regulate illicit activity
  • The network is limited by nodes with the weakest hardware

Notes:

  1. Latency may be an issue if we need to wait for many peers to receive the data produced from a single node since everyone may not have a direct connection. Mention finality time!
  2. No central point to go and snoop all users data (for better or for worse).
  3. Why we have hardware requirements for blockchain networks.

Gossip Protocol

Notes:

  • Talk about how we have and want block 45 being peered to others

---v

Gossip Protocol

Notes:

Talk about advertising vs just blind sending and how that can be inefficient


Structured vs Unstructured P2P Networks

Structured P2P Networks Unstructured P2P Networks
Organization Nodes are organized following specific protocols and structures (like Distributed Hash Tables) Nodes are connected in an ad-hoc manner without any particular organization
Search Efficiency Efficient search operations due to structured nature Search operations may be less efficient and can involve flooding the network
Flexibility Less flexible as changes in topology require restructuring Highly flexible as nodes can freely join, leave, and reorganize
Privacy Data location is predictable due to structured organization Greater potential for anonymity

Discovery

  1. Connect to a peer
  2. Ask peer for a list of their known nodes
  3. Connect to random subset of peers from the list
  4. Repeat steps 2 and 3

Applications

Notes:

  1. What are some of the types of applications that lend themselves to this kind of network topology? Can anyone think of any?
  2. File sharing(Music)?
  3. Messaging and communication?

Initial Discovery

  • Bootnode/bootnodes (More on this later in Substrate)

Notes:

  1. Must know someone who is participating in the network initially(Bootnode)

Attacks

Notes:

  • Can anyone think of a way to exploit some of these networks?
  • What would be some things to try to take advantage of?

Attacks

Notes:

  1. Distorts view of the healthy normal honest state of the network
  2. Transaction confirmations can be fictions

Attacks


Eclipse Attack Execution

  1. Flood a target node with a bunch of malicious peer addresses
  2. The targeted node then stores these malicious peers and utilizes them when re-syncing on next bootup
  3. DOS targeted node to take it offline to force a resync with these new malicious peers

Preventing Attacks

  • Restrict inbound connections in some way
  • Random selection of peers to connect with
  • Deterministic node selection (Bootnodes)
  • Restricting new nodes (Probably not what we want...)

Notes:

  1. Be wary of new connections with other nodes
  2. Don't just take the most recent request for connections to avoid the flooding
  3. Bootnodes with higher credibility and trust (Can be a bottleneck) - Rotate bootnodes as they are also subject to attacks

Conclusion

P2P networks offer us a path forward towards applications which are more decentralized and censorship resilient