Software-Deﬁned Network-Based Energy-Aware Routing Method for Wireless Sensor Networks in Industry 4.0

: Recent technological developments have led to the emergence of the next generation of industry—Industry 4.0. The Industrial Internet of Things (IIoT) is a key enabler of this new manufacturing paradigm where millions of interconnected smart devices, such as sensors and robots, manage massive amounts of data. Wireless sensor networks (WSNs), which allow the integration, ﬂexibility, and scalability of the production line, thus avoiding the need for complex and expensive wired networks, are essential for IIoT. Nevertheless, the nonstop improvements of the smart industry have increased the amount of data transmitted by WSNs, making their nodes, which rely on small batteries, prone to exhaustion. In this scenario, where the transmission could be abruptly interrupted, losing time, information, and money, the development of energy-based management strategies for reducing the energy consumption of WSNs is urgent. In this paper, a software-deﬁned network (SDN)-based energy-aware routing protocol is proposed to optimize the power consumption of WSNs within the framework of IIoT to support Industry 4.0. The SDN controller estimates the energy level of critical nodes in the WSN and decides the best routing path based on their energy consumption rather than on the widely used shortest-path criterion. Experimental results, obtained via a Mininet-Wiﬁ simulation, show that the proposed approach prevents WSNs’ nodes from draining their batteries and abruptly interrupting the data transmission. Hence, valuable retransmission time is saved, potential information loss is prevented, the need for replacing the node’s battery is avoided, and the transmission lifetime is prolonged. In addition, the baseline shortest-path routing method is outperformed in terms of energy consumption and node failure, doubling its transmission time.


Introduction
In recent years, technological developments, including digitalization and intelligence in many sectors, have led to the fourth manufacturing revolution, and a new type of industry-Industry 4.0-has emerged.Industry 4.0 aims to digitalize, optimize, and automatize the production process within an energy-efficient communication environment including human-machine and machine-to-machine (M2M) interactions.In this way, it adds significant value to the product life cycle and positively affects the business economy [1].
Figure 1 shows different areas where the implementation of Industry 4.0 can lead to great improvements in terms of smartness, performance, and quality [2].Nevertheless, its success depends on complex technologies, such as the Internet of Things (IoT), Industrial IoT (IIoT), cloud computing, and software-defined networks (SDNs) [3].In this scenario, the efficient implementation of these critical enablers has become a crucial subject of research.
The IoT concept entails massively connecting smart devices that sense, transmit, process, and feedback data through the Internet.The IIoT, which is the subset of the IoT technology focused on manufacturing applications, is one of the key pillars of Industry 4.0 [4,5].Generally speaking, the IIoT is devoted to the industrial value chain where an enormous number of sensors, robots, and devices are connected to the Internet for smart manufacturing purposes.In particular, it is based on M2M interfaces, which enable sensing, monitoring, collecting, transmitting, exchanging, and analyzing data without human intervention [6].Thus, communication technologies are the foundation of IIoT.Within its framework, three communication layers-sensing, network, and applicationcan be distinguished.The network layer constitutes a communication neck.This layer includes technologies based on wired sensors, such as Ethernet, and wireless sensors, such as Zigbee, WIFI, Bluetooth, Internet Protocol Version 6 (IPv6), Long Range Wide Area (LoRa), and IPv6 over Low Power Wireless Personal Area Networks (6LoWPAN) [7,8].In general, the need for mobility and wireless connections in the industrial environment is supported by wireless sensor networks (WSNs) and wireless actuator networks (WANs).Wireless sensor networks and WANs are a group of interconnected sensors and actuators that enable data sensing, information gathering, and intelligent processing with less interaction with human actions and decisions.Their capacity to address different challenges in the production line, such as integration, flexibility, and scalability, which help to reduce optimizing costs, makes them essential in the intelligent industry [9].Wireless sensor networks have been successfully implemented in several industrial scenarios, from environment monitoring to cyber-physical cloud systems [10].Nevertheless, the increasing demand for WSN-based solutions within the context of the IIoT technology to support Industry 4.0 requires further improvements in their quality of service (QoS).
Nowadays, the data generated from factories' stations are massive according to the number of sensors and data required to sense; thus, the energy consumption becomes extraordinary.In this scenario, the need for an efficient implementation of WSNs in terms of energy and end-to-end delay increases are accruing with improvement in the Industry 4.0 field.According to the authors of [11], it is possible to improve power consumption with minor delays, thus solving both issues by efficiently controlling the energy consumption.In this line, different strategies-power control schemes, data aggregation schemes, and energy-efficient routing protocols-have been proposed in the literature to deal with industrial WSNs' energy constraints imposed by their small batteries and processor memories [12,13].Unlike the traditionally used shortest-path routing protocols, which are focused on minimizing the end-to-end delay and maximizing the throughput, energy-aware routing protocols are focused on optimizing energy consumption, so that the nodes do not drain their batteries and their lifetime is prolonged [14][15][16].In this sense, they are better suited for managing WSNs within the exigent context of IIoT applications supporting Industry 4.0, where energy consumption is critical and can be solved at a minimal delay expense [11,16].
In recent years, SDNs have been successfully deployed in many fields to meet the requirements of the smart industry [17].Moreover, they have demonstrated promising results regarding energy consumption optimization [18,19].Software-defined network architectures separate the control plane (networking logic) from the data plane (routers and switches) to enable parallel processing and centralized control, which improves traditional network programmability, flexibility, scalability, and management [20,21].Recent works in [22][23][24] have shown that shifting the routing decisions from basic network elements to the SDN controller enables efficiently solving energy consumption issues as well as other important QoS issues, such as end-to-end delay and reliability.
In this paper, a SDN-based energy-aware routing protocol is proposed to optimize the power consumption of WSNs within the framework of IIoT to support Industry 4.0.In the proposed approach, the SDN controller estimates the energy level of critical nodes in the WSN and decides the best routing path based on their energy consumption rather than on the shortest-path criterion.The contributions of the proposed approach are twofold.On one hand, it prevents nodes from draining their batteries, thus preventing their failure, which would abruptly interrupt the transmission.In addition, it avoids the need for replacing the nodes' batteries, which is crucial in the practice since batteries are usually difficult to access and located in remote areas.On the other hand, balancing the energy consumption of all the nodes in the WSN allows the transmission time to last longer.The proposed approach is implemented using the Mininet-Wifi emulator [25], where the SDN architecture, including the network topology, access points, and stations, are simulated.The Ryu controller is used to control the routing path and the traffic flow.The Ryu controller is an open-source SDN framework developed by Nippon Telegraph and Telephone (NTT) cloud data written entirely in Python [26].
The experimental results show that the proposed SDN-based energy-aware routing protocol outperforms the traditionally used baseline shortest-path routing method regarding energy consumption and node failure, doubling its transmission time.
The rest of the paper is organized as follows.Sections 2 and 3 present the background and related work, respectively.The proposed SDN-based energy-aware routing protocol is introduced in Section 4. The conducted experiments are presented in Section 5.In particular, the experimental setup and the network topology are described in Sections 5.1 and 5.2, respectively.Section 6 discusses the obtained results in terms of data traffic and energy consumption.Finally, Section 7 provides the concluding remarks and discusses promising directions for future research.

Background
In this section, a brief background on Industry 4.0, WSNs, and SDNs is provided.

Industry 4.0
In recent years, manufacturing has become intelligent due to the emergence of Industry 4.0.The term "Industry 4.0" was first devised by Germans and refers to digitizing technologies [2,4].This transformation has induced a smart factory characterized by technologies that represent autonomous robots, IIoTs, SDNs, and artificial intelligence (AI) [27].
Industry 4.0 has four layers-physical, data, cloud and intelligence, and control.Figure 2 illustrates each one of them.Within this structure, the data layer transforms data from the sensor (physical layer) to the cloud and intelligence layer, and vice versa.These data are stored in the cloud temporally.Then, the control layer is responsible for controlling and assigning switching and other tasks performed by the master controller [28].In this way, the cooperation between the sensors and their integration with AI technologies, which is enabled by the Industry 4.0 framework, takes the production process to the next level [29].

Wireless Sensor Networks (WSNs)
Generally speaking, WSNs connect spatially dispersed and dedicated sensor nodes that are capable of sensing a massive amount of data and transmit them to the sink, usually referred to as the base station.Then, the sensed data are either transmitted to another base station or another sensor node in the base station.The main components of a WSN are illustrated in Figure 3 and described as follows: • Base stations: The base station transforms the data-to-data center or cloud for more processing.The sink node is responsible for analyzing and collecting data from sensors around.Choosing its best location near the sensors preserves their energy since it enables the sink node to centralize the system and receive the signals from all the sensors.The sink node is also known as a gateway when communicating to external networks.Besides the interface between the sink node and the sensors, the sink node also has a simple human interface [15].

•
Sensor nodes: The sensor nodes are used to ease the network complexity of cables; furthermore, they are admitted to be energy efficient with a long-life cycle.The sensor nodes minimize energy consumption by assigning a sleep mode to a sensor that does not sense data and an active mode to one that does.Their state changes periodically according to the state of the sensing environment [30].The sensor nodes are diffuse to sense data from the environment; then, the significant data is transmitted to the sink node.Finally, the sink nodes communicate with each other or with other sensors in the environment [30,31].

Sensor Nodes Sensor Nodes
Base Station Base Station Within the industrial environment, WSNs prevent the problems of a wired network, such as installation and maintenance costs.Moreover, the recent improvements in the field of WSNs have allowed their implementation in industrial low-cost embedded systems.In such systems, sensor nodes offer customized jobs, ranging from area, structural, waste, temperature, machine health, and power quality monitoring to industrial automation, control feedback, disaster prevention, and emergency response [32,33].

Software-Defined Networks (SDNs)
Software-defined networks are the latest technology proposed to separate the control plane from the data plane preventing the traditional network's limitations in terms of programmability, flexibility, scalability, and management.Via this separation, performed by well-defined programming interfaces between switches and the SDN controller, the switch shifts to simple forwarding devices, and all control logic becomes centralized in the SDN controller [34].
Figure 4 shows a simplified SDN architecture.The southbound application software interface (API) represents the interface between the switches and the SDN controller.The OpenFlow protocol, first introduced in [35], is used in this boundary to transfer data from the data plane to the network plane.The northbound API, for its part, enables the communication between the SDN controller and the application running above the network.Finally, the SDN controller has the advantage of being flexible so that it can be adapted to the network environment and the application using the network [36].
Within the context of Industry 4.0, SDNs address the nature of the wired/wireless IIoT nodes using the rules created in the SDN controller.These rules route the data packet coming from one switch to another or to the station connected to the switch [17].The SDN-based IIoT to support Industry 4.0 contains three layers:

•
Application layer: The application layer contains the IIoT processing system located in the data.• Control layer: In the control layer, the IIoT applications are connected to the IIoT infrastructure through the SDN controller.

•
Infrastructure layer: The infrastructure layer consists of IIoT sensors and actuators that connect to the network gateway and the whole backbone network [37].

Related Work
The rapid developments in Industry 4.0 and the IIoT have exponentially increased the need for developing efficient network solutions in terms of energy consumption and delay.As introduced in Section 1, the authors of [11] stated that power consumption can be improved with minor delays, thus solving both issues by controlling power consumption.In this line, several studies have been conducted in the field toward reaching energyefficient consumption within the IIoT and Industry 4.0 frameworks.
Khan et al. [38] presented a novel energy-harvested and cooperative-enabled efficient routing protocol for an IoT wireless body area network.Multiple parameters were considered in [38] to improve the routing including the number of hops from the sensor to the sink, the node traffic level, the signal-to-noise ratio, and the residual energy.Then, the forward nodes were selected based on the calculation of the path's cost.The results in [38] showed that the proposed parameters' cost-path calculation increases the lifetime of the sensor and decreases the end-to-end delay.
In [39,40], traditionally used routing protocols were modified to reduce their energy consumption.The authors of [39] improved the clustering protocol, which is mainly focused on reducing the end-to-end delay, to save energy and prolong the WNS's lifetime.The proposed approach reduced and balanced the energy consumption of nodes by improving the clustering structure based on a fuzzy c-means algorithm.The results in [39] proved that the modified clustering approach is suitable for long-life systems outperforming the existing clustering-based protocols.In [40], a priority-based and efficient routing protocol was proposed based on the well-known low-power and lossy (RPL) network model.In the proposed approach, each network sensor used timing patterns while sending data to the destination and tackling the traffic along the path.The experimental results of [40] showed that the proposed approach increases the routing's robustness, thus reducing delay and energy consumption.In addition, it outperforms the QoS-based RPL, which is one of the most widely used routing strategies for IoT applications.
In recent years, AI methods, especially reinforcement learning (RL) methods, have gained great popularity within the field of WSNs, IIoT and Industry 4.0 [14,41,42].In particular, intelligent routing algorithms have demonstrated that they can enable the change of the routing path according to the crowd or the complexity of data, thus improving the energetic performance of WSNs [43].In [14], an extensive review of the most relevant AI methods used in the literature to optimize the energy consumption and the network's lifetime in WSNs was conducted.Different routing protocols based on RL, ant colony optimization, fuzzy logic, genetic algorithms, and neural networks were studied.The results in [14] confirmed that RL, which is flexible, fully distributed, and robust against node failures, is the best-suited technique for WSN applications.In this line, in [42], an intelligent method based on a distributed Q-learning-aided power allocation algorithm for heterogeneous IIoT network layers was proposed to meet the QoS requirements for Industry 4.0.The performance of the proposed approach was evaluated for independent, docitive, and cooperative learning.The simulation results in [42] showed that the proposed approach is effective regarding power consumption while having low computational complexity and fast convergence.Haseeb et al. [41] introduced a secure and energy-aware heuristic-based routing protocol for WSNs.The proposed approach used AI-based heuristic analysis to accomplish reliability and security with the least complexity.The results in [41] revealed that the proposed protocol improves end-to-end delay, power consumption, and network dynamics.
Software-defined networks have also been recently used for energy optimization purposes [18,19].In [18], a binary linear programming model was proposed to manage the switches and SDN controllers based on different metrics, including traffic on the link, several flows at the network edge, and the distance between switches and controllers.The results in [18] revealed that the proposed approach saves up to 40% of the energy consumption.Shrabanee et al. [19] proposed an SDN-based resource management approach.In particular, the SDN enabled the cloud to manage resources efficiently, thus consuming less energy.The results in [19], obtained using a data center example, showed that the proposed SDN-based resource management strategy reduces 60% of the power consumption.
Finally, in [22][23][24], SDNs were used to build routing protocols for different types of networks.In [24], a recent literature review studying the most relevant SDN-based routing protocols proposed in the literature for wireless ad-hoc networks (WANETs) can be found.In particular, the current challenges in the field as well as the most concerning research gaps were discussed.In [23], an SDN-based link quality-aware routing protocol for WSNs based on the cognition of real-time network data was proposed to improve realtime data transmission.Results in [23] showed that the proposed approach achieves good performance in terms of real-time data transmission and reliability.In [22], an intelligent routing protocol based on SDN and RL was proposed.In particular, the proposed approach included RL in the SDN controller to make better decisions in terms of the different QoS issues and thus improve the routing.Results in [22] showed that the proposed approach outperforms baseline routing protocols in terms of stability, delay, and loss rate.
As discussed above, SDNs have been used in the literature to reduce energy consumption in different applications [18,19] and build QoS-aware routing protocols for different types of wireless networks, including WANETs and WSNs [22][23][24].Nevertheless, none of these works have exclusively addressed-and solved-the energy consumption issue in IIoT and Industry 4.0 by developing energy-aware routing strategies based on SDNs.In this paper, an SDN-based energy-aware routing protocol is proposed to optimize the power consumption of WSNs within the framework of IIoT to support Industry 4.0.In particular, the SDN controller estimates the energy level of critical nodes in the WSN and decides the best routing path based on their energy consumption rather than on the shortest-path criterion.In this way, by balancing the energy consumption of all the nodes in the WSN, critical nodes do not drain their batteries.Consequently, the transmission lasts longer, and the need for replacing nodes' batteries is avoided.

Proposed SDN-Based Energy-Aware Routing Protocol
In recent years, Industry 4.0 has gained great popularity in the manufacturing field.Nodes are a primary technology in this industry due to the central role of data exchange.In general, nodes relay and forward data to other nodes in the sector; thus, energy is spent on both transmitting and receiving data.Since wireless mobile nodes depend on the batteries equipped within, the life of these batteries is critical.In particular, it affects the energy consumption of the whole wireless network as well as the duration of the data transmission.
Traditionally, routing strategies have been based on the shortest-path criterion, which uses optimal (shortest) paths no matter the nature (or state) of the nodes.Consequently, nodes used large amounts of their energy to exchange huge amounts of data, and the batteries of the mobile, wireless nodes become exhausted.In order to solve this issue, we have developed a SDN-based energy-aware routing protocol for WSNs that allows the SDN controller to estimate the energy level of critical nodes in the WSN and decide the best routing path based on their energy consumption and battery state rather than on the shortest-path criterion.
In the proposed routing approach, the battery level is the primary factor in deciding the path.At the beginning of transmission, the battery is assumed to be fully charged for all the access points.During transmission, the access points' battery levels decrease as the amount of traffic is transmitted through them.If any access point reaches a critical battery level, the SDN controller will decide to change the routing path.
The proposed method distinguishes itself from the traditionally used routing techniques since it can be used in access points and stations in the industry without turning off the devices with low batteries.It is important to highlight that the proposed routing strategy takes care of the energy of access points, not the data center, within a wifi environment.
Figure 5 shows the components of the proposed approach, which works as follows.The sensor senses the data, processes them, and proceeds to the access point to transmit them.In order to transmit the data, the access point needs to know the appropriate path according to the energy level of the other components in the network.To this end, the SDN controller estimates the amount of energy consumed in each node based on the number of bytes sent and received and assigns the right path to deliver data traffic based on the estimated battery level.In the proposed algorithm, the battery level of WSN is considered to change the path.The amount of battery consumed affects the energy consumption.This assignment is focused on making the node live longer to reach the following objectives: The pseudocode of the algorithm developed to implement the proposed routing protocol is provided in Algorithm 1. Algorithm 1 has four functions: TopologyDiscovery(), TrafficGenerator(), EnergyEstimation(Power,Byte), and PathSelection(AP,Path).It works as follows.
Initially, TopologyDiscovery() determines the network topology; the function result sets the number of access points and stations.Subsequently, TrafficGenerator() generates user datagram protocol (UDP) traffic from the first node in the network to the last one, independently of the chosen path.The energy at each access point is estimated by EnergyEstimation (byte, time) based on the number of transmitted bytes and the power consumption.If an access point's power reaches its maximum level (denoted as MaxEnergy in Algorithm 1), the PathSelection() function will choose the path depending on the energy consumption.

Evaluation Experiments
In this section, the experiments conducted to evaluate the performance of the proposed SDN-based energy-aware routing approach are described.In particular, Section 5.1 describes the experimental setup, and Section 5.2 presents the network topology used in the experiments.

Experimental Setup
In this paper, the Mininet-Wifi tool proposed in [25] is used for emulation purposes.Mininet-Wifi is an open source tool that extends the well-known Mininet emulator http: //mininet.org/accessed on 24 August 2022 to implement SDNs with virtual wireless access points and stations.Within the Mininet-Wifi framework, the Ryu controller is considered.Traffic between nodes is generated by the iperf command, whereas the number of bytes sent and received by the access point is captured by the cat/proc/net/dev commands.The main technical aspects of the emulation are summarized in Table 1.The SDN controller estimates the transmission (E tx ) and receiving (E tx ) energies as [44]: )Power tx , where Time is the transmitter and receiver time; Byte is the number of transmitted bytes at each second; DataRate is a specific number of bytes transmitted per second; and Power tx and Power rx are the transmission and receiving power, respectively.

Network Topology
The network topology used to evaluate the proposed SDN-based energy-aware routing approach is shown in Figure 6.The network contains five nodes.Each one of them contains a sensor and access point.The proposed approach will be evaluated based on a transmission of UDP packets from Sensor 1 to Sensor 4 using iperf.Two different routing alternatives can be distinguished to transmit the packet.On one hand, the default routing strategy (i.e., the shortest-path routing) will transfer the UDP packet through Node 2. On the other hand, the proposed SDN-based energy-aware routing approach will take into account the energy level in each node to decide the best route.In particular, the energy of each node will be calculated based on the number of bytes sent and received.Then, the SDN controller will alter the routing path based on the energy consumed by Node 2 and route through another path (Node 3 and Node 5) whenever necessary to keep Node 2 alive and balance the energy consumption in all nodes.
The data traffic and energy consumption of all the nodes in the network resulting from the implementation of the proposed routing approach are analyzed in Section 6.In addition, these results are compared to the ones obtained with the baseline shortest-path routing method.

Results and Discussions
In the network topology shown in Figure 6, Node 2 is the optimal path between Node 1 and Node 4 since it shortens the route.Nevertheless, this route is not always a viable alternative since it probably leaves Node 2 exhausted.The SDN-based energy-aware routing approach proposed in this paper considers the energy consumption in each node to overcome this issue.It works as follows.At the beginning of the transmission, the shortest path is used to send the UDP packets from Access Point 1 to Access Point 4 through Access Point 2. This holds until the SDN controller decides to change the route path to the longest-but more efficient-path based on the estimation of the energy consumption of Access Point 2. The longest and more efficient path includes Access Point 3 and Access Point 5, as shown in Figure 6.The transmission from Access Point 1 to Access Point 4 through Access Point 3 and Access Point 5 holds until the battery level of Access Point 2 enables the use of the shortest path again.Then, the SDN controller shifts the routing path to the shortest path, and Access Point 1 transmits to Access Point 4 through Access Point 2 again.This procedure is repeated until the transmission ends.In this way, whenever the battery level of Access Point 2 decreases, it becomes inactive, thus receiving and transmitting data for less time and preventing its battery from becoming exhausted.
The performance of the proposed SDN-based energy-aware routing protocol is evaluated in terms of the data traffic and the energy consumed to transmit the UDP packets from Node 1 to Node 4 in the network depicted in Figure 6.For comparison purposes, the performance of the baseline shortest-path routing method is also evaluated on the same network.
Figures 7 and 8 show the transmitted and received bytes when using the proposed and the shortest-path routing methods.In the proposed SDN-based energy-aware routing protocol, the energy level of each of the access points in the network is the primary factor in the selection path by the SDN controller.At the same time, the data traffic impacts the total energy consumption of each of the access points.Figures 9 and 10 show the transmission and receiving energies consumed when using the proposed routing approach as well as the shortest-path routing method.In Sections 6.1-6.5, we discuss each one of the access points in the network (see Figure 6) separately in terms of data traffic and energy consumption.Finally, in Section 6.6, the packets transmitted and received by Access Point 2 as well as its power consumption are evaluated for each of the studied routing protocols.

Access Point 1
The number of bytes transmitted and received by Access Point 1 when using the proposed and shortest-path routing methods is shown in Figures 7a and 8a, respectively.The data traffic of Access Point 1 when using each of the evaluated routing protocols is as follows:  7a.
Finally, the transmission energy consumption of Access Point 1 is shown in Figure 9a for the proposed and shortest-path routing methods.It is the same in both cases since the transmission of Access Point 1 lasts the whole communication time.

Access Point 2
The data traffic and energy consumption of Access Point 2 when using each of the evaluated routing protocols are as follows: • Shortest-path routing method: Access Point 2 receives bytes from Access Point 1.
Figure 8b shows the number of received bytes in Access Point 2. While receiving these bytes, the receiving energy consumed in Access Point 2 increases, as shown in Figure 10b.Then, Access Point 2 transmits the received bytes to Access Point 4, as shown in Figure 7b.In this case, the transmission energy in Access Point 2 is high, as shown in Figure 9b.At 200 s, the number of bytes transmitted and received drops sharply since the battery of Access Point 2 diminishes, and so does the consumed energy, either for receiving (see Figure 10b) or for transmitting (see Figure 9b).This is due to the fact that, when only the shortness of the path is considered to assign the routes, Access Point 2 works during the whole time Access Point 1 and Access Point 4 are communicating.

•
Proposed SDN-based energy-aware routing method: Access Point 2 receives bytes from Access Point 1 and transmits them to Access Point 4 (shortest-path routing).This holds until the SDN controller, based on the estimation of the energy level of Access Point 2, decides to shift the routing path to the energy-aware routing path to prevent Access Point 2's failure.In this way, Access Point 2 stops receiving and transmitting bytes.At 160 s, when the battery level of Access Point 2 increases, the routing path is shifted to the shortest-path routing, and Access Point 2 receives and transmits bytes again.According to Figures 7b and 8b, where the received and transmitted bytes in Access Point 2 are shown, respectively, Access Point 2 is active from 0 to 60 s and 160 to 240 s, whereas it is idle for the rest of the transmission time.
The transmission and receiving energies, shown in Figures 9b and 10b, respectively, follow the same pattern the traffic data does.They increase between 0 and 60 s while Access Point 2 is transmitting and receiving, decrease when Access Point 2 is idle from 60 to 160 s, increase again between 160 and 240 s, and decrease one more time between 240 and 400 s.In this way, the battery of Access Point 2 lasts longer.

Access Point 3
The data traffic and energy consumption of Access Point 3 when using each of the evaluated routing protocols are as follows: • Shortest-path routing method: Access Point 3 only participates in the longest (energyaware) path.Thus, in this routing method, it is idle the whole transmission time.
Consequently, the number of bytes transmitted and received as well as the transmission and receiving energies are close to zero, as shown in Figures 7c and 8c as well as Figures 9c and 10c, respectively.• Proposed SDN-based energy-aware routing method: Access Point 3 is idle from 0 to 60 s since the SDN controller selects the shortest path (Access Point 2).Then, from 60 to 160 s, the SDN controller decides on the energy-aware path.At 160 s, the SDN controller prefers to revert back to the default routing path (shortest path) until 240 s.Finally, the energy-aware path is chosen again between 240 and 400 s.Whenever the energy-aware path is chosen, Access Point 3 receives bytes from Access Point 1, as shown in Figure 8c, and the consumed receiving energy increases, as shown in Figure 10c.Then, Access Point 3 transmits the bytes to Access Point 5 as shown in Figure 7c, and the consumed transmission energy increases, as shown in Figure 9c.The rest of the time (from 0 to 60 s and 160 to 240 s), Access Point 3 neither receives nor transmits data, and the corresponding energies are close to zero.

Access Point 4
Since Access Point 4 is the destination of the transmission, it does not transmit bytes in either of the routing methods; thus, the number of transmitted bytes as well as the consumed energy for doing so are close to zero, as shown in Figures 7d and 9d, respectively.The received bytes and receiving energy consumption of Access Point 4 when using each of the evaluated routing protocols are as follows: • Shortest-path routing method: Access Point 4 receives the data traffic from Access Point 2. The received bytes are shown in Figure 8d, and the receiving energy increases as shown in Figure 9d.In this case, the transmission depends entirely on the battery state of Access Point 2.Then, when Access Point 2 becomes ineffective (at 200 s), the receiving energy drops, and the transmission is terminated.8d.In this line, the receiving energy consumption of Access Point 4 is stable until the end of the transmission, as shown in Figure 10d.

Access Point 5
The data traffic and energy consumption of Access Point 5 when using each of the evaluated routing protocols are as follows: As discussed above, based on the results shown in Figures 7-10, the traditionally used shortest-path routing method exhausts Access Point 2. Consequently, the battery of Access Point 2 drains, and the transmission, which only uses Access Point 2 to reach Access Point 4 from Access Point 1, is abruptly interrupted at 200 s.The proposed SDN-based energyaware routing approach outperforms this baseline routing method by enabling the SDN controller to shift the routing path from the default one (shortest path) to the energy-aware path based on the estimation of the energy level of Access Point 2. In particular, Access Point 2, which is energetically critical, is only used when its energy level is high.When its energy level is low, it is skipped, and Access Point 1 is connected to Access Point 4 through Access Point 3 and Access Point 5.In this way, the battery of Access Point 2 is preserved, which prevents its failure, as this would abruptly interrupt the transmission as well as the need for replacing it.Moreover, since the energy consumption of all access points in the network is balanced by the SDN controller's decisions, the transmission lifetime is prolonged, and its duration doubles the one corresponding to the shortest-path routing method.

Packet Evaluation at Access Point 2
The transmitted and received packets and the energy consumption of Access Point 2 when using each of the evaluated routing protocols are as follows:

End-to-End Delay
The delay of transmitted bytes from Access Point 1 to Access Point 4 using the shortest path routing method and the SDN-based energy-aware routing method is described in this section.
In the shortest-path routing method, Access Point 1 transmits bytes to Access Point 4 through the shortest path via Access Point 2, as demonstrated in Figure 12.The delay is lower due to there being two links between Access Point 1 to Access Point 4, Access Point 1 to Access Point 2 and Access Point 2 to Access Point 4. In the Proposed SDN-based energy-aware routing method, Access Point 1 transmits the bytes to Access Point 3, then Access Point 3 transmits the packet to Access Point 5. Finally, the bytes arrive at Access Point 4. According to the transmission path and associated links, the delay is higher, as shown in Figure 12.The differences in delay increase as the links increase.However, in the industry environment, energy consumption is more critical than a slight difference in delay.

