# VAE-Based Real-Time Anomaly Detection Approach for Enhanced V2X Communication Security
## 5 Discussion
### Interpretation of Results and the Implications for V2X Security  
Our proposed VAE-CNN model consistently outperformed both a traditional autoencoder and a VAE-LSTM architecture, particularly in detecting complex anomalies such as vehicle speed and position offsets. The superiority of the VAE-CNN can be attributed to several factors. Firstly, the integration of CNN layers enables effective hierarchical feature extraction from the windowed time-series BSM data, capturing localized patterns and spatial relationships within the sequence of observations within a window. Secondly, the  
Figure 4: Reconstruction error distribution comparison between (**a**) our VAE and (**b**) the autoencoder for vehicle targeted speed offset.  
VAE component, with its probabilistic encoder and decoder, learns a robust representation of the normal data distribution. This probabilistic approach, regularized by the KL divergence term, enables the model to generalize more effectively and identify subtle deviations that a deterministic autoencoder might overlook. The VAE-LSTM, while theoretically capable of capturing temporal dependencies, exhibited higher inference times and struggled with certain complex vehicle-targeted anomalies. This suggests that for the specific BSM anomaly detection task with short window sizes, the feature extraction capabilities of the CNN, combined with the VAE's reconstruction fidelity, offer a more efficient and effective solution.  
The very low average inference time of approximately 0.0013 s per sliding window, as shown in Equation (8), is a critical finding that underscores the model's suitability for real-time deployment in latency-sensitive V2X applications. This efficiency, coupled with a training time of around 5 min on the specified hardware, confirms the \"lightweight\" nature of the framework, making it viable for implementation on resource-constrained OBUs or RSUs. The sliding window mechanism is instrumental in this real-time capability, ensuring prompt processing of incoming BSMs.  
The reconstruction error distributions in Figures 3 and 4 visually affirm the model's discriminative power. Our VAE-CNN demonstrated a more precise separation between the reconstruction errors of normal and anomalous samples compared to the VAE-LSTM and traditional autoencoder, particularly for vehicle-targeted offsets. This clear distinction is crucial for setting an effective detection threshold that balances high recall with acceptable precision, as targeted by our 98 th percentile thresholding strategy.  
The high performance achieved by our model indicates its potential to enhance the security of V2X communication significantly. By accurately detecting falsified BSMs in real-time, the system can help prevent the propagation of misleading information that could lead to incorrect decisions by vehicle safety applications or traffic management systems. The framework's design for adaptability through periodic retraining is also vital for long-term reliability in dynamic V2X environments, where normal traffic patterns can evolve due to various factors, such as time of day, weather, or road construction. The inclusion of a subset of historical data during retraining aims to mitigate catastrophic forgetting, allowing the model to adapt without losing previously learned knowledge of normal patterns.