⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 network protocols - tinyos documentation wiki.htm

📁 从官方网站上下载tinyos2.0的学习指南
💻 HTM
📖 第 1 页 / 共 2 页
字号:
node that will receive all the data packets. For this, we use the interface 
RootControl:<BR>tos/lib/net/RootControl.nc<BR></P><PRE>interface RootControl {<BR>    command error_t setRoot();<BR>    command error_t unsetRoot();<BR>    command bool isRoot();<BR>}<BR>
</PRE>
<P>This interface controls whether the current node is a root of the tree. Using 
the setRoot() command and assuming that the base station ID is 1, we select the 
root of the collection <I>tree</I> as follows:<BR></P><PRE>if (TOS_NODE_ID == 1) <BR>    call RootControl.setRoot();  <BR>else<BR>    call Timer.startPeriodic(2000);
</PRE>
<P>The remaining nodes in the network periodically generate some data and send 
it to the base station. To send and receive data we use two interfaces that will 
be wired to the collection tree. That is, when we call the send command, the 
data packet will be sent through the collection tree. Similarly, the receive 
event will be only called in the root of the tree, that is, in the base station. 
When the base station receives a "collected" packet it just toggle a led. Now we 
will see how to wire these interfaces .<BR>The 
<CODE>EasyCollectionAppC.nc</CODE> provides the needed wiring:<BR></P><PRE>configuration EasyCollectionAppC {}<BR>implementation {<BR>  components EasyCollectionC, MainC, LedsC, ActiveMessageC;<BR>  components CollectionC as Collector;<BR>  components new CollectionSenderC(0xee);<BR>  components new TimerMilliC();<BR><BR>  EasyCollectionC.Boot -&gt; MainC;<BR>  EasyCollectionC.RadioControl -&gt; ActiveMessageC;<BR>  EasyCollectionC.RoutingControl -&gt; Collector;<BR>  EasyCollectionC.Leds -&gt; LedsC;<BR>  EasyCollectionC.Timer -&gt; TimerMilliC;<BR>  EasyCollectionC.Send -&gt; CollectionSenderC;<BR>  EasyCollectionC.RootControl -&gt; Collector;<BR>  EasyCollectionC.Receive -&gt; Collector.Receive[0xee];<BR>}<BR>
</PRE>
<P>Most of the collection interfaces (RoutingControl, RootControl and Receive) 
are provided by the CollectionC module. The send interface is provided by 
CollectionSenderC which is a virtualized collection sender abstraction 
module.<BR>This is an extract of the signature of the CollectionC module and 
CollectionSenderC:<BR>tos/lib/net/ctp/CollectionC.nc<BR></P><PRE>configuration CollectionC {<BR>  provides {<BR>    interface StdControl;<BR>    interface Send[uint8_t client];<BR>    interface Receive[collection_id_t id];<BR>    interface Receive as Snoop[collection_id_t];<BR>    interface Intercept[collection_id_t id];<BR><BR>    interface Packet;<BR>    interface CollectionPacket;<BR>    interface CtpPacket;<BR><BR>    interface CtpInfo;<BR>    interface CtpCongestion;<BR>    interface RootControl;    <BR>  }<BR>
</PRE>
<P>tos/lib/net/ctp/CollectionSenderC:<BR></P><PRE>  generic configuration CollectionSenderC(collection_id_t collectid) {<BR>  provides {<BR>    interface Send;<BR>    interface Packet;<BR>  }
</PRE>
<P>Note that the sender and receive interfaces requires a collection_id_t to 
differentiate different possible collections trees. <BR>Note also that the 
CollectionC module provides some other interfaces in addition to the ones used 
in this example. As we explained previously, the CollectionC module generates a 
collection tree that will be using for the routing. These interfaces can be used 
get information or modify this routing tree. For instance, if we want to obtain 
information about this tree we use the CtpInfo interface (see 
tos/lib/net/ctp/CtpInfo.nc) and if we want to indicate/query if any node/sink is 
congested we use the CtpCongestion interface (see 
tos/lib/net/ctp/CtpCongestion.nc)<BR></P>
<P>Finally, to compile this program we create the following Makefile:<BR></P><PRE>COMPONENT=EasyCollectionAppC<BR>CFLAGS += -I$(TOSDIR)/lib/net \<BR>          -I$(TOSDIR)/lib/net/4bitle \<BR>          -I$(TOSDIR)/lib/net/ctp<BR>include $(MAKERULES)<BR>
</PRE>
<P>Now install this program into several nodes (make sure you have one base 
station, that is, one node whose ID is 1) and see how all the packets generated 
in the nodes are collected in the base station.<BR><BR>For more information, 
read TEP119 [Collection].<BR><BR></P><A name=To_experiment_further></A>
<H1><SPAN class=mw-headline>To experiment further <BR></SPAN></H1>
<P>If you want to experiment with a more complex application take a look at 
apps/test/TestNetwork/ which combines dissemination and collection into a single 
application.<BR><BR></P><A name=Related_Documentation></A>
<H1><SPAN class=mw-headline>Related Documentation</SPAN></H1>
<UL>
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep118.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep118.html" rel=nofollow>TEP 
  118: Dissemination</A> 
  <LI><A class="external text" 
  title=http://www.tinyos.net/tinyos-2.x/doc/html/tep119.html 
  href="http://www.tinyos.net/tinyos-2.x/doc/html/tep119.html" rel=nofollow>TEP 
  119: Collection</A><BR></LI></UL>
<HR>

<P><BR></P>
<CENTER>
<P>&lt; <B><A title=TOSSIM 
href="http://docs.tinyos.net/index.php/TOSSIM">Previous Lesson</A></B> | <B><A 
title="" 
href="http://docs.tinyos.net/index.php/Network_Protocols#Dissemination">Top</A></B> 
| <B><A title="TinyOS Toolchain" 
href="http://docs.tinyos.net/index.php/TinyOS_Toolchain">Next Lesson</A> 
&gt;</B> </P></CENTER><!-- Saved in parser cache with key tinyosdocs:pcache:idhash:17-0!1!0!!en!2!edit=0 and timestamp 20080401133245 -->
<DIV class=printfooter>Retrieved from "<A 
href="http://docs.tinyos.net/index.php/Network_Protocols">http://docs.tinyos.net/index.php/Network_Protocols</A>"</DIV><!-- end content -->
<DIV class=visualClear></DIV></DIV></DIV></DIV>
<DIV id=column-one>
<DIV class=portlet id=p-cactions>
<H5>Views</H5>
<DIV class=pBody>
<UL>
  <LI class=selected id=ca-nstab-main><A title="View the content page [c]" 
  accessKey=c 
  href="http://docs.tinyos.net/index.php/Network_Protocols">Article</A> 
  <LI class=new id=ca-talk><A title="Discussion about the content page [t]" 
  accessKey=t 
  href="http://docs.tinyos.net/index.php?title=Talk:Network_Protocols&amp;action=edit">Discussion</A> 

  <LI id=ca-viewsource><A 
  title="This page is protected. You can view its source. [e]" accessKey=e 
  href="http://docs.tinyos.net/index.php?title=Network_Protocols&amp;action=edit">View 
  source</A> 
  <LI id=ca-history><A title="Past versions of this page. [h]" accessKey=h 
  href="http://docs.tinyos.net/index.php?title=Network_Protocols&amp;action=history">History</A> 
  </LI></UL></DIV></DIV>
<DIV class=portlet id=p-personal>
<H5>Personal tools</H5>
<DIV class=pBody>
<UL>
  <LI id=pt-login><A 
  title="You are encouraged to log in, it is not mandatory however. [o]" 
  accessKey=o 
  href="http://docs.tinyos.net/index.php?title=Special:Userlogin&amp;returnto=Network_Protocols">Log 
  in / create account</A> </LI></UL></DIV></DIV>
<DIV class=portlet id=p-logo><A title="Visit the Main Page [z]" 
style="BACKGROUND-IMAGE: url(/images/tos-jwall-small.jpg)" accessKey=z 
href="http://docs.tinyos.net/index.php/Main_Page"></A></DIV>
<SCRIPT type=text/javascript> if (window.isMSIE55) fixalpha(); </SCRIPT>

<DIV class=portlet id=p-navigation>
<H5>Navigation</H5>
<DIV class=pBody>
<UL>
  <LI id=n-mainpage><A title="Visit the Main Page [z]" accessKey=z 
  href="http://docs.tinyos.net/index.php/Main_Page">Main Page</A> 
  <LI id=n-portal><A 
  title="About the project, what you can do, where to find things" 
  href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Community_Portal">Community 
  portal</A> 
  <LI id=n-currentevents><A 
  title="Find background information on current events" 
  href="http://docs.tinyos.net/index.php/Current_events">Current events</A> 
  <LI id=n-recentchanges><A title="The list of recent changes in the wiki. [r]" 
  accessKey=r 
  href="http://docs.tinyos.net/index.php/Special:Recentchanges">Recent 
  changes</A> 
  <LI id=n-randompage><A title="Load a random page [x]" accessKey=x 
  href="http://docs.tinyos.net/index.php/Special:Random">Random page</A> 
  <LI id=n-help><A title="The place to find out." 
  href="http://docs.tinyos.net/index.php/Help:Contents">Help</A> 
  <LI id=n-sitesupport><A title="Support us" 
  href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Site_support">Donations</A> 
  </LI></UL></DIV></DIV>
<DIV class=portlet id=p-search>
<H5><LABEL for=searchInput>Search</LABEL></H5>
<DIV class=pBody id=searchBody>
<FORM id=searchform action=/index.php/Special:Search>
<DIV><INPUT id=searchInput title="Search TinyOS Documentation Wiki [f]" 
accessKey=f name=search> <INPUT class=searchButton id=searchGoButton type=submit value=Go name=go>&nbsp; <INPUT class=searchButton id=mw-searchButton type=submit value=Search name=fulltext> 
</DIV></FORM></DIV></DIV>
<DIV class=portlet id=p-tb>
<H5>Toolbox</H5>
<DIV class=pBody>
<UL>
  <LI id=t-whatlinkshere><A title="List of all wiki pages that link here [j]" 
  accessKey=j 
  href="http://docs.tinyos.net/index.php/Special:Whatlinkshere/Network_Protocols">What 
  links here</A> 
  <LI id=t-recentchangeslinked><A 
  title="Recent changes in pages linked from this page [k]" accessKey=k 
  href="http://docs.tinyos.net/index.php/Special:Recentchangeslinked/Network_Protocols">Related 
  changes</A> 
  <LI id=t-upload><A title="Upload images or media files [u]" accessKey=u 
  href="http://docs.tinyos.net/index.php/Special:Upload">Upload file</A> 
  <LI id=t-specialpages><A title="List of all special pages [q]" accessKey=q 
  href="http://docs.tinyos.net/index.php/Special:Specialpages">Special pages</A> 

  <LI id=t-print><A title="Printable version of this page [p]" accessKey=p 
  href="http://docs.tinyos.net/index.php?title=Network_Protocols&amp;printable=yes">Printable 
  version</A> 
  <LI id=t-permalink><A title="Permanent link to this version of the page" 
  href="http://docs.tinyos.net/index.php?title=Network_Protocols&amp;oldid=812">Permanent 
  link</A> </LI></UL></DIV></DIV></DIV><!-- end of the left (by default at least) column -->
<DIV class=visualClear></DIV>
<DIV id=footer>
<DIV id=f-poweredbyico><A href="http://www.mediawiki.org/"><IMG 
alt="Powered by MediaWiki" 
src="Network Protocols - TinyOS Documentation Wiki.files/poweredby_mediawiki_88x31.png"></A></DIV>
<UL id=f-list>
  <LI id=lastmod>This page was last modified 18:19, 25 February 2008. 
  <LI id=viewcount>This page has been accessed 804 times. 
  <LI id=privacy><A title="TinyOS Documentation Wiki:Privacy policy" 
  href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:Privacy_policy">Privacy 
  policy</A> 
  <LI id=about><A title="TinyOS Documentation Wiki:About" 
  href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:About">About 
  TinyOS Documentation Wiki</A> 
  <LI id=disclaimer><A title="TinyOS Documentation Wiki:General disclaimer" 
  href="http://docs.tinyos.net/index.php/TinyOS_Documentation_Wiki:General_disclaimer">Disclaimers</A> 
  </LI></UL></DIV>
<SCRIPT type=text/javascript>if (window.runOnloadHook) runOnloadHook();</SCRIPT>
</DIV><!-- Served in 0.261 secs. --></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -