PeerWire is a distributed file sharing system implemented in C++. It eliminates reliance on a single server by allowing peers to both download and upload file chunks concurrently.
The system follows a tracker-based architecture. Peers register themselves and discover other peers sharing the same file. Each file is divided into fixed-size chunks, and each chunk is verified using cryptographic hashes (SHA-256) to ensure data integrity.
- Decentralized file transfer (P2P)
- Tracker-based peer discovery
- Parallel chunk downloading
- Cryptographic data verification
- Cross-platform support (Windows/Linux)
- C++17 compliant compiler
- CMake 3.10 or higher
You can use the provided Makefile or scripts:
# Using Make
make
# Using Script
scripts/build.shThe executables (tracker and peer) will be placed in build/bin.
Convenience scripts are in the scripts/ directory:
scripts/run_tracker.sh: Starts the Tracker.scripts/run_daemon.sh: Starts the Daemon.scripts/tui.sh: Starts the TUI Client.
See the scripts/ directory for run scripts.
- Enter your listening port (e.g.,
9001) when prompted. - Default tracker is
127.0.0.1:8080. Usetracker <IP> <Port>to change it. - Use commands:
seed <file>download <hash> <outfile>help
The tracker coordinates peers.
./build/bin/trackerTo share a file, start a peer in seed mode.
./build/bin/peer <MyPort> <TrackerIP> <TrackerPort> seed <FilePath>Example:
./build/bin/peer 9001 127.0.0.1 8080 seed mydata.txtTo download a file, start a peer in download mode using the file hash obtained from the seeder.
./build/bin/peer <MyPort> <TrackerIP> <TrackerPort> download <FileHash> <OutputFileName>Example:
./build/bin/peer 9002 127.0.0.1 8080 download a1b2c3... downloaded_data.txtSee the docs/ directory for detailed information:
docs/architecture.md: System design and components.docs/protocol.md: Communication protocol specification.
The project includes unit tests for core utilities (SHA256).
./build/bin/unit_testsA Python script is provided to verify the full flow (Tracker + Seeder + Downloader).
python run_tests.pyNote: This script requires Python 3 and builds the project automatically if needed. test change