## 4 New Routing Protocol for MWSNs
### Our Efficient Routing Strategy in MWSNs
#### 4.1.3 Routing Path Recovery  
When sink moves out of the radio rang of agent or relay node fails, the original routing path need to be recovered to continue the data gathering. The routing recover procedure is detailed in two cases:  
(1) When sink moves out of the radio rang of agent. \(Sink_{i}\) cannot receive any packet from _Agent\({}_{i}\)_, then it needs to select a new agent and build a new routing path to continue the data gathering. To ensure no previous data packet is lost, Temporary Agent node (TA) is introduced in our routing strategy. This routing recovery result is shown in Figure 2b. In order to help the sink to judge whether or not it is within the radio rang of an agent, the agent and relay nodes are required to send at least one packet to sink for a time interval \(T\). Therefore, even though they have nothing to send, they also need to send a NULL packet to sink. Therefore, if not any packet has been received from _Agent\({}_{i}\)_ for time interval \(T\), _Sink\({}_{i}\)_ can knows that it moves away from _Agent\({}_{i}\)_. To continue the data gathering, the following steps need to be completed:  
_Step 1_ Select the TA. Sink selects the closest node as the TA. If the sink moves faster, then TA is farther away from _Agent\({}_{i}\)_,which means that more relay nodes are required between TA and _Agent\({}_{i}\)_. _Step 2_ Build the temporary routing path  
After TA is selected, _Sink\({}_{i}\)_ sends Temporary Routing Path Setup (TRPS) packet to _Agent\({}_{i}\)_ via TA. Once received the TRPS packet, _Agent\({}_{i}\)_ sends its cached data packets which come from source _Source\({}_{j}\)_ to TA along the reverse path of TRPS packet, the reverse path is named Temporary Path (TP). Because some data packets will be lost after the sink moved away from _Agent\({}_{i}\)_ and before TP is established, the _Agent\({}_{i}\)_ needs to cache the data packets in this time interval to avoid data loss. Once the _Agent\({}_{i}\)_ received the TRPS packet, these cached data packets are routed to TA via TP. _Step 3_ Collect network statuses. The procedure is the same to _Step 2_ in Section 4.1.2. The only difference is that the sink sends Routing Path Reset (RPRS) packet to source _Source\({}_{j}\)_ to collect the newly network status information. _Step 4_ Build optimal routing path. As same as _Step 3_ in Section 4.1.2. The only difference is that the optimal routing tree is built for the nearest source nodes using those nodes whose response packet (RPRSR) are received by sink. _Step 5_ Establish routing tree and begin data transmission. The procedure is the same as _Step 4_ in Section 4.1.2. _Step 6_ Clear original routing path. Notably, when the new optimal routing path established, the original routing path is still work on. Before source node begin routing data packet via new optimal routing path, it sends Routing Path Clear (RPC) packet to TA along the original routing path and TP, each relay node on the path that received RPC packet will reset its isRelay = 0 to remove routing state information. Once the original routing path and TP is cleared, TA becomes the new agent \(Agent_{i}\). When the relay node fails  
Now we consider the relay node fault tolerant. This routing recovery procedure is shown in Figure 2c. _Step 1_ Locate the failed node  
When a relay node (e.g., \(RN_{j}^{k}\)) in \(Path_{j}=\{Source_{j},\ RN_{j}^{1},\ RN_{j}^{2},\ \ldots,\ RN_{j}^{k}\ \ldots,\ RN_{j}^{n},\ Agent_{i},\ Sitk_{i}\}\) has failed, e.g., exhausted its battery power, then \(Path_{j}\) is broken, its next relay node \(RN_{j}^{k+1}\) can realize this situation if it cannot receive any packet from \(RN_{j}^{k}\) for a predetermined time interval \(T\). Once detecting routing path is broken, \(RN_{j}^{k+1}\) immediately queries its neighbor table to obtain the failure node ID (i.e., \(RN_{j}^{k}\)) and sends a relay node failure (RNF) packet, which includes the failure node ID to \(Agent_{i}\) via the original path.