# Spoofing Detection Algorithm Based on Pseudorange Differences
## 2 Spoofing Detection Algorithm
### Theoretical Analysis
\right]=\left\{\left[ \begin{array}{c}\mathbf{0}_{1 \times 1}^{\mathbf{L}}\\ \mathbf{L}_{1}\end{array} \right]-\left[ \begin{array}{c}\mathbf{0}_{1\times 1 }^{\mathbf{L}}\\ \mathbf{L}_{2}\end{array} \right]\right\} \tag{10}\]  
where,  
\[\mathbf{0}_{1\times 3}^{\mathbf{M}}=\left[ \begin{array}{cc}u_{x,k+1,k}^{1}&u_{y,k+ 1,k}^{1}&u_{z,k+1,k}^{1}\end{array} \right]\]  
\[\mathbf{0}_{1\times 1}^{\mathbf{L}}=\left[\Delta\rho_{k+1,k}^{1}+R\left( \mathbf{X}_{k}^{1},\mathbf{X}_{p,k}\right)-R\left(\mathbf{X}_{k+1}^{1}, \mathbf{X}_{k}\right)-\left(\varepsilon c_{k+1}^{1}-\varepsilon c_{k}^{1} \right)\right]\]  
As the following relationships exist:  
\[\left[ \begin{array}{c}\mathbf{0}_{1\times 3}^{\mathbf{M}}\\ \mathbf{M}_{1}\end{array} \right]\left[ \begin{array}{c}x_{k+1,SDA}-x_{k}\\ y_{k+1,SDA}-y_{k}\\ z_{k+1,SDA}-z_{k}\end{array} \right]=\left[ \begin{array}{c}\rho_{k+1}^{1}-R \left(\mathbf{X}_{k+1}^{1},\mathbf{X}_{k}\right)-\delta t_{r,k+1}\times c- \varepsilon c_{k+1}^{1}\\ \rho_{k+1}^{1}-R\left(\mathbf{X}_{k+1}^{1},\mathbf{X}_{k}\right)-\delta t_{r,k +1}\times c-\varepsilon c_{k+1}^{1}\\ \vdots\\ \rho_{k+1}^{1}-R\left(\mathbf{X}_{k+1}^{1},\mathbf{X}_{k}\right)-\delta t_{r,k +1}\times c-\varepsilon c_{k+1}^{1}\end{array} \right] \tag{11}\]  
\[\left[\rho_{k}^{i}-R\left(\mathbf{X}_{k}^{i},\mathbf{X}_{p,k}\right)- \varepsilon c_{k}^{i}\right]-\left[\rho_{k}^{j}-R\left(\mathbf{X}_{k}^{j}, \mathbf{X}_{p,k}\right)-\varepsilon c_{k}^{j}\right]=0 \tag{12}\]  
We calculate the difference between \(\left\{\left[ \begin{array}{c}\mathbf{0}_{1\times 1}^{\mathbf{L}}\\ \mathbf{L}_{1}\end{array} \right]-\left[ \begin{array}{c}\mathbf{0}_{1\times 1 }^{\mathbf{L}}\\ \mathbf{L}_{2}\end{array} \right]\right\}\) and \(\left[ \begin{array}{c}\mathbf{0}_{1\times 3}^{\mathbf{M}}\\ \mathbf{M}_{1}\end{array} \right]\left[ \begin{array}{c}x_{k+1,SDA}-x_{k}\\ y_{k+1,SDA}-y_{k}\\ z_{k+1,SDA}-z_{k}\end{array} \right]\). Combining the obtained difference result with Equations (11) and (12), Equation (10) can be rewritten as:  
\[\left[ \begin{array}{c}\mathbf{0}_{1\times 3}^{\mathbf{M}}\\ \mathbf{M}_{2}\end{array} \right]\!\!\left[ \begin{array}{c}x_{k+1,SDA}\\ y_{k+1,SDA}\\ z_{k+1,SDA}\end{array} \right]\!\!=\!\!\left[ \begin{array}{c}\mathbf{0}_{1 \times 3}^{\mathbf{M}}\\ \mathbf{M}_{2}\end{array} \right]\!\!\left[ \begin{array}{c}x_{k}\\ y_{k}\\ z_{k}\end{array} \right]\!+\!\!\left[ \begin{array}{c}\rho_{k+1}^{1}-R\left( \mathbf{X}_{k+1}^{1},\mathbf{X}_{k}\right)\\ \rho_{k+1}^{2}-R\left(\mathbf{X}_{k+1}^{2},\mathbf{X}_{k}\right)\\ \vdots\\ \rho_{k+1}^{n}-R\left(\mathbf{X}_{k+1}^{n},\mathbf{X}_{k}\right)\end{array}  \right]\!\!-\!\left[ \begin{array}{c}\delta t_{r,k+1}\times c\\ \delta t_{r,k+1}\times c\\ \vdots\\ \delta t_{r,k+1}\times c\end{array} \right]\!\!-\!\left[ \begin{array}{c} \varepsilon c_{k+1}^{1}\\ \varepsilon c_{k+1}^{2}\\ \varepsilon c_{k+1}^{n}\end{array} \right] \tag{13}\]  
By calculating Equation (13) iteratively, the position vector \((x_{k+1,SDA},y_{k+1,SDA},z_{k+1,SDA})\) at \(t_{k+1}\) for the spoofing detection algorithm can be obtained. For the traditional least squares method [25], only the measurement information of one time epoch is needed. The pseudorange after corrections at \(t_{k+1}\) can be written as:  
\[\rho_{k+1}^{j}=R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{p,k+1}\right)+\delta t_{ r,k+1}\times c+\varepsilon c_{k+1}^{j} \tag{14}\]Taylor expansion for \(R\left(\mathbf{X}_{k+1}^{i},\mathbf{X}_{p,k+1}\right)\) is done at \((x_{k},y_{k},z_{k})\). Then, we have:  
\[\mathbf{G}_{e}\left[ \begin{array}{c}x_{k+1,LS}\\ y_{k+1,LS}\\ z_{k+1,LS}\\ \delta t_{r,k+1}\times c\end{array} \right]=\mathbf{G}_{e}\left[ \begin{array}[] {c}x_{k}\\ y_{k}\\ z_{k}\\ 0\end{array} \right]+\left[ \begin{array}{c}\rho_{k+1}^{1}-R\left(\mathbf{X}_{ k+1}^{1},\mathbf{X}_{k}\right)\\ \rho_{k+1}^{2}-R\left(\mathbf{X}_{k+1}^{2},\mathbf{X}_{k}\right)\\ \vdots\\ \rho_{k+1}^{n}-R\left(\mathbf{X}_{k+1}^{n},\mathbf{X}_{k}\right)\end{array}  \right]-\left[