Contiki 3.x
tsch-conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, SICS Swedish ICT.
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  * \file
35  * TSCH configuration
36  * \author
37  * Simon Duquennoy <simonduq@sics.se>
38  */
39 
40 #ifndef __TSCH_CONF_H__
41 #define __TSCH_CONF_H__
42 
43 /********** Includes **********/
44 
45 #include "contiki.h"
46 
47 /******** Configuration *******/
48 
49 /* Default IEEE 802.15.4e hopping sequences, obtained from https://gist.github.com/twatteyne/2e22ee3c1a802b685695 */
50 /* 16 channels, sequence length 16 */
51 #define TSCH_HOPPING_SEQUENCE_16_16 (uint8_t[]){ 16, 17, 23, 18, 26, 15, 25, 22, 19, 11, 12, 13, 24, 14, 20, 21 }
52 /* 4 channels, sequence length 16 */
53 #define TSCH_HOPPING_SEQUENCE_4_16 (uint8_t[]){ 20, 26, 25, 26, 15, 15, 25, 20, 26, 15, 26, 25, 20, 15, 20, 25 }
54 /* 4 channels, sequence length 4 */
55 #define TSCH_HOPPING_SEQUENCE_4_4 (uint8_t[]){ 15, 25, 26, 20 }
56 /* 1 channel, sequence length 1 */
57 #define TSCH_HOPPING_SEQUENCE_1_1 (uint8_t[]){ 20 }
58 
59 /* Default hopping sequence, used in case hopping sequence ID == 0 */
60 #ifdef TSCH_CONF_DEFAULT_HOPPING_SEQUENCE
61 #define TSCH_DEFAULT_HOPPING_SEQUENCE TSCH_CONF_DEFAULT_HOPPING_SEQUENCE
62 #else
63 #define TSCH_DEFAULT_HOPPING_SEQUENCE TSCH_HOPPING_SEQUENCE_4_4
64 #endif
65 
66 /* Hopping sequence used for joining (scan channels) */
67 #ifdef TSCH_CONF_JOIN_HOPPING_SEQUENCE
68 #define TSCH_JOIN_HOPPING_SEQUENCE TSCH_CONF_JOIN_HOPPING_SEQUENCE
69 #else
70 #define TSCH_JOIN_HOPPING_SEQUENCE TSCH_DEFAULT_HOPPING_SEQUENCE
71 #endif
72 
73 /* Maximum length of the TSCH channel hopping sequence. Must be greater or
74  * equal to the length of TSCH_DEFAULT_HOPPING_SEQUENCE. */
75 #ifdef TSCH_CONF_HOPPING_SEQUENCE_MAX_LEN
76 #define TSCH_HOPPING_SEQUENCE_MAX_LEN TSCH_CONF_HOPPING_SEQUENCE_MAX_LEN
77 #else
78 #define TSCH_HOPPING_SEQUENCE_MAX_LEN 16
79 #endif
80 
81 /* Timeslot timing */
82 
83 #ifndef TSCH_CONF_DEFAULT_TIMESLOT_LENGTH
84 #define TSCH_CONF_DEFAULT_TIMESLOT_LENGTH 10000
85 #endif /* TSCH_CONF_DEFAULT_TIMESLOT_LENGTH */
86 
87 /* Configurable Rx guard time is micro-seconds */
88 #ifndef TSCH_CONF_RX_WAIT
89 #define TSCH_CONF_RX_WAIT 2200
90 #endif /* TSCH_CONF_RX_WAIT */
91 
92 /* The default timeslot timing in the standard is a guard time of
93  * 2200 us, a Tx offset of 2120 us and a Rx offset of 1120 us.
94  * As a result, the listening device has a guard time not centered
95  * on the expected Tx time. This is to be fixed in the next iteration
96  * of the standard. This can be enabled with:
97  * #define TSCH_DEFAULT_TS_TX_OFFSET 2120
98  * #define TSCH_DEFAULT_TS_RX_OFFSET 1120
99  * #define TSCH_DEFAULT_TS_RX_WAIT 2200
100  *
101  * Instead, we align the Rx guard time on expected Tx time. The Rx
102  * guard time is user-configurable with TSCH_CONF_RX_WAIT.
103 
104  * (TS_TX_OFFSET - (TS_RX_WAIT / 2)) instead */
105 
106 #if TSCH_CONF_DEFAULT_TIMESLOT_LENGTH == 10000
107 /* Default timeslot timing as per IEEE 802.15.4e */
108 
109 #define TSCH_DEFAULT_TS_CCA_OFFSET 1800
110 #define TSCH_DEFAULT_TS_CCA 128
111 #define TSCH_DEFAULT_TS_TX_OFFSET 2120
112 #define TSCH_DEFAULT_TS_RX_OFFSET (TSCH_DEFAULT_TS_TX_OFFSET - (TSCH_CONF_RX_WAIT / 2))
113 #define TSCH_DEFAULT_TS_RX_ACK_DELAY 800
114 #define TSCH_DEFAULT_TS_TX_ACK_DELAY 1000
115 #define TSCH_DEFAULT_TS_RX_WAIT TSCH_CONF_RX_WAIT
116 #define TSCH_DEFAULT_TS_ACK_WAIT 400
117 #define TSCH_DEFAULT_TS_RX_TX 192
118 #define TSCH_DEFAULT_TS_MAX_ACK 2400
119 #define TSCH_DEFAULT_TS_MAX_TX 4256
120 #define TSCH_DEFAULT_TS_TIMESLOT_LENGTH 10000
121 
122 #elif TSCH_CONF_DEFAULT_TIMESLOT_LENGTH == 15000
123 /* Default timeslot timing for platfroms requiring 15ms slots */
124 
125 #define TSCH_DEFAULT_TS_CCA_OFFSET 1800
126 #define TSCH_DEFAULT_TS_CCA 128
127 #define TSCH_DEFAULT_TS_TX_OFFSET 4000
128 #define TSCH_DEFAULT_TS_RX_OFFSET (TSCH_DEFAULT_TS_TX_OFFSET - (TSCH_CONF_RX_WAIT / 2))
129 #define TSCH_DEFAULT_TS_RX_ACK_DELAY 3600
130 #define TSCH_DEFAULT_TS_TX_ACK_DELAY 4000
131 #define TSCH_DEFAULT_TS_RX_WAIT TSCH_CONF_RX_WAIT
132 #define TSCH_DEFAULT_TS_ACK_WAIT 800
133 #define TSCH_DEFAULT_TS_RX_TX 2072
134 #define TSCH_DEFAULT_TS_MAX_ACK 2400
135 #define TSCH_DEFAULT_TS_MAX_TX 4256
136 #define TSCH_DEFAULT_TS_TIMESLOT_LENGTH 15000
137 
138 #elif TSCH_CONF_DEFAULT_TIMESLOT_LENGTH == 65000U
139 /* 65ms timeslot, i.e. nearly the max length allowed by standard (16-bit unsigned in micro-seconds).
140  * Useful for running link-layer security on sky or z1 in Cooja, where only S/W security is supported.
141  * Note: this slot timing would require a total of 120ms. If a slot overlaps with the next active slot,
142  * the latter will be skipped.
143  * This configuration is mostly a work-around to test link-layer security in Cooja, it is recommended
144  * to use it with a 6TiSCH minimal schedule of length >= 2. */
145 
146 #define TSCH_DEFAULT_TS_CCA_OFFSET 1800
147 #define TSCH_DEFAULT_TS_CCA 128
148 #define TSCH_DEFAULT_TS_TX_OFFSET 52000
149 #define TSCH_DEFAULT_TS_RX_OFFSET (TSCH_DEFAULT_TS_TX_OFFSET - (TSCH_CONF_RX_WAIT / 2))
150 #define TSCH_DEFAULT_TS_RX_ACK_DELAY 58600
151 #define TSCH_DEFAULT_TS_TX_ACK_DELAY 59000
152 #define TSCH_DEFAULT_TS_RX_WAIT TSCH_CONF_RX_WAIT
153 #define TSCH_DEFAULT_TS_ACK_WAIT 800
154 #define TSCH_DEFAULT_TS_RX_TX 2072
155 #define TSCH_DEFAULT_TS_MAX_ACK 2400
156 #define TSCH_DEFAULT_TS_MAX_TX 4256
157 #define TSCH_DEFAULT_TS_TIMESLOT_LENGTH 65000
158 
159 #else
160 #error "TSCH: Unsupported default timeslot length"
161 #endif
162 
163 /* A custom feature allowing upper layers to assign packets to
164  * a specific slotframe and link */
165 #ifdef TSCH_CONF_WITH_LINK_SELECTOR
166 #define TSCH_WITH_LINK_SELECTOR TSCH_CONF_WITH_LINK_SELECTOR
167 #else /* TSCH_CONF_WITH_LINK_SELECTOR */
168 #define TSCH_WITH_LINK_SELECTOR 0
169 #endif /* TSCH_CONF_WITH_LINK_SELECTOR */
170 
171 /* Estimate the drift of the time-source neighbor and compensate for it? */
172 #ifdef TSCH_CONF_ADAPTIVE_TIMESYNC
173 #define TSCH_ADAPTIVE_TIMESYNC TSCH_CONF_ADAPTIVE_TIMESYNC
174 #else
175 #define TSCH_ADAPTIVE_TIMESYNC 0
176 #endif
177 
178 /* HW frame filtering enabled */
179 #ifdef TSCH_CONF_HW_FRAME_FILTERING
180 #define TSCH_HW_FRAME_FILTERING TSCH_CONF_HW_FRAME_FILTERING
181 #else /* TSCH_CONF_HW_FRAME_FILTERING */
182 #define TSCH_HW_FRAME_FILTERING 1
183 #endif /* TSCH_CONF_HW_FRAME_FILTERING */
184 
185 #endif /* __TSCH_CONF_H__ */