Introduction

The Internet of Things (IoT) technology connects physical objects, computers, and humans [1, 2]. IoT has the potential to revolutionize how people interact with their environment, allowing for more efficient use of resources and improved automation. It can also create new business opportunities and provide consumers more convenience [3]. A unique IP address is assigned to every item under Internet Protocol (IP) for information exchange and communication, enabling intelligent positioning, tracking, monitoring, and management of items with RFID, infrared sensors, global positioning systems, laser scanners, and other information-sensing equipment [4]. This technology allows businesses to monitor and optimize their supply chain processes, improve customer service, and reduce operational costs. It also gives consumers real-time information about products, such as availability and pricing [5]. The system architecture may, for example, be determined by the context in which operations and processes are carried out in real-time. For example, an electrical switch box in a smart home could be controlled remotely by a smartphone [6].

IoT systems are characterized by their capacity for selecting and combining services under end users’ requirements and preferences. This means that the systems can be customized to the user’s needs, allowing them to select the most important services and combine them in a most efficient way [7]. Service selection forms the basis of service composition, which involves determining appropriate services among independent candidates to meet the end user’s needs. These candidate services may be functionally equivalent; however, their non-functional characteristics may differ. The non-functional characteristics are quality of service (QoS) parameters with varying values [8]. It is, therefore, imperative to consider QoS factors that align with the end user’s needs. Smart devices are becoming increasingly prevalent, generating and publishing many Internet-based services. Public transportation facilitates IoT service discovery by serving as a dynamic and interconnected network that facilitates the seamless integration and accessibility of diverse services, contributing to enhanced mobility and efficiency in smart city ecosystems [9].

Nevertheless, context-aware environments do not require all services. In most cases, accessing a particular set of services at a specific time is necessary to meet certain needs. A service discovery function allows a network to search effectively for devices providing the required services. A critical role for service discovery in IoT is highlighted in [7]. This functionality, however, poses several challenges because an excessive number of devices would result in large search areas. In addition, network traffic may become too large to handle efficiently, resulting in scalability concerns. The service discovery problem is also confronted with other issues, such as environmental context, geographical constraints, and dynamic availability. A distributed indexing and searching architecture is needed to overcome these challenges to support efficient service discovery. This architecture should be able to manage large-scale networks, scale to meet changing demand, and consider environmental context [10].

Integrating meta-heuristic algorithms, machine learning, deep learning, and neural networks is paramount in advancing the domain of IoT service selection and discovery [11]. As the IoT ecosystem expands, interconnected devices’ sheer complexity and scale necessitate intelligent and adaptive methodologies for efficient service discovery. Meta-heuristic algorithms, such as the Whale Optimization Algorithm (WOA), Simulated Annealing (SA), and Imperialists Competitive Algorithm (ICA), offer robust optimization techniques that navigate the vast solution space to enhance the accuracy and speed of service selection [12]. Machine learning techniques, coupled with deep learning and neural networks, bring a transformative dimension by enabling systems to autonomously learn and adapt to evolving patterns within the IoT network [13, 14]. These technologies empower service discovery mechanisms to comprehend intricate relationships, dependencies, and dynamic changes in real-time, thereby optimizing decision-making processes [15]. Through the utilization of these advanced algorithms, IoT environments can achieve enhanced QoS, reduced latency, and improved resource utilization [16]. The synergy of meta-heuristic algorithms and machine learning paradigms streamlines the service discovery process and fosters adaptability and intelligence in IoT systems, ensuring they remain responsive to the dynamic and diverse demands of modern interconnected environments [17, 18]. As we continue to explore the frontiers of IoT innovation, incorporating these technologies stands as a cornerstone, shaping the evolution of intelligent and efficient service selection in the IoT landscape [19, 20].

The selection of services becomes even more challenging when combined with specific requirements for quality of service. When dealing with this situation, it is important to select the most appropriate service that satisfies the end user’s functional and quality requirements, not simply identify, select, and combine services with specific capabilities [21]. Optimizing algorithms are required to select services consistent with specific criteria, including energy consumption, response time, reliability, availability, cost, throughput, and accuracy. In recent years, research has focused on developing algorithms for optimizing the selection of IoT services based on a defined set of quality requirements. The most well-known algorithms are cluster head selection, shortest path algorithms, mapping flow-based algorithms, co-locating services, physical services models, genetic algorithms (GAs), and particle swarm optimization (PSO) algorithms.

