# Investigating Master-Slave Architecture for Underwater Wireless Sensor Network
## 4 System Model
### Distribution of PFNs into Masters and Slaves  
The distribution of master and slave nodes is based on the values of the Master Selector Function (MSF). For the top 3 values of MSF, we rank the nodes as masters and the rest as slaves for that region. This master-slave race exists in both PFZ1 and PFZ2 regions.  
\[MSF=\frac{(P1+P2)*E_{n}}{Z} \tag{7}\]  
where \(E_{n}\) is the normalized form of that PFN's energy for whom we are finding the MSF. The parameter \(Z\) is the normalized depth, whose value ranges between 0 and 1 of that PFN. The parameters \(P1\) and \(P2\) are priority factors, dependent upon the population of PFNs in PFZ1 and PFZ2 regions of the next master respectively, while their values range between 1.0 and 0.5. These values are only applicable if the number of PFNs in both the regions (PFZ1 and PFZ2) is equal to or greater than 1. To find the next forwarder (master) closer to the sink, we considered these priority values. As discussed above, the forwarder will have a higher value of MSF. The value that contributes more in MSF is \(P1=1\) as compared to \(P2=0.5\) which clearly shows that the region PFZ1 gets the higher probability and hence the desired forwarder. Complete elaboration of this process is depicted in Figure 5.  
Our proposed approach is based on the master-slave architecture. The selection of master nodes is carried out via the defined Algorithm 1 (Master Selection Algorithm). The selection is based on the information of the neighboring nodes, stored in a neighboring table. Once a master node is selected, its information is stored in the master nodes table, which can be further used for selection at run time. The master node information of each node is stored in the mentioned master table. Before broadcasting a data packet to the surrounding, a control packet is sent to the neighborhood, to activate all master nodes and deactivate slave nodes. However, since it is a challenging task to accomplish at run time, we devised a formula called Master Selection Function (MSF). The mentioned formula filters out the best nodes among the neighbor nodes based on the energy, small depth difference, and number of PFNs. The resulted values from MSF are stored in an array, while the top 3 values from the array are stored in the master table. We assume that each transmitting node has the information of its neighbors as well as master nodes, as periodic requests are sent for updating the neighbor and master tables. These functions are achieved  
Figure 5: Master and Slave division.  
via control packets, which are used to broadcast control signals across the network and to enable or disable other nodes.  
```
for\(k\gets 1\)toNodes by \(1\)do  z=normalized energy  D=normalized depth  p1,p2,p3,p4=0 if\(S(k)\)has nodes in PFZthen  limit1=number of nodes in PFZ1 for\(i\gets 1\)to\(limit1\)by \(1\)do ifnode\(i\)has nodes in PFZ1 then  p1=1 ifnode\(i\)has nodes in PFZ2 then  p2=0.5  calculate MSF  MSF1[i]=MSF1  ID1[i]= ID of node i  p1,p2=0 if\(S(k)\)has nodes in PFZthen  limit2=number of nodes in PFZ2 for\(i\gets 1\)to\(limit2\)by \(1\)do ifnode\(i\)has nodes in PFZ1 then  p3=1 ifnode\(i\)has nodes in PFZ2 then  p4=0.5  calculate MSF  MSF1[i]=MSF2  ID1[i]= ID of node i  P3,p4=0 for\(n\gets 1\)to\(limit2\)by \(1\)do  RM1[1] = pick three best nodes from MSF1  RM2[2] = get three best nodes from MSF2
```  
**Algorithm 1**Masters selection algorithm