# A Smart Collaborative Routing Protocol for Reliable Data Diffusion in IoT Scenarios
## 3 The Smart Collaborative Routing Protocol for IoT
### Creating the Query Command Path  
In the GIN protocol, when the node \(N\) needs to transmit the query command \(P\) to the event area \(R\), the next hop of the node \(N\) is selected based on the shortest distance from the neighboring nodes to \(R\) and the energy consumption of the neighboring nodes is also taken into account. In order to comprehensively consider the distance and energy, the proposed protocol utilizes the learned cost and estimate cost to identify the path cost. The \(h(M,R)\) is described as the learned cost from the node  
\begin{table}
\begin{tabular}{c c c} \hline \hline  & **IN** & **MN** \\ \hline IN & \(\frac{1}{C_{in}}\frac{1}{C_{in}}\) & \(\frac{1}{C_{in}}\frac{1}{C_{in}}\) \\ MN & \(\frac{1}{C_{in}}\frac{1}{C_{in}}\) & 0,0 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The strategy form of two players.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Type of Node** & **List of Managed Entities** \\ \hline IN & CH, MN \\ CH & IN, MN, neighbor CHs \\ MN & IN, CH \\ \hline \hline \end{tabular}
\end{table}
Table 2: The reputation management mechanism.  
Figure 6: The process of the IN selection.  
\(M\) to node \(R\). When the node does not know the learned cost, \(c(N_{i}\),\(R)\) substitutes the learned cost for representing the estimate cost of the neighboring nodes. We can get:  
\[c(N_{i},R)=ad(N_{i},R)+(1-a)e(N_{i}) \tag{8}\]  
where \(a\) is a variable parameter, \(d(N_{i}\),\(R)\) is regarded as the distance from \(N_{i}\) to the center \(D\) of the event area \(R\), and e(\(N_{i}\)) is named as the energy consumption of \(N_{i}\). The distance \(d(N_{i}\),\(R)\) and consumption e(\(N_{i}\)) are all the normalized formulas. When the node \(N_{i}\) is selected as the next hop of \(N\), the learned cost of \(N\) becomes:  
\[h(N,R)=h(N_{i},R)+c(N,N_{i}) \tag{9}\]  
where \(c(N\),\(N_{i})\) is described as the transmission consumption from \(N\) to \(N_{i}\).  
When there exists a hole problem in the routing process, as shown in Figure 7, we assume that the distance between the adjacent nodes is \(i\) and each node can communicate with the eight surrounding nodes. The six nodes in the figure (i.e., \(M\), \(N\), \(O\), \(P\), \(Q\), \(R\) nodes) cannot forward the packets because of being used up or attacked. The packets are to be transmitted to the destination node \(L\). The GIN protocol is based on the greedy algorithm of the GPSR. When the node \(S\) receives the query command, the node \(S\) selects node \(C\) among three nodes \(B\), \(C\), \(D\) as its lowest-cost neighbor. Because node \(C\) is the closest point to \(S\) on the transmission path from node \(S\) to node \(L\). In order to solve the routing hole problem, node \(C\) chooses the neighboring node with the lowest learned cost as the next hop node. In this situation of Figure 7, node \(B\) is selected as the next hop of node \(C\). The learned cost from node \(C\) to the destination is changed to \(h(C\),\(L)=h(B\),\(L)+c(C\),\(B)\). According to the routing rule, a secure query command path will be established.