mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
startet implementation of objective function mrhof
This commit is contained in:
parent
39482f7316
commit
567be35fc4
56
sys/net/sixlowpan/rpl/of_mrhof.c
Normal file
56
sys/net/sixlowpan/rpl/of_mrhof.c
Normal file
@ -0,0 +1,56 @@
|
||||
#include <string.h>
|
||||
#include "of_mrhof.h"
|
||||
|
||||
rpl_of_t rpl_of_mrhof = {
|
||||
0x1,
|
||||
calc_rank,
|
||||
which_parent,
|
||||
which_dodag,
|
||||
reset,
|
||||
NULL
|
||||
};
|
||||
|
||||
rpl_of_t *rpl_get_of_mrhof(){
|
||||
return &rpl_of_mrhof;
|
||||
}
|
||||
|
||||
void reset(rpl_dodag_t *dodag){
|
||||
if(PARENT_SET_SIZE > 3){
|
||||
//do stuff
|
||||
}
|
||||
//todo implement if necessary
|
||||
}
|
||||
|
||||
uint16_t calc_rank(rpl_parent_t * parent, uint16_t base_rank){
|
||||
if(base_rank == 0) {
|
||||
if(parent == NULL) {
|
||||
return INFINITE_RANK;
|
||||
}
|
||||
base_rank = parent->rank;
|
||||
}
|
||||
|
||||
uint16_t add;
|
||||
if(parent != NULL){
|
||||
add = parent->dodag->minhoprankincrease;
|
||||
}
|
||||
else{
|
||||
add = DEFAULT_MIN_HOP_RANK_INCREASE;
|
||||
}
|
||||
if( base_rank + add < base_rank ){
|
||||
return INFINITE_RANK;
|
||||
}
|
||||
return base_rank + add;
|
||||
}
|
||||
|
||||
//We simply return the Parent with lower rank
|
||||
rpl_parent_t * which_parent(rpl_parent_t *p1, rpl_parent_t *p2){
|
||||
if(p1->rank < p2->rank){
|
||||
return p1;
|
||||
}
|
||||
return p2;
|
||||
}
|
||||
|
||||
//Not used yet, as the implementation only makes use of one dodag for now.
|
||||
rpl_dodag_t * which_dodag(rpl_dodag_t *d1, rpl_dodag_t *d2){
|
||||
return d1;
|
||||
}
|
28
sys/net/sixlowpan/rpl/of_mrhof.h
Normal file
28
sys/net/sixlowpan/rpl/of_mrhof.h
Normal file
@ -0,0 +1,28 @@
|
||||
#include "rpl_structs.h"
|
||||
|
||||
// Disallow links with greater than 4 expected
|
||||
// transmission counts on the selected path.
|
||||
#define MAX_LINK_METRIC (512)
|
||||
|
||||
// Disallow paths with greater than 256
|
||||
// expected transmission counts.
|
||||
#define MAX_PATH_COST (32768)
|
||||
|
||||
// Switch to a new path only if it is
|
||||
// expected to require at least 1.5 fewer transmissions than the
|
||||
// current path.
|
||||
#define PARENT_SWITCH_THRESHOLD (192)
|
||||
|
||||
// If the preferred parent is not available, two
|
||||
// candidate parents are still available without triggering a new
|
||||
// round of route discovery.
|
||||
#define PARENT_SET_SIZE (3)
|
||||
|
||||
// Do not allow a node to become a floating root.
|
||||
#define ALLOW_FLOATING_ROOT (0)
|
||||
|
||||
rpl_of_t *rpl_get_of_mrhof();
|
||||
uint16_t calc_rank(rpl_parent_t *, uint16_t);
|
||||
rpl_parent_t *which_parent(rpl_parent_t *, rpl_parent_t *);
|
||||
rpl_dodag_t *which_dodag(rpl_dodag_t *, rpl_dodag_t *);
|
||||
void reset(rpl_dodag_t *);
|
Loading…
Reference in New Issue
Block a user