A peer-to-peer file sharing application implementing the BitTorrent protocol in C++.
This project is a simplified implementation of the BitTorrent protocol, featuring a tracker server for peer coordination and client applications for file sharing. It demonstrates core concepts of distributed file sharing including piece-based transfer, multi-peer downloading, and file integrity verification.
bit_torrent/
├── README.md # Project overview (this file)
├── problem/ # Problem statement and resources
│ └── links.txt # Reference links
└── solution/ # Implementation code
├── README.md # Detailed implementation documentation
├── tracker_info.txt # Tracker configuration
├── client/ # Client implementation
│ ├── client.cpp
│ ├── peer_server.cpp
│ ├── utility.h
│ └── Makefile
└── tracker/ # Tracker implementation
├── server.cpp
├── client_handle.cpp
├── utility.cpp
├── utility.h
└── Makefile
- C++ compiler (GCC/Clang) with C++11 support
- Make build tool
- POSIX Threads library
- OpenSSL library (for crypto functions)
- readline library
- Clone the repository:
git clone https://github.com/viserion999/bit_torrent.git
cd bit_torrent/solution- Build the tracker:
cd tracker
make- Build the client:
cd ../client
make- Start the tracker server:
cd tracker
./tracker ../tracker_info.txt 101- Start client(s) in separate terminals:
cd client
./client 127.0.0.1:6000 ../tracker_info.txt- Peer-to-Peer Architecture: Decentralized file sharing between clients
- Tracker Coordination: Central tracker maintains peer lists and file metadata
- Chunk-based Transfer: Files divided into 512KB chunks for efficient distribution
- Multi-peer Downloads: Download different pieces from multiple peers simultaneously
- File Integrity: Hash verification for each chunk to ensure data correctness
- User Authentication: Login/logout system for clients
- Group Management: Organize file sharing within groups
- Concurrent Connections: Multi-threaded architecture for handling multiple transfers
- Maintains database of users, groups, and shared files
- Tracks which peers have which file pieces
- Coordinates peer discovery and connection
- Handles user authentication and group management
- Acts as both client (downloading) and server (uploading)
- Maintains local file storage and metadata
- Connects to tracker for peer discovery
- Establishes direct connections with peers for file transfer
- Verifies chunk integrity using hash verification
Once connected, clients can use these commands:
create_user <user_id> <password>- Register a new userlogin <user_id> <password>- Login to the systemcreate_group <group_id>- Create a new sharing groupjoin_group <group_id>- Join an existing groupleave_group <group_id>- Leave a grouplist_groups- Show all available groupsshare_file <file_path> <group_id>- Share a file with a grouplist_files <group_id>- Show files available in a groupdownload_file <group_id> <file_name> <dest_path>- Download a filelogout- Logout from the systemquit- Exit the client