## 4 Testbed and Experiments
### Experiments  
First, the latency prediction module was optimized. We called it Experiment #1. We did the optimization by simulating a simple 2-lane, traffic light-controlled 60-s cycle intersection with an increasing number of vehicles. This is because it has been shown in previous works [32; 33] that the latency experienced by 5G network devices depends on the number of active devices. Therefore, simulations were performed in the previously described scenario, with 1, 4, 16, 64, 128, and 256 vehicles. Simulations were run 10 times, and the vehicles followed random routes in each simulation, and the communication latency between the vehicle (mrCar in Simu5g) and a 5G base station (gNodeB in Simu5g) was measured. The gNodeB was located at the edge of the intersection, at a height of 20 m. This intersection was controlled by a traditional traffic light system. For the latency calculation, the message exchange described above was implemented in Omnet++, where the base station gNodeB sent the _probe_ message periodically (every 250 ms), and when this message was received by the vehicles, the vehicles responded with a control _request_ message after a random time \(t\) that followed a uniform distribution with a minimum of 0 ms and a maximum of 50 ms, as shown in the previous section. For training the latency predictor module, the gNodeB (acting as IM) was configured to send _probe_ messages every 250 ms. The scenario had a duration of 300 s, and the first 250 s of the simulation were used as the training dataset and the last 50 s as a testing dataset, obtaining an 83%/17% split of the dataset. The forecaster predicts the latency experienced based on previous latencies, i.e., it considers a previous temporal window (\(h\) in Figure 4) \begin{table}
\begin{tabular}{c c c} \hline \hline
**Simulator** & **Parameter** & **Value** \\ \hline \multirow{6}{*}{SUMO} & Simulation step & 0.25 segs \\  & Flow step & 100 veh/h \\  & Min flow & 200 veh/h \\  & Train duration & 5 min/simulation \\  & Test duration & 840 min/simulation \\  & Scenario & 4 branches, 3 lanes/way, and all ways. \\  & Control distance & 100 m \\ \hline \multirow{6}{*}{Simu5G} & Carrier Frequency & 2 GHz \\  & Bandwidth & 20 MHz \\  & IM Tx Power & 40 dBm \\ \cline{1-1}  & IM antenna gain & 12 dB \\ \cline{1-1}  & IM noise figure & 5 dB \\ \cline{1-1}  & AV antenna gain & 3 dB \\ \cline{1-1}  & AV noise figure & 7 dB \\ \cline{1-1}  & Path loss model & 3 GPP TP 36.783 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Summary of Simulator Setup. to forecast the expected future latency behavior. This temporal window was optimized during training to find the optimal window size that obtained the best performance in latency prediction. In addition, since the latency experienced could depend on the number of AVs at the intersection, it was decided to include this feature in the latency forecast. Finally, the latency forecast module included a neural network based on Transformers, with an output of 1 hidden neuron. The output of this network was concatenated with the number of simulated AVs variable and these variables were used as input to a deep neural network composed of 3 Fully Connected (FC) layers, with 64, 16, and 1 neuron in each layer, respectively, with ReLU as activation functions in the hidden layers. The neuron in the last layer is responsible for providing the latency forecast output during the next control interval. A representation of the architecture of the prediction module can be seen in Figure 4.  
Once the latency forecast module was optimized, the AIM5 LA control algorithm could be optimized. The results of this optimization can be seen in the following section. To optimize the AIM5 LA control algorithm, another scenario was developed, namely Experiment #2, consisting of an intersection with an AIM in charge of controlling the vehicles crossing that intersection. The intersection had four 200-m branches (north, east, south, and west), 3 lanes per direction, left turns, straight ahead, and right turns were allowed.