\chapter{Introduction}
\section{Motivation}
Recent developments in the field of physics, chemistry and electronics 
have led to cheap and compact size 
manufacturing of diverse single chip integrated solutions. As a consequence of the
rapid development it became possible to integrate a GPS receiver into almost every cell
phone without drastically increasing the price, physical size or weight of 
the cell phone. An example of this would be the GPS receiver chip
inside the Apple iPhone 3GS, the cost was estimated to be around \$2.25 USD \citep{GPSiphoneCost}. 
It is important to note, the number of wireless connections has increased as well,
in 2011 there were 
6 billion mobile connections worldwide \citep{gsmConnection}. In the following European
countries, Germany, France, Spain, Italy and UK, 44\% of all GSM users own a smart phone,
whereas in the US and Canada this number is slightly higher, 46\% \citep{smartPhoneUsage}. By the
statistics of the Blur group 47\% of all the cell phones on the world shall be smart phones 
by 2015 \citep{smartPhone2015}. 

An emerging new market of location based services (LBS) have grown out of it and since then
changes the telecommunication and marketing industry with fast pace. In 2009, 63 million users 
used some of the LBS on their cell phones, this number is expected to grow in 2012 to 
468 million users worldwide \citep{smartPhone2015}. As social networks grow like Facebook,
Twitter or Foursquare (a location based social network), it has become a trend 
for the users to share their location with their friends \citep{smartPhone2015}. 
It has been reported that LBS represent a bonanza opportunity for new startup 
companies and Global Industry Analysts project by 2015 a global market
worth of \$21 USD billion ($\approx$ \euro17.142 billion) \citep{Bonanza}. 
New ideas and algorithms for tracking,
navigation solutions, safety, security, local business search and payments shall emerge
from it as well as the new market that shall emerge from the results of data mining 
user's movement \citep{Bonanza}. LBS have been used for tracking people with dementia, Alzheimer's
disease, as reported in a study performed by the University of Siegen \citep{Muller}.
The Enhanced 911 (E911), an emergency service in the US for linking
emergency callers with appropriate public service (police, firefighters and emergency room),
regulated with the US Federal Communication Commission (FCC) a standard for all telecommunication 
providers to have capabilities of localizing their users within a defined range \citep{novine}.
Similar standards exist for Europe's E112 service as well \citep{0849333490}. Next generation 
networks, long term evolution (LTE) 4G networks, have been designed from the start to have LBS capabilities integrated
in the system and even a better LBS performance as well as accuracy compared to GSM networks \citep{lteLocation}.
In the introductory chapter, some of the most known positioning techniques in 
wireless networks shall be presented and analysed, Cell-ID, time of arrival, angle of
arrival and GPS positioning. Then the author shall proceed and describe the goals of his thesis. 


\newpage
\section{Positioning techniques}
In this section related technologies for estimating the position of a mobile user shall be presented
and their working principle. 
When the GSM network was designed, its primary goal was to enable wireless 
full duplex telephony service \citep{gsmTelephony}.
Over the past decade the GSM and its follower networks became more popular and mature compared to the initial GSM standard so
the demands grew for different services. One of the demands, was the demand from emergency services
to localize mobile user in emergency situations like snow avalanches or other not 
typical daily emergency situations \citep{0849333490}. This demand led to the 
devolopment of different approaches that differ in complexity and in the degree of accuracy of position fixes.
However, the user positioning was limited by using existing technology standards 
without making extremely expensive cost modifications to the existing network infrastructures. With
regards to costs and existing infrastructure, different ideas have been developed to localize mobile users.
They shall be presented in the following sections but before the details are revealed it is important to
distinguish three different approaches to positioning mobile user's, handset, network and hybrid-based
approach. The handset based techniques are based on one fact, the handset itself tries to estimate its 
position using the available information on its own. In the network based approach the network makes 
all the required measurements and the handset itself is passive. The last approach, hybrid based, uses 
resources from the handset and network together, both are active participants in the position estimation process. In
the further text with mobile station the target user one wants to locate is ment. A few different methods,
varying by their complexity and precision, shall be presented. First simple and then more advanced techniques
shall be presented in their complexity order.

\subsection{Cell-ID}
Cell-identification method is the simplest known GSM ranging method \citep[Chapter 8]{0470092319}. 
By knowing the geographical location of the base transceiver
station (BTS) one can roughly estimate the position of the mobile station (MS) \citep[Chapter 4]{0470694513}. 
It is important to build maps where the BTS signal can be received and where the border \textit{handover} points
are located. Handover is the process of switching from one BTS to another where the signal reception strength
is higher than on the currently connected BTS. 
The basic principle is shown in figure \ref{img:cellid}. The BTS are
divided into geographical regions\footnote{Usually they are represented as hexagons but it could take
any other geometric shape!} by their signal coverage. The MS is in the region of the currently connected BTS
and it could be at any point inside of the hexagon. Every
BTS has a unique identifier code name and hence can be distinguished from other BTS's.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.70]{img/CellID.pdf}
  \caption{Cell-ID position estimation technique where a mobile user can be connected to only one BTS.}
\label{img:cellid}
\end{figure}

Using this method even higher accuracies
can be achieved than the known shape of signal reception \citep[Chapter 8]{0470092319}. Basically, provided that the
\textit{timing advance} (TA) value is known. The TA is the rough prediction of the \textit{round trip time} (RTT), time 
required for a data packet to be received and acknowleded by the MS. Using this measure a rough circle can be made between
the BTS and the bordering points of the Cell-ID region since TA multiplied with speed of light produces the radius distance
of the circle. To obtain the TA value a connection between the MS and the BTS has to exist or a silent call can be made
where the GSM subscriber does not even notice that he/she is being called since there is no ringing
or any other sign that an idle connection is being performed on the MS \citep[Chapter 4]{3GPPTS03.71}. 
If there are more antennas than one, then it can be even further specified where the MS is positioned. 
This can be still inaccurate because of the multipath signal reflections. 
In urban environments it is usually the case that there is no optical line of sight between the BTS and MS,
so while the signal propagates from the BTS to the MS and vice versa it may get reflected from multiple buildings
or other objects which add extra propagation time (extra range to the distance). The accuracy of this method is typically
in a range of 200 m \citep{Zeimpekis}.
This method can be seen both as a handset and network based position
estimation technique, due to the fact that the user may run his/her own application on the cell phone or it can be applied by 
the network operator himself. This estimation technique does not require the MS to be a smart phone, it works with
any type of cell phone.

\subsection{Received Signal Strength}
The Received Signal Strength (RSS) position estimation technique, as the name states,
uses the signal strength measurement reports to localize the MS. RSS measurement 
reports  in GSM networks are transmitted from the MS to the BTS and they
are used to determine if the handover process should be triggered or not \citep{Richard2011Master}. 

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/RSS.pdf}
  \caption{Basic idea of the RSS estimation technique. One rectangle location is represented by two
  RSS measurements for two BTS, blue is BTS1 and red is BTS2.}
\label{img:rssLoc}
\end{figure}
This method requires mapping the location blocks with RSS of the 
covered areas before it can be used \citep{Richard2011Master}. The basic 
idea can be seen in figure \ref{img:rssLoc}, where one location region is represented
by two differently colored (blue and red) RSS measurements inside of one rectangle. 
By knowing pre advance the RSS one can estimate 
the probability that the MS is located in the black rectangle.
Since it is difficult to measure the RSS at every point, the map is interpolated with
RSS using the Voronoin interpolation to calculate the expected RSS at places were 
the measurement have not been conducted \citep{Richard2011Master}. 
In the next step the probability
distribution, the Bayes Theorem, is utilised to estimate the location of the MS
by computing probabilities for all the points in the map. The precision of this method
is limited to the amount of BTS in range and the manufacturer design of the RF front end 
in the cell phone. However, this method can be applied on any cell phone and does not
require a smart phone. It is a network based estimation technique. 

\subsection{E-OTD and UL-TDOA}
E-OTD and UL-TDOA are two similarly working positioning techniques, both use the time difference of 
signal arrival and for this reason have been grouped as one. 
E-OTD stands for Enhanced Observed Time Difference. This technique requires the GSM network to be
clock synchronized. The clock synchronization of the GSM network can be achieved with
a location measurement unit (LMU) \citep{ETSI.TS.125.111}. LMU's provide the precise time to the BTS's 
by having an atomic clock synchronized with the BTS on a seperate location from the BTS or 
by providing a special GPS device at the BTS location that can provide precise time \citep{ETSI.TS.125.111}. 
The clock synchronization of the MS and the BTS is required becase the E-OTD technique 
takes advantage of measuring signal propagation time. 
A data signal with current time information is transmitted from three or more spatially distinct BTS's at the same time
and then propagation time is measured on the MS (all these BTS's must be detecable by the MS itself) \citep{200mRangeEOTD}. 
Once the difference in time is known between the time point when the signal was transmitted and when it was received, 
it is easy to estimate the relative position to the BTS's with hyperbolic trilateration \citep{200mRangeEOTD}
\citep[Chapter 4]{3GPPTS03.71}. 
In order to estimate the absolute position, it is required to know 
the absolute location of the BTS's. The basic idea can be seen in figure \ref{img:eotdLoc}. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=1.20]{img/EOTD.pdf}
  \caption{Basic idea of the E-OTD positioning technique. Current time information
  are transmitted from 3 different BTS's at the same time.Then the MS observes the difference of time when
  the information arrive and using trilateration technique calculates the relative position of 
  the MS.}
\label{img:eotdLoc}
\end{figure}
E-OTD requires the cell phone to be equiped with the firmware software to perform the measurements but does 
not require new or external hardware. The accuracy of this method lies in the range between 50-200 m, depending
on the location of the MS \citep{malik2009rtls}. This method is not resistant to the multipath signal reflection problem.
E-OTD is a handset based position estimation technique.

UL-TDOA (Up-Link Time Difference of Arrival) is a similar localization technique as E-OTD \citep{malik2009rtls}.
The basic difference between UL-TDOA and E-OTD is that the signal propagation time is observed on the BTS's and
not on the MS itself. To estimate the position of the MS, the BTS responsible for the MS forces the MS to request  
for a handover to neighboring two or more BTS's. The MS sends a handover burst signal and the neighboring BTS 
measure the waiting time between the handover request signal itself and the transmitted burst from the MS.
Using the observed time difference, the BTS's can compute the location of the MS. It is important to note, this 
position estimation technique takes place while there is an active call on the MS or the BTS makes a silent call
to the MS where the mobile user is not aware of being tracked \citep{malik2009rtls}. This technique is slightly
less accure than E-OTD, the accuracy lies between 50-300 m \citep{200mRangeEOTD}. Both of these techniques are
challenged by the nature of the GSM network due to its unsynchronized operation. One microsecond error shall produce
an error of around 300 m. The advantage of UL-TDOA over E-OTD lies in the fact that no extra software modifications
have to be made on the cell phone and this technique works on every cell phone. UL-TDOA is a network based position
estimation technique.

\subsection{Assisted-GPS}
Another positioning technique named Assisted-GPS (AGPS) is recently gaining on popularity
because of the great number of smart phones with an embedded AGPS receiver and the introduction. 
of 3G/4G networks. These networks are clock synchronized since 
high-bandwidth wireless services require synchronous working operation \citep{oscilloquartz} \citep{3gNetworkSpeed}.
AGPS receivers can decrease the waiting time required to estimate the position if the 
``exact'' time is known \citep[Chapter 4]{diggelen2009a-gps}.
It works by exploiting the existing
navigation satellite network. 
In the case when mobile users are in urban environments, the GPS satellite signals are blocked
by the buildings. Further analyses showed that the received signals, at the cell phone arrive
with errors because of multiple propagation reflection and are mostly hard 
distinguishable from noise  \citep[Chapter 2]{diggelen2009a-gps}. 
The power of received signals on a GPS receiver is in the range
of 100 attowatts\footnote{1 attowatt = $10^{-16} W$.
The reception quality depends on the receiver antenna and RF front-end part as well.} 
when the GPS receiver is outdoors on open sky,
the signal strength becomes even smaller by a factor of 10-1000 if the user is 
between tall buildings or indoors \citep[Chapter 2]{diggelen2009a-gps}. All these given factors 
affect the acquisition of GPS signals and make the correct reception of GPS signals unrealisable
and impractical. 
Instead of searching manually for the GPS satellites and waiting
for the orbiting parameters to arrive from the satellites, which are required to estimate the
position, information about the orbiting GPS satellites are transmitted over an existing GSM
network infrastructure. This provides the AGPS receiver additional data to track weak signals.
The theoretical foundation of how GPS and AGPS receivers estimate the position is addressed 
in more detail in chatper \ref{gpsTheoryChatper}. 
This method does not work on every cell phone as the previously mentioned methods. 
It requires the cell phones to be equiped with an AGPS receiver.
From this point on, cell phones with an AGPS receiver shall be refered as smart phones 
since they have another potential use aside from the default communication application. The AGPS
position estimation technique is a hybrid based technique because the position is estimated 
with the help of the handset, that estimates the position, and the network provider since
it delivers the required data for faster acquisition time.

\subsection{Other techniques}
The earlier mentioned localization techniques are not the only existing methods but are the standardized ones. 
In this section, two more techniques shall be briefly described, angle of arrival and Google maps WiFi tagging. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=1.20]{img/AOA.pdf}
  \caption{Basic idea of the Angle of Arrival positioning technique. The angle of the reception signal
  on the BTS antenna is measured. By knowing at least two angles on two BTS's, it is possible to 
  interpolate the intersection point where the MS is located.}
\label{img:aoadLoc}
\end{figure}

Angle of Arrival (AOA) is a localization technique that exploits a geometric fact that by knowing at least 
two angles from two known points, i.e. BTS's, it is possible to construct the third triangle point (intersection point). 
The intersection point represents the location of the MS. The angle is derived by a burst 
signal transmitted from the MS and the time difference of arrival for different elements of the burst 
signal. Once the angle is computed, it is straightforward to find the intersection point. 
This technique requires the BTS's to be synchronized with LMU's and to be in line of sight with the BTS's,
otherwise this method shall develiver poor position results. It belongs to the group of network based 
position estimation techniques.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/WiFiTag.pdf}
  \caption{Wireless Access Point tagging. The MS could be located anywhere where all three access points
  are visible, this area has a wavy background and is between access points 1, 2 and 4.}
\label{img:WiFiTag}
\end{figure}

Another technique gaining on popularity is used by Google maps to identify the position of the user by
simply tagging an area with all visible wireless access points \citep{googleLBS}. Since each access point has a unique MAC address
it is not hard to identify them while driving through urban areas with a WiFi scanning device. The basic idea is 
depicted in figure \ref{img:WiFiTag}, where the MS in this particular example is located where access points
1, 2 and 4 are visible at the same time stamp. 
This technique works efficiently indoors as well as outdoors in cities since 
ranges of wireless networks 801.11 b/g are not more than 30-150 m, though the new standard 801.11 n has a wider coverage area.
A simple overview of all the mentioned techniques is given in 
table \ref{tbl:overviewLoc}.

\begin {table}[tp!]
\caption{Overview of the localization techniques.}
\label{tbl:overviewLoc}\centering 
%\rowcolor{2}{light-gray}{}
\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Method&Sync.&Advantage\&Disadvantage&Accuracy&Type\\\toprule
\rowcolor{light-gray}Cell-ID& No& Works on any cell phone,& Anywhere in cell& Network\\
\rowcolor{light-gray}       &   &Imprecise&&\\%\midrule
Cell-ID + TA& No& Works on any cell phone,& Anywhere in cell& Network\\
       &   &Imprecise but better& but with a radius\\ 
       &   &than Cell-ID alone&\\%\midrule
\rowcolor{light-gray}RSS    & No& Works on any cell phone,& $\approx 300$ m& Network\\
\rowcolor{light-gray}       &   &Depends on cell phone&&\\
\rowcolor{light-gray}       &   &model and environment&&\\ %\midrule
E-OTD  &Yes& Works on most new& $\approx 50-200$ m& Handset\\
       &   &cell phone models,&\\
       &   &Expensive because LMU&\\ %\midrule
\rowcolor{light-gray}UL-TDOA&Yes&Works on any cell phone& $\approx 50-300$ m& Network\\
\rowcolor{light-gray}       &   &Expensive because LMU&&\\ %\midrule 
AGPS&Yes/No&Works on some cell& $\approx 5-20$ m& Hybrid\\
       &   &phones with AGPS&\\
       &   &receivers, Very precise&\\ %\midrule
\rowcolor{light-gray}AOA    &Yes&Works on any cell phone,& Depends if MS is& Network\\
\rowcolor{light-gray}       &   &Expensive because LMU&in line of sight&\\%\midrule
Google maps&No&Requires a smart phone&$\approx 5-30$ m& Handset\\
with WiFi&    &with Google maps and& &with aid\\
       &    &Wireless 801.11 b/g/n,& &of\\
       &    &Does not work outside & &Network\\
       &    &of cities or missing \&& \\
       &    &unknown WiFi signal&\\\bottomrule
\end {tabular}
\end {table}

\clearpage
\section{Goals of the thesis}
In this thesis the author shall provide theoretical and practical 
background knowledge required for building a localization system of mobile users 
inside of a 2G GSM network by taking the advantage of AGPS receivers inside of smart phones.
%This work may be perceived as pioneer work from authors perspective

The thesis can be divided into three parts, theoretical introduction to GSM and GPS systems as well as 
the protocol required for the positioning of mobile users. The second part shall provide more details on 
the software implementation and the hardware used in this work. The last part may be seen as a discussion
of the achieved results in the test environment and authors views on the work.

Theoretical knowledge of GPS and AGPS receivers shall be provided in chapter 2, 
as well as of the GSM operational principles in chapter 3 for understanding the basic functioning principles of the
entire positioning system. The theoretical concepts of GPS receivers 
shall be analysed and discussed in profound depth 
since it shall provide strong evidence on the advantages and limitations
of this method. These two chapters shall provide an answer for the achieved 
and observed results in this thesis. Once the GPS and GSM working principles have
been explained, the author shall proceed with introducing the reader to the
Radio Resource Location Protocol (RRLP), responsible for transmission of
assistance data and obtaining the position of the mobile user. More 
details on RRLP shall be given in chapter 4. 

Furthermore, the reader shall be introduced to the software 
development and implementation process in chapter 5. More details on the hardware connections and set up
shall be provided in chapter 6.

In the last two chapters of this thesis, in chapter 7 test results shall be presented and the test environment. 
In chapter 8 summary of the entire system shall be provided. 

