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