📄 tinydb.tex
字号:
\documentclass[11pt]{article}\usepackage[pdftex]{graphicx}\usepackage{html}\usepackage{psfig}\usepackage{makeidx}\usepackage{nomencl}\usepackage{tabularx}\usepackage[letterpaper, top=1.0in, bottom=1in, inner=1.0in, outer=1.0in, foot=.25in]{geometry}\newif\ifpdf\ifx\pdfoutput\undefined\pdffalse\else\pdfoutput=1\pdftrue\fi\newcommand{\pdfgraphics}{\ifpdf\DeclareGraphicsExtensions{.pdf,.jpg}\else\fi}\oddsidemargin -0.1in % Note that \oddsidemargin = \evensidemargin\evensidemargin -0.1in%\topmargin -55pt % Nominal distance from top of page to top% % of box containing running head.%\headheight 12pt % Height of box containing running head.%\headsep 25pt % Space between running head and text.%\footskip 60pt % Distance from baseline of box containing%\textheight 9.125in % Height of text (including footnotes and % figures, excluding running head and foot).%\textwidth 6.75in % Width of text line. % For two-column mode:%\textheight 9.125in % Height of text (including footnotes and % figures, excluding running head and foot).%\textwidth 6.75in % Width of text line. % For two-column mode:\renewcommand{\baselinestretch}{1.2}\renewcommand{\nomname}{Glossary}\makeindex\makeglossary\newcounter{sqlquerycounter}\setcounter{sqlquerycounter}{1}\newcommand{\sqlquery}[1]{{\renewcommand\baselinestretch{.8}\rm\begin{samepage}\setlength{\parskip}{.1\baselineskip} \small\hspace{.3in}\parbox[t]{5in}{\setlength{\parindent}{-.1in}\tt{#1}\\}\normalsize\renewcommand\baselinestretch{1.0}\rm%\vspace{-22pt}\end{samepage}}}\newcounter{lastquery}\newcommand{\numsqlquery}[1]{(\thesqlquerycounter) \sqlquery{#1}\setcounter{lastquery}{\value{sqlquerycounter}}\refstepcounter{sqlquerycounter}}\newcommand{\queryref}[1]{\newcounter{#1}\setcounter{#1}{\value{lastquery}}}\newcommand{\docroot}{tinyos-1.x} \newcommand{\java}{tinyos-1.x/tools/java}\begin{latexonly}\title{\vspace{2.5in} TinyDB: In-Network Query Processing in TinyOS}\end{latexonly}\begin{htmlonly}\title{TinyDB: In-Network Query Processing in TinyOS}\end{htmlonly}\author{Sam Madden, Joe Hellerstein, and Wei Hong \\ \{madden,jmh\}@cs.berkeley.edu, whong@intel-research.net}\date{}\begin{document}\pdfgraphics\pagenumbering{arabic}%\pagestyle{myheadings}\markright{{\bf TinyDB\index{TinyDB} Documentation. }}\maketitle\begin{latexonly}\vspace{2in}\end{latexonly}\begin{center}Version 0.4 \\September, 2003\end{center}\thispagestyle{empty}\begin{latexonly}\newpage\end{latexonly}\tableofcontents\begin{latexonly}\newpage\end{latexonly}\section{What's New In This Release}This document refers to the TinyDB 1.1 release, which accompanied TinyOS 1.1 and was officially released September, 2003and represents major changes to the functionality and stabilityof TinyDB, particularly over the 1.0 release.For users already familiar with TinyDB, new features in this releaseinclude:\begin{itemize} \item {\bf Queries over Flash Memory}: Queries in TinyDB can now log to the on-mote Flash, via the Matchbox filing system. Logged query results can be read fetched via queries as well. See Section \ref{sec:flash} for syntax and usage details. \item {\bf Support for New Sensor-Boards and Sensors}: TinyDB supports the new Mica2 and Mica2Dot motes as well as a variety of new sensors for detecting air-pressure, humiditity, temperature and light. It also includes code to calibrate these readings on the PC after they have been retrieved. See Section \ref{sec:sb-config}. \item {\bf New, Modularized Network Interface}: The network interfaced used by TinyDB has been totally rewritten. The default interface improves multi-hop routing stability, and it is now much easier to replace the default routing with new routing layers that provide alternative functionality. Section \ref{sec:tinydbnetwork} has been rewritten to reflect these changes. \item {\bf New, Modularized Aggregate Interface}: It is now much easier to extend TinyDB with new aggregate operators. Section \ref{sec:adding-aggs} gives a brief tutorial on this. \item {\bf Power Management}:When running queries with long sample periods, TinyDB intelligently power consumption, allowing the network to last for months a time. Sections \ref{sec:time-sync} and \ref{sec:pm-config} describe these features. \item {\bf Time Synchronization}: Sensors in TinyDB are now time synchronized. This means that aggregate results are guaranteed to have been collected at the same time, and that motes agree on the real-world start and end-time of every epoch. Section \ref{sec:time-sync} also includes details about these features. \item {\bf Event-based Queries}: TinyDB includes support for queries that are initiated by low-level operating system ``events''. These events can be defined much like commands and attributes, and referenced in queries. See Section \ref{sec:event-queries} for more details. \item {\bf Tiny Application Sensor Kit (TASK)}: TinyDB is at the core of the new ``tiny application sensor kit'', a toolkit that provides a new user-interface and relational database interface for collecting data from TinyDB. Section \ref{sec:task} summarizes the kit and provides pointers to documentation.\item {\bf Simulator Support}: TinyDB now runs in the TOSSIM simulator, which can be useful for debugging or demonstration purposes. Section \ref{sec:tossim} describe running TinyDB in the simulator. \item {\bf New Debugging, Testing, and Status Tools}: Finally, several new tools and interfaces have been added to make it much easier to retrieve status information from TinyDB and listen to TinyDB specific network traffic. Section \ref{sec:debugging} describes these features.\end{itemize}\section{Introduction}TinyDB\index{TinyDB} is a query processing system for extractinginformation from a network of\htmladdnormallink{TinyOS}{http://webs.cs.berkeley.edu/tos}sensors.\index{TinyOS}\index{sensor} Unlike existing solutions fordata processing in TinyOS\index{TinyOS}, TinyDB\index{TinyDB} does notrequire you to write embedded C\index{C} code forsensors\index{sensor}\index{embedded}. Instead, TinyDB\index{TinyDB}provides a simple, SQL\index{SQL}-like interface to specify the datayou want to extract, along with additional parameters, like the rateat which data should be refreshed -- much as you would pose queriesagainst a traditional database. Given a query specifying your datainterests, TinyDB\index{TinyDB} collects that data frommotes\index{mote} in the environment, filter\index{filter}s it,aggregates\index{aggregate} it together, and routes\index{routing} itout to a PC. TinyDB\index{TinyDB} does this via power-efficientin-network\index{in-network} processing algorithms.To use TinyDB\index{TinyDB}, you install its TinyOS\index{TinyOS} components\index{component} ontoeach mote\index{mote} in your sensor\index{sensor} network. %(TinyDB\index{TinyDB}'s components\index{component} can co-exist%with other components\index{component}, although they can place extensive demands on%the memory and radio resources of the mote\index{mote}.) TinyDB\index{TinyDB} provides a simple Java\index{Java} API\index{API}for writing PC applications that query and extract data from thenetwork; it also comes with a simple graphical query-builder andresult display that uses the API\index{API}.The primary goal of TinyDB\index{TinyDB} is to make your life as a programmersignificantly easier, and allow data-driven applications to bedeveloped and deployed {\em much} more quickly than what is currentlypossible. TinyDB\index{TinyDB} frees you from the burden of writing low-level codefor sensor\index{sensor} devices, including the (very tricky) sensor network\index{sensor network}interfaces. Some of the features of TinyDB\index{TinyDB} include:\begin{itemize}\item {\it Metadata Management\index{catalog}}: TinyDB provides a metadata catalog to describe the kinds of sensor readings that are available in the sensor network.\item {\it High Level Queries}: TinyDB uses a {\em declarative}\index{declarative} query language that lets you describe the data you want, without requiring you to say how to get it. This makes it easier for you to write applications, and helps guarantee that your applications continue to run efficiently as the sensor network changes.\item {\it Network Topology\index{topology}}: TinyDB\index{TinyDB} manages the underlying radio network by tracking neighbors\index{neighbor}, maintaining routing\index{routing} tables, and ensuring that every mote\index{mote} in the network can efficiently and (relatively) reliably deliver its data to the user.\item {\it Multiple Queries}: TinyDB\index{TinyDB} allows multiple queries to be run on the same set of motes\index{mote} at the same time. Queries can have different sample\index{sample} rates and access different sensor\index{sensor} types, and TinyDB\index{TinyDB} efficiently shares work between queries when possible.\item {\it Incremental Deployment via Query Sharing}: To expand your TinyDB\index{TinyDB} sensor network\index{sensor network}, you simply download\index{download} the standard TinyDB\index{TinyDB} code to new motes\index{mote}, and TinyDB\index{TinyDB} does the rest. TinyDB\index{TinyDB} motes\index{mote} share queries with each other: when a mote\index{mote} hears a network message for a query that it is not yet running, it automatically asks the sender of that data for a copy of the query, and begins running it. No programming or configuration of the new motes\index{mote} is required beyond installing TinyDB\index{TinyDB}.\end{itemize}This document serves a number of purposes. The first sections aretargeted at the sensor\index{sensor} application programmer, and include a basicoverview of the TinyDB\index{TinyDB} system architecture, and a QuickStart guide tousing the TinyDB\index{TinyDB} system, its query language and APIs\index{API}. The remainingsections are targeted at readers who want to extend the TinyDB\index{TinyDB} systemitself.%% We never added this stuff.% They describe the TinyDB\index{TinyDB} software components\index{component}, highlighting% places where the system could be profitably extended.\subsection{System Overview}This section provides a high level overview of the architecture of theTinyDB\index{TinyDB} software. It is designed to be accessible tousers of the TinyDB\index{TinyDB} system who are not interested in thetechnical details of the system's implementation. A detaileddescription of the TinyDB\index{TinyDB} software design is reservedfor Sections~\ref{sec:devel} and~\ref{sec:inside}.We begin with a short description of a typical use-case for TinyDB\index{TinyDB}. Imagine that Marywishes to locate an unused conference room in her sensor\index{sensor}-equipped building, andthat an application to perform this task has not already been built.The motes\index{mote} in Mary'sbuilding have a sensor board\index{sensor board} with light sensors\index{sensor} and microphones and have been programmed witha room number. Mary decides that her applicationshould declare a room {\it in-use} when the average light reading of all the sensors\index{sensor} in a roomare above $l$ and when the average volume is above $v$. Mary wants her application to refresh this occupancy information every 5 minutes. Without TinyDB\index{TinyDB}, Marywould have to write several hundred lines of custom embedded C\index{C}code~\index{embedded} to collect informationfrom all the motes\index{mote} in a room, coordinate the communication of readingsacross sensors\index{sensor},aggregate\index{aggregate} these readings together to compute the average lightand volume, and then forward that information from within the sensor network\index{sensor network} to the PC wherethe application is running. She would then have to download\index{download} her compiled\index{compile}program to each of the motes\index{mote} in the room. Instead, if the motes\index{mote} in Mary's building are running TinyDB\index{TinyDB},she can simply pose the following SQL\index{SQL}query to identify the rooms that are currently in-use:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -