# VAE-Based Real-Time Anomaly Detection Approach for Enhanced V2X Communication Security
## 4 Experimental Setup and Results
### Dataset Collection and Experiment Setup  
To evaluate our proposed model for V2X communication security, we first utilized a simulation environment created using the Simulation of Urban Mobility (SUMO) tool to generate the normal dataset. SUMO [33] is a widely recognized, open-source traffic simulation suite designed to model large road networks and generate realistic vehicle  
Figure 2: Our VAE Architecture. movement patterns. It provides a detailed, microscopic simulation of individual vehicle behaviors, making it well-suited for research on V2X communication. The road network for a selected region of Gangnam, Seoul, was obtained from OpenStreetMap (OSM) data and converted into a SUMO-compatible format using the NETCONVERT tool. Initial traffic demand, resulting in over 680 unique vehicles during the 1000 s simulation period, was generated using SUMO's capabilities for creating trips based on the imported OSM network. Parameters such as 'Through Traffic Factor' set to 5 for cars and vehicle 'Count' set to 12 for initial car departures were used to influence the trip generation process, aiming to simulate typical urban traffic flow and density variations. The simulation included a default mix of passenger car vehicle types. The primary data collector vehicle, V\({}_{0}\), was manually assigned a specific, recurring route within the selected map area using SUMO's NETEDIT tool. This ensured V\({}_{0}\) remained active and collected data consistently throughout the simulation period within the boundaries of the Gangnam district map. While this simulation utilized a single collector vehicle (V\({}_{0}\)) to systematically gather BSM data for evaluating the proposed anomaly detection model, the framework itself is designed to process incoming BSM streams. As such, it can be deployed on individual vehicles that process data received from their peers or on RSUs that aggregate data from multiple vehicles in the vicinity. The SUMO simulation initially produced Floating Car Data (FCD) [34] for all vehicles active in the scenario. The FCD output included Vehicle ID, X and Y positions, Vehicle type, Speed, Position on the lane, Heading angle, and Acceleration parameters for each vehicle. To simulate the BSM collection process by V\({}_{0}\), a post-processing step was implemented. This involved filtering the comprehensive FCD output: for each 0.1 s time step, only data from vehicles located within the 500 m [35] communication range of V\({}_{0}\)'s current position was retained. For our simulation, this 500 m value was used to define the data collection radius for V\({}_{0}\), with the understanding that the anomaly detection itself processes the content of successfully received messages. From this subset, only the essential BSM attributes--X and Y positions, Speed, and Acceleration--were extracted to form the raw dataset for our anomaly detection model. After filtering, the dataset was divided into training and testing sets. The data was split, with 90% allocated for training the model and the remaining 10% reserved for testing. To evaluate the model's capability in detecting anomalies, the test set was manually injected with various types of anomalies to simulate potential security threats and data abnormalities in V2X communications [7]. The experiments were conducted on Google Colab, utilizing its free GPU resources to ensure computational efficiency. The proposed VAE with CNN layers was implemented using the PyTorch 2.x framework on Google Colab [36], leveraging its NVIDIA Tesla T4 GPU with 16 GB of VRAM to ensure efficient computation and training. The training data consisted of a simulated Basic Safety Message dataset generated using the SUMO tool and preprocessed as described in Section 3.2, Steps 1 and 2. A set of carefully chosen hyperparameters was used to balance training stability and detection performance during model training. The learning rate was set to 0.001 and optimized using the Adam optimizer with a weight decay of \(10^{-3}\) to avoid overfitting [37].