Toward Blockchain Technology in IoT Applications: An Analysis for E-health Applications

. Research involving Blockchain technology has been growing due to its decentralization and immutability characteristics. Several applications from the most varied areas can beneﬁt from the Blockchain, such as ﬁnance, logistics, and others. Internet of Things (IoT) is a new paradigm that has emerged to provide services to users through intelligent objects arranged in the day-to-day and provided various research, for example, smart buildings, smart cities, precision agriculture, and E-health. E-health applications can be considered as a set of computational solutions focused on the health area. This paper aims to study the introduction of Blockchain technology in an E-health approach. A Blockchain tool was used in conjunction with an E-health database and evaluated its performance. The results indicated that the transaction validation times are favorable for the characteristics of an E-health application.


Introduction
Due to advances in microelectronics and wireless communication, it has been possible to develop small mobile devices that have the computational power to capture data and retransmit them to other devices in order to generate information, thus providing services to users [16] [6].These devices may contain one or more sensors to monitor the status of a given individual, and from that data generate useful information for the user.These advances provided the rise of the Internet of Things (IoT).
IoT is an emerging paradigm that has combined several technologies.IoT interconnects various physical devices present in daily life, and that has the computational power to capture data, providing services to users.These physical devices are called smart objects.IoT covers a wide variety of different types of applications, such as education, transportation, agriculture, health, among others [1] [6].
E-health applications are a set of health-related computing solutions that use the internet to provide their services [15].These applications can range from monitoring a patient's physiological data to the medication management system in a hospital infrastructure [11].One of the main challenges of E-health is the security and privacy of the data captured or manipulated by these applications.E-health application data are considered sensitive because it can present information about the disease and the treatment of a particular patient [15] [11].That means unauthorized persons should not access it.
A Blockchain consists of a set of data composed of a chain of data packets (blocks) where a block comprises multiple transactions [17].Blockchain is extended by each additional block and thus represents a complete general record of the transaction history.The network using cryptographic mechanisms can validate these blocks [17].
Blockchain is known to be the technology used to create Bitcoin.However, due to its characteristics, it is possible to use it in several other applications.Currently, there are studies on the use of Blockchain technology in applications that need its features.IoT can be cited as one of those applications that fit with the use of Blockchain.Conoscenti et al. (2016) described some uses of blockchain with IoT, such as the use of blockchain to exchange data collected by IoT device sensors and other goods and to store and manage data collected by IoT devices, decentralized and private-by-design fashion [7].
Many IoT applications require information storage that can be auditable and have a history of data changes, such as E-health applications.Blockchain technology can provide several advantages to E-health applications.Advantages like immutability, audacity, security, and others are part of Blockchain technology.
This paper aims to present research on the introduction of Blockchain technology in an E-health approach.An E-health application architecture is proposed with the insertion of a Blockchain, based on the [15] model.In order to reach the proposed goal, a Blockchain experiment was carried out in conjunction with an E-health database.The BigchainDB is a distributed Blockchain database.
The performance of Blockchain is analyzed with the data provided by the used E-health application.We discussed the possibility of the integration of Blockchain in several types of E-health applications.
The rest of this paper is divided into the following sections: in section 2 a brief background is presented on IoT, E-health, and Blockchain technologies, respectively.In section 3 shows the work related to the proposal of this work.
Section 4 details our approach to using Blockchain technology in an E-health application.Subsequently, in section 5, the experimental design is described.Section 5 presents the detail about the experiments.Section 6 presents the results and discussions derived from the experiments conducted.Finally, in the section 7 the conclusions are presented.

