SD-EAR: Energy Aware Routing in Software Defined Wireless Sensor Networks

In today’s internet-of-things (IoT) environment, wireless sensor networks (WSNs) have many advantages, with broad applications in different areas including environmental monitoring, maintaining security, etc. However, high energy depletion may lead to node failures in WSNs. In most WSNs, nodes deplete energy mainly because of the flooding and broadcasting of route-request (RREQ) packets, which is essential for route discovery in WSNs. The present article models wireless sensor networks as software-defined wireless sensor networks (SD-WSNs) where the network is divided into multiple clusters or zones, and each zone is controlled by a software-defined network (SDN) controller. The SDN controller is aware of the topology of each zone, and finds out the optimum energy efficient path from any source to any destination inside the zone. For destinations outside of the zone, the SDN controller of the source zone instructs the source to send a message to all of the peripheral nodes in that zone, so that they can forward the message to the peripheral nodes in other zones, and the process goes on until a destination is found. As far as energy-efficient path selection is concerned, the SDN controller of a zone is aware of the connectivity and residual energy of each node. Therefore, it is capable of discovering an optimum energy efficient path from any source to any destination inside as well as outside of the zone of the source. Accordingly, flow tables in different routers are updated dynamically. The task of route discovery is shifted from individual nodes to controllers, and as a result, the flooding of route-requests is completely eliminated. Software-defined energy aware routing (SD-EAR)also proposes an innovative sleeping strategy where exhausted nodes are allowed to go to sleep through a sleep request—sleep grant mechanism. All of these result in huge energy savings in SD-WSN, as shown in the simulation results.


Introduction
The internet of things (IoT) has gained considerable attention recently from industry and academia. An important component of IoT is wireless sensor networks (WSN). Energy efficiency in the routing of WSNs is extremely necessary to preserve energy and increase the lifetime of nodes . Nodes in wireless sensor networks deplete quickly if a huge number of route discoveries are initiated. One route discovery means the broadcasting of route-request to all of the nodes in the network. This requires an excessive number of unnecessary forwarding of route-requests, especially if the source or the routers do not know of a recent destination or location. In order to save energy, nodes try to go to sleep, but there is no central authority who can judge whether the sleep request is valid or not. Therefore, nodes take decisions on their own, and this information is propagated only to its neighbors; it cannot be circulated throughout the network to avoid energy consumption. Therefore, if a source wants to to its neighbors; it cannot be circulated throughout the network to avoid energy consumption. Therefore, if a source wants to communicate with one such sleeping node, then all of its associated forwarding of route-requests will go in vain.

What is SDN?
Software defined networking (SDN) is a recent trend of a network that introduces the idea of eliminating tight coupling between the control and the forwarding plane. The network can be broadly divided into three components: a centralized controller, hosts, and switches that connect a pair of hosts, a pair of switches, or a host-switch pair. Northbound and southbound application programming interfaces (APIs) are there to establish communication between various network entities. The centralized controller has the responsibility of configuring forwarding planes (popularly termed as flow tables) according to which switches forward the packets during communication. The basic structure of an SDN appears in Figure 1.
SDN is deployed in various types of networks, such as LAN, MAN, WAN, data center networks, etc. The advantages are flexible network control without sacrificing forwarding performance, ease of implementation, administration, and ample opportunities of reducing energy consumption [44,45]. SDN has proven to be extremely successful in highly scalable data centers extending from private enterprises to public sectors where managing big data is not the only issue [8][9][10]; thousands of new data are being generated every day to satisfy the requirements of various applications initiated by different levels of users. OpenFlow-based SDN data centers have set a new trend as far as performance efficiency is concerned. Scheduling the flows to various ports is a very important component of network flow control. Also, the occasional deactivation of switches is required to preserve energy. Reduction of energy consumption is an important aspect of efficiency in SDN.

Contributions of the Present Paper
In the present paper, software defined energy aware routing (SD-EAR) and SDN divide the completely distributed structure of a sensor network into clusters or zones where each controller is in charge of one zone. The controllers are aware of the topologies of the associated zone, and also keep track of peripheral nodes. Peripheral nodes in a zone are nodes that have some portion of radio circle outside the zone. SD-EAR particularly aims at proposing an energy-efficient routing protocol along with a sleeping strategy to promote energy preservation in the network. Its novelties are as follows: Reduction of energy consumption is an important aspect of efficiency in SDN.

Contributions of the Present Paper
In the present paper, software defined energy aware routing (SD-EAR) and SDN divide the completely distributed structure of a sensor network into clusters or zones where each controller is in charge of one zone. The controllers are aware of the topologies of the associated zone, and also keep track of peripheral nodes. Peripheral nodes in a zone are nodes that have some portion of radio circle outside the zone. SD-EAR particularly aims at proposing an energy-efficient routing protocol along with a sleeping strategy to promote energy preservation in the network. Its novelties are as follows: (i) Normally in a WSN, whenever a source needs to establish a route to a sink, it mostly applies blind flooding [27,33,38,39] or gossiping [38,39]. In flooding, each router retransmits the route-request (RREQ) generated by a source to all of its neighbors, whereas the gossiping technique enables the routers to select a subset of neighbors to rebroadcast the route-request packet. Both of these suffer from redundancies that unnecessarily eat up energies in routers. In SD-EAR, since the SDN controller of each zone is aware of the zonal topology, it is capable of finding all of the possible paths between a given source and a destination through the depth-first traversal technique if both the source and destination are within the same zone. Among all of these paths, one optimal path is selected by a fuzzy controller named FUZZ-OPT-ROUTE, which is embedded within each SDN controller. If the destination is not within same zone as the source, then the SDN controller of the source zone instructs the source to send a request for discovering the route to the destination or to all of the peripheral nodes in the zone, through the optimum paths selected by the FUZZ-OPT-ROUTE embedded in the SDN controller of the source. Routers perform similar to the source. SD-EAR gives special weight to the presence of alternative nodes in live communication paths. As a result, the broadcasting of a route-request is eliminated irrespective of intra-zone or inter-zone communication, resulting in huge message saving. (ii) An alternative node n v of a node n u in a live communication route R, should be such that energy efficiency as well as the lifetime of R should not decrease after replacing n u with n v . This provides a facility to improve the residual energy and lifetime of a route. It may happen that after replacing the least energy node with an alternative, the new minimum energy becomes higher than the previous minimum. In that case, the new minimum will depend upon other nodes in the route except the one with the previous minimum energy. Assuming all of these nodes to be equally likely, we consider both the minimum and average residual energy to compute the residual energy effect of a route. Please note that the alternatives for a node are searched if its battery is almost exhausted. (iii) A sleeping strategy is also proposed where nodes that request to go to sleep are granted sleep by the SDN controller of the zone, provided the situation demands so. All of these help to greatly reduce the energy consumption in the network, and increase network throughput. Also, the provision of forceful sleep is introduced in which if all of the neighbors of a node are suffering from exhausted battery, then n u is directed by the SDN controller to go to sleep. All of these result in great energy saving by avoiding the broadcasting of route-requests during route discovery as well as rediscovery.

