Skip to content

About

Minimal BitTorrent client in C++ with HTTP tracker support and SHA1 piece verification.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

BitTorrent Client in C++

A simple, lightweight BitTorrent client implementation in C++17. This client supports downloading single-file torrents via HTTP trackers.

Features

  • Bencoding Parser: Decodes and encodes bencoded data.
  • Torrent Parsing: Extracts metadata, announce URLs, and piece hashes from .torrent files.
  • 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.

Dependencies

  • C++17 compiler (GCC/Clang)
  • CMake 3.10+
  • libcurl (for HTTP tracker requests)
  • OpenSSL (for SHA1 hashing)

Build and Run Instructions

The easiest way to build and run the project is using the included Makefile.

Quick Start

To build and run the client with the default debian.torrent file:

make run

Manual Commands

  • Build: make build
  • Clean: make clean
  • Run (Manual): ./build/bittorrent <path/to/torrent>

Architecture

  • 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.

Limitations

  • 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).

Screenshot

License

MIT

About

Minimal BitTorrent client in C++ with HTTP tracker support and SHA1 piece verification.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages