SDORP: SDN Based Opportunistic Routing for Asynchronous Wireless Sensor Networks

In wireless sensor networks (WSNs), it is inappropriate to use conventional unicast routing due to the broadcast storm problem and spatial diversity of communication links. Opportunistic Routing (OR) benefits the low duty-cycled WSNs by prioritizing the multiple candidates for each node instead of selecting one node as in conventional unicast routing. OR reduces the sender waiting time, but it also suffers from the duplicate packets problem due to multiple candidates waking up simultaneously. The number of candidates should be restricted to counterbalance between the sender waiting time and duplicate packets. In this paper, software-defined networking (SDN) is adapted for the flexible management of WSNs by allowing the decoupling of the control plane from the sensor nodes. This study presents an SDN based load balanced opportunistic routing for duty-cycled WSNs that addresses two parts. First, the candidates are computed and controlled in the control plane. Second, the metric used to prioritize the candidates considers the average of three probability distributions, namely transmission distance distribution, expected number of hops distribution and residual energy distribution so that more traffic is guided through the nodes with higher priority. Simulation results show that our proposed protocol can significantly improve the network lifetime, routing efficiency, energy consumption, sender waiting time and duplicate packets as compared with the benchmarks.


INTRODUCTION
T RADITIONAL wireless sensor networks (WSNs) consist of a large number of randomly deployed nodes with limited sensing, computing, and wireless communication capabilities [1], [2]. Since network design is built with physical resources, thus, designing of efficient routing approach is a fundamental step towards achieving the least consumption of resources [3], [4]. Traditional WSNs are believed to be specified application, making it extremely hard to respond to events and reconfiguring high-level policies across the network. It is, therefore, necessary to specify these highlevel policies in terms of distributed low-level configuration [5], [6]. Although many difficulties exist, such as sleep mechanisms or various types of data fusion which could be result of unstable links or large amounts of energy waste that cannot be solved in ossified network architecture. Various mechanisms must be used as part of a large scale WSN management to facilitate maintainability and system self-healing. When energy resources becomes insufficient, the system should be able to adjust the parameters on the basis of factors such as reduction in service quality. In existing WSN configurations, this is a challenge where all data and control packets are routed across the limited network band.
It is for this reason the design of a network management system is a challenging task, especially on a large-scale network which is typically seen as the second phase of project planning. In general, many problems inherent to traditional WSNs are deeply rooted in network architecture. Each node is manufactured as an autonomous system to accommodate all functionalities from the physical layer up to the application layer that executes both network control and data forwarding. This architecture works well, particularly with small scale short-range WSNs due to well-designed algorithms. However, it lacks flexibility and simplicity, making it difficult to manage when trying to implement a large scale with low power and long-range WSNs. Several recent techniques have been studied and implemented to solve this problem in the management of WSNs, in which some of the techniques revolve around the idea of Software Defined Networking (SDN) [7], [8].
The SDN architecture enhances the network intelligence by separating the control plane from the data plane. The separation of planes provides flexibility and efficiency in management and vendor independence (due to the standardized interface). As a result, nodes in the data plane only perform the data forwarding without doing the network control functionalities like routing strategies, topology management, and increasing their energy efficiency etc. On the contrary, the control plane performs the network control functionalities like scheduling, routing rules, comprehensive duty cycling, and topology management etc., armed with the networkwide view [9]. In addition, it prevents WSNs from being an application specific, where the data plane virtually supports all the routing rules and the control plane distinguishes the application layer from physical layer to support various applications with different hardware to run within the same architecture of the physical network. Moreover, it prevents WSNs from being vendor specific by empowering multiple vendors to design non-isolated application-customizable devices by sharing similar features. Apart from accelerating the innovation in protocols, production, and prototyping, this evades the complex network management caused by multi-vendor node deployment, showing the network intelligently controlled in a vendor independent manner [10].
SDN managed the frequent change of functionalities and improved the network's centralized view. Consequently, it offers flexibility, scalability and centralized control to enhance network efficiency. Conversely, it requires provision of duty cycling in WSNs because the energy consumption of the sensor node is an essential problem to be solved in this technology where sensors do not take measurements.
Duty cycle scheduling is the primary mechanism used at the Medium Access Control (MAC) level to enhance energy usage efficiency and lifetime of the network [11]. In this approach, the nodes switched between active/sleep states based on the predefined active and sleep intervals. There have been numerous sleep schedule mechanisms for the MAC layer [12], [13], [14], that help to minimize energy consumption by putting nodes into a sleep state when there are no data packets to be sent or received. These mechanisms on sleep schedule coordinates by one of the two approaches, namely synchronous and asynchronous. In the synchronous MAC protocols, nodes are synchronized with the wake-up schedule of other nodes because at the same time all of them are active to exchange the data packets. However, maintaining time of synchronization can be expensive in terms of a high control packet overhead, as well as lengthening active time. Due to this, the energy consumption during synchronous duty-cycling rises rapidly with one or more communications and parallel data packet flows, making synchronization intolerable in the large-scale energy constrained and condensed networks. On the contrary, asynchronous MAC protocols do not require the periodic time of synchronization between the nodes to wake up at the same time. In fact, the nodes randomly switched between active/sleep modes in the network which is more energy efficient as no additional packets circulate in the network. Asynchronous protocols can attain greater scalability and higher energy efficiency than synchronized protocols without periodic time of synchronization.
Opportunistic Routing (OR) is a new design of routing protocol that can enhance the efficiency of duty cycled WSNs by leveraging the advantages of overhearing wireless signals [15], in which nodes take multiple candidates instead of a single candidate to forward the packet. This approach could reduce the sender waiting time and fit well with the asynchronous MAC protocols. Opportunistic Routing in Wireless Sensor Networks (ORW) [12] protocol is based on this approach to minimize energy consumption.
Considering the ORW protocol, the Expected Duty Cycled Wake-ups (EDC) is used as a routing metric for the computation of forwarder sets of each node based on the neighbor information. In EDC approach, each node knows its distance from other nodes. Starting with an empty set, the neighbor nodes are inserted into the forwarder set in the ascending order of their EDC's. Every time when new neighbor is inserted the EDC of the node is recomputed. The EDC of the neighbor node must be smaller than the current EDC of the node. ORR [13] improved over ORW by considering the residual energy of each node to select their forwarder set. Their approach reduces the individual node scheduling computation which simultaneously minimizes the cost and energy consumption of the nodes.
We intend to extend the EDC and significantly improve ORW and ORR by adding three attributes namely, transmission distance, expected number of hops and residual energy. ORW selects forwarders based on expected wait time, thus, nodes with the large number of neighbors are more likely to become forwarders candidature. ORR frequently selects forwarders based on nodes with higher residual energy. We select forwarders based on shorter transmission distance, minimum expected number of hops to sink, and higher residual energy of the nodes. The reasons behind the selection of these distributions are explained in Section 4.3.
The aforementioned studies provided convincing motivations for expanding the SDN concept with OR to the traditional WSN which enables the users to centrally control the network over an opportunistic routing stack. Therefore, in this paper, we propose an SDN based opportunistic routing for asynchronous duty-cycled WSNs (SDORP). We use the same approach as in ORW and ORR but improving over them by deeply addressing the flow computation and Expected Duty-Cycle Wake-up (EDC) to achieve the following objectives. First, the SDN concept integrated with WSNs which gives the flexible management of the network and routing strategies from the control plane to the data plane to enhance the network and energy efficiency. Second, calculating the flows using EDC metric with the integration of probability distributions on the controller is defined for each node as well as controls the number of candidates for each node. Third, the candidates of each node are prioritized based on the following attributes, which are defined as the average of three probability distributions, namely transmission distance distribution, expected number of hops distribution and residual energy distribution. The goal of this paper is to counterbalance between the sender waiting time and the number of duplicate packets along with the improvement of network efficiency through flexible management of the network. In summary, the key contributions of this work are as follows: 1) A new load balancing enhancement method has been developed, namely extended Expected Duty Cycled Wake-ups (EEDC) by including three attributes in the first term of EDC, transmission distance, expected number of hops and residual energy. 2) A new protocol, SDORP, is proposed that integrates EEDC with MINI-SDN [14] to enhance load balancing and facilitates efficient management to reduce energy consumption and enhance the network efficiency. This work presents a more comprehensive solution to SDN based duty cycled opportunistic routing in WSNs. 3) A detailed probabilistic analysis is carried out to analyze the performance of the SDORP network by calculating the expected energy cost, the redundant packets and the sender waiting time. 4) We implemented the SDORP that is based on [14], [16]. The source code is available at https://github.com/howbani/sdorp. The rest of the paper is organized in the next sections. The Section 2 explains the related work. Section 3 presents the preliminaries. Section 4 presents the system model and problem formulation. Section 5 presents the proposed protocol. Section 6 presents the analysis. Section 7 evaluates the performance of the proposed protocol using extensive simulation. Finally, Section 8 concludes the paper.

RELATED WORK
Various mechanisms for wireless sensor networks have been proposed over a decade. Some of them are adopted from different kinds of wireless networks such as LANs, but SDN based opportunistic routing makes a unique protocol designed for wireless sensor networks. Following are the previous studies which are divided into two parts. SDN based WSNs and Opportunistic Routing in WSNs.

SDN Based WSNs
WSN complexity is growing rapidly to the point where dense networks cannot be controlled and maintained manually in real-time [17]. The Software Defined Wireless Sensor Network (SDWSN) meets this requirement that overcomes the traditional WSN limitations and induces it with control and automonitoring. It is commonly believed that SDN is an inevitable trend for WSN development with the rapid growth of various information and communication technologies.
Software-Defined Networking concept is introduced in wireless sensor networks with organized and hierarchical management to solve some intrinsic challenges in WSN management. In [18], the authors expressed that SDN in traditional WSN should support energy awareness actions which is currently being investigated in WSNs such as innetwork data aggregation, duty-cycling, and cross-layer optimization. SDWSN architecture [19] merges contextaware and policy-based routing modules according to the SDN standards. Another effort was made to merge WSN and SDN in order to explain the inherent challenges of WSN [20]. In [21], an architecture was developed to categorize control plane and data plane individually, where Open-Flow is described as a standard SDWSN communication protocol among both planes. Subsequently, to reduce the energy consumption and intricacy of sensor nodes structure, the smart grid WSNs utilized SDWSN. Moreover, SDN was utilized for managing WSNs under the smart softwaredefined control by keeping the controller at the base location. It was suggested and argued that SDN can solve most of the intrinsic challenges of WSNs through smart management [22]. In order to simplify the management of the network, a networking solution SDN-WISE was introduced [23]. In [24], the improved SDWSN framework has been introduced to enhance the network reliability which minimizes the network coupling by separating the control and data planes and used an external controller to assign flow rules. This framework has reduced the energy consumption of the network, but to a certain limit as expected because they did not consider any energy aware algorithm. In [25], the authors proposed an energy-aware cognitive-based SDWSN protocol by utilizing Reinforced Learning (RL) for monitoring applications. This protocol was introduced to improve the energy efficiency for WSN monitoring applications. In [26], a tiny OS-based SDN mechanism has been introduced which utilizes the multiple controllers within the SDWSN. This work focused solely on hardware architecture. In [27], the authors proposed a routing algorithm for data routing on software-defined WSNs in which the nodes are divided into clusters and each of them allocated to a control node (cluster head). The control node is selected by the controller based on the transmission distance and the remaining energy of the nodes. The selection of control nodes at the control plane is formulated as an NP-hard problem and then optimized by utilizing the Practical Swarm Optimization (PSO) algorithm.
The aforementioned literature demonstrated the feasibility and acceptability of SDWSN. However, they lack a combined focus on both planes regarding information exchange, which is a key factor that must be reduced in order to overcome network message overhead. Besides, the combined problem of load balancing and data routing between two planes has not been properly addressed. Therefore, we go beyond the state of the art by utilizing the software-defined concept to WSNs, where such kind of framework offers information exchange between two planes and overcomes the above-mentioned problems. For the detailed explanation refer to Section 3.

Opportunistic Routing in WSNs
A number of diverse mechanisms have been proposed for Opportunistic Routing (OR) with duty-cycling based on MAC to assist data routing in WSNs. The majority of OR protocols are devoted to routing metric, candidate selection, and candidate coordination.
Existing MAC protocols of WSNs, divided into synchronous and asynchronous MAC, are developed on top of dutycycling. S-MAC [28] is a synchronized protocol designed for WSNs. The nodes are based on periodic sleep and wake-up method. The nodes exchange their schedule by periodically broadcasting SYNC packets and use the RTS/CTS mechanism to avoid collision. The AIMRP protocol proposed in [29] based on S-MAC utilizes a hop count coordinate system to the sink. A node's candidate set is formed by the neighbor nodes with smaller hop count than it's own. To minimize waiting cost, the first node that wake-up will be selected as a forwarder. However, it is not a good way to build a candidate set only with the hop count.
On the contrary, asynchronous MAC protocols work with different wake-up times. To communicate between two nodes, the sender or the receiver must wait for a wake-up of its counterpart. Some of the OR protocols [12], [30], [31] operates with sender-based MAC protocols. A sender sends a preamble packet before transmitting a data packet. The candidate node which wakes-up first, hears the packet, and sends back an acknowledgment will become the forwarder.
OR is a useful approach to further minimize the sender waiting time by allowing multiple candidates, in which any of the candidates can receive and forward the packet. SLOR [1] focused on reducing end to end delay by identifying an ideal candidate set. In the forwarder selection criteria, they considered the quality of the sender-to-receiver link, the wake-up order of the nodes, and the estimated one-hop latency of the nodes. The energy levels of the nodes are not considered in this criterion. A geographically based OR approach is presented in [32] to improve network end-toend (E2E) delay performance. In this approach, each sender node has a set of candidates whose geographical distance from the sender is greater than a threshold value, and it then transmits packets to the first awakened candidate in this manner. The threshold value has a significant influence on packet E2E delay and its suitable selection can result in low latency. However, they did not include a method for determining the duty cycle while ignoring delay constraints. The authors of [33] introduced three delay analytical models for the following cases: single-forwarder OR, multiple-forwarder OR with known topologies, and multiple-forwarder OR without known topology. They did not consider the energy term while selecting a forwarder in any of the three cases. In [34], the authors presented the modified analytical hierarchy process (MAHP) to obtain the location properties of nodes. It then integrated the multiple network attributes and inferred the final routing decision using MAHP and fuzzy logic techniques. The authors of [35] presented the link synergy (LS) routing metric, which prioritizes next-hop candidate nodes based on the correlation of transmission failures among the links. In the design of the LS routing metric, this method lacks other effective factors. ORW utilized a new metric called an Expected number of Duty-Cycled wake-ups (EDC) for the global metric and proposed a candidate set algorithm for each node that could minimize the EDC to the sink [12]. Duplicate-Detectable Opportunistic Forwarding (DOF) protocol is capable of solving duplicate transmissions in traditional OR protocols operating with sender-based MAC protocols [30]. ORR [13] and ORIA [36] are almost similar to ORW, both are based on EDC with slight differences. ORR eliminates the third term in EDC (i.e., eliminates the forwarding cost from EDC) and adds the remaining energy parameter to the first term of EDC. ORIA considers two metrics hop count and EDC.
Although all of these routing techniques can reduce energy consumption to enhance the energy efficiency of individual nodes or the entire network. However, they did not consider the effective load balancing approach among the nodes while designing their OR metric to achieve the longer network lifetime. Therefore, in our proposed protocol, software-defined networking is adapted to the opportunistic routing for flexible WSN management. In addition, we have considered three attributes (transmission distance, expected number of hops, and residual energy) in the EDC metric for effective load balancing between nodes. The EDC is computed and the number of candidates is controlled in the control plane, as explained in Section 5.

Integration of SDN
The aforementioned literature contributed significantly and offered convincing motivations for considering SDN concepts into opportunistic routing in WSNs. Therefore, in this paper, the SDN architecture is adapted from our previous work [14]. The model contains the control plane, data plane and the sink. The sink acts as a gateway between the control plane and the data plane. The primary objective of decoupling the control plane and data plane in SDN is to make a centralized plane that manages all the data plane's nodes. The decoupling is necessary so that each plane can develop and evolve autonomously. The SDN controller could be located externally on a remote server or internally in the sink. In this work, the controller is considered as an autonomous external device that interacts directly with the sink instead of the sensor nodes. It also manages and draws the network topology, as well as making data routing decisions for each node. The data plane (forwarding plane) follows the rules of control plane and forwards the data packets from one node to the next. The SDN architecture is composed of three built-in sub-architectures (SDN-Node, SDN-Sink, and SDN-Controller). Fig. 1a presents the SDN-Node protocol stack that operates the basic functionalities of PHY and MAC layers. At the top of the protocol stack, there is network layer which operates the micro-control unit that consisting of three operations: Neighbor Discovery (ND), Data Aggregation (DA), and Packets Router. In ND, each node is allowed to discover and store information (e.g., ID, battery state, etc.) about neighboring nodes. DA performs data aggregation or decision fusion to provide complete coverage for a certain area, minimize data redundancy, and conserve network resources such as energy and bandwidth [20]. A packet router can route network data packets to other nodes based on their addresses. The packet router consists of three operations: Candidates Coordination (CC), Flow Table and Neighbor  Table. The CC is used by the sender node to determine which of the candidate required to forward the packet. The candidate with highest priority must forward and receive the packet and the other candidates will drop it. In general, this mechanism requires the signaling between the nodes to avoid redundant packets. The flow table plays a critical role in SDN, which stores the matching rules populated by the control plane for controlling and directing the packet flows in SDN. The neighbor table stores information about the neighbor nodes of each node. Fig. 1b presents the SDN-Sink protocol stack that operates the basic functionalities of PHY and MAC layers. At the top of the protocol stack, the Embedded Network Operation System (ENOS) is an intermediary interface that operates from sink to nodes and sink to controller communications. The ENOS consists of two principal sides, the controller and the node sides. The node and the controller sides are responsible for intercommunications of nodes to sink and controller to sink respectively. The node side consists of three operations: Candidates Coordination (CC), Flow Table, and Gateway Discovery. We have already explained above the candidates coordination and flow table because they implement the same functionality as in the packets router of SDN-Node. The access nodes are discovered by the gateway discovery. For instance, the neighboring nodes of the sink that can communicate directly through one hop. The controller side consists of two operations: PCI (Programmable Communication Interface) and Adapter. The PCI operation is responsible for managing communication between the sink and controller through an interface (e.g., TCP/IP, RS232, USB, etc.). The adapter operation is responsible for interpreting the network policies and messages in a way that sensor nodes and controller can understand. Fig. 2 presents a simplified view of an SDN-Controller, which performs network service functionalities (such as data-forwarding decisions, high and low level networkwide policies, and so on) through a centralized unit that employs a Network Operating System (NOS). The NOS consists of Flow Engine (FE), Network Visualization (NV), Topology Constructor (TC), Database, PCI and Applications. The PCI operation is responsible for managing communication between the sink and controller. The design of the database operation is to store topological gathered data, particularly node's ID, node's battery level, node's neighbors, node's location, and sink, etc. The topology constructor operation uses vertices and edges to build a graphbased pattern for the sensor network based on the data stored in the database. The network visualization operation builds a coherent and comprehensive representation of the network's statistics and current state by using the topology constructor and the database for topological gathered data. The controller's flow engine is an important operation that takes all the data forwarding decisions and implements all high/low levels network policies. Furthermore, it is responsible for interpreting network event-driven policies into forwarding rules that are incorporated into the nodes, as well as updating the nodes and sink flow tables.
According to Table 1, the flow table saves the routing flows. The routing flows in a sender node have three neighboring nodes and each flow is assigned with EDC priority value. The flow table is designed to emphasize on two objectives. The first objective is to reduce the information exchange between the control and the data plane where the controller delivers the routing flows to each node, but for each packet, it does not need to specify the flows. This reduces the exchange of information between the two planes. The flows are updated by the controller on the basis of the statistics obtained from the end nodes. The second objective for duty cycled nodes is to shorten the waiting time and minimize the redundant packets, with multiple flows allocated to each node. The EDC priority value of each node is computed in the Flow Engine. Whenever a sender node needs to send a packet, it first sends the preamble packet to its neighboring nodes. The awakened neighboring nodes will hear and receive that packet, and then send the ACK back to the sender. The ACK value is set to 1.0 by the sender in the flow table. According to the EDC priority, if the flow is matched, then the corresponding action is performed and the information is updated in the statistics. The information of the node statistics is reported regularly to the controller. The computations of EDC priority and Actions are explained in Section 5.
Based on the network wide-view the controller fills the flow table and each node fills its own neighbor table in a distributed manner as shown in Table 2 where the node n i stored the required information. We assume that the node n i has four neighboring nodes N i ¼ fn 1 ; n 2 ; n 3 ; n 4 g, the function Fðn j 2 N i Þ returns the battery level of the neighboring nodes n j , E½Hðn j 2 N i Þ returns the expected number of hops of the neighboring nodes from the node n j to the sink n b and tðn j 2 N i Þ returns the transmission distance from the node n i to node n j . The estimated location returns the location of the neighboring nodes.

