# Dynamic Control Architecture Based on Software Defined Networking for the Internet of Things
## 3 System Model
Upon receiving this message, a node replies with an ACK. After the ACK reception, the Controller supposes that the specific node is going to sleep mode. If, after the sleeping period, the Controller does not receive a Hello packet from the node, it will consider the node disconnected from the network and it will remove him from the network view. In our implementation, the sleep interval of DC was set equal to the transmission period of Data messages; thus, nodes will be active only for the few seconds needed for data transmission. There are several routing policies that an SDN Controller is able to adopt, depending upon the choice of the time varying weights \(w_{i,j}(t)\) associated to each link, as expressed in the optimisation problem (1). An affordable solution could consider those weights as _constant_ over time, resulting in a _static_ strategy. If we specifically focus on the QoS constraints expressed in the optimisation problem (2), two opposite routing schemes are possible:  
* MinHop: This algorithm minimises only the number of hops between source and destination nodes (i.e., \(w_{\tau}(t)=1\,w_{\epsilon}(t)=0\,\ \forall t\)), thus being efficient especially in terms of latencies and overhead, but without taking into account the effect of energy consumption. * MaxBattery: This approach merely monitors each node residual battery level and minimises its consumption in order to optimise the overall network lifetime, that is \(w_{\tau}(t)=0\,w_{\epsilon}(t)=1\,\ \forall t\). It also includes power-saving additional techniques, such as the packet rate reduction and the duty cycling. In general, when taking into account both the energy consumption and delivery latency, a hybrid strategy is to be adopted, but always following a _dynamic_ approach. Specifically, we integrated this scheme on board of the SDN Controller within the so-called Dynamic Routing Module (DRM), which performs a real-time estimation of the network status, integrating the local information received by each node (i.e., neighbours list, link quality indicator and battery level), with a sampling frequency which depends on the e2e control signalling delay. Besides, the DRM is capable of updating the global weights and to apply the correct strategy, as again detailed along Algorithm 1. Initially, the SDN Controller modifies the traffic flows minimising the path length and updates the network status according to the control messages sent by the nodes. Specifically, it changes the status of the nodes following the \(T_{s}\) and \(T_{c}\) thresholds. If the sum of nodes in soft or critical status is greater than the remaining ones, the DRM deactivates the default strategy and starts to consider the battery levels in the traffic path evaluation. Finally, when the soft nodes are lower than the number of nodes in critical status, the algorithm mostly optimises the residual energy and accordingly performs traffic redirection. It could be noticed that the proposed approach is close to the MinHop one if the number of nodes in soft or critical state is lower than the remaining ones, while it is similar to the MaxBattery strategy whenever the number of nodes with a critical battery level is greater than the ones with soft energetic level. In conclusion, the proposed DRM aims at jointly increasing the network lifetime, achieving a more uniform battery consumption and keeping as low as possible the communication latencies between any couple of nodes. ```
Require: Sensor nodes and soft (Ts) and critical (Tc) thresholds Ensure: Tradeed between latency and energy consumption
1: Initialisation of the MinHop Strategy
2: Setting \(w_{tr}=1\) and \(w_{c}=0\)
3: Initialisation of a Network Graph \(\mathcal{G}=(\mathcal{V},\mathcal{E})\). 4: A Battery state vector B is set as an empty array. Each next element \(b_{i}\) in B is a list of two elements (address a, battery state s).