## Main Design of DERM
### Track Routing
#### 4.4.1 Determining the Forwarding Direction  
When a packet enters the track routing mode at a node called _tracking node_ (e.g., \(N_{0}\) in Figure 6), it will determine the packet forwarding direction first (Lines 2-20). Our method supports two types of sink paths, i.e., the round-trip path and the cyclic path. For the round-trip path, the tracking node broadcasts a message to its neighbors to query their sink Beacon timestamps. Obviously, the fresher the timestamp, the closer the distance between a node and the sink. Therefore, the neighboring RN having the freshest timestamp will be selected as the next-hop forwarder. Assuming the timestamps of the tracking node and node \(i\) are \(t_{0}\) and \(t_{i}\), respectively, the forwarder has a maximum \(t_{i}-t_{0}\). If there are no RNs in the neighborhood, the tracking node will choose the adjacent node with a fresher timestamp as the forwarder. The packet forwarding direction (termed \(fwdDirc\)) can be represented by a vector from the current node to the next-hop node. For example, in Figure 5(a), \(N_{3}\) is the forwarder and the vector \(\overrightarrow{N_{0}N_{3}}\) (or \(\overrightarrow{BA}\)) indicates \(fwdDirc\). ```
1:the neighbor node set \(N(i)\); the sink path, the timestamp \(t_{i}\); \(fwd\)_Direc_, \(reverse\_flag\);
2:the next-hop forwarder;
3:while receiving or buffering a packet in the track routing mode do
4:if node \(i\) is the tracking node then
5:if\(tp\)==\(round\)-\(trip\)then
6: Find the node \(j\) with the maximum \(t_{j}\) in \(N(i)\);
7:if\(j!=null\)then
8: Forward the packet to \(j\);
9:\(fwd\)_Direc_\(=\)\(i\)\(j\);
10:else
11: Forward the packet to the adjacent node \(k\) with the maximum \(t_{k}\);
12:\(fwd\)_Direc_\(=\)\(i\)\(k\);
13:endif
14:else
15: Determine \(fwd\)_Direc_ based on Equation (15);
16: Find the node \(j\) satisfying Equation (17);
17:if\(j!=null\)then
18: Forward the packet to \(j\);
19:else
20: Forward the packet to the adjacent node in \(fwd\)_Direc_;
21:endif
22:endif
23:else
24:if\(dist(i,M)\leq R\)then
25: Deliver the packet to \(M\);
26:elseif\(reverse\_flag==true\)then
27: Forward the packet to the adjacent node in \(fwd\)_Direc_;
28:elseif\(is\_missed==true\)then
29: Reverse \(fwd\)_Direc_ and forward the packet to the adjacent node in new \(fwd\)_Direc_;
30:\(reverse\_flag=true\);
31:else
32: Find the node \(j\) satisfying Equation (17);
33:if\(j!=null\)then
34: Forward the packet to \(j\);
35:else
36: Forward the packet to the adjacent node in \(fwd\)_Direc_;



respect to \(N_{0}\). Hence, the packet will be forwarded in the opposite direction of the sink movement, as shown in Figure 6b. #### 4.4.2 Selecting the Forwarder

After determining \(fwd\)_Dirc_, a node would select a best next-hop forwarder (Lines 21-37). An intuitive solution is directly forwarding the packet to its adjacent node in the direction \(fwd\)_Dirc_. However, it will make the packet visit the RNs one by one along the path towards the sink, which is obviously inefficient. We perform the track routing in a greedy manner. To facilitate the presentation, we define \(Adv_{fD}^{P}(i,j)\) as the advance along the path \(P\) in the direction \(fwd\)_Dirc_ when a packet is forwarded from node \(i\) to \(j\). Denote \(P_{i}\) and \(P_{j}\) as the access points of \(i\) and \(j\) on the path \(P\), respectively. \(Path(P_{i},P_{j})\) represents the path from \(P_{i}\) to \(P_{j}\), which may include turning points of \(P\). \(Adv_{fD}^{P}(i,j)\) can be calculated as

\[Adv_{fD}^{P}(i,j)=\left\{ \begin{array}{ll}||Path(P_{i},P_{j})||_{2},&if\; \text{dirc}(Path(P_{i},P_{j}))=fwd\text{{D}}\text{{i}}\text{{c}}\text{{c}},\\ -||Path(P_{i},P_{j})||_{2},&otherwise.\end{array} \right. \tag{16}\]

If \(Path(P_{i},P_{j})\) has the same direction as \(fwd\)_Dirc_, \(Adv_{fD}^{P}(i,j)\) equals the length of \(Path(P_{i},P_{j})\). Otherwise, it is negative. When node \(i\) receives a packet in the track routing mode, it will first check whether the sink is within the communication range. If so, the packet will be directly delivered.