Giter Club home page Giter Club logo

likhithagaddi / peer-to-peer-file-sharing-system Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 10 KB

Implemented peer-to-peer multimedia file-sharing network using TCP. Each client can share and downloads multimedia through the custom torrent file from multiple peers via the central tracker. It also supports multithreaded client/server and tracker.

C++ 100.00%
bittorrent tcp socket-programming cpp17 systemcalls multithreading peertopeer sha1-hash

peer-to-peer-file-sharing-system's Introduction

Peer-to-Peer Group Based File Sharing System

In this project, a simple 'BitTorrent' like P2P system for file download has been implemented. Its operation is based around the concept of a torrent file, a centralized tracker and an associated swarm of peers. A user (peer) joins a P2P system by contacting the tracker. Any peer in the network that is registered, can upload files in the network and download files from the network. Peers which are online communicate with each other with the help of tracker. When multiple peers requesting for the same file, the publisher splits the file into chunks and different chunks are sent to each peer, and the peers download the missing chunks from each other, thus both download time and load on the server is reduced. The peers select the chunk to be downloaded using piece selection algorithm. Peers can upload file to another peer as well as download from another peer simultaneously.

Prerequisites

Software Requirement
  1. G++ compiler
    • To install G++ : sudo apt-get install g++
  2. OpenSSL library
    • To install OpenSSL library : sudo apt-get install openssl

Platform: Linux

Compile code

tracker :

g++ tracker.cpp -o tracker -pthread

client :

g++ peer.cpp -o peer -lssl -lcrypto -pthread

Run code

Tracker

./tracker​ <TRACKER INFO FILE> <TRACKER NUMBER>

ex: ./tracker tracker_info.txt

Client
  1. Run code

    `./peer​

    ex: ./peer 127.0.0.1 5000 tracker_info.txt

  2. Create user account:

    create_user​ <user_id>

  3. Login:

    login​ <user_id>

  4. Create Group:

    create_group​ <group_id>

  5. Join Group::

    join_group​ <group_id>

  6. Leave Group:

    leave_group <group_id>:

  7. List pending requests:

    list_requests ​<group_id>

  8. Accept Group Joining Request:

    accept_request​ <group_id> <user_id>

  9. List All Group In Network:

    list_groups

  10. List All sharable Files In Group:

    list_files​ <group_id>

  11. Upload File:

    upload_file​ <file_path> <group_id​>

  12. Download File:​

    download_file​ <group_id> <file_name> <destination_path>

  13. Logout:​

    logout

  14. Show_downloads: ​

    show_downloads

  15. Stop sharing: ​

    stop_share ​<group_id> <file_name>

Working

  • Peers are different instances of the same code client.cpp.
  • Each peer/user should create an account and register with tracker.
  • Login using the user credentials.
  • Tracker maintains information of clients with their files(shared by client) to assist the clients for the communication between peers.
  • User can create Group and the one who created the group would become admin of that group.
  • User can fetch list of all Groups in server.
  • User can join/leave group. Peer should send request in order to join any group.
  • Only group admin can accept group join requests.
  • Upload file across group: Shares the filename and SHA1 hash of the complete file as well as piecewise SHA1 with the tracker.
  • Fetch list of all sharable files in a Group.
  • Download:
    • Retrieve the list of peers sharing that file, from tracker.
    • download file from multiple peers (different pieces of file from different peers - piece selection algorithm ) simultaneously and all the files which client downloads will be shareable to other users in the same group. File integrity is ensured using SHA1 comparison.
  • Piece selection algorithm used:
  • Show downloads.
  • Stop sharing file.
  • Logout - stops sharing all files.
  • Whenever client logins, all previously shared files before logout would automatically be on sharing mode.

Assumptions

  • Only one tracker is implemented and that tracker should always be online.
  • The peer cannot login from different IP addresses.
  • files of size more than 500kb cannot be downloaded properly.
  • File paths can be absolute/relative.

peer-to-peer-file-sharing-system's People

Contributors

likhithagaddi 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.