# Design of Encoding Algorithm for Underwater Wireless Optical Communication Based on Spinal Code
## 4 Theoretical Complexity Analysis of Superposition UEP-Spinal Code
\begin{array}{ll}T_{S}&=T_{Sm}+T_{Sl}\\ =\frac{n_{m}}{k_{1}}B_{Fm}2^{k_{1}}(v+k_{1}+\lg B_{Fm}+c)T_{hm}\\ &+\frac{n_{l}}{k_{2}}B_{Fl}2^{k_{2}}(v+k_{2}+k_{3}+\lg B_{Fl})T_{hl}\\ \leq B(\frac{n_{l}}{k_{1}}n_{m}(v+k_{1}+\lg B+c)T_{hm}\\ &+\frac{n_{l}}{k_{2}}n_{l}(v+k_{2}+k_{3}+\lg B)T_{hl})\end{array}  \tag{21}\]  
Among them, \(T_{Sm}\) and \(T_{Sl}\) represent the decoding times for \(m_{m}\) and \(m_{l}\), respectively, \(T_{hm}\) and \(T_{hl}\) represent the time required to generate a single hash value using the hash function for \(m_{m}\) and \(m_{l}\), and both \(B_{Fm}\) and \(B_{Fl}\) do not exceed the number of retained optimal nodes \(B\). The lower bound of \(T_{S}\) is  
\[T_{C}\geq(\frac{2^{k_{1}}}{k_{1}}n_{m}(v+k_{1}+c)T_{hm}+\frac{2^{k_{2}}}{k_{2} }n_{l}(v+k_{2}+k_{3})T_{hl}) \tag{22}\]  
Next, the decoding complexity of the two encoding schemes will be compared by contrasting the decoding times of Spinal codes and Superposition UEP-Spinal Codes. To more intuitively compare the theoretical decoding times, this paper will unify some encoding parameters for Spinal codes and Superposition UEP-Spinal Codes, thereby simplifying the equations. Simplification 1: Since different hash functions require different times to generate a single hash value, to avoid the impact of the hash function on the comparison of decoding complexity between Spinal codes and Superposition UEP-Spinal Codes, the same hash function is selected for hash value calculation, i.e., \(T_{h}=T_{hm}=T_{hl}\). Simplification 2: In Superposition UEP-Spinal Codes, the complexity and generation time of the check bits for \(m_{m}\) vary depending on the method used. To facilitate comparison with Spinal codes, the check bits for \(m_{m}\) are generated using RNG mapping, meaning \(l\) and \(c\) have the same complexity (\(l=c\)). To calculate the relationship between the code lengths of Superposition UEP-Spinal Codes and Spinal codes, the ratio of the original information quantities of \(m_{m}\) and \(m_{l}\) is set to 2:1, i.e., \(n_{m}/n_{l}=2\). Simplification 3: In Superposition UEP-Spinal Codes, the division length of the original information for \(m_{m}\) and \(m_{l}\) directly affects the amount of information contained in each hash value, thereby influencing the number of expanded nodes. By setting the division length of the original information for \(m_{m}\) and \(m_{l}\) to be the same \((k_{1}=k_{2}+k_{3}=k)\), the amount of information contained in each hash value can be ensured to be the same, facilitating the control of the number of decoding expanded nodes in Simplification 3. Simplification 4: Adjustments to the weight factor matrix \(P\) can alter the transmission performance of \(m_{m}\) and \(m_{l}\), thereby affecting the number of decoding expanded nodes. Therefore, the weight factor matrix \(P\) is fixed to be all ones, meaning the protection properties for \(m_{m}\) and \(m_{l}\) are the same. Combined with Simplification 3, it can be inferred that the number of decoding expanded nodes is the same, i.e., \(B_{Fm}=B_{Fl}\). Based on the above simplifications, it can be calculated that \(c=3v/2\), and the code length of the Superposition UEP-Spinal Codes \(Ls=4 nv/(3k)\). This means that a Spinal code of the same length needs to generate random numbers \(l=4v/3\) through RNG mapping. The decoding times for Spinal codes and Superposition UEP-Spinal Codes of the same length can be simplified from Equations (12) and (20), as follows:  
\[T_{R}=\frac{n}{k}B_{F}2^{k}(\frac{7}{3}v+k+\log B_{F})T_{h} \tag{23}\]  
\[T_{S}=\frac{n}{k}B_{F}2^{k}(2v+k+\log B_{F})T_{h} \tag{24}\]  
The lower bounds of the two are  
\[T_{R}=\frac{n}{k}2^{k}(\frac{7}{3}v+k)T_{h} \tag{25}\]  
\[T_{S}=\frac{n}{k}2^{k}(2v+k)T_{h} \tag{26}\]  
It is not difficult to see that there will be a difference in decoding time between the two lower bounds of \(nv2^{k}/(3k)T_{h}\). The difference in decoding complexity will further increase with the length of the hash function \(v\) and the number of expanded nodes \(\text{B}_{\text{F}}\).