mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
Configuration of the objective function made easier. Updated OF0 to the new rank calculation.
This commit is contained in:
parent
b2296e462b
commit
7a43b7d832
@ -1 +1,2 @@
|
||||
CONTIKI_SOURCEFILES += rpl.c rpl-dag.c rpl-icmp6.c rpl-timers.c rpl-of-etx.c
|
||||
CONTIKI_SOURCEFILES += rpl.c rpl-dag.c rpl-icmp6.c rpl-timers.c \
|
||||
rpl-of-etx.c
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-dag.c,v 1.42 2010/12/17 15:24:25 nvt-se Exp $
|
||||
* $Id: rpl-dag.c,v 1.43 2011/01/04 20:43:28 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -43,6 +43,7 @@
|
||||
|
||||
#include "net/rpl/rpl.h"
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/uip.h"
|
||||
#include "net/uip-nd6.h"
|
||||
#include "lib/list.h"
|
||||
@ -56,8 +57,8 @@
|
||||
#include "net/uip-debug.h"
|
||||
|
||||
/************************************************************************/
|
||||
extern rpl_of_t rpl_of_etx;
|
||||
static rpl_of_t *objective_functions[] = {&rpl_of_etx, NULL};
|
||||
extern rpl_of_t RPL_OF;
|
||||
static rpl_of_t * const objective_functions[] = {&RPL_OF};
|
||||
/************************************************************************/
|
||||
|
||||
#ifndef RPL_CONF_MAX_DAG_ENTRIES
|
||||
@ -153,7 +154,7 @@ rpl_set_root(uip_ipaddr_t *dag_id)
|
||||
dag->grounded = RPL_GROUNDED;
|
||||
dag->mop = RPL_MOP_DEFAULT;
|
||||
dag->rank = ROOT_RANK;
|
||||
dag->of = rpl_find_of(RPL_DEFAULT_OCP);
|
||||
dag->of = &RPL_OF;
|
||||
dag->preferred_parent = NULL;
|
||||
dag->dtsn_out = 1; /* Trigger DAOs from the beginning. */
|
||||
|
||||
@ -376,7 +377,7 @@ rpl_get_dag(int instance_id)
|
||||
|
||||
for(i = 0; i < RPL_MAX_DAG_ENTRIES; i++) {
|
||||
if(dag_table[i].joined && (instance_id == RPL_ANY_INSTANCE ||
|
||||
dag_table[i].instance_id == instance_id)) {
|
||||
dag_table[i].instance_id == instance_id)) {
|
||||
return &dag_table[i];
|
||||
}
|
||||
}
|
||||
@ -386,11 +387,13 @@ rpl_get_dag(int instance_id)
|
||||
rpl_of_t *
|
||||
rpl_find_of(rpl_ocp_t ocp)
|
||||
{
|
||||
rpl_of_t *of;
|
||||
int i;
|
||||
|
||||
for(of = objective_functions[0]; of != NULL; of++) {
|
||||
if(of->ocp == ocp) {
|
||||
return of;
|
||||
for(i = 0;
|
||||
i < sizeof(objective_functions) / sizeof(objective_functions[0]);
|
||||
i++) {
|
||||
if(objective_functions[i]->ocp == ocp) {
|
||||
return objective_functions[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,7 +478,7 @@ join_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
|
||||
PRINTF("\n");
|
||||
|
||||
dag->rank = dag->of->calculate_rank(NULL, dio->rank);
|
||||
dag->min_rank = dag->rank; /* So far this is the lowest rank we know */
|
||||
dag->min_rank = dag->rank; /* So far this is the lowest rank we know of. */
|
||||
|
||||
dag->default_lifetime = dio->default_lifetime;
|
||||
dag->lifetime_unit = dio->lifetime_unit;
|
||||
|
@ -32,7 +32,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: rpl-of0.c,v 1.5 2010/06/14 12:44:37 nvt-se Exp $
|
||||
* $Id: rpl-of0.c,v 1.6 2011/01/04 20:43:28 nvt-se Exp $
|
||||
*/
|
||||
/**
|
||||
* \file
|
||||
@ -58,10 +58,7 @@ rpl_of_t rpl_of0 = {
|
||||
0
|
||||
};
|
||||
|
||||
#define DEFAULT_RANK_INCREMENT 4
|
||||
#define MINIMUM_RANK_INCREMENT 1
|
||||
#define MAXIMUM_RANK_INCREMENT 16
|
||||
#define MAXIMUM_RANK_STRETCH 4
|
||||
#define DEFAULT_RANK_INCREMENT DEFAULT_MIN_HOPRANKINC
|
||||
|
||||
static void
|
||||
reset(void *dag)
|
||||
|
@ -30,7 +30,7 @@
|
||||
*
|
||||
* Author: Joakim Eriksson, Nicolas Tsiftes
|
||||
*
|
||||
* $Id: rpl.h,v 1.28 2010/12/17 15:24:25 nvt-se Exp $
|
||||
* $Id: rpl.h,v 1.29 2011/01/04 20:43:28 nvt-se Exp $
|
||||
*/
|
||||
|
||||
#ifndef RPL_H
|
||||
@ -57,6 +57,18 @@
|
||||
#define RPL_CONF_STATS 0
|
||||
#endif /* RPL_CONF_STATS */
|
||||
|
||||
/*
|
||||
* The objective function used by RPL is configurable through the
|
||||
* RPL_CONF_OF parameter. This should be defined to be the name of an
|
||||
* rpl_of_t object linked into the system image, e.g., rpl_of0.
|
||||
*/
|
||||
#ifdef RPL_CONF_OF
|
||||
#define RPL_OF RPL_CONF_OF
|
||||
#else
|
||||
/* ETX is the default objective function. */
|
||||
#define RPL_OF rpl_of_etx
|
||||
#endif /* RPL_CONF_OF */
|
||||
|
||||
/* The RPL Codes for the message types */
|
||||
#define RPL_CODE_DIS 0 /* DIS message */
|
||||
#define RPL_CODE_DIO 1 /* DIO message */
|
||||
@ -116,8 +128,6 @@
|
||||
#define RPL_DEFAULT_INSTANCE 0
|
||||
#define RPL_ANY_INSTANCE -1
|
||||
|
||||
#define RPL_DEFAULT_OCP 1
|
||||
|
||||
/* Represents 2^n ms. */
|
||||
/* Default alue according to the specification is 3 which
|
||||
means 8 milliseconds - this is not a reasonable value if
|
||||
|
Loading…
Reference in New Issue
Block a user