# A Deep-Learning-Based Secure Routing Protocol to Avoid Blackhole Attacks in VANETs +
## 3 System Model
### The Proposed DLC Protocol: The Underlying Structure  
The proposed clustering protocol is called the DLC protocol as an underlying structure, as shown in Figure 2. The proposed DLC protocol uses a DNN model to optimize the fitness function weights for selecting a CH to follow by a CM. Here, we consider three factors to form a cluster, namely, cosine similarity, cosine distance, and remaining energy. Figure 3 shows the flowchart of the proposed DLC protocol. The procedure for forming a cluster and electing the CH is as follows:  
* **Step 0: Initialization** Each node activates and operates independently once the simulation begins. * **Step 1: The Dissemination of Node Information** Each node \(n_{k}\) periodically estimates its remaining energy information. Then, node \(n_{k}\) generates and broadcasts information (INFO) packets to its NN periodically to advertise its node information with NN. The following fields are included in the INFO packet: \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E}\rangle\] where Type represents packet type, \(\texttt{S}_{\texttt{ID}}\) represents source node ID, \(\texttt{D}_{\texttt{ID}}\) represents destination node ID, and E represents the remaining energy of the node, respectively. Then, go to **Step 2**. * **Step 2: Cluster Heads Candidate Selection** The CH is chosen by the candidate node from all NN with the highest remaining energy. This can be mathematically expressed as [35] \[k^{*}=\arg\max_{k\in\texttt{NN}^{*}_{\texttt{U}}\cup\{k\}}\texttt{E}_{k},\] (1)  
Figure 1: The basic concepts of the proposed DLSR protocol. where \(\mathbb{E}_{k}\) indicates the remaining energy of the \(k^{th}\) node. The node with the highest remaining energy is chosen as a CH because all communication must pass through the CH. Therefore, it provides robust connectivity between CH and cluster members (CM). If \(k=k^{*}\), the node \(n_{k}\) becomes CH, then go to **Step 3**. Otherwise, go to **Step 4**. * **Step 3: The Dissemination of Cluster Head Information** When \(n_{k}\) becomes the CH, \(n_{k}\) generates and broadcasts the cluster head information (CHI) packet to advertise it to its NN. The following fields are included in the CHI packet: \[\left\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{Pos},\texttt{S},\texttt{Dir}\right\rangle\] where Type represents the packet type, \(\texttt{S}_{\texttt{ID}}\) represents the source node ID, \(\texttt{D}_{\texttt{ID}}\) represents the destination node ID, Pos represents the node position \((x_{k},y_{k})\), \(\texttt{S}\) represents the node speed, and Dir represents the node direction, respectively. Then, go to **Step 4**. * **Step 4: Determination of Gateway Nodes** The GW is selected when \(n_{k}\) is located in between more than one CH. In this case, the CHs from the neighbor may send \(n_{k}\) several CHI packets. Therefore, \(n_{k}\) becomes the GW and goes to **Step 5.1**. Otherwise, \(n_{k}\) becomes a CM node and goes to **Step 5.2**. * **Step 5: Determination of Cluster Members** The procedure for the node \(n_{k}\) receiving either one or multiple CHI packets is as follows:  
**- Step 5.1:** If node \(n_{k}\) receives multiple CHI packets, it selects the CH among the CH candidates to follow based on the maximum fitness function value. Input parameters such as cosine similarity, cosine distance, and remaining energy are taken into account. The proposed fitness function can be expressed as \[\max_{\{x_{1},x_{2},x_{3}\}}F_{k}=x_{1}\texttt{CS}_{k}+x_{2}\texttt{CD}_{k}+x_ {3}\mathbb{E}_{k},\] (2a)  
Figure 2: The Basic Concept of the DLC Protocol. s.t \[x_{1}+x_{2}+x_{3}=1,\] (2b) \[\text{CS}_{k}\geq\text{CS}_{th},\] (2c) \[\text{CD}_{k}\leq\text{CD}_{th},\] (2d) \[\langle\texttt{Type},\texttt{S}_{\texttt{ID}},\texttt{D}_{\texttt{ID}}, \texttt{E}\rangle\]0 (2e)  
where \(\text{CS}_{k},\text{CD}_{k}\), and \(\text{E}_{k}\) are the cosine similarity, cosine distance, and remaining energy, respectively. Equation (2b) indicates the total weight that must be equal to one.