System Model
A standard software-defined wireless sensor network consists of three layers: application plane, control plane and the data plane as shown in Fig. 3. The application plane interacts with the different applications of the network. The control plane is responsible for topology management, data transmission in terms of flow control and load balancing across the network. This reduces the energy resources of the sensor nodes individually. The data plane consists of sensor nodes, N ¼ fn 1 ; n 2 ; . . . ; n m g, with m ¼ jNj where the sensor functions are performed for data generation and forwarding which is based on the routing rules assigned by the control plane. We assume that each sensor node ðn i 2 NÞ is aware of its geographical coordinates ðx i ; y i Þ through a localization approach such as [37] or is integrated with a Global Positioning System (GPS) device.
Consequently, the operational network model of a SDWSN architecture is assumed to be a directed graph G ¼ ðV; EÞ where V is the vertex set including sensor nodes and E denotes the directed communication links connecting sensor nodes. The SDN controller manages all the sensor nodes in the network. Some of the notations used in this paper are summarized in Table 3.

Energy Consumption Model
In this study, a highly simplified energy consumption model [38] is adapted for transmitting and receiving the packets. The model used both the free space ð" fs Þ (d 2 energy loss) and the multi-path fading channels ð" mp Þ (d 4 energy loss) which totally depends on the distance between the sender and the receiver calculated by Euclidean distance d using Eq. (6). The path loss can be compensated by using the energy control mechanism. The required transmission energy consumption can be computed in Eq. (1) to transmit the k bits packet for the distance d.
The required receiving energy consumption can be computed in Eq. (2) to receive k bit packet for the distance d.
(2Þ E elec is the energy consumed per unit to operate the transmitter or receiver circuit which depends on various factors such as filtering, signal propagation, modulation and digital coding. " mp and " fs are elected for the transmission amplifier model. The transmitted data packet length is denoted by k, the d Ã is the transmission distance threshold value which is computed by Eq. (3).

Problem Statement and Formulation
It is possible that a candidate node with a greater number of hops to the sink can become a forwarder based on the structure of the EDC in ORW. In this case, if the node uses a greater number of hops to sink and longer transmission distance to the next hop node, it can increase energy consumption in two ways. First, a greater number of hops to sink consumes more energy than a smaller number of hops. Second, if the hop to hop transmission distance is equal or greater than the threshold d Ã , it will also affect the energy consumption of the network. Fig. 4 shows the difference between a greater and a smaller number of hops to sink. It depicts that the node n 77 selects the path to sink n 0 , which is expressed as a dotted line. The path contains a greater number of hops to sink consumes more energy than a smaller number of hops. The transmission distance of each hop is assumed to be less than the threshold d Ã as expressed in Eq. (1).
In Section 4.2, based on Eqs. (1) and (2), we derived the Eq. (4). Here in Eq. (4), we consider the multi-hop scenario with m number of nodes in the network. The energy required to transmit the k bits packet from one node to another node, depending on the transmission distance d of each other, is denoted by E Tx ðk; dÞ. The energy required in receiving the k bits packet is denoted by E Rx ðkÞ. The required transmission power is based on the transmission amplifier " amp :d Ç , the free space " fs and the multi-path " mp models as expressed in Eq. (1). Here, Ç is the energy control variable for the energy model. Fig. 5 shows the difference between longer and shorter transmission distance towards the next hop node. If we consider the shorter transmission distance between node n 77 and node n 99 assuming less than the threshold d Ã then it will apply free space " fs model with d 2 to consume transmission energy. If we consider the longer transmission distance between node n 77 and node n 48 assuming equal or greater than the threshold d Ã then it will apply multi-path " mp model with d 4 to consume transmission energy. Hence, for all multi-hop cases depicted in Figs. 4 and 5, we expressed the total energy consumption for transmitting and receiving the k bits packet by m number of nodes in the network in Eq. (4) and the generalized term is obtained by Eq. (5).

TABLE 3 Notations
Notation Definition N N¼ fn 0 ; n 1 ; n 2 ; . . . ; n m g; n i 2 N is a sensor node; m is the size of N.
The neighboring nodes of n i ; m i is the size of N i . n b The sink. n s The source node. n t The target node.
The expected number of hops of n i 's neighbor n j to sink n b .
The transmission distance from n i to n j .
The residual energy of the of n i 's neighbor n j . e Ã The initial energy. e The Euler's Constant. Its value is approximately equal to 2.71828. R The radius of communication.

Ç
The energy control variable for energy model. p The default value of Pi is approximately equal to 3.14159.  However, in order to achieve a greater network lifetime, it is very important to balance the load among the nodes. ORW did not consider the load balancing among the nodes and ORR only considers the residual energy of each node for selecting the forwarders. The nodes with the higher residual energy will become the forwarders more often. Both ORW and ORR did not consider the transmission distance between nodes while calculating the EDC. Thus, considering only the residual energy in ORR will not give much effective results because the transmission distance between nodes is strongly related to the energy consumption of sender and the receiver as described in Section 4.2.
In order to balance the load among the nodes, we consider the three attributes: residual energy, the transmission distance and the expected number of hops. The nodes with higher residual energy, shorter transmission distance and minimum expected number of hops will be selected as forwarders more often. The reason behind considering the expected number of hops is that, in the design of the EDC, it is possible that a node can become a forwarder with a greater number of hops to the sink. This will reduce the above-mentioned problem which simultaneously affects to reduce the energy consumption of the network.
The forwarding structure is demonstrated to be loop free feature. Since the forwarder sets established the graph which forms a Directed Acyclic Graph (DAG). A DAG structure upstream node always has a lower EDC than a downstream node. We propose a model for selecting forwarder which includes the average of three probability distributions in the first term of EDC. The Section 5 explains the proposed methodology.

THE PROPOSED PROTOCOL
The main purpose of this study is to counterbalance the two contradictory problems: sender waiting time and packets duplication, as well as to improve network efficiency through flexible network management. We propose SDN based opportunistic routing which deeply addresses the computation of the routing flows with EDC. The rest of the section focuses on the data reporting at network initialization, computing the routing flows (i.e., the paths from the end nodes to sink), and flow instantiation (i.e., controller assigns flows to end nodes). Furthermore, its implementation is based on the low power listening BoX-MAC protocol [39]. The novelty and contributions of this study are explained in Section 1.

Network Initialization
A distributed algorithm is used to initialize the network to report the required information to the controller because the controller does not have any information about the network nodes. To compile the topological data and report to the controller, each node transmits the beacon packets during the initialization stage. The data is stored in the Database and can be used by the Network Visualization (NV), Topology Constructor (TC) and Flow Engine (FE). Algorithm 1 describes the initialization of the network in a distributed manner and how the topological data is gathered in the Neighbors Table  (Table 2). During the initialization phase the only information regarding location of each node in the network should be collected. We apply the Euclidean distance Eq. (6) to calculate the distance from each node to sink. By performing the following steps, the compiled data is reported to the sink. First, the sender node sends a preamble packet and after receiving these packets by the neighboring nodes, they return ACK packets to the sender subject to their availability. Second, the packet router selects a forwarding candidate from the neighboring nodes, which expresses their availability such that the distance of the forwarding candidate node is smaller than the distance of the sender to the sink. Finally, the ID of the forwarding candidate is mentioned by the packet router in its IDs field of the control packet. This process is carried out till the packet approaches the sink.

The Routing Flows
The node-to-controller data routing is determined in the Flow Table (Table 1) based on the priority value of each flow. Since each node has numerous candidates at each transmission phase. Consequently, each node has numerous paths to reach at the sink. To optimize the path selection, our proposed protocol includes three important attributes in the first term of EDC to obtain the higher link quality. A node that has links with higher quality will have smaller EDC, because the expected sender waiting time is shorter. The attributes in EDC are defined as the average of the three probability distributions expressed in Eq. (17). The distributions are transmission distance distribution Eq. (8), the expected number of hops distribution Eq. (14), and the residual energy distribution Eq. (16).

Transmission Distance Distribution
To compute the transmission distance between the sender node to each of its neighbor t i;j , we consider the Euclidean distance Eq. (6) from n i to n j . After getting the distance from sender node to each neighbor, we normalized it between ½0 À 1 by Eq. (7), and then obtained the exponential distribution of transmission distance by using the probability mass function in Eq. (8), where e is the Euler's Constant. The aim of this distribution is to set a higher priority to those nodes which are closer to the sender. In Eq. (8), t ! 0 is the distribution control variable, the higher the distribution control variable expresses the greater probability for the nodes which have closer transmission distance to the sender to be selected as forwarders. The default value of the control variable is set to t ¼ 0:5.

Expected Number of Hops Distribution
To compute the expected number of hops, we first calculate the Euclidean distance Eq. (6) d i;b from the node n i to the sink n b . If the distance d i;b is greater than the communication radius R, then the node n i uses the intermediate nodes to forward the packet towards sink n b using two or more hops. Let us consider the Fig. 6 where the node n i has independent random neighbor nodes having the random distribution with the communication radius ½0 À R. The density function of distance x between the node n i and neighbor nodes n j is computed by Eq. (9). f Xa ðx; aÞ ¼ 2x Where À p 2 a p 2 and 0 x R. Integrating the Eq. (9) over a gives the density function of f X ðxÞ in Eq. (10).
According to the concept of maximum of n random variables in [40], the sender node n i computes the neighbor node with the expected maximum distance E½M n j within communication radius towards sink n b . The expected maximum distance neighbor node E½M n j is computed by Eq. (11). Based on Eqs. (10) and (11), the expected number of hops from each node n i to sink n b is computed by Eq. (12). If the distance d i;b lies within the communication radius R, it will count expected one hop.
The E½H i;j represents the expected number of hops of n i 's neighbor node n j . The random variable E½H i ¼ ðE½H i;1 ; E½H i;2 ; E½H i;3 ; . . . ; E½H i;m i Þ is defined by the expected number of hops of each neighbor node n j to sink n b . In an analogy with Eqs. (7) and (8), the expected number of hops is normalized between ½0 À 1 by Eq. (13), and then obtained the exponential distribution by using the probability mass function in Eq. (14). The distribution set a higher priority to those forwarders which have the minimum expected number of hops towards sink n b . In Eq. (14), H ! 0 is the distribution control variable, the higher the distribution control variable expresses the greater probability for the nodes which have minimum expected number of hops. The default value of the control variable is set to H ¼ 0:5.

Residual Energy Distribution
The F i;j represents the residual energy of n i 's neighbor node n j . The random variable F i ¼ ðF i;1 ; F i;2 ; F i;3 ; . . . ; F i;m i Þ is defined by the residual energy of each neighbor node n j . The random variable F i is normalized between ½0 À 1 by Eq. (15), where e Ã is the initial energy of node n j . The exponential distribution of residual energy is obtained by using the probability mass function in Eq. (16). The aim of this distribution to set a higher priority to those nodes which have the greater remaining energy. In Eq. (16), F ! 0 is the distribution control variable, the higher the distribution control variable expresses the greater probability for the nodes which have greater residual energy to be selected as forwarders. The default value of the control variable is set to F ¼ 1.

Link Estimation
In the link estimation, the controller calculates the average of three attributes: the transmission distance distribution (t i;j ) Eq. (8), the expected number of hops distribution ðE½H i;j Þ Eq. (14), and the residual energy distribution (F i;j ) Eq. (16). It also defines the distributions term for each node n i by the vector " L ¼ ð " L i;1 ; " L i;2 ; . . . " L i;m i Þ such thatL i;j ¼ ðF i;j þt i;j þ E½H i;j Þ=3. The average term is computed by Eq. (17). To obtain the higher link quality by balancing the load among the nodes, we consider this average distribution term in the first term of the EDC Eq. (18). The higher link quality will have a smaller EDC. The controller computes the EDC for each node to assign flow rules, which reduces information exchange between the controller and the end nodes. The three exponential control variables ( t , H , and F ) control the three distributions. Increasing the value of any control variable will increase the impact of the corresponding distribution. To maximize the network lifetime the value of F is set to be greater than the value of t and H . The F is designed to avoid selecting the nodes with lower residual energy in each transmission phase.

Flow Instantiation
The role of the controller is very critical in terms of handling the intelligence of the network at a central place. A heuristic based distributed algorithm is designed to compute the path from the controller to the end nodes. The purpose is that the controller wants each node to know about how the data is treated. The controller computes and prioritizes the routing flow rules and store into the flow table of each node as shown in Table 1. Also, it makes decision to control the transmission flows in the data plane. The controller manages and controls the network and keeps up to date the topology and state of the network. According to Fig. 7, there are multiple reverse paths from sink node n b to end node n 61 . In order to disseminate the user defined operations to each node, the controller builds a sub-graph G i ¼ ðV i ; E i Þ for the target node n t and applies the Euclidean distance Eq. (6) from node to neighbor node and the next hop node to the target node to compute the shortest path. The Fig. 7 shows the example of potential paths from n 0 to n 61 , each path contains the same number of hops. We assume that the edges weight contains the distance from node to next hop node. The weight under the node contains the distance from the node to the target node n 61 . The weight above the node contains the cumulative distance from the source node to the current node reaching towards the target node, while the vertex value inside the node shows the ID of the sensor node.
According to Algorithm 2, the controller sorts out and utilizes the possible shortest route expressed in dotted lines to assign the flow rules from n 0 to n 61 .

Candidates Coordination
Coordination among candidates in OR is a challenging issue. It is the mechanism that candidates use to decide whether to forward or discard the received packet. A constructive mechanism for candidate coordination should prevent the transmission of more than one packet by choosing the best candidate for forwarding the packet. The mechanism for candidate coordination generally involves the signaling between the nodes. If there is an imperfection of coordination among candidates, this can lead to duplicate packet transmissions from different candidates. The OR protocol must use reliable signals to have complete candidate coordination. Generally, the active/sleep states of the MAC layer are coordinated by one of the two approaches: synchronous and asynchronous [41]. In the synchronous approach of MAC protocol, several nodes wake-up at the same time and have the same active period. While in the asynchronous approach of the MAC protocol, the sender and receiver nodes should be engaged in the active state as the nodes randomly define their wake-up intervals and active periods. The candidate coordination of MAC layer executes in the following steps. 1) The next hop (forwarder) decided by the network layer using a predefined routing metric e.g., link quality. 2) The MAC layer waits for the forwarder node to wake-up and receive the packet.
3) The forwarder node sends the ACK back to the sender when the packet is received. In order to avoid the negative effect of multiple receiver, the coordination among the candidates is an essential mechanism. However, if multiple candidates are in active mode, the candidate coordination selects the forwarder node that has lower EDC in Table 1 to ensure that the data packet will be sent to one candidate. Algorithm 2. Flow Instantiation n b is the Sink and Source Node, n t is the Target Node 1 Q = (; // define an open list queue 2 C = (; // define close list queue 3 S = (; // define shortest path queue 4 for each node n i in the network do The Routing Flow Action. The action of the routing flow to be performed on the packets (forward, drop) is described by Eq. (19), where C ! i is the routing candidates threshold value that are selected by the node n i .
In accordance with the remaining node energy, the priority value is updated by time. Otherwise, energy will be diminished sooner by the end nodes with greater priority values. The controller updates the flows according to end node statistics. In our work, the controller updates the routing flows for the end nodes every time it loses 5 percent of its energy. The controller recomputes the EDC and updates the end nodes flow table.

ANALYSIS
This section provides performance analysis of our proposed protocol SDORP. The analysis is entirely related to the multiple receivers problem theory. The basic theory and formulas for the multiple receivers problem are contained in ORW [12] and ORR [13]. We will express mathematically the energy cost, the number of redundant packets and the sender waiting time. In OR, the major influence on the performance of SDORP is the number of active candidates assigned to the sender node in each hop. We will, therefore, calculate the probability of active candidate nodes for sender node before we evaluate the expected energy cost, the redundant packets and the sender waiting time. The sensor nodes are assumed to be asynchronous having a uniform distribution with a continuous interval of the same active period of length, say t, then the distribution of being active for any node is 1 t in ½a; a þ t. We assume that the starting point of each interval is randomly selected within ½0; T . For a given node n i , let there exist m i neighbors with the maximum number of candidate The selection of candidate nodes for the sender node n i and their activation time is distributed by Eq. (20).
The probability P ¼ ð} ¼ 0Þ of all candidate nodes assigned to the sender node n i are in sleep state is given by Eq. (21).
The probability P ¼ ð} ¼ 1Þ of only one active candidate node for a sender node n i is given by Eq. (22).
The probability P ¼ ð} < 2Þ of all candidate nodes assigned to the sender node n i are in sleep state or only one active candidate node among them, is given by Eq. (23).
The probability P ¼ ð} ! 2Þ of two or more active candidate nodes for a sender node n i is given by Eq. (24).
To generalize the probability of active candidate nodes P ¼ ð}Þ for a sender node, the probability where there are exactly P ¼ ð1 < } c i Þ active candidate nodes for sender node n i is given by Eq. (25).
Suppose that the first node is active between ½a; a þ t since t is fixed for all active nodes. The second node is activated randomly at ½a 1 ; a 1 þ t, where a < a 1 , and their joint activation last in the interval ½a 1 ; a þ t. Then the probability of intersection of two active nodes is expressed in Eq. (27). Hence, Similarly, we further elaborate the following equations.
The probability of exactly P ¼ ð1 < } c i Þ active candidate nodes and P ¼ ðc i À}Þ sleep candidate nodes for the sender node n i is obtained by Eq. (32). (32Þ

Expected Energy Cost
According to the Energy Consumption Model described in Section 4.2, the energy cost E Tx ði; j; kÞ for transmitting a packet of size k from n i to n j is formulated in Eq. (33). The energy cost E Rx ðj; kÞ for receiving a data packet of size k by n j is formulated in Eq. (34).
As a matter of fact, in our proposed protocol SDORP, it is necessary to compute and sums the energy costs of transmitting and receiving the beacon packets, the ACK packets, and the data packets to compute the total energy costs of each transmission phase. For this reason, whenever a sender node n i is ready to forward a packet to one of its candidate nodes, it will first transmit a beacon packet to its candidates. The beacon packet will be received by candidates if they are active and return the ACK packet to the sender. The sender node will know about their availability after receiving the ACK packet. Based on SDORP routing flow strategy, the sender node decides the final candidate among them and sends the data packet to it. T EEC ði; j; k; }Þ denotes the expected total energy cost when there are } active candidates that are assigned to sender node n i .
The energy cost of transmitting and receiving beacon packet is expressed in equation Eq. (35).
The energy cost of transmitting and receiving the ACK packet is expressed in Eq. (36).
T AP ði; j; k a ; }Þ ¼ The energy cost of transmitting and receiving the data packet is expressed in Eq. (37).
T DP ði; j; kÞ ¼ T DP ði; j; kÞ þ R DP ðj; kÞ Hence, the expected energy cost for } active candidates that are assigned to the sender node n i is formulated in Eq. (38).
T EEC ði; j; k; }Þ ¼ T BP ði; j; k b ; }Þ þ T AP ði; j; k a ; }Þ þ T DP ði; j; kÞ: (38) Finally, based on Eq. (38) the expected energy cost T hop ði; jÞ for each transmission phase is obtained by Eq. (39) in accordance with P ¼ ð}¼xÞ which is the probability of exactly } ! 1 candidates that are assigned to the sender node n i .
Based on Eq. (39), the expected energy cost for delivering the data packet along the routing path P ¼ fn 1 ; n 2 ; . . . ; n % g is obtained by Eq. (40) where % denotes the number of nodes in the path P and P ¼ ð}¼xÞ is given by Eq. (32). (40Þ

Waiting Time
The average waiting time (AWT) represents the average number of times the sender has to wait until at least one of its candidates to wakes up and receives the data packet. Based on Eq. (21) we obtained the AWT for a packet in one hop in Eq. (41). Consequently, the AWT along the routing path P ¼ fn 1 ; n 2 ; . . . ; n % g is obtained by Eq. (42). (42)

Redundant Packets
The sender node needs to identify which of its candidates are active to decide the final candidate. For that reason, a packet is broadcasted by the sender node and the packet is sent to its several candidates that are awoken. Based on SDORP routing flow strategy, one candidate is chosen among them to transmit the packet, and others will abort the received packet. The abortion of the packets is regarded as redundant. Based on the probability of redundant packets P ¼ ð}!2Þ Eq. (24), we obtained the average number of redundant packets in each hop by Eq. (43). Consequently, the average number of redundant packets along the path P ¼ fn 1 ; n 2 ; . . . ; n % g is obtained by Eq. (44).

