# Dynamic-RPL: Enhancing RPL-Based IoT Networks with Effective Support of Dynamic Topology Management
## 5 Design
### Dynamic Multi-DODAG Algorithm
The decision is made using the algorithm to carry out the _Split_ operation if any of three conditions are met. First, the potential-sink has a global-child and globally attaches to another potential-sink locally connected to another local-DODAG. Second, the current _LD-LS-Index_ calculations indicate that merging with its global-parent would result in unacceptable local-DODAG performance. Third, the merging movement would lead to an over-sized local-DODAG. Otherwise, it ceases the _Split_ operation and decides for merging its sub-DODAG with one of its global-parents. The algorithm ensures that a multi-DODAG network is always kept enhanced from the topological and performance perspective. It also works effectively when the network has its local-instance with a single local-DODAG. In this case, the network contains only a single local-sink, which becomes the global-sink of the global-DODAG. All the level-1 non-sink nodes then become potential-sinks attaching to the global-sink. These global-nodes are the only nodes being attached to the global-DODAG while the local-DODAG is connecting all the nodes in the network. This setup is maintained as long as the network is under-sized with a stable and non-congested topology. Otherwise, the algorithm would enforce one or more potential-sinks to perform the _Split_ operation. It causes the local-DODAG to be split into two or more separate local-DODAGs to rectify the situation. It is evident that the algorithm adds much to the flexibility and efficiency of RPL networks against challenging network conditions. A global-node initiates a dynamic operation by first detaching from its current local-DODAG. The RPL specification specifies how a node poisons its DODAG to initiate the detach process. This is achieved by advertising INFINITE_RANK in its DIO messages to force the recipients to disjoin the DODAG and find alternative parent nodes. The same procedure is adopted for the algorithm operations with a slight modification. Instead of disjoining their current parent nodes, the recipients maintain their parent associations and wait for their parents to complete the operation. The global-node first sends a DIO message with INFINITE_RANK and a special flag indicating that this is a dynamic poisoning. Once received, the recipient clears the state of its current local-DODAG and waits for further DIO messages from their current local-parents. In the case of a _Split_ operation, the global-node then detaches from its current local-DODAG and initiates a new local-DODAG. It acts as the local-sink of the newly initiated local-DODAG and broadcasts local-DIO messages with new DODAG initiation information. These messages cause the recipients to reattach again and join the new local-DODAG. The _Merge_ operation is also initiated following the same poisoning procedure but without initiating a new local-DODAG. Instead, the merging global-node attaches to its global-parent and starts forwarding the local-DIO messages being received. This enables the recipients to complete the merging operation by attaching to their local-parents again and joining the merged local-DODAG.