




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構無線傳感器網絡分類和特點WSN操作系統傳感器概述:功用:一感二傳,即感受被測信息,并傳送出去。傳感器定義
我國國標(GB7665-2005)對傳感器的定義是:“能感受被測量并按照一定的規律轉換成可用輸出信號的器件或裝置”。傳感器的作用主要是感受和響應規定的被測量,并按一定規律將其轉換成有用輸出,特別是完成非電量到電量的轉換。2/28
傳感器的組成
傳感器的組成,并無嚴格的規定。一般說來,可以把傳感器看作由敏感元件(有時又稱為預變換器)和變換元件(有時又稱為變換器)兩部分組成。qzm_mail@3/28傳感器的分類根據被測量與輸出電量的轉換原理分類能量轉換型、能量控制型根據傳感器感知的對象分類溫度傳感器、力傳感器、等根據輸出信號的性質不同分類二值型、數字型、模擬型根據傳感器測量原理分類物理和化學….4常用物理傳感器
與化學傳感器5分類-物理傳感器1.物理傳感器物理傳感器的原理是利用力、熱、聲、光、電、磁、射線等物理效應,將被測信號量的微小變化轉換成電信號物理傳感器可以進一步分為:力傳感器、熱傳感器、聲傳感器、光傳感器、電傳感器、磁傳感器與射線傳感器等7類6(1)力傳感器力傳感器是能感受外力并將其轉換成可用輸出信號的傳感器。力傳感器的種類繁多,常用的力與壓力傳感器有電阻應變式、半導體應變式、壓阻式、電感式、電容式、諧振式壓力傳感器,以及光纖壓力傳感器等用金屬應變絲作為敏感元件的壓力傳感器原理示意圖7不同用途的
力傳感器8(2)溫度傳感器(3)聲傳感器9(4)光傳感器圖像傳感器光纖傳感器10分布式光纖傳感系統分布式光纖傳感系統利用光纖作為傳感敏感元件和傳輸信號介質,探測出沿著光纖不同位置的溫度和應變的變化,實現分布、自動、實時、連續、精確的測量。分布式光纖傳感系統應用領域包括:
—智能電網的電力電纜表面溫度檢測、事故點定位
—發電廠和變電站的溫度監測、故障點檢測和報警
—水庫大壩、河堤安全與滲漏監測
—橋梁與高層建筑結構安全性監測
—公路、地鐵、隧道地質狀況的監測分布光纖溫度傳感系統可以在易燃、易爆的環境下同時測量上萬個點,可以對每個溫度測量點進行實時測量與定位11(5)電傳感器電傳感器可以分為:電阻式、電容式、電感式傳感器電阻式傳感器利用變阻器將非電量轉換成電阻信號的原理制成的。電阻式傳感器主要用于位移、壓力、應變、力矩、氣流流速、液面與液體流量等參數的測量電容式是利用改變電容器的幾何尺寸或介質參數,來使電容量變化的原理制成的。電容式傳感器主要用于壓力、位移、液面、厚度、水分含量等參數的測量電感式是利用改變電感磁路的幾何尺寸或磁體位置,來使電感或互感量變化的原理制成的,主要用于壓力、位移、力、振動、加速度等參數的測量。12(6)磁傳感器磁傳感器是最古老的傳感器,指南針是磁傳感器的最早的一種應用磁傳感器將磁信號轉化成為電信號輸出磁電式傳感器目前已經被高性能磁敏感材料的新型磁傳感器所替代13(7)射線傳感器
射線傳感器是將射線強度轉換出可輸出的電信號的傳感器射線傳感器可以分為:X射線傳感器、γ射線傳感器、β射線傳感器、輻射劑量傳感器射線傳感器已經在環境保護、醫療衛生、科學研究與安全保護領域廣泛使用14分類-化學傳感器化學傳感器可以將化學吸附、電化學反應過程中被測信號的微小變化轉換成電信號的一類傳感器
按傳感方式的不同,可分為:
—接觸式化學傳感器
—非接觸式化學傳感器按結構形式的不同,可以分為:
—分離型化學傳感器
—組裝一體化化學傳感器按檢測對象的不同,可以分為:
—氣體傳感器
—離子傳感器
—濕度傳感器
15分類-生物傳感器生物傳感器是由生物敏感元件和信號傳導器組成生物敏感元件可以是生物體、組織、細胞、酶、核酸或有機物分子不同的生物元件對于光強度、熱量、聲強度、壓力有不同的感應特性16生物傳感器的分類常用傳感器qzm_mail@17/28
智能傳感器qzm_mail@18/28
定義:傳統傳感器加上處理器具有智能功能的傳感器。所謂智能式傳感器,就是一種帶有微處理機的,兼有信息檢測、信號處理、信息記憶、邏輯分析與判斷功能的傳感器。組成:傳感器+微處理器+信號處理電路。微處理器為核心。智能傳感器的特點具有自動調零和自動校準功能具有判斷和信息處理功能、對測量值進行修正和誤差補償實現多慘了綜合測量(復合感知能力)自動診斷故障靈活的通信能力智能傳感器的發展為傳感器技術的研究提出了很多富有挑戰性的課題qzm_mail@19/28微機電系統對智能傳感器發展的影響微機電系統(MEMS)是指集微型機構、微型傳感器、微型執行器以及信號處理和控制電路,直至接口、通信和電源等于一體的微型器件或系統qzm_mail@20/28性能指標靜態指標線性范圍:輸出量與輸入量呈線性關系的測量范圍線性度:傳感器實際輸入輸出量曲線與擬合曲線的重疊程度靈敏度:輸出變化量與輸入變化量的比值穩定性:表示傳感器經過長期使用后,輸出特性不發生變化的性能分辨率:能檢測到的被測量的最小變化量21/28(具體定義公式見教材)性能指標
遲滯:傳感器在輸入量從小到大正向變化與反向變化,其輸入輸出特性曲線不重合的程度重復性:傳感器在輸入量按同一方向做全量程連續多次變化時所得特性曲線一致的程度漂移:輸入量不變的情況下,輸出量隨時間變化的現象測量范圍:最小/最大輸入量的范圍精度:測量結果的可靠程度,以給定的準確度來表示重復某個讀數的能力動態指標輸出信號對應隨時間變化的輸入量的響應特性,反映測量精度、重復性和可靠性第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構無線傳感器網絡分類和特點WSN操作系統24無線傳感器節點結構(1)無線傳感器節點通常由4個功能模塊組成:感知模塊、處理模塊、通信模塊和電源模塊25無線傳感器節點結構(2)感知模塊:由一個或多個傳感器以及模數轉換器組成。傳感器負責感知監測目標的物理特征和現象,并產生相應的模擬信號。感知聲、光、電、震動、磁、氣體等信號模數轉換器負責將模擬信號轉換為數字信號,并將數字信號送往處理模塊進行處理。處理模塊:由一個微處理器及相應的內存組成,負責對數據進行處理、濾波、決策、執行、資源分配等判斷,并對傳感器節點進行控制通信模塊:由數模轉換器和無線收發送器(Zigbee,WiFi,GPRS,短波等)組成,負責發送和接收數據和控制信息26無線傳感器節點結構(3)電源模塊:負責節點的供電(電池供電或從自然界采集能量)其他模塊位置模塊:節點可以配置全球定位系統(GlobalPositioningSystem,GPS)或北斗定位系統接收器移動模塊:在某些需要移動傳感器節點的應用中,可以配置馬達來驅動傳感器節點/wiki/List_of_wireless_sensor_nodes一個簡單的應用開發需要:一個簡單的應用開發需要:Serialgateway
(MIB510)MICA2(MPR400)(處理模塊和通信模塊)MTS310(感知模塊)QTY:1
COST:$95.00
Serial"gateway"usedtoprogramandcommunicatewiththemotes.
NOTE:Ifyourcomputerdoesnothaveaserialport,youwillalsoneedtobuyaserialtoUSBadapter.QTY:2
COST:$150.00each
The900MHzmotesoffergreaterbandwidth,whichmeansmoreavailablechannels.Ifyouwanttohaveseveralmotenetworksoperatingatonce,thisisthewaytogo.The433MHzmotesgetbetterrange.Bestforoutdoorapplications.QTY:1
COST:$120.00
Basicsensorboardthatplugsintothemote.Containslightsensor,temperaturesensor,microphoneandsounder.Moreadvancedsensorboardshaveaccelerometers,magnetometersandGPS.ProgrammingBoard(MIB510)29Mica2MotesMICA2MOTE/isf/facilities/isa/internal/CrossBow/DataSheets/mica2.pdf30
SensorBoard-MTS31032第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構無線傳感器網絡分類和特點WSN操作系統
跨層設計聯合優化無線傳感器網絡協議棧WSN的體系架構35WSN的通信協議
物理層(主要是電磁波)負責頻率選擇、頻率產生、信號檢測、調制解調和數據加密36WSN的通信協議(續)鏈路層負責介質訪問和差錯控制確保通信中點-點/點-多點的連接介質訪問控制:創建網絡架構在節點間公平有效的共享通信資源差錯控制前向糾錯FEC自動重發檢錯ARQ37WSN的通信協議(續網絡層(路由層)節能總是最重要的考慮傳感網絡多以數據為中心數據聚合不能影響傳感節點的協同理想的傳感器網絡基于屬性尋址并能感知位置38WSN的通信協議(續傳輸層負責數據流的傳輸控制可靠性和擁塞控制當傳感系統需要被Internet或者其它外部網絡訪問時傳輸層設計與實現至關重要研究不成熟39WSN的通信協議(續)跨層設計聯合優化應用層負責任務調度和數據分發等具體業務,使得底層硬件和軟件對傳感應用是透明的
Sensormanagementprotocol(SMP)Taskassignmentanddataadvertisementprotocol(TADAP)Sensorqueryanddatadisseminationprotocol(SQDDP)網絡管理平臺主要是對傳感器節點自身的管理和用戶對wsn的管理,包括:拓撲控制服務質量管理能力管理安全管理移動管理網絡管理應用支撐平臺包括一系列基于監測任務的應用層軟件,通過應用服務借口和網絡管理接口為用戶提供各種應用的支持。時間同步定位應用服務接口網絡管理接口第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構無線傳感器網絡分類和特點WSN操作系統43無線傳感網的布設形式隨機布設網戰場:炮射、空投應急:火災、毒氣固定布設網工控:自動控制監測:遠程監測44無線傳感器網絡的網絡結構(1)傳感器網絡基本組成:傳感器節點(sensornode)
匯聚節點(sink)管理節點(Management
node)匯聚節點→傳感器節點:查詢消息或指令匯聚節點還作為連接外部傳輸網絡(如互聯網、衛星網等)的網關,對收集到的數據進行簡單的處理,然后將數據通過互聯網或其它傳輸網絡,傳送給監控中心和需要使用這些數據的終端用戶傳感器節點→匯聚節點:監測數據sinkInternet/SatelliteSensornode45無線傳感器網絡的網絡結構(2)單跳結構各傳感器節點可以采用單跳的方式將各自的數據直接發送給匯聚節點基于蜂窩的窄帶物聯網(NarrowBandInternetofThings,NB-IoT)Sensornode
Ref:NB-IoT:AsustainabletechnologyforconnectingbillonsofdevicesEricssionTechnologyReviewApril22,2016
NB-IoT的應用無線傳感器網絡的網絡結構(3)多跳結構傳感器節點通過一個或多個網絡中間節點將所采集到的數據傳送給匯聚節點,從而有效地降低通信所需的能耗平面結構多跳分簇結構
多層分簇結構第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構無線傳感器網絡分類和特點WSN操作系統50無線傳感器網絡的分類(1)單跳網絡與多跳網絡single-hop/multi-hop靜止網絡與移動網絡static/mobile靜止傳感網中,所有傳感器節點都是靜止不動的。靜止傳感網實現簡單,但靜止WSN存在瓶頸;移動傳感網中,某些節點可以移動。移動可以平衡網絡流量和能耗分布,但動態性使得協議實現復雜。靜止匯聚節點網絡與移動匯聚節點網絡靜止匯聚節點網絡中,匯聚節點的位置靜止固定在監測區域附近或內部;移動匯聚節點網絡中,匯聚節點在監測區域移動,收集傳感器節點的監測數據,可以平衡各網絡負載,減小熱點效應。51無線傳感器網絡的分類(2)確定性網絡與非確定性網絡根據傳感器節點部署的情況不同確定性傳感器網絡中,傳感器節點的位置是預先規劃的,且一旦部署不再變化;非確定性傳感器網絡中,節點隨機布設,甚至可以移動,適合自然條件惡劣或敵對的應用場合,難以預先規劃。單匯聚節點網絡與多匯聚節點網絡根據匯聚節點的數量單匯聚節點網絡中,只有一個匯聚節點位于監測區域的附近或內部;多匯聚節點網絡中,多個匯聚節點布設于不同位置,各傳感器節點可以將其監測數據發送給離自己最近的匯聚節點。52無線傳感器網絡的分類(3)同構網絡與異構網絡根據傳感器節點是否具有相同的能力(通信能力、感知能力、計算能力等的不同)同構傳感器網絡中,所有傳感器節點能力完全相同;異構傳感器網絡中,傳感器節點(或部分)能力不同,可以配備較強的通信、處理模塊或傳感器。先應式網絡和反應式網絡先應式網絡采用連續操作模式,節點定期打開傳感器和發送器、感知環境并進行數據匯包適用于定期監控的應用反應式網絡采用查詢-響應的操作模式,節點按需的進行感知和數據匯報WSN的特征四大受限:能量受限
通信能力受限計算能力受限存儲能力受限組網特征:自組織性以數據為中心應用相關性事件驅動拓撲動態性大規模需要考慮可靠性和魯棒性54無線傳感器網絡的設計目標節點體積小型化節點成本低廉節點功耗超低節點可自組成網可擴展性強自適應性強可靠性高滿足一定的安全性和服務質量要求55傳感網絡面臨的問題和挑戰56影響傳感器網絡的因素(1)57影響傳感器網絡的因素(2)58影響傳感器網絡的因素(3)制造成本單個節點的成本是衡量整個網絡成本的關鍵如何以低于一美元的成本制造一定功能的傳感節點是很大的挑戰傳輸介質(選擇的傳輸介質必須是全球可用的)無線電紅外其他光波59影響傳感器網絡的因素(4)傳感器的環境敵方戰場居家/大型建筑物大型倉庫動物身上快速移動的車輛有水流動的排水管/河流第二章網絡體系架構
WSN節點概述和分類WSN節點結構WSN節點體系結構WSN網絡結構WSN分類WSN操作系統MajorConcernsinWSNOSDesign能在有限的資源上運行:WSN節點資源非常有限(通信帶寬資源/能量資源/計算資源),操作系統必須能夠高效地使用各種資源;允許高度的并發性:要求執行模式能對事件作出快速的直接響應;適應硬件升級支持一系列平臺:要求組件和執行模式能夠應對硬件/軟件的替換,具有可移植性;支持多樣化的應用程序:良好的模塊化設計,使應用/協議/服務與硬件資源之間可以隨意搭配,要求能夠根據實際需要,裁減操作系統的服務;魯棒性強:要求通過組件間有限的交互渠道,就能應對各種復雜情況;提供高效的組網機制:WSN是一個網絡系統,其操作系統也必然是面向網絡化開發的。網絡化系統要求操作系統必須為應用提供高效的組網和通信機制WSNOSOutlineFunctionalAspectsDataTypesSchedulingStacksSystemCallsHandlingInterruptsMultithreadingThread-basedvs.Event-basedProgrammingMemoryAllocationNon-FunctionalAspectsSeparationofConcernSystemOverheadPortabilityDynamicReprogrammingPrototypesTinyOSContikiEvaluationOperatingSystemsAnoperatingSystemisathinsoftwarelayerresidesbetweenthehardwareandtheapplicationlayerprovidesbasicprogrammingabstractionstoapplicationdevelopersItsmaintask
istoenableapplicationstointeractwithhardwareresourcesOperatingSystemsOperatingsystemsareclassifiedas:
single-task/multitaskingand
single-user/multiuseroperatingsystemsmulti-taskingOS-theoverheadofconcurrentprocessingbecauseofthelimitedresourcessingletaskOS-tasksshouldhaveashortdurationThechoiceofaparticularOSdependsonseveralfactors;typicallyfunctional
and
non-functional
aspectsOutlineFunctionalAspectsDataTypesSchedulingStacksSystemCallsHandlingInterruptsMultithreadingThread-basedvs.Event-basedProgrammingMemoryAllocationNon-FunctionalAspectsSeparationofConcernSystemOverheadPortabilityDynamicReprogrammingPrototypesTinyOSContikiEvaluation
DataTypesInteractionsbetweenthedifferentsubsystemstakeplacethrough:well-formulatedprotocolsdatatypesComplexdatatypeshavestrongexpressionpowerbutconsumeresources-structandenumSimpledatatypesareresourceefficientbuthavelimitedexpressioncapability-CprogramminglanguageSchedulingTwoschedulingmechanisms:queuing-basedscheduling
FIFO-thesimplestandhasminimumsystemoverhead,buttreatstasksunfairlysortedqueue-e.g.,shortestjobfirst(SJF)-incurssystemoverhead(toestimateexecutionduration)round-robinschedulingatimesharingschedulingtechniqueseveraltaskscanbeprocessedconcurrentlySchedulingRegardlessofhowtasksareexecuted,aschedulercanbeeitheranon-preemptivescheduler-ataskisexecutedtotheend,maynotbeinterruptedbyanothertaskorpreemptivescheduler-ataskofhigherprioritymayinterruptataskoflowpriorityStacks&SystemCallsStacksadatastructurethattemporarilystoresdataobjectsinmemorybypilingoneuponanotherobjectsareaccessedusinglast-in-first-out(LIFO)SystemCalls:istheprogrammaticwayinwhichacomputer
program
requests
a
service
from
the
kernel
of
the
operating
system
it
is
executed
ondecoupletheconcernofaccessinghardwareresourcesfromimplementationdetailswheneveruserswishtoaccessahardwareresource,theyinvoketheseoperationswithouttheneedtoconcernthemselveshowthehardwareisaccessedHandlingInterruptsAninterruptisanasynchronoussignalgeneratedby
ahardwaredeviceseveralsystemeventsOSitselfAninterruptcauses:theprocessortointerruptexecutingthepresentinstructiontocallforanappropriateinterrupthandlerInterruptsignalscanhavedifferentprioritylevels,ahighpriorityinterruptcaninterruptalowlevelinterruptInterruptmask:letprogramschoosewhetherornottheywishtobeinterruptedMulti-threadingA
thread
isthepathtakenbyaprocessororaprogramduringitsexecutionMulti-threading
-ataskisdividedintoseverallogicalpiecesscheduledindependentfromeachotherexecutedconcurrentlyTwoadvantagesofamulti-threadedOS:tasksdonotblockothertasksshort-durationtaskscanbeexecutedalongwithlong-durationtasksMulti-threadingThreadscannotbecreatedendlesslythecreationofthreadsslowsdown
theprocessornosufficientresourcestodivideTheOScankeepthenumberofthreadstoamanageable
size
usingathreadpoolThread-basedvs.Event-basedProgrammingDecisionwhethertousethreadsoreventsprogramming:needforseparatestacksneedtoestimatemaximumsizeforsavingcontextinformationThread-basedprograms
usemultiplethreadsofcontrolwithin:asingleprogramasingleaddressspaceThread-basedvs.Event-basedProgrammingAdvantage:athreadblockedcanbesuspendedwhileothertasksareexecutedindifferentthreadsDisadvantages:mustcarefullyprotectshareddatastructureswithlocksuseconditionvariablestocoordinatetheexecutionofthreadsThread-basedvs.Event-basedProgrammingInevent-basedprogramming:useeventsandeventhandlersevent-handlersregisterwiththeOSschedulertobenotifiedwhenanamedeventoccursaloopfunction:
pollsforeventscallstheappropriateevent-handlerswheneventsoccurAneventisprocessedtocompletionunlessitshandlerreachesatablockingoperation(callbackandreturnscontroltothescheduler)MemoryAllocationThememoryunitisapreciousresourceReadingandwritingtomemoryiscostlyHowandforhowlongamemoryisallocatedforapieceofprogramdeterminesthespeedoftaskexecutionMemoryAllocationMemorycanbeallocatedtoaprogram:statically
-afrugalapproach,buttherequirementofmemorymustbeknowninadvancememoryisusedefficientlyruntimeadaptationisnotalloweddynamically
-therequirementofmemoryisnotknowninadvance(onatransientbasis)enablesflexibilityinprogrammingbutproducesaconsiderablemanagementoverheadOutlineFunctionalAspectsDataTypesSchedulingStacksSystemCallsHandlingInterruptsMultithreadingThread-basedvs.Event-basedProgrammingMemoryAllocationNon-FunctionalAspectsSeparationofConcernSystemOverheadPortabilityDynamicReprogrammingPrototypesTinyOSContikiEvaluationSeparationofConcernSoC
isadesignprincipleforseparatinga
computer
program
into
distinct
sections,
such
that
each
section
addresses
a
separate
concernIngeneral,separationbetweentheoperatingsystemandtheapplicationslayerTheoperationsystemscanprovide:anumberoflightweightmodules-“wired”together,oranindivisiblesystemkernel+asetoflibrarycomponentsforbuildinganapplication,orakernel+asetofreconfigurablelow-levelservicesSeparationofconcernenables:flexibleandefficientreprogrammingandreconfigurationPortabilityIdeally,operatingsystemsshouldbeabletoco-existandcollaboratewitheachotherHowever,existingoperatingsystemsdonot
providethistypeofsupportInordertoaccommodateunforeseenrequirements,operatingsystemsshouldbeportableandextensibleSystemOverheadAnoperatingsystemexecutesprogramcode-requiresitsownshareofresourcesTheresourcesconsumedbytheOSarethesystem’soverhead,itdependsonthesizeoftheoperatingsystemthetypeofservicesthattheOSprovidestothehigher-levelservicesandapplicationsSystemOverheadTheresourcesofwirelesssensornodeshavetobesharedbyprogramsthatcarryout:sensingdataaggregationself-organizationnetworkmanagementnetworkcommunication
DynamicReprogrammingOnceawirelesssensornetworkisdeployed,itmaybenecessarytoreprogramsomepartoftheapplicationortheoperatingsystemforthefollowingreasons:thenetworkmaynotperformoptimallyboththeapplicationrequirementsandthenetwork’soperatingenvironmentcanchangeovertimemaybenecessarytodetectandfixbugsDynamicReprogrammingManualreplacementmaynotbefeasible-developanoperatingsystemtoprovidedynamicreprogrammingsupport,whichdependsonclearseparationbetweentheapplicationandtheOStheOScanreceivesoftwareupdatesandassembleandstoreitinmemoryOSshouldmakesurethatthisisindeedanupdatedversionOScanremovethepieceofsoftwarethatshouldbeupdatedandinstallandconfigurethenewversionalltheseconsumeresourcesandmaycausetheirownbugsDynamicReprogrammingSoftwarereprogramming(update)requiresrobustcodedisseminationprotocols:splittingandcompressingthecodeensuringcodeconsistencyandversioncontrollingprovidingarobustdisseminationstrategytodeliverthecodeoverawirelesslinkOutlineFunctionalAspectsDataTypesSchedulingStacksSystemCallsHandlingInterruptsMultithreadingThread-basedvs.Event-basedProgrammingMemoryAllocationNon-FunctionalAspectsSeparationofConcernSystemOverheadPortabilityDynamicReprogrammingPrototypesTinyOSContikiEvaluationTinyOS(Gayetal.2007)TinyOSisthemostwidelyused,richlydocumented,andtool-assisted
runtimeenvironmentinWSN
http://staticmemoryallocationevent-basedsystemTinyOS’sarchitectureconsistsofaschedulerasetofcomponents,whichareclassifiedintoconfigurationcomponents-"wiring"(howmodelsareconnectedwitheachother)modules-thebasicbuildingblocksofaTinyOSprogramTinyOS(Gayetal.2007)Acomponentismadeupofaframecommandhandlerseventhandlersasetofnon-preemptivetasksAcomponentissimilartoanobjectinobject-basedprogramminglanguages:itencapsulatesstateandinteractsthroughwell-definedinterfacesaninterfacethatcandefinecommands,eventhandlers,andtasksTinyOS(Gayetal.2007)ThelogicalstructureofcomponentsandcomponentconfigurationsFigure4.2ATinyOScomponentprovidinganinterfaceInFigure4.2,ComponentAdeclaresitsservicebyprovidinginterfaceC,whichinturnprovidescommandD1andsignalseventD2.Figure4.3ATinyOScomponentsthatusesaninterfaceFigure4.4ATinyOSconfigurationthatwiresaninterfaceproviderandaninterfaceuserInFigure4.3,ComponentBexpressesinterestininterfaceCbydeclaringacalltocommandD1andbyprovidinganeventhandlertoprocesseventD2.InFigure4.4,abindingbetweenComponentAandComponentBisestablishedthroughtheConfigurationE.TinyOS(Gayetal.2007)Figure4.1Logicaldistinctionbetweenlow-levelandhigh-levelcomponents(Hilletal.2000)TinyOS(Gayetal.2007)Componentsarestructuredhierarchicallyandcommunicatewitheachotherthroughcommandsandevents:higher-levelcomponentsissuecommandstolower-levelcomponentslower-levelcomponentssignaleventstohigher-levelcomponentsInFigure4.1,twocomponentsatthehighestlevelcommunicateasynchronouslythroughactivemessagesroutingcomponent-establishingandmaintainingthenetworksensorapplication-responsibleforsensingandprocessingTasks,CommandsandEventsThefundamentalbuildingblocksofaTinyOSruntimeenvironment:tasks,commands,andeventsenablingeffectivecommunicationbetweenthecomponentsofasingleframeTasks:monolithicprocesses
-shouldexecutetocompletion-theycannotbepreemptedbyothertasks,thoughtheycanbeinterruptedbyeventspossibletoallocateasinglestacktostorecontextinformationcalllowerlevelcommands;signalhigherlevelevents;andpost(schedule)othertasksscheduledbasedonFIFOprinciple(inTinyOS)Tasks,CommandsandEventsCommands:non-blockingrequestsmadebyhigher-levelcomponentstolower-levelcomponentssplit-phaseoperation:
afunctioncallreturnsimmediatelythecalledfunctionnotifiesthecallerwhenthetaskiscompletedEvents:
eventsareprocessedbytheeventhandlereventhandlersarecalledwhenhardwareeventsoccuraneventhandlermayreacttotheoccurrenceofaneventindifferentwaysdepositinformationintoitsframe,posttasks,signalhigherlevelevents,orcalllowerlevelcommandsOutlineFunctionalAspectsDataTypesSchedulingStacksSystemCallsHandlingInterruptsMultithreadingThread-basedvs.Event-basedProgrammingMemoryAllocationNon-FunctionalAspectsSeparationofConcernSystemOverheadPortabilityDynamicReprogrammingPrototypesTinyOSContikiEvaluationLiteOS(Caoetal.2008)LiteOSisathread-basedoperatingsystemandsupportsmultipleapplicationsbasedontheprincipleofcleanseparationbetweentheOSandtheapplicationsdoesnotprovidecomponentsormodulesthatshouldbe“wired”togetherprovidesseveralsystemcallsprovidesashell-isolatesthesystemcallsfromauserprovidesahierarchicalfilemanagementsystemprovidesadynamic
reprogrammingtechniqueLiteOS(Caoetal.2008)LiteOSismodeledasadistributedfilesystemFigure4.8TheLiteOSoperatingsystemarchitecture(Caoetal.2008)ShellandSystemCallsTheshellprovides:
amountingmechanismtoawirelessnodewhichisone-hopawayfromitadistributedandhierarchicalfilesystemausercanaccesstheresourcesofanamednodealargenumberofLinuxcommandsfilecommands-move,copyand,deletefilesanddirectoriesprocesscommands-managethreadsdebuggingcommands-setupadebuggingenvironmentanddebugcodeenvironmentcommandsuser-managingtheenvironmentofOSmanual-displayinginteractionhistoryandprovidingcommandreferencedevicecommands-providedirectaccesstohardwaredevicesLiteFSFigure4.9ThefilesystemstructureofLiteFS(Caoetal.2008)DynamicReprogrammingTheLiteFSisadistributedfilesystemAusercanaccesstheentiresensornetworkprogramandmanageindividualnodesLiteOSsupportsthedynamicreplacementandreprogramming
ofuserapplicationsiftheoriginalsourcecodeisavailabletotheOSrecompiledwithanewmemorysettingtheoldversionwillberedirectedDynamicReprogrammingIftheoriginalsourcecodeisnotavailabletotheOSuseadifferentialpatching
mechanismtoreplaceanolderversionbinarythestartaddress(S)ofthebinaryexecutableintheflashmemorythestartaddressofallocatedmemoryinRAM(M)thestacktop(T)T-M=thememoryspaceallocatedfortheprogramcodebuttheparametersareobtainedempiricallyandrequireknowledgeofthenodearchitecture-limitstheusefulnessofthepatchingschemeTinyOS簡介TinyOS是一個開源的嵌入式操作系統,它是由加州大學的伯利克分校開發出來的,主要應用于無線傳感器網絡方面。它是基于一種組件(Component-Based)的架構方式,使得能夠快速實現各種應用。支持的平臺:eyesIFXv2、intelmote2、mica2、mica2dot、micaZ、telosb、tinynode。TinyOS的編程語言
TinyOS最初是用匯編和C語言編寫的,后來改用支持組件化編程的nesC語言。該語言把組件化模塊化思想和基于事件驅動的執行模型結合起來。nesC:使用C作為其基礎語言,支持所有的C語言詞法和語法,其獨有的特色如下:增加了組件(component)和接口(interface)的關鍵字定義;定義了接口及如何使用接口表達組件之間關系的方法;目前只支持組件的靜態連接,不能實現動態連接和配置。TinyOS提供一系列可重用的組件component,包括networkprotocols,distributedservices,sensordrivers,anddataacquisitiontools
一個組件由兩部分組成Specification規范說明,包含要用接口的名字implementation接口的具體實現。組件分兩種:Module組件(模塊):實現某種邏輯功能;Configuration組件(配件):將各個組件連接起來成為一個整體。一個應用程序可以通過連接配置文件(AWiringSpecification)將各種組件連接(wire)起來,以完成它所需要的功能組件特征:組件內變量、函數可以自由訪問,但組件之間不能訪問和調用。Component
basedOS
組件component一個應用程序都由一個或多個組件鏈接起來一個組件由接口(interface)組成,它是雙向的并且是組件間的唯一訪問點
可以提供(provides)接口,描述了該組件提供給調用者的功能
可以使用(uses)接口,則表示該組件本身工作時需要用到的功能
一個接口由命令(command)和事件(event)組成Acommandisarequesttoperformsomeservice,接口的提供者必須實現它們Aneventsignalsthecompletionoftheservice,接口的使用者必須實現它們
Theinterface’susermakesrequests(callscommands)ontheinterface’sprovider,theprovidermakescallbacks(signalsevents)totheinterface’suser.組件模型WiringcomponentsAconfigurationcanbindaninterfaceusertoaproviderusing->
or<-Uerface->
PerfacePerface<-
UerfaceBounceresponsibilitiesusing=Uerface=
UerfacePerface=
PerfaceTheinterfacemaybeimplicitifthereisnoambiguitye.g.,Uerface->
Provider Uerface->PerfaceTinyOS(Gayetal.2007)ThelogicalstructureofcomponentsandcomponentconfigurationsFigure4.2ATinyOScomponentprovidinganinterfaceInFigure4.2,ComponentAdeclaresitsservicebyprovidinginterfaceC,whichinturnprovidescommandD1andsignalseventD2.Figure4.3ATinyOScomponentsthatusesaninterfaceFigure4.4ATinyOSconfigurationthatwiresaninterfaceproviderandaninterfaceuserInFigure4.3,ComponentBexpressesinterestininterfaceCbydeclaringacalltocommandD1andbyprovidinganeventhandlertoprocesseventD2.InFigure4.4,abindingbetweenComponentAandComponentBisestablishedthroughtheConfigurationE.BlinkM.nc/*ImplementationforBlinkapplication.ToggletheredLEDwhenaTimerfires.*/moduleBlinkM{provides{//必須實現這個接口interfaceStdControl;}uses{//它可能調用這些接口中聲明的任何命令以及必須實現這些接口中聲明的任何事件。interfaceTimer;interfaceLeds;}}implementation{//Imandresult_tStdControl.init(){callLeds.init();returnSUCCESS;}/*Startthingsup.Thisjustsetstheratefortheclockcomponent.*/commandresult_tStdControl.start(){ returncallTimer.start(TIMER_REPEAT,1000);//Startarepeatingtimerthatfiresevery1000ms}/*Haltexecutionoftheapplication.Thisjustdisablestheclockcomponent.*/commandresult_tStdControl.stop(){ returncallTimer.stop();}/*ToggletheredLEDinresponsetothe<code>Timer.fired</code>event.*/eventresult_tTimer.fired(){callLeds.redToggle();returnSUCCESS;}}Example-modulefileExample-configuration
fileBlink.ncconfigurationBlink{}implementat
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 急診護理科普大賽
- 電商平臺消費者債權轉讓及清收服務協議
- 植物人離婚監護權及子女撫養權共享協議
- 醫療資源整合遠程會診項目合作協議
- 智能停車管理系統租賃與智能停車場運營管理及增值服務合同
- 醫院潔凈手術部BIM管線施工與運維協議
- 草原牧場放牧權競標與草原生態修復協議
- 世界杯羽毛球賽贊助商協議
- 家居裝修工程設計與施工合同
- 影視拍攝場地消毒衛生保障協議
- 廣東省廣州市增城區2025屆九年級下學期中考一模歷史試卷(含答案)
- 大學班會課件
- 2025年云計算與大數據技術考試試題及答案
- 納西族文化課件
- 礦石加工中的化學工藝安全技術考核試卷
- 中國共產主義青年團紀律處分條例試行解讀學習
- 網絡釣魚攻擊防范-第1篇-全面剖析
- 《環境設計中的天人合一》教學課件-2024-2025學年人美版(北京)(2024)初中美術七年級下冊
- 采礦管理協議書范本
- 國家能源集團陸上風電項目通 用造價指標(2024年)
- 廣西壯族自治區2025年4月高三畢業班診斷學考試數學試卷及答案(廣西三模)
評論
0/150
提交評論