This repository was archived by the owner on Oct 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswjammer-detection.tex
More file actions
111 lines (92 loc) · 4.52 KB
/
Copy pathswjammer-detection.tex
File metadata and controls
111 lines (92 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{algorithm2e}
%opening
\title{}
\author{}
\begin{document}
%\maketitle
\section{Background}
The algorithm detects the use of a jammer that spoofs disconnect packets to the network resetting connections to the clients on a wi-fi network. The attack is documented here \href{http://hackaday.com/2011/10/04/wifi-jamming-via-deauthentication-packets/}{(video+ links from 2011)}.
On the android phone, the \href{http://developer.android.com/reference/android/net/wifi/WifiInfo.html}{WifiInfo} class has the data about the WiFi status.
The data from two functions in this class are used to estimate the connectivity state.
The fuctions:
\begin{itemize}
\item \emph{\href{http://developer.android.com/reference/android/net/wifi/WifiInfo.html\#getSupplicantState()}{Supplicant State}} This function returns the connectivity state of the WiFi connection, i.e Connected, not connecting, authenticating etc.
\item \emph{\href{http://developer.android.com/reference/android/net/wifi/WifiInfo.html\#getRssi()}{Signal strength}} Information about quality of the wifi connection to the accesspoint. The signal strength is the not normalised, so the kalman filter is reinitialised every time the app is restarted.
\end{itemize}
\section{The Equations}
The kalman filter works by estimating the next RSSI value and when this number is within a set threshold the connectivity state can be accurately identified.
The kalman filter estimates the RSSI of the WiFi signal, and a proof of concept implementaion is available in the file ``recordedvaluse.ods/xls''. The implementation is going to be used to explain the logic used for the kalman filter by columns:
\begin{description}
\item [G, Estimated RSSI]: This column is the prior estimate of the RSSI, it is represented by $x^-_k$
\item [H, Estimated Co-variance]: This is the prior estimate of the Covariance of the Kalman Filter represented by $P^-_k$
\item [I, Kalman Gain]: This is the kalman gain for the current state, represented by $K_k$
\item [J, RSSI Estimate]: This is the current estimate of the RSSI, represented by $\hat{x}_k$
\item [K, Covariance Change]: This is the current estimate of the covariance, represented $P_k$
\end{description}
Some additional values are required to implement the Kalman filter, the running mean and standard deviation for the distribution usling Welford's algorithm:
\begin{description}
\item [D, mean]: The mean for the RSSI values, represented by $ m_k$
\item [E, Ss]: Sum of squares of the values, represented by $ s_k$
\item [F, Variance]: The variance for the RSSI values at the current reading, represented by $R$
\item [A, RSSI Value]: The input RSSI value, represented by $z_k$
\item [B, Wifi Status]: The current status of the wifi connection for the device,
\item ['k']: The current row is represented by `$k$' and the previous row by `$k-1$' or `$^-_k$'
\end{description}
There are two constants that the filter needs:
\begin{itemize}
\item $Q$, the learning rate for the filter
\item $T_T$, the threshold above which prediction of connection state will not be possible
\end{itemize}
Using the above information, the WiFi connectivity status of the device can be estimated as follows:
Find the current mean and the sum of squares:
\[m_k = m_{k-1}+ (z_k - m_{k-1})k \]
\[s_k = s_{k-1}+ (z_k - m_{k-1})*(x_k-m_k) \]
use the above values to find the variance $R$(column F)
\[R = s_k/(k-1) \]
Use the variance to estimate the kalman gain $K_k$(column I) for state $k$,
\[K_k = \frac{P^-_k}{P^-_k+R} \]
now use this to estimate the current RSSI value
\[\hat{x}_k = x^-_k + K_k(z_k - x^-_k) \]
and update the co-variance:
\[P_k = (1-K_k)P^-_k \]
use this to check the next state:
\[x^-_k = \hat{x}_k \]
and use the constant $Q$ to update the estimated co-variance
\[P^-_k = P_{k-1}+Q \]
\section{Algorithm}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{Supplicant State, Wifi Signal Strength}
\KwResult{Jammed or Not}
set $Q = 60$\;
set $k=1$\;
set $m_k = z_k$\;
set $s_k = 0$\;
set $x^-_k= 0$\;
set $P^-_k =1 $\;
calculate $R$\;
estimate kalman gain $K_k$\;
estimate RSSI $\hat{x}_k$
\While{app running}{
set $x^-_k = \hat{x}_k$\;
set $P^-_k = P_{k-1}+Q$\;
set $k=k+1$\;
update $m_k, s_k$\;
find $R_k$\;
estimate $K_k$ and $\hat{x}_k$\;
update covariance $P_k$\;
\eIf{$(z_k - \hat{x}_k) <T_T$} {
\eIf{Wifi not connected?} {
alert user to jamming\;
}{
do nothing;
}
}{
jamming detection not possible;
}
}
\end{algorithm}
\end{document}