Abstract

In this paper, a routing protocol based on energy temperature degree-low energy-adaptive clustering hierarchy (ETD-LEACH) is proposed. In the protocol, nodes consume less energy when transmitting data, which improves the network lifetime. The proposed protocol selects the cluster heads (CHs) on the bases of degree, temperature, and energy to perform routing. Moreover, for solving the issue of a single point of failure, the blockchain is utilized. The data transactions are also housed in the blockchain, which is deployed on the CHs and BSs, as, in blockchain, multiple nodes take part. Therefore, to perform a consensus between them, a proof-of-authority (PoA) consensus mechanism is used in the underlying work. In the blockchain, the secure hashing algorithm-256 (SHA-256) is used for secure hashing of data transactions. Furthermore, malicious nodes are detected during the routing using the real-time message content validation (RMCV) scheme in the ETD-LEACH protocol. The proposed model is evaluated under the denial-of-service (DoS) attack, the man-in-the-middle (MITM) attack, and the smart contract analysis performed by the Oyente tool. The performance of the proposed model is evaluated through simulations. The ETD-LEACH and energy threshold-low energy-adaptive clustering hierarchy (ETH-LEACH) protocols are compared using different parameters like number of alive nodes, energy consumption, throughput, and delay. ETD-LEACH consumes less energy and has a better network lifetime as compared to ETH-LEACH. In addition, the RMCV-ETD-LEACH network performance is better than that of both DoS-ETD-LEACH and MITM-ETD-LEACH. Moreover, PoA transaction cost is less than that of proof of work. Also, the execution time of SHA-256 is less than the execution time of SHA-512. Moreover, the value of the packet delivery ratio (PDR) is found to be 89.9% and 99.9% with and without the malicious nodes, respectively.

1. Introduction

In the past few years, the wireless sensor networks (WSNs) have been globally used in different fields of life like the military, transportation, health applications, etc. [1, 2]. The WSN consists of compact-sized sensors that are deployed in the targeted environment. The sensors are used for tracking and monitoring purposes. In tracking purposes, sensors track enemies, animals, road traffic, etc., while in the monitoring process, sensors monitor the environment, patients’ health, malicious activities, etc. [3, 4].

Unfortunately, WSNs have high security threats. The attackers attack the network and affect the network performance. Malicious nodes take part and tamper or misroute the data packets [5, 6]. Moreover, sensors are resource-constrained devices and have limited storage for storing the sensed data, while the base station (BS) is a centralized entity that causes a high chance of a single point of failure. Therefore, blockchain is used in the WSNs to store data and provide security.

The blockchain is a decentralized, distributed, transparent, and tamper-proof ledger. In the blockchain, data transactions of the networks are stored in blocks. All blocks are chronologically connected with each other using hashes. The block structure consists of a block header and body. In the block header, there is a nonce, hash, timestamp, and Merkle tree, as shown in Figure 1, while all transactional informational is stored in the body. The nonce contains a 32-bit value that shows that the block is generated correctly. It is used in the block-mining process. Proof of work (PoW), proof of authority (PoA), and proof of stake are some of the prominent consensus mechanisms that are used to perform mining in blockchain networks. Besides, the hash is of two types: block hash and Merkle root hash. The hash is generated by the secure hashing algorithm-256 (SHA-256). Moreover, the timestamp shows the time when a new block is generated. In the Merkle tree, the hashes of all the transactions are stored in the root, and it provides security to the transactions. Therefore, it is difficult for a third party to tamper with the transactions.

Moreover, once the data transaction is added to the block, it is difficult to tamper. Therefore, blockchain is used to avoid a single point of failure. Furthermore, in the WSNs, the blockchain uses double SHA-256 for security that consumes high computational power. Furthermore, the PoW consensus mechanism is used, which incurs high transaction costs. Moreover, in WSNs, CHs are resource constrained, and their energy is drained at an early stage. Therefore, all nodes die early, which affects the network lifetime [3, 5, 7]. Moreover, in the WSNs, malicious nodes attack the network while performing routing to tamper with the data packets [810].

In this paper, we focus on the efficient selection of cluster heads (CHs), malicious nodes’ detection, and secure routing data. The CHs are efficiently selected using the energy threshold-low energy-adaptive clustering hierarchy (ETD-LEACH), while the malicious nodes are detected using real-time message content validation (RMCV). Furthermore, the PoA consensus mechanism is used to perform consensus between the network nodes while SHA-256 is used for secure hashing the routing data. Moving ahead, the robustness and resilience of the proposed model is checked by evaluating it against denial-of-service (DoS) and man-in-the-middle (MITM) attacks. The smart contract is also assessed against different vulnerabilities using Oyente.

The major contributions made in the proposed work are as follows. (1)ETD-LEACH and RMCV are used for efficient clustering and malicious nodes’ detection, respectively(2)PoA consensus mechanism is used for consensus while SHA-256 is used for secure hashing of the routing data(3)The proposed model is evaluated against DoS and MITM attacks, while Oyente tool is employed to check the smart contract’s resilience against different vulnerabilities

The organization of the remaining manuscript is as follows. The related work is provided in Section 2 while Section 3 comprises the explanation of the proposed system model. The validation of the proposed work is performed through simulations, the results of which are discussed in Section 4. Furthermore, the resilience of the smart contract against different vulnerabilities is discussed in Section 5, while Section 6 presents the conclusion. Table 1 presents the list of acronyms.

The Internet of Things (IoTs) is a subdomain of WSN. In IoTs, multiple nodes communicated with each other via wireless connectivity. To disturb the communication, the nodes are attacked both internally and externally. When attacked internally (referred to as internal attack), malicious nodes tamper the data, while when attacked externally (referred to as external attack), malicious nodes attack the whole network, which is more damaging than the damage caused by an internal attack. Therefore, malicious nodes’ detection is the main issue nowadays [11]. In [12], the authors work on localization issues in WSN. However, malicious nodes tamper the location of unknown nodes; therefore, nodes’ energy is consumed. The high energy consumption affects the network lifetime [13].

In the WSN [1], authentication of the nodes is not efficient. However, a third party performs authentication, which has a high chance of performing maliciously. In [14], while performing routing, detection of the data-tampering nodes is performed. Furthermore, in [7], IoTs generate a large amount of data; therefore, security risks in terms of tampering data and unauthorized devices accessing the data are increased. However, malicious nodes’ presence affects the customer’s trust.

The sensors sense the data and forward it to the destination [9]. A WSN is mostly used in military wars, education, healthcare, etc. The security issue arises in the WSN while sending a data packet from source to destination. The security issues involve the malicious nodes attacking the data packet or a legitimate node acting selfishly. Moreover, a malicious node creates a black hole attack in the network. The data packets are not being forwarded to the destination and are dropped on their way to the destination due to the malicious nodes. Therefore, to resolve the above-mentioned security issues, the authors propose a central management routing protocol in which the intermediary node acts as a gateway and third party [9]. However, central authority or third party does not provide a fair secure model. Malicious nodes attack the central authority. Furthermore, in routing, a loop routing issue also arises. Malicious nodes broadcast false routing information; therefore, the data packet does not reach the destination and continuously moves in the loop [15, 16].

IoTs are used worldwide for every field of life [17]. However, IoTs have less memory and computational power and a high rate of security threats. Furthermore, the blockchain is widely used in WSN [18]; however, the consensus used in blockchain takes much time in mining data and is not suitable for smart health.

In [19], it is mentioned that WSNs are used in each field of life. However, sensors are not secured, and customers are not satisfied because of the lack of trust in terms of packet drop, delay, and energy consumption [20, 21]. In [22], the blockchain is widely used in each application for data storage and security. However, the number of users increases with the increase in applications; therefore, the PoW consensus mechanism incurs a large computational cost. Moreover, no consensus mechanism is scalable; therefore, a scalability issue also arises.

In [23], the authors highlight the issue of the centralized database. IoTs are used everywhere like smart cities, healthcare, e-commerce, etc. Large data is accessed and stored on the fog layer, which is centralized and not secure. In [24], the authors highlight the issue of security, in which a third party is involved in the communication of two parties. However, the third party is not trustworthy. In the past, authors resolve this issue by using a central authority (CA) that communicates with both parties. However, in CA, there is an issue of a single point of failure. Therefore, in the communication of IoTs, the main challenges are the single point of failure and connectivity between the increasing number of devices in IoT networks.

