📄 nido.tex
字号:
\vspace{0.2in}\begin{tabular}{ll}all: & Enable all available messages \\boot: & Simulation boot and StdControl\\clock: & The hardware clock\\task: & Task enqueueing/dequeueing/running\\sched: & The TinyOS scheduler\\sensor: & Sensor readings \\led: & Mote leds\\crypto: & Cryptographic operations (e.g., TinySec)\\route: & Routing systems\\am: & Active messages transmission/reception\\crc: & CRC checks on active messages\\packet: & Packet-level transmission/reception\\encode: & Packet encoding/decoding\\radio: & Low-level radio operations: bits and bytes\\logger: & Non-volatile storage\\adc: & The ADC \\i2c: & The I2C bus\\uart: & The UART (serial port)\\prog: & Network reprogramming\\sounder: & The sounder on the mica sensor board\\time: & Timers\\sim: & \sim internals\\queue: & \sim event queue\\simradio: & \sim radio models\\hardware: & \sim hardware abstractions\\simmem: & \sim memory allocation/deallocation (for finding leaks)\\usr1: & User output mode 1\\usr2: & User output mode 2\\usr3: & User output mode 3\\temp: & For temporary use\\\end{tabular}\vspace{0.2in}\normalsizeAs an example, the statement\scriptsize\begin{verbatim} dbg(DBG_CRC, "crc check failed: \%x, \%x\n", crc, mcrc);\end{verbatim}\normalsize\noindent will print out the failed CRC check message if the user has enabledCRC debug messages, while\scriptsize\begin{verbatim} dbg(DBG_BOOT, "AM Module initialized\n");\end{verbatim}\normalsize\noindent will be printed to standard out if boot messages are enabled. DBGflags can also be combined, as in this example:\scriptsize\begin{verbatim} dbg(DBG_ROUTE|DBG_ERROR, "Received control message: lose our network name!.\n");\end{verbatim}\normalsize\noindent This will print out if either route or error messages are enabled.There are a set of bindings from ASCII strings to debug modes. Forexample, setting DBG to ``{\tt boot}'' will enable boot message (bysetting the appropriate bit in the mask). Setting DBG to ``{\ttboot,route,am}''\footnote{E.g. ``{\tt export DBG=boot,route,am}'' in bash,``{\tt setenv DBG boot,route,am}'' in tcsh, etc.} will enable boot,routing and active message output. Generally, the name of the flag inTinyOS source is ``{\tt DBG\_}'', followed by the name of the DBGoption in all caps. For example, the environment variable value ``{\ttam}'' enables {\tt DBG\_AM} messages, and the value ``{\tt usr1}''enables {\tt DBG\_USR1} messages. Note that if you don't set DBG, then alldebug output is enabled and the simulation will run very slowly.Four modes are reserved for application components: usr1, usr2, usr3,and temp. Developers are urged to use these modes in their code. WhenTinyOS is compiled for mote hardware, all of debug statements areremoved; we have verified that they add no instructions to the TinyOScode image.We have found one of the easiest way to run experiments and gatherdata is to use dbg statements and save them to a file. Generally, themore data printed out, the better (to a point); Perl scripts or othertools can then read in the log of the run and provide information onpacket loss rates, routing state, etc. A useful function, defined in{\tt external\_comm.c}, is {\tt printTime(char* buf, int len)}. Ittakes the current time in simulation and converts it to the formHH:MM:SS, putting it in {\tt buf}..\subsection{Network Monitoring and Packet Injection}To interact with a simulated network, you must use SerialForwarder,the standard TinyOS interface tool. To work with \sim,SerialForwarder's input source must be set appropriately. \simprovides two modes: communication through a serial port to mote 0and network snooping.The serial port mode (``tossim-serial'' in the ``Mote Communications''field or ``-comm tossim-serial'' at the command line) interacts with mote 0over its serial port. Programs connecting to SerialForwarder can readmessages mote 0 sends to its serial port, and send messages to mote 0 overits serial port.The snooping mode (``tossim-radio'' in the ``Mote Communications'' fieldor ``-comm tossim-radio'' at the command line) sits on top of the \simnetwork model. Programs connecting to SerialForwarder hear every radiomessage sent in the network, and can inject radio messages to arrive(without error) at any mote. Because this mode outputs every message {\itsent}, it does not consider loss; programs connecting will hear packetsthat might not arrive successfully at any mote.It's often helpful to use the {\tt -l} flag when using the serial portmode; external applications can then interact with a network insomething approximating real time. Otherwise, in simulations of smallnumbers of motes, things like network timeouts can go off before a PCapplication has a chance to respond.Message Interface Generator (MIG) is a tool that generates Javaclasses for TinyOS packets. The MIG tool parses C structures forTinyOS packets and builds a Java class with accessors for each of thepacket fields. The message classes can also unpack from and pack tobyte arrays.Using MIG with \sim has one hitch; you must specify the {\tt-target=pc} flag when compiling your message classes. MIG classesgenerated for motes may not work with \sim; the two platforms do notnecessarily pack messages identically. Having different wordboundaries (one byte on motes, four bytes on PCs) means thatstructures will have different padding. Problems will definitelyappear if message structures use platform-dependent types such as {\ttint}. \section{Radio Models}\label{sec:radio}\sim simulates the TinyOS network at the bit level, using TinyOScomponent implementations almost identical to the mica 40KbitRFM-based stack. \sim provides two radio models: simple and lossy. Themica2 CC1000-based stack does not currently have a simulationimplementation.In \sim, a network signal is either a one or zero. All signals are ofequal strength, and collision is modeled as a logical or; there is nocancellation. This means that distance does not effect signalstrength; if mote B is very close to mote A, it cannot cut through thesignal from far-away mote C. This makes interference in \sim generallyworse than expected real world behavior.The ``simple'' radio model places all nodes in a single cell. Everybit transmitted is received without error. Although no bits arecorrupted due to error, two motes can transmit at the same time; everymote in the cell will hear the overlap of the signals, which willalmost certainly be a corrupted packet. However, because of perfectbit transmission in a single cell, the probability of two motestransmitting at the same time is very, very low, due to the TinyOSCSMA protocol.The simple model is useful for testing single-hop algorithms andTinyOS components for correctness. Deterministic packet receptionallows deterministic results.\begin{figure}\centering\subfigure[Empirical] {\centering\label{fig:loss_empirical} \includegraphics[clip,angle=-90,width=2in]{fig/empirical.pdf}}\subfigure[Simulated] {\centering\label{fig:loss_sim} \includegraphics[clip,angle=-90,width=2in]{fig/simulated.pdf}}\caption{Empirical and Corresponding Simulated Packet Loss Data}\label{fig:loss_fig}\end{figure}The ``lossy'' radio model places the nodes in a directed graph. Eachedge $(a,b)$ in the graph means $a$'s signal can be heard by$b$. Every edge has a value in the range $(0,1)$, representing theprobability a bit sent by $a$ will be corrupted (flipped) when $b$hears it. For example, a value of 0.01 means each bit transmitted hasa 1\% chance of being flipped, while 1.0 means every bit will beflipped, and 0.0 means bits will be transmitted without error. Eachbit is considered independently.The graph of the lossy model can be specified at \sim boot with afile. \sim looks for the file ``lossy.nss'' by default, but analternate file can be specified with the {\tt -rf} flag. The file hasthe following format:\begin{verbatim}<mote ID>:<mote ID>:bit error rate<mote ID>:<mote ID>:bit error rate<mote ID>:<mote ID>:bit error rate ...\end{verbatim}For example,\begin{verbatim}0:1:0.0123331:0:0.0091121:2:0.013196\end{verbatim}\noindent specifies that mote 1 hears mote 0 with a bit error rate of 1.2\%,mote 0 hears mote 1 with a bit error rate of 0.9\%, and mote 2 hearsmote 1 with a bit error rate of 1.3\%. By making the graph directed,\sim can model asymmetric links, which initial empirical studies havesuggest are a common occurance in TinyOS RFM-stack networks.By specifying error at the bit level, \sim can capture many causes ofpacket loss and noise in a TinyOS network, including missed startsymbols, data corruption, and acknowledgement errors.\sim includes a Java tool, {\tt net.tinyos.sim.LossyBuilder} for generatingloss rates from physical topologies. The tool models loss ratesobserved empirically in an experiment performed by Woo et al. on aTinyOS network~\cite{empirical}. The empirical data is from a networkof twenty-six \motes, placed in a line, spaced at regular two footintervals, with the TinyOS radio set at a medium power setting (50 outof 100). Each \mote transmitted two hundred packets, with each other\mote keeping track of the number of packetsheard. Figure~\ref{fig:loss_empirical} shows a plot of this empiricaldata.To generate lossy models, the tool has Gaussian packet lossprobability distributions for each distance, fit to match theempirical data. Given a physical \mote topology, the tool generatespacket loss rates for each \mote pair by sampling thesedistributions. The tool translates packet error rates into independentbit error rates. Figure~\ref{fig:loss_sim} shows the results of theexperiment used to gather loss data when run in \sim.The lossy model models interference and corruption, but it does notmodel noise; if no mote transmits, every mote will hear a perfectlyclear channel.\subsection{Using LossyBuilder}LossyBuilder assumes each mote has a transmission radius of 50feet. Combined with the bit error rate, this means each mote transmitsits signal in a disc of radius 50 feet, with the bit error rateincreasing with distance from the center.LossyBuilder can read in or generate physical topologies ((x,y)coordinates), and generate loss topologies from physical topologies bysampling from the model of the empirical distribution inFigure~\ref{fig:loss_empirical}. Its usage is:\begin{verbatim}usage: java net.tinyos.sim.LossyBuilder [options]options: -t grid: Topology (grid only and default) -d <m> <n>: Grid size (m by n) (default: 10 x 10) -s <scale>: Spacing factor (default: 5.0) -o <file>: Output file -i <file>: Input file of positions -p: Generate positions, not error rates\end{verbatim}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -