Selfish node Detection Based on Fuzzy Logic and Harris Hawks Optimization Algorithm in IoT Networks

*e Internet of things describes a network of physical things for example, “things” that are connected with the sensors, software, and other technologies to connect and exchange data with other devices and systems via the Internet. In this type of network, the nodes communicate with each other because of the low radio range by step by step with the help of each other until they reach their destination, but there are nodes in the network that do not cooperate with other nodes in the network, which are called “selfish nodes”. In this paper, we try to detect selfish nodes based on a hybrid approach to increase the performance of our network. *e proposed method consists of three stages: in the first stage, with the help of the Harris hawk operation, we try to set up the cluster and select head cluster; in the second stage, the sink investigates the existence or nonexistence of selfish nodes in the network by considering the general parameters of the network; and in the event of a selfish node in the network, it informs the head clusters to check the cluster members and recognize the selfish node. In the third stage, with the help of fuzzy logic, the amount of reputation of each of the nodes has been realized, and finally, with the help of fusion of head clusters and fuzzy logic, each node is decided to be cooperate or selfish nodes, and in case of head clusters and fuzzy logic in some cases, the opportunity node will be reestablished to participate in network activities otherwise the node will be isolated. *e results show that the accuracy of selfish node detection has increased by an average of 12% and the false positive rate is 8% in comparison to existing methods.


Introduction
With the influence of new technologies, the coverage of the networks is increased, and the number of intelligent things connected to the network have also increased, and a new pattern has been created with the name of the Internet of things [1][2][3]. e Internet of things has evolved versions of wireless technologies, microelectromechanical systems (MEMS) that provide wireless connectivity of physical and virtual things. e Internet of things consists of connected smart mechanical devices to each other, computational devices, digital machines, and things that are connected to the cloud data center [4][5][6]. Internet of things devices are fixed and mobile things in providing simple and sophisticated services for cloud environments and macro data applications [7,8].
e Internet of things is a dynamic global network structure that has its capabilities to configuration and is based on standard communication protocols and interoperability and uses smart interfaces that are integrated into the data network; the Internet of things has been made up of many technologies which can be referred to as range intelligence, Internet Protocol, Communication Technologies (WIFI, Bluetooth, and Zig bee), and RFID embedded devices and applications [9,10]. With recent advancements in Internet of things technology, things have more influence on our daily lives and has begun offering new, interesting, and helpful services [11,12]. e Internet of things has created hope for creating new opportunities in various industries such as health care, e-commerce, power plant (green energy), manufacturing industries, city/organization/smart houses, as well as personal applications. In general, the main purpose of IoT is to increase the quality of human life [13].
In these networks, nodes use finite energy sources, so the management of energy consumption in these networks is one of the most important issues [14,15]. Owing to the limited range of things in these networks, the data are carried out as step by step. Nodes having a noninvolvement in data transmission are a several steps to mitigate the performance of the network; these are called the selfish nodes [16]. Lack of a propellant depends on the interest of selfish nodes because they do not use energy to send data packets to other nodes. e selfish nodes are expecting cooperation from other nodes to send their data packets to the destination, but they are not willing to cooperate with other nodes [17].
Because of the lack of communication infrastructure, if a node in this network is willing to cooperate and transmit its neighbors' data packets to other neighbors to reach the final destination, the data packets will be lost and the network will face the problem [18]. ese nodes do not perform any assistance to save energy consumption and communicate with other nodes in the routing and propellant operations, thus cutting off some nodes with the network [19]. e selfish nodes use the network facilities for their personal uses and do not contribute any assistance to reducing energy consumption, thus increasing network lifetime, as well as maintaining the relevance of other nodes [20]. e proposed method is used to reduce the effects of selfish nodes in a multistage method; in the proposed method, we will have three stages: the first stage includes the establishment and setting up the cluster and cluster head selection, which will be done with the help of the Harris Hawks optimization; in the second stage, head clusters communicate their opinions to members of their cluster. In the third stage, the fuzzy logic is used to achieve the reputation of each node and ultimately to help integrate the opinions of head clusters and fuzzy logic on the partner or being selfish of each node to make decision. If the opinion of head clusters and fuzzy logic is in conflict in some cases, the opportunity node will be reestablished to participate in network activities; otherwise, the node will be isolated. Finally, the main task of this paper can be summarized as follows: We propose a Harris Hawks optimization and fuzzy logic based on strategy to establish cooperation for network nodes of Internet of things. To encounter the challenges of noncooperative behaviors in the network of Internet of things, we introduce and use an evocative strategy. e main idea is that, with the help of fuzzy logic, we obtain the reputation of each of the nodes, as well as the rest of the nodes analyzed by the sync of behavior in the network and it requests the cluster head for recognition of selfish nodes in the face of selfish behavior in the network. en, the ideas of the fuzzy system and clusters are integrated, which makes the proposed method strong and better in decisionmaking on each node. Using this strategy, we demonstrate that nodes are encouraged to do cooperation because any deviation from the level of uncertainty of the data packet results in a low cooperation or even noncooperation step that reduces the reputation of nodes, which eventually quit the network activity and gives them a chance again for low cooperation. We provide theoretical analysis of the mixed method, and we model the proposed method as a reputation based method and estimate the level of power of cooperation with a reputation by the fuzzy system. We also show that the energy consumption of this method is less than the other proposed methods. It is true that the dynamics of nodes in networks such as VANETs can cause problems, but in the Internet of ings where nodes are intended for sensors, this is not the case, even in cases where things are sufficiently mobile by reforming clusters with the help of new nodes, our method will be able to detect selfish nodes with a slight delay and it does not decrease network performance by the dynamicity of the network.
In the first section, the networks of Internet of things and the selfish nodes are introduced. Next, in the second section, algorithms for discovering selfish nodes are presented and then compared with each other. In Section 3, the proposed method will be presented with the help of a hybrid algorithm to eliminate these nodes and will be simulated in Section 4 of the proposed method where their results are evaluated, and finally, the conclusion and future work are presented in Section 5.

Related Work
e detection mechanisms of selfish nodes are divided into five categories [21]: the reputation-based approach that in this approach is the behavior of nodes along with feedback and some validity that node has been credited with high reliability as a trusted node [22]. e credit-based approach to which the nodes that have data to send will pay for it and sell them to the business of the data packets and then sell it at a higher price [23]. e method based on the punishment and persuasion of each network node monitors directly or indirectly on how other nodes cooperate and thus use the observations obtained to determine the other nodes' reputation [24]. e authentication-based methods that ensure that sending a packet by a node will be authenticated using the message [25]. e method based on the game theory is to send or resend between nodes as a model game, which can be between two-or as one-to-several, that is, defined for each game of utility function so that each node tries to obtain the maximum value from the utility function [17,26,27]. e following algorithms are stated to deal with the selfish nodes recently.
In the Nobahari method, a multiphase mechanism based on the game theory and reputation for excitation of noncooperative nodes has been designed for collaboration on the Internet of things. In the first phase, nodes are grouped into clusters with head clusters and at least one base station for data collection. en, in the second phase (the multigame phase and packet transmission phase), they perform when the data packet is advanced a multiplayer game by itself or others.
If the neighboring node run the data packets, the node optimizes the likelihood of the neighbor node selection for the next period. In the third phase (the discovery of the noncooperative node and update), nodes can choose their strategy while driving data packing. Nodes classified other nodes by their function and updated the reputation table [28].
In the other method, Nobahari et al. has been proposed an algorithm based on credit detection of being selfish which is used for better control and monitoring of nodes from clustering. Clusters are discovered by controlling the general characteristics of the network such as delay, the number of sent packets, and the number of delivered packets, throughput, and traffic network in existence of the selfish node. e credits are kept in a table where nodes with low reputation are considered selfish. ree guard nodes are selected from within the suspicious node's neighbors to monitor the behavior of the suspicious node. e guard nodes will send their attention to the cluster head based on the selfishness or cooperation of the node. e cluster head decides the majority of the suspicious node by voting. In case of selfishness diagnosis, it informs the other nodes of the cluster to not send data to the node from the network nodes [29].
In the method of Babaei et al, removing the nodes from the network by seeing the first suspect behavior significantly reduces the number of active nodes and often reduces the number of regular network missions. While these disorders are likely to occur over time, solve and the node may be a partner node in the future. e three variables, the number of steps, the remaining energy, and the history of cooperation are considered as input to the fuzzy logic process, and the amount of cooperation of the nodes is considered as the output of the proposed system. e node is selected with a high trust factor to send data. e amount of cooperation of nodes is as binary digit, where the node state is determined between 0 and 1 [30].
TEEM is a trust-based approach to detect malicious and selfish nodes in mobile ad hoc networks and wireless sensor networks, which is usually dependent on the watchdog approach, although such monitoring devices have more energy consumption [31]. is method is based on the time division of the monitoring strategy to achieve high-security levels.
is method includes both the trust and the link duration between the true cooperation pairs relative to the diving period of the monitoring, which is completely distributed by switching Hello messages between the nodes. In TEEM, network nodes are commonly monitored from the beginning. After that, the task of network monitoring will be distributed among the trusting pairs. Hence, they can store their energy power over other nodes.
Acknowledgment-based methods guarantee that sending a packet through a node will be performed using an authentication message. In these methods, a node sends a confirmation message to the source when it requires to forward the packet. If a source node does not receive a confirmation message, it is considered unreasonable behavior. In confirmation-based methods, they guarantee that sending a packet through a node will be based on a confirmation message. In these methods, a node sends a confirmation message to the source when it wants to forward the packet. If a source node does not receive a confirmation message, it is considered unreasonable behavior. Liu and et al have proposed the 2ACK method. Mahdi Bounouni et al. proposed an approach consists of four models [32]. e monitoring model is responsible for controlling the sending of routing packets and data packets using the acknowledgment packet. e reputation model evaluates each nodes' neighbors.
e stimulator model manages and updates nodes' credit accounts, and malicious and selfish nodes are punished by the isolator model.
In the NACK method, the destination node responds to a data packet sent by the origin, with a Nack packet. Each node has two lists: one for the packets sent and the other for the packets re-sent. As soon as the node is sending a data packet, it added the packet identifier to the list of sent data packets. As soon as the packet receives a Nack packet for the data packet, the associated data packet identifier is omitted from the submitted data packet list. e source node is compared with receiving the Nack message of the two paths in the Nack packet. In the absence of a change in the paths, the source node concludes that there is probably no malicious node in the path. In the presence of two different paths, the node in the source destination path is isolated as the path is different from the destination to the source path. e node is represented as the node of the bad behavior by the source node. e number of times a node is measured as a node is likely to be more than the threshold mark as the bad behavior node [33].
In this method (AISDTR), each node is analogous to the dendritic cell (DC) in the human immune system (HIS). As in the body, harmful cells are detected by pathogen-associated molecular pattern (PAMP) in this algorithm, nodes have a list of their well-behaved neighbors. e node will send its data source to its well-behaved neighbor node and then adds a confirmation message to the node's well-behaved frequency. With the receipt of the confirmation message, the source node perceives the bad behavior of the selfish node, and the data are transmitted from the other direction. Selfishness of a node is notified to other nodes so that the data will not be sent to the node [34][35][36].
e DSSAM method is proposed to identify the selfish and malicious nodes. is method uses digital signatures to establish node and packet authentication as well as a secure authentication message. A two-layered approach is used to secure the security of the authentication message. Additional bits and sequence numbers are used in the first layer for fixed transmission time and packets sequences. e next layer is the digital signature, where the seven bits are reserved, which are intended for maintaining sequence numbers. Data packets and confirmation packets are digitally signed by the source node and the destination node. RSA encryption is used in the proposed method [37][38][39].

