A simple BitTorrent client built in Python with a GUI interface for practicing Python and exploring how peer-to-peer (P2P) file sharing works.
Table of Contents
- Introduction
- Features
- Requirements
- Installation
- Usage
- How It Works
- Future Enhancements
- Contributing
- License
Introduction
This project is a Python-based BitTorrent client developed to understand the fundamentals of the BitTorrent protocol. It enables users to connect to peers, perform the BitTorrent handshake, and download pieces of a file through the protocol. The client also comes with a GUI for better interaction.
Features
- Connects to peers and performs BitTorrent handshakes.
- Downloads and saves pieces of a file from multiple peers.
- Displays download progress through a graphical user interface (GUI).
- Error handling for peer connection issues.
Requirements
- Python 3.7 or higher
bencodepyfor reading and decoding torrent filestkinterfor the graphical user interface- Basic knowledge of Python and networking concepts
Installation
-
Clone the repository:
git clone https://github.com/remoomer1408/rtorrent.git cd your-repo-name -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install bencodepy
Usage
-
Run the client:
python gui_client.py
-
Select a
.torrentfile** and start the download process.
How It Works
- Torrent Parsing: The client reads a
.torrentfile usingbencodepyto extract metadata such asinfo_hash, file name, and piece length. - Peer Connection: The client connects to peers using the extracted information and performs the handshake.
- Download: Pieces of the file are requested and downloaded concurrently from different peers using threads.
- Progress Update: A
tkinter-based GUI displays the progress of the download.
Future Enhancements
- Implement support for magnet links.
- Add peer exchange (PEX) for improved peer discovery.
- Enhance the GUI with more detailed statistics and controls.
Contributing Contributions are welcome! If you'd like to contribute, please fork the repository, make your changes, and submit a pull request.
License This project is licensed under the MIT License. See the(LICENSE) file for more details.