Internet of Things and E-health
Internet of Things (IoT) has been an emerging paradigm in recent years.Advances in wireless technologies, embedded systems, and sensing have led to the emergence of this new paradigm [16].IoT is a set of computational devices that can monitor and transmit data from an environment over the Internet, providing services and information to users [16][6].These devices are called smart-objects and can exchange data and information from the monitored environment with each other [6][9].
Smart objects are usually limited in computing power and do not have the same level of protection as personal computers and smartphones.This feature of smart objects makes it necessary to research efficient and low computational techniques for access control and data privacy in IoT applications.
IoT has provided the creation of applications in various sectors such as transportation, industry 4.0, education, health, and smart-* applications 1 .
According to the Healthcare Information and Management Systems Society (HIMSS), E-health is a set of the application of the Internet and other technologies related to the health sector to improve access, efficiency, and effectiveness of quality clinical processes.It also aims to improve the business processes used by healthcare organizations, professionals, patients, and consumers to improve patients' health status.
E-health includes several dimensions: • Delivery of relevant information to health partners; • Provision of essential delivery services (example: medicines); • Ease of interaction between health professionals and patients; • Ease of integration of business processes related to the health sector; • Local and remote access to health information; • Remote monitoring of patients; • Support for employers and employees, payers and suppliers.
In this context, the overall objective is to improve the health status of patients, as well as to provide more efficient services, avoiding possible complications.Electronic Health Records (EHRs) are an evolving concept defined as a longitudinal collection of electronic health information about individual patients and populations [10].
Initially, the EHR is a mechanism for integrating health care information currently collected into printed and electronic medical records to improve the quality of care.These records consist of a series of patient data such as complaints, laboratory tests, medicines used, procedures performed, and various other information.With the possession of the data of the registry, it is possible to carry out instant analyzes, identifying relations between the existing data.
In general, delivery of E-health services related to remote monitoring of vital signs consists of collecting signals on a mobile or wearable device, transmitting the raw or pre-processed signals to a server, storing them, processing them, and them to the end-user.Also, depending on the usage scenario, the remote monitoring process may involve voice and video consultation of the end-users.
However, these data are considered sensitive data since they should not be accessed and should not be modified by unauthorized persons.Blockchain technology can provide these essential features for E-health applications.

Blockchain
Blockchain is a block sequence, which contains the complete record of transactions as a public book, indicating the order in which the transactions occurred [5]. Figure 1 shows a Blockchain in which the newly validated block points to the immediately preceding block generated.That is, each block in the chair confirms the integrity of the previous and the way back to the first block, called the genesis block.
A Blockchain consists of a set of data composed by a chair of data packets (blocks) where a block comprises multiple transactions [17].Blockchain is extended by each additional block and thus represents a complete general record of the transaction history.The network using cryptographic mechanisms can validate these blocks [17].In addition to transactions, each block contains a timestamp (date and time), the hash value of the previous block (parent), and a random number used to check the hash named Nonce.This concept ensures the integrity of the entire Blockchain up to the first block (genesis block).
The hash values are unique, preventing fraud from being performed on the system since changes to a block in the chain would immediately change its hash value [17].
The block can be added to the chain if most of the network nodes agree through a consensus mechanism on the validity of the transactions in a block and on the validity of the block itself.Therefore, new transactions are not automatically added to the record.
The consensus process ensures that these transactions are stored in a block for some time before being transferred to the ledger (for example, in Bitcoin2 is 10 minutes).After this process, the Blockchain information can no longer be changed.
In the Bitcoin, the blocks are created by the so-called "miners", who are rewarded with Bitcoins for the validation of the blocks.The Bitcoin example illustrates that Blockchain's principle can change not only the process of moneymaking transactions.Using encryption, people around the world can trust each other, and transfer different types of assets, point to point on the internet.All Blockchain implementations are based on virtual currency [18].The basic types of records kept by the book are transactions related to the creation of new coins (only made by miners), as well as the transfer of currency from one user to another.That is, in addition to these simple transactions, many Blockchains allow distributed books to store smart contracts.
A smart contract is an autonomous application with pre-defined inputs and outputs that can be performed by a miner in a deterministic manner [18].Any user can invoke a smart contract, the result of which is logged as a transaction in the distributed log book.That is, the user can use Blockchain technology in other contexts.Blockchain becomes an exciting technology in the health area due to its inherent characteristics.
A smart contract can also be viewed as a collection of codes and data (functions and states) that are implemented through transactions [20].It should be emphasized that an intelligent contract should generate a similar result in all nodes that perform the same contract, maintaining cohesion.However, not all Blockchain networks allow the use of smart contracts [20].There are several possibilities of use for smart contracts, such as calculations, information storage, automation of financial assets, among others [13].

