Git Product home page Git Product logo

peer_to_peer_file_sharing_system's Introduction

Bit-Torrent: Peer-to-Peer File Sharing System

Prerequisites

Socket Programming, SHA1 hash, Multi-threading in C++

Goal

In this project, I build a group based file sharing system where users can share, download files from the group they belong to and files are downloaded parallely in multiple pieces from multiple peers.

Approach:

  • File: The file into logical pieces, where the size of each piece is 512KB.
    • Suppose the file size is 1024KB, then it is divide into two pieces of 512KB each
  • Data Integrity: After downloading the complete file, the SHA1 value of the file is calculated and then is checked with the original SHA1 value available on the tracker side to verify the integrity of the file.
  • Authentication: Every user should have an account inorder to download or share the files.

Architecture Overview:

The Following entities will be present in the network:

  1. Server/Tracker : Maintain information of clients with their files(shared by client) to assist the clients for the communication between peers
  2. Clients:
    • User should create an account and register with tracker
    • Login using the user credentials
    • Create Group and hence will become owner of that group<
    • Fetch list of all Groups in server
    • Request to Join Group
    • Leave Group
    • Accept Group join requests (if owner)
    • Share file across group: Share the filename and SHA1 hash of the complete file with the tracker
    • Fetch list of all sharable files in a Group
    • Download file
      • Retrieve peer information from tracker for the file
      • Core Part: Download file from multiple peers (different pieces of file from different peers using piece selection algorithm) simultaneously and all the files which client downloads will be shareable to other users in the same group
    • Show downloads
    • Stop sharing file
    • Stop sharing all files(Logout)
    • Whenever client logins, all previously shared files before logout should automatically be on sharing mode

How to compile project

  1. go to client.cpp
    • g++ client.cpp -o client -lssl -lcrypto -lpthread
  2. go to server.cpp
    • g++ server.cpp -o server -lpthread

How to Run project

To run the Server

./server <my_server_ip> <my_server_port>
eg : ./server 127.0.0.1 5000

To run the Client

./client <CLIENT_IP> <CLIENT_PORT> <SERVER_IP> <SERVER_PORT>
  • creating client1 on new terminal with socket : 127.0.0.1:6000
    eg : ./client 127.0.0.1 6000 127.0.0.1 5000

  • creating client2 on another terminal with socket : 127.0.0.1:7000
    eg : ./client 127.0.0.1 7000 127.0.0.1 5000

Commands available for clients

1. Create User Account :

create_user <user_id> <passwd>

2. Login :

login <user_id> <passwd>

3. Create Group :

create_group <group_id>

4. Join Group :

join_group <group_id>

5. Leave Group :

leave_group <group_id>

6. List Pending Request :

requests list_requests <group_id>

7. Accept Group Joining Request :

accept_request <group_id> <user_id>

8. List All Group In Network :

list_groups

9. List All sharable Files In Group :

list_files <group_id>

10. Upload File :

upload_file <file_path> <group_id>
eg.: upload_file /home/rishabh/F/video.mp4 my_grp

11. Download File :

download_file <group_id> <file_name> <destination_path>
eg.: download_file my_grp video.mp4 /home/rishabh/D/

12. Logout :

logout

13. Show_downloads :

show_downloads

Output format:
[D] [grp_id] filename
[C] [grp_id] filename

D(Downloading), C(Complete)

14. Stop sharing :

stop_share <group_id> <file_name>

Assumption

  • Enter absolute path for files.

peer_to_peer_file_sharing_system's People

Contributors

maneeshguptanvss avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.