A small visual simulator for distributed algorithms. This repository contains two front-ends: a legacy Create React App under src/ and a modern Next.js app under app/.
Keep it simple — quick commands below work on Windows PowerShell.
Recommended: pnpm (but npm works).
# install dependencies
pnpm install
# or with npm
npm install- Run the default (legacy) React app (uses
react-scripts):
pnpm start
# or
npm start- Run the Next.js app (modern UI inside
app/):
pnpm exec next dev
# or with npm's npx
npx next devIf ports conflict, run Next on another port:
npx next dev -p 3001Legacy app (react-scripts):
pnpm run build
# or
npm run buildNext.js production build and start:
pnpm exec next build
pnpm exec next start
# or
npx next build; npx next startapp/— Next.js (app-router) source (modern UI)components/— shared UI components used by Next appsrc/— legacy Create React App sourcepublic/— static assets (legacy app index.html)styles/,app/globals.css— global CSS & Tailwind setup
OTA-SimLab is a lightweight, interactive simulator for teaching, experimenting with, and prototyping distributed coordination algorithms. It focuses on visual clarity and quick iteration so you can:
- See how algorithms exchange messages and make decisions in real time.
- Adjust network/clock parameters (latency, message loss, node counts) and observe behavior.
- Collect simple metrics (message count, latency, time-to-complete, fairness) to compare algorithms.
Who it's for
- Students learning distributed systems and concurrency concepts.
- Researchers/engineers prototyping coordination protocols or OTA update strategies.
- Educators who want a simple demo for lectures or labs.
- Built-in algorithm visualizations: token ring, Lamport logical clocks, Ricart-Agrawala, mutex-based and lock-free approaches, observer pattern (see
src/utils/algorithmsfor implementations). - Interactive simulator controls: start, pause, step, reset, adjustable speed, and node management (add/remove nodes).
- Network fault simulation: configurable message delay, packet loss, and node failures to test robustness.
- Real-time metrics panel (charts) showing messages, latency distribution, and algorithm-specific stats.
- Pluggable algorithm architecture: add a new algorithm module and register it in the selector to see it in the UI.
- Two front-ends in one repo: quick CRA-based dev flow (legacy) and an in-progress Next.js UI (modern) for an improved experience.
To add a new algorithm:
- Create a module under
src/utils/algorithms/exporting the algorithm lifecycle (init, onMessage, tick, teardown) following existing files as examples. - Register the algorithm in
src/utils/algorithms/index.jsso it appears inAlgorithmSelector.jsx. - Add UI hooks if the algorithm needs custom controls or metrics. Recharts is used for metric charts (see
src/components/MetricsPanel.jsx).
Data & wiring notes
- The simulator keeps a model of nodes and message queues in
src/hooks/useSimulation.js. - UI components under
src/componentsconsume the simulation state and dispatch control actions.
- Simulation core (state + scheduler) — maintains node states and delivers messages (with simulated delay/loss).
- Algorithms — pure logic modules that react to messages and schedule actions.
- UI — React components (legacy CRA or Next.js) that render nodes, messages and charts.
- Not production-grade networking — it simulates behavior in-memory for visualization and experiments only.
- Some features are duplicated between the legacy and Next.js front-ends; choose one to iterate on for larger refactors.
This repo's package.json includes these scripts (legacy CRA): start, build, test, eject (uses react-scripts).
- If
pnpmisn't installed, usenpm install -g pnpmor run withnpm/npx. - If you see a port-in-use error, change the port (see Next command above) or stop the other server.
- Branch from
dev. - Add tests for new logic where possible.
- Open a PR with a short description and screenshots if the UI changed.