# An Integrated DQN and RF Packet Routing Framework for the V2X Network
## 3 Design of the IDRF System
### Real-Time Phase  
2.1 Calculating the Vehicle's Arrival Time at the Next Intersection Based on Vehicle Information by the Analysis Unit of the RSU  
A DRL training unit can determine the optimal end-to-end delay path using the vehicle's trajectory. Trajectories with insufficient data are excluded from the training process during the offline phase. As depicted in Figure 16, some paths lack intermediary nodes. Hence, untrained vehicle trajectories can be added to determine whether a new route can be formed in the real-time phase. The following sections delve into the detailed calculation of real-time vehicle information. Vehicles periodically transmit information to RSUs, which are responsible for the calculations. We define vehicle information as \(v_{i_{T}}=\{send_{i},speed_{i},angle_{i},lat_{i},lon_{i}\}\). Assuming that vehicle \(V_{i}\) is on the road, its trajectory \(V_{i_{T}}\) and \(angle_{i}\) indicate that it is moving towards intersection \(I_{x}\). By using the longitudes and latitudes of vehicle trajectory \(V_{i_{T}}\) and intersection \(I_{x}\), the distance between them can be calculated. Furthermore, the vehicle's speed enables the estimation of its arrival time \(I_{x_{T}}\) at the intersection, as shown in Figures 17 and 18. For all vehicles, the analysis unit calculates arrival times at the intersection. It is assumed that the road segment \(S_{1}\) is composed of intersections 4 and 5. There are five vehicles within road segment \(S_{1}\). After transmitting their information to the RSU, the RSU analysis unit calculates their arrival times. The consolidation of vehicle information on the same segment yields a road segment table for each road segment across all intersections. The road segment table includes the Arrival Time to Next Intersection, Vehicle Direction, and Next Intersection fields. This process obtains arrival time data for all segments, as shown in Figure 19. Each RSU records information related to the road segments it covers. 2.2 Estimation of the Minimum Packet Propagation Delay for a Road Segment Using the Vehicle Connection Stability, Road Segment, and Intersection Tables  
Due to the high mobility of vehicles, the maintenance of consistent connectivity is often challenging. Therefore, it is necessary to determine whether the connection time between two vehicles is sufficient to transmit a complete packet. According to [35; 36], we must first obtain the vehicle speed, moving direction, current location, and transmission range to calculate the available link connection time between two vehicles. Assuming this information is available, the theoretical packet transmission time can be defined as \(T=\frac{Packet\ size}{Transmission\ rate}\). The link connection time between two vehicles must be greater than or equal to the theoretical time \(T\) required to transmit one packet (Figure 20). Differences in positions along the \(X\)-axis and \(Y\)-axis after the packet transmission time \(T\) from the initial location are \(D_{xij}=\left(X_{j}-X_{i}\right)+\left(V_{j}cos\theta_{j}-V_{i}cos\theta_{i}\right)T\) and \(D_{yij}=\left(Y_{j}-Y_{i}\right)+\left(V_{j}cos\theta_{j}-V_{i}cos\theta_{i} \right)T\), respectively. To transmit a complete packet between two vehicles, the distance between two nodes \(d\) after the packet transmission time \(T\) must be smaller than or equal to the transmission range \(r\), formulated by Equation (7). Let \(e=\left(V_{j}cos\theta_{j}-V_{i}cos\theta_{i}\right)\), \(f=\left(X_{j}-X_{i}\right)\), \(g=\left(V_{j}cos\theta_{j}-V_{i}cos\theta_{i}\right)\), \(h=\left(Y_{j}-Y_{i}\right)\). By substituting these values into Equation (5), the packet transmission time \(T\) is constrained by Equation (8).