This is my C++ solutions to the "Build Your Own BitTorrent" Challenge.
In this challenge, I built a BitTorrent client that's capable of parsing a .torrent file and downloading a file from a peer. I also learnt about how torrent files are structured, HTTP trackers, BitTorrent’s Peer Protocol, pipelining and more.
Note: Head over to codecrafters.io to try the challenge.
To test this client, you will have to seed a file using a thrid-party app like uTorrent, then get its .torrent
metafile from that app. Put the metafile in the src
directory to execute the commands
-
Clone the repository:
git clone https://github.com/lavanderhoney/codecrafters-bittorrent-cpp.git
-
Navigate to the project directory:
cd codecrafters-bittorrent-cpp
-
Build the project using cmake:
cmake . make
The client supports several commands:
-
decode: Decodes bencoded data
./your_bittorrent decode <encoded_value>
-
info: Displays torrent metadata information
./your_bittorrent info <torrent_file>
-
peers: Lists available peers
./your_bittorrent peers <torrent_file>
-
handshake: Tests peer handshake protocol
./your_bittorrent handshake <torrent_file> <peer_ip>:<peer_port>
-
download_piece: Downloads specific pieces
./your_bittorrent download_piece -o <output_filename> <torrent_filename> <index>
-
download: Downloads complete files
./your_bittorrent download -o <output_filename> <torrent_filename>