## 4 Oscar: Tsch Optimized Cell Allocation Algorithm
### Design
#### 4.1.2 Rescheduling Algorithm  
The purpose of Algorithm 1 is to grant slots to the nodes according to their requirement. We know that the nodes close to the root are those with a high traffic load. In this vision, this algorithm is part of the scheduling of these nodes and proposes to manage the number of timeslots allocated to each node using the value of the node's rank. On initialization, the rank value is extracted for each node of the network. Classes are determined based on the rank value in RPL. RPL networks introduce the concept of rank to define the individual position of a node relative to all other neighbors and relative to the root. OSCAR is characterized by the classification of nodes in 6 classes according to their rank value knowing that the rank of the root is equal to 0. Each class is delimited by rank values. Each node is assigned a class ID, representing the layer it occupies. The class ID, which ranges from 0 to 5, is set according to the distance from the root. In the OSCAR configuration presented here, any node whose rank is between 0 and 128 is in class 0. For class 1, the node rank must be between 128 and 256, class 2 between 256 and 384, class 3 between 384 and 512, and class 4 between 512 and 768. Finally, any node with a rank greater than 768 is in class 5. Therefore, nodes located in class 4 are more distant from the root compared to those located in class 2. The well-known trade-off between energy and latency has been a challenge to be taken into account when designing of OSCAR. We chose to use 6 classes because this number presented a good trade-off in terms of energy/latency balance. Depending on network topologies and traffic types, different number of classes and rank threshold couldbe configured. The timeslot allocation mechanism of OSCAR generates a timeslot schedule for the slotframe that uses the routing topology information, the Class ID and the node ID. To explain the slot allocation process, we first discuss the partitioning strategy. This is a mechanism for the distribution of timeslots over the next six slotframes. If the node belongs to class 0, it will have 6 slots on the next six slotframes. Class 1 will have five slots on the next six slotframes and so on up to the last class which will have only one slot on the six slotframes. ```
Classes definition and initialization of the current class; Input : New Class ifNewClass = CurrentClassthen  return; end ifNewClass < CurrentClassthen  Allocate_more_slots(); else  Reduce_allocated_slots(); end
```  
**Algorithm 1**Reschedule cell based on class  
When the rank changes, OSCAR allocates or removes a slot according to the new value of that rank. Therefore, by moving the node away from the root, fewer slots will be allocated. Conversely, more slots are allocated when the node is moved closer to the root. Thus, any node which changes position in the topology of the network sees its class number changed and consequently the number of slots allocated to it. The rescheduling algorithm occurs every five packets, i.e., there is a refresh of the slot allocation and the current state of the network every five packets. The Allocate_more_slots function allocates a slot according to the rank value. For example, if the node is originally located in class 5 and then ends up in class 3, the function allocates two additional time slots. The Reduce_allocated_slots function, on the other hand, removes a slot according to the value of the rank. With the same example, if the node is originally located in class 3 and then ends up in class 5, the function removes two of the added time slots. Nodes listen for any traffic in one slot, and the children maintain a transmit slot towards their parent. Therefore, with this algorithm, each Tx slot is synchronized with an Rx slot at the parent side, so that when a parent Rx slot is removed to diminish its energy consumption, the corresponding Tx children slots are also deleted. It is the parent who therefore sends a packet to all of its children to indicate that the slot is no longer available.