Contiki-NG
Loading...
Searching...
No Matches
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/* Slotframe size for the root rule. Usually this should be shorter than the unicast slotframe size,
80 as the root node receives more traffic than the other nodes in the network. */
81#ifdef ORCHESTRA_CONF_ROOT_PERIOD
82#define ORCHESTRA_ROOT_PERIOD ORCHESTRA_CONF_ROOT_PERIOD
83#else /* ORCHESTRA_CONF_ROOT_PERIOD */
84#define ORCHESTRA_ROOT_PERIOD 7
85#endif /* ORCHESTRA_CONF_ROOT_PERIOD */
86
87/* Is the per-neighbor unicast slotframe sender-based (if not, it is receiver-based).
88 * Note: sender-based works only with RPL storing mode as it relies on DAO and
89 * routing entries to keep track of children and parents. */
90#ifdef ORCHESTRA_CONF_UNICAST_SENDER_BASED
91#define ORCHESTRA_UNICAST_SENDER_BASED ORCHESTRA_CONF_UNICAST_SENDER_BASED
92#else /* ORCHESTRA_CONF_UNICAST_SENDER_BASED */
93#define ORCHESTRA_UNICAST_SENDER_BASED 0
94#endif /* ORCHESTRA_CONF_UNICAST_SENDER_BASED */
95
96/* The hash function used to assign timeslot to a given node (based on its link-layer address).
97 * For rules with multiple channel offsets, it is also used to select the channel offset. */
98#ifdef ORCHESTRA_CONF_LINKADDR_HASH
99#define ORCHESTRA_LINKADDR_HASH ORCHESTRA_CONF_LINKADDR_HASH
100#else /* ORCHESTRA_CONF_LINKADDR_HASH */
101#define ORCHESTRA_LINKADDR_HASH(addr) ((addr != NULL) ? (addr)->u8[LINKADDR_SIZE - 1] : -1)
102#endif /* ORCHESTRA_CONF_LINKADDR_HASH */
103
104/* The hash function used to assign timeslot for a pair of given nodes.
105 * The value of 264 is a good choice for the default slotframe size 17. It also a good choice for
106 * most other slotframe sizes: there are no prime numbers between 2 and 101 (inclusive) that
107 * produce modulo 1 when used to divide 264. This ensures that for any a1, a2 this is true:
108 * `ORCHESTRA_LINKADDR_HASH2(a1, a2) != ORCHESTRA_LINKADDR_HASH2(a2, a1)` */
109#ifdef ORCHESTRA_CONF_LINKADDR_HASH2
110#define ORCHESTRA_LINKADDR_HASH2 ORCHESTRA_CONF_LINKADDR_HASH2
111#else /* ORCHESTRA_CONF_LINKADDR_HASH2 */
112#define ORCHESTRA_LINKADDR_HASH2(addr1, addr2) ((addr1)->u8[LINKADDR_SIZE - 1] + 264 * (addr2)->u8[LINKADDR_SIZE - 1])
113#endif /* ORCHESTRA_CONF_LINKADDR_HASH2 */
114
115/* The maximum hash */
116#ifdef ORCHESTRA_CONF_MAX_HASH
117#define ORCHESTRA_MAX_HASH ORCHESTRA_CONF_MAX_HASH
118#else /* ORCHESTRA_CONF_MAX_HASH */
119#define ORCHESTRA_MAX_HASH 0x7fff
120#endif /* ORCHESTRA_CONF_MAX_HASH */
121
122/* Is the "hash" function collision-free? (e.g. it maps to unique node-ids) */
123#ifdef ORCHESTRA_CONF_COLLISION_FREE_HASH
124#define ORCHESTRA_COLLISION_FREE_HASH ORCHESTRA_CONF_COLLISION_FREE_HASH
125#else /* ORCHESTRA_CONF_COLLISION_FREE_HASH */
126#define ORCHESTRA_COLLISION_FREE_HASH 0 /* Set to 1 if ORCHESTRA_LINKADDR_HASH returns unique hashes */
127#endif /* ORCHESTRA_CONF_COLLISION_FREE_HASH */
128
129/* Channel offset for the default common rule, default 0 */
130#ifdef ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET
131#define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET ORCHESTRA_CONF_DEFAULT_COMMON_CHANNEL_OFFSET
132#else
133#define ORCHESTRA_DEFAULT_COMMON_CHANNEL_OFFSET 0
134#endif
135
136/* Min channel offset for the unicast rules; the default min/max range is [2, sizeof(HS)-2].
137 If the HS has less then 3 channels [1, 1] is used instead.
138*/
139#ifdef ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET
140#define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MIN_CHANNEL_OFFSET
141#else
142#define ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET (sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE) > 2 ? 2 : 1)
143#endif
144
145/* Max channel offset for the unicast rules */
146#ifdef ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET
147#define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET ORCHESTRA_CONF_UNICAST_MAX_CHANNEL_OFFSET
148#else
149#define ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET \
150 (MAX(ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET, sizeof(TSCH_DEFAULT_HOPPING_SEQUENCE) - 1))
151#endif
152
153/* Channel offsets for the EB rule, default: 1 */
154#ifdef ORCHESTRA_CONF_EB_MIN_CHANNEL_OFFSET
155#define ORCHESTRA_EB_MIN_CHANNEL_OFFSET ORCHESTRA_CONF_EB_MIN_CHANNEL_OFFSET
156#else
157#define ORCHESTRA_EB_MIN_CHANNEL_OFFSET 1
158#endif
159
160#ifdef ORCHESTRA_CONF_EB_MAX_CHANNEL_OFFSET
161#define ORCHESTRA_EB_MAX_CHANNEL_OFFSET ORCHESTRA_CONF_EB_MAX_CHANNEL_OFFSET
162#else
163#define ORCHESTRA_EB_MAX_CHANNEL_OFFSET 1
164#endif
165
166#endif /* ORCHESTRA_CONF_H_ */