In the appendix, details for configuring the entire system and for obtaining the same results
shall be provided. This thesis includes an USB stick with the source code developed 
during the work on this thesis.




\setchapterpreamble[u]{%
  \dictum[Stobaeus] {What use is knowledge if there is no understanding?}
}
\chapter{GPS \& Assisted-GPS}
\label{gpsTheoryChatper}
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.38]{img/satelliteRanges.pdf}
  \caption{GPS Simple working principle, a) example in 3D space with spheres b) example in 2D space with circles.}
\label{img:GPSSimplePrinciple}
\end{figure}
In the new global economy age, GPS positioning has become of important value for various services
and businesses. It has been growing at a rate of 30\% in the past few years and the application
market is expected to be worth \euro 240 milliard by 2020 only in Europe \citep{gpsMoney}.
The goal of this chapter is to bring more details and insights of how GPS receivers work.
The chapter is divided in few sections that explain how the data are modulated before transmission, 
demodulated on the receiver, how the search space works, how the target user position is estimated and
the errors that can influence the overall working of the system.



In this paragraph the general idea shall be given of how GPS works and how the position is estimated.
Before all the details are revealed in the following sections,
it is important to understand the basic principle of GPS navigation.
GPS positioning works by using the principle of \textit{trilateration}.
Distances from the satellites to the GPS receiver are measured and 
from these distances receiver's position is estimated. The distances are estimated
by measuring the signal propagation time between the satellites and the receiver,
this position estimation technique is also known as time-of-arrival (TOA) method.
Once sufficient amount of measurements from different satellites were generated, 
the position of the receiver can be approximated. 
It is important to understand that the positions from the satellites
need to be known and same location reference system has to be used.
The general principle of this idea can be seen in figure
\ref{img:GPSSimplePrinciple}, picture (a) represents the idea
with spheres in 3D space and picture (b) the same idea but in 2D space.
The blue, yellow and green wireframes below the GPS satellites represent the spheres 
for a given range, between the satellite and the estimated position of the GPS user
for the given satellite. 
By intersecting all the three spheres, the position of the user is estimated.
In the next sections this general idea shall be developed in more details,
in an step by step approach, and the ideas shall be verified using the appropriate mathematical
models. 

\clearpage
\section{GPS data and signal modulation}
\label{sec:gpsDataAndSignal}
The aim of this section is to give the reader an overview of the transmitted GPS data and
to understand what type of processing takes place on the GPS satellite itself.
As mentioned in the paragraph earlier, to estimate the position of the GPS receiver, it is
important to know the position of the satellite at the moment of signal transmission. Prior to
releasing the data in the athmosphere, they need to be modulated in order for the GPS receiver
to receive and demodulate them. 

Each one of the GPS satellites transmits the same type of information.
The transmitted data are called \textit{frames} \citep{9780817643904}. 
One frame of data can be seen in figure \ref{img:gpsframe}. Every of the 25 transmitted frames
can be divided into five subframes of 300 bits length \citep{diggelen2009a-gps}. The data in the
frames are called \textit{navigation data} because using them the GPS receiver can estimate
user's position. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.60]{img/NAV-Message.pdf}
  \caption{One frame of 1500 bits on L1 frequency carrier}
\label{img:gpsframe}
\end{figure}
Each subframe can be divided into three fields of data,
as shown in figure \ref{img:gpssubframe}, telemetry (TLM), 
handover (HOW) word and rest of the data (navigation data).
TLM is the first word of the subframe and consists of
a unique preamble used to synchronize and identify 
the subframes \citep{9780817643904}. HOW is the second
word of the subframe and consists of the \textit{GPS system time}
and subframe ID \citep{9780817643904}. 
GPS system time is the time the atomic clock on the satellite generates
at the moment of subframe broadcast 
and it acts as a time stamp \citep{GPS-Interface-Specification}.
The third segment of the subframe, indicated as rest of data in figure
\ref{img:gpssubframe}, consists of the navigation data. The first subframe
includes data about the satellite accuracy and health as well as parameters
used for the clock corrections on the receiver side. More details on these
parameters shall be given in section \ref{sec:SigDemod}. Subframe two and three
are made of \textit{ephemeris data}. Ephemeris
information are precise parameters for predicting the precise orbital
position of the GPS satellite. Using ephemeris data for the specific
system time stamp and the equations given in appendix section \ref{sec:gpsConsAndEq} 
the GPS receiver can precisely estimate the position $(x_s,y_s,z_s)$ of
the satellite. The first three subframes are satellite dependent and do not
change in the transmitted 25 frames aside from the system time stamp \citep{GPS-Guide}.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/GPSSubframe.pdf}
  \caption{Subframes always start with telemetry and handover words}
\label{img:gpssubframe}
\end{figure}
Fourth and fifth subframes include \textit{almanac data}, low-precision clock corrections, 
ionospheric model and UTC time calculation parameters. Almanac information are
rough coarse parameters for predicting the orbital position of the GPS satellites.
These low-precision parameters are used by the GPS receiver to estimate the rough
position of the GPS satellites and to reduce the searching space for the GPS satellite
transmission frequencies\footnote{Although all satellites transmit on the same one frequency, 
when the signals are received on Earth, they have a different frequency
from the transmitted one. This shall be further explained in more details in the following sections \ref{sec:Carrierdemod},
\ref{sec:CAdemod} and \ref{sec:2dSearch}.} and
obtaining the precise ephemeris data.
Ionospheric model and UTC time calculation parameters are required
by the GPS receiver to refine the calculation of delays through
the ionosphere \citep{9780817643904}. The reason why there are 25 frames is because of the last two
subframes, four and five. 
Subframes four and five have data which cycle through the 25 frames, i.e. almanac data
are transmitted for all the 32 GPS satellites\footnote{24 satellites are used in the GPS system, 
the rest is used in case one of the 24 fails.} in case the receiver found only one satellite
and once it collected all almanac data, it can search for other visible GPS satellites. 
These 25 frames create a masterframe. Once the 25 frames
have been transmitted, the process is repeated again. 
 
The data are modulated using the binary phase shift keying (BPSK) technique. The
newly modulated signal is the \textit{L1} signal and it is emitted from the satellite
directed antennas towards Earth \citep{GPS-Guide}. The BPSK technique works by changing 
the phase of the carrier signal for $180^{\circ}$ at the moment of bit toggle (flipping) in the
data \citep{GPS-Guide} \citep{9780817643904}.
Basic principle of this technique can be seen in figure \ref{img:bpskmod}. The carrier wave
for GPS BPSK modulation is centered at a frequency of 1575.42 MHz \citep{9780817643904}.
These signals travel an average distance of $20200 \, km$ from the satellite to the GPS receiver 
and are affected by various sources of noise. BPSK modulation is mostly used for satellite links 
because of its simplicity and immunity to noise and signal intereference for the price of
transfering data at low speed rates \citep[Chapter 1]{9780849316579}. The demodulation process
of L1 shall be discussed and analysed seperately in section \ref{sec:Carrierdemod}.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/BPSKModulation.pdf}
  \caption{BPSK Modulation - First signal is the carrier wave,
  and it is multiplied (mixed) with the second signal, which are
  the data to be transmitted. The resulting signal at the output
  of the satellite antenna is the third one.}
\label{img:bpskmod}
\end{figure}

However, before the raw navigation data enter the BPSK modulation process, they are XORed
with pseudo random noise (PRN) sequences for different satellites (each satellite
owns a unique PRN sequence) \citep{9780817643904}. PRN sequences are used to identify
which satellite signal is being decoded, transmission of the data on the same frequency
as well as to enable the distance measuring mechanism between the satellite and the GPS receiver. 
Equivalent PRN sequence is generated on the
GPS receiver and it is compared with the received PRN sequence which is delayed (shifted) 
due to the distance. This delay multiplied with the speed of light yields the distance
between the satellite and the GPS receiver.
PRN sequences have similar autocorrelation properties as noise, when it is shifted in
time domain it has a low correlation value whereas when it is matched with exact image of itself 
it produces a high correlation peak \citep[Chapter 3]{bensky2008wireless}. This property is used
for identifying the satellites and for finding the exact phase shift. 
The second important property of PRN sequences is the property of
orthogonality. This proberty enables the reception of different data on the same frequency,
also known as code division multiple access (CDMA). It is important to note that the PRN sequences
must have a higher frequency than the data, i.e. the bit duration of a PRN sequence is much shorter
than of the data \citep[Chapter 3]{bensky2008wireless}. Single bits in PRN sequences are called \textit{chips}
and the complete sequence as \textit{code} \citep[Chapter 3]{bensky2008wireless}. This newly generated
signal is called direct sequence spread spectrum (DSSS) \citep[Chapter 3]{bensky2008wireless}. In
GPS terminology it is named as Code/Acquisition (C/A) code. C/A code is feed into the BPSK modulation
process, where it is mixed with the carrier wave and producing the L1 signal. More details shall be given in the
C/A demodulation section \ref{sec:CAdemod}. Transmission speed of the navigation message is
50 bps, therefore the reception of a complete masterframe requires around $\approx12.5$ minutes, i.e. 
$(1500 \, \mathrm{bits per frame}\, \cdot \, 25 \, \mathrm{frames}) / (50 \,\mathrm{bps} \, \cdot \, 60\, \mathrm{s})$.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/GPS-Modulation.pdf}
  \caption{Modulation of the GPS signal L1}
\label{img:gpsmod}
\end{figure}

The described GPS navigation data modulation can be seen in figure \ref{img:gpsmod} and it 
can be represented in form of equation \eqref{eq:GPSSignalReceived1} \citep{1656803}, where $D(t)$
are the navigation data at the moment $t$, $C(t)$ is the PRN chip at the moment $t$, $cos(2\pi f_{c}+\varphi_{SV})$
is the generated carrier wave with frequency $f_c$ and phase $\varphi_{GPS}$, $P$ is output power of the transmitter
amplifier.
\begin{equation}
\label{eq:GPSSignalReceived1}
S(t) = PD(t)C(t)cos(2\pi f_{c}+\varphi_{GPS})
\end{equation}
The equation \ref{eq:GPSSignalReceived1} shall be rewritten as given in \ref{eq:GPSSignalReceived2}. It
represents the same equation but at the GPS receiver after traveling $\approx 20200 \, km$, where $d_{C/A}$
is the C/A data and $n(t)$ is the random noise at moment $t$ influenced by various factors that influence
electromagnetic waves.
\begin{equation}
\label{eq:GPSSignalReceived2}
S(t) = \sqrt{\frac{P}{2}}d_{C/A}cos(2\pi f_{c}+\varphi_{GPS}) + n(t)
\end{equation}
The GPS satellites are positioned in orbits so that at every moment at any spot on Earth, at least four satellites are visible 
(a spot can be considered as a mountain peak since in the cities GPS signals are blocked by buildings).
In the next section, more details shall be revealed on the process of demodulating the GPS L1 signal and acquiring the
correct time and position.





\newpage
\section{GPS signal acquisition and demodulation}
\label{sec:SigDemod}
GPS satellites\footnote{Ssatellites are named as space vehicles 
in GPS terminology and the abrevation SV is used in the equation notations
to denote a parameter related to the satellite itself.}
orbiting our planet, at a distance of approximately $20200 \, km$,
are equiped with precise atomic clocks \citep[Chapter 2.7]{diggelen2009a-gps}.
These atomic clocks are calibrated and maintained on
a daily basis by the U.S. Air Force \citep{GPS-Pentagon}. 
The time the atomic clock generate, refered earlier as GPS
system time, denoted as $t_{SV}$, is generated as a time stamp at the moment
of the subframe broadcast \citep{GPS-Interface-Specification}.
In addition to the
broadcast time, subframe 1 contains parameters to account
for the deterministic clock errors embedded in the
broadcasted GPS system time stamp. These errors can be
characterized as bias, drift and aging errors
\citep{GPS-Interface-Specification}. The correct broadcast
time, denoted as $t$, can be estimated using the model given in equation
\eqref{eq:timecorrection1} \citep{GPS-Interface-Specification}. 
In equation \eqref{eq:timecorrection2}, where the GPS
receiver is required to calculate the satellite clock
offset, denoted as $\Delta t_{SV}$, a number of unknown terms can be
seen. These terms are encapsulated inside of the transmitted frames. The polynomial
coefficients: $a_{f0}$ - \textit{clock offset}, $a_{f1}$ - 
\textit{fractional frequency offset}, $a_{f2}$ - \textit{
fractional frequency drift}; and
$t_{0c}$ - \textit{reference epoch} are encapsulated inside
of subframe 1. The only remaining unknown term left in equation 
\eqref{eq:timecorrection2} is the \textit{relativistic correction
term}, denoted as $\Delta t_{r}$. $\Delta t_{r}$ can be evaluated
by applying the equation given in \eqref{eq:timecorrection3}.
$F$ is a constant calculated from the given parameters
in \eqref{eq:paramconst1} and \eqref{eq:paramconst2},
whereas $e$, $\sqrt{A}$ and $E_{k}$ are orbit
parameters encapsulated in subframes 2 and 3
\citep{GPS-Interface-Specification}. 

\begin{equation}
\label{eq:timecorrection1}
\centering
t=t_{SV}-\Delta t_{SV} 
\end{equation}
\begin{alignat}{4}
 & \Delta t_{SV} &= \;& a_{f0} + a_{f1}(t_{SV}-t_{oc}) + a_{f2}(t_{SV}-t_{oc})^{2} + \Delta t_{r} \label{eq:timecorrection2} \\
 & \Delta t_{r}  &= \; & Fe\sqrt{A}\sin{E_{k}} \label{eq:timecorrection3} \\
 & F &= \;& \frac{-2\sqrt{\mu_{e}}} {c^{2}} = -4.442807633 \cdot 10^{-10} \frac{s}{\sqrt{m}} \label{eq:timecorrection4} 
\end{alignat}

Nevertheless, the broadcast satellite time
information is not sufficient to estimate the precise
time at the moment of the signal arrival. Even though the signal
arrives in approximately\footnote{Propagation time
depends on user and GPS satellite position.} $77 \, ms$,
the precision of the atomic clock is in the
range of 10 ns \citep[Chapter 2]{diggelen2009a-gps}. 
Undoubtedly the signal propagation (travel)
time, denoted as $t_{prop}$, has to be taken into account.
In that case, the exact time at the moment of arrival is known,
denoted as $t_{exact}$ and is given in equation \eqref{eq:exactTime}.
%The signal propagation time must be known to
%estimate the distance from the satellite
%but is not sufficient to estimate the position of the GPS receiver. 
Propagation time is computed by measuring the phase shift of the C/A
signal, more details shall be given in sections \ref{sec:CAdemod} 
and \ref{sec:distanceAndPosition}.
More importantly, $t_{exact}$ time shall be later used 
to synchronize various time dependent systems like the
GSM, LTE, GNSS or other communication and ranging systems.
\begin{equation}
\label{eq:exactTime}
t_{exact} = t_{prop}+t
\end{equation}

\subsection{Carrier wave demodulation}
\label{sec:Carrierdemod}
In order to calculate the signal propagation time between
the satellite and the receiver, the internal sine 
wave synthesizer inside of the receiver has to be
synchronized with the carrier sine wave generator
of the GPS satellite \citep{4560215}. In other words,
the identical carrier wave replica has to be generated
on the receiver as on the satellite \citep{736341}. 
However, the received signal is not the equivalent
of the transmitted signal. Due to the nature of the
Doppler effect\footnote{Doppler effect is a
phenomenon that happens as a result of relative
motion of the two bodies, transmitter and
receiver, towards or away from each other and causes 
frequency shift of the electromagnetic wave
\citep[Chapter 4]{3540727140}.}
and wave propagation, the transmitted signal arrives 
phase disordered at the receiver \citep{4560215}. 
This phase disorder is a consequence of the relationship 
between the instantaneous frequency and instantaneous phase
according to equations \eqref{eq:freqPhase} and \eqref{eq:phaseFreq}. 
\begin{equation}
\label{eq:freqPhase}
f(t)=\frac{1}{2\pi}\frac{\partial}{\partial t}\phi(t)
\end{equation}
\begin{equation}
\label{eq:phaseFreq}
\phi(t) = 2\pi \int_{-\infty}^{t} f(\tau) d\tau
\end{equation}

Considering that the GPS satellites orbit the Earth with
a speed of around $3.9 \, km/s$, the Earth rotates 
around its axis and the target user 
with the GPS receiver may move as well, the Doppler effect
is unavoidable.
The observed phase at the receiver antenna, 
denoted as $\varphi_{o}$, can be described using
the equation given in \eqref{eq:phaseShift}, 
where $\varphi_{GPS}$ represents the known satellite
carrier wave phase, $\delta \varphi_{SV}$ the clock
instabilities on the GPS satellite,
$\varphi_{a}$ the phase shift error
caused by propagation delays in the ionosphere
and troposphere respectively, $\delta \varphi_{DE}$ the phase shift 
caused by the Doppler effect and $\delta \varphi_{w}$
is the wideband noise phase shift. 
\begin{equation}
\label{eq:phaseShift}
\varphi_{o} = \varphi_{GPS}+ \delta\varphi_{SV} + \varphi_{a} +\delta \varphi_{DE} + \delta \varphi_{w} 
\end{equation}
The task of the demodulation process is to 
generate a replica carrier wave with the matching
phase shift and mix it with the incoming signal. 
In the ideal case the observed phase
on the antenna and the generated phase on the
receiver, denoted as $\varphi_{rec}$, cancel each other
out, that is to say, equation \eqref{eq:phaseIdealCase}
equals zero. 
\begin{equation}
\label{eq:phaseIdealCase}
\Delta \varphi = \varphi_{o} - \varphi_{rec}
\end{equation}
The circuit responsible for generating the same
carrier wave is the phase locked loop (PLL). 
The PLL circuit is a feedback loop that modifies the synthesized wave parameters
such that $\Delta \varphi \approx 0$, a phase shift is shown in figure \ref{img:phaseShift}.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/Phase-Diff.pdf}
  \caption{Two equivalent carrier waves with the same frequency but different phase shift}
\label{img:phaseShift}
\end{figure}

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/L1-Demodulation.pdf}
  \caption{Demodulation of the L1 GPS signal}
\label{img:L1Demod}
\end{figure}

The reason for this is straightforward to understand by looking at the
 multiplication of two sine waves. The GPS L1 signal 
 demodulator at the receiver is depicted in figure
\ref{img:L1Demod}, the incoming signal L1 is multiplied with 
the synthesized sine wave (multiplication is the function of
a mixer, denoted as $\otimes$ in figure \ref{img:L1Demod}). 
For the purpose of easier analysis, cosine waves
shall be used istead of sine waves, the difference between them 
is only in the phase shift, as denoted in equation
\eqref{eq:sineEqCosine}. 
\begin{equation}
\label{eq:sineEqCosine}
\sin(\pm x) = \cos\bigg(\frac{\pi}{2} \pm x\bigg)
\end{equation}
Multiplication of two cosine waves, as in equation \eqref{eq:multCosin},
can be derived by adding $\cos(A+B)$ and $\cos(A-B)$ together, as respectively
given in equations \eqref{eq:cos1} and \eqref{eq:cos2}.
\begin{equation}
\label{eq:multCosin}
\cos(A)\cdot\cos(B) = \frac{1}{2}\cos(A-B)+\frac{1}{2}\cos(A+B)
\end{equation}
\begin{equation}
\label{eq:cos1}
\cos(A+B) = \cos(A)\cos(B)-\sin(A)\sin(B)
\end{equation}
\begin{equation}
\label{eq:cos2}
\cos(A-B) = \cos(A)\cos(B)+\sin(A)\sin(B)
\end{equation}
The incoming GPS L1 signal with a frequency $f_{1}$, given in figure \ref{img:L1Demod}, 
can be written as $d_{C/A}\cos(\omega_{1}t)$, a similar form is given in equation \eqref{eq:GPSSignalReceived2},
where $\omega_{1}=2\pi f_{1}$ is
the angle frequency and
$d_{C/A}$ is the C/A data (navigation message modulated with the PRN code),
$d_{C/A}=d_{PRN}\oplus d_{NAV}$.
If equation \eqref{eq:multCosin} is rewritten with the received GPS signal L1
and synthesized wave with frequency $f_{2}$, the equation results the one
given in \eqref{eq:cosResult}
\begin{equation}
\label{eq:cosResult}
d_{C/A}\cdot\cos(\omega_{1}t)\cos(\omega_{2}t) = \frac{1}{2}d_{C/A}\cdot\cos(\omega_{1}t-\omega_{2}t) + \frac{1}{2}d_{C/A}\cos(\omega_{1}t+\omega_{2}t)
\end{equation}
This leaves the resulting signal with two frequency terms, a low frequency 
term $(\omega_{1}t-\omega_{2}t)$
and a high frequency term $(\omega_{1}t+\omega_{2}t)$,
the $t$ can be taken in front of the bracket as it
is a common multiplier.
The high frequency term, $(\omega_{1}+\omega_{2})$, can be filtered out using
a low-pass filter\footnote{A low-pass filter passes
low frequency signals and attenuates
high frequency signals. In other words, signals higher than the
specified cutoff frequency of the low-pass filter, are cut off by reducing their amplitudes.}.
Ideally, the difference of the angle frequencies is zero,
as in equation \eqref{eq:delaOmega}, since $\cos(\Delta \omega)=\cos(0)=1$
and the remaining left signal is only the C/A code multiplied
with the DC term (zero frequency producing a constant voltage) leaving only $\frac{1}{2}d_{C/A}$.
\begin{equation}
\label{eq:delaOmega}
\Delta \omega = \omega_{1}-\omega_{2} = 0
\end{equation}
However, if the frequencies do not match, $f_{1}\neq f_{2}$,
then the output signal $\frac{1}{2}d_{C/A}$ shall be
modified by the residual frequency $f_{1}-f_{2}$, 
and subsequently this shall change the demodulated C/A output (also known as phase shift). Under those circumstances
the correlator shall be unable to match the C/A code with the
correct PRN code. An illustration of this phenomenon is depicted
in figure \ref{img:multCAPhase}. 

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/PRN-PhaseShiftAfterDemod.pdf}
  \caption{Effects of the low frequency term on the demodulated output
  C/A wave on the GPS receiver (the explanations and figures are from top to bottom).
  If the synthesized frequency is correct, $f_{1}=f_{2}$, the low 
  frequency term becomes a DC term and does not modify the output
  $d_{C/A}$ wave (first figure). If the frequency matches but the
  phase not, in this case the phase is shifted for $\pi$, then
  $d_{C/A}$ is inverted (second figure).
  If the phase shifts with time, then the amplitude and phase of $d_{C/A}$
  shall vary as well (third figure).}
\label{img:multCAPhase}
\end{figure}


\newpage
\subsection{C/A wave demodulation}
\label{sec:CAdemod}
As a result of the previous step, one can continue with
the demodulation of the C/A wave. Demodulating the C/A wave
with the PRN code shall result in the time and navigation data.
Each tracked GPS satellite signal is demodulated seperately 
using the same PRN code, code chipping rate and carrier frequency-phase 
(which was determined above) for the given satellite
\citep[Chapter 4]{understandGPS}. 
The PRN codes for each GPS satellite is well defined and
known by the GPS receiver. The receiver has to generate the
equivalent PRN code with matching code chipping rate (phase)
of the transmitted C/A code,
this is depicted in figure \ref{img:prnCodeCompare} \citep[Chapter 5]{understandGPS}. 
This phase shift is again a consequence of the Doppler effect described in
section \ref{sec:Carrierdemod}.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/PRN-ChipRate.pdf}
  \caption{Comparison between the original C/A code generated on the
  GPS satellite with two synthesized PRN codes with a different phase shift on the receiver.}
\label{img:prnCodeCompare}
\end{figure}
For the particular example, the matching phase shift was achieved with
the second replica PRN code, with a phase shift of $\tau=0$ but
there could be a case with any other value of $\tau$, $\tau\in[0,1022]$.
Implementation of the PRN code synthesizer depends on the GPS receiver
manufacturer but it is usually implemented as a linear feedback shift
registers (LFSR) that produces an output according to a predefined function $f(\tau)$. 
This function, $f(\tau)$, generates an PRN code, that is
delayed in phase by $\tau$, where $\tau$ is a multiple of the chipping
rate period $T_{c}=977.5 \,ns$. The chipping period $T_{c}$
can be derived from equation \eqref{eq:chipPeriod}. 
The amount of time required to find a matching PRN code shift, $\tau$,
on the receiverr is proportional to the amount of parallely working LFSRs on the system
\citep[Chapter 3]{bensky2008wireless}. Clearly with more LFSRs
the required time for finding the matching phase shift increases.
\begin{equation}
\label{eq:chipPeriod}
T_{c} = \frac{1}{f_{PRN}} = \frac{1}{1.023\cdot 10^6 \mathrm{Hz}}
\end{equation}

To determine whether the synthesized PRN code,
matches the incoming C/A code of the received satellite
signal, known correlation properties of PRN codes are used,
as described in section \ref{sec:gpsDataAndSignal}. 
Since the PRN code is modeled as a sequence of +1's and
-1's, the autocorrelation of
a signal is at its maximum if it is in phase, i.e. 
summing up the sequence products yields the absolute
maximum value for the case where each bit from one signal matches
the bit from the other signal. As an illustration of the idea, an example is
given in figure \ref{img:correlatingSignals}. The cross-correlation
of the incoming C/A code with the first synthesized PRN code produces a 
result of $-3=(+1)\cdot(-1)+(-1)\cdot(+1)+(+1)\cdot(-1)+(+1)\cdot(+1)+(-1)\cdot(+1)$,
whereas the cross-correlation of the incoming C/A code
and the second synthesized PRN code yields a result of 
$+5=(+1)\cdot(+1)+(-1)\cdot(-1)+(+1)\cdot(+1)+(+1)\cdot(+1)+(-1)\cdot(-1)$.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/Correlation.pdf}
  \caption{Cross-correlation on three different signals}
\label{img:correlatingSignals}
\end{figure}
The same principle applies to the transmitted C/A and 
generated PRN code sequences in the GPS receiver. Thus, this can be modeled using
the equation given in \eqref{eq:autocorrelationProperty}, 
where $G_{i}(t)$ is the C/A code\footnote{PRN generated code for GPS satellites 
is called Gold code sequences
since they were first discovered by Dr. Robert Gold.} as a
function of time $t$, for the GPS satellite $i$; $T_{C/A}$ is the
C/A chipping period of $977.5 \,ns$ and $\tau$ is the phase shift 
in the auto-correlation function \citep[Chapter 4]{understandGPS}.

\begin{equation}
\label{eq:autocorrelationProperty}
R_{i}(t) = \frac{1}{1023\cdot T_{C/A}} \int_{t=0}^{1022} G_{i}(t)G_{i}(t+\tau)d\tau
\end{equation}
Another correlation property of the PRN codes is used,
the fact that in the ideal case the cross-correlation of two
different PRN codes yields a result of zero. The ideal case of
PRN code can be modeled as in equation \eqref{eq:prnIdealCaseZero},
\begin{equation}
\label{eq:prnIdealCaseZero}
R_{ij}(\tau) = \int_{-\infty}^{+\infty} PRN_{i}(t)PRN_{j}(t+\tau)d\tau = 0
\end{equation}
where $PRN_{i}$ is the PRN code waveform for GPS satellite $i$ and 
$PRN_{j}$ is the PRN code waveform for every other GPS satellite other
than $i$, $i\neq j$ \citep[Chapter 4]{understandGPS}. Equation
\eqref{eq:prnIdealCaseZero} ``states that the PRN waveform of satellite
$i$ does not correlate with PRN waveform of any other satellite $j$ for
any phase shift $\tau$'' \citep[Chapter 4]{understandGPS}.
Without the property given in \eqref{eq:prnIdealCaseZero},
the GPS receiver would not be able to smoothly 
differentiate between different GPS satellite signals. 
Once the phase shift, $\tau$, has been found, the C/A code is modulated
(XORed) with it. The resulting binary code shall be the navigation message.
The implementation problem of finding correct C/A and carrier wave demodulation shall be
further explained in the following section \ref{sec:2dSearch}.

\subsection{Implementation of the 2D search space problem}
\label{sec:2dSearch}
In the following paragraphs an introduction shall be given on 
the implementation problems of the previously mentioned concepts. 
As it can be seen, 
from subsections \ref{sec:Carrierdemod} and
\ref{sec:CAdemod}, decoding the GPS navigation message is a 2D 
search space problem for each GPS satellite
signal acquisition. The 2D search space is limited by well known
physical properties of the GNSS system such as the motion speed of GPS satellites
(and the receiver) as well as the frequency oscillator on the receiver. 

GPS satellites move toward or away
from the GPS receiver with a speed of $800 \, \mathrm{m/s}$
\citep[Chapter 3]{diggelen2009a-gps}. The Doppler effect on the frequency
of the satellite can be estimated using equation \eqref{eq:dopplerEffectSpeed},
where $f_{e}$ is the emitting frequency (L1), $v_{SV}$ is the speed of the
satellite towards (away from) the receiver and $c$ is the speed of light.
\begin{equation}
\label{eq:dopplerEffectSpeed}
f_{DE} = f_{e}\frac{v_{SV}}{c}
\end{equation}
By inserting the appropriate values in equation \eqref{eq:dopplerEffectSpeed}
yields a result of $\approx4.2 \, \mathrm{kHz}$, for $800 \, \mathrm{m/s}$ and
$\approx-4.2 \, \mathrm{kHz}$ (if the satellite moves away from the GPS receiver
then the speed is taken as negative). This makes a total range of $\approx8.4 \, \mathrm{kHz}$.
The Doppler effect of the GPS receiver motion can be ignored since for
each $1 \, \mathrm{km/h}$ of movement, it affects the frequency
range for $\approx 1.46 \,\mathrm{Hz}$.

On the other hand, the frequency offset induced by the reference
oscillator in the GPS receiver can not be ignored. Function of the reference
oscillator is to give the GPS receiver the clock pulse required for all
the computations and comparisons. 
The frequency search space is ``additionaly affected for $1.575 \, \mathrm{kHz}$
of unknown frequency offset for each $1 \, \mathrm{ppm}$
(\textit{parts per million}) of the unknown receiver
oscillator offset'' \citep[Chapter 3]{diggelen2009a-gps}. The reference oscillators
in GPS receivers have typically an offset of 
$\pm0.5, \pm1, \pm2, \pm3, \mathrm{or} \pm5 \,\mathrm{ppm}$
\citep{daishinku}, \citep[Chapter 3]{diggelen2009a-gps}, the standard in 
smart phone design has been set to $\pm 2.5 \, \mathrm{ppm}$
\citep{oscillatorGPSSmarthPhone}. In the worst case this makes the
unknown frequency to be in range of $10 \, \mathrm{kHz}-25 \, \mathrm{kHz}$.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.70]{img/2D-SearchSpaceInk.pdf}
  \caption{Segment of the frequency/code delay search space for a single GPS satellite}
\label{img:prnSearchSpace3d}
\end{figure}

A typical receiver searches in frequency bands (bins) of several hundred Hz \citep{1656803}.
Commonly used frequency bin size is $500 \, \mathrm{Hz}$,
therefore there are about 20-50 bins to search ($10000\, \mathrm{Hz}/500\, \mathrm{Hz} = 20$) \citep[Chapter 3]{diggelen2009a-gps}.
The frequency search bin (band) size is a function of the desired peak magnitude loss (signal to noise ratio)
due to the frequency mismatch and integration time period. Larger frequency
bands mean a smaller number of bins to search but
a greater correlation peak magnitude loss, i.e. with larger frequency bands
it becomes harder to identify the correlation peaks described in sections \ref{sec:gpsDataAndSignal} and \ref{sec:CAdemod}. 
The frequency search bin size can be
estimated using the frequency 
mimsmatch loss \textit{sinc} function given in equation \eqref{eq:mistunigLoss} \citep{implSoftGPSRec},
\citep[Chapter 6]{diggelen2009a-gps},
where $\Delta f$ is the frequency mismatch in $\mathrm{Hz}$,
in other words it represents the difference
between the received signal frequency and
the synthesized carrier frequency on the receiver;
and $T_{ci}$ is the coherent integration time (usually $0.5\, ms$ according to \citep{implSoftGPSRec}
and \citep[Chapter 3]{diggelen2009a-gps} but depends on the implementation).
\begin{equation}
\label{eq:mistunigLoss}
D_{F} = \left\vert \frac{\sin(\pi \Delta fT_{ci})}{\pi \Delta fT_{ci}} \right\vert
\end{equation}
The frequency mimsmatch loss sinc function, $D_{F}$, is evaluated in dB,
therefore for a loss of $\approx 0.98 \,\mathrm{dB}$, the frequency mismatch ought to be
$\Delta f = 250\, \mathrm{Hz}$,
due to the fact that the maximum loss shall occur when the frequency is differing
by 1/2 of the bin spacing. That is to say, for a bin space of 500 Hz, it is 250 Hz. 

``The total range of possible GPS code delays is $1\, ms$. This is because the GPS C/A
PRN code is $1 \,ms$ long, and then it repeats. The PRN code chipping rate is $1.023
\,\mathrm{MHz}$, and there are 1023 chips in the complete $1\, ms$ epoch'' \citep[Chapter 3]{diggelen2009a-gps}.

%Size of the frequency 
%bin is inversely proportional to the ratio between the amplitude of the detected
%peak and other non-peak values, 
%the smaller the bins are the higher the peak will be.

For the purpose of better understanding, a segment of the
frequency/code delay search space is shown in figure \ref{img:prnSearchSpace3d}.
The peak implies the correct frequency and code delay have been found. In figure
\ref{img:prnSearchSpace3d} smaller frequency bins have been used so that the concept
becomes understandable to the reader. 

The speed of searching the 2D search space (finding the peak)
depends on the complexity and strategy of the 
implemented algorithm \citep[Chapter 6]{9780817643904}. In the worst case,
there are in total 102300 conbinations in the search space,
this can be derived from equation \eqref{eq:totalSearch}, visually shown 
in figure \ref{img:SearchSpace2d}.
\begin{equation}
\label{eq:totalSearch}
\mathrm{Search \, Space} = 50 \,\mathrm{(bins)} \cdot 1023\, \mathrm{(C/A \,codes)} \cdot 2\, \mathrm{(Phases\, per\, C/A\, chip)}
\end{equation}

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/2DSearchSpace.pdf}
  \caption{The total search space}
\label{img:SearchSpace2d}
\end{figure}

The common strategy is to start searching from the middle frequency bins and to jump
up and down until the entire search space has been exhausted (first 500 Hz,
second -500 Hz, then in the 1000 Hz bin and then in the -1000 Hz bin),
as shown in figure \ref{img:freqSearch}
\citep[Chapter 3]{diggelen2009a-gps}.
This procedure is performed when no extra information are known by the receiver (almanac data
are missing), i.e. 
first time the GPS receiver is turned on. It is known under the name of cold start.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/frequencySearch.pdf}
  \caption{Idea of the frequency searching algorithm}
\label{img:freqSearch}
\end{figure}

There are three different working modes when it comes to searching
for the GPS satellites. If no information are known,
when some information are known and when almost all information are
known. These three modes are known as \textit{cold} (as mentioned earlier),
\textit{warm} and \textit{hot} start. They differ from each other by the amount of known
information by the GPS receiver. Cold start indicates the GPS receiver
has no almanac, ephemeris, 
oscillator offset and time data. In order to track the satellites faster next time
the GPS receiver is started, it stores the previously mentioned data (last known almanac, 
ephemeris, oscillator offset, time and position data) in its electrically erasable
programmable read only memory (EEPROM). This new type of start,
is known as a warm start,
provided that the data in the receivers' EEPROM are not older than 180 days and
its real time clock counter was constantly updated.
In this case, the receiver uses the previously saved information
to estimate the position of the satellites, therefore the Doppler effects can be roughly estimated. 
As a consequence of the known Doppler effect, the frequency bin where to start
the search first is known this time \citep[Chapter 3]{diggelen2009a-gps}.
Hot start works in the same manner, only the ephemeris data and time data are precisely
known (time ought to be known in accuracy of submilliseconds). 

\newpage
\section{Distance and position estimation}
\label{sec:distanceAndPosition}
In this section the focus is set on distance and position estimation inside of the GPS receiver.
GPS system, as mentioned earlier, takes advantage of the TOA ranging concept
to determine user position. Time is measured how long it takes for a signal to arrive from a
known location.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/Localization.pdf}
  \caption{Basic distance estimation principle for one satellite}
