A simulated peer-to-peer file-sharing network with a central tracker, built as the third project for Principios de Sistemas Operativos at Tecnológico de Costa Rica.
- Server (
Server/): a central tracker built with the cpp-httplib HTTP library. It keeps an in-memory index of(hash1, hash2, size) → (peer name, peer IP)for every file registered by connected peers, and exposes:GET /find?file=<name>— substring search over registered filenames (KMP matching)POST /— a peer registers the files it sharesPOST /owners— given a file's hash pair and size, returns the peers that hold it
- Peer (
Peers/): a CLI client. On startup it hashes every file in a chosen local folder with two custom hash functions (a rolling hash and an FNV-1a variant) and registers them with the tracker, then runs its own embedded HTTP server to serve file chunks to other peers. To download a file, it queries/owners, splits the requested file into one chunk per owning peer, fetches all chunks concurrently, retries failed chunks against other owners, and reassembles the result.
There is no DHT and no peer discovery beyond the central tracker — this is a tracker/swarm-style simulation, not a fully decentralized network.
- C++ (server target set to C++14 in CMake; the peer side uses
<filesystem>and<future>, so it needs C++17) - CMake ≥ 3.29 (server build only)
- cpp-httplib v0.18.1 (vendored,
httplib.h), no other external dependencies - POSIX networking (
ifaddrs.h) on the peer side — Linux/WSL, not native Windows
The CMake target only builds the tracker server:
cmake -S . -B build
cmake --build build
./build/sternapThe peer is not wired into CMake and is built manually (Linux/WSL, needs C++17 and pthreads):
g++ -std=c++17 -pthread Peers/MainPeer.cpp -o peer
./peerThe peer prompts interactively for the tracker's IP, a local folder to share,
and a listening port, then offers a menu to request a file (by hash pair) or
find one (by filename substring). The server listens on 0.0.0.0:8080
(hardcoded).
prueba.pdf / prueba.tex is the course write-up describing the design:
tracker architecture, the two content-hashing functions, and the chunked
download protocol.
Team project for Principios de Sistemas Operativos at Tecnológico de Costa Rica, by Alejandro Cerdas, Kener Castillo, and Pablo Pérez (Luco1421).
MIT — see LICENSE.