1 Introduction

In the last few years, following the rapid progression of hardware and software, Internet users significantly increased [1]. As a result of this leap, the amount of data traffics remarkably increased, which requires the management, controlling, and upgrading of the foundational and infrastructure systems to fulfill the Internet's current demands [2,3,4]. Software-defined networks (SDN) is among the most popular technologies, transforming the traditional networking infrastructure into more adaptable, agile, flexible, and manageable network topologies [5, 6].

A software-defined network is an attention-grabbing network paradigm that decouples the control plane from the data plane in network switches [7, 8]. In this framework, control procedures are disconnected from the data plane and address to the external device, named controller [9, 10]. Therefore, developers are enabled to propose new algorithms on the SDN controller, which could manage the network and change its performance [11]. Figure 1 represents the three planes of SDN architecture, namely management, control, and data planes.

Fig. 1
figure 1

The architecture of software-defined networks [24]

Switches exist in the data plane controllers, and management defines the plane policies and rules [12]. The controller controls and manages the traffic of the network [8]. The switches' data in the network is sent to the corresponding controller for further switching of the processing [13]. The controllers in the software-defined networks manage and control the available switches' data streams by installing new flow rules and policies on them [14, 15]. However, especially in large-scale networks, a single controller may not be possible for a trade-off among the factors.

Furthermore, the performance of a single controller of SDN has many limitations. Consequently, using multiple controllers is a promising strategy to alleviate many factors such as reliability, resiliency, scalability, availability, minimum latency, and load balancing in a large-scale network [16,17,18,19]. One of the particularly vital issues in the SDN framework with multiple controllers is the controller placement problem (CPP) [20]. The controller placement problem involves two fields: the optimal number of controllers to be deployed in SDN, and these controllers' locations [21]. These characteristics affect the functionality of the network. The controller placement problem has been defined as an NP‐hard problem [22]. It shows the number of required controllers to address the controllers' traffic loads and their location in the SDN cost-effectively. According to a series of factors, each switch would be linked to one of the SDN controllers [23].

Nature-inspired meta-heuristic algorithms are the utmost innovative and efficient approaches in solving complex real-world problems [25,26,27,28]. These algorithms have been applied to various problems and achieved promising results. Equilibrium Optimizer [29], Black Widow Optimization Algorithm [30], Seagull Optimization Algorithm [31], Deer Hunting Optimization Algorithm [32], Shuffled Shepherd Optimization [33], and Barnacles Mating Optimizer [34] are instances of the newly-developed meta-heuristic optimization algorithms. In the scope of software-defined networks, these algorithms have been utilized in numerous aspects embracing security, load balancing, routing, switch migration, etc. [15, 35,36,37,38,39,40,41]. Various solutions have been proposed for the controller placement problem based on optimization algorithms described in Sect. 2.

In the present paper, a novel meta-heuristic-based algorithm was proposed for controller placement in a software-defined network, which could provide dynamic load balancing and latency. In the proposed controller placement algorithm, the propagation latency between controllers and switches, dynamic traffic load, and linking switches to the best suitable controller were considered. The propagation latency in the SDN network was a critical factor since it affects network proficiency, especially in a large-scale network.

The critical contributions of this paper are as follows:

  • The MRFO was innovatively discretized.

  • The SSA was solitarily discretized.

  • The discrete SSA and MRFO algorithms were hybridized using a multi-swarming concept.

  • The greedy selection mechanism was employed in the resulting discrete hybrid algorithm.

  • The proposed algorithm was applied to the CCP problem.

  • Dijkstra’s algorithm was embedded in the proposed algorithm to find the shortest routes between network switches.

  • The Haversine formula was utilized to calculate the distance between the switches.

  • The proposed controller placement algorithm was assessed on six real-world software-defined networks.

  • The results of the proposed algorithm were compared with the state-of-the-art meta-heuristic-based algorithms.

The rest of the present paper is organized as follows: Sect. 2 is devoted to the related works. In Sect. 3, the background algorithms comprising SSA, MRFO, and Dijkstra’s shortest path algorithms are described. In Sect. 4, the proposed controllers' placement algorithm is provided in detail for solving the CPP. Section 5 presents the extensive conducted experiments to evaluate the performance of the proposed algorithm. Section 6 gives the conclusions and future perspectives.

2 Related work

Extensive amounts of effort have been dedicated to the controller placement in software-defined networks, summarized in Table 1. Some of the studies have been presented in this section. In [42], Ateya et al. proposed a meta-heuristic algorithm based on the chaotic Salp Swarm Optimization Algorithm (SSOA) for improving the optimizer performance. It dynamically determines the optimal number of controllers and the optimal paths between switches and the determined controllers in the large scale SDNs. This scheme was compared in various scenarios with other linear and metaheuristic algorithms for several real topologies obtained from the zoo topology. Their proposed method has brought improvements in terms of network latency and reliability. However, various network metrics such as latency, deployment cost, and system utilization have been considered in the present method, which requires more powerful hardware and higher running time. Additionally, to calculate the deployment cost, there was a requirement for more complex datasets and multiple assumptions (which may lose their accuracy over time). Therefore, the computational complexity was high, and the precision could be conditional.

Table 1 State-of-the-art of the controller placement in software-defined networks

In [43], Gao et al. introduced a new algorithm for the controller placement problem in SDNs. The introduced algorithm considered controllers with capacity limitation, latency between controllers, and the latency between switches and controllers. In this scheme, a meta-heuristic algorithm was proposed based on the PSO algorithm for solving the problem, and the global latency is defined. Experiments showed that although the proposed algorithm minimized propagation latency, the controllers' Fixative traffic load was ignored. Besides, in the present paper, the problem and the discretizing approach was not apparent. Additionally, their proposed method was presented for the capacitated SDN networks.

In the controller placement approach provided by Hu et al. in [44], the focus was on defining the controllers' place for a distributed control plane to save SDN's energy. That is formulated as a binary integer program (BIP). In this model, the network's energy consumption that serves for the control traffic was reduced by a load of controllers and delay of control paths. Based on the high complexity of the BIP in wide-scale networks, the proposed IGCPA was an improved genetic controller placement algorithm, which is used to find an efficient sub-optimal solution for the power-aware CPP. The results indicated that IGCPA was close to that of the optimal solution. However, they did not consider the energy-aware issue on the data forwarding plane for a complete energy-aware SDN. Moreover, their method is still extensively complicated on large-scale networks.

