## 3 DenseNet-Hybrid Control Plane Architecture
### Control Logic Switching Algorithm
**Input**: \(current\_state\), \(CPLR\), \(S_{k-1}\), \(S_{k}\)  
**Output**: \(next\_state\)\(\triangleright\) centralized or distributed  
```
1:procedureDECIDE_STATE
2:if\(current\_state\)=centralizedthen
3:if\((CPLR<CPLR_{max})\)then
4:if\(S_{k}\leq\delta\)then\(\triangleright\) If low CPLR increasing trend
5:\(next\_state\)=centralized
6:else
7:if\(S_{k-1}>\delta\)then
8:\(next\_state\)=distributed
9:else
10:\(next\_state\)=centralized
11:endif
12:endif
13:else
14:\(next\_state\)=distributed
15:endif
16:else
17:\(next\_state\)=centralized



When in distributed operation (lines #16 et seq. ), the aim is to switch back to centralized when an improvement in network conditions is detected. This is coded in the algorithm as measuring a non-positive slope in this period (no need to wait for two periods, as above) (line #19), and the CPLR value is below the one that guarantees that the network can operate in centralized mode (\(CPLR_{max}\)) (line #20). Under other conditions, the algorithm decides that the problem persists and decides to stay in distributed mode. #### 3.3.1 Network Operation Switching: Centralized to Distributed

In the case of high loss conditions, when the CPLR of the control communication channel is increasing and the decision module detects that the CPLR curve is sloping upwards or the CPLR value reaches \(CPLR_{max}\), the switching algorithm integrated into the local agent of the nodes takes the network operation switching decision from centralized to distributed mode. In order to perform network operation switching from centralized to distributed, the following steps are followed by the local agent:

1. The _rules modifier_ module deletes the old rules, except the _flow-miss_ entry rule, from the SCS flow tables that were installed with the intervention of the SDN controller, as this rule is important while network operation is again restored to centralized mode (see Section 3.3.2). 2. The _rules modifier_ module installs new rules in the SCS flow table, which include an OpenFlow _POP_VLAN_ action, aiming to remove the VLAN tag of the incoming packets to the ingress port of a node and to forward the incoming packets to the IP forwarding engine. 3. Incoming packets arriving at the SCS ingress port are then forwarded to the IP forwarding engine via internal virtual port, in order to process the packets through the IP routing daemon. In the IP routing daemon, a distributed routing protocol (in our case, Open Shortest Path First (OSPF)) makes the policies to route packets to their intended destination and send the packets to the SCS egress port via internal virtual port (see Section 3.2.1). 4. On the other hand, the _rules modifier_ module of the local agent also updates the SCS flow table by adding another rule that pushes the VLAN tag again to the packets using an OpenFlow _PUSH_VLAN_ action before the packets leave the SCS egress port and sends the packets toward the following hop toward the destination host. All these modifications (e.g., deletion and installation) of rules in SCS flow table are performed without the intervention of the SDN controller. Whenever the network operation in the node has been switched to distributed mode, the node act as a legacy device where a distributed routing protocol (e.g., OSPF) ensures the policy making and routing of incoming packets. The SDN controller, in that case, does not have any influence over the nodes in the network because of control packet loss due to impairment in the control communication channel. #### 3.3.2 Network Operation Switching: Distributed to Centralized

During the distributed mode of operation, the module _CPLR detector_ of the local agent continues measuring the CPLR (and its slope) of the control communication channel, and when the CPLR goes below \(CPLR_{max}\) (and there is a non-increasing CPLR trend), the switching algorithm takes the network operation switching decision from distributed to centralized again. The local agent then restores centralized operation back by following the steps as follows:

1.