Related work

NWE, et al. [22] proposed an adaptive QoS-based service selection technique that allows users to provide subjective preferences in a friendly and simple manner. It identifies services under subjective information given by service consumers and objective information provided by service providers. Using artificial neural network backpropagation, it finds objective factors and evaluates the creditability of user subjective factors using similarity aggregation, which has already been evaluated using ontological reasoning through the proposed Quality of Service ontology. According to the comparative study and experimental results, the proposed algorithm outperforms other methods of selecting services.

Jia, et al. [23] presented a service discovery method that employs a multi-stage semantic service matching strategy. It uses a layer filtering approach, considering various constraints associated with IoT services, including quality of experience, precondition/effect, input/output, and service category. It obtains accurate matching results more efficiently. In the first place, they describe IoT services and requests uniformly using OWL-Siot, which is an IoT service description language. Then, a 4-layer structure model for service discovery is proposed, comprising a first layer for interactive interfaces, a second layer for parsing annotations, a third layer for service matching, and a fourth layer for data semantics. A hybrid service matching degree measurement is also proposed by synthesizing the concept logic and semantic similarity on a layer-by-layer basis. In experimental studies, the method is effective in improving service discovery performance.

Osamy et al. [24] presented a novel adaptive service discovery architecture to enable service discovery and service selection in IoT-based sensor networks with a high degree of dynamicity. It offers a robust framework to provide user-oriented and environment-aware service discovery. The proposed architecture is based on a multi-agent system and can provide a dynamic, distributed, and self-organized service discovery architecture. It also offers a reliable and efficient search mechanism for selecting services most appropriate for the user’s requirements and the environment. An extensive simulation is conducted to evaluate the proposed architecture. The experimental results demonstrate the superiority of the proposed architecture over existing baselines regarding query success rate, number of transmission messages, and transmission cost.

Pattar et al. [25] proposed a progressive search algorithm for mapping user requirements to IoT resources and smart services, thereby providing personalized search results. Users’ requirements have been divided into essential and optional requirements, which in turn have been correlated with the intrinsic and extrinsic properties of smart services. To refine the search results, two search strategies are suggested, namely, primitive search and elaborate search. In order to establish the practicability of the proposed search algorithm, empirical studies were conducted on a Smart Airport ecosystem and compared with the existing approaches in the literature.

Bensalah Azizou et al. [26] proposed a new distributed service discovery technique based on the Ant Colony Optimization (ACO) algorithm. Their technique uses the ACO algorithm to find the shortest path from the service consumer to the service provider. The algorithm uses the probabilistic behavior of ants in the natural environment to identify the most efficient paths to the destination. Simulation results indicate that the proposed approach performs well with fewer hops used to discover services and can achieve a high discovery success rate. The proposed approach also offers load balancing and can easily be adapted to dynamic environments.

Jia et al. [27] developed a privacy-aware service discovery technique using the artificial fish swarm algorithm. This method strives to select services that offer an optimal Quality of Experience (QoE), incorporating privacy requirements, to minimize privacy concerns and select services that meet all user requirements. As a first step, a model of quality of experience based on privacy requirements is created, and restrictions along with quantitative measures are presented. The second step is constructing an algorithm that utilizes the above model to determine which services should be selected. As a final step, the suggested strategy is validated by simulation. According to the results, this algorithm performed better in terms of accuracy and recall than the GA-based algorithm, demonstrating that it can effectively and feasibly solve privacy-sensitive service selection problems with IoT effectively and feasibly.

Zhu et al. [28] proposed a novel access selection approach that facilitates users to request IoT services in heterogeneous 5G networks while achieving optimal quality of experience. Specifically, a fuzzy logic-based network pre-assessment process filters available networks by the user device. In addition, a framework for evaluating preferences is developed that employs the objective entropy weight method and a subjective analytical hierarchy process to determine preference levels. Then, they developed an algorithm based on relative entropy for selecting multi-service networks quickly from the filtered available networks to enhance the quality of service for users under the constraints of limited network capacity. According to the evaluation results, the proposed mechanism is effective at maintaining stable service connections and significantly improving the quality of service for users.

