inf5100 mandatory exercise - universitetet i oslo exercise autumn 2010 jarle søberg, 2010 important...
TRANSCRIPT
Important notes
Due: Wednesday November 10th 2010 at
16:00
Deliver by email to Jarle (jarleso at ifi.uio.no)
If needed: installation/run procedures (explain)
See also delivery instructions for Part I
Read through and apply to the guidelines for
written assignments
Jarle Søberg, 2010
Team structure
Max 2 students in each team
Team member names and UiO email adresses email to Jarle (jarleso at ifi.uio.no).
before midnight September 28th (Tuesday).
Those who haven‟t got a group by the 28th will be randomly assigned to a group
Requests for group of 1 person need a good reason!
email to Jarle (jarleso at ifi.uio.no)
before midnight September 27th (Mon).
Jarle Søberg, 2010
About the mandatory exercise
The exercise consists of three parts
Part I: TinyDB
Part II: Esper
Part III: Discussion
All parts and exercises must be solved.
Language: English or Norwegian
Jarle Søberg, 2010
Outline
Overview
TinyDB – TinyOS and limitations
The assignment
Lab setup and practical information
Jarle Søberg, 2010
Overview
Understanding usage of declarative
languages for querying sensors
Use an ordinary DBMS to extract even more
information
Discuss possible optimizations
Jarle Søberg, 2010
Overview
Each group has its own user on dmms-lab107.ifi.uio.no
Login from Linux with options –XY
Login from Windows: Make sure to enable X11 forwarding
Each group has one instance of TinyOS
TinyDB
PostgreSQL
Avrora WSN emulator
Esper
The last three are explicitly used in the assignment
Jarle Søberg, 2010
Overview
We use both an emulator and real motes
The emulator is for testing and making sure things
are all right and confirming that the results are
correct
Each group will receive a time slot where the real
experiments on the motes are performed
The fewer groups, the longer time to work on the
real motes, thus groups of two persons is
recommended for all
Jarle Søberg, 2010
TinyOS
Is located in tinyos-1.x/ in your group‟s folder
Contains the files and libraries used by TinyDB (and other programs)
All TinyOS programs on the motes are written in nesC and compiled on the base station (BS) before distributed to the motes
Please look at the code if you‟re interested
Jarle Søberg, 2010
TinyDB
A small DSMS written for WSNs
Needs a root node, which is connected to a stationary, i.e. connected to a power outlet, computer The root mote is node 0
Creates a tree to the other motes
Handles all distribution of the queries
Has a simple and intuitive interface
Can log the result tuples to a PostgreSQL database
Jarle Søberg, 2010
TinyDB
The query is stated by pressing the buttons,
and the resulting query shows up
Check the „Log to Database‟ field to log all
the arriving tuples to PostgreSQL
Press „Send Query‟ and a result window
appears
Get known to the system by trying the
different buttons, but…
Jarle Søberg, 2010
TinyDB - Limitations
TinyDB has limited expression strength Only some parts are implemented in the version we are currently
using
Windowing is not supported, i.e., results do not appear even though the query executor doesn‟t complain, and so on…
Sometimes you have to resend queries if results do not appear
The running time of the query can not be set
We cannot really use TinyDB optimally: It is a research project with code made just for showing concepts The examples in the TinyDB slides are not working since they
have slightly different syntax than for the TinyDB prototype
Jarle Søberg, 2010
TinyDB
In the assignment, we should use PostgreSQL to perform some post analyses of the tuples
Analysis of the data Stored as tuples in the database
Start the PostgreSQL client at your group‟s login domain at dmms-lab107.ifi.uio.no by writing mypsql
Make sure the postmaster server is running: ps ax | grep
postmaster
If not, start it by writing pg_ctl start –l /tmp/INF5100-
<your group #>_logfile and then write mypsql
Check out the table called queries
The result tuples are stored there if “Log to Database” is marked in the TinyDB interface (see slide 13)
Jarle Søberg, 2010
TinySQL
These are the TinySQL clauses that you should need:
SELECT <aggregates>, <attributes>
[FROM {sensors}]
[WHERE <predicates>]
[GROUP BY <exprs>]
[HAVING <aggregate>]
[SAMPLE PERIOD <const> | ONCE]
Jarle Søberg, 2010
The Sensor Network Assignment Tasks
1. Measure the light for 60 seconds with a preferred sample interval. Argue why you use this sample interval. Remember to log to the database.
2. What is the total average of these readings?
3. Use these readings to measure only those readings having a value less than the total average. Run test for 60 seconds with the preferred sample interval.
4. Are there any difference in the results from the emulator and the motes? Why/Why not?
5. What is the difference between a central and a distributed implementation of the HAVING clause for aggregations like SUM and MAX? How does this affect the power consumption? Discuss and give examples.
6. Discuss some of the differences between the theoretical and practical experience with TinyDB.
Jarle Søberg, 2010
Delivery of the sensor network part of the
INF5100 assignment
The result should be a document
Discuss/show the queries and plots of the results
for task 1 – 3
Discuss the results, do not assume the reader
understands the results from the plots
End up with a nice discussion on task 4 – 6 (0.5 to
1 page per question). Show that you understand.
Deliver your data and the document packet
tarred and (g)zipped
Jarle Søberg, 2010
Running TinyDB with emulator
1. Set to old Java version (this applies to all TinyDB usage) > ojava
2. The Avrora WSN emulator Open a new window at dmms-lab107.ifi.uio.no > avrora
3. The serial forwarder Open a new window at dmms-lab107.ifi.uio.no > sf
4. TinyDB Open a new window at dmms-lab107.ifi.uio.no
Uncomment comm-string:sf@localhost$900N (N depends on the group, e.g. group INF5100-1 has 9002) in tinyos-1.x/tools/java/net/tinyos/tinydb/tinydb.conf
> tinydb
Jarle Søberg, 2010
Running TinyDB for real
Comment comm-string:sf@localhost$900N (N depends on the group) in
tinyos-1.x/tools/java/net/tinyos/tinydb/tinydb.conf
Uncomment comm-string:serial@COM1$57600 in tinyos-
1.x/tools/java/net/tinyos/tinydb/tinydb.conf
> tinydb
Jarle Søberg, 2010
Lab Setup
The three motes are located in the DMMS lab but you will only access them remotely
The experiments on the motes can start in the beginning of October Use the emulator for so long
Solve the other two parts of the assignment
A schedule for access to the real motes is presented in heim.ifi.uio.no/~jarleso/INF5100/schedule.html and is ready when the groups are registered
The schedule is tight, but everything (queries) should be ready when you can access the motes
Jarle Søberg, 2010
Practical information
Initially, the password for each group is equal to the group name, i.e., INF5100-5, for example
Wait to log in before you know which group you are on…
Jarle Søberg, 2010
Practical Information
To get data from PostgreSQL to a file, write
mypsql -q -F ',' -A -t –c ’<query>’ –o <result
file>
Use your favorite plotting program to create the plots
Use your favorite document creation program to write the text
But the delivered document must be in pdf.
Jarle Søberg, 2010
Introduction
Smart homes Turn on/off light/electric devices in rooms
E.g. X10 has been a standard since the 70‟s
Home security
Recently used for automated homecare People want to stay at home instead of hospitals
Sensors are cheaper than humans
For elder care: the portion of elders in the world increases
Homes equipped with sensors Movement, cameras, temperature, touch, etc.
Combine sensor readings with ideas from complex event processing (CEP) For this task we use Esper
Jarle Søberg, 2010
INF5100 Setup
Each group‟s home directory contains workspace a directory called workspace/INF5100SmartHomes in the home directories on the machine dmms-lab107.ifi.uio.no When solving Part II, use the newer Java version
> njava
„Plug-and-play‟ with Eclipse, but can also be changed with any text editor
Contains code that compiles and runs Type make in the directory to compile if you use any other text editor than Eclipse
Type ./INF5100 <tracefile> <queriesfile> <listenersfile> <sensorsfile> <resultfile> in the directory to run Esper
Contains PostgreSQL for simple database support
Place additional Java files in the src/inf5100Homecare/ directory in the workspace
It is also possible to copy the code from the directory to a private machine and use Eclipse Need to download Esper jar-files on the personal machine and configure Esper (and
Eclipse) accordingly
It is faster to have it on your own machine, since there might be many users on dmms-lab107.ifi.uio.no
Jarle Søberg, 2010
INF5100 Setup
The groups need to write queries and listeners to solve the mandatory assignment
We use dynamic class loading for the possible additional listeners and event descriptions Create explicit listeners for each task
Depending on the output we are interested in
Place additional compiled listeners and event descriptions together with the other class files
Automatically compiled by eclipse or when writing make.
The queries should be written in a separate file End the queries with „;‟ and separate the queries with a
newline
Jarle Søberg, 2010
Our Data Set
Trace files from two subjects who have been monitored by various types of sensors in a home We have changed the format of the original trace files to match
Esper‟s event processing model
The stream name is SensorEvent Sensors report either ON or OFF (activated or deactivated), and an event
is modelled as follows
<sensor, sensorReference, ON/OFF, timestamp> where the timestamp is shown as epoch, e.g., Refrigerator,74,ON,1053313309093
The duration of a sensor reading is denoted by the time range between a sensor reports ON until it reports OFF We have represented this as two separate data tuples, where the
ON data tuple has a lower timestamp than the OFF data tuple
The trace files contain one data tuple per line
Jarle Søberg, 2010
Implementation details
The code already consists of INF5100.java
Takes as argument the current trace file
Contains methods for nicer printing of timestamps
ListenerLoader.java Dynamically loads the listeners that are specified in <listenerfile>
SensorEvent.java Example of an event file and the event description of the data tuples from the trace
files
INF5100Listener.java Abstract class to be extended by the listeners
SensorEventListener.java Example of a listener
Queries.dat Example of a query
Listeners.dat Example of usage of the listeners
Jarle Søberg, 2010
Mandatory Assignment
Run a set of CEP queries against trace files to discover complex events Can also be helpful to use the files with sensor overview
All the tasks should be solved with Esper and the interpretation of each query should be explained thoroughly, since there can be many possible solutions Also show results from both the subjects
For each of the tasks deliver the query, listener files and results
Also deliver a document (in pdf) where you discuss and explain your solutions
Jarle Søberg, 2010
Mandatory Assignment: Esper Part
1. For each day, how many sensor readings are reported? Give the number of sensors and a timestamp that shows the day.
2. Show the timestamp and duration of every time the subject uses the telephone.
3. When does the subject ever use the microwave while using the telephone?
The complex event meal preparation consists of readings from the following sensors in the given order:
1. Light switch in kitchen = ON
2. Refrigerator = ON, Refrigerator = OFF at least two times
3. Microwave = ON, Microwave = OFF at least two times
4. Toaster = ON, Toaster = OFF at least two times
5. Light switch in kitchen = OFF
4. Create a complex event called MealPreparation.
5. When does the meal preparation last for more than two hours?
6. When does the kitchen door either open or close before and after the meal preparation?
Jarle Søberg, 2010
Discussion part
Give examples of the differences between
TinyDB and Esper with respect to querying
sensor network data.
This is possibly a large task, so please choose
only some areas to discuss.
1 to 2 pages with 11pt, A4 and standard margins
and in pdf.
Jarle Søberg, 2010
Need help? Questions? TinyDB
frustrations? Esper does not work?
Jarle (jarleso at ifi.uio.no) or visit my office (3232)
Send me an email if you experience some practical challenges A FAQ is located at heim.ifi.uio.no/~jarleso/INF5100/FAQ
I add Q&As there, if the question is not too way out
Remember to backup your data on the machine, since dmms-lab107 is not supported by Ifi drift!
Jarle Søberg, 2010
References
Esper: esper.codehaus.org
The trace files have been taken from http://courses.media.mit.edu/2004fall/mas622j/04.projects/home/and more details are available in the following publications E. Munguia Tapia, S. S. Intille, and K. Larson, "Activity recognition in the
home setting using simple and ubiquitous sensors," in Proceedings of PERVASIVE 2004, vol. LNCS 3001, A. Ferscha and F. Mattern, Eds. Berlin Heidelberg: Springer-Verlag, 2004, pp. 158-175.
Tapia, E.M. Activity Recognition in the Home Setting Using Simple and Ubiquitous Sensors. M.S. Thesis Media Arts and Sciences, Massachusetts Institute of Technology, September 2003.
E. M. Tapia, N. Marmasse, S. S. Intille, and K. Larson, "MITes: Wireless portable sensors for studying behavior," in Proceedings of Extended Abstracts Ubicomp 2004: Ubiquitous Computing, 2004.
Jarle Søberg, 2010