# Data-Driven Packet Loss Estimation for Node Healthy Sensing in Decentralized Cluster
## 4 The PingBasedDown Algorithm
### Decision Model
#### 4.2.2 Leader Determination Module
 \tag{21}\]  
The second approach is fetching healthy states from remote nodes. In the condition that the transitivity is not applicable, we have to fetch all the partial topologies from remote nodes and combine them to a global topology. This helps us to choose a unique leader in this module and further help to do execution in the next module. Recall the very first of this section, partial topology in node \(v_{x}\) are denoted by a group of directed graphs \(G^{\prime}(v_{x})=(V,E^{\prime}(v_{x}))\) and \(\overline{G}^{\prime}(v_{x})=(V,\overline{E}^{\prime}(v_{x}))\) and the global topology is denoted by an undirected graph \(G=(V,E)\). For an arbitrary healthy node \(v_{i}\), the target of this module is to fetch the remote partial \(G^{\prime}(v)\) for \(v\in V-\{v_{i}\}\), and combine these \(G^{\prime}(v)\) to an undirected graph \(G^{\prime}=(V,E^{\prime})\) which is expected to be equal to \(G\). When a node successfully constructs \(G^{\prime}\), it will be able to calculate the states of nodes using the approach provided in Self-Checking module. The candidate rule can then be defined as:\[r_{c}(v_{i},v_{j})= \begin{cases}TRUE,&deg_{G^{\prime}}(v_{j})>[\frac{|V|}{2}]-1,\\ FALSE,&otherwise.\end{cases}  \tag{22}\]  
To introduce our approach in detail, we here make definitions on Healthy observation set and Unhealthy observation set of nodes. Definition 6: Healthy observation set of an arbitrary node \(v_{x}\) is the set of nodes that the link between them and \(v_{x}\) is healthy, which can be expressed as \(S_{h}(v_{x}):=\big{\{}v:v\in V\setminus\{v_{x}\},s_{l}(v_{x},v)=\text{Healthy} \big{\}}\). Definition 7: Unhealthy observation set is defined as \(v_{x}\): \(\overline{S_{h}}(v_{x}):=\big{\{}v:v\in V\setminus\{v_{x}\},s_{l}(v_{x},v)= \text{Unhealthy}\big{\}}\). For implementation, we also use \(s^{\prime}_{l}(I_{n}(v_{i},v_{j}))\) to approximate \(s_{l}(v_{i},v_{j})\) in order to obtain the observed \(S_{h}\) and \(\overline{S_{h}}\) in each node. To combine the partial topologies into a global topology, we have to deal with the following issues (suppose the local node is \(v_{l}\)). First, \(v_{l}\) fetches partial topologies from the nodes in \(S_{h}(v_{l})\) directly. Then, \(v_{l}\) asks for partial topologies of unreachable nodes, i.e., nodes in \(\overline{S_{h}}(v_{l})\), with the help of nodes in \(S_{h}(v_{i})\). While fetching partial topologies, handle the ask timeout. While combining the partial topologies, check for and resolve the conflict state of a certain edge from two sides of nodes. Finally, give the combination result. Algorithms 2-4 shows the full workflow of this module. Algorithms 2 shows the workflow of fetching and combining process. This process is started by the initiator who tries to acquire the global topology. It first initializes a pair of mutable graphs \((\mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime})\), which will eventually hold the combination result, i.e., global graph; a mutable set \(V_{seen}\), which indicates whose sub connectivity graphs have been combined into the the intermediate \(\mathcal{G}^{\prime}\) and \(\overline{\mathcal{G}}^{\prime}\), an immutable Healthy observation set \(S_{h}\). For all nodes in \(S_{h}\cap V_{t}\), it sends a _AskTopo_ RPC to these nodes. If a _ReplyTopo_ is replied, try to merge the replied graph \(G^{\prime}(v_{r}),\overline{\mathcal{G}}^{\prime}(v_{r})\) with \(\mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime}\). If merging process succeeded, combine the returned seen set \(V^{\prime}_{seen}\) with the local seen set \(V_{seen}\). If merging process failed, stop the fetching and combining process immediately and report the conflict issue. If no _ReplyTopo_ is replied, mark the edge from the local node to this remote node as Unhealthy and also add this remote node into seen set. Algorithm 4 shows the workflow when a node receives a _AskTopo_ RPC.