FireBug ---
Multihop test application
Last updated 21 April 2003 |
FireBug is currently using the mh6
multihopping code.
mh6 is under development, in the experimental branch of
the TinyOS source tree at Sourceforge.net.
|
We write an test application code for applying the multihop protocol mh6 for our firebug project. Running this code , we can tell how the motes communicate with each other and how they establish the network for transmitting the data packet to the basestation. The code can be tested by uploading one base station and several "collectdata" motes.
|
All the motes and basestation send out 2 kinds of packets: data packet and routing packet. The motes and basestation send out the these two packet right after the power is turned on at specific time interval. Once a mote receives a routing packet, it will calculate the link cost of the communication, if it is better than the current link, it will update its routing table, that means it will have a new parent(parent means the next hopper of the mote itself). So from then on, the mote will send out the data packet to the parent solely.
|
Let's look first at the module mote sends data packet: the data struct of data is like the following.
CollectDataM.nc
Struct DataFormat_t { uint8_t addr; //the address of mote which generate the message uint8_t cnt; uint8_t sending1; //uint8_t sending2; //more sensor data put here... } Related code to give the value for the variables. struct DataFormat_t *df; df = (struct DataFormat_t *) dataPortion; df->addr = TOS_LOCAL_ADDRESS; df->cnt = counter++; df->sampledata=TOS_LOCAL_ADDRESS; //more sensor data put here |
The CollectData keep a timer running at specific interval, when the timer fires, the mote will collect the sensor data, write it into the struct, and send it out.
|
Also, mote will sends and receive route packet to establish or maintain its communication networks, Every time it receives a route packet, it will calculate the cost of the link using a special algorithm. Once the mote find the better link with small cost that its current link, it will upate the routing table. So next time when it forward message, it will put the parent into the destination Address, the data will be forwarded to that mote.
|
CollectDataM.nc
event TOS_MsgPtr ReceiveAll.receive(TOS_MsgPtr msg) { if (msg->addr == TOS_UART_ADDR) return msg; if (msg->group != TOS_AM_GROUP) return msg; signal CommNotifier.notifyReceive(msg); if (msg->addr == TOS_LOCAL_ADDRESS && msg->type == RS_DATA_TYPE) { msg->length -= sizeof(VirtualCommHeader); return signal ForwardReceive.receive(msg); } return msg; } <<<<<<< mhapp.html |
All motes receive a data packet, only if they confirm it is data packet,they will forward data packet to the next hop according to their routing tables. The basestation will send it to UART for display data on PC, because the mote set the basestation's parent is UART forever.
We use the leds on the mote to indicate the
current state and activity of the mote with
respect to the mh6 multihop code.
Red Led
---- The mote is receiving the data packet.
Green Led
---- Receiving the routing data packet.
Yellow Led
---- The Mote has selected some other motse as its parent.
All motes receive a data packet, only if they confirm it is data packet,they will forward data packet to the next hop according to their routing tables. The basestation will send it to UART for display data on PC, because the mote set the basestation's parent is UART forever.
|
Compiling the test application require 2 steps:
|
We use the leds on the mote to indicate the current state
and activity of the mote with respect to the mh6 multihop
code.
Red Led ---- The mote is receiving
the data packet.
Green Led ---- Receiving the
routing data packet.
Yellow Led ---- The Mote is
selected by some other mote as their parent.
|
The surge
demo provide a graphical view of
the network connectivity of motes deployed using the
mh6 multihop code.