Methods

This section describes a process for discovering and selecting cloud-edge services based on factors affecting QoS for an IoT platform. Additionally, a general description, a model for discovering services, and a methodology for selecting services based on a hybrid WOA-GA algorithm are provided. The process consists of four steps: (1) identifying the factors that affect QoS, (2) discovering cloud-edge services in the IoT platform, (3) modeling the discovery process, and (4) selecting services based on a hybrid WOA-GA algorithm.

Problem statement

In order to optimize the QoS parameters in IoT environments, we need to choose the appropriate automated services. Research on service discovery has primarily focused on two approaches: syntactic and semantic. In each method, the search is conducted in a different manner. Syntactic service discovery is based on identifying the features of a service and matching them to a predefined set of requirements. Semantic service discovery uses semantic annotations to match services to user needs. Both methods are used to optimize QoS in IoT environments. Semantic approaches are limited by their reliance on syntactic theories. In addition, many of these approaches have difficulties or cannot be applied in the environment. Therefore, a hybrid syntactic and semantic service discovery process is necessary to achieve optimal QoS in IoT environments. This hybrid approach can leverage the strengths of both syntactic and semantic service discovery to provide a more efficient and effective way of discovering and connecting services. We propose a system for retrieving syntactic information about services that use data collected from IoT devices to identify the best services.

In our method, clients or IoT nodes send their desired service specifications. Service providers, in this instance an IoT node, provide their QoS measurements and information about the services using Web Service Definition Language (WSDL), which is used by the evaluation system to determine whether the candidate IoT node is appropriate for the Service Requester (SR) requirements. The evaluator system will then compare the SR and the measured QoS and, based on the user-defined parameters, will determine whether the candidate IoT node is eligible for deployment. If the candidate node is chosen, the evaluator will inform the Client and the IoT node of acceptance. Figure 1 illustrates how a service search is conducted within an IoT network.

Fig. 1
figure 1

A conceptual and operational overview of service discovery architecture

Procedure for collecting service data

The information that leads to the discovery of the service is derived through a single source but in variable forms and with additional details. This source can be the customer’s request, the market research, or the customer feedback on the existing services. As more details become available, the scope of the service increases, and more elements are added. The end result is a comprehensive service that meets the customer’s needs. Service discovery will primarily rely on QoS measurements sent from IoT devices; however, we will also use the information provided by IoT device users to select more appropriate matches to fulfill SR requirements. In addition, information about the Service Provider (SP) can be used in the discovery of services. In order to verify the QoS factors, the service matching broker exchanges information with the node data administrator. The service matching broker then queries the service provider’s database and retrieves the required information. The node data administrator then compares the retrieved data with the QoS requirements and selects the best-matching service. Finally, the service is provided to the user.

The IoT devices serve as service node data and send QoS measures to node data administrators. Node Data Administrators (NDAs) receive information from IoT devices directly and are prepared to act as service providers in the network. NDAs are able to monitor the performance of the network and make necessary changes for improved services. The data collected by the NDAs can also be used to improve the forecasting of future network performance. This helps to ensure a high quality of service for users of IoT devices. Data concerning QoS will be identified and forwarded inside the NDA to the Service Node Evaluator (SNE). In its QoS analyzer, SNE analyzes QoS measures. In the process of analyzing QoS, measurements generated by IoT devices will be examined and checked. This is to ensure that they satisfy service expectations within the network. The network administrator sets these requirements. Upon completion of the analysis of QoS measures, the information will be returned to NDA and placed in a database in order to preserve information regarding QoS.

The WSDL in our model collects information generated by IoT devices and user interactions periodically. The information we obtain in this way will be helpful in the initial discovery process by minimizing the number of candidates for service discovery and providing greater detail about the service provider. This information will be sent from IoT devices to service storage in the form of WSDL. This information will be stored in the service storage so the service matching broker can use it in response to an SR request. We will use this information to minimize potential candidates for SR further. Both NDA and QoS measures will be used to collect this data. In the same manner as QoS indicators, the information collected will be verified by an IoT information evaluator before it is available for inclusion in service storage and WSDL-based IoT information.

