Contiki 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  * \file
32  * Public configuration and API declarations for ContikiRPL.
33  * \author
34  * Joakim Eriksson <joakime@sics.se> & Nicolas Tsiftes <nvt@sics.se>
35  *
36  */
37 
38 #ifndef RPL_CONF_H
39 #define RPL_CONF_H
40 
41 #include "contiki-conf.h"
42 
43 /* Set to 1 to enable RPL statistics */
44 #ifndef RPL_CONF_STATS
45 #define RPL_CONF_STATS 0
46 #endif /* RPL_CONF_STATS */
47 
48 /*
49  * The objective function (OF) used by a RPL root is configurable through
50  * the RPL_CONF_OF_OCP parameter. This is defined as the objective code
51  * point (OCP) of the OF, RPL_OCP_OF0 or RPL_OCP_MRHOF. This flag is of
52  * no relevance to non-root nodes, which run the OF advertised in the
53  * instance they join.
54  * Make sure the selected of is inRPL_SUPPORTED_OFS.
55  */
56 #ifdef RPL_CONF_OF_OCP
57 #define RPL_OF_OCP RPL_CONF_OF_OCP
58 #else /* RPL_CONF_OF_OCP */
59 #define RPL_OF_OCP RPL_OCP_MRHOF
60 #endif /* RPL_CONF_OF_OCP */
61 
62 /*
63  * The set of objective functions supported at runtime. Nodes are only
64  * able to join instances that advertise an OF in this set. To include
65  * both OF0 and MRHOF, use {&rpl_of0, &rpl_mrhof}.
66  */
67 #ifdef RPL_CONF_SUPPORTED_OFS
68 #define RPL_SUPPORTED_OFS RPL_CONF_SUPPORTED_OFS
69 #else /* RPL_CONF_SUPPORTED_OFS */
70 #define RPL_SUPPORTED_OFS {&rpl_mrhof}
71 #endif /* RPL_CONF_SUPPORTED_OFS */
72 
73 /*
74  * Enable/disable RPL Metric Containers (MC). The actual MC in use
75  * for a given DODAG is decided at runtime, when joining. Note that
76  * OF0 (RFC6552) operates without MC, and so does MRHOF (RFC6719) when
77  * used with ETX as a metric (the rank is the metric). We disable MC
78  * by default, but note it must be enabled to support joining a DODAG
79  * that requires MC (e.g., MRHOF with a metric other than ETX).
80  */
81 #ifdef RPL_CONF_WITH_MC
82 #define RPL_WITH_MC RPL_CONF_WITH_MC
83 #else /* RPL_CONF_WITH_MC */
84 #define RPL_WITH_MC 0
85 #endif /* RPL_CONF_WITH_MC */
86 
87 /* The MC advertised in DIOs and propagating from the root */
88 #ifdef RPL_CONF_DAG_MC
89 #define RPL_DAG_MC RPL_CONF_DAG_MC
90 #else
91 #define RPL_DAG_MC RPL_DAG_MC_NONE
92 #endif /* RPL_CONF_DAG_MC */
93 
94 /* This value decides which DAG instance we should participate in by default. */
95 #ifdef RPL_CONF_DEFAULT_INSTANCE
96 #define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
97 #else
98 #define RPL_DEFAULT_INSTANCE 0x1e
99 #endif /* RPL_CONF_DEFAULT_INSTANCE */
100 
101 /*
102  * This value decides if this node must stay as a leaf or not
103  * as allowed by draft-ietf-roll-rpl-19#section-8.5
104  */
105 #ifdef RPL_CONF_LEAF_ONLY
106 #define RPL_LEAF_ONLY RPL_CONF_LEAF_ONLY
107 #else
108 #define RPL_LEAF_ONLY 0
109 #endif
110 
111 /*
112  * Maximum of concurent RPL instances.
113  */
114 #ifdef RPL_CONF_MAX_INSTANCES
115 #define RPL_MAX_INSTANCES RPL_CONF_MAX_INSTANCES
116 #else
117 #define RPL_MAX_INSTANCES 1
118 #endif /* RPL_CONF_MAX_INSTANCES */
119 
120 /*
121  * Maximum number of DAGs within an instance.
122  */
123 #ifdef RPL_CONF_MAX_DAG_PER_INSTANCE
124 #define RPL_MAX_DAG_PER_INSTANCE RPL_CONF_MAX_DAG_PER_INSTANCE
125 #else
126 #define RPL_MAX_DAG_PER_INSTANCE 2
127 #endif /* RPL_CONF_MAX_DAG_PER_INSTANCE */
128 
129 /*
130  * RPL Default route lifetime
131  * The RPL route lifetime is used for the downward routes and for the default
132  * route. In a high density network with DIO suppression activated it may happen
133  * that a node will never send a DIO once the DIO interval becomes high as it
134  * has heard DIO from many neighbors already. As the default route to the
135  * preferred parent has a lifetime reset by receiving DIO from the parent, it
136  * means that the default route can be destroyed after a while. Setting the
137  * default route with infinite lifetime secures the upstream route.
138  */
139 #ifdef RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME
140 #define RPL_DEFAULT_ROUTE_INFINITE_LIFETIME RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME
141 #else
142 #define RPL_DEFAULT_ROUTE_INFINITE_LIFETIME 1
143 #endif /* RPL_CONF_DEFAULT_ROUTE_INFINITE_LIFETIME */
144 
145 /*
146  * Maximum lifetime of a DAG
147  * When a DODAG is not updated since RPL_CONF_DAG_LIFETIME times the DODAG
148  * maximum DIO interval the DODAG is removed from the list of DODAGS of the
149  * related instance, except if it is the currently joined DODAG.
150  */
151 #ifdef RPL_CONF_DAG_LIFETIME
152 #define RPL_DAG_LIFETIME RPL_CONF_DAG_LIFETIME
153 #else
154 #define RPL_DAG_LIFETIME 3
155 #endif /* RPL_CONF_DAG_LIFETIME */
156 
157 /*
158  *
159  */
160 #ifndef RPL_CONF_DAO_SPECIFY_DAG
161  #if RPL_MAX_DAG_PER_INSTANCE > 1
162  #define RPL_DAO_SPECIFY_DAG 1
163  #else
164  #define RPL_DAO_SPECIFY_DAG 0
165  #endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */
166 #else
167  #define RPL_DAO_SPECIFY_DAG RPL_CONF_DAO_SPECIFY_DAG
168 #endif /* RPL_CONF_DAO_SPECIFY_DAG */
169 
170 /*
171  * The DIO interval (n) represents 2^n ms.
172  *
173  * According to the specification, the default value is 3 which
174  * means 8 milliseconds. That is far too low when using duty cycling
175  * with wake-up intervals that are typically hundreds of milliseconds.
176  * ContikiRPL thus sets the default to 2^12 ms = 4.096 s.
177  */
178 #ifdef RPL_CONF_DIO_INTERVAL_MIN
179 #define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
180 #else
181 #define RPL_DIO_INTERVAL_MIN 12
182 #endif
183 
184 /*
185  * Maximum amount of timer doublings.
186  *
187  * The maximum interval will by default be 2^(12+8) ms = 1048.576 s.
188  * RFC 6550 suggests a default value of 20, which of course would be
189  * unsuitable when we start with a minimum interval of 2^12.
190  */
191 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
192 #define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
193 #else
194 #define RPL_DIO_INTERVAL_DOUBLINGS 8
195 #endif
196 
197 /*
198  * DIO redundancy. To learn more about this, see RFC 6206.
199  *
200  * RFC 6550 suggests a default value of 10. It is unclear what the basis
201  * of this suggestion is. Network operators might attain more efficient
202  * operation by tuning this parameter for specific deployments.
203  */
204 #ifdef RPL_CONF_DIO_REDUNDANCY
205 #define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
206 #else
207 #define RPL_DIO_REDUNDANCY 10
208 #endif
209 
210 /*
211  * Default route lifetime unit. This is the granularity of time
212  * used in RPL lifetime values, in seconds.
213  */
214 #ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
215 #define RPL_DEFAULT_LIFETIME_UNIT 60
216 #else
217 #define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
218 #endif
219 
220 /*
221  * Default route lifetime as a multiple of the lifetime unit.
222  */
223 #ifndef RPL_CONF_DEFAULT_LIFETIME
224 #define RPL_DEFAULT_LIFETIME 30
225 #else
226 #define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
227 #endif
228 
229 /*
230  * DAG preference field
231  */
232 #ifdef RPL_CONF_PREFERENCE
233 #define RPL_PREFERENCE RPL_CONF_PREFERENCE
234 #else
235 #define RPL_PREFERENCE 0
236 #endif
237 
238 /*
239  * RPL DAO ACK support. When enabled, DAO ACK will be sent and requested.
240  * This will also enable retransmission of DAO when no ack is received.
241  * */
242 #ifdef RPL_CONF_WITH_DAO_ACK
243 #define RPL_WITH_DAO_ACK RPL_CONF_WITH_DAO_ACK
244 #else
245 #define RPL_WITH_DAO_ACK 0
246 #endif /* RPL_CONF_WITH_DAO_ACK */
247 
248 /*
249  * RPL REPAIR ON DAO NACK. When enabled, DAO NACK will trigger a local
250  * repair in order to quickly find a new parent to send DAO's to.
251  * NOTE: this is too agressive in some cases so use with care.
252  * */
253 #ifdef RPL_CONF_RPL_REPAIR_ON_DAO_NACK
254 #define RPL_REPAIR_ON_DAO_NACK RPL_CONF_RPL_REPAIR_ON_DAO_NACK
255 #else
256 #define RPL_REPAIR_ON_DAO_NACK 0
257 #endif /* RPL_CONF_RPL_REPAIR_ON_DAO_NACK */
258 
259 /*
260  * Setting the DIO_REFRESH_DAO_ROUTES will make the RPL root always
261  * increase the DTSN (Destination Advertisement Trigger Sequence Number)
262  * when sending multicast DIO. This is to get all children to re-register
263  * their DAO route. This is needed when DAO-ACK is not enabled to add
264  * reliability to route maintenance.
265  * */
266 #ifdef RPL_CONF_DIO_REFRESH_DAO_ROUTES
267 #define RPL_DIO_REFRESH_DAO_ROUTES RPL_CONF_DIO_REFRESH_DAO_ROUTES
268 #else
269 #define RPL_DIO_REFRESH_DAO_ROUTES 1
270 #endif /* RPL_CONF_DIO_REFRESH_DAO_ROUTES */
271 
272 /*
273  * RPL probing. When enabled, probes will be sent periodically to keep
274  * parent link estimates up to date.
275  */
276 #ifdef RPL_CONF_WITH_PROBING
277 #define RPL_WITH_PROBING RPL_CONF_WITH_PROBING
278 #else
279 #define RPL_WITH_PROBING 1
280 #endif
281 
282 /*
283  * RPL probing interval.
284  */
285 #ifdef RPL_CONF_PROBING_INTERVAL
286 #define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL
287 #else
288 #define RPL_PROBING_INTERVAL (120 * CLOCK_SECOND)
289 #endif
290 
291 /*
292  * Function used to select the next parent to be probed.
293  */
294 #ifdef RPL_CONF_PROBING_SELECT_FUNC
295 #define RPL_PROBING_SELECT_FUNC RPL_CONF_PROBING_SELECT_FUNC
296 #else
297 #define RPL_PROBING_SELECT_FUNC get_probing_target
298 #endif
299 
300 /*
301  * Function used to send RPL probes.
302  * To probe with DIO, use:
303  * #define RPL_CONF_PROBING_SEND_FUNC(instance, addr) dio_output((instance), (addr))
304  * To probe with DIS, use:
305  * #define RPL_CONF_PROBING_SEND_FUNC(instance, addr) dis_output((addr))
306  * Any other custom probing function is also acceptable.
307  */
308 #ifdef RPL_CONF_PROBING_SEND_FUNC
309 #define RPL_PROBING_SEND_FUNC RPL_CONF_PROBING_SEND_FUNC
310 #else
311 #define RPL_PROBING_SEND_FUNC(instance, addr) dio_output((instance), (addr))
312 #endif
313 
314 /*
315  * Function used to calculate next RPL probing interval
316  */
317 #ifdef RPL_CONF_PROBING_DELAY_FUNC
318 #define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC
319 #else
320 #define RPL_PROBING_DELAY_FUNC get_probing_delay
321 #endif
322 
323 /*
324  * Interval of DIS transmission
325  */
326 #ifdef RPL_CONF_DIS_INTERVAL
327 #define RPL_DIS_INTERVAL RPL_CONF_DIS_INTERVAL
328 #else
329 #define RPL_DIS_INTERVAL 60
330 #endif
331 
332 /*
333  * Added delay of first DIS transmission after boot
334  */
335 #ifdef RPL_CONF_DIS_START_DELAY
336 #define RPL_DIS_START_DELAY RPL_CONF_DIS_START_DELAY
337 #else
338 #define RPL_DIS_START_DELAY 5
339 #endif
340 
341 #endif /* RPL_CONF_H */