Abstract
Wireless sensor network based on service-oriented architecture has provided important support for Internet of Things in smart city; therefore, multi-requests can be satisfied through service composition. However, as the number and complexity of requests increase, the dynamic and low energy of sensors in wireless sensor network gradually limit the development of the service-oriented architecture in Internet of Things; therefore, optimizing energy under the condition that multi-requests can be satisfied in the dynamic wireless sensor network becomes an important problem. To address this challenge, first, this paper analyzes the mobility of sensors to predict the path stability and manage the information and capabilities on them so that we can find the satisfactory service provider candidates. Then, this article proposes a service mapping pre-process to achieve the work flow reduction in a service layer to save energy in advance and a service mapping process to find the optimal sensors in a network layer that can satisfy the requests. Simulation results show that our strategies can achieve the goal of energy conservation, load balancing, and network lifetime extension under the premise of guaranteeing requests function and non-function attributes and have better performance than traditional ones.
Introduction
In smart cities, wireless sensor network (WSN) uses a service-oriented architecture (SOA) to provide support for the execution of services in the novel paradigms of Internet of Things (IoT).1,2 Services include both functional and non-function attributes. 3 The function attributes refer to the process in which service operates input data to produce expected output data, while the non-function attributes refer to the quality of service (QoS) which the service can provide, including delay, cost, and reliability.
Generally, service composition represents the process that several atomic services implement complex functions which cannot be fulfilled individually. 4 The related researches have achieved such results in the traditional platform.5,6 Currently, it mainly adopts the method of matching between input and output of atomic services and then generating work flow to realize functions. In SOA-based WSN, a large number of sensors not only sense environment information but also have certain communication and computing capabilities and can provide multiple atomic services. Using work flow technology, WSN integrates the capabilities of sensors and converges them to the sink node to satisfy the functions of IoT requests.
Besides function attributes, QoS that can improve experience of users should also be considered. 7 In this article, the atomic service provided by the node is called concrete service. Correspondingly, a service set consisting of the same or similar concrete service is represented as abstract service (AS). In the work flow, the AS representing a certain function takes concrete services with different levels of QoS as candidates 8 to satisfy non-functions of IoT requests.
However, unlike traditional platforms that deploy atomic services on servers with powerful capabilities, resources of nodes in WSN such as energy, computing, and bandwidth are quite limited. At the same time, WSN has some special properties such as high mobility. All of those make supporting stable services by traditional methods impossible. 9 Hence, how to intelligently and efficiently meet the functions and non-functions of complex and variable requests through service composition becomes a hot topic of current researches.
To satisfy the functions of IoT requests, we need to obtain the services that can be provided in the WSN. However, in WSN, there is a lack of powerful central management devices, and the high mobility of nodes leads to unstable functions. These factors make it difficult to obtain and maintain global services information. Currently some methods assume that all services information is known 10 or set devices in hot area to record; 11 however, they are not adaptive enough. Satisfying the non-functions of IoT requests is a current main research direction. Most of the work focus on finding best QoS service composition such as delay, 12 cost, 13 and reliability. 14
Wireless sensors are generally battery powered, have limited power, and work at one-time; therefore, energy is the most important factor of WSN. The work flow of service layer executed by mapping to the network layer. 15 Since similar service nodes are relatively dispersed, a large amount of energy consumption will be generated in the data-transmission process. 16 However, few studies optimized the energy consumption of the network layer in service composition.
In this article, we propose a strategy named multi-requests satisfied based on energy optimization for the service composition in WSN to save energy, maintain load balance, and extend WSN lifetime with the function and non-function attributes of the user requests satisfied in the process of mapping work flow from the service layer to the network layer. Our main contributions are summarized as follows
Node mobility prediction: according to the relative motion relationship of nodes, the mobility law of nodes is analyzed. Based on this, we predict the link connectivity probability. The node with the optimal connectivity and residual energy is identified as the cluster head and the service information of local nodes is managed in the unit of cluster. All cluster heads aggregate information to the sink node to dynamically cover global services.
Work flow reduction: work flow is described as a directed acyclic graph (DAG) composed of the matching of the AS input and output. Service subgraph pruning (SSP) algorithm is proposed to delete the redundant nodes and links. In the service layer, energy consumption is reduced in advance.
Mapping from service layer to network layer: mapping the service work flow to a specific network architecture includes nodes and links mapping. In the nodes mapping process, qualified candidate services are filtered according to the QoS and energy. In the links mapping process, the optimal anypath network subgraph (OANS) algorithm is proposed to obtain the energy optimal subgraph in network layer.
Related work
Obtaining the service information provided in the network is a simple task in the traditional platform. However, in WSN, services are provided by sensor nodes and the high mobility makes services management quite hard. Recently, hierarchical routing protocols17,18 used clusters to manage nodes distributedly by electing cluster heads locally, and then, cluster heads collect sensor data from nodes in the cluster and exchange data with other heads to gather global data. Mobility is an important factor in the process of cluster head election. In order to reduce the frequent validation/failure of routes for the mobility of nodes, the MOBIC algorithm is proposed by Basu et al. 19 to select nodes with the most stable relative motion as cluster heads. Leng et al. 20 proposed a uniform linear motion model, adopting node connectivity as the cluster head–selection criteria. Sakhaee and Jamalipour 21 proposed a pseudo-linear motion model to analyze the Doppler effect during motion and selecting the cluster heads through the stability of the route. The recent researches are generally based on special node motion law. Therefore, inspired by Qin et al., 22 this article proposes a probability analysis method which can support the random motion of nodes, measure the stability of the route, predict the connectivity of the nodes, and then select the cluster heads. As the existing results are quite mature, this article uses few previous studies18,23 as the fundamental methods to manage the sensor nodes in WSN and uses Wu et al.’s method 24 as the basic method to manage the sensor data.
The general process of the service composition is selecting the AS related to the requests through the matching of semantic similarity 15 and then get the work flow according to the matching between the input and output. 25 However, there are often many redundancies in the work flow, for example, multiple subflows that can achieve the same function. In recent years, work flow has been described as a service dependency graph,25,26 and it has received much attention from the perspective of graph theory. The Sim–Dijkstra 25 algorithm proposed for traditional platforms selects and retains the subgraph that can provide the optimal QoS, but it is difficult to replace QoS directly with energy in WSN. Zhou et al. 26 assumes that any service is executed sequentially. Based on this, a method for finding the optimal service chain is proposed. But in order to improve efficiency, parallel links are necessary during service-execution process, which means that oversimplified service graph as service chain is not very reasonable. Therefore, this article proposes a work flow reduction algorithm based on Dijkstra algorithm for service-execution process to find optimal service subgraph. Energy optimization is implemented first in the service layer.
Service mapping refers to executing work flow in the specific devices of the network layer. Main methods include linear programming27,28 and shortest path search.15,29 Ngoko et al. 27 used energy as a factor of QoS for global modeling optimization, but the energy consumption in WSN is concentrated in the data-transmission process and cannot be uniformly measured as the attribute of QoS. The use of multi-dimensional multi-choice knapsack problem (MMKP) 28 has improved the computational efficiency, but there is still a problem of the computational complexity increasing exponentially as the size of service and network expand. To solve the shortcomings of the linear programming problem, the shortest path search method was introduced. An improved backward search was proposed by Chen et al., 15 and an improved breadth-first search (BFS) was proposed in Yan et al. 29 However, due to the dynamic nature of the WSN, the shortest path is difficult to maintain stably, and each hop requires multi-node coordination, so the shortest path problem should be converted into the optimal subgraph problem. Inspired by Zhong et al. 30 and Laufer et al., 31 this article utilizes the characteristics of anypath routing, which mainly find the minimum of the sum of the weighted paths to coordinate multi-nodes at each hop, successfully solving the problem of searching for optimal subgraphs.
Mathematical model and problem description
In this section, we will introduce the mathematical model about the scene that we have concentrated on, and describe the problems that we have encountered. The frequently used notations in this article are listed in Table 1.
Frequently used notations.
QoS: quality of service.
Service model
A concrete service
where
An
where
Request
where
Service dependency graph is a DAG that is generated based on work flow, can be presented by
The action of choosing all relevant ASs in the service dependency graph according to the request and generating a subgraph can be presented by
Network model
WSN can be presented by
For simplicity, assuming that each node provides only one cs, which means
QoS model
The QoS of a concrete service can be presented as
where
There are two types of QoS attributes
1. Positive attribute: the bigger the value, the better (e.g. availability and security). It can be calculated as
where
2. Negative attribute: the bigger the value, the better (e.g. cost and delay). It can be calculated by
Request preference
Request preference represents the preference for various QoS attributes. Different requests have different preferences, can be presented as follow
in which important attributes have higher weight.
Under the
Energy model
1. Energy model in the service layer
where
where
2. Energy model in the network layer
where
where
where
According to Shannon formula, to meet the communication rate we should have
where
Service mapping
Service mapping, as shown in Figure 1, including the mapping of service nodes and links to network nodes and links, is used to find sensors to implement requests. Service nodes represents the AS corresponding to network nodes which support concrete service. Service links between service nodes represents the data flow between services corresponding to the network data flow through a few relay nodes. The algorithms proposed in this article will be introduced in the following sections to achieve the goal of energy conservation, load balancing, and network lifetime extension under the premise of guaranteeing requests function and non-function attributes during this service mapping process.

Service mapping.
Energy optimization for the service composition in the WSN
Service management based on cluster
This article proposes the connectivity and energy information of nodes as the criteria for cluster head selection. First, according to the position and relative motion between nodes, the probability of connection with adjacent nodes is estimated, and then the connectivity of the nodes is predicted. Then, combined with the remaining energy status of nodes, the nodes with the best performance are elected as the cluster heads to maintain the service information locally.
1. Mobility analysis
As shown in Figure 2, node

Ring center in circle I

Ring center in circle II

Ring center outside circle I

Ring center outside circle II
In the following section, according to different situations, the probability that other nodes enter the node
For nodes within the communication range, as shown in (a) and (b) in the following passage, we can obtain the distance between them directly.
(a)
As shown in Figure 2, according to the Helen formula, the area of
where
According to the cosine theorem
Furthermore
Therefore, the probability is
(b)
As shown in Figure 3, in the same way, we can get
For node
According to the cosine theorem
(c)
As shown in Figure 4
(d)
As shown in Figure 5
2. Criterion for cluster head selection
The connectivity of node
The energy information is expressed as the ratio of the remaining energy to the maximum in the network
The cluster head–selection criterion is set as the product of connectivity and energy information
Each node broadcasts its own criterion locally, and elects the node with the largest value as the cluster head. The cluster head is responsible for collecting the service information of the nodes in the cluster and converging in the sink node to obtain and maintain the global service dependency graph
Service mapping pre-process
1. SSP
Service subgraph

Service subgraph.
The SSP algorithm is an improved BFS. It uses a backward search method to simplify the structure while satisfying the integrity of the output data. For multiple sources of the same data, backward search is performed separately, all nodes satisfying the out-degree of 1 are recorded, multiple result lists are stored by the priority queue, the minimum list is retained, and the nodes and links in the other lists are deleted. After the traversal is completed, generating the simplified service subgraph
2. Service node pre-mapping
According to the request, simplifying the candidates of ASs to get sensor nodes which can satisfy the restriction of QoS and energy. We call this process as service node pre-mapping, and the candidates we get as service node pre-mapping set (SNPS)
where
Service mapping process
Due to the limited bandwidth and instability of the wireless link in the network layer, the mapping of service links is difficult to find an optimal transmission path meeting request. Therefore, it is necessary to utilize multiple nodes at each hop, which means to find the optimal transmission subgraph; however, the difficulty of searching greatly increases. This article, inspired by anypath routing theory,30,31 proposes an OANS algorithm and solves the problem.
We select multiple nodes per hop and named the corresponding link set as hyperlink which is presented by
Based on anypath routing theory,
where
The node
In algorithm 2, the priority queue is used to store the D of nodes that have not found the optimal subgraph in order from small to large and F is used to record the selected forwarding nodes. For adjacent node set
Multi-requests execution process
In this section, we introduce the algorithm named service mapping to network (SMN) to achieve energy optimization for the service composition in WSN with multi-requests satisfied.
Initialization phase
Nodes mobility is analyzed, and the cluster head node is elected. Service information was collected by the cluster head node and aggregated to the sink node. The whole network service information is obtained and updated regularly to provide support for the function attributes of requests.
Request execution phase
Priority is set according to the delay sensitivity of requests, and the delay-sensitive requests priority is relatively high. The key-value pair is used to store the mapping relationship between service layer node and network layer node. Executing SSP to prune the service dependency subgraph. All nodes are traversed in reverse from
Simulation
In this section, we use MATLAB to evaluate the algorithms proposed in this article. We generated nodes randomly and set
SSP
In the service layer, the SSP algorithm is used at first to streamline service structure. The ratios of the remaining nodes and links are, respectively, used as criteria for the performance of the SSP.
All nodes randomly generate inputs and outputs that match each other to form a connected DAG. The simulation results are shown in Figure 7. The SSP algorithm proposed in this article can effectively achieve the goal of streamlined service subgraph. When it is 10 AS, reduced links by 38% and reduced nodes by 29%. In the mean time, as the network nodes increase, the redundancy ratio that can be deleted increases. Compared with deleting nodes, the SSP can delete redundant links more effectively and then reduce unnecessary energy consumption in the network layer transmission process in advance.