Procedure for discovering services

In order to find optimal automated services, we consider three QoS factors. As indicated in Eq. 1, three factors, including cost, execution time, and energy consumption, come together in order to determine the overall QoS value used for measuring the fitness function in optimal service discovery. The aim of this approach is to find the optimal services for a given user request with an acceptable trade-off between the three QoS factors. This enables users to obtain services with the best performance at an affordable cost. The objective of the fitness function is to minimize the overall QoS value, resulting in optimal automated services. The optimal services are then used to create a solution that meets the QoS requirements of the system. The Whale Optimization Algorithm (WOA) provides the best solution for discovering cloud-edge services.

The formal solution for achieving and determining efficient service discovery and IoT smart objects is formulated in the following manner. The IoT network consists of a variety of smart devices and sensors. SLA agreements specify that these smart applications rely on an array of services known as S at the edge layer and on a variable known as N at the sensor layer. Cloud-edge services typically outnumber sensors. The sensors also incorporate a limited power-saving feature, which is indicated by Ei. ET shows the total energy consumed by a set of sensors. The proposed method defines the service capabilities of intelligent sensors and applications as follows:

$${E}^{T}=\sum {EN}_{1},{EN}_{2},\dots ,{EN}_{M}$$
(1)

In Eq. 1, S and A sets define the respective positions of guide sensors and items, respectively. Thus, a guide object can determine its position using the Global Locator; however, the significant problem lies in the lack of information regarding the location and position of the sensors, so it is necessary to determine their locations. The primary issue with this study is that it is assumed that three locator objects are defined as the positions of (a), but an object’s position, such as |x, y|, remains unspecified. Thus, the following steps must be followed to identify this object’s location.

  • Calculate and estimate the distance between an unknown object and objects with known locations.

  • The object’s location is first estimated by using the location of three reference points.

  • Several locations in the vicinity of the present position are derived from three sources, and those positions represent the WOA population. From there, multiple solutions are produced, and then a more precise location is attempted.

The WOA can be used to estimate distances between sensor objects based on three reference objects. The three-reference strategy allows us to obtain the object’s position. Nonetheless, the three-reference method’s locating error significantly depends on the accuracy with which the distance between the sensor object and the reference object is calculated. The WOA algorithm uses swarm intelligence to solve continuous optimization problems. WOA exhibits superior performance than recent meta-heuristic algorithms. Compared to other swarm intelligence algorithms, it is more straightforward and robust. The desired result can be achieved in practice by adjusting a single parameter (time interval). It involves humpback whales searching for food in a multidimensional environment. Locations of humpback whales are considered decision variables, while distances between them and food are considered objective costs. Whales’ time-dependent location is determined by three operational processes: searching for prey, using bubble nets to attack, and shrinking encircling prey. Figure 2 illustrates the primary presentation of the WOA.

Fig. 2
figure 2

Position update in a spiral

The behavior of humpback whales in bubble nets can be described mathematically as follows.

