This repository contains a Python simulation framework for evaluating multi-hop collective perception in Vehicular Ad-hoc Networks (VANETs). The simulation replicates the research presented in the paper "An Application Layer Multi-Hop Collective Perception Service for Vehicular Adhoc Networks" by Wolff et al.
This simulation evaluates different forwarding algorithms for the Collective Perception Service (CPS) in VANETs, with a focus on improving environmental awareness in scenarios with low market penetration rates. The simulation includes:
- A realistic Manhattan grid environment with buildings and roads
- Vehicle movement simulation with realistic parameters
- Implementation of two CPS modes:
- Standard ETSI CPS (no forwarding)
- Application layer multi-hop forwarding (proposed algorithm)
- Metrics collection for:
- Environmental Awareness Ratio (EAR)
- Channel Busy Ratio (CBR)
- Age of Information (AOI)
- CPM message sizes
- Python 3.8+ (tested on 3.9 and 3.12)
- NumPy
- Pandas
- Matplotlib
- Seaborn
- tqdm
# Clone the repository
git clone git@github.com:comejv/cps_multihop.git
cd cps_multihop
# Create a virtual environment (optional but recommended)
python -m venv .venv
source .venv/bin/activate # On Windows, use: .venv\Scripts\activate
# Install the required packages
pip install -r requirements.txt
vanet-collective-perception/
├── algenum.py # Enumerations for algorithms
├── environment.py # Manhattan grid environment
├── log_config.py # Logging configuration
├── main.py # Main simulation runner
├── metrics.py # Metrics collection and analysis
├── network.py # Wireless network simulation
├── simulation.py # Core simulation logic
├── vehicle.py # Vehicle class with CPS implementation
├── utils.py # Utility functions
├── results/ # Directory for simulation results
│ ├── csvs/ # CSV result files
│ └── plots/ # Generated plots
└── logs/ # Simulation logs
python main.py
This will run the full simulation with default parameters matching those used in the Wolff et al. paper.
Note
Default configuration will use as many threads as there are cores in your CPU. To change this use the option --threads N
.
python main.py --quick
Runs a shorter simulation with fewer configurations for testing purposes.
python main.py --visualize
Enables real-time visualization of the simulation.
Warning
When using real time visualization it is recommended to run only one thread with the option --threads 1
.
-h, --help show this help message and exit
--visualize Visualize the simulation
--quick Run a quick test with fewer configurations
--load-csv LOAD_CSV Load results from CSV file instead of running simulations
--experiment-tag EXPERIMENT_TAG
Optional tag to add to output filenames
--exit-on-first Exit after first simulation
--threads THREADS Set the number of available threads for the simulations
--num-runs NUM_RUNS Choose the number of runs per configuration
--console-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Console logging level
--file-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
File logging level
--log-dir LOG_DIR Directory for log files
--log-components {simulation,environment,vehicle,network,metrics} [{simulation,environment,vehicle,network,metrics} ...]
Set specific components to DEBUG level
- NO_FORWARDING: Baseline ETSI CPS implementation without any forwarding mechanism.
- MULTI_HOP: Application layer multi-hop forwarding as proposed in the Wolff et al. paper.
The simulation generates:
- CSV files with all metrics data
- Box plots comparing Environmental Awareness Ratio (EAR) for different algorithms
- Channel Busy Ratio (CBR) analysis
- Age of Information (AOI) cumulative distribution function plots
- CPM message size comparisons
To add a new forwarding algorithm:
- Add a new enum value in
algenum.py
- Implement the algorithm logic in
vehicle.py
within therun_cps_algorithm
method
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this code for academic research, please cite both the original paper and this implementation:
V. A. Wolff, E. Xhoxhi and F. Tautz, "An Application Layer Multi-Hop Collective Perception Service for Vehicular Adhoc Networks," 2024 IEEE Intelligent Vehicles Symposium (IV), Jeju Island, Korea, Republic of, 2024, pp. 1847-1852, doi: 10.1109/IV55156.2024.10588398.
VINCENT, Côme. (2024). VANET Multi-Hop Collective Perception Simulation. https://github.com/comejv/cps_multihop
Caution
This is an independent implementation aimed at replicating the results presented in the Wolff et al. paper. It is not affiliated with or endorsed by the original authors.
This simulation framework is based on the research presented by Wolff et al. in their paper "An Application Layer Multi-Hop Collective Perception Service for Vehicular Adhoc Networks".