Organization of the Article
Related work is presented in Section 2, whereas a detailed network framework appears in Section 3. Section 4 illustrates routing in SD-EAR along with proposed sleep request-sleep grant mechanism. Section 5 presents simulation results, and Section 6 concludes the paper.

Related Work
Currently, most applications and services in WSN, such as network flexibility, network management, energy conservation, network robustness, and packet loss probability, rely on a data exchange between the sensor nodes and the switch infrastructure, or among sensor nodes. We divide all of the energy-efficient approaches to WSNs in two groups: non-software defined and software defined. These are described below.

Non-Software Defined Energy-Efficient Approaches
LEACH (Low energy adaptive clustering hierarchy), SPIN (Sensor protocol for information via negotiation), threshold-sensitive energy-efficient sensor networks (TEEN), etc. are extremely important from the perspective of non-software defined energy efficiency in sensor networks. The idea of LEACH protocol is to organize the sensor nodes into clusters, where each cluster has one cluster head CH that acts as a router to the base station. However, the LEACH protocol has problems; one of those problems is the random selection of a cluster head or CHs [35,36,43]. This process does not consider the location of sensor nodes in the wireless sensor network, and hence, the sensor nodes may be very far from their CH, causing them to consume more energy to communicate with the CH [35,36,43]. The role of the cluster head is rotated in order to balance the energy consumption among multiple nodes. The optimum route chosen for communication is the shortest one computed using Dijkstra's shortest path algorithm [36]. However, the shortest route is not always the most energy-efficient option.
SPIN [38] is another energy-efficient routing protocol worthy of mention; which is a modification of classic flooding. In classical flooding, the information is forwarded on every outgoing link of a node. This drains out the battery of a huge number of nodes in the sensor network. SPIN was developed to overcome this drawback. It is an adaptive routing protocol that transmits the information first by negotiating. It proposes the use of metadata of actual data to be sent. Metadata contains a description of the actual message that the node wants to send. Actual data will be transmitted only if the node wishes to receive it, that is, it is similar to being keen to watch a movie after viewing its trailer. In this context, we humbly state that SPIN requires the broadcasting of metadata at least. However, an important aspect of the energy efficiency of SD-EAR arises from it not requiring broadcasting to establish routes.
TEEN (threshold-sensitive energy-efficient sensor networks) [46] protocol was proposed for time-critical applications. Here, sensor nodes sense the medium continuously, but data transmission is done less frequently. A cluster head sensor sends its members a hard threshold (HT), which is the threshold value of sensed attribute, and a soft threshold (ST), which is a small change in the value of the sensed attribute that triggers the node to switch on its transmitter and transmit. The main drawback of this scheme is that if the thresholds are not received, the nodes will never communicate, and the user will not get any data from the network at all. Also, it has the complexity associated with forming clusters at multiple levels and the method of implementing threshold-based functions [46].

Software Defined Energy-Efficient Approaches
Figueiredo et al. [12] used multiple adaptive hybrid approaches, which are considered better than a single algorithm. This work (which subsequently will be referred to as software defined wireless sensor network 1, or SD-WSN1, in this article) discusses the usage of policies to establish adaptive routing rules so that the WSN elements of a network can acquire more flexible and accessible development and maintenance tasks. The routing policy is either proactive or reactive. If the number of nodes in the network is less than a pre-defined threshold, then proactive routing is applied to determine the forwarding rules in order to save the cost of route discovery. However, if the number of nodes in the network crosses a pre-defined threshold, then proactive routing becomes impossible due to an abnormal rise in the size of the flow table. Reactive routing follows the behavior of ad hoc distance vector routing, or AODV. This applies flooding for route discovery. Ejaz et al. [20] designed an energy-efficient SD-WSN (which subsequently will be referred to as SD-WSN2 in this article) to minimize the energy consumption of energy transmitters. This article is based on the energy that is transferred to sensor nodes through energy transmitters. It aims at the optimal placement of energy transmitters, which depends on the trade-off between the minimum energy charged in the network and a fair distribution of energy. This does not propose any energy-efficient routing protocol or sleeping strategy of nodes. Xiang et al. [21] studied an energy-efficient routing algorithm for SD-WSN (which subsequently will be referred to as SD-WSN3 in this article) by selecting the control nodes and assigning different tasks dynamically through control nodes. SD-WSN3 selects some control nodes out of all of the nodes in the network using the particle swarm optimization method. These nodes assign tasks to others depending upon their residual energy. However, it is very difficult to determine the exact number of required control nodes, and how many nodes will be under the control of one particular control node.
Luo et al. [10] proposed a software-defined WSN architecture to solve the rigidity of policies and the difficulty of management by addressing Sensor OpenFlow. Jacobsson and Orfanidis [11] adopted low-cost off-the-shelf hardware and an individual deployment method to flexibly reconfigure WSN networking and in-network processing functionality. Regarding the network management, Gante et al. [13] presented a smart management in WSN by employing the OpenFlow protocol and modifying the forwarding rule in the controller, which can use the unified standard to communicate with all of the nodes. A networking solution called SDN-WISE was proposed by Galluccio et al. [14] to simplify the management of the network. Olivier et al. [15] proposed a cluster-based architecture with multiple base stations used as hosts for the SDN control functions as well as cluster heads, and adopted a structured and hierarchical management. Modieginyane et al. [16] summarized the application challenges faced by WSNs for monitored environments and the opportunities that can be realized in applications of WSNs using SDN.
Jayashree et al. [19] proposed a framework for a software-defined wireless sensor network, where the sensor node only performed the forwarding. The controller was implemented as the base station in this framework, thus reducing the energy consumption. For packet loss probability and robustness, Levendovszky et al. [22] provided the Hopfield neural network to guarantee uniform packet loss probabilities for the nodes. Sachenko et al. [23] presented modified correction codes based on a residual number system, high correction characteristics, and a simplified coding procedure to show the characteristics of these codes, which can improve the data transmission robustness in WSN.
Jin et al. [24] dealt with the packet loss by designing a hierarchical data transmission framework of a suitable industrial environment. For a real industrial environment, the commonly-used WSN framework discussed above is not well suited to the environment's unique characteristics, such as a harsh application environment, a strict requirement for data transmission, data diversity, and so on. The traditional SD-WSN framework is a universal network framework that is not specific to the IoT. In order to resolve these problems and adapt the framework for an industrial environment, we will present an improved SD-WSN framework in the next section.

