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 /********************************** Timing ************************************/
196 /******************************************************************************/
197 
198 /*
199  * The DIO interval (n) represents 2^n ms.
200  *
201  * According to the specification, the default value is 3 which
202  * means 8 milliseconds. That is far too low when using duty cycling
203  * with wake-up intervals that are typically hundreds of milliseconds.
204  * ContikiRPL thus sets the default to 2^12 ms = 4.096 s.
205  */
206 #ifdef RPL_CONF_DIO_INTERVAL_MIN
207 #define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
208 #else
209 #define RPL_DIO_INTERVAL_MIN 12
210 #endif
211 
212 /*
213  * Maximum amount of timer doublings.
214  *
215  * The maximum interval will by default be 2^(12+8) ms = 1048.576 s.
216  * RFC 6550 suggests a default value of 20, which of course would be
217  * unsuitable when we start with a minimum interval of 2^12.
218  */
219 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
220 #define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
221 #else
222 #define RPL_DIO_INTERVAL_DOUBLINGS 8
223 #endif
224 
225 /*
226  * DIO redundancy. To learn more about this, see RFC 6206.
227  *
228  * RFC 6550 suggests a default value of 10. We disable this mechanism by
229  * default, using a value of 0. This is to enable reliable DTSN increment
230  * propagation, and periodic rank dissemination without the need to increment
231  * version. Note that Trickle was originally designed for CTP, aiming to
232  * reduce broadcast traffic, which was particularly expensive done over an
233  * LPL MAC. In MAC layers such as non-beacon enabled or TSCH, broadcast is no
234  * more costly than unicast. Further, in this RPL implementation, DIOs are
235  * responsible for only a portion of the control traffic, compared to Link
236  * probing which is done at a period of minutes (RPL_PROBING_INTERVAL)
237  * for reliable parent selection.
238  */
239 #ifdef RPL_CONF_DIO_REDUNDANCY
240 #define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
241 #else
242 #define RPL_DIO_REDUNDANCY 0
243 #endif
244 
245 /*
246  * Default route lifetime unit. This is the granularity of time
247  * used in RPL lifetime values, in seconds.
248  */
249 #ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
250 #define RPL_DEFAULT_LIFETIME_UNIT 60
251 #else
252 #define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
253 #endif
254 
255 /*
256  * Default route lifetime as a multiple of the lifetime unit.
257  */
258 #ifndef RPL_CONF_DEFAULT_LIFETIME
259 #define RPL_DEFAULT_LIFETIME 30
260 #else
261 #define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
262 #endif
263 
264 /* Maximum lifetime of a DAG as a multiple of the lifetime unit. */
265 #ifdef RPL_CONF_DAG_LIFETIME
266 #define RPL_DAG_LIFETIME RPL_CONF_DAG_LIFETIME
267 #else
268 #define RPL_DAG_LIFETIME (60 * 60) /* one hour */
269 #endif /* RPL_CONF_DAG_LIFETIME */
270 
271 /*
272  * RPL probing interval.
273  */
274 #ifdef RPL_CONF_PROBING_INTERVAL
275 #define RPL_PROBING_INTERVAL RPL_CONF_PROBING_INTERVAL
276 #else
277 #define RPL_PROBING_INTERVAL (90 * CLOCK_SECOND)
278 #endif
279 
280 /*
281  * Function used to calculate next RPL probing interval
282  */
283 #ifdef RPL_CONF_PROBING_DELAY_FUNC
284 #define RPL_PROBING_DELAY_FUNC RPL_CONF_PROBING_DELAY_FUNC
285 #else
286 #define RPL_PROBING_DELAY_FUNC get_probing_delay
287 #endif
288 
289 /* Poisoining duration, before leaving the DAG */
290 #ifdef RPL_CONF_DELAY_BEFORE_LEAVING
291 #define RPL_DELAY_BEFORE_LEAVING RPL_CONF_DELAY_BEFORE_LEAVING
292 #else
293 #define RPL_DELAY_BEFORE_LEAVING (5 * 60 * CLOCK_SECOND)
294 #endif
295 
296 /* Interval of DIS transmission */
297 #ifdef RPL_CONF_DIS_INTERVAL
298 #define RPL_DIS_INTERVAL RPL_CONF_DIS_INTERVAL
299 #else
300 #define RPL_DIS_INTERVAL (30 * CLOCK_SECOND)
301 #endif
302 
303 /* DAO transmissions are always delayed by RPL_DAO_DELAY +/- RPL_DAO_DELAY/2 */
304 #ifdef RPL_CONF_DAO_DELAY
305 #define RPL_DAO_DELAY RPL_CONF_DAO_DELAY
306 #else /* RPL_CONF_DAO_DELAY */
307 #define RPL_DAO_DELAY (CLOCK_SECOND * 4)
308 #endif /* RPL_CONF_DAO_DELAY */
309 
310 #ifdef RPL_CONF_DAO_MAX_RETRANSMISSIONS
311 #define RPL_DAO_MAX_RETRANSMISSIONS RPL_CONF_DAO_MAX_RETRANSMISSIONS
312 #else
313 #define RPL_DAO_MAX_RETRANSMISSIONS 5
314 #endif /* RPL_CONF_DAO_MAX_RETRANSMISSIONS */
315 
316 #ifdef RPL_CONF_DAO_RETRANSMISSION_TIMEOUT
317 #define RPL_DAO_RETRANSMISSION_TIMEOUT RPL_CONF_DAO_RETRANSMISSION_TIMEOUT
318 #else
319 #define RPL_DAO_RETRANSMISSION_TIMEOUT (5 * CLOCK_SECOND)
320 #endif /* RPL_CONF_DAO_RETRANSMISSION_TIMEOUT */
321 
322 /******************************************************************************/
323 /************************** More parameterization *****************************/
324 /******************************************************************************/
325 
326 #ifndef RPL_CONF_MIN_HOPRANKINC
327 /* RFC6550 defines the default MIN_HOPRANKINC as 256.
328  * However, we use MRHOF as a default Objective Function (RFC6719),
329  * which recommends setting MIN_HOPRANKINC with care, in particular
330  * when used with ETX as a metric. ETX is computed as a fixed point
331  * real with a divisor of 128 (RFC6719, RFC6551). We choose to also
332  * use 128 for RPL_MIN_HOPRANKINC, resulting in a rank equal to the
333  * ETX path cost. Larger values may also be desirable, as discussed
334  * in section 6.1 of RFC6719. */
335 #if RPL_OF_OCP == RPL_OCP_MRHOF
336 #define RPL_MIN_HOPRANKINC 128
337 #else /* RPL_OF_OCP == RPL_OCP_MRHOF */
338 #define RPL_MIN_HOPRANKINC 256
339 #endif /* RPL_OF_OCP == RPL_OCP_MRHOF */
340 #else /* RPL_CONF_MIN_HOPRANKINC */
341 #define RPL_MIN_HOPRANKINC RPL_CONF_MIN_HOPRANKINC
342 #endif /* RPL_CONF_MIN_HOPRANKINC */
343 
344 #ifndef RPL_CONF_MAX_RANKINC
345 #define RPL_MAX_RANKINC (8 * RPL_MIN_HOPRANKINC)
346 #else /* RPL_CONF_MAX_RANKINC */
347 #define RPL_MAX_RANKINC RPL_CONF_MAX_RANKINC
348 #endif /* RPL_CONF_MAX_RANKINC */
349 
350 #ifndef RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD
351 #define RPL_SIGNIFICANT_CHANGE_THRESHOLD (4 * RPL_MIN_HOPRANKINC)
352 #else /* RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD */
353 #define RPL_SIGNIFICANT_CHANGE_THRESHOLD RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD
354 #endif /* RPL_CONF_SIGNIFICANT_CHANGE_THRESHOLD */
355 
356 /* This value decides which DAG instance we should participate in by default. */
357 #ifdef RPL_CONF_DEFAULT_INSTANCE
358 #define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
359 #else
360 #define RPL_DEFAULT_INSTANCE 0 /* Default of 0 for compression */
361 #endif /* RPL_CONF_DEFAULT_INSTANCE */
362 
363 /* Set to have the root advertise a grounded DAG */
364 #ifndef RPL_CONF_GROUNDED
365 #define RPL_GROUNDED 0
366 #else
367 #define RPL_GROUNDED RPL_CONF_GROUNDED
368 #endif /* !RPL_CONF_GROUNDED */
369 
370 /*
371  * DAG preference field
372  */
373 #ifdef RPL_CONF_PREFERENCE
374 #define RPL_PREFERENCE RPL_CONF_PREFERENCE
375 #else
376 #define RPL_PREFERENCE 0
377 #endif
378 
379 /* RPL callbacks when TSCH is enabled */
380 #if MAC_CONF_WITH_TSCH
381 
382 #ifndef RPL_CALLBACK_PARENT_SWITCH
383 #define RPL_CALLBACK_PARENT_SWITCH tsch_rpl_callback_parent_switch
384 #endif /* RPL_CALLBACK_PARENT_SWITCH */
385 
386 #ifndef RPL_CALLBACK_NEW_DIO_INTERVAL
387 #define RPL_CALLBACK_NEW_DIO_INTERVAL tsch_rpl_callback_new_dio_interval
388 #endif /* RPL_CALLBACK_NEW_DIO_INTERVAL */
389 
390 #endif /* MAC_CONF_WITH_TSCH */
391 
392 /** @} */
393 
394 #endif /* RPL_CONF_H */