## 3 Methodology
### Proposed Work Flow Model
#### 3.3.2 Traffic Priority Based Load Balancing  
Despite the fact that there are many load balancing techniques in the state of the art, we have presented a typical example of IP-based multi-class traffic classification and load balancing in a multi-controller SDN environment. Traffic priority-based load balancing is different from traditional load balancing schemes, where the decision of path selection is not made only on the basis of the shortest path or load on the controller or switch but also according to the severity of traffic. The proposed load balancing Algorithm 2 is shown below. ```
1 Host starts sending traffic to another host in network
2 Obtain incoming traffic from external network
3 OVSswitches transfers unknown traffic packets from external network
4 whileTraffic Leveldo
5 ifVideothen
6 Send traffic to dedicated path1 // send the video traffic
7 ifVoicethen
8 Send traffic to dedicated path2 // send the voice traffic
9 ifdatathen
10 Send traffic to dedicated path3 // send the data traffic
11
12 Send traffic to the switch connected to the receiver host
13 Send traffic to the receiver host
14 Traffic received by receiver host
```  
**Algorithm 2**Proposed load balancing algorithm in multi-controller environment  
Each traffic type has its own path, and, when congestion occurs, the traffic with the greatest priority is shifted to another path. Other types of traffic are either passed parallelly or blocked based on the path's capacity at the time. The Simple Depth First Search (DFS) algorithm, which analyzes the topology to find the path with the minimum cost between the source IP and destination IP, is used to calculate the shortest path. Thus, using the pre-defined rules, the controller and path that satisfy the delay requirement for the specific type of traffic are then chosen. Each switch's flow table and group table are updated to handle various types of traffic separately for the purpose of allocating different paths for different types of traffic. Figure 5: Real-time Classification. Then, the intermediate switch sends the traffic to the terminal switch connected to the host, following the shortest path given by DFS from the host to the destination user. The global controller to which both local controllers, main and secondary, are connected monitors the CPU utilisation of both controllers using the get_cpu_utilisations() function. CPU UTILISATION THRESHOLD = 70 is used to set the threshold at 70%. Here, 70% of CPU utilization was arbitrarily chosen to ensure not to cross the warning level for the emulation purpose. The global controller runs on port 6633, which is the default port for the Ryu controller. The two local controllers run on ports 6634 and 6635, respectively. Using self.global_port, the local controller connects to the global controller by listening on its port. If the utilisation of the main controller exceeds the defined threshold value, i.e., 70%, the perform load balancing() function shares the classification and load balancing roles of the main controller with the secondary controller. The function send_role_request is called in order to accomplish this. Further, the global controller continues monitoring the CPU utilization of both controllers, and if the threshold on the main controller drops below 70%, the complete role of traffic classification and load balancing is redirected to the main controller, reducing the resource consumption of the second controller. The threshold for this research was chosen at random and can be adjusted by the network administrator based on the network's convenience or performance requirements. Furthermore, the performance of the proposed approach may be verified using various threshold values. The detailed flow of the controller-switching action in the case of CPU utilization exceeding the threshold is shown in Algorithm 3.