Proposed Method
e selfish nodes are nodes that send their data but avoid sending other data nodes.
e existence of such nodes paralyzes the network, hampering the natural flow of the Security and Communication Networks network and reduces network performance. To solve this problem, it tries to motivate the node to reduce the number of selfish nodes to work together. In the proposed method we will have three general phases. e phase of the setup and establishment phase (cluster formation and cluster head selection), which we will do with the help of the Harris Hawks optimization algorithm, is the second phase where the head clusters of each expressed their opinions about their cluster members, and the third phase is the use of fuzzy logic to achieve the reputation of each of the nodes, and at the end, the combination of the opinions decides of clusters and fuzzy logic on the being partner or selfishness of each node. In case of head clusters and fuzzy logic in some contrastive cases, the opportunity node will be reestablished to participate in network activities; otherwise, the node will be isolated.

Establishment and Clustering Phase.
Each metaheuristic algorithm has its own advantages and disadvantages and is used in different usage; we can get the best results when they are used in their intended usage. e Harris Hawks optimization (HHO) algorithm is one of the best clustering algorithms that authors decided to use it for clustering and determining the cluster heads in each cluster in the proposed method. e method can select the best node as cluster head and cluster member' nodes. e cluster head selection phase with the help of the HHO algorithm is that the HHO selects a group of sensors that are actually the network sensors. e location of each hawk with an identifier starts randomly from 1 to n (n is the total number of nodes in the network).
in this equation i represent each of the hawks, and H i.d is the location of each hawk, which is 1 ≤ d ≤ n, and m is the number of head clusters.
In the first phase, there are the n number of nodes given in the network. Each node has identified all of its neighboring nodes that have been able to send messages by sending the hello message in public and Provides information on its own status and its neighbors in a table consisting of four fields as shown in Figure 1 in its data base.
Further details of each of these fields will be investigated. Node id field: this field is 8 bits and is used to store node identities.
Energy: One of the important parameters in the field of energy is because it affects network lifetime and network survival, so we need to store the remaining energy of each node. e node is chosen as the cluster head must have more energy since it is tasked with gathering data and making calculations.
In this regard, E elec is the necessary energy to activate the electronic circuits; ε fs and ε amp , respectively, are the energies needed to amplify the signals sent to convey a bit in the open space model and multipath model. d is the distance between the sender and receiver node, and d 0 is also the threshold value of the distance obtained from equation (2), After obtaining the value of all these parameters, the value of E TX (l.d) can be calculated using equation (1).
Equation (3) represents the amount of energy required to receive l bit of data, l is the number of data packets, and E elec is the amount of energy required to amplify a bit of data.
Density: in a real network, nodes in different parts are scattered across different parts; a node chosen as a cluster head must have a lot of congestion and a large number of neighbors.
Centrality: sometimes, the density of a node is high, but the nodes around that node are only listed on one side of the node. When nodes are in the central part of the region, they play an important role in the network structure as the central nodes play an important role in the data in the next stage. erefore, the cluster head is preferred to increase the load balance, the cluster head in the central neighborhood.
e average distance of the nodes: we first compute the two distances of each node from the other by the equation (4) and then compute the mean distance by equation (5).
Distance of nodes n .
Distance to sink: in most networks, the network lifetime is achieved with low energy consumption in the head clusters. It has a direct relationship with the distance between the cluster head and the sink. By observing the fact that the close proximity of the data stores more energy to transmit data from the cluster head to the sink. Owing to this fact, close ties are more likely to be selected as head clusters, compared to other nodes. After calculating the values of each parameter, we normalize the values with equation (6); after generating unit values, we are placed in the fitness function equation.
After the identification phase of the neighboring network nodes, it is divided into head clusters. After saving each of the fields, we take action according to the values registered for each node to select head clusters. Each node has higher energy, higher density, better centrality, lower bound distance, distance to sink, considers with respect to the fitness function equation (7) as the cluster node.
In equation (1), E n is the energy of each node in joules, D n is the Density of the node, which indicates the number of nodes near the target node, C n is the centrality of the node, which considers the coordinates of the node, the node in the central neighborhood, Dis n is the distance between nodes, and Diss n is distance between the node and the sink.
In Equation (8), a coefficient is selected for each parameter, and the value of factors is selected based on the importance of each weighting factor parameter that the sum of the coefficients is equal to one.

Selfish Node Detection by the Cluster Head Phase.
is phase is based on the results and analysis of the influence of selfish nodes on the general characteristics of the network. e sink in each cluster has the task of monitoring the cluster function to determine whether it occurs in the relevant cluster of selfish behavior. Note that this monitoring is carried out on the performance of network clusters within each network operation by the sink. In this study, only features of the network in the cluster will be examined, which will lead to the existence of a selfish node in the cluster. If the sink is in the distance all the way to the existence of the selfish node in the suspicious cluster, the procedure of detecting the selfish node will be called. e diagnosis procedure of the existence of selfish behavior in the cluster is costly because the sink in each cluster should monitor all its members through the parameters required to distinguish the selfish node and examine their behavior during the period required by the eavesdropping.
Selfish behaviors in parameters such as network throughput, network load, and the number of packets sent/ received, packet delay, and other items have an impact. According to the different involved factors which have various units, we need to normalize these metrics. In this phase, the values of the general characteristics of the proposed technique are proposed for the discovery of selfish behavior which represents a combination of these properties for the calculation of the general parameter using equation (9).
Equation (9) presents the subtitle of measurements and normal subtitles for network behavior in a nonselfish mode and normal mode. e delay parameter estimates mean packet delay with a microsecond unit, load network traffic with (byte/s) unit the total number of data packets received, and the total number of data packets sent, and throughput the average power rate of the network is calculated using the (byte/s) unit. e delay factor, network load, and the total number of data packets sent is as negative communication with the value of examining selfishness. e amount of weight factor must be selected based on the importance of each factor; the sum of these factors is equal to one according to the equation (10). In other words, the factor that differs from ordinary behavior must be given more to strengthen the examining selfishness composition and thus will be found to be selfish behavior. e sink is tasked with calculating examining selfishness, which indicates the cluster in the face of the selfish behavior and the existence of the selfish Node's ID Node's energy Density Centrality Average distance of nodes Distance to sink Security and Communication Networks node in the network (i.e., the value of examining selfishness is higher than the threshold θ value) to the cluster to run the detection procedure of the selfish node in the cluster and identify the selfish node. In the selfish cluster detection procedure in each cluster, the local characteristics are calculated by clusters for each cluster member of the selfishness value. Since a node acts as selfish, the number of packets sent by itself is greater compared to the number of packets sent by other nodes, the node prefers to send only its own packets and does not send and perform to other packets of nodes in a selfish manner. Either randomly sending some packets or sending down the packet by delay, so the head clusters of each cluster are discovered by monitoring the performance of cluster members and calculating the relationship of equation (11) in selfish nodes.
To calculate the existence of selfish behavior in the network, various parameters such as the average packet delay, network traffic, network throughput, and so on are considered, which include other parameters as well, to detect the selfish node in each cluster; the study of two parameters, average packet delay and the packet delivery rate, has provided satisfactory results in the detection of the selfish node. In addition, we can say that the average delay for all packet in all nodes in the network show hidden transmission propagation time and network delay as average delay.
In equation (11), the value of the coefficients, which are weighting factors, to combine the effect of the two packets delay and the number of packets sent by node i is the value of delay with the negative relation the need for the interaction of one of them with the other.in addition, to reflect the real effect of mutual interaction, the first two values are normalized. D is the mean delay packet and micro second unit and S is the total sent data packets. Subtitle (S totalpi ) mean total data packets except the data packet of node i and subtitle (S totalpi−i ) mean total data packets of node i except i. In other word, (D totalpi ) is the total delay in sent data packets of node i with reversed affection and (D totalpi−i ) is as the amount of sent data packets except the packet itself of node i. Although weight factors indicate the importance of each of these relationships, the number of packets sent from neighbors is more important; therefore, (ω < δ) is assumed, But the sum of these two weighting factors according to Equation (12) is equal to one. Figure 2 shows the Simi-code related to the diagnosis of selfish behavior in the cluster and the diagnosis of the selfish node in each cluster. In the following, see the Simi-code and flowchart of first phase and second phase of proposed algorithm.
In the proposed method of the Simi-code, HHO first selects a group of sensors which are based on the network sensors. e number of nodes n is the number of sensors starting to send and receive a Hello message to identify their neighbors. e specification of each neighbor is then recorded in the other nodes ' database, these specifications (according to line 5) include node identifier, energy, density, centrality, average distance of nodes, the distance to sink, after obtaining the values of each specification we normalize them (line 6), and then in the fitness function equation (line 7), and among them, we choose the highest values as head clusters.
e sink begins to explore the existence of the selfish node in the network. In this way, values D, L, S, T, and R of examining selfishness are kept constantly checking if the values of threshold θ obtained are higher than those of the head clusters. To begin the discovery of selfish nodes in clusters, the clusters begin to compute values of delay, sent packets, and selfishness (line 11) to discover the selfish node.
We are going to have the flowchart of the first and second phases of the proposed model in Figure 3. e top procedure initially forms the initial population of the HHO; then each of the nodes sends a hello message to each other to identify their neighbors In its database, the information of each of their neighbors contains the following: energy -density -centrality -the distance between the nodes -the distance to the sink. en the obtained values are used to calculate the fitness function values of each node, and the best is chosen as the cluster head in each cluster, in the continuation of the workflow so that the sink begins to examine the network to detect the existence of a selfish node, hence calculating parameters of load, throughput, sent packets, received packets, delay, and obtained examining selfishness amount. If the obtained value is higher than the threshold Ѳ value, then it takes place in the self-serving behavior network. In this case, the sink will tell clusters to check their cluster head for the discovery of selfish nodes and the cluster value of delay which each node travels to packets of other nodes in time and also calculate the number of packets sent to other nodes and obtain the amount selfishness in packets.

