# A Deep-Learning-Based Secure Routing Protocol to Avoid Blackhole Attacks in VANETs +
## 3 System Model
### The Proposed DLSR Protocol
#### 3.3.2 Route Reply Process  
Following the route request process, in this sub-subsection, we explain in detail the RREP process of the proposed DLSR protocol, as follows:  
* **Step 5: Destination Generates and Sends RREP Packet** Once the destination node receives the RREQ packet, it records the sender's ID, updates the routing table, and an RREP packet with an updated destination sequence number is generated. It unicasts the RREP packet to the previous node using the reverse path. The RREP packet contains the following fields: \[\langle\texttt{Type},\texttt{D}_{\texttt{ID}},\texttt{S}_{\texttt{ID}}, \texttt{D}_{\tt seq},\texttt{E},\texttt{Pos},\texttt{H},\texttt{F}\rangle\] where Type represents the packet type, \(\texttt{D}_{\texttt{ID}}\) represents the destination node ID, \(S_{\texttt{ID}}\) represents the source node ID, \(D_{\tt seq}\) represents the destination sequence, E is the remaining energy, Pos represents the node position \((x_{i},y_{i})\), H is a hop count, and F is a fitness function, respectively. Then, go to **Step 6**. * **Step 6: Intermediate Node Operation at GW for RREP** GW\({}_{\rm i}\) records the sender's ID and updates the routing table when it receives the RREP packet. Then, GW\({}_{\rm i}\) forwards the RREP packet to the previous node by using unicast and increasing the number of hop counts, then goes to **Step 7**. Otherwise, it waits until it receives the RREP packet. * **Step 7: Intermediate Node Operation at CH for RREP*
* When CH\({}_{\rm i}\) receives the RREP packets, it checks whether the route information received is from a blackhole node or not. The process can be summarized as follows:
* **Step 7.1:*
* If CH\({}_{\rm i}\) receives the RREP packet more than once, then go to **Step 7.2**. Otherwise, go to **Step 7.6**. * **Step 7.2:** Classify the RREP packet received by using the DNN model that is elaborated in detail in the forthcoming Section 4.2. This model is used to identify any suspicious behavior of a node. If no blackhole node is detected, go to **Step 7.3**. Otherwise, go to **Step 7.4**. **Step 7.3:** If the packet is not from a blackhole node, calculate the fitness function for normal routing (without penalty for blackhole nodes). The fitness function can be expressed as  
\[\min_{\{x_{1},x_{2},x_{3}\}}\mathrm{F}_{i} =x_{1}\mathrm{E}_{i}+x_{2}\mathtt{Dist}_{i}+x_{3}\mathtt{H}_{i},\] (6a) s.t \[x_{1}+x_{2}+x_{3}=1, \tag{6b}\] \[\mathrm{E}_{i}\geq\mathrm{E}_{\mathtt{th}},\] (6c) \[\mathtt{Dist}_{i}\leq\mathtt{D}_{\mathtt{th}},\] (6d) \[\mathtt{H}_{i}\leq\mathtt{H}_{\mathtt{th}}, \tag{6e}\]  
where \(\mathtt{E}_{i},\mathtt{Dist}_{i}\), and \(\mathtt{H}_{i}\) are the remaining energy, distance, and hop count, respectively. Equation (6b) indicates the total weight that must be equal to one. Equation (6c) explains that the remaining energy of the node must be greater than equal to the remaining energy threshold, (6d) explains that the distance must be lower than equal to the distance threshold, (6e) explains that the hop count must be lower than equal to the hop count threshold, respectively. To find the optimal weight in (6b), we use the proposed DNN model that is elaborated in detail in the forthcoming Section 4.2. Furthermore, to establish an accurate and reliable energy model, we reference the work of [7; 8], which provides comprehensive insights into energy-efficient approaches in wireless networks. In addition, we consider the distance between two nodes, which is based on the node position and can be expressed as  
\[\mathtt{Dist}_{(i,t^{\prime})}=\sqrt{(x_{i}-x_{i^{\prime}})^{2}+(y_{i}-y_{i^{ \prime}})^{2}}, \tag{7}\]  
where \(x_{i}\) and \(y_{i}\) represents the node location longitude and latitude, respectively. Then, go to **Step 7.5**. **Step 7.4:** If the packet is from a blackhole node, then we employ secure routing.