# Data-Driven Packet Loss Estimation for Node Healthy Sensing in Decentralized Cluster
## 4 The PingBasedDown Algorithm
### Decision Model
#### 4.2.2 Leader Determination Module
If the sender of this RPC asks for aid to grab sub connectivity graphs from other nodes in \(\overline{S^{r}_{h}}\) (because the sender cannot connect to these nodes), the receiver will invoke FetchAndCombine and set the parameter \(V_{t}\) to be \(S_{h}\cap\overline{S^{r}_{h}}\). If \(V_{t}=\emptyset\), the FetchAndCombine will do nothing but return its own sub graph. After FetchAndCombine process is completed, the receiver will pack the combine result into ReplyTopo message and send back to the sender of AskTopo RPC. ```
Input:  the node set \(V\)  local node \(v_{l}\)  its sub connectivity graph \(G^{\prime}(v_{l})=(V,E^{\prime}(v_{l}))\), \(\overline{G}^{\prime}(v_{l})=(V,\overline{E}^{\prime}(v_{l}))\)  node set \(V_{aid}\) that need others help to fetch. Initialize: \(\mathcal{E}^{\prime}\gets E^{\prime}(v_{l})\), \(\mathcal{G}^{\prime}\leftarrow(V,\mathcal{E}^{\prime})\) \(\overline{\mathcal{E}}^{\prime}\leftarrow\overline{E}^{\prime}(v_{l})\), \(\overline{\mathcal{G}}^{\prime}\leftarrow(V,\overline{\mathcal{E}}^{\prime})\) \(V_{seen}\leftarrow\{v_{l}\}\) \(S_{h}\gets V\setminus\overline{E}^{\prime}(v_{l})\) for\(v_{r}\in\ S_{h}\cap V_{t}\)do  Send a RPC AskTopo(\(v_{l}\), \(V_{aid}\)) to \(v_{r}\) ifGot the ReplyTopo(\(G^{\prime}(v_{r}),\overline{G}^{\prime}(v_{r})\), \(V^{r}_{seen}\)) then \((\mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime},status)\gets Merge( \mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime},V_{seen},G^{\prime}(v_{r}),\overline{G}^{\prime}(v_{r}),V^{r}_{seen})\) ifstatus \(\
eq\) successthen return\((\emptyset,\emptyset),(\emptyset,\emptyset), conflict\) else \(V_{seen}\gets V_{seen}\cup V^{r}_{seen}\) else \(V_{seen}\gets V_{seen}\cup\{v_{r}\}\) \(\overline{\mathcal{E}}^{\prime}\leftarrow\overline{\mathcal{E}}^{\prime}\cup(v_ {l},v_{r})\) return\(\mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime},success\)
```  
**Algorithm 2**Fetching and combining algorithm. \(\text{FetchAndCombine}(V,v_{l},G^{\prime},\overline{G}^{\prime},V_{t},V_{aid})\). ```
Input:  first and second graph to merge \(G_{1},G_{2};\overline{G}_{1},\overline{G}_{2}\)  first and second observers set \(V^{seen}_{1},V^{seen}_{2}\) Initialize: \(\mathcal{E}^{\prime}\leftarrow\emptyset\), \(\mathcal{G}^{\prime}\leftarrow(V,\mathcal{E}^{\prime})\) \(\overline{\mathcal{E}}^{\prime}\leftarrow\emptyset\), \(\overline{\mathcal{G}}^{\prime}\leftarrow(V,\overline{\mathcal{E}}^{\prime})\) for\(e\in V^{seen}_{1}\times V^{seen}_{2}\)do if(\(e\in G_{1}\) and \(e\in\overline{G}_{2}\)) or (\(e\in G_{2}\) and \(e\in\overline{G}_{1}\))then return\((\emptyset,\emptyset),(\emptyset,\emptyset), conflict\) else if\(e\in G_{1}\) or \(e\in G_{2}\)then \(\mathcal{E}^{\prime}\leftarrow\mathcal{E}^{\prime}\cup\{e\}\) if\(e\in\overline{G}_{1}\) or \(e\in\overline{G}_{2}\)then \(\mathcal{E}^{\prime}\leftarrow\overline{\mathcal{E}}^{\prime}\cup\{e\}\) return\(\mathcal{G}^{\prime},\overline{\mathcal{G}}^{\prime},success\)
```  
**Algorithm 3**Merging algorithm. \(\text{Merge}(G_{1},\overline{G}_{1},V^{seen}_{1},G_{2},\overline{G}_{2},V^{seen}_{2})\). ```
Input:  first and second graph to merge \(G_{1},G_{2};\overline{G}_{1},\overline{G}_{2}\)  first and second observers set \(V^{seen}_{1},V^{seen}_{2}\) Initialize: \(\mathcal{E}^{\prime}\leftarrow\emptyset\), \(\mathcal{G}^{\prime}\leftarrow(V,\mathcal{E}^{\prime})\) \(\overline{\mathcal{E}}^{\prime}\leftarrow\emptyset\), \(\overline{\mathcal{G}}^{\prime}\leftarrow(V,\overline{\mathcal{E}}^{\prime})\) for\(e\in V^{seen}_{1}\times V^{seen}_{2}\)do if(\(e\in G_{1}\) and \(e\in\overline{G}_{2}\)) or (\(e\in G_{2}\) and \(e\in\overline{G}_{1}\))then return\((\emptyset,\emptyset),(\emptyset,\emptyset), conflict\) else if\(eGenerally speaking, the workflow is that, the initiator \(v_{i}\) starts the fetching process by calling \(\text{FetchAndCombine}(V,v_{i},G^{\prime}(v_{i}),\overline{G}^{\prime}(v_{i}),S_{ h}(v_{i}),\overline{S_{h}}(v_{i}))\), which will send AskTopo RPCs to all reachable remote nodes. This will trigger the process of Algorithm 4 in all these remote nodes.