In addition, in [45], Liyanage et al. presented a new hierarchically distributed Software-Defined Vehicular Network (HD-SDVN) framework with a controller placement problem to optimize the placement of the controllers regarding the delaying limitation in VANET. The framework divides the control plane into the top level, deployed on the Internet, and the bottom level, deployed at the Road Side Unit (RSU) level. Incorporating the existing SDVN framework and conventional Vehicular Ad-hoc Network (VANET), they indicated that their controller placement scheme could cause a lower latency than other possible controller placement schemes. The presented a scheme that obtained fair results concerning latency and workload in regional networks. Besides, various delays (transmission delay, queuing delay, contention delay, processing delay, propagation delay) are calculated in the presented paper, which is not necessarily required to be calculated all-in-one. Therefore, it could be deduced that the presented algorithm consumes a significant amount of time on calculating these delays.

Furthermore, in [46], Singh et al. have addressed controller placement in SDN by developing a new optimization algorithm named Varna-Based Optimization (VBO) to solve the capacitated controller placement problem. They analyzed the solution based on the optimization and clustering concept for CPP. Their simulation results indicated that the solution based on the optimization had better results than the clustering one, which minimized SDN's overall average latency. Its convergence rate was better than PSO, TLBO, and Jaya algorithms. Also, VBO classified particles just in two classes, where each class had a specific task and could be dynamically enhanced by changing the number of classes during generations. The proposed method had various superiorities over previous methods; however, it was not usable for all SDN networks and was provided for capacitated networks.

Besides, an approach is proposed by Wang et al. in [47] to minimize latency between controllers and their switches. They estimated qualitatively by considering the total latency between switches and controllers. They also proposed a partition method based on clustering to partition a network into subnetworks to decrease the end-to-end latency and the queuing latency of controllers. This algorithm ensured that each partition could minimize the maximum end-to-end delay between switches and controllers. Multiple controllers are proposed to be established into each subnetwork to reduce queuing latency by extreme packet requests from switches. A series of simulations were conducted using two real-world topologies from the Zoo Topology to analyze the proposed algorithm’s performance. The simulation results showed that the overall latency decreased by multiple controllers deployed in subnetworks compared with K-center and K-means. The proposed algorithm was applied to only two networks, making it irritable to evaluate the algorithm's performance accurately.

Moreover, in [48], Wang et al. presented a routing-based algorithm to solve the controllers' load balancing problem in a software-defined network. They considered an effective mechanism for network status maintenance between distributed controllers to increase their algorithm's performance and analyzing the estimation performance. The simulation results showed that although their proposed algorithm could not decrease link load balancing performance, compared with the multi-thread successor of the NOX (NOX-MT) solution, it could decrease the maximum controller response time by 70% [55]. The proposed algorithm could find proper controller placement to decrease the response time and balance the network load; however, the present paper's main focus was on the routing concept. Therefore, the experiments were mainly conducted concerning the link load, and little attention has been paid to other network parameters.

Furthermore, Singh et al. developed a novel optimization algorithm called varna-based optimization (VBO) in [46] and used it to solve the SDN controller placement problem. The proposed algorithm's main goal was to minimize average network latency, defined as the VBO algorithm's objective. They evaluated the proposed algorithm on Internet2 and Savvis SDN networks, and the experimental results showed the superiority of the proposed algorithm. The proposed algorithm minimized the average network latency and had low complexity; however, the experiments were insubstantial. Additionally, the algorithm was applied to only two networks and did not compare with state-of-the-art algorithms accurately. Besides, the discretizing method and operators were not transparent, and the complexity was not discussed.

Moreover, in [11], Moradi et al. proposed a new controller placement algorithm based on iterated local search for SDN networks. In the proposed algorithm, network deployment costs, including installing the controllers, connecting switches to the controllers, and connecting controllers to other controllers, were considered objective. Also, the local search was used to find better solutions by searching the neighbors. The proposed algorithm was compared with CPLEX and SCIP solvers. Furthermore, the performance of the algorithms was evaluated on several random networks on a \(20\times 20\) grid. The results demonstrated that the proposed algorithm was computationally efficient. In the proposed algorithm, there was a vacancy for the meta-heuristic algorithm. Furthermore, the proposed method was only tested on small networks and compared with a few algorithms.

Besides, in [21], Schütz and Martins suggested an approach to find optimal places for SDN controllers. The suggested algorithm constrained propagation latency and controller capacity. Also, it able to find the minimum number of controllers and their locations. Once the controller's optimal number and location were found, the suggested algorithm connected to a controller and balanced the controllers' load. The suggested algorithm was evaluated on fifteen SDN network and balanced the load better than competitor algorithms. Besides, it considered crucial network parameters such as latency, capacity, and load balance. It used a heuristic approach to find optimal places; however, there was a lack of investigation into the impact of using meta-heuristic algorithms in this study. Since further improvements could be achieved by using meta-heuristic algorithms.

Furthermore, in [52], Sahoo et al. provided a novel controller placement algorithm for SDN networks. The provided algorithm supplied a seamless backup technique against single link failure, minimizing communication delay using survivability. The particle swarm optimization and Firefly algorithm were used in the provided algorithm to achieve the targets mentioned above. Also, latency between controllers, latency between switches and controllers, and multi-path connectivity between the switches and controllers were taken into accounts in the provided algorithm. The performance of the provided algorithms was evaluated on a set of publicly SDN networks. The experimental results showed that the provided algorithm improved the control path's survivability and the network's performance effectively. The proposed algorithm used a hybrid meta-heuristic optimization algorithm to solve the CPP problem, bringing significant advantages. Furthermore, the proposed method was evaluated by various SDN networks that tested the algorithm's performance more accurately. Nevertheless, the optimization algorithms used in this paper (PSO and FFA) were old ones that might not be efficient for today's problems. The use of newer optimization algorithms, newer improvement methods, newer combining approaches, etc., would increase the algorithm's efficiency. Moreover, another predicament of this paper was that the proposed algorithm was compared with a small number of algorithms, which could not correctly show the superiority of the proposed algorithm.