In [25], the authors discuss the issue of localization in WSNs. In the past, authors propose localization algorithms [26]; however, the algorithms are not secure, consume high computational resources of BS, and do not provide an accurate location of sensors. Therefore, securing sensor nodes’ localization remains a challenge. The authors face the issue of security in smart cities, fog, and cloud in [27]. There is another issue of trustworthiness among nodes and privacy of data. The data is not secure against unauthorized users. Moreover, smart cities are scalable; however, there is an issue of data traceability.

In [28], authors highlight the issues related to a centralized entity and nodes’ malicious behavior. In traditional models, authors use centralized servers that process and store the data in a centralized manner. Therefore, there is a high chance that unauthorized nodes access the data and tamper or misuse the data. Furthermore, in the centralized system, there is a chance of a single point of failure. In [29, 30], IoTs share the data both intranetwork and internetwork. The data is shared on a large scale; however, data is not secured because users are not authorized. Traditional models use CA, digital signature, etc. However, these all are centralized and not secure.

3. System Model

1: Deployment of nodes and BS
2: Degree of nodes
3: Fordo
4: Fordo
5:  Ifthen
6:   Find distance of the nodes
7:   Ifthen
8:    Add index of the nodes
9:   End if
10:  End if
11: End for
12: End for
13: Fordo
14: Fordo
15:  Check the nodes, neighbors
16:  Ifthen
17:   
18:  Else
19:   
20:  End if
21: End for
22: End for
23: Fordo
24: Fordo
25:  Ifthen
26:   Then all nodes will die
27:  End if
28:  Ifthen
29:   First node dies
30:  End if
31:  If dead==0.5nodes then
32:   Half nodes die
33:  End if
34:  Ifthen
35:   Full nodes die
36:  End if
37: End for
38: Fordo
39:  On the basis of degree, CHs are selected
40:  If
then
41:   Ifthen
42:    
43:    Ifthen
44:     Perform CHs’ selection
45:     Send data packets
46:    End if
47:   End if
48:  End if
49: End for
50: End for
3.1. Network Deployment

In the proposed system model, we deploy ordinary nodes (ONs) in the network, select the cluster heads (CHs) from ONs, and perform routing. The CHs’ selection and routing are performed using the ETD-LEACH protocol. The ETD-LEACH is used for reactive networks. In these networks, sudden changes occur in the environment like change in temperature, humidity, etc., and nodes sense the data immediately. The ONs sense data from the surroundings and forward it to the CHs, which have more energy than ONs. Afterwards, CHs forward energy to the BSs. The ETD-LEACH protocol is divided into two phases that are mentioned as follows. (1)Cluster formation(2)Data transmission

3.1.1. Cluster Formation

At the initial stage, nodes are deployed with energy . When the sensors sense the same type of data, they are grouped in one cluster. After clusters’ formation, CHs are created from ONs based on energy, temperature, and degree, in which those ONs are selected as CHs, which have high energy and degree. These CHs sense the temperature value within the given range that gives the current sensing value (CV), as provided in Equation (1).

3.1.2. Data Transmission

In the ETD-LEACH protocol, data is transmitted hierarchically [31]. The ONs sense the data and forward it to the CHs, which further transmit the data to the BS. In this protocol, data is transmitted to the BS when sensed data values meet the given thresholds. The following two types of thresholds are used in the proposed work. (a)Hard threshold (HT): in the HT, when ONs sense the data and data values are found to be greater than or equal to HT, then ONs transmit the sensed data towards the CHs. The sensed data is calculated in the following equation. where is the current sensed value and and are the minimum and maximum ranges of temperature, respectively. The is a random function.(b)Soft threshold (ST): in the ST, ONs transmit data only in the condition when the difference of CV and the previously sensed value is greater than or equal to the given ST

Therefore, the ETD-LEACH network lifetime is better because less energy is consumed when data is transmitted in the low range. Moreover, only that data is transmitted to BS that meets the thresholds.

3.2. Blockchain Deployment

After the deployment of the WSN, the blockchain is deployed on CHs and BS. Blockchain is the decentralized ledger in which data hashes are stored on CHs and data is transmitted to BS. The private blockchain is utilized, and the PoA consensus mechanism is used for mining new blocks. In the blockchain, the SHA-256 hashing algorithm is used to secure data. In SHA-256 [32, 33], data is converted into ciphertext, and a hash of 256 bits is generated, which is difficult to tamper. The size of the generated hash is the same for one letter, one paragraph, and one word. The block size is 512 bits, and the padding length is 10 bits. Moreover, extra data can be added at the end of the message, as shown in Figure 2.

