Contiki-NG
rpl-conf.h
Go to the documentation of this file.
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 /**
34  * \addtogroup rpl-lite
35  * @{
36  *
37  * \file
38  * Public configuration and API declarations for ContikiRPL.
39  * \author
40  * Joakim Eriksson <joakime@sics.se>, Nicolas Tsiftes <nvt@sics.se>,
41  * Simon DUquennoy <simon.duquennoy@inria.fr>
42  *
43  */
44 
45 #ifndef RPL_CONF_H
46 #define RPL_CONF_H
47 
48 #include "contiki.h"
49 
50 /******************************************************************************/
51 /*********************** Enabling/disabling features **************************/
52 /******************************************************************************/
53 
54 /* RPL Mode of operation */
55 #ifdef RPL_CONF_MOP
56 #define RPL_MOP_DEFAULT RPL_CONF_MOP
57 #else /* RPL_CONF_MOP */
58 #define RPL_MOP_DEFAULT RPL_MOP_NON_STORING
59 #endif /* RPL_CONF_MOP */
60 
61 /*
62  * We only support non-storing mode
63  */
64 #define RPL_WITH_STORING 0
65 
66 /*
67  * Embed support for non-storing mode
68  */
69 #ifdef RPL_CONF_WITH_NON_STORING
70 #define RPL_WITH_NON_STORING RPL_CONF_WITH_NON_STORING
71 #else /* RPL_CONF_WITH_NON_STORING */
72 /* By default: embed support for non-storing if and only if the configured MOP is non-storing */
73 #define RPL_WITH_NON_STORING (RPL_MOP_DEFAULT == RPL_MOP_NON_STORING)
74 #endif /* RPL_CONF_WITH_NON_STORING */
75 
76 /*
77  * The objective function (OF) used by a RPL root is configurable through
78  * the RPL_CONF_OF_OCP parameter. This is defined as the objective code
79  * point (OCP) of the OF, RPL_OCP_OF0 or RPL_OCP_MRHOF. This flag is of
80  * no relevance to non-root nodes, which run the OF advertised in the
81  * instance they join.
82  * Make sure the selected of is inRPL_SUPPORTED_OFS.
83  */
84 #ifdef RPL_CONF_OF_OCP
85 #define RPL_OF_OCP RPL_CONF_OF_OCP
86 #else /* RPL_CONF_OF_OCP */
87 #define RPL_OF_OCP RPL_OCP_MRHOF
88 #endif /* RPL_CONF_OF_OCP */
89 
90 /*
91  * The set of objective functions supported at runtime. Nodes are only
92  * able to join instances that advertise an OF in this set. To include
93  * both OF0 and MRHOF, use {&rpl_of0, &rpl_mrhof}.
94  */
95 #ifdef RPL_CONF_SUPPORTED_OFS
96 #define RPL_SUPPORTED_OFS RPL_CONF_SUPPORTED_OFS
97 #else /* RPL_CONF_SUPPORTED_OFS */
98 #define RPL_SUPPORTED_OFS {&rpl_mrhof}
99 #endif /* RPL_CONF_SUPPORTED_OFS */
100 
101 /*
102  * Enable/disable RPL Metric Containers (MC). The actual MC in use
103  * for a given DODAG is decided at runtime, when joining. Note that
104  * OF0 (RFC6552) operates without MC, and so does MRHOF (RFC6719) when
105  * used with ETX as a metric (the rank is the metric). We disable MC
106  * by default, but note it must be enabled to support joining a DODAG
107  * that requires MC (e.g., MRHOF with a metric other than ETX).
108  */
109 #ifdef RPL_CONF_WITH_MC
110 #define RPL_WITH_MC RPL_CONF_WITH_MC
111 #else /* RPL_CONF_WITH_MC */
112 #define RPL_WITH_MC 0
113 #endif /* RPL_CONF_WITH_MC */
114 
115 /* The MC advertised in DIOs and propagating from the root */
116 #ifdef RPL_CONF_DAG_MC
117 #define RPL_DAG_MC RPL_CONF_DAG_MC
118 #else
119 #define RPL_DAG_MC RPL_DAG_MC_NONE
120 #endif /* RPL_CONF_DAG_MC */
121 
122 /*
123  * RPL DAO-ACK support. When enabled, DAO-ACK will be sent and requested.
124  * This will also enable retransmission of DAO when no ack is received.
125  * */
126 #ifdef RPL_CONF_WITH_DAO_ACK
127 #define RPL_WITH_DAO_ACK RPL_CONF_WITH_DAO_ACK
128 #else
129 #define RPL_WITH_DAO_ACK 1
130 #endif /* RPL_CONF_WITH_DAO_ACK */
131 
132 /*
133  * Setting the RPL_TRICKLE_REFRESH_DAO_ROUTES will make the RPL root
134  * increase the DTSN (Destination Advertisement Trigger Sequence Number)
135  * from the DIO trickle timer. If set to 4, DTSN will be increased every 4th
136  * iteration. This is to get all children to re-register their DAO route.
137  * This is needed when DAO-ACK is not enabled to
138  * add reliability to route maintenance.
139  * */
140 #ifdef RPL_CONF_TRICKLE_REFRESH_DAO_ROUTES
141 #define RPL_TRICKLE_REFRESH_DAO_ROUTES RPL_CONF_TRICKLE_REFRESH_DAO_ROUTES
142 #else
143 #if RPL_WITH_DAO_ACK
144 #define RPL_TRICKLE_REFRESH_DAO_ROUTES 0
145 #else
146 #define RPL_TRICKLE_REFRESH_DAO_ROUTES 4
147 #endif
148 #endif /* RPL_CONF_TRICKLE_REFRESH_DAO_ROUTES */
149 
150 /*
151  * RPL probing. When enabled, probes will be sent periodically to keep
152  * neighbor link estimates up to date. Further configurable
153  * via RPL_CONF_PROBING_* flags
154  */
155 #ifdef RPL_CONF_WITH_PROBING
156 #define RPL_WITH_PROBING RPL_CONF_WITH_PROBING
157 #else
158 #define RPL_WITH_PROBING 1
159 #endif
160 
161 /*
162  * Function used to select the next neighbor to be probed.
163  */
164 #ifdef RPL_CONF_PROBING_SELECT_FUNC
165 #define RPL_PROBING_SELECT_FUNC RPL_CONF_PROBING_SELECT_FUNC
166 #else
167 #define RPL_PROBING_SELECT_FUNC get_probing_target
168 #endif
169 
170 /*
171  * Function used to send RPL probes.
172  * To probe with DIO, use:
173  * #define RPL_CONF_PROBING_SEND_FUNC(addr) rpl_icmp6_dio_output((addr))
174  * To probe with DIS, use:
175  * #define RPL_CONF_PROBING_SEND_FUNC(addr) rpl_icmp6_dis_output((addr))
176  * Any other custom probing function is also acceptable.
177  */
178 #ifdef RPL_CONF_PROBING_SEND_FUNC
179 #define RPL_PROBING_SEND_FUNC RPL_CONF_PROBING_SEND_FUNC
180 #else
181 #define RPL_PROBING_SEND_FUNC(addr) rpl_icmp6_dio_output((addr))
182 #endif
183 
184 /*
185  * This value decides if this node must stay as a leaf or not
186  * as allowed by draft-ietf-roll-rpl-19#section-8.5
187  */
188 #ifdef RPL_CONF_DEFAULT_LEAF_ONLY
189 #define RPL_DEFAULT_LEAF_ONLY RPL_CONF_DEFAULT_LEAF_ONLY
190 #else
191 #define RPL_DEFAULT_LEAF_ONLY 0
192 #endif
193 
194 /*
195  * Function used to validate dio before using it to init dag
196  */
197 #ifdef RPL_CONF_VALIDATE_DIO_FUNC
198 #define RPL_VALIDATE_DIO_FUNC RPL_CONF_VALIDATE_DIO_FUNC
199 #endif
200 
201 /******************************************************************************/
202 /********************************** Timing ************************************/
203 /******************************************************************************/
204 
205 /*
206  * The DIO interval (n) represents 2^n ms.
207  *
208  * According to the specification, the default value is 3 which
209  * means 8 milliseconds. That is far too low when using duty cycling
210  * with wake-up intervals that are typically hundreds of milliseconds.
211  * ContikiRPL thus sets the default to 2^12 ms = 4.096 s.
212  */
213 #ifdef RPL_CONF_DIO_INTERVAL_MIN
214 #define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
215 #else
216 #define RPL_DIO_INTERVAL_MIN 12
217 #endif
218 
219 /*
220  * Maximum amount of timer doublings.
221  *
222  * The maximum interval will by default be 2^(12+8) ms = 1048.576 s.
223  * RFC 6550 suggests a default value of 20, which of course would be
224  * unsuitable when we start with a minimum interval of 2^12.
225  */
226 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
227 #define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
228 #else
229 #define RPL_DIO_INTERVAL_DOUBLINGS 8
230 #endif
231 
232 /*
233  * DIO redundancy. To learn more about this, see RFC 6206.
234  *
235  * RFC 6550 suggests a default value of 10. We disable this mechanism by
236  * default, using a value of 0. This is to enable reliable DTSN increment
237  * propagation, and periodic rank dissemination without the need to increment
238  * version. Note that Trickle was originally designed for CTP, aiming to
239  * reduce broadcast traffic, which was particularly expensive done over an
240  * LPL MAC. In MAC layers such as non-beacon enabled or TSCH, broadcast is no
241  * more costly than unicast. Further, in this RPL implementation, DIOs are
242  * responsible for only a portion of the control traffic, compared to Link
243  * probing which is done at a period of minutes (RPL_PROBING_INTERVAL)
244  * for reliable parent selection.
245  */
246 #ifdef RPL_CONF_DIO_REDUNDANCY
247 #define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
248 #else
249 #define RPL_DIO_REDUNDANCY 0
250 #endif
251 
252 /*
253  * Default route lifetime unit. This is the granularity of time
254  * used in RPL lifetime values, in seconds.
255  */
256 #ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
257 #define RPL_DEFAULT_LIFETIME_UNIT 60
258 #else
259 #define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
260 #endif
261 
262 /*
263  * Default route lifetime as a multiple of the lifetime unit.
264  */
265 #ifndef RPL_CONF_DEFAULT_LIFETIME
266 #define RPL_DEFAULT_LIFETIME 30
267 #else
268 #define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
269 #endif
270 
271 /* Maximum lifetime of a DAG as a multiple of the lifetime unit. */
272 #ifdef RPL_CONF_DAG_LIFETIME
273 #define RPL_DAG_LIFETIME RPL_CONF_DAG_LIFETIME
274 #else
275 #define RPL_DAG_LIFETIME (8 * 60) /* 8 hours */
276 #endif /* RPL_CONF_DAG_LIFETIME */
277 
278 /*
279  * RPL probing interval.
280  */
281 #ifdef RPL_CONF_PROBING_INTERVAL
282 #define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL
283 #else
284 #define RPL_PROBING_INTERVAL (90 * CLOCK_SECOND)
285 #endif
286 
287 /*
288  * Function used to calculate next RPL probing interval
289  */
290 #ifdef RPL_CONF_PROBING_DELAY_FUNC
291 #define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC
292 #else
293 #define RPL_PROBING_DELAY_FUNC get_probing_delay
294 #endif
295 
296 /* Poisoining duration, before leaving the DAG */
297 #ifdef RPL_CONF_DELAY_BEFORE_LEAVING
298 #define RPL_DELAY_BEFORE_LEAVING RPL_CONF_DELAY_BEFORE_LEAVING
299 #else
300 #define RPL_DELAY_BEFORE_LEAVING (5 * 60 * CLOCK_SECOND)
301 #endif
302 
303 /* Interval of DIS transmission */
304 #ifdef RPL_CONF_DIS_INTERVAL
305 #define RPL_DIS_INTERVAL RPL_CONF_DIS_INTERVAL
306 #else
307 #define RPL_DIS_INTERVAL (30 * CLOCK_SECOND)
308 #endif
309 
310 /* DAO transmissions are always delayed by RPL_DAO_DELAY +/- RPL_DAO_DELAY/2 */
311 #ifdef RPL_CONF_DAO_DELAY
312 #define RPL_DAO_DELAY RPL_CONF_DAO_DELAY
313 #else /* RPL_CONF_DAO_DELAY */
314 #define RPL_DAO_DELAY (CLOCK_SECOND * 4)
315 #endif /* RPL_CONF_DAO_DELAY */
316 
317 #ifdef RPL_CONF_DAO_MAX_RETRANSMISSIONS
318 #define RPL_DAO_MAX_RETRANSMISSIONS RPL_CONF_DAO_MAX_RETRANSMISSIONS
319 #else
320 #define RPL_DAO_MAX_RETRANSMISSIONS 5
321 #endif /* RPL_CONF_DAO_MAX_RETRANSMISSIONS */
322 
323 #ifdef RPL_CONF_DAO_RETRANSMISSION_TIMEOUT
324 #define RPL_DAO_RETRANSMISSION_TIMEOUT RPL_CONF_DAO_RETRANSMISSION_TIMEOUT
325 #else
326 #define RPL_DAO_RETRANSMISSION_TIMEOUT (5 * CLOCK_SECOND)
327 #endif /* RPL_CONF_DAO_RETRANSMISSION_TIMEOUT */
328 
329 /******************************************************************************/
330 /************************** More parameterization *****************************/
331 /******************************************************************************/
332 
333 #ifndef RPL_CONF_MIN_HOPRANKINC
334 /* RFC6550 defines the default MIN_HOPRANKINC as 256.
335  * However, we use MRHOF as a default Objective Function (RFC6719),
336  * which recommends setting MIN_HOPRANKINC with care, in particular
337  * when used with ETX as a metric. ETX is computed as a fixed point
338  * real with a divisor of 128 (RFC6719, RFC6551). We choose to also
339  * use 128 for RPL_MIN_HOPRANKINC, resulting in a rank equal to the
340  * ETX path cost. Larger values may also be desirable, as discussed
341  * in section 6.1 of RFC6719. */
342 #if RPL_OF_OCP == RPL_OCP_MRHOF
343 #define RPL_MIN_HOPRANKINC 128
344 #else /* RPL_OF_OCP == RPL_OCP_MRHOF */
345 #define RPL_MIN_HOPRANKINC 256
346 #endif /* RPL_OF_OCP == RPL_OCP_MRHOF */
347 #else /* RPL_CONF_MIN_HOPRANKINC */
348 #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
349 #endif /* RPL_CONF_MIN_HOPRANKINC */
350 
351 #ifndef RPL_CONF_MAX_RANKINC
352 #define RPL_MAX_RANKINC (8 * RPL_MIN_HOPRANKINC)
353 #else /* RPL_CONF_MAX_RANKINC */
354 #define RPL_MAX_RANKINC RPL_CONF_MAX_RANKINC
355 #endif /* RPL_CONF_MAX_RANKINC */
356 
357 #ifndef RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD
358 #define RPL_SIGNIFICANT_CHANGE_THRESHOLD (4 * RPL_MIN_HOPRANKINC)
359 #else /* RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD */
360 #define RPL_SIGNIFICANT_CHANGE_THRESHOLD RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD
361 #endif /* RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD */
362 
363 /* This value decides which DAG instance we should participate in by default. */
364 #ifdef RPL_CONF_DEFAULT_INSTANCE
365 #define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
366 #else
367 #define RPL_DEFAULT_INSTANCE 0 /* Default of 0 for compression */
368 #endif /* RPL_CONF_DEFAULT_INSTANCE */
369 
370 /* Set to have the root advertise a grounded DAG */
371 #ifndef RPL_CONF_GROUNDED
372 #define RPL_GROUNDED 0
373 #else
374 #define RPL_GROUNDED RPL_CONF_GROUNDED
375 #endif /* !RPL_CONF_GROUNDED */
376 
377 /*
378  * DAG preference field
379  */
380 #ifdef RPL_CONF_PREFERENCE
381 #define RPL_PREFERENCE RPL_CONF_PREFERENCE
382 #else
383 #define RPL_PREFERENCE 0
384 #endif
385 
386 /* RPL callbacks when TSCH is enabled */
387 #if MAC_CONF_WITH_TSCH
388 
389 #ifndef RPL_CALLBACK_PARENT_SWITCH
390 #define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch
391 #endif /* RPL_CALLBACK_PARENT_SWITCH */
392 
393 #ifndef RPL_CALLBACK_NEW_DIO_INTERVAL
394 #define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval
395 #endif /* RPL_CALLBACK_NEW_DIO_INTERVAL */
396 
397 #endif /* MAC_CONF_WITH_TSCH */
398 
399 /* Set to 1 to drop packets when a forwarding loop is detected
400  * on a packet that already had an error signaled, as per RFC6550 - 11.2.2.2.
401  * Disabled by default for more reliability: even in the event of a loop,
402  * packets get a chance to eventually find their way to the destination. */
403 #ifdef RPL_CONF_LOOP_ERROR_DROP
404 #define RPL_LOOP_ERROR_DROP RPL_CONF_LOOP_ERROR_DROP
405 #else /* RPL_CONF_LOOP_ERROR_DROP */
406 #define RPL_LOOP_ERROR_DROP 0
407 #endif /* RPL_CONF_LOOP_ERROR_DROP */
408 
409 /** @} */
410 
411 #endif /* RPL_CONF_H */