e ird Phase (Determining the Reputation of Each
Node with the Help of Fuzzy Logic). We need at least four key parameters to determine the reputation of nodes because determining the selfishness of nodes and isolating the nodes is not only by specifying one or two parameters in the proposed method; we use four parameters: number of omitted packets, mean delay, residual energy, and cooperation history as a fuzzy system input to consider the effect of more parameters and more efficient parameters in detecting selfish nodes. In Figure 4, the schematic diagram of the fuzzy system is plotted against four input parameters and ultimately determines the system output that identifies the reputation of each node.
In fuzzy logic, by determining the appropriate input parameters and in sufficient numbers, as well as the number of levels for membership functions, it can provide us with an accurate output. e cluster-head opinion is another factor influencing on correct judgment about the nodes statues; the cluster-head opinion will be combined by the fuzzy logic Algorithm. Stage 1,2 1. Initialize population of the Harris hawks (i=1 to n) 2. For i=1 to n do 3. Send Hello message 4. Specify the neighbor nodes 5. Specify the properties of each node (Node's ID, Energy, Density-Centrality-Distance between nodes -Distance to the sink) 6. Normalize each parameter 7. Calculate Fitness function for each node 8. Choose the node that have best Fitness function as cluster heads 9. Calculating D, L, S, T, R, Examining selfishness by Sink 10. If Examining selfishness >Ѳ 11. Calculating D, S, selfishness by cluster heads  Security and Communication Networks system opinion, and the simulation result has shown high quality in detection accuracy and other metrics.

e Normalization Process of Numbers.
In the decisionmaking process to facilitate the selection of an appropriate option among existing solutions, the real numbers are first converted into fuzzy terms. In this case, the user will have a clearer understanding of the level of an attribute relative to the extent of its domain. For example, if the number of missed packets can be expressed as a real number, the user cannot judge either too much or lack of it, unless the attribute domain can observe the number of missing packets and then comment on it. However, the expression of the attributes in the form of fuzzy terms helps the user approximate the extent of its value regardless of the values of the variable in domain. e simplest method for converting real numbers into fuzzy terms is to use expert opinions, but it is not always possible because the expert is not always available. Another method of using membership functions is functions that are trapezoidal and triangular. e amplitude of the input variable is divided into triangular intervals, and each interval represents an expression quantity; the true value of the input variable is converted into a linguistic term, which has the closest distance with the corresponding range. In some of the past work, different fuzzy parts have been used for different features; different features may differ from different types (continuous, ordinal, and relative). e four input parameters include the number of missing packets, the mean of delay, remained energy, cooperation history. We use the Equation (6) to normalize the numbers, after normalization of all numbers in the range [0-1].
We apply the membership functions of four input parameters, considering three levels for each one. For the number of omitted packets, three levels (high, medium, low) of delay average parameters and the third parameter, where the remaining energy of the node has three levels (high, medium, low) ,and the last parameter which defines cooperation history has three levels (strong, medium, weak), whose diagrams are as follows: in the form of membership functions, if we are to compute the distance between the membership functions centers, we use equation (13) and n represents the number of membership functions.
e number of membership functions per one of the fuzzy system inputs is 3, so the distance between the membership functions centers is calculated as In Figures 5 and 6, we present three membership functions related to the four fuzzy input parameters (average latency, the number of discarded packets, residual energy, cooperation history) and also the distance between the membership functions which is calculated with the help of equation (14) is equal to 0.5.

Draw the Fuzzy Rules Base.
We multiply the number of membership functions of all inputs, that is, the number of membership functions the numbers of removed packets * the number of membership functions in average of delays * the number of remaining energy membership functions * the number of functions of the cooperation history 3 * 3 * 3 * 3 � 81.
To map the fuzzy rules base 3 * 3 * 3 * 3 * 3, we write different scenarios of each input parameters. is table of rules indicates how much the reputation of each node acts as a self-serving which must be isolated or cooperating. e degree of selfishness of each node is determined by its behavior, the amount of each of the variables, like delay in sending packets, the number of dropped packets, the residual energy, and the history of cooperation determine the degree of cooperation or non-cooperation of the nodes. Table 1, which is the fuzzy rules table, shows that 81 different modes of nodes parameters conditions indicate that VVVH is the best node (associated node) in the network.
us, in the last row, the VVVL node is selfish node in the network, which the cluster head node will decide. e purpose of this system is to identify the reputation of each node. R output variable defines the degree of selfishness of each node and allocates different values that represent different modes of reputation of each node according to Table 2.
After gaining the reputation of each node by fuzzy system (Phase III) and gathering comments from the second  phase (nodes that call the cluster head as selfish) to decide to end each node the results of the fuzzy system and the ideas of cluster heads together as shown in Table 3.
In the following, we observed the Simi code and flowchart of the proposed method, which are presented in Figures 7 and 8, respectively.
We observed the Simi code and flowchart of the proposed method, which are presented in Figures 7 and 8, respectively. e third phase of the proposed method first (line 1) specifies the input parameters and the values from these parameters are determined for each node, and then these values are normalized in [ 1,0]. In the following (line 7) for each input parameters, the number of levels (number of membership functions) and distance between the levels are calculated and then the membership functions are plotted for each input parameter (line 10). We calculate the number of membership functions and show in the fuzzy rules base table (line 13). e cluster head theory and fuzzy system are then combined into each other and isolate in the face of the full selfishness of the node (line 16), and in the face of low selfishness, the opportunity node will be reestablished. e procedure in Figure 7 at the beginning of the round identifies four input parameters and then the values of each parameter are normalized in [1,0]. In the next step, the membership functions for each input parameter are determined and then the membership functions for each inputs are plotted with respect to the number of membership functions; then the number of rules specified and each of the rules is represented in the fuzzy rules base and the degree of reputation of each state becomes known. e cluster is then combined with each node and each state of the fuzzy system in the case of nodes together, and in the case of full selfishness detection, the node will be isolated and will continue to operate in the form of less selfishness, it will give a new chance and if it works, the node continues to operate.

Evaluations and Simulation Results
A network of Internet of things is distributed in an environment of 1000 * 1000 square meters that are uniform and random, and nodes for 4 types of networks and Internet nodes are different things with different numbers and parameters in the environment. In the simulation performed at the center of all four types of network types, a data collection station is located and the network of Internet of things is considered to include nonmobility things and with a limited energy source similar to that of wireless sensor networks with four different types of nodes. All of these networks have wireless communications. Note that each of these different networks has a different simulation model. erefore, in the first place, we will have a clustering by specifying head clusters in accordance with the HHO clustering algorithm [22] as shown in Figure 9.
To perform simulation at the center of each type of network, four data collection stations are considered. In different regions, the base station is fixed and the positions are considered as (250-250), (750-750), (250-750), and (750-250). Simulation has been repeated over 100 iterations, and the initial energy for network nodes is equal to 0.5, 10, 1, 150 J, and 200, 100, 150, 20 and with radio range of 80, 70, 90, 70 m, respectively. e energy consumption model and the type of nodes are similar. Table 4 shows the parameters used in this simulation.

Evaluating the Performance of the Proposed Algorithm.
To investigate the effectiveness of the proposed algorithm, the results obtained from the simulation, which are implemented in an operating system of 8.1 with Intel(R) core (TM) i7 with speeds of 4.2 GHz and internal memory 16 GB, were implemented in MATLAB 2018 software background.  Having maximum reputation (100% cooperative node) Very high (VH) Having above reputation (100% cooperative node) High (H) Having high reputation (100% cooperative node) Medium (M) Having average reputation (maybe cooperative node, need to be checked) Low (L) Having low reputation (having selfish behavior) Very low (VL) Having very low reputation (having selfish behavior) Very very low (VVL) Having little reputation (having selfish behavior) e effectiveness of the proposed strategy is evaluated and its efficiency performance is evaluated. For this purpose, accuracy parameters of nonassociated nodes detection, the positive warning rate, successful delivery rate, and mean of end-to-end delay algorithms as acknowledgment-based [32], TEEM [31], and game theory based [28] are compared with the proposed method. e Fuzzy system is designed, and each metric is described in detail with the corresponding diagram.

Assessment of the Designed Fuzzy System.
e fuzzy system is designed with four inputs and an output. e number of missing data packets, the average packet delay, and the remaining energy of the nodes and the association history of the nodes are in forwarding packets. e output of the system shows the degree and level of interoperability within the network, which are stored in cluster head nodes. e proposed protocol can determine the highest level of cooperation of nodes and their lowest cooperation level. e input and output of the fuzzy system and its maximum and minimum are shown in Figure 10 and Table 5, respectively.
Doing Fuzzy on inputs and outputs: the triangular membership functions are used to make fuzzy the inputs. For different inputs, the fuzzy variable and its input range are shown in Table 5. e four input parameters include the number of missing packets, the mean of delay, remained energy, and cooperation history. In other words, the amount of linguistic variables can range from that domain. e number of discarded packets by each node as a linguistic variable with the range of ? (Number of dropped packets) T, U [800, 1] domain is 1 to 800 packets. e range is divided into three levels. Each variable in the number of dropped (T) packet is described by a fuzzy set, such as U � [800, 1]. erefore, each level has a fine function that represents the degree of dependency of each value to this level. e optimization of these algorithms is often done through test and error method to achieve the desired performance of the designed fuzzy system, but there is only one output, the level of collaboration of the node, and, like the inputs, the membership function is assigned as a triangular function. In Figure 11 membership functions of the inputs of the fuzzy system are represented. e fuzzy inference method in MATLAB is used to determine the level of cooperation of network nodes and so-called MAMDANI (max-min) method is applied. e fuzzy rules are represented in the optimal performance of the system proportional to the inputs and output of the system in Figure 12. e output, which is node collaboration level for different inputs, for example, remained energy level, removed packets, and cooperation node history ( Figure 13).

12
Security and Communication Networks

Detection Accurate (DA) of the Selfish Node.
Detection Accurate (DA) of the selfish node represents the number of normal nodes detected to the total selfish and associate nodes in the network. us, if TP represents the number of discovered normal nodes, FN indicates the number of selfish nodes found incorrectly as associated. Equation (15) shows the accuracy of diagnosing the selfish node.
To investigate the important parameter of the discovery of the selfish node in the Internet network of things, it is assumed at the beginning of the simulation of 10% of the total selfish network nodes, while the rate of selfish nodes gradually increased by 15%, 20%, . . . to 40%. However, it is noted that in the real world, the nodes tend to maintain energy and avoid sending packets to other nodes on the initial energy level, and they will be as selfish node.
Accuracy is shown in Figure 14 clearly by increasing the accuracy of the discovery of the selfish node. e proposed method is performed by increasing the percentage of selfish nodes in the network number of more games in order to update the reputation of each node during the games and crossing the different nodes. For this reason, when only 10% of the network nodes are selfish nodes, there is less game to prevent greater energy loss, and the popularity associated with the network nodes is not sufficient and only  Figure 10: Fuzzy system model with inputs and outputs. 92% of selfish nodes have been identified, thus increasing the percentage of selfish nodes in the network and increasing the number of games, the reputation of nodes updates and recognition is performed correctly, and even to 100% selfish nodes will be identifiable; But the increase in the number of selfish nodes will be subject to many games that will not be reasonable with respect to energy consumption, and the number of games can also be a reasonable percentage of the diagnosis of selfish nodes even with a percentage of the presence of selfish nodes. e numerical values of Game theory-based [28], acknowledgment -based [32], TEEM [31] algorithms show that by increasing the percentage of selfish nodes in the network, the accuracy of the algorithm is higher than the other algorithms and at the same time, it has a lenient slope compared to other similar methods for the discovery of the Selfish node while other methods have a steeper slope with increasing the existence of selfish nodes. e fact that the proposed method has a gentler slope compared to other existing methods is clearly visible because the method uses the general characteristics of the network in each cluster to uncover the selfish nodes and check the recognition by using fuzzy rules to check the accuracy of detecting selfish nodes. Whereas other methods in higher percentages of the number of selfish nodes are usually incapable of detecting them in a high percentage. In the game theory-based methods, their computational overhead and the energy consumption are high. is method also requires playing several games in order to be able to detect the selfish node in the network, which is a time overhead. But the proposed method has no computational and time overhead.

False-Positive Rate.
is metric shows the ratio of the number of normal nodes found to be selfish incorrectly on the sum of the number of normal nodes found incorrectly (FP)and the number of normal nodes found correctly (TP) in the network. Equation (16) shows a positive warning rate.
is parameter actually has a photo relationship so that its level of its level accuracy indicates the accuracy of the presented approach. at is, the higher true detection of the number of associates nodes, the higher the performance of the network, since the time network detect a node as a selfish node, avoids cooperating with that node, so if this diagnosis is a mistake, it will reduce the efficiency and delivery of less data packets to the destination.
e implementation of the algorithm is repeated in such a cycle so that the performance of the algorithm is evaluated in different states.
e numerical values of the comparisons show that by increasing the existence of selfish nodes in the network, the positive warning rate of the proposed algorithm is lower than other algorithms. As indicated in the diagram, the positive warning rate exceeds 25% higher than the other algorithms and has fewer errors than the other algorithms, but it operates by 25% on the level of the proposed methods of acknowledgment-based [32] TEEM [31] and Game theory-based [28] algorithms, and its positive warning rate is lower than the other two algorithms. Other methods make more errors by increasing the percentage of selfish nodes. is reduces the throughput and efficiency of the network. e results have shown in Figure 15.

Data Packet Delivery Rate.
e delivery rate of successful data packets is one of the most important parameters of network evaluation in most working areas in the context of the networks of Internet of things. is parameter is basically the number of packets delivered successfully during the routing and transmission process from source to destination, so the packet delivery rate is the average number of packets delivered to the destination from all network nodes to the total number of packets generated in the network.
Equation (17) shows that R i is the total number of packets received in the destination nodes and S i is the total number of packets transmitted at the origin nodes. is metric has a significant impact on network performance. e higher the number of packets received at the destination, the lower delay on the number of packets arriving at the destination, the network delivery rate increases. For when the selfish nodes do not send the data packets in the network and the confirmation message is not received at the source, the node is again sent back in the network, increasing the traffic and the total number of packets produced and sent in the network, which has been ineffective. erefore, the higher the packet delivery rate in the network, the more efficient use of the network resources include the bandwidth or limited energy resources of the nodes. In Figure 16, the high performance of the proposed approach is found to be due to early detection of selfish nodes in the network, which avoid repetitive data packet production and increase network traffic and delay in nodes.

e Average of End-to-End Delay.
e average time period, which takes the length of the data packet from the source to the destination, is denoted by the time unit of the second. e mean delay is as time for storing data packets from the sender to the receiver as the scale of the different networks. is time is actually the total amount of time spent by the sender with different steps from relay nodes to reach the receiver and it has calculated by  end to end delay � sum of time taken packet to recieve destination number of recieved packet .
As Figure 17 shows the mean delay in the proposed method, especially in the high percentages of the selfish node in the network, is less than the other methods. e reason for this is that performance and transmission scale in the proposed method are higher than other methods and because there is less traffic on the network, the average packet delivery time on the network and the average waiting time is reduced to network nodes. Some selfish nodes in the network are associated with the nature of malice in the network which will increase the delay of end to the end at network nodes, As the packet lasts until it is alive, the packet remains in the buffer middle node, and then it is sent away, which causes the closure of the packet to be discarded at the other node. Since the time of survival of packet is over, the same issue increases the mean delay end to end at the network nodes. Obviously, the less time the packet delivery time is delivered to the network, and it is actually the desired goal of the network.

Conclusion and Future Works
is paper presents a new hybrid method that is used to identify the selfish node on the Internet of things. e proposed method will benefit from the advantages of the Harris Hawks Optimization (HHO) and fuzzy logic, it operates in three stages of trying to discover selfish nodes and decide how to deal with those nodes in a way that the node is isolated or given the opportunity again. e performance of this method is tested in the network and compared with acknowledgment -based [32], Game theory based [28], TEEM [31] algorithms. e results showed that the proposed method significantly identifies the selfish nodes and prevents the consumption of node resources (energy, battery, memory) and ending the delay end to end of data packets to reach the destination. e average throughput which is the percentage of successful delivery of data packets to the destination is 20% and is reduced by 12% at the same time the end -to -end delay at the end of the data packets. e percentage of selfish nodes in comparison with the same methods has increased by 10% and the false positive and false negative rate decreased 8% that indicates the accuracy of the selfish nodes detection accuracy. In future work, we will try to add more parameters that are effective in node reputation as input parameters to our fuzzy system as well as other Metaheuristic algorithms with higher performance to choose cluster nodes.

Data Availability
is manuscript has no data availability statement.