The ratios of remaining nodes and links.
OANS
In the network layer, the OANS algorithm is implemented for network graph between the
In order to highlight the experimental results, it is assumed that source node and target node are respectively at the two ends of the network. By increasing the number of networks nodes, the complexity of the network is increased, and the performance of two algorithms is compared. The simulation results are shown in Figure 8. Under the energy and bandwidth constraints, the OANS algorithm has a lower energy-consumption rate. With the increase of network complexity, OANS and shortest path algorithms both show an upward trend, but the growth rate of OANS is slower; therefore, the numerical gap increases, which indicates OANS has better adaptability.

Energy-consumption rate with different number of network nodes.
The number of nodes is controlled at 80, and the energy-consumption performance is measured by changing the proportion of dead nodes. The simulation results are shown in Figure 9. Dead nodes refer to nodes that do not meet energy or bandwidth constrains. As the percent of dead nodes increase, the energy-consumption rate of the two algorithms increase gradually due to the decrease of available nodes. The OANS algorithm is gradually close but still lower than the shortest path algorithm, which means the OANS has better robustness and the shortest path is the lower boundary of the OANS.

Energy-consumption rate with different percent of dead nodes.
SMN
In this section, we execute the SMN to map service graph to the network layer and still compare with the shortest path algorithm to evaluate the whole network performance.
The number of network nodes is controlled at 80. The standard deviation of the energy-consumption rate of the whole network is used as a criteria of the load balancing. The simulation results are shown in Figure 10. As requests increase, the standard deviation of two algorithms decrease gradually. SMN proposed in this article has a faster rate of decline and is much lower than shortest path algorithm, which means that it has better performance in load balancing. SMN can utilize multiple relay nodes per hop so that it can disperse load pressure and avoid partial over-consumption effectively.

Standard deviation of energy consumption with different requests.
Network lifetime is used to evaluate both energy conservation and load balancing in the whole process of mapping in the same time, and it is the most important criteria for WSN. In this section, we set network lifetime as the duration from the moment that all nodes are 100% energy to the moment that no more requests can be satisfied due to the energy exhausted. Because we disperse the load, the pressure on the core nodes is mitigated and the SMN can support more requests than the shortest path algorithm with high probability. Because of the limitation of network resource, the lifetime keeps steady finally. As shown in Figure 11, as the requests increase, the lifetime of SMN is larger than shortest path algorithm, and the shortest path algorithm becomes stable more quickly. The results reflect that the SMN has longer lifetime and can support more requests than the shortest path algorithm; therefore, the SMN can optimize the energy consumption and achieve load balancing simultaneously.

Network lifetime with different requests.
Conclusion
In this article, we propose a service-execution strategy for energy optimization in WSN. In the network layer, the motion model of the sensor is designed, the probability of connectivity between nodes is analyzed, and the cluster head is elected, based on which service information is collected and managed to satisfy function attributes. In the service layer, we propose SSP to delete the redundancy of the service graph and pre-select candidate nodes to satisfy non-function attributes. In the process of mapping from the service layer to the network layer, OANS and SMN are proposed. The simulation results show that our strategy can save energy and balance load on the basis of guaranteeing the function and non-function attributes and has better performance than traditional ones.
Footnotes
Handling Editor: Michel Kadoch
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.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
