z1_ot.tex 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538
  1. % Copyright (C) 2014-2017 by Thomas Auzinger <thomas@auzinger.name>
  2. %\documentclass[draft,final]{vutinfth} % Remove option 'final' to obtain debug information.
  3. \documentclass[final]{vutinfth} % Remove option 'final' to obtain debug information.
  4. % Load packages to allow in- and output of non-ASCII characters.
  5. \usepackage{lmodern} % Use an extension of the original Computer Modern font to minimize the use of bitmapped letters.
  6. \usepackage[T1]{fontenc} % Determines font encoding of the output. Font packages have to be included before this line.
  7. \usepackage[utf8]{inputenc} % Determines encoding of the input. All input files have to use UTF8 encoding.
  8. % Extended LaTeX functionality is enables by including packages with \usepackage{...}.
  9. \usepackage{amsmath} % Extended typesetting of mathematical expression.
  10. \usepackage{amssymb} % Provides a multitude of mathematical symbols.
  11. \usepackage{mathtools} % Further extensions of mathematical typesetting.
  12. \usepackage{microtype} % Small-scale typographic enhancements.
  13. \usepackage[inline]{enumitem} % User control over the layout of lists (itemize, enumerate, description).
  14. \usepackage{multirow} % Allows table elements to span several rows.
  15. \usepackage{booktabs} % Improves the typesettings of tables.
  16. \usepackage{subcaption} % Allows the use of subfigures and enables their referencing.
  17. \usepackage[ruled,linesnumbered,algochapter]{algorithm2e} % Enables the writing of pseudo code.
  18. \usepackage[usenames,dvipsnames,table]{xcolor} % Allows the definition and use of colors. This package has to be included before tikz.
  19. \usepackage{nag} % Issues warnings when best practices in writing LaTeX documents are violated.
  20. \usepackage{todonotes} % Provides tooltip-like todo notes.
  21. \usepackage{hyperref} % Enables cross linking in the electronic document version. This package has to be included second to last.
  22. \usepackage[acronym,toc]{glossaries} % Enables the generation of glossaries and lists fo acronyms. This package has to be included last.
  23. \usepackage{listings}
  24. \usepackage{tabularx}
  25. \usepackage[section]{placeins}
  26. % Define convenience functions to use the author name and the thesis title in the PDF document properties.
  27. \newcommand{\authorname}{Stephan Felber} % The author name without titles.
  28. \newcommand{\thesistitle}{Porting OpenThread to Resource Constrained Devices} % The title of the thesis. The English version should be used, if it exists.
  29. % Set PDF document properties
  30. \hypersetup{
  31. pdfpagelayout = TwoPageRight, % How the document is shown in PDF viewers (optional).
  32. linkbordercolor = {Melon}, % The color of the borders of boxes around crosslinks (optional).
  33. pdfauthor = {\authorname}, % The author's name in the document properties (optional).
  34. pdftitle = {\thesistitle}, % The document's title in the document properties (optional).
  35. pdfsubject = {Subject}, % The document's subject in the document properties (optional).
  36. pdfkeywords = {a, list, of, keywords} % The document's keywords in the document properties (optional).
  37. }
  38. \setpnumwidth{2.5em} % Avoid overfull hboxes in the table of contents (see memoir manual).
  39. \setsecnumdepth{subsection} % Enumerate subsections.
  40. \nonzeroparskip % Create space between paragraphs (optional).
  41. \setlength{\parindent}{0pt} % Remove paragraph identation (optional).
  42. \makeindex % Use an optional index.
  43. \makeglossaries % Use an optional glossary.
  44. %\glstocfalse % Remove the glossaries from the table of contents.
  45. % Set persons with 4 arguments:
  46. % {title before name}{name}{title after name}{gender}
  47. % where both titles are optional (i.e. can be given as empty brackets {}).
  48. \setauthor{}{\authorname}{}{male}
  49. \setadvisor{Ao.Univ.Prof. Dipl.-Ing. Dr.techn.}{Wolfgang Kastner}{}{male}
  50. % For bachelor and master theses:
  51. \setfirstassistant{Dipl.-Ing.}{Stefan Seifried}{BSc}{male}
  52. \setsecondassistant{Univ.Ass. Dipl.-Ing.}{Philipp Raich}{BSc}{male}
  53. % Required data.
  54. \setaddress{Address}
  55. \setregnumber{1426418}
  56. \setdate{01}{04}{2019} % Set date with 3 arguments: {day}{month}{year}.
  57. \settitle{\thesistitle}{OpenThread auf Resource beschränkten Geräten} % Sets English and German version of the title (both can be English or German). If your title contains commas, enclose it with additional curvy brackets (i.e., {{your title}}) or define it as a macro as done with \thesistitle.
  58. %\setsubtitle{Optional Subtitle of the Thesis}{Optionaler Untertitel der Arbeit} % Sets English and German version of the subtitle (both can be English or German).
  59. % Select the thesis type: bachelor / master / doctor / phd-school.
  60. % Bachelor:
  61. \setthesis{bachelor}
  62. %
  63. % Master:
  64. %\setthesis{master}
  65. %\setmasterdegree{dipl.} % dipl. / rer.nat. / rer.soc.oec. / master
  66. %
  67. % Doctor:
  68. %\setthesis{doctor}
  69. %\setdoctordegree{rer.soc.oec.}% rer.nat. / techn. / rer.soc.oec.
  70. %
  71. % Doctor at the PhD School
  72. %\setthesis{phd-school} % Deactivate non-English title pages (see below)
  73. % For bachelor and master:
  74. \setcurriculum{Computer Engineering}{Technische Informatik} % Sets the English and German name of the curriculum.
  75. % For dissertations at the PhD School:
  76. %\setfirstreviewerdata{Affiliation, Country}
  77. %\setsecondreviewerdata{Affiliation, Country}
  78. \lstset{
  79. basicstyle=\ttfamily,
  80. columns=fixed,
  81. fontadjust=true,
  82. breaklines=true,
  83. basewidth=0.5em
  84. }
  85. \begin{document}
  86. \newacronym{ot}{OT}{OpenThread}
  87. \newacronym{phy}{PHY}{Physical Layer}
  88. \newacronym{iot}{IoT}{Internet of Things}
  89. \newacronym{ipv6}{IPv6}{Internet Protocol version 6}
  90. \newacronym{ipv4}{IPv4}{Internet Protocol version 4}
  91. %\newacronym{ip}{IPv4}{Internet Protocol}
  92. \newacronym{6lowpan}{6LoWPAN}{IPv6 over Low Powered Personal Area Networks}
  93. \newacronym{hal}{HAL}{Hardware Abstraction Layer}
  94. \newacronym{posix}{POSIX}{Portable Operating Systems Interface}
  95. \newacronym{uart}{UART}{Universal Asynchronous Receiver / Transmitter}
  96. \newacronym{osi}{OSI}{Operating Systems Interconnection}
  97. \newacronym{ffd}{FFD}{Full Function Device}
  98. \newacronym{rfd}{RFD}{Reduced Function Device}
  99. \newacronym{pan}{PAN}{Personal Area Network}
  100. \newacronym{mtu}{MTU}{Maximum Transmission Unit}
  101. \newacronym{udp}{UDP}{User Datagram Protocol}
  102. \newacronym{tcp}{TCP}{Transmission Control Protocol}
  103. \newacronym{reed}{REED}{Router Eligible End Device}
  104. \newacronym{sed}{SED}{Sleepy End Device}
  105. \newacronym{mle}{MLE}{Mesh Link Establishment}
  106. \newacronym{psdu}{PSDU}{Physical Service Data Unit}
  107. \newacronym{ack}{ACK}{Acknowledge}
  108. \newacronym{icmp}{ICMP}{Internet Control Message Protocol}
  109. \newacronym{usb}{USB}{Universal Serial Bus}
  110. \newacronym{mac}{MAC}{Medium Access Control}
  111. \newacronym{mcu}{MCU}{Micro controller Unit}
  112. \newacronym{tls}{TLS}{Transport Layer Security}
  113. \newacronym{cts}{CTL}{Clear To Send}
  114. \newacronym{rtt}{RTT}{Round Trip Time}
  115. \newacronym{spi}{SPI}{Serial Peripheral Interface}
  116. \frontmatter % Switches to roman numbering.
  117. % The structure of the thesis has to conform to
  118. % http://www.informatik.tuwien.ac.at/dekanat
  119. %\addtitlepage{naustrian} % German title page (not for dissertations at the PhD School).
  120. \addtitlepage{English} % English title page.
  121. \addstatementpage
  122. %\begin{danksagung*}
  123. %\todo{Meine Kaffeemaschine.}
  124. %\end{danksagung*}
  125. \begin{acknowledgements*}
  126. My coffee machine without which I would not even have started university and
  127. my room mates without whom this thesis would have been finished a year earlier.
  128. Thanks boys.
  129. \end{acknowledgements*}
  130. \begin{abstract}
  131. Small embedded systems featuring radio capabilities are getting cheaper and
  132. cheaper to produce. These devices are characterised by a comparably low
  133. processing power, a reduced periphery and low power consumption. To allow
  134. wireless communication between such devices, while respecting the
  135. restrictions, a new specially crafted communication protocol had to be
  136. designed. Demanding that it be power efficient, allowing devices to run on
  137. battery, error resistant and easy to use may seem like too much to ask, but
  138. Thread building on 802.15.4 and IPv6 fullfills all of the above.
  139. This thesis presents an implementation of OpenThread, an implementation of
  140. the Thread specification for the Zolertia Z1 mote. The Z1 is a cheap and power
  141. efficient 16-bit micro controller.
  142. By outlining the integral protocols of the Thread stack, the challenges of the
  143. thesis are presented. In the end, an implementation for OpenThread using
  144. the Zolertia Z1 is given. This implementation may be used to develop
  145. applications for OpenThread on a PC while taking part in an actual Thread
  146. network.
  147. \end{abstract}
  148. % Select the language of the thesis, e.g., english or naustrian.
  149. \selectlanguage{english}
  150. % Add a table of contents (toc).
  151. \tableofcontents % Starred version, i.e., \tableofcontents*, removes the self-entry.
  152. % Switch to arabic numbering and start the enumeration of chapters in the table of content.
  153. \mainmatter
  154. \chapter{Introduction}
  155. \section{Motivation}
  156. As small computers, or so called embedded systems, got cheaper over the last
  157. few years, the need for specially tailored communication protocols arose. These
  158. embedded systems are restricted to a small power consumption and have to to be
  159. fairly cheap to produce, as they are expected to be used in large numbers.
  160. Designing a way of communication for such devices has to take these factors
  161. into account. It can neither be too complex to be run on a \gls{mcu} nor too
  162. energy consuming to use.
  163. The low cost per unit and the resulting volumes of units produced allow
  164. for local networks with a larger amount of participants. Connecting this local
  165. domain of communication to the Internet results in the so called \gls{iot}.
  166. The \gls{iot} mainly consists of tiny computers which primarily do one or
  167. both of two things: firstly most of them serve as an actuator or a sensor. Like a light bulb
  168. that can be controlled via an app on your mobile phone, or a door lock that can
  169. be remotely released. Secondly they collect data. A humidity sensor might record
  170. the air quality, a smart dog feeder may remember when you feed your dog, and the
  171. light bulb might record when it is switched on and off. This data is then sent
  172. via the Internet to the user or the manufacturer.
  173. An interesting sector for \gls{iot} is health care. As the median of the
  174. population age keeps getting older, new solutions for health care services have
  175. to be found. Because pretty much every bed is already connected to the
  176. Internet, it is expected that gathering all data available from a patient can
  177. be beneficial to both their recovery and further medical research.
  178. As \gls{iot} devices are expected to get even cheaper and more numerous,
  179. more data sources will be monitoring the patients recovery story. The industry
  180. expects to develop more efficiently using such databases and keywords like Big
  181. Data, data mining and distributed intelligence are often associated with Health
  182. \gls{iot} \cite{doi:10.1080/17517575.2013.776118}.
  183. \subsection{Technical Motivation}
  184. Both the actuator and the sensor part of the connected device need a channel of
  185. communication to receive commands and deliver information \cite{5523336}.
  186. Taking into account that the participants of the network should be allowed to
  187. spread about in the range of the network, a wireless communication is heavily
  188. favored because it eliminates the need of a cable tree to every node. Although
  189. wireless clears some difficulties, it also presents new challenges, like
  190. increased power consumption or interference on the shared medium.
  191. There are nevertheless solutions to the challenges presented. One of them is
  192. \gls{ot} which builds on the 802.15.4 \gls{phy} standard. The 802.15.4
  193. standard was crafted specifically with such low power devices in mind. In order
  194. to provide direct connectivity to the Internet, the \gls{6lowpan} layer
  195. translates \gls{ipv6} to 802.15.4 friendly packets. This promotes every
  196. participant in the network to a fully qualified member of the \gls{ipv6}
  197. Internet and grants all the benefits of a direct Internet access. \gls{ot}
  198. is easing network setup and maintenance by providing self healing mechanisms
  199. and fully encrypted communication.
  200. %This thesis provides an implementation of the \gls{ot} stack utilizing the
  201. %Zolertia Z1 mote.
  202. The Z1 features a 802.15.4 capable radio chip and multiple connection
  203. possibilities to connect sensors or actuators. It can run on battery or on the
  204. power provided by a \gls{usb} cable. Altough there are already multiple smaller
  205. devices providing the same functionality, the Z1 is still a candidate for the
  206. \gls{ot} stack.
  207. %Glossary oder acronyms?
  208. \section{Problem Statement}
  209. %This chapter states the problem which this work aims to solve. The initial
  210. %problem proved not to be solvable in the alloted amount of time but a different
  211. %approach allowed similar results.
  212. The task of this thesis is to port the \gls{ot} implementation to the Zolertia
  213. Z1 mote.
  214. Up to now, \gls{ot} is already running on multiple embedded platforms from
  215. different manufacturers, such as RIOT OS, Zephyr and provides two border
  216. router implementations. The porting process of the \gls{ot} stack in
  217. general consists of writing a new \gls{hal}. This means implementing an
  218. \gls{hal} between the program logic and the hardware it runs on.
  219. \gls{ot} is already a Thread certified implementation, which means that the
  220. Thread Group assures its compliance with the Thread standard. It was released
  221. under an open source license allowing developers easier development of
  222. applications for Thread.
  223. The Z1 is in general not as powerful as the other hardware \gls{ot} is already
  224. running on because it was released much earlier. This presents new challenges
  225. for the development of a \gls{hal} and problems like memory size or \gls{mcu}
  226. capabilities may arise.
  227. \section{Aim of the Thesis}
  228. %TODO measureable. Aim at the last result from the beginning. The thing in
  229. %between is just a failure.
  230. This thesis provides an implementation of the \gls{ot} stack utilizing the
  231. Zolertia Z1 mote. As the Z1 provides a 802.15.4 compatible radio interface it
  232. allows the \gls{ot} Stack to operate either directly on the device or with some
  233. transport layer in between. This model is already similarly described on the
  234. official \gls{ot} website as a network co-processor model, but no actual
  235. implementation was found at this time \cite{OTsite:platform}.
  236. The result should allow developers writing applications for the \gls{ot} stack
  237. to actively develop on a normal computer while still having access to actual
  238. radio hardware. Applications may be tested in an existing \gls{ot} network and
  239. concurrently inspected by, for example, the GNU Debugger (GDB).
  240. %This implementation allows developers to write their applications for
  241. %\gls{ot} on a normal computer, with all standard debugging tools, like the
  242. %GNU Debugger available. But it also provides an actual link to a running Thread
  243. %network. This may prove especially valuable when debugging network related
  244. %errors.
  245. \chapter{State of the Art}
  246. This chapter provides a more exhaustive description of the standards and
  247. protocols that Thread relies on and are relevant for this thesis. Starting with
  248. the fundamentals, 802.15.4 will be explained, continuing with 6LoWPAN and its
  249. features. Thread, building on top of the previous two, is explained at the
  250. end. The corresponding \gls{osi} model is visualized in figure
  251. \ref{fig:osi}.
  252. Thread itself fullfills some aspects in the transport layer and some
  253. responsibilities of a network infrastructure manager. Considering this, it is
  254. both part of the transport layer and exceeds it. According to the \gls{osi}
  255. model, Thread corresponds to the transport layer, but Threads network
  256. management capabilities are simply not reflected in the \gls{osi} model.
  257. This correctly classifies Thread but neglects the efforts for the mesh network
  258. establishment and maintenance.
  259. %\input{images/802_15_4_topologies.tex}
  260. \begin{figure}
  261. \centering
  262. \includegraphics[width=0.5\linewidth]{images/sota_osi.png}
  263. \caption{The first three layers of the \gls{osi} model on the left, and their
  264. respective specifications on the right.}
  265. \label{fig:osi}
  266. \end{figure}
  267. \section{802.15.4}
  268. In 2003, the Institute of Electrical and Electronics Engineers introduced the
  269. 802.15.4 standard to enable "very low-cost, low-power communication" for
  270. devices while ensuring consistent transmission and keeping the protocol simple
  271. but flexible. \cite[13, 45]{802_15_4_std}
  272. This standard proved to be the foundation for many communication stacks
  273. operating on power constrained devices. Since efficient energy saving
  274. communication requires fine-grained control over the hardware used, it was
  275. necessary to start such a communication stack at the very lowest \gls{osi}
  276. level, the \gls{phy} layer. This may be observed in figure \ref{fig:osi}.
  277. The lowest layer in the \gls{osi} model states how the bits are delivered
  278. from one point to another. It takes care of the physical and mechanical aspects
  279. and ensures the actual delivery of the information.
  280. \subsection{Topology}
  281. Two different network arrangements are allowed, called the star topology and
  282. the peer-to-peer topology. As the name suggests, the star topology forms a
  283. 'star' because every node connects to the same router, also called the
  284. \gls{pan} coordinator. The single \gls{pan} coordinator handles all the message
  285. routing and every node participating in the network requires a connection to
  286. it, as visualized in figure \ref{fig:topstar}. This brings simplicity because
  287. it eliminates the need for routing algorithms, but also looses the ability to
  288. cover wider areas.
  289. The peer-to-peer topology forms a mesh, which basically means that all routers
  290. connect to all other routers in range. A mesh is visualized in figure
  291. \ref{fig:topmesh}. This implies that a router has to handle not only its
  292. children, but also maintains a table of its neighbouring routers. This topology
  293. grants more redundancy to the network infrastructure but also brings more
  294. complexity. Message routing algorithms for finding the best path between two
  295. routers are required, but the network can span over a bigger area compared to
  296. the star topology. Thread uses the distance-vector routing protocol to find the
  297. ideal path between non adjacent routers \cite[112]{thread_spec}.
  298. Both topologies deploy a single \gls{pan} coordinator which acts as
  299. the leader in infrastructure questions. It decides on new addresses, allows
  300. or denies new routers in a mesh network or sets the \gls{pan} prefix, to
  301. name only a few tasks.
  302. %\todo{verify this}
  303. \begin{figure}
  304. \begin{subfigure}{0.4\textwidth}
  305. \includegraphics[width=\textwidth]{images/802_15_4_topologie_star.png}
  306. \caption{The star topology as set in the 802.15.4 standard.}
  307. \label{fig:topstar}
  308. \end{subfigure}
  309. \qquad
  310. \begin{subfigure}{0.4\textwidth}
  311. \includegraphics[width=\textwidth]{images/802_15_4_topologie_mesh.png}
  312. \caption{The mesh, or peer-to-peer topology allows networks to cover a bigger
  313. area compared to the star topology. In the top right, there is a \gls{ffd}
  314. that is not yet a router, because there is no need for it.}
  315. \label{fig:topmesh}
  316. \end{subfigure}
  317. \end{figure}
  318. \subsection{Network Structure}
  319. Two different device types are specified, a \gls{ffd} and a \gls{rfd}.
  320. \glspl{ffd} build the network. In the case of a star topology, one \gls{ffd}
  321. assumes the role of the sole router and the \gls{pan} coordinator. It handles
  322. message routing, coordinates new nodes wanting to join the network and is also
  323. responsible for the connection to the Internet if available. If the sole router
  324. breaks, any other \gls{ffd} that already joined the network can compete for the
  325. role as the new router and \gls{pan} coordinator.
  326. The peer-to-peer topology, also called mesh, utilizes more than just one router
  327. \cite[47]{802_15_4_std}. Redundancy is achieved by simply deploying more than
  328. one device for the same task. If a router breaks, all of its connected children
  329. will try to reconnect to the network using another router in reach. If there
  330. was a \gls{ffd} amongst the orphaned children, it will attempt to promote
  331. itself to a router, replacing the failed node.
  332. If the network does not require another router, the \gls{ffd} may simply
  333. work as an end node. It then waits until, for example, it receives a join
  334. request from a \gls{rfd}, in that case it asks for a promotion to router status
  335. from the \gls{pan} coordinator and subsequently adds the new node as its child.
  336. A \gls{rfd}, as already mentioned, fully depends on \glspl{ffd} for a working
  337. network infrastructure. In order to join a network a router or a \gls{ffd} that
  338. is not yet a router needs to be in range. Since \glspl{rfd} are not important
  339. to the network structure they can operate on much less power.
  340. \section{Messages} \label{802_15_4_messages}
  341. In an effort to ensure delivery over the generally unreliable nature of a
  342. wireless \gls{phy} layer, 802.15.4 specifies special acknowledge frames
  343. \cite[105]{802_15_4_std}. If the transmitting device requests a frame to be
  344. acknowledged by the receiving side, the receiver shall indicate through the so
  345. called \gls{ack} frame that the frame was correctly received. The standard sets
  346. a timeout within which the \gls{ack} has to be received, otherwise the frame is
  347. re-transmitted for a set amount of retries. If no \gls{ack} is received and all
  348. retries have been exhausted, the transmission of the frame fails.
  349. %TODO kinda weird here, if not needed leave it
  350. %A message for a Reduced-function Device has to be polled by the device itself
  351. %which allows it to sleep, as the router will buffer all communication. As a
  352. %consequence, every router has to be capable of storing messages long enough for
  353. %its children to wake up again.
  354. Regarding security, messages may be encrypted using symmetric keys and can be
  355. authenticated using a cryptographic block cipher. \cite[360]{802_15_4_std} The
  356. standard does not set how the keys may be exchanged, but defines how messages
  357. are to be encrypted on the \gls{mac} layer.
  358. \section{6LoWPAN}
  359. %Providing internet access to the network of sensors is achieved by extending
  360. %IPv6 to work with 802.15.4. This adaption problem concentrates on the fact that
  361. %the Maximum Transmission Unit (MTU) of IPv6 is required to be 1280 bytes and
  362. %the MTU of 802.15.4 is only 128 bytes. This means, that some sort of adaption
  363. %layer between the Network layer (IP) and the Mac layer is needed to handle
  364. %fragmentation and reassembly, which is where 6LoWPAN comes in.
  365. %6LoWPAN, or "IPv6 over Low-Power Wireless Personal Area
  366. %Networks" \cite{rfc4919} specifies how the bigger IPv6 packets are delivered
  367. %over the 802.15.4 network.
  368. So far a structure for point-to-point communication was defined. Messages can
  369. be delivered to neighboring nodes, but up to now there is no concept of message
  370. routing to nodes with no direct line of communication. Considering that a
  371. connection to the Internet is a requirement, \gls{ipv6} seems like a good
  372. candidate for the network layer. Since \gls{ipv6} is expected to take a
  373. significant portion of all Internet traffic by 2019,
  374. \cite{Czyz:2014:MIA:2740070.2626295} and distributed low power networks
  375. typically exhibit a large amount of devices, \gls{ipv6} proved to be the
  376. better choice over \gls{ipv4}. Its large address space allows for an individual
  377. address assigned to every node and eliminates the need for subnets.
  378. % TODO HC is more important than fragmentation
  379. The main problem \gls{6lowpan} solves, is that the \gls{mtu} of
  380. \gls{ipv6} is 1280 bytes while the 802.15.4 can only send 127 bytes at once.
  381. Using a conventional link, a full \gls{ipv6} packet could be sent on the
  382. \gls{phy} layer in one go, but on 802.15.4 it needs to be split up. This
  383. imposes longer latency for larger packets, which is justified by the assumption
  384. that \gls{6lowpan} networks are expected to rather send small packets
  385. periodically anyway \cite[5]{rfc4944}. This nevertheless calls for an adaption
  386. layer between 802.15.4 and \gls{ipv6}, \gls{6lowpan} to take care of efficient
  387. packet fragmentation, packet routing and compression. Since 802.15.4 reaches up
  388. to the \gls{osi} model layer 2 and \gls{ipv6} operates on layer 3,
  389. \gls{6lowpan} bridges the gap in the middle of those two.
  390. \subsection{Fragmentation and Reassembly}
  391. If an \gls{ipv6} packet is too big to be sent in one go, it will be split into
  392. multiple fragments that are sent independently. On the receiver side, the
  393. fragments are reassembled and presented as one packet to the next layer. This
  394. is achieved by preceding the packet with a fragmentation header which contains
  395. the index of the fragment and the total size of the packet. Allowing the
  396. receiver to efficiently assemble the whole packet even if the fragments arrive
  397. out of order \cite[p.~11]{rfc4944}. In contrast to \gls{ipv4}, the \gls{mtu} in
  398. 802.15.4 networks is guaranteed to be 127 bytes on every link which allows
  399. every router to forward a fragment without fully assembling it. Figure
  400. \ref{fig:6lowpan_frag} shows a fragmented \gls{6lowpan} packet with a \gls{udp}
  401. payload.
  402. \begin{figure}
  403. \centering
  404. \includegraphics[width=0.8\linewidth]{images/6lowpan_frag.png}
  405. \caption{Boxes sharing the same border color also share the same information.
  406. The first bar shows the \gls{ipv6} frame, the second and the last bar model
  407. the first and the last fragment of the fragmented \gls{ipv6} packet.}
  408. \label{fig:6lowpan_frag}
  409. \end{figure}
  410. \subsection{Header compression}
  411. Some assumptions about the \gls{pan} allow \gls{6lowpan} to strip the
  412. \gls{ipv6} header down to just the necessary information. In the best case,
  413. assuming a link local communication, the 40 bytes \gls{ipv6} header can be
  414. compressed to just 2 bytes. If the packet has to pass multiple routers on its
  415. way to the destination, a special mesh header is required. In this case, the
  416. total \gls{6lowpan} header can be as small as 7 bytes. Providing further
  417. compression, the following \gls{udp}, \gls{tcp} or \gls{icmp} headers may also
  418. be reduced in size. \cite[p.~19]{rfc4944}
  419. If the message is larger than the \gls{mtu} of 802.15.4, the \gls{6lowpan}
  420. fragmentation header introduces only 3 bytes resulting in a 5 byte overhead. A
  421. small packet travelling just in the mesh network consists of a mesh header and
  422. the compressed \gls{ipv6} header, adding up to only 6 bytes.
  423. \cite{Mulligan:2007:ARC:1278972.1278992}
  424. \subsection{Link Layer Packet forwarding}
  425. As the mesh header of a packet is transmitted first, intermediate routers may
  426. need to forward the packet to the next stop at the link layer. This saves time
  427. as the upper layers do not have to be consulted. In figure
  428. \ref{fig:6lowpan_frag}, it can be seen that the mesh header also precedes
  429. fragmented packets and thus allows link layer forwarding.
  430. \section{Thread}
  431. With \gls{6lowpan} providing means of addressing nodes in and outside of a
  432. network, only a protocol for building and maintaining the network is missing.
  433. Thread fills this gap and provides features like self healing, nearly automated
  434. network joining, full data encryption and \gls{udp} plus optionally
  435. \gls{tcp} as a transport layer.
  436. \subsection{Devices}
  437. In addition to the \gls{ffd} and the \gls{rfd}, Thread utilizes three
  438. more devices types. A Network Leader, a \gls{reed} and a Border Router.
  439. The \gls{rfd} is simply renamed to a \gls{sed}. Before a network
  440. becomes usable, all the routers participating will elect a Network Leader among
  441. them. The leader takes decisions for the whole network, such as which address a
  442. new node receives or if a \gls{reed} gets promoted to a router. A typical
  443. Thread network imposes a limit of 32 routers. A \gls{reed} can ask the
  444. Network Leader to be promoted if another node tries to join the network using
  445. that \gls{reed} as a parent. In the same manner, if all children of a
  446. router have disconnected, it will be downgraded to a \gls{reed} again.
  447. The Border Router typically utilizes different hardware compared to the other
  448. Thread devices, as it is also connected to some other network. In most cases,
  449. this works over Wi-Fi or Ethernet. A Border Router also routes messages within
  450. the mesh network as it still is a complete router. Thread allows for more than
  451. one Border Router.
  452. \subsection{Network Structure}
  453. Children of a router can be either \glspl{reed} or \glspl{sed} The latter
  454. received their name because they are allowed to sleep for short time frames to
  455. save energy and typically run on battery.
  456. Thread networks form a mesh, as illustrated in figure \ref{fig:topmesh}, which
  457. grants redundancy for certain nodes. A network consisting of just one router
  458. and multiple \gls{sed}s simply turns into a star topology. If the router
  459. representing the parent of a \gls{sed} breaks, the \gls{sed} can and will
  460. connect to another router or \gls{reed} in its range. This happens
  461. automatically without the need for user interaction. Even if the acting
  462. Network Leader breaks, the other routers will elect a new one among them.
  463. To form the network in the first place, Thread employs special messages called
  464. \gls{mle} messages. These are used to discover neighbors, test link quality
  465. and distribute route configuration. The link quality in Thread is not
  466. necessarily reflexive. This means that in a 802.15.4 network the link quality
  467. from device A to B may differ from the link quality from B to A. As a result,
  468. Thread can choose to route messages from B to A over an intermediate router and
  469. ensure safe delivery. \gls{mle} messages are not just used during the
  470. setup, but periodically utilized allowing the network to adjust dynamically.
  471. \subsection{Transport Layer}
  472. To actually deliver messages, every Thread device has to provide a
  473. \gls{udp} implementation, the \gls{tcp} implementation is optional.
  474. Starting with the authentication process, all communication in the network is
  475. encrypted. Every device "must be specifically authenticated and authorized" to
  476. join the network and complete a \gls{tls} handshake to agree on a common key
  477. \cite{thread_spec}. All further communication is then secured with a network
  478. key.
  479. \section{Zolertia Z1}
  480. The Zolertia Z1 mote data sheet was released in March 2010 and predates the
  481. initial release of Thread by 5 years. The equipped hardware on the board also
  482. dates back to the earlier stages of embedded systems with a wireless
  483. connection. Its most important feature is the CC2420 chip from Texas
  484. Instruments which brings full 802.15.4-compliant radio communication. The Z1
  485. allows up to 92 KB of program logic to be stored in flash memory, and provides
  486. 8 kB of RAM. The data sheet states that the chip brings 16 MB of flash, but the
  487. linker script provided by the manufacturer only provided 92 KB. As no further
  488. time was spent in investigating this discrepancy, the 92 KB of memory are
  489. assumed. The Z1 features a TI MSP430 16 bit \gls{mcu} with up to 16 MHz clock
  490. speed.
  491. In comparison, the TI CC2538 32 bit \gls{mcu}, a device \gls{ot} already
  492. supports, features 32 kB of RAM, 512 kB of flash memory and a Cortex M3. All
  493. further already ported platforms also feature a 32 bit \gls{mcu} which hints
  494. the first complications concerning the 16 bit Z1 platform.
  495. \begin{figure}
  496. \includegraphics[width=0.65\linewidth]{images/Z1.jpg}
  497. \caption{Zolertia Z1 mote, the silver plate on the right covers the radio
  498. chip. Image taken from \cite{Z1}}
  499. \label{fig:Z1}
  500. \end{figure}
  501. \chapter{Methodology}
  502. Projects such as the \gls{ot} stack utilize a \gls{hal}, which allows a
  503. developer to assume a reasonable hardware interface and write the application
  504. against it. To actually build the executable, a specific \gls{hal} is chosen
  505. that maps the abstract interface to an actual hardware.
  506. Obvious advantages are less code duplication and the core logic of the
  507. application is less exposed to errors as it may be tested independently. It is
  508. also easier to distribute the same application to a variety of hardware without
  509. any modifications. For example, Google utilizes a \gls{hal} to distribute
  510. Android to different cellphones.
  511. The \gls{hal} of the \gls{ot} stack includes access to a 802.15.4 capable
  512. radio chip, non-volatile memory, hardware timers and various communication
  513. interfaces.
  514. \section{Tools}
  515. This section lists all the tools used and developed over the course of this
  516. thesis.
  517. \subsection{Linker Map Analyzer}
  518. In order to analyze the memory issues encountered during the development of
  519. the solution, a Linker Map Analyzer was developed
  520. \footnote{\url{https://notabug.org/agentcoffee/stats}}. Using Python, it parses
  521. all information present in the map file and stores it in a two dimensional
  522. linked list. It is then possible to run queries over the sections of the
  523. resulting hex file.
  524. For example, just a specific section may be printed, all sections in
  525. \texttt{.text} sorted by size, or just one function. This example is visualised
  526. in listing \ref{fig:link_analyzer}. The output of the linker map analyzer
  527. allowed for a estimate of how many functions need to be removed in order to fit
  528. the implementation into the provided flash.
  529. %0x380 text ot::Lowpan::Lowpan::Compress(ot::Message&, ot::Mac::Address const&, ot::Mac::Address const&, unsigned char*)
  530. %0x402 text _printf_i
  531. %0x406 text ot::Mle::Mle::HandleParentResponse(ot::Message const&, ot::Ip6::MessageInfo const&, unsigned long)
  532. %0x428 text addSetting.isra.1
  533. %0x43a text ot::Cli::Interpreter::ProcessCounters(int, char**)
  534. %0x48c text ot::Mle::Mle::HandleUdpReceive(ot::Message&, ot::Ip6::MessageInfo const&)
  535. %0x4a2 text ot::Lowpan::Lowpan::DecompressBaseHeader(ot::Ip6::Header&, ot::Mac::Address const&, ot::Mac::Address const&, unsigned char const*, unsigned short)
  536. %0x4e0 text mbedtls_sha256_process
  537. %text: 0x18356(99158), listed: 0x18356(99158)
  538. %
  539. %Section table:
  540. %...
  541. %0x1602 bss
  542. %0x161b rodata
  543. %0x18356 text
  544. \begin{lstlisting}[
  545. caption={A sample output of the script with the arguments \texttt{-f
  546. ot-cli-mtd.map -p -o -t -s text}. The number behind \texttt{text:} states
  547. the current size of the \texttt{.text} section which itself is bigger than
  548. the available flash memory in the Z1. The \texttt{\_printf\_i} corresponds
  549. to the newlib implementation of the c library that is more memory
  550. efficient. It is also interesting that two \gls{6lowpan} functions are
  551. under the top eight biggest functions. The arguments taken by the functions
  552. have been removed in order to maintain readability.},
  553. label={fig:link_analyzer},
  554. captionpos=b
  555. ]
  556. ...
  557. 0x380 text ot::Lowpan::Lowpan::Compress(...)
  558. 0x402 text _printf_i
  559. 0x406 text ot::Mle::Mle::HandleParentResponse(...)
  560. 0x428 text addSetting.isra.1
  561. 0x43a text ot::Cli::Interpreter::ProcessCounters(...)
  562. 0x48c text ot::Mle::Mle::HandleUdpReceive(...)
  563. 0x4a2 text ot::Lowpan::Lowpan::DecompressBaseHeader(...)
  564. 0x4e0 text mbedtls_sha256_process
  565. text: 0x18356(99158), listed: 0x18356(99158)
  566. Section table:
  567. ...
  568. 0x1602 bss
  569. 0x161b rodata
  570. 0x18356 text
  571. \end{lstlisting}
  572. Running on Python 3.7, the script reads one linker map file and analyzes it
  573. according to the arguments given. Obtaining the linker map file may be achieved
  574. by invoking the linker with the argument \texttt{-Map=linker\_map\_file}. Usage
  575. of the script is provided in table \ref{fig:link_analyzer_usage}.
  576. \begin{table}
  577. \begin{tabularx}{\textwidth}{l | X}
  578. \multicolumn{2}{l}{\texttt{stats.py -f out.map [-p [-s text] [-i
  579. otMle] [-o]] [-t]}} \\ \hline
  580. \texttt{-p} & Prints all the entries in the linker map matching the selection
  581. criteria. \\
  582. \texttt{-s <section>} & Selects just entries in the specified section. \\
  583. \texttt{-i <object>} & Selects just entries that, in a C++ manner, are
  584. instantiated from object. This allows for example, listing all functions
  585. in the object Mle (Mesh Link Establishment). \\
  586. \texttt{-o} & Orders (sorts) all selected entries by size. \\
  587. \texttt{-t} & Prints a table of all sections with their size at the very end. \\
  588. \end{tabularx}
  589. \caption{The usage of the linker map analyzer explained in more detail.}
  590. \label{fig:link_analyzer_usage}
  591. \end{table}
  592. \subsection{Flashing}
  593. The Z1 flash is written using a python script written by Chris Liechti and
  594. taken from the contiki project
  595. \footnote{\url{https://github.com/contiki-os/contiki/tree/master/tools/zolertia}}.
  596. The script is also hosted at the implementation mirror.
  597. \section{Settings} \label{settings}
  598. This section lists all the settings necessary for the implementation.
  599. \subsection{Compiler Flags}
  600. To compile the project, the MSPGCC-TI version 5.01.02.00 was used.
  601. The \gls{ot} project used the following arguments to invoke the compiler.
  602. \begin{tabularx}{\textwidth}{r X}
  603. \texttt{COMMONCFLAGS} & \texttt{-DNDEBUG -minrt -mlare -mmcu=msp430f2617
  604. -mhwmult=16bit -I/usr/msp430-elf/include -L/usr/msp430-elf/lib/large -g
  605. -fdata-sections -ffunction-sections -Os} \\
  606. \texttt{CFLAGS} & \texttt{-Wall -Wextra -Wshadow -std=c99 \$COMMONCFLAGS} \\
  607. \texttt{CXXFLAGS} & \texttt{-Wall -Wextra -Wshadow -std=gnu++11 -Wno-c++14-compat
  608. \$COMMONCFLAGS} \\
  609. \texttt{LDFLAGS} & \texttt{-Wl,--gc-sections -nostartfiles \$COMMONCFLAGS} \\
  610. \end{tabularx}
  611. The Server/Client implementation then used the following arguments to run the
  612. compiler.
  613. \begin{tabularx}{\textwidth}{r X}
  614. \texttt{CFLAGS} & \texttt{-Os -g -mmcu=msp430f2617 -Wall -Wpedantic
  615. -fpack-struct -std=c99 -Iinclude/ -I/opt/ti/mspgcc/include
  616. -Wl,-Map=out.map"}
  617. \end{tabularx}
  618. \subsection{\gls{uart} settings}
  619. A Linux system was used to develop the software for the Z1 and control the
  620. device. The necessary configuration is set using \texttt{stty}, short for set
  621. teletype, as can be seen in listing \ref{fig:stty}. The \texttt{stty} program
  622. is part of the GNU Coreutils package
  623. \footnote{\url{https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=tree;f=src;h=938a6f26722ec723c52a9b88b490761b8f42c281;hb=HEAD}}.
  624. \begin{lstlisting}[
  625. caption={The options to configure the serial device for usage on the host.
  626. The \texttt{/dev/ttyS0} corresponds to the actual serial device. The baud
  627. rate is set to 115200. The option \texttt{min 1} tells the serial driver to
  628. wait for at least one character before returning. Specifying
  629. \texttt{-parenb} disables the generation of a parity bit. The
  630. \texttt{crtscts} option enables flow control.},
  631. label={fig:stty},
  632. captionpos=b]
  633. stty -F /dev/ttyS0 115200 min 1 -parenb crtscts
  634. \end{lstlisting}
  635. \subsection{\gls{ot} version} \label{ot_version}
  636. The \gls{ot} source code was initially cloned from the original git repository
  637. \footnote{\url{https://github.com/openthread/openthread/tree/6805cfa81e181cf35770d0f24cb42cbb86a88594}}.
  638. As changes had to be incorporated into the \gls{ot} core itself, the whole
  639. repository is also hosted in a git repository
  640. \footnote{\url{git@notabug.org:agentcoffee/openthread.git}} at the last commit
  641. for this thesis.
  642. \begin{figure} \includegraphics[width=\linewidth]{images/test_setup.jpg}
  643. \caption{The test setup. The two devices are connected and powered via
  644. common micro \gls{usb} cables.}
  645. \label{fig:test_setup}
  646. \end{figure}
  647. \section{Evaluation} \label{evaluation}
  648. In accordance to the procedure given by \gls{ot} in \cite{ot:cert} to validate
  649. a new \gls{hal} port, the implementation is evaluated through the following 4
  650. steps.
  651. \begin{enumerate}
  652. \item Interaction with the command line interface. This point is fulfilled
  653. by executing a few commands, which is done during the next few points
  654. anyway.
  655. \item Building a Thread network and joining it with another device. By
  656. powering one device alone, it detects that no other Thread network is
  657. already present and shall start a new one. Powering the second device,
  658. it should detect the already present Thread network and attempt to
  659. join. After successfully becoming a child node, the second device
  660. shall be promoted to a router.
  661. \item Transmission speed. By sending seven \gls{icmp} echo requests from
  662. one device to the other, the transmission speed is measured. The
  663. \gls{rtt} is chosen as the method of evaluation. \gls{rtt} measures
  664. the time a packet is traveling from point A to B and the time it takes
  665. for B to acknowledge the reception of the packet. In case of layer 3 in
  666. the \gls{osi} model, the acknowledge does not happen with an \gls{ack}
  667. frame, but with the same \gls{icmp} message.
  668. \item Re-attaching after a reset. After joining the Thread network, the
  669. second device saves information about the currently joined Thread
  670. network in its non-volatile storage. After resetting the device, it
  671. shall automatically rejoin the same Thread network without user
  672. intervention.
  673. \end{enumerate}
  674. \chapter{Implementation}
  675. In this chapter, two different approaches to achieve the goal stated are
  676. presented.
  677. The direct port tries to run the \gls{ot} stack directly on the Z1 by simply
  678. implementing a suitable \gls{hal}. This is the intended way of porting \gls{ot}
  679. to another hardware. After encountering various obstacles as described in
  680. \ref{first_approach}, a second approach to achieve is taken.
  681. The host / client oriented approach involves rewriting the \gls{hal} of the
  682. \gls{posix} implementation already provided by Nest to work with the CC2420
  683. chip on the Z1. This means developing a protocol over a \gls{uart} connection
  684. and a receiving logic on the Z1 that handles the communication with the CC2420,
  685. which is described in detail under section \ref{second_approach}.
  686. \section{Direct Port} \label{first_approach}
  687. This section details the challenges and possible solutions encountered while
  688. trying to port the \gls{ot} stack directly on to the Z1.
  689. \begin{enumerate}
  690. \item The first problem that appears are predefined enums. Since a lot of
  691. static values are hard coded in such enums, and not in
  692. \texttt{\#defines}, the compiler tries to place them into
  693. \texttt{int}s that correspond to 16 bits on the Z1. Unfortunately, a
  694. lot of bit masks and values are bigger than $2^{16}$ which requires
  695. them to either be rewritten, or compiled with a C++ compiler, as C++
  696. allows sized enums in its standard. This turns out to be a solvable
  697. challenge, although multiple files that are not part of the \gls{hal}
  698. have to be rewritten.
  699. \item Furthermore, the flash memory of the Z1 is divided into two parts.
  700. This is due to the fact that the original instruction set architecture
  701. on the 16 bit processor was only able to address $2^{16} = 65536$ bytes
  702. of flash memory but the Z1 provides $93884$ bytes. This led to the
  703. modification of the instruction set architecture to allow 20 bit
  704. pointers, which are able to span the whole flash memory. The interrupt
  705. routine could not follow the update, and so the interrupt vector has to
  706. sit at the top of the $2^{16}$ byte flash and thus divides the whole
  707. flash into two parts.
  708. The relevant parts of the linker file may be seen in figure
  709. \ref{fig:z1mem}. This rather unusual setup is not fully supported by
  710. the compiler, and no real bin packing for sections is implemented. It
  711. is possible to place whole sections in either region, but this does not
  712. utilize the flash to its fullest potential. This implies that either
  713. the project is small enough to fit in either region, or it is
  714. sufficient that just the \texttt{.data} section goes in the upper flash
  715. region, which is supported by the compiler. It is definitely possible
  716. to assign each function section into either flash region, but this
  717. requires a hard coded linker file and is not really optimal for ongoing
  718. development.
  719. \item The 8 KB of RAM are mostly consumed by two 5352 bytes large state
  720. objects, that hold the complete state of the \gls{ot} stack. This
  721. leaves about 2840 bytes for the whole stack and heap. Further, all
  722. already supported devices feature at least 28 KB of RAM. To ensure
  723. correct functionality, memory checks to avoid stack and heap corruption
  724. would have been required.
  725. \item To provide encryption, Thread includes the size-optimised
  726. \texttt{mbedtls}\footnote{\url{https://tls.mbed.org/}} library. As the
  727. CC2420 network chip on the Z1 provides a hardware implementation for
  728. the used Counter with CBC-MAC algorithm, this library was replaced by
  729. an interface to the CC2420 encryption capabilities.
  730. \item As the \gls{ot} stack uses the standard \texttt{printf}
  731. implementation to format strings, the much smaller newlib
  732. \footnote{\url{https://sourceware.org/newlib/}} was included which
  733. provides the size-optimised \texttt{iprintf} function which was used
  734. instead of the standard \texttt{printf}.
  735. \end{enumerate}
  736. Over the course of developing the \gls{hal} for the direct port, it turns out
  737. that just the default example application already exceeds the available flash
  738. memory on the Z1, even with all the size optimistions mentioned above.
  739. To visualize the issue of memory limitation, the linker map analyzer already
  740. introduced in section \ref{fig:link_analyzer_usage} comes in handy. As the
  741. biggest sections all correspond to functions that are essential to the correct
  742. operation of \gls{ot}, which can be seen in listing \ref{fig:link_analyzer}, a
  743. greater amount of smaller functions would have to be removed. This is possible,
  744. but stripping the \gls{ot} project in size while also keeping some core
  745. functionality alive, requires deeper knowledge of the \gls{ot} implementation.
  746. This led to the conclusion that porting the \gls{ot} stack directly onto the Z1
  747. presents challenges that exceed the workload assigned for this thesis. As a
  748. result to this conclusion, another approach to reaching the goal stated is
  749. taken.
  750. \begin{figure}
  751. \begin{lstlisting}
  752. MEMORY {
  753. ...
  754. RAM : ORIGIN=0x1100, LENGTH=0x2000 /* END=0x30FF, size 8192 */
  755. ...
  756. ROM (rx) : ORIGIN=0x3100, LENGTH=0xCEBE /* END=0xFFBD, size 52926 */
  757. HIROM (rx) : ORIGIN=0x10000, LENGTH=0x9FFF /* END=0x19FFF, size 40958 */
  758. ...
  759. VECT1 : ORIGIN=0xFFC0, LENGTH=0x0002
  760. ...
  761. VECT31 : ORIGIN=0xFFFC, LENGTH=0x0002
  762. RESETVEC : ORIGIN=0xFFFE, LENGTH=0x0002
  763. }
  764. \end{lstlisting}
  765. \caption{The memory segment of the linker file for the TI MSP430. Non relevant
  766. parts have been replaced by dots. It can be observed that the Read only
  767. Memory (\texttt{ROM}), or Flash Memory, is cut by the interrupt vectors
  768. from 1 to 31 and \texttt{RESETVEC} and ultimately continues in section
  769. \texttt{HIROM}. The total size of the \texttt{ROM} and \texttt{HIROM}
  770. section is 93884 bytes.}
  771. \label{fig:z1mem}
  772. \end{figure}
  773. \section{Host / Client oriented Port} \label{second_approach}
  774. The result for this thesis consists of a small protocol on top of the
  775. \gls{uart} connection that, in combination with the Z1, allows the 802.15.4
  776. compatible radio to be controlled. The device runs a small server controlling
  777. the radio chip and providing access to received data. This setup is compareable
  778. to an external 802.15.4 compatible \gls{usb} antenna. An existing \gls{ot}
  779. \gls{hal} implementation was convinced to talk with the new antenna and is thus
  780. theoretically able to participate in an actual \gls{ot} network.
  781. The so called host runs all the \gls{ot} logic and sends data to the
  782. device, in this case the Z1. In the concept of splitting the radio controller
  783. and the \gls{ot} logic onto two different devices the radio controller, or
  784. device, is also called network co-processor. Thread mentions this concept but
  785. uses a different protocol to control the device. As no documentation or actual
  786. implementation can be found, the protocol described in the following section is
  787. developed \cite{ot:hostcontr}.
  788. \begin{figure}
  789. \includegraphics[width=\linewidth]{images/implementation_structure.png}
  790. \caption{Implementation overview. All the parts in red have been implemented
  791. over the course of this thesis.}
  792. \label{fig:impl_ovw}
  793. \end{figure}
  794. \subsection{Protocol}
  795. Sending one command and a variable-size payload, the protocol can be seen as a
  796. memory interface. The command corresponds to the memory location, the data
  797. represents the data to be written there. As no extra information is
  798. transmitted, no additional features such as error correction or automatic
  799. retransmission are provided. Such extension may easily be added, but is out of
  800. the scope of this thesis.
  801. The underlying \gls{uart} transmits with a baudrate of 115200 baud, no
  802. parity, one stop and one start bit. A frame of the protocol contains the size
  803. of the data, the command and at most 255 bytes of data. The size information
  804. being sent first allows for easier assembly on the receiving part. As just one
  805. byte is reserved for commands or memory addresses, up to 256 commands could be
  806. implemented, although only a few are currently available. For a list of
  807. commands, see table \ref{tab:prot_cmds}.
  808. %TODO write data length taken
  809. \begin{table}
  810. \begin{center}
  811. \begin{tabular}{l|l|l|l|}
  812. \cline{2-4}
  813. Bytes: & $1$ & $1$ & $0 \leq n \leq 255$\\ \cline{2-4}
  814. & Size (n) & Command & Data \\
  815. \cline{2-4}
  816. \end{tabular}
  817. \caption{The frame structure of the UART protocol}
  818. \label{tab:prot_frame}
  819. \end{center}
  820. \end{table}
  821. \begin{table} \begin{tabularx}{\textwidth}{l X} Command & Description \\ \hline
  822. %OTPLATRADIOGETIEEEEUI64 & \\
  823. %\hline
  824. OTPLATRADIOSETPANID & Sets the PANID on the CC2420, to enter the specified
  825. 802.15.4 network.\\
  826. \hline
  827. OTPLATRADIOSETEXTENDEDADDRESS & Sets a 802.15.4 extended address for
  828. the source address match feature. See OTPLATRADIOENABLESRCMATCH and
  829. \cite[103]{802_15_4_std}.\\
  830. \hline
  831. OTPLATRADIOSETSHORTADDRESS & Sets the 802.15.4 short address. See
  832. OTPLATRADIOENABLESRCMATCH and \cite[103]{802_15_4_std}\\
  833. \hline
  834. OTPLATRADIOGETSTATE & Returns the debug state of the CC2420 as described in
  835. \cite[43]{cc2420_ds}.\\
  836. \hline
  837. OTPLATRADIOENABLE & Starts the CC2420 from its idle state.\\
  838. \hline
  839. OTPLATRADIODISABLE & Sets the CC2420 into its idle state.\\
  840. \hline
  841. OTPLATRADIOISENABLED & Returns true if the radio is enabled.\\
  842. \hline
  843. OTPLATRADIOSLEEP & Allows the CC2420 to sleep and save power.\\
  844. \hline
  845. OTPLATRADIORECEIVE & Sets the CC2420 explicitly into receive mode.\\
  846. \hline
  847. %OTPLATRADIOENABLESRCMATCH & Controls the Frame Pending bit in
  848. %Acknowledge frames sent to children as described here
  849. %\cite[103]{802_15_4_std}.\\
  850. %\hline
  851. %OTPLATRADIOADDSRCMATCHSHORTENTRY & \\
  852. %\hline
  853. %OTPLATRADIOADDSRCMATCHEXTENTRY & \\
  854. %\hline
  855. %OTPLATRADIOCLEARSRCMATCHSHORTENTRY & \\
  856. %\hline
  857. %OTPLATRADIOCLEARSRCMATCHEXTENTRY & \\
  858. %\hline
  859. %OTPLATRADIOCLEARSRCMATCHSHORTENTRIES & \\
  860. %\hline
  861. %OTPLATRADIOCLEARSRCMATCHEXTENTRIES & \\
  862. %\hline
  863. %OTPLATRADIOGETTRANSMITBUFFER & Not used\\
  864. %\hline
  865. %OTPLATRADIOTRANSMIT & Starts a transmission. This requires the PSDU to be
  866. %already present on the device.\\
  867. %\hline
  868. %OTPLATRADIOGETRSSI & Returns the last measured Received Signal
  869. %Strength
  870. %Indicator (RSSI).\\
  871. %\hline
  872. %OTPLATRADIOGETCAPS & \\
  873. %\hline
  874. %OTPLATRADIOGETTRANSMITPOWER & \\
  875. %\hline
  876. %OTPLATRADIOSETTRANSMITPOWER & \\
  877. %\hline
  878. %OTPLATRADIOGETPROMISCUOUS & Fetches the promiscuous value
  879. %\cite[109]{802_15_4_std}.\\
  880. %\hline
  881. %OTPLATRADIOSETPROMISCUOUS & Sets the promiscuous value
  882. %\cite[109]{802_15_4_std}. A value equal to true instructs the radio to
  883. %pass all frames received to the next layer without any filtering.\\
  884. %\hline
  885. %OTPLATRADIOENERGYSCAN & \\
  886. %\hline
  887. %OTPLATRADIOGETRECEIVESENSITIVITY & Returns the current receive
  888. %sensitivity.\\
  889. %\hline
  890. %RADIOPOLLFRAME & Polls the device if a new frame has been received.\\
  891. %\hline
  892. RADIOSETCHANNEL & \\
  893. \hline
  894. RADIOSETPSDULEN & Sets the length of the \gls{psdu} to
  895. be sent.\\
  896. \hline
  897. RADIOSETPSDU & Sets the actual \gls{psdu}.\\
  898. \hline
  899. %OTPLATRADIORECEIVEDONE & \\
  900. %\hline
  901. %OTPLATRADIOTXSTARTED & \\
  902. %\hline
  903. %OTPLATRADIOTXDONE & \\
  904. %\hline
  905. %OTPLATDIAGRADIOTRANSMITDONE & \\
  906. %\hline
  907. %OTPLATDIAGRADIORECEIVEDONE & \\
  908. %\hline
  909. %OTPLATRADIOENERGYSCANDONE & \\
  910. %\hline
  911. \end{tabularx}
  912. \caption{The commands implemented by the protocol.}
  913. \label{tab:prot_cmds}
  914. \end{table}
  915. \subsection{Host} \label{impl_16ms}
  916. The host runs the logic of the \gls{ot} stack. As the \gls{hal}
  917. implementation for \gls{posix}-compliant platforms already exists, it can be
  918. simply adapted to forward the relevant data to the client. The reference
  919. implementation utilizes sockets to send data between different \gls{ot}
  920. processes on the same system. This implementation enables the data to be sent
  921. over the air using the Z1 mote and allows the host to take part in an actual
  922. \gls{ot} network.
  923. % TODO elaborate?
  924. This is achieved by cutting the \gls{ot} stack in the radio implementation and
  925. rewriting the necessary functions to send information via the \gls{uart} bridge
  926. to the device. Communication with the device is only done where necessary, if
  927. information that is already available on the host side allows the function to
  928. finish, then no communication is taking place.
  929. The existing socket design already requires the whole \gls{psdu} to be
  930. constructed on the host which is then simply sent to the device. The payload of
  931. the \gls{psdu} is encrypted on the host using the \texttt{mbedtls} library.
  932. As the \gls{ot} stack requires an \gls{ack} (see section
  933. \ref{802_15_4_messages}) to be received within the following 16 milliseconds
  934. after sending a frame, the \gls{ack} timeout has been raised to 40
  935. milliseconds. In an attempt to minimise the overhead, the device already sends
  936. \gls{ack} frames itself and instantly transfers the message to the host. In
  937. theory, 16 milliseconds are enough for the acknowledge to reach the
  938. transmitter, but altering it to 40 milliseconds allows for a much stabler
  939. usage.
  940. %TODO say something about usage and ref results
  941. The host implementation with the corresponding \gls{hal} may be found at
  942. section \ref{ot_version}.
  943. \subsection{Device}
  944. The device starts by initialising all the necessary components on the Z1 board.
  945. As the Z1 board features an adjustable oscillator, an iterative algorithm
  946. anneals the desired 8 MHz CPU frequency. Once the \gls{spi} and the \gls{uart}
  947. are running, the CC2420 is initialised.
  948. With the periphery set up, the device waits for a command to be received over
  949. the \gls{uart} bridge. As soon as a full command is available, it is
  950. executed. In the regular case, this involves sending data to the CC2420. If
  951. the CC2420 receives a frame, it will alert the chip through an interrupt which
  952. schedules a read from the CC2420. The chip then copies the frame into an
  953. internal ring buffer and immediately transmits it to the host. The computer
  954. running the \gls{ot} logic will buffer the data sent in the serial pipe and
  955. serve it once needed. This immediately clears the internal buffer of the
  956. CC2420, as it only has enough space for 127 bytes.
  957. The receiving module on the device is structured into 3 different buffers as
  958. visualised in figure \ref{fig:buffer_system}.
  959. \begin{enumerate}
  960. \item The first buffer is a standard ring buffer. The \gls{uart} receive
  961. interrupt fills it with incoming bytes. If it detects that the next byte
  962. will overflow the ring buffer, the \gls{cts} line is asserted,
  963. indicating to the host that no more bytes may be sent. As soon as space
  964. is available again in the ring buffer, the \gls{cts} line is released
  965. again. This guarantees that no data is lost and the execution is not
  966. stalled for longer than necessary.
  967. \item The second buffer slowly assembles a full command. The main loop
  968. periodically dispatches a routine that empties all available bytes from the
  969. ring buffer into the second buffer. As soon as the command is completed
  970. in the second buffer, it is copied into the third buffer and executed.
  971. This allows the next command to be assembled while executing. As the
  972. first byte in every telegram contains the length of the variable data
  973. section \ref{tab:prot_frame}, it is used to detect when the whole
  974. command is received.
  975. \item From the third buffer, the received instruction is executed. If said
  976. command requires data to be sent back, the information in question is
  977. handed to an asynchronous sending routine. This second interrupt driven
  978. routine transmits the data back to the host, where it is buffered in
  979. the serial file descriptor.
  980. %This function handles all communication with the CC2420 chip.
  981. \end{enumerate}
  982. %The protocol employs two buffers, a ringbuffer and a command buffer. While a
  983. %\gls{uart} interrupt routine fills the ringbuffer with incoming bytes, a
  984. %periodically called receive function assembles the full command in the second
  985. %buffer by copying all the available bytes from the ringbuffer into a command
  986. %oriented buffer. This command buffer can hold at least $1+1+255$ bytes. As
  987. %soon as the command in the command buffer is fully assembled, which is checked
  988. %with the \texttt{size} argument given in \ref{tab:prot_frame}, the line is
  989. %copied into a second buffer and executed. This allows a command to be sent
  990. %while the previous is still running.
  991. In theory, the device may stack up to $2$ full commands plus the size of the
  992. ring buffer before the \gls{cts} line is set to logical $1$. As most commands
  993. do not require the maximum data length available, more commands may be stacked
  994. in practice.
  995. In an effort to reduce the overhead of the serial communication, a received
  996. message from the CC2420 is instantly transmitted to the host. The operating
  997. system will then buffer the message and deliver it to the \gls{ot} stack once
  998. needed. This also reduces the overhead of reading the message on the host
  999. side, as the host does not have to wait for the serial communication and is
  1000. just limited by the reading speed on the serial file descriptor.
  1001. If the message received by the CC2420 requires an \gls{ack}, the Z1 will
  1002. instantly acknowledge the reception. The special acknowledge with data pending,
  1003. required for routers with \gls{sed} as children, is not implemented, yet.
  1004. \begin{figure}
  1005. \includegraphics[width=\linewidth]{images/buffer_system.png}
  1006. \caption{The 3 buffer system illustrated in detail. The ring buffer is
  1007. filled by a \gls{uart} interrupt routine and periodically copied into
  1008. the command buffer. If the command is fully assembled in the command buffer,
  1009. it is moved to the executing buffer and executed. In this example, the
  1010. \texttt{RADIOSETPSDULEN (0x1D)} command is currently executed while the
  1011. command \texttt{RADIOSETPSDU (0x1E)} is still being built up in the
  1012. command buffer. As the name says, \texttt{RADIOSETPSDULEN (0x1D)} sets the
  1013. length of the \gls{psdu}, which is also the length of the payload of
  1014. \texttt{RADIOSETPSDU (0x1E)}. The actual \gls{psdu} was set to
  1015. \texttt{0x0A} for illustration purposes.}
  1016. \label{fig:buffer_system}
  1017. \end{figure}
  1018. The complete device implementation is available in a separate repository at
  1019. \footnote{\url{https://notabug.org/agentcoffee/z1_board}}, together with a
  1020. flash script mentioned in section \ref{settings}. It also contains a Makefile
  1021. with targets to compile, flash and reset the Z1.
  1022. \section{Usage}
  1023. The original executable has been extended with a low level debug framework that
  1024. simply prints everything received and sent through the \gls{uart} bridge to a
  1025. file provided through the \texttt{-d} argument. Passing it a pipe, previously
  1026. created with \texttt{mkfifo}, allows observation of the log in real time as can
  1027. be seen in figure \ref{fig:work_setup}. As the original \gls{ot} framework
  1028. sends all logs directly to the system log, the logging framework has been
  1029. modified to write all logs to the file descriptor 3 that has to be piped to a
  1030. file or just \texttt{/dev/null} if it is of no interest. \gls{ot} will not work
  1031. correctly if no pipe is passed.
  1032. After connecting and flashing the Z1, the corresponding character device has to
  1033. be passed to the executable via the \texttt{-f} argument. Additionally, a node
  1034. ID is required, using the \texttt{-n} parameter. The usage is specified in
  1035. table \ref{fig:ot_usage}
  1036. \begin{table}
  1037. \begin{tabularx}{\textwidth}{l | X}
  1038. \multicolumn{2}{l}{\texttt{./ot-cli-ftd -f /dev/ttyUSB0 -n 2 -d
  1039. dbg.fifo}} \\ \hline
  1040. \texttt{-f <device>} & The USB character device of the z1. \\
  1041. \texttt{-n <node id>} & The node ID of this specific node in the
  1042. network.\\
  1043. \texttt{-d <debug pipe>} & A file object the protocol log should be
  1044. written to. If it is not needed /dev/null has to be passed.\\
  1045. \end{tabularx}
  1046. \caption{The usage of the \gls{ot} logic.}
  1047. \label{fig:ot_usage}
  1048. \end{table}
  1049. \begin{figure} \includegraphics[width=\linewidth]{images/work_setup.png}
  1050. \caption{The typical developing setup. The two terminals at the top run the
  1051. \gls{ot} logic. The two terminals at the bottom show the debug output
  1052. of the protocol implementation. Currently, two frames can be seen being
  1053. sent from the left process to the right process via two Zolertia Z1 motes.
  1054. The top two terminals also show the results of four pings.}
  1055. \label{fig:work_setup}
  1056. \end{figure}
  1057. % Evaluation or Discussion if no measurements
  1058. \chapter{Results}
  1059. This thesis presents a functional implementation for the specified protocol
  1060. together with a working \gls{hal} for \gls{ot}. As the implementation is just
  1061. expected to underline the feasibility of such an external network co-processor
  1062. it may still miss features for a full \gls{ot} compliance. For example,
  1063. currently the special acknowledge frame with data pending flag is not
  1064. implemented \cite[152]{802_15_4_std} as this feature is not needed for the
  1065. proof of concept. Adding it is rather straight forward and no further pitfalls
  1066. are expected.
  1067. \section{Evaluation}
  1068. The implementation was evaluated against the tutorial given in
  1069. \cite{ot:tutorial} and defined in subsection \ref{evaluation}. The test setup
  1070. can be seen in figure \ref{fig:test_setup}
  1071. \subsection{Interaction with the command line interface}
  1072. As can be seen in figure \ref{fig:cli_interaction}, the command line works
  1073. fine. The \texttt{help} command lists all available commands. Some of them may
  1074. require additional arguments, a full reference may be found in the official
  1075. \gls{ot} repository
  1076. \footnote{\url{https://github.com/openthread/openthread/blob/master/src/cli/README.md}}.
  1077. \begin{figure}[h!]
  1078. \includegraphics[width=\linewidth]{images/evaluation/help.png}
  1079. \caption{The tail of the \texttt{help} command can be seen. As the command
  1080. line logic of \gls{ot} was not modified, it is expected to work the same as
  1081. before.}
  1082. \label{fig:cli_interaction}
  1083. \end{figure}
  1084. \subsection{Building a Thread network and joining it with another device}
  1085. After powering the first device and letting it establish a Thread network, the
  1086. second device is started. Follwing some negotiation, which usually takes abut 5
  1087. to 10 seconds, one device joins the other. The delay happens because the
  1088. \gls{ack} may miss its time frame and thus invalidates the message, which
  1089. crashes the current joining process. The reason was explained in further detail
  1090. in section \ref{impl_16ms}.
  1091. This may result in device A joining the Thread network of device B, even though
  1092. A was started earlier. This happens because after a failed attempt to join a
  1093. network the joining device assumes that the network has failed and starts its
  1094. own. As soon as the other device notices the presence of the second network, it
  1095. attempts to join. Figure \ref{fig:build_thread_a} shows the joining process
  1096. from the parents view. At first the \texttt{router table} contains only itself,
  1097. because the child is not yet promoted to a router. After some time, the child
  1098. is also promoted and shows up in the \texttt{router table}. One \gls{icmp} echo
  1099. request has been sent and answered and the \texttt{router table} command shows
  1100. that two devices are taking part in this Thread network.
  1101. In figure \ref{fig:build_thread_b}, the same process may be seen from the child
  1102. side. After joining, the device automatically becomes a child and after some
  1103. time it is promoted to a router. One \gls{icmp} echo request has been sent and
  1104. answered. The \texttt{state} command tells us that the device has changed its
  1105. state from child to a router and once the device has been promoted to a router,
  1106. it also maintains a router table.
  1107. \begin{figure}[h!]
  1108. \includegraphics[width=\linewidth]{images/evaluation/ping_a_r.png}
  1109. \caption{This figure shows the leader of the established Thread network as
  1110. can be seen by the output of the \texttt{state} command while another
  1111. device joins the Thread network.}
  1112. \label{fig:build_thread_a}
  1113. \end{figure}
  1114. \begin{figure}[h!]
  1115. \includegraphics[width=\linewidth]{images/evaluation/ping_b_r.png}
  1116. \caption{This figure shows the child joining an existing Thread network.}
  1117. \label{fig:build_thread_b}
  1118. \end{figure}
  1119. \subsection{Transmission speed, \gls{rtt}}
  1120. The seven \gls{icmp} echo requests have been sent within 2 minutes and the
  1121. devices were about 30 centimeters apart. Tables \ref{tab:ping_r_l} and
  1122. \ref{tab:ping_l_r} list the results of the 14 pings.
  1123. The \gls{rtt} from the parent to the child is on average faster here. That
  1124. could imply that in general a router takes less time to answer than the network
  1125. leader. This assumption requires more thorough testing but the fact that a
  1126. network leader has more responsibilities than a router could explain the
  1127. delayed \gls{icmp} response.
  1128. \begin{table}
  1129. \begin{center}
  1130. \begin{tabular}{l|l}
  1131. Sequence & round trip time $(ms)$ \\
  1132. 1 & 1308 \\
  1133. 2 & 1272 \\
  1134. 3 & 1313 \\
  1135. 4 & 1298 \\
  1136. 5 & 1056 \\
  1137. 6 & 1216 \\
  1138. 7 & 1606 \\
  1139. \hline
  1140. Mean & 1295 \\
  1141. \end{tabular}
  1142. \caption{Seven \gls{icmp} echo requests from the child to the parent.}
  1143. \label{tab:ping_r_l}
  1144. \end{center}
  1145. \end{table}
  1146. \begin{table}
  1147. \begin{center}
  1148. \begin{tabular}{l|l}
  1149. Sequence & round trip time $(ms)$ \\
  1150. 1 & 1115 \\
  1151. 2 & 871 \\
  1152. 3 & 1010 \\
  1153. 4 & 912 \\
  1154. 5 & 716 \\
  1155. 6 & 1204 \\
  1156. 7 & 1146 \\
  1157. \hline
  1158. Mean & 996 \\
  1159. \end{tabular}
  1160. \caption{Seven \gls{icmp} echo requests from the parent to the child as can
  1161. be seen in figure \ref{fig:rtt_a}.}
  1162. \label{tab:ping_l_r}
  1163. \end{center}
  1164. \end{table}
  1165. \begin{figure}[h!]
  1166. \includegraphics[width=\linewidth]{images/evaluation/rtt_a.png}
  1167. \caption{The seven \gls{icmp} echo requests and responses from the network
  1168. leader to its child.}
  1169. \label{fig:rtt_a}
  1170. \end{figure}
  1171. \subsection{Resetting a router and validate reattachment}
  1172. Figure \ref{fig:reset_3} shows the reset and re-attach procedure. After
  1173. successfully joining the Thread network, the device is reset using the command
  1174. \texttt{reset}. As the whole Thread stack is now in its original state, the
  1175. whole interface has to be brought up again using \texttt{ifconfig up}. After
  1176. restarting the Thread stack, the device immediately re-joins the network and
  1177. assumes its previous role as a router. The \texttt{ping} at the very end
  1178. confirms connectivity to the network.
  1179. One \gls{icmp} echo request is sent to the network leader to confirm actual
  1180. connectivity with the network.
  1181. \begin{figure}[h!]
  1182. \includegraphics[width=\linewidth]{images/evaluation/reset_3.png}
  1183. \includegraphics[width=\linewidth]{images/evaluation/reset_4.png}
  1184. \caption{The reset and re attach procedure. Immediately after the reset,
  1185. the debug message informing about the physical state of the radio is seen.
  1186. There are two images as the total output had to be split over two pages of
  1187. terminal output.}
  1188. \label{fig:reset_3}
  1189. \end{figure}
  1190. \section{Conclusion}
  1191. The results show a possible implementation of the so called network
  1192. co-processor where the logic of the application runs on a different hardware
  1193. than the network related logic.
  1194. This thesis also acknowledges that the timing constraints introduced by the
  1195. \gls{uart} connection may not be fixed at this stage of the \gls{ot} stack.
  1196. While certain optimisations may allow for a faster \gls{rtt} or faster
  1197. acknowledging of frames, the minimum time to transmit a full 802.15.4 frame to
  1198. the device cannot be lower than 11 $(ms)$ on a baud rate of 115200. Taking
  1199. into account that it also takes another 11 $(ms)$ for the receivig device to
  1200. deliver the frame to the host, this introduces a delay of at least 22 $(ms)$
  1201. simply due to transportation.
  1202. This may seem reasonable for a protocol as a whole, but as the delay is
  1203. introduced at the \gls{hal} for a protocol stack that already has timing
  1204. windows of 16 $(ms)$ \ref{impl_16ms}, it is not certain that the 22 $(ms)$ do
  1205. not violate other timing constraints. Through testing, this thesis assumes that
  1206. other timing windows are met, but cannot guarantee it.
  1207. The new \gls{hal} works most of the time, but seeing that already one timing
  1208. window in the stack had to be altered for stable operation, this is probably
  1209. not the most efficient way to write a fully Thread certified \gls{hal} for
  1210. \gls{ot}.
  1211. Despite the solution still leaving room for improvement it presents an already
  1212. working state of \gls{ot} utilizing the Z1. Of course it also allows
  1213. applications to be developed against the \gls{ot} stack and tested over a real
  1214. wireless connection.
  1215. Testing it in an actual Thread network requires the special \gls{ack} with
  1216. data pending to be implemented \cite[152]{802_15_4_std}. The mechanism the
  1217. \gls{ot} \gls{posix} implementation uses to determine which devices receive a
  1218. data pending flag can be mirrored to the device. All necessary commands may be
  1219. added to the \gls{uart} bridge.
  1220. \section{Further Research}
  1221. % TODO Rephrase this
  1222. Implementing the missing \gls{ack} with data pending feature and testing the Z1
  1223. together with other Thread devices would be the next step building on top of
  1224. this thesis. This would be the final step towards actual Thread certification
  1225. for new \gls{hal} implementations \cite{ot:cert}.
  1226. Assuming the timing restrictions imposed by the serial communication line are
  1227. too high to deal with, moving more of the \gls{ot} stack on to the device can
  1228. speed things up. This is already proposed by the \gls{ot} developers in form of
  1229. a network co-processor, but no actual implementation was found at the time of writing
  1230. \cite{ot:hostcontr}.
  1231. The Z1 is definitely a good candidate for a network co-processor implementation
  1232. because of its power efficient operation, the 802.15.4 compatible radio chip
  1233. and the rather fast \gls{uart} connection to the host. It also features a
  1234. rather large memory and flash, compared to devices from its time.
  1235. As the protocol developed through this thesis is not Thread specific, it can be
  1236. adapted for any project taking part in 802.15.4 networks as required.
  1237. \backmatter
  1238. % Use an optional list of figures.
  1239. %\listoffigures % Starred version, i.e., \listoffigures*, removes the toc entry.
  1240. % Use an optional list of tables.
  1241. %\cleardoublepage % Start list of tables on the next empty right hand page.
  1242. %\listoftables % Starred version, i.e., \listoftables*, removes the toc entry.
  1243. % Use an optional list of alogrithms.
  1244. %\listofalgorithms
  1245. %\addcontentsline{toc}{chapter}{List of Algorithms}
  1246. % Add an index.
  1247. \printindex
  1248. % Add a glossary.
  1249. \printglossaries
  1250. % Add a bibliography.
  1251. \bibliographystyle{alpha}
  1252. \bibliography{z1_ot}
  1253. \end{document}