= 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. 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 initiator of the query. By looking at the quality of information and depending on the application scenario, the initiator of query decides to use the response of FAIR or not. The response can may ignored for example in a critical application if the quality of information is low. 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, Gateway, 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) allows Resource Users to access the services of FAIR over Internet. * WSN island: This is component is a sensor island running the FAIR protocol. == Installation == === Hardware and Software Requirements To install and run the FAIR protocol requires the following hardware tools and software packages: * Linux PC * [http://docs.tinyos.net/index.php/Getting_started#Installing_TinyOS_2.1.1 TinyOS-2.1.1] * At least 3 TelosB sensor nodes * [http://localhost/trac/sensei/wiki/cpp_gatway 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. We skip the installation of TinyOS here. We describe the installation and configuration steps in the following for a Ubuntu operating system. For simplicity all required software packages are archived in to a single file. Please download it from [https://ncit-cluster.grid.pub.ro/trac/Sensei-WP5/export/1759/BillingPrivacy/Phase-3/pb_firefox_plugin.tar.g here] and extract in to the into e.g., {{{ ~/tmp}}} directory. {{{ $ cd ~/tmp $ tar -xvf fair.tar.gz }}} You will see three subdirectories {{{FAIR/CPP_GATEWAY, FAIR/FAIR_CPP_GATEWAY_PLUGIN, and FAIR/FAIR_WSN}}}. === Compiling C++ Gateway We need to install some packages prior to compilation of the C++ Gateway with 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 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''' which can be used for starting the 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 }}} === Installing FAIR on Sensor Nodes Following installation process assumes 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 other nodes and also implement the interface between FAIR and the C++ Gateway. Other two sensor nodes will be the '''Sensing nodes''' and be responsible for measuring the temperature and light level of the environment. The files implementing FAIR in TinyOS-2.1.1 for TelosB sensor platform is located in the FAIR_WSN directory. Please change into this directory {{{ $ cd ~/tmp/FAIR/FAIR_WSN }}} We will start with compiling the FAIR for sensing nodes. To do so, please plug-in one of the sensing nodes to the USB port on your machine. If your TinyOS has been configured properly, you should be able to see the sensor node in the output of the motelist command as shown below. {{{ $ motelist Reference Device Description ---------- ---------------- --------------------------------------------- M4AN7DJZ /dev/ttyUSB0 Moteiv tmote sky }}} This output shows that the sensor node is connected to the device '''/dev/ttyUSB0'''. Now, please run the following command to install the FAIR protocol for sensing nodes: {{{ $ cd ~/tmp/FAIR/FAIR_WSN $ make -f Makefile.Sensor telosb install.1 bsl,/dev/ttyUSB0 }}} The '''1''' in the '''install.1''' will give the '''ID = 1''' to this node in the network. ''''''install.X'''''' compiles a sensor node with '''ID = X'''. '''Please compile each sensor node with a unique ID'''. Repeat the steps above for the other sensing nodes. In order to compile the Aggregator node with '''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 aggregation node. But, it should be '''unique''' for the whole network. === Compiling Serial Forwarder The Aggregator node will be the bridge between the Gateway and the WSN. The gateway will send its request to the WSN via the aggregator node. The response 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 the directory. == Running the Test Application == FAIR provides aggregation of the temperature and light values measured in the WSN as SENSEI resource. To run the demo, please start the C++ Gateway by giving the following commands in a console: {{{ $ cd ~/tmp/FAIR/CPP_GATEWAY $ make $ ./bin/sensei-gateway }}} This will start the 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 of the light and temperature resources 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 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