# Multi-Gateway-Based Energy Holes Avoidance Routing Protocol for WSN
## 6 Proposed Algorithm
In the proposed algorithm, if the initial value of the area is 500 \(\times\) 500 m\({}^{2}\), the initial value of Area 1 = Area 2 is 100 \(\times\) 100 m\({}^{2}\) and the initial value of \(R\) is 4 or \(R\) is 8, the area is divided in a similar manner as for Area = 100 \(\times\) 100 m\({}^{2}\). However, if the Area 1 = Area 2 is 75 \(\times\) 75 m\({}^{2}\) and number of regions \(R\) is 12, take the min and max values of the \(x\)-axis coordinates and divide the area into four equal parts and using the min and max values of the \(y\)-axis coordinates again divided the area into 12 regions. Set the Area 1 around the sink and Area 2 around the gateway nodes by using coordinates points (\(x\pm\) (Area 1 = Area 2)/2, \(y\pm\) (Area 1 = Area 2)/2) of the sink and gateways, respectively. Similarly, if the area is 1000 \(\times\) 1000 m\({}^{2}\) and \(R\) = 20, divide the area into \(R\) regions by using the min and max values of the \(x\)-axis and \(y\)-axis coordinates. If the area is 2000 \(\times\) 2000 m\({}^{2}\) and \(R\) = 42, divide the area into \(R\) regions by using the min and max values of the \(x\)-axis and \(y\)-axis coordinates. In general, as the size of the area and number of regions (\(R\)) increase, divided the area into equal sized regions by using the min and max values of the \(x\)-axis and \(y\)-axis coordinates, respectively. At each round, every normal sensor node sends data to its respective cluster head. The cluster heads perform data aggregation and send data to the gateway node which, again, aggregates data received from CHs and nodes in the gateway region (GR). After completing the data aggregation \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Value** \\ \hline \(E_{\rm init}\) & 0.5 J \\ \(E_{\rm elec}\) & 5 nJ /bit \\ \(E_{\rm fs}\) & 10 pJ/bit/m\({}^{2}\) \\ \(E_{\rm mp}\) & 0.0013 pJ/bit/m\({}^{4}\) \\ \(E_{\rm DA}\) & 5 pJ/bit \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Network simulation setup parameters. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Area** & **2 Gateways** & **4 Gateways** & **6 Gateways** & **8 Gateways** \\  & **Area 1 = Area 2** & **Area 1 = Area 2** & **Area 1 = Area 2** & **Area 1 = Area 2** \\ \hline
100 \(\times\) 100 m\({}^{2}\) & 20 \(\times\) 20 m\({}^{2}\) & 20 \(\times\) 20 m\({}^{2}\) & 15 \(\times\) 15 m\({}^{2}\) & 10 \(\times\) 10m\({}^{2}\) \\
200 \(\times\) 200 m\({}^{2}\) & 40 \(\times\) 40 m\({}^{2}\) & 40 \(\times\process, the gateway node transmits the data to the sink. The data aggregation is performed twice, which reduces the energy consumption to a great extent. Moreover, if some CH is nearer to the sink than a gateway node, it transmits data directly to the sink instead of the gateway node. This reduces the delay and increases the throughput in the network. Therefore, total data packets received by the sink from all gateway nodes and from nearby CHs are known as the throughput of the WSN. The stability period of the network is defined by the round number when the first node in the network exhausts its energy and dies (FND). The network lifetime is defined by the round number when all nodes of the network die (AND). HND denotes the round number when 50% of the nodes in the network die. Packets transmitted to the sink are the total number of packets sent by all sensor nodes to CHs, from CHs to gateway nodes, and from the gateways to the sink. Residual energy is the total remaining energy in the network per round. Figure 4a,b describe and compare all protocols' throughput for 100 sensor nodes in 100 \(\times\) 100 m\({}^{2}\) area and 500 \(\times\) 500 m\({}^{2}\) areas, respectively. By using the optimal number of gateways at proper positions, network throughput can be increased and a larger area can be monitored very well. The MGBEHA protocol outperforms other protocols in small areas as well as large areas. It is capable of producing throughput for a large number of rounds. When the number of gateways increases from 6 to 8, there is no difference in the throughput of the area.