## 5 Localized Recovery of Query Losses
### The Impact of Detector Number on Successful Recovery  
We study the impact of the number of detectors on the performance of packet loss recovery. The target is to highlight the correlation between detector number and the effectiveness of immune inspired operation. Let \(n\) be the number of detectors that perform recovery of an object at which the query packet is lost. We analyze the packet loss recovery at an object node \(A\). The recovery is performed after a query loss was detected at the object \(A\). The detectors of object \(A\) recover the loss by unicasting the recovery packet to object \(A\). The recovery unicast from a detector faces contention with other detectors at MAC layer as well as the network layer packet loss. Figure 7: Ratio of the route length of recovery (RLR) between the proposed method and sink-based approach. Suppose the MAC protocol adopts random media access with node contention. Although there are various MAC protocols, we adopt random access due to its high channel utilization capability [19,20] and its simplicity for small sensor nodes. Random access is the commonly utilized contention based MAC scheme in technologies such as WLAN, Zigbee, _etc._ If the recovery contention window size is \(W\), the detector recovers the query loss detected in a random time within \((0,W)\). Let \(P_{RS}\) be the probability of recovery success for a detector to send a recovery packet to its object node. Note that the probability of recovery success of a detector is under the condition that  
1. MAC layer success: there is no collision with other detectors at the time of recovery packet delivery,
2. PHY layer success: successful PHY layer unicast of the recovery packet to the object. Let \(P_{\textit{PHY}}\) be the probability of recovery unicast failure at PHY layer to deliver a packet from the neighbor detector nodes. Further, let \(P_{\textit{MAC}}\) be the probability of recovery failure at MAC layer to deliver a packet from neighbor detector nodes. Therefore, we have  
\[P_{\textit{RS}}=\left(1-P_{\textit{PHY}}\right)\left(1-P_{\textit{MAC}}\right) \tag{5}\]  
Note a MAC success for a detector indicates that there is no collision with any of the other \(n-1\) detector nodes in a contention window \(W\). Suppose each MAC access time is one time unit in a contention window of \(W\) time units. By regarding the media access operation as Bernoulli trials without sequence correlation, we can calculate \(P_{MAC}\) as  
\[P_{\textit{MAC}}=1-\left(\frac{W-1}{W}\right)^{n-1} \tag{6}\]  
Then, we can rewrite Equation (5) as  
\[P_{\textit{RS}}=\left(1-P_{\textit{PHY}}\right)\left(\frac{W-1}{W}\right)^{n-1} \tag{7}\]  
Let \(P_{\textit{RF}}=1-P_{RS}\) be the probability of recovery failure for a detector to send a recovery packet to its object node. Then the probability that all detectors of an object fail to recover can be written as  
\[P_{\textit{RF}}^{*}=\left(P_{\textit{RF}}\right)^{n} \tag{8}\]  
leading to the overall probability of successful recovery  
\[P_{\textit{succ}} =1-P_{\textit{RF}}^{*}\] \[=1-\left(1-\left(1-P_{\textit{PHY}}\right)\left(\frac{W-1}{W} \right)^{n-1}\right)^{n} \tag{9}\]  
To illustrate the impact of the detector number on PHY layer performance in recovery, we allow \(W\) to be large enough so that the probability of success in MAC is \(\left(\frac{W-1}{W}\right)^{n-1}\approx 1\). Then we can approximate Equation (9) as  
\[P_{\textit{succ,PHY}}=1-P_{\textit{PHY}}^{n} \tag{10}\]To illustrate the impact of the number of detectors on MAC layer performance in recovery, we allow \(P_{\textit{PHY}}\) to be 0. Then we can rewrite Equation (10) as  
\[P_{\textit{succ,MAC}}=1-\left(1-\left(\frac{W-1}{W}\right)^{n-1}\right)^{n} \tag{11}\]  
We now briefly discuss some examples. Let \(W=10\), and \(P_{\textit{PHY}}=0.5\).