Contiki-NG
orchestra-conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 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  */
30 
31 /**
32  * \file
33  * Orchestra configuration
34  *
35  * \author Simon Duquennoy <simonduq@sics.se>
36  */
37 
38 #ifndef __ORCHESTRA_CONF_H__
39 #define __ORCHESTRA_CONF_H__
40 
41 #ifdef ORCHESTRA_CONF_RULES
42 #define ORCHESTRA_RULES ORCHESTRA_CONF_RULES
43 #else /* ORCHESTRA_CONF_RULES */
44 /* A default configuration with:
45  * - a sender-based slotframe for EB transmission
46  * - a sender-based or receiver-based slotframe for unicast to RPL parents and children
47  * - a common shared slotframe for any other traffic (mostly broadcast)
48  * */
49 #define ORCHESTRA_RULES { &eb_per_time_source, \
50  &unicast_per_neighbor_rpl_ns, \
51  &default_common }
52 /* Example configuration for RPL storing mode: */
53 /* #define ORCHESTRA_RULES { &eb_per_time_source, \
54  &unicast_per_neighbor_rpl_storing, \
55  &default_common } */
56 
57 #endif /* ORCHESTRA_CONF_RULES */
58 
59 /* Length of the various slotframes. Tune to balance network capacity,
60  * contention, energy, latency. */
61 #ifdef ORCHESTRA_CONF_EBSF_PERIOD
62 #define ORCHESTRA_EBSF_PERIOD ORCHESTRA_CONF_EBSF_PERIOD
63 #else /* ORCHESTRA_CONF_EBSF_PERIOD */
64 #define ORCHESTRA_EBSF_PERIOD 397
65 #endif /* ORCHESTRA_CONF_EBSF_PERIOD */
66 
67 #ifdef ORCHESTRA_CONF_COMMON_SHARED_PERIOD
68 #define ORCHESTRA_COMMON_SHARED_PERIOD ORCHESTRA_CONF_COMMON_SHARED_PERIOD
69 #else /* ORCHESTRA_CONF_COMMON_SHARED_PERIOD */
70 #define ORCHESTRA_COMMON_SHARED_PERIOD 31
71 #endif /* ORCHESTRA_CONF_COMMON_SHARED_PERIOD */
72 
73 #ifdef ORCHESTRA_CONF_UNICAST_PERIOD
74 #define ORCHESTRA_UNICAST_PERIOD ORCHESTRA_CONF_UNICAST_PERIOD
75 #else /* ORCHESTRA_CONF_UNICAST_PERIOD */
76 #define ORCHESTRA_UNICAST_PERIOD 17
77 #endif /* ORCHESTRA_CONF_UNICAST_PERIOD */
78 
79 /* Is the per-neighbor unicast slotframe sender-based (if not, it is receiver-based).
80  * Note: sender-based works only with RPL storing mode as it relies on DAO and
81  * routing entries to keep track of children and parents. */
82 #ifdef ORCHESTRA_CONF_UNICAST_SENDER_BASED
83 #define ORCHESTRA_UNICAST_SENDER_BASED ORCHESTRA_CONF_UNICAST_SENDER_BASED
84 #else /* ORCHESTRA_CONF_UNICAST_SENDER_BASED */
85 #define ORCHESTRA_UNICAST_SENDER_BASED 0
86 #endif /* ORCHESTRA_CONF_UNICAST_SENDER_BASED */
87 
88 /* The hash function used to assign timeslot to a given node (based on its link-layer address).
89  * For rules with multiple channel offsets, it is also used to select the channel offset. */
90 #ifdef ORCHESTRA_CONF_LINKADDR_HASH
91 #define ORCHESTRA_LINKADDR_HASH ORCHESTRA_CONF_LINKADDR_HASH
92 #else /* ORCHESTRA_CONF_LINKADDR_HASH */
93 #define ORCHESTRA_LINKADDR_HASH(addr) ((addr != NULL) ? (addr)->u8[LINKADDR_SIZE - 1] : -1)
94 #endif /* ORCHESTRA_CONF_LINKADDR_HASH */
95 
96 /* The hash function used to assign timeslot for a pair of given nodes.
97  * The value of 264 is a good choice for the default slotframe size 17. It also a good choice for
98  * most other slotframe sizes: there are no prime numbers between 2 and 101 (inclusive) that
99  * produce modulo 1 when used to divide 264. This ensures that for any a1, a2 this is true:
100  * `ORCHESTRA_LINKADDR_HASH2(a1, a2) != ORCHESTRA_LINKADDR_HASH2(a2, a1)` */
101 #ifdef ORCHESTRA_CONF_LINKADDR_HASH2
102 #define ORCHESTRA_LINKADDR_HASH2 ORCHESTRA_CONF_LINKADDR_HASH2
103 #else /* ORCHESTRA_CONF_LINKADDR_HASH2 */
104 #define ORCHESTRA_LINKADDR_HASH2(addr1, addr2) ((addr1)->u8[LINKADDR_SIZE - 1] + 264 * (addr2)->u8[LINKADDR_SIZE - 1])
105 #endif /* ORCHESTRA_CONF_LINKADDR_HASH2 */
106 
107 /* The maximum hash */
108 #ifdef ORCHESTRA_CONF_MAX_HASH
109 #define ORCHESTRA_MAX_HASH ORCHESTRA_CONF_MAX_HASH
110 #else /* ORCHESTRA_CONF_MAX_HASH */
111 #define ORCHESTRA_MAX_HASH 0x7fff
112 #endif /* ORCHESTRA_CONF_MAX_HASH */
113 
114 /* Is the "hash" function collision-free? (e.g. it maps to unique node-ids) */
115 #ifdef ORCHESTRA_CONF_COLLISION_FREE_HASH
116 #define ORCHESTRA_COLLISION_FREE_HASH ORCHESTRA_CONF_COLLISION_FREE_HASH
117 #else /* ORCHESTRA_CONF_COLLISION_FREE_HASH */
118 #define ORCHESTRA_COLLISION_FREE_HASH 0 /* Set to 1 if ORCHESTRA_LINKADDR_HASH returns unique hashes */
119 #endif /* ORCHESTRA_CONF_COLLISION_FREE_HASH */
120 
121 /* Channel offset for the EB rule, default 0 */
122 #ifdef ORCHESTRA_CONF_EB_CHANNEL_OFFSET
123 #define ORCHESTRA_EB_CHANNEL_OFFSET ORCHESTRA_CONF_EB_CHANNEL_OFFSET
124 #else
125 #define ORCHESTRA_EB_CHANNEL_OFFSET 0
126 #endif
127 
128 /* Channel offset for the default common rule, default 1 */
129 #ifdef ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET
130 #define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET
131 #else
132 #define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET 1
133 #endif
134 
135 /* Min channel offset for the unicast rules; the default min/max range is [2, 255] */
136 #ifdef ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET
137 #define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET
138 #else
139 #define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET 2
140 #endif
141 
142 /* Max channel offset for the unicast rules */
143 #ifdef ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET
144 #define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET
145 #else
146 #define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET 255
147 #endif
148 
149 #endif /* __ORCHESTRA_CONF_H__ */