Skip to content

Luco1421/sternap

 
 

Repository files navigation

sternap

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.

How it works

  • 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 shares
    • POST /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.

Stack

  • 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

Building and running

The CMake target only builds the tracker server:

cmake -S . -B build
cmake --build build
./build/sternap

The 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
./peer

The 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).

Report

prueba.pdf / prueba.tex is the course write-up describing the design: tracker architecture, the two content-hashing functions, and the chunked download protocol.

Credits

Team project for Principios de Sistemas Operativos at Tecnológico de Costa Rica, by Alejandro Cerdas, Kener Castillo, and Pablo Pérez (Luco1421).

License

MIT — see LICENSE.

About

Simulated peer-to-peer file-sharing network with a central tracker, in C++ with CMake.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages