SDFMUCR: Software-defined and fuzzy-based multi-hop unequal cluster routing

Recently, wireless sensor networks play an important role in our life. Researchers give more and more attention to the design of the routing algorithm. Cluster routing is the most popular routing protocol in wireless sensor networks. However, hotspot problem always exists. Unequal cluster routing is an effective method to solve this problem. In these protocols, nodes closer to base station have the smaller cluster size than other sensor nodes. It will reduce the relay pressure of the node which is near to the base station. The development of the software-defined network optimizes the performance of wireless sensor networks. In this article, we propose a software-defined and fuzzy-based multi-hop unequal cluster routing protocol. It adopts three methods to make the routing protocol outstanding. First, it uses a novel software-defined network architecture to reduce computation overhead and energy overhead in sensor nodes. Then, the fuzzy logic–based intracluster and intercluster routing is designed to balance energy consumption. Finally, residual energy–based rotating scheme is proposed to reduce most of the control overhead. According to the simulation results, the proposed protocol balances and reduces the energy consumption, extends the lifetime, and reduces the control overhead and latency of the network.


Introduction
In the past years, wireless sensor networks (WSNs) have gained more and more attention because of the development of the micro-electro-mechanism system (MEMS), 1 wireless communication techniques, and so on. WSNs play an important role in environmental sensing, military defiance, habitat, tracking, monitoring, and so on.
WSN is the network which consists of a large number of wireless nodes. Each node is equipped with sensors and a battery. They can sense and transmit information to the base station (BS) through single hop or multi-hops. 2 Generally, WSNs are deployed in harsh environment which makes it difficult to recharge the battery of the sensor nodes. This reduces the network lifetime and leads to an energy consumption unbalance.
Many studies show that the wireless transmission unit consumes more energy than other units. As a consequence, designing an efficient routing protocol is a great way to increase the lifetime of the entire network. Cluster routing has been paid more and more attention because of the advantage of a balanced energy consumption. 3 In cluster-based WSNs, cluster members (CMs) gather and transmit the sensor data to the cluster heads (CHs) through the schedule of time-division multiple access (TDMA). [4][5][6] Then, CHs aggregate the sensor data and transmit it to the BS. Clustering algorithm reduces the amount of data transmitted in the network because of the aggregation in the CHs. As a result, the network energy consumption is reduced.
In most cluster routing algorithms, CHs consume more energy than CMs. This is the hotspot problem in WSNs. Unequal clustering approach is a good way to overcome the hotspot problem. In the unequal clustering approach, the size of cluster which is closer to BS is smaller. And the cluster size of CH which is far away from the BS is larger. CHs with less CMs consume less energy in the phase of aggregate and transmit aggregated data. They use the redundant energy to relay data packets far from the BS.
When determining the optimal size of clusters, the distance to BS, remain energy, density, and so on are considered. When there are lots of uncertainties, fuzzy logic (FL) is one of the best approaches to prevent this problem. 7 FL is a logical system which consists of four parts: (a) fuzzifier, (b) inference system, (c) de-fuzzifier, and (d) fuzzy rule. Crisp values are input to the FL system and are converted into fuzzy linguistic variables. Then, fuzzy linguistic variables are input to the inference system which includes the fuzzy rule. Then, inference system uses if-then rules to convert fuzzy linguistic variables into fuzzy variables. Finally, the fuzzy variables are input to the de-fuzzifier and converted into a crisp value. [8][9][10] As it is well known, the first-order radio model is used as the energy consumption model for WSNs. So, it can consume more energy in a large wireless network if CHs transmit data directly to the BS. Therefore, CHs far from the BS can transmit data to the CH which is near to the BS to reduce energy consumption.
The WSNs need to balance the energy by rotating the CHs among sensor nodes. However, it usually reclustering in each round makes it consume more time, energy, and calculation resources. 11 Hence, it should both consider the network lifetime and energy consumption balance. In this article, we propose an algorithm which considers multiple factors comprehensively to design the best rotating rounds after each reclustering.
In most distributed routing protocols, cluster routing protocols for example, each node should collect the information of other nodes in the CH selection phase. Meanwhile, CHs need dispatched messages to find the routing between CHs and BS. However, it can be difficult for an edge node to find the best routing to the BS when using distributed routing in a large network. It will increase the routing overhead in order to guarantee the success in routing discovery phase.
Software-defined wireless sensor networks (SDWSNs) are proposed to use software-defined technologies for sensing, routing, and measurement tasks in WSNs. SDWSN separates the control plane from the data plane which reduces the computation overhead and routing overhead in sensor nodes. 12 In SDWSN, some dispatched messages are surely needed in the topology discovery phase. Then controller uses the information of the whole network to design the optimal routing. Sensor nodes can make it easy to get the optimal routing to BS which reduces failure rate in the routing discovery phase and reduces the number of dispatched messages. Therefore, software-defined networking (SDN) based routing protocols reduce the overall energy consumption in the sensor nodes.
In conclusion, the issues of the existing work are given as follows: 1. In most distributed routing protocols, sensor nodes need a lot of dispatched messages to find the routing to BS. The routing is calculated in the sensor nodes, which makes the computation overhead high. 2. In most cluster routing algorithms, nodes far from the BS die quicker than other nodes when CHs transmit data to the BS directly. However, the nodes which are near to the BS consume energy quicker than other nodes when CHs transmit data to BS through multi-hops. 3. The WSNs need to balance the energy by rotating the CHs among sensor nodes. However, it usually re-clustering in each round makes it consume more time, energy, and calculation resources. 11 Hence, it should both consider the network lifetime and energy consumption balance.
In this article, we propose a software-defined and fuzzy-based multi-hop unequal cluster routing (SDFMUCR) algorithm. The main contributions of this article are given as follows: 1. According to issue 1, a novel SDN framework is used in this algorithm to reduce the energy consumption of transmitting redundant messages in the cluster setup phase. This method reduces the computation overhead and the routing overhead in the sensor nodes which prolongs the network lifetime. The BS acts as controller which uses fuzzy-based multi-hop unequal cluster routing and residual energy-based rotating scheme to calculate the routing of the entire network. Sensor nodes only need to gather and transmit the data to the next hop which has been designed in controller. 2. According to issue 2, the proposed protocol uses fuzzy-based multi-hop unequal cluster routing to ensure the unequal clustering and choose the best relay node. Different from other proposed protocols, we propose the ''relative intercluster cost,'' ''relative intracluster cost,'' and ''relative relay cluster cost'' innovatively to design the best routing of the whole network. Unequal cluster scheme reduces the intracluster cost for the CHs which are near to the controller. A novel algorithm is proposed to find the optimum CH for CMs. This algorithm considers three factors innovatively in order to find the best CH for CMs. Multi-hop scheme reduces the intercluster cost for the CHs which are far from controller. These methods balance the energy consumption and prolong the network lifetime. 3. According to issue 3, the proposed residual energy-based rotating scheme gives a highperformance network. This method reduces the number of times to re-cluster the routing and reduces the control overhead in each round. Only when WSN satisfies the conditions which are proposed in section ''Residual energy-based rotating scheme,'' it will re-calculate the routing of the entire network. This scheme reduces the energy consumption in sensor nodes as well as balances the energy of the entire network.
The rest of the article is organized as follows. Section ''Related works'' reviews the related works of routing protocols in WSNs. The network assumptions and energy model are described in section ''System model.'' Section ''SDFMUCR protocol'' introduces the framework of the SDWSN which is used in this article. Meanwhile, this section describe the intracluster routing and the intercluster routing which use the FL system. Section ''Theoretical analysis of the protocol'' analyzes the protocol at the theoretical level. Simulation results and analysis are expounded in section ''simulation results.'' We will conclude the article in section ''Conclusion.''

Related works
In recent years, the design of low-energy consumption routing protocols has gained more and more attention. At the mean time, FL and the software-defined network are usually used to extend the network lifetime and optimize other performances of the WSNs. The overview of the SDWSN and FL-based unequal cluster routing are given as follows.

SDWSN
For traditional routing protocols in WSNs, sensor nodes need to collect the related information such as residual energy, neighbor information, and so on. Then, sensor nodes use the information to calculate the routing. This method increases computation overhead in sensor nodes. However, only the controller needs to calculate the routing of the entire network in SDWSN. This will reduce computation overhead in sensor nodes. Meanwhile, this architecture reduces the consumption of energy and prolongs the network lifetime.
Many SDWSN-based frames have been proposed earlier. 13,14 These frames usually have advantages like energy efficiency, robustness, scalability, or adaptability. However, many of them only contain one or two advantages as mentioned above. The proposed architecture includes all the features mentioned above, and the main contribution is to make the network energy efficient.
T Luo et al. 15 proposed the SDWSN, which synergizes SDN and WSN to solve WSN-inherent problems. S Bera et al. 16 designed a software-defined wireless sensor network (Soft-WSN) architecture which consists of the device and network management. The proposed scheme is able to meet real-time requirements of internet of things (IoT). These two architectures did not consider designing the effect flow table which is used to manage the energy consumption. We proposed the SDN framework overall consideration of the topology information module, controller module, flow table, and data management module. It well reduces the energy consumption of the network. W Liao et al. 17 designed an energy-efficient algorithm-based multi-energy-space (MES) in Soft-WSN. They designed the architecture of SDWSNs and proposed an MES-based algorithm. SDN-based routing protocol reduces the routing overhead as well as balances the energy consumption and increases the network lifetime. P Li et al. 18 used game theoretic to improve the energy consumption performance in SDWSN. The architecture of the SDWSN is same as Liao et al.'s 17 and it also improves network performance. In Liao's and Li's algorithm, sensor nodes transmit the data packets to the controller by multi-hops and without data aggregate. This way increases consumption of energy and network overhead. J Aparicio et al. 19 designed an algorithm to improve the energy efficiency of SDN-based mobile wireless sensor network (MWSN). It adopts the sensor OpenFlow protocol to achieve the SDN architecture. Meanwhile, they proposed a cross-over net algorithm between the network layer and transport layer. This algorithm increases the network lifetime as well as reduces the overhead in the central processing unit (CPU) and message retransmission.
X Wei et al. 20 proposed a particle swarm optimization (PSO)-based algorithm in SDWSN. This protocol divides the network into clusters. And each cluster consists of one control node and a number of sensor nodes. The algorithm is suitable for a variety of scenarios and overcomes the NP-hard problem. The SDN-based protocols perform better than distributed routing protocols. But the huge number of control nodes will increase the cost of network. N Abdolmaleki et al. 21 designed the fuzzy topology discovery protocol (FTDP) which is according to the software-defined network solution for wireless sensor networks (SDN-WISE). FTDP separates the control logic from sensor node. This method reduces the routing overhead in sensor nodes. It increases the packet delivery ratio and the network lifetime.

FL-based unequal cluster routing
Unequal cluster routing is one of the best ways to solve the hotspot problem in WSNs. FL is a great method to implement unequal cluster-based routing protocols. FL can consider many factors (such as residual energy, distance to BS, etc) synthetically and make the protocol efficiently. 22 Therefore, FL-based unequal cluster routing is a good method to improve the performance of the network.
Energy-aware unequal clustering algorithm (EAUCF) 23 is an FL and unequal-based routing algorithm which is proposed earlier. Candidate CHs are elected randomly in WSNs first. The FL's input parameters are the distance to BS and residual energy. The FL's output parameter is competition radius. The final CHs are determined among the candidate CHs by comparing residual energy with each other. CMs transmit the data to CH and CHs transmit the aggregation data to the BS directly. The lifetime is extended and the energy is balanced. Nevertheless, the algorithm does not consider the density of each node and if the final CHs with high density are selected, the energy consumption will be huge for these CHs.
The FL approach is used for unequal clustering in distributed load balancing unequal clustering (DUCF) 24 too. It uses the residual energy, node degree, and distance to BS as input variables to fuzzy inference system (FIS). The output parameters are the chance to be CH and the number of CMs. It ensures the load balance among clusters and improves the network lifetime. However, it increases the transmission information in the cluster setup phase because of using the number of CMs as the output of fuzzy system.
Fuzzy-based unequal clustering algorithm (FUCA) 7 uses the FL system to form unequal clusters. It prolongs the network lifetime and balances the energy consumption. It elects the candidate CHs randomly, and only candidate CHs can be the final CHs which reduces the CPU usage and the energy consumption in sensor nodes. The inputs of the fuzzy system are residual energy, node density, and distance to BS. The outputs of the fuzzy system are competition radius and rank. If a node has the highest rank within its competition radius, it will be selected as a CH. CHs collect the sensor data of the CMs and then transmit the aggregation data to BS. It does not consider the relay mechanism which makes the network consumption unbalanced.
Multi-objective fuzzy clustering algorithm (MOFCA) 25 solves both the energy hole and the hotspot problem successfully using the FUCA. This algorithm has excellent performance in the total remaining energy (TRE), the lifetime of the WSNs, and the first node dies (FND). The protocol selects candidate CHs the same as the FUCA routing algorithm. Unfortunately, it causes the energy unbalance if low residual energy nodes are chosen as the candidate CHs.
Distributed FL-based energy-aware and coverage preserving unequal clustering algorithm (DECUC) 2 considers the coverage parameter of the sensor nodes innovatively. It prolongs the coverage lifetime of the target area as well as the lifetime of the network. This routing protocol uses the FL system to ensure the unequal cluster and choose the optimum CHs. Then, non-CH nodes also use the FL system to select which cluster to join in. This scheme increases the calculation amount and energy consumption of sensor nodes. It uses the delay time when choosing CHs and when sensor nodes decide to join which cluster. The disadvantages are extending the time in CHs selection phase and the cluster formation phase.
In FL-based unequal clustering (FBUC) 26 routing protocol, the CH selection is the same as the aforementioned routing protocols. The innovation of this protocol is to use the FL system makes CMs decide which CH to join. It reduces the transmission delay and power consumption. However, it does not design the intercluster routing which will not apply for a large network.
Some cluster-based algorithms design the reasonable intercluster routing such as ant colony optimization (ACO)-based relay routing protocol. Fuzzy-and ACObased combined mac, routing, and unequal clustering cross-layer protocol (FAMACROW) 27 and fuzzy-based unequal clustering and ACO-based routing hybrid protocol (FUCHAR) 28 both use the FL for CHs selection and ACO for intercluster routing. FAMACROW improves performance of energy consumption, network lifetime and packet delivery rate. In order to reduce the time to re-clustering, CMs rotate to act as CHs for each round. However, protocol should ensure that each CMs can communicate with the CH, and this requirement causes the size of cluster decreased. FUCHAR increases the network lifetime and solves the hotspot problem. In the cluster setup phase, it uses five values such as residual energy and node degree as the input to the FL system to calculate the cluster size and CH probability. This method increases the CPU and energy overhead in sensor nodes.
Distributed fuzzy approach to unequal clustering and routing algorithm (DFCR) 29 is designed base on the unequal cluster and multi-hop intercluster routing algorithm. This routing protocol also uses the FL to guarantee the unequal cluster. It can lower the intercluster cost by proposing the intercluster communication rationally. In the distributed unequal cluster-based routing algorithm (DUCR), CHs find the routing to BS by broadcasting control messages and comparing the level information. However, it will increase the broadcast range continually until they find the optimum relay CH to the BS. It increases control messages that increments the probability of message collision and energy consumption.
Intra and intercluster communication (IICC) 30 uses the fuzzy-based unequal cluster and multi-hop routing algorithm. It reduces the average energy consumption, reduces the end-to-end delay and increases the packet delivery ratio. However, the process of the intracluster routing and intercluster routing are both handled in sensor nodes which increases the energy consumption of the network. DUCR 31 reduces the energy consumption and prolongs the network lifetime. However, it does not consider the density in clustering phase. If a node which has a high density is selected as CH, it will unbalance the energy consumption of the network. Meanwhile, CH may broadcast more messages in order to search the optimal relay CH.
Shawkat K. Guirguis et al. proposed the hybrid fuzzy multi-hop unequal clustering algorithm (HFMUC) algorithm in order to increase the network performance in network lifetime and energy balance. 32 This protocol uses the FL system for unequal cluster in heterogeneous dense WSNs. And CHs transmit the data packets to BS through multi-hop.
Hybrid unequal energy-efficient clustering (HEEC) 33 uses the unequal cluster and multi-hop mechanism for intracluster routing. It also designs the multi-hop mechanism for intercluster routing. First, sensor nodes determine the layer of itself based on the distance to BS. Next, nodes calculate the radius and delay time based on the density, residual energy, and the distance to BS. Nodes broadcast the head message until the end of delay time. If a node receives a head message before the end of delay, it quits the CHs election. Then, CMs join the CH with the shortest distance. Finally, CHs select the next hop based on the layer information. CMs transmit the data packet to CH, and CHs transmit aggregation packet to BS hop by hop. In the next round, the node which has the highest residual energy will be selected as a new CH. It reduces network overhead, increases network stability, energy balance, and network lifetime.
The comparison of some of the algorithms with our proposed method is listed in Table 1.

Network assumption
The proposed algorithm adopts the SDN to reduce the energy consumption in the network. It uses the FL for intracluster and intercluster routing. Some assumptions of the network are listed as follows: 1. Sensor nodes act as switches at random distribution and stationary after deployment, and only exit the network when a node is dead due to energy exhaustion. 2. The BS acts as a controller. 3. Sensor nodes and controllers are equipped with global positioning system (GPS) to get their own accurate position. 4. Network links are symmetrical and sensor nodes are homogeneous. 5. The energy of the sensor nodes are limited, and the energy of the controller is sufficient. 6. Power of transmit data and calculation speed of the controller are stronger than those of sensor nodes.
In WSNs, sensor nodes are usually deployed in the harsh environment. So it is hard to recharge the battery of sensor nodes which makes the energy of the sensor nodes limited. A controller is used to collect topology information, calculate routing, collect sensor data, and so on. Therefore, it does not need to deploy in the harsh environment. It is convenient to recharge the battery. So the energy of the controller is sufficient. The controller must process more information and calculate the routing of the entire network. So the calculation speed of the controller must be higher. The transmitted power of the controller can be higher in order to reduce the packer loss in multi-hop routing.

Energy model
In WSNs, the total energy consumed of the sensor nodes includes the transmission, reception, and aggregation. The transmission and reception energy model uses the first-order radio model. The energy consumption in transmitting l bits packet over a distance d is given by equation (1) where E elec is the electronic energy dissipated by transmitter or receiver, e fs and e mp are the energy dissipated for free space and multipath fading. The parameter d 0 = ffiffiffiffiffiffiffiffiffiffiffiffiffi e fs =e mp p is the distance threshold. The energy dissipated is proportional to the d 2 when transmission distance is less than distance threshold. Otherwise, it is proportional to the d 4 .
The energy consumed in receiving l bits packet is given by equation (2) The energy consumed in aggregating data is given by equation (3) N is the sensor nodes belong in a cluster. E agg is the aggregation energy dissipated for each packet. The total energy consumed of the CHs includes the transmission, reception, and aggregation. Nevertheless, it only includes the transmission in the non-CHs. The total energy consumption for the CHs is given by equations (4) and (5). Where agg is the data aggregation rate in the CH. d c is the distance between CH and controller. d nonÀCH is the distance between CH and non-CH

SDFMUCR protocol
The SDFMUCR protocol can be divided into four phases. It includes the topology discovery phase, the routing table generate phase, the routing table delivery phase, and the data transmission phase. The phases of the proposed protocol are given as Figure 1.
In the topology discovery phase, the BS acts as a controller to broadcast control message. Sensor nodes send necessary information to the controller in order to let the controller calculate the routing. The details of the topology discovery phase are given by section ''SDN framework for the proposed protocol.'' Next, the controller designs the FL-based intracluster routing and intercluster routing. The details of the routing protocol are given by section ''Fuzzy-based multi-hop unequal cluster routing.'' Then, the controller delivers the flow table by multi-hop. Finally, sensor nodes transmit sensor data to the controller and start the topology maintain phase. If WSNs need to re-compute the flow tables in the topology maintain phase, it returns to the topology discovery phase. The trigger cases for reclustering are given by section ''Residual energy-based rotating scheme.''

Residual energy-based rotating scheme
For most cluster routing protocols, the network recomputes the routing after each round. It increases the calculation pressure and dissipates the energy resource in the cluster setup phase. In this article, residual energy-based rotating scheme is used to prevent this problem. The network updates the cluster routing until an interrupt occurs. The interval between interruptions should not be too long or too short. If too long, it causes energy unbalance in the network. On the contrary, it transmits more control messages and consumes more energy in the phase of topology discovery. Hence, it is necessary to design the best conditions in order to return topology discovery phase and to update the routing again. Some conditions to re-calculate the routing are listed as follows. It will be executed in the controller as long as one happens.
1. The number of alive nodes changes in the network. 2. The network has run more than r max after update the routing. Where r max is a constant, which is the maximum running rounds after the controller delivers the flow tables. 3. It satisfies the inequality (6). Where E min is the minimum energy of the whole network, and E th is the energy threshold for the controller to recalculate the routing We define the FND as the network lifetime. The purpose of this condition is to prolong the lifetime of the entire network. And E min is a key parameter of the entire network. If a sensor node with less energy still acts as a CH, it will run out of energy rapidly. When the energy of the sensor node is less than E th , the controller will re-calculate the routing. This method prolongs the lifetime of the entire network and avoids the sensor nodes with less energy continuously act as CHs.
4. It satisfies the inequality (7). Where E ave is the average energy of the entire network The purpose of this condition is to balance the energy consumption of the whole network. We hope energy consumption of all the sensor nodes in the network as consistent as possible. When the residual energy of a sensor node is far less than the average energy, the protocol can reduce the energy consumption of this node by re-calculating the routing of the entire network.

SDN framework for the proposed protocol
In the proposed protocol, we adopt the SDN framework in order to reduce the consumed energy. The network consists of sensor nodes and controller. Sensor nodes act as switches which only need to collect the position, residual energy, and other information of itself and inform the controller. The BS acts as a controller that computes the routing table of the whole network and transmits forward table to the sensor nodes. The proposed protocol uses a controller instead of sensor nodes to compute the routing of the entire network. This method reduces computation overhead and energy consumption in sensor nodes.
The protocol structures of controller and sensor nodes are given as Figure 2. Both of them have three layers: physical layer, network operating system (NOS) layer, and application layer. In order to implement function, the NOS layer replaces the transport layer, network layer, and data link layer. The physical layer is responsible for the signal processing. The application layer is responsible for application management. For controller, the NOS layer is used for topology information management, load balance management, energy efficiency management, virtualization management, and generating the flow table. For sensor nodes, the NOS layer is used for topology management as well as processes the flow table which is received from the controller.
The proposed SDWSN architecture for SDFMUCR protocol is shown in Figure 3. It includes the application layer, control plane, data plane, northbound interface, and southbound interface. The application layer includes a variety of applications. The southbound interface is between the control plane and data plane. It is used to exchange data between the controller and sensor nodes. The northbound interface is between the application layer and control plane. The application layer uses this interface to get the resources of the underlying network. The controller works on the control plane and sensor nodes work on the data plane. Data plane consists of the sensor module, sending module and receiving module. Sensor module is used to sense and generate the sensor data. Sending and receiving module is used to transmit and receive the massage. Control plane consists of the topology information module, controller module, flow table, and data management module. Topology information is managed in the topology information module. These messages are processed in the controller module and then controller generates the flow table. Sensor data are managed in the data management module. The phases of the  SDFMUCR protocol are topology discovery, topology maintain, flow table generation, and flow table delivery. The details of the phases are introduced below.
Topology discovery phase. The main purpose in the topology discovery phase is to collect the key information such as the location and the residual energy of the sensor nodes. The key information is collected by the controller and then is used to calculate the routing of the entire network.
The topo_rq message and the topo_rp message are used in the topology discovery phase. The controller broadcasts the topo_rq message in order to collect the topology information at the start of the topology discovery phase. Sensor nodes which receive the topo_rq message will packet the location (including x and y coordinates) with the residual energy into the topo_rp message. For the sensor nodes which distance to controller is far from the transmission range, a multi-hop routing mechanism is established to solve this problem. When a node receives the topo_rq message, it establishes a temporary one-way secure channel to the controller. Next, it rebroadcasts this topo_rq message until it gets to the edge of the network. The nodes which far from the controller then establish a one-way secure channel to the node which transmits this topo_rq message. So far, the multi-hop routing to controller has been established. Finally, sensor nodes send the topo_rp message through the secure channel. If a node receives the same topo_rq message of the same node in a round, it discards this message. This mechanism ensures the controller receives the topo_rp message from the nodes which are far from the controller. The controller records the topology information to the topology information module as long as it receives the topo_rp message.
In this phase, sensor nodes and controllers are equipped with GPS to get their own accurate position. Although the use of GPS consumes more energy than the GPS-free localization methods, it can get the exact location of the node which makes the routing of the entire network generated earlier. Meanwhile, the GPS goes into sleep mode once the sensor node gets its own position. What's more is that, the proposed protocol uses the residual energy-based rotating scheme to further reduce the work time of the GPS. These methods reduce the energy consumption of the GPS which makes the use of GPS energy efficient. A sensor node typically consists of a computational sensing element, a processing unit, a storage unit, and a power source. The GPS module is only a small part of the sensor node; its cost is much lower than other parts of the sensor node. Compared to the scene of GPS-free methods, this method does increase the cost of the network. Since most GPS modules cost less, the price of this approach is only a little more than the scene of GPSfree. However, this approach greatly improves the performance of the network. So this method is costefficient.
Flow table generation and delivery phase. The main purpose of the flow table generation phase is to calculate the routing of the entire network. The operations take place in the controller's control module. The control module calculates the routing using the location and residual energy information which are in the topology information module. The fuzzy-based multi-hop unequal cluster routing is used to decrease the energy consumption and to extend the network lifetime which will be discussed in detail in section ''Fuzzy-based multi-hop unequal cluster routing.'' The sensor nodes are divided into CHs and CMs in the cluster routing. Control module generates the flow table after designing the optimal routing. The flow table includes the CH flag (flag CH ), precursor list, TDMA schedule list and next hop. For CHs, the CH flag is ''1'' and the precursor list lists the nodes whose data packets or aggregate packets need to be relayed by local node. The CH flag is ''0'' and the precursor list is empty for the CMs. The next hop domain is used to transmit data packets. The TDMA schedule list consists of the time slot number and the node number. When a CH receives the flow table, it generates a TDMA schedule for its precursor nodes. The precursor nodes number will be added to the TDMA schedule list from the smallest to the biggest. So far, the TDMA schedule list has been filled in completely. Then, the control module establishes two-way secure channels to deliver the flow table. Finally, the flow table will be delivered to the sensor nodes hop by hop. So far, the routing for the entire network is established.
Data transmission and topology maintain phase. The main purposes in the topology maintain phase are to transmit the data packets and agg_data packets and detect changes of the network in order to update the routing timely. Agg_data packet is the packet which is aggregated by CHs. The operations are different in different nodes. For CMs, they only awake in the time slot which is allotted by their CHs. In this time slot, CMs packet the sensor data with the residual energy in the data packet and transmit it to the controller according to the flow table in each round. Then they sleep in the remaining time. The residual energy is used in the control module to decide whether to update the flow table. It does not need the location information because the nodes are stationary after being deployed. As for CHs, they will be awake at any moment in order to receive the data packets from CMs. Once a CH receives all the data packets from precursor nodes, they aggregate the data packets and transmit the agg_data packet to the next hop. They will also detect the precursor list in each round. The precursor list contains the CH and CMs which are the precursor nodes of the local node. If it does not receive the data packet from any precursor nodes, that means the precursor node dies and the precursor list changes. If the precursor list changes, the CH establishes a one-way secure channel and transmits the topo_repair message to the controller.
In the topology maintain phase, the controller updates the topology information when it receives the data packet. It returns to the topology discovery phase when it receives the topo_repair message. Besides, some other reasons to let the network into the topology discovery phase are listed in section ''Residual energybased rotating scheme.'' The process of SDFMUCR protocol is shown in Algorithms 1 and 2.
Secure channel. In the proposed protocol, we design the dynamic secure channel. The design of the secure channel makes the control message of the entire network and the sensor data of the nodes transmitted in two channels, respectively. This method reduces the traffic load in one channel and avoids the collision between these two types of information. Normal channel and control channel are built at different frequencies. The secure channel is only established when the sensor nodes transmit the topo_rp message, controller delivers the flow_table to the entire network, or the Wait until an interrupt occur 8: if On receiving a message then 9: switch Type of the message 10: case: On receiving the topo_rq message 11: if The first time receive topo_rq message then 12: Set node state as topology discovery phase 13: Update the next hop node 14: Establish a one-way secure channel 15: Response topo_rp message 16: Rebroadcast 1: Initialization 2: Set node state as topology discovery phase 3: Set timer t1 to collect the topology information 4: Set timer t2 to collect the data message 5: t The running time of each round 6: t3 t3r max 7: Broadcast a topo_rq message 8: while j do 9: Wait until an interrupt occur 10: if Timer t1 runs out then 11: Establish two-way secure channels 12: Using algorithm 3 compute and deliver the flow_table 13: Set node state as topology maintain phase 14: else if timer t2 runs out then 15: ifResidual energy of the entire network satisfies the inequality (6) and (7) 16: Set node state as topology discovery phase 17: end if 18: else if timer t3 runs out then 19: Set node state as topology discovery phase 20: else if On receiving a message then 21: switch Type of the message 22: case: On receiving the topo_rq message 23: Drop the topo_rq message 24: case: On receiving the topo_rp message 25: Update the topology information module which includes the location and the residual energy of the nodes 26: case: On receiving the topo_repair message 27: Set node state as topology discovery phase 28: case: On receiving the data packet 29: Update the energy information in the topology information module 30: end switch 31: end if 32: end while sensor nodes transmit the topo_repair message. The temporary secure channel consists of one-way secure channel and two-way secure channel. The establishment of secure channel is given as follow.
In the topology discovery phase, sensor nodes establish the one-way secure channel to controller when receiving the topo_rq message. The next hop is the node which transmits this topo_rq message. Then local node responses the topo_rp message to controller through this secure channel. So far, the one-way secure channel has been established.
In the flow table generation and delivery phase, the controller uses the information of the whole network to calculate the optimal secure channels to sensor nodes. The secure channel aims at reliable, security, and less energy consumption. Then controller module establishes the two-way secure channels to each sensor nodes. Next, controller delivers the flow_table hop to hop through these two-way secure channels. When sensor nodes receive the flow_table, they will use the twoway secure channel to response the ACK message to controller and forward the flow_table to next hop. So far, the one-way secure channel has been established. In the data transmission and topology maintain phase, the controller will re-calculate the two-way secure channels for the whole network when receiving the topo_repair message from sensor nodes.
The proposed framework designs the flow_table as simple as possible. So the overheads of the control message are low. In WSNs, the topology of the whole network is not stationary which makes the secure channels not absolute secure. So the secure channels should be used as less as possible.

Fuzzy-based multi-hop unequal cluster routing
The detail of the SDFMUCR will be discussed in this section. The architecture of the SDFMUCR is shown in Figure 4. The proposed routing protocol includes the intracluster routing and the intercluster routing. They are both calculated in the controller. This mechanism reduces the calculation pressure and energy consumption in sensor nodes.
Fuzzy-based unequal cluster routing is used to calculate the intracluster routing. The intracluster routing includes the CHs selection process and the cluster formation process. The FL system for intracluster routing is shown in Figure 5. The inputs to the FL system are relative residual energy, relative intercluster cost, and relative intracluster cost. These three parameters are used to calculate the CH probability and the competition radius.
Relative residual energy. The responsibilities of the CHs in WSNs are to receive and aggregate the sensor data from the CMs and transmit the agg_data packets to the controller or the relay CH. So its energy consumption is heavier than CMs. Therefore, the node with high residual energy should have a high CH probability and a large competition radius. The relative residual energy is given by equation (8) E 0 re is the relative residual energy. E re is the residual energy of the node. E min and E max are the minimum and the maximum residual energy of the entire network, respectively. These two parameters are learned from the control module.  Before introducing the relative intercluster cost and relative intracluster cost, we assume node i is the CH and analyze the total energy consumption of its cluster in each round. The total energy consumption is given as equation (9) where N nei is the set of neighbor nodes of node i. Neighbor node means the distance to node i which is less than the node communication radius. And according to equation (1)-(5) which are defined in section ''Energy model.'' We can get the equation (10) where N , l, E elec , E agg , agg, and e fs are constants. And only the d c 2 and P j2N nei d ij 2 can influence the E total . d c is the distance between node i and controller. d ij is the distance between node i and node j. The purpose in our protocol is to minimum the ''E total .'' So we define d c 2 as the intercluster cost and P j2N nei d ij 2 as the intra cluster cost. The relative intercluster and the relative intracluster costs are defined as follows.
Relative intercluster cost. Relative intercluster cost C inter is the normalization of the intercluster cost which given as (11). d max is the maximum distance between controller and sensor nodes which is learned from control module. For CHs, the intercluster cost depends on the distance to controller. In a multi-hop routing, the nodes near to controller also undertake the relay task that consume more intercluster cost. So the sensor nodes with low C inter should have low CH probability and small competition radius Relative intra cluster cost. Relative intra cluster cost C intra is the normalization of the intra cluster cost which given as (12). R is the communication radius of the sensor nodes. The nodes with high C intra increase the average energy consumption within the cluster. Hence, the sensor nodes with high C intra should have low CH probability and small competition radius CH probability. CH probability is the chance to be a CH. It is a decimal between 0 and 1. The nodes with high CH probability are more likely to be selected as the CH.
Competition radius. Competition radius is the broadcast radius in the CHs selection process. The nodes with higher competition radius are more likely to be selected as the CHs.
The crisp values input to the FL system should be converted into a fuzzy linguistic variable. And the handle of the input and output variables are given as follows.
The first input variable ''relative residual energy'' has three fuzzy linguistic variables. They are low (L), medium (M), and high (H). Low and high have trapezoidal membership function and medium has the triangular membership function. The membership functions base on the related work and our simulation results. The fuzzy set for ''relative residual energy'' is shown in Figure 6.
The second input variable ''relative intercluster cost'' has three fuzzy linguistic variables. They are low (L), medium (M), and high (H). Low and high have trapezoidal membership function and medium has the triangular membership function. The fuzzy set for ''relative intercluster cost'' is shown in Figure 7.
The third input variable ''relative intracluster cost'' has three fuzzy linguistic variables. They are low (L), medium (M), and high (H). Low and high have trapezoidal membership function and medium has the triangular membership function. The fuzzy set for ''relative intra cluster cost'' is shown in Figure 8.
The first output variable ''CH probability'' has 11 fuzzy linguistic variables. They are very very low (VVL), very low (VL), low (L), rather low (RL), low medium (LM), medium (M), high medium (HM), rather high (RH), high (H), very high (VH), and very very high (VVH). VVL and VVH have trapezoidal membership function and other variables have the triangular membership function. The fuzzy set for ''CH probability'' is shown in Figure 9.
The second output variable ''competition radius'' has 11 fuzzy linguistic variables. They are very very small (VVS), very small (VS), small (S), rather small (RS), medium small (MS), medium (M), medium large (ML), rather large (RL), large (L), very large (VL), and very very large (VVL). VVS and VVL have trapezoidal membership function and other variables have the triangular membership function. The fuzzy set for ''competition radius'' is shown in Figure 10.
In the CHs selection process, the control module learns the location and residual energy from topology information module first. Then, the control module calculates the relative residual energy, relative intercluster cost, and relative intracluster cost for each sensor nodes according to equations (8), (11), and (12). These three input variables fuzzify into linguistic variables. The linguistic variables are processed by fuzzy if-then rules which are developed by Mamdani method shown in Table 2. The total of the fuzzy if-then rules are 27 and center of area (COA) method is used to de-fuzzify the output linguistic variables into crisp variables. So far, controller generates the CH probability and competition radius for each sensor node.
Next, each sensor node compares the CH probability to other sensor nodes which are among the competition radius. The node which has the highest CH probability    is selected as the final CH; otherwise it quits the CH selection. This process decides the final CH and is operated in the control module because the control module knows the location of each node. In this process, the controller also acts as the CH. Hence, the non-CH nodes which are closer to the controller will select controller as its CH.
Finally, non-CHs select its CH. And the selected CH should be in its communication range. It considers three factors, the distance to CH d CH , the residual energy of CH E re CH , and the number of neighbor nodes of CH N 0 nei . N max nei is the number of neighbor nodes of the CH which has the max N 0 nei of the entire network. So the N 0 nei =N max nei is the density of the CH. If the number of nodes in a cluster is large, it will increase the intracluster cost of CH. Therefore, the high-density CH should have a low probability to be selected as CH. The probability to select a CH for the non-CH P e is given as equation (13). Then, the non-CH selects the CH which has the maximum P e . So far, the intracluster routing is finished The purpose of the first part in this equation is to reduce the energy consumption for non-CH. The purpose of the last two parts is to reduce the energy consumption for CH. The energy consumption in transmit is higher than receipt. So the first part is the most important and need to have a high weight. Based on the experience, the weight is 0.8, 0.1, and 0.1.
A FL-based intercluster routing is proposed to reduce the intercluster energy consumption. Distance threshold d th is defined in this process. A CH whose distance to the controller is greater than d th should find a relay CH as its next hop. The relay CH should satisfy the inequalities (14), (15), and (16). E r is the residual energy of the relay CH. d rc is the distance between the relay CH and controller. d r is the distance to the relay node It selects set of relay CHs through above process. Then, we use the FL system to calculate the join CH chance. The two input parameters to the FL system are relative residual energy and relative relay cluster cost. The equation and fuzzy set of ''relative residual energy'' are given as equation (8) and Figure 6.
Relative relay cluster cost. Relative relay cluster cost C relay is the normalization of the relay cluster cost which is given as equation (17). The nodes with high C relay increase the intercluster energy consumption of CH. So the sensor nodes with high C relay should have low join CH chance Relative relay cluster cost has three fuzzy linguistic variables. They are low (L), medium (M), and high (H). Low and high have trapezoidal membership function and medium has the triangular membership function.
The fuzzy set for ''relative relay cluster cost'' is shown in Figure 11.
Join CH chance is the probability of a non-CH node join a CH. The output variable ''join CH chance'' has five fuzzy linguistic variables. They are very low (VL), low (L), medium (M), high (H), and very high (VH). VL and VH have trapezoidal membership function and other variables have the triangular membership function. The fuzzy set for ''join CH chance'' is shown in Figure 12.
In the intercluster routing process, the control module selects the CHs which need relay to the controller. Then, CHs generate the set of relay CHs which satisfy the inequalities (14), (15), and (16). Next, control module calculates the relative residual energy and relative relay cluster cost for each node in the set of relay CHs. These two input variables are fuzzified into linguistic variables. The linguistic variables are processed by fuzzy if-then rules which are developed by Mamdani method shown in Table 3. The total of the fuzzy if-then rules are 9 and COA method is used to de-fuzzify the output linguistic variables into crisp variables. So far, it generates the ''join CH chance'' for CHs. The CHs select the relay CH which has the maximum ''join CH chance'' as its next hop. So far, the process of the intercluster routing has finished.
The media access control (MAC) mechanism of the proposed protocol is given as follow. SDFMUCR consists of the normal channel and the secure channel. These two channel work on the different frequencies which reduces the collision of the control message. Sensor nodes contain two modes: sleep mode and wakeup mode. In the topology discovery phase, sensor nodes work on the wakeup mode. The topo_rq message is transmitted in the normal channel and the topo_rp message is transmitted in the secure channel. Next, the controller calculates the routing of the whole network and delivery the flow_table through secure channel. In the data transmission phase, CHs allocate the time slots to the CMs according to TDMA. CMs awake and  transmit the data packets to CH in its own time slot. The CMs are in the sleep mode at other time slots. Then, CHs receive and aggregate the data packet and transmit the agg_data packets to the next hop until the agg_data packets arrive at the controller. In this phase, the CHs always in the wakeup mode. The process of the forwarding rules generation in controller is shown in Algorithm 3. The flowchart of SDFMUCR protocol is given as Figure 13. In the topology discovery phase, controller broadcasts the topo_rq message. When a sensor node receives the topo_rq message, it establishes the twoway secure channels, responses the topo_rp message, and rebroadcasts the topo_rq message. Once controller receives all topo_rp message of the network, it uses the fuzzy-based multi-hop unequal cluster routing mechanism to calculate the routing of the entire network. Controller also works as CH in the proposed protocol. Controller calculates the E 0 re , C inter , and C intra and then uses fuzzy system to calculate competition radius C R and CH probability CH p. A node which has the highest CH p within C R will be selected as CH. CMs select CH which has the highest P e . If a CH's distance to controller is less than R, the next hop of itself is controller. Otherwise, it finds the nodes which satisfy equations (14)-(16) as the relay node set. Join CH chance J CH is calculated by fuzzy system. The next hop is CH which has the highest J CH. Finally, sensor nodes add itself to the precursor list of next hop and the flow table is generated.
In the flow table delivery phase, the controller delivers the flow table. When a node receives the flow table, it updates the CH flag , precursor list, the TDMA schedule list and the next hop. CH will forward the flow table to the nodes which are in the precursor list. In the data transmission and topology maintain phase, CMs transmit data packet to CH and CHs aggregate the data packets and transmit the agg_data packet to the next hop. If a node's residual energy satisfies the conditions to re-calculate the routing, it sends the topo_repair message to controller. The network will return to the topology discovery phase when the controller finds the number of alive node change, the network has run more than r max or receives the topo_repair message.

Time complexity
The time complexity of SDFMUCR is given as follow.
We define n as the number of sensor nodes in the entire network. First, controller processes the topology information of each sensor nodes through FL system. Next, it determines which nodes are CHs. The time complexity is O(n). Then, controller calculates the intracluster routing. The number of CHs in the network is C and the time complexity is O(C(n À C)) = O(Cn À C 2 ). Finally, controller calculates the intercluster routing. The time complexity is O(C 2 ). So the time complexity is O(n + Cn À C 2 + C 2 ) = O(n).

Memory complexity
The flow table includes the CH flag (flag CH ), precursor list, TDMA schedule list, and next hop. So the memory complexity of SDFMUCR is O(n). Using equation (8), (11), (12) calculate E re 0 , C inter 8: and C intra 9: ½C R, CH p = fuzzy1(E re 0 , C inter , C intra ) 10: end for 11: for i = 1 ! N do 12: if 9j : Sjd ij \C R i CH p j .CH p i 13: i:flag CH = 0 14: if j satisfy inequality (14), (15) and (16) then 40: Using (17)  Control overhead is the average number of the control messages to be transmitted in the network within a round. In the topology discovery phase, the nodes within the transmission range of controller response the topo_rp message to controller directly. Other nodes response the topo_rp by multi-hops. We define N t as the number of nodes within the transmission range and k as the maximum hops of the entire network. The maximum number of the control message in the topology discovery phase is N t + k(n À N t ) = kn + (k À 1)N t . In the flow table generation and delivery phase, CHs need to response the ACK message and retransmit the flow_table to the precursor nodes. CMs only need to response the ACK message. The number of the control message in the flow table generation and delivery phase is (n À C) + 2C = n + C. Therefore, the maximum number of the control message is C m = kn + (k À 1) N t + n + C = (k + 1)n + (k À 1)N t + C. In the proposed protocol, it only need control message to recalculate the routing when the network satisfy the conditions proposed in section ''residual energy based rotating scheme.'' So the control overhead of SDFMUCR is between C m =r max and C m .

Simulation results
The proposed SDFMUCR protocol is compared with the EAUCF, 23 FUCA, 7 and HEEC 33 under four scenarios. EAUCF and FUCA are the distributed FLbased unequal clustering protocols for WSNs. HEEC is the multi-hop-based unequal clustering protocol for WSNs. The different network scenarios are shown in Figure 14 and the simulation parameters are given as Table 4.
The nodes are random distributed in the 100 m 3 100 m location area. The initial energy of each node is 0.5 J. The length of the control message is 32 bits and the length of the data packet is 4000 bits. The data aggregation rate in the CHs is 0.1. The controller is located in the center of network in Scenarios 1 and 2. In Scenarios 3 and 4, the controller is located in the corner of network. The numbers of the deployed nodes in four scenarios are 100, 200, 100, and 200, respectively.
We use the MATLAB to simulate and evaluate the proposed protocol and other well-known protocols. Each scenario is simulated 50 times to reduce error in simulation. Five metrics are considered as the performance parameters to evaluate the routing protocols. They are the TRE, the lifetime of the network, the number of alive nodes of communication round, control overhead of the network, and the latency of the sensor nodes. In each scenario, the average of the simulated results is shown as follows.

Lifetime and energy consumption of the network
One goal in our research is to reduce the energy consumption of the entire network. If the residual energy of the sensor node reduces slowly, the nodes will have more time for collecting and transmitting the data to the BS. It prolongs the lifetime of the network which makes the protocol more suitable for deployment in harsh environments. For the lifetime of the network, first node die is as the metric to evaluate it. The number of alive nodes of communication round represents the trend of the number of alive nodes in the network. With the decrease in the number of alive node, the nodes which are far from BS will have a hard time to transmit the data packet to the BS. So when a node dies, some of the alive nodes may stop working because there is no routing to the BS. So we define the FND as the lifetime of the network, and the number of alive nodes of communication round reflects the connectivity of the network. Table 5 and Figure 15 show the lifetime for all protocols. They express that the proposed protocol performs well in each scenario. The lifetime in each scenarios are 1144 rounds, 1140 rounds, 714 rounds, and 784 rounds. The details for all protocol simulation results in each scenario are shown in the subsequent paragraphs.
In Scenario 1, the controller is located in the center of the network and 100 sensor nodes are deployed in the area. The total of remain energy of communication rounds is shown in Figure 16. In simulation result, SDFMUCR consumes energy slower than other protocols which indicates the proposed protocol reduces the   Figure 16. For the lifetime of network, the SDFMUCR performs better than EAUCF by 222.2%, FUCA by 175% and HEEC by 23.9%. In EAUCF, FUCA, and HEEC, CM nodes transmit the packet to CH and then CH aggregates and transmits the agg_data packet to BS. In SDFMUCR, the sensor nodes which are near to controller transmit the data packets to controller directly. This method reduces the energy consumption of aggregation, reception, and transmission in CH nodes which are closer to controller. Meanwhile, SDFMUCR proposes the residual energy-based rotating scheme and this scheme reduces the average control overhead and energy overhead in each round. Finally, SDN architecture is used in this protocol and reduces the computation overhead in sensor nodes. In Scenario 2, the position of the controller remains unchanged and the node density is twice than that in Scenario 1. The simulation results are shown in Figures  18, 19 and Table 5, which are nearly the same as Scenario 1 shown in Figures 17 and 18. Therefore, the node density does not influence the performance of the proposed protocol. For the lifetime of network, the SDFMUCR performs better than EAUCF by 208.1%, FUCA by 210.6%, and HEEC by 32.9%.
In Scenario 3, the controller is located in the corner of the network and the number of deployed nodes is 100. The simulation results are shown in Figures 20 and  21 and Table 5. It can be seen that the proposed protocol performs better than the comparison algorithms in energy consumption. Meanwhile, the SDFMUCR performs better than EAUCF by 142.0%, FUCA by 59.4%, and HEEC by 50.3%. For SDFMUCR, CHs find the optimum CH as its next hop if necessary. This way avoids the large energy consumption for the CHs which are far away from the controller. The EAUCF and FUCF do not have the scheme for relay, so their performance is worse than SDFMUCR. In HEEC, distributed intercluster routing increases the control    Table 5. In Scenario 4, the SDFMUCR also performs well in energy consumption and the lifetime of the network. The SDFMUCR performs better than EAUCF by 412.4%, FUCA by 335.6%, and HEEC by 9.0% for the lifetime of the network. This simulation results show that the position of the controller and the network density do not influence the performance of the proposed protocol.
According to the simulation results, SDFMUCR performs better than the comparison protocols. It reduces the energy consumption and prolongs the network lifetime. First, the proposed SDN framework reduces the control overhead and calculation overhead of the sensors. Second, residual energy-based rotating scheme reduces the average number of control message transmitted in the network. Third, fuzzy-based unequal cluster routing and multi-hop scheme balance the    energy consumption of the intercluster routing which prolongs the lifetime of the entire network. Fourth, CMs join the CH based on the distance to CH, residual energy of CH, and the density of CH. This mechanism balances the energy consumption of the intracluster routing. Fifth, controller also works as CH which balances the energy of the node which is near to controller.
In the above reasons, the proposed SDN framework plays an important role in reducing the energy consumption of the entire network. Three reasons are listed as follows. First, SDFMUCR reduces the number of the control message. For sensor nodes, it only needs to transmit the topo_rq message, topo_rp message, and flow_table to establish the routing of the entire network. However, the distributed routing protocols need many control message for intercluster routing and more control message for intracluster routing which increases the control message and increases the energy consumption. Second, SDFMUCR transmits the control message through two channels which reduces the collision of the message, reduces the number of times to retransmit the message and reduces the energy consumption. Third, instead of calculating the routing in the sensor nodes, SDFMUCR generates the routing in the controller which reduces the calculation overhead in sensor nodes. So the proposed SDN framework in SDFMUCR reduces the energy consumption in the network.

Control overhead
The control overhead for all protocols is given as Table  6. Control overhead is the average number of the control messages to be transmitted in the network within a round. If the protocol's control overhead is low, the energy consumption for control message and the time for generating the routing is low. According to simulation, SDFMUCR performed well than all comparison protocols in each scenario. The control overhead of EAUCF and FUCA is relatively low because they do not have the mechanism to relay which reduces the number of control message in the entire network. HEEC has the highest control overhead because the relay mechanism increases the number of control message of the network. SDFMUCR proposes the residual energy-based rotating scheme. It only need control message to re-calculate the routing when satisfy the conditions to re-establish the routing. This mechanism reduces the average control message in each round and the control overhead is very low.

Latency
The latency for all protocols is given as Figure 24. Latency is the average time between when the data were sensed and when the data were transmitted to BS for a sensor node. If the latency is low, the network will be more suitable for deployment scenarios with low latency requirements. EAUCF and FUCA almost have   the same latency because they do not have the relay mechanism and the intracluster routing is similar for these two protocols. HEEC has the relay mechanism in order to balance the energy of the sensor nodes. It needs more time to relay the aggregate data packet, so the latency of the HEEC is the most highest. In SDFMUCR, controller also works as a CH in the network. The nodes which are closer to controller can transmit the sensor data to controller directly, so the latency of the SDFMUCR is low.

Conclusion
In this article, the proposed protocol combines SDN architecture with FL-based unequal cluster routing. The intra and intercluster routing are calculated in the control module that reduces calculation and energy overhead in sensor nodes. Meanwhile, all nodes participate in the CHs selection process which avoids the low residual energy nodes that are selected as the CHs. Simultaneously, the residual energy-based rotating scheme is proposed to reduce the control message in each round. Finally, FL-based unequal cluster routing and multi-hop intercluster routing are proposed to ensure the optimum performance of the designed algorithm. Via simulation, SDFMUCR performs better than the wellknown algorithms, such as EAUCF, FUCA, and HEEC. The proposed protocol reduces the energy consumption, prolongs the lifetime of the network, balances the energy consumption, reduces the control overhead, and reduces the latency of the network. The proposed SDWSN framework and protocol can be used in the barren areas, forests, or farms for a long time to monitor environment variables. Further studies will focus on the design of the routing with mobile BS.

Declaration of Conflicting Interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.