Skip to content

alexbologan/BitTorrent_Protocol_Simulation_using_MPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitTorrent Protocol Simulation using MPI

Overview

This project aims to simulate the BitTorrent protocol, a peer-to-peer (P2P) file-sharing protocol, using MPI (Message Passing Interface). The BitTorrent protocol enables decentralized sharing and downloading of files over the "internet". By dividing files into smaller segments, BitTorrent allows users to simultaneously download and upload segments, optimizing file transfer speeds and reducing dependency on centralized servers.

Project Features

This simulation replicates key components of the BitTorrent protocol:

  1. File Segmentation:

    • Files are divided into fixed-size segments.
    • Each segment is protected by a cryptographic hash for integrity verification (for this simulation we will work just with hashes and as a response we will get an ACK but not the segment itself)
  2. Peer-to-Peer Communication:

    • Peers exchange file segments using MPI-based message passing.
    • Roles (seed, peer) are dynamically assigned based on file availability.
  3. Swarm Coordination:

    • The system mimics the interaction between peers in a swarm to efficiently upload and download file segments.
  4. Tracker Simulation:

    • A central tracker coordinates the initial communication, managing lists of peers and seeds available for each file.
    • After the tracker collected all the data (files and segment hashes for each file owned by each peer), starts a loop that manages requests from any peer, there are 4 types of requests
      1. Request (R)- when the peer need all the information about the file and swarm for the file
      2. Update (U)- when the peer needs to update the swarm
      3. Download (D)- The peer signals to the tracker about finishing downloading the file, tracker marks the client as seed.
      4. Finish (F) - The peer signals that it is done with the downloading part, tracker marks the peer as done.

Efficiency in the Simulation

To make the downloading a little more efficient the client will try to download from a different peer or seed every time. The main idea is that we update our swarm of seeds and peers every 10 downloaded segments.

  • So the first 0 - 5 segments will be downloaded from the peers, cause the segments are lower in the order and the chance that the peers will have the is higher than the other 5 - 10. The other 5 will be downloaded from the seeds.
  • The seeds and peers will be chosen randomly from the given swar
  • If the response is NACK (this will happen just in the peers cases) then the second attempt will be to a seed.

Running the Simulation

Compile and execute the project using MPI commands (in the nr of processes u have to include the tracker and the peers):

  • mpicc -o bit_sim tema2.c
  • mpirun -np [number_of_processes] ./bit_sim

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages