BitTorrent is a miniature implementation of Torrent applications using C++ and its standard network libraries for Unix based Operating systems. This project involves challenges like Socket and Network programming, Muti-Threading, Peer-to-Peer file sharing, Linux Server Programming, Piece-Selection Algorithm for file sharing, OpenSSl libraryfor SHA1 encoding of the file.
Pre-Requisites
- You must have Unix based operating system like MacOS or any version of Linux, if you are using windows make sure you have WSL library installed to run Linux based system software
- You need to have the OpenSSL library installed on your computer. Installing instructions are given at https://zoomadmin.com/HowToInstall/UbuntuPackage/libssl-dev
- I have already provided the compiled files for my software if you are having any problem compiling the original code
- tracker.cpp file is to be launched first
Compile the code yourself using
g++ -pthread -o tracker tracker.cpp
command - Run the tracker file by using
./tracker tracker_ip_port.txt 1
command - peer.cpp file is to be launched now Compile the code yourself using
g++ -pthread -o peer peer.cpp
command - Run the peer file by using
./peer 127.1.1.10 2212 tracker_ip_port.txt 1
You would have to change the IP and PORT manually for every peer - After you have successfully launched the full program you can proceed as per the video tutorial or the steps given in the “Working and Procedure” section of this document.
- The commands to operate the program are listed as follows -
- Create User account
signup “userID” “password”
- Login
login “userID” “password”
- Create Group
create_group “groupID”
- Join Group
join_group “groupID”
- Leave Group
leave_group “groupID”
- Pending request list
list_request “groupID”
- Accept join request of a peer
accept_request “groupID” “userID”
- List all the groups present in tracker
list_group
- List all the files present to download
list_file “groupID”
- Upload File
upload_file “FilePath” “groupID”
- Download File
download_file “groupID” “FileName” “DestinationPathWithNewFileNameAtEnd”
- Logout
logout
- Stop Share of File
stop_share “groupID” “fileName”
- This program basically, allows you to share files between peers/users without involving any use of a server in between. To share a file first you need to create an account, login to that account, create a group and accept requests of other peers to join that particular group.
- After you have more than one member in your group, any one of the peers can upload the file, whose information is sent to the tracker, the rest of the peers can approve if they have the same file and become a2 seeder of the file. If some other peer of the group wants to download the file, a request is sent to the tracker to give the file details and details of the seeders of the file.
- The size of the file to be shared is divided into blocks of 512KB and these blocks are shared from seeders of the file to the peer requesting the file. Equal number of pieces are downloaded from all the peers and these chunks of files are finally reassembled into the original file that was to be shared.
- At the end, after downloading is completed, the peers start listening to the connections again, for more requests of file sharing.