{'fraction_non_alphanumeric': 0.03034995354598947, 'fraction_numerical': 0.014529782182306184, 'mean_word_length': 4.733796981355431, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
RetroFlow: Maintaining Control Resiliency and Flow Programmability for Software-Defined WANs

Providing resilient network control is a critical concern for deploying Software-Defined Networking (SDN) into Wide-Area Networks (WANs). For performance reasons, a Software-Defined WAN is divided into multiple domains controlled by multiple controllers with a logically centralized view. Under controller failures, we need to remap the control of offline switches from failed controllers to other active controllers. Existing solutions could either overload active controllers to interrupt their normal operations or degrade network performance because of increasing the controller-switch communication overhead. In this paper, we propose RetroFlow to achieve low communication overhead without interrupting the normal processing of active controllers during controller failures. By intelligently configuring a set of selected offline switches working under the legacy routing mode, RetroFlow relieves the active controllers from controlling the selected offline switches while maintaining the flow programmability (e.g., the ability to change paths of flows) of SDN. RetroFlow also smartly transfers the control of offline switches with the SDN routing mode to active controllers to minimize the communication overhead from these offline switches to the active controllers. Simulation results show that compared with the baseline algorithm, RetroFlow can reduce the communication overhead up to 52.6% during a moderate controller failure by recovering 100% flows from offline switches and can reduce the communication overhead up to 61.2% during a serious controller failure by setting to recover 90% of flows from offline switches.


INTRODUCTION
Software-Defined Networking (SDN) has been deployed in real networks [1] [2]. One critical scenario for the SDN is Wide-Area Networks (WANs), known as the SD-WANs. For instance, as one of the world's largest Internet service provider, AT&T has softwarized 65% of its WAN with programmable devices (e.g., SDN switches) by 2018 and plans to improve the ratio to 75% by 2020 [3]. In the future, most of the network infrastructure in WANs (e.g., switches and routers) will be replaced by programmable devices.
In SD-WANs, the network is usually divided into multiple domains to achieve low latency control given the large scale of a WAN and the huge number of SDN switches in it [4]. Each domain usually has an SDN controller that can quickly reply to requests from all the SDN switches within the domain. The controllers from different domains are physically distributed, but they can achieve a logically centralized control by the synchronization among them to maintain a consistent network view [5].
Control resiliency is a critical concern for SD-WANs. Essentially, an SDN controller is a network software installed in a physical server or a virtual machine. Due to some unexpected issues (e.g., hardware/software bugs, power failure), one controller could accidentally fail, and then all of its connected switches are out of control, which we refer to as the offline switches. Existing solutions to maintain the control resiliency of SDN can be categorized into two classes: (1) controller placement and (2) switch remapping. Solutions in the former category carefully choose physical locations of controllers to optimize the control performance under controller failures, such as minimizing the latency between backup controllers and switches [6] [7] and/or minimizing the latency among the main controller, backup controllers, and switches [8]. These solutions are usually based on some unrealistic assumptions, such as the same control cost and unlimited capability of controllers, which are far from practical. In contrast, the switch remapping approaches propose to dynamically shift the control of offline switches to other active controllers [9]. However, in an almost saturated SDN, controllers almost reach their processing limits. There will be little room left in active controllers to accept offline switches from the failed controllers without overloading the active controllers, which otherwise can degrade the performance (e.g., increasing the communication overhead) or even cause the cascading controller failure [9][10] [11].
In this paper, we present a feature available in existing commercial SDN switches that shed light on this issue. Existing commercial SDN switches (e.g., Brocade MLX-8 PE [12]) can freely change between two routing modes, the SDN mode and the legacy mode. The former relies on the SDN controller's decision to process flows while the latter processes flows using its traditional routing table without consulting the controller. Inspired by the feature in commercial devices, we propose to configure switches in hybrid modes so that we can enjoy the flow programmability (e.g., the ability to change the paths of flows) brought by the SDN mode while avoiding the out-of-control disasters coming with the offline switches during the controller failures.
To get the best of both worlds, we have overcome two main challenges. First, configuring SDN switches to work in the legacy mode will decrease the flow programmability of SDN. We carefully choose a set of offline switches working in the legacy mode to maximize the number of programmable flows that have at least one alternative path to forward. Second, the switch-controller mapping affects the communication overhead from offline switches to active controllers. For the remaining offline switches that still work in the SDN mode, we carefully remap them to active controllers, which is a complex optimization problem restricted to the switches' control cost (e.g., the per-flow state pulling [13] [14]) and the controller's real-time workload. Since these two problems are coherent, we approach the optimal results with the joint optimization.
In summary, our paper makes the following contributions: • We formulate the joint optimization problem as the Optimal Switch Configuration and Mapping (OSCM) problem, which aims to keep low communication overhead of controllers by deciding the offline switch control shift based on the switch and controller states in real time. • We provide a rigorous proof of the OSCM problem to be NP-hard and propose a heuristic solution named RetroFlow to efficiently solve the problem. • We evaluate the performance of RetroFlow under a real topology. Simulation results show that compared with the baseline algorithm, RetroFlow can reduce the communication overhead up to 52.6% during a moderate controller failure that active controllers have enough ability to recover 100% flows from offline switches, and can reduce the communication overhead up to 61.2% during a serious controller failure by setting to recover 90% flows from offline switches. The rest of the paper is organized as follows. In Section 2, we introduce the background of SDN and the motivation of this paper. Section 3 introduces our design considerations, and Section 4 mathematically formulates our design as the OSCM problem. Section 5 proves the OSCM problem's complexity and proposes RetroFlow to efficiently solve the problem. We evaluate and analyze the performance of RetroFlow in Section 6. Section 7 introduces related works, and Section 8 concludes this paper.

BACKGROUND AND MOTIVATION
In this section, we introduce the background of SDN, analyze the limitation of SDN under controller failures, and present opportunities to solve the problem using features available in commercial SDN switches.

Blessing of the SDN
One big benefit of SDN is to provide flexible control on traffic flows based on the global state of the network. To achieve this benefit, the SDN controller can establish forwarding paths for individual flows reactively when they enter the network for the first time or proactively before they arrive at the network. During the network operation, the controller periodically pulls flow state information from the controlled switches to update its global network view and dynamically changes some flows' paths to improve network performance. These unique features and advantages, called flow programmability, help SDN to prevail over traditional network techniques. Therefore, many networks start to deploy SDN [1][2] [3].
For an SD-WAN that consists of many switches, we usually divide the WAN into multiple domains with different number of SDN switches and use a logically centralized control on domains with distributed controllers [5]. In each domain, its controller can quickly reply to requests from switches and synchronize with other controllers to maintain the consistent network view.

Curse of the SDN
The normal operations of an SD-WAN rely on the controllers' decision and the communication between controllers and switches for conducting the decision and pulling flow state information. The controller becomes the Achilles Heel of SDN. In other words, an SDN switch will be out of control if its controller fails. In order to provide a resilient control of the network, an SDN switch usually connects to a master controller and several backup controllers [15]. When the master controller of a switch crashes, its connection to the switch becomes inactive, and the switch will request one of its backup controllers to become its new master controller. We call the switches previously controlled by failed controllers the offline switches. The problem of remapping the control of offline switches to other active controllers is called SDN switch remapping under controller failures. This switch remapping has two impacts on other active controllers: • Overloading controllers: A master controller mainly has two types of operations on switches: (1) flow entry operations to establish/update flows' forwarding paths and (2) flow state pulling operations to get the network state variation. Both of the two operations consume the processing ability of the master controller. Backup controllers only maintain the connection to their switches without operations until they become master controllers. Becoming the new master controller of some switches from remote domains increases the processing load of a controller, potentially overloading the controller [9] [10]. Existing studies show the switches' requests handled by an overloaded controller could experience long-tail latency [16], which could degrade the network performance significantly.  • Increasing the communication overhead of controllers: The communication overhead of a controller is proportional to two factors: (1) the propagation latency between the controller and its controlled switches and (2) the number of flows in the switches. In WANs, the propagation latency is the dominant factor among all latencies because the propagation latency bounds a controller's control reactions that can be executed at a reasonable speed [17] [18]. A long propagation latency could limit convergence time (e.g., routing convergence, network update). Thus, remapping offline switches to active controllers should consider the propagation latency among the switches and controllers. Otherwise, the reaction of the controllers to dynamic network changes could be delayed. To better illustrate our view, we use a motivation example in Figure 1 to show that existing solutions under controller failures suffer from the two impacts. In Figure 1(a), an SDN consists of three domains, and each domain is controlled by one master controller and connected to two backup controllers. In this example, we mainly focus on domain D 2 and do not show details of the other two domains. In domain D 2 , controller C 2 is the master controller that controls five SDN switches s20-s24. Controllers C 1 and C 3 are backup controllers of D 2 . The three controllers synchronize with each other to maintain the consistent network information. Both C 1 and C 3 know that D 2 has five switches and the flow information of D 2 . We denote the processing ability of a controller as the number of flows. In this example, without interrupting a controller's normal operations, C 1 can pull the state of ten flows, but C 3 can only pull the state of at most five flows. Figure 1(b) shows the flows in D 2 and their paths.
An SDN is vulnerable. In Figure 1(c), controller C 2 fails, and the control of the five switches in D 2 should be transferred to active controllers C 1 and C 3 . As summarized above, two problems are raised in the following cases: (1) Controller overload: Figure 1(d) shows that remapping switches in D 2 to active controllers only considers the switch-controller propagation delay. In this figure, the five switches are remapped to their nearest, active controller C 3 . This solution minimizes the communication overhead of the entire network but controller C 3 has to pull the states of eleven flows (i.e., f 1, f 2, and f 3 from s20, f 1 and f 3 from s21, f 1 and f 2 from s22, f 2 and f 3 from s23, f 1 and f 2 from s24), which interrupts its normal operations by introducing queueing delays [16]. (2) High controller communication overhead: Figure 1(e) shows that remapping switches in D 2 to active controllers considers the switch-controller propagation delay and controllers' processing abilities. In this figure, switches s20, s22, and s24 are remapped to controller C 3 while switches s21 and s23 are remapped to controller C 1 . This solution prevents controllers from being overloaded but incurs higher communication overhead than the solution in Figure 1

Opportunities
We note that many commercial SDN switches today are hybrid SDN switches (e.g., Brocade MLX-8 PE [12]) and support two routing modes: legacy mode and SDN mode. In the legacy mode, switches route flows with the destination-based entries in the routing table generated from legacy routing protocols (e.g., OSPF), whereas in the SDN mode, they route flows using OpenFlow table managed by the controller. In other words, a switch with the legacy mode can work without the controller. Thus, we can reduce the controller's processing load by configuring some switches working under the legacy mode.
A controller can dynamically set the routing mode of a hybrid SDN switch by sending a control message. Figure 2 shows an example of changing the routing mode under a controller failure. In Figure 2(a), switch s connects to its master controller C 1 and backup controllers C 2 and C 3 . C 1 sets s to work under the SDN mode, and the three controllers synchronize with others. In Figure 2(b), when C 1 fails, s identifies its connection to C 1 become inactive and then sends a master controller selection request to C 1 , C 2 , and C 3 . Both C 2 and C 3 reply a rejection message to switch s's request with a legacy mode configuration, and then s starts to work under the legacy mode. s can go back to the SDN mode when one controller wants to become its new master controller. This dynamic routing mode configuration feature offers us more flexibility to tackle the problem of switch remapping under controller failures.

DESIGN CONSIDERATIONS
In this section, we propose to relieve the controller's control cost of offline switches and reduce the communication overhead during controller failures by introducing the optimal switch configuration and mapping problem.

Switch mode configuration problem
Inspired by the hybrid SDN switches available in the market, we propose to relieve the controller's control cost of offline switches by degrading a pure SDN of the offline switches to a hybrid SDN that consists of switches with the SDN mode and legacy mode. In other words, we configure a subset of offline switches to run under the SDN mode and others to run under the legacy mode without the management of controllers. However, when configuring the routing mode on switches, we should guarantee the programmability of flows in the hybrid SDN.
The programmability of flows is an essential feature of SDN [19][20] [21]. Taking the routing problem as an example, the programmability of a flow is the ability to change the flow's path. Existing pure SDN designs realize the network programmability with a per-hop programmable routing, which enables the controller to change each flow's path from any switches 1 on the flow's path. In contrast, by maintaining the basic programmability, we keep only 1-hop programmable routing for flows of offline switches. In other words, we can still change the path of a flow from offline switches by controlling one switch on the flow's path while letting other switches on the flow's path just forward the flow using the legacy destination-based routing. Thus, the switches using the legacy routing do not need to consult the controllers for routing flows. Figure 3(a) shows an example that under the same failure case of Figure 1(c), we achieve the programmablity of flows f 1-f 3 using switches with the SDN mode and legacy mode. In this figure, switches s21 and s23 work under the SDN mode, and switches s20, s22, and s24 work under the legacy mode. Flows f 1, f 2, and f 3's forwarding paths can be changed at switches s21, s23, and s21, respectively.

Switch remapping problem
With the reduced number of switches under the SDN mode, we have more freedom to remap these switches to active controllers. The switch remapping should maintain low communication overhead between these switches and active controllers without exceeding the controller's processing ability. The load of a controller is defined as the number of flows the controller can control, and it is restricted to the processing ability of the controller. As explained in Section 2.2, the load consists of two parts: flow entry operations and flow state pulling operations. The former one has been considered in many existing works [22], while we argue the latter one is more important in the WAN scenario. In WANs, each flow's path is usually proactively configured since each flow is an aggregated large flow of multiple flows and always has a traffic rate. Only a limited number of flow entry operations are conducted to reroute some flows at some extreme situations (e.g., congestion). However, each controller conducts the flow state pulling operations periodically (e.g., every few seconds [23]) to maintain the updated network view. Per-flow pulling [13] [14] are popular state pulling methods. The controller sends a request to a switch to pull the state of one flow. The number of flow state pulling requests is proportional to the number of flows in a switch. Thus, in WANs, the flow state pulling is a big overhead for the controllers and is our main concern in this paper.
We name the solution that sequentially solves the above two problems one by one the two-phase solution, which obtains the final result by solving the switch mapping problem using the result of the switch mode configuration problem. Figure 3

A joint optimization problem
However, it is not enough to consider the above two problems independently because the two problems are correlated. Recall the communication overhead of a controller equals to the propagation latency between the controller and its controlled switches multiplied with the number of flows in the switches. Thus, to achieve the low communication overhead, it may be better to choose more switches (or switches with more flows) with lower delays than to choose fewer switches (or switches with fewer flows) with higher delays. Figure 3(b) shows the result of RetroFlow under the same failure case of Figure 1(c). In this figure, RetroFlow remaps switches s20 and s22 to controller C 3 and configure switches s21, s23, and s24 under the legacy mode. Flows f 1, f 2, and f 3's forwarding paths can be changed at switches s20 and s22, at switch s22, and at switch s20, respectively. Under the given processing ability of controllers, RetroFlow outperforms the two-phase solution in Figure 3(a) in two aspects. First, RetroFlow has a higher flow programmablitily since flow f 1 traverses two switches with the SDN mode. Second, RetroFlow has a lower communication overhead. RetroFlow pulls flow f 1 twice from two switches, but switches s20 and s22 are much closer to controller C3 than switches s21, s23, and s24. Thus, for the communication overhead, the significant decrease of propagation delay compromises the increased number of flows.
Therefore, we should jointly consider the number of flows in offline switches and the propagation delay among the switches and active controllers to configure switches' routing mode and the controller-switch mapping. We name this problem Optimal Switch Configuration and Mapping (OSCM) problem and literally explain it as follows: under controller failures, we need to maintain the programmability of flows from offline switches with the minimum communication overhead among offline switches and active controllers by efficiently configuring each offline switch with a routing mode and mapping the offline switches with the SDN mode to the active controllers.

PROBLEM FORMULATION
In this section, we introduce how to optimally configure and remap switches by modeling the system, introducing constraints and the objective function, and finally formulating an optimization problem. For simplicity, in the rest of this paper, we use a switch instead of an offline switch.

System description
Typically, an SD-WAN consists of H controllers at H locations, and each controller controls a domain of switches. Controllers C M +1 , ... , C H fail, and they control N switches in total. The set of active controllers is C = {C 1 , ..., C j , ....C M }, and the set of switches controlled by the failed controllers are S = {s 1 , ..., s i , ..., s N }. We need to select some switches from S, configure them with the SDN mode, and map these selected switches to controllers in C; the rest of switches in S are configured with the legacy mode. If switch s i ∈ S is configured with the SDN mode, x i = 1; otherwise, the switch is configured with the legacy mode and does not rely any controller, and thus x i = 0. We use z i j = 1 to denote that switch s i ∈ S under the SDN mode is mapped to controller C j ∈ C; otherwise z i j = 0. Since both x i and z i j are binary variables, and a feasible switch-controller mapping requires that a switch is under the SDN mode and mapped to an active controller, we can have

Constraints
4.2.1 Switch-controller mapping constraint. If switch s i is configured with the SDN mode, it must be controlled by only one controller; if switch s i is configured with the legacy mode, it is not controlled by any controller. Thus, we have 4.2.2 Controller processing ability constraint. If some controllers fail, it is unfair to overload other active controllers to take full responsibility for the failed controllers to control offline switches. Active controllers should only try their best to control the offline switches without interrupting their normal operations. The state pulling operations of a switch equal to the total number of flows in the switch's flow table. We measure a controller's processing ability as the number of flows that the controller can normally pull from its controlled switches without introducing extra delays (e.g., queueing delay). The processing load of a controller should not exceed the controller's processing ability. It can be written as where A r est j denotes the available processing ability of controller C j . Bringing (1) into the above inequality and letting д i denote the number of flows in switch s i we can reformulate the above nonlinear constraints as the following linear constraints:

Flow programmability constraint.
If a switch works under the SDN mode, the flows in the switch become programmable. The flow f l 's programmability can be expressed as follows: In the above inequality, the equal sign comes when there is only one offline switch with the SDN mode that contains flow f l . If multiple switches contain this flow, the inequality sign is used. The flow programmability equals the total number of unique programmable flows. If we require Q unique flows are programmable, we have

Objective function
The objective is to minimize the communication overhead of active controllers to pull flow state from offline switches, which equals the total propagation delay of programmable flows between the switches with the SDN mode and their newly mapped controllers. We use D i j (D i j ≥ 0) to denote the propagation delay between switch s i and controller C j and formulate the overhead as follows: If we use w i j to denote controller C j 's communication overhead to switch s i : we can write the objective function as follows

Problem formulation
The goal of our problem is to minimize the communication overhead between active controllers in C and offline switches in S and provide the programmability for flows in F by smartly configuring switches in S and mapping switches with the SDN mode to active controllers in C. Therefore, we formulate the OSCM problem as follows: (2)(4)(5) (6),

SOLUTION
In this section, we first analyze the complexity of the OSCM problem and then propose our RetroFlow algorithm for solving the problem.

Complexity analysis
Theorem 1. For a special case with two conditions: (1) all flows from offline switches should be programmable, and (2) each flow traverses only two switches and has different source and destination switches with others, the OSCM problem is NP-hard.
Proof: We first introduce the Generalized Assignment Problem (GAP) [24]. The GAP aims to minimize the cost assignment of n tasks to m agents such that each task is precisely assigned to one agent subject to capacity restrictions on the agents. A typical formulation of the GAP is shown below: where c i j is the cost of assigning task i to agent j, a i j is the capacity of task i when the task is assigned to agent j, and b j is the available capacity of agent j. Binary variable x i j equals 1 if task i is assigned to agent j, otherwise it equals 0. It has been proved when assigning multiple tasks to an agent and ensuring each task is performed exactly by one agent, the GAP is NP-hard [24].
We then prove for a special case of conditions (1) and (2), problem (P) and the GAP are equivalent problems. Given condition (1) that all flows from offline switches should be programmable, we have Q = L. (6) can be changed to y l = 1 for all l ∈ [1, L], and (5) can be rewritten as follows: Recall a flow cannot change its path at its destination switch. Given condition (2) that each flow traverses only two switches and has different source and destination switches with others, we have that each offline switch has a unique flow, and the number of offline   N ]. Thus, we can change the above inequality as the following equation Bringing the above equation into (2), we have M j=1 Following the above two conditions, our OSCM problem can be reformulated as follows: (P') Problem (P') aims to minimize the communication cost of N switches to M controllers such that each switch is precisely assigned to one controller subject to processing ability restrictions on the controllers. We can treat switch s i and controller C j in problem (P') as task i and agent j in the GAP. By this construction, it is easy to prove that there exists the minimum communication cost by mapping switches in S to controllers C, if and only if there exists the optimal solution of the GAP by assigning n tasks to m agents. The construction can be done in polynomial time. In problem (P'), the mapping between switches and controllers could be many to one. Since the GAP is NP-hard when multiple tasks are assigned to an agent, and each task is performed exactly by one agent [24], problem (P') is NP-hard.
□ Problem (P') is a special case of the OSCM problem and is NPhard. Therefore, we can have the following conclusion: Theorem 2. The OSCM problem is NP-hard.

RetroFlow algorithm
Typically, we can use existing integer program optimization solvers to obtain the OSCM problem's optimal solution. However, for the if | L l =1 β l i | > δ then 12: //assign switch s i 0 to controller C j 0 , which has the lowest communication overhead and enough processing ability 16: for Y ← Y ∪ l; if |S| == ∅ or |Y| ≥ Q then 28: break; 29: end if 30: end while 31: return X, Z, Y; problem with a large network, the solver could require a very long time or sometimes is impossible to find a feasible solution. Therefore, we propose a heuristic algorithm called RetroFlow for solving the problem to achieve the trade-off between the performance and time complexity.
The idea behind RetroFlow is to select and test variables based on their importance. The first priority of our problem is to enables many unique flows from offline switches to become programmable flows. Thus, we first select a switch that has the maximum number of flows which are different from existing programmable flows. This switch selection method helps us to efficiently rescue as many unique flows as possible in each iteration. For this selected switch, we choose a switch-controller mapping among all mappings in the ascending order of the communication overhead and then test whether the mapping satisfies the controller's processing ability. If yes, the mapping is selected, and all flows in the switch become programmable; otherwise, a new mapping is tested. This mapping selection method effectively reduces the communication overhead.  Controller ID  2  5  6  13  20  22  Switch ID  2  3 9  16 4 5  8 14 0 1 6 7 10 11 12 13 15 19 20 17 18 21 22 23      Details of RetroFlow are summarized in Algorithm 1, and Table  1 shows the notations used in the algorithm. In line 1, the sets X, Z, and Y are first set to be empty. In line 2, we start iteratively to find switches and their mappings. In line 3, for each iteration, we set δ to 0, and set i 0 and j 0 to NULL. In lines 5-14, we find the required switch. We first remove the existing programmable flows from each switch in S (lines 6-10) and find the required switch and update this switch's index to i 0 (lines [11][12][13]. In lines 16-25, we test the mapping between switch s i 0 and controller C j . If controller C j has enough ability to control switch s i 0 , we select the controller as C j 0 , establish the mapping between switch s i 0 and controller C j 0 , update the processing ability of controller C j 0 , and upgrade the set of programmable flows. In line 26, we remove the tested switch from the offline switches S. In lines [27][28][29], if all switches are tested or the number of programmable flows reaches the flow programmability requirement, the algorithm jumps out of the iterations. In line 31, the result returns.

SIMULATION 6.1 Simulation setup
We evaluate the performance of RetroFlow with a real backbone topology named ATT from Topology Zoo [25]. The ATT topology is a national topology of US with 25 nodes and 112 links. In this topology, each node is given a unique ID with a latitude and a longitude. We calculate the distance between two nodes using Haversine formula [26] and use the distance divided by the propagation speed (i.e., 2×10 8 m/s) [27] to represent the propagation delay between the two nodes. In our simulation, each node is an SDN switch, and some selected nodes are further deployed controllers. Any two nodes have a traffic flow, and each flow is forwarded on its shortest path. We set the processing ability of a controller to 500. The default selection of controllers and default mapping between controllers and switches are obtained by solving an optimization problem, which aims to minimize the communication overhead among all switches and controllers. Table 2 shows the default relationship of controllers, switches, and the number of flows in the switches.

Comparison algorithms
(1) Optimal: it is the optimal solution of the OSCM problem that minimizes the communication overhead between offline switches and active controllers during controller failures. We solve the problem using GUROBI solver [28]. (2) Nearest: during controller failures, each offline switch maps to its nearest controller. This solution can minimize the propagation delay but could overload active controllers. (3) RetroFlow: this algorithm is shown in Algorithm 1.

Simulation results
In our simulation, the SDN control plane consists of six controllers. Many existing works consider only one controller failure [9] [10]. RetroFlow can cover a wide range of multiple controller failure scenarios. We compare RetroFlow with other algorithms under two scenarios: (1) one controller failure and (2) two controllers failure. Scenario (1) is a moderate controller failure that active controllers have enough ability to handle all offline switches. Scenario (2) is a serious controller failure that active controllers are not able to handle all offline switches with their given processing abilities. Our performance metrics are the percentage of programmable flows from offline switches, communication overhead, and processing load of active controllers. We use Nearest as the baseline algorithm and normalize the metric of each algorithm to that of Nearest.
6.3.1 One controller failure. Figure 4 shows the results of three algorithms when one of the six controllers fail. In Figures 4(a) and (b), all three algorithms recover 100% flows from offline switches, and they remap the same number of offline switches to active controllers. However, in Figure 4(c), Optimal and RetroFlow outperform Nearest in term of the communication overhead. This is because Optimal and RetroFlow remap offline switches to their closest controllers with enough processing ability, while Nearest only considers the propagation delay to remap offline switches to controllers and thus could overload controllers, leading to long queueing delay for processing flow state pulling. The queueing delay setup follows the existing work [16]. In Figure 4(c), Optimal performs better than RetroFlow because of its better switch-controller remapping. [13,20]   However, compared with Nearest, RetroFlow can reduce the communication overhead up to 52.6%. Figure 4(d) shows the processing load of controllers. In this figure, Nearest experiences controller overload at all six cases.
6.3.2 Two controllers failure. Figures 5 and 6 show the results of three algorithms when two of the six controllers fail. There are 15 combinations of the two controllers failure. In Figure 5, we require 100% flows from offline switches to become programmable.   their processing limits. Because RetroFlow is a heuristic algorithm, it always has a solution. In this figure, RetroFlow recovers flows in the range of 71 % to 99 %. We analyze two representative failure cases: (1) the failure of controllers C 20 and C 22 , and (2) the failure of controllers C 6 and C 20 . In case (1), we have eight offline switches s 17 -s 24 . In Figure 5(b), RetroFlow enables 99 % flows to become programmable by recovering six offline switches, and Nearest recovers two more switches (s 18 and s 19 ) than RetroFlow does but only controls 1% more programmable flows. Because most of the flows in switches s 18 and s 19 have been recovered by remapping other six switches, remapping the two switches have only limited benefit. In case (2), we have six offline switches s 0 , s 1 , s 6 , s 7 , s 19 , and s 20 . In Figure 5(b), RetroFlow recovers 71 % flows by recovering three offline switches (s 0 , s 6 , and s 7 ), and Nearest recovers three more switches than RetroFlow with an increase of 29% more programmable flows. In this case, the left ability of controllers C 2 , C 5 , C 13 , and C 22 are only 124, 184, 23, and 35 flows. Thus, under the controller's processing ability bound, RetroFlow can only recover three switches, leading to a gap of programmable flow percentage between Nearest and RetroFlow. Nearest enables 100% programmable flows recovery at the cost of high communication overhead and controller overloading. In Figures 5(c) and (d), Nearest requires 25% to 82% more communication overhead due to the queueing delay of controller overloading.
If some controllers fail, it is unfair to overload other active controllers to take full responsibility for the failed controllers to control offline switches. Active controllers should only try their best to control offline switches. Based on this concern, in Figure 6, we require 90% flows to become programmable. In this figure, Optimal has results for 12 of 15 cases. By reducing the number of programmable flows, the communication overhead of RetroFlow reduces. Comparing the case of controllers C 13 and C 22 failure in Figures 5(c) and 6(c), RetroFlow's overhead reduces from 74% to 53% because it maps five switches, which are three switches less than the scenario of 100% flow recovery. When controllers C 20 and C 22 failure, RetroFlow reduces the communication overhead up to 61.2%.

RELATED WORKS
Pareto-based optimal controller-placement [6] minimizes different objectives (e.g., the latency between switches and controllers, latency between controllers) under controller failures. Works in [7] [29] try to find the best trade-off between the performance and cost during the controller failure under several constraints (e.g., load balancing and QoS). The solution in [30] proposes a controller placement model that ensures resiliency against the controller failure by minimizing the distance from a switch to its i-th closest controller. Capacitated Next Controller Placement [8] proposes a controller placement problem that not only considers the capacity and reliability of master controllers but also plans ahead for the master controller failure by considering a backup controller for each master controller. Different from all the aforementioned solutions, RetroFlow reduces the impact of controller failures by leveraging the features of hybrid SDN switches to maintain the advantage of SDN (i.e., flow programmability) and low communication overhead without overloading the rest active controllers.

CONCLUSION
In this paper, we propose RetroFlow to jointly achieve resilient network control and flow programmablility during controller failures. RetroFlow maintains active controllers' normal operations and programmablility of flows from offline switches while reducing the controllers' processing load from the offline switches by taking advantage of commercial hybrid SDN switches that support switches working under the legacy mode without controllers. By jointly considering the propagation delay and controllers' control cost in real time, RetroFlow also achieves a low communication overhead among offline switches and active controllers. We hope that our work can inspire researchers to creatively utilize existing features in commercial SDN switches to better solve existing problems.