A system for creating network topologies, running simulations, and viewing live events.
-
Frontend (
frontend/):- A Next.js application providing the user interface.
- Uses React Flow for the
TopologyEditor. - Displays
RunHistoryandEventLogusing real-time subscriptions to Supabase. - Communicates with the Backend API to submit topologies.
-
Backend (
backend/):- A FastAPI application acting as the service layer.
- Receives topology submissions (
/simulation/topology), creates run records in Supabase, and triggers the simulation process. - Receives simulation events (
/simulation/event) from the simulation listener and stores them in Supabase, updating run statuses.
-
Simulation (
simulation/):- Python scripts designed to run network simulations (e.g., using Mininet).
main.py: Core simulation logic, configured with arun_id.core/: Contains modules likeEventSenderto structure event data.api_listener.py: A Flask listener (or similar) that receives events from the simulation process (stdout/stderr or direct calls) and forwards them to the Backend API's/simulation/eventendpoint.
-
Database (Supabase):
- Cloud-based PostgreSQL database with real-time capabilities.
simulation_runstable: Stores metadata for each simulation run (ID, status, timestamps).simulation_eventstable: Stores events generated during each simulation run, linked bysimulation_run_id.
Prerequisites:
- Node.js (v18 or later recommended)
- Python (v3.9 or later recommended)
pip(Python package installer)- A Supabase account and project.
- VirtualBox (or another VM provider)
- Mininet VM Image (Download the recommended VirtualBox image)
- SSH client (usually built-in on macOS/Linux, available on Windows)
Steps:
-
Clone the repository:
git clone https://github.com/CubeStar1/network-vulnerability-analysis.git cd network-vulnerability-analysis -
Set up the Supabase Database:
- Create a new project in Supabase.
- Open the SQL editor and run scripts from
frontend/lib/supabase/schema.sqlto create the necessary tables.
-
Setup Frontend:
- Navigate to the frontend directory:
cd frontend - Create a
.env.localfile by copying.env.example(if provided) or creating it manually. - Add your Supabase project URL and Anon Key:
NEXT_PUBLIC_SUPABASE_URL=YOUR_SUPABASE_URL NEXT_PUBLIC_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY NEXT_PUBLIC_BACKEND_URL=http://localhost:8000 # Or the IP/port where your backend runs
- Install dependencies:
npm install
- Navigate to the frontend directory:
-
Setup Backend:
- Navigate to the backend directory:
cd ../backend - Create a Python virtual environment (recommended):
python -m venv venv source venv/bin/activate # Linux/macOS # .\venv\Scripts\activate # Windows
- Create a
.envfile. - Add your Supabase project URL and Service Role Key:
SUPABASE_URL=YOUR_SUPABASE_URL SUPABASE_KEY=YOUR_SUPABASE_SERVICE_ROLE_KEY MININET_VM_IP=YOUR_MININET_VM_IP # IP address of your Mininet VM from step 4
- Install dependencies:
pip install -r requirements.txt
- Navigate to the backend directory:
-
Setup Mininet VM:
- Import the downloaded Mininet VM image into VirtualBox.
- Configure Networking:
- Go to the VM's Settings -> Network.
- For Adapter 1, ensure it's Enabled and set "Attached to:" to Bridged Adapter.
- Select the Name of your host machine's active network interface (e.g., Wi-Fi or Ethernet adapter).
- (Optional) You might want to configure a second adapter as NAT for easier internet access from within the VM if needed.
- Start the Mininet VM. Login credentials are typically
mininet/mininet. - Find the VM's IP address on your local network (using the
ip addrcommand in the VM's terminal, look for the address associated with the bridged interface, likelyeth0or similar). - IMPORTANT: Update the
MININET_VM_IPenvironment variable in the backend.envfile with the VM's IP address.
-
Setup Simulation Code (inside the VM):
- Access the VM: It's highly recommended to use SSH to access the VM for easier file management and command execution. You can use VS Code's Remote - SSH extension.
ssh mininet@<VM_IP_ADDRESS> # Default password is 'mininet'
- Clone the repository inside the VM (if you haven't mounted a shared folder):
git clone https://github.com/CubeStar1/network-vulnerability-analysis.git cd network-vulnerability-analysis/simulation - (Optional) Setup Virtual Environment:
# sudo apt update && sudo apt install python3-venv -y # If venv isn't installed python3 -m venv venv source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Configure Backend Endpoint:
- Edit the configuration file:
nano core/config.py(or usevim, or edit via VS Code SSH). - Update
FASTAPI_ENDPOINTto point to the IP address and port where your Backend (FastAPI) service is running. For example, if your backend is running on your host machine at192.168.1.100:8000, set:
FASTAPI_ENDPOINT = "http://192.168.1.100:8000"
- Save the file (Ctrl+X, then Y, then Enter in
nano).
- Edit the configuration file:
- Access the VM: It's highly recommended to use SSH to access the VM for easier file management and command execution. You can use VS Code's Remote - SSH extension.
-
Start the Backend (on your host machine or server):
- Navigate to the
backenddirectory. - Activate the virtual environment.
cd ..- Run:
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
- Navigate to the
-
Start the Frontend (on your host machine):
- Navigate to the
frontenddirectory. - Run:
npm run dev - Access
http://localhost:3000(or your configured port).
- Navigate to the
-
Start the Simulation Listener (inside the Mininet VM via SSH):
- Navigate to the
simulationdirectory within the project folder. - Activate the virtual environment (if used).
- Run:
python api_listener.py - Keep this SSH session open.
- Navigate to the
Workflow:
- Open the frontend (
http://localhost:3000). - Go to the Topology Editor page.
- Design a network topology.
- Click "Submit Topology".
- The frontend sends the topology to the backend.
- The backend creates a
simulation_runsrecord in Supabase and triggers the simulation via theapi_listener.pyrunning in the VM. - The
api_listener.pystartsmain.pywith the assignedrun_id. main.pyruns the Mininet simulation, generating events.- Events are captured/sent by
EventSenderback toapi_listener.py. api_listener.pyPOSTs events to the backend's/simulation/{run_id}/eventendpoint.- The backend saves events to the
simulation_eventstable in Supabase and updates the run status. - The frontend's
RunHistoryandEventLogcomponents update in real-time based on Supabase changes.


