Introduction

In the IoT environment, large-scale data detected in the environments surrounding the physical world can be distributed, processed, and used by various services and applications to enable autonomous and intelligent decision-making [1, 2]. The number of objects added to IoT is approaching 200 billion, and the number of sensors is already over 50 billion [3]. As a result, the data generated by IoT far outweigh the capabilities of existing IT architectures and infrastructures, and its real-time requirement will also much emphasize the available computing capacity.

The cloud computing model is an efficient alternative for managing large volumes of data, allowing greater use without degrading performance. It is achieved through the implementation of homogeneous and theoretically unlimited computing, storage, and network components. However, these advantages become an issue for latency-sensitive applications, which require nearby network nodes to meet their delay requirements [4].

To meet this demand, CISCO proposed the creation of a platform that it called Fog Computing, or, briefly, Fog, simply because fog (Fog) is a cloud close to the ground (network edge) [4]. In this computational architecture, each smart object is connected to one of the Fog devices. The devices can be interconnected, and each one is linked to the cloud [5]. The architecture allows sensors from the IoT environment (Edge) to produce useful data about the environment around them, aiming to make this environment more intelligent. This task is made possible through access to the necessary information related to the environments, the collection, and analysis of past and present data. These data allow optimal decisions about people and their environments, preferably in real time [6].

To allow data sharing, using these concepts, IoT middleware solutions have been adopted [7]. IoT middleware is used to collect data from sensors to be used by different applications, acting as an interface between the user/application and the IoT network [8].

An IoT middleware usually offers resources for acquisition, the discovery of new sensors, indexing, ranking, and query [9]. The indexing process involves storing and indexing the data collected from the resources, considering that the resources include sensors, devices, and services, to allow a fast and efficient search. The IoT resources ranking is performed by prioritizing criteria as quality of data, device availability, energy efficiency, and network latency. This task can be performed based on the generated observation (content) and the measurement data (context). Examples of use are applications such as industry and health that require reliability associated with the processing and provision of data with low latency [10]. Only these two resources, indexing, and ranking will be considered in this research work.

The complexity and heterogeneity of objects connected to the IoT environment are also present in the data generated by them. Thus, a set of challenges arises from the vast, changeable, and diversified mass of data (data-intensive), on how to handle and use these data [11]. According to the National Science Foundation (NSF) [12], some of the significant challenges of this environment include supporting real-time applications, from enabling artificial intelligence to controlling feedback in cyber-physical systems, by reducing latency.

Therefore, IoT systems with intensive use of data are challenged by the dynamics and uncertainty of the circumstances in which the system is located and by the recognition and search quickly in an ocean of noisy data coming from heterogeneous devices, meeting requirements that evolve rapidly [11].

To overcome these challenges, this research paper presents a sensor ranking approach. The method proposes to reduce latency and increase the reliability in the use of the information generated by the sensor. The construction of the ordered list of sensors is carried out based on the quality of the collected data. The work also intends to help in identifying extreme events or failures in the devices, serving as a support tool in the control of the monitored environments. For this, the method uses the content (data generated by the sensor) and context information related to the state of the sensor at the exact moment of capture. To evaluate the data, two evaluation techniques are used. The first one is applied to most of the data and the second one is applied only to uncertain data, which considers the dynamic aspect and uses a time slice of data to define the sensor state. Finally, using context parameters, the method updates the ranking list.

This article describes the evolution of the research work presented in [13]. Unlike the previous work, the second level of the proposal now uses the nearest neighbor algorithm combined with the Interquartile Range (IQR) metric. The IQR metric was also used to generate labels for the data in the training step. Fuzzy logic is now only used in the third and last level of the proposal, to generate the final label related to the current state of each sensor. In addition, the proposal now brings an implementation of the computational architecture with a distributed approach, through the maintenance of ranking lists in distributed hash tables. Different datasets were also used, aiming to work with datasets used in more recent works. Additionally, the new datasets were also studied in works that identify the points of anomaly and failure present in each set, thus providing a way to assess the accuracy when using these data.

The remainder of the paper is organized as follows: the section "Related Works" section presents the related works with this proposal. The section "Background" presents the concepts related to the proposal. In the section "Sensor Ranking", the details of this proposal are discussed. The materials and methods used in this work are presented in the section "Evaluation". In the section "Experimental Results", the results obtained are presented and discussed in the section “Discussion”. The section “Conclusions and Future Works” brings the conclusions and future works.

Related Works

Applications, such as industry, agriculture, and healthcare, require reliability associated with computing in services that require low latency requirements [10]. In this sense, many works have been dedicated to the discovery, indexing, and ranking of sensors to provide a fast and safe way to recover data from IoT devices. In this section, the most relevant works related to the ranking of sensors are presented.

In Table 1, it is possible to see a list of the works focusing on the ranking of sensors. The second column identifies whether the architecture proposed by the work can be implemented with a distributed approach. The third column identifies which tier (Cloud, Fog, or Edge) the data are processed in the proposal. The fourth column presents the computational complexity of the proposal (computational complexity less than O(n2) is considered low). The fifth column, Ranking Calculation, identifies how the values used in the ranking calculation are generated: Before (a user query), After, or Diverse (when part of the values is previously calculated, and another part is calculated after the user query). The sixth column identifies how many steps or techniques the work uses to evaluate the data and generate the ranking of sensors. The seventh shows which works consider using historical sensor data (time) and the eighth column if the work considers fault handling (an anomaly in the environment or failure in capture).

Table 1 Related works

The previous version of this research [13], named Greatest of Actual Time (GoAT), covers all aspects present in related works, except the feature of maintaining the classification list in a distributed way, which is extremely important to meet the latency requirements present in this scenario. Comments below on related work do not include the previous version of this research. This means that statements like "none of the work", for example, disregard GoAT.

According to the bibliographic research carried out, only one of the articles [14] considers aspects related to identifying failures or anomalies. Despite this, the work does not describe how it is done and does not show results, so it was not included in the table of related works. None of the related works considers the fact that sensor failures can be transient or persistent, given the dynamic nature of the IoT environment, so the generated ranking may not reflect the actual state of the sensors. The researched works also do not create the ranking previously (make the ordering available before receiving queries), making it impossible to immediately respond to a request for a list of trusted sensors. The use of the theory of active perception for ranking sensors was not used in any related works. The design of the proposal associated with the theory of perception aims to create a method that adds knowledge to the reasoning at each level of the theory, improving the data analysis process. Regarding this aspect, only three studies use more than one technique to evaluate the data.

Thus, considering the use of two evaluation techniques, one of them considering the dynamic aspect using the evaluation of the data referring to a time slice; regarding the classification of the state of the sensors in the normal, anomalous, and failure categories and, finally, considering the previous generation of the ranking list, thus reducing the latency in queries; and finally considering the ability to manage the ranking list of sensors in a distributed way, make evident the important scientific contribution of this proposal.

The literature review carried out presents the various approaches used in the sensor ranking activity, demonstrating the importance of this activity for the development of the IoT. However, despite the related proposals showing promising results, there are still some challenges and opportunities:

  • Properly treat the data generated by sensors in the IoT environment, differentiate data that represent real measurements of the environment around the sensor from data generated by failures or interference.

  • Improve the sensor selection processes to reduce the amount of data to be analyzed in decision-making, allowing the time between analysis and action to be as short as possible, meeting low latency requirements.

  • Improve the reliability of data obtained from sensors in the IoT environment, to reduce uncertainty in decision-making.

  • Provide a fully distributed solution capable of meeting low latency requirements.

This work aims to contribute to overcoming these challenges.

Background

This section describes the basic concepts related to the techniques and algorithms employed. Concepts related to the Gradient Tree Boosting, used in the first data evaluation, are described. Nearest Neighbors, used to identify anomalous segments in time series, are also presented. To compare these segments, a similarity measure is used to define an anomaly index for each segment. Using the generated anomaly index, the Interquartile Range metric is used to divide the data into normal, anomaly, and failure types. This division uses the anomaly index to evaluate each data segment and thus define which category it belongs to. The Fuzzy Inference System (FIS), used to evaluate the sensor state, is also presented. The Quality of Context (QoC) theory, which one of the parameters is used, and the Distributed Hash Table (DHT), used to manage the distributed sensor rank lists, are also presented.

Gradient Tree Boosting