Validation of Analysis
We validate the expected energy cost, the average waiting time and the average redundant packets over the number of nodes by comparing the theoretical and experimental results. The accuracy of probability analysis is shown by comparing these results obtained from their average values. Expected Energy Cost. Fig. 8a shows the feasibility of theoretical and experimental results of expected energy cost for each transmission phase by varying the number of nodes. It increases with an increase in the number of nodes. The reason behind is, the number of candidates for each node increases as the network size increases gradually.
Waiting Time. Fig. 8b shows the feasibility of theoretical and experimental results of average waiting time for each transmission phase by varying the number of nodes. The average waiting time gets higher with smaller number of candidates and gets lower with the greater number of candidates due to the variation in the network size.
Redundant Packets. Fig. 8c shows the feasibility of theoretical and experimental results of average number of redundant packets for each transmission phase by varying the number of nodes. The average number of redundant packets gets higher with the increase in the number of nodes. The reason behind is, large network size generates a higher number of candidates to each node.

Simulation Scenario
The proposed protocol is tested and evaluated its performance via simulations with a simulator written in visual studio 2015 (C# WPF) [14], [16]. The source code and the documents are available online through the link: https:// github.com/howbani/sdorp. To ensure the generality of the simulation results, we randomly deployed the nodes and the sink node which is located in the center of the square-shaped monitoring area. The controller is positioned in the sink node for our convenience in the simulation phase. We used one sink and one controller. Each node operates the BoX-MAC [39] and nodes have the same active (1s)/sleep (2s) periods in the simulation phase. Each node is powered by a battery of 0.5J and consumes energy according to the Energy Model as explained in Section 4.2. We carry out the simulation 20 times in each parameter set to guarantee the accuracy of simulation results and all the results are obtained from their average values.

Evaluation Metrics
The following evaluation metrics are used and defined for the evaluation of routing protocol performance.
Energy Consumption: The total energy consumption required to transmit and receive the packets from the source to destination in a given simulation time.
Average Number of Redundant Packets (AxRP): When a packet is broadcasted by a sender node and the packet is sent to its several awoken candidates. Among them, one candidate is chosen to transmit the packet, and the others, after coordination, will abort the received packet. The abortion of the packets is regarded as redundant. AxRP is the average number of redundant packets at a given simulation time. Average Routing Distance Efficiency (RDE): The average routing distance efficiency is calculated as the ratio of the distance between each source and destination to the actual routing distance of a packet that proceeded along the path. Average Waiting Time (AWT): The average number of times the sender has to wait until at least one of its candidates wakes up and receives the packet at a given simulation time. Network Lifetime: The time from the start of the simulation until the first node dies. The simulation results presented below with the comparison of the three main protocols named ORW, ORR, and LORA.
ORW [12] utilizes the novel opportunistic routing metric, Expected Duty Cycled Wake-ups (EDC), where each node computes its EDC and forwarder set that is based on the number of neighbor nodes. ORW does not control the number of forwarders, which leads to multiple receivers problem more often. It did not consider the load balancing problem.
ORR [13] is an opportunistic routing protocol based on residual energy, that utilizes the forwarder score as a routing metric. The objective of ORR is to compute the finest forwarder that is based on forwarder score computations. ORR addressed the load balancing issue by obtaining forwarder sets solely based on residual energy.
LORA [31] is a zone-based opportunistic routing technique in which each node defines a Candidates Zone (CZ). Candidates inside the zone are given preference using a multiplication criterion that considers residual energy, perpendicular distance, transmission distance, and direction. It controls the number of candidates for each node and counterbalance the problems of waiting time and redundant packets.

Results
We evaluate the performance of the network under various scenarios Test 1 to Test 5. The network simulation parameters are mentioned in Table 4.
Test 1-Performance for Varying the Communication Ranges. The communication range varies from 50m to 100m. The simulation time to test this scenario is 480s. The improved results of various performance metrics are shown in a graphical view Figs. 9a, 9b, 9c, 9d, and 9e. Fig. 9a presents the evaluation of energy consumption. We concluded that the energy consumption of the network decreases as the communication range increases and reaches 100m. This shows much better results in the case of SDORP as compared to ORW, ORR, and LORA. In ORW and ORR, the total energy consumption decreases until the communication range reaches 70m, after that the energy consumption increases gradually. This happens because, the number of forwarders increases for each node as the communication range increases, which were not well controlled. Even though in ORR, the sink periodically calculates the maximum number of forwarders for each node and it also updates its EDC to achieve load balancing by considering residual energy among nodes. This implies that each node sends its current energy status to the sink in every update procedure. The sink recalculates the EDC and updates the node value. This consumes a lot of energy during calculation and cripples the network performance. ORW calculates its EDC in the initialization process. ORW did not consider to control the number of forwarders for each node. The adverse effect of duplicate packets affects both ORR and ORW. LORA performs better compared to ORW and ORR. It controls the number of candidates by utilizing the Candidates Zone (CZ) defined by each node and selects potential forwarders based on the prioritization criterion. SDORP calculates its EDC in the controller to assign flows to each node. It achieved better energy consumption for the following reasons. 1) It calculates the expected number of hops so that packets are guided mostly through the paths with the minimum expected number of hops towards the sink. 2) SDORP forwarders are controlled using Eq. (19) such that few candidates are allowed to be forwarders for each node. This will help to reduce the negative effect of duplicate packets generated from multiple receivers.
3) The centralized management of SDORP using the SDN approach simplifies network energy management. Fig. 9b compares the average number of hops between ORW, ORR, LORA, and SDORP. The results show that the average number of hops over communication ranges is better in the case of SDORP compared to the benchmarks. Fig. 9b also depicts that the average number of hops decreases as the communication range increases from 50m to 100m. Since smaller number of hops implies shorter routing distance, which in turn consumes less energy. SDORP utilizes the EDC metric in the controller, where it adds the Expected Number of Hops Distribution Eq. (14) parameter to ensure that packets are regularly guided through the minimum expected number of hops towards the destination. ORW, ORR, and LORA did not consider the number of hops. Fig. 9c illustrates the comparison of AxRP between ORW, ORR, LORA, and SDORP. It shows that AxRP over the communication ranges outperformed the benchmarks in the case of SDORP because it generates fewer redundant packets. Fig. 9c also depicts that the average number of redundant packets increases as the communication range increases from 50m to 100m. The greater communication ranges lead the node to select more candidates as forwarders which in turn generates a higher number of redundant packets. SDORP utilizes Eq. (19) to control the number of forwarders for each node of the routing flows, whereas LORA controls the number of forwarders based on the expected number of forwarders in the candidates zone. The network density determines the size of the candidate's zone. The ORR and ORW scenarios, on the other hand, are different, as explained above. Fig. 9d illustrates the performance of RDE over the communication ranges. SDORP achieves significant results and outperforms the benchmarks because packets are guided through the shortest route to sink. The main reason is that SDORP utilizes the Transmission Distance Distribution Eq. (8) and Expected Number of Hops Distribution Eq. (14), whereas LORA only considers the transmission distance. ORR and ORW did not consider both parameters. Fig. 9e shows the comparison of AWT between ORW, ORR, LORA, and SDORP. The results show that the AWT over the communication ranges is acceptable for all protocols. SDORP has achieved satisfactory waiting time and less redundant packets. Fig. 9e also depicts that the AWT decreases as the communication range increases from 50m to 100m because the greater communication range allows each node to select more candidates as forwarders. The increment in the number of candidates for each node has both positive and negative effects. The negative effect is that the number of redundant packets increases, affecting the network's energy consumption. In contrast, the positive effect is that the sender does not have to wait for a particular candidate node to wake up and receive the packet, which reduces the number of waiting times. The nature of asynchronous duty-cycled WSN reflects these two contradictory effects. Therefore, SDORP is designed to counterbalance between the waiting time and the redundant packets.
Test 2-Performance for Varying the Number of Nodes. The number of nodes varies from 100 to 200. The simulation time to test this scenario is 300s and the communication range is set to 80m. The improved results of various performance metrics are shown in a graphical view Figs. 10a, 10b, 10c, and 10d. Fig. 10a presents the evaluation of energy consumption for varying the number of nodes. Here, we concluded that the energy consumption of the network increases as the number of nodes increases which leads to large network size. When the size of the network is large, the number of candidates assigned to each node increases because of this, it generates more redundant packets and consumes a lot of energy. However, the large network size increases the number of hops and enforces the packet to travel through longer paths that also consume a lot of energy. The Fig. 10a shows much better results in the case of SDORP due to the utilization of Eq. (19) to control the number of forwarders such that few candidates are allowed to be forwarders for each node and also minimize the number of hops towards the destination by using Expected Number of Hops Distribution Eq. (14) which outperforms the benchmarks.  The results show that the average number of hops over the number of nodes is better in the case of SDORP as compared to the benchmarks for the same reasons explained in Test 1.
The AxRP is depicted in Fig. 10c. Here, we concluded that the AxRP increases with an increase in the number of nodes due to the higher network size that leads to generate more candidates to each node. The comparison illustrates the results of AxRP over the number of nodes are better in the case of SDORP as compared to the benchmarks for the same reasons explained in Test 1. Fig. 10d illustrates the comparison of AWT between ORW, ORR, LORA, and SDORP varying the number of nodes. We concluded that for each path AWT decreases with an increase in the number of nodes due to the larger network size that leads each node to select more candidates as forwarders. The results show that AWT over the number of nodes is acceptable for all protocols. In this scenario, SDORP has achieved a satisfactory waiting time and less redundant packets. The details are explained in Test 1.
Test 3-Performance for Varying the Wake-up Intervals.
In this test, we studied the influence of the duty-cycle on the network performance with a variation in wake-up interval from 1s to 5s and each node sleeps for 2s. The simulation time to test this scenario is 300s, the communication range is set to 80m and the number of nodes are set to 100. Fig. 11a shows the comparison of ORW, ORR, LORA, and SDORP to evaluate energy consumption over wake-up intervals. The results show that energy consumption increases with an increase in the wake-up intervals. The energy consumption increases when the node stays active for a long time due to this reason it also increases redundant packets. SDORP shows much better performance compared to the benchmarks for the same reasons explained in Test 1.
The AxRP performance is evaluated in Fig. 11b. The results show that the AxRP increases with an increase in the wake-up intervals. The main reason is that nodes wake-up for a long time which simultaneously increases the probability of multiple receivers. SDORP achieves better results compared to the benchmarks for the same reasons explained in Test 1.
The results of the AWT evaluation over wake-up intervals are shown in Fig. 11c, where SDORP achieved an acceptable results along with the benchmarks. In this scenario, SDORP has achieved a satisfactory waiting time and less redundant packets. Here, we have observed that the longer active time allows the nodes to have more candidates and for this reason, the AWT is reduced concurrently. For more details, refer to Test 1.
Test 4: Performance of Network Lifetime.
The test evaluated the performance of network lifetime over communication ranges and wake-up intervals respectively. The number of nodes is set to 100 for Figs. 12a and 12b. Fig. 12a shows the performance of network lifetime over communication range varying from 50m to 100m. SDORP shows much better performance compared to the benchmarks. The main reason is that ORW's impact on network lifetime is worst because it lacks the load balancing approach as well as it generates too many redundant packets which  consumed a lot of energy. ORR achieved better network lifetime than ORW because it controlled the maximum number of forwarders. ORR considers the energy balancing approach but it also needs to update its EDC metric periodically. In this scenario, it consumes much energy in every updating iteration. The details are explained in Test 1. LORA shows longer lifetime than ORW and ORR. In the prioritization criterion, it considers various network attributes for nodes to be selected as forwarders. SDORP applies the SDN concept to WSNs for flexible management, making energy management easier. It also employs three distributions in the EDC metric to assign the highest priority to nodes which have greater remaining energy, the shortest transmission distance to sender in each transmission phase and minimum expected number of hops to destination. Fig. 12b illustrates how wake-up intervals affect the performance of the network lifetime. The wake-up intervals vary from 1s to 5s and the node sleeps time is set to 2s. The communication range is set to 80m. The following observations can be concluded based on the results of Fig. 12b. First, the network lifetime decreases with an increase in the wake-up intervals. Second, when the node is active for a long time, it negatively affects the probability of multiple receivers, resulting in a large number of redundant packets. SDORP achieves much better results compared to the benchmarks.
The network lifetime is evaluated by varying the number of nodes, as shown in Fig. 12c. SDORP achieved promising results compared to the benchmarks. This is due to the effective load balancing approach among the nodes and efficient network management using the SDN concept. LORA attained better results compare to ORW and ORR by considering the load balancing approach. ORR only considered the energy parameter while ORW did not consider the load balancing at all and the nodes deplete their energy quickly.
Test 5: Impact of Control Variables.
The test evaluated the performance of average number of hops and network lifetime varying control variables. The number of nodes are set to 100, the communication range varies from 50m to 100m and the node active/sleep period is set to 1=2s.
The attributes control variables ( t , H , F ) can be modified to meet the application requirements. The link quality estimation is based on the average result of the three attributes that is considered in the first term of the EDC. Any control variable will enhance the influence of the respective distribution by increasing the value. The performance impact of control variables is evaluated in two parts. First, we evaluated the average number of hops varying the control variable H , it varies from 0.5 to 5. While the residual energy and transmission distance control variables ( F , t ) are set to 0.2. The packet rate is set to 1=1s. Fig. 13 shows that as the value of H increases the average number of hops decreases because the H control variable prioritize the node that has minimum number of hops to the sink. Second, we evaluated the network lifetime varying the control variable F from 0.1 to 0.5. While the values of other control variables t and H are set to 0.2 and initial energy is set to 0.1J. Each node sends 1 packet/0.1s. Fig. 14 shows that the impact of energy control variable F on the network lifetime.

