Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

 

Note
NOTE: this is a workaround for debugging purposes. This code is not intended for permanent use but only in case that you want to force a certain topology.

Forcing Multihop in OpenWSN has been simplified. 

For debugging purposes may be interesting to force a certain topology, specially for multi-hop networks. Some debugging code has been introduced and can be controlled by defined constants. Forcing a topology is done at two layers of the stack, at MAC layer, packets are filtered so a particular node can only receive information from certain neighbors.

In file IEEE802154e.c

 

...

Follow this simple steps:

  1. Edit file topology.c in 02a-MACLow folder
  2. Modify TOPOLOGY_MOTEX by adding the 16bit UID of your motes to form a topology. 

Code Block
themeEclipse
languagecpp
linenumberstrue
#include "stdlibopenwsn.h"

//debug -- this define is used to force multihop. Look at isValidAdv and isValidRxFrame functions. Comment it if you don't want to hardcode multihop.
#define FORCE_MULTIHOP
#define GINA_FORCE_MULTIHOP
//#define TELOSB_FORCE_MULTIHOP#include "topology.h"
#include "idmanager.h"

//=========================== defines =========================================

#define TOPOLOGY_MOTE1 0x01
#define TOPOLOGY_MOTE2 0x02
#define TOPOLOGY_MOTE3 0x03
#define TOPOLOGY_MOTE4 0x04
//=========================== variables =======================================

There are different defined constants that are used to control the forced topology.

...


...

TELOSB_FORCE_MULTIHOP enables multihop for a set of telosb motes (or any other platform)

If you want to force a particular topology you need to know the ID of the motes that will be involved and modify the isValidAdv and isValidRxFrame functions as follows. For data packets you want that motes only receive packets and acks from certain motes. Hence you filter whenever a packet is received as follows:

 
Code Block
languagecpp
titleisValidRxFrame
firstline1488
linenumberstrue
#ifdef GINA_FORCE_MULTIHOP
   switch(add->addr_64b[7]){
   case 0xED: 
     res=res&(ieee802514_header->src.addr_64b[7]==0xC9);//only PKT from C9
     break;
   case 0xC9:
     res=res&(ieee802514_header->src.addr_64b[7]==0xED ||ieee802514_header->src.addr_64b[7]==0xD8);//only PKT from ED or D8
     break;
   case 0xD8:
     res=res&(ieee802514_header->src.addr_64b[7]==0xC9||ieee802514_header->src.addr_64b[7]==0xDC);//only PKT from C9 or DC
     break;
   case 0xDC:
     res=res&(ieee802514_header->src.addr_64b[7]==0xD8||ieee802514_header->src.addr_64b[7]==0x9B);//only PKT from D8 or 9B
     break;
   case 0x9B:
     res=res&(ieee802514_header->src.addr_64b[7]==0xDC);//only PKT from DC
     break;
   }
#endif 

Also we need to filter ADV packet as we only want that motes join to a particular parent.

 
Code Block
languagecpp
titleisValidAdv
firstline1421
linenumberstrue
#ifdef GINA_FORCE_MULTIHOP
   switch(add->addr_64b[7]){
   case 0xC9:
     res=res&(ieee802514_header->src.addr_64b[7]==0xED);//only ADV from ED
     break;
   case 0xDC:
     res=res&(ieee802514_header->src.addr_64b[7]==0xD8);//only ADV from D8
     break;
   case 0xD8:
     res=res&(ieee802514_header->src.addr_64b[7]==0xC9);//only ADV from C5
     break;
   case 0x9B:
     res=res&(ieee802514_header->src.addr_64b[7]==0xDC);//only ADV from DC
     break;
   }
#endif

At network layer we also need to ensure that motes choose always the correct preferred parent so we force the selection:

In file neighbors.c first enable the feature.

 

Code Block
languagecpp
titleneighbors.c
firstline8
linenumberstrue
#include "linkcost.h"

//to force routing topology -- see above.
#define FORCE_MULTIHOP
#define GINA_FORCE_MULTIHOP
//#define TELOSB_FORCE_MULTIHOP 
 

...

 
 

...

languagecpp
titleneighbors_updateMyDAGrankAndNeighborPreference()
firstline542
linenumberstrue

...


//=========================== prototypes ======================================


//=========================== public ==========================================

bool topology_isAcceptablePacket(ieee802154_header_iht* ieee802514_header) {
   bool returnVal;
   switch (idmanager_getMyID(ADDR_64B)

...

->addr_64b[7]) {

...


      case 

...

TOPOLOGY_MOTE1:
         if (

...

ieee802514_header->src.addr_64b

...

[7]==

...

TOPOLOGY_MOTE2) {
            

...

returnVal=TRUE;
         } else {
   

...

         

...

returnVal=FALSE;
         }

...


         

...

break;

...


      

...

case 

...

TOPOLOGY_MOTE2:
         

...

if (

...

ieee802514_header->src.addr_64b[7]==

...

TOPOLOGY_MOTE1 ||
             

...

ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE3) {
            

...

returnVal=TRUE;
         } else {
   

...

         returnVal=FALSE;
      

...

   

...

}
         break;
       

...

case 

...

TOPOLOGY_MOTE3:
         

...

if (

...

ieee802514_header->src.addr_64b

...

[7]==

...

TOPOLOGY_MOTE2 ||
             

...

ieee802514_header->src.addr_64b[7]==TOPOLOGY_MOTE4) {
            

...

returnVal=TRUE;
         } else {
   

...

         returnVal=FALSE;
      

...

   }
         

...

break;
       

...

case 

...

TOPOLOGY_MOTE4:
         

...

if (

...

ieee802514_

...

header->src.addr_64b

...

[7]==

...

TOPOLOGY_MOTE3) {
            

...

returnVal=TRUE;
         } else {
   

...

         

...

returnVal=FALSE;
         

...

}

...


         

...

break;
      

...

default:
         

...

returnVal=TRUE;
   }
   return 

...

returnVal;
}

...

 

In this example a 3 hop topology is being defined where Mote with 16bit UID = 0x01 will be the DAGroot. Mote with 16bit UID = 0x02 will be the first hop, Mote with 16bit UID = 0x03 will be the second hop and Mote with 16bit UID = 0x04 will be the third hop.