## 3 API Protocol
As shown in Figure 2, the time duration of a round differs from each other because it depends on the number of sub-rounds. Hence, the time duration of \(R_{k}\) can be obtained from the equation: \(R_{k}=\ Q_{k}\times\tau\). * All parameters defined for the API are summarized in Table 2.  
In the API, a master node controls overall network initialization. A master node performs the following procedures in one round:  
1. At the start of a round, a master node randomly chooses \(Q_{k}\) slave nodes among uninitialized slave nodes and activates the selected slave nodes via a one-by-one initialization process. The number of selected slave nodes and the selected slave nodes vary according to the initialization round. In the case of \(R_{1}\), a master node determines the number of sub-rounds \(Q_{1}\) as the same as the application requirement. 2. The master node then starts initializing slave nodes sequentially during \(Q_{k}\) sub-rounds. At each sub-round, the master node sends an initialization request message to one of the selected slave nodes and waits for the initialization response message from the slave node during \(\tau\). If the master node receives an initialization response from the slave node before the expiration of that sub-round, it adds the slave node to the initialization success list. Otherwise, the master node confirms that the slave node failed to be initialized in that round. This one-to-one initialization is performed in ascending order of the slave node index. 3. At the end of the round, the master node counts the number of slave nodes that were successfully initialized during \(R_{k}\), which is denoted by \(\overline{Q}_{k}\). Additionally, the master node calculates the accumulated number of slave nodes that have been successfully initialized until \(R_{k}\), denoted by \(N_{k}\). \(N_{k}\) is expressed as \(N_{k}=\sum_{i=1}^{k}\overline{Q}_{i}\). The master node then checks whether the number of accumulated slave nodes that are successfully initialized satisfies the application requirement (i.e., \(N_{k}\geq Q_{1}\)). \begin{table}
\begin{tabular}{c c} \hline
**Parameters** & **Description** \\ \hline \(N\) & The number of slave nodes \\ \(K\) & The maximum number of repetitions (or rounds) \\ \(k\) & An index of a round (\(1\leq k\leq K\)) \\ \(R_{k}\) & The \(k_{th}\) round \\ \(\underline{Q}_{k}\) & The number of sub-rounds in \(R_{k}\) \\ \(\overline{Q}_{k}\) & The number of slave nodes that are successfully initialized in \(R_{k}\) \\ \(l\) & An index of a sub-round \\ \(SR_{l}\) & The \(l_{th}\) sub-round \\ \(\tau\) & The time duration of a sub-round \\ \(N_{k}\) & The accumulated number of slave nodes that are successfully initialized until \(R_{k}\) \\ \hline \end{tabular}
\end{table} 
Table 2: The description of parameters for the API protocol. Figure 2: The illustration of the concept of a round and a sub-round in the API protocol. * If the application requirement is satisfied, the master node terminates the initialization stage and goes to the operational stage. * Otherwise, the master node increases the round index by 1 and checks whether the index exceeds the maximum number of rounds, \(K\). * If the increased index value exceeds \(K\), the master node also terminates the initialization stage. This extreme case implies that the underwater channel is disabled and a UWASN failure occurs. In this case, the network initialization process needs to be restarted when the channel condition is good. * Otherwise, the master proceeds to the next round and goes to Step 2. The pseudo code for the API algorithm for a master node is specified in Algorithm 1. ```
1:for\(k=1:1:K\)
2:if\(k=1\) then
3: Set \(Q_{1}\) according to the application requirement. 4:else
5: Set \(Q_{k}=Q_{k-1}-\overline{Q}_{k-1}\)
6:endif
7: Randomly select \(Q_{k}\) slave nodes among uninitialized slave nodes. 8: Set \(\overline{Q}_{k}=0\). 9:for\(j=1:1:Q_{k}\)
10: Send an initialization request message to an initialized slave node. 11: Wait for an initialization response message from the slave node during \(\tau\).