Conclusions and Future Work
The IIoT is a key enabler of Industry 4.0 and produces a massive amount of data for the manufacturing process that is usually managed by WSNs.Nevertheless, with the continuous improvement of the smart industry, WSNs that rely on a number of nodes with small batteries have been led to their boundaries.Traditionally, network management strategies such as the baseline shortest-path routing protocol have paid little to no attention to energy consumption issues.However, transmitting huge amounts of data through WSNs can exhaust their nodes, thus abruptly interrupting the transmission and losing time, information, and money.In this scenario, the development of energy-based management strategies for reducing the energy consumption of WSNs is urgent.
In this paper, an SDN-based energy-aware routing protocol has been proposed to optimize the power consumption of WSNs within the framework of IIoT to support Industry 4.0.In the proposed approach, the SDN controller estimates the energy level of critical nodes in the WSN and decides the best routing path based on their energy consumption rather than on the shortest-path criterion.In this way, the energy consumption of all the nodes in the WSN is balanced since the critical nodes are used only when their energy level is high and preserved when their energy level is low.
Experimental results, obtained via a Mininet-Wifi simulation, have shown that the proposed SDN-based energy-aware routing protocol efficiently distributes the data packets among the nodes at different time intervals based on the SDN controller's decision, and thus reduces the energy consumption of the WSN.In particular, it has been possible to prevent WSNs' nodes from draining their batteries and abruptly interrupting the data transmission.This saves valuable retransmission time, prevents potential information loss, avoids the need for replacing the nodes' batteries, which are difficult to access, and makes the transmission time last longer.Finally, the proposed approach outperforms the traditionally used baseline shortest-path routing method in terms of energy consumption and node failure in addition to doubling its transmission time.
As future work, we plan to apply the developed SDN-based energy-aware routing protocol in different scenarios.The topology limitation constrains the SDN-based energyaware routing protocol in future scenarios, where nodes could not connect to other nodes in the network except through the low battery node due to the vast distance.In particular, we intend to implement it within the environment of mobile nodes with a restricted-energy source.In addition, using AI strategies to improve the performance of the proposed approach is also a promising future research direction.

•Figure 5 .
Figure 5. Components of the proposed SDN-based energy-aware routing protocol.

•
Shortest-path routing method: Similar to the case of Access Point 3, Access Point 5 only participates in the longest (energy-aware) path.Consequently, the number of bytes transmitted and received as well as the transmission and receiving energies are close to zero, as shown in Figures 7e and 8e as well as Figures 9e and 10e, respectively.• Proposed SDN-based energy-aware routing method: In the energy-aware routing path, Access Point 5 receives bytes from Access Point 3. The received bytes from Access Point 3 are shown in Figure 8e, whereas the consumed receiving energy is shown in Figure 10e.Subsequently, Access Point 5 transmits the bytes to Access Point 4, as shown in Figure 7e, consuming the transmission energy shown in Figure 9e.As in the case of Access Point 3, Access Point 5 is active from 60 to 160 s and 240 to 400 s.During these periods of time, the transmission and receiving energies increase, whereas during the first 60 s and from 160 to 240 s, the SDN controller selects Access Point 2 to transfer the traffic, and the transmission and receiving energies decrease.

•Figure 11 .
Figure 11.Cumulative Packets and Energy of Access Point 2.

Figure 12 .
Figure 12.End-to-End Delay of Transmiited Bytes From Access Point 1 to Access Point 4.

Table 1 .
Technical aspects of emulation.
• Proposed SDN-based energy-aware routing method: Access Point 4 is the destination of the bytes from Access Point 1.On one hand, if the battery level of Access Point 2 is high, Access Point 4 receives traffic from Access Point 2. On the other hand, if the battery level of Access Point 2 is low, the SDN controller shifts the traffic path to the energy-aware routing path, and Access Point 4 receives traffic from Access Point 5.In this case, independently of whether Access Point 2 or Access Point 5 is transmitting them, Access Point 4 receives bytes continuously, and the transmission lasts up to 400 s, as shown in Figure