# Enhancing Unmanned Marine Vehicle Security: A Periodic Watermark-Based Detection of Replay Attacks
## 3 A Periodic Watermark-Based Detection of Replay Attacks
### Construction of Periodic Compensation Signal  
To construct the auxiliary system for obtaining the measurement compensation signal \(y^{f}(k)\) after watermark insertion (\(k>t_{0}\)):  
\[\left\{\begin{aligned} x^{f}(k+1)&=\sum_{p=1}^{3} \hbar_{p}(\Delta o(k))\Big{(}A_{dp}x^{f}(k)+B_{di}\Delta o(k)\Big{)}\\ y^{f}(k)&=-Cx^{f}(k)\end{aligned}\right. \tag{15}\]  
where \(x^{f}(t_{0})=0\).  
Theorem 1: _Assume \(A_{dp}\) is stable, there exits an \(n_{0}\in\mathbb{N}^{r}\) such that \(A_{dp}^{(n_{0}-1)T}\approx 0\). By introducing watermark signals into the UMVs system over \(n_{0}\) periods, the compensatory signal \(y^{f}(k)\) achieves periodicity for \(k\geq t_{0}+n_{0}T\), mirroring the periodic nature of the watermark. A series of these compensatory signals \(\mathbb{Y}^{f}=[\mathbb{Y}^{f}(0),\mathbb{Y}^{f}(1),\ldots,\mathbb{Y}^{f}(T-1 )]\). Therefore, each compensatory signal within a period corresponds directly to its associated watermark signal, as demonstrated by the relationship \(o(i-1)\leftrightarrow\mathbb{Y}^{f}(i)\), where \(i=(k-t_{0})\mod T\)._  
Proof: To demonstrate that the compensation signal \(y^{f}(k)\) becomes periodic for \(k\geq t_{0}+n_{0}T\), it suffices to prove that the compensation state \(x^{f}(k)\) becomes periodic for \(k\geq t_{0}+n_{0}T\). When \(k\in[t_{0},t_{0}+T-1]\), the compensation signal state can be expressed as:  
\[\begin{aligned} x^{f}(k)=&\sum_{p=1}^{3} \hbar_{p}(\varrho(k))(A_{dp}x^{f}(k)+B_{dp}\Delta o(k))\\ =&\sum_{i=0}^{k-t_{0}}\sum_{p=1}^{3}\hbar_{p}(\varrho (k))\Big{(}A_{dp}x^{f}(k)^{i}B_{dp}\Delta o(k-t_{0}-i)\Big{)}\end{aligned} \tag{16}\]  
When \(k=t_{0}+nT+i\), with \(i\in[0,T-1]\) and \(n\in\mathbb{N}^{r}\), the compensation signal state can be represented as:  
\[\begin{aligned} x^{f}(k)=& x^{f}(t_{0}+nT+i)\\ =&\sum_{p=1}^{3}\hbar_{p}\varrho(k)(A_{dp}x^{f}(t_{ 0}+nT+i-1))^{i}B_{dp}\Delta o(t_{0}+nT+i-1))\\ =&\sum_{p=1}^{3}\hbar_{p}\varrho(k)((A_{dp}{}^{2}(A_ {dp}x^{f}(t_{0}+nT+i-3))^{i}B_{dp}\Delta o(i-3)))+A_{dp}B_{dp}\Delta o(i-2)) +B_{dp}\Delta o(i-1)\\ =&\sum_{p=1}^{3}\hbar_{p}\varrho(k)(A_{dp}{}^{(n-1)T} +x^{f}(t_{0}+T)+x^{f}(t_{0}+(l-1)T+i))\end{aligned} \tag{17}\]  
Given the stability of the transition matrix \(A_{dp}\), an integer \(n_{0}\in\mathbb{N}^{r}\) is identified for which \(A_{dp}^{(n_{0}-1)T}\approx 0\). This value of \(n_{0}\) is determined solely by the matrix \(A_{dp}\). Consequently, it is observed that for \(n\geq n_{0}\), the state \(x^{f}(t_{0}+nT+i)=x^{f}(t_{0}+(n-1)T+i)\). We can achieve  
\[x^{f}(k)=x^{f}(k-T) \tag{18}\]It is indicated in (18) that the state values of the compensatory signal are deduced to become periodic after \(n_{0}\) operational periods, reflecting the periodicity of the watermark signal. With the independence of watermark signals within each period, the state of the compensatory signal is confirmed to be distinct within any given period. Given that the compensatory signal \(y^{\prime}(k)\) is defined as \(y^{\prime}(k)=-Cx^{\prime}(k)\) and output matrix \(C\) is constant, the compensatory signal is periodic, with each cycle exhibiting distinct values.  
In accordance with (15), it is observed that for \(k=t_{0}+n_{0}T+i\), where \(i\) spans from \(0\) to \(T-1\), a precise correlation is established between the value of the compensatory signal \(\mathbb{Y}^{f}(i)\) and the watermark signal value \(\Delta o(k-1)=\Delta o(i)\) present in the measurement data. It has been confirmed that for any distinct \(i\) and \(j\), \(\text{Prob}(\Delta o(i)=\Delta o(j))=0\). Thus, a one-to-one correspondence between compensatory signal \(\mathbb{Y}^{f}(i)\) and the watermark signal sequence \(\Delta o(i-1)\) is established.