\label{img:SatLocalization}
\end{figure}
In figure \ref{img:SatLocalization}, an example concept can be seen, where $\vec{u}=(x_u,y_u,z_u)$ represents the unknown 
GPS user position vector with respect to Earth-Centered, Earth-Fixed\footnote{ECEF is a Cartesian coordinate system
where the point $(0,0,0)$ is defined as the center of mass of the Earth \citep{earthCoordinates}.} 
(ECEF) coordinate system,  $\vec{r}$ is the distance vector from the satellite to the user and  $\vec{s}=(x_s,y_s,z_s)$
represents the GPS satellite position with respect to ECEF at a timepoint. Vector $\vec{s}$ is computed from ephemeris data broadcasted
by the satellite. The distance vector $\vec{r}$, distance between the satellite and user, can be computed using equation \eqref{eq:r} and its magnitude is
given in equation \eqref{eq:rMag}.
\begin{equation}
\label{eq:r}
\vec{r}=\vec{s}-\vec{u}
\end{equation}
\begin{equation}
\label{eq:rMag}
r=\Vert s-u\Vert
\end{equation}
The geometric distance of $r$ is computed by measuring the signal propagation time, this is illustrated in figure \ref{img:TimingLoc}
and it was mentioned in section \ref{sec:CAdemod}. The PRN code generated on the GPS satellite 
at time $t_1$ arrives at the time $t_2$, the difference between these two time stamps, $\Delta t$, represents the 
propagation time. By multiplying the propagation time, $\Delta t$, with the speed of light, $c$, the 
geometric distance $r$ is computed, as given in equation \eqref{eq:rDist}. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/TimingLoc.pdf}
  \caption{Estimating the distance by phase shift $\Delta t =t_2 - t_1 =\tau$}
\label{img:TimingLoc}
\end{figure}
\begin{equation}
\label{eq:rDist}
r=c\Delta t
\end{equation}
Since the clocks are not synchronized, 
as described in sections \ref{sec:SigDemod} and \ref{sec:2dSearch},
clock error offsets have to be added to 
the geometric distance $r$. This new distance is called \textit{pseudorange}, $\rho$, because the range is 
determined using the difference of two nonsynchronized clocks (one on the GPS satellite and
the other one on the receiver) that generate PRN codes\footnote{pseudo - Not genuine; sham; not perfect.}. Pseudorange is calculated as given in equation \eqref{eq:rho}, where 
$t_{u}$ is the advance of the receiver clock with respect to the system time\footnote{System
time is the exact time on Earth and it is the most precise time known!} and $\delta t$ is the offset of the
satellite clock from the system time \citep{understandGPS}.
\begin{equation}
\label{eq:rho}
\rho=r + c(t_{u}-\delta t)
\end{equation}
Equation \eqref{eq:rMag} can be rewritten as \eqref{eq:rhoR} with respect to equation \eqref{eq:rho}.
\begin{equation}
\label{eq:rhoR}
\rho - c(t_{u}-\delta t) = \Vert s-u\Vert
\end{equation}
Offset of the satellite clock from the system time, $\delta t$, is updated from Earth, as mentioned in \ref{sec:SigDemod}
and for that reason it can be removed for sake of simplicity, i.e. it is not an unknown term anymore,
then the eqaution \eqref{eq:rhoR} can be rewritten as \eqref{eq:rhoNew}.
\begin{equation}
\label{eq:rhoNew}
\rho - ct_{u} =  \Vert s-u\Vert
\end{equation}
In order to estimate the user (GPS receiver) position,
advance of the receiver clock with respect to the system time, $t_u$, has to be found, in other words equation \eqref{eq:rhoSats}
has to be solved, where $i$ is the index of visible satellites at the moment of signal reception \citep{understandGPS}.
\begin{equation}
\label{eq:rhoSats}
\rho_i= \Vert s_i-u\Vert + ct_u
\end{equation}
The estimated position of the user, $\vec{u}=(x_u,y_u,z_u)$, is a three dimensional vector and as mentioned
above the clock offset, $t_u$, is unknown as well. This four dimensional space requires to have at least four pseudorange
equations \eqref{eq:rhoSats} to find all the four unknown terms. 
As a result of this fact, at least four satellites have to be visible at 
the same time to estimate the position of the target user. Equation given in \eqref{eq:rhoSats} takes the form in
\eqref{eq:rhoSatsNew} because the coordinate system is Cartesian and  $\rho_i$ is nothing else but Euclidean distance
where $i=1,2,...,n$ such that $n\geq4$ and $\vec{s_i}=(x_i,y_i,z_i)$ is the satellite position estimated from the ephemeris data.
\begin{equation}
\label{eq:rhoSatsNew}
\rho_i= \sqrt{(x_i-x_u)^2+(y_i-y_u)^2+(z_i-z_u)^2} + ct_u
\end{equation}
Undoubtedly, the given equation in \eqref{eq:rhoSatsNew} is a nonlinear 
equation\footnote{Nonlinear
equations, also known as polynomial equations, are equations that can not satisfy both
of the linearity properties:
additivity $f(x+y)=f(x)+f(y)$ and homogeneity $f(\alpha x) = \alpha f(x)$, $\alpha \in \mathbb{R}$ \citep{nonlinear}.}.
It is not straightforward to find explicit solutions of nonlinear equations, it is more difficult than
compared to linear equations.
There are different techniques to solve sets of nonlinear equations \citep[Chapter 7]{understandGPS}
but in this work the linearization method\footnote{Linear approximation is a technique where a function
is approximated using a linear function.}
shall be presented to find the unknown terms $(x_u,y_u,z_u,t_u)$, i.e. out of an approximate position and clock
offset the true user position and the true clock offset shall be calculated.
\begin{equation}
\label{eq:rhoSatsNewFun}
\rho_i= \sqrt{(x_i-x_u)^2+(y_i-y_u)^2+(z_i-z_u)^2} + ct_u = f(x_u,y_u,z_u,t_u)
\end{equation}
Let the equation \eqref{eq:rhoSatsNew} for pseudoranges, be rewritten as a function $f$ of four
unknown terms $x_u$, $y_u$, $z_u$ and $t_u$, as
given in \eqref{eq:rhoSatsNewFun} \citep[Chapter 2]{understandGPS}. Suppose that the approximation of the
position and the clock offset are known,
denoted as $\hat{x_u}$, $\hat{y_u}$, $\hat{z_u}$ and $\hat{t_u}$, then equation \eqref{eq:rhoSatsNewFun}
can be rewritten as an approximate pseudorange \eqref{eq:rhoSatsNewFunApprox}.
\begin{equation}
\label{eq:rhoSatsNewFunApprox}
\hat{\rho_i}= \sqrt{(x_i-\hat{x_u})^2+(y_i-\hat{y_u})^2+(z_i-\hat{z_u})^2} + c\hat{t_u} = f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})
\end{equation}
In other words, the unknown true position terms $x_u$, $y_u$, $z_u$ and the clock offset term $t_u$, of the GPS receiver,
shall be expressed by the approximate values and an incremental component as shown in equation \eqref{eq:userCoordinates} \citep{understandGPS}.
\begin{equation}
\label{eq:userCoordinates}
\begin{array}{l}
x_u = \hat{x_u}+\Delta x_u \\
y_u = \hat{y_u}+\Delta y_u \\
z_u = \hat{z_u}+\Delta z_u \\
t_u = \hat{t_u}+\Delta t_u
\end{array} 
\end{equation}
By inserting the terms from \eqref{eq:userCoordinates} into equation \eqref{eq:rhoSatsNewFun}, a new equation is derived
as in \eqref{eq:rhoSatsNewFunwithApprox}.
\begin{equation}
\label{eq:rhoSatsNewFunwithApprox}
f(x_u,y_u,z_u,t_u) = f(\hat{x_u}+\Delta x_u, \hat{y_u}+\Delta y_u, \hat{z_u}+\Delta z_,\hat{t_u}+\Delta t_u)
\end{equation}
In the next step the pseudorange function shall be approximated using Taylor series\footnote{Taylor
series ``is a representation of a
function as an infinite sum of terms that are calculated from the values of the function's
derivatives at a single point'' \citep[Chapter 11]{taylor}.} (linearization of the nonlinear equation). Taylor
series for a function $f(x)$ is given in equation \eqref{eq:taylor}, where as $a$ approches $x$ the estimation
error shall be smaller and smaller, i.e. $f(x) = f(a)$ when $x=a$. The approximation error
depends on Taylor polynomial degree (the amount of terms or taken derivatives of the function)
and how far away the point $a$ is from $x$ \citep[Chapter 11.9]{taylor}.
The basic idea of the principle can be seen in figure \ref{img:taylorSeries}.
\begin{equation}
\label{eq:taylor}
f(x) = \sum_{n=0}^{\infty}\frac{f^{(n)}(a)}{n!}(x-a)^n = f(a) + \frac{f'(a)}{1!}(x-a)+\frac{f''(a)}{2!}(x-a)^2+...
\end{equation}

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/TaylorSeries.pdf}
  \caption{Taylor series approximation for a point $a=0.5$ where $n$ is the Taylor polynomial degree.}
\label{img:taylorSeries}
\end{figure}
Due to the four unknown terms, Taylor series for multivariables
have to be used. The general formula is given in
equation \eqref{eq:Multitaylor}, where vector $\mathbf{x}\in\mathbb{R}^n$ denotes
$n$ variables, $\nabla$ (nabla) is the Del\footnote{Del, $\nabla$,
is the vector differential operator.} operator given in \eqref{eq:Del} and $\mathbf{a}$ is the 
linearization point of interest
\citep{multiTaylor}.
\begin{equation}
\label{eq:Multitaylor}
f(\mathbf{x}) \approx f(\mathbf{a}) + \nabla f |_{\mathbf{x=a}} \cdot (x-a)
\end{equation}
\begin{equation}
\label{eq:Del}
\nabla^{T} = \left[\frac{\partial}{\partial x_{1}}...\frac{\partial}{\partial x_{n}}\right]
\end{equation}
One can note that in equation \eqref{eq:Multitaylor} the Taylor series polynomial is of the first degree.
This is because of one reason, it linearizes the approximation of the function $f(\mathbf{x})$ at point $\mathbf{a}$
and as a consequence it removes the nonlinearities \citep{understandGPS} \citep[Chapter 11.10]{taylor}, as seen
in figure \ref{img:taylorSeries}, for $n=1$ the resulting function is linear.
In the previously described step, one would calculate a hyperplane tangent to a
point $a$ in a $n$-Dimensional space. By inserting equation \eqref{eq:rhoSatsNewFunwithApprox} in 
equation \eqref{eq:Multitaylor}, it yields equation \eqref{eq:MultitaylorFour} where $\mathbf{x}=(x_u,y_u,z_u,t_u)$
and $\mathbf{a}=(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})$.
\begin{equation}
\label{eq:MultitaylorFour}
\begin{array}{l}
f(\hat{x_u}+\Delta x_u, \hat{y_u}+\Delta y_u, \hat{z_u}+\Delta z_,\hat{t_u}+\Delta t_u) \approx
		     f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u}) \\[0.5em]
		    + \dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{x_u}}\Delta x_u 
+\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{y_u}}\Delta y_u \\
+\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{z_u}}\Delta z_u 
+\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{t_u}}\Delta t_u 
\end{array}
\end{equation}
The terms from equation \eqref{eq:MultitaylorFour} are solved individually in
equations \eqref{eq:MultitaylorDeriv} where $\sqrt{(x_i-\hat{x_u})^2+(y_i-\hat{y_u})^2+(z_i-\hat{z_u})^2}$
has been subsituted with $\hat{r_i}$.
\begin{equation}
\label{eq:MultitaylorDeriv}
\begin{array}{l}
\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{x_u}} = \dfrac{1}{2}\dfrac{-2(x_{i}-\hat{x_{u}})}{\sqrt{(x_i-\hat{x_u})^2+(y_i-\hat{y_u})^2+(z_i-\hat{z_u})^2}}
=-\dfrac{x_i-\hat{x_u}}{\hat{r_i}}\\[0.9em]
\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{y_u}} = \dfrac{1}{2}\dfrac{-2(y_{i}-\hat{y_{u}})}{\sqrt{(x_i-\hat{x_u})^2+(y_i-\hat{y_u})^2+(z_i-\hat{z_u})^2}}
=-\dfrac{y_i-\hat{y_u}}{\hat{r_i}}\\[0.9em]
\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{z_u}} = \dfrac{1}{2}\dfrac{-2(z_{i}-\hat{z_{u}})}{\sqrt{(x_i-\hat{x_u})^2+(y_i-\hat{y_u})^2+(z_i-\hat{z_u})^2}}
=-\dfrac{z_i-\hat{z_u}}{\hat{r_i}}\\[0.9em]
\dfrac{\partial f(\hat{x_u},\hat{y_u},\hat{z_u},\hat{t_u})}{\partial \hat{t_u}} = c
\end{array}
\end{equation}
Then by substituting the equation terms from \eqref{eq:MultitaylorDeriv}, \eqref{eq:rhoSatsNewFun} and \eqref{eq:rhoSatsNewFunApprox}
into \eqref{eq:MultitaylorFour}, the resulting equation is given in \eqref{eq:MultitaylorDerivAfter}.
\begin{equation}
\label{eq:MultitaylorDerivAfter}
\begin{array}{l}
\rho_i = \hat{\rho_i} -\dfrac{x_i-\hat{x_u}}{\hat{r_i}}\Delta x_u -\dfrac{y_i-\hat{y_u}}{\hat{r_i}}\Delta y_u -\dfrac{z_i-\hat{z_u}}{\hat{r_i}}\Delta z_u + c\Delta t_u
\end{array}
\end{equation}
At this step, by solving equation \eqref{eq:MultitaylorFour}, the linearization of the nonlinear equations is completed. 
\begin{equation}
\label{eq:MultitaylorDerivAfterRearange}
\begin{array}{l}
\hat{\rho_i} - \rho_i = \dfrac{x_i-\hat{x_u}}{\hat{r_i}}\Delta x_u +\dfrac{y_i-\hat{y_u}}{\hat{r_i}}\Delta y_u +\dfrac{z_i-\hat{z_u}}{\hat{r_i}}\Delta z_u - c\Delta t_u
\end{array}
\end{equation}
\begin{equation}
\label{eq:SubsTerms1}
\Delta\rho = \hat{\rho_i} - \rho_i \\[0.7em]
\end{equation}
\begin{equation}
\label{eq:SubsTerms2}
\alpha_{xi} = \dfrac{x_i - \hat{x_u}}{\hat{r_i}} \hspace{1.5em} \alpha_{yi} = \dfrac{y_i - \hat{y_u}}{\hat{r_i}} \hspace{1.5em} \alpha_{zi} = \dfrac{z_i - \hat{z_u}}{\hat{r_i}}
\end{equation}
By rearanging the equation \eqref{eq:MultitaylorDerivAfter} one derives equation \eqref{eq:MultitaylorDerivAfterRearange}.
And then by substituting the terms in \eqref{eq:SubsTerms1} and \eqref{eq:SubsTerms2} into \eqref{eq:MultitaylorDerivAfterRearange}, 
the equation resembles the one given in \eqref{eq:userPosition}.
\begin{equation}
\label{eq:userPosition}
\Delta\rho_i = \alpha_{xi}\Delta x_u + \alpha_{yi}\Delta y_u + \alpha_{zi}\Delta z_u - c\Delta t_u
\end{equation}
There are four unknowns, $\Delta x_u$, $\Delta y_u$, $\Delta z_u$ and $\Delta t_u$, in equation \eqref{eq:userPosition}.
By solving this set of linear equations, which shall result in finding $\Delta x_u$, $\Delta y_u$, $\Delta z_u$ and $\Delta t_u$,
the GPS receiver position $(x_u, y_u, z_u)$ and clock offset $t_u$ is computed by replacing the
same into equations in \eqref{eq:userCoordinates}. Equation \eqref{eq:userPosition} can be rewritten for four satellites 
in the matrix form as in \eqref{eq:userPositionMatrix}.
\begin{equation}
\label{eq:userPositionMatrix}
\Delta\boldsymbol{\rho} = \boldsymbol{\alpha} \Delta \boldsymbol{x}
\end{equation}

\begin{equation}
\Delta\boldsymbol{\rho}=
\begin{bmatrix}
\Delta \rho_1 \\
\Delta \rho_2 \\
\Delta \rho_3 \\
\Delta \rho_4 
\end{bmatrix}
\hspace{1.5em}
\boldsymbol{\alpha}=
\begin{bmatrix}
\alpha_{x1} & \alpha_{y1} & \alpha_{z1} & 1 \\
\alpha_{x2} & \alpha_{y2} & \alpha_{z2} & 1 \\
\alpha_{x3} & \alpha_{y3} & \alpha_{z3} & 1 \\
\alpha_{x4} & \alpha_{y4} & \alpha_{z4} & 1 
\end{bmatrix}
\hspace{1.5em}
\Delta \boldsymbol{x}=
\begin{bmatrix} 
\Delta x_u \\
\Delta y_u \\
\Delta z_u \\
-\Delta ct_u 
\end{bmatrix}
\end{equation}
Finally, by multiplying both left sides\footnote{Matrix multiplication is not communitative, $\mathbf{AB\neq BA}$.} of the equation \eqref{eq:userPositionMatrix}
with the inverse term of $\boldsymbol{\alpha}$, it yields the result of the unknown terms, as given in equation \eqref{eq:userPositionMatrixFinal}.
\begin{equation}
\label{eq:userPositionMatrixInverseMult}
\boldsymbol{\alpha}^{-1}\Delta\boldsymbol{\rho} = \boldsymbol{\alpha}^{-1}\boldsymbol{\alpha} \Delta \boldsymbol{x}
\end{equation}
\begin{equation}
\label{eq:userPositionMatrixFinal}
\Delta \boldsymbol{x} = \boldsymbol{\alpha}^{-1} \Delta\boldsymbol{\rho}
\end{equation}
Linearization is repeated in a loop, where in the next round the approximate positions are set
to the just derived position values, that is, $\hat{x_u}=x_u$, $\hat{y_u}=y_u$, $\hat{z_u}=z_u$ and
$\hat{t_u}=t_u$. This process is repeated until the approximated positions converge to their final
values. It is not necessarily required that the initial positions are very accurate
and the results are usually obtained by 4-5 itterations \citep{pseudorangeError}. 
Risks exist that the solutions shall still be corrupted but there are different error avoiding 
mechanisms to solve these problems, like minimizing the error contribution using more than four satellite
measurements \citep{pseudorangeError} \citep[Chapter 7]{understandGPS}. 



\newpage
\section{Assisted GPS in Wireless networks}
\label{sec:agps}
In the following paragraphs Assisted GPS (AGPS) shall be presented and how it works. 
AGPS receivers work on the equivalent idea as warm/hot start on GPS receivers.
Instead of loading the recently saved data from the EEPROM, an external
information transfer medium is used to deliver the equivalent type of information that are known 
at a warm/hot start \citep{755159}, \citep{901174}, \citep{springerlink:10.1007/s10291-002-0028-0}.
In this work, the external transfer medium is air and the information are transfered using electromagnetic
waves. The existing GSM interface was utilised for the purpose of delivering the data to the smart phone
with an AGPS receiver. The basic scenario can be seen in figure \ref{img:agpsPrinciple}.

The BTS station is connected to the global navigation satellite system (GNSS) server, which is directly
connected to the GPS reference station. The GPS reference station delivers the GNSS server exact time stamps,
approximate location, satellite health as well as clock corrections, ionospheric and UTC model, almanac and ephemeris data 
\citep{springerlink:10.1007/s10291-002-0028-0}. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/A-GPS.pdf}
  \caption{Basic AGPS principle}
\label{img:agpsPrinciple}
\end{figure}

Time stamp is not used in GSM networks since it can be
off by several seconds and would require additional equipment for synchronizing the network
\citep{springerlink:10.1007/s10291-002-0028-0}, \citep{901174}. However in CDMA networks the time stamp is 
accurate to within $100 \, \mu s$ \citep{springerlink:10.1007/s10291-002-0028-0}. Approximate
location is typically taken to be the location of the BTS from which the target AGPS receiver
acquires the assistance data. Ephemeris and navigation data obtained by the AGPS receiver in the smart phone
help it to estimate the positions of the GPS satellites. This method can greatly
enhance the sensitivity of the receiver especially in urban environments \citep{springerlink:10.1007/s10291-002-0028-0}.

Conventional GPS receivers require at least up to extra $18$ to $30\,s$ to receive and decode the navigation data
and to generate a location fix \citep{springerlink:10.1007/s10291-002-0028-0}. 
The bit error rate associated with gathering and decoding data dramatically decreases since the acquired signals 
can be attenuated by $10$ to $20\, \mathrm{dB}$ indoors \citep{springerlink:10.1007/s10291-002-0028-0} of the nominal
$-130 \,\mathrm{dB}$ on a $3\, dBi$ ``linearly polarized user receiving antenna\footnote{3 dBi antenna indicates
an antenna with a gain of $3\, \mathrm{dB}$ with respect to an isotropic (omnidirectional) antenna
\citep[Chapter 2]{diggelen2009a-gps}.} (located near ground) at worst normal orientation''
\citep{GPS-Interface-Specification}.

A simplified AGPS algorithm given in \citep{springerlink:10.1007/s10291-002-0028-0} shall be presented here. This
algorithm benefits in speed the more assistance data is present. As the first satellites are tracked,
the AGPS algorithm has an estimation of the feasible region where the target AGPS user might be located.
Consequently, this feasible region shall shrink until the location has been fully estimated
\citep{springerlink:10.1007/s10291-002-0028-0}.
  \begin{enumerate}[(i)]
    \item Visible satellites and their positions are identified and computed out of the delivered ephemeris
    and time data. 
    \item For each visible satellite $SV_i$, the code phase, $\tau_i$, is estimated.
    \item Pseudoranges are calculated for each visible satellite $SV_i$.
    \item Trilaterate the position out of the pseudoranges $\rho_i$.
  \end{enumerate}
Although the AGPS algorithms can be seen as a set of equations with more unknown terms being known. It is 
straightforward to solve a set of equations when all the terms are known. However, without assistance information
which provide additional information to the GPS receiver,
it takes more time to obtain (decode) assistance data from the satellite message. 
Numerous AGPS algorithms exist, some do not require the exact time component and navigation data to
be present in the assistance data \citep{998892}.

\section{Error estimation}











\chapter{GSM}
In the past two decades we have been witness to an increasing development of wireless communication technologies,
one of the most rapidly developing fields of engineering. Global System for Mobile Communications\footnote{First
time when the standard was developed, GSM meant \textit{Groupe Spéciale Mobile} \citep{0890064717}} (GSM) networks 
played a major role in wide-spreading wireless voice services in every corner of the planet \citep{gsmConnection}. According
to the GSM Association (GSMA) in 2011 there have been 6 billion registered wireless connections world wide \citep{gsmConnection}. In
this chapter more details shall be given on the second generation GSM network which was employed in this work for
delivering GPS assistance data to cell phones. More information shall be provided on the general working principles of GSM
and how a Standalone Dedicated Control Channel (SDCCH) is initialized to deliver data to cell phones. 
\newpage
\section{Overview}
In this section the reader shall be provided with principles how the GSM network operates. 
The main task of GSM networks was to enable wireless voice transmission between GSM and other GSM/telephone users
inside of switched networks. It was not designed to be used with data services which are a necessity in today's standards.
GSM networks are worldwide spread and work on different frequency spectrums depending on the country where
the networks are employed. The reason why different frequencies are used is because of intereference with different
wireless systems and used telecommunication standards. Particularly in Germany, the Federal Network Agency (German: $Bundesnetzagentur$) is the
responsible organisation for assigning different frequencies to GSM operators since these frequencies belong
to the group of licensed frequencies and are not allowed to be used by everyone. In Germany the used frequency bands
are GSM900, EGSM900 and GSM1800, their frequency ranges can be seen in table \ref{tbl:GSMfreqs} \citep{konrad}.
These frequency bands are divided into 200 KHz channels, 
for a frequency band range of 25/35 MHz there are 124/175 operating
channels. This technique is called Frequency Division Multiple Access (FDMA) and
supports using parallely more frequency channels inside of the same covered area with GSM RF signal. 
FDMA is employed when the frequency bandwidth is limited like in the GSM networks. By utilizing FDMA the network throughput
is used more efficiently since different users can send or receive information at different 
frequency slots instead of waiting for their turn.
These frequency channels have a unique identifier number. They are named as Absolute Radio Frequency 
Channel Numbers (ARFCN). The basic idea of FDMA inside of the frequency spectrum GSM900 for GSM can be 
seen in figure \ref{img:GSMFreqRangChannel}, ARFCN numbers are assigned according to the 
frequencies which are employed. 
It is important to distinguish uplink and downlink frequencies. 
Uplink frequency is used when the cell phone transmits data 
to the network operator, whereas downlink from the network operator to the cell phone. GSM is a full duplex communication 
system, at the same time the cell phone or the network operator can send and receive data.
Although the equivalent ARFCN number is used for uplink and downlink, the frequencies are shifted 45 MHz in EGSM900/GSM900 and
95 MHz in GSM1800 as it can be seen in figure \ref{img:GSMFreqRangChannel} for GSM900.
\begin {table}[hb]
\caption{GSM operating frequencies in Germany}
\label{tbl:GSMfreqs}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{ccccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Frequency band&Uplink frequency (MHz)&Downlink frequency (MHz)& Channel number\\\toprule
GSM900&890 - 915&935 - 960& 1 - 124\\\midrule
EGSM900&880 - 915&925 - 960&0, 1 - 124, 975 - 1023\\\midrule
GSM1800&1710 - 1785&1805 - 1880& 512 - 885\\\bottomrule
\end {tabular}
\end {table}
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/GSMUpDownFreq.pdf}
  \caption{Frequency ranges of uplink and downlink channels in the GSM900 band. Each box represents a frequency band (channel).}
\label{img:GSMFreqRangChannel}
\end{figure}
\par Aside from using different frequency channels, each frequency channel is split up into eight time slots.
This technique of dividing a frequency into time slots is named Time Division Multiple Access (TDMA). 
TDMA allows several users to share the same frequency
channel but in different time slots. Using this technique the voice throughput is better utilised and a broader amount
of users can be served at the ``same'' time, i.e. the capacity of parallely speaking GSM users is increased.
TDMA was employed because the voice could be compressed with Linear Predictive Coding (LPC) without the human 
noting a difference in the call quality \citep{0824740408}. By taking advantage of LPC, instead of the 64 kbps required for transmission of voice 
it was possible to compress the voice without losing much of the call quality into 8 kbps for half rate and 16 kbps for
full rate\footnote{Human speech has a frequency bandwidth between 0 and 4000 Hz \citep{humanFreq}.
Human voice is by its nature analog and requires to be converted into a digital stream of ones and zeros.
By Nyquist-Shannon sampling theorem the sampling frequency must be at least two times greater 
than the sampled frequency and with an 8 bit Analog to Digital Converter (ADC) this defines the 
64 kbps required to transfer voice ($2\cdot4000 Hz\cdot8 = 64000$).}. Since new wireless services are
data oriented and the networks become packet networks this type of modulating data had to be changed, 
3G and 4G networks use different frequency ranges and technique to modulate and demodulate data.

TDMA applied on the FDMA technique constrains the GSM air interface to be of 
2D structure. The idea of employing TDMA on FDMA in the GSM900 band can be seen in figure \ref{img:GSMFreqTime}. 
Each time slot duration is $\approx$577 $\mu s$, all 8 time slots have a period of $\approx$ 4.615 $ms$ 
\citep{dennis} \citep{0890064717}. By applying this technique each GSM user can send data inside of the assigned time slot
without disturbing users on different time slots. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/GSMFreqTime.pdf}
  \caption{Each frequency channel is split into 8 time slots. More GSM users can be served at the ``same'' time.}
\label{img:GSMFreqTime}
\end{figure}

Eight time slots in GSM are called a TDMA frame. Each time slot
in GSM is known as a burst. Every TDMA frame is assigned a unique integer number which is then repeated and reassigned
every 3h:28m:53s:760ms, also known as \textit{hyperframe} \citep[Chapter 7]{0890064717}. In the hierarchy pyramid,
a layer lower of the hyperframe is the \textit{superframe}. There are two types of superframes, consisting of two types
of \textit{multiframes}, differing in their length \citep[Chapter 7]{0890064717}. The relations can be seen in figure
\ref{img:GSMHierarchy} with their duration periods. The multiframe with 26 TDMA frames carries only traffic channels (TCH) and associated
control channels (CCH). The other multiframe type, with 51 TDMA frames carries solely signaling data. This hierarchy constrain
was defined due to internal synchronization and cyphering between the MS and the Base Transceiver Station (BTS)
\citep[Chapter 7]{0890064717}.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.70]{img/GSMHierarchy.pdf}
  \caption{Hierarchy of the GSM frames.}
\label{img:GSMHierarchy}
\end{figure}

BTS is the first hardware unit the cell phone is communicating with over the air interface
and provides a ``physical'' connection with the cell phone \citep[Chapter 3]{0890064717}. This physical connection between the
BTS and the cell phone is the \textit{$U_m$ interface}, as shown in figure \ref{img:GSMBig}. A BTS can serve up 
to seven users on one frequency since one out of eight time slot is used for broadcasting of signaling and system information, 
known as the broadcast control channel (BCCH). By sectorizing BTSs with different frequencies the number of seven mobile users
can be increas. BTS consists of a RF tranceiver, internal clock and modulator/demodulator. The function of the RF transceiver is 
to enable the reception and transmission on the uplink and downlink channel for the cell frequency where the 
BTS is located\footnote{Cell is the area covered with GSM signal and from which a cell phone can communicate with a BTS.}. 
The main function of the internal clock is to supply the BTS with a frequency such that the internal 
circuits can produce the TDMA frames, with an accuracy of at least $\pm$5 ppm \citep{dennis}. 
Modulator/demodulator main function is the modulation and demodulation of the received and transmitted signals.
The transmission from the cell phone to the BTS is shifted for 3 time slots compared to the reception 
of the signal from the BTS\footnote{Timing advance factor is added to the three time slots.}
\citep[Chapter 7]{0890064717} \citep{konrad} \citep{}. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/GSMBig.pdf}
  \caption{Basic GSM network block diagram.}
\label{img:GSMBig}
\end{figure}

One or more BTSs are connected to the Base Station Controller (BSC). The main task of the BSC is to control the radio 
resources of the connected BTSs such as assigning radio channels to different BTS, frequency hopping in case of an handover 
and controlling the power levels within channel \citep[Chapter 4]{0470742984} \citep{konrad} \citep[Chapter 3]{0890064717}.
BSC is connected to the Transcoding Rate and Adaptation Unit (TRAU). This builds the Base Station Subsystem (BSS), as it can
be seen in figure \ref{img:GSMBig}, on left side inside of the gray dashed line rectangle. Inside of the BSS, TRAU 
is responsibe for compressing and decompressing speech between the cell phone and a speech signal from the other side, 
from 64 kbps to 16 or 8 kbps depending if it is a full or half rate channel.

The next subsystem block is the Network Switching Subsystem (NSS), as it can be seen on figure \ref{img:GSMBig}, on right
side inside of the gray dashed line rectangle. 

\section{SDCCH Channel}














\chapter{Radio Resource Location Protocol}
This chapter shall focus on the Radio Resource Location Protocol (RRLP) and a description 
how it works inside of the GSM network shall be given. RRLP is a protocol from the family of Location Services (LCS)
which were not part of the initial GSM standard. It is a widely used protocol in other cellular 
networks like UMTS, it was later introduced to the GSM system as well \citep{3GPPTS03.71}. It was
developed by the request of government and rescue organizations to fulfill the wireless enhanced 911
standard in the US, each mobile user had to be located within a range of 300 m in 95\% of cases and
within 100 m in 67\% of cases \citep{E911Accuracy}. 

The standard supports three positioning mechanisms: E-OTD, UL-TDOA and AGPS \citep{3GPPTS03.71}. 
The LCS process can be divided into two seperate stages, signal measurements and
position estimation from the derived data in the previous stage. In this chapter
the description shall be given on how to make an RRLP request, how to send assistance
data and then more information shall be given on its response. 

\newpage
\section{RRLP Request}
In this section the RRLP protocol and its request shall be reviewed in more detail.
RRLP represents the connection/protocol between the Serving Mobile Location Center (SMLC) 
and the standalone handset, in this case the MS \citep[Chapter 5]{harper2010server-side}.
The SMLC node contains the functionaly to support 
location services for the GSM network \citep{3GPPTS03.71}. SMLCs primary function is to manage 
the overall coordination and scheduling of resources required to perform the localization of the MS
and it is located on the Base Station Controller (BSC) \citep{3GPPTS03.71}. 
SMLC controls the LMU's as well but since in this work no LMU were available this part
shall be skipped as well as the description of E-OTD and UL-TDOA localization. 

Before an attempt is made, of requesting the SMLC to initialize an RRLP request, an SDCCH connection 
channel has to be initialized to the MS, this connection can not be seen by the MS user\footnote{However,
it is possible to take into consideration that something is going on the cell phone if the MSs battery
is drained faster because an active RF connection drains the battery faster than a passive MS
connected to the GSM network.}.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/RRLPRequest.pdf}
  \caption{RRLP Request protocol. Assistance data can be sent before the request is made. If the assistance
  data are sent, their reception acknowledgement is sent as a response from the MS.}
\label{img:RRLPReqProt}
\end{figure}

Data sent inside of a protocol are called Protocol Data Unit (PDU). On different 
layer levels PDU's may take a different shape and size because of the encapsulation or splitting \citep{kozierok2005the} \citep{stevens1994tcp/ip}. 
In RRLP, the PDU's sent from the SMLC ought to be not greater than 244 bytes\footnote{Bytes of 8 bits!},
although the standard defines that larger packets shall be split in lower layers, in this work the 
rule of 244 bytes has been obeyed and each PDU packet is not greater 
than 211 bytes \citep{04.31V8.18.0}. In the RRLP standard terms, the messages are entitled
as \textit{components} and fields in the messages (components) are labelled as \textit{information elements} (IE) \citep{04.31V8.18.0}.
The SMLC may send only the request for the position of the MS or it may assist the MS with assistance data
required to estimate the position (in case of an AGPS request, these data may be ephemeris, almanac, 
accurate timing data and similar data that help to estimate the position in a shorter period of time). 
The RRLP protocol is shown in figure \ref{img:RRLPReqProt}. Dashed lines represent optionally transmitted data 
like assistance data according to which an acknowledgement or error shall be produced. Once the MS obtains the RRLP request, 
after a period of processing time it shall respond to the SMLC with the position of the MS or with an error IE indicating what 
assistance data are missing or why it can not return the position \citep{04.31V8.18.0} \citep{49.031V8.1.0}. In the response component IE it is exactly indicated
what type of data ought to be sent to the MS so it can complete the RRLP request and give back its 
position. To save bandwidth space in the communication between the SMLC and MS, it can be proceeded in such a manner that
first the RRLP request is sent out for the position estimation and then if the MS requires some of the assistance data,
it shall send a request for those data back to the SMLC and then the SMLC can send the required data and expect an 
successful response from the MS. However, in this work the author had a different approach in that sense, that first 
all the RRLP assistance data were sent and then the RRLP position request. This way, sending all assistance data,
was choosen over the other idea of waiting for the MS response because in OpenBSC it was not possible to access
directly the response data without querying the database directly. Since this system is a real time system, 
waiting for the database to respond may have corrupted the state machine of the GSM network and this would
led to the malfunction and eventually failure of the complete network!  

The structure of the RRLP messages (requests, assistance data and response) is well defined using
Abstract Syntax Notation One (ASN.1) in the technical specifications 3GPP 04.31
and ETSI TS 144 031 \citep{49.031V8.1.0} \citep{ETSITS144031}. ASN.1 is a conventional notation 
for denoting the abstract syntax of data used inside of protocols or data 
structures \citep[Chapter 8]{sharp2008principles} \citep{ITU-TX.680}. In other words, using ASN.1 it is possible 
to describe data in an indepedent representation of programming languages in which a protocol is implemented.
In this section, only some of the mostly important and used parts of the RRLP protocol 
inside of the thesis shall be presented, more details can be found in the
technical specifications \citep{49.031V8.1.0} \citep{ETSITS144031}. Structure 
of the RRLP message encoding for transmission can be seen in listing \ref{lst:RRLP}. 
Further details on some of the unknown terms are given in listings
\ref{lst:RRLPReq} and \ref{lst:RRLPReqData}. An example how to build an RRLP request packet shall be given,
then it shall be encoded using Packed Encoding Rules (PER). PER is one of the telecommunication
standards used for encoding and decoding messages inside of protocols specified in the ASN.1 
notation \citep{ITU-TX.691}.
\newpage
\begin{lstlisting}[label=lst:RRLP,
caption={\textbf{Structure of the RRLP message in ASN.1}},
backgroundcolor=\color{light-gray},
basicstyle={\scriptsize\ttfamily},
escapechar=@,
emph={},
emphstyle=\color{crvena},
emph={[2]},
emphstyle={[2]\color{plava}}]
RRLP-Messages
-- { RRLP-messages }