Related Work
In this section, it is present selected papers that involved IoT, E-health applications, and Blockchain.
The paper proposed by Metter (2016) presented an account of initial points of use of Blockchain in E-health applications [14].The work was focused on the management of medical care, user-oriented research, and pharmaceutical falsification in the pharmaceutical sector.Medical treatment processes usually involve more than one health care specialist and need access to information from their patients.Blockchain technology enables transparent access for those interested in patient care information.This ability to track the interaction between patient and physician is fundamental to correct treatment.
In the paper of Liu, W. et al. (2017) proposed a Blockchain architecture focusing on E-health applications called Advanced BlockChain (ABC) [12].This proposed architecture is described as a reliable and secure solution for medical record exchanges.This work presented some fundamentals of E-health and Blockchain, considered the following elements of the architecture: Blockchain and E-health protocols, inter-domain adaptations, certification authorities and security operations, regulatory compliance, additional value E-health systems [12].With computational logic to be incorporated into E-Health's blockchains, personalized medicine is enabled by the complete and consistent data blocks available to all service providers involved [12].The Advanced BlockChain mechanism enables security audits, regulatory compliance reports, billing updates, lab results alerts, and medication events.
Rifi, N. et al. ( 2017) presented problems for E-health, and Blockchain could help develop a safe and scalable medical solution.They paid attention to the data exchange security and the low computational power of the sensors [19].Patients, doctors, and hospitals are connected to a Blockchain, which provides privacy and security of medical data.These data can come from patient-connected sensors or the hospital infrastructure, and the data generated can trigger smart contracts that will notify interested parties.As sensors generally have low computational power, gateways can be used for this function, and thus enjoy an IoT environment with Blockchain.
The work proposed by Freitas and Rolim (2019) presented a framework called Demochain to assist in the development of hybrid Blockchains platforms in the context of IoT [8].The lack of standardization of IoT devices due to their different areas of operation makes it difficult to implement a Blockchain network customized for IoT.Therefore, the proposed framework aims to create Blockchain hybrid networks [8].This framework can offer combination options of different levels in Blockchain architecture and functionalities, varying protocols and encryptions.This framework provides the creation of IoT applications from various areas.
It possible to observe from the works cited that there are several proposals for E-health applications and, because the data is sensitive, privatization and security become a challenge in this category of applications.E-health applications can have several aspects that, consequently, manipulate different data types.However, because the manipulated data present relevant information about the patient, it is necessary to use a security mechanism and data privatization.Also, retrieving the history of data changes in E-health applications is essential for applications that manipulate medical protuberances.
Blockchain's technology provides a history of all the transactions that have been performed through the ledger, i.e., it is possible to analyze which changes were made to a given file.It is also possible to insert data anonymization algorithms into a Blockchain, preventing unauthorized users from satisfactorily extracting the data.
Our application aims to evaluate the possibility of using Blockchain technology in IoT applications, particularly in the E-health application.It is possible to evaluate the insertion of Blockchain in an application that requires a low latency through code execution time and transaction validation metrics.

Description of Our Approach
The purpose of this article is to study the use of Blockchain technology in an E-health approach.A distributed Blockchain database tool was tested with the MHEALTH dataset used by Moreira Neto et al. (2018) proposal architecture.We intend to analyze the possibility of the use of the Blockchain database in conjunction with the E-health approach.
The proposal of Moreira Neto et al. ( 2018) presents a three-layer architecture in which: (i) the first layer is the perception layer that is composed of smart objects; (ii) a network layer that is responsible for managing, routing, and identifying network technologies used in the application; and (iii) an application layer that is responsible for providing services to users.In this architecture, we can see that each layer offers a service to the top layer.Figure 2
The application proposed by [15] is divided into three parts.The first part of the approach is the collection of users' physiological data through wearable devices.The communication of these devices is done using a communication protocol of low cost (i.e., Bluetooth Low Energy -BLE).This physiological information is made available by the mobile application.The mobile app presents the physiological data of the user and the feedback of the responsible health professional.
The second part is responsible for sending the captured data for processing and storage in the cloud.Information inferences are made from the data stored in the cloud.It is possible to create information historical about the behavior of the patient's physiological data through inference.The data is sent to the healthcare professional through a web application.The web application is the third part and it is responsible for receiving the information processed in the cloud and presented to the health professional through visualizations.Figure 3 presents our proposed architecture.Our approach is to evaluate the introduction of the Blockchain module into the E-health architecture.This module can be added to a remote server that is located in a public or private cloud.

