Cleaned up code style, comments, and print outs. Set default DAG parameters when the DIO configuration option is missing.

This commit is contained in:
Nicolas Tsiftes 2012-02-29 21:59:50 +01:00
parent 6e41f6fbe9
commit d0e2d9b47e
7 changed files with 102 additions and 107 deletions

View File

@ -62,11 +62,11 @@ extern rpl_of_t RPL_OF;
static rpl_of_t * const objective_functions[] = {&RPL_OF};
/************************************************************************/
#ifndef RPL_CONF_MAX_PARENTS_PER_DODAG
#define RPL_MAX_PARENTS_PER_DODAG 8
#ifndef RPL_CONF_MAX_PARENTS_PER_DAG
#define RPL_MAX_PARENTS_PER_DAG 8
#else
#define RPL_MAX_PARENTS_PER_DODAG RPL_CONF_MAX_PARENTS_PER_DODAG
#endif /* !RPL_CONF_MAX_PARENTS */
#define RPL_MAX_PARENTS_PER_DAG RPL_CONF_MAX_PARENTS_PER_DAG
#endif /* !RPL_CONF_MAX_PARENTS_PER_DAG */
/************************************************************************/
/* RPL definitions. */
@ -77,30 +77,16 @@ static rpl_of_t * const objective_functions[] = {&RPL_OF};
#define RPL_GROUNDED RPL_CONF_GROUNDED
#endif /* !RPL_CONF_GROUNDED */
#ifndef RPL_CONF_DIO_INTERVAL_MIN
#define RPL_DIO_INTERVAL_MIN DEFAULT_DIO_INTERVAL_MIN
#else
#define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
#endif /* !RPL_CONF_DIO_INTERVAL_MIN */
#ifndef RPL_CONF_DIO_INTERVAL_DOUBLINGS
#define RPL_DIO_INTERVAL_DOUBLINGS DEFAULT_DIO_INTERVAL_DOUBLINGS
#else
#define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
#endif /* !RPL_CONF_DIO_INTERVAL_DOUBLINGS */
/************************************************************************/
/* Allocate parents from the same static MEMB chunk to reduce memory waste. */
MEMB(parent_memb, struct rpl_parent,
RPL_MAX_PARENTS_PER_DODAG * RPL_MAX_INSTANCES * RPL_MAX_DODAG_PER_INSTANCE);
RPL_MAX_PARENTS_PER_DAG * RPL_MAX_INSTANCES * RPL_MAX_DAG_PER_INSTANCE);
/************************************************************************/
/* Allocate instance table. */
rpl_instance_t instance_table[RPL_MAX_INSTANCES];
rpl_instance_t *default_instance;
/************************************************************************/
/* lollipop greater than function. */
/* Greater-than function for the lollipop counter. */
/************************************************************************/
int rpl_lollipop_greater_than(int a, int b) {
/* Check if we are comparing an initial value with an old value */
@ -113,7 +99,6 @@ int rpl_lollipop_greater_than(int a, int b) {
(a < b && (b - a) > (RPL_LOLLIPOP_CIRCULAR_REGION + 1-
RPL_LOLLIPOP_SEQUENCE_WINDOWS));
}
/************************************************************************/
/* Remove DAG parents with a rank that is at least the same as minimum_rank. */
static void
@ -225,15 +210,15 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id)
memcpy(&dag->dag_id, dag_id, sizeof(dag->dag_id));
instance->dio_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
instance->dio_intmin = DEFAULT_DIO_INTERVAL_MIN;
instance->dio_intdoubl = RPL_DIO_INTERVAL_DOUBLINGS;
instance->dio_intmin = RPL_DIO_INTERVAL_MIN;
/* The current interval must differ from the minimum interval in order to
trigger a DIO timer reset. */
instance->dio_intcurrent = DEFAULT_DIO_INTERVAL_MIN +
DEFAULT_DIO_INTERVAL_DOUBLINGS;
instance->dio_redundancy = DEFAULT_DIO_REDUNDANCY;
instance->max_rankinc = DEFAULT_MAX_RANKINC;
instance->min_hoprankinc = DEFAULT_MIN_HOPRANKINC;
instance->dio_intcurrent = RPL_DIO_INTERVAL_MIN +
RPL_DIO_INTERVAL_DOUBLINGS;
instance->dio_redundancy = RPL_DIO_REDUNDANCY;
instance->max_rankinc = RPL_MAX_RANKINC;
instance->min_hoprankinc = RPL_MIN_HOPRANKINC;
instance->default_lifetime = RPL_DEFAULT_LIFETIME;
instance->lifetime_unit = RPL_DEFAULT_LIFETIME_UNIT;
@ -409,7 +394,7 @@ rpl_alloc_dodag(uint8_t instance_id, uip_ipaddr_t *dag_id)
return dag;
}
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DODAG_PER_INSTANCE; dag < end; ++dag) {
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(!dag->used) {
memset(dag, 0, sizeof(*dag));
dag->parents = &dag->parent_list;
@ -438,8 +423,8 @@ rpl_free_instance(rpl_instance_t *instance)
PRINTF("RPL: Leaving the instance %u\n", instance->instance_id);
/* Remove any DODAG inside this instance */
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DODAG_PER_INSTANCE; dag < end; ++dag) {
/* Remove any DAG inside this instance */
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(dag->used) {
rpl_free_dodag(dag);
}
@ -519,7 +504,7 @@ find_parent_dag(rpl_instance_t *instance, uip_ipaddr_t *addr)
rpl_parent_t *p;
rpl_dag_t *dag, *end;
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DODAG_PER_INSTANCE; dag < end; ++dag) {
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(dag->used) {
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(uip_ipaddr_cmp(&p->addr, addr)) {
@ -537,7 +522,7 @@ rpl_find_parent_any_dag(rpl_instance_t *instance, uip_ipaddr_t *addr)
rpl_parent_t *p;
rpl_dag_t *dag, *end;
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DODAG_PER_INSTANCE; dag < end; ++dag) {
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(dag->used) {
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(uip_ipaddr_cmp(&p->addr, addr)) {
@ -567,7 +552,7 @@ rpl_select_dodag(rpl_instance_t *instance, rpl_parent_t *p)
}
} else if(p->dag == best_dag) {
best_dag = NULL;
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DODAG_PER_INSTANCE; dag < end; ++dag) {
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(dag->used && dag->preferred_parent != NULL && dag->preferred_parent->rank != INFINITE_RANK) {
if(best_dag == NULL) {
best_dag = dag;
@ -588,7 +573,7 @@ rpl_select_dodag(rpl_instance_t *instance, rpl_parent_t *p)
/* Remove routes installed by DAOs. */
rpl_remove_routes(instance->current_dag);
PRINTF("RPL: New preferred DODAG: ");
PRINTF("RPL: New preferred DAG: ");
PRINT6ADDR(&best_dag->dag_id);
PRINTF("\n");
@ -613,7 +598,7 @@ rpl_select_dodag(rpl_instance_t *instance, rpl_parent_t *p)
instance->current_dag->preferred_parent = NULL;
if(instance->mop != RPL_MOP_NO_DOWNWARD_ROUTES && last_parent != NULL) {
/* Send a No-Path DAO to the removed preferred parent. */
dao_output(last_parent, ZERO_LIFETIME);
dao_output(last_parent, RPL_ZERO_LIFETIME);
}
return NULL;
}
@ -626,7 +611,7 @@ rpl_select_dodag(rpl_instance_t *instance, rpl_parent_t *p)
if(instance->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
if(last_parent != NULL) {
/* Send a No-Path DAO to the removed preferred parent. */
dao_output(last_parent, ZERO_LIFETIME);
dao_output(last_parent, RPL_ZERO_LIFETIME);
}
/* The DAO parent set changed - schedule a DAO transmission. */
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
@ -692,7 +677,7 @@ rpl_nullify_parent(rpl_dag_t *dag, rpl_parent_t *parent)
}
dag->instance->def_route = NULL;
}
dao_output(parent, ZERO_LIFETIME);
dao_output(parent, RPL_ZERO_LIFETIME);
}
}
@ -768,7 +753,7 @@ rpl_get_dodag(uint8_t instance_id, uip_ipaddr_t *dag_id)
return NULL;
}
for(i = 0; i < RPL_MAX_DODAG_PER_INSTANCE; ++i) {
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; ++i) {
dag = &instance->dag_table[i];
if(dag->used && uip_ipaddr_cmp(&dag->dag_id, dag_id)) {
return dag;
@ -1003,7 +988,7 @@ rpl_local_repair(rpl_instance_t *instance)
int i;
PRINTF("RPL: Starting a local instance repair\n");
for(i = 0; i < RPL_MAX_DODAG_PER_INSTANCE; i++) {
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
if(instance->dag_table[i].used) {
instance->dag_table[i].rank = INFINITE_RANK;
nullify_parents(&instance->dag_table[i], 0);
@ -1029,7 +1014,7 @@ rpl_recalculate_ranks(void)
*/
for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) {
if(instance->used) {
for(i = 0; i < RPL_MAX_DODAG_PER_INSTANCE; i++) {
for(i = 0; i < RPL_MAX_DAG_PER_INSTANCE; i++) {
if(instance->dag_table[i].used) {
for(p = list_head(instance->dag_table[i].parents); p != NULL; p = p->next) {
if(p->updated) {
@ -1190,7 +1175,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DODAG) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DAG) {
/* Make room for a new parent. */
remove_worst_parent(dag, dio->rank);
}
@ -1220,7 +1205,7 @@ rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
}
}
PRINTF("RPL: preferred DODAG ");
PRINTF("RPL: preferred DAG ");
PRINT6ADDR(&instance->current_dag->dag_id);
PRINTF(", rank %u, min_rank %u, ",
instance->current_dag->rank, instance->current_dag->min_rank);

View File

@ -92,6 +92,8 @@ void RPL_DEBUG_DIO_INPUT(uip_ipaddr_t *, rpl_dio_t *);
void RPL_DEBUG_DAO_OUTPUT(rpl_parent_t *);
#endif
extern rpl_of_t RPL_OF;
/*---------------------------------------------------------------------------*/
static int
get_global_addr(uip_ipaddr_t *addr)
@ -209,9 +211,15 @@ dio_input(void)
memset(&dio, 0, sizeof(dio));
dio.dag_intdoubl = DEFAULT_DIO_INTERVAL_DOUBLINGS;
dio.dag_intmin = DEFAULT_DIO_INTERVAL_MIN;
dio.dag_redund = DEFAULT_DIO_REDUNDANCY;
/* Set default values in case the DIO configuration option is missing. */
dio.dag_intdoubl = RPL_DIO_INTERVAL_DOUBLINGS;
dio.dag_intmin = RPL_DIO_INTERVAL_MIN;
dio.dag_redund = RPL_DIO_REDUNDANCY;
dio.dag_min_hoprankinc = RPL_MIN_HOPRANKINC;
dio.dag_max_rankinc = RPL_MAX_RANKINC;
dio.ocp = RPL_OF.ocp;
dio.default_lifetime = RPL_DEFAULT_LIFETIME;
dio.lifetime_unit = RPL_DEFAULT_LIFETIME_UNIT;
uip_ipaddr_copy(&from, &UIP_IP_BUF->srcipaddr);
@ -251,8 +259,10 @@ dio_input(void)
dio.rank = get16(buffer, i);
i += 2;
PRINTF("RPL: Incoming DIO InstanceID-Version %u-%u\n", (unsigned)dio.instance_id,(unsigned)dio.version);
PRINTF("RPL: Incoming DIO rank %u\n", (unsigned)dio.rank);
PRINTF("RPL: Incoming DIO (id, ver, rank) = (%u,%u,%u)\n",
(unsigned)dio.instance_id,
(unsigned)dio.version,
(unsigned)dio.rank);
dio.grounded = buffer[i] & RPL_DIO_GROUNDED;
dio.mop = (buffer[i]& RPL_DIO_MOP_MASK) >> RPL_DIO_MOP_SHIFT;
@ -265,9 +275,9 @@ dio_input(void)
memcpy(&dio.dag_id, buffer + i, sizeof(dio.dag_id));
i += sizeof(dio.dag_id);
PRINTF("RPL: Incoming DIO DODAG ");
PRINTF("RPL: Incoming DIO (dag_id, pref) = (");
PRINT6ADDR(&dio.dag_id);
PRINTF(", preference: %u\n", dio.preference);
PRINTF(", %u)\n", dio.preference);
/* Check if there are any DIO suboptions. */
for(; i < buffer_length; i += len) {
@ -326,7 +336,7 @@ dio_input(void)
return;
}
/* flags is both preference and flags for now */
/* The flags field includes the preference value. */
dio.destination_prefix.length = buffer[i + 2];
dio.destination_prefix.flags = buffer[i + 3];
dio.destination_prefix.lifetime = get32(buffer, i + 4);
@ -337,7 +347,7 @@ dio_input(void)
memcpy(&dio.destination_prefix.prefix, &buffer[i + 8],
(dio.destination_prefix.length + 7) / 8);
} else {
PRINTF("RPL: Invalid route infoprefix option, len = %d\n", len);
PRINTF("RPL: Invalid route info option, len = %d\n", len);
RPL_STAT(rpl_stats.malformed_msgs++);
return;
}
@ -360,14 +370,14 @@ dio_input(void)
/* buffer + 12 is reserved */
dio.default_lifetime = buffer[i + 13];
dio.lifetime_unit = get16(buffer, i + 14);
PRINTF("RPL: DIO Conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n",
dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund,
dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp,
dio.default_lifetime, dio.lifetime_unit);
break;
case RPL_OPTION_PREFIX_INFO:
if(len != 32) {
PRINTF("RPL: DAG Prefix info not ok, len != 32\n");
PRINTF("RPL: DAG prefix info not ok, len != 32\n");
RPL_STAT(rpl_stats.malformed_msgs++);
return;
}
@ -398,6 +408,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
{
unsigned char *buffer;
int pos;
rpl_dag_t *dag = instance->current_dag;
#if !RPL_LEAF_ONLY
uip_ipaddr_t addr;
#endif /* !RPL_LEAF_ONLY */
@ -409,8 +420,6 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr)
}
#endif /* RPL_LEAF_ONLY */
rpl_dag_t *dag = instance->current_dag;
/* DAG Information Object */
pos = 0;
@ -597,7 +606,7 @@ dao_input(void)
/* Is the DAGID present? */
if(flags & RPL_DAO_D_FLAG) {
if(memcmp(&dag->dag_id, &buffer[pos], sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring a DAO for a DODAG different from ours\n");
PRINTF("RPL: Ignoring a DAO for a DAG different from ours\n");
return;
}
pos += 16;
@ -640,7 +649,7 @@ dao_input(void)
rep = uip_ds6_route_lookup(&prefix);
if(lifetime == ZERO_LIFETIME) {
if(lifetime == RPL_ZERO_LIFETIME) {
/* No-Path DAO received; invoke the route purging routine. */
if(rep != NULL && rep->state.saved_lifetime == 0 && rep->length == prefixlen) {
PRINTF("RPL: Setting expiration timer for prefix ");
@ -733,19 +742,19 @@ dao_output(rpl_parent_t *n, uint8_t lifetime)
buffer[pos++] = instance->instance_id;
buffer[pos] = 0;
#if RPL_DAO_SPECIFY_DODAG
#if RPL_DAO_SPECIFY_DAG
buffer[pos] |= RPL_DAO_D_FLAG;
#endif /* RPL_DAO_SPECIFY_DODAG */
#endif /* RPL_DAO_SPECIFY_DAG */
#if RPL_CONF_DAO_ACK
buffer[pos] |= RPL_DAO_K_FLAG;
#endif /* RPL_CONF_DAO_ACK */
++pos;
buffer[pos++] = 0; /* reserved */
buffer[pos++] = dao_sequence;
#if RPL_DAO_SPECIFY_DODAG
#if RPL_DAO_SPECIFY_DAG
memcpy(buffer + pos, &dag->dag_id, sizeof(dag->dag_id));
pos+=sizeof(dag->dag_id);
#endif /* RPL_DAO_SPECIFY_DODAG */
#endif /* RPL_DAO_SPECIFY_DAG */
/* create target subopt */
prefixlen = sizeof(prefix) * CHAR_BIT;

View File

@ -112,7 +112,7 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
if(base_rank == 0) {
return INFINITE_RANK;
}
rank_increase = NEIGHBOR_INFO_FIX2ETX(INITIAL_LINK_METRIC) * DEFAULT_MIN_HOPRANKINC;
rank_increase = NEIGHBOR_INFO_FIX2ETX(INITIAL_LINK_METRIC) * RPL_MIN_HOPRANKINC;
} else {
/* multiply first, then scale down to avoid truncation effects */
rank_increase = NEIGHBOR_INFO_FIX2ETX(p->link_metric * p->dag->instance->min_hoprankinc);

View File

@ -62,7 +62,7 @@ rpl_of_t rpl_of0 = {
0
};
#define DEFAULT_RANK_INCREMENT DEFAULT_MIN_HOPRANKINC
#define DEFAULT_RANK_INCREMENT RPL_MIN_HOPRANKINC
#define MIN_DIFFERENCE (NEIGHBOR_INFO_ETX_DIVISOR + NEIGHBOR_INFO_ETX_DIVISOR / 2)

View File

@ -110,10 +110,10 @@
/* Default values for RPL constants and variables. */
/* The default value for the DAO timer. */
#define DEFAULT_DAO_LATENCY (CLOCK_SECOND * 8)
#define RPL_DAO_LATENCY (CLOCK_SECOND * 4)
/* Special value indicating immediate removal. */
#define ZERO_LIFETIME 0
#define RPL_ZERO_LIFETIME 0
/* Default route lifetime unit. */
#define RPL_DEFAULT_LIFETIME_UNIT 0xffff
@ -125,13 +125,14 @@
((unsigned long)(instance)->lifetime_unit * (lifetime))
#ifndef RPL_CONF_MIN_HOPRANKINC
#define DEFAULT_MIN_HOPRANKINC 256
#define RPL_MIN_HOPRANKINC 256
#else
#define DEFAULT_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
#define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
#endif
#define DEFAULT_MAX_RANKINC (7 * DEFAULT_MIN_HOPRANKINC)
#define RPL_MAX_RANKINC (7 * RPL_MIN_HOPRANKINC)
#define DAG_RANK(fixpt_rank, instance) ((fixpt_rank) / (instance)->min_hoprankinc)
#define DAG_RANK(fixpt_rank, instance) \
((fixpt_rank) / (instance)->min_hoprankinc)
/* Rank of a virtual root node that coordinates DAG root nodes. */
#define BASE_RANK 0
@ -148,23 +149,23 @@
means 8 milliseconds, but that is an unreasonable value if
using power-saving / duty-cycling */
#ifdef RPL_CONF_DIO_INTERVAL_MIN
#define DEFAULT_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
#define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
#else
#define DEFAULT_DIO_INTERVAL_MIN 12
#define RPL_DIO_INTERVAL_MIN 12
#endif
/* Maximum amount of timer doublings. */
#ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
#define DEFAULT_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
#define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
#else
#define DEFAULT_DIO_INTERVAL_DOUBLINGS 8
#define RPL_DIO_INTERVAL_DOUBLINGS 8
#endif
/* Default DIO redundancy. */
#ifdef RPL_CONF_DIO_REDUNDANCY
#define DEFAULT_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
#define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
#else
#define DEFAULT_DIO_REDUNDANCY 10
#define RPL_DIO_REDUNDANCY 10
#endif
/* Expire DAOs from neighbors that do not respond in this time. (seconds) */
@ -207,6 +208,20 @@
#endif
#define RPL_DIS_START_DELAY 5
/*---------------------------------------------------------------------------*/
/* Lollipop counters */
#define RPL_LOLLIPOP_MAX_VALUE 255
#define RPL_LOLLIPOP_CIRCULAR_REGION 127
#define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
#define RPL_LOLLIPOP_INIT (RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1)
#define RPL_LOLLIPOP_INCREMENT(counter) \
((counter) > RPL_LOLLIPOP_CIRCULAR_REGION ? \
++(counter) & RPL_LOLLIPOP_MAX_VALUE : \
++(counter) & RPL_LOLLIPOP_CIRCULAR_REGION)
#define RPL_LOLLIPOP_IS_INIT(counter) \
((counter) > RPL_LOLLIPOP_CIRCULAR_REGION)
/*---------------------------------------------------------------------------*/
/* Logical representation of a DAG Information Object (DIO.) */
struct rpl_dio {
uip_ipaddr_t dag_id;

View File

@ -225,8 +225,8 @@ rpl_schedule_dao(rpl_instance_t *instance)
if(!etimer_expired(&instance->dao_timer.etimer)) {
PRINTF("RPL: DAO timer already scheduled\n");
} else {
expiration_time = DEFAULT_DAO_LATENCY / 2 +
(random_rand() % (DEFAULT_DAO_LATENCY));
expiration_time = RPL_DAO_LATENCY / 2 +
(random_rand() % (RPL_DAO_LATENCY));
PRINTF("RPL: Scheduling DAO timer %u ticks in the future\n",
(unsigned)expiration_time);
ctimer_set(&instance->dao_timer, expiration_time,

View File

@ -97,24 +97,24 @@
/*
* Maximum of concurent dodag inside an instance
*/
#ifndef RPL_CONF_MAX_DODAG_PER_INSTANCE
#define RPL_MAX_DODAG_PER_INSTANCE 2
#ifndef RPL_CONF_MAX_DAG_PER_INSTANCE
#define RPL_MAX_DAG_PER_INSTANCE 2
#else
#define RPL_MAX_DODAG_PER_INSTANCE RPL_CONF_MAX_DODAG_PER_INSTANCE
#endif /* !RPL_CONF_MAX_DODAG_PER_INSTANCE */
#define RPL_MAX_DAG_PER_INSTANCE RPL_CONF_MAX_DAG_PER_INSTANCE
#endif /* !RPL_CONF_MAX_DAG_PER_INSTANCE */
/*
*
*/
#ifndef RPL_CONF_DAO_SPECIFY_DODAG
#if RPL_MAX_DODAG_PER_INSTANCE > 1
#define RPL_DAO_SPECIFY_DODAG 1
#else /* RPL_MAX_DODAG_PER_INSTANCE > 1*/
#define RPL_DAO_SPECIFY_DODAG 0
#endif /* RPL_MAX_DODAG_PER_INSTANCE > 1 */
#else /* RPL_CONF_DAO_SPECIFY_DODAG */
#define RPL_DAO_SPECIFY_DODAG RPL_CONF_DAO_SPECIFY_DODAG
#endif /* RPL_CONF_DAO_SPECIFY_DODAG */
#ifndef RPL_CONF_DAO_SPECIFY_DAG
#if RPL_MAX_DAG_PER_INSTANCE > 1
#define RPL_DAO_SPECIFY_DAG 1
#else /* RPL_MAX_DAG_PER_INSTANCE > 1*/
#define RPL_DAO_SPECIFY_DAG 0
#endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */
#else /* RPL_CONF_DAO_SPECIFY_DAG */
#define RPL_DAO_SPECIFY_DAG RPL_CONF_DAO_SPECIFY_DAG
#endif /* RPL_CONF_DAO_SPECIFY_DAG */
/*---------------------------------------------------------------------------*/
@ -123,20 +123,6 @@
/*---------------------------------------------------------------------------*/
typedef uint16_t rpl_rank_t;
typedef uint16_t rpl_ocp_t;
/*---------------------------------------------------------------------------*/
/* Lollipop counters */
#define RPL_LOLLIPOP_MAX_VALUE 255
#define RPL_LOLLIPOP_CIRCULAR_REGION 127
#define RPL_LOLLIPOP_SEQUENCE_WINDOWS 16
#define RPL_LOLLIPOP_INIT RPL_LOLLIPOP_MAX_VALUE - RPL_LOLLIPOP_SEQUENCE_WINDOWS + 1
#define RPL_LOLLIPOP_INCREMENT(ctr) (ctr > RPL_LOLLIPOP_CIRCULAR_REGION ? \
++ctr & RPL_LOLLIPOP_MAX_VALUE : \
++ctr & RPL_LOLLIPOP_CIRCULAR_REGION)
#define RPL_LOLLIPOP_IS_INIT(counter) (counter > RPL_LOLLIPOP_CIRCULAR_REGION)
/*---------------------------------------------------------------------------*/
/* DAG Metric Container Object Types, to be confirmed by IANA. */
#define RPL_DAG_MC_NONE 0 /* Local identifier for empty MC */
@ -217,7 +203,7 @@ typedef struct rpl_prefix rpl_prefix_t;
/* Directed Acyclic Graph */
struct rpl_dag {
uip_ipaddr_t dag_id;
rpl_rank_t min_rank; /* should be reset per DODAG iteration! */
rpl_rank_t min_rank; /* should be reset per DAG iteration! */
uint8_t version;
uint8_t grounded;
uint8_t preference;
@ -286,7 +272,7 @@ struct rpl_instance {
rpl_metric_container_t mc;
rpl_of_t *of;
rpl_dag_t *current_dag;
rpl_dag_t dag_table[RPL_MAX_DODAG_PER_INSTANCE];
rpl_dag_t dag_table[RPL_MAX_DAG_PER_INSTANCE];
/* The current default router - used for routing "upwards" */
uip_ds6_defrt_t *def_route;
uint8_t instance_id;