## 4 Adaptive Fault-Tolerant Communication Scheme
### Resource Reservation Based on Priority Queue
As a result, the \(D_{i}^{\cdot}\) is recalculated as follows:  
\[D_{i}^{\cdot}=\max\left\{D_{i}\times\frac{BW_{\mathit{ideal}}\ /\ BW_{\mathit{ effective}}}{T_{i}^{\cdot}/T_{\mathit{minPkt}}},K_{\mathit{min}}\right\} \tag{7}\]  
The method described above assumes that all the sensors have fixed priorities. However, the priorities will be adjusted due to the change of physiological and external environments. Moreover, the bandwidths of some sensors cannot be reserved successfully due to the limited system resources. To tackle these problems, we present a feasible decision-making control of bandwidth allocation. We compute the requested data bandwidth \(BW_{\mathit{required}}\) and compare it with the actual effective bandwidth \(BW_{\mathit{effective}}\). Then we allocate the bandwidth based on the dynamic fault-tolerant priorities. Different from [11], the bandwidth reservation for fault-related information is considered as a portion of \(BW_{\mathit{required}}\). As illustrated in Figure 6, the requested data bandwidth \(BW_{\mathit{required}}\) includes four parts: (1) Reservations for non-polling packets (e.g., control packets for activation and dormancy) from the control node to sensors \(BW_{\mathit{CScontrol}}\); (2) Reservations for fault-related information packets (e.g., the packets including the information of battery usage, buffer usage, _etc._) from sensors to the control node \(BW_{\mathit{CSCaware}}\); (3) Reservations for sampled data packets from sensors to the control node \(BW_{\mathit{CSCdata}}\); (4) Reservations for polling packets from the control node to sensors \(BW_{\mathit{CSpolling}}\). We can consequently get the bandwidth requirements of all reservations in the system as follows:  
\[BW_{\mathit{required}}=BW_{\mathit{CScontrol}}+BW_{\mathit{CSCaware}}+BW_{ \mathit{SCdata}}+BW_{\mathit{CSpolling}} \tag{8}\]Figure 7 illustrates the process of bandwidth reservation decision-making. \(BW_{CScontrol}\) and \(BW_{SCaware}\) are reserved fist, and then the bandwidths of \(BW_{CSpolling}\) and \(BW_{SCdata}\) for sensors are reserved according to the order of fault-tolerant priority queue. We use an approach similar to BodyQoS [11] to divide the effective bandwidth into three parts: 0-\(B_{L}\)\(\times\)\(BW_{effective}\), \(B_{L}\)\(\times\)\(BW_{effective}\)\(\sim\)\(B_{H}\)\(\times\)\(BW_{effective}\), and \(B_{H}\)\(\times\)\(BW_{effective}\)-\(BW_{effective}\), where \(0<B_{L}<B_{H}<1\). The control node allocates unused wireless resources for best-effort communications. Algorithm 1 presents the pseudocode of the bandwidth reservation control algorithm used in AFTCS. A reservation sensor queue \(Q_{reserved}\) and a queue \(Q_{removed}\) containing all sensors removed from reservation queue are maintained through minimum heap and maximum heap respectively based on reliability requirements of sensors. If multiple sensors need to re-reserve bandwidth for fault-tolerance simultaneously, the sensors will be processed in priority descending order. The new reservation \(S_{add}\) for the sensor is handled according to the total required bandwidth \(BW_{required}\) (including the new reservation):  
(1) If the total required bandwidth \(BW_{required}\)\(\leq\)\(B_{L}\)\(\times\)\(BW_{effective}\), then the new reservation \(S_{add}\) is acceptable and \(S_{add}\) is added into \(Q_{reserved}\). (2) Under the condition of \(B_{L}\)\(\times\)\(BW_{effective}\)\(<\)\(BW_{required}\)\(\leq\)\(B_{H}\)\(\times\)\(BW_{effective}\), if the fault-tolerant priority of \(S_{add}\) is not less than the lowest fault-tolerant priority in \(Q_{reserved}\), then its new reservation is accepted and \(S_{add}\) is added into \(Q_{reserved}\). Otherwise, its new reservation is refused and \(S_{add}\) is added into \(Q_{removed}\).