# An Energy Efficient Routing Approach for IoT Enabled Underwater WSNs in Smart Cities
## 3 Motivation for U-(ACH)\({}^{2}\): Underwater Implementation of (ACH)\({}^{2}\)
#### Network Model
The hard threshold is responsible for sending data only when the sensed feature range is satisfied. Initially, the number of nodes and rounds is specified for simulation. During the transformation of data packets, a condition is required to be satisfied in which hard and soft thresholds are defined. Afterwards, the energy of the node is computed to identify whether it is alive or dead. The next step is the computation of total energy of the node. The count is incremented from node 1 to node 2, and so on, until no dead node is found. ```
1:procedure
2:\(\textit{rmax}\leftarrow\) no. of rounds
3:\(N\leftarrow\) no. of nodes
4:for\(r=1:1:rmax\)do
5: calculate cv
6:for\(i=1:1:N\)do
7:if\(S(i).E>0\)then
8:\(\textit{T\_Energy}=\textit{T\_Energy}+S(i).E\)
9:\(\textit{count}=\textit{count}+1\)
10:endif
11:endfor
12: calculate E_avg
13: calculate k_opt
14: call CH_Election
15: call CH_Selection
16:for\(i=1:1:N\)do
17: calculate min_dis_sink
18: calculate min_dis_CH
19:if\(\textit{min\_dis\_sink}<\textit{min\_dis\_CH}\)then
20:if\(cv>=h\)then
21:\(\textit{test}\gets cv-sv\)
22:if\(\textit{test}>=s\)then
23: send data directly to sink
24:endif
25:endif
26:endif
27:else
28:if\(cv>=h\)then
29:\(\textit{test}\gets cv-sv\)
30:if\(\textit{test}>=s\)then
31: send data to CH
32:endif
33:endif
34:endif
35:endfor
36:endprocedure
```  
**Algorithm 2** TEEN-ACH\({}^{2}\). Next, the E_avg and K_opt values are computed. A call is generated to the CH-Election function and then CH-selection function. The distance from the sensor node to CH and sink node is computed. The sensor node will transmit data to the CH if its distance value is less when compared to the sink node or vice versa. The sensor node forwards for the first time when the sensed value is total up to the hard threshold value. However, in a case to transmit for the second time, the sensed value should be larger than the hard threshold and it should be either larger or equal to the soft threshold value as shown in the algorithm. ```
1:procedure
2:\(\mathit{rmax}\leftarrow\) no. of rounds
3:\(N\leftarrow\) no. of nodes
4:for\(i=1:1:N\)do
5:if\(i>=m*N+1\)then
6:\(\mathrm{S(i).E}\)=E\({}_{0}\)
7:\(\mathrm{S(i).Energy}\)=0
8:endif
9:if\(i<m*N+1\)then
10:\(\mathrm{S(i).E}\)=E\({}_{0}\)*(1+a)
11:\(\mathrm{S(i).Energy}\)=1
12:endif
13:endfor
14:for\(r=1:1:rmax\)do
15:\(\mathit{p}\mathit{r}\mathit{r}=p/(1+a*m)\)
16:\(\mathit{p}\mathit{d}\mathit{v}=p*(1+a)/(1+a*m)\)
17:for\(i=1:1:N\)do
18:if\(\mathrm{S(i).E}>0\)then
19:\(\mathit{T}\_\mathit{Energy}\)\(=\)\(\mathit{T}\_\mathit{Energy}\)\(+\)\(\mathit{S(i).E}\)
20:\(\mathit{count}\)=\(\mathit{count}+1\)
21:endif
22:endfor
23: calculate E_avg, k_opt
24:while cluster!= k_opt_do
25:for\(i=1:1:N\)do
26:if\(\mathrm{S(i).E}>E\_\mathit{avg}\)then
27:\(\mathit{Temp}\leftarrow\) rand
28:if\(\mathrm{S(i).Energy}==0\)then
29:if\(\mathrm{Temp}\)\(<\)=\(\mathit{p}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\)/1-\(\mathit{p}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\)(\(\mathit{r}\mathit{r}\mathit{r}\mathit{r}\))) then
30: add node in c
31:endif
32:endif
33:endif
34:if\(\mathrm{S(i).Energy}==1\)then
35:if\(\mathrm{Temp}\)\(<\)=\(\mathit{p}\mathit{d}\mathit{v}\)/1-\(\mathit{p}\mathit{d}\mathit{v}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\mathit{r}\)(\(\mathit{r}\mathit{r}\mathit{r}\))) then
36: add node in c
37:endif
38:endif
39:endif
40:endfor
41:endwhile
42: call CH_Selection
43:for\(i=1:1:N\)do
44: calculate min_dis_sink
45: calculate min_dis_CH
46:if\(\mathit{min\_dis\_sink}<\mathit{min\_dis\_CH}\)then
47: send data directly to sink
48:else
49: send data to CH
50:endif
51:endfor
52:endfor
53:endfor
54:endfor
55:endprocedure
```  
**Algorithm 3** SEP-ACH\({}^{2}\). Like DEEC-ACH\({}^{2}\), the SEP-ACH\({}^{2}\) scheme is also based on heterogeneous scheme comprising of two different levels of energies, as shown in Algorithm 3. Initially, the number of nodes and rounds is specified for simulation, m is the percentage of advance nodes.