A simple, lightweight BitTorrent client implementation in C++17. This client supports downloading single-file torrents via HTTP trackers.
- Bencoding Parser: Decodes and encodes bencoded data.
- Torrent Parsing: Extracts metadata, announce URLs, and piece hashes from
.torrentfiles. - HTTP Tracker Support: Communicates with trackers to retrieve peer lists.
- Peer Wire Protocol: Implements handshake, bitfield, interested, and piece exchange messages.
- Concurrent Downloading: Connects to peers and downloads pieces (basic sequential/random implementation).
- Integrity Checking: Verifies downloaded pieces against SHA1 hashes.
- C++17 compiler (GCC/Clang)
- CMake 3.10+
libcurl(for HTTP tracker requests)OpenSSL(for SHA1 hashing)
The easiest way to build and run the project is using the included Makefile.
To build and run the client with the default debian.torrent file:
make run- Build:
make build - Clean:
make clean - Run (Manual):
./build/bittorrent <path/to/torrent>
Bencoder: Handles parsing of bencoded data structures.Torrent: Loads and parses the torrent metadata.Tracker: Handles communication with the tracker to get peers.Peer: Manages a TCP connection to a single peer and handles the wire protocol.Client: Orchestrates the download process, managing state and piece verification.
- Only supports single-file torrents.
- Only supports HTTP trackers (no UDP).
- No DHT or Magnet link support.
- Basic single-threaded peer loop (one active peer at a time for simplicity in this version, though architecture supports more).
MIT
