# Enhancing Unmanned Marine Vehicle Security: A Periodic Watermark-Based Detection of Replay Attacks
## 3 A Periodic Watermark-Based Detection of Replay Attacks
### Detection of Replay Attacks  
At time \(k\), the measurement \(y^{\prime}(k)\) is received and augmented by adding the compensatory signal \(\mathbb{Y}^{f}(m)\), resulting in a compensated measurement represented as \(y^{\prime}(k,m)=y^{\prime}(k)+\mathbb{Y}^{f}(m)\). This process results in the modified measurement being defined as \(y^{\prime}(k,m)=y^{\prime}(k)+\mathbb{Y}^{f}(m)\). The prediction state estimate from the Kalman filter at this point is designated as \(\hat{x}^{\epsilon}(k|k-1)\). Subsequently, the residual is computed as \(r^{\epsilon}=y^{\epsilon}(k,m)-Cx^{\epsilon}(k|k-1)\). This residual is then employed to construct the chi-squared detection function \(g(k,m)=(r^{\epsilon}(k,m))^{T}\Sigma_{r}^{-1}r^{\epsilon}(k,m)\), where \(\Sigma_{r}\) is defined as \(CPC^{T}+V\). The effectiveness of the proposed detection method is confirmed in this paper, and it is demonstrated that the subsequent theorem is applicable. At time \(k\), where \(k=t_{0}+nT+i\), \(i\in[0,T-1]\), and \(n\geq n_{0}\), the control watermark signal is \(\Delta o(i-1)\). Introducing different compensatory signals \(\mathbb{Y}^{f}(m)\), \(m\in[0,T-1]\), results in the chi-square detection function \(g(k)\) satisfying \(g(k,i)<g(k,j)\) for \(j\in[0,T-1]\) and \(j\
eq i\). This indicates that assume compensatory signal \(\mathbb{Y}^{f}(m)\) is injected with \(m=i\), the detection function value \(g(k,m)\) is minimized. Proof. : According to Theorem 1, the compensation signal at time \(k=t_{0}+nT+i\) is denoted by \(\mathbb{Y}^{f}(i)\). When \(m=i\), \(\mathbb{Y}^{f}(m)=\mathbb{Y}^{f}(i)\). Thus, the measurement value \(y^{\epsilon}(k,m)\) after adding the compensation signal \(\mathbb{Y}^{f}(m)\) can be derived as follows:  
\[ \begin{split} y^{\epsilon}(k,m)=& y^{\prime}(k)+ \mathbb{Y}^{f}(m)\\ =& y^{\prime}(k)+\mathbb{Y}^{f}(t_{0}+nT+i)C\sum_{p=1 }^{3}\hbar_{p}(\varrho(k))(A_{dp}x^{\prime}(k-1)+B_{dp}(u(k-1)\\ &+\Delta o(k-1))+\theta_{di}(k-1)-A_{dp}x^{f}(k-1)-B_{dp}\Delta o (k-1)+v(k)\\ =& C\sum_{p=1}^{3}\hbar_{p}(\varrho(k))A_{dp}^{k}x(0 )+\sum_{i=0}^{k-1}A_{dp}^{i}(B_{dp}u(k-1-i)+\theta_{di}(k-i-1))+v(k)\\ =& Cx(k)+v(k)\\ =& y(k)\end{split}  \tag{19}\]  
As established by (19), at time \(k\), the measurement \(y^{\epsilon}(k,m)\), which incorporates the compensatory signal \(\mathbb{Y}^{f}(m)\), coincides with the system's original measurement \(y(k)\). This concurrence indicates that the disturbances induced by the watermark signal in the measurement are effectively neutralized by the compensatory signal. The prediction state estimate by the Kalman filter post-compensation is represented as \(\hat{x}^{\epsilon}(k|k-1)\), and the original system's state prediction estimate is denoted as \(\hat{x}(k|k-1)\). At the initial, it is affirmed that \(\hat{x}^{\epsilon}(0|-1)=\hat{x}(0|-1)\). Following the integration with (19), it is derived that:\[ \begin{split}\hat{x}^{e}(k|k-1)=&\sum_{n=1}^{3}\hbar_{p}( \varrho(k))\big{(}A_{dp}\hat{x}^{e}(k-1|k-1)+B_{dp}u(k-1)\big{)}\\ =&\sum_{n=1}^{3}\hbar_{p}(\varrho(k))\big{(}A_{dp}+B_ {dp}F\big{)}\hat{x}^{e}(k-1|k-1)\\ =&\sum_{n=1}^{3}\hbar_{p}(\varrho(k))(\hat{x}^{k} \hat{x}(0|1)+\sum_{i=0}^{k-1}\hat{e}^{i}(A_{dp}+B_{dp}F)Ly(k-i-1))\\ =&\sum_{n=1}^{3}\hbar_{p}(\varrho(k))\big{(}\hat{x} (k-1|k-2)+(A_{dp}+B_{dp}F)Ly(k-1)\big{)}\\ =&\hat{x}(k|k-1)\end{split}  \tag{20}\]  
Given the condition that \(m=i\), it is found that the post-compensation state prediction estimate \(\hat{x}^{e}(k|k-1)\) aligns with the state prediction estimate \(\hat{x}(k|k-1)\) obtained when a control quantity watermark has not been injected. Hence, the residual \(r^{e}(k,m)\) under the scheme presented in this paper is determined as:  
\[ \begin{split} r^{e}(k,m)=& y^{e}(k,m)-C\hat{x}^{e} (k|k-1)\\ =& y^{e}(k)+\mathbb{Y}^{f}(m)-C\hat{x}^{e}(k|k-1)\\ =& y(k)-C\hat{x}^{e}(k|k-1)\\ =& y(k)-C\hat{x}(k|k-1)\\ =& r(k)\end{split}  \tag{21}\]  
Consequently, the chi-squared detection function derived from the compensated residual is determined as follows:  
\[