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  * Select routing metric supported at runtime. This must be a valid
50  * DAG Metric Container Object Type (see below). Currently, we only
51  * support RPL_DAG_MC_ETX and RPL_DAG_MC_ENERGY.
52  * When MRHOF (RFC6719) is used with ETX, no metric container must
53  * be used; instead the rank carries ETX directly.
54  */
55 #ifdef RPL_CONF_DAG_MC
56 #define RPL_DAG_MC RPL_CONF_DAG_MC
57 #else
58 #define RPL_DAG_MC RPL_DAG_MC_NONE
59 #endif /* RPL_CONF_DAG_MC */
60 
61 /*
62  * The objective function used by RPL is configurable through the
63  * RPL_CONF_OF parameter. This should be defined to be the name of an
64  * rpl_of object linked into the system image, e.g., rpl_of0.
65  */
66 #ifdef RPL_CONF_OF
67 #define RPL_OF RPL_CONF_OF
68 #else
69 /* ETX is the default objective function. */
70 #define RPL_OF rpl_mrhof
71 #endif /* RPL_CONF_OF */
72 
73 /* This value decides which DAG instance we should participate in by default. */
74 #ifdef RPL_CONF_DEFAULT_INSTANCE
75 #define RPL_DEFAULT_INSTANCE RPL_CONF_DEFAULT_INSTANCE
76 #else
77 #define RPL_DEFAULT_INSTANCE 0x1e
78 #endif /* RPL_CONF_DEFAULT_INSTANCE */
79 
80 /*
81  * This value decides if this node must stay as a leaf or not
82  * as allowed by draft-ietf-roll-rpl-19#section-8.5
83  */
84 #ifdef RPL_CONF_LEAF_ONLY
85 #define RPL_LEAF_ONLY RPL_CONF_LEAF_ONLY
86 #else
87 #define RPL_LEAF_ONLY 0
88 #endif
89 
90 /*
91  * Maximum of concurent RPL instances.
92  */
93 #ifdef RPL_CONF_MAX_INSTANCES
94 #define RPL_MAX_INSTANCES RPL_CONF_MAX_INSTANCES
95 #else
96 #define RPL_MAX_INSTANCES 1
97 #endif /* RPL_CONF_MAX_INSTANCES */
98 
99 /*
100  * Maximum number of DAGs within an instance.
101  */
102 #ifdef RPL_CONF_MAX_DAG_PER_INSTANCE
103 #define RPL_MAX_DAG_PER_INSTANCE RPL_CONF_MAX_DAG_PER_INSTANCE
104 #else
105 #define RPL_MAX_DAG_PER_INSTANCE 2
106 #endif /* RPL_CONF_MAX_DAG_PER_INSTANCE */
107 
108 /*
109  *
110  */
111 #ifndef RPL_CONF_DAO_SPECIFY_DAG
112  #if RPL_MAX_DAG_PER_INSTANCE > 1
113  #define RPL_DAO_SPECIFY_DAG 1
114  #else
115  #define RPL_DAO_SPECIFY_DAG 0
116  #endif /* RPL_MAX_DAG_PER_INSTANCE > 1 */
117 #else
118  #define RPL_DAO_SPECIFY_DAG RPL_CONF_DAO_SPECIFY_DAG
119 #endif /* RPL_CONF_DAO_SPECIFY_DAG */
120 
121 /*
122  * The DIO interval (n) represents 2^n ms.
123  *
124  * According to the specification, the default value is 3 which
125  * means 8 milliseconds. That is far too low when using duty cycling
126  * with wake-up intervals that are typically hundreds of milliseconds.
127  * ContikiRPL thus sets the default to 2^12 ms = 4.096 s.
128  */
129 #ifdef RPL_CONF_DIO_INTERVAL_MIN
130 #define RPL_DIO_INTERVAL_MIN RPL_CONF_DIO_INTERVAL_MIN
131 #else
132 #define RPL_DIO_INTERVAL_MIN 12
133 #endif
134 
135 /*
136  * Maximum amount of timer doublings.
137  *
138  * The maximum interval will by default be 2^(12+8) ms = 1048.576 s.
139  * RFC 6550 suggests a default value of 20, which of course would be
140  * unsuitable when we start with a minimum interval of 2^12.
141  */
142 #ifdef RPL_CONF_DIO_INTERVAL_DOUBLINGS
143 #define RPL_DIO_INTERVAL_DOUBLINGS RPL_CONF_DIO_INTERVAL_DOUBLINGS
144 #else
145 #define RPL_DIO_INTERVAL_DOUBLINGS 8
146 #endif
147 
148 /*
149  * DIO redundancy. To learn more about this, see RFC 6206.
150  *
151  * RFC 6550 suggests a default value of 10. It is unclear what the basis
152  * of this suggestion is. Network operators might attain more efficient
153  * operation by tuning this parameter for specific deployments.
154  */
155 #ifdef RPL_CONF_DIO_REDUNDANCY
156 #define RPL_DIO_REDUNDANCY RPL_CONF_DIO_REDUNDANCY
157 #else
158 #define RPL_DIO_REDUNDANCY 10
159 #endif
160 
161 /*
162  * Initial metric attributed to a link when the ETX is unknown
163  */
164 #ifndef RPL_CONF_INIT_LINK_METRIC
165 #define RPL_INIT_LINK_METRIC 2
166 #else
167 #define RPL_INIT_LINK_METRIC RPL_CONF_INIT_LINK_METRIC
168 #endif
169 
170 /*
171  * Default route lifetime unit. This is the granularity of time
172  * used in RPL lifetime values, in seconds.
173  */
174 #ifndef RPL_CONF_DEFAULT_LIFETIME_UNIT
175 #define RPL_DEFAULT_LIFETIME_UNIT 0xffff
176 #else
177 #define RPL_DEFAULT_LIFETIME_UNIT RPL_CONF_DEFAULT_LIFETIME_UNIT
178 #endif
179 
180 /*
181  * Default route lifetime as a multiple of the lifetime unit.
182  */
183 #ifndef RPL_CONF_DEFAULT_LIFETIME
184 #define RPL_DEFAULT_LIFETIME 0xff
185 #else
186 #define RPL_DEFAULT_LIFETIME RPL_CONF_DEFAULT_LIFETIME
187 #endif
188 
189 /*
190  * DAG preference field
191  */
192 #ifdef RPL_CONF_PREFERENCE
193 #define RPL_PREFERENCE RPL_CONF_PREFERENCE
194 #else
195 #define RPL_PREFERENCE 0
196 #endif
197 
198 #endif /* RPL_CONF_H */