# Minimum-Cost-Based Neighbour Node Discovery Scheme for Fault Tolerance under IoT-Fog Networks
## 3 Materials and Methods
### Problem Formulation and Objective Function
To further check the remaining Fog access nodes, the task is offloaded to the N8 node. Again, it identifies the minimum cost from N2 for task-offloading. Finally, N2 is declared a processing node for task-processing because it has the minimum cost compared with other linked neighbouring candidate Fog access nodes. Figure 2: Identification of faulty Fog access nodes. For the second case in Algorithm 2, a simple example is taken from case 1 of the MC-NCND algorithm by considering all Fog access nodes and the busy states in the source Fog server. The structure of this is illustrated in Figure 4. Initially, the user device sends the task for processing to Fog access node N9, which acts as an initiator. The task will be offloaded to the neighbouring Fog server, which contains a minimum cost or the exact cost. Here, there are only two servers, so it offloads the task to server 2. Next, server 2 will find the next candidate Fog access node for task-processing; here, Fog access node N9 is identified as the initiator. By using the MCNCND algorithm, the node for task-processing will be found. Fog access node N9 will request the list of all linked neighbouring candidate Fog access nodes' costs; the cost of N1 is shown to be the minimum, so it then offloads the task to N1 for processing. Then, N1 will request the cost list and identify itself having the minimum cost as compared with other linked neighbouring candidate Fog access nodes. Finally, N1 is declared as the processing node for task-processing. The proposed MCNCND algorithm is summarized in Algorithm 2. Figure 4: Case 2: Neighbouring candidate node discovery in neighbouring Fog server. \[\mathrm{Opt}(\mathrm{E}_{r})=\max\{\mathrm{E}_{r};\mathrm{high}\ \mathrm{priority}(\mathrm{X}_{i})\}\]0 Case 1: Neighbouring candidate node discovery within the source Fog server. ```
1:Initialization: Fog server, \(\mathbf{F_{s}}\) = {S\({}_{1}\), S\({}_{2}\),......., S\({}_{8}\)},
2: Fog Node, \(\mathbf{F_{n}}\) = {N\({}_{1}\), N\({}_{2}\),......., N\({}_{nl}\)};
3: Fog control node, \(\mathbf{F_{nc}}\) = {N\({}_{\mathrm{C1}}\), N\({}_{\mathrm{C2}}\),......., N\({}_{\mathrm{cm}}\)},
4: Fog access node, \(\mathbf{F_{nn}}\) = {N\({}_{\mathrm{A1}}\), N\({}_{\mathrm{A2}}\),......., N\({}_{\mathrm{nn}}\)} with the condition of (a > c)
5:Begin
6:For i = 1,2,3,...., k
7: Receive task from IoT/user device
8: If \(\mathbf{F_{si}}\) \(\
eq\)\(\mathbf{F_{lan}}\) {\(\Phi\)} //_Source server with the neighbouring candidate Fog access nodes_
9: Calculate and broadcast the initial cost of Fog control node C\({}_{\mathrm{C1}}\), C\({}_{\mathrm{C2}}\),...., C\({}_{\mathrm{cm}}\)
10: Initiator (i) (source node) computes its own cost, C\({}_{\mathrm{Lai}}\)
11: Initiator sends a request to every linked neighbouring candidate Fog access node \"\(\mathbf{F_{la}}\)\" in the same server
12: Fog control nodes (\(\mathbf{F_{nc}}\)) will compute the cost function of all possible linked fog access nodes as follows: C\({}_{\mathrm{Lai}}\), C\({}_{\mathrm{Lai2}}\),...., C\({}_{\mathrm{lan}}\)
13: The initiator node will receive the cost list of all linked neighbouring nodes and Identify the Fog access node, stating whether the node is a candidate node or a busy node.