# Traffic Aware Scheduler for Time-Slotted Channel-Hopping-Based IPv6 Wireless Sensor Networks
## 4 Design of the Subtree-Size and Traffic Aware Scheduler
### Initialization Phase  
This phase overlaps with the building of the RPL DODAG. The steps of the initialization phase can be visualized in Figure 4. At the start of the network's formation, each node is allocated one Rx cell. The time slot offset is computed based on the node's characteristics with the help of a hashing function (Figure 4a). When nodes choose a new parent, one Tx cell is allocated, with the time slot offset computed based on the parent's characteristics (Figure 4b). Nodes are informed when a new child is added, and a Tx cell is allocated, with the time slot offset computed based on the child's characteristics (Figure 4c). In all steps, the channel offset is computed based on the characteristics of the node. When nodes send messages, a new channel offset is computed, now based on the characteristics of the receiver. Up to this point, the functioning of our scheduler is identical to RBS Orchestra.  
In our implementation, the root node keeps track of the subtree size of all its children. As a reminder, the root's children subtree size is further used to determine the number of additional cells allocated for each child of the root. Knowing the children's subtree sizes is not immediate. Since RPL is in storing mode, we can use the DAO messages to piggyback the subtree size. DAO messages are sent in response to DIO messages whenever a child chooses a parent. In the storing mode, DAO messages are sent to the parent. Upon receiving a DAO message, the parent adds a new entry in the routing table with information about the new node. The DAO message is forwarded to the parent's ancestors, including the root. Whenever the root receives DAO messages from its children, it extracts and stores the subtree size information. The _Reserved_ field in the DAO message is used to piggyback the subtree size. This field is normally set to zero and ignored by the receiver. By changing this specific field, we do not hamper the flow of the RPL control messages exchange and the building of the DODAG.  
The root node receives through the DAO messages information about all the nodes in the network. We are only interested in the subtree size of the children of the root, and therefore we check the _target prefix_ field in the RPL target option of the DAO message to know to which node the information belongs to. Figure 5 illustrates the structure of a DAO message (Figure 5a) and the RPL target option (Figure 5b).  
At the end of this phase, the RPL tree is formed, cells for unicast traffic are allocated for all nodes in the network based on the principles of RBS Orchestra, and the root node keeps a list of all its children and their subtree size. By using the DAO message to inform the root about the subtree size of its children, we ensure that the information is kept up to  
Figure 4: Initialization phase: allocation of Rx and Tx slots. (**a**) Initialization phase step 1: Rx slots are allocated for each node. (**b**) Initialization phase step 2: Tx slots are allocated for children to communicate with parent. (**c**) Initialization phase step 3: Tx slots are allocated for the parent to communicate with children.  
date. Whenever there is a change in the network DAO messages are sent upward to inform the parents and ancestors about the changes.