3.3. Malicious Nodes’ Detection

Malicious nodes are present in the network, which act as legitimate nodes and send the data packets during routing. Malicious nodes are detected using the real-time message content validation (RMCV) scheme. In this scheme [34], malicious nodes are detected by validating the message content. Data packets are divided into clusters; same types of data packets are gathered in one cluster while different types of data packets are grouped in different clusters. Then, data packet validation is performed in intraclustering to find false and true data packets. In this manner, malicious nodes are detected. Figure 3 put forwards the overview of malicious nodes’ detection process. The format of the data packet is given in the following equation. where is the location of the receiver, is the location of the sender, and is the message type like temperature conditions, e.g., rainy and sunny. The is the information that the message contains like temperature is an event and its is sunny, rainy, and cloudy. is the time in which a message is received by the receiver. The shows the path from where the data packet is transmitted. After sending data packets to the destination, trustworthiness of data packets is calculated using Equation (3).

1: Deployment of nodes and BS
2: Degree of nodes
3: Fordo
4: Fordo
5:  Ifthen
6:   Find distance of the nodes
7:   Ifthen
8:    Add index of the nodes
9:   End if
10:  End if
11: End for
12: End for
13: Fordo
14: Fordo
15:  Check the nodes’ neighbors
16:  Ifthen
17:   
18:  Else
19:   
20:  End if
21: End for
22: End for
23: Fordo
24: Fordo
25:  Ifthen
26:   All nodes will die
27:  End if
28:  Ifthen
29:   First node dies
30:  End if
31:  Ifthen
32:   Half nodes die
33:  End if
34:  Ifthen
35:   Full nodes die
36:  End if
37: End for
38: Fordo
39:  On the basis of nodes’ degree, CHs are selected
40:  If
then
41:   Ifthen
42:    
43:    Ifthen
44:     Perform CHs’ selection
45:     Send data packets
46:    End if
47:   End if
48:  End if
49: End for
50: Calculate content similarity of data packets using Equation (2)
51: Calculate content conflict using Equation (3)
52: Calculate path similarity using Equation (3)
53: Calculate final trust using Equation (3)
54: End for

In Equation (3), is the exponential function with , which is a positive number. The increases with the increase in conflicts in data packets’ content. Conflict is either true or false. The is the function that shows the path from where the data packet is sent. When the same paths are used for data packet transmission, then there is a high chance of a false data packet being transmitted. Therefore, finds independent paths. The message tampering rate is low when the data packet is sent over independent paths. After calculation of trust of each message, we come to know that these nodes send less trustworthy data packets and are considered as malicious. For performing secure routing and successfully sending all the packets to the destination, malicious nodes are detected and revoked from the network [35].

The identified limitations are mapped with their proposed solutions and validations in Table 2. The first limitation (L1) is inefficient CHs’ selection because CHs consume high energy and have minimum network lifetime. The limitation is solved through ETD-LEACH in which CHs are selected on the bases of energy, degree, and temperature. The selected CHs have less energy and high network lifetime. The second limitation (L2) is the presence of malicious nodes that is solved through the RMCV technique. Through this technique, 35% of malicious nodes are detected. Furthermore, in limitation three (L3), a single point of failure issue arises that is solved through decentralized blockchain. Limitation four (L4) is consuming high computational power while mining using the PoW consensus mechanism. This issue is solved through the PoA consensus mechanism that consumes less computational power. Limitation five (L5) is that the XOR hashing function is not secure for hashing of routing data. In the proposed model, SHA-256 is used for securely hashing the routing data while storing it in the blockchain.

4. Simulation Results and Discussions

4.1. Simulation Parameters

In this section, we evaluated the performance of the proposed system model by implementing and comparing the routing protocols and schemes. The WSN consists of 100 nodes that are randomly deployed in an area of , and each node has 1.5 J energy. The data packets are delivered to the destination through the source node. Here, it is to be noted that the data packet size is 4000 bits. The simulation parameters are provided in Table 3.

The routing protocols use 10,000 rounds. The ETD-LEACH is used for routing, and RMCV is used for the malicious nodes’ detection during routing. The blockchain is deployed on BS and CHs. The SHA-256 is used in the blockchain for data hashing.

4.2. Comparison of ETD-LEACH and ETH-LEACH

The ETD-LEACH protocol is used for clustering and routing. The ETD-LEACH performance is better than that of ETH-LEACH because ETD-LEACH has high energy as compared to ETH-LEACH. In ETH-LEACH, CHs are selected on the basis of energy threshold, which is equal to 0.85 J, whereas, in ETD-LEACH, CHs are selected on the bases of high degree, energy, and temperature-sensing value. Moreover, in ETH-LEACH, the energy threshold is fixed. In ETD-LEACH, the node that has high energy is selected as a CH. This is the reason that in ETH-LEACH, nodes’ energy dissipates early as compared to ETD-LEACH.

In Figure 4 and Table 4, it is seen that in ETD-LEACH, the first node dies at the 4000th round while all nodes die at the 9500th round, whereas, in ETH-LEACH, the first node dies at the 3000th round while all nodes die at the 7500th round. Therefore, network lifetime of ETD-LEACH is better than that of ETH-LEACH.

In Figure 5, it is seen that ETH-LEACH has less delay as compared to ETD-LEACH. The ETD-LEACH has high delay because of HT and ST. In ETD-LEACH, data is transmitted after meeting the thresholds due to which the delay occurs while sending data to the BS. In ETH-LEACH, data is frequently sent to the BS without meeting any thresholds; therefore, delay does not occur.

In the routing protocols, high energy is consumed when data is sensed and transmitted from nodes to CHs and CHs to BS. As shown in Figure 6 and Table 5, the ETD-LEACH consumes less energy as compared to ETH-LEACH because ETD-LEACH uses thresholds while transmitting the data. When sensed data meets the HT, then data is transmitted towards the CHs. In the next iteration, when new data is sensed, which is different from the saved sensed data and equal to or greater than ST, then it is transmitted, whereas, in ETH-LEACH, data packets are transmitted repeatedly. Therefore, nodes’ energy dissipates early, and they die rapidly.

In Figure 7, it is shown that the data packets are sent from CHs to BS. In ETD-LEACH, fewer data packets are sent to the BS as compared to ETH-LEACH. The data packet sending rate is less in ETD-LEACH because only that data is sent to the BS, which meets the thresholds. In ETH-LEACH, there is no threshold to send the sensed data towards the BS; therefore, the throughput rate is high.

4.3. Malicious Nodes’ Detection Using RMCV

Routing is performed by the ETD-LEACH protocol. We performed routing in which 89.9% of data packets are received at the destination while the remaining 10.1% of data packets are dropped that shows the presence of malicious nodes. These nodes are detected by the RMCV scheme. In this scheme, malicious nodes are detected by data packets’ content. Moreover, the scheme checks the trust of each data packet and marks the packet as either honest or fake. Afterwards, nodes that send the fake data packets are detected. Based on the nature of data packets, 35% of malicious nodes are detected. After detection, routing is performed again. 99.9% of data packets are received while 0.1% of data packets are dropped, as shown in Figure 8 and Table 6.

The RMCV-ETD-LEACH performs better than ETD-LEACH because nodes remain alive for a long period in the absence of malicious nodes. As given in Figure 9 and Table 7, in RMCV-ETD-LEACH, the last node is alive till the 4800th round while in ETD-LEACH, the last node is alive till the 3900th round. In ETD-LEACH, nodes die early as compared to RMCV-ETD-LEACH because in ETD-LEACH, nodes act maliciously by sending wrong data packets. As a result, correct data packets are to be resent. Moreover, high energy is consumed while sending accurate data packets again.

In Figure 10 and Table 8, ETD-LEACH consumes high energy as compared to RMCV-ETD-LEACH because of corrupted data packets’ delivery in ETD-LEACH. 31% of malicious nodes are present in the ETD-LEACH. These nodes are revoked from the network using RMCV-ETD-LEACH. It means that the number of nodes in RMCV-ETD-LEACH is less as compared to ETD-LEACH and that is why less energy is consumed.

4.4. SHA-256 in Blockchain

The blockchain is implemented on CHs and BS. In the blockchain, the PoA consensus mechanism is used because its transaction cost is less than that of PoW. In the PoW, miners first solve a complex mathematical puzzle and then add a new block to the blockchain, which incurs a high transaction cost. In the PoA, preselected miners have the authority to add new blocks without solving a complex mathematical puzzle. Therefore, PoA outperforms PoW in terms of transaction cost, as shown in Figure 11.

The routing data is stored on BS and is encrypted by SHA-256. The data hashes are stored in the blockchain. The SHA-256 is used because it is more secure than SHA-1 and has less execution time than SHA-512. In the SHA-1, 164 bits are used for hashing the data. Therefore, it is less secure because 164 bits can be tampered easily and quickly. In the SHA-512, 512 bits are used for hashing, which makes it more secure than SHA-1 and SHA-256. However, execution time is maximum in it because of 512-bit hashing. Therefore, SHA-256 is used for hashing because it is more secure than SHA-1, and its execution time is less than that of SHA-512, as shown in Figure 12.

4.5. Formal Security Analysis

The security analysis is performed on the proposed ETD-LEACH protocol. The attacks discussed below are induced in our proposed model. Attacks are evaluated using different performance metrics: PDR, dead nodes, energy consumption, and delay.

The DoS and MITM attacks are induced in ETD-LEACH. In the DoS, malicious nodes send extensive unnecessary data packets towards the destination and create heavy traffic. Therefore, due to heavy traffic during routing, large bandwidth is occupied that minimizes the network performance. The fake data packets are received at the destination that are not required. Therefore, under DoS, 82% of legitimate data packets are received at destination, and the remaining 18% of data packets are considered malicious. In the MITM attack, malicious nodes become part of the network that eavesdrop and tamper the data packets. In this attack, tampered data packets are sent towards destinations. In the MITM attack, PDR is 79% because in this attack, tampered data packets are received at the destination. This attack has lower PDR as compared to DoS because this attack steals the victim node’s IP address and also gateway IP address. Therefore, malicious nodes in the MITM attack easily get routing information and tamper the data packets without any limit. It is because malicious nodes get access to the data packets without the knowledge of the legitimate source and destination nodes. Furthermore, both attacks are prevented by the RMCV scheme that detects the malicious nodes present in the network. The scheme evaluates the trust of each data packet once the data packets are successfully received at the destination. Afterwards, malicious and legitimate data packets are detected and checked. Based on malicious and legitimate data packets, 35% of malicious nodes are detected. The RMCV scheme detects the malicious nodes because clusters are formed and the trust is calculated on the basis of trust of the malicious node. In the same way, malicious nodes are detected. The data required at destination is sent by maximum nodes; however, a minimum number of nodes send tampered data and they have low trust. Therefore, malicious nodes are detected through RMCV. After the malicious nodes’ detection, PDR is increased to 99%, which shows that all legitimate data packets are received by the destination, as shown in Figure 13 and Table 9.

Figure 14 and Table 10 show that RMCV-ETD-LEACH has high network lifetime because all nodes are dead after 3900 rounds, and all such nodes that behave maliciously are removed from the network. Therefore, only legitimate nodes perform routing, and the network consumes low energy, whereas, in the presence of DoS and MITM attacks, all nodes are dead at the 2300th and 1400th rounds, respectively. In the DoS attack, malicious nodes send a large number of data packets towards the destination node that consume a large amount of resources. As a result, the energy is drained, and the nodes die early. Moreover, in the MITM attack, all nodes die early as compared to the DoS attack. In this attack, malicious nodes act as legitimate nodes, and legal nodes perform routing using malicious nodes as intermediary nodes. Upon receiving the data packets, the malicious nodes behave maliciously and corrupt the data packets before forwarding them to the destination. All the received data packets are tampered; therefore, destination nodes again send the request for the legitimate data packets. Consequently, nodes’ energy depletes, and they die at the 1400th round.

