An interactive, educational static web app that visualizes and simulates MAC-layer protocols: CSMA (1-persistent), CSMA/CD, and CSMA/CA.
NetProtoSim provides a deterministic, tick-based simulation and synchronized flowchart visualization to demonstrate how CSMA-family protocols arbitrate access to a shared medium. It's designed for teaching and experimentation — step through ticks, observe state transitions, and inspect flowchart highlights and the event log.
- Three protocol modes: CSMA (1-persistent), CSMA/CD, CSMA/CA
- Deterministic tick engine (manual Step or Play/Pause auto-step)
- 4-node topology:
A(user-controlled) and autonomousB,C,D - Live SVG flowcharts that highlight the flow for the active protocol
- Channel visualizer with Idle / Busy / Collision and an animated frame particle
- Binary exponential backoff and ACK behavior (protocol-dependent, K up to 15)
- Timestamped event log and full Reset
Short file overview:
index.html— App layout, controls, and SVG containers for flowchartscss/styles.css— Styles, variables, and component layoutjs/flowcharts.js— SVG flowchart renderer and highlight API (FC)js/simulation.js— Discrete simulation engine and protocol logic (SIM)js/main.js— UI controller, DOM rendering, and event bindings
The app is intentionally dependency-free — just static HTML/CSS/JS.
Open index.html in any modern browser (no build step required).
Options:
- Double-click
index.htmlon Windows or open it from your browser. - Or serve the folder with a simple static server (handy for Live Server in VS Code):
# from the project root
# serve with Python 3 (optional)
python -m http.server 8000
# then visit http://localhost:8000/- Use the top tabs to switch protocols; the corresponding flowchart and theory panel update.
- Click
Send Frame from Ato make nodeAtransmit (choose destination with the Destination pills). Playtoggles auto-stepping;Stepadvances one tick while paused.Resetclears the simulation and flowchart highlights.- Watch the Event Log for timestamped actions and the channel badge for current channel state.
- The simulation is deterministic per tick, with autonomous nodes B/C/D scheduled via
SIM.scheduleAutoTx(). - Flowchart nodes have stable IDs mapped in
SIM.FC_MAPand are highlighted viaFC.highlight(...). - Node state and UI are synced from
SIMbymain.js'srenderAll().
License: MIT — see the LICENSE file.
The project is published at: