# Empowering Adaptive Geolocation-Based Routing for UAV Networks with Reinforcement Learning
## 3 System Design and Algorithm
### GLAN Algorithm  
For readability, we define the terminology used in this paper in Table 1.  
In this subsection, we introduce the GLAN algorithm, which can deliver data in an optimal direction even when broadcasting. When a data transmission request reaches the UAV server, the locations of S and D are confirmed in a simulation. Figure 4 presents the map of the GLAN system. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Term** & **Math Expression** & **Meaning** \\ \hline Forwarding angle & \(U\) & The angle of the forwarding region \\ \hline Network range & T & The network range \\ \hline Source node & S & A source node with a geographic location \\ \hline Intermediate node & I & An intermediate node with a geographic location \\ \hline Destination node & D & A destination node with a geographic location \\ \hline x coordinates & \(x_{n}\) & Longitude of node n \\ \hline y coordinates & \(y_{n}\) & Latitude of node n \\ \hline z coordinates & \(z_{n}\) & Altitude of node n \\ \hline Distance & dis (a,b) & The distance between a node and b node \\ \hline Angle & Ang (n) & The angle of node n \\ \hline Cosine & cos (n) & The cosine of node n \\ \hline Arccosine & acos (N) & The arccosine of an angle N \\ \hline \hline \end{tabular}
\end{table} 
Table 1: GLAN terminology. We consider a situation wherein data need to be passed from node S to node D. If the final destination of transmission is not within the T of the transmitted UAV, a forwarding process is required. The distance from S to D can be obtained through an equation that can be expressed as  
\[dis(a,b)=\sqrt{(x_{a}-x_{b})^{2}+(y_{a}-y_{b})^{2}+(z_{a}-z_{b})^{2}}\, \tag{1}\]  
where a is S and b is D. According to Equation (1), since node D is outside the T of node S, forwarding is required to transmit the data successfully. Therefore, S requests forwarding to nodes within the T through broadcasting. The intermediate node checks whether its position is in the FR. The distances between S, D, and I can be obtained through Equation (1), and the cos value of Ang(S) can be obtained through Equation (2), which can be expressed as  
\[cos(Ang(a))=\frac{dis^{2}(a,b)+dis^{2}(a,c)-dis^{2}(b,c)}{2\times dis(a,b)\times dis (a,c)}\, \tag{2}\]  
where a is node S, b is node I, and c is node D for the situation in Figure 4. Ang(S) can be obtained through Equation (3), which can be expressed as  
\[\frac{d}{da}\arccos a=\frac{d}{da}\cos^{-1}a=\frac{-1}{\sqrt{1-a^{2}}}\, \tag{3}\]  
where a equals Ang(S). When Ang(S) is obtained through Equation (3), it determines whether to forward or discard the data by comparison with \(U\). Because Ang(s) has a lower value than \(U\), the data are forwarded to node D. It can be seen that node I is in the FR, while nodes Q and R are not. The process of the GLAN algorithm is expressed in Algorithm 1. Firstly, the algorithm calculates the distance from node S to I to check whether node I is in the network range of node S. If d has a larger value than T, it means that node I is out of range of Node S, so we discard the packets. Otherwise, the algorithm compares \(U\) and Ang(S) to determine whether node I is in the FR. If node I is in the FR, the data are forwarded to node D. This algorithm is repeated until the packet arrives at its destination. Figure 4: Map of GLAN system. ```
Input :Routing information: \(U,T\)  Geographic location: \(S,I,D\)
1 //Initialization \(s\gets dis(I,D)\) \(i\gets dis(S,D)\) \(d\gets dis(S,I)\) \(Ang(S)\gets acos(equation(2))\) if\(d>T\)then
2 //check distance from S to I is in network range T Discard packets
3 else
4 if\(Ang(S)<U\)then
5 //check whether Ang(S) is in FR Forward packets
6
7 else
8 Discard packets
9
10 end if
```  
**Algorithm 1**GLAN algorithm procedure  
This proposed system reduces the number of links that generate the network load, which is a problem when broadcasting data through the GLAN algorithm, and delivers data through an optimized path.