Contiki-Inga 3.x
rpl-conf.h
1 /*
2  * Copyright (c) 2010, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  */
31 
32 /**
33  * \file Public configuration and API declarations for ContikiRPL.
34  *
35  * \author Joakim Eriksson <joakime@sics.se>
36  * \author Nicolas Tsiftes <nvt@sics.se>
37  */
38 
39 #ifndef RPL_CONF_H
40 #define RPL_CONF_H
41 
42 #include "contiki-conf.h"
43 
44 /* Set to 1 to enable RPL statistics */
45 #ifndef RPL_CONF_STATS
46 #define RPL_CONF_STATS 0
47 #endif /* RPL_CONF_STATS */
48 
49 /*
50  * Select routing metric supported at runtime. This must be a valid
51  * DAG Metric Container Object Type (see below). Currently, we only
52  * support RPL_DAG_MC_ETX and RPL_DAG_MC_ENERGY.
53  * When MRHOF (RFC6719) is used with ETX, no metric container must
54  * be used; instead the rank carries ETX directly.
55  */
56 #ifdef RPL_CONF_DAG_MC
57 #define RPL_DAG_MC RPL_CONF_DAG_MC
58 #else
59 #define RPL_DAG_MC RPL_DAG_MC_NONE
60 #endif /* RPL_CONF_DAG_MC */
61 
62 /*
63  * The objective function used by RPL is configurable through the
64  * RPL_CONF_OF parameter. This should be defined to be the name of an
65  * rpl_of object linked into the system image, e.g., rpl_of0.
66  */
67 #ifdef RPL_CONF_OF
68 #define RPL_OF RPL_CONF_OF
69 #else
70 /* ETX is the default objective function. */
71 #define RPL_OF rpl_mrhof
72 #endif /* RPL_CONF_OF */
73 
74 /* This value decides which DAG instance we should participate in by default. */
75 #ifdef RPL_CONF_DEFAULT_INSTANCE
76 #define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
77 #else
78 #define RPL_DEFAULT_INSTANCE 0x1e
79 #endif /* RPL_CONF_DEFAULT_INSTANCE */
80 
81 /*
82  * This value decides if this node must stay as a leaf or not
83  * as allowed by draft-ietf-roll-rpl-19#section-8.5
84  */
85 #ifdef RPL_CONF_LEAF_ONLY
86 #define RPL_LEAF_ONLY RPL_CONF_LEAF_ONLY
87 #else
88 #define RPL_LEAF_ONLY 0
89 #endif
90 
91 /*
92  * Maximum of concurent RPL instances.
93  */
94 #ifdef RPL_CONF_MAX_INSTANCES
95 #define RPL_MAX_INSTANCES RPL_CONF_MAX_INSTANCES
96 #else
97 #define RPL_MAX_INSTANCES 1
98 #endif /* RPL_CONF_MAX_INSTANCES */
99 
100 /*
101  * Maximum number of DAGs within an instance.
102  */
103 #ifdef RPL_CONF_MAX_DAG_PER_INSTANCE
104 #define RPL_MAX_DAG_PER_INSTANCE RPL_CONF_MAX_DAG_PER_INSTANCE
105 #else
106 #define RPL_MAX_DAG_PER_INSTANCE 2
107 #endif /* RPL_CONF_MAX_DAG_PER_INSTANCE */
108 
109 /*
110  *
111  */
112 #ifndef RPL_CONF_DAO_SPECIFY_DAG
113  #if RPL_MAX_DAG_PER_INSTANCE > 1
114  #define RPL_DAO_SPECIFY_DAG 1
115  #else
116  #define RPL_DAO_SPECIFY_DAG 0
117  #endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */
118 #else
119  #define RPL_DAO_SPECIFY_DAG RPL_CONF_DAO_SPECIFY_DAG
120 #endif /* RPL_CONF_DAO_SPECIFY_DAG */
121 
122 /*
123  * The DIO interval (n) represents 2^n ms.
124  *
125  * According to the specification, the default value is 3 which
126  * means 8 milliseconds. That is far too low when using duty cycling
127  * with wake-up intervals that are typically hundreds of milliseconds.
128  * ContikiRPL thus sets the default to 2^12 ms = 4.096 s.
129  */
130 #ifdef RPL_CONF_DIO_INTERVAL_MIN
131 #define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
132 #else
133 #define RPL_DIO_INTERVAL_MIN 12
134 #endif
135 
136 /*
137  * Maximum amount of timer doublings.
138  *
139  * The maximum interval will by default be 2^(12+8) ms = 1048.576 s.
140  * RFC 6550 suggests a default value of 20, which of course would be
141  * unsuitable when we start with a minimum interval of 2^12.
142  */
143 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
144 #define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
145 #else
146 #define RPL_DIO_INTERVAL_DOUBLINGS 8
147 #endif
148 
149 /*
150  * DIO redundancy. To learn more about this, see RFC 6206.
151  *
152  * RFC 6550 suggests a default value of 10. It is unclear what the basis
153  * of this suggestion is. Network operators might attain more efficient
154  * operation by tuning this parameter for specific deployments.
155  */
156 #ifdef RPL_CONF_DIO_REDUNDANCY
157 #define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
158 #else
159 #define RPL_DIO_REDUNDANCY 10
160 #endif
161 
162 /*
163  * Initial metric attributed to a link when the ETX is unknown
164  */
165 #ifndef RPL_CONF_INIT_LINK_METRIC
166 #define RPL_INIT_LINK_METRIC 5
167 #else
168 #define RPL_INIT_LINK_METRIC RPL_CONF_INIT_LINK_METRIC
169 #endif
170 
171 /*
172  * Default route lifetime unit. This is the granularity of time
173  * used in RPL lifetime values, in seconds.
174  */
175 #ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
176 #define RPL_DEFAULT_LIFETIME_UNIT 0xffff
177 #else
178 #define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
179 #endif
180 
181 /*
182  * Default route lifetime as a multiple of the lifetime unit.
183  */
184 #ifndef RPL_CONF_DEFAULT_LIFETIME
185 #define RPL_DEFAULT_LIFETIME 0xff
186 #else
187 #define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
188 #endif
189 
190 #endif /* RPL_CONF_H */