The original monolithic version3.py file has been refactored into multiple modules based on functionality:
OSMNode: Represents geographic nodes from OSM dataOSMWay: Represents roads/paths in OSM dataVehiclePath: Handles vehicle movement along paths with progress tracking
Key Functions:
get_position_at_progress(): Calculate vehicle position along pathget_direction_at_progress(): Calculate vehicle heading/direction
OSMParser: Static class for parsing OSM XML files
Key Functions:
parse_osm_file(): Parse OSM XML and extract nodes/waysget_bounds(): Calculate geographic boundsconvert_coordinates_to_canvas(): Convert lat/lon to canvas coordinatescreate_vehicle_paths(): Generate vehicle paths from road datacreate_sample_data(): Generate sample data for testing
SimulationEngine: Core simulation logic and calculations
Key Features:
- Application type assignment (File Transfer, IoT Sensing, Voice Call, etc.)
- Bandwidth requirement calculations (traditional and SemCom)
- Vehicle/carriage creation with requirements
- Connection assignment algorithm (priority-based)
- System metrics calculation (throughput, goodput, success ratio)
Key Methods:
calculate_bandwidth_requirement(): Standard BW calculationcalculate_bandwidth_requirement_semcom(): SemCom-aware BW calculationcompute_semantic_comm_delays(): Model compression/compute trade-offsassign_connections(): Priority-based user-to-AP assignmentcalculate_metrics(): Compute performance metrics
CanvasRenderer: Handles all drawing operations
Key Features:
- OSM road network visualization with color-coded road types
- Vehicle rendering with directional arrows
- Train carriage rendering
- Base station and satellite visualization
- Connection line drawing
- Legend creation
- Utilization-based color coding
Key Methods:
draw_osm_roads(): Render road networkdraw_road_vehicle(): Draw vehicle with directiondraw_base_station(): Draw BS tower with utilizationdraw_satellite(): Draw satellite with solar panelsdraw_legend(): Create visualization legend
MetricsLogger: Handles metrics tracking and CSV output
Key Features:
- CSV file management with configurable test numbers
- Metric formatting for display
- Structured logging with headers
Key Methods:
log_metrics(): Append metrics to CSV fileclear_csv(): Reset CSV file with headerformat_metrics_summary(): Format metrics for status display
UIBuilder: Constructs all UI elements
Key Features:
- Tabbed control interface (OSM, Simulation, Logging, SemCom, Map)
- Slider controls for parameters
- Requirement display tables
- Canvas setup with scrollbars
Key Methods:
create_all_widgets(): Main UI construction_create_control_tabs(): Tabbed interface_create_requirements_tree(): User requirement displays_create_canvas_panel(): Simulation visualization area
EnhancedScenarioSimulator: Main application class (extendstk.Tk)
Key Responsibilities:
- Application initialization and coordination
- State management (vehicles, base stations, satellites)
- Simulation loop control
- Integration of all modules
Key Methods:
simulate_scenario(): Start simulationupdate_simulation(): Main simulation loopinitialize_simulation_objects(): Create simulation entitiesredraw_canvas(): Update visualizationupdate_requirement_displays(): Refresh UI tables
main.py
├── models.py
├── osm_parser.py
│ └── models.py
├── simulation_logic.py
│ └── models.py
├── visualization.py
│ └── models.py
├── metrics_logger.py
└── ui_components.py
└── visualization.py
bandwidth_mb_s: max 12.5 MB/s (≈100 Mbps)base_delay_s: 0.001 s (1 ms)compute_capacity_mb_s: 62,500 MB/salpha: 0-1.0 (compression exponent)
- Traditional DT: +(0-50ms) cloud delay
- Multilayer DT: No additional delay
- File Transfer: 50 MB, 10s latency, Priority 1
- IoT Sensing: 0.01 MB, 500ms latency, Priority 1
- Charging Scheduling: 0.5 MB, 1s latency, Priority 1
- Voice Call: 0.1 MB, 150ms latency, Priority 2
- Traffic Planning: 0.5 MB, 150ms latency, Priority 2
- Autonomous Driving: 1.0 MB, 50ms latency, Priority 3
python main.py- OSM Integration: Load real OpenStreetMap data or use sample data
- Dynamic Simulation: Vehicles move along realistic road networks
- Semantic Communication: Model compression vs. compute trade-offs
- Priority-Based Scheduling: Higher priority users get preference
- Real-Time Metrics: Track throughput, goodput, and success ratios
- CSV Logging: Export metrics for analysis
- Interactive Visualization: Pan, zoom, and observe simulation in real-time
- Maintainability: Each module has a clear, focused purpose
- Testability: Individual components can be tested in isolation
- Reusability: Modules can be reused in other projects
- Scalability: Easy to add new features without affecting existing code
- Readability: Smaller files are easier to understand and navigate
- Collaboration: Multiple developers can work on different modules simultaneously