ID: 488108
Download Pdf The PPT/PDF document "DAIS: Enabling Declarative Applications ..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
DAIS: Enabling Declarative Applications in Immersive Sensor NetworksTR-UTEDGE-2006-000 ©Copyright 2006 [23]L.Neitzel,S.Seixas,andK.Ren.Areviewofcranesafetyintheconstructionindustry.AppliedOccupationalandEnvironmentalHygiene,16(12):1106{1117,2001.[24]M.Puccio.Enhancingcranesafety:Digitallycompensatedtiltsensors.SensorsMagazine,20(9),2003.[25]HuangQ,C.Lu,andG.-C.Roman.Spatiotemporalmulticastinsensornetworks.InProc.ofthe1stInt'l.Conf.onEmbeddedNetworkedSensorSystems,pages205{217,2003.[26]A.Ranganathan,S.Chetan,J.Al-Muhtadi,R.Campbell,andM.D.Mickunas.Olympus:Ahigh-levelprogrammingmodelforpervasivecomputingenvironments.InProc.ofthe3rdInt'l.Conf.onPervasiveComputingandCommunications,2005.[27]G.-C.Roman,C.Julien,andQ.Huang.Networkabstractionsforcontext-awaremobilecomputing.InProc.inthe24thInt'l.Conf.onSoftwareEngineering,pages363{373,2002.[28]M.Roman,C.Hess,R.Cerqueira,A.Ranganathan,R.Campbell,andK.Narstedt.Amiddlewareinfrastructureforactivespaces.IEEEPervasiveComputing,1(4):74{83,2002.[29]K.Romer,O.Kasten,andF.Mattern.Middlewarechallengesforwirelesssensornetworks.ACMSIGMOBILEMobileComputingandCommunicationsReview,6(4):59{61,2002.[30]N.Shrivastava,C.Burgohain,D.Agrawal,andS.Suri.Mediansandbeyond:Newaggregationtechniquesforsensornetworks.InProc.ofthe2ndInt'l.Conf.onEmbeddedNetworkedSensorSystems,pages239{249,2004.[31]M.Weiser.Thecomputerforthetwenty-rstcentury.ScienticAmerican,265(3):94{101,1991.[32]M.WelshandG.Mainland.Programmingsensornetworksusingabstractregions.InProc.ofthe1stUSENIX/ACMSymp.onNetworkedSystemsDesignandImplementation,2004.[33]K.Whitehouse,C.Sharp,E.Brewer,andD.Culler.Hood:Aneighborhoodabstractionforsensornetworks.InProc.ofthe2ndInt'l.Conf.onMobileSystems,Applications,andServices,pages99{110,2004.[34]Y.YaoandJ.Gehrke.Thecougarapproachtoin-networkqueryprocessinginsensornetworks.ACMSIGMODRecord,31(3):9{18,2002.[35]Y.Yu,B.Krishnamachari,andV.K.Pasanna.Issuesindesigningmiddlewareforwirelesssensornetworks.IEEENetwork,18(1):15{21,2004.20 theSceneMmodulemustmonitorchangesinthescenemembershipthatmightcauseittonolongerbeamember.Forexample,ifthesceneisdenedbyrelativelocation,andtheuseriswalkingthroughthesensornetwork,ashemovespastthesensorandfurtheron,thesensorwillneedtoberemovedfromthescene.Toaccomplishthis,thescenemustmonitorincomingbeaconmessagesforthisscenefromtheparent(asindicatedbythepreviousHopeldinthemessage).SuchmessagesarealsoreceivedinSceneMthroughtheReceiveMsginterface.SceneMpassesthemtotheMonitormodulethroughtheMonitorMsginterface.TheMonitormoduleusesincomingbeaconmessagesfromtheparent,informationaboutthescene(fromtheinitialmessage),andinformationfromthecontextsourcestomonitorwhetherthisnoderemainsinthescene.Inaddition,theMonitorTimerrequiresthatthenodehasheardabeaconfromtheparentatleastonceinthelastthreebeaconintervals.Ifeithertheparenthasnotbeenheardfromorthereceivedbeaconpushesthenodeoutofthescene,theMonitormodulegeneratesaneventthatishandledbytheSceneMmodulethatultimatelyceasesthenode'sparticipationinthescene.ThisincludessignalingareceiveeventontheReceiveinterfaceconnectiontotheQueryProcessor.ThiseventpassesanullmessagethatindicatestotheQueryProcessortoceaseevaluatingthenotedpersistentquery.Finally,theBeaconmoduleshowninFigure9isalsoactivatedwhenapersistentqueryisreceived.Thismoduleperiodicallytransmitsanupdateforthisnode'smetricvalueforthescene.AstheMonitormoduledetectschangesinthemetricvalue(basedonthemessagesfromitsparent),themetricvalueisupdated(throughtheSceneMmodule).WhentheMonitormoduledetectsthatthenodeisnolongerpartoftheuser'sscene,theSceneMmoduleshutsdowntheBeaconmodule.ProcessingQueries.OncetheSceneMmoduledescribedabovedeterminesthatthenodeisinthescene,itpassesthereceivedmessagetotheQueryProcessorcomponentshowninFigure11. Figure11.ImplementationoftheQueryProcessorfunctionalityonsensorsInourinitialimplementation,thiscomponentimplementsthefunctionalityshownatthetoplayerofthesensorportionofthearchitectureinFigure2.ThedatarequestmessagearrivesintheQueryProcessorthroughthereceiveeventoftheReceiveinterface.Ifthequeryisaone-timequery(i.e.,ifthepersistent aginthemessageisfalse),thentheQueryProcessorsimplyconnectstotheon-boardsensorthatcanprovidetherequesteddatatype(depictedasSensorinthegure)throughtheADC16 Figure8.SimpliedobjectdiagramforDAISquery,atablewithintheSceneViewisupdatedwithamappingfromauniquequeryidgeneratedforthequerytotheResultListenerhandleprovidedwiththequery.Inaddition,forpersistentqueries,thisuniqueidisreturnedtotheapplicationasareceiptofregistrationthatcanbeusedinsubsequentinteractionstoderegisterthequeryassociatedwiththeparticularuniqueid.Whentheunderlyingprotocolimplementation(accessedthroughtheStrategypatterndescribednext)returnsaresulttoaquery,theQueryResultisforwardedtotheSceneView,whichusesitslocaldatastructuretomaketheQueryResultbacktotheappropriateResultListener,basedontheuniquequeryidreferencedintheQueryResult.TheResultListenerthenpassestheresultbacktotheapplicationbyinvokingtheresultReceivedmethodintheResultListenerinterface.Thelocaldataproxies(i.e.,theQueryandQueryResult)mediatebetweentheSceneandtheSceneViewAPIsandtheprotocolimplementationsthatunderliethemiddleware.AsshowninFigure8,multiplequeriesmaybeactiveoverasinglesceneatanygiventime.Foreachscene,theSceneViewcontrolsallofthesequeriesandconnectsthemtotheunderlyingimplementationviathestrategypatterninterface.4.2StrategyPatternInterfaceInourmiddleware,wemakeuseofthestrategypattern[7].Thestrategypatternisaparticularsoftwaredesignpattern,wherealgorithms(suchasstrategiesforquerydissemination)canbechosenatruntimedependingonsystemconditions.Thestrategypatternprovidesameanstodeneafamilyofalgorithms,encapsulateeachoneasanobject,andmaketheminterchangeable.Suchanapproachallowsthealgorithmstovaryindependentlyfromclientsthatusethem.FortheDAISmiddleware,theclientsthatemploythestrategiesarethequeries,andthedierentstrategiesaretheSceneStrategyalgorithmsThesealgorithmsdeterminehowaQueryisdisseminatedtotheSceneandhowtheQueryResultisreturnedfromtheScene.Ifaparticularquerydissemina-tionalgorithmotherthanthedefaultalgorithmisrequiredforaspecicapplication,anappropriateSceneStrategyalgorithmisinstantiatedandpluggedintotheSceneStrategy.Twoprincipledirectivesofobject-orienteddesignareusedinthestrategypattern:Encapsulatetheconceptthatvaries.12 Operation Description protectedSceneView() Theconstructorispackageprotectedbecausetheonly accesstoaSceneViewisthroughitsassociatedScene. voidsendQuery(Queryq, Sendsaone-timequerytotheScene.Theresultlistener ResultListenerr) receivesresultsfromthisquery. intregisterQuery(Queryq, RegistersapersistentqueryontheScene.Thefrequency ResultListenerr, indicateshowoftenreadingscomefromeachqualied intfrequency) sensorinthescene.Themethodreturnsareceiptthatcan beusedtocanceltheregistrationwhendesired. voidsendAggQuery(Queryq, Sendsaone-timequery,requestingin-networkaggregation. ResultListenerr, Theuserprovidestheaggregationfunction. Aggregatora) intregisterAggQuery(Queryq, RegistersapersistentqueryontheScene,requestingin- ResultListenerr, networkaggregation.Theuserprovidestheaggregation intfrequency, function.Themethodreturnsareceiptthatcanbeused Aggregatora) tocanceltheregistrationwhendesired. voidderegisterQuery(intreceipt) Stopstheregisteredqueryreferencedbythereceipt. Figure7.SceneViewAPIoperationsregisterAggQuery:Theapplicationasksfortheaveragetemperaturefromconcretesensorsinthesceneeveryveminutes.(Theprotocolrealizingsuchaquerymaydierfordierentfrequencies.Forhigh-frequencyqueries,itwilllikelymakesensetopushtheproactivenesstothesensors.Forlow-frequencyqueries,i.e.,ontheorderofminutes,itmaybemoreecienttosendaone-timequeryeachtimesincetheexpenseofmaintainingthescenewillnotbeamortizedovermanyresults,especiallyiftheuserissignicantlymobile.)Eachqueryisdispatchedtoeverynodethatiswithinthesceneandeverynoderespondstoeachquery.Themiddlewareimplementationofthisquerymodelincludesthreeadditionalabstractions:theQueryobject,theQueryResultobject,andtheResultListenerobject.ThedeclarativespecicationofaQueryallowstheprogrammertodescribethedatahewants,withoutrequiringhimtospecifyhowitshouldbeobtained.Therefore,thequeryprocessinglayercanchangehowitrunsaquery,withoutrequiringthequeryitselftobechanged,whichwillbeexplainedinSection4.Inourinitialprototype,aQueryprovidesadeclarationofasimpledatatypeprovidedbyasensor.Toeasetheprogrammingtask,thetypesenabledarebuilt-inasconstantswithinthemiddleware,sobuildingaqueryisaseasyasselectingaMetricforthescene.Morecomplicateddatatypesareconstructedusingthevirtualsensors(describedbrie yearlier),whichareoutsidethescopeofthispaper.Forexample,asinglesensormayprovidetemperatureorlocationinformation,whileavirtualsensorcanprovidethecombinationofhtemperature,locationi.Withinthemiddleware,eachdatatypemustalsodenehoweachstyleofaggregationisperformedonthetype(e.g.,whatitmeanstoaveragetheparticulartypeofdata).Forthemostcommoncases(e.g.,numericaldatavalues),thesedenitionsareprovidedinthedatatypebaseclass.Whileweomitthespecicsforbrevity,theinterfaceforintroducingnewdatatypes(aswellastheinterfacesforintroducingnewaggregatorsornewmetrics)arequitesimpleandmakeeveryeorttoguideanoviceprogrammerincreatingcorrectconstructs.AResultListenerisregisteredtoreceivetheresultsofeachquery.Whentheresultisready,themiddlewarecallstheresultReceived(QueryResult)methodfortheresultlistenerstoforwardtheresultstotheapplication.Thisachievesanasynchronousandnonblockingimplementation,sothattheapplicationcanperformothertasksincasenoresponsecomesbacktothequeryortheresponseforthequeryisdelayed.10 (a) (b)Figure4.Accuracyoflocation-basedScenecalculationsnetworkwaslargelydisconnected,soourapproachdidnotmissmanyconnectedscenemembers.Totherightofthevalley,thenetworkwasmuchmoreconnected,andthedirectapproachisquitesuccessful.TheresultsdepictedinFigure4arguethatourapproachtendstondthevastmajorityofthemembersofasceneunderreasonableconditions.Forthisreason,DAISfavorsthesimplicityofnaturalscenespecications(describednext)overcompleteaccuracyofscenemembership.3.1.2AProgrammingInterfaceforSceneDenitionTopresentthedynamicsceneconstructtotheapplicationdeveloper,webuildasimpleAPIthatin-cludesbuilt-ingeneral-purposemetrics(e.g.,hopcount,distance,etc.)andprovidesastraightforwardmechanismfordeveloperstoinsertadditionalmetrics.Figure5showstheAPIfortheSceneclass.classScenefpublicScene(Constraints[]c);publicSceneViewgetSceneView();gFigure5.TheAPIfortheSceneclassFromtheapplication'sperspective,thesceneisadynamicdatastructurecontainingasetofqualiedsensorswhichareconstrainedasspeciedbyalistofconstraints,Constraints[],andaccessedthroughaSceneView.EachconstraintisatripleoftheformhMetricm,Aggregatora,Thresholdti,and,tobeincludedinaScene,adatasource'smetricvaluemustmeettheseconstraints.ThegetSceneView()methodprovidesaccesstothedatasourcesintheSceneandseparatesthecontentsofascenefromtheaccesstothosecontents.Thus,ausercanspecifyasceneandseamlesslyaccesstherelevantdatasources,whichmaychangeastheusermoves,withoutrequiringhimtochangehisscenedenition.Figure6showssomeexamplesofhowscenesmaybespecied.Theseexamplesincluderestrictingthescenebythemaximumnumberofhopsallowed,theminimumallowablebatterypoweroneachparticipatingnode,orthemaximumphysicaldistance.Asoneexample,SCENE HOP COUNTisametricexplicitlydenedwithintheDAISarchitecture,andithastheeectofassigningavalueofonetoeachnetworklink.Therefore,usingthebuilt-inSCENE SUMaggregator,theapplicationcanbuild8 needtobe.Consider,forexample,aconstructionsitesupervisorthatwantstomonitortheaverageconcretecurerates.Hemaychoosetolimittheconcretepadstothosethatliewithinacircleofradiusvemetersaroundhimorhemaychoosetoreceivetheaverageconcretecureratesoveralltheconcretepadsthroughouttheconstructionsite.Thesceneforthelattercasewouldbespeciedas\allconcretecureratesensorswithintheconstructionsiteboundaries."Inthisexample,\within5m"or\withintheconstructionsiteboundaries"speciesthethreshold.Fortime-sensitiveinformation,hemayneedtofurtherrestrictthesetofconcretepadsensorsheinteractswithbasedonthelatencyofthelinks.Furthermore,astheconstructionsitesupervisorwalksthroughthesite,thescenespecicationstaysthesame,butthedatasourcesbelongingtothescenemaychange.Asimilarconceptwasexploredinmobileadhocnetworksinthenetworkabstractionsmodel[27]whichallowsapplicationstoprovidemetricsoverpathsofnetworkconnectivity.Nodestowhichthereexistsapathsatisfyingthemetricareincludedinthespecier'snetworkcontext,whilethoseoutsideareexcluded.Thisapproachisoverlyexpressive,makingitdicultforthenoviceapplicationdevelopertospecifysimplemetricsusingtheprogramminginterface.Also,asitwasbuiltformorecapabledevices,itistoocomplexforoperationonlightweightsensornodes.Morerecently,similarconceptshavebeenexploredinthecontextofsensornetworks.Hood[33]allowssensornodestodeneareasaroundthemselvesbasedonhopcountsandothernetworkproperties.Coordinationisthenperformedwithinthisneighborhood.Similarly,AbstractRegions[32]allowsapplicationstodeneregionsofcoordinationbutcouplestheabstractionwithprogrammingconstructsthatallowapplicationstoissueoperationsovertheregions.Whilebothapproacheshaveshownpromiseincoordinatingtraditionalsensornetworkapplicationslikeobjecttrackingandcontournding,theapproachesarenotevaluatedwithrespecttothedynamicspresentinouroperationalenvironmentandbothrequireconstantproactivebehaviorofanysensorthatmaybelongtoaregion.Mobicast[25]denesamessagedisseminationalgorithmforpushingmessagestonodesthatfallinaregioninfrontofamovingtarget.Itprovides\just-in-timedelivery"toallownodestosleepuntiltheyneedtoreceiveamessagebypredictingthemovementpatternofthetarget.MobiQuery[20]alsosupportsspatiotemporalqueriesinawirelesssensornetworkandallowsaqueryareatorespondtoauser'sannouncedmotionprole.Thequeryareaisdenedusingspatiotemporalpropertiesprovidedbytheapplication.Thesceneconcept,ontheotherhand,seekstominimizetheoverallcommunicationcostincurredbyhavingalightweightcollectionalgorithmthatreactsdirectlytoauser'sactualmovement.3.1.1DeningScenesBasedonPhysicalCharacteristicsThemetricsusedtospecifyscenescanbedividedintotwocategories.Therstcategorydenesscenesbasedonpropertiesofnetworkpaths,eitherdenedbycharacteristicsofthelinks(e.g.,latency)orofthedevices(e.g.,batterypower).Thesecondcategorydenesscenesbasedonphysicalcharacteristicsoftheenvironment(e.g.,locationortemperature).Theabilitytoqueryanetworkbasedonsuchphysicalcharacteristicsisimportanttomanyapplications.However,theattempttouseaphysicalcharacteristicsuchaslocationtocalculatenetworkpathsisplaguedbytheC-shapednetworkproblem.ConsiderthenetworkshowninFigure3.Inthiscase,nodesAandBarewithin50metersofeachother,yetadiscoveryfromAtoBmustleavetheregionofradius50meterssurroundingAinordertondB.Theonlywaytoguaranteethateverydevicewithinadistanceradiusisdiscoveredisto oodtheentirenetwork.Thenetworkabstractionsmodel[27]directlyrecognizesthissituationandguaranteesthatitcalculatesacorrectregionbyrequiringapplications'regiondenitionstoincludemetricsthatstrictlyincreasealonganetworkpath.Absolutephysicaldistanceisnotsuchametric,sototintothismodel,itmustbecombinedwithanothermetricthatdoessatisfytherequirement(e.g.,hopcount).TheAbstractRegions[32]approachimplicitlyaddressesthisissueby6 provideindirectmeasurementsofabstractconditions(that,bythemselves,arenotphysicallymeasurable)bycombiningsenseddatafromagroupofheterogeneousphysicalsensors.Forexample,onanintelligentconstructionsite,usersmaydesirethecranestohavesafeloadindicatorsthatdetermineifacraneisexceedingitscapacity.Suchavirtualsensorwouldtakemeasurementsfromphysicalsensorsthatmonitorboomangle,load,telescopinglength,two-blockconditions,windspeed,etc.[23,24].Signalsfromtheseindividualsensorsareusedincalculationswithinthevirtualsensortodetermineifthecranehasexceededitssafeworkingload.Withthevirtualsensorsmodel,anapplicationperceivestheenvironmentthroughacombinationofphysicalandvirtualsensorsthatprovidetheapplicationwiththenecessaryinformationaboutitsenvironment.Inthispaper,wefocusnotonthedenitionofthesevirtualsensors,butonthebehavioralprogrammingabstractionsDAISprovidesforapplicationdevelopment.Werstdescribehowadeveloperdenesanimmersivesensorenvironment,wherethelocalityofinteractionsisspeciedbyanabstractioncalledthescene.Wethendetailhowprogramsdynamicallyinteractwithdatafromtheenvironmentthroughahigh-levelprogramminginterface.Thedetailsoftheunderlyingimplementationsoftheabstractions(i.e.,thelowerlevelsofFigure2andallofthecomponentson-boardthesensors)willbedescribedinSection4.3.1Scenes:DeclarativeSpecicationsofLocalInteractionsInaninstrumentedsensornetwork,auser'soperationalcontextishighlydynamic.Thatis,thesetofavailabledatasourceschangesbasedontheuser'slocationandmovement.Furthermore,ifthesensornetworkiswell-connected,theuser'sdevicewillbeabletoreachvastamountsofrawinformationthatmustbelteredtobeusable.Foranecientapproach,theapplicationmustbeabletolimitthescopeofitsinteractionstoincludeonlythedatathatmatchesitsneeds.Inourmodel,anapplication'soperatingenvironment(i.e.,thesensorswithwhichitinteracts)isencapsulatedinanabstractioncalledascene.Byitsdenition,asceneconstrainswhichparticularsensorsmayin uenceaparticularapplication.Theconstraintsmaybeonpropertiesofhosts(e.g.,batterylife),ofnetworklinks(e.g.,bandwidth),andofdata(e.g.,type).Thesetypesofconstraintsoergeneralityand exibilityandprovideahigherlevelofabstractiontotheapplicationdeveloper.Thedeclarativespecicationdeningasceneallowsanapplicationprogrammertodescribethetypeofscenehewantstocreate,withoutrequiringhimtospecifytheunderlyingdetailsofhowitshouldbeconstructed.Theprogrammeronlyneedstospecifythreeparameterstodenetheconstraints:Metric:Aquantiablepropertyofthenetworkorofthephysicalenvironmentthatdenesthecostofaconnection.Aggregator:Anaggregationfunction(suchasSUM,AVG,MIN,MAX)thatoperatesonlinkweightsinanetworkpathtocalculatethecostofthepath.Threshold:Thethresholdvaluethatthecostcalculatedforapathmustsatisfyforthatsensortobeamemberofthescene.TheuseoftheAggregatorinthisrespectisdierentfromexistingdataaggregationschemesinsensornetworks[12,21,30].Inthiscase,weareusingthesamenotionofaggregatingvaluestocalculatetheexpanseofasceneinsteadoftoconsolidatedatareadingsenroutebacktoarequester.WerevisittheuseofthisAggregatorinterfaceforamoretraditionalpurposeinSection3.2.Eventhoughthesceneconceptconveysanotionoflocality,anapplicationmaychooseitsscenetobeasexpansiveasthewholenetwork.Thatistheapplicationmaydecidehow\local"theinteractions5 adiculttask.Inimmersivesensornetworks,however,theprogrammingburdensaremagniedduetothechallengesdescribedhere.Inaddition,thedesiretoprovideend-userapplications(asopposedtomoredatabaseorienteddatacollection)increasesthedemandforapplicationsandthenumberofprogrammersthatwilldesiretoconstructthem.Thecon uenceofthesechallengesdemonstratestheneedfor exibleyetexpressiveprogrammingenvironmentsthatenableapplicationdevelopmentforimmersivesensornetworkswhilepayingcarefulattentiontoresourceconstraints.DAIS,describednext,addressestheseconcernsbyprovidingintuitiveabstractionsoftheimmersiveenvironment.3TheDAISMiddlewareModelInthissection,wediscussthehigh-levelmiddlewaremodelusedinDAIS.Figure2showstheDAISarchitecture,whichconsistsofahandheldcomponent(runningoneitheralaptoporaPDA)andtheimmersivesensorenvironment(asdenedbyacommunityofsensors). Figure2.TheDAIShigh-levelarchitecture.Theleft-handsideshowsthecomponentscomprisingthemodelonthecomponentcarriedbytheuser(e.g.,PDAorlaptop),andtheright-handsideshowstheDAIScomponentsonthesensors.AsFigure2shows,aclientapplicationrunswiththesupportoftwokeyabstractions,namelybehav-ioralprogrammingabstractionsandvirtualsensors.Throughinterfacesprovidedbythesecomponents,theapplicationdevelopernotonlydeneshisapplications'interactionenvironments,butcanalsopro-grammaticallyspecifytheirdatarequests.Thesecondofthesecomponents,virtualsensors,provideprogrammingsupportthatallowsapplicationstospecifysophisticatedaggregationmechanismsforheterogeneousdatasources.Suchvirtualsensors4 (a)Usingtoday'scapabilities,auser'squeryisphysicallydetachedfromthesensoreld.Res-olutionofthequeryreliesonacentralizedcollectionpoint,generallytherootofaroutingtreeconstructedoverthenetwork. (b)UsingDAIS,anapplicationrunningontheuser'sdevicecanseamlesslyconnecttothesensorsinthelocalregion,removingtherequirementthatphysicallydistantsensorsparticipateinthequery'sresolution.Figure1.Comparisonof(a)existingoperationalenvironmentswith(b)theoperationalenvironmentimposedbyDAIS.thatexistingcollectionbehaviorsthatsense,aggregate,andstreaminformationtoacentralcollectionpointmaystillbeusefuleveninimmersivesensornetworks,thispaperundertakesonlytheportionoftheproblemrelatedtoenablingapplications'direct,on-demandinteractions.Fromthisperspective,ourapproachfocusesonusingsensornetworkstoenablepervasivecomputingapplications,notonremotedistributedsensing.Thisstyleofinteractiondiersfromcommonusesofsensornetworks,introducingseveraluniquechallengesandheighteningexistingones:Localityofinteractions:asdescribedabove,anapplicationwilloftenwishtointeractdirectlywithlocalsensornodes.Whilethiscanbebenecialwithrespecttominimizingthecommunicationoverheadandlatency(seeFigure1),itcanalsobecumbersomewithrespecttoenablingtheapplicationtopreciselyspecifytheareafromwhichitneedstocollectinformation.Mobilityinduceddynamics:whilethesensornodesarestilllikelystationary(asinmanyotherdeployments),theapplicationinteractingwiththesensorsrunsonadevicecarriedbyausermovingamongthesensors.Therefore,thedevice'sconnectionstoparticularsensorsandtheareafromwhichtheapplicationdesirestodrawinformationaresubjecttoconstantchange.Unpredictabilityofcoordination:whileotherrecentworkinsensornetworkshasalsomotivatedtheneedforgeneral-purposealgorithmicsolutions,suchconcernsareaggravatedinimmersivesensornetworkswhichdemandthatthenetworkbegeneral-purpose.Assuch,fewaprioriassumptionscanbemadeabouttheneedsorintentionsofapplicationsthatwillruninthenetwork,requiringthenetworktoadapttounexpectedandchangingsituations.Complexityofprogramming:applicationdevelopmentforsensornetworksislargelyrecognizedas3 needforprogrammingplatforms(i.e.,middleware)thatprovideabstractionsforsimplifyingapplicationdevelopment.Asdescribedinmoredetailinlatersections,muchoftheexistingworkinsimplifyingtheprogrammingtaskinsensornetworksfocusesonapplication-specicnetworkswherethenodesarestaticallydeployedbyaparticulardevelopertoserveaparticulartask.Weenvisionamorefuturisticbutnotunrealisticscenarioinwhichsensornetworksbecomemoregeneralpurposeandreusable.Whilethenetworksmaystillremaindomainspecic,wetargetsituationsinwhichthetypesofapplicationsthatwillbedeployedarenotknownaprioriandmayincludeapplicationswithvaryingsensingneedsandadaptivebehaviors.Examplesofsuchdomainsincludeawarehomes[17],intelligentconstructionsites[5],battleeldscenarios[13],andrstresponderdeployments[19].Finally,existingapplicationscommonlyassumethatsensordataiscollectedfromthenetworkatacentrallocationtobeprocessedandusedinthefutureand/oraccessedviatheInternet.Applicationsfromthedomainsdescribedabove,however,ofteninvolveusersimmersedinthesensornetworkthataccesslocallysensedinformationon-demand.Thisisexactlythevisionoffuturepervasivecomputingenvironments[31],inwhichsensornetworksmustplayanintegralpart[4].ThispaperintroducestheDAIS1(DeclarativeApplicationsinImmersiveSensornetworks)middlewareplatformthatprovidesobject-orientedprogrammingabstractionstailoredtotheubiquitousapplicationsdescribedabove.DAISisnotamiddlewareforsensornetworksinthesensethatitrunsstrictlyonthesensorsthemselves.Instead,DAISallowsdeveloperstocreateapplicationsthatrunonclientdevices(e.g.,laptopsorPDAs)thatinteractdirectlywithanembeddedsensornetwork.Whilethisstyleofinteractioniscommoninmanyapplicationdomains(includingthoseenumeratedabove),throughouttheremainderofthepaperwewilluseapplicationsfromanintelligentjobsitetomotivatethemiddlewareanditsprovidedconstructs.Suchanenvironmentprovidesauniqueandheterogeneousmixofsensingandmobiledevices.Theformerincludessensorsonequipmenttomeasureitslocation,withinconcretetomeasuretemperatureandgeneratecureddata,oncranestomeasuretheirmovementandstresses,andevennearbytohazardousmaterialstomeasuretheconcentrationofpotentiallydangerouschemicals.Mobiledevicesincludethosemovingwithinvehiclesorcarriedbyworkers[16].Severalapplicationsinthisscenariodemandopportunisticinteractionwithlocallyavailablesensors,andwewillusetheseapplicationstodemonstratetheuseoftheDAISmiddleware.Thespecicnovelcontributionsofthisworkarethreefold.First,wedescribeanewmiddlewarearchi-tecturedesignedtomediatetheinteractionsofapplicationsonclientdeviceswithanimmersivesensornetwork.Second,wedevelopanessentialunderlyingabstractionthatallowsanapplicationdevelopertopreciselyspecifythedynamicsetofsensorsthatitinteractswith.Finally,wedescribeaprototypeimplementationofthismiddlewarethatincludesthecreationofaprotocolenablingadaptiveandecientconstructionoflocalzoneswithinthesensornetwork.Theremainderofthispaperisorganizedasfollows.Thenextsectiondescribesthechallenges,high-lightinghowimmersivesensorenvironmentschangetherequirementsofamiddleware.InSection3,weprovideadetaileddescriptionoftheDAISarchitectureincludingitsmostimportantaspect:thepro-gramminginterfaceprovidedtoapplicationdevelopers.Section4coverstheinternalsofthemiddleware.Section5contrastsrelatedprojects,andSection6concludes.2ProblemDenitionInthispaper,weaddresstheneedsofapplicationsdesignedforimmersivesensornetworks.Insuchscenarios,usersmovethroughaninstrumentedenvironmentanddesiretohaveon-demandaccesstoinformationgatheredfromthelocalarea.Figure1(a)showshowcurrentinteractionswithsensornetworkscommonlyoccur,whileFigure1(b)showstheneedsofourintendedapplications.Whilewerecognize 1DAIS(da0s):fromthemiddleEnglishwordmeaning\raisedplatform"2 deployedonthenodes.MiLAN[10]aimstoenableapplicationstocontrolthenetwork'sresourceusageandallocationtooptimallytunetheperformanceofanentiresensornetworkthroughthedenitionofapplicationpoliciesthatareenactedonthenetwork.Whilesuchapproachesarehighlybenecialwhentheapplicationisknownandthenetworksarerelativelyapplication-specic,theydonotmapwelltoimmersivesensornetworkswherethenodesmustbeabletoserviceavarietyofunpredictableapplications.Moregeneralizedapproachesattempttoprovideintegratedsuitesoftoolsthatenablesimpliedpro-grammingofsensornetworks.Forexample,EmStar[8]providesasuiteoflibraries,developmenttools,andapplicationservicesthatfocusoncoordinatingmicroservers(e.g.,sensingdeviceswithcomputationalpowerequivalenttoaPDA).TheSensorNetworkApplicationConstructionKit(SNACK)[9]consistsofasetoflibrariesandacompilerthatmakesitpossibletowriteverysimpleapplicationdescriptionsthatspecifysophisticatedbehavior.Agilla[5]isanagentbasedmiddlewarethatallowsapplicationstoinjectagentsintothesensornetworkthatmigrateintelligentlytocarryouttheapplications'tasks.DAISdiersfromtheseapproachesinthatitperceivesthesensornetworknotasadatarepositorybutasaninstrumentedenvironmentthathasthecapacitytoaugmentauser'spervasivecomputingexperi-ence.Similarly,TinyLime[3]isatuplespacebasedmiddlewarethatenablesmobilecomputingdevicestointeractwithsensordatainamannerdecoupledinbothspaceandtime.TinyLimeprovidesonlysingle-hopconnectionstosensorsandassumesthatthesensorsdonotcommunicateamongthemselves.Thiseectivelyplacesalloftheburdenofaggregationontheshouldersoftheapplicationdeveloper.7ConclusionsInthispaper,wehavedescribedDAIS,atieredmiddlewarethatallowsdeveloperstocreatelightweightapplicationsthatrunonclientdevices(e.g.,laptopsorPDAs)andallowuserstointeractdirectlywithanimmersivesensorenvironment.DAISdenesasetofprogrammingconstructscenteredonthesceneabstraction.Asceneisalocalizedbutdynamicviewofthesensornetworkthatadaptstochangesastheusermovesthroughhisenvironment.Byabstractingtheprocessofselectingsensorstointeractwith,DAISenablesapplicationstomakeintelligenttradeosregardingthepropertiesoftheselectedsensorsandtheircommunicationlinkswithouthavingtodirectlydealwithlow-levelprogrammingconcerns.Usingthesceneabstraction,DAISprovidesawrapperforlow-leveldataacquisitionandaggregation,allowingapplicationstouseahigh-level,asynchronousqueryandresponsemechanismforretrievingdatafromtheenvironment.Asnecessitatedbytheunpredictablesensorenvironment,theseinteractionsaredata-centric,therebydirectlyleveragingapplicationknowledgewithinthecommunicationprocess.Whilethefocusofthispaperisprogrammingabstractionsandtheensuingsimplicationofdevelop-ment,wealsodemonstratedtheaccuracywithwhichscenescanbebuiltaroundlocationinformation.Futureworkwillincludeasimilarevaluationfordierentmetricsandacompletenetworkperformanceevaluationthatconsidersscenedynamicsandmeasuresqueryresponsetimes,energyusage,andoverallcommunicationoverhead.Otherfutureworkwillincludetheintegrationofadditionalstrategiesforsceneconstructionandtheabilitytodynamicallyupdatethecodeonsensornodestoincludenewlyintroducedmetricsandaggregators.Insummary,DAISpresentsauniqueviewofprogrammingpervasivecomputingenvironmentsthatinthefuturewillincludelargenumbersofheterogeneouswirelesssensors.Bycreatinghigh-levelprogram-mingabstractionsthatencapsulatethelocalityofpervasivecomputinginteractions,DAISisarststepinenablingnoviceprogrammerstocreatesophisticatedpervasivecomputingapplications.16 (a) (b)Figure11.Accuracyoflocation-basedScenecalculationstocaseswhenthenetworkwaslargelyconnected,buttheconnectionsweresparse.Inthesesituations,roundaboutpathsmayexistbetweennodeswhenmoredirectroutesdonot.Totheleftofthevalley,thenetworkwaslargelydisconnected,soourapproachdidnotmissmanyconnectedscenemembers.Totherightofthevalley,thenetworkwasmuchmoreconnected,andthedirectapproachisquitesuccessful.TheresultsdepictedinFigure11showthatourapproachtendstondthevastmajorityofthemembersofasceneunderreasonableconditions.Forthisreason,DAISfavorsthesimplicityofnaturalscenespecicationsovercompleteaccuracyofscenemembership.6RelatedWorkSystemsdesignedtoaddressthespecicchallengesposedbysensornetworksand/orpervasivecom-putinghaverecentlybeenatopicofresearchdiscussions.Existingworkhashighlightedseveraldesigntenetsthatamiddlewareforwirelesssensornetworksmustadhereto[31],andtheDAISplatformat-temptstofollowtheseguidelines.Otherprojectshavealsoundertakensimilareorts,andwehighlightafewofthesesystems.Asoneexampleofamiddlewareforpervasivecomputing,GAIA[25]introducesActiveSpacesthatcanbeprogrammedintopervasivecomputingapplications.However,themodelassumesacentralizedandheavyweightsystemstructurewhichisindirectoppositiontothegoalofmiddlewareforcoordinatingwithwirelesssensornetworks.Projectstargeteddirectlyforsensornetworkshaveoftenexploredrepresentingthesensornetworkasadatabase.TwodemonstrativeexamplesareTinyDB[21]andCougar[30].Generallytheseapproachesenableapplicationswithdatarequeststhat owoutfromacentralpoint(i.e.,abasestation)andcreateroutingtreestofunnelrepliesbacktothisroot.Muchoftheworkwithintheseapproachesfocusesonperformingintelligentinnetworkaggregationandroutingtoreducetheoverallenergycostwhilestillkeepingthesemanticvalueofdatahigh.VM?[17]providesavirtualmachineapproachdirectedathandlingdeviceheterogeneity.WhilethisisalsoanimportantconcerninDAIS,VM?assumessituationswheretheapplicationanditsneedscanbeknowninadvancesothattheVMdeployedcanbeoptimizedwithrespecttotheapplicationanddevice.TinyGALS[1]allowsprogrammerstorepresentapplicationsintermsofrelativelyhigh-levelcomponentswhicharesubsequentlysynthesizedintothelow-level,lightweight,ecientprogramsthatare15 Figure9.ImplementationoftheQueryProcessorfunctionalityonsensorsisaone-timequery(i.e.,ifthepersistent agisfalse),thentheQueryProcessorsimplyconnectstotheon-boardsensorthatcanprovidetherequesteddatatype(depictedasSensorinthegure)throughtheADCinterface.Ifthedatarequestisforasensortypethatisnotsupportedonthisdevice(i.e.,thesensortablestoredintheQueryProcessorhasnomappingtoasensorthatcanprovidethespecieddatatype),thenthemessageisignored.Thenodeisstillincludedinthescenebecauseitmaybeanecessaryroutingnodeconnectingtherequestertoanothernodethatdoeshavetherequiredsensor.Ifthequeryispersistent,theninadditiontoimmediatelyreturningtherequestedvalue,theQueryProcessorMmodulealsoinitializesaQueryTimerusingtherequestfrequencyspeciedinthedataportionofthereceivedmessage.Whenthetimerres,QueryProcessorMretrievesavaluefromthesensorandsendsitbacktotheinitialrequesterusingthesendMsginterfaceoftheQueuedSendmodule.Whenanodeisnolongerinascene,theSceneMmodulecreatesanullmessagethatitsendstotheQueryProcessorthroughtheReceiveinterface.TheQueryProcessortakesthismessageasasigntoceasestreamingdatabacktotherequester,andstopstheQueryTimer.5ACaseStudyinSceneDenitionThemetricsusedtospecifyscenescanbedividedintotwocategories.Therstdenesscenesbasedonpropertiesofnetworkpaths,eitherdenedbycharacteristicsoflinks(e.g.,latency)ordevices(e.g.,batterypower).Thesecondcategorydenesscenesbasedonphysicalcharacteristicsoftheenvironment(e.g.,locationortemperature).Theabilitytoqueryanetworkbasedonsuchphysicalcharacteristicsisimportanttomanyapplications.However,theattempttouseaphysicalcharacteristicsuchaslocationtocalculatenetworkpathsisplaguedbytheC-shapednetworkproblem.ConsiderthenetworkshowninFigure10.Inthiscase,nodesAandBarewithin50metersofeachother,yetadiscoveryfromAtoBmustleavetheregionofradius50meterssurroundingAinordertondB.Theonlywaytoguaranteethateverydevicewithinadistanceradiusisdiscoveredisto oodtheentirenetwork.Thenetworkabstractionsmodel[24]directlyrecognizesthissituationandguaranteesthatitcalculatesacorrectregionbyrequiringapplications'regiondenitionstoincludemetricsthatstrictlyincreasealonganetworkpath.Absolutephysicaldistanceis13 componentsmakesthesystemeasiertomaintain,extend,andreuse.Fornow,weprovideonlyasingleimplementationofthestrategy,theBasicScene.Thisisasimple,greedyschemeinwhichalldataaggregationisperformedlocally.Wehavechosenthisasarststeptoprovideaquickprototypeoftheentiremiddleware.OthercommunicationapproachescanbeswappedinfortheBasicScene(forexampleonebuiltaroundTinyDB[21]ordirecteddiusion[14],althoughtheimplementationsoftheseapproachesonthesensorsmayhavetobemodiedslightlytoaccommodatesceneconstruction).BydeningtheSceneStrategyinterface,weenabledeveloperswhoareexpertsinexistingcommunicationapproachestocreatesimpleplug-insthatusedierentquerydisseminationand/oraggregationprotocols.Dierentcommunicationparadigmscanbeusedindierentenvironmentsortosupportdierentapplicationdomainsdependingontheresourceconstraintsordomain-speciccapabilitiesofthedevicesinaparticulardomain.EachSceneStrategyinteractswiththejavax.commpackagetoprovidetheDAISabstractionproto-colsthatallowtheportionofthemiddlewareimplementedinJava(describedabove)tointeractwiththesensorhardware.EachSceneStrategyrequiresnotonlyahigh-levelportionimplementedonthehandhelddevice,butalsoalow-levelportionthatrunsonthesensors.Inthenextsection,wedetailourimplementationoftheportionoftheBasicScenethatmustrunonthesensornodesthatrespondtoaclientapplication'squeries.ThisservesasjustoneexampleofaparticularimplementationoftheSceneStrategy.4.3RealizingtheSceneImplementationonResourceConstrainedSensorsInDAIS,sensorcomponentshavebeendevelopedfortheCrossbowMica2moteplatform[2].OurinitialimplementationiswrittenforTinyOS[13]inthenesClanguage[7]andhelpstheBasicScenestrategyconformtotheSceneStrategyinterfacedescribedpreviously.4.3.1BuildingScenesInnesC,anapplicationconsistsofmoduleswiredtogetherviasharedinterfacestoformcongurations.WehavecreatedseveralcomponentsthatformthefundamentalfunctionalityoftheSceneconguration.Figure7abstractlydepictsthenecessarycomponentsandtheinterfacestheyshare.Thisimplementationfunctionsasaroutingcomponentoneachnode,receivingeachincomingmessagefromtheradioandprocessingitasourprotocoldictates.Inthispicture,weshowcomponentsasroundedrectanglesandinterfacesasarrowsconnectingcomponents.Acomponentprovidesaninterfaceifthecorrespondingarrowpointsawayfromitandusesaninterfaceifthearrowpointstowardsit.Ifacomponentprovidesaninterface,itmustimplementallofthecommandsintheinterface,andifacomponentusesaninterface,itcancallanycommandsintheinterfaceandmusthandlealleventsgeneratedbytheinterface.TheScenecongurationusestheReceiveMsginterface(providedinTinyOS)whichallowsthecom-ponenttoreceivemessagesincoming(byhandlingthereceiveevent).ThestructureofthemessagesreceivedthroughthisprocessisshowninFigure8.ThemessagecontainstwoconstantsthatinstructtheSceneMcomponentinprocessingthescenecalculation.Therstindicatesthepropertyusedtoconstructthescene(e.g.,SCENE DISTANCEfromFigure4).Thesecondindicatestheaggregationfunctiontobeused(e.g.,SCENE MINfromFigure4).Theuseoftheseconstantsmakestheimplementationabitmorein exiblebecausethesetofmetricsthatcanbeusedinanetworkmustbeknownonthesensorsapriori,buttheapproachpreventsmessagesfromhavingtocarrythecodethatdenestheevaluation.ThemetricValueintheSceneMsgallowstheScenebuildingprocesstopropagatestate.ThepreviousHopintheSceneMsgallowsthisnodetoknowitsparentintheroutingtree,whichisimportantinmaintainingthesceneastherequestermovesthrough10 Figure6.SimpliedobjectdiagramforDAISsendaQueryovertheScene.Uponreceivinganyqueryrequest,theSceneViewobjectadjustsitsstateinseveralways.First,foreveryquery,atablewithintheSceneViewisupdatedwithamappingfromauniquequeryidgeneratedforthequerytotheResultListenerhandleprovidedwiththequery.Inaddition,forpersistentqueries,thisuniqueidisreturnedasareceiptofregistrationthatcanbeusedinsubsequentinteractionstoderegisterthequery.Whentheunderlyingprotocolimplementationreturnsaresulttoaquery,theQueryResultisfor-wardedtotheSceneView,whichusesitslocaldatastructuretodelivertheQueryResulttotheappropri-ateResultListener,byinvokingtheresultReceivedmethodintheResultListenerinterface.Thelocaldataproxies(i.e.,theQueryandQueryResult)mediatebetweentheSceneandtheSceneViewAPIsandtheprotocolimplementationsthatunderliethemiddleware.AsshowninFigure6,multiplequeriesmaybeactiveoverasinglesceneatanygiventime.Foreachscene,theSceneViewcontrolsallofthesequeriesandconnectsthemtotheunderlyingimplementationviathestrategypatterninterface.4.2StrategyPatternInterfaceOurmiddlewaremakesuseofthestrategypattern[6],asoftwaredesignpatterninwhichalgorithms(suchasstrategiesforquerydissemination)canbechosenatruntimedependingonsystemconditions.Thestrategypatternprovidesameanstodeneafamilyofalgorithms,encapsulateeachoneasanobject,andmaketheminterchangeable.Suchanapproachallowsthealgorithmstovaryindependentlyfromclientsthatusethem.InDAIS,theclientsthatemploythestrategiesarethequeries,andthedierentstrategiesaretheSceneStrategyalgorithms.ThesealgorithmsdeterminehowaQueryisdisseminatedtotheSceneandhowtheQueryResultisreturned.Ifaparticulardisseminationalgorithmotherthanthedefaultisrequiredforaspecicapplication,anappropriateSceneStrategyalgorithmisinstantiated.Twoprincipledirectivesofobject-orienteddesignareusedinthestrategypattern:encapsulatetheconceptthatvaries,andprogramtoaninterface,nottoanimplementation.Usingthestrategypattern,wedecoupletheQueryfromthecodethatrunsitsowecanvarythequerydisseminationalgorithmwithoutmodifyingtheQueryclass.Theloosecouplingthatthestrategypatternenablesbetweenthe9 Operation Description voidsendQuery(Queryq, Sendsaone-timequerytotheScene.Theresultlistener ResultListenerr) receivesresultsfromthisquery. intregisterQuery(Queryq, RegistersapersistentqueryontheScene.Thefrequency ResultListenerr, indicateshowoftenreadingscomefromeachqualied intfrequency) sensorinthescene.Themethodreturnsareceiptthatcan beusedtocanceltheregistrationwhendesired. voidsendAggQuery(Queryq, Sendsaone-timequery,requestingin-networkaggregation. ResultListenerr, Theuserprovidestheaggregationfunction. Aggregatora) intregisterAggQuery(Queryq, RegistersapersistentqueryontheScene,requestingin- ResultListenerr, networkaggregation.Theuserprovidestheaggregation intfrequency, function.Themethodreturnsareceiptthatcanbeused Aggregatora) tocanceltheregistrationwhendesired. voidderegisterQuery(intreceipt) Stopstheregisteredqueryreferencedbythereceipt. Figure5.SceneViewAPIoperationswants,withoutrequiringhimtospecifyhowitshouldbeobtained.Therefore,thequeryprocessinglayercanchangehowitrunsaquery,withoutrequiringthequeryitselftobechanged.Inourinitialprototype,aQueryprovidesadeclarationofasimpledatatypeprovidedbyasensor.Toeasetheprogrammingtask,thetypesenabledarebuilt-inasconstantswithinthemiddleware,sobuildingaqueryisaseasyasselectingaMetricforthescene.Morecomplicateddatatypesareconstructedusingvirtualsensors.Withinthemiddleware,eachdatatypemustalsodenehoweachstyleofaggregationisperformedonthetype(e.g.,whatitmeanstoaveragethedata).Forcommoncases(e.g.,numericaldata),thesedenitionsarebuiltintothebaseclass.Whileweomitthespecicsforbrevity,theinterfaceforintroducingnewdatatypes(aswellastheinterfacesforintroducingnewaggregatorsornewmetrics)isquitesimpleandmakeseveryeorttoguideanoviceprogrammerincreatingcorrectconstructs.AResultListenerisregisteredtoreceivetheresultsofeachquery.Whentheresultisready,themiddlewarecallstheresultReceived(QueryResult)methodfortheresultlistenerstoforwardtheresultstotheapplication.Thisachievesanasynchronousandnonblockingimplementation,sothattheapplicationcanperformothertasksincasenoresponsecomesbacktothequeryortheresponseforthequeryisdelayed.4ImplementationDetailsInthissection,wedescribetheinternalsoftheDAISmiddlewarethatprovidestheseprogrammingabstractionsdescribedabove.Figure6depictsasimpliedobjectdiagramoftheDAISmiddlewarelayers.ThenamesofthelayersontherightofthegurecorrespondtothelayersinFigure3.Werstgivebriefdetailsofthetoplayersofthisdesign,relatingthemtoourdiscussionoftheAPIinSection2.Wethendiscusstheideaofthestrategypattern,itsimportancetotheoveralldesignofthesystem,andhowourmiddlewaremakesuseofthisconcept.Finally,wewilldetailoneexamplerealizationofthesceneabstractiononthesensors.4.1ApplicationProgrammingInterfaceTheSceneobjectiscreatedthroughtheAPIprovidedtotheapplicationdeveloper,asdiscussedinSection3.Thatis,whentheapplicationneedstoquerytheScene,itcallsthegetSceneView()methodwhichreturnsahandletoaSceneView.OncetheapplicationhasthisaccesstotheScene,itisfreeto8 coordinationbutcouplestheabstractionwithprogrammingconstructsthatallowapplicationstoissueoperationsovertheregions.Whilebothapproacheshaveshownpromiseincoordinatingtraditionalsensornetworkapplicationslikeobjecttrackingandcontournding,theapproachesdonotdirectlyconsiderdynamicsandbothrequireconstantproactivebehaviorofanysensorthatmaybelongtoaregion.Mobicast[23]denesamessagedisseminationalgorithmforpushingmessagestonodesthatfallinaregioninfrontofamovingtarget.Itprovides\just-in-timedelivery"toallownodestosleepuntiltheyneedtoreceiveamessagebypredictingthemovementpatternofthetarget.MobiQuery[19]alsosupportsspatiotemporalqueriesinawirelesssensornetworkandallowsaqueryareatorespondtoauser'sannouncedmotionprole.Thesceneconcept,ontheotherhand,seekstominimizetheoverallcommunicationcostincurredbyhavingalightweightcollectionalgorithmthatreactsdirectlytoauser'sactualmovement.3.1.1AProgrammingInterfaceforSceneDenitionTopresentthedynamicsceneconstructtotheapplicationdeveloper,webuildasimpleAPIthatin-cludesbuilt-ingeneral-purposemetrics(e.g.,hopcount,distance,etc.)andprovidesastraightforwardmechanismfordeveloperstoinsertadditionalmetrics.Figure3showstheAPIfortheSceneclass.classScenefpublicScene(Constraints[]c);publicSceneViewgetSceneView();gFigure3.TheAPIfortheSceneclassFromtheapplication'sperspective,thesceneisadynamicdatastructurecontainingasetofqualiedsensorswhichareconstrainedasspeciedbyalistofconstraints,andaccessedthroughaSceneView.EachconstraintisatriplehMetricm,Aggregatora,Thresholdti,and,tobeincludedinaScene,anode'svalueforthemetricmustmeettheseconstraints.ThegetSceneView()methodprovidesaccesstothedatasourcesintheSceneandseparatesthecontentsofascenefromtheaccesstothosecontents.Thus,ausercanspecifyasceneandseamlesslyaccesstherelevantdatasources,evenashemovesandtheparticularsourceschange.Figure4showssomeexamplesofhowscenesmaybespecied.Theseexamplesincluderestrictingthescenebythenumberofhopsallowed,therequiredbatterypoweroneachparticipatingnode,orthemaximumphysicaldistance.Wenotethatbatterypowerbyitselfmaynotbeagoodmetric(sinceitdoesnotconveyanynotionoflocality),buttheuseofmultipleconstraintsinascenedenitionallowsittobenaturallyandeasilycombinedwithothermetrics(suchasdistanceorhopcount,toensurethatthequerystopspropagating). HopCountScene BatteryPowerScene DistanceScene Metric SCENE HOP COUNT SCENE BATTERY POWER SCENE DISTANCE Aggregator SCENE SUM SCENE MIN SCENE DFORMULA MetricValue numberofhopstraversed minimumbatterypower locationofsource Threshold maximumnumberofhops minimumallowablebatterypower maximumphysicaldistance Figure4.ExampleSceneDenitions6 (a)Usingtoday'scapabilities,auser'squeryisphysicallydetachedfromthesensoreld.Res-olutionofthequeryreliesonacentralizedcollectionpoint,generallytherootofaroutingtreeconstructedoverthenetwork. (b)UsingDAIS,anapplicationrunningontheuser'sdevicecanseamlesslyconnecttothesensorsinthelocalregion,removingtherequirementthatphysicallydistantsensorsparticipateinthequery'sresolution.Figure1.Comparisonof(a)existingoperationalenvironmentswith(b)theoperationalenvironmentimposedbyDAIS.Thisstyleofinteractiondiersfromcommonusesofsensornetworks,introducingseveraluniquechallengesandheighteningexistingones:Localityofinteractions:Anapplicationinteractsdirectlywithlocalsensornodes.Whilethiscanminimizethecommunicationoverheadandlatency(seeFigure1),itcanalsobecumbersomewithrespecttoenablingtheapplicationtopreciselyspecifytheareafromwhichitcollectsinformation.Mobilityinduceddynamics:Whilethesensornodesarelikelystationary(asinmanyotherdeploy-ments),theapplicationinteractingwiththemrunsonadevicecarriedbyamobileuser.Therefore,thedevice'sconnectionstoparticularsensorsandtheareafromwhichtheapplicationdesirestodrawinformationaresubjecttoconstantchange.Unpredictabilityofcoordination:Immersivesensornetworksdemandthatthenetworkbegeneral-purpose.Assuch,fewaprioriassumptionscanbemadeabouttheneedsorintentionsofapplica-tions,requiringthenetworktoadapttounexpectedandchangingsituations.Complexityofprogramming:applicationdevelopmentforsensornetworksislargelyrecognizedasadiculttask.Inimmersivesensornetworks,theprogrammingburdensaremagniedduetothechallengesdescribedhere.Inaddition,thedesiretoprovideend-userapplications(asopposedtomoredatabase-orienteddatacollection)increasesthedemandforapplicationsandthenumberofprogrammersthatwillneedtoconstructthem.Thecon uenceofthesechallengesnecessitatesfor exibleyetexpressiveprogrammingenvironmentsthatenableapplicationdevelopmentforimmersivesensornetworkswhilepayingcarefulattentiontoresourceconstraints.DAISaddressestheseconcernsbyprovidingintuitiveabstractionsoftheimmersiveenvironment.3 Asdescribedinmoredetailinlatersections,muchoftheexistingworkinsimplifyingprogramminginsensornetworksfocusesonapplication-specicnetworkswherethenodesarestaticallydeployedforaparticulartask.Weenvisionamorefuturistic(butnotunrealistic)scenarioinwhichsensornetworksbecomemoregeneral-purposeandreusable.Whilethenetworksmayremaindomain-specic,wetargetsituationsinwhichtheapplicationsthatwillbedeployedarenotknownaprioriandmayincludevaryingsensingneedsandadaptivebehaviors.Examplesofsuchdomainsincludeawarehomes[16],intelligentconstructionsites[15],battleeldscenarios[12],andrstresponderdeployments[18].Finally,existingapplicationscommonlyassumethatsensordataiscollectedatacentrallocationtobeprocessedandusedinthefutureand/oraccessedviatheInternet.Applicationsfromthedomainsdescribedabove,however,involveusersimmersedinthesensornetworkwhoaccesslocallysensedinformationon-demand.Thisisexactlythevisionoffuturepervasivecomputingenvironments[27],inwhichsensornetworksmustplayanintegralrole[4].ThispaperintroducestheDAIS1(DeclarativeApplicationsinImmersiveSensornetworks)middlewareplatformthatprovidesprogrammingabstractionstailoredtotheubiquitousapplicationsdescribedabove.DAISisnotamiddlewareforsensornetworksinthesensethatitrunsstrictlyonthesensors.Instead,DAISallowsdeveloperstocreateapplicationsthatrunonclientdevices(e.g.,laptopsorPDAs)thatinteractdirectlywithembeddedsensornetworks.Whilethisstyleofinteractioniscommoninmanyapplicationdomains,throughoutthepaperwewilluseapplicationsfromanintelligentjobsitetomotivatethemiddlewareanditsprovidedconstructs.Suchanenvironmentprovidesauniqueandheterogeneousmixofsensingandmobiledevices.Thefor-merincludessensorsonequipmenttomeasureitslocation,withinconcretetomeasuretemperatureandgeneratecureddata,oncranestomeasuretheirmovementandstresses,andevennearhazardousmate-rialstomeasuretheconcentrationofpotentiallydangerouschemicals[15].Mobiledevicesincludethosemovingwithinvehiclesorcarriedbyworkers.Theapplicationsinthisscenariodemandopportunisticinteractionwithlocallyavailablesensors,andwewillusethemtodemonstratetheuseofDAIS.Thespecicnovelcontributionsofthisworkarethreefold.First,wedescribeanewmiddlewarearchitecturedesignedtomediatedirectinteractionsbetweenmobiledevicesandanimmersivesensornetwork.Second,wecreateanessentialunderlyingabstractionthatallowsadevelopertopreciselyspecifythedynamicsetofsensorsthatitinteractswith.Finally,wedescribeaprototypeimplementationofthismiddlewarethatincludesthecreationofaprotocolenablingadaptiveandecientconstructionoflocalzoneswithinthesensornetworkthatdynamicallyre ectanapplication'sneeds.Section2ofthispaperdescribesthechallenges,highlightinghowimmersivesensorenvironmentschangetherequirementsofamiddleware.InSection3,weprovideadetaileddescriptionoftheDAISarchitecture.Section4coverstheinternalsofthemiddleware.InSection5,weevaluateacasestudyinscenedenition.Section6contrastsrelatedprojects,andSection7concludes.2ProblemDenitionInimmersivesensornetworks,usersmovethroughaninstrumentedenvironmentanddesiretohaveon-demandaccesstoinformationgatheredfromthelocalarea.Figure1(a)showshowcurrentinteractionswithsensornetworkscommonlyoccur,whileFigure1(b)showstheneedsofourintendedapplications.Whileexistingcollectionbehaviorsthatsense,aggregate,andstreaminformationtoacentralcollectionpointmaybeusefulinimmersivesensornetworks,thispaperundertakesonlytheportionoftheproblemrelatedtoenablingapplications'direct,on-demandinteractions.Fromthisperspective,ourapproachfocusesonusingsensornetworkstoenablepervasivecomputingapplications,notonremotedistributedsensing. 1DAIS(da0s):fromthemiddleEnglishwordmeaning\raisedplatform"2