Web App Cloud
By capturing the patients' physiological data through wearable devices, these data are routed to the mobile application.The mobile application receives this data and presents it to the user through views, as well as it sends the data to the server to be processed and stored.The server will process the data and generate information through statistical inferences.Blockchain will store this information and send it to the healthcare professional through the web application.

Experimental Design
As previously reported, the goal of the paper is to evaluate the use of Blockchain technology in an IoT application.Therefore, to use the BigchainDB tool together with the E-health database to analyze tool performance.This section details the materials and evaluation methods applied for the proposed application.

Goals
The experiment's goals are to check if it is possible to insert a Blockchain tool into an IoT-E-health approach.A series of experiments were carried out using a Blockchain database and an E-health dataset to achieve the proposed goal.We scaled the number of nodes that form the Blockchain network, as well as the number of sent transactions in the experiments.Using these evaluations, we can verify if the validation and execution times of the algorithm may or may not impact the performance of a real E-health application.

Materials and Methods
The dataset MHEALTH [3][2] [4] has body movement data and vital sign recordings on ten volunteers with different profiles.Each volunteer performed physical activities, thus generating the dataset data.The sensors were placed on the pelvic floor, the right wrist, and the left ankle of the individuals.These sensors captured data of acceleration, rate of rotation, and orientation of the magnetic field.The sensor positioned on the breastplate captured the 2-lead ECG measurements, which can be used for essential cardiac monitoring and can detect arrhythmias.Data extracted from the dataset was preprocessed and sent to the Blockchain network in the form of JSON3 files.Each sent JSON file corresponds to a transaction with the default shown below: • {'heartBeats': Double, 'speed': Double, 'acelerometerX': Double, 'acelerom-eterY': Double, 'acelerometerZ': Double, 'indexData': Integer} We used the BigchainDB4 , which is a Blockchain database that offers Blockchain characteristics such as decentralization and immutability.BigchainDB also allows deploying scalable IoT applications and artificial intelligence.It was created six Virtual Machines (VM) with 1GB of primary memory and 20GB secondary memory, similar to Amazon t2.micro.The operating system used was Ubuntu 18.04-LTS.These virtual machines were virtualized from a server with processor: Intel(R) Xeon(R) E5645 @2.40GHz.
The experiment consists of varying the number of transactions, observing the validation times of transactions, and the average number of blocks created by execution.The same experiment is performed for a Blockchain network with two, four, and six virtual machines.Table 1 presents a set of performed experiments.Legend: VM = Virtual Machine.
We execute three different scenarios based on the number of transactions, each executed five times, that is, 5 x 100 transactions, 5 x 150 transactions and 5 x 200 transactions.

Metrics
The metrics that were used to evaluate the viability of using the Blockchain tool in an E-health application are presented below: • Execution time of the algorithm; • Validation time of the Transactions; • Number of blocks created.Also, it was extracted statistical data analysis from the validation times of the transactions, considering that it is the most important metric because it is directly responsible for Blockchain's performance.
The execution time of the algorithm is the time that the algorithm takes to send the transactions to BigchainDB.This metric is strongly related to the send mode of transaction.BigchainDB has three send modes: commit mode, asynchronous mode, and synchronous mode.In our experiment, we used the synchronous mode; that is, the processing to send transactions only finished after the storage confirmation return.The synchronous mode may provide a longer delay than asynchronous mode by waiting for block storage confirmation.However, the synchronous mode guarantee that the block has been properly inserted into the Blockchain.
The validation time of transactions is the time when all transactions were successfully stored in Blockchain.This metric is also related to the sending mode.The sending mode can impact the time of validation.
Finally, the number of created blocks is directly related to the block creation time parameter.Each block has a timeout for closing the block, i.e., all transactions sent by the end of that time will be stored in the block.All subsequent transactions will be stored in the next block, and so on.

