Skip to content

ViserionBuild/bit_torrent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BitTorrent Implementation

A peer-to-peer file sharing application implementing the BitTorrent protocol in C++.

Overview

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.

Project Structure

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

Quick Start

Prerequisites

  • C++ compiler (GCC/Clang) with C++11 support
  • Make build tool
  • POSIX Threads library
  • OpenSSL library (for crypto functions)
  • readline library

Installation

  1. Clone the repository:
git clone https://github.com/viserion999/bit_torrent.git
cd bit_torrent/solution
  1. Build the tracker:
cd tracker
make
  1. Build the client:
cd ../client
make

Running

  1. Start the tracker server:
cd tracker
./tracker ../tracker_info.txt 101
  1. Start client(s) in separate terminals:
cd client
./client 127.0.0.1:6000 ../tracker_info.txt

Key Features

  • 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

Architecture

Tracker Server

  • 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

Client/Peer

  • 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

Usage

Client Commands

Once connected, clients can use these commands:

  • create_user <user_id> <password> - Register a new user
  • login <user_id> <password> - Login to the system
  • create_group <group_id> - Create a new sharing group
  • join_group <group_id> - Join an existing group
  • leave_group <group_id> - Leave a group
  • list_groups - Show all available groups
  • share_file <file_path> <group_id> - Share a file with a group
  • list_files <group_id> - Show files available in a group
  • download_file <group_id> <file_name> <dest_path> - Download a file
  • logout - Logout from the system
  • quit - Exit the client

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors