## 4 Implementation
### GPSR_DA Algorithm
#### 4.1.2 Angle Calculation
\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]1

### Routing Hole Response Mechanism

Node stability can be measured by the Average Movement Distance (_AMD_) based on the updated node position information. In a given time period \(T\), each node in a link will update \(k+1\) times. The set of updated position coordinates for each node within the time period \(T\) can be represented as follows:

\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]2

The average movement distance of the node within the past time period \(T\) is

\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]3

Considering these two cost estimates, the smaller the Manhattan distance between the node and the destination node, the lower the cost incurred. Additionally, a smaller average movement distance of the node indicates a more stable routing path. Therefore, in this study, we select the node with the minimum comprehensive value and maximum benefit to join the link. The comprehensive cost estimate for the node is

\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]4

Suppose that through the \(A^{*}\) algorithm, the routing path with the minimum cost is found, consisting of \(m\) nodes. When the \(A^{*}\) algorithm reaches the \(n\)-\(th(n<m)\) node during its search, the overall cost of the \(n\) nodes already added to the link is

\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]5

After adding the \((n+1)\)-\(th((n+1)<m)\) node, the cost estimate for the updated path is

\[\rho=L_{(N_{k}^{\prime\prime\prime},S)}=d_{(N_{k}^{\prime\prime\prime},SD)}sin\theta. \tag{2}\]6

The final algorithm implementation, as shown in Algorithm 2, obtains a path with the minimum cost based on the cost estimation function. This path is then sent to the reporting node, which carries the path information to complete the data-forwarding process. ```
1:\(openList\): set of nodes to be traversed
2:\(closedList\): set of nodes that have been traversed
3:\(destNode\): destination node
4:\(startNode\): source node
5:\(curNode\): current node
6:\(routList\): list that stores the returned path nodes
7:\(routList\)
8: Push the neighbor list of \(startNode\) into \(openList\)
9:while\(openList\) is not empty do
10:for\(i=1\)to\(openList.length()\)do
11:if\(openList[i]==destNode\)then
12:\(curNode\gets openList[i]\)
13:while\(curNode\) is not \(startNode\)do
14: Push \(curNode\) into \(routList\)
15:\(curNode\gets curNode.parent\)
16:endwhile
17:return\(routList\)
18:endif
19:endfor
20: Find the node with minimum value in \(openList\) using (7)
21:\(curNode\leftarrow\) the node with minimum value
22: Pop \(curNode\) from \(openList\)
23: Add \(curNode\) to \(closedList\)
24:\(nbrList\leftarrow\) neighbor list of \(curNode\)
25:while\(nbrList\) is not empty do
26:for\(j=1\)to\(nbrList.length()\)do
27:if\(nbrList[j]\) is in \(closedList\)then
28:continue
29:endif
30:if\(nbrList[j]\) is not in \(openList\)then
31: Push \(nbrList[j]\) into \(openList\)
32:\(nbrList[j].parent\leftarrowcurNode\)
33: Calculate cost using (14)
34:elseif\(nbrList[j]\) is in \(openList\)then
35: Calculate new cost with \(curNode\) as parent
36:if new cost \(<\) old cost then
37:\(nbrList[j].parent\leftarrowcurNode\)
38: Update cost of \(nbrList[j]\)
39:endif
40:endif
41:endfor
42:endwhile
43:endwhile
```

**Algorithm 2**\(A^{*}\)

### Location Preservation Method

In addition, in the SD-GPSR routing method, the source node needs to request the location information of the destination node from the controller. We design a location preservation method where the destination node can obtain its relatively accurate location information at a future time through location prediction services.