# Dynamic-RPL: Enhancing RPL-Based IoT Networks with Effective Support of Dynamic Topology Management
## 5 Design
### Dynamic Multi-DODAG Algorithm  
Figure 4 shows how the dynamic multi-DODAG algorithm works. It enables dynamic topological adjustments for optimizing an RPL network toward better performance and stability. It defines two main operations: DODAG aggregation and partitioning. The former allows two local-DODAGs to be merged into a single one (_Merge_ operation) whereas the latter enables splitting a local-DODAG into separate local-DODAGs (_Split_ operation). These  
are performed based on the positions of global-nodes within a global-DODAG in addition to certain performance and topological considerations regarding their individual local-DODAGs. The algorithm identifies the different global-nodes as global-sinks, local-sinks, and potential-sinks (non-sink-global-nodes). The algorithm can be configured to run at specific time intervals, in response to any local-DODAG updates, and upon any dynamic topological changes in the entire network. As illustrated in Figure 4, the algorithm is run using all the nodes in a global-DODAG except for certain ones such as the global-sink (_GS_). These also include any local-sink (_LS_) with its global-parent (_GP_) being a potential-sink (_PS_) or another local-sink that used to be its local-child (_Old-LC_). In addition, a local-sink having a local-child (_LC_) with external global attachment to any global-node should not also be considered. These also include a potential-sink connecting to a small-sized and stable local-DODAG (_LD-Size_). All  
Figure 4: Operational overview of the dynamic multi-DODAG algorithm. these kinds of global-nodes should be restrained from any dynamic activities in order to effectively maintain manageable and optimizable topological management. Eligible global-nodes carry out the two main operations of the algorithm based on their current status of the global-DODAG and under specific conditions regarding their local-DODAGs. Both operations can be carried out using the global-nodes unless it is a local-sink that can only run the _Merge_ operation. It is not reasonable for local-sinks to perform the _Split_ operation and disjoin their local-DODAG to establish a new one. Each eligible local-sink is left with only the aggregation decision to make based on the topological size (_LD-Size_) and current LSOF indicators (_LD-LSI_) of its local-DODAG. _LD-Size_ is basically the total number of local-nodes in the local-DODAG whereas _LD-LSI_ is periodically calculated at the sink node according to the following formula:  
\[LD\text{-}LSI=(w^{1}*FR+w^{2}*MHC+w^{3}*GRR+w^{4}*NPMR)/TN \tag{1}\]  
where \(w^{1}\)-\(w^{4}\) represent non-negative tunable weights that account for the importance of the corresponding parameters and  
* _FR_ (Forwarding Rate): the number of forwarded data packets per second;
* _MHC_ (Maximum Hop Count): the length of the longest path across a DODAG;
* _GRR_ (Global Repair Rate): the total number of initiated global repairs;
* _NPMR_ (No-Path Message Rate): the number of messages per second;
* _TN_ (Total Nodes): the total number of nodes in a DODAG. Therefore, each eligible local-sink merges its local-DODAG with one of its global-parents once two conditions are met. One is that the local-sink and its global-parent perform well as indicated with their current LSOF indicators. The other one is ensuring that merging the two local-DODAGs does not scale to a large _LD-Size_. Otherwise, the algorithm stops running without any topological adjustments. It is also held back if the local-sink has a global-parent and mergeable global-child but the performance measures indicate that the global-child is better-performing. That is, waiting for the global-child to merge would result in a better-performing aggregated-local-DODAG than the current possible one. Note that defining the limit values for _LD-LSI_ and _LD-Size_ is implementation-specific. In the case of an eligible potential-sink, it proceeds to run the algorithm unless the measurements indicate that its local-DODAG is still stable and uncongested with an under-limit size.