DEFINITIONS AUTOMATIC TAGS ::=

BEGIN
IMPORTS
  MsrPosition-Req, MsrPosition-Rsp, AssistanceData,
  ProtocolError
FROM
  RRLP-Components -- { RRLP-Components }
;

PDU ::= SEQUENCE {
  @\textcolor{red}{referenceNumber INTEGER (0..7),}@
  @\textcolor{blue}{component RRLP-Component}@
}

RRLP-Component ::= CHOICE {
  @\textcolor{narandzasta}{msrPositionReq MsrPosition-Req,}@
  msrPositionRsp MsrPosition-Rsp,
  assistanceData AssistanceData,
  assistanceDataAck NULL,
  protocolError ProtocolError,
  ...,
  posCapabilityReq PosCapability-Req,
  posCapabilityRsp PosCapability-Rsp
}
END
\end{lstlisting}
\begin{lstlisting}[label=lst:RRLPReq,
caption={\textbf{Structure of the RRLP request in ASN.1}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily]
-- Measurement Position request component

MsrPosition-Req ::= SEQUENCE {
  positionInstruct PositionInstruct,
  referenceAssistData ReferenceAssistData OPTIONAL,
  msrAssistData MsrAssistData OPTIONAL,
  systemInfoAssistData SystemInfoAssistData OPTIONAL,
  gps-AssistData GPS-AssistData OPTIONAL,
  extensionContainer ExtensionContainer OPTIONAL,
  ...,
  -- Release 98 extension element
  rel98-MsrPosition-Req-extension Rel98-MsrPosition-Req-Extension OPTIONAL
}
\end{lstlisting}
PER is intended for use in circumstances where
minimizing the size of the representation of values is the major concern
in the choice of encoding rules \citep{ITU-TX.691}. In other words, it compresses the data
in the PDU packets by limiting the bit field length to the minimal amount of 
bits required to define the minimal and maximal variable values defined in the standard. 
There are two variations of PER, 
aligned and nonaligned \citep{ITU-TX.691}. In the RRLP protocol the nonaligned type of PER
is used. The major difference between aligned and nonaligned PER lies in the fact that some
data structures are aligned on octet boundaries in aligned PER, i.e.
there are some wasted padding bits which are set to zero if not used according to the size of the 
packets. 

Before proceeding with an example, summary for the used ASN.1 type
elements shall be provided otherwise it is not possible to proceed with an example
RRLP request. A type of \textbf{SEQUENCE} is used to 
reference a ``fixed, ordered list of types (some of which may be declared to be
optional); each value of the sequence type is an ordered list of values,
one from each component type'' \citep{ITU-TX.691} where the 
IE (fields) of \textbf{OPTIONAL} type do not need to be included and are not mandatory.
Variables defined by \textbf{CHOICE} are used to reference ``a list of distinct types; 
each value of the choice type is derived from the value of one of the
component types'' \citep{ITU-TX.691}, i.e. only one element is selected from the 
list and the elements of the list are defined according to their variable type.
Variables of type \textbf{ENUMERATED} are ``simple types whose values are given
distinct identifiers as part of the type notation'' \citep{ITU-TX.691}, these types
are used to distinguish a choice by identifying it with an incremented number from the previous
element where the
first element is of value zero. Variables defined by \textbf{INTEGER} are of the ``simple 
type with distinguished values which are the positive and negative whole numbers,
including zero (as a single value)'' \citep{ITU-TX.691}. 

At this point the meaning of RRLP data elements marked in red, blue and orange from listing \ref{lst:RRLP} shall be given. 
To construct an RRLP PDU sequence (packet) these fields need to be known: \textit{referenceNumber}
and \textit{RRLP-Component}. \textbf{referenceNumber}
specifies the reference number of the request and is used for the purpose of identifying 
the response from the MS. It can take any value between 0 and 7, in 
PER enocoding this requires at least a three bit representation since with three bits, 
eight different values can be represented ($2^3=8$). \textbf{component} is of the type RRLP-Component, 
which is a CHOICE list. RRLP-Component is used for defining what type of information the 
packet shall include (assistance data, request, response, error, etc.). For this particular example 
one chooses \textbf{msrPositionReq} that is of type MsrPosition-Req (marked in orange in listing \ref{lst:RRLP}),
with this information the MS shall know that its position is requested. MsrPosition-Req is a SEQUENCE,
consisting out of one mandatory and few optional IE elements. One choice shall be only considered,
\textbf{PositionInstruct}, the rest is used later for the assistance data and what
type of information is included inside of the PDU message. \textbf{PositionInstruct} consists 
of five elements but four are mandatory: \textit{methodType}, \textit{positionMethod}, 
\textit{measureResponseTime} and \textit{useMultipleSets}. These four elements are the most
compact representation of an inquiry for the MS to differentiate between all the possible 
position measurements it could perform, how long (time duration) it is allowed to measure 
the position and how many positions it should perform and return in its response.
\newpage
\textbf{methodType} defines where the position estimation calculation ought to be executed, 
shall it take place solely on the MS (\textit{msBased}), solely on the server\footnote{With server 
the BTS location is ment!} (\textit{msAssisted}),
or one is prefered over the other depending if the MS can execute the prefered one
(\textit{msBasedPref} or \textit{msAssistedPref}). The uncertainty of the accuracy 
of the estimated position is only optional if the choosen method is \textit{msAssisted}, 
otherwise it must be included in the message.
\begin{lstlisting}[label=lst:RRLPReqData,
caption={\textbf{Structure of the data types from RRLP request in ASN.1}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily]
-- Position instructions
PositionInstruct ::= SEQUENCE {
  -- Method type
  methodType MethodType,
  positionMethod PositionMethod,
  measureResponseTime MeasureResponseTime,
  useMultipleSets UseMultipleSets,
  environmentCharacter EnvironmentCharacter OPTIONAL
}

--
MethodType ::= CHOICE {
  msAssisted AccuracyOpt, -- accuracy is optional
  msBased Accuracy, -- accuracy is mandatory
  msBasedPref Accuracy, -- accuracy is mandatory
  msAssistedPref Accuracy -- accuracy is mandatory
}

-- Accuracy of the location estimation
AccuracyOpt ::= SEQUENCE {
  accuracy Accuracy OPTIONAL
}

-- The values of this field are defined in 3GPP TS 03.32 (Uncertainty code)
Accuracy ::= INTEGER (0..127)

-- Position Method
PositionMethod ::= ENUMERATED {
  eotd (0),
  gps (1),
  gpsOrEOTD (2)
}

-- Measurement request response time
MeasureResponseTime ::= INTEGER (0..7)

-- useMultiple Sets, FFS!
UseMultipleSets ::= ENUMERATED {
  multipleSets (0), -- multiple sets are allowed
  oneSet (1) -- sending of multiple is not allowed
}
\end{lstlisting}
\begin{equation}
\label{eq:uncerAccuracy}
r=10((1.1)^{K}-1)
\end{equation}
\begin{equation}
\label{eq:responseTime}
MeasureResponseTimeBitValue=\frac{ln(N)}{ln(2)}
\end{equation}
\newpage
This uncertainty of the accuracy, is an integer
number, that defines how certain the accuracy of the returned position ought to be. It can be calculated 
using the equation \eqref{eq:uncerAccuracy}, where $K$ is the seven bit integer number
and $r$ is the accuracy uncertainty in meters \citep{3gppequations}. The next three parameters
to be defined are the position estimation technique (GPS, E-OTD or one of the two prefered by the MS),
the position measurement time and how many measurements the MS ought to report back to SMLC.
Since in this thesis the author exploits the AGPS method, GPS is choosen for \textbf{PositionMethod}.
\textbf{MeasureResponseTime} is a three bit integer value that corresponds to the time the MS is allowed
to perform the position estimation and to send a respose back to SMLC. Otherwise, if it takes longer the MS
than the specified time period, it shall disconnect the SDCCH channel without responding back. 
It can be calculated using the equation
given in \eqref{eq:responseTime}, where $N$ is the number of seconds the MS is allowed to perform the
position estimation.

After the ASN.1 parameters of an RRLP request have been understood, they can be 
choosen and set according to the position measurement request which the network operator wants to perform.
In the next step the RRLP request can be constructed and encoded using PER. To construct the RRLP request 
query from the above given ASN.1 specifications is straightforward. The choosen values are only concatenated
into a binary string. A simple
RRLP request in PER encoded form is shown in figure \ref{img:RRLPReqExplained} and the previous conversion 
process might become more clear, different variables have been colored with distinguishable colors to its neighbor
variables so that it is easy to recognize different variables. The five red zeros define what type of data
shall be included in the current RRLP packet. This becomes more understandable by looking at the listing \ref{lst:RRLPReqPER}.
After the concationation it can be converted to the 
desired notation system (binary, hexadecimal, etc.). In this particular example the RRLP request to be sent 
using the RRLP protocol in hexadecimal notation is: \textbf{400178F8}. This message is transmitted to the MS
via the opened SDCCH channel. However, before sending this request the assistance data can be sent. In the 
folowing section \ref{sec:rrlpassistance} more details of how assistance data are sent shall be presented. 
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.80]{img/RRLPReqExplained.pdf}
  \caption{An example RRLP request. Constructing a binary RRLP request in PER from ASN.1. Yellow zero bits 
  are extension markers or spare bits. }
\label{img:RRLPReqExplained}
\end{figure}

\newpage
\begin{lstlisting}[label=lst:RRLPReqPER,
caption={\textbf{Encoding an RRLP request from ASN.1 to PER}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily]
             RRLP Message:
40 010.....   referenceNumber = 2
              component:
   ...0....    Extension of RRLP-Component = 0 :Absent
   ....000.     RRLP-Component = 0 :msrPositionReq
                 MsrPosition-Req:
   .......0       Extension of MsrPosition-Req = 0 :Absent
01 0.......       referenceAssistData = 0 :Absent
   .0......       msrAssistData = 0 :Absent
   ..0.....       systemInfoAssistData = 0 :Absent
   ...0....       gps-AssistData = 0 :Absent
   ....0...       extensionContainer = 0 :Absent
                  PositionInstruct:
   .....0..        environmentCharacter = 0 :Absent
                   MethodType:
   ......01         MethodType = 1 :msBased
                     Accuracy:
78 0111100.           Accuracy = 60
                   PositionMethod:
   .......0         PositionMethod = 1 :gps
F8 1.......
                   MeasureResponseTime:
   .111....         MeasureResponseTime = 7
                   UseMultipleSets:
   ....1...         UseMultipleSets = 1 :oneSet
   .....000  Spare Bits = 000b
\end{lstlisting}

 
\newpage
\section{RRLP Assistance data}
\label{sec:rrlpassistance}
Assistance data are of the most important value when it comes to RRLP response time. 
If the assistance data are present, the response time ought to be shorter since 
the AGPS receiver knows the orbital information of the satellites and the exact time
which allows the AGPS to find immediatelly the Doppler frequency and phase shift of
the visible GPS satellite. In the assistance data packets, same as in the request
packet, one has to specify what type of assistance information are included in the RRLP assistance packets.
In this thesis, as assistance data only the almanac, ephemeris, UTC model, ionospheric
model and reference location are transmitted to the MS. There are also other assistance
data like differential GPS corrections (DGPS), real time integrity, acquisition assistance
and reference time but none of these were available to the author, so they were avoided. The reasons for
this decision were explained earlier as cost and complexity issues.

DGPS corrections give additional accuracy to the GPS measurement reports between $1-3$ m \citep{489522} and they 
are rarely used \citep[Chapter 4]{harper2010server-side}. Real 
time integrity is a list of satellites the AGPS receiver ought not use because these satellites
have an integrity problems \citep[Chapter 4]{harper2010server-side}. 
This helps the AGPS receiver to know why assistance data for satellites with errors
are not included in the ephemeris or almanac and to be aware not to use instead the old 
cached data \citep[Chapter 4]{harper2010server-side}. Reference time can be considered as 
the ``most valuable'' data for the MS because it provides ``exact time'' to the AGPS receiver. 
This helps the AGPS receiver to better estimate the phase shift required to detect GPS
signal which in return allows the AGPS receiver better integration period $\tau$ to detect
weaker signals in cities or buildings (see section \ref{sec:SigDemod}
and page \pageref{sec:CAdemod} for better understanding) \citep[Chapter 4]{harper2010server-side}.
By knowing the reference time, it is straightforward for the AGPS receiver to predict the TLM and
HOW starting words of the transmitted GPS packets from the satellites 
(refer to section \ref{sec:gpsDataAndSignal}). Reference time data can include the relationship
between the GSM network and GPS time, as well as the GSM frame number to help the MS to 
synchronize with the BTS (earlier this was described as time synchronized GSM networks which is
required for methods like E-OTD) \citep[Chapter 4]{harper2010server-side}. Acquisition assistance
data, as the name itself says provides the AGPS receiver directly with acquisition data. Acquisition data
are the Doppler frequencies and phase shift precalculated on the BTS for the MS. If this type of data is 
provided to the AGPS receiver, it does not require to compute and search for the given data from the provided time
on its on \citep[Chapter 4]{harper2010server-side}. This would speed up the process of getting a
position and would help weak signals to be detected which in return would minimize the reception errors. 

More information on the assistance data transmitted within the RRLP protocol 
in this work shall be presented here. As listed above, 
almanac, ephemeris, UTC model, ionospheric model and reference location are transmitted to the MS. Reference
location is the location of the BTS and provides the MS with an approximate location which can be used 
for the position determination in equations given in section \ref{sec:distanceAndPosition}. 
Furthermore, this limits the search space in time and frequency domain for satellites 
to lock on, since if the AGPS receiver has access to these data it can not expect to see satellites 
which send signals on the opposite side of the Earth \citep[Chapter 4]{harper2010server-side}. 
With the reference location, one sends also the altitude and uncertainty of the included location
data so that the AGPS receiver inside the MS can determine and limit the time and frequency search space even further. 
The ionospheric model includes data for correcting errors introduced by the radio wave transmission through
the ionosphere \citep[Chapter 4]{harper2010server-side}. These data are not satellite dependent therefore they 
are not sent for each satellite seperately but once and they are valid for
all satellites \citep[Chapter 4]{harper2010server-side}. Navigation data in RRLP terminology are the ephemeris data.
The transmitted assistance data can be seen in the following tables \ref{tbl:utcModel}, \ref{tbl:navMessage},
\ref{tbl:almanacMessage} and \ref{tbl:ionoModel}, on the following pages \pageref{tbl:utcModel},
\pageref{tbl:navMessage} and \pageref{tbl:almanacMessage}. How other 
data are encoded shall be given in the implementation chapter, chapter \ref{Implementation}.

The packets are constructed in the same manner as RRLP requests with a slight difference of selecting 
different RRLP components and including assistance data. In this particular example, 
only a packet with the reference location shall be presented, a ``complete'' 211 bytes PDU packet constructed by author's 
software would require at least four pages to be shown. Instead of RRLP request (\textit{msrPositionReq})
in \textbf{RRLP-Component} one has to choose assistance data (\textit{assistanceData}) (for the purpose
of better understanding in this listening different colors have been used,
this particular difference was bolded in listing \ref{lst:RRLPAssisPER}). Afterwords one
needs to specify what type of assistance the packet includes, in this case it is GPS assistance
data (\textit{gps-AssistData}, marked in red color in listing \ref{lst:RRLPAssisPER}). GPS assistance data were described in the 
two previous paragraphs and therefore shall be omitted here. They shall be only listed in the order as
specified in the RRLP standard for GPS assistance data, listing \ref{lst:GPSAssisData}: reference time, reference location, DGPS corrections, navigation model,
ionospheric model, UTC model, almanac, acquisition assistance and real time integrity (all marked with blue color in 
listing \ref{lst:RRLPAssisPER}). The assistance data one
wants to include in the RRLP packet have to be selected previously.
Selecting is straightforward and one only is required to set 
the appropriate bit to one (1=included in the packet, 0=not included in the packet). Since in this example only the reference
location is transmitted inside the RRLP PDU packet, the \textit{refLocation}
bit is set to one. Once the variables have been set, the assistance data 
have to follow the given order as in listing \ref{lst:GPSAssisData}.
The top variable data (\textit{referenceTime}) would follow as first and 
bottom variable (\textit{realTimeIntegrity}) would be the last to be included
in the RRLP assistance PDU packet. The reference location has to be converted
into an ellipsoid point with altitude and uncertainty ellipsoid as described 
in the standard \citep{3gppequations} under section \textit{7.3.6}, as shown
in figure \ref{img:refLocStandard}.

\begin{lstlisting}[label=lst:GPSAssisData,
caption={\textbf{Structure of data types of GPS assistance data in ASN.1}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily]
-- Control header of the GPS assistance data
ControlHeader ::= SEQUENCE {

  -- Field type Present information
  referenceTime ReferenceTime OPTIONAL,
  refLocation RefLocation OPTIONAL,
  dgpsCorrections DGPSCorrections OPTIONAL,
  navigationModel NavigationModel OPTIONAL,
  ionosphericModel IonosphericModel OPTIONAL,
  utcModel UTCModel OPTIONAL,
  almanac Almanac OPTIONAL,
  acquisAssist AcquisAssist OPTIONAL,
  realTimeIntegrity SeqOf-BadSatelliteSet OPTIONAL
}
\end{lstlisting}

The reference location consists of longitude, latitude, altitude, uncertainty semi-major,
uncertainty semi-minor, orientation of major axis, uncertainty of altitude and confidence
level. \textbf{S} is sign of the latitude, it is set to zero if it is North and one if
it is South. \textbf{D} is the altitude direction, it is set to zero if the altitude that
follows is height and to one if it is depth. Uncertainty semi-major and uncertainty semi-minor
are uncertainties for longitude and latitude. Orientation of major axis is the orientation angle
of the BTS between the major axis and North pole in degrees. These terms are depicted in figure
\ref{img:earthElipsoid} by showing the World Geodetic System 1984 (WGS84). The latitude,
longitude and altitude need to be encoded into a format recognized by the RRLP standard. This is 
straightforward and can be proceeded using the equations shown in \eqref{eq:latLong}, where $\varphi$
is the latitude and $\lambda$ is the longitude value in decimal degrees. 
Longitude is encoded as second compliment binary number \citep{3gppequations}.
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/ElipsoidPoint.pdf}
  \caption{Reference location is a 14 octet stream built according to the given rule as 
  specified in the standard \citep{3gppequations} under section \textit{7.3.6}.}
\label{img:refLocStandard}
\end{figure}
\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/EarthElipsoid.pdf}
  \caption{World Geodetic System 1984}
\label{img:earthElipsoid}
\end{figure}
The altitude is encoded as it is where one bit increments represent one meter incerements. 
The uncertainties for latitude, longitude and altitude are encoded using the equation 
given in \eqref{eq:uncerAltitudeStand}, where $r$ is the uncertainty in meters for 
latitude and longitude, and $h$ is the uncertainty in meters for altitude of the BTS.
Both values, $U_L$ and $U_A$, are 7 bit numbers in the range between 0 and 127.
Orientation of major axis is not used in this work so it was set to zero. 
Confidence describes the level by which the sent BTS reference position is 
known to be correct. The confidence is a 7 bit number but ought to take values 
between 0 and 100 since it represents the percentage. In this work it was set
to zero, i.e. no information is available about the confidence for our reference
location. It did not change the output behaviour from the MS.

If the reference location is included in the RRLP assistance packet, it is 
important to specify the octet length of the reference location. The length of the reference
location of an ellipsoid point with altitude and uncertainty ellipsoid is of length 14 octets, 
as it can be seen in figure \ref{img:refLocStandard} (amount of rows), it is written as 13 octets
in the RRLP PDU packet.
It is always specified as one number less since at least one octet has to be included in the 
reference location. There are other reference location standards inside of the RRLP protocol. 
This way the RRLP protocol knows where the data end and where new data may start if they are included.
What type of reference location is include is defined by the first four bits of the reference location,
in this case it is $1001$, as it can be seen in figure \ref{img:refLocStandard}. This is an additional
mechanism for error control, if the numbers do not match when the transmitted binary data have been decoded
then the MS can return an error and ask for retransmission of the data. Information related to the reference
location in the example listing \ref{lst:RRLPAssisPER} are marked with orange color. Once the assistance data
have been transmitted to the MS, it shall respond back with an acknowledgement or error depending if the 
data were correctly received and parsed by the MS. The acknowledgement shall have the same reference number 
as the assistance packet. This can be seen as well in figure \ref{img:RRLPReqProt}.
In the next section more
details shall be given on the RRLP response from the MS.
\begin{equation}
\label{eq:latLong}
\begin{array}{l}
\begin{split}
  Lat = \frac{2^{23}}{90}\cdot\vert\varphi\vert
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Latitude}
  \end{split}\\
  \\