The first evaluation of the sensor data in this work uses an algorithm belonging to the Gradient Tree Boosting (GDB) class, as shown in Fig. 1. Figure 1 demonstrates the application of the GDB algorithm to the Intel Lab dataset [33], which contains information about data collected from sensors, mounted on a Mica2DotFootnote 1 board, deployed at the Intel Berkeley Research Lab (IntelLab). The algorithms of the GDB class are algorithms that start by creating only one decision tree. After training, the values ​​for which the tree makes incorrect predictions are recorded. Then, a new tree is created to see how much the other tree makes mistakes. Then, the cycle is repeated up to a certain limit, always trying to reduce the error rate [34]. The XGBoost implementation improves the performance of the conventional gradient augmentation tree by introducing two techniques: weighted quantile sketching (a data structure that supports merging and removing operations) and dispersion recognition split location (default direction at each node in the tree). XGBoost has been applied to several machine learning problems and has obtained better results than the other algorithms [35]. This algorithm has linear time complexity.

Fig. 1
figure 1

Classification of a single sensor data [13]

Nearest Neighbors Algorithm

Nearest neighbor techniques are widely applied to detect anomalous segments [36]. The technique uses a measure to generate an index that represents the similarity between each segment in the time series and all other segments. Segments with similar sequences of samples represent closest neighbors. The similarity of a segment to its nearest neighbors is the basis for its anomaly index. In particular, if a segment is anomalous, its similarity to any other segment will be low [37].

Similarity Measure

To measure the similarity between segments, the Euclidean distance metric was used. The motivation for using the Euclidean distance is that a zero distance, in other words, maximum similarity, occurs only when two segments are very similar in all n samples [37]. The Euclidean metric is presented in Eq. 1

$$\begin{array}{*{20}c} {d\left( {u, v} \right) = \sqrt {\mathop \sum \limits_{i = 1}^{n} \left( {u_{i} - v_{i} } \right)^{2} } } \\ \end{array} .$$
(1)

Interquartile Range

The Interquartile Range (IQR) metric is useful to indicate whether the values of a dataset can be considered outliers [38]. Quartiles are the separators that divide a numerical dataset into four equal parts. The first quartile (Q1) is the value of the set that delimits the 25% smaller values (25% of the values are less than Q1 and 75% are greater than Q1). The second quartile (Q2) is the median itself, which separates the 50% smaller from the 50% larger values. The third quartile (Q3) is the value that delimits the 25% higher values (75% of the values are lower than Q3 and 25% are higher than Q3). Thus, the first range of data (first 25% of data) starts at the smallest value and goes to Q1. The second range between 25 and 50% are values greater than Q1 and less than Q2. The third range corresponds to values between 50 and 75%, that is, values greater than Q2 and smaller than Q3. The fourth and last range corresponds to values between 75 and 100% (or the maximum value) of the data [39]. The interquartile range is the difference between Q3 and Q1.

The idea is to create thresholds using the value of the IQR index to facilitate the identification of values that are far from the most frequent values, and in some cases, even extrapolating the valid range of domain values.

Fuzzy Inference System (FIS)

The fuzzy logic is inspired by real-world phenomena in which events can hardly be considered entirely false or completely true [40]. Fuzzy logic offers a method, based on rules and mathematical sets, for the treatment of inaccuracy, thus being able to deal with imprecise or qualitative terms, such as "Low", "Medium", and "High" which cannot be expressed using binary logic.

These characteristics of fuzzy logic will be used to manage the current state of each sensor, with more qualitative information than just the value of the trustworthiness parameter.

Quality of Context (QoC)

One of the main problems in the way of intelligent IoT is to understand the “context” or to understand the environment, situation, or state using data from sensors and then act autonomously. This is called "context-aware computing". However, context information of the same entity, of the same type, and obtained simultaneously may differ in terms of accuracy, probability of correction, reliability, etc. Therefore, it can be said that the information has a quality, and this quality is called "Quality of Context" (QoC) [41]. QoC can help to resolve uncertain and conflicting situations about context information. Therefore, context-aware applications can take advantage of QoC if they are provided with usable QoC metrics that are evaluated considering their requirements regarding the collection, processing, and provision of context information [42]. It is important to highlight the difference between data and contextual information: “data” are raw data, taken directly from its source (sensors), and “context information” is processed data obtained by processing raw data and usually with added metadata [43].

Distributed Hash Table (DHT)

This work considers the use of gateways, in which the data of each sensor will be processed and evaluated. The gateways exchange information in a ranking list management model using the Distributed Hash Table (DHT) technique. The choice of this technique is due to its high degree of scalability and the flexible support for query and update operations. DHT is a system with a decentralized approach that provides fast mechanisms for storage, queries, and updates. DHT is built on overlapping networks in which network objects are spread and identified with unique keys [44].

The Apache Cassandra implementation was chosen to enable exchanging information between the distributed lists [45]. Cassandra achieves horizontal scalability by partitioning all data stored in the system using a hash function called consistent hashing. Consistent hashing is similar to a Chord model [46], which is based on DHT. This model provides a scalable and efficient protocol for dynamic research in P2P systems with frequent node inputs and outputs. It indicates how to locate a resource, how a new node enters the system, and how to deal with failures. DHT is used for both file storage and resource tracking. The nodes are placed in ascending order according to their IDs in a virtual ring. To improve scalability, the Chord node does not need routing information about all other nodes, but only a number of O (log N) nodes, and therefore, the search needs a maximum of O (log N) messages.

Active Perception Theory

The active perception uses models to inform the context-dependent adjustments in sensors, aiming to direct the sensors toward phenomena of greater interest [47].

Perception is not passive but active. Perceptual activity is exploratory, probing, searching. Perceptions do not merely fall on sensors as rain falls on the ground. During the act of looking, the pupils adjust to the level of illumination, the eyes bring the world into sharp focus, converge or diverge, the heads move to improve the vision of something [48]. This adaptability is crucial for survival in an uncertain world. Thus, the problem of active perception can be defined as the use of control strategies applied to the data acquisition process, which, in turn, will depend on the interpretation of the data and the objective of the task [48].

Considering that perception is often dependent on context, other senses, and time, the active perception approach is divided into four levels: sensation, perception, perception over time, and active perception. Sensation is the process by which the captured data enter the system. After sensation, perception interprets these data and gives it meaning. By observing a process for a particular time, it is possible to improve the interpretation of these data. This process is called perception over time, in which data are classified according to time, indicating that it is possible to evaluate perception concerning another perception. Finally, active perception includes reasoning, decisions, and actions based on the information received [49, 50].

Sensor Ranking

This section describes the method proposed in this research paper. Before describing the process, itself, some important concepts used in the proposal are defined. The datasets used in evaluating the method, as well as the experimental computing platform used in the tests, are also described.

Time Series

The proposed method uses time series data. A time series is a finite sequence of samples, taken at increasing instants of time. In the proposal, the data of a measurement are evaluated first individually and then in small subsets that refer to the data generated during a given time slice, or segments. A segment refers to a sequence of time series samples ordered in time.

Normal and Abnormal Data

In this proposal, if a given sample follows the trend of the rest of the data, then it is considered normal and, otherwise, it is considered abnormal. If considered normal, no further assessment is necessary. On the other hand, if it is considered abnormal, a second evaluation is made.

Persistent and Transient Failures

Sensor failures can be persistent or transient. As it is common for failures to occur in this type of communication (in capture and transmission), if the interference occurs in only one measurement, generating a single incorrect value, there is a high probability that these data will be misinterpreted. The way to get around this problem is through the analysis of the data produced in a time slice. The reason is that disturbances related to energy sources and means of transmission are mainly transient, caused by imbalances that lead to momentary instabilities [51].

Failures and Anomalies

To verify the behavior of each sensor, the data generated by them are classified with the labels normal, abnormal, anomaly, and failure. Data marked as normal are those that indicate that both the sensor and the environment in which the measurement is being made are stable (no anomalies) and the reading process was not affected by interference during data capture and transmission. Data in this range of values represent the data most frequently generated by the sensor.

Data considered abnormal are evaluated again, but in this case, considering the temporal aspect (slice of time). In this second evaluation, a piece of data can also be considered normal, even though it was considered abnormal in the first evaluation. This occurs in cases where the data were considered abnormal due to a transient failure. If a measurement affected by a fault is analyzed as a time series, the sequence or sample segment corresponding to the fault will be different from the normal trend of the time series. However, this will only be true if the deviation from normality is large enough to influence the measurement of the entire segment, which occurs in persistent failures. In the case of transient failures, a single abnormal data point, the influence on series measurement is less significant. Thus, when analyzed in a data segment, the disturbance caused is mitigated due to the presence of several other normal values.

In this second evaluation, the data can also be marked as anomalies, indicating the occurrence of anomalies in the environment. This occurs when several of the values in the data segment are relatively far from the normal range, but within a range of values that may exist in the environment's domain. This kind of data does not happen that often.

Finally, data considered as failure are data that occur due to persistent failures in devices, affecting the capture or transmission of data. In this case, the range of values is much further away from the other values, extrapolating the limits of valid values in the domain

$$Q3 + {\text{FF}}*{\text{IQR}} < ai > Q3 + {\text{AF}}*{\text{IQR}}$$
(2)
$$ai > Q3 + {\text{FF}}*{\text{IQR}}{.}$$
(3)

Equations 2 and 3 use the anomaly index (ai) and IQR metric to label samples. Equation 2 is used to verify if a value is considered anomaly and Eq. 3 is used to label values considered failures. The factors anomaly factor (AF) and failure factor (FF) used in the formulas were defined in the data set training stage to better identify the discrepant data in each set.

Figure 2 shows an example of the application of this metric: the points located below the gray line (close to 0.035) represent the data considered normal; the points between the gray and the green line (close to 0.05) represent the anomalous data, and the points above the green line represent probably failure data. No data exist below zero, because the values represent the temperature in an environment that does not have negative temperatures.

Fig. 2
figure 2

Division of data into normal, anomaly, and failure values using the IQR metric

The samples marked as failures refer to noise in the transmission or capture of sensor data, and the data considered as anomalies represent the presence of a phenomenon in the observed environment surrounding the sensor.

Three-Level Sensor Ranking

The ranking method proposed in this work is based on the theory of active perception [49, 50]. Similarly, in this proposal, the task of ranking sensors is performed through an analysis that allows different levels of reasoning according to the context found.

Figure 3 shows an overview of all steps involved in this proposal and Fig. 4 presents an overview of the proposed algorithm only.

Fig. 3
figure 3

Overview of all steps involved in this proposal: tiers of processing, processes, and tools for each tier and active perception (proposed)

Fig. 4
figure 4

Algorithm for ranking sensors

In the pre-processing step shown in Fig. 3, the samples are labeled, the variable data are discretized, and the training phase of the algorithms used is performed. Then, in the processing step shown in the figure, it is possible to identify the layer (Edge, Fog, and Cloud) the processes (acquisition, modeling, reasoning, and distribution) of the middleware that are executed (boxes with a gray background). Below the identification of each process, in orange, the functions performed in the standard middlewares are represented. In the boxes with a green background, the processes present in the architecture of the developed experimental environment are described, represented by the text in black. In these boxes, the orange text represents the process performed or the input data sent to the tools used, identified by the gray text.

Finally, the ranking process is detailed in the last section (indicated by the up arrow), on the top right (Active Perception), which shows the information flow of the proposal. The image displays the levels of active perception starting with the activity of collecting data in the environment (following the direction of the red arrow), perception, perception over time, and active perception. The first level of the active perception, sensation (wrapped in a dashed line), is carried out by the sensors and, therefore, is outside the scope of this work. This activity is emulated by scripts in the evaluation tests performed. In this part of the image, the flow returns to the environment, indicating the execution of the actions taken at the level of active perception. Below the identification of each level, characteristics of the respective activity, and the techniques used to implement them are presented. Each step is identified according to the theory of active perception (black text), as well as the function of each one (text in green) and the algorithm or technique used (in blue).

Figure 4 presents a general flowchart of the algorithm used in the decision process during information processing. The flow shows the levels of the proposal and the decisions taken at the exit of the first and second level. As can be seen, the second and third levels are only executed if the information on the first level (perception) is classified as abnormal. Otherwise, the flow goes directly to updating the distributed hash tables. Considering the case of the data being classified as abnormal, it is evaluated again at the second level (time perception) to see if it is a normal, a fault or if it is a change in the environment, that is, an anomaly. The flow continues to the third level, where the amount of each type of data generated by the sensor is used to define its current state as normal, fault, or anomaly. Finally, the process ends by updating the distributed hash tables. The image also displays a query module through which the distributed ranking list can be queried. In the current state of the proposal, this module has not yet been implemented and queries are made manually. In the following subsections, the implementations of each level will be detailed.

First Level

At this level, which was implemented using XGBoost, the model created in the training phase is used to classify data into normal and abnormal. The training of the algorithm was carried out with a sample of 25,000 cases from each dataset. In this proposal, if the segment that does not follow the trend of normal data will be considered abnormal, and after that, a second evaluation will be made to decide whether the data are an anomaly or a failure.

