# An Eccentricity Based Data Routing Protocol with Uniform Node Distribution in 3D WSN
## 3 Proposed EDR Protocol
### RC Nodes Election Phase  
After completing the network initialization phase, the RC nodes election starts at \(T_{2}\) time. In this phase, each node finds the minimum average distance obtaining node from its own MADT. If the minimum \(MAD\) obtaining _node_id_ match with its own \(id\), it broadcasts a _Schedule_Msg_ according to the member nodes from its MADT within its radio range \(R_{\min}\). Otherwise, it will wait to receive the _Schedule_Msg_ from another minimum \(MAD\) obtaining member node in the same subspace. Meanwhile, the self-elected RC node updates its own MADT by changing its initial _node_type_ from '\(N\)' to '\(RC\)' and _flag_ bit from 0 to 1. Upon receiving the _Schedule_Msg_, each member node updates its own MADT by changing the initial _node_type_ and _flag_ bit of the elected RC node according to the index of that node. Once a node is elected as an RC, it will continue its role as the RC until its residual energy gets as below as the threshold energy level \(T_{E}\), which is defined by \(Ei/\alpha\), where \(Ei\) is the initial energy of a node and \(\alpha>0\) is a factor value.  
When an RC node's residual energy is less than or equal to the \(T_{E}\), after completing the data forwarding task, it broadcasts a _Not_Msg_ within its radio range \(R_{\min}\) and updates its own _node_type_ and _flag_ bit back to '\(N\)' and 0, respectively. On receiving the message, each member node updates its own MADT by changing the _node_type_ and _flag_ bit according to the index of the RC node and repeats the RC node election within the particular subspace. In this case, whenever all the nodes in a subspace have already participated as the RC node, the residual energy of each of the nodes will be less than the \(T_{E}\). In this scenario, the RC node election in the subspace will be based on the node's fitness value \(F_{1}\) defined in Equation (3) in a periodic fashion. The equation guarantees that the node which has less average distance and higher residual energy has a higher fitness value. For this, the nodes broadcast their estimated \(F_{1}\) along with their _Node_Msg_s. The member nodes receive the messages and update their MADT. A higher \(F_{1}\) obtained node will be elected as an RC node in each round.  
\[F_{1}=\ \beta\frac{s_{i}.Er\in SubS_{k}}{\sum_{j=1}^{m\in SubS_{k}}s_{j}.Ei}+( 1-\beta)\frac{1}{s_{i}.MAD}, \tag{3}\]  
where \(s_{i}.Er\) is the residual energy of a node in a subspace \(SubS_{k}\), \(s_{i}.Ei\) is the initial energy of a node in the same subspace, \(m\) is the number of member nodes in that subspace, and \(\beta\) is the weight factor value between 0 and 1.  
The details of this phase is given by the pseudo-code in Algorithm 2.  
```
start state \(\leftarrow\) Candidate and RC node election while(\(T_{2}\) has not expired) do if\(\textbf{s}_{i}\)_type == 'RC' & \(\textbf{s}_{i}\)_Er \(>T_{\text{E}}\)do  Continue as an RC node  if\(RC_{i}\)_Er \(\leq T_{\text{E}}\)do  Broadcast \(Not\_Msg\)  Update own MADT  Receive \(Node\_Msg\) (member nodes)  Update own MADT (member nodes)  end if elseif\(s_{1}\)_MADT(;7) == Null & \(\textbf{s}_{1}\)_Er \(>T_{\text{E}}\)do  Minimum \(MAD\) obtaining node is selected as an RC node from MADT  Update own MADT  Broadcast \(Schedule\_Msg\)  Receive \(Schedule\_Msg\) (member nodes)  Update MADT (member nodes) elseif\(s_{1}\)_MADT(;4) \(<T_{\text{E}}\)do  Broadcast \(F_{1}\) value with \(Node\_Msg\)  Receive the \(Node\_Msg\) (member nodes)  Update own MADT  Maximum \(F_{1}\) obtaining node is selected as an RC node from MADT  Broadcast \(Schedule\_Msg\)  Receive \(Schedule\_Msg\) (member nodes)  end if end
```  
**Algorithm 2**Routing centroid (RC) nodes election algorithm