Network Framework in SD-EAR
The software defined wireless sensor network framework consists of the following layers, as shown in Figure 2.

Physical Layer (PL)
This layer consists of several sensor nodes that connect with the SDN controller through OpenFlow protocol [4], and receive relevant flow table information from the SDN controller in that zone. Please note that nodes are divided into certain zones, and each zone is under one unique controller.

Virtualization Layer (VL)
The key nodes of the sensor network in the physical layer map to virtual key nodes, in order to form the virtual node layer (virtual layer).

Control Layer (CL)
Controllers in the control layer provide routing, sleep monitoring, and other services to achieve the intelligent management of the WSN. OpenFlow protocol is used to transmit optimum route information to the various nodes that are required to discover the route to some destination. Controllers are capable of generating interrupts to awaken sleepy nodes, and granting sleep requests to worthy or needy nodes.

Physical Layer (PL)
This layer consists of several sensor nodes that connect with the SDN controller through OpenFlow protocol [4], and receive relevant flow table information from the SDN controller in that zone. Please note that nodes are divided into certain zones, and each zone is under one unique controller.

Virtualization Layer (VL)
The key nodes of the sensor network in the physical layer map to virtual key nodes, in order to form the virtual node layer (virtual layer).

Control Layer (CL)
Controllers in the control layer provide routing, sleep monitoring, and other services to achieve the intelligent management of the WSN. OpenFlow protocol is used to transmit optimum route information to the various nodes that are required to discover the route to some destination. Controllers are capable of generating interrupts to awaken sleepy nodes, and granting sleep requests to worthy or needy nodes.
Depending upon the residual energy of the neighbors of a node, certain nodes are also sent mandatory sleep messages, which are forceful instructions for the node to go to sleep, even though it did not ask for a sleep session. All of these contribute to the reduced energy consumption of the network.

Application Layer (AL)
The strategy of each application is defined in the application layer. Each application obtains the network status (topology, node status, etc.) from the control layer, and makes decisions according to that strategy. The strategy instructs how services will be provided to the sensor node.

