This is a very simple BitTorrent client that I implemented for fun and to learn more about P2P protocols like BitTorrent. On the way, I learned the following:
- Python's
asyncio
library for asyncronous programming - How to structure a big project
Limitations -
- Only supports downloading a torrent with single file
- Doesn't support seeding
$ pip install -r requirements.txt
$ python cli.py --file C:\Users\chaitanya\Documents\torrents\linuxmint-18-cinnamon-64bit.iso.torrent
The main controller is the TorrentClient
. It is responsible for the following:
- Connecting to
Tracker
and getting the peer information. Created a Queue with peers that workers will consume from. - Starting workers to consume data from the peers
- Using
PieceManager
to manage the torrent piecesPieceManager
is also responsible for devising a stratedy as to which piece to be requested next for a peer
Protocol
implementes the BitTorrent protocol. The unofficial specification can be found here: https://wiki.theory.org/BitTorrentSpecification
Read more about each module in /docs
- Support torrents with multiple files
- Support seeding aka uploading data to other peers
- Improve performance
The client is released under the MIT license, see LICENSE.