Additionally, Jalili et al. presented a novel controller placement algorithm using NSGA-II for large-scale software-defined networks [53]. In the presented algorithm, maximum and average latencies and load balancing on controllers were considered objective functions. Several networks from the Topology Zoo evaluated the presented algorithm, and the obtained results demonstrated the superiority of the presented algorithm over the other similar algorithms. The presented multi-objective controller placement algorithm optimized the latency and balanced controllers’ load using NSGA-II. The inverted generational distance (IGD) metric was also used to evaluate the Pareto Front obtained by the algorithms. Nonetheless, the NSGA-II algorithm was older, and newer multi-objective algorithms could be used instead. The Pareto Front obtained by the proposed algorithm and the competitor algorithms did not plot and compared efficiently. Moreover, although the proposed algorithm was applied to several SDN networks, it was compared with PSA and PSO algorithms, which did not accurately express the proposed algorithm's possible superiority.

Moreover, in [54], Tahmasebi et al. suggested a novel synchronization-aware controller placement algorithm for WSN networks to optimize network performance. The optimization process was done in the suggested algorithm using the cuckoo search algorithm, which is a meta-heuristic optimization algorithm. The performance of the suggested algorithm was evaluated by comparing it with simulated annealing and quantum annealing algorithms. The results of the comparisons demonstrated that the suggested algorithm outperformed competitor algorithms. In the proposed algorithm, various network metrics were considered. The method's overall complexity and reliability were good; however, it was applied to the WSN networks. The proposed algorithm could apply to SDN networks with some modifications, and the newer meta-heuristic algorithm could be employed instead of the Cuckoo search algorithm.

Additionally, Nasiri and Derakhshan investigated the SDN networks and presented a novel greedy method to discover an optimal way to embed offline VNE into OpenFlow networks and manage communications between the virtual controllers and switches [56]. In the presented paper, various metrics such as node capacity, link capacity, revenue, cost, latency, CPU, and bandwidth resources were considered. The performance of the presented method was investigated in different environments regarding revenue, cost, and delay.

In this paper's presented method, most-recently developed powerful algorithms (MRFO and SSA) were recruited, and the simplicity and low complexity were the authors' priorities. Furthermore, the presented paper provides a comprehensive approach for all kinds of SDN networks rather than a specific network range. Therefore, the proposed algorithm was applied to various SDN networks in terms of its comprehensiveness and to evaluate the algorithm's reliability. The networks were selected from real-world SDN networks (Topology Zoo) with different sizes (small- and large-scales). Afterward, the proposed algorithm was compared with various neoteric meta-heuristic-based controller placement algorithms to demonstrate the algorithm's superiority.

3 Research background

3.1 Manta ray foraging optimization algorithm

Manta ray foraging optimization (MRFO) is a novel bio-inspired optimization algorithm inspired by manta rays' intelligent behaviors in nature [57]. MRFO was developed to solve various optimization problems and was composed of three phases: chain foraging, cyclone foraging, and somersault foraging. These phases model the behaviors of the manta rays mathematically and are described as follows.

3.1.1 Chain foraging

This phase of the algorithm models the observation and movement of the mana rays toward plankton. Manta Rays line up head-to-tail and form a foraging chain. The chain was modeled as below:

