# An Integrated DQN and RF Packet Routing Framework for the V2X Network
## 3 Design of the IDRF System
### Real-Time Phase
Opposite direction: * As \(v_{carry}\) and the relay vehicle are driving in opposite directions but approaching each other, the speed difference between vehicles \(i\) and \(j\) is defined as \(VS=\left|speed_{i_{t}}+speed_{j_{t}}\right|\). The distance between the two vehicles is described as \(VD=\sqrt{{D_{xij}}^{2}+{D_{yij}}^{2}}\). When \(VD\) is greater than \(R\), indicating that the two vehicles are not within each other's communication radii, \(Encounter\)\(Time=\frac{VD-R}{VS}\) and \(Transfer\)\(Time=0\). When \(VD\) is less than or equal to \(R\), indicating that the two  
Figure 20: Diagram of the estimated vehicle connection stability. vehicles are within each other's communication radii, \(\mathit{Encounter\ Time}=0\) and \(\mathit{Transfer\ Time}=\frac{VD}{VS}\). As \(v_{\mathit{carry}}\) and the relay vehicle drive in opposite directions and gradually move apart, the speed difference between vehicles \(i\) and \(j\) is defined as \(VS=\mathit{speed}_{i_{k}}+\mathit{speed}_{j_{k}}\). The distance between the two vehicles is described as \(VD=\sqrt{D_{xij}^{2}+D_{yij}^{2}}\). When \(VD\) is greater than \(R\), indicating that the two vehicles are not within each other's communication radii and will not meet again, \(\mathit{Encounter\ Time}=\infty\) and \(\mathit{Transfer\ Time}=0\). When \(VD\) is less than or equal to \(R\), indicating that the two vehicles are within each other's communication radii, \(\mathit{Encounter\ Time}=0\) and \(\mathit{Transfer\ Time}=\frac{R-VD}{VS}\). In this case, the \(\mathit{Transfer\ Time}\) is the time spent by the two vehicles moving from their current positions until their distance reaches \(R\) because they gradually move apart. From Figure 19, it is possible to obtain the time at which each vehicle arrives at the next intersection. As stated above, the \(\mathit{Encounter\ Time}\) and \(\mathit{Transfer\ Time}\) can be inferred. However, when the positions at which the two vehicles meet or their distance equal to \(R\) are not located within the road segment at which vehicle \(v_{\mathit{carry}}\) is located, the \(\mathit{Encounter\ Time}\) and \(\mathit{Transfer\ Time}\) must be updated as follows: We define the arrival times of vehicles \(i\) and \(j\) at intersection \(I_{x}\) as \(R_{xi_{T}}\) and \(R_{yi_{T}}\). If the \(\mathit{Encounter\ Time}\) is larger than the minimum value between \(R_{xi_{T}}\) and \(R_{yi_{T}}\), i.e., \(\min\Bigl{\{}R_{xi_{T}},R_{yi_{T}}\Bigr{\}}\), the \(\mathit{Encounter\ Time}\) is modified to \(\infty\). If the \(\mathit{Transfer\ Time}\) is larger than \(\min\Bigl{\{}R_{xi_{T}},R_{yi_{T}}\Bigr{\}}\), the \(\mathit{Transfer\ Time}\) is modified to \(\min\Bigl{\{}R_{xi_{T}},R_{yi_{T}}\Bigr{\}}-\mathit{Encounter\ Time}\). As illustrated in Figure 21, road segment \(S_{1}\) is composed of intersections 4 and 5, and the communication radius is \(R=300\ M\) meters. There are five vehicles within road segment \(S_{1}\). \(v_{\mathit{carry}}\) is denoted as \(V_{1}\). The \(VS\) and \(VD\) between \(V_{1}\) and \(V_{5}\) are 400 M and 30 km/h, respectively. Hence, the \(\mathit{Encounter\ Time}\) is \(\frac{400\ M-300\ M}{30\ km/h}=\frac{100\ M}{30\ km/h}\cong 12\) s. Upon transmitting vehicle information to the RSU, the analysis unit of the RSU is responsible for calculating the estimated vehicle link stability within road segment \(S_{1}\), resulting in the estimation of the vehicular connection stability between \(v_{\mathit{carry}}\) and all vehicles on road segment \(S_{1}\). Figure 22 depicts the addition of vehicle connection stability to the road segment table, as shown in Figure 19. The time spent by \(V_{1}\) and \(V_{5}\) moving from their current positions to the position at which they meet and that spent by \(V_{1}\) and \(V_{5}\) moving from their current positions until their distance reaches \(R\) are \(\frac{300\ M}{30\ km/h}=\frac{300\ M}{30\ km/h}\cong 36\) s and \(\frac{300\ M-0\ M}{30\ km/h}=\frac{300\ M}{30\ km/h}\cong 36\) s, respectively.