# Knowledge Distillation-Based GPS Spoofing Detection for Small UAV
## 5 Methodology
### Long-Short Term Memory (LSTM)-Based Detection  
With GPS localization, a UAV recognizes its positions effectively and adjusts its mobility to follow the designed trajectory and finish missions. With the correct navigation system, the UAV can avoid obstacles and reach destinations safely. Based on the laws of motion, force, and acceleration, we have  
\[P_{t^{\prime}}=P_{t}+v\times\Delta t \tag{1}\]  
Here, \(P_{t^{\prime}}\) and \(P_{t}\) are two positions of the UAV in time \(t^{\prime}\) and \(t\), \(v\) is the speed of the UAV, and \(\Delta t\) is the duration of the measurement, \(\Delta t=t^{\prime}-t\). With IMUs, we can measure the acceleration \(A\) of the UAV. With \(A\), we can convert equation 1 to  
\[P_{t^{\prime}}=P_{t}+\int_{t}^{t^{\prime}}A\times\delta \tag{2}\]  
Here, \(\delta\) is the variance of time. Due to noise \(N\) existing in IMU, the real acceleration \(A\) is different from the measured acceleration \(\hat{A}\). \[\hat{A}=A+N \tag{3}\]  
The noise includes thermal noise and zero drift, which are hard to eliminate and predict. The noise is not usually stable during measurement, which causes a loss of confidence in position prediction for the UAV with IMUs. GPS spoofing usually focuses on forged signal broadcasts, which cannot interfere with the functions of IMUs, so IMUs are also used to measure whether the UAV is under GPS spoofing. However, the noise causes many false alarms, which makes it hard to deploy IMU-based methods in real scenarios. Figure 1: GPS spoofing attack. With regard to noise in IMUs, we leverage LSTM to optimize the processing of position prediction of UAVs. Due to its advantages in sequential data [36], LSTM can have good performance on time-sequential data, like position prediction. With the observation of GPS results and IMU measurements, we predict the position variance of the UAV and trigger alerts if the difference between the calculated positions and predicted positions is over the designed threshold, \(Th_{p}\). \(Th_{p}\) is derived from the limitations of the UAV's mobility [37], which is usually set to 100 mph \(\approx\) 44 m/s. We have a preliminary test of different values of \(Th_{p}\) on the false detection rate, which is shown in Figure 2. The triggered alerts indicate that the UAV is under GPS spoofing and needs countermeasures to get rid of the attacks. With the GPS and IMUs, we have positions, \(P_{t}=(x_{t},y_{t},z_{t})\), and accelerations, \(A_{t}=(Ax_{t},Ay_{t},Az_{t})\), of the UAV. In the position prediction, we put \(P_{t}\) and \(A_{t}\) into LSTM and obtain the predicted position, \(P_{t}\). To make the two inputs compatible to LSTM [38], we concatenate \(P_{t}\) and \(A_{t}\) into a new array, \(PA_{t}=\{P_{t},\ A_{t}\}\). The integration of LSTM is shown as follows:  
\[i_{t}=\sigma(W_{ii}PA_{t}+b_{ii}+W_{im}m_{t-1}+W_{ic}c_{t-1}+b_{i}) \tag{4}\]  
In input layer, \(W_{ii}\), \(W_{ic}\), and \(W_{im}\) are weight matrices for the input gate to input, cell activation vector, \(c_{t-1}\), and cell activation output vector, \(m_{t-1}\), respectively. \(b_{i}\) is the bias for the input layer. \(\sigma\) is the logistic sigmoid function. \[f_{t}=\sigma(W_{fi}PA_{t}+W_{fm}m_{t-1}+W_{fc}c_{t-1}+b_{f}) \tag{5}\]  
In forget layer, \(W_{fi}\), \(W_{cf}\), and \(W_{mf}\) are weight matrices for the forget gate to input, \(c_{t-1}\), and \(m_{t-1}\), respectively. \(b_{f}\) is the bias for the forget layer. \(\odot\) is the Hadamard product. \[c_{t}=f_{t}\odot c_{t-1}+i_{t}\odot g(W_{cx}PA_{t}+W_{cm}m_{t-1}+b_{c}) \tag{6}\]  
In cell state, \(g\) is the cell input activation function. \(W_{cx}\) and \(W_{cm}\) are weight matrices for the cell state to input and \(m_{t-1}\), respectively. \(b_{c}\) is the bias for the cell state. \[o_{t}=\sigma(W_{oi}PA_{t}+W_{om}m_{t-1}+W_{oc}c_{t}+b_{o}) \tag{7}\]  
In output layer, \(W_{oi}\), \(W_{oc}\), and \(W_{om}\) are weight matrices for the output gates to input, \(c_{t}\), and \(m_{t-1}\), respectively. \(b_{o}\) is the bias for the forget layer.