# Energy-Saving Traffic Scheduling in Hybrid Software Defined Wireless Reschargeable Sensor Networks
## 5 Energy-Aware Traffic Scheduling Algorithm  
As mentioned above, the problem of energy-saving traffic scheduling in hybrid SDWRSNs is NP-hard. To prolong the steadily working time of the networks under new environments, we should fully consider the new characters in hybrid SDWRSNs, and take advantage of the SDN controller's direct control ability on SDN nodes and indirect control ability on normal nodes. Consequently, based on the above idea as well as the fast heuristic method, in this paper, we propose an Energy-aware Traffic Scheduling (ETS) Algorithm for hybrid SDWRSNs. The ETS Algorithm improves the energy efficiency by more energy efficient traffic scheduling schemes, which mainly solves the following three problems:  
1. Enlarging the amount of sleeping nodes while satisfying the service requirements. Different from traditional energy saving algorithms in normal wireless sensor networks, in the effective charging scope of wireless chargers, ETS does not need to consider energy consumption balance among different nodes, or single node's lifetime. ETS algorithm converts the energy consumption of each node into the final energy consumption of the wireless charger, and pays attention to minimize the finally total energy consumption. 2. The trade-off among different nodes that would be turned into sleeping state. As described above, the same energy consumption in different nodes will result in a different burden on the whole network, or specifically, to the wireless chargers. The ETS algorithm prefers to turn nodes farther to wireless chargers into sleep so as to decrease the energy loss in charging. 3. The indirect control ability of SDN controllers on normal nodes. In the process of the ETS algorithm, the SDN controller selects the directions of flows on SDN nodes and thus influences the inputted flows on normal nodes, so as to change the normal nodes on the selected path, and achieve a more energy efficient traffic scheduling pattern. In this paper, while the SDN nodes choose routes according to the flow table determined by the SDN controller, the normal nodes are running MTE protocol. For convenience, the route calculated according to MTE protocol are called MTE route in this paper. When an MTE route of a certain flow has at least one SDN node, we define this flow as an SDN flow; otherwise, it is a normal flow. Algorithm 1 describes the process framework of ETS. According to current flow distribution and network topology, we choose an MTE route for each flow and judge whether it is an SDN flow or a normal flow. For the normal flows, the SDN controller cannot schedule them directly. Therefore, the nodes on the routes for normal flows must be active. The normal flows should be distributed according to their MTE routes in the first place. Then, for the SDN flows, the first SDN node on its MTE route should be recorded. Algorithms 2 and 3 embody the advantages of SDN nodes provided as compared to the normal nodes, i.e., on the basis of MTE, adjusting the distribution of flows after they arrive the SDN nodes. Algorithm 2 is used to find all the optional paths (as defined in Definition 1) for an SDN flow.