## 4 Proposed Protocol
### Fuzzy Logic  
Fuzzy logic is a type of multi-valued logic that deals with reasoning to provide an approximate rather than exact result. Fuzzy logic is also used for estimating and making a decision among multiple variables. Figure 4 shows a block diagram that illustrates the block diagram of a fuzzy logic system. Fuzzy inference is the name of the process of mapping a given input to an output using fuzzy logic. As already mentioned in the previous section, a fuzzy logic system, also called fuzzy inference system, has three stages: Fuzzifier, core decision stage, or Fuzzy Inference Engine, and Defuzzifier, as shown in Figure 4. In the first and third stages, linguistic terms are used to map the stage input variables to the real interval [0,1]. The mapping is performed by the so-called membership functions. The linguistic terms are shown in Tables 1 and 2. The fuzzy inference provides a basis from which decisions can be made or patterns distinguished [20]. The system output is a real number in the interval [0,1]. The term Chance is used to refer to either the linguistic term or the numerical values. It has been found that Chance is a good name to represent the score of a node to be chosen as forwarding node. The three stages of the system are described below. There is a membership function associated to every linguistic term in Table 1. The first stage is to evaluate the membership functions for each input (number of hops, number of neighbors and distance). The triangular membership functions are described as [21]  
\[\mu(x)=\left\{ \begin{array}{ll}0,&x\leq a\\ \frac{x-a}{b-a},&a\leq x\leq b\\ \frac{c-x}{c-b},&b\leq x\leq c\\ 0&c\leq x\end{array} \right. \tag{14}\] \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Input** & \multicolumn{2}{c}{**Membership**} \\ \hline Number of hops & Minimum & Average & Maximum \\ Number of neighbors & Minimum & Average & Maximum \\ Distance & Near & Close & Far \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Fuzzification linguistic terms. Figure 4: Block diagram of a fuzzy logic system. The membership function \(\mu(x)\) provides the degree of membership. In Figure 5a-c, the three used membership functions are shown jointly with the associated linguistics terms. Stage 2: Fuzzy Rules  
Fuzzy rules are based on _IF-THEN_ consequences by applying Boolean _AND_/_OR_ operations to the input. To do that, Mamdani method has been used. As an example, the fuzzy rules for the limit values of Chance are explained (limit values of Chance are Best and Worst; they are used because they are more illustrative than others):  
Instance 1: _IF_ number of hops are Minimum, _AND_ number of neighbors are Minimum _AND_ RSSI distance is Near, _THEN_ Chance of packet forwarding is Very Best. Instance 2: _IF_ number of hops are Maximum, _AND_ number of neighbors are Maximum _AND_ RSSI distance is Far, _THEN_ Chance of packet forwarding is Worst. In the problem of underwater routing, the proposal to choose the candidate nodes for packet forwarding is based on the fuzzy rules described in the Table 3.  
Figure 5: Memberships functions used in the fuzzification (**a–c**) and defuzzification (**d**) stages. The defuzzification stage involves two steps. In the first step, the membership function of Figure 5d is evaluated at the values obtained in the second stage. In the second step, a single number is obtained. In this work, the Center of Mass (CoM) method has been used, and the single number is calculated as  
\[z=\frac{\sum_{i=1}^{q}x_{i}\,\mu(x_{i})}{\sum_{i=1}^{q}\mu(x_{i})}\, \tag{15}\]  
where \(\mu(x)\) are the triangles of Figure 5d, and \(z\) is Chance. The node with a larger value \(z\) is the node with better Chance to be the forwarding node. Table 4 shows some examples of the results obtained.