$$ X_{i}^{d} (t + 1) = \left\{ {\begin{array}{*{20}c} {X_{i}^{d} (t) + r.(X_{{best}}^{d} (t) - X_{i}^{d} (t)) + \alpha .(X_{{best}}^{d} (t) - X_{i}^{d} (t))\quad i = 1} \\ {X_{i}^{d} (t) + r.(X_{{i - 1}}^{d} (t) - X_{i}^{d} (t)) + \alpha .(X_{{best}}^{d} (t) - X_{i}^{d} (t))\quad \;i = 2 \ldots .N} \\ \end{array} } \right. $$
(1)

where, \({X}_{i}^{d}\) is the position of \(i\)th manta ray, t indicates time, \(d\) is the dimension, \(r\) is a vector with random numbers in [0, 1], \({X}_{best}^{d}(t)\) is the plankton with a high concentration in time \(t\), and \(a\) is a weight coefficient which was calculated as follow:

$$\alpha =2.r.\sqrt{\left|log(r)\right|}$$
(2)

3.1.2 Cyclone foraging

This phase models the long foraging chain of the manta rays formed to swim toward the food by a spiral. This foraging chain was similar to the foraging strategy of the Whale optimization algorithm [58]. However, in the cyclone foraging strategy, each manta ray swims toward the one in front of it using the manta rays' spiral movements. A manta ray moves toward one of the fronts-lines and moves toward the food along a spiral path. Equation (3) models this behavior of the manta rays mathematically.

$$ X_{i}^{d} (t + 1) = \left\{ {\begin{array}{*{20}c} {X_{{best}}^{d} + r.(X_{{best}}^{d} (t) - X_{i}^{d} (t)) + \beta .(X_{{best}}^{d} (t) - X_{i}^{d} (t))\quad i = 1} \\ {X_{{best}}^{d} (t) + r.(X_{{i - 1}}^{d} (t) - X_{i}^{d} (t)) + \beta .(X_{{best}}^{d} (t) - X_{i}^{d} (t))\quad i = 2 \ldots .N} \\ \end{array} } \right. $$
(3)

where \(T\) is the maximum number of iterations, and \(\beta \) is the weight coefficient that could be defined as below:

$$\beta =2{e}^{{r}_{1}\frac{T-t+1}{T}}*sin(2\pi {r}_{1})$$
(4)

where \({r}_{1}\) in a random number in [0,1].

This cyclone foraging strategy has excellent exploitation for a part of the search space that the plankton is in it, as the manta rays search the problem space concerning the food. The manta rays are forced to search for new positions far from the current best manta ray to increase the exploration. In MRFO, this is modeled by assigning a new random position in the problem search to the manta rays as their reference position. The following equation mathematically models this strategy:

$$ X_{i}^{d} (t + 1) = \left\{ {\begin{array}{*{20}c} {X_{{rand}}^{d} + r.(X_{{rand}}^{d} (t) - X_{i}^{d} (t)) + \beta .(X_{{rand}}^{d} (t) - X_{i}^{d} (t))\quad i = 1} \\ {X_{{rand}}^{d} (t) + r.(X_{{i - 1}}^{d} (t) - X_{i}^{d} (t)) + \beta .(X_{{rand}}^{d} (t) - X_{i}^{d} (t))\quad i = 2 \ldots .N} \\ \end{array} } \right. $$
(5)

where Xrand in a random position in the search space and is produced as follow:

$${X}_{rand}^{d}= {lb}^{d}+r.({ub}^{d}-{lb}^{d})$$
(6)

where \(lb\) and \(ub\) are the lower and upper bounds of the search space, respectively.

3.1.3 Somersault foraging

In this phase, the best previously discovered individual was considered a pivot, and the manta rays update their position by swimming and turning around the pivot. Therefore, this phase increases the exploitation capability of the MRFO. Equation (7) models this behavior of the manta rays mathematically.

$${X}_{i}^{d}(t+1) = {X}_{i}^{d}(t) + S.({{r}_{2}.X}_{best}^{d}(t)-{r}_{3}.{X}_{i}^{d}(t)) + \beta .({X}_{rand}^{d}(t)-{X}_{i}^{d}(t)) i=1\dots .N$$
(7)

where \(S\) is the somersault factor, which decides the somersault range of manta rays, \({r}_{2}\) and \({r}_{3}\) are random numbers between \([\mathrm{0,1}]\).

The flowchart of MRFO is illustrated in Fig. 2.

Fig. 2
figure 2

Flowchart of the MRFO algorithm

3.2 SSA algorithm

Salp swarm algorithm (SSA) is a robust nature-inspired optimization algorithm developed by Mir Jalili et al. in [59]. SSA has very low complexity and is inspired by the Salp chain's two foraging behaviors in nature. The salps are very similar to jellyfish and use water to move toward food. In SSA, the salp swarm divides into two groups: leader and followers. The leader is at the front of the chain and guides the swarm. The remaining salps in the swarm were considered as followers. The leader in the swarm updates its position using Eq. (8).

$$ X_{1}^{j} = \left\{ {\begin{array}{*{20}c} \begin{gathered} X_{{best}}^{j} + c_{1} (c_{2} .(ub^{j} - lb^{j} ) + lb^{j} ) \hfill \\ X_{{best}}^{j} + c_{1} (c_{2} .(ub^{j} - lb^{j} ) + lb^{j} ) \hfill \\ \end{gathered} & \begin{gathered} c_{3} \ge 0 \hfill \\ c_{3} < 0 \hfill \\ \end{gathered} \\ \end{array} } \right. $$
(8)

where \({X}_{1}^{j}\) is the \(j\)th dimension of the leader, Xbest in the position of the best solution that is found so far, \({c}_{2}\) and \({c}_{3}\) are random numbers in \([\mathrm{0,1}]\), and \({c}_{1}\) balances exploration and exploitation and was calculated as follow:

$${c}_{1}={2e}^{{-(\frac{t}{T})}^{2}}$$
(9)

where \(t\) and \(T\) are the current and maximum number of iterations, the follower salps update their positions using Eq. 10.

$${X}_{i}^{j}=\frac{1}{2}({X}_{i}^{j}-{X}_{i-1}^{j})$$
(10)

where \({X}_{i}^{j}\) is the \(j\)th dimension of the \(i\)th salp and \(i>1\). Figure 3 shows the flowcharts of SSA.

Fig. 3
figure 3

Flowchart of the SSA algorithm

4 Proposed controller placement solution

As mentioned in previous sections, controller placement is one of the most critical issues in SDN networks. By selecting the appropriate number of controllers and their locations, the network delay could be significantly reduced, and the network load could be distributed. In the current paper, a new method was proposed for selecting the controllers' optimal location by using MRFO and SSA optimization algorithms, which were discretized in a novel way. The controller placement algorithm proposed in the present paper consists of several pieces described in detail in the following subsections.

4.1 Discrete MRFO algorithm

Even though the basic Manta ray foraging optimization algorithm is suitable for solving continuous problems, the controller placement problem is discrete. Therefore, in the present paper, MRFO was modified by two new operators to solve discrete problems. For this purpose, Eq. (1) was replaced by a two-point swap operator with \({X}_{i}\) and \({X}_{best}\) as ins inputs. It is worth mentioning that the order of the inputs is significant, and by exchanging the order of input solutions, the results will be changed significantly. The pseudocode of the two-point swap operator is presented in Fig. 4.

Fig. 4
figure 4

Pseudocode of the two-point swap operator

In Fig. 4, \(SP1\) and \(SP2\) are swap points that were selected randomly. Figure 5 illustrates the results of the two-point swap operator.

Fig. 5
figure 5

Two-point swap operator

In Fig. 5, the values of \(SP1\) and \(SP2\) are 2 and 5, respectively. Besides, Eq. (3) was replaced with the two-point swap operator with \({X}_{best}\) and \({X}_{i}\) as its inputs. Furthermore, Eq. (5) was replaced by a random insert operator. The pseudocode of this new operator was presented in Fig. 6. The function of the random insert operator is illustrated in Fig. 7.

Fig. 6
figure 6

Pseudocode of the random insert operator

Fig. 7
figure 7

Random insert operator

In Fig. 6, \(NC\) is the number of controllers, \(RN\) is a random integer number between \([1 \mathrm{NC}]\), \(\overrightarrow{RP}\) is a vector with random numbers in \([1 \mathrm{NC}]\), and \(randperm\) generates a vector with \(RN\) random integer numbers in \([1 \mathrm{NP}].\)

In Fig. 7, \(NC\) is 6, \(RN\) is 3, \(\overrightarrow{RP}\) is \([\mathrm{2,3},5]\), and as it can be observed clearly in the figure, the points 2,3 and 5 are replaced with random indices. Additionally, Eq. (7) was replaced by Eq. (11).

$$ X_{i}^{j} = \left\{ {\begin{array}{*{20}c} \begin{gathered} X_{{best}}^{j} \hfill \\ X_{r}^{j} \hfill \\ \end{gathered} & \begin{gathered} R < {1 \mathord{\left/ {\vphantom {1 3}} \right. \kern-\nulldelimiterspace} 3} \hfill \\ {1 \mathord{\left/ {\vphantom {1 3}} \right. \kern-\nulldelimiterspace} 3} < R < {2 \mathord{\left/ {\vphantom {2 3}} \right. \kern-\nulldelimiterspace} 3} \hfill \\ \end{gathered} \\ {RI} & {{2 \mathord{\left/ {\vphantom {2 3}} \right. \kern-\nulldelimiterspace} 3} < R < 1} \\ \end{array} } \right. $$
(11)

where \(R\) is a random number in \([\mathrm{0,1}]\), Xr is a randomly chosen solution from the current swarm, and \(RI\) is a random index. Figure 8 depicts the pseudocode of the proposed discrete MRFO.

Fig. 8
figure 8

Pseudocode of the proposed discrete Manta ray foraging optimization algorithm

4.2 Discrete salp swarm algorithm

Like the MRFO, the SSA algorithm is a continuous algorithm designed to solve continuous problems. This subsection presents the proposed discrete SSA algorithm. In the literature, discrete versions of the SSA algorithm have been proposed by scholars [42, 60, 61]; however, the presented discrete version in this paper is a novel method that has not been tapped before. For this purpose, Eq. (8) was replaced by Eq. (12).

$$ X_{i}^{j} = \left\{ {\begin{array}{*{20}c} {X_{r}^{j} } & {if\;c3 > 0.5} \\ {X_{{best}}^{j} } & {otherwise} \\ \end{array} } \right. $$
(12)

where \(c3\) is a random number in \([\mathrm{0,1}].\)

Moreover, Eq. (10) was replaced by the half points crossover operator. Figure 9 presents the pseudocode of the half points crossover operator.

Fig. 9
figure 9

Pseudocode of the proposed half points crossover operator

The function of the half points crossover operator is shown in Fig. 10. In this figure, \(NC\) is 6, \(HP\) is 3, \(CP1\) is [1, 2, 5], and \(CP2\) is [2, 4, 5]. The pseudocode of the proposed discrete SSA algorithm is provided in Fig. 11.

Fig. 10
figure 10

Half points crossover operator

Fig. 11
figure 11

Pseudocode of the proposed discrete SSA algorithm

4.3 Dijkstra’s shortest path algorithm

In the proposed algorithm, Dijkstra’s shortest path algorithm was used to find the shortest path between switches in the SDN. The pseudocode of Dijkstra’s shortest path algorithm is provided in Fig. 12 [62].

Fig. 12
figure 12

Dijkstra’s shortest path algorithm

It should also be mentioned that the position of SDN switches was expressed based on latitude and longitude. Therefore, a particular mechanism was needed to find the distance between the switches in kilometers. Various methods, such as cosine-haversine formula [63], Pythagorean theorem [64, 65], low of cosines [66], etc., were proposed to calculate the distance between two longitudes and latitudes based on kilometers. In the proposed algorithm, the cosine-haversine formula was used. In the cosine-haversine formula, the distance was calculated as follow:

$$d=2.r.arcsin(\sqrt{harv})$$
(13)

where the \(r\) is the earth's radius, which varies from 6356.752 km at the poles to 6378.137 km at Ecuador. Additionally, \(harv\) is the haversine function that was defined as below:

$$harv={sin({In}_{1})}^{2}+cos({\varphi }_{1}) cos({\varphi }_{2}) {sin({In}_{2})}^{2}$$
(14)
$${In}_{1}=\frac{{\varphi }_{1}-{\varphi }_{2}}{2}$$
(15)
$${In}_{2} = \frac{{\gamma }_{1}-{\gamma }_{2}}{2}$$
(16)

where φ1 and γ2 are latitude and longitude of the first switch, φ2 and γ2 are latitude and longitude of the second switch in radians, respectively. Also, Eq. (17) was used to convert longitude and latitude from degree to radian.

$$ \begin{gathered} latitude\left( {radian} \right) = \frac{{latitude\left( {degree} \right) \times \pi }}{180} \hfill \\ longitude\left( {radian} \right) = \frac{{longitude\left( {degree} \right) \times \pi }}{180} \hfill \\ \end{gathered} $$
(17)

where, \(\pi = 3.1415\).

4.4 Problem formulation

In the current paper, the controller placement problem was attentively scrutinized, and a novel method was proposed to reduce the overall delay of the software-defined networks (SDNs) by splitting it into several sections. In this case, the network is split into several sub-network, in which each sub-network has a controller. To mathematically model the network partition and controller placement problem, the following assumptions were taken into account.

  • The location of all network switches was given and was consistent.

  • The length, bandwidth, and traffic through the link were recognized.

  • The numbers and locations of controllers could be changed.

  • The communication links were given and were consistent.

The controller placement problem with a different number of sub-networks is demonstrated in Fig. 13. The SDN networks could be shown by a graph \(G=(S,E)\), which \(S=\{{s}_{1},{s}_{2},\dots ,{s}_{n}\}\) is the set of switches, and \(E\) is the set of communication links between switches. The \(S\) was formulated as:

Fig. 13
figure 13

Controller placement problem with different number of controllers

$$S= {\left[ \begin{array}{cc}\begin{array}{cc}{X}_{1}& {Y}_{1}\\ {X}_{2}& {Y}_{2}\end{array}& \\ \begin{array}{cc}\vdots & \vdots \\ {X}_{n}& {Y}_{n}\end{array}& \end{array}\right]}_{n\times 2}$$
(18)

where the \(n\) is the number of switches. Besides, the set of links between switches could be illustrated by a \(NS\times NS\) matrix as below:

$$E={\left[\begin{array}{cc}\begin{array}{cc}{l}_{\mathrm{1,1}}& {l}_{\mathrm{1,2}}\\ {l}_{\mathrm{2,1}}& {l}_{\mathrm{2,2}}\end{array}& \begin{array}{cc}\dots & {l}_{1,n}\\ \dots & {l}_{2,n}\end{array}\\ \begin{array}{cc}\vdots & \vdots \\ {l}_{n,1}& {l}_{n,2}\end{array}& \begin{array}{cc}\vdots & \vdots \\ \dots & {l}_{n,n}\end{array}\end{array}\right]}_{NS\times NS}$$
(19)

where \(NS\) is the number of switches in the network, and the elements of the matrix were defined as follows [67]:

$$ l_{{i,j}} = \left\{ {\begin{array}{*{20}l} 1 & {if\;there\;is\;a\;link\;between\;ith\;and\;jth\;switches} \\ o & {otherwise} \\ \end{array} } \right. $$
(20)

In addition, \(C=\{{c}_{1},{c}_{2},\dots ,{c}_{NC}\}\) is the set of controllers that were installed in the network. The controllers were a sub-set of the switches that were selected as controllers. Firstly, the set of controllers was selected randomly. Afterward, the set is modified by the proposed optimization algorithm to minimize network latency. The process was encoded, the procedure of which is shown in Fig. 14.

Fig. 14
figure 14

Encoding the controller selection process

In Fig. 14, the numbers are the IDs of the switches that were selected as controllers. In other words, the 15th, 24th, 3rd, and 10th switches were selected as controllers. The network latency was calculated following the selection of an appropriate sub-set of switches as controllers. The process of calculating the latency is described in subsect. 4.5.

After selecting the controllers, each switch determines the nearest controller using Dijkstra’s shortest path algorithm and sends its data to the nearest controller. It should be noted that there may be more than one path for data transfer between a switch and the nearest controller, which is also selected by Dijkstra’s shortest path algorithm. Figure 15 illustrates the proposed controller placement process.

Fig. 15
figure 15

The controller placement process

4.5 Objective function

Various competing objective functions were proposed in the literature to evaluate controller placement approaches. In the current paper, the average switch to controller latency was considered as an objective function. The average switch to controller latency is an eminent and widely-used evaluation criterion for controller placement used extensively in the literature [22, 68,69,70]. Equation (21) defines the average switch to controller latency.

$$F(C(\pi )) = \frac{1}{|S|}\sum_{u\in S}(\underset{v\in C}{\mathrm{min}}{L}_{u,v})$$
(21)

where |S| is the number of switches, and \({L}_{u,v}\) is the minimum latency between switch \(u\) and controller \(v\). The latency could be calculated by Eq. (22) [71].

$${L}_{u,v}=\frac{{d}_{u,v}}{2*{10}^{8}}$$
(22)

where \({d}_{u,v}\) is the shortest path length between the switch \(u\) and the controller \(v\).

4.6 The proposed hybrid controller placement algorithm

This subsection presents the proposed hybrid controller placement algorithm (PHCPA). The hybridization mechanism is a renowned mechanism to increase the optimization algorithms' efficiency and overcome their shortcomings, such as low convergence rate, trapping in the local optimums, poor exploration/exploitation capability, etc. [25, 26, 72]. As previously mentioned, the proposed controller placement algorithm is a network segmentation algorithm, which is considered an optimization problem. The main goal of PHCPA is to minimize the delay in the network by selecting an appropriate subset of switches as controllers. Initially, a random subset of switches was selected as controllers by Eq. (23).

$${X}_{i}= floor(\overrightarrow{rv}*NS)+1$$
(23)

where \(\overrightarrow{rv}\) is a vector with \(NC\) random numbers in \([\mathrm{0,1}]\), \(NC\) is the number of controllers, \(NS\) is the number of network controllers, and \(floor\) is a function that rounds the decimal number to the nearest smaller integer. Following the generation of random sunsets of controllers, the subsets were modified by the proposed hybrid discrete MRFO-SSA algorithm to find the best subset of controllers to minimize the network delay. In each round of the proposed PHCPA algorithm, the solutions were divided into two swarms; discrete MRFO modified the first swarm controller sets. Discrete SSA modified the solutions in the second swarm. Figure 16 presents the pseudocode of PHCPA. In modifying controller sets, it is possible to place duplicate indexes in a set. For instance, Fig. 17 represents this situation in using a two-point swap operator.

Fig. 16
figure 16

Pseudocode of the proposed PHCPA controller placement algorithm

Fig. 17
figure 17

Duplicated indexes in the controller sets

It is evident from Fig. 17 that in the resulting set, the index seven was duplicated, and the number of controllers was reduced from 6 to 5. A mechanism was needed to solve this unacceptable situation. Therefore, the \(CheckX\) function was proposed in the PHCPA algorithm to check the controllers' set, the pseudocode of which is illustrated in Fig. 18. Furthermore, the diagram of the proposed system is provided in Fig. 19.

Fig. 18
figure 18

Pseudocode of \(\mathrm{CheckX}\) function

Fig. 19
figure 19

Diagram of the proposed system

4.7 Computational complexity

This subsection discusses the computational complexity of the proposed algorithm. The proposed algorithm consists of three main parts: calculating the distances between switches, finding the shortest path between switches, finding the optimal controller places.

The computational complexity of the distance calculation step is \(O({S}^{2})\), where \(S\) is the number of switches. The complexity of the basic Dijkstra’s algorithm, which finds the shortest path between two points, is \(O(S+E\times log(S))\). Therefore, the computational complexity of calculating the shortest path between all switches is \(O(S\times (S-1)\times (S+E)\times log(S))\), where the \(E\) is the number of the network’s communication links.

The computational complexity of finding optimal controller places could be argued in three partial parts (i.e., initialization, discrete SSA, and discrete MRFO). The complexity of the initialization is \(O({N}^{2})\), where \(N\) in the number of solutions. The computational complexity of the proposed discrete SSA algorithm is \(O(R\times N\times NC)\), where \(R\) is the number of iterations, and \(NC\) is the number of controllers. The complexity of the proposed discrete MRFO algorithm is also \(O(R\times N\times NC)\).

It should be noted that the proposed controller placement algorithm is a multi-swarm algorithm, the solutions of which were divided into two swarms in each iteration, and each swarm was updated with one of the discrete algorithms. Therefore, the overall computational complexity of the optimal location discovery of the controller selection part could not be calculated accurately. However, since the computational complexity of discrete SSA and MRFO algorithms was almost similar, the complexity of this part was approximately equal to \(O(R\times {N}^{3}\times NC)\).

5 Experimental result

This section presents a bulk of experiments’ results to evaluate the proposed algorithm's performance and substantiate the previous section's contributions. The experiments were conducted on six real-world networks (see Table 2), and the results of the proposed algorithm was compared with the results of several newfangled algorithms containing the Moth-Flame Optimization algorithm (MFO) [73], Manta-Ray Foraging Optimization algorithm (MRFO) [57], Multi-Verse Optimizer (MVO) [74], Sine Cosine Algorithm (SCA) [75], Salp Swarm Algorithm (SSA) [59], and Whale Optimization Algorithm (WOA) [58]. Furthermore, due to the random nature of the optimization algorithms mentioned above, each algorithm was run 30 times independently, and the results were presented statistically/visually.

Table 2 Details of the software-defined networks

It is worth mentioning that all experiments were carried out in the same environment with specifications expressed in Table 3. The number of solutions and the maximum number of iterations in the algorithms were set to 50 and 200, respectively. The other parameter values of the algorithms are shown in Table 4, which are the algorithms' default values. Moreover, reaching the maximum number of iterations was considered as a stopping criterion.

Table 3 The specifications of the test environment
Table 4 The parameter values of the algorithms

5.1 Experiments on ATT North America network

This subsection presents the obtained results by the algorithms on the ATT North America network. As provided in Table 2, this network possesses twenty-two switches and fifty-seven links between them. Figure 20 illustrates the network and the position of the switches.

Fig. 20
figure 20

ATT North America network

The statistical results of the algorithms obtained on this network for a different number of controllers are presented in Table 5. The bar graphs of the maximum delay obtained by the algorithms are represented in Fig. 21.

Table 5 Statistical results of the algorithms obtained on the ATT North America network over 30 independent runs in terms of network delay
Fig. 21
figure 21

Bar graphs of the maximum delay obtained by the algorithms on the ATT North America network

It can be deduced from Table 5 and Fig. 21 that the proposed algorithm achieved better results than other competing algorithms in terms of minimum, maximum, average delay, and standard deviation of obtained results on three different numbers of controllers in the network. For further investigation of the algorithm's performance, the algorithms' best convergence rates for different numbers of controllers were compared, and the results are illustrated in Fig. 22.

Fig. 22
figure 22

Convergence rates of the algorithms on the ATT North America network

According to the graphs of Fig. 22, it can be observed that the proposed solution converged earlier and found a better solution than other algorithms. Moreover, Fig. 23 represents the box plots of the algorithms on the ATT North America Network. It can be concluded from the box plots of Fig. 23, the proposed algorithm outperformed the competitor algorithms and had a lesser random state.

Fig. 23
figure 23

Box plots of the algorithms on the ATT North America network

5.2 Experiments on BICS network

The BICS software-defined network has thirty-three switches and forty-eight links, which are shown in Fig. 24. The details of the BICS network are stated in Table 2. This subsection presents the results of experiments on this network.

Fig. 24
figure 24

The BICS network

The statistical results of the algorithms obtained from this network for the different number of controllers are presented in Table 6. Besides, the bar graphs of the maximum delay obtained by the algorithms are represented in Fig. 25.

Table 6 Statistical results of the algorithms obtained on the BICS network over 30 independent runs in terms of network delay
Fig. 25
figure 25

Bar graphs of the maximum delay obtained by the algorithms on the BICS network

According to the results of Table 6 and Fig. 25, the proposed algorithm outperformed competitor algorithms and decreased the minimum, maximum, and average delays of the network on three different numbers of controllers. Additionally, Fig. 26 shows the convergence rates of the algorithms for the different numbers of controllers.

Fig. 26
figure 26

Convergence rates of the algorithms on the BICS network

The simulation results expressed that the proposed solution achieved better results in a shorter time than competitor algorithms. Additionally, the algorithms' box plots on this network are provided in Fig. 27 for more-in-depth comparisons. These box graphs showed that competing algorithms' results were very scattered, especially at \(NC=5\), which was more complicated. Notwithstanding, the proposed algorithm results in all three scenarios were more consistent, which could be stated that the proposed algorithm was better than competing algorithms.

Fig. 27
figure 27

Box plots of the algorithms on the BICS network

5.3 Experiments on Bell Canada network

This subsection evaluates the algorithms' performance on the Bell Canada network and provides the statistical and visual results. The Bell Canada network consists of forty-eight switches in Canada and the USA and sixty-five communication links. The geolocation of the switches and the details of the links are exhibited in Fig. 28.

Fig. 28
figure 28

The Bell Canada network

The statistical results of the algorithms obtained on this network for a different number of controllers are presented in Table 7. Moreover, the bar graphs of the maximum delay obtained by the algorithms are represented in Fig. 29.

Table 7 Statistical results of the algorithms obtained on the Bell Canada network over 30 independent runs in terms of network delay
Fig. 29
figure 29

Bar graphs of the maximum delay obtained by the algorithms on the Bell Canada network

The statistical results of Table 7 demonstrated that all algorithms found the optimal places of controllers of the network with three controllers. Nonetheless, by increasing the number of network controllers, the algorithms lost their efficiency and could not find the optimal places. This phenomenon can be due to the fact that the increase in the number of controllers surges the complexity of finding optimal places. However, by examining the results of Table 7 and the graphical results of Fig. 29, it can be concluded that the proposed algorithm performed better than competitor algorithms and reduced the delay of the network by finding optimal places for deploying the controllers. Like previous subsections, the algorithms' convergence rate was investigated, and the results are provided in Fig. 30 for the different number of controllers.

Fig. 30
figure 30

Convergence rates of the algorithms on the Bell Canada network

It could be inferred from the algorithms' results that the proposed solution outperformed the competitor algorithms and reduced network delay on the Bell Canada network. Furthermore, Fig. 31 illustrates the box plots of the algorithms on this network. In the guise of the box graphs of Fig. 31, the proposed method's network latency was less than other algorithms. The difference between the algorithms increased with the growing complexity (raising the number of controllers).

Fig. 31
figure 31

Box plots of the algorithms on the Bell Canada network

5.4 Experiments on Palmetto Net network

Herein, the experimental results of the algorithms on the Palmetto Net network are presented. The Palmetto Net network is a regional network and has forty-five switches with seventy links. Figure 32 represents the Palmetto Net network.

Fig. 32
figure 32

The Palmetto Net network

Table 8 presents the statistical results of the algorithms on the Palmetto Net network. The results are provided for three different numbers of controllers: 3, 4, and 5. Besides, Fig. 33 illustrates the bar graphs of the worst results of the algorithms on this network.

Table 8 Statistical results of the algorithms obtained on the Palmetto Net network over 30 independent runs in terms of network delay
Fig. 33
figure 33

Bar graphs of the maximum delay obtained by the algorithms on the Palmetto Net network

Table 8 and Fig. 33 express that the proposed solution algorithm found better places to establish controllers and significantly reduced network delay. For having a more in-depth evaluation algorithm, the converge rate analysis was done for the algorithms, and the results are provided in Fig. 34. The graphs of Fig. 34 corroborated Table 8 and imparted the superiority of the proposed algorithm.

Fig. 34
figure 34

Convergence rates of the algorithms on the Palmetto Net network

Additionally, for a more detailed examination of the algorithms, the algorithms’ box plots on the Palmetto Net network are presented in Fig. 35. Box plots of Fig. 35 confirmed the statistical results of Table 8, bar diagrams of Fig. 33, and convergence diagrams of Fig. 34 and revealed the proposed algorithm's superiority.

Fig. 35
figure 35

Box plots of the algorithms on the Palmetto Net network

5.5 Experiments on IRIS network

The IRIS network is another regional software-defined network, which was speared in Tennessee and the USA. The IRIS network has fifty-one switches and sixty-four communicational links among them (see Table 2). Figure 36 plots the IRIS network and the details of switches and links of it.

Fig. 36
figure 36

The IRIS network

The calculated minimum, maximum, and average delays obtained by the algorithms on the IRIS network are stated in Table 9. Furthermore, Fig. 37 demonstrated the bar graphs of the maximum network delay obtained by the algorithms.

Table 9 Statistical results of the algorithms obtained on the IRIS network over 30 independent runs in terms of network delay
Fig. 37
figure 37

Bar graphs of the maximum delay obtained by the algorithms on the IRIS network

As shown in Table 9 and Fig. 37, the proposed algorithm achieved better results than other competing algorithms in terms of minimum, maximum, average delay, and standard deviation of obtained results on three different numbers of controllers in the network. Besides, for a more in-depth evaluation of the algorithms’ performance, the algorithms' best convergence rates for different numbers of controllers were compared, the results of which are illustrated in Fig. 38.

Fig. 38
figure 38

Convergence rates of the algorithms on the IRIS network

The convergence rate graphs of Fig. 38 represent that the proposed solution discovered better solutions in a shorter time compared to other state-of-the-art algorithms.

Figure 39 presents the box plots of the algorithms on the IRIS network. Regarding these box diagrams, it could be easily comprehended that competitor algorithms achieved a different network latency level in the independent runs, unlike the proposed algorithm, which refutes these algorithms' effectiveness. However, by examining the box diagrams, it could be claimed that the proposed algorithm was reliable and could reduce network latency.

Fig. 39
figure 39

Box plots of the algorithms on the IRIS network

5.6 Experiments on SURFNET network

In this subsection, the algorithms were evaluated on a giant software-defined network to examine the algorithms' scalability. Finally, the algorithms were investigated in terms of their performance as well. The last network was the SURFNET network, which had fifty switches and seventy-three communicational links. The details of this network are presented in Table 10 and Fig. 40.

Table 10 Statistical results of the algorithms obtained on the SURFNET network over 30 independent runs in terms of network delay
Fig. 40
figure 40

The SURFNET network

The minimum, maximum, and average network delay of the algorithms on the SURFNET network for three different numbers of controllers are represented in Table 10. Moreover, Table 10 provides the standard deviations of the results of the algorithms. Additionally, Fig. 41 depicts the maximum delays of the network obtained by the algorithms using bar graphs.

Fig. 41
figure 41

Bar graphs of the maximum delay obtained by the algorithms on the SURFNET network

According to Table 10 and Fig. 41, it could be seen that the proposed algorithm demonstrated a significant difference from the competitor algorithms and achieved better results. The best convergence rates of the algorithms on the different number of controllers are presented in Fig. 42.

Fig. 42
figure 42

Convergence rates of the algorithms on the SURFNET network

Likewise, the box plot graphs of the algorithms for the SURFNET network are exhibited in Fig. 43. Concerning the box graphs of Fig. 43, it could be perceived that the proposed algorithm had a significant difference from the competitor algorithms and depreciated the network latency as much as possible. Furthermore, it was observed that the results of the proposed algorithm were more coherent compared to the results of other algorithms, which is an indicator of the proposed algorithm’s superiority.

Fig. 43
figure 43

Box plots of the algorithms on the SURFNET network

The algorithms' experimental results on various software-defined networks revealed the proposed controller placement algorithm's efficiency for the real-world SDN networks with a different number of controllers.

6 Conclusion

The present paper addressed the controller placement problem (CCP) in software-defined networks (SDNs) and imparted a novel algorithm called PHCPA. The PHCPA used the network portioning concept and the hybrid Manta-Ray Foraging Optimization algorithm (MRFO) with Salp Swarm Algorithm (SSA). Minimizing network propagation latency was the main objective of the current paper.

The MRFO and SSA algorithms were powerful nature-inspired meta-heuristic algorithms recently developed to solve various incessant problems. However, given that the CCP is a discrete problem, the MRFO and SSA algorithms were discretized by the two-point swap, random insert, and half points crossover operators. Afterward, they were hybridized to enhance their search capabilities, and their deficiencies such as slow convergence and trapping into local optimums would be eliminated. Henceforth, the resulting discrete hybrid optimization algorithm, was adopted for the controller placement problem. Subsequently, the PHCPA was applied to six real-world software-defined networks embracing topology-zoo to investigate the proposed algorithm's performance. In the experiments, the PHCPA was compared with state-of-the-art meta-heuristic-based algorithms regarding the best, worst, and average network propagation obtained by the algorithms. Additionally, the results’ standard deviations of the algorithms’ independent runs were compared.

Moreover, for a more in-depth investigation of the algorithms’ performance, the algorithms' convergence rate was also compared. It is worth mentioning that the experiments on each software-defined network were repeated on three different numbers of controllers for further performance evaluations. The experimental results verified the effectiveness of the contributions and superiority of the proposed controller placement algorithm.

The proposed algorithm had a supreme convergence rate and preeminent exploration and exploitation capabilities. Nonetheless, it took more CPU time and required additional storage space. For future research, enthusiasts could recruit other algorithms or apply other metrics along with the propagation latency.