Second Level

This level uses time to evaluate the data provided by the sensor. The adoption of this approach (time) allows distinguishing transient from persistent failures. If a measurement affected by a failure is analyzed as a time series, then the sequence of samples or segments corresponding to the failure will be distinct from the normal trend of the time series. In other words, this segment will be considered anomalous [36].

To implement this concept, the nearest neighbor’s algorithm was chosen. The basic idea is to use a similarity measure to assess the similarity between each segment in the time series and all other segments. Similar segments, that is, with similar sequences of samples, are known as nearest neighbors. These must be differentiated from neighbors almost in time, which are adjacent segments with overlapping samples [52].

The anomaly index, a measure of similarity between each segment, calculated using the Euclidean distance metric, is used to generate the thresholds values that divide data into normal, anomaly, and failure categories. These thresholds are generated by applying the IQR metric on the calculated anomaly indices. As a result, the data are divided into three categories according to how far each value is from most of the data (those furthest to the center of the normal distribution), as shown in Fig. 2. The limits are generated in the training step of the algorithm and then used in the tests. This allows the computational cost to be very small when executing the algorithm.

Third Level

In the final level, the sensor index is updated with this new information. To update the index, the data are processed using the concepts of Quality of Context (QoC) theory. The trustworthiness parameter of QoC (Eq. 4) is used as an indicator to generate the ranking of sensors. In the trustworthiness parameter, the value 0 (zero) means that this context source is not reliable, and 1 (one) represents total reliability in the context source [53]. In Eq. 4, the parameter T is the reliability, the ctxi is the set of trusted context elements for a sensor (labeled as "normal"), and W is the total number of context elements and must be greater than zero. The terms reliability and trustworthiness have the same meaning, and the second was used to name the QoC parameter

$$T\left( {{\text{ctx}}_{i} } \right) = \frac{{{\text{Number}}\,{\text{of}}\,{\text{Realiable}}\,{\text{Samples}}\,{\text{(ctx}}_{i} {)}}}{W}.$$
(4)

The value of the trustworthiness context parameter is then evaluated using a FIS. The modeled FIS has an input variable and an output variable. Figure 5 presents the fuzzy pertinence functions of the input variable (trustworthiness) and the output variable (sensor state). The sensor state variable shows the functions with the output value already set.

Fig. 5
figure 5

Fuzzy membership functions

As a final step, regardless of the level that was last performed, the sensor ranking is updated with the new values of the trustworthiness parameter.

Evaluation

In this section, the computational architecture and the data sets used in the tests of the proposal are presented.

IoT Platform

Given the distributed nature of IoT devices, it is necessary to adopt a distributed architecture capable of ensuring the scalability of the proposal. The exponential growth in the number of sensors in the IoT environment justifies the requirement for this type of approach. Thus, the proposed method will use a distributed approach using a cooperation model between Cloud and Fog Computing. The Apache Cassandra framework was used to manage the distributed ranking lists.

The computational architecture used in the tests is an adaptation of the FASTEN project [54]. Flexible and Autonomous Manufacturing Systems for Custom-Designed Products (FASTEN) is a project funded by the EU Horizon 2020 program. FASTEN's Industrial IoT Platform aims to manipulate data from devices (robots, sensors, etc.) in industrial environments and serves as an intelligent data repository for the optimization and forecasting layer, allowing to improve the quality of the services offered and while meeting Industry 4.0 [55] requirements.

Figure 6 presents architecture used. The changes about the FASTEN project consist in the use of the sensor ranking solution (GoAT [13]) and the use of distributed rank lists (Apache Cassandra). The bottom box in Fig. 6 represents the sensors (devices). The data from these sensors are sent to the platform using the Message Queuing Telemetry Transport (MQTT) protocol. To perform this function, the VerneMQ tool [56] was chosen. A connector continuously monitors topics (such as a message queue) in MQTT, and, as soon as a message arrives, it is automatically transferred to the Apache Kafka streaming platform [57]. Following the flow, the next box, GoAT, represents the proposal of this research work for ranking sensors.

Fig. 6
figure 6

Proposed experimental environment—IoT platform

After processing by the GoAT broker, messages are maintained in the Apache Cassandra tool. The persisted data can be used for monitoring the system. For the tests, three containers were configured in the Docker tool, representing a node in the DHT network. In this way, this architecture allows parallel processing, also reinforcing the scalability of the proposal.

