# Congestion Control and Traffic Differentiation for Heterogeneous 6 TiSCH Networks in IIoT
## 3 The Proposed Congestion Control Mechanism
### Detecting and Controlling Congestion
#### 3.1.2 The LB-Criterion  
As mentioned earlier, the ETX metric is insufficient for the detection of congestion in heavy traffic conditions. The small queues of the LLN nodes start to overflow before the congestion is heavy enough to degrade the ETX and be detected through the HL-criterion. In this case, \(n_{i}\) keeps transmitting to its \(P_{i}\) even if it suffers from consecutive queue losses. We introduce the LB-criterion to detect the congestion in parent nodes and change to \(P_{i}^{*}\) based on the queue occupancy information to achieve load balancing. The formulation of the LB-criterion is mainly based on the backlog factor \(BF(n_{i})\) that represents the queue occupancy of \(n_{i}\). \(BF(n_{i})\) is defined as the ratio of the number of backlogged packets in the output queue \(Q(n_{i})\) to the total queue size \(L(n_{i})\). How to set the LB-criterion and \(BF(n_{i})\) properly is illustrated as follows. When \(P_{i}\) is congested, \(BF(n_{i})\) may be much smaller than \(BF(P_{i})\) even if \(P_{i}\) suffers from queue losses; hence, \(BF(n_{i})\) cannot properly reflect congestion in this case. Furthermore, when \(BF(n_{i})\) is high, changing the parent of \(n_{i}\) would not help in load balancing, but instead, the children of \(n_{i}\) should migrate to another parent to reduce the load on \(n_{i}\). \(BF(P_{i})\) is also not a proper indicator of congestion, as when the network is balanced, each node will have low \(BF(P_{i})\); hence, the LB-criterion would not be satisfied, and parent selection would only be triggered based on the HL-criterion, causing an imbalanced network again. Therefore, we define the LB-criterion as:  
\[\max\left\{BF_{max},BF_{max}^{[m+1]}(n_{i})\right\}>\delta, \tag{6}\]  
where \(BF_{max}\) is the maximum backlog factor recognized for all parent candidates of \(n_{i}\) within the last \(m\) consecutive slotframes, \(BF_{max}^{[m+1]}(n_{i})\) is the maximum backlog factor of all parents of \(n_{i}\) in the current slotframe, and \(\delta\) is the congestion threshold. To further illustrate, the maximum backlog factor of parent nodes recorded by node \(n_{i}\) within the \(j^{\text{th}}\) slotframe is given as:  
\[BF_{max}^{[j]}(n_{i})=\max_{p_{i}\in Parent(n_{i})}\left\{BF(p_{i})\right\}.\]  
Then, \(n_{i}\) maintains these values and calculates the maximum for the recent \(m\) slotframes as follows:  
\[BF_{max}=\max_{j\in\{1,2,\ldots,m\}}\left\{BF_{max}^{[j]}(n_{i})\right\}.\]  
Finally, \(n_{i}\) uses the sliding window to update \(BF_{max}\) for every slotframe, select the maximum of these values, and compare it with the congestion threshold \(\delta\) as given in (6). The value of the number of consecutive slotframes \(m\) in (6) is a configurable parameter and is empirically selected considering the following conditions regarding the selection of its lower and upper limits. First, \(m\) is selected such that \((m\times T)>I_{min}\), where \(T\) is the duration of a slotframe and \(I_{min}\) is the minimum interval of the Trickle timer. This is because the value of \(BF_{max}^{[j]}(n_{i})\) of a node \(n_{i}\) is determined using the backlog information of its parents \(BF(p_{i})\) according to (6), and such information is propagated through the DIO messages whose interval is determined through the Trickle timer, i.e., collecting the information at least every \(I_{min}\). Moreover, the node needs to maintain a reasonable record of past congestion events in order to be more aware of the congestion situation of its parents and avoid hasty parent changes. Second, LLN nodes are resource-constrained devices that typically have limited storage capacity, and increasing \(m\) means storing more values of \(BF(p_{i})\), which might be a limitation to the node if it increases beyond a certain value. Therefore, the upper bound of \(m\) is mainly based on the available resources. Furthermore, it is pointless to increase \(m\) to store too old history of \(BF(p_{i})\). The threshold value \(0<\delta<1\) determines when to perform parent change as a result of congestion.