# An Integrated DQN and RF Packet Routing Framework for the V2X Network
## 3 Design of the IDRF System
### Real-Time Phase
\[d=\sqrt{{D_{xij}}^{2}+{D_{yij}}^{2}}\leq r \tag{7}\]  
\[\sqrt{\left(f+eT\right)^{2}+\left(h+gT\right)^{2}}<r,\]  
\[\left(e^{2}+g^{2}\right)T^{2}+2(ef+gh)T+\left(f^{2}+h^{2}-r^{2}\right)\leq 0, \tag{8}\]  
\[T\leq\frac{-\left(ef+gh\right)+\sqrt{\left(e^{2}+g^{2}\right)r^{2}-\left(eh- gf\right)^{2}}}{\left(e^{2}+g^{2}\right)}\]  
However, since vehicles do not always travel at a constant speed, the abovementioned equation was modified to incorporate the calculation of the average vehicle acceleration. Assuming vehicle \(V_{i}\) has speed \(speed_{i_{t}}\) at time \(t\) and speed \(speed_{i_{t-1}}\) at time \(t-1\), the acceleration \(a_{t}\) is obtained by dividing the velocity change \(\left(speed_{i_{t}}-speed_{i_{t-1}}\right)\) by the time interval \(\left(t-\left(t-1\right)\right)\). Hence, differences in position along the \(X\)-axis and \(Y\)-axis after the packet transmission time \(T\) from the initial location are modified to \(D_{xij}=\left(X_{j}-X_{i}\right)+\sum_{t=1}^{T}(\left(V_{j_{t}}+a_{t}\right) cos\theta_{j}-\left(V_{i_{t}}+a_{t}\right)cos\theta_{i}))\), and \(D_{yij}=\left(Y_{j}-Y_{i}\right)+\sum_{t=1}^{T}\left(\left(V_{j_{t}}+a_{t} \right)sin\theta_{j}-\left(V_{i_{t}}+a_{t}\right)sin\theta_{i})\right)\), respectively. Figure 19: Road segment tables record all vehicles’ arrival times at the following intersections. Next, the analysis unit calculates the vehicle's connection stability for the road segment where the vehicle \(v_{carry}\) is located. If both \(v_{carry}\) and the vehicles in that segment cannot transmit packets completely, the vehicles at the intersection where \(v_{carry}\) arrives that can be selected for relaying should be determined. We define the time at which vehicles enter each other's communication radii as the \(Encounter\)\(Time\). The maximum time taken for vehicles to establish a connection is defined as the \(Transfer\)\(Time\). The communication radius between two vehicles is set as \(R\). Considering the moving directions of vehicles, we explain this concept in two categories: in the same and opposite directions. 1. Same direction: * As \(v_{carry}\) and the relay vehicle are driving in the same direction and 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 larger 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 vehicles are within each other's communication radii, \(Encounter\)\(Time=0\) and \(Transfer\)\(Time=\frac{VD}{VS}\). In this case, the \(Transfer\)\(Time\) is the time spent by the two vehicles moving from their current positions to the position at which they meet because they are approaching each other. * As \(v_{carry}\) and the relay vehicle drive in the same direction but gradually move apart, 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 and will not meet again, \(Encounter\)\(Time=\infty\) and \(Transfer\)\(Time=0\). When \(VD\) is less than or equal to \(R\), indicating that the two vehicles are within each other's communication radii, \(Encounter\)\(Time=0\) and \(Transfer\)\(Time=\frac{R-VD}{VS}\). In this case, the \(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. 2.