1 /*
2  *  Copyright (c) 2016-2023, The OpenThread Authors.
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 are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file includes compile-time configurations for Mesh Forwarder.
32  */
33 
34 #ifndef CONFIG_MESH_FORWARDER_H_
35 #define CONFIG_MESH_FORWARDER_H_
36 
37 /**
38  * @addtogroup config-mesh-forwarder
39  *
40  * @brief
41  *   This module includes configuration variables for the Mesh Forwarder.
42  *
43  * @{
44  *
45  */
46 
47 #include "config/border_router.h"
48 
49 /**
50  * @def OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
51  *
52  * Define as 1 for OpenThread to drop a message (and not send any remaining fragments of the message) if all transmit
53  * attempts fail for a fragment of the message. For a direct transmission, a failure occurs after all MAC transmission
54  * attempts for a given fragment are unsuccessful. For an indirect transmission, a failure occurs after all data poll
55  * triggered transmission attempts for a given fragment fail.
56  *
57  * If set to zero (disabled), OpenThread will attempt to send subsequent fragments, whether or not all transmission
58  * attempts fail for a given fragment.
59  *
60  */
61 #ifndef OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE
62 #define OPENTHREAD_CONFIG_DROP_MESSAGE_ON_FRAGMENT_TX_FAILURE 1
63 #endif
64 
65 /**
66  * @def OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT
67  *
68  * The reassembly timeout between 6LoWPAN fragments in seconds.
69  *
70  */
71 #ifndef OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT
72 #define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 2
73 #endif
74 
75 /**
76  * @def OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES
77  *
78  * The number of fragment priority entries.
79  *
80  */
81 #ifndef OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES
82 #define OPENTHREAD_CONFIG_NUM_FRAGMENT_PRIORITY_ENTRIES 8
83 #endif
84 
85 /**
86  * @def OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE
87  *
88  * Define to 1 to enable delay-aware queue management for the send queue.
89  *
90  * When enabled device will monitor time-in-queue of messages in the direct tx queue and if the wait time is lager than
91  * specified thresholds it may update ECN flag (if message indicates it is ECN-capable) or drop the message.
92  *
93  */
94 #ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE
95 #define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_ENABLE \
96     (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3)
97 #endif
98 
99 /**
100  * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL
101  *
102  * Specifies the time-in-queue threshold interval in milliseconds to mark ECN on a message if it is ECN-capable or
103  * drop the message if not ECN-capable.
104  *
105  */
106 #ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL
107 #define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL 500
108 #endif
109 
110 /**
111  * @OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL
112  *
113  * Specifies the time-in-queue threshold interval in milliseconds to drop a message.
114  *
115  */
116 #ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL
117 #define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_DROP_MSG_INTERVAL 1000
118 #endif
119 
120 /**
121  * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME
122  *
123  * Specifies the max retain time in seconds of a mesh header fragmentation tag entry in the list.
124  *
125  * The entry in list is used to track whether an earlier fragment of same message was dropped by the router and if so
126  * the next fragments are also dropped. The entry is removed once last fragment is processed or after the retain time
127  * specified by this config parameter expires.
128  *
129  */
130 #ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME
131 #define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_RETAIN_TIME (4 * 60) // 4 minutes
132 #endif
133 
134 /**
135  * OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE
136  *
137  * Specifies the number of mesh header fragmentation tag entries in the list for delay-aware queue management.
138  *
139  * The list is used to track whether an earlier fragment of same message was dropped by the router and if so the next
140  * fragments are also dropped.
141  *
142  */
143 #ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE
144 #define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_FRAG_TAG_ENTRY_LIST_SIZE 16
145 #endif
146 
147 /**
148  * @def OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE
149  *
150  * Specifies the maximum number of frames in direct tx queue before new direct tx messages are dropped.
151  *
152  * If set to zero then the behavior is disabled, i.e., no check is performed on tx queue length.
153  *
154  */
155 #ifndef OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE
156 #if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_3)
157 #define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 100
158 #else
159 #define OPENTHREAD_CONFIG_MAX_FRAMES_IN_DIRECT_TX_QUEUE 0
160 #endif
161 #endif
162 
163 /**
164  * @def OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE
165  *
166  * Define as 1 to enable TX queue time-in-queue statistics collection feature.
167  *
168  * When enabled, histogram of the time-in-queue of messages in the transmit queue is collected. The time-in-queue is
169  * tracked for direct transmissions only and is measured as the duration from when a message is added to the transmit
170  * queue until it is passed to the MAC layer for transmission or dropped.
171  *
172  * The histogram data consists of number of bins, each representing a range of time-in-queue values. The bin interval
173  * length is specified by the `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_BIN_INTERVAL` configuration, and the
174  * maximum tracked interval is given by the `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_MAX_INTERVAL`.
175  *
176  * Along with histogram, the maximum observed time-in-queue is also tracked.
177  *
178  */
179 #ifndef OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE
180 #define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_ENABLE (OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE && OPENTHREAD_FTD)
181 #endif
182 
183 /**
184  * @def OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_MAX_INTERVAL
185  *
186  * Specifies the maximum time-in-queue interval in milliseconds tracked by the histogram when the TX queue time-in-queue
187  * statistics collection feature is enabled.
188  *
189  * By default the `OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL` is used which defines the
190  * maximum time-in-queue interval after which a non-ECN capable message is dropped by delay-aware queue management
191  * feature.
192  *
193  */
194 #ifndef OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_MAX_INTERVAL
195 #define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_MAX_INTERVAL \
196     OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL
197 #endif
198 
199 /**
200  * @def OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_BIN_INTERVAL
201  *
202  * Specifies the time-in-queue histogram bin interval in milliseconds when the TX queue time-in-queue statistics
203  * collection feature is enabled.
204  *
205  * The number of bins is calculated by dividing `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_MAX_INTERVAL` by
206  * `OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_BIN_INTERVAL` and rounding up to the nearest integer.
207  *
208  */
209 #ifndef OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_BIN_INTERVAL
210 #define OPENTHREAD_CONFIG_TX_QUEUE_STATISTICS_HISTOGRAM_BIN_INTERVAL 10
211 #endif
212 
213 /**
214  * @}
215  *
216  */
217 
218 #endif // CONFIG_MESH_FORWARDER_H_
219