# Dynamic Control Architecture Based on Software Defined Networking for the Internet of Things
## 3 System Model  
The proposed SD-WSN architecture, combining the SDN paradigm with the main traditional WSN elements, is shown in Figure 1, where it is possible to notice the classical three-layers arrangement (i.e., DP, CP and AP). In more details, DP is responsible to process incoming data packets executing the CP directives. Differently from _wired_ SDNs, in which the traffic paths can be dynamically and easily managed by modifying the flow entries of the OpenFlow Switches and selecting the appropriate output port, in the wireless domain, this approach is usually not straightforward, because packets are always _broadcasted_. Therefore, an e2e wireless path needs to be controlled in order to avoid unintended loops, due to spurious _r_etransmissions. Depending on its different capabilities in handling data flows, a WSN node can be logically classified in:  
* _Root_ (or _Sink_) node h represents the unique interface between the local and an external IP network in order to collect or disseminate data. * _Non-Root_ node could be a:
* _Leaf_ node, which cannot support downstream connections, since it is not connected to any _child_ node; or
* _Relay_ (or _Intermediate Parent_) node, which is acting neither as a Root node or Leaf, and can transmit, receive and forward packets flowing in its upstream and downstream connections. Figure 1: Reference SDN-IoT architecture, which shows the presence of Application, Control and Data Planes. AP is comprised of both local and remote applications, while CP is composed of a Controller with endowed the routing module (DRM). Finally, generic sensor nodes are within DP, where only Root is physically connected to the Controller. The introduction of the SDN principle does not alter the node roles, but it shifts the routing task to the SDN Controller, which operates within the SDN CP and relies on a comprehensive and up-to-date view of the underlying WSN. Additionally, the SDN Controller can modify each node flows forwarding entries and dynamically change the data traffic path based on real-time requirements. The last feature is usually exploited by applications residing in the AP (though physically running in CP local devices or in remote Servers). It allows the interoperability of Cloud and Fog/Edge computing architecture in a dynamic way, depending on the evolution of the information flows which interest a large-scale distributed and heterogeneous systems, as depicted in Figure 1.  
Differently from traditional WSNs, in which nodes resort to distributed routing protocols, the SD-WSN architecture can dynamically adopt centralised and specific forwarding strategies by simply allowing the SDN Controller to _annotate_ the _network graph_ for improving the overall system flexibility, reliability, and lifetime. In particular, the proposed approach is focused on dynamically adjusting the routing strategy based on the real-time network state for enhancing the network _responsiveness_ and its _energetic footprint_. It is worth noticing that this policy being application-oriented is able to support time varying and heterogeneous QoS requirements usually originating when the Cloud and Fog/Edge architectures are effectively integrated. To take into account the above-mentioned goals, we combined the typical one way latency requirements of time sensitive applications, together with the energy constraints of a green IoT domain, by focusing on the following optimisation problem:  
\[\underset{w_{ij,i}}{\text{minimise}} \frac{\lambda(s,d)}{\theta(\pi_{s,d})}\] (1) subject to: \[s,d\in\mathcal{G}\] \[i,j\in\pi_{s,d}\] \[\phi_{s,out}=\phi_{d,in}\]  
where \(\mathcal{G}\) represents the overall network graph, \(s\) and \(d\) are a generic couple of source-destination nodes, \(\pi_{s,d}\) is a possible path connecting \(s\) to \(d\) and \(i\) and \(j\) ate two generic adjacent nodes along \(\pi_{s,d}\).