## 3 Proposed Mechanism
### Channel Allocation and Deallocation (CAD)  
The channel allocation and deallocation component assigns the channels for the TBs. When an overloaded channel is used by multiple TBs, CAD assigns a lightly loaded or unused channel to one of the TBs. LPMC aims to use the minimum number of channels needed to satisfy the traffic load, so it first finds a lightly loaded channel that can be allocated to the overloaded TB (_i.e._, the TB with the highest loss rate). If it does not find such a channel, then an unused channel is allocated for the overloaded TB. However, if an overloaded channel is used by only one TB, then it cannot allocate another channel to the same TB, as in LPMC, all of the nodes in a TB should use the same channel. In this case, the _path update_ component adds a new path by dividing an overloaded TB into two TBs, and assigns a new channel to one of the TBs. In contrast, if the network becomes lightly loaded after having been at an overloaded status, then it removes one or more of the added channels. The idea of removing a channel is that the unused channel can be allocated to other nodes if necessary. A static channel allocation mechanism cannot do so. More specifically, if there is a continuous source of external interference for any channel, then the delivery ratio of the nodes that use this channel will be very low. A dynamic channel allocation mechanism can easily overcome this problem. First, because the sink keeps track of the achievable data rates of individual channels, it can determine if the loss of data packets is due to some reason other than overloading and can reallocate a separate channel. Second, even if the sink cannot compare it with the maximum achievable capacity, it adds a new channel for the nodes, which at least reduces the load of the channel. Therefore, LPMC tries to shrink the number of used channels. If two or more channels are shrink, the allocation mechanism keeps the channel with the smallest id as the active channel. The channels with higher id's are removed. The CAD mechanism maintains two lists: the channel list with the fields \(<channel\_id\), \(status\), \(max\_load\), \(curr\_load\) and \(rem\_load\)\(>\), and the TB list with the fields \(<tb\_id\) and \(avg\_load\)\(>\). The \(status\) of a channel is either _used_ or _unused_. The CAD periodically obtains the average load (\(avg\_load\)) of each TB from the NLD. The current load (\(curr\_load\)) of a channel is the sum of the loads of the TBs using this channel. The maximum load (\(max\_load\)) of a channel is the highest load that has been supported by the channel so far. When a channel is overloaded, the \(max\_load\) is updated by the CAD; if the \(curr\_load\) is higher than the \(max\_load\), \(curr\_load\) becomes the \(max\_load\) of the channel. The remaining load (\(rem\_load\)) of a channel is the difference between the \(max\_load\) and \(curr\_load\). ```
1:Input: \(status[\ ]\), \(max\_load[\ ]\), \(curr\_load[\ ]\),
2:\(rem\_load[\ ]\), \(avg\_load[\ ]\)
3:ChannelAllocation (Channel \(i\)) {\(i\)-th channel is overloaded}
4:Find the no of TBs, \(N\), those use channel \(i\). 5:if\(N\leq 1\)then Call path update component and return. 6:Find the TB with maximum loss rate, \(tb\). 7:for Each used channel \(j=1\) TO \(K\), Except channel \(i\)do
8:if\(avg\_load[tb]\leq(1-\beta)\times rem\_load[j]\)then
9: Assign channel \(j\) to \(tb\) and return. 10:endfor
11:if unused channel available then assign it to \(tb\). 12:ChannelDeallocation ()
13:for Each Channel \(i=1\) TO \(K\)do
14:for Each Channel \(j=i+1\) to \(K\)do
15:if\(curr\_load[i]\) + \(curr\_load[j]\leq\) (1-\(\beta\)) \(\times\)\(max\_load[i]\)then
16: Assign Channel \(i\) to the TBs using Channel \(j\)
17:\(curr\_load[i]\) += \(curr\_load[j]\)
18:\(status[j]\) = \(unused\)
19:endif
20:endfor
21:endfor
```  
**Algorithm 1** Channel Allocation and Deallocation (CAD)  
Algorithm 1 shows the detailed operation of CAD. The NLD component notifies the CAD about an overloaded channel.