Experiments and Results
Figures 4(a) and 4(b) present, respectively, the median and the mean of the validation times of the transactions of each performed experiment.We choose the median validation times because it is the more reliable metric due to the low influence on the values derived from the outliers data.
It was observed the occurrence of outliers during the experiments.These outliers come from the creation of empty blocks.When an empty block occurs, it means that the timeout has been reached, so the counted time of this block is high and it becomes an outlier about other blocks.These outliers have a high impact on the mean values of the validation times but have little impact on the values of the medians.Table 2 presents the mean, median and standard deviation data of the conducted experiments.
It can be seen from Figure 4(a) that transaction validation times grow according to the increase in the number of transactions sent to the Blockchain network.We also observed this feature when analyzing Figure 5, which presents the execution times of the algorithm for sending the transactions.There was a  positive correlation between the number of transactions and the execution time of the algorithm.Another point observed is the growth of the time of the about the number of nodes in the Blockchain network, as can be seen in Figure 5 and Table 3.The validation time of the blocks grows as more nodes compose the Blockchain network, and this happens due to the intense communication between the nodes during the validation stage of the transactions.During the consensus that will validate the transaction, it occurs intense exchange information between the nodes of the Blockchain network until the moment the block is created and stored in the cash book of each node.Figure 6 shows the number of blocks created by experiments.Each experiment adds two nodes in the Blockchain network to a network of a maximum of 6 nodes.It can be observed that as we increase the number of transactions, consequently, there is an increase in the number of blocks.It is also possible to observe the occurrence of empty blocks in each set of blocks.These empty blocks occur due to the block creation timeout.Each block has a timeout parameter that, when reached, causes the block to be generated empty.Transactions that come after this timeout are stored in the next block and so on.There is a low occurrence of empty blocks in each experiment because the BigchainDB consensus algorithm took a few seconds to validate the transactions stored in the blocks.

Discussion
The results obtained by the experiments present a satisfactory performance for an E-health application.The medians and averages of transaction validation times were approximate, which characterizes that there were few outliers.Outliers causing the average to grow from the median were found to be caused by the generation of empty blocks during the storage of transactions in Blockchain blocks.
Transaction validation time has increased as the number of transactions sent to Blockchain has increased, which may impact the performance of an E-health system.However, the order of transaction validation time remained in seconds until the maximum value of transactions sent by the conducted experiments.Another interesting aspect that was analyzed is the relation between the validation times and the number of nodes in the Blockchain network.It has been noted that the average time on a block node network with few nodes is less than the average time on a network with many nodes.This factor can be justified by the intense exchange of information between the nodes that make up the network during the consensus stage.
Finally, it was observed the execution time of Blockchain's transaction submission algorithm.The execution time had a linear growth with the number of transactions sent, as observed in Figure 5.This feature is due to the executed transaction submission mode, which expects a return with a confirmation of the validation of the submitted transactions.

Conclusion
This paper proposed research for the use of Blockchain technology in E-health applications.An E-health application architecture was created using the Blockchain database.Experiments were performed using the BigchainDB tool together with the M-HEALTH database to evaluate the possibility of using a Blockchain tool in an E-health application.The results presented validation times in the order of seconds and the creation of a few empty blocks, which allows a satisfactory performance to introduce the tool in an E-health approach architecture.
As future work, we intend to use other Blockchain tools and compare them to mitigate the performance of each, showing which tool best fits E-health applications.We intend to analyze the recovery time of information that is stored in a Blockchain and evaluated the possibility of introducing privacy techniques in Blockchain.
presents the three-layer architecture proposed by Moreira Neto et al. (2018).

Fig. 3 .
Fig. 3. Architecture of the Application of Moreira et al. (2018) with the introduction of a Blockchain module.

Table 2 .
Validation times of the Transactions.
Legend: SD = Standard Deviation.*The collected times are in the order of seconds.

Table 3 .
Execution times of the algorithm.