An interactive educational web application for exploring p-persistent CSMA and Slotted Aloha saturation throughput analysis. Built for EE 597 Wireless Networks at USC.
Live Demo: pcsma-sim.vercel.app
This simulator lets students explore how the p-persistent CSMA protocol achieves higher throughput than Slotted Aloha by exploiting carrier sensing. The key parameter is T/σ (packet duration / idle slot duration):
- T/σ = 1 → Slotted Aloha (no sensing advantage)
- T/σ > 1 → p-CSMA (idle slots are "cheap", throughput improves dramatically)
Students can adjust parameters in real-time and observe how throughput, optimal transmission probabilities, and multi-user fairness boundaries change.
- T/σ slider (1-100) with quick preset buttons and automatic Slotted Aloha / p-CSMA badge
- n slider (2-30 users)
- Throughput vs p curve -- S(p) with optimal p* marker
- Optimal p and S vs n** -- dual-axis plot showing how optimal parameters scale with user count
- 2-User Pareto boundary (probability space) -- p2* vs p1* feasible region
- 2-User throughput region -- S2 vs S1 achievable throughput pairs
- Statistics panel -- p*, S*, slot probabilities, Slotted Aloha 1/e limit comparison
- KaTeX-rendered equations covering:
- Slotted Aloha review (slot probabilities, throughput, optimization)
- p-CSMA protocol (renewal theory, full throughput formula)
- Heterogeneous 2-user analysis (Pareto boundaries)
- Generalization to n users
- 10 multiple-choice questions spanning Slotted Aloha, p-CSMA, and heterogeneous scenarios
- Hints referencing the simulator for guided exploration
- Instant feedback with detailed explanations
- Auto-save to localStorage
- Download results as text file
| Concept | Where to Explore |
|---|---|
| Slotted Aloha throughput limit (1/e) | Set T/sigma=1, increase n, watch S* converge |
| Carrier sensing advantage | Increase T/sigma from 1 to 100, observe S* rise |
| Optimal transmission probability | S vs p curve shows p* moving left as n grows |
| Multi-user fairness | Pareto plots show throughput trade-offs between 2 users |
| Protocol comparison | Toggle T/sigma between 1 and higher values |
- Node.js 18+
git clone https://github.com/ANRGUSC/pcsma-sim.git
cd pcsma-sim
npm installnpm run devOpen http://localhost:5173 in your browser.
npm run build
npm run previewpcsma-sim/
├── src/
│ ├── components/
│ │ ├── ThemeToggle.tsx # Dark/light theme switcher
│ │ ├── ControlPanel.tsx # T/σ and n sliders with presets
│ │ ├── ThroughputVsP.tsx # S vs p curve plot
│ │ ├── OptimalVsN.tsx # p* and S* vs n dual-axis plot
│ │ ├── ParetoP1P2.tsx # 2-user Pareto boundary (p-space)
│ │ ├── ParetoS1S2.tsx # 2-user throughput region (S-space)
│ │ ├── StatsPanel.tsx # Key computed values display
│ │ ├── Theory.tsx # KaTeX equations page
│ │ └── Quiz.tsx # Interactive quiz with solutions
│ ├── utils/
│ │ └── pcsma.ts # All math: throughput, optimization, Pareto
│ ├── App.tsx # Main simulator layout
│ ├── main.tsx # React Router setup
│ └── index.css # Tailwind + theme variables
├── vercel.json # SPA routing for Vercel
├── LICENSE.md # PolyForm Noncommercial 1.0.0
└── README.md
The p-CSMA saturation throughput for n homogeneous users:
S = [n * p * (1-p)^(n-1) * (T/sigma)] / [(1-p)^n + (T/sigma) * (1 - (1-p)^n)]
When T/sigma = 1, this reduces to Slotted Aloha: S = n * p * (1-p)^(n-1)
Optimal p* is found via golden section search on (0, 1) -- efficient and dependency-free.
Probability space: p1 + p2 + p1*p2*(T/sigma - 1) = 1
Throughput space: sqrt(T/sigma) * (1 - S1 - S2) = 2*sqrt(S1*S2)
For Slotted Aloha (T/sigma = 1): sqrt(S1) + sqrt(S2) = 1
- React 19 with TypeScript
- Vite for fast builds
- Tailwind CSS v4 for styling
- Recharts for interactive plots
- KaTeX for LaTeX equation rendering
- React Router for tab navigation
PolyForm Noncommercial License 1.0.0
Bhaskar Krishnamachari, USC March 2026 Developed with Claude Code