\begin{split}
  Long = \frac{2^{24}}{360}\cdot\lambda
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Longitude}
  \end{split}
\end{array} 
\end{equation}

\begin{equation}
\label{eq:uncerAltitudeStand}
\begin{array}{l}
\begin{split}
  U_L=\bigg\lceil\frac{ln(\frac{r}{10}+1)}{ln(1.1)}\bigg\rceil \bigg| U_A \in [0,127]
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Uncertainty for latitude and longitude}
  \end{split}\\
  \\
\begin{split}
  U_A=\bigg\lceil\frac{ln(\frac{h}{45}+1)}{ln(1.025)}\bigg\rceil \bigg| U_A \in [0,127]
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Uncertainty for altitude}
  \end{split}
\end{array} 
\end{equation}

\begin {table}[hb]
\caption{GPS UTC Model content}
\label{tbl:utcModel}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Field (IE) & Description\\\toprule
$A_{1}$&Drift coefficient of GPS time scale relative\\
&to UTC time scale\\\midrule
$A_{0}$&Bias coefficient of GPS time scale relative\\
&to UTC time scale\\\midrule
$t_{ot}$&Time data reference time of week\\\midrule
$\Delta t_{LS}$&Current or past leap second count\\\midrule
$WN_{0}$&Time data reference week number\\\midrule
$WN_{LSF}$&Leap second reference week number\\\midrule
$DN$&Leap second reference day number\\\midrule
$\Delta t_{LSF}$&Current of future leap second count
\\\bottomrule
\end {tabular}
\end {table}

\begin {table}[ht!]
\caption{Navigation message (ephemeris) content}
\label{tbl:navMessage}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Field (IE) & Description\\\toprule
Satellite ID&This is the satellite ID that is in the range of 0 to 63. PRN=SatelliteID + 1\\\midrule
Satellite status&This is an indicator of whether this is a new or existing satellite and whether\\
&the navigation model is new or the same.\\\midrule
C/A or P on L2&Code(s) on L2 channel\\\midrule
URA Index&User range accuracy\\\midrule
SV Health&Satellite health\\\midrule
IODC&Issue of data, clock\\\midrule
L2 P Data flag& \\\midrule
SF 1 Reserved& \\\midrule
$T_{GD}$&Estimated group delay differential\\\midrule
$t_{oc}$&Apparent clock correction\\\midrule
$a_{f2}$&Apparent clock correction\\\midrule
$a_{f1}$&Apparent clock correction\\\midrule
$a_{f0}$&Apparent clock correction\\\midrule
$C_{rs}$&Ampltitude of the sine harmonic correction term to the orbit radius (meters)\\\midrule
$\Delta n$&Mean motion difference from computed value (semicircles/second)\\\midrule
$M_{0}$&Mean anomaly at reference time (semicircles)\\\midrule
$C_{uc}$&Ampltitude of the cosine harmonic correction term to the\\
&argument of latitude (radians)\\\midrule
$e$&Eccentricity\\\midrule
$C_{us}$&Amplitude of the sine harmonic correction term to the argument of latitude\\
&(radians)\\\midrule
$A^{1/2}$&Square root of semi-major axis (meters)\\\midrule
$t_{oe}$&Reference time ephemeris\\\midrule
Fit Interval Flag&\\\midrule
AODO&Age of data offset\\\midrule
$C_{ic}$&Amplitude of the cosine harmonic correction term to the angle of inclination\\
&(radians)\\\midrule
$\Omega_0$&Longitude of ascending node of orbit plane at weekly epoch (semicircles)\\\midrule
$C_{is}$&Amplitude of the cosine harmonic correction term to the angle of inclination\\
&(radians)\\\midrule
$i_{0}$&Inclination angle at reference time (semicircles)\\\midrule
$C_{rc}$&Amplitude of the cosine harmonic correction term to the orbit radius (meters)\\\midrule
$\omega$&Argument of perigee (semicircles)\\\midrule
OMEGAdot&Rate of right ascension (semicircles/second)\\\midrule
Idot&Rate of inclination angle (semicircles/second)
\\\bottomrule
\end {tabular}
\end {table}

\begin {table}[hb]
\caption{Almanac message content}
\label{tbl:almanacMessage}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Field (IE) & Description\\\toprule
SatelliteID&This is the satellite ID that is in the range of 0 to 63. PRN=SatelliteID + 1\\\midrule
SV Health&Satellite health (e.q. 000 means the satellite is fully operational)\\\midrule
$e$&``Eccentricity shows the amount of the orbit deviation from circular (orbit).\\
&It is the distance between the foci divided by the length of the semi-major axis'' \citep{ubxGPSDict}\\\midrule
TOA&Time of applicability, reference time for orbit and clock parameters (seconds).\\
&``The number of seconds in the orbit when the almanac data were generated'' \citep{ubxGPSDict}\\\midrule
OI&Orbital inclination (radians). The angle to which the SV orbit meets\\
&the equator \citep{ubxGPSDict}\\\midrule
RORA&Rate or right ascension (radians/second). ``Rate of change of the angle of right ascension\\
&as defined in the Right Ascension mnemonic'' \citep{ubxGPSDict}\\\midrule
$A^{1/2}$& Square root of semi-major axis (meters$^{1/2}$). `` This is defined as the measurement\\
&from the center of the orbit to either the point of apogee or the point of perigee'' \citep{ubxGPSDict}\\\midrule
$\Omega_0$& Right Ascension at Week (radians). Longitude of ascending node of orbit plane at\\
&weekly epoch\\\midrule
$\omega$&Argument of perigee (semicircles).  ``An angular measurement along the orbital path\\
&measured from the ascending node to the point of perigee, measured in the direction of\\
&the SV's motion'' \citep{ubxGPSDict}\\\midrule
$M_0$&Mean anomaly (radians)\\\midrule
$a_{f0}$&Satellite clock bias (seconds). Satellite clock error at reference time\\\midrule
$a_{f1}$&Satellite clock drift (seconds per second). Satellite clock error rate\\\midrule
Week&Week number since the last reset (i.e. since year 1980 modulo 1024 weeks)
\\\bottomrule
\end {tabular}
\end {table}

\begin {table}[hb]
\caption{GPS Ionosphere Model content}
\label{tbl:ionoModel}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Field (IE) & Description\\\toprule
$\alpha_{0}$&Coefficient 0 of vertical delay\\\midrule
$\alpha_{1}$&Coefficient 1 of vertical delay\\\midrule
$\alpha_{2}$&Coefficient 2 of vertical delay\\\midrule
$\alpha_{3}$&Coefficient 3 of vertical delay\\\midrule
$\beta_{0}$&Coefficient 0 of period of the model\\\midrule
$\beta_{1}$&Coefficient 1 of period of the model\\\midrule
$\beta_{2}$&Coefficient 2 of period of the model\\\midrule
$\beta_{3}$&Coefficient 3 of period of the model
\\\bottomrule
\end {tabular}
\end {table}