The ETD-LEACH performance depends on the energy consumed by the nodes. As shown in Figure 15, the MITM attack consumes high energy as compared to the DoS attack and the proposed scheme RMCV-ETD-LEACH. The legitimate nodes perform routing for the sake of sending legitimate data packets. Furthermore, in the DoS attack, malicious nodes target a legitimate node and send heavy traffic that makes the legitimate node busy, and it does not receive legitimate data packets. After receiving a large number of malicious data packets, its energy is depleted. Moreover, in RMCV-ETD-LEACH, malicious nodes are not part of the network, and only the legitimate nodes are part of the network. They do not perform any malicious activity and consume less energy. Consequently, the RMCV-ETD-LEACH network performance is better than that of both DoS-ETD-LEACH and MITM-ETD-LEACH.

DoS-ETD-LEACH has high delay as compared to both MITM-ETD-LEACH and RMCV-ETD-LEACH, as shown in Figure 16. In the DoS attack, the destination node receives a large number of data packets resulting in high congestion. The legitimate data packets have to wait for routing that increases the delay. The MITM attack has less delay because the delay occurs only when the data packets are being tampered by the malicious nodes. These corrupted data packets are then sent to the destination node. Furthermore, in RMCV-ETD-LEACH, delay is the least, and it occurs only when checking the presence of malicious nodes in the routing path. (1)Impersonation attack: the registration of nodes at the blockchain secures the network against this attack. Moreover, it is ensured that malicious node cannot make a duplicate ID of a legitimate node(2)Spoofing attack: the malicious node acts as a legitimate node using its ID. This attack is not possible because it is difficult to steal a legitimate ID from the blockchain

5. Smart Contract Analysis

The blockchain is used around the globe for data security. However, malicious entities perform attacks on the smart contract to make it vulnerable and to tamper the data. Therefore, the security analysis of the proposed smart contract through which CHs are registered and authorized, and routing data is stored, is performed. Furthermore, the registration of those CHs is canceled from the smart contracts that are detected as malicious by the RMCV scheme. The security analysis is performed through the Oyente tool that detects the attacks, which is possible on the smart contract, as shown in Figure 17. The attacks are discussed as follows [35].

5.1. Integer Underflow and Overflow

In the smart contract, the maximum size of the integer is 256 bits. The error arises when an attacker changes the integer value by subceeding and exceeding the lower and upper boundaries of the smart contract.

5.2. Parity Multisig Bug 2

Multiple fake accounts are created, and transactions are performed by an attacker in this attack. The smart contract stops working when multiple fake accounts are detected. From Figure 17, it is inferred that the proposed smart contract is not affected by this attack.

5.3. Callstack Depth Attack Vulnerability

The call function depth limit is taken to be 1023 frames. If the limit exceeds 1024 frames, the execution of new instructions fails. The attacker intentionally makes the frames to exceed, so the execution of new information fails. In the proposed smart contract, this attack is not possible because only authorized nodes call the functions.

5.4. Transaction Ordering Dependence

The functions involved in the smart contract consumes gas during execution. Malicious nodes manipulate the gas price to execute transactions maliciously. In this smart contract, this attack is not possible because there is no transaction-ordering function.

5.5. Timestamp Dependency

In this attack, the attacker changes the timestamp. When the mining time of the transaction is changed from a block, then the mining time of all transactions is changed. In our smart contract, this attack is not possible because there is no timestamp dependency function.

5.6. Reentrancy Vulnerability

The attacker calls the same function again and again that interrupts its execution. In the proposed smart contract, this attack is not possible because only authorized nodes are allowed to call the functions.

6. Conclusion

In this paper, we focus on efficient clustering using ETD-LEACH that consumes less energy and has better network lifetime. Moreover, blockchain is deployed on the WSNs for achieving security and SHA-256 is used for secure hashing. Furthermore, RMCV is used to find the trustworthiness of data packets. Based on the trustworthiness, malicious nodes are detected during routing. The efficiency of the proposed model is evaluated through simulations. The ETD-LEACH network lifetime is found to be better than that of ETH-LEACH. Moreover, in ETD-LEACH, energy consumption is less than ETH-LEACH. Moreover, the PoA transaction cost is less than that of PoW, and the SHA-256 execution time is less than that of SHA-512. The PDR is calculated to be 89.9% and 99.9% with and without the malicious nodes, respectively. Furthermore, the proposed model’s resilience is tested by inducing DoS and MITM attacks and performing security analysis. Smart contract analysis is also performed using the Oyente tool, which shows the robustness of the proposed smart contract.

Data Availability

No dataset is used in this article.

Conflicts of Interest

The authors declare that they have no conflicts of interest.