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.

Introduction

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.

How mh6 works

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.

Motes Send Data Packet

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.

Motes Send Route Packet

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.

Mote Receive and Relay A Data Packet


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.

Running the the mh6 test app

We use the leds on the mote to indicate the current state and activity of the mote with respect to the mh6 multihop code.
blinking  red ledRed Led ---- The mote is receiving the data packet.
blinking green ledGreen Led ---- Receiving the routing data packet.
blinking yellow ledYellow Led ---- The Mote has selected some other motse as its parent.


======= >>>>>>> 1.8

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 mh6 test app

Compiling the test application require 2 steps:

  1. Compile and install the BaseStation on mote with ID = 1.
  2. Compile and install the CollectData application on motes 2 through n.
These steps are performed by requiring the APPLICATION variable in the multihop Makefile to point at BaseStation.nc and CollectData.nc respectively. In the current Makefile, this only requires commenting out the undesired application. In the future, this two step process will likely be resolved by separating the base station code completely.

Running the mh6 test app

  1. Plug the BaseStation (mote 1) into the programming board.
  2. Connect the programming board to a pc using a 9 pin serial cable.
  3. Deploy the other motes as desired.
  4. Open a terminal window and change directories to firebug/project/java, and invoke the mhrun.sh script.

We use the leds on the mote to indicate the current state and activity of the mote with respect to the mh6 multihop code.
blinking red ledRed Led ---- The mote is receiving the data packet.
blinking green ledGreen Led ---- Receiving the routing data packet.
blinking yellow ledYellow Led ---- The Mote is selected by some other mote as their parent.

Running the surge demo


The surge demo provide a graphical view of the network connectivity of motes deployed using the mh6 multihop code.

  1. Start the mh6 test application (see above).
  2. Start the SerialForwarder java application.
  3. Start surge using the appropriate group ID (gid). The default gid is 125, which is set as a parameter in the Makefile for the test application. The GID value is used by CollectData for setting up communications channels. More information on communications channels may be found FIXME