## 7 Superframe Duration Allocation Schemes
### Proportional Allocation Scheme Based on the Number of Nodes  
We also propose a _proportional Superframe Duration Allocation_ scheme based on the number of descendant nodes (**Nodes-SDA**), which proportionally allocates a superframe duration for each cluster without considering the load imposed by each of its descendant nodes. Differently to the Load-SDA scheme, this allocation scheme is suitable for applications where the load imposed by each cluster is unknown. The Nodes-SDA scheme is described in Algorithm 2.  
```
// Step 1: define the beacon Interval (\(BI\)) if\((Scheduling\) Scheme = Bottom-\(Up\))then \(BI\leq P_{min}-\delta_{i}\); end if else \(BI\leq\frac{P_{min}-\delta_{i}}{depth_{MAX}}\); end if // Step 2: define the capacity \(X\) of the \(SD_{min}\) \(X\) = number of messages transferred during \(SD_{min}\) (Equation (27)); // Step 3: define the Superframe Duration for each cluster for\(j\): \(=1\) to \(N_{CH}\)do  Compute \(N\) for \(CH_{j}\) based on Equation (32);  Compute \(SD_{j}\) for \(CH_{j}\) based on Equation (35); end if // Step 4: test the Protocol Constraint  Compute the Protocol Constraint based on Equation (10); if\((Protocol\) Constraint is not satisfied)then  System is not schedulable; end if // Step 5: test the Timing Constraint for\(j\): \(=1\) to \(m\)do  Compute the Timing Constraint based on Equations (25) and (26); if\((Timing\) Constraint is not satisfied)then  Message Stream Configuration or Network Parameters are not adequate for the System;  end if  end while
```  
**Algorithm 2**Nodes-SDA Algorithm  
The first and second steps of the Nodes-SDA algorithm are similar to Load-SDA algorithm. The Beacon Interval and the number \(X\) of messages transferred during the minimum superframe duration \(SD_{min}\) are defined according to Equations (10) and (27) (lines 1-7 in Algorithm 2). Thus, to define \(SD_{j}\) for cluster-head \(CH_{j}\), the Nodes-SDA algorithm just considers the number \(N\) of hierarchically descendant nodes below the analysed cluster-head (step 3 in Algorithm 1, line 10), including its child nodes and the accumulated child nodes of each child cluster-head:  
\[N=\sum_{S_{i}\in S_{below}}1,\quad\text{for }1\leq i\leq M \tag{32}\]From Equations (27) and (32), the algorithm defines the necessary number of \(SD_{min}\) to guarantee the message stream traffic. Thus, we have:  
\[SD_{j}=\left\lceil\frac{N}{X}\right\rceil\times SD_{min} \tag{33}\]  
Following the constraints imposed by Equation (6), it follows that:  
\[SD_{j}=\alpha\times 2^{SO_{j}} \tag{34}\]  
From Equations (33) and (34), to define the superframe duration (\(SD_{j}\)) for cluster-head \(CH_{j}\) (step 3 in Algorithm 2, line 11), we derive the following equation to evaluate its respective superframe order (\(SO_{j}\)):  
\[\begin{split}\alpha\times 2^{SO_{j}}&=\left\lceil \frac{N}{X}\right\rceil\times\alpha\times 2^{0}\\ SO_{j}&=\left\lceil\log_{2}\left(\left\lceil \frac{N}{X}\right\rceil\right)\right\rceil\end{split} \tag{35}\]  
Finally, both the protocol and timing constraints (Equations (10) and (26)) must be verified (steps 4 and 5 in Algorithm 1, lines 12-20).  
As Nodes-SDA scheme allocates superframe durations based just on the number of nodes, it may over-allocate durations for cluster-heads with lower message loads. This way, Nodes-SDA commonly allocated a larger sum of superframe durations, when compared to Load-SDA.