Welcome to the Bittorrent Implementation project! This project aims to guide you through the process of building a simplified Bittorrent client in stages, covering essential functionalities step by step.
Ensure you have go (1.19)
installed locally
Run ./bittorrent.sh
to run your program, which is implemented in
cmd/bittorrent/main.go
.
Bencode is a serialization format used in the BitTorrent protocol. This phase focuses on decoding strings. Here's how to run the program:
$ ./bittorrent.sh decode 5:hello
Extend the decode command to support bencoded integers:
$ ./bittorrent.sh decode i52e
Extend the decode command to support bencoded lists:
$ ./bittorrent.sh decode l5:helloi52ee
Extend the decode command to support bencoded dictionaries:
$ ./bittorrent.sh decode d3:foo3:bar5:helloi52ee
Parse a torrent file and print information about the torrent:
$ ./bittorrent.sh info sample.torrent
Calculate the info hash for a torrent file:
$ ./bittorrent.sh info sample.torrent
Print piece length and piece hashes in hexadecimal format:
$ ./bittorrent.sh info sample.torrent
Make a GET request to a HTTP tracker to discover peers:
$ ./bittorrent.sh peers sample.torrent
Establish a TCP connection with a peer and complete a handshake:
$ ./bittorrent.sh handshake sample.torrent <peer_ip>:<peer_port>
Download one piece and save it to disk:
$ ./bittorrent.sh download_piece -o /tmp/test-piece-0 sample.torrent 0
Download the entire file and save it to disk:
$ ./bittorrent.sh download -o tmp/test.txt sample.torrent
Feel free to explore each phase of the project and expand your understanding of the Bittorrent protocol implementation!