Back

My Experience with Peer to Peer Protocols

A brief background about my experiences with different peer to peer technologies + learnings from building one for Bitping.

Published on

July 22, 2024

Time to Read

Unknown

Figure out a nicer intro here?

Back in the mid-2000s when file sharing was reaching critical mass, Limewire looked like the pinnacle of unrestricted “Peer to Peer” file transmission. Until it was replaced by majority BitTorrent clients such as Frostwire or uTorrent. When Limewire finally was shut down around 2010, it felt like the end of an era.

It became apparent to me that decentralised technologies based on well made protocols such as BitTorrent were going to be the future, not only of file sharing or piracy but of private communications in general. It was around 2012-2014 that I really started delving into P2P technologies and reading the BitTorrent source code and stumbled across Bitcoin.

I think I dismissed Bitcoin at first, not because I didn’t think the technology was cool but I don’t think I truly grasped the phenomenon of digital money. It wasn’t until I read Economics in One Lesson by Henry Hazlitt TODO: Link and make this flow nicer that I really started to understand the benefits and the potential digital cash could bring to the world. Unfortunately, Bitcoin has diverged sharply from Satoshis original promise, but I digress.

Delving into Bitcoin

Satoshis implemention and issues P2P struggles and questionable decisions

Attempts to Merge Bitcoin and Bittorrent WebTorrent, qBittorrent and Synapse

Beginning on Bitping

When Bitping was first implemented, it was just a hub and spoke network built on Websockets in NodeJS and was a far cry from where I actually wanted it to be. Sure Bitping worked great but it was only really tuned for running an uptime testing tool and required a lot of resources on our servers as it scaled up. Not to mention the fact that all traffic was required to go via Bitping’s servers before hitting our nodes. I wanted to reduce as much overhead between the customer and the node operator as possible.

My goal was to eventually allow anyone in the world to connect to this network to earn money without being pigeonholed into just Bitping’s service model. One of the core ideas was the idea of Federation. Businesses who have their own ideas such as hosting a distributed AI model or Bitcoin mining service, etc. should be able to add a Bitping “Hub” and get all the benefits that the P2P network brings without all of the technical knowledge and overhead that building one requires.

Designing Bitping as a peer to peer network

Its actually quite easy to build a Peer to Peer network, but its hard to build a new one

Principles and concepts of building P2P network

  • Symmetric vs Asymmetric
  • Addressing
  • NAT
  • Systems Design
  • Event coordination
  • Scaling

DHTs

Take aways


History

  • Bittorrent
  • Bitcoin
  • BitTorrent + Bitcoin
  • Bitping

Symmetric vs Asymmetric Peers

  • every node is the equal
  • Every node has a different role

Event Sourcing

Peer Exchange

DHTs

  • Kad VS no Kad
  • Kad is overloaded, tries to do too many things at once

Trustless Networking

Hole punching

Libp2p vs Rolling your own

Conclusions