Simulation platform
The solution provides two simulation modes: a local service for development and a cloud service for automated testing and demos.
Local simulation
The local simulation service is a Python Flask application (services/simulation/simulation_api.py) that runs on the developer’s machine and exposes a REST API on port 5001. The Fleet Manager UI connects to this service to start, stop, and monitor simulations.
How it works:
-
The developer starts the service with
./manage_simulation.sh start. -
The Fleet Manager UI (or a direct API call) sends a POST to
/api/simulation/startwith configuration: number of vehicles, trips per vehicle, city, safety event rate, telemetry mode (MQTT Direct or FWE), and driver selection. -
The service spawns a background thread running
realtime_telemetry_simulator.py. -
For each vehicle, the simulator:
-
Retrieves the vehicle’s IoT certificate from DynamoDB (if using real vehicles).
-
Generates a realistic GPS route for the selected city using waypoints and interpolation.
-
Simulates an ignition ON event (trip start).
-
Publishes telemetry messages every 1-3 seconds with realistic signal values: speed following the route, engine RPM correlated to speed, tire pressure with gradual drift, battery voltage, fuel consumption, and all 75 CAN signals.
-
Randomly injects safety events (hard braking, speeding, harsh cornering) based on the configured safety rate.
-
Randomly injects maintenance conditions (low oil pressure, high engine temp, low tire tread) for maintenance alert testing.
-
After the configured trip duration, simulates an ignition OFF event (trip end).
-
Repeats for the configured number of trips.
-
-
In MQTT Direct mode, the simulator compresses each telemetry JSON with gzip, base64-encodes it, and publishes to
cms/telemetry/{vehicleId}via IoT Core MQTT. -
In FleetWise Edge mode, the simulator:
-
Starts a per-vehicle FWE agent Docker container (
fwe-{vin}). -
Creates virtual CAN bus interfaces (
vcan0,vcan1, etc.) — one per vehicle for isolation. -
Writes CAN frames to the virtual bus using the DBC signal definitions.
-
Injects GPS coordinates through a Unix domain socket.
-
The FWE agent collects signals based on active campaigns and uploads protobuf to IoT Core.
-
Cloud simulation
The cloud simulation service runs on AWS infrastructure, eliminating the need for a local development environment.
Architecture:
-
API Lambda — A Lambda function (
simulation_lambda.py) serves as the orchestrator. It receives simulation requests through API Gateway and manages ECS tasks. -
ECS Cluster — An ECS cluster runs simulation tasks using Fargate (MQTT Direct) or EC2-backed capacity (FleetWise Edge). EC2 instances are t4g.small ARM64 with Amazon Linux 2023 ECS-optimized AMI.
-
Worker Tasks — In MQTT Direct mode, a single Fargate task runs the simulator. In FleetWise Edge mode, two separate EC2-backed tasks run on the same host:
fwe-agent(FleetWise Edge Agent) andfwe-simulator(Python simulator with python-can). Both share virtual CAN interfaces (vcan0, vcan1…) via HOST network mode for per-vehicle isolation. -
DynamoDB — A simulations table tracks task state (running, completed, stopped) with task ARN references.
How it works:
-
The Fleet Manager UI sends a POST to
/api/simulation/start(routed to the Lambda via API Gateway). -
The Lambda builds the simulator command-line arguments from the request configuration.
-
The Lambda calls
ecs:RunTaskto launch ECS tasks:-
In MQTT Direct mode: a single Fargate task (
sim-worker) runs the simulator with network access to IoT Core. -
In FleetWise Edge mode: two separate EC2-backed tasks —
fwe-agent(long-lived, runs the FleetWise Edge Agent binary) andfwe-simulator(per-trip, generates CAN signals on the assigned vcan interface). The Lambda retrieves the vehicle’s IoT certificate from DynamoDB and passes it to the FWE agent container. Each vehicle gets a unique vcan interface (vcan0, vcan1, vcan2…) to prevent cross-contamination.
-
-
The Lambda stores the simulation ID, task ARN, configuration, and status in DynamoDB.
-
The worker task runs autonomously, publishing telemetry to IoT Core.
-
The UI polls
/api/simulation/status/{id}to track progress. The Lambda checks the ECS task status and fetches recent logs from CloudWatch. -
When the simulation completes (all trips finished), the Fargate task exits. The Lambda detects the
STOPPEDstatus on the next poll and marks the simulation ascompleted. -
The UI can stop a simulation early via POST
/api/simulation/stop/{id}, which callsecs:StopTask.
Presets:
The cloud simulation includes built-in presets:
-
Quick Test — 1 vehicle, 1 trip (for smoke testing)
-
Fleet Demo — 5 vehicles, 3 trips each (for demonstrations)
-
Stress Test — 10 vehicles, 5 trips, 50% safety event rate (for load testing)
Forced scenarios:
The API supports flags to force specific maintenance conditions for testing:
-
force_tire_blowout— Simulates sudden tire pressure drop -
force_engine_overheat— Simulates engine temperature spike -
force_battery_critical— Simulates battery voltage drop -
force_brake_failure— Simulates brake wear critical -
force_oil_pressure_low— Simulates oil pressure drop