42 #include "net/rpl/rpl-private.h"
44 #define DEBUG DEBUG_NONE
49 static void reset(rpl_dag_t *);
50 static rpl_parent_t *best_parent(rpl_parent_t *, rpl_parent_t *);
51 static rpl_rank_t calculate_rank(rpl_parent_t *, rpl_rank_t);
52 static void update_metric_container(rpl_dag_t *);
59 update_metric_container,
63 #define DEFAULT_RANK_INCREMENT DEFAULT_MIN_HOPRANKINC
65 #define MIN_DIFFERENCE (NEIGHBOR_INFO_ETX_DIVISOR + NEIGHBOR_INFO_ETX_DIVISOR / 2)
70 PRINTF(
"RPL: Resetting OF0\n");
74 calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
84 increment = p !=
NULL ? p->dag->min_hoprankinc : DEFAULT_RANK_INCREMENT;
86 if((rpl_rank_t)(base_rank + increment) < base_rank) {
87 PRINTF(
"RPL: OF0 rank %d incremented to infinite rank due to wrapping\n",
91 return base_rank + increment;
96 best_parent(rpl_parent_t *p1, rpl_parent_t *p2)
101 PRINTF(
"RPL: Comparing parent ");
102 PRINT6ADDR(&p1->addr);
103 PRINTF(
" (confidence %d, rank %d) with parent ",
104 p1->link_metric, p1->rank);
105 PRINT6ADDR(&p2->addr);
106 PRINTF(
" (confidence %d, rank %d)\n",
107 p2->link_metric, p2->rank);
110 r1 = DAG_RANK(p1->rank, (rpl_dag_t *)p1->dag) * NEIGHBOR_INFO_ETX_DIVISOR +
112 r2 = DAG_RANK(p2->rank, (rpl_dag_t *)p1->dag) * NEIGHBOR_INFO_ETX_DIVISOR +
118 dag = (rpl_dag_t *)p1->dag;
119 if(r1 < r2 + MIN_DIFFERENCE &&
120 r1 > r2 - MIN_DIFFERENCE) {
121 return dag->preferred_parent;
130 update_metric_container(rpl_dag_t *dag)
132 dag->mc.type = RPL_DAG_MC_NONE;