# Accurate Sybil Attack Detection Based on Fine-Grained Physical Channel Information
## 5 Static Detection Algorithm  
### Self-Adaptive MUSIC Algorithm  
In a standard WiFi network, the transmitter and receiver are not time-synchronized, so they are not synchronized to the sampling clock at the DAC and ADC. The Sampling Time Offset (STO) [12] will deviate from the arrival time and phase of the LoS path and NLoS path, which possibly cause the direct path of AoA not to be the real wave of the angle. The NLoS path may be determined as the line of sight and produces an offset. Meanwhile, when transmitting the device RF link connection to the RF oscillator, it will generate Sampling Frequency Offset (SFO). The SFO changes the sampling time offset of the same packet, which in turn leads to another additional time offset of the ToF estimate across the packet and unknown phase \(\beta\). The total time delays \(\Delta t\) caused by STO and SFO are very different across two packets' transmissions between a pair of transmitter and receiver. Hence, the phase of the \(i\)-th subcarrier can be expressed as \(\widehat{\phi}_{i}=\phi_{i}+2\pi f_{i}\Delta t+\beta+N_{\text{i}}\). \(\phi_{i}\) is the genuine CSI phase we are searching for, and \(N_{\text{i}}\) is measurement noise. We use the classification algorithm to calculate \(\phi_{i}\), and the values of \(\Delta t\) and \(\beta\) are always the same. Suppose \(\phi_{\text{i}}(m,k)\) is the unwarped phase of the CSI at the \(k\)-th subcarrier of the \(i\)-th packet received at \(m\)-th antenna; we can obtain the optimal linear fit of the phase for the \(i\)-th packet as:  
\[\widehat{\tau}_{\text{i}}=\operatorname*{arg\,min}_{\Delta t}\sum_{m,k=1}^{M,K}\left(\phi_{\text{i}}(m,k)+2\pi f_{i}(k-1)\Delta t+\beta\right) \tag{8}\]  
The \(\widehat{\tau}_{\text{i}}\) is the time delay of the \(i\)-th packet, and we can get modified CSI phase \(\phi_{i}(m,k)=\widehat{\phi}_{i}(m,k)-2\pi f_{\text{i}}(k-1)\widehat{\tau}_{ \text{i}}\). Our method is similar to sanitizing ToF estimates in SpotFi, and this method eliminates the residual synchronization error in the CSI phase. However, this method destroys the independence of the subcarrier CSI phases so that the processed result can only be used for the digital signature, and the phase deviation of the SFO is not effectively eliminated. In order to eliminate the phase offset of the SFO and obtain a more accurate angle value, we apply the self-adaptive MUSIC algorithm to calculate the phase offset between the antennas. We assume that the phase deviation between the antennas is \(\langle\delta_{0},\delta_{1}\rangle\). Because \(\langle\delta_{0},\delta_{1}\rangle\) is a hidden random variable, we cannot directly get the size of these two variables, so this algorithm uses the search method. It selects all combinations of \(\langle\delta_{0},\delta_{1}\rangle\) that can be used to achieve the best combination of the reception effect as our estimated antenna deviation. We verify that we estimate the estimated antenna deviation by a number of experiments. Because we selected better calibration results from a combination of \(\langle\delta_{0},\delta_{1}\rangle\), the true value of the angle is not exactly equal to the value we measured. In addition, it is possible that not all combinations allow the peak of the pseudo spectrum to be exactly equal to the measured value. To improve the stability of the evaluation system, we need to choose a robust evaluation function to evaluate the pseudo spectrum of each combination. * When the peak of the dummy spectrum is equal to the measured AoA value, the combination has the greatest probability of being the best calibration. * When the peak of the dummy spectrum is close to the measured AoA value, the combination also has a larger probability of becoming the best calibration combination. Consider the above two points; we designed our evaluation function \(\eta(\rho)\), where \(\rho\) is the pseudo spectrum, as follows:  
* Find a normalizing constant \(k\) such that \(\rho^{\prime}=k\rho\) is one, and set \(\int k\rho\left(\theta\right)d\left(\theta\right)=1\).