CONCLUSION
A deep and detailed study of opportunistic routing and software-defined wireless sensor networks gives a great deal of an improved solution to traditional opportunistic routing protocols. Opportunistic routing works well with asynchronous duty-cycled MAC protocols that address some issues: First, the sender waiting time, where the sender must wait till its receiver wakes up. Second, assigning multiple candidates to each node reduces the waiting time, but the multiple receivers wake up at the same time that causes the packet duplication. These two problems are contradictory to each other. Third, the load balancing among the nodes is required to improve the overall network performance. The proposed SDORP protocol utilizes the SDN approach towards opportunistic routing which separates the control plane and data plane. The benefit of the SDN approach is to provide flexible management in WSNs   which enables centralized control of the whole network to simplify the deployment of on-demand network-wide management protocols and applications. The protocol addresses the above-mentioned problems by including the heuristic function that combines three attributes, transmission distance, expected number of hops, and residual energy for each node. The controller computes the EDC by integrating the average attribute term for each node in the network. The evaluation of our proposed protocol with simulation results shows better performance as compared to benchmark solutions.
Muhammad Umar Farooq received the BS degree from International Islamic University Islamabad, Pakistan, in 2012, and the MS degree in computer science and technology from the University of Science and Technology of China, China, in July 2017. He is currently working toward the PhD degree in computer science and technology from the University of Science and Technology of China, China. His research interests include WSN, SDN and security. " For more information on this or any other computing topic, please visit our Digital Library at www.computer.org/csdl.