# An Integrated DQN and RF Packet Routing Framework for the V2X Network
## 3 Design of the IDRF System
### Real-Time Phase
#### 3.2.4 Integration of DQN and RF Using the Real-Time Decision Unit  
The dataset employed in this study comprises taxi data. The driving characteristics of taxis can vary due to unpredictable passenger destinations. As mentioned above, RF is used to determine the intersection of vehicles, while DQN determines the shortest end-to-end delay forwarding route. In real-time scenarios, vehicles with insufficient data and new vehicles may appear, and it may be challenging to make instantaneous decisions solely using RF or DQN due to the presence of untrained data. In the IDRF, the real-time vehicle decision unit integrates DQN and RF to address the abovementioned question. As illustrated in Figure 16, for the source vehicle to relay packets to the destination vehicle, relay nodes of M hops are required for packet forwarding. Packet forwarding may occur on either road segments or intersections. During the forwarding of packets on road segments, the vehicles with DQN-predicted results and the real-time new vehicles that DQN has not trained must be considered to determine the best relay vehicle with the shortest delay. When forwarding packets at intersections, the travel directions of vehicles, predicted results from DQN, and real-time vehicles must be considered concurrently. Moreover, the scenario in which the source and destination nodes are real-time vehicles without prior training by DQN must also be considered. The real-time decision unit flow is illustrated in Figure 26.  
1. Determine if the destination vehicle is a real-time new vehicle. If the destination vehicle is not new, DQN is used to determine the shortest path from the source vehicle to the destination vehicle for forwarding. Then, go to step 2. Otherwise, go to step 4. 2. If the destination is a new vehicle, determine whether the destination and packet-carrying vehicles are on the same road segment. If they are, go to step 5. Otherwise, go to step 3. 3. If the destination vehicle and the packet-carrying vehicle are not on the same road segment, temporarily set the upcoming intersection of the destination vehicle as the destination intersection. Figure 25: The flow of DQN routing decisions and exception handling processes. Use DQN to determine the shortest path from the source vehicle to the destination intersection. Then, go to step 6. * Forward the packet to the destination vehicle. Then, go to step 15. * Determine whether packet forwarding occurs on the road segment. If it does, go to step 7; if not, go to step 11. * Determine whether the candidate vehicles forwarding the packet in this hop have real-time new vehicles. If they do, go to step 8; if not, go to step 9. * Classify the vehicle with the largest DQN delay weight at this road segment as the relay node. If there are no real-time new vehicles, there is no need to recalculate the DQN delay weights for all candidate vehicles in that hop. Instead, use the DQN delay weights to determine the optimal forwarding node. * Forward the packet to the selected relay node. Then, go to step 15. * If packet forwarding occurs at an intersection, determine whether real-time new vehicles are in this forwarding hop. If there are real-time new vehicles, go to step 12. Otherwise, go to step 13. * Calculate the DQN delay weights for all vehicles in that hop. * Multiply the DQN delay weight by the RF intersection transfer probability to compute the transfer delay weight. If there are no real-time new vehicles in this forwarding hop, calculate the transfer delay weight using the original DQN delay weight multiplied by the RF intersection transfer probability. * Classify the vehicle with the largest transfer delay weight at this road segment as the relay node. * Determine whether the packet has been forwarded to the destination vehicle. If it has, the flow of the real-time decision unit has finished. If not, return to step 1. Figure 26: The flow of the real-time decision unit in the IDRF.