## 4 Proposed Method and Problem Formulations
### Problem Formulations  
This subsection presents the mathematical formulation of our proposed approach for migration modeling and controller placement. The fundamental requirement is that ONOS/SDN-IP should be directly connected with any one SDN switch for its operation. The first migrated switch is supposed to be the root source switch (RSS) that has a direct connection to the ONOS controller with a BGP speaker. The first router selected in the optimal path during migration is the RSS. The RSS is determined by the median router amongst the routers in the LSSP. The list of parameters used in the problem formulation of our proposed approach is defined in Table 2.  
The least cost path routers from source to destination are identified by Equation (1). The shortest path is calculated using the well-known Dijkstra algorithm [33]. \[\forall R\in V|A_{0},p\in P:p=[R_{s,d}]\leftarrow\Delta_{s,d}\text{ is the least} \tag{1}\]  
The median router that is best suited to directly connect to the controller for control path latency optimization is determined by Equation (2). \[\forall R_{s,d}\in V|p:\mathbb{R}=R_{k},\text{where }k= \begin{cases}\frac{n}{2},& \text{for }n\text{ is even}\\ \frac{n+1}{2},&\text{for }n\text{ is odd}\end{cases}  \tag{2}\]  
where \"\(n\)\" is the number of routers in the shortest path. The sequence of routers to be migrated in the shortest path is identified using BFT, then only the routers which are not already migrated to switches are set into migration. The median router is migrated first, and then other routers are either upgraded or replaced using the BFT approach. Router replacement planning using the BFT approach is termed as the breadth-first router replacement (BFR) mechanism. Equation (3) defines the median router replacement, while Equation (4) defines the BFT on other router replacements in the shortest path. If we define a timestamp (\(T_{p}\)) of 6 months to be considered to migrate routers in the shortest paths, then the total time period for whole network migration depends on the size of the network. \[\forall\mathbb{R},\phi_{0}^{s}=migrate(\mathbb{R}),\text{ if }x_{0}=0 \tag{3}\]  
\[\forall R_{i}\in BFT(R_{s,d},\mathbb{R})|p,\tau\in(1,...t\subseteq T_{p}):migrate (R_{i})\text{ if }x_{i}=0 \tag{4}\]  
Figure 2: Transition steps from source network to target network (**a**)–(**f**). AS, autonomous system, GR, gateway router. The functions \"\(migrate()\)\" in Equations (3) and (4) transform the legacy router into a SoDIP6-capable switch. Router migration means either upgrading the device hardware/firmware to make it compatible with SDN/IPv6 or replacing the device with a newer one that is already SoDIP6-capable. The details on router migration considering technical and budgetary constraints are discussed in our previous work [7]. If customer endpoint router is originated from AS1, then the shortest path routers from GR1 to GR4 are (R1, R5, R2). To replace these routers into SoDIP6-capable switches, we drill the network in the sequence (GR1, R1, R2, GR4). However, whenever a router is replaced by an SDN switch, the network turns into hybrid SDN, and a controller should directly be attached with that switch to establish the communication as shown in Figure 2b. In this drilling, router R5 is selected as the median router for migration. After router R5 is replaced to switch S5, it is now called the root source switch (RSS). All the traffic to be routed through the RSS is to be managed by the controller where iBGP peering sessions are to be established between switch gateway routers (R1, R6, R2) that are directly connected with switch S5. Multiple sessions with multiple paths as BGP multi-homing can be established between the BGP speaker and switch gateway routers (iBGP routers) of AS0, which ensures better failure handling. The first established controller is the master controller, while other controllers will be established based on control traffic load in the future during the migration of other routers.