This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
proiecte:temp [2018/09/21 17:01] narcisa_ana.vasile [Network Topology] |
proiecte:temp [2018/11/28 11:48] (current) narcisa_ana.vasile [Bibliography] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
===== Introduction ===== | ===== Introduction ===== | ||
+ | The goal of this project is to create a flexible platform for developing Wireless Sensor Networks applications using the Sparrow sensor nodes. The key objectives of this project include porting the open-source operating system, Contiki, to Sparrow sensor nodes and porting CoAP network protocol to Contiki-running Sparrow nodes. | ||
===== Network Topology ===== | ===== Network Topology ===== | ||
Line 10: | Line 11: | ||
One of the Sparrow nodes is chosen to be the border router that communicates with a host using a tool called tunslip6. Tunslip6 creates a virtual network interface(tun0) and uses SLIP (Serial Line Internet Protocol) to encapsulate the traffic on the serial line. The border router will receive the address aaaa::1 and it will form a network with the other Sparrow nodes, by passing the prefix received from the host to all nodes. | One of the Sparrow nodes is chosen to be the border router that communicates with a host using a tool called tunslip6. Tunslip6 creates a virtual network interface(tun0) and uses SLIP (Serial Line Internet Protocol) to encapsulate the traffic on the serial line. The border router will receive the address aaaa::1 and it will form a network with the other Sparrow nodes, by passing the prefix received from the host to all nodes. | ||
+ | The other Sparrow nodes will run Contiki with a CoAP server as the main application. Those nodes will acquire data using different sensors and will pass the data to the CoAP client in the external network. | ||
+ | |||
+ | ===== Technologies ===== | ||
+ | |||
+ | ==== Contiki ==== | ||
+ | |||
+ | Contiki is an operating system for memory constrained systems, optimized for low-power microcontrollers. A list of available hardware platforms on which Contiki has been ported can be found at http:// | ||
+ | |||
+ | ==== CoAP ==== | ||
+ | |||
+ | Sensor nodes are devices capable of acquiring information from the environment using different types of sensors attached to them. Those sensors perform measurements and return information such as the value of the temperature, | ||
+ | |||
+ | {{ :proiecte: protocols.png? | ||
+ | |||
+ | |||
+ | CoAP is an application layer protocol used for message transfer on devices with very strict memory constraints. | ||
+ | Since CoAP is based on the REST model, obtaining data from the nodes using CoAP is similar to performing HTTP requests. For each sensor attached to the Sparrow nodes a resource object can be created, to store information about the data provided by the sensor and to associate a handler for each request that can be made on that sensor. For example, if a GET operation is possible for a sensor, a " | ||
- | The other Sparrow nodes will run Contiki with a CoAP server as the main application. Those nodes will acquire data using different sensors and will pass the data to the CoAP client in the external network. Since CoAP is based on the REST model, obtaining data from the nodes using CoAP is similar to performing HTTP requests. The general syntax for making such a request looks like this: | ||
< | < | ||
coapclient -o REQUEST -p PATH | coapclient -o REQUEST -p PATH | ||
Line 20: | Line 37: | ||
coapclient -o GET -p coap:// | coapclient -o GET -p coap:// | ||
</ | </ | ||
- | + | ||
- | The data received by the CoAP client | + | In the above command, aaaa:: |
===== Setup ===== | ===== Setup ===== | ||
+ | |||
+ | The components needed to setup the system are: | ||
+ | - One Sparrow node that will play the role of the border router. | ||
+ | - One or more Sparrow nodes that will run CoAP servers and will gather data. | ||
+ | - A device(e.g. laptop) that will run a CoAP client that will make requests to the CoAP server. Optionally, | ||
+ | | ||
+ | The following steps need to be followed to setup the system: | ||
+ | |||
+ | < | ||
+ | git clone https:// | ||
+ | git checkout sparrow | ||
+ | </ | ||
+ | |||
+ | Then follow the instructions from https:// | ||
+ | |||
+ | ==== Border Router ==== | ||
+ | |||
+ | To make and upload the border-router application to the Sparrow node | ||
+ | |||
+ | < | ||
+ | cd examples/ | ||
+ | make TARGET=sparrow savetarget | ||
+ | make upload WITH_SLIP=1 WITH_WEBSERVER=0 AVRDUDE_PORT=/ | ||
+ | </ | ||
+ | |||
+ | ''< | ||
+ | The border-router can optionally host a mini webserver which can be disabled using ''< | ||
+ | |||
+ | To bridge the Sparrow nodes network and the host's networt, the tunslip6 tool is used. | ||
+ | |||
+ | < | ||
+ | cd tools | ||
+ | make tunslip6 | ||
+ | cd examples/ | ||
+ | sudo ../ | ||
+ | </ | ||
+ | |||
+ | You should see something similar to the following output: | ||
+ | |||
+ | < | ||
+ | ifconfig tun0 inet `hostname` up | ||
+ | ifconfig tun0 add aaaa:: | ||
+ | ifconfig tun0 | ||
+ | tun0 Link encap: | ||
+ | inet addr: | ||
+ | inet6 addr: aaaa::1/64 Scope: | ||
+ | UP POINTOPOINT RUNNING NOARP MULTICAST | ||
+ | RX packets:0 errors:0 dropped:0 overruns:0 frame: | ||
+ | TX packets:0 errors:0 dropped:0 overruns:0 carrier: | ||
+ | | ||
+ | tun0 Link encap: | ||
+ | inet addr: | ||
+ | inet6 addr: aaaa::1/64 Scope: | ||
+ | UP POINTOPOINT RUNNING NOARP MULTICAST | ||
+ | RX packets:0 errors:0 dropped:0 overruns:0 frame: | ||
+ | TX packets:0 errors:0 dropped:0 overruns:0 carrier: | ||
+ | | ||
+ | RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) | ||
+ | |||
+ | Autostart other processes | ||
+ | RPL-Border router started | ||
+ | *** Address: | ||
+ | |||
+ | SIN: 10 | ||
+ | Got configuration message of type P | ||
+ | Setting prefix aaaa:: created a new RPL dag | ||
+ | Server IPv6 addresses: | ||
+ | aaaa:: | ||
+ | fdfd::4 | ||
+ | fe80:: | ||
+ | </ | ||
+ | |||
+ | ==== CoAP Server ==== | ||
+ | |||
+ | To make and upload the CoAP server on a different Sparrow node: | ||
+ | |||
+ | < | ||
+ | cd examples/ | ||
+ | make upload WITH_COAP=1 AVRDUDE_PORT=/ | ||
+ | make login AVRDUDE_PORT=/ | ||
+ | </ | ||
+ | |||
+ | The ip address of the CoAP server should be printed in the console. | ||
+ | |||
+ | ==== CoAP Client ==== | ||
+ | |||
+ | From Github, clone the open source CoAP client (implemented in Python). Example of running the client: | ||
+ | < | ||
+ | python coapclient.py -o GET -p coap:// | ||
+ | </ | ||
+ | |||
+ | ==== Firebase ==== | ||
+ | |||
+ | Firebase is an application development platform that offers services such as realtime database, cloud messaging, analytics, etc. It can be used to store the data gathered by the Sparrow nodes and it's easy to integrate it with mobile application, | ||
+ | |||
+ | I order to setup Firebase, firstly, go to Firebase console https:// | ||
+ | |||
+ | < | ||
+ | npm install -g firebase-tools | ||
+ | firebase login | ||
+ | </ | ||
+ | |||
+ | Login with your google account and initialize Firebase: | ||
+ | |||
+ | < | ||
+ | firebase init | ||
+ | </ | ||
+ | |||
+ | If you want to link Firebase with a mobile phone application, | ||
+ | |||
+ | < | ||
+ | firebase init functions | ||
+ | </ | ||
+ | |||
+ | A file named " | ||
+ | |||
+ | < | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | To store the information gathered from the sensors in the database, follow these steps: | ||
+ | - From Firebase console **Project settings -> Service accounts -> Generate new provate key**. Download the file generated locally - this will be used to allow access to firebase from your laptop. | ||
+ | - Go to Firebase console, copy the url of your project. It should be something similar to ' | ||
+ | - Send the information received by the CoAP client running on the laptop to Firebase. Below, is an example of a python code that sends the value of the temperature in cloud: | ||
+ | |||
+ | < | ||
+ | import firebase_admin | ||
+ | from firebase_admin import credentials | ||
+ | from firebase_admin import db | ||
+ | |||
+ | firebase_url = ' | ||
+ | cred = credentials.Certificate(" | ||
+ | firebase_admin.initialize_app(cred, | ||
+ | ' | ||
+ | }) | ||
+ | |||
+ | ref = db.reference(' | ||
+ | data_ref = ref.child(' | ||
+ | data_ref.set({ | ||
+ | ' | ||
+ | ' | ||
+ | }) | ||
+ | </ | ||