Datasets Used

Four real data sets were selected to evaluate the proposed method, as shown in Table 2.

Table 2 Datasets

The Intel Lab dataset [33] contains information about data collected from 54 sensors with weatherboards that collected timestamped topology information, along with humidity, temperature, light, and voltage values once every 31 s. The sensors, deployed in the Intel Berkeley Research Lab (Intel), were arranged in the lab. The data from sensor 52 were used in the training phase, and data from sensors 2, 3, 20, and 39 were used for testing the proposal.

Another dataset referred to environmental data and was collected from 9 buoys of the Networked Aquatic Microbial Observing System (NAMOS), which is widely used in anomaly detection schemes [58]. In this dataset, data from sensor 107 were used in training, and that from sensors 101, 102, and 106 were used for tests.

Figure 7 shows an overview of 14.181 stations of the National Oceanic and Atmospheric Administration (NOAA) [59]. In the NOAA dataset, data from station 010080 were used in training, and data from stations 010100, 010230, and 010490 were used in the tests.

Fig. 7
figure 7

NOAA hourly dataset [59]

The last of the four datasets used have data collected from 23 stations of the SensorScope [60], an outdoor temperature. For training, data from station 19 were used, and data from stations 2, 6, 7, 9, and 17 were used in the tests.

The subsets of data for each sensor (stations) were chosen, because they contain data that are far from the average of each set (possible anomalies or failures). The combination of these datasets, in which the data were generated under different conditions, contributed to the evaluation of our proposal. To realize the experiments, a computer with an Intel Core i7 processor with 16 GB of RAM and a 250 GB SSD is used.

Experimental Results

Since the cases of datasets do not have labels, and to provide some metrics capable of demonstrating the quality of our method, the IQR metric is used to generate labels for the data in the training step. This approach allows generating indicators of the accuracy of the proposal, enabling the comparison of the outputs generated in the tests with the information obtained in the training step.

As an example of the application of the IQR metric to generate labels in the data, a graphical representation of the division of the data from the dataset SensorScope into the normal and abnormal values is showed in Fig. 8.

Fig. 8
figure 8

SensorScope dataset classified using the IQR metric

In the SensorScope dataset image shown in Fig. 8, the dots in blue (normal values) represent the natural temperature variations during a day (between 15 and − 10 °C) and the red dots represent the values considered to be abnormal (anomalies in the environment or failures in capture or transmission). The data shown in the image refer to station 19 of the dataset.

The thresholds of the IQR metric (Fig. 9) defined in the training step of the k-nearest neighbor algorithm were used in the tests of the algorithm.

Fig. 9
figure 9

The IQR metric is applied to values of the datasets: a Intel, b NAMOS, c NOAA, and d SensorScope

Table 3 presents the overall error rates (in parentheses next to the name of each dataset) and the confusion matrices (the letters N and A represent the normal and abnormal labels, respectively) for all datasets. Both overall error rates and confusion table values are percentage values. Note that the values are presented in percentages, but values such as the total normal values and the total abnormal values were considered to inform the percentages, so the values add up to 100% for each column of normal values and for each column of values abnormal. As the dataset cases did not have labels, the responses of the proposed algorithm were compared with the labels generated in the pre-processing step.

Table 3 Normalized confusion matrix for all datasets (%)

Table 4 shows the differences, for abnormal values, between the classification obtained in the pre-processing step (Abnormal-True) and in the tests (Abnormal-Predicted). The values referring to the pre-processing step are expressed in quantity and the other values are expressed in percentage. The table also displays the percentage of values for each data label. The Abnormal-True and Abnormal-Predicted columns have values defined at the first level of the algorithm (Perception), and the anomaly, failure, and normal columns have values defined at the second level (Perception Time) of the algorithm. Note that in the values referring to the second level, the values of anomaly and failure add up to 100%, as they correspond to the parcels of abnormal values.

Table 4 Classification of abnormal values (%)

Figure 10 shows the times spent per dataset for processing a request. The item "Response Time" refers to the total time from the submission of the request to the receipt of the response. The item "Latency" refers to the processing time of the ranking algorithm. The difference between latency and response time is because, in the calculation of latency, the time spent on data manipulation by the python Pandas framework was disregarded. In Fig. 10a, the times spent in the first step of the algorithm (first level of active perception) are shown, and in Fig. 10b, the times referring to the execution of the three levels of the algorithm are shown.

