本文整理汇总了C++中rpl_schedule_dao函数的典型用法代码示例。如果您正苦于以下问题:C++ rpl_schedule_dao函数的具体用法?C++ rpl_schedule_dao怎么用?C++ rpl_schedule_dao使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rpl_schedule_dao函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: global_repair
static void
global_repair(uip_ipaddr_t *from, rpl_dag_t *dag, rpl_dio_t *dio)
{
rpl_parent_t *p;
remove_parents(dag, 0);
dag->version = dio->version;
dag->dtsn_out = 1;
dag->of->reset(dag);
if((p = rpl_add_parent(dag, dio, from)) == NULL) {
PRINTF("RPL: Failed to add a parent during the global repair\n");
dag->rank = INFINITE_RANK;
} else {
rpl_set_default_route(dag, from);
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
dag->min_rank = dag->rank;
rpl_reset_dio_timer(dag, 1);
if(should_send_dao(dag, dio, p)) {
rpl_schedule_dao(dag);
}
}
PRINTF("RPL: Participating in a global repair (version=%u, rank=%hu)\n",
dag->version, dag->rank);
RPL_STAT(rpl_stats.global_repairs++);
}
示例2: rpl_select_parent
rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
rpl_parent_t *p;
rpl_parent_t *best;
best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(p->rank == INFINITE_RANK) {
/* ignore this neighbor */
} else if(best == NULL) {
best = p;
} else {
best = dag->of->best_parent(best, p);
}
}
if(best == NULL) {
/* need to handle update of best... */
return NULL;
}
if(dag->preferred_parent != best) {
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
PRINTF("RPL: Sending a No-Path DAO to old DAO parent\n");
dao_output(dag->preferred_parent, ZERO_LIFETIME);
}
dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag);
rpl_set_default_route(dag, &best->addr);
/* The DAO parent set changed - schedule a DAO transmission. */
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
rpl_schedule_dao(dag);
}
rpl_reset_dio_timer(dag, 1);
PRINTF("RPL: New preferred parent, rank changed from %u to %u\n",
(unsigned)dag->rank, dag->of->calculate_rank(best, 0));
RPL_STAT(rpl_stats.parent_switch++);
}
/* Update the DAG rank, since link-layer information may have changed
the local confidence. */
dag->rank = dag->of->calculate_rank(best, 0);
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
} else if(!acceptable_rank(dag, best->rank)) {
/* Send a No-Path DAO to the soon-to-be-removed preferred parent. */
if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
dao_output(best, ZERO_LIFETIME);
}
remove_parents(dag, 0);
return NULL;
}
return best;
}
示例3: rpl_select_parent
rpl_parent_t *
rpl_select_parent(rpl_dag_t *dag)
{
rpl_parent_t *p;
rpl_parent_t *best;
best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(best == NULL) {
best = p;
} else {
best = dag->of->best_parent(best, p);
}
}
if(dag->preferred_parent != best) {
dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag);
rpl_set_default_route(dag, &best->addr);
/* The DAO parent set changed - schedule a DAO transmission. */
rpl_schedule_dao(dag);
rpl_reset_dio_timer(dag, 1);
PRINTF("RPL: New preferred parent, rank changed from %u to %u\n",
(unsigned)dag->rank, dag->of->calculate_rank(best, 0));
}
/* Update the DAG rank, since link-layer information may have changed
the local confidence. */
dag->rank = dag->of->calculate_rank(best, 0);
if(dag->rank < dag->min_rank) {
dag->min_rank = dag->rank;
} else if(!acceptable_rank(dag, best->rank)) {
/* Send a No-Path DAO to the soon-to-be-removed preferred parent. */
dao_output(p, ZERO_LIFETIME);
remove_parents(dag, 0);
return NULL;
}
return best;
}
示例4: rpl_process_dio
//.........这里部分代码省略.........
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
} else if(dio->rank == INFINITE_RANK && dag->joined) {
rpl_reset_dio_timer(instance);
}
/* Prefix Information Option treated to add new prefix */
if(dio->prefix_info.length != 0) {
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
PRINTF("RPL : Prefix announced in DIO\n");
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
#if !WITH_ORPL
return; /* With ORPL we want to have neighbors in the "rpl_parents"
table as we need their rank and ackcount for routing set. */
#endif
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
/* Add the DIO sender as a candidate parent. */
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a new parent (");
PRINT6ADDR(from);
PRINTF(")\n");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank=dio->rank;
}
}
#if WITH_ORPL
if(dag->rank == ROOT_RANK(instance)) {
/* We have added the parent, now return if we are root */
return;
}
#endif
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);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, -1/*p->mc.obj.etx*/, p->link_metric, instance->mc.obj.etx);
/* We have allocated a candidate parent; process the DIO further. */
#if RPL_DAG_MC != RPL_DAG_MC_NONE
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
uip_ds6_defrt_add(from, RPL_LIFETIME(instance, instance->default_lifetime));
}
p->dtsn = dio->dtsn;
}
示例5: rpl_process_dio
//.........这里部分代码省略.........
PRINT6ADDR(from);
PRINTF("\n");
return;
}
if(instance == NULL) {
PRINTF("RPL: New instance detected: Joining...\n");
rpl_join_instance(from, dio);
return;
}
if(dag == NULL) {
PRINTF("RPL: Adding new DAG to known instance.\n");
rpl_add_dag(from, dio);
return;
}
if(dio->rank < ROOT_RANK(instance)) {
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
} else if(dio->rank == INFINITE_RANK && dag->joined) {
rpl_reset_dio_timer(instance);
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS_PER_DAG) {
/* Make room for a new parent. */
remove_worst_parent(dag, dio->rank);
}
/* Add the DIO sender as a candidate parent. */
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a new parent (");
PRINT6ADDR(from);
PRINTF(")\n");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank=dio->rank;
}
}
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);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, p->mc.obj.etx, p->link_metric, instance->mc.obj.etx);
/* We have allocated a candidate parent; process the DIO further. */
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
}
p->dtsn = dio->dtsn;
}
示例6: rpl_process_dio
//.........这里部分代码省略.........
}
// LVD 24/03/2011
instanceID = dio->instance_id;
dag = rpl_get_dag(dio->instance_id);
if(dag == NULL) {
/* Join the first possible DAG of this RPL instance. */
if(dio->rank != INFINITE_RANK) {
join_dag(from, dio);
} else {
PRINTF("RPL: Ignoring DIO from node with infinite rank: ");
PRINT6ADDR(from);
PRINTF("\n");
}
return;
}
if(memcmp(&dag->dag_id, &dio->dag_id, sizeof(dag->dag_id))) {
PRINTF("RPL: Ignoring DIO for another DAG within our instance\n");
return;
}
if(dio->version > dag->version) {
if(dag->rank == ROOT_RANK(dag)) {
PRINTF("RPL: Root received inconsistent DIO version number\n");
dag->version = dio->version + 1;
rpl_reset_dio_timer(dag, 1);
} else {
global_repair(from, dag, dio);
}
return;
} else if(dio->version < dag->version) {
/* Inconsistency detected - someone is still on old version */
PRINTF("RPL: old version received => inconsistency detected\n");
rpl_reset_dio_timer(dag, 1);
return;
}
if(dio->rank == INFINITE_RANK) {
rpl_reset_dio_timer(dag, 1);
} else if(dio->rank < ROOT_RANK(dag)) {
PRINTF("RPL: Ignoring DIO with too low rank: %u\n",
(unsigned)dio->rank);
return;
}
if(dag->rank == ROOT_RANK(dag)) {
if(dio->rank != INFINITE_RANK) {
dag->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
if(RPL_PARENT_COUNT(dag) == RPL_MAX_PARENTS) {
/* Make room for a new parent. */
remove_worst_parent(dag, dio->rank);
}
/* Add the DIO sender as a candidate parent. */
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a new parent (");
PRINT6ADDR(from);
PRINTF(")\n");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else if(DAG_RANK(p->rank, dag) == DAG_RANK(dio->rank, dag)) {
PRINTF("RPL: Received consistent DIO\n");
dag->dio_counter++;
}
/* We have allocated a candidate parent; process the DIO further. */
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
p->rank = dio->rank;
if(rpl_process_parent_event(dag, p) == 0) {
/* The candidate parent no longer exists. */
return;
}
if(should_send_dao(dag, dio, p)) {
rpl_schedule_dao(dag);
}
p->dtsn = dio->dtsn;
}
示例7: join_dag
static void
join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
{
rpl_dag_t *dag;
rpl_parent_t *p;
rpl_of_t *of;
dag = rpl_alloc_dag(dio->instance_id);
if(dag == NULL) {
PRINTF("RPL: Failed to allocate a DAG object!\n");
return;
}
p = rpl_add_parent(dag, dio, from);
PRINTF("RPL: Adding ");
PRINT6ADDR(from);
PRINTF(" as a parent: ");
if(p == NULL) {
PRINTF("failed\n");
return;
}
PRINTF("succeeded\n");
/* Determine the objective function by using the
objective code point of the DIO. */
of = rpl_find_of(dio->ocp);
if(of == NULL) {
PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF\n",
dio->instance_id);
return;
}
/* Autoconfigure an address if this node does not already have an address
with this prefix. */
if((dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) {
uip_ipaddr_t ipaddr;
/* assume that the prefix ends with zeros! */
memcpy(&ipaddr, &dio->prefix_info.prefix, 16);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
if(uip_ds6_addr_lookup(&ipaddr) == NULL) {
PRINTF("RPL: adding global IP address ");
PRINT6ADDR(&ipaddr);
PRINTF("\n");
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
}
}
dag->joined = 1;
dag->used = 1;
dag->of = of;
dag->grounded = dio->grounded;
dag->mop = dio->mop;
dag->preference = dio->preference;
dag->instance_id = dio->instance_id;
dag->max_rankinc = dio->dag_max_rankinc;
dag->min_hoprankinc = dio->dag_min_hoprankinc;
dag->version = dio->version;
dag->preferred_parent = p;
dag->of->update_metric_container(dag);
dag->dio_intdoubl = dio->dag_intdoubl;
dag->dio_intmin = dio->dag_intmin;
dag->dio_redundancy = dio->dag_redund;
memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id));
/* copy prefix information into the dag */
memcpy(&dag->prefix_info, &dio->prefix_info, sizeof(rpl_prefix_t));
dag->rank = dag->of->calculate_rank(p, dio->rank);
dag->min_rank = dag->rank; /* So far this is the lowest rank we know of. */
PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ",
dio->instance_id, dag->rank);
PRINT6ADDR(&dag->dag_id);
PRINTF("\n");
ANNOTATE("#A join=%u\n",dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
dag->default_lifetime = dio->default_lifetime;
dag->lifetime_unit = dio->lifetime_unit;
rpl_reset_dio_timer(dag, 1);
rpl_set_default_route(dag, from);
if(should_send_dao(dag, dio, p)) {
rpl_schedule_dao(dag);
} else {
PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO\n");
}
}
示例8: rpl_join_instance
//.........这里部分代码省略.........
with this prefix. */
if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {
check_prefix(NULL, &dio->prefix_info);
}
//-----------------elnaz
tx =cc2420_get_txpower();
printf("Power=%d \n",tx);
switch(tx) {
case 3:
dag->Tx = 0.003;
break;
case 7:
dag->Tx = 0.03;
break;
case 11:
dag->Tx = 0.1;
break;
case 15:
dag->Tx = 0.2;
break;
case 19:
dag->Tx = 0.3;
break;
case 23:
dag->Tx = 0.5;
break;
case 27:
dag->Tx = 0.8;
break;
case 31:
dag->Tx = 1;
}
/*
float mv = (bateria * 2.500 * 2) / 4096;
printf("Battery: (%ld.%03d mV)\n", (long) mv, (unsigned) ((mv - floor(mv)) * 1000));
*/
//printf("Test tx=%ld ",(long) (dag->Tx*1000));
//----------------------elnaz
dag->joined = 1;
dag->preference = dio->preference;
dag->grounded = dio->grounded;
dag->version = dio->version;
instance->of = of;
instance->mop = dio->mop;
instance->current_dag = dag;
instance->dtsn_out = RPL_LOLLIPOP_INIT;
instance->max_rankinc = dio->dag_max_rankinc;
instance->min_hoprankinc = dio->dag_min_hoprankinc;
instance->dio_intdoubl = dio->dag_intdoubl;
instance->dio_intmin = dio->dag_intmin;
instance->dio_intcurrent = instance->dio_intmin + instance->dio_intdoubl;
instance->dio_redundancy = dio->dag_redund;
instance->default_lifetime = dio->default_lifetime;
instance->lifetime_unit = dio->lifetime_unit;
memcpy(&dag->dag_id, &dio->dag_id, sizeof(dio->dag_id));
/* Copy prefix information from the DIO into the DAG object. */
memcpy(&dag->prefix_info, &dio->prefix_info, sizeof(rpl_prefix_t));
rpl_set_preferred_parent(dag, p);
instance->of->update_metric_container(instance);
dag->rank = instance->of->calculate_rank(p, 0);
/* So far this is the lowest rank we are aware of. */
dag->min_rank = dag->rank;
if(default_instance == NULL) {
default_instance = instance;
}
// PRINTF("RPL: Joined DAG with instance ID %u, rank %hu, DAG ID ", dio->instance_id, dag->rank);
// PRINT6ADDR(&dag->dag_id);
// PRINTF("\n");
ANNOTATE("#A join=%u\n", dag->dag_id.u8[sizeof(dag->dag_id) - 1]);
rpl_reset_dio_timer(instance);
rpl_set_default_route(instance, from);
if(instance->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
rpl_schedule_dao(instance);
} else {
// PRINTF("RPL: The DIO does not meet the prerequisites for sending a DAO\n");
}
}
示例9: rpl_process_dio
//.........这里部分代码省略.........
rpl_set_prefix(dag, &dio->prefix_info.prefix, dio->prefix_info.length);
}
}
if(dag->rank == ROOT_RANK(instance)) {
if(dio->rank != INFINITE_RANK) {
instance->dio_counter++;
}
return;
}
/*
* At this point, we know that this DIO pertains to a DAG that
* we are already part of. We consider the sender of the DIO to be
* a candidate parent, and let rpl_process_parent_event decide
* whether to keep it in the set.
*/
p = rpl_find_parent(dag, from);
if(p == NULL) {
previous_dag = find_parent_dag(instance, from);
if(previous_dag == NULL) {
/* Add the DIO sender as a candidate parent. */
p = rpl_add_parent(dag, dio, from);
if(p == NULL) {
PRINTF("RPL: Failed to add a new parent (");
PRINT6ADDR(from);
PRINTF(")\n");
return;
}
PRINTF("RPL: New candidate parent with rank %u: ", (unsigned)p->rank);
PRINT6ADDR(from);
PRINTF("\n");
} else {
p = rpl_find_parent(previous_dag, from);
if(p != NULL) {
rpl_move_parent(previous_dag, dag, p);
}
}
} else {
if(p->rank == dio->rank) {
PRINTF("RPL: Received consistent DIO\n");
if(dag->joined) {
instance->dio_counter++;
}
} else {
p->rank = dio->rank;
}
}
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);
PRINTF("parent rank %u, parent etx %u, link metric %u, instance etx %u\n",
p->rank, -1 /*p->mc.obj.etx */, p->link_metric,
instance->mc.obj.etx);
/*
* If the DIO being processed came from smart-HOP decision, change default route,
* schedule DAO and finish the mobility process.
*/
if(mobility) {
rpl_remove_parent(previous_preferred);
rpl_set_preferred_parent(dag, p);
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
/*dao_output(p, 255);*/
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
PRINTF("adding default route\n");
current_t = clock_time() * 1000 / CLOCK_SECOND;
printf("End %u\n", current_t);
rpl_set_default_route(instance, from);
rpl_schedule_dao(instance);
/*check_dao_ack = 1;*/
process_post(&tcpip_process, RESET_MOBILITY_FLAG, NULL);
return;
}
if(mobility == 0) {
#if RPL_DAG_MC != RPL_DAG_MC_NONE
memcpy(&p->mc, &dio->mc, sizeof(p->mc));
#endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
if(rpl_process_parent_event(instance, p) == 0) {
PRINTF("RPL: The candidate parent is rejected\n");
return;
}
}
/* We don't use route control, so we can have only one official parent. */
if(dag->joined && p == dag->preferred_parent) {
if(should_send_dao(instance, dio, p)) {
RPL_LOLLIPOP_INCREMENT(instance->dtsn_out);
rpl_schedule_dao(instance);
}
/* We received a new DIO from our preferred parent.
* Call uip_ds6_defrt_add to set a fresh value for the lifetime counter */
uip_ds6_defrt_add(from,
RPL_LIFETIME(instance, instance->default_lifetime));
}
p->dtsn = dio->dtsn;
}