## 5 Results
### Experiment #1--Forecast Module Optimization  
After performing the simulations, the average latency, as well as its standard deviation as a function of the number of simulated vehicles, can be seen in Figure 7. These results show that the latency value strongly depends on the number of vehicles and can increase by up to \(\times 10\) if we increase from 1 to 256 vehicles simulated simultaneously, which corroborates the expectations. This increase in latency can be caused by a variety of factors, including communication channel saturation, a decrease in available bandwidth, overlapping communication requests with other devices, and so on. In addition, a summary of the results can be found in Table 3. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Vehicle** & **Distribution (\%)** & **Fuel Type/Electric** \\ \hline Car & 30 & Gasoline \\ Car & 40 & Diesel \\ Car & 20 & Electric \\ Van & 5 & Diesel \\ Bus & 5 & Diesel \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Vehicle distribution and fuel type used. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Number of Vehicles** & **Mean Latency** & **Std Latency** \\ \hline
1 & 1.51 & 0.48 \\
4 & 2.43 & 0.61 \\
16 & 4.85 & 1.05 \\
64 & 6.48 & 1.93 \\
128 & 10.24 & 1.95 \\
256 & 15.63 & 2.12 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Results of latency simulation. The temporal behavior of the latency for a random vehicle in each of the simulated scenarios can be seen in Figure 8a. In this figure, the dependence of the number of AVs on the latency experienced can be seen. Furthermore, it is clear that the greater the number of devices simulated simultaneously, the greater the latency variance (-jitter). This is important when predicting the latency behavior; therefore, this variable of the number of simultaneous AVs is important to consider for the latency prediction module because it influences both the average latency value and its variation. Once we had simulated the behavior of the AVs in OMNeT++ using the Simu5G library and obtained the experienced latency, we had a dataset that could be used to train the latency prediction module. For the division of the dataset, the first 250 s of latencies were used as the training dataset, and the remaining 50 s were left as the test and validation dataset. This division of the dataset can be seen graphically in Figure 8b below. This figure shows the latency behavior for one vehicle in the 4-vehicle scenario, showing the division of the dataset into training (<Message #1000, blue line) and test (\(\geq\)Message #1000, red line). The results of the training and testing can be seen in Figure 9. In it, the Root Mean Square Error (RMSE) [42] metric as a function of the historical latency window size (\(h\) in Figure 4) has been represented. In addition, the results are shown both when the number  
Figure 8: Latency behavior and split: (**a**) Latency temporary evolution for a random vehicle in each simulation group. The legend indicates the number of vehicles simulated simultaneously; (**b**) Example of dataset division. Up to latency sample (message), 1000 was used to form the training dataset, blue line. From the latency sample (message), 1000 was used for the test dataset, red line. Figure 7: Latency vs. Number of vehicles. It represents the mean and standard deviation values for each group. of vehicles parameter was considered (w/nvehs) and when it was not considered (w/o nvehs) as an input parameter to the deep neural network of the latency forecast module. From these results, the optimal size of the historical latency window (_h_) was about 10 samples, since it makes the least error with the smallest window size. Finally, when we considered 10 previous samples for latency prediction at the next time instant, as well as the number of simultaneous vehicles, the mean value and standard deviation of the RMSE results were 0.4551 \(\pm\) 0.0264 in the training set and 0.3702 \(\pm\) 0.0301 in the test dataset.