Fig. 10
figure 10

Response time and latency costs

Discussion

In Figs. 8 and 9, it is possible to see that the use of the IQR metric is efficient to separate the data into normal, anomalous, and fault data. The images clearly show the separation of the data close to the average of the most distant data. The justification lies in the fact that the occurrence of anomalies and failures in the sensors should generally be rare events when compared to data considered normal.

The general error percentages shown in Table 3 demonstrate the efficacy of our proposal. However, in the NOAA data set, it is possible to verify higher values by analyzing only the error rates of the values classified as abnormal by the algorithm. In the other data sets, this rate is minimal. It was possible to verify, after analysis, that the threshold values of this set, for the failure and anomaly categories, differ drastically from the others. As can be seen in Fig. 9, the limits between the normal and the other values are very close, which probably reveals the cause of the errors made by the algorithm.

Besides that, only a small part of the data are analyzed at all levels of the proposal. This is because the data considered normal, which consists of most of the data, are not processed in the second level of the proposal (Perception Time). This idea is clear when checking the graphs shown in Fig. 10, which shows considerably shorter processing times relative to the first level, Fig. 10a, concerning to the total processing time of the three levels shown in Fig. 10b.

Finally, Table 4 presents the data referring to the division of the data considered abnormal into data that represent anomalies in the environment and in data that represent faults in the sensors. This type of approach can be extremely useful not only for controlled environments, assisting in disaster prevention and maintenance of problematic sensors, but mainly to allow the safe use of information from sensors in the Normal state.

Conclusions and Future Works

This paper describes the efforts and results of a differentiated research work focusing on the ranking of sensors for the Edge–Fog–Cloud environments. The main contributions of the work are to improve the reliability in the use of sensor data and to reduce the latency of this process, offering a method based on artificial intelligence to meet the requirements of intelligent environments, such as Smart Cities and Industry 4.0.

The immense volume of complex and heterogeneous data generated in the IoT environment poses challenges that must be overcome. One of the main challenges is related to computational resources, essential to process these data, to meet the real-time requirements inherent to the IoT environment. Also, the uncertainty added to the process, generated precisely by the complexity of the data, also represents an obstacle to be overcome.

The presented proposal allows to manipulate this data and using software components capable of processing data in a parallel, distributed way and, thus, meeting time restriction requirements.

Besides, through the implemented mechanisms, it allows to drastically reduce the computational effort involved in data processing, since almost all the data are analyzed with a very low computational cost (only the first level of the proposal is used in this subset of the data).

Another characteristic present in the proposal is related to the ability to deal with the imprecision inherent to devices in the IoT environment. The artificial intelligence algorithms applied incrementally provide more reliability in the use of the generated data.

Finally, due to the treatment of the uncertainty present in the data, the proposal also offers resources to facilitate monitoring in controlled environments through the classification of sensors in anomalous or in a state of failure.

The presented method makes use of several sets of real data, already used in other proposals, aiming to help to overcome the present challenges, as well as to facilitate the improvement of future proposals. Test results show error rates below 3% in two sets of data, 11% in one of them, and in only one of the four sets used, the rate cannot be considered low. Considering together the times obtained with regard to latency, which were close to 2 ms in the first processing level and 30 ms in the total time, it can be said that the proposed method is promising, as it combines reliability and latency reduction.

Finally, to the best of our knowledge, this is the first sensor ranking proposal that considers the fact that sensor failures can be transient or persistent, given the dynamic nature of the IoT environment. This work, as it was implemented, also previously generates the list with the classification of the sensors, which allows responding immediately to a request for a list of reliable sensors. The use of the theory of active perception as the basis for developing the proposal allowed the creation of a method that adds knowledge to the reasoning at each level of the theory, thus improving the reliability of the data analysis process, using low computational resources.

As future work, tests are planned in a computational grid environment. This will considerably increase the amount of data processed by the method, since the volume of data generated by sensors is quite large. This procedure aims to demonstrate and evaluate the computational capacity of the proposal. In this test, we also intend to use data captured online to reflect the characteristics of real environments further. In the proposal presented, only univariate data were considered, and the missing data were disregarded. In future work, we also intend to address these two aspects. Finally, to optimize the use of the proposal, we want to use artificial intelligence techniques to define the hyperparameters, currently defined manually.