## 3 Physical-Layer Network Coding Based on Block Markov Superposition Transmission  
### Encoding Algorithm  
To mitigate asymmetric channel impairments in maritime TWRNs, we employ the repetition and single-parity-check (RSPC) codes as the basic codes for BMST. These fixed-length multi-rate codes, constructed via time-sharing between the repetition (R) codes and the single-parity-check (SPC) codes, inherently satisfy PNC's fundamental requirement of equal-length signal blocks from source nodes while accommodating link asymmetry. Let \(\mathcal{C}[n,k]\) denote a binary linear code with an input of \(k\) bits and an output of \(n\) bits. For any given integer \(n>1\), the R code and the SPC code can be denoted as \(\mathcal{C}[n,1]\) and \(\mathcal{C}[n,n-1]\), respectively. Mathematically, the structure of an RSPC code is given by the Cartesian product of \(\mathcal{C}^{\alpha}[n,1]\times\mathcal{C}^{\beta}[n,n-1]\). This implies that the R code is utilized \(\alpha\) times in the procedure, while the SPC code is utilized \(\beta\) times. The structure of an RSPC code is shown in Figure 3, and the code rate \(\mathcal{R}\) can be expressed as  
\[\mathcal{R}=\frac{\alpha}{\alpha+\beta}\cdot\frac{1}{n}+\frac{\beta}{\alpha+ \beta}\cdot\frac{n-1}{n}. \tag{5}\]  
For a target code rate ranging from \(1/n\) to \((n-1)/n\), we can implement it by setting \(\beta=k-1\) and \(\alpha=n-2-\beta\). It is evident that the RSPC codes with varying code rates possess the same length \((\alpha+\beta)n=n(n-2)\), which indicates that they can be encoded/decoded without hardware reconfiguration through adjustments in \((\alpha,\beta)\). Taking \(n=4\) and \(k=2\) as an example, the generator matrix \(G\) corresponding to the RSPC code has the following form:  
\[G= \begin{bmatrix}1&1&1&1&0&0&0&0\\ 0&0&0&0&1&0&0&1\\ 0&0&0&0&0&1&0&1\\ 0&0&0&0&0&0&1&1\end{bmatrix} . \tag{6}\]  
For more details, refer to [33]. To boost the reliability of maritime data transfer, BMST coding is applied at the source node. During this process, each codeword is replicated and then superimposed onto subsequent codewords for transmission (see Figure 4 for reference). This approach achieves coding gain through repetition while guaranteeing transmission efficiency. BMST enables the upgrade construction from arbitrary short/weak basic codes to long/strong codes through its unique encoding mechanism. The encoding procedure for source node \(N_{i}\) is shown in Figure 5, in which \(\boxed{D}\), \(\boxed{\Pi}\), and \(\boxed{\Pi}\) represent a shift register, an interleaver, and the modulo-2 addition, respectively. Figure 3: This is the structure for RSPC code. Let \(\mathbf{u}_{i}^{(t)}=(u_{i,0}^{(t)},u_{i,1}^{(t)},\cdots,u_{i,k(n-2)-1}^{(t)})\in\mathbb{F }_{2}^{k(n-2)}\) be the \(t\)-th block of the binary sequence generated by source node \(N_{i}\). The binary sequence \(\mathbf{u}_{i}=(\mathbf{u}_{i}^{(0)},\mathbf{u}_{i}^{(1)},\cdots,\mathbf{u}_{i}^{(L-1)})\) with \(L\) blocks is sent to the encoder of the RSPC code \(\mathcal{C}[n(n-2),k(n-2)]\) in turn, yielding a coded sequence \(\mathbf{c}_{i}=(\mathbf{c}_{i}^{(0)},\mathbf{c}_{i}^{(1)},\cdots,\mathbf{c}_{i}^{(L+m-1)})\) with \(L+m\) blocks, where \(m\), called the memory, is the number of registers in the BMST system. Each sub-block \(\mathbf{c}_{i}^{(t)}=(c_{i,0}^{(t)},c_{i,1}^{(t)},\cdots,c_{i,n(n-2)-1}^{(t)})\in \mathbb{F}_{2}^{n(n-2)}\), \(0\leq t\leq L+m-1\) can be expressed by  
\[\mathbf{c}_{i}^{(t)}=\mathbf{u}_{i}^{(t)}\mathbf{G}\mathbf{\Pi}_{0}+\mathbf{u}_{i}^{(t-1)}\mathbf{G} \mathbf{\Pi}_{1}+\cdots+\mathbf{u}_{i}^{(t-m)}\mathbf{G}\mathbf{\Pi}_{m}, \tag{7}\]  
where \(\mathbf{G}\) is a \(k(n-2)\times n(n-2)\) generator matrix of RSPC code and \(\mathbf{\Pi}_{j}\) (\(0\leq j\leq m\)) is a \(n(n-2)\times n(n-2)\) permutation matrix. Note that, for \(t<0\), \(\mathbf{u}_{i}^{(t)}\) is set to a zero vector initially. The detailed encoding algorithm is presented in Algorithm 1. ```
Initialization: Set \(\mathbf{v}_{i}^{(t)}=\mathbf{0}\in\mathbb{F}_{2}^{n(n-2)}\) for all \(t<0\).