Network Model
Network is modeled as a graph G = (V, E) where V represents the set of vertices or sensor nodes, and E represents the set of edges between those nodes. The SDN controller of a zone Z p (1 ≤ p ≤ P; P is the number of all of the zones in the network) consists of the two following tables: The network topology of zone Z p is stored in the form of the adjacency list in NET-TOPL p . The attributes of this table are: (i) node-id (ii) neighbor-list node-id specifies the unique identification number of a node, whereas neighbor-list is the set of neighbors of the node. NODE-STAT p is a table that contains information about all of the nodes within the zone Z p . The components of this information are: (i) node-id (ii) (latitude, longitude) pair (iii) radio range (iv) maximum energy (v) most recent residual energy (vi) most recent rate of energy depletion (vii) minimum receive power (viii) sleep status (ix) last sleep timestamp (x) peripheral status For a node n i , the present geographical position in terms of the (latitude, longitude) pair is specified as (x i , y i ), with its radio range being rad i . Maximum energy, the last known residual energy, and the rate of battery depletion are denoted as m-en i , r-en i , and dep i . Sleep status slp i is 1 if currently n i is sleeping; it is 0 otherwise. τ-sl i is the most recent timestamp when n i went to sleep. The peripheral status of n i is given by pphr i . It is set to 1 if the radio circle of current node n i is not completely embedded within the area of the zone, i.e., it may have some neighbor belonging to any neighboring zone of Z p . Otherwise, it is set to 0.
Whenever a node n i starts its operation in the network, it has to first register itself by sending a registration request message to the SDN controller. The components of the registration request are: Receiving the registration request of n i , the corresponding SDN controller checks the NODE-STAT p table to determine whether any entry with same node identifier n i exists within that table. If yes, then an id-clash message will be sent back to n i . The components of an id-clash message are: On the other hand, if no such event of a node identifier clash is detected, then a registration-success message is sent to n i . The attributes of registration-success are the same as id-clash; only the message-type-id is set to 2. After that, the peripheral status of n i is determined. It finds out whether the radio circle of n i is completely embedded within a zone. Three types of zone structures are considered: polygonal, circular, and elliptic. The polygonal structure is the closest to the real life scenario, while the circular structure is the ideal one, where the neighborhood of a node spreads around the node equally in all directions. Please note that the circle is a special kind of ellipse, where both foci are at the same point (the center). Therefore, both circular and elliptic structures have been considered in our simulation. Below, we derive the conditions under which a polygonal, circular, or elliptic zone embeds a radio circle of n i . If the radio circle of n i is completely embedded in the zone, then pphr i is set to 0; otherwise, it is 1.
Situation 1: The zone under inspection is polygonal, defined by consecutive vertices (x v+q , y v+q ) s.t. 0 ≤ q ≤ Q; the node to be embedded has center (x i , y i ) and a radiorange ofrad i .
The situation is expressed in Figure 3. (v) maximum energy Receiving the registration request of ni, the corresponding SDN controller checks the NODE-STATp table to determine whether any entry with same node identifier ni exists within that table. If yes, then an id-clash message will be sent back to ni. The components of an id-clash message are: On the other hand, if no such event of a node identifier clash is detected, then a registrationsuccess message is sent to ni. The attributes of registration-success are the same as id-clash; only the message-type-id is set to 2. After that, the peripheral status of ni is determined. It finds out whether the radio circle of ni is completely embedded within a zone. Three types of zone structures are considered: polygonal, circular, and elliptic. The polygonal structure is the closest to the real life scenario, while the circular structure is the ideal one, where the neighborhood of a node spreads around the node equally in all directions. Please note that the circle is a special kind of ellipse, where both foci are at the same point (the center). Therefore, both circular and elliptic structures have been considered in our simulation. Below, we derive the conditions under which a polygonal, circular, or elliptic zone embeds a radio circle of ni. If the radio circle of ni is completely embedded in the zone, then pphri is set to 0; otherwise, it is 1.
Situation 1: The zone under inspection is polygonal, defined by consecutive vertices (xv+q, yv+q) s.t. 0 ≤ q ≤ Q; the node to be embedded has center (xi, yi) and a radiorange ofradi.
The situation is expressed in Figure 3. Consider one particular edge E from (xv, yv) to (xv+1, yv+1). The slope m1 of E is mathematically expressed in Equation (1): Let C be the center of the radio-circle of ni. The shortest distance from C to edge E is given by the length of perpendicular from C to E. Assume that the perpendicular drawn on E from C intersects E at point W. Then, the slope m2 of CW is related to m1 as in Equation (2): CW passes through the point (xi, yi). Based on this, the equation of CW appears in Equation (3): where: and: Consider one particular edge E from (x v , y v ) to (x v+1 , y v+1 ). The slope m 1 of E is mathematically expressed in Equation (1): Let C be the center of the radio-circle of n i . The shortest distance from C to edge E is given by the length of perpendicular from C to E. Assume that the perpendicular drawn on E from C intersects E at point W. Then, the slope m 2 of CW is related to m1 as in Equation (2): CW passes through the point (x i , y i ). Based on this, the equation of CW appears in Equation (3): where: and The equation of the edge E from (x v , y v ) to (x v+1 , y v+1 ) is mathematically expressed in Equation (6): The coordinates (w x , w y ) of the point of intersection of edge E and CW (i.e., the point W) are given by: If the Cartesian distance between the two points (x i , y i ) and (w x , w y ) is greater than or equal to rad i , then it can be concluded that the radio-circle of n i is embedded within the given zone. The mathematical version of the condition appears in Equation (10): If such a condition (as in Equation (10)) is satisfied by all of the edges of the polygon, then it can be concluded that the radio circle of n i is completely bounded by the polygonal zone.
Situation 2: The zone Z p under inspection is circular, defined by cnter (x(Z p ), y(Z p )) and radius rad(Z p ); the node to be embedded has center (x i , y i ) and a radio range rad i of n i The situation is expressed in Figure 4.
The equation of the edge E from (xv, yv) to (xv+1, yv+1) is mathematically expressed in Equation (6): The coordinates (wx, wy) of the point of intersection of edge E and CW (i.e., the point W) are given by: If the Cartesian distance between the two points (xi, yi) and (wx, wy) is greater than or equal to radi, then it can be concluded that the radio-circle of ni is embedded within the given zone. The mathematical version of the condition appears in Equation (10): If such a condition (as in Equation (10)) is satisfied by all of the edges of the polygon, then it can be concluded that the radio circle of ni is completely bounded by the polygonal zone.
Situation 2: The zone Zp under inspection is circular, defined by cnter (x(Zp), y(Zp)) and radius rad(Zp); the node to be embedded has center (xi, yi) and a radio range radi of ni The situation is expressed in Figure 4. In Figure 4, AQ is the radius of the zone; AM specifies the distance between the centers of the zone and node ni. Please note that node ni is positioned at point M. MN is the radio range of the node. The mathematical expressions for AQ, AM, and MN appear in Equations (11-(13): The required conditions for circle embedding appears in Equation (14): Situation 3: The zone under inspection is elliptic, as defined by Equation (15); the node to be embedded has center (xi, yi) and a radio range of radi. In Figure 4, AQ is the radius of the zone; AM specifies the distance between the centers of the zone and node n i . Please note that node n i is positioned at point M. MN is the radio range of the node. The mathematical expressions for AQ, AM, and MN appear in Equations (11)-(13): The required conditions for circle embedding appears in Equation (14): Situation 3: The zone under inspection is elliptic, as defined by Equation (15); the node to be embedded has center (x i , y i ) and a radio range of rad i .
The situation is represented in Figure 5.
The situation is represented in Figure 5. The node to be embedded has a center of O (xi, yi) and a radio range of radi. (h,k) is the center of the ellipse. We draw a line AB through O i.e., the center of the radio circle of ni, parallel to the Y axis. The line intersects the ellipse at points A and B. Similarly, we draw a horizontal line through O, i.e., the center of the radio circle of ni, parallel to the X axis. The line intersects the ellipse at points C and D. In order to compute the coordination of A and B, we need to put x = xi into the equation of the ellipse, and calculate the corresponding x coordinates. Similarly, to calculate the coordinates of C and D, we need to put y = yi.
Putting x = xi in the equation of the ellipse: Without any loss of generality, the y coordinates of A and B are y1 and y2, respectively, s.t.: Putting y = yi in the equation of the ellipse: Therefore, the x coordinates of A and B are either x1 or x2 s.t.: If OA < min(b,OB) and OC < min(a,OD) and OC > OA, then the circle is embedded in the zonal ellipse.
After determining the peripheral characteristics of the new node, ni, the SDN controller inserts an entry ENTR(i) corresponding to ni in the NODE-STATp table. The node to be embedded has a center of O (x i , y i ) and a radio range of rad i . (h,k) is the center of the ellipse. We draw a line AB through O i.e., the center of the radio circle of n i , parallel to the Y axis. The line intersects the ellipse at points A and B. Similarly, we draw a horizontal line through O, i.e., the center of the radio circle of n i , parallel to the X axis. The line intersects the ellipse at points C and D. In order to compute the coordination of A and B, we need to put x = x i into the equation of the ellipse, and calculate the corresponding x coordinates. Similarly, to calculate the coordinates of C and D, we need to put y = y i . Putting x = x i in the equation of the ellipse: Without any loss of generality, the y coordinates of A and B are y 1 and y 2 , respectively, s.t.: Putting y = y i in the equation of the ellipse: Therefore, the x coordinates of A and B are either x 1 or x 2 s.t.: After determining the peripheral characteristics of the new node, n i , the SDN controller inserts an entry ENTR(i) corresponding to n i in the NODE-STAT p table.
ENTR(i) = (n i , x i , y i , rad i , m-en i , m-en i , 0, 0, −1, pphr i ) Accordingly, NET-TOPL p is also updated. The information in this table corresponding to n i is (n i , EN(i)) where EN(i) is the set of neighbors of n i in zone Z p itself. A node n j in zone Z p will be the neighbor of n i provided the following condition is true. Generally in sensor networks, the links are bi-directional [2,4,10,15,17]. We have kept this property intact for SD-EAR for simplicity purposes.
The flowchart for node registration process appears in Figure 6, where node n i is about to start its operation at zone Z p . Let the SDN controller of Z p be denoted as S p . neighbor of ni provided the following condition is true. Generally in sensor networks, the links are bi-directional [2,4,10,15,17]. We have kept this property intact for SD-EAR for simplicity purposes.
The flowchart for node registration process appears in Figure 6, where node ni is about to start its operation at zone Zp. Let the SDN controller of Zp be denoted as Sp.

Optimum Route Selection
Whenever a node ni wants to communicate with another node nj, it sends an opt-route-select message to the SDN controller. The attributes of opt-route-select are: Receiving opt-route-select from ni, the SDN controller of zone Zp checks to see whether destination nj belongs to the same zone or not. This is performed by searching nj in the NODE-STATp

Optimum Route Selection
Whenever a node n i wants to communicate with another node n j , it sends an opt-route-select message to the SDN controller. The attributes of opt-route-select are: (i) message-type-id (3) (ii) source-id (n i ) (iii) destination-id (n j ) (iv) timestamp (v) traversed-zone-list (initially it is {Z p } only; this field is particularly required for inter-zone communication. Whenever opt-route-select arrives at a new zone, the identification number of the new zone is added to the list) Receiving opt-route-select from n i , the SDN controller of zone Z p checks to see whether destination n j belongs to the same zone or not. This is performed by searching n j in the NODE-STAT p table. If n j ∈ extr(NODE-STAT p , 1), then an intra-zone route selection is performed; otherwise, an inter-zone route section is performed. Please note that extr(NODE-STAT p , 1) is a function that extracts 1-th field from the NODE-STAT p table.
After the selection of the optimal route, the SDN controller informs about the chosen sequence of routes to the source of communication in an opt-route-reply message. The attributes of opt-route-reply are: (i) message-type-id (4) (ii) source-id (n i ) (iii) destination-id (n j ) (iv) optimal sequence of routers with locations The flowchart of route discovery appears in Figure 7. inter-zone route section is performed. Please note that extr(NODE-STATp, 1) is a function that extracts 1-th field from the NODE-STATp table.
After the selection of the optimal route, the SDN controller informs about the chosen sequence of routes to the source of communication in an opt-route-reply message. The attributes of opt-routereply are: (i) message-type-id (4) (ii) source-id (ni) (iii) destination-id (nj) (iv) optimal sequence of routers with locations The flowchart of route discovery appears in Figure 7.

Intra-Zone Route Discovery with Example
If n j belongs to the same zone Z p , then the SDN controller finds all of the routes from n i to n j through the depth first traversal of the graph starting from n i . Among all of the available paths, the optimum one is selected based on a fuzzy controller FUZZ-OPT-ROUTE, which is embedded in the controller. This situation is depicted in Figure 8a, while Figure 8b shows the steps with respect to Figure 8a. Without any loss of generality, we consider a polygonal zone. optimum one is selected based on a fuzzy controller FUZZ-OPT-ROUTE, which is embedded in the controller. This situation is depicted in Figure 8a, while Figure 8b shows the steps with respect to Figure 8a. Without any loss of generality, we consider a polygonal zone.

Intra-zone communication is loop-free
The communication inside a zone is completely controlled by the SDN controller of the zone, which is aware of the topology of the entire zone. While discovering the optimum route between two nodes inside a zone, the controller of that zone applies depth-first traversal, which automatically eliminates loops. Therefore, intra-zone communication is loop-free.

Inter-Zone Route Discovery with Example
If destination nj doesn't belong to the same zone Zp as source ni, then the SDN controller Sp finds all of the routes from ni to all of the peripheral nodes of Zp through the depth-first traversal of the graph, starting from ni.
The situation can be seen in Figure 9a, while Figure 9b shows the steps of optimum route selection in case of inter-zone route discovery. In this case, opt-route-select has to be propagated to neighbors Zp, too. In that case, the SDN controller finds the routes from ni to all of the nodes nq ∈ extr(NODE-STATp,1) s.t. extr(NODE-STATp,9) = 1. nq forwards the opt-route-select to all of the neighbors that do not belong to Zp.
The neighbors of nq ask the SDN controllers of their respective zones to find out routes to all of the nodes in its neighbor list. Communication in neighbor zones may be again intra-zone or interzone. Please note that SDN controllers belonging to multiple zones do not directly communicate with each other. Rather, the peripheral nodes of various zones communicate with each other. Inter-zone communication is actually a collection of multiple intra-zone communications.
In inter-zone communication, if a SDN controller Sq of a zone Zq receives opt-route-select from more than one of its nodes corresponding to the same destination, then it sends opt-route-reply to the one with the highest residual energy (nb), while the others (say nc) are instructed to remain silent.

Intra-zone communication is loop-free
The communication inside a zone is completely controlled by the SDN controller of the zone, which is aware of the topology of the entire zone. While discovering the optimum route between two nodes inside a zone, the controller of that zone applies depth-first traversal, which automatically eliminates loops. Therefore, intra-zone communication is loop-free.

Inter-Zone Route Discovery with Example
If destination n j doesn't belong to the same zone Z p as source n i , then the SDN controller S p finds all of the routes from n i to all of the peripheral nodes of Z p through the depth-first traversal of the graph, starting from n i .
The situation can be seen in Figure 9a, while Figure 9b shows the steps of optimum route selection in case of inter-zone route discovery. In this case, opt-route-select has to be propagated to neighbors Z p , too. In that case, the SDN controller finds the routes from n i to all of the nodes n q ∈ extr(NODE-STAT p ,1) s.t. extr(NODE-STAT p ,9) = 1. n q forwards the opt-route-select to all of the neighbors that do not belong to Z p .
The neighbors of n q ask the SDN controllers of their respective zones to find out routes to all of the nodes in its neighbor list. Communication in neighbor zones may be again intra-zone or inter-zone. Please note that SDN controllers belonging to multiple zones do not directly communicate with each other. Rather, the peripheral nodes of various zones communicate with each other. Inter-zone communication is actually a collection of multiple intra-zone communications.
In inter-zone communication, if a SDN controller S q of a zone Z q receives opt-route-select from more than one of its nodes corresponding to the same destination, then it sends opt-route-reply to the one with the highest residual energy (n b ), while the others (say n c ) are instructed to remain silent. The attributes of this silence message are as follows: (i) message-type-id (5) The attributes of this silence message are as follows: (i) message-type-id (5) (ii) source-id (n i ) (iii) destination-id (n j ) (iv) router-id (n c )

Inter-zone communication is loop-free
The traversed-zone-list field contains the sequence of zones that one particular opt-route-select message has traversed. Therefore, one opt-route-select message cannot be propagated within a zone more than once. This avoids loops. Moreover, intra-zone communication from a node to the peripheral nodes of the zone are definitely loop-free, because they are determined by the SDN controller of that zone by dint of the depth-first traversal of the zonal topological graph. This technique is loop-free, as already mentioned, in case of intra-zone communication.
INPUT PARAMETERS OF FUZZ-OPT-ROUTE reft(R) or residual energy effect of route R This parameter indicates how the residual energy of nodes belonging to R influence the performance of the route. It is mathematically modeled in Equation (23): f-en 1 (R) = 1 − {1/(min r-en k + 2)} (24) n k ∈ R such that k = start(R) and k = end(R) start(R) and end(R) specify the source and destination nodes, respectively, in route R. If, for one particular route, no router nodes are there, then (minr-en k ) among all of the routers n k ∈R, will be 0.
f-en 2 (R) = 1 − {α(R)/(∑r-en k + 2)} n k ∈ R From the formulation in Equation (23), it is evident that reft(R) ranges between 0 and 1. It is close to 1 if the minimum and average residual energies of R are high. The high values of this parameter are beneficial for the performance of the route. In Equation (24), 2 is added to the denominator to avoid a zero value when the min r-en k among all of the routers n k ∈ R is 0. Similarly, in Equation (25), 2 is added to the denominator to avoid a zero value when r-en k of all of then k ∈ R is 0. If any one of the f-en 1 (R) and f-en 2 (R) is 0, then the effect of the other one will be completely eliminated, which is undesirable.

trim(R) or the transmission energy impact of route R
Transmission energy impact depends on the minimum received power of the nodes in route R and the maximum distance between consecutive nodes. With the increase in this distance and the minimum received power of the successors (by successor we mean all of the nodes except the source) in R, the transmission cost increases, while trim(R) decreases.
f-recv 1 (R) = (1 − ∑mrpw(succ(n k , R))/(α(R) × (max mrpw (n v ) + 1)) n k ∈ R n v ∈ Z p f-recv 2 (R) = max {1, dist(n k , succ(n k , R))} n k ∈ R succ(n k , R) is the successor node of n k in R. mrpw(n v ) is the minimum received power of node n v . dist(n a , n b ) specifies the Cartesian distance between nodes n a and n b .
From the formulation in Equation (26), we can see that trim lies between 0 and 1. High values of it contribute to improve the performance of R.

neff(R) or node efficiency in R
The node efficiency in a path will be high, as most of the nodes are awake, and alternatives are available to sleeping nodes (if any). A node n u will be an alternative to another node n v w.r.t. route provided the following conditions are satisfied: Condition (27a) specifies that n u should not belong to any live communication route passing through n v . Condition (27b) says that n v must have all of the neighbors of n u as its neighbors. The condition (27c) indicates that the additional forwarding load from neighbors of n u should not reduce the lifetime of n v below the lifetime of n u . If n u is an alternative of n v , then n u ∈ alt(v) where alt(v) is the set of all of the alternatives of n v .
The mathematical formulation of neff appears in Equation (28): n k ∈ R k = start(R) and From Equation (28), it is evident that the efficiency of a route increases with the number of awake nodes and the number of alternatives to sleepy nodes. neff lies between 0 and 1. High values of it indicate the efficiency of the associated route.

FUZZY RULE BASES OF FUZZ-OPT-ROUTE
All of the input parameters of the FUZZ-OPT-ROUTE are divided into four equal ranges between 0 and 1. The ranges and corresponding fuzzy premise variables are as follows: (i) 0-0.25 (LOW or 'L' is short) (ii) 0.25-0.50 (SATISFACTORY or 'S' in short) (iii) 0.50-0.75 (HIGH or 'H' in short) (iv) 0.75-1.00 (VERY HIGH or 'VH' in short) The rule bases of this fuzzy controller appear in Tables 1 and 2. Table 1 combines reft and trim, producing temporary output temp1. Both of these parameters are assigned equal weight, since both are equally important in determining the efficiency of the route. If a node has high residual energy but suffers from huge energy consumption due to the long distance from its successor in a communication path, then the energy efficiency of a path greatly reduces. Therefore, temp1 = min (reft, trim) in Table 1. Examples are: reft = H, trim = S, temp1 = S; reft = S, trim = L, temp1 = L; and reft = VH, trim = S, temp1 = S. The composition of temp1 and neff is presented in Table 2. Then eff of a route increases with an increased number of awake nodes and alternatives to sleepy nodes, if any. temp1 is given more weight than neff, only because a huge number of awake nodes will not do. They need to have high residual energy and a low transmission energy requirement in each hop so that the route can last for a long time. The influence of neff increases when temp1 is not high. Hence, in Table 2, when temp1 = L or S, the output opt-performance = min(temp1, neff). On the other hand, when temp1 = H or VH, small values of neff are capable of reducing it to some extent. For example, when temp1 = H and neff = L, opt-performance = S. The optimal path is the one that produces the best opt-performance. In the case of multiple optimal options, any one with the least weight is elected as optimal. Weight(R), that is, the weight of an optimal route R, is mathematically formulated below in Equation (29): γ(R) specifies the total number of sleepy nodes in R, while α(R) is the total number of nodes in R. If still a tie remains, then any one is chosen for communication.  Table 3 specifies all of the node ids in Figure 10 along with their descriptions. Based on these assumptions, we are about to find out the optimal route from n b to n d at current timestamp 100. The significance of all of the symbols used in Table 3 have been mentioned earlier in this section. For the purpose of simplicity, we have assumed that all of the links are bi-directional. The latitude and longitudinal positions are given in Table 3. It is seen from Figure 10 that n a is directly connected to n e only, while n e is directly connected to n a , n b , n g , n u , and n v . Among them, n u and n v are out of Z A . So, EN(a) = {n e } and pphr a = 0, since n e ∈ Z A . On the other hand, EN(a) = {n a , n b , n g , n u , n v } and pphr e = 1, since n u , n v / ∈ Z A . Similarly, the EN and pphr of other nodes can be computed. Other attribute values are assumed. The performances of different routes from n b to n d are calculated in the FUZZ-OPT-ROUTE of SDN controller of Z A .  The different routes from n b to n d obtained through a depth-first traversal of topology of Z A , are as follows: In this path, only n g is sleeping. We need to search for alternatives of n g . However, no node in zone Z A has the same set of neighbors as n g . So, n g has no alternative. neff(R 5 ) = [{1 − 1/(3 + 1)} (1 − 1/(0 + 2))] 0.5 = 0.61237 After fuzzification, the fuzzy premise variables corresponding t reft(R 5 ), trim(R 5 ), and eff(R 5 ) become VH, L, and H, respectively. Their combination, according to Tables 1 and 2, is L.
Hence, opt-performance = L R 1 and R 4 both have performance VH. Therefore, we compute the weight of these paths.
Therefore, R 1 is chosen as optimal.

Sleeping Strategy
Whenever a node n i wants to go to sleep, it needs to ask for permission from the SDN controller of that zone. It gets a sleep grant provided that the following conditions are true: (i) (r-en i /dep i ) < TH where TH is a threshold. (ii) If n i is part of any live communication route, then it must have at least one valid alternative.
The strategy of computing an alternative is present in (27a)-(27c).
Also, there is one forceful sleep grant mechanism. When all of the neighbors of a node n i are sleeping, then n i is instructed by the SDN controller in that zone to go to sleep if it does not want to transmit anything. It has practically no reason to listen to the network, because it has no way of receiving any traffic.
The attributes of a sleep request are: Similarly, the attributes of a sleep grant are: (i) message-type-id (6) (ii) node-id (n i )

Simulation Environment
This experiment is based on SDN and the IEEE 802.15.4 protocol for wireless sensor networks. The network emulator for the framework is Mininet [30], and the controller is Floodlight [31]. Floodlight runs on a server with an AMD Opteron processor 6348 and 16 GB memory. The server is installed with Linux kernel version 2.6.32. Mininet runs on a separate server, and the servers are connected by a 10 Gbps Ethernet network. Details appear in Table 4. Table 4. Simulation parameters.

Network Parameters Values
Number

Simulation Results
Graphical comparisons of SD-EAR with its state-of-the-art competitors LEACH, SPIN, SD-WSN1, SD-WSN2, and SD-WSN3, are presented in Figures 11-20.

SD-EAR versus LEACH, SPIN
LEACH divides the sensor network into multiple clusters. The technique for electing a clusterhead is the main source of energy efficiency here. If a node has already played the role of a clusterhead in several runs, then its chance of becoming a cluster-head in the next run again reduces greatly. This encourages the rolling of cluster-heads by the balancing load. However, LEACH does not consider the location of sensor nodes [35,36,43] and therefore, certain cluster members may stay very far from the cluster-head. So, the energy consumed by the cluster-head in transmitting a message to those members that are located far, increases substantially. Also, LEACH applies Dijkstra's shortest path algorithm to select the optimum path [43]. The authors would like to state here that shortest path, in most cases, is not the most energy-efficient one. Hence, the performance improvement produced by SD-EAR over LEACH is noteworthy. This is evident in Figures 11-15.
SPIN [38] is also a very important energy-efficient protocol that broadcasts metadata, which is data about data. If a neighbor develops interest about actual data after receiving the metadata, only then is data sent to it. The energy efficiency in SPIN arises from the size of the metadata being much less than the size of the actual data, and the actual data is sent to a subset of neighbors instead of all of the neighbors, as in an ordinary broadcast.
On the other hand, in SD-EAR, the broadcasting of an opt-route-select is not performed, not even in inter-zone communication. Actually, in the inter-zone route discovery, opt-route-select is at most multicast to all of the peripheral nodes, as well as also through energy-efficient paths, as instructed by the SDN controller in that zone. Those routes do not break easily, and the requirement of routerediscovery arises significantly less in our proposed protocol, which reduces the message cost in SD-EAR compared with LEACH and SPIN, as seen from Figure 11.

SD-EAR versus SD-WSN1, SD-WSN2 and SD-WSN3
SD-WSN1 applies either a proactive or reactive routing policy depending upon the total number of nodes in the network. If the number of nodes is low, then proactive routing is applied, where the identifiers of successors in optimum paths to various destinations are stored in routing tables. This does not require route discovery before each communication session, and saves energy by eliminating the broadcast operation during route discovery when the number of nodes is low [12]. However, when the number of nodes becomes high, routing table storage becomes inefficient; also, keeping track of stale routes is difficult. In that case, it applies reactive routing and the corresponding protocol is ad hoc on demand distance vector routing, or AODV. Among the various paths through which the route-request arrives at its destination from the source, the path with the least number of hops is elected as optimal. No energy efficiency is applied during optimum route selection. Also, there is no provision of giving rest to exhausted nodes. SD-WSN1 is capable of avoiding the broadcasting of route-request only when number of nodes is low enough.

SD-EAR versus LEACH, SPIN
LEACH divides the sensor network into multiple clusters. The technique for electing a cluster-head is the main source of energy efficiency here. If a node has already played the role of a cluster-head in several runs, then its chance of becoming a cluster-head in the next run again reduces greatly. This encourages the rolling of cluster-heads by the balancing load. However, LEACH does not consider the location of sensor nodes [35,36,43] and therefore, certain cluster members may stay very far from the cluster-head. So, the energy consumed by the cluster-head in transmitting a message to those members that are located far, increases substantially. Also, LEACH applies Dijkstra's shortest path algorithm to select the optimum path [43]. The authors would like to state here that shortest path, in most cases, is not the most energy-efficient one. Hence, the performance improvement produced by SD-EAR over LEACH is noteworthy. This is evident in Figures 11-15.
SPIN [38] is also a very important energy-efficient protocol that broadcasts metadata, which is data about data. If a neighbor develops interest about actual data after receiving the metadata, only then is data sent to it. The energy efficiency in SPIN arises from the size of the metadata being much less than the size of the actual data, and the actual data is sent to a subset of neighbors instead of all of the neighbors, as in an ordinary broadcast.
On the other hand, in SD-EAR, the broadcasting of an opt-route-select is not performed, not even in inter-zone communication. Actually, in the inter-zone route discovery, opt-route-select is at most multicast to all of the peripheral nodes, as well as also through energy-efficient paths, as instructed by the SDN controller in that zone. Those routes do not break easily, and the requirement of route-rediscovery arises significantly less in our proposed protocol, which reduces the message cost in SD-EAR compared with LEACH and SPIN, as seen from Figure 11.

SD-EAR versus SD-WSN1, SD-WSN2 and SD-WSN3
SD-WSN1 applies either a proactive or reactive routing policy depending upon the total number of nodes in the network. If the number of nodes is low, then proactive routing is applied, where the identifiers of successors in optimum paths to various destinations are stored in routing tables. This does not require route discovery before each communication session, and saves energy by eliminating the broadcast operation during route discovery when the number of nodes is low [12]. However, when the number of nodes becomes high, routing table storage becomes inefficient; also, keeping track of stale routes is difficult. In that case, it applies reactive routing and the corresponding protocol is ad hoc on demand distance vector routing, or AODV. Among the various paths through which the route-request arrives at its destination from the source, the path with the least number of hops is elected as optimal. No energy efficiency is applied during optimum route selection. Also, there is no provision of giving rest to exhausted nodes. SD-WSN1 is capable of avoiding the broadcasting of route-request only when number of nodes is low enough. SD-WSN2 [20] is concerned with only the optimum placement of energy transmitters. Energy transmitters provide energy to the nodes when they suffer from a shortage of charge. Please note that the recharging of nodes is less frequent than the initiation of new communication sessions. SD-WSN3 [21] selects a few control nodes among all of the nodes in the network. These nodes assign task to others, depending upon the residual energy. However, here, the authors want to humbly state that residual energy is not the only criteria. A node n i may have higher residual energy (say for example, 50 mj) than another node n j (30 mj), but this does not mean that n i will live longer. It depends on the energy depletion rate or packet-forwarding load. If we assume that the energy depletion rate of n i is 10 mj/s and that of n j is 2 mj/s, then the residual lifetime of n i and n j are 5 s and 15 s, respectively.
SD-EAR considers different aspects of energy efficiency, such as residual energy, the energy depletion rate, the distance between consecutive nodes in a route, the number of sleeping nodes, and their alternatives. All of these criteria enable the establishment of long-lasting routes and the requirement of route rediscovery reduces up to a greater extent than SD-WSN1, SD-WSN2, and SD-WSN3. SD-EAR converts the broadcasting of a route-request to multicasting opt-route-select to only the peripheral node group whose member cardinality is generally much smaller than the total number of nodes in a zone. Therefore, SD-EAR suffers from much less message cost than its state-of-the-art software defined competitors, as seen in Figure 16.

Overall Energy Consumed (OEC)
The most important aspect of SD-EAR is that it completely eliminates broadcasting during route discovery. This saves a huge number of messages. Also, route selection strategy in SD-EAR is extremely energy-efficient. The eligibility of a route depends upon the pairwise distance between consecutive nodes, the number of alternatives, the residual energy, the rate of energy depletion, etc. A sleeping strategy is proposed too, that examines the need of sleep of a node after receiving a sleep request. A sleep is granted by the SDN controller if the zonal topology has a provision of its alternative, so that the alive communication session does not face any link breakage. The provision of forceful sleep instruction from the SDN controller to different nodes is possible in SD-EAR. Link breakages are repaired proactively. All of these things greatly reduce the overall energy consumption, or OEC, in SD-EAR compared with its competitors. This is seen in Figures 12 and 17. However, as the number of nodes increases, the OEC also increases for all of the protocols, but still, the growth is least steep for SD-EAR.

Percentage of alive nodes per established communication session (PALCS)
Routing protocol in SD-EAR balances the load between various nodes in the network and greatly reduces the overall energy consumption. The reduction in message cost cuts down on the energy consumption in various nodes. Moreover, balancing the load prohibits overwhelming differences between the residual energy of various nodes. This increases the number of alive nodes in different communication sessions, as shown in Figures 15 and 20.

Network Throughput (NT)
We all know that if the number of messages in the network increases upto a great extent, then it gives rise to a huge amount of message contention and collision, yielding a high rate of packet loss. Since the competitors of SD-EAR suffer from much more message overhead than our proposed protocol SD-EAR, the network throughput produced by SD-EAR is much higher than others, as shown in Figures 13 and 18. It is seen in the figures that for all of the protocols, network throughput initially increases with the number of nodes; then, it starts decreasing. The reason is that with the increase in the number of nodes, more links are formed, and more data packets are delivered to their respective destinations. However, when the network becomes saturated with nodes, message contention and collision increases, reducing network throughput.

Average Delay (AD)
We have already mentioned that broadcasting for route-request is completely eliminated in SD-EAR. Therefore, the delay in route discovery is reduced by a great extent in our proposed protocol. Moreover, link breakages are also repaired proactively. This saves the time span that would have been required to identify a broken link and initiate route-rediscovery to repair the link. Therefore, the average delay in SD-EAR is much smaller than that of its competitors, as shown in Figures 14  and 19.

Conclusions
This article presents a software defined wireless sensor framework where the network is divided into multiple clusters or zones, and each zone is controlled by an SDN controller thatis aware of topology within that zone. The broadcasting of route-requests is completely eliminated in SD-EAR. The selection of the optimum route is energy efficient. A sleep grant mechanism is proposed that allows nodes to go to sleep without hampering live communication sessions. These techniques greatly reduce the energy consumption in the network, and increase the number of alive nodes and network performance.

Future Scope
We have simulated our present work in Mininet simulator. In the future, we shall implement SD-EAR in real life, and compare its performance with its state-of-the-art competitors.