## 4 Implementation
### GPSR_DA Algorithm
#### 4.1.2 Angle Calculation  
The set of neighboring nodes of node \(S\), which are closer to the destination node than node \(S\) itself, is denoted as \(N^{\prime\prime\prime}=\{N_{k}^{\prime\prime\prime},k\in N^{*}\}\). The coordinates of \(N_{k}^{\prime\prime\prime}\) are \((x_{k}^{\prime\prime\prime},y_{k}^{\prime\prime\prime})\). In this text, the relationship between node \(N_{k}^{\prime\prime\prime}=(k=1,2,\ldots,i+j)\) and the line \(SD\) is represented in polar coordinates, as shown in Figure 3.  
Taking node \(S\) as the origin of polar coordinates and \(SD\) as the x-axis, the distance between node \(N_{k}^{\prime\prime\prime}\) and node \(S\) is denoted as \(\rho\), and the line connecting them is represented as \(SN_{k}^{\prime\prime\prime}\). The angle between \(SN_{k}^{\prime\prime\prime}\) and \(SD\) is denoted as \(\theta=\{\theta_{k},k\in N^{*}\}\). Therefore, we have the following equation:  
\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]  
Therefore, we can obtain the following equation:  
\[\theta=arcsin(\frac{L_{(N_{k}^{\prime\prime\prime},S)}}{d_{(N_{k}^{\prime \prime\prime},SD)}}), \tag{3}\]  
where \(d_{(N_{k}^{\prime\prime\prime},SD)}\) represents the distance from point \(N_{k}^{\prime\prime\prime}\) to the line \(SD\). The equation of the line \(SD\) can be expressed as:  
\[(y_{d}-y_{S})x+(x_{d}-x_{S})y+(x_{S}y_{d}-x_{d}y_{S})=0. \tag{4}\]  
Figure 3: Calculation of relay node angle. The distance \(d_{(N_{k}^{\prime\prime},SD)}\) from point \(N_{k}^{\prime\prime\prime}\) to the line \(SD\) can be represented as follows:  
\[d_{(N_{k}^{\prime\prime},SD)}=\frac{((y_{d}-y_{S})\times x_{N^{\prime}}+(x_{d}-x _{S})\times y_{N^{\prime}}+(x_{S}y_{d}-x_{d}y_{S}))}{sqrt(\sqrt{(y_{d}-y_{S})^{ 2}}+\sqrt{(x_{d}-x_{S})^{2}})}. \tag{5}\]  
Based on the calculation of the distance and angle mentioned above, a shorter distance indicates that the neighboring node is closer to the destination node. A smaller value for \(\theta\) increases the probability of a straight-line distance to the destination node. Therefore, considering both the distance and angle calculations, a smaller evaluation value for the neighboring node indicates that it is a better next-hop forwarding node. The comprehensive evaluation value is calculated as follows:  
\[Vue=\alpha\theta+\beta L_{(N_{i},D)}, \tag{6}\]  
where \(\alpha\) and \(\beta\) are the weights assigned to the angle and distance, \(\alpha=2/\pi\), \(\beta=1/(L_{(S,D)})\). Due to the fact that the GPSR_DA algorithm only considers the angle and distance when selecting the next hop node, it is highly likely to select a node with a very small angle at a very close range from the source node, resulting in the minimum calculated \(Vue\). This may cause the selected next hop node to be very close to the source node but very far from the destination node, thus increasing the number of forwarding hops. Therefore, we divide the communication range of node \(S\) into different regions, as shown in Figure 4.  
Node \(S\) first selects a next-hop-forwarding node within Region II. If there are no available nodes in Region II, then the selection process moves to Region I. Experimental results have shown that the optimal range for Region II is 20% of the communication range at the edge of node \(S\). We select all neighboring nodes of node \(S\) that are closer to the destination node and located within 20% \(R\) of the communication range of node \(S\). These nodes form the first priority node set, denoted as \(N^{\prime}=\{N_{i}^{\prime},i\in N^{*}\}\). In other words, the nodes in set \(N^{\prime}=\{N_{i}^{\prime},i\in N^{*}\}\) must satisfy the following conditions:  
\[R-L(N_{i}^{\prime},S)\leq 20\%R. \tag{7}\]  
We consider all neighboring nodes of node \(S\) that are closer to the destination node and not present in the first priority node set as the second priority node set, denoted as \(N^{\prime\prime}=\{N_{j}^{\prime\prime},j\in N^{*}\}\).