# Spoofing Detection Algorithm Based on Pseudorange Differences
## 2 Spoofing Detection Algorithm
### Theoretical Analysis
\begin{array}{c}\varepsilon c_{k+1}^{1}\\ \varepsilon c_{k+1}^{2}\\ \vdots\\ \varepsilon c_{k+1}^{n}\end{array} \right] \tag{15}\]  
where,  
\[\mathbf{G}_{e}=\left[ \begin{array}{cc}\mathbf{0}_{1\times 3}^{\mathbf{M}}& \mathbf{1}_{1\times 1}\\ \mathbf{M}_{2}&\mathbf{1}_{(n-1)\times 1}\end{array} \right]\]  
By calculating Equation (15) iteratively, the position vector \((x_{k+1,LS},y_{k+1,LS},z_{k+1,LS})\) at \(t_{k+1}\) for the traditional least squares method can be obtained. According to the signal transmission path presented in Figure 1, we can build the pseudorange model. Then, we have:  
* When the signal is real, it transmits directly from the satellite to the receiver. We have \(R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{p,k+1}\right)=R\left(\mathbf{X}_{k+1 }^{i},\mathbf{X}_{r,k+1}\right)\). * When the signal is spoofing, according to the principle of the spoofing attack, we have: (1) for the meaconer, it includes the physical distance between the satellite and the meaconer \(R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{s,k+1}\right)\), and the physical distance between the meaconer and the receiver \(R\left(\mathbf{X}_{s,k+1},\mathbf{X}_{r,k+1}\right)\); (2) for the spoofer, it includes the virtual distance \(R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{s,k+1}\right)\), which is controlled by the generator's hardware and software and the physical distance between the spoofer and the receiver \(R\left(\mathbf{X}_{s,k+1},\mathbf{X}_{r,k+1}\right)\). We have \(R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{p,k+1}\right)=R\left(\mathbf{X}_{k+1 }^{i},\mathbf{X}_{s,k+1}\right)\). For the algorithm proposed in this paper, the term \(R\left(\mathbf{X}_{s,k+1},\mathbf{X}_{r,k+1}\right)\) is removed due to the difference, while for the traditional least squares method, the term \(R\left(\mathbf{X}_{s,k+1},\mathbf{X}_{r,k+1}\right)\) can be included inside the receiver clock offset term \(\delta t_{r,k+1}\times c\). By comparing Equations (13) and (15), we can see that the only difference is the clock offset term \(\delta t_{r,k+1}\times c\). In addition, the method proposed in this paper needs two epochs (\(t_{k}\) and \(t_{k+1}\)). Both of the clock offset term and the result at \(t_{k}\) will affect our method's result at \(t_{k+1}\). According to the above  
Figure 1: The signal transmission path. analysis, we can write the method as: the position obtained at \(t_{k+1}\) is equal to the position at \(t_{k}\) plus the position deviation caused by the change in pseudorange between \(t_{k}\) and \(t_{k+1}\), plus the position deviation caused by the clock offset term. For the position result at \(t_{k}\), when the position deviation of the two algorithms at \(t_{k}\) is less than the threshold, the traditional least squares method's result at \(t_{k}\) is used to calculate the position result at \(t_{k+1}\). When the position deviation of the two algorithms at \(t_{k}\) is greater than the threshold, our method's result at \(t_{k}\) is used to calculate the position result at \(t_{k+1}\). To sum up,  
* When the traditional least squares method's result at \(t_{k}\) is used, the position at \(t_{k+1}\) can be written as: the position obtained at \(t_{k+1}\) is equal to the position at \(t_{k}\), plus the position deviation caused by the change in the pseudorange between \(t_{k}\) and \(t_{k+1}\), plus the position deviation caused by \(\delta t_{r,k+1}\times c\). From the simulation result in Section 3, we can see that the maximum equivalent distance of the clock offset is \(10^{-6}\times c\), which is small enough to ignore its influence, and the position results of the two algorithms are approximately equal. \[\left\{ \begin{array}{l}x_{k+1,LS}\approx x_{k+1,SDA}\\ y_{k+1,LS}\approx y_{k+1,SDA}\\ z_{k+1,LS}\approx z_{k+1,SDA}\\ \end{array}