= FAIR- Resilient Data Aggregation Cookbook = This document includes instructions how to install and to run the resilient data aggregation protocol FAIR. [[PageOutline(2-3,Table of Contents,inline)]] == Introduction == Irregularities occurred in a wireless sensor network may cause the data aggregation process to fail such that no response is provided by the sensor island or the provided response is incomplete. FAIR is a robust and secure data aggregation protocol that ensures continuity of service even in case of attacks and hardware failures. Instead of requiring waiting for a failure free protocol run, FAIR uses a quality of information to indicate how many failures occurred and what quality can be expected from the response of sensor nodes. The response is then sent together with the quality of information to the resource user. By looking at the quality of information and depending on the application scenario, the resource user then decides whether to use the response of FAIR or to refuse it. The response may be refused for example in a critical application if the quality of information is not high enough. Obviously, having continuous service from a sensor island and the knowledge on the quality of data provides a great flexibility in wireless sensor network applications. == Architectural Overview == The SENSEI architecture with a wireless sensor network (WSN) running the FAIR protocol is depicted in the figure below. [[Image(fair_arch.png, 40%, center)]] The architecture above is composed of three main components: '''Sensei Framework [SpQuickStart], Gateway [NativeGateway], and a WSN island'''. * Sensei Framework: This component represents the core SENSEI architecture. * Gateway: This component interconnects the WSAN island with the SENSEI architecture by implementing RPI and RAI interfaces. RPI (Resource Publication) interface is used for publishing FAIR as a SENSEI resource in the resource directory (RD) of the SENSEI architecture. RAI (Resource Access) interface allows Resource Users to access the services of FAIR over Internet. * WSN island: This component represents a sensor island running the FAIR protocol. == Installation == === Hardware and Software Requirements Installing the FAIR protocol requires the following hardware tools and software packages: * [http://www.ubuntu.com/ Linux PC (Ubuntu)] * [http://docs.tinyos.net/index.php/Getting_started#Installing_TinyOS_2.1.1 TinyOS-2.1.1] * At least 3 TelosB sensor nodes * [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway SENSEI Native Gateway (C++ Gateway)] We assume that the installation PC is running a '''Linux''' operating system and the [http://docs.tinyos.net/index.php/Getting_started#Installing_TinyOS_2.1.1 TinyOS-2.1.1] has been installed and configured properly on it. We skip the installation of TinyOS here and refer to [http://docs.tinyos.net/index.php/Getting_started#Installing_TinyOS_2.1.1 TinyOS-2.1.1] if needed. We describe the installation and configuration steps in the following for the [http://www.ubuntu.com/ Ubuntu] operating system. For simplicity all required software packages are archived in to a single file including the [wiki:NativeGateway C++ Gateway]. Please download it from [wiki:Fair-dwl here] and extract it the into the e.g., {{{ ~/tmp}}} directory. {{{ $ cd ~/tmp $ tar -xvf fair.tar.gz }}} You will see three subdirectories being created: {{{FAIR/CPP_GATEWAY, FAIR/FAIR_CPP_GATEWAY_PLUGIN, and FAIR/FAIR_WSN}}}. === Compiling C++ Gateway The installation procedure for the C++ Gateway is provided [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway here]. We repeat the required installation steps below for the convenience. Some packages are required to be installed prior to the compilation of the C++ Gateway with the FAIR support. Please install the following packages from the Ubuntu repository if you did not do already so. {{{ $ sudo apt-get install gcc g++ libssl-dev libxml2-dev }}} Sockets library also needs to be installed: {{{ $ cd ~/tmp/FAIR/CPP_GATEWAY/lib/Sockets-2.3.6 $ make $ sudo make install }}} Now, you can compile the [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway C++ Gateway] including FAIR support by running the following commands: {{{ $ cd ~/tmp/FAIR/CPP_GATEWAY $ make }}} A successful compilation creates a binary file '''sensei-gateway''' in the {{{ ~/tmp/FAIR/CPP_GATEWAY/bin}}} directory as shown below. {{{ ... ... ... strip sensei-gateway cp sensei-gateway ../bin make[1]: Leaving directory `/home/ugus/tmp/FAIR/CPP_GATEWAY/src }}} This binary is used to start the [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway C++ Gateway]. === Installing FAIR on Sensor Nodes Following installation steps assume a WSN that is composed of '''three''' TelosB sensor nodes. One of the sensor nodes will be used as the '''Aggregator node'''. This node will aggregate the sensor readings from the sensing nodes and also implement the communication interface between FAIR and the [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway C++ Gateway]. Other two sensor nodes will be the '''Sensing nodes''' and be responsible for measuring the temperature and the light level of the environment. The files implementing FAIR in TinyOS-2.1.1 for the TelosB sensor platform is located in the FAIR_WSN directory. Please change into this directory: {{{ $ cd ~/tmp/FAIR/FAIR_WSN }}} To compile the FAIR on a sensing node, please plug-in one of the sensing nodes to the USB port of your machine. If the TinyOS on your machine was configured properly, you should be able to see the connected sensor node in the output of the '''motelist''' command as shown below. {{{ $ motelist Reference Device Description ---------- ---------------- --------------------------------------------- M4AN7DJZ /dev/ttyUSB0 Moteiv tmote sky }}} This output indicates that the sensor node is recognized as device '''/dev/ttyUSB0'''. Now, please run the following command to install the FAIR protocol on the connected sensor node: {{{ $ cd ~/tmp/FAIR/FAIR_WSN $ make -f Makefile.Sensor telosb install.1 bsl,/dev/ttyUSB0 }}} The '''1''' in the '''install.1''' parameter assigns the '''ID = 1''' to the node being programmed. Therefore, you can use ''''''install.X'''''' to program a sensor node with the '''ID = X'''. '''Please note that each sensor node in the network must have a unique ID'''. Repeat the steps above for programming the remaining sensing nodes. In order to compile the Aggregator node with the '''ID = 0''', please run the following command: {{{ $ cd ~/tmp/FAIR/FAIR_WSN $ make -f Makefile.Aggregator telosb install.0 bsl,/dev/ttyUSB0 }}} Please note that you can of course choose an another ID for the aggregator node. But, it must be '''unique''' for the whole network. === Compiling Serial Forwarder The Aggregator node will be the bridge between the C++ Gateway and the WSN. The gateway will forward the requests of resource users to the WSN via the aggregator node. Responses of the WSN to the gateway will be send via the aggregator node. The communication between the aggregator node and the gateway will be over the serial port. To enable the communication via the serial port, the serial forwarder application of TinyOS needs to be compiled. To do so, please run the following command: {{{ $ cd ~/tmp/FAIR/FAIR_CPP_GATEWAY_PLUGIN/tinyos_lib/sf $ make }}} This will create a binary executable '''sf''' in that directory. == Running the Test Application == FAIR provides the aggregation of the temperature and light values measured in the WSN as SENSEI resources. To run a local demo, please start the [https://ncit-cluster.grid.pub.ro/trac/Sensei-Cookbook/wiki/NativeGateway C++ Gateway] by giving the following commands in a console: {{{ $ cd ~/tmp/FAIR/CPP_GATEWAY $ make $ ./bin/sensei-gateway }}} This will start the C++ Gateway which runs a http server at '''localhost:8000'''. Now, connect the '''aggregator node''' on which you installed the FAIR protocol above to the USB port of the gateway machine. Assuming that the aggregator node is connected to the device '''/dev/ttyUSB0''', you can start the serial forwarder at port '''9002''' for TelosB motes as follows: {{{ $ cd ~/tmp/FAIR/CPP_GATEWAY/bin $ ./sf >> Starting sf-control. >> Accepting commands on standard input... start 9002 /dev/ttyUSB0 115200 }}} FAIR is now ready for providing its resources to the SENSEI resource users. The temperature and light resources can be accessed from the following URIs: * Temperatur (in RDF format): http://localhost:8000/fair/wsan/temp * Temperatur (in HTML format): http://localhost:8000/fair/wsan/temp/html * Light (in RDF format): http://localhost:8000/fair/wsan/light * Light (in HTML format): http://localhost:8000/fair/wsan/light/html As an example, the responses in HTML and RDF formats are shown in the figures below: Temperature in HTML: [[Image(temp_res_html.png, 50%, center)]] Temperature in RDF: [[Image(temp_res_rdf.png, 50%, center)]] Light in HTML: [[Image(light_res_html.png, 50%, center)]] Light in RDF: [[Image(light_res_rdf.png, 50%, center)]] == FAIR Island in Heidelberg == A WSN composed of three sensing nodes and an aggregator node is deployed in the NEC Lab. in Heidelberg, Germany. The FAIR resources can be accessed via the following URIs: * Temperatur (in RDF format): http://sensei-app.nlehd.de:8000/fair/wsan/temp * Temperatur (in HTML format): http://sensei-app.nlehd.de:8000/fair/wsan/temp/html * Light (in RDF format): http://sensei-app.nlehd.de:8000/fair/wsan/light * Light (in HTML format): http://sensei-app.nlehd.de:8000/fair/wsan/light/html