## 4 Implementation
### GPSR_DA Algorithm
#### 4.1.2 Angle Calculation
Therefore, we have  
\[N^{\prime\prime\prime}=N^{\prime}\cup N^{\prime\prime}. \tag{8}\]  
The specific implementation steps are as follows:  
**Step I:** If \(L_{(S,D)}\leq R\), search for the MAC address of the destination node in the neighbor table of node \(S\), forward the data to \(D\), and stop. \[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]0 Division of the communication range of forwarding nodes. **Step II:** If \(L_{(S,D)}\geq R\), calculate the distance between \(N_{i}\) and \(D\) based on Equation (1) and select the first priority node set. If the first priority set contains nodes, calculate the angle \(\theta\) between the nodes in the set and the line connecting the forwarding node and the destination node according to Equation (3). Then, calculate the value \(Vue\) based on Equation (6), which combines distance and angle calculations. Select the node with the smallest as the next-hop-forwarding node. **Step III:** If the first priority set does not contain any nodes, select all nodes that are closer to the destination node than the forwarding node as the second priority node set. Calculate the angle \(\theta\) between the nodes in the set and the line connecting the forwarding node and the destination node according to Equation (3). Then, calculate the value \(Vue\) based on Equation (6), which combines distance and angle calculations. Select the node with the smallest as the next-hop forwarding node. **Step IV:** The next-hop forwarding node repeats **Step I** and **Step II** until the data packet reaches the destination node. The specific execution algorithm is shown in Algorithm 1. ```
1:\(S_{x},S_{y}\): coordinates of node \(S\)
2:\(D_{x},D_{y}\): coordinates of destination node
3:\(N_{x},N_{y}\): coordinates of next-hop node
4:\(\alpha,\beta\): weights of angle and distance
5:\(N_{i}\): neighbors of node \(S\)
6:\(R\): radius of node \(S\)
7:\(N_{opt}\): optimal next-hop node ID
8:while neighbor table is not empty do
9:if there is a next-hop node then
10:return next-hop node ID [Return next-hop node if available]
11:else
12: Calculate distance to destination node using (1)
13: Determine whether neighbor node belongs to set \(N^{\prime}\) using (7)
14:if\(N_{i}\in N^{\prime}\)then
15: Add \(N_{i}\) to set \(N^{\prime}\)
16:else
17: Add \(N_{i}\) to set \(N^{\prime\prime}\)
18:endif
19: Calculate the equation of the line \(SD\) using (5)
20: Calculate the angle between each neighbor node in \(N^{\prime}\) or \(N^{\prime\prime}\) and the line \(SD\) using (3)
21: Calculate the result \(Vue\) based on distance and angle using (6)
22:if node belongs to \(N^{\prime}\) and \(Vue\) is smaller than the minimum value in \(N^{\prime}\)then
23: Replace the node in \(N^{\prime}\) with the current node and update \(Vue\)
24:endif
25:if node belongs to \(N^{\prime\prime}\) and \(Vue\) is smaller than the minimum value in \(N^{\prime\prime}\)then
26: Replace the node in \(N^{\prime\prime}\) with the current node and update \(Vue\)
27:endif
28:endif
29:endwhile
30:if\(N^{\prime}\) has the best node then
31:return its ID
32:elseif\(N^{\prime\prime}\) has the best node then
33:return its ID
34:endif
35:return\(N_{opt}\) {Return optimal node ID}
```  
**Algorithm 1** GPSR_DA  
**Step IV:** The next-hop forwarding node repeats **Step I** and **Step II** until the data packet reaches the destination node. The specific execution algorithm is shown in Algorithm 1. ```
1:\(S_{x},S_{y}\): coordinates of node \(S\)
2:\(D_{x



In order to avoid the occurrence of routing holes in the GPSR_DA algorithm, we propose a simple and effective solution by combining SDN controller capabilities. By leveraging the controller's global view, we use a centralized approach to perform routing calculations and update routing paths in the controller, using flow table matching to ensure seamless data forwarding.