## 3 Proposed Routing Algorithm
### Operation of the Radio-Aware Routing Algorithm
#### 3.2.3 The node selection algorithm  
RA is originally designed to select an optimum route based on the distance and the air time cost. These two metrics of RA have an important role to make a route decision respectively. If a routing protocol decides a route based on the distance, the protocol can choose the shortest route between a source and a sink. However, the routing protocol only based on the distance information cannot properly cope with the lossy situation because the distance information does not have the information of the current network's status. Whereas, if a routing protocol uses the air time cost for deciding the route, the protocol can choose the best route based on the current network's status. However, if a routing protocol only considers the air time cost, the direction of the data transmission can be opposite to the data forwarding route from a source to sink. The effect of inverse directed data transmission causes the long route or loop on the communicating route. For these reasons, we designed RA to take the advantages of each scheme for choosing optimum route based on two metrics to overcome lossy situation. The detailed operation of RA is as follows. \begin{table}
\begin{tabular}{|c|c|c|c|c|} \hline Node id & Position x & Position y & Air time cost & Route failure flag \\ \hline
22 & 50 & 50 & 0.08819 & 1 \\ \hline
**23** & **50** & **70** & **0.09115** & **0** \\ \hline
24 & 50 & 90 & 0.09115 & 0 \\ \hline \(\vdots\) & \(\vdots\) & \(\vdots\) & \(\vdots\) \\ \hline
32 & 70 & 50 & 0.07311 & 1 \\ \hline
44 & 90 & 90 & \(\infty\) & 0 \\ \hline \end{tabular}
\end{table} 
Table 1: Neighbor table. The air time cost was calculated and updated whenever receiving the interest and data from its neighbors. Also, the distance between each node and its sink node was calculated by examining the interest packet including the position of the sink node. Each node already knows the position of sink node and neighbor nodes from interest propagation. This directional information can be used to find closer nodes to the sink among neighbor nodes by comparing with the reference distance (D\({}_{\text{ref}}\)) of the sender S. The distance to the sink node of each node was considered to avoid the loop and longer hops caused by selecting an irrelevant node with inverse direction. \[D_{k}=\sqrt{\left(x_{s}-x_{k}\right)^{2}+\left(y_{s}-y_{k}\right)^{2}} \tag{2}\]  
Equation (2) is from Pythagorean Theorem to calculate the distance between two nodes. Each node is aware of the position of neighbors through the interest propagation. For example, the distance \(D_{k}\) to a sink at node \(k\) (Sink: \(x_{s},y_{s}\) and N\({}_{\text{k}}\): \(x_{k},y_{k}\)) can be calculated from the Equation (2). When the sender S finds the closest node among neighbors, the distance is calculated among neighbors to compare with the reference distance. The node selection process of the proposed algorithm is as follows. When a sender S receives the packets of both interest and data from the neighboring nodes, it calculates the air time cost for each node and updates it into its neighbor table from Equation (1). After that, the nodes that are closer than the reference node (sender, S) were selected as the candidate nodes. Finally, RA chooses a target node with the highest air time cost among candidate nodes. Figure 2 depicts the node selection process for the proposed algorithm. In the figure, N\({}_{1}\), N\({}_{2}\), N\({}_{3}\) are selected as candidate nodes. Among them, N\({}_{1}\) will be selected as the next node because it has the  
Figure 2: The node selection scheme of the proposed algorithm. smallest value of the air time cost. Although the node N\({}_{4}\) has the best air time cost (0.7615) among the neighbors, N\({}_{4}\) will not be selected as the candidate because the direction to N\({}_{4}\) is inverse to the sink node from the sender S.  
The reason for selecting N\({}_{1}\) instead of N\({}_{4}\) with the best air time cost is as follows.