# Dynamic Allocation of SDN Controllers in NFV-Based MEC for the Internet of Vehicles
## 4 Problem Formulation  
In the proposed architecture depicted in Figure 1, the vehicular connectivity to the infrastructure is achieved through access points such as (IEEE 802.11p/DSRC) RSUs but is extensible to small cell or RRH (Remote Radio Head). For the sake of modeling, we considered that all RSUs have the same coverage and the MEC servers are located at the gNB. Each RSU is directly connected to the gNB site through a one-hop high-speed connection, forming an arrangement. The mobile core is not shown in Figure 1 for modeling purposes, our system considers reliable RSUs connections, but our architecture allows switching the connectivity to gNB when vehicles have both interfaces. Both RSUs and gNB are openflow-enabled, whereas the SDN controllers are instantiated at the MEC server. We assume that there is sufficient capacity in the existing controllers to meet vehicle requests and that vehicles must first request content through an access point in order to acquire services. Considering there is no flow-rule to handle the request, the RSU issues a packet-in message to an SDN controller at the MEC to acquire a flow-rule. Then, the controller responds by sending a flow-mod message to the RSU to install a new entry in its flow-table. The _Monitor_ periodically monitors the number of requests from the RSUs, \(D_{j}\), and decides upon the assignment of RSUs to SDN controllers in order to balance the vehicular traffic/requests. Figure 3: Sequence diagram for heuristic decision and assignment/deployment of SDN controllers. Furthermore, the RSUs will be connected to its arrangement's gNB through Ethernet links to reduce 5G connectivity costs. Let \(M\) be the set of RSUs; then each RSU \(j\) is responsible for receiving requests from vehicles, while \(D_{j}\) is the number of all requests from each vehicle to the RSU \(j\). In this way, \(Y_{i}\) is a binary variable representing whether or not the controller \(i\) from \(N\) is picked. The controller capacity \(i\) is defined as \(C_{i}\) and the number of requests \(D_{j}\) from vehicles to RSUs assigned to a controller should not surpass the capacity \(C_{i}\). Besides, a resource reservation factor of \(0\leq\omega\leq 1\) is granted to avoid overloading controllers during resizing periods. Table 4 defines the notations used in this letter. Figure 4 shows the flowchart of proposed model optimization approach. \[Minimize: \sum_{i=1}^{N}(1-\omega)\cdot C_{i}\cdot Y_{i}-\sum_{j=1}^{M}D_{j} \tag{1}\] \[S.T: \sum_{j=1}^{M}D_{j}\cdot X_{ij}\leq(1-\omega)\cdot C_{i}\cdot Y_{i },\hskip 14.226378 pt\forall i\in N,\] (2) \[\sum_{i=1}^{N}X_{ij}=1,\hskip 14.226378 pt\forall j\in M,\] (3) \[X_{ij}\in\{0,1\},\hskip 14.226378 pt\forall i\in N,\forall j\in M,\] (4) \[Y_{i}\in\{0,1\},\hskip 14.226378 pt\forall i\in N. \tag{5}\]  
Figure 4: Flowchart of proposed model optimization approach. The objective function defined in Equation (1) aims to minimize the number of wasted resources; Constraint (2) ensures that the sum of the requests assigned to the controller does not exceed its capacity. Constraint (3) defines that an RSU is assigned to only one controller. Constraints (4) and (5) define the binary variables. HeuristicThis section describes the proposed heuristic implemented by the Autonomic Manager named aSDNalloc - autonomic SDN allocator. aSDNalloc allocates dynamically computational resources to VNFs that run SDN controllers and applications. This solution is of fundamental importance to DSDVMEC since it reduces the amount of idle resources allocated to the controllers deployed in an MEC-NFV environment, which is not a resourceful data center. aSDNalloc was designed to run in shortest possible time without sacrificing the quality of the obtained solution.