## 3 Design of SOCA
### Slot Selection for Collision Avoidance  
After the TDMA channel selection is completed, the ship station conducts collision avoidance slot selection on the selected TDMA channel. To reduce collisions with AIS caused by VDE-TER data transmission, the ship station should prioritize candidate slots that are not potentially occupied by itself or its neighboring stations for AIS message transmission. We define the probability of a candidate slot being occupied by the ship station itself or its neighboring stations for AIS message transmission as the expected slot occupancy probability. A candidate slot is considered more interference-resilient if it has a lower expected slot occupancy probability. The ship station calculates the expected slot occupancy probability for candidate slots within the selected TDMA channel to perform collision avoidance slot selection for VDE-TER data transmission. The expected slot occupancy probability for the candidate slot (\(p_{k}\)) in the TDMA channel selected by the ship station is given by  
\[p_{k}=1-\prod_{m\in\mathbf{STA}}(1-p_{m,k}),\]where \(k\) denotes the slot number of the candidate slot. **STA** represents the set consisting of the ship station and its neighboring stations. \(p_{m,k}\) represents the probability that slot \(k\) can be used by ship station \(m\) to transmit an AIS message, as given by  
\[p_{m,k}=\frac{1}{l_{S_{lm}}}\cdot\delta_{k\in\textbf{SI}_{m}}, \tag{7}\]  
where \(l_{S_{lm}}\) represents the length of the SI for the ship station \(m\). \(\textbf{SI}_{m}\) represents the set of slot numbers within the SIs of the current TDMA frame for the ship station \(m\). \(\delta_{k\in\textbf{SI}_{m}}\) indicates whether slot \(k\) is within \(\textbf{SI}_{m}\), being 1 if exists and 0 otherwise. Following the calculation of the expected slot occupancy probabilities for all candidate slots within the selected TDMA channel, the ship station performs normalization on these probabilities. The normalized expected slot occupancy probability of slot \(k\) (\(p^{\prime}_{k}\)) is given by  
\[p^{\prime}_{k}=\frac{p_{k}}{\sum_{j\in\textbf{CS}_{ch}}p_{j}}, \tag{8}\]  
where \(\textbf{CS}_{ch}\) represents the candidate slot list for the TDMA channel selected by the ship station. \(p_{j}\) represents the expected slot occupancy probability of the candidate slot with slot number \(j\) in \(\textbf{CS}_{ch}\). The ship station maintains a list of the normalized expected slot occupancy probabilities for all candidate slots in the selected TDMA channel (\(\textbf{P}_{ch}\)). \(\textbf{P}_{ch}\) can be represented by  
\[\textbf{P}_{ch}=\left[p^{\prime}_{1,ch},p^{\prime}_{2,ch},\cdots,p^{\prime}_{i, ch},\cdots,p^{\prime}_{n_{cs},ch}\right], \tag{9}\]  
where \(p^{\prime}_{i,ch}\) and \(p^{\prime}_{n_{cs},ch}\) represent the normalized expected slot occupancy probability of the \(i\)-th candidate slot and the number of candidate slots within the TDMA channel selected by the ship station. Finally, the ship station conducts collision avoidance slot selection based on the normalized expected slot occupancy probabilities of all candidate slots in the selected TDMA channel. Algorithm 2 presents the procedure for the collision avoidance slot selection. The algorithm takes \(n_{req}\), \(\textbf{CS}_{ch}\), and \(\textbf{P}_{ch}\) as inputs. The output of the algorithm is a list, denoted as **SN**, containing the slot numbers of the candidate slots selected from \(\textbf{CS}_{ch}\). ```
Input:\(n_{req}\), \(\textbf{CS}_{ch}\) and \(\textbf{P}_{ch}\) Output: SN Initialize:
1:\(\textbf{SN}\leftarrow[\ ]\)
2:\(val\gets 0\)
3:\(idx\gets 0\)
4:for\(i=1\) to \(n_{req}\)do
5:\([val,idx]\gets min(\textbf{P}_{ch})\)
6:\(\textbf{SN}\leftarrow\textbf{CS}_{ch}(idx)\)
7: Remove \(val\) from \(\textbf{P}_{ch}\)
8:endfor
9:return SN
```  
**Algorithm 2** Slot selection for collison avoidance  
The algorithm first defines **SN** and initializes it to an empty list. It also defines \(val\) and \(idx\), initializing both to zero.