$$\overrightarrow{X}\left(t+1\right)=\overrightarrow{{D}^{\mathrm{^{\prime}}}}.{e}^{bl}.{\text{cos}}\left(2\pi l\right)+\overrightarrow{{X}^{*}}(t)$$
(2)
$$\overrightarrow{X}\left(t+1\right)=\left\{\begin{array}{c}\overrightarrow{{X}^{*}}\left(t\right)-\overrightarrow{A}.\overrightarrow{D} if p<0.5\\ \overrightarrow{{D}^{\mathrm{^{\prime}}}}.{e}^{bl}.{\text{cos}}\left(2\pi l\right)+\overrightarrow{{X}^{*}}\left(t\right) if p\ge 0.5\end{array}\right.$$
(3)

In Eq. 3, p describes the logarithmic spiral’s shape, and k refers to a uniformly distributed number. As a global optimizer, if A > 1 or A <  − 1, a randomly selected search agent replaces the best search agent as follows:

$$\overrightarrow{D}=\left|\overrightarrow{C}.\overrightarrow{{X}_{rand}}-\overrightarrow{X}\right|$$
(4)
$$\overrightarrow{X}\left(t+1\right)=\overrightarrow{{X}_{rand}}-\overrightarrow{X}.\overrightarrow{D}$$
(5)

where Xrand is randomly selected from whales in the current iteration.

Service selection process

In order to select automated services, GA employs a Weighted Acyclic Graph (WAG) method to select discovered automated services. The discovered services are evaluated based on QoS factors. GA draws inspiration from Darwin’s biological evolution theory. In fact, GA simulates natural selection. In nature, organisms with higher fitness exhibit a higher survival rate. This facilitates the transmission of their genes to future generations. Genes that allow species to better adapt to their environment (avoid enemies and find food) become dominant over time. GA models optimization problems by employing a set of variables derived from natural chromosomes and genes. In an optimization problem, each solution represents a chromosome, and each gene denotes a variable of the problem. As an example, GA utilizes chromosomes containing ten genes when dealing with a problem involving ten variables. GA enhances chromosomes in each generation through three main operations: selection, crossover, and mutation. In GA, a set of random chromosomes is used to begin the optimization process. Binary GA is based on the following equation:

$${X}_{i}=\left\{\begin{array}{c}1 {r}_{i}<0.5\\ 0 otherwise\end{array}\right.$$
(6)

where ri represents a random number between 0 and 1, independently calculated for each gene, and Xi denotes the ith gene. In continuous GA, genes are randomly initialized using the following equation:

$${X}_{i}=\left({ub}_{i}-{lb}_{i}\right)\times {r}_{i}+{lb}_{i}$$
(7)

where lbi and ubi correspond to the lower and upper bounds for the ith gene (variable), respectively. The primary goal is to obtain uniformly distributed random solutions over the entire set of variables for use in the following operations. Parents’ characteristics should be reflected in future generations of the population while minimizing the possibility of selecting individuals with poor fitness values. It is first necessary to calculate the probability of selecting each individual, which can be calculated as follows:

$$P\left(i\right)=\frac{f(i)}{{\sum }_{i=1}^{N}f(i)}$$
(8)

where f(i) represents the fitness value of an individual and P(i) indicates the probability of the individual being selected. It is more likely that an individual with a higher fitness value will be selected than one with a lower fitness value. The crossover operator plays an important role in GA. It is required to perform the crossover operator between two individuals in order to improve global search capability. As a measure of crossover probability, we use the parameter P-crossover, expressed as follows:

$$P-crossover={k}_{1}\frac{{f}_{max}-{f}_{a}}{{f}_{max}-{f}_{b}} if {f}_{a}\ge {f}_{b}$$
(9)
$$P-crossvoer={k}_{2} if{f}_{a}\le {f}_{b}$$
(10)

where k1 and k2 share the same value between 0 and 1, fb represents the average fitness value of the overall population, fa represents the largest fitness value among the two individuals required to perform the crossover operator, and fmax reflects the maximum fitness value observed in a population. The crossover operator is shown in Fig. 3.

Fig. 3
figure 3

Chromosome crossover operator

The mutation operator enhances GA’s local search capabilities and maintains the population’s diversity. Equations (5) and (6) provide formulae for calculating the mutation probability. The crossover operator is illustrated in Fig. 4.

Fig. 4
figure 4

Chromosome gene variation

$$P-mutate={k}_{3}\frac{{f}_{max}-{f}_{c}}{{f}_{max}-{f}_{b}} if {f}_{c}\ge {f}_{b}$$
(11)
$$P-mutate={k}_{c} if{f}_{c}<{f}_{b}$$
(12)

As depicted in Fig. 4, two chromosome genes can be affected separately at locations (i + 1) and (N-2). At location (i + 1), the gene value is between R2 and R4. Gene values range from R5 to R2 at locations (N-2). Mutations in genes may lead to positive outcomes. Sometimes, it may result in negative outcomes. Nevertheless, maintaining genetic diversity within a population requires the mutation of genes.

The proposed method begins by randomly selecting an initial server from the alternative servers, designating it as the first in the selected population. If the chosen server hosts the requested service, it is added to the candidate server set. Subsequently, another server is randomly chosen from the nodes linked to the initial server, becoming the second in the population and the new current server. The associated servers form a set, and a random server from this set is nominated as the updated current server. This process continues iteratively, looping back if the current server lacks neighbors and has not reached the maximum server limit until the total servers meet the specified minimum and maximum criteria. The fittest server from the candidate set is then selected, ensuring servers are within the defined range. The procedure repeats while preserving used servers, contributing to a systematic and adaptable service discovery approach in the IoT network, as depicted in Algorithm 1.

figure a

Algorithm 1. Pseudocode of the proposed method

Results and discussion

In this section, the performance of the proposed service discovery technique is compared with that of previous techniques. The experiment outcomes are presented graphically in diagrams and graphs. Test results and comparisons will be presented on time, cost, energy, and convergence diagrams. The suggested technique has been simulated and assessed using the MATLAB simulator. The results of the suggested technique are evaluated and compared with those obtained by PSO, WOA, and GA algorithms.

Figures 5, 6, and 7 illustrate the costs associated with 100 nodes with different numbers of tasks. It is clear that the cost increases in proportion to the number of tasks. However, the percentage increment obtained from the first and third tests, i.e., with 100 and 500 tasks, was greater than that obtained from the other algorithms. In the second experiment involving 300 tasks, the genetic algorithm proved more effective than the proposed method. Figures 8, 9, and 10 compare methods in terms of data access between 100 nodes with a variety of tasks. It is evident from the simulation results that the time has increased with increasing the number of tasks, but the rate of this increment is higher in the first two experiments, namely with 100 tasks and 300 tasks, than in the other algorithms. Figures 11, 12, and 13 compare the methods in terms of energy consumption. Increasing the number of tasks has resulted in an increase in energy utilization. However, in the first two experiments, with 100 and 300 tasks, the rate of this increment was higher than the other algorithms. Nevertheless, the genetic algorithm is superior to the method proposed in this paper in the third experiment with 500 tasks.

Fig. 5
figure 5

Cost comparison for 100 tasks

Fig. 6
figure 6

Cost comparison for 300 tasks

Fig. 7
figure 7

Cost comparison for 500 tasks

Fig. 8
figure 8

Time comparison for 100 tasks

Fig. 9
figure 9

Time comparison for 300 tasks

Fig. 10
figure 10

Time comparison for 500 tasks

Fig. 11
figure 11

Energy consumption comparison for 100 tasks

Fig. 12
figure 12

Energy consumption comparison for 300 tasks

Fig. 13
figure 13

Energy consumption comparison for 500 tasks

Conclusions

The dynamic nature of IoT demands a responsive sensor network infrastructure to handle emerging technologies. The problem of service discovery and selection in dynamic networks is presented as an NP-hard problem in this context. A novel service discovery and selection technique utilizing whale optimization and genetic algorithms is presented in this paper. With our approach, we offer a robust solution to the NP-hard problem of optimal service discovery, reducing the time and cost implications for cloud providers striving to meet QoS requirements. Simulation results confirmed the effectiveness of our algorithm, demonstrating superior performance in comparison to existing baseline approaches. In particular, our method minimizes data access time, optimizes energy usage, and improves cost-effectiveness. Therefore, this research contributes significantly to the field by providing an advanced, efficient, and scalable solution to the challenges of dynamic service discovery in IoT environments. Our work lays the foundation for future developments in enhancing QoS-aware service discovery techniques, ultimately contributing to the evolution of responsive and adaptive IoT infrastructures. While the proposed method demonstrates notable advantages, it is crucial to acknowledge its limitations. The algorithm’s performance may be influenced by specific network configurations and environmental factors. Future work should explore the adaptability of the approach across diverse IoT scenarios and investigate potential scalability challenges. Additionally, incorporating real-world deployment insights and addressing security considerations will further enhance the robustness of the proposed method. As the IoT landscape continues to evolve, ongoing research endeavors can focus on refining and extending the applicability of the algorithm, ensuring its efficacy in increasingly complex and diverse IoT environments.