codecrafters-io / build-your-own-x

Master programming by recreating your favorite technologies from scratch.
https://codecrafters.io
302.97k stars 28.42k forks source link

BitTorrent Protocol from scratch (with inline Node.js scripts) #860

Open LiveDuo opened 1 year ago

LiveDuo commented 1 year ago

Main programming language

Node.js / Javascript

Tutorial title

Bittorrent Protocol in 25 minutes

Tutorial URL

https://www.tzionis.com/bittorrent-protocol-in-25-minutes

Category

Ehab-24 commented 1 year ago

I have gone through the article and its a nice little read (8/10 🌟 imho). The article covers DHT Wire protocol, Bittorrent Wire protocol and some other key concepts related to torrent. The inline nodejs scripts are not the cleanest ones but they do help you understand the concepts more clearly.

It would be a nice addition to the repository. 👍

LiveDuo commented 1 year ago

Thanks for reviewing @Ehab-24. If you have any suggestion to improve the article let me know.

ranjansmygit commented 1 year ago

Crucial components are missing. Piece Selection Algorithm should needs to be mentioned in order to explain the Kademilla (DHT). Difference from HTTP could bring the correct posture on the Protocol.

LiveDuo commented 1 year ago

Hey @ranjansmygit, thanks for your feedback.

Crucial components are missing. Piece Selection Algorithm should needs to be mentioned in order to explain the Kademilla (DHT). Difference from HTTP could bring the correct posture on the Protocol.

The "Piece Selection" algorithm is intentionally left out. The goal of the article is to help anyone who wants to get started quickly to get something working and put a lot of effort in minimising the explanations. I know this is a bit controversial but my thinking is that if you have a piece of code that's working and is 100 lines or less you don't need a lot of explanation. As for the "Piece Selection" algorithm my thinking is that if you know details such as what pieces are and the format Bittorrent nodes use to communicate it's easy for you to look it up. I don't have strong opinions about this and it may be good to include it for completeness but the reason it's was left out.

Difference from HTTP could bring the correct posture on the Protocol.

If you mean differences between HTTP and TCP, it might be a good addition. I'd guess most people looking to go into distributed networks might have an understanding of HTTP but some might not be familiar with lower level protocols such as TCP. When I get some time I might put a section that gives a more gentle introduction.