\clearpage
\begin{lstlisting}[label=lst:RRLPAssisPER,
caption={\textbf{Encoding reference location from ASN.1 to PER}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily,
escapechar=@,
emph={gps-AssistData},
emphstyle=\color{red},
emph={[2]referenceTime,refLocation,dgpsCorrections,
navigationModel,ionosphericModel,utcModel,almanac,acquisAssist,realTimeIntegrity},
emphstyle={[2]\color{blue}}]
             RRLP Message:
44 010.....   referenceNumber = 2
              component(RRLP-Component):
   ...0....    Extension of RRLP-Component = 0 :Absent
   @\textbf{....010.}@     @\textbf{RRLP-Component}@ @\textbf{=}@ @\textbf{2}@ @\textbf{:assistanceData}@
                 AssistanceData:
   .......0       Extension of AssistanceData = 0 :Absent
11 0.......       referenceAssistData = 0 :Absent
   .0......       msrAssistData = 0 :Absent
   ..0.....       systemInfoAssistData = 0 :Absent
   ...1....       @\textcolor{red}{gps-AssistData}@ = 1 :Present
   ....0...       moreAssDataToBeSent = 0 :Absent
   .....0..       extensionContainer = 0 :Absent
                  GPS-AssistData:
                   ControlHeader:
   ......0.         referenceTime = 0 :Absent
   .......1         refLocation = 1 :Present
00 0.......         dgpsCorrections = 0 :Absent
   .0......         navigationModel = 0 :Absent
   ..0.....         ionosphericModel = 0 :Absent
   ...0....         utcModel = 0 :Absent
   ....0...         almanac = 0 :Absent
   .....0..         acquisAssist = 0 :Absent
   ......0.         realTimeIntegrity = 0 :Absent
                    RefLocation:
                     threeDLocation(Ext-GeographicalInformation):
   .......0           @\textcolor{narandzasta}{Ext-GeographicalInformation length(octet)}@ = 13 :13 + 1 = 14
D9 1101....
   ....1001           @\textcolor{narandzasta}{Ext-GeographicalInformation = 904445940594B200000707000700h}@
04 00000100
44 01000100
59 01011001
40 01000000
59 01011001
4B 01001011
20 00100000
00 00000000
00 00000000
70 01110000
70 01110000
00 00000000
70 01110000
00 0000....

   ....0000  Spare Bits = 0000b
\end{lstlisting}
\clearpage
\section{RRLP Response}
In this section the RRLP response from the MS shall be analysed. The RRLP response is  
constructed in the same manner as the RRLP request and assistance data by following
ASN.1 rules precisely specified in the RRLP standard. RRLP response is produced by the MS itself.
It may include the estimated position, data for estimating the position on the BTS (if MS assisted was
choosen as the prefered method) or errors indicating that some of the 
previously mentioned assistance data are missing. Missing data and errors are 
specified inside of the RRLP response. The response data shall be PER encoded and require
to be decoded into the ASN.1 notation. In listing \ref{lst:RRLPRespError} an example of an 
RRLP response with an error can be seen. The location error bit is set if the location 
of the MS is not present within the message (marked in red). The MS may sometimes supply more
information on the error if the MS knows this information (newer models support this).
In case it does support more information, it shall set an optional IE \textit{additionalAssistanceData} bit 
(marked in cyan). 
\begin{lstlisting}[label=lst:RRLPRespError,
caption={\textbf{Decoding an error RRLP response from Samsung Galaxy S3}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily,
escapechar=@,
emph={gps-AssistData},
emphstyle=\color{red},
emph={[2]referenceTime,refLocation,dgpsCorrections,
navigationModel,ionosphericModel,utcModel,almanac,acquisAssist,realTimeIntegrity},
emphstyle={[2]\color{blue}}]
             RRLP Message:
42 010.....   referenceNumber = 2
              component(RRLP-Component):
   ...0....    Extension of RRLP-Component = 0 :Absent
   @\textbf{....001.}@     @\textbf{RRLP-Component}@ @\textbf{=}@ @\textbf{1}@ @\textbf{:msrPositionRsp}@
                 MsrPosition-Rsp:
   .......0       Extension of MsrPosition-Rsp = 0 :Absent
04 0.......       multipleSets = 0 :Absent
   .0......       referenceIdentity = 0 :Absent
   ..0.....       otd-MeasureInfo = 0 :Absent
   ...0....       locationInfo = 0 :Absent
   ....0...       gps-MeasureInfo = 0 :Absent
   .....1..       @\textcolor{red}{locationError = 1 :Present}@
   ......0.       extensionContainer = 0 :Absent
                  LocationError:
   .......0        Extension of LocationError = 0 :Absent
99 1.......        @\textcolor{cyan}{additionalAssistanceData = 1 :Present}@
                   LocErrorReason:
   .0......         Extension of LocErrorReason = 0 :Absent
   ..0110..          @\textcolor{blue}{LocErrorReason = 6 :gpsAssDataMissing}@
                   AdditionalAssistanceData:
   ......0.         Extension of AdditionalAssistanceData = 0 :Absent
   .......1         @\textcolor{magenta}{gpsAssistanceData = 1 :Present}@
0B 0.......         extensionContainer = 0 :Absent
                    GPSAssistanceData:
   .000101.          @\textcolor{narandzasta}{GPSAssistanceData length(octet)}@ = 5 :5 + 1 = 6
   .......1          @\textcolor{narandzasta}{GPSAssistanceData = E80000000000h}@
D0 11010000
00 00000000
00 00000000
00 00000000
00 00000000
00 0000000.
   .......0  Spare Bits = 0b
\end{lstlisting}
This is followed with a more detailed explanation of the error that not sufficient
assistance data were present, \textit{LocErrorReason} (marked with blue color). There 
are other possible location error reasons as well and they are listed in listing 
\ref{lst:RRLPPosError}. Depending on the MS model, it can even further specify 
what kind of GPS assistance data are missing. This shall be well specified by setting 
the IE \textit{gpsAssistanceData} bit, this is shown in listing \ref{lst:RRLPRespError}
(marked with magenta color). If this bit is set, the length of the IE for requested missing assistance 
data shall be exactly specified as well as what assistance data are missing (marked in orange color).
\begin{lstlisting}[label=lst:RRLPPosError,
caption={\textbf{Possible location error reasons}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily]
LocErrorReason ::= ENUMERATED {
  unDefined (0),	
  notEnoughBTSs (1),
  notEnoughSats (2),
  eotdLocCalAssDataMissing (3),
  eotdAssDataMissing (4),
  gpsLocCalAssDataMissing (5),
  gpsAssDataMissing (6),
  methodNotSupported (7),
  notProcessed (8),
  refBTSForGPSNotServingBTS (9),
  refBTSForEOTDNotServingBTS (10),
  notEnoughGANSSSats (11),	
  ganssAssDataMissing (12),
  refBTSForGANSSNotServingBTS (13)
}
\end{lstlisting}
\begin{figure}[hb]
  \centering
  \includegraphics[scale=0.5]{img/ReqGPSAss.pdf}
  \caption{Requested AGPS assistance data to be delivered}
\label{img:RequestedGPSAss}
\end{figure}
The first two bytes of the IE \textit{GPSAssistanceData} contain the information for requested
assistance AGPS data (marked in orange color). They can be seen 
in figure \ref{img:RequestedGPSAss} \citep{49.031V8.1.0}. If one of these bits from A to K is set,
the MS requires more assistance data. The meaning of the bits in figure \ref{img:RequestedGPSAss}
is given in table \ref{tbl:RRLPReqAss}. In this particular example, the first two bytes are: \textbf{E800},
indicating acquisition assistance, reference time, reference location and the navigation model are requsted
by the MS as assistance data. The next RRLP response example, shown in listing \ref{lst:RRLPRespSucc}, is 
a response with a successfully estimated position! A successful or erroneous position response
is of RRLP measurement responses type, this can be seein in listing \ref{lst:RRLPRespSucc}
(bolded, in listing \ref{lst:RRLPRespError} it is bolded as well). It can not be
distinguished by analysing the first byte of the response stream! In the second byte, two mutually exclusive IE
contain the information if the response contains the location information or not, \textit{locationInfo} bit must
be set and \textit{locationError} must be unset (both marked in red color in listing \ref{lst:RRLPRespSucc}).
If the IE \textit{locationInfo} bit is one and \textit{locationError} bit zero, then the position of the MS is
included in the response. Aside from the position information, the time when the position measurement 
was performed is included as well however, only the least significant bits in the range of miliseconds. The 
most significant bits shall be derived by the SMLC using the GSM frame number, included in the IE \textit{refFrame}.
\textit{refFrame} contains the GSM frame number as observed by the MS without the TA factor taken into account \citep{49.031V8.1.0}!
The time of miliseconds can be found in the IE \textit{gpsTOW}. The included time is
not in UTC format and would require additional conversions. 
The elements of \textit{locationInfo} can be seen in listing \ref{lst:RRLPLocInfo}. The IE \textit{fixType} contains
the information if the performed measurement was 2D or 3D.
\begin {table}[ht]
\caption{Requested AGPS assistance data bit meaning}
\label{tbl:RRLPReqAss}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{clccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
Bit (IE) & Description\\\toprule
$A$&Acquisition assistance requested\\\midrule
$B$&Reference time requested\\\midrule
$C$&Reference location requested\\\midrule
$D$&DGPS corrections requested\\\midrule
$E$&Navigation model requested\\\midrule
$F$&Ionospheric model requested\\\midrule
$G$&UTC model requested\\\midrule
$H$&Almanac data requested\\\midrule
$I$&Real time integrity requested\\\midrule
$J$&Ephemeris extension requested\\\midrule
$K$&Ephemeris extension check requested
\\\bottomrule
\end {tabular}
\end {table}
\begin{lstlisting}[label=lst:RRLPLocInfo,
caption={\textbf{Structure of data types of location info data in ASN.1}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily,
escapechar=@]
-- Location information IE
LocationInfo ::= SEQUENCE {
  refFrame INTEGER (0..65535), -- Reference Frame number
  -- If refFrame is within (42432..65535), it shall be ignored by the receiver
  -- in that case the MS should provide GPS TOW if available
  gpsTOW INTEGER (0..14399999) OPTIONAL, -- GPS TOW
  fixType FixType,
  -- Note that applicable range for refFrame is 0 - 42431
  -- Possible shapes carried in posEstimate are
  -- ellipsoid point, ellipsoid point with uncertainty circle,
  -- ellipsoid point with uncertainty ellipse,
  -- ellipsoid point with altitude and uncertainty ellipsoid
  posEstimate Ext-GeographicalInformation
}

FixType ::= INTEGER {
  twoDFix (0),
  threeDFix (1)
} (0..1)
\end{lstlisting}
The position information is extracted with the inverse process as it was specified for the reference location. 
Equations to return from the bit format to decimal degrees are given in equation \eqref{eq:latLongBack}. %\clearpage
In the next chapter, more details shall be given on the implementation of the complete system.
\begin{lstlisting}[label=lst:RRLPRespSucc,
caption={\textbf{Decoding a successful RRLP response from iPhone 3GS}},
backgroundcolor=\color{light-gray},
basicstyle=\scriptsize\ttfamily,
escapechar=@,
emph={gps-AssistData},
emphstyle=\color{red},
emph={[2]referenceTime,refLocation,dgpsCorrections,
navigationModel,ionosphericModel,utcModel,almanac,acquisAssist,realTimeIntegrity},
emphstyle={[2]\color{blue}}]
             RRLP Message:
42 010.....   referenceNumber = 2
              component(RRLP-Component):
   ...0....    Extension of RRLP-Component = 0 :Absent
   @\textbf{....001.}@     @\textbf{RRLP-Component = 1 :msrPositionRsp}@
                 MsrPosition-Rsp:
   .......0       Extension of MsrPosition-Rsp = 0 :Absent
11 0.......       multipleSets = 0 :Absent
   .0......       referenceIdentity = 0 :Absent
   ..0.....       otd-MeasureInfo = 0 :Absent
   ...1....       @\textcolor{red}{locationInfo = 1 :Present}@
   ....0...       gps-MeasureInfo = 0 :Absent
   .....0..       @\textcolor{red}{locationError = 0 :Absent}@
   ......0.       extensionContainer = 0 :Absent
                  LocationInfo:
   .......1        gpsTOW = 1 :Present
FF 11111111        refFrame = 65535
FF 11111111
61 01100001        gpsTOW = 6399000
A4 10100100
18 00011000
                   FixType:
B6 1.......         FixType = 1 :threeDFix
                   posEstimate(Ext-GeographicalInformation):
   .01101..         @\textcolor{narandzasta}{Ext-GeographicalInformation length(octet)}@ = 13 :13 + 1 = 14
   ......10         @\textcolor{narandzasta}{Ext-GeographicalInformation = 904445840594A6016316114F1D44h}@
41 01000001
11 00010001
16 00010110
10 00010000
16 00010110
52 01010010
98 10011000
05 00000101
8C 10001100
58 01011000
45 01000101
3C 00111100
75 01110101
10 000100..
   ......00  Spare Bits = 00b
\end{lstlisting}
\begin{equation}
\label{eq:latLongBack}
\begin{array}{l}
\begin{split}
  \varphi = \frac{90}{2^{23}}\cdot Lat
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Latitude in decimal degrees}
  \end{split}\\
  \\
\begin{split}
  \lambda = \frac{360}{2^{24}}\cdot Long
  \end{split}
\quad\Longleftarrow\quad
  \begin{split}
    \mbox{Longitude in decimal degrees}
  \end{split}
\end{array} 
\end{equation}












\chapter{Implementation}
\label{Implementation}
The aim of this chapter is to give the reader a review of the software implementation in this thesis.
The implementation can be divided into two sections. One section of the implementation is responsible
for generating the RRLP assistance data and the other section is modification of the existing 
open source GSM software (OpenBSC) and implementing the transfering of assistance data to the cell 
phone and to obtain the response back. In this work two programming languages have been employed, C and C++
whereas basic knowledge of Erlang was required to understand an implementation of a similar RRLP assistance
data generation. The Erlang implementation by Kurtis Heimerl was used as a guide while the author
developed a C++ version since at the time of testing it was not a working implementation of the RRLP
protocol\footnote{Kurtis Heimerl's 
code can be found on \url{https://github.com/ttsou/RRLP}}! More details shall be given in the following
sections. OpenBSC is an open source implementation of 

-from rinex conversion\\
explain rinex form \\
explain a bit ephemeris data and almanac \\
data and conversion \\

Author's test system operated on the ARFCN 877 channel. ARFCN (Absolute Radio
Frequency Channel Number) defines the uplink and downlink channel frequency insdide 
the GSM network \citep{Richard2011Master}. ARFCN 877 corresponds to the uplink frequency
of 1,783.2 MHz and a downlink frequency of 1,878.2 MHz, where the uplink direction
represents the direction from the nanoBTS to the mobile stations and downlink the
opposite direction. The decision to use the ARFCN 877 channel was derived from
the fact that the channel was free, measurements were carried out with a
spectrum analyser built on the USRP hardware. 

\chapter{Hardware}
In the following chapter the author shall introduce the reader to the hardware
components used in the thesis. The hardware components shall be presented
according to their importance of building an operational and
functional GSM network with GPS localization capabilities. Firstly the nanoBTS
shall be introduced since it is the main hardware component used for building a
basic GSM network infrastructure. Then a short insight into the used
GPS receiver shall be given. Additionally the mobile stations used for
testing of the system shall be reviewed. Finally, a hardware connection diagram
shall be given.
 
\section{GSM BTS - nanoBTS}
In recent years, there has been an increasing interest in deployment of
private cellular networks in remote areas or for research which lead to
the devolopment of diverse ``low-cost'' GSM hardware solutions. According to 
ip.access\footnote{http://www.ipaccess.com}, the manufacturer of nanoBTS,
their hardware product is deployed for coverage of ``hard-to-reach places;
in-buildings; remote areas; marine and aviation; and public spaces''.
A nanoBTS with its plastic cover can be seen in Figure \ref{img:nanoBTSPlastic}. 
Our University GSM network consists of three nanoBTS stations. The deployed
nanoBTS in author's thesis works in the 1800 MHz frequency range,
for which the University of Freiburg had obtained a licence from the
Federal Network Agency (German: $Bundesnetzagentur$). The transmission frequencies
range between 1805-1880 MHz, with 200 kHz channel spacing and maximal output power
of +13 dBm ($\approx$20 mW)\todo{Check the output powere 20 dBm}, whereas the receiving frequencies
lie in the range between 1710-1785 MHz and same channel spacing as for transmission
of 200 kHz \citep{nanoGSM2007brochure}. \todo{Add the Abis over IP protocol}

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.50]{img/nanoBTS.jpg}
  \caption{nanoBTS with its plastic cover. Image courtesy of ip.access ltd}
\label{img:nanoBTSPlastic}
\end{figure}

The nanoBTS is equiped with an internal 0 dBi (nominal) omni-directional antenna. However, 
two external antennas sized 30x36 mm, one for transmission (TX) and the other one for
reception (RX) of radio waves were used to extend the coverage area. These
antennas are connected via the SMA connectors. By using an RF amplifier
and larger antennas, for these frequency ranges, the covered area with the GSM signal
reception can be increased. For the gain estimation and radiation angle of the used antennas
the measurement equipment was missing and therefore was not conducted and described
in this work.\todo{Check for what NWL is}

At the bottom of the nanoBTS there are 5 ports, as seen in Figure \ref{img:nanoBTSPorts}.
The ports from left to right are: voltage supply, ethernet cable with power supply, USB
port, TIB-IN and TIB-OUT. In the next paragraph a brief overview of each port shall be given. 

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.15]{img/nanoBTSPorts.jpg}
  \caption{nanoBTS with two external antennas and five connection ports}
\label{img:nanoBTSPorts}
\end{figure}

The left most port is the power supply port used for supplying the nanoBTS with 48 V DC
and is optionally used depending on the cable configuration. In author's hardware
configuration the power supply port is not used. The following port is for the ethernet
connection with 48 V DC power supply. This port is connected to a power supply
that is supplied with the nanoBTS. It extends the ethernet connection with 48 V DC 
for the normal operation mode of the nanoBTS which is in the range between 38-50 V DC.
The power consumtion of the nanoBTS is 13 W. More details on how to interconnect the cables
shall be given in section \ref{sec:hardwareConfig}. In the middle of the five port region,
the mini USB port can be found. It is used by the manufacturer to write the firmware software
to the nanoBTS. The last two ports are the TIB-IN and TIB-OUT port\footnote{TIB stands
for Timing Interface Bus}. These two ports are used if the GSM network operator requires more
than 11 channels to increase the overall capacity of the network. 
``Up to 4 nanoBTS can be combined into a multiple TRX cell, increasing the number of 
supported users per TRX by up to 200\%. The TIB-OUT from the Master TRX must be connected to
the TIB-IN of the slave TRX. This in turn has its TIB-OUT connected to the next TRX in the chain''
\citep{multipleTRX}. The multiple TRX cell configuration shall not be further discussed in this work
since the purpose of the work was not to boost the capacity of a GSM network but implementation 
and testing of the RRLP protocol.

To determine the working state of the nanoBTS, an indicator status LED is located on the
left side of the five ports region. After the nanoBTS is connected to the power suplly
with the ethernet cable, it shall change its color and blink speed according to the state
it is in. The states can be seen in the Table given in \ref{tbl:LEDStatus} \citep{installnanoBTS}.

One of the key limitations of gathering more technical data and the critical aspect of this
description lies in the fact, that nanoBTS is not an open source hardware platform and ip.access does not 
offer more details on their product. The lack of systematic hardware analysis can be seen as 
a major drawback of working with the nanoBTS hardware. However, the given technical data 
are sufficient for reproducing and conducting the RRLP tests described in this thesis. 


\begin {table}[hb]
\caption{Indicator LED status on the nanoBTS}
\label{tbl:LEDStatus}\centering 
%\rowcolor{2}{light-gray}{}
\scriptsize\fontfamily{iwona}\selectfont
\begin{tabular}{cccc}
\toprule 
%$D$&&$P_u$&$\sigma_N$\\
State&Color \& Pattern&When&Precedence\\\toprule
Self-test failure&Red - Steady       &In boot or application code when a power&1 (High) \\
				     &&on self-test fails\\\midrule
Unspecified failure&Red - Steady &On software fatal errors&2\\\midrule
No ethernet&Orange - Slow flash &Ethernet disconnected&3\\\midrule
Factory reset&Red - Fast blink       &Dongle detected at start up and the&4\\
				     &&factory defaults have been applied\\\midrule
Not configured&Alternating Red/&The unit has not been configured&5\\
	       &Green Fast flash\\\midrule
Downloading code&Orange - Fast flash &Code download procedure is in progress&6\\\midrule
Establishing XML&Orange - Slow blink &A management link has not yet been established&7\\
				      &&but is needed for the TRX to become operational.\\
				      &&Specifically: for a master a Primary OML or\\
				      &&Secondary OML is not yet established; for a\\
				      &&slave an IML to its master or a Secondary \\
				      &&OML is not yet established. \\\midrule
Self-test &Orange - Steady            &From power on until end of backhaul&8\\
				      &&power on self-test\\\midrule
NWL-test 	 &Green - Fast flash& OML established, NWL test in progress&9\\\midrule
OCXO Calibration &Alternating Green/& The unit is in the fast calibrating state [SYNC]&10\\
	         &Orange - Slow blink\\\midrule
Not transmitting &Green - Slow flash & The radio carrier is not being transmitted &11\\\midrule
Operational &Green - Steady & Default condition if none of the above apply&12 (Low)\\\bottomrule
\end {tabular}
\end {table}


%\begin{table}[h!t!p!]
%\begin{center}
%\caption{Indicator LED status on the nanoBTS}
%\begin{tabular}{|c||p{3cm}|p{5cm}|c|c|}
%\hline
%% \T and \B would not work if it is placed here (needs to go inside cell)
% State&Color \& Pattern&When&Precedence \\ \hline\hline
% Self-test failure&Red - Steady&In boot or application code when a power on self-test fails&1 (High) \\ \hline
% Unspecified failure&Red - Steady &On software fatal errors&2 \\ \hline
% No ethernet&Orange - Slow flash &Ethernet disconnected&3 \\ \hline
% Factory reset&Red - Fast blink &Dongle detected at start up and the factory defaults have been applied&4 \\ \hline
% Not configured&Alternating Red/Green - Fast flash &The unit has not been configured&5 \\ \hline
% Downloading code&Orange - Fast flash &Code download procedure is in progress&6 \\ \hline
% Establishing XML&Orange - Slow blink &A management link has not yet been established&7\\
%				      &&but is needed for the TRX to become operational.\\
%				      &&Specifically: for a master a Primary OML or\\
%				      &&Secondary OML is not yet established; for a\\
%				      &&slave an IML to its master or a Secondary \\
%				      &&OML is not yet established. \\ \hline
% Self-test &Orange - Steady & From power on until end of backhaul powe on self-test&8 \\ \hline
% NWL-test &Green - Fast flash & OML established, NWL test in progress&9 \\ \hline
% OCXO Calibration &Alternating Green/Orange - Slow blink & The unit is in the fast calibrating state [SYNC]&10 \\ \hline
% Not transmitting &Green - Slow flash & The radio carrier is not being transmitted &11 \\ \hline
% Operational &Green - Steady & Default condition if none of the above apply&12 (Low) \\ \hline
% 
%\end{tabular}
%\end{center}
%\label{tbl:LEDStatus} 
%\end{table}


\newpage
\section{GPS Receiver - NL-402U}
\label{sec:gpsDevice}
In the next paragraphs the used GPS device shall be described. 
In contrast to the earlier described hardware, nanoBTS, which the University of Freiburg
already owned, the budget for the GPS receiver was limited and the Navilock NL-402U
was bought considering only the single criterion, the price. The Navilock NL-402U
GPS receiver is based on the u-blox UBX-G5000 single chipset and is a one 
chip solution \citep{ubxDatasheet}. It can be seen on Figure \ref{img:gpsNavilock}
with its passive ceramic patch antenna. 1575,42 MHz is the operating frequency of
the receiver which corresponds to the L1 civil frequencies and Coarse/Acquisition (C/A) code.
The GPS chipset consists of 50 channels,
each channel tracks the transmission from a single satellite \citep{understandGPS}.
It is important to note, the number of channels inside a GPS receiver interrelates 
with the amount of time required to obtain the first fix. Receiver tracking sensitivity is 
-160 dBm ($10^{-16}$ mW). 
The GPS receiver communicates with the computer ovet the USB port.
Although the GPS receiver uses an USB interface, on the computer it emulates 2 UART ports, 
which are serial communication interfaces.


\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.12]{img/gpsNavlock.jpg}
  \caption{Navilock NL-402U, opened up with the antenna and USB cable}
\label{img:gpsNavilock}
\end{figure}

\section{Cable configuration}
\label{sec:hardwareConfig}
In the next section, the author shall focus on properly connecting the hardware. 
At least 4 ethernet cables with RJ45 connectors, on both sides, were required
and one switch or hub connected to the internet. One should
take notice of the cabling between the nanoBTS and the ethernet switch or hub,
since wrong cabling with the power supply unit (PSU) could damage one of
the devices. In Figure \ref{img:connectionDiagram}, the junction points are
label according to the used configuration setting. The ethernet cables
between the switch/hub, PSU and nanoBTS should not be longer
than 100 m \citep{installnanoBTS}.

\begin{figure}[ht!]
  \centering
  \includegraphics[scale=0.5]{img/hardwareConnection}
  \caption{Cable connections, showing interconnection diagram}
\label{img:connectionDiagram}
\end{figure}

\chapter{Results}
Test if it can be tricked out by the software Dennis mentioned (protect my privacy)!

\chapter{Summary}

\chapter*{Dictionary of acronyms}
\begin{itemize}
\item \emph{ARFCN} - Absolute Radio Frequency Channel Number - The channel number specifies the physical frequency channel used for transmission and reception of radio waves inside of an BTS covered area.
\item \emph{BTS} - Base Transceiver Station - 
\item \emph{DC} - Direct Current
\item \emph{GNSS} - Global Navigation Satellite System - A satellite navigation system that allows a specialized receive to determine its location on Earth.
\item \emph{LED} - Light Emitting Diode - A diode that emitts light.
\item \emph{IP Address} - \todo{Write what an IP address is}.
\item \emph{PCB} - Printed Circuit Board - The board where electronic components are soldered onto and wired through conductive tracks.
\item \emph{RRLP} - Radio Resource Location Protocol - The employed protocol in GSM, UMTS and other wireless networks for providing and exchange of geolocation information. 
\item \emph{SMA} - SubMiniature version A - SMA is a connector used for interconnecting coaxial cables or PCB electronics that work in the frequency range between 0-18 GHz.
\item \emph{TIB} - Time Interface Bus - The TIB is used to provide the synchronization of the clock, frequency and frame number between the nanoBTS when operating in a single 2-4 BTS configuration.
\item \emph{TRX} - 
\item \emph{UART} - Universal Asynchronous Receiver Transmitter - A serial communication interface used by computers or other peripheral devices to communicate.
\item \emph{UMTS} - Universal Mobile Telecommunications System - Third generation mobile network based on the GSM standards. 
\end{itemize}