Contiki 3.x
roll-tm.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Loughborough University - 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 
32 /**
33  * \file
34  * Header file for IPv6 multicast according to the algorithm in the
35  * "MCAST Forwarding Using Trickle" internet draft.
36  *
37  * The current version of the draft can always be found in
38  * http://tools.ietf.org/html/draft-ietf-roll-trickle-mcast
39  *
40  * This implementation is based on the draft version stored in
41  * ROLL_TM_VER.
42  *
43  * In draft v2, the document was renamed to
44  * "Multicast Protocol for Low power and Lossy Networks (MPL)"
45  * Due to very significant changes between draft versions 1 and 2,
46  * MPL will be implemented as a separate engine and this file here
47  * will provide legacy support for Draft v1.
48  *
49  * \author
50  * George Oikonomou - <oikonomou@users.sourceforge.net>
51  */
52 
53 #ifndef ROLL_TM_H_
54 #define ROLL_TM_H_
55 
56 #include "contiki-conf.h"
58 
59 #include <stdint.h>
60 /*---------------------------------------------------------------------------*/
61 /* Protocol Constants */
62 /*---------------------------------------------------------------------------*/
63 #define ROLL_TM_VER 1 /* Supported Draft Version */
64 #define ROLL_TM_ICMP_CODE 0 /* ICMPv6 code field */
65 #define ROLL_TM_IP_HOP_LIMIT 0xFF /* Hop limit for ICMP messages */
66 #define ROLL_TM_INFINITE_REDUNDANCY 0xFF
67 #define ROLL_TM_DGRAM_OUT 0
68 #define ROLL_TM_DGRAM_IN 1
69 
70 /*
71  * The draft does not currently specify a default number for the trickle
72  * interval nor a way to derive it. Examples however hint at 100 msec.
73  *
74  * In draft terminology, we use an 'aggressive' policy (M=0) and a conservative
75  * one (M=1).
76  *
77  * When experimenting with the two policies on the sky platform,
78  * an interval of 125ms proves to be way too low: When we have traffic,
79  * doublings happen after the interval end and periodics fire after point T
80  * within the interval (and sometimes even after interval end). When traffic
81  * settles down, the code compensates the offsets.
82  *
83  * We consider 125, 250ms etc because they are nice divisors of 1 sec
84  * (quotient is power of two). For some machines (e.g sky/msp430,
85  * sensinode/cc243x), this is also a nice number of clock ticks
86  *
87  * After experimentation, the values of Imin leading to best performance are:
88  * ContikiMAC: Imin=64 (500ms)
89  * Null RDC: imin=16 (125ms)
90  */
91 
92 /* Configuration for Timer with M=0 (aggressive) */
93 #ifdef ROLL_TM_CONF_IMIN_0
94 #define ROLL_TM_IMIN_0 ROLL_TM_CONF_IMIN_0
95 #else
96 #define ROLL_TM_IMIN_0 32 /* 250 msec */
97 #endif
98 
99 #ifdef ROLL_TM_CONF_IMAX_0
100 #define ROLL_TM_IMAX_0 ROLL_TM_CONF_IMAX_0
101 #else
102 #define ROLL_TM_IMAX_0 1 /* Imax = 500ms */
103 #endif
104 
105 #ifdef ROLL_TM_CONF_K_0
106 #define ROLL_TM_K_0 ROLL_TM_CONF_K_0
107 #else
108 #define ROLL_TM_K_0 ROLL_TM_INFINITE_REDUNDANCY
109 #endif
110 
111 #ifdef ROLL_TM_CONF_T_ACTIVE_0
112 #define ROLL_TM_T_ACTIVE_0 ROLL_TM_CONF_T_ACTIVE_0
113 #else
114 #define ROLL_TM_T_ACTIVE_0 3
115 #endif
116 
117 #ifdef ROLL_TM_CONF_T_DWELL_0
118 #define ROLL_TM_T_DWELL_0 ROLL_TM_CONF_T_DWELL_0
119 #else
120 #define ROLL_TM_T_DWELL_0 11
121 #endif
122 
123 /* Configuration for Timer with M=1 (conservative) */
124 #ifdef ROLL_TM_CONF_IMIN_1
125 #define ROLL_TM_IMIN_1 ROLL_TM_CONF_IMIN_1
126 #else
127 #define ROLL_TM_IMIN_1 64 /* 500 msec */
128 #endif
129 
130 #ifdef ROLL_TM_CONF_IMAX_1
131 #define ROLL_TM_IMAX_1 ROLL_TM_CONF_IMAX_1
132 #else
133 #define ROLL_TM_IMAX_1 9 /* Imax = 256 secs */
134 #endif
135 
136 #ifdef ROLL_TM_CONF_K_1
137 #define ROLL_TM_K_1 ROLL_TM_CONF_K_1
138 #else
139 #define ROLL_TM_K_1 1
140 #endif
141 
142 #ifdef ROLL_TM_CONF_T_ACTIVE_1
143 #define ROLL_TM_T_ACTIVE_1 ROLL_TM_CONF_T_ACTIVE_1
144 #else
145 #define ROLL_TM_T_ACTIVE_1 3
146 #endif
147 
148 #ifdef ROLL_TM_CONF_T_DWELL_1
149 #define ROLL_TM_T_DWELL_1 ROLL_TM_CONF_T_DWELL_1
150 #else
151 #define ROLL_TM_T_DWELL_1 12
152 #endif
153 /*---------------------------------------------------------------------------*/
154 /* Configuration */
155 /*---------------------------------------------------------------------------*/
156 /*
157  * Number of Sliding Windows
158  * In essence: How many unique sources of simultaneous multicast traffic do we
159  * want to support for our lowpan
160  * If a node is seeding two multicast streams, parametrized on different M
161  * values, then this seed will occupy two different sliding windows
162  */
163 #ifdef ROLL_TM_CONF_WINS
164 #define ROLL_TM_WINS ROLL_TM_CONF_WINS
165 #else
166 #define ROLL_TM_WINS 2
167 #endif
168 /*---------------------------------------------------------------------------*/
169 /*
170  * Maximum Number of Buffered Multicast Messages
171  * This buffer is shared across all Seed IDs, therefore a new very active Seed
172  * may eventually occupy all slots. It would make little sense (if any) to
173  * define support for fewer buffered messages than seeds*2
174  */
175 #ifdef ROLL_TM_CONF_BUFF_NUM
176 #define ROLL_TM_BUFF_NUM ROLL_TM_CONF_BUFF_NUM
177 #else
178 #define ROLL_TM_BUFF_NUM 6
179 #endif
180 /*---------------------------------------------------------------------------*/
181 /*
182  * Use Short Seed IDs [short: 2, long: 16 (default)]
183  * It can be argued that we should (and it would be easy to) support both at
184  * the same time but the draft doesn't list this as a MUST so we opt for
185  * code/ram savings
186  */
187 #ifdef ROLL_TM_CONF_SHORT_SEEDS
188 #define ROLL_TM_SHORT_SEEDS ROLL_TM_CONF_SHORT_SEEDS
189 #else
190 #define ROLL_TM_SHORT_SEEDS 0
191 #endif
192 /*---------------------------------------------------------------------------*/
193 /*
194  * Destination address for our ICMPv6 advertisements. The draft gives us a
195  * choice between LL all-nodes or LL all-routers
196  *
197  * We use allrouters unless a conf directive chooses otherwise
198  */
199 #ifdef ROLL_TM_CONF_DEST_ALL_NODES
200 #define ROLL_TM_DEST_ALL_NODES ROLL_TM_CONF_DEST_ALL_NODES
201 #else
202 #define ROLL_TM_DEST_ALL_NODES 0
203 #endif
204 /*---------------------------------------------------------------------------*/
205 /*
206  * M param for our outgoing messages
207  * By default, we set the M bit (conservative). Define this as 0 to clear the
208  * M bit in our outgoing messages (aggressive)
209  */
210 #ifdef ROLL_TM_CONF_SET_M_BIT
211 #define ROLL_TM_SET_M_BIT ROLL_TM_CONF_SET_M_BIT
212 #else
213 #define ROLL_TM_SET_M_BIT 1
214 #endif
215 /*---------------------------------------------------------------------------*/
216 /* Stats datatype */
217 /*---------------------------------------------------------------------------*/
218 struct roll_tm_stats {
219  UIP_MCAST6_STATS_DATATYPE icmp_in;
220  UIP_MCAST6_STATS_DATATYPE icmp_out;
221  UIP_MCAST6_STATS_DATATYPE icmp_bad;
222 };
223 
224 #endif /* ROLL_TM_H_ */
Header file for IPv6 multicast forwarding stats maintenance