Project for Innopolis University Distributed Network Programming Course with realization of the Peer-to-Peer file sharing system using DHT.
A simple peer-to-peer (P2P) file sharing system implemented in Python, allowing users to share files directly between connected peers without a central server.
- Decentralized Architecture: No central server required - peers communicate directly
- File Sharing: Share and download files from connected peers
- Peer Discovery: Automatically discover other peers on the same network
- Multi-threaded: Handles multiple connections simultaneously
- Simple CLI: Easy-to-use command line interface
- Python 3.6+
- Additional Library
progressto show the progress bar:#Run the following command to download needed library pip install progress
-
Make sure that all Requirements are met.
-
Clone the repository:
git clone https://github.com/WorriedSeat/Peer-to-Peer.git cd Peer-to-Peer
DHT_node.py- code of the DHT-Nodepeer.py- code of the Peer- Folders with the name of peer address IP:PORT (ex: 0.0.0.0:5000) represent the Peer Storage which store all files that Peer have and able to share.
python peer.py [peer_port PORT] [dht_port PORT] [--file NAME]Options:
peer_port: Port of the peerdht_port: Port of the corresponding DHT-Node--file: Name of the file to download. Note! if--filenot stated than the peer able only to send packets
Note! You need to run these commands in the different terminals
python peer.py 5000 6883python peer.py 5001 6884python peer.py 5002 6885 --file image.pngResult A folder '0.0.0.0:5002' will be created in the project directory and the downloaded 'image.png' file will appear in it.
-
Peer Discovery:
- Peers broadcast their presence on the local network
- Maintain a list of known peers
-
File Sharing:
- Each peer shares files from a designated folder
- File lists are exchanged between peers
- Files are transferred directly between peers when requested
-
Network Communication:
- Uses TCP sockets for reliable communication
- Simple custom protocol for commands and file transfers