%\section{Wi-Fi Range Measurements}
%\label{sec:ftm}
%
%Ganz grundsätzlich zwei drei Sätze dazu. Distanzen sind gut für Lokalisierung weil... Kurz die Unterschiede der Beiden.
%
%\subsection{Fine Timing Measurement}
%\begin{itemize}
%	\item New IEEE 802.11mc standard to measure round trip time from client to access point.
%	\item Theory, protocol.
%	\item Expected error behavior 
%\end{itemize}
%
%
%FTM defines a protocol to measure the round trip time between an initiator and a responder, e.g. a smartphone based client and access point.
%For data privacy reasons the responder is always passive and only the initiator can trigger time measurements.
%
%\subsection{Received Signal Strength Indication}
%
%Klassisch RSSI mit Log Distance Modell... 
%steckt die rssi in das log distance modell und bekommt eine distanz raus. baby easy
%
%\subsection{Measurement Pre-Filtering}
%
%<zeige fehlerplots mit range messungen>
%
%wenn man sich die messungen nun ansithet, dann... argumentiere kalmanfilter über diese range messungsplots und begründe warum er die messdaten stabiler macht.
%kalman auf rssi ist erstmal nicht so klug weil kalman linear und rssi nicht linear sind. in LOS konditionen ist rssi logritmisch und in NLOS ganz was anders... nicht-linear halt 
%in den späteren evaluatieren werden wir uns aber dennoch raw vs pre-filtering ansehen, um ein bessere gefühl dafür zu bekommen was es in welcher situation bringt
%
%Filter measurements per AP with simple Kalman filter before localization
%
%RSSI leichter messbar und einfach gegegeben, aber abhänigi von umgebung  - coarsely quantized 
%RTT deutlich komplexer zu messen, daher eigener FTM Standard. Super-resolution?!



\section{Wi-Fi Range Measurements}
\label{sec:ftm}

A obvious approach to estimate a location is to measure the distance between the current unknown position and a known position.
Given multiple measurements to different reference points an absolute position in a local coordinate system can be found.
With ideal distance measurements it is straightforward to calculate the current position.
However, in the present of noise and imperfect measurements estimating a accurate position is a challenging problem.

\subsection{Received Signal Strength Indication}
% TODO dBm vs dB??

Received Signal Strength Indication (RSSI) is a measure of the received RF power and is obtained by the radio hardware at the antenna connector using an analog-to-digital converter.
It is usually expressed in \si{\dBm} and quantified to integer values.
For indoor localization RSSI is often used to deduce the distance from a smartphone to the access point, because it is virtually always available on common devices.
The \docLogDistance{} model is commonly used to predict the signal strength $s$ at a given distance $d$.
Which is formally given with
\begin{equation}
	s = \mTXP - 10 \mPLE \log_{10}{\frac{\mMdlDist}{\mMdlDist_0}} + \mathcal{X}   \text{,}
	\label{eq:logDistModel}
\end{equation}
where $\mTXP$ denotes the sending power of the AP at reference distance $\mMdlDist_0$ (\eg \si{1}{m}) in \si{\dBm}, $\mPLE$ is the path loss exponent, which value needs to be empirically chosen for the given environment.
The added zero-mean Gaussian random variable $\mathcal{X}$ models signal fading and random channel noise in \si{\decibel}.

The \docLogDistance{} model can be reformulated to compute the distance $d$ based on the RSSI $s$ with
\begin{equation}
  d = 10^{(\mTXP-s) / 10\mPLE}
\end{equation}

In free space the value of the path loss exponent is $\mPLE=2$.
In indoor scenarios $\mPLE$ accounts for the architecture around the AP, thus a single global factor is chosen for the whole building.
%This restricts the \docLogDistance{} model to a uniform view on the complete environment and does not allow to differentiate between different types of materials, and ignores  which walls are actually transmitted the signal.

This restricts the \docLogDistance{} model to a uniform view on the whole environment and does not take the actual propagation path of the signal into account.
Therefore it is not possible 
 not allow to differentiate between different types of materials, and ignores  which walls are actually transmitted the signal.

In order to take walls into account the model must include the power loss of every traversed wall, which results in the wall-attenuation factor model \cite{TODO}.
Often the dampening factors of walls are unknown and hard to measure.
Additionally, the computation of the wall-attenuation factor model requires costly intersection tests with the geometry of the environment which can be intractable to perform on a regular smartphone.

Another approach is to take measurements at known positions distributed throughout the building.
These fingerprints can then be used in the localization phase to obtain the current position with a nearest neighbour search.
Given the current RSSI value the most likely position is the one which has
This method includes the characteristics of the environment into the prerecorded fingerprints.
Recording the fingerprints is a time-consuming and tedious process for large buildings and needs to be redone whenever the environment changes significantly.
 
However, RSSI values are often coarsely quantized, depend heavily on the environment, differ from device to device, and are affected by the interferences.

- free space loss
- walls
, also dynamic obstacles like persons can interfere with the signal.


\subsection{Fine Timing Measurement}
Time-based distance measurements are based on successive timestamps taken at the sender and receiver site.
The difference of the two timestamps is the time the signal took to travel from the sender to the receiver.
Multiplied by the propagation speed of light results in the distance between the two nodes.

The propagation speed of the signal depends on the propagation medium and is slower in media with higher relative permittivity, like concrete walls, compared to air.
However, for most indoor environments the signal propagation speed can be assumed to be constant, as the total travel distance in non-air media is usually negligible short compared to the travel distance in air \cite{marcaletti2014filtering}.
For that reason,  time of flight (ToF) measurements are more robust compared to received power measurements.
While RF power is relatively simple to measure, obtaining accurate ToF values at small resolutions like nanoseconds needs much more caution, as the measurements are sensitive to noise.
Relatively small deviations from the real time value result in a large error in the distance estimate, \eg a error of 1ns results in xx meter.
Therefore, distance estimates can greatly differ from the ideal euclidean distance.

The accuracy of distance estimate depends on the ability of the hardware to detect the line-of-sight signal.
In an indoor environment it is very common that a signal will reach the receiver from different paths with different lengths.
The prime example is a signal which reaches the receiver via a direct line-of-sight propagation plus two reflected paths of the same length.
As the reflected paths have the same length and phase they constructively interfere at the receiver resulting in a higher receiving power compared to the direct connection.
The difficulty in such multipath scenarios is to distinguish the direct path from the reflected paths.
Here the limiting factor is the sampling rate of the receiving hardware.
Given 802.11xxx the channel bandwidth is 20 mhz which results in a sampling rate of 

In order to measure the ToF the hardware needs to detect the direct line-of-sight signal
However, obtaining accurate ToF measurements of the line-of-sight signal in heavy multipath environment like indoors is not easy.


Error sources:
multipath propagation, noise, finite sample rate

