# GNSS Spoofing Detection and Mitigation Based on Maximum Likelihood Estimation
## 4 MLE-Based GNSS Anti-Spoofing Method
### Estimation-Cancellation Approach
The highest peak of the MLE cost function at \(\hat{\mathbf{\rho}_{1}}\) is superimposed by the signal components in the area emphasized by the dashed lines. (a) \(\hat{\mathbf{\rho}_{1}}\) is equal to \(\mathbf{\rho}_{s}\); (b) \(\hat{\mathbf{\rho}_{1}}\) is equal to \(\mathbf{\rho}_{a}\); (c) \(\hat{\mathbf{\rho}_{1}}\) is neither equal to \(\mathbf{\rho}_{s}\) nor to \(\mathbf{\rho}_{a}\). We will discuss the three cases respectively in the rest of the subsection. As for the first case, we will first consider the limiting case in which the two circles in Figure 2a are separate. All of the authentic signals will be reserved in \(\mathbf{y}\), and the hypothesis test in Equation (14) can be rewritten as follows:  
\[\mathcal{H}_{0}:\mathbf{y} =\mathbf{w} \tag{15}\] \[\mathcal{H}_{1}:\mathbf{y} =\mathbf{G}(\mathbf{\rho}_{a})\mathbf{a}_{a}+\mathbf{w}\]  
Then, we perform the MLE-based positioning again with \(\mathbf{y}\). The ML estimates of \(\tau_{a}\), \(f_{a}\), \(\mathbf{a}_{a}\) and \(\sigma^{2}\) under \(\mathcal{H}_{1}\) can be obtained with Equations (4)-(6) by replacing \(\mathbf{x}\) with \(\mathbf{y}\), and they are denoted as \(\hat{\mathbf{\tau}}_{2}\), \(\hat{\mathbf{\mu}}_{2}\) and \(\hat{\sigma}_{2}^{2}\), respectively. The only unknown parameter under \(\mathcal{H}_{0}\) is the variance of noise, which is denoted as \(\sigma_{0}^{2}\), and its ML estimate is given by:  
\[\hat{\sigma_{0}}^{2}=\frac{1}{K}\mathbf{y}^{H}\mathbf{y} \tag{16}\]  
Then, with the ML estimates mentioned above, the generalized likelihood ratio test (GLRT) statistic can be derived as:  
\[ \begin{split} L_{G}(\mathbf{y})&=\frac{\max_{\mathbf{\tau}, \mathbf{f},\mathbf{a},\sigma^{2}}p_{1}(\mathbf{y};\mathbf{\tau},\mathbf{f},\mathbf{a},\sigma^{2})}{ \max_{\sigma^{2}}p_{0}(\mathbf{y};\sigma^{2})}\\ &=(\frac{\hat{\sigma}_{0}^{2}}{\hat{\sigma}_{2}^{2}})^{\frac{K}{2 }}=\Big{\{}\frac{\mathbf{y}^{H}\mathbf{y}}{[\mathbf{y}-\mathbf{G}(\hat{\mathbf{\rho}}_{2})\hat\mathbf{{\mu}}_{2}]^{H}[\mathbf{y}-\mathbf{G}(\hat{\mathbf{\rho}}_{2})\hat{\mathbf{\mu}}_{2}]}\Big{\}} ^{\frac{K}{2}}\end{split}  \tag{17}\]  
where \(p_{0}(\mathbf{y},\sigma^{2})\) and \(p_{1}(\mathbf{y};\mathbf{\tau},\mathbf{f},\mathbf{a},\sigma^{2})\) denote the likelihood functions under \(\mathcal{H}_{0}\) and \(\mathcal{H}_{1}\), respectively. \(\hat{\mathbf{\rho}}_{2}\) is the ML estimate of the PVT result corresponding to the residual signal \(\mathbf{y}\). Using the monotonicity of the function \(f(x)=a(1-1/x^{c})\), \(x,a,c>0\), we have:  
\[ \begin{split} T(\mathbf{y})&=2K[1-\frac{1}{L_{G}(\mathbf{y })^{\frac{2}{K}}}]\\ &=2\frac{\mathbf{y}^{H}\mathbf{y}-[\mathbf{y}-\mathbf{G}(\hat{\mathbf{\rho}}_{2}) \hat{\mathbf{a}}_{2}]^{H}[\mathbf{y}-\mathbf{G}(\hat{\mathbf{\rho}}_{2})\hat{\mathbf{a}}_{2}]}\mathbf{{y}^{H}\mathbf{y}/K}\\ &=\frac{\hat{\mathbf{a}}_{2}^{H}\mathbf{G}(\hat{\mathbf{\rho}}_{2})^{H}\mathbf{G} (\hat{\mathbf{\rho}}_{2})\hat{\mathbf{\mu}}_{2}}{\hat{\sigma}_{0}^{2}/2}\\ &=\frac{\mathbf{y}^{H}\mathbf{G}(\hat{\mathbf{\rho}}_{2})[\mathbf{G}(\hat{\mathbf{ \rho}}_{2})^{H}\mathbf{G}(\hat{\mathbf{\rho}}_{2})]^{-1}\mathbf{G}(\hat{\mathbf{\rho}}_{2})^{H} \mathbf{y}}{\hat{\sigma}_{0}^{2}/2}\\ &=\frac{\max_{\rho_{2}}J(\rho_{2};\mathbf{y})}{\hat{\sigma}_{0}^{2}/ 2}>\gamma\end{split}  \tag{18}\]  
The cost function \(J(\rho_{2};\mathbf{y})\) after estimation-cancellation is shown in Figure 3. All of the simulation parameters are the same as those in Figure 1. It can be seen that when \([\delta x_{u},\delta y_{u}]=[0,0]\), the cost function is maximized. Figure 3 shows that \(\mathbf{\rho}_{a}\) can be obtained by maximizing \(J(\rho_{2};\mathbf{y})\) in the first case. \(T(\mathbf{y})\) follows \(F\) and non-central \(F\) distributions under \(\mathcal{H}_{0}\) and \(\mathcal{H}_{1}\), respectively [25]. Since the estimation are performed with a large number of samples considering the sampling frequency and processing time, the ML estimate \(\hat{\sigma}_{0}^{2}\) is very close to its true value \(\sigma^{2}\).