A hierarchical congestion control method in clustered internet of things

Internet of things (IoT) is a modern technology where data can be transmitted to any things (human, animal, or object) over communications networks, whether internet or intranet. Congestion occurs when the input data rate to the node was higher than the output data rate of node. Congestion control in computer network modulates traffic entry into a network in order to avoid congestive. This paper suggests a method for congestion control in the internet of things in two phases. The first phase is intra-cluster congestion control, which uses two parameters, congestion score (CS) and buffer empty space (BES), to congestion avoidance. In this phase based on these two parameters, nine states are defined to determine the congestion status of each node, and based on these 9 states the appropriate decision is made to the node. The second phase is inter-cluster congestion control. In this phase, after determining cluster head priority, the parameters of back-off timer (BFT), waiting time to receive acknowledgment (WTTRACK)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$({\text {WTTR}}_{\text {ACK}})$$\end{document}, sequence number (SEQ) and retransmission counter (RC) are used for congestion control. The proposed congestion control method is simulated by NS-2 software. A comparison between the performance of proposed method and conventional methods shows that applying proposed method results in a significant improvement in average congestion score (CS), packet lost rate, energy consumption and end-to-end delay.

congestion avoidance is suggested. In the demand reduction approach, the amount of resources available will be shared among service users, and by sending explicit or implicit messages to message senders, the allowed rate for sending data is notified [11,12]. Policies affecting the phenomenon of congestion in the transmission layer include: retransmission policies, storage policies for packets that arrive out of order, acknowledgment receipt of packages policies, flow control policies and determine the expiration time of the timers (or time out policies). Policies affecting the phenomenon of congestion at the network layer include: virtual circuit versus datagram method in the subnet, package queuing mechanisms (or Queue management mechanisms) and various service methods, package drop policies, routing algorithm and management the time to live of packages. Policies affecting the phenomenon of congestion in the data link layer include: retransmission policies, storage policies for packets that arrive out of order, acknowledgment receipt of packages policies and flow control policies [12].
In this paper a congestion control method was proposed in the clustered internet-of-things network. In the proposed method, the internet-of-things network is considered clustered and done in two phase, intra-cluster and inter-cluster. In intra-cluster congestion control, for each node 9 states are defined based on two parameters of the node's congestion score (CS), and buffer empty space (BES). In this phase, the appropriate decision for the node is made based on each of the occurrences state. In inter-cluster congestion control, we consider four parameters: waiting time to receive acknowledgment (WTTR ACK ) , back-off timer (BFT), sequence number (SEQ) and retransmission counter (RC). Waiting time to receive acknowledgment (WTT RACK ) depends on the number of hops each packet takes to reach its destination and the number of retransmission of clusters head's packets. The main purpose of estimating the waiting time to receive acknowledgment (WTTR ACK ) for congestion control is to reduce packet lost and packets delay. The proposed method defines a back-off timer (BFT) between consecutive transmissions. In fact, back-off timer is the time interval between two transmissions that the sender node does not send any packet during this interval. The sequence number (SEQ) depends on the cluster head's priority, and the retransmission counter (RC) depends on the sequence number (SEQ). Using these parameters, we try to inter-cluster congestion avoidance. The innovations of the proposed method are: • Use the combination of parameters' congestion score (CS) and buffer empty space (BES) to determine the states of each node and appropriate decisions are made based on the states of node in the first phase. • In the second phase, cluster heads prioritize based on their data type so that important data are more likely to reach its destination. • Using a combination of parameters such as waiting time to receive acknowledgment (WTTR ACK ) , back-off timer (BFT), sequence number (SEQ) and retransmission counter (RC) to send data to each cluster head based on their priority in the second phase.
The rest of the paper is organized as follows: Section 2 represents an overview of the related works. In Sect. 3, the details of the proposed method, which is in two phase intra-cluster and inter-cluster to congestion control in the internet of things, are presented. Then, we provide the simulation of the proposed protocol and the analysis of its performance in Sect. 4. Finally, Sect. 5 concludes this paper.

Related works
TCP congestion control with MDP algorithm for internet of things over heterogeneous network was provided by Toprasert and Lilakiataskun [3]. This method is designed to describe TCP congestion control algorithm and is called TCP Siam, which increases congestion avoidance. Useful output, useful round-trip time and use in heterogeneous networks are the advantages of this method. This model uses the Markov decision-making process to estimate the round-trip time (RTT). This model is sufficient to handle congestion window (cWnd) values in TCP and strong incremental mode. In this method, three phases of congestion control, Markov decision process model and friendliness and fairness compatibility are defined. Congestion control mode is a transfer mode from TCP connection. In the Markov decisionmaking phase, the MDP algorithm improves congestion status by calculating the probability of transfer status, reward and discount factor. In the third phase, TCP is designed to share bandwidth between streams and others using other congestion control TCP protocols. Poddar et al. [7] presented a congestion control method for IoT using a channel trust-based approach. This method uses the node congestion and reliability criteria to determine whether the channel is reliable for packet transfer from source to destination. A priority plan has been chosen to determine a faster response time in emergency cases. Each node has a number of priority queues of equal size for the two data types. Queue schedulers are provided to provide different traffics with different priorities than priority queues. The proposed method is divided into three stages: priority setting, node-level congestion size and channel reliability estimation. In step one, the node with the maximum number of links to neighboring nodes in the network is designated as monitoring node and assigns heterogeneous traffic data priorities. In the second step, the scheduling rate and the sending rate are used to determine the node surface congestion. In the third step, channel validation is used to decide whether the channel selected is safe to transfer packets securely to the next node.
Rathood et al. [10] presented a new congestion control algorithm called CoCoA++ to address the issue of network congestion in internet of things (IoT). The method uses delay gradient (DG) to obtain a better measurement of network congestion and implements a probable back-off to counter congestion. The delay gradients and the probability back-off factor are integrated with constrained application protocol (CoAP). The main goal of the CoCoA++ algorithm is to provide better end-to-end network congestion estimation using the benefits of CDG. Delay gradients give a more accurate measure of congestion, and the retransmission time out (RTO) is reduced significantly, thereby leading to less delays and high packet sending rates.
Ancillotti and Bruno [13] have compared COAP and COCOA+ congestion control mechanisms for different scenarios of IoT application. CoAP is a web transfer protocol that provides basic RESTful services for IoT devices. CoAP uses a reload time (RTO) technique to identify packet lost. In fact, when a confirmation message is sent, a timer is set for the RTO value. If the timer expires and the sender has not yet received confirmation from the destination, the lost message is assumed and the CoAP message is retransmitted. CoCoA+ is a simple CoAP_CC enhancement that makes CoAP congestion control more responsive to network conditions.
Hassan et al. [14] proposed the congestion control method in CoAP. In this method, the proposed solution involves an adaptive mechanism for sending node data. This adaptive mechanism mainly depends on the traffic priority class and the loss rate. The proposed method has three stages: traffic priority allocation, adaptive RTO and adaptive pause timer. In the first stage, data traffic is divided into high-priority traffic and low-priority traffic. Second, the RTO value is calculated using two estimators. In the third step, the back-off timer for default CoAP increases mainly at the exponential level.
Bolettieri et al. [15] proposed precise congestion control algorithm for CoAP (PCoCoA). The proposed method guarantees precise COAP congestion control and delays comparable to CoAP and COCOA+. This approach proposes two methods for congestion control: introducing a specific COAP option and modifying the message ID semantic. In the first case, a new CoAP option is called the transmission counter (TC). This option is used to link any ACK message to its corresponding transmitted CON message. An alternative solution is to avoid overloading the message ID. To support this approach, MID can be divided into a 14-bit ID and a 2-bit sequence number. The second element is used to reduce fake retransmission.
Hamimi et al. [16] proposed the congestion control mechanism for internet-ofthings (IoT) paradigm. The purpose of this approach is to reduce the number of closed losses during transmission and minimize the number of visits to reduce the corresponding cost, energy and response time. The proposed method is divided into two phase: cluster head selection and package discarding. Hence, the presence of a cluster head reduces the loading in the sink node, while improving the performance of applications. In the second part of the cluster, the process of packet destruction is performed by each node. The purpose of the deletion process is to reduce the number of data packets that are sent to the next cluster head.
CoAP congestion control in the internet of things was provided by Betzler et al. [17]. CoAP defines four types of messages: confirmable (CON), non-confirmable (NON), reset (RST), and acknowledgment (ACK) messages. CoCoA offers a congestion control solution that reduces the conservative message rate limitations of the basic CoAP specifications while ensuring that protocol operations are secure. CoCoA includes three main components: adaptive RTO calculation, a variable backoff factor (VBF) and RTO aging.
Betzler et al. [18] proposed an advanced congestion control mechanism for CoAP (Cocoa+). CoAP with the main congestion control (CC) mechanism resolves this important issue. CoCoA+ includes the following suggestions to address when using CoCoA as a congestion control mechanism: (1) A modification of the weak estimator calculations to reduce the impact of RTT weak A hierarchical congestion control method in clustered internet… variations and its impact on RTO overall. (2) Replacement of BEB used for remobilization by a variable return factor (VBF). (3) New approach for large amounts of RTO overall age .
Bhalerao et al. [19] proposed the improve congestion control in CoAP protocol. The CoCoA 4-State-Strong method is presented to analyze and improve congestion control in the CoAP. Depending on the number of times a package is resent, each CoAP transaction is considered in one of four modes: 1, 2, 3, 4. The transaction starts in Mode 1 and each time a packet is resubmitted, its status increases by one. Each time a packet is successfully transmitted and verified within a specified time, its status decreases by one. This allows you to adjust the return parameters accordingly.
Enhancement of CoAP-based congestion control in IoT network-a novel approach proposed by Swarna et al. [20]. This advanced congestion control mechanism uses various margins implemented using CoAP to analyze. This work emphasizes CoAP due to its squat overhead to reduce consumption in memory utilization and reduces the overall network power consumption. In this paper, the proposed work is to build a robust IoT Network which improved the response time, the proposed network consumed very little power in the largescale network nodes, and very effectively congestion has been controlled. The experiment showed that all the IoT network optimization had been proved using CoAP in that latency, power and performance are substantially achieved.
A summary and comparison of the mentioned algorithms are presented in Table 1.

The proposed method
When the number of sent packets exceeds the capacity of the network, congestion occurs, and as a result the sent packets are either deleted or delayed. Congestion control in the internet of things, like any other subject, has its own objectives, such as increasing packet delivery rates, reducing energy consumption, fair allocation in the shortest possible time and most effective way, maintaining and enhancing accountability and reducing the time of responsiveness. In the proposed method for achieving these goals, it is assumed that the network is clustered and congestion control is performed in two phases, intra-cluster and inter-cluster. In the first phase based on two parameters, congestion score (CS) and buffer empty space (BES), the congestion state of each cluster member is specified and the appropriate transfer rate for each node is determined according to node congestion state. In the second phase, the inter-cluster congestion control is based on the cluster head priority. The phases of the proposed method are described as follows. The notations used in the proposed method are listed in Table 2. Proposed method A hierarchical congestion control method in clustered internet of things Low congestion score (CS), low packet loss rate, low energy consumption and low end-to-end delay Due to the prioritization in the second phase, there is a possibility of famine for too lowpriority cluster data

First phase: Intra-cluster congestion control
The main purpose of this phase is control and provides a solution to congestion avoidance in the cluster head. In this section, two parameters of congestion score (CS) and buffer empty space (BES) are used to control and provide a solution to congestion avoidance. According to these parameters, nine states may occur for each cluster member node. Based on these nine states, the appropriate decision for data sending rate for each cluster member's node is determined. According to the states that may occur for each node, the state space for the finite state machine is determined. The steps of the first phase are as follows.
Step 1: Calculate congestion score (CS) CS determines the current congestion score in cluster member's node and calculated by Eq. (1).
where r i in , r i for , N i ACK , and N i source_send indicate the input packets rate to node i, the forwarding packets rate of node i, the number of acknowledgment received by node i, and the number of source sent packets (the number of packets generated by the node i itself), respectively. According to equation (2) r i in of the sum of R i s which is the source traffic rate (number of packets generated by node i) and R i tr which is the  (3), the congestion score in each node has three levels.
The conditions under which the node congestion scores may be in one of the three above levels are described below.
• When CS is between 0 and 1, node does not have congestion. But it is divided into two levels for better understanding. If CS is between 0 to 0.5, the node does not have congestion and if CS is 0.5 to 1, the node is on the threshold of congestion.
1. Conditions where the node does not have congestion. (0 ≤ CS node i < 0.5) 2. If the number of forwarding packets by the node is equal to the number of input packets to the node ( r i for == r i in ) and the number of acknowledgment messages received by the node is equal to the number of source sent packets ( N i ACK == N i source_send ), the congestion score is zero ( CS node i ==0) and the node has not congestion. 3. If the number of acknowledgment messages received by the node is more than half the number of source sent packets ( N i ACK > 1 2 N i source_send ) and the number of forwarding packets by the node with the number of input packets to the node, be equal ( r i for == r i in ), the congestion score is less than 0.5. ( CS node i < 0.5) 4. If the number of forwarding packets by the node is more than half the number of input packets to the node ( r i for > 1 2 r i in ) and the number of acknowledgment messages received by the node is equal to number of source sent packets ( N i ACK == N i source_send ), the congestion score is less than 0.5. ( CS node i < 0.5) 5. Conditions where the node is on the threshold of congestion.
(0.5 ≤ CSP node i < 1) 6. If the number of acknowledgment messages received by the node is equal to half the number of source sent packets ( N i ACK == 1 2 N i source_send ) and the number of forwarding packets by the node with the number of input packets to the node be equal ( r i for == r i in ), the congestion score is 0.5. ( CS node i ==0.5) 7. If the number of forwarding packets by the node is equal to half the number of input packets to the node ( r i for == 1 2 r i in ) and the number of acknowledgment messages received by the node is equal to the number of source sent packets ( N i ACK == N i source_send ), the congestion score is 0.5. ( CS node i ==0.5) 8. If the number of forwarding packets by the node is less than half the number of input packets to the node ( r i for < 1 2 r i in ) and the number of acknowledgment messages received by the node is equal to the number of source sent , the congestion score is more than 0.5. (0.5 < CS node i < 1) 9. If the number of acknowledgment messages received by the node is less than half the number of source sent packets ( N i ACK < 1 2 N i source_send ) and the number of forwarding packets by the node with the number of input packets to the node be equal ( r i for == r i in ), the congestion score is more than 0.5. (0.5 < CS node i < 1) • Conditions where the node has congestion. (1 ≤ CS node i ≤ 2) 1. If the number of forwarding packets by the node is zero ( r i for == 0 ) and the number of acknowledgment messages received by the node is equal to the number of source sent packets ( N i ACK == N i source_send ), the congestion score is one. ( CS node i ==1) 2. If the number of acknowledgment messages received by the node is zero ( N i ACK ==0) and the number of forwarding packets by the node with the number of input packets to the node be equal ( r i for == r i in ), the congestion score is one. ( CS node i ==1) 3. If the number of acknowledgment messages received by the node is half the number of source sent packets ( N i ACK == 1 2 N i source_send ) and the number of forwarding packets by the node with half the number of input packets to the node be equal ( r i for == 1 2 r i in ), the congestion score is one. ( CS node i ==1) 4. If the number of acknowledgment messages received by the node is less than half the number of source sent packets ( N i ACK < 1 2 N i source_send ) and the number of forwarding packets by the node is zero ( r i for ==0), the congestion score is more than one. (1 < CS node i < 2) 5. If the number of acknowledgment messages received by the node is half the number of source sent packets ( N i ACK == 1 2 N i source_send ) and the number of forwarding packets by the node is zero ( r i for ==0), the congestion score is more than one. (1 < CS node i < 2) 6. If the number of acknowledgment messages received by the node is more than half the number of source sent packets ( N i ACK > 1 2 N i source_send ) and the number of forwarding packets by the node is zero ( r i for ==0), the congestion score is more than one. (1 < CS node i < 2). 7. If the number of forwarding packets by the node is less than half the number of input packets to the node ( r i for < 1 2 r i in ) and the number of acknowledgment messages received by the node is zero ( N i ACK ==0), the congestion score is more than one. (1 < CS node i < 2) 8. If the number of forwarding packets by the node is half the number of input packets to the node ( r i for == 1 2 r i in ) and the number of acknowledgment messages received by the node is zero ( N i ACK =0), the congestion score is more than one. (1 < CS node i < 2) 9. If the number of forwarding packets by the node is more than half the number of input packets to the node ( r i for > 1 2 r i in ) and the number of acknowl-edgment messages received by the node is zero ( N i ACK ==0), the congestion score is more than one. (1 < CS node i < 2) 10. If the number of forwarding packets by the node is zero ( r i for ==0) and the number of acknowledgment messages received by the node is zero ( N i ACK =0), the congestion score is two. ( CS node i ==2) In summary, the conditions described for the node's congestion are shown in Table 3. Figure 1 shows the congestion score in the node.
Step 2: Calculate the buffer empty space (BES) If two nodes a and b are neighbors and node a intends to send a packet to node b, node b must have sufficient buffer space to store packets from node a, BES is the buffer empty space in the node that calculated by Eq. (4).
where N i Q and N i T indicate the number of packets in the node's buffer i and the buffer size in node i.
T , the buffer is completely full and BES node i is zero percent, and this is the worst case for a node's buffer.
, the buffer is completely empty and BES node i is %100. • When N i Q < N i T and 0 < BES node i <100, according to Eq. (5), the buffer empty space in each node is divided into three levels. Figure 2 shows conditions of buffer empty space in each node.
Step 3: Determine the states of each node After calculating the congestion score (CS) and the buffer empty space (BES), based on CS and BES nine states are defined for each node. When each of the states occurs, the node sends a notification to the cluster head to announce its status. According to the received notification, cluster head warns node's neighbors that decrease or increase the data transmission rate so that congestion avoidance is in the node. This method leads to control and congestion avoidance in the cluster member nodes. The nine states for each node are shown in Table 4. The command that the cluster head announces based on received notification message to node's neighbors is shown in Table 5.
• The worst state that can happen to a node is when it has congestion and the buffer is full; in this case, it sends a notification message to the cluster head (4) Table 3 Different conditions of node congestion Node's congestion interval or level The node is without congestion and is divided into two levels for better understanding The node is without congestion The node is on the threshold of congestion (NTC) The node has congestion (1 ≤ and then cluster head announces to node's neighbors to sharp decrease transmission rate to this node. • If the node has congestion and the buffer is empty or node has congestion and the buffer is almost empty or node is on the threshold of congestion and the buffer is full, node sends a notification message to its cluster head requesting a reduction  Remains at the current state in transmission rates, and then, cluster head announces to node's neighbors to decrease the transmission rate to this node. • If the node is on the threshold of congestion and the buffer is empty or node is on the threshold of congestion and the buffer is almost empty or node has not congestion and the buffer is full, its status will remain unchanged and does not send the notification message to its cluster head. • If the node has not congestion and the buffer is almost empty, it sends a notification message to its cluster head and the cluster head announces to node's neighbors; they can increase the transmission rate. • If the node has not congestion and the buffer is empty, it sends a notification message to its cluster head and the cluster head announces to node's neighbors; they can sharp increase transmission rate. Table 6 shows the transition conditions of different states of the finite state machine. Figure 3 shows the finite state machine for nine states that may occur for a node. Figure 4 shows the overall flowchart of the first phase of the proposed method.

Second phase: Inter-cluster congestion control
The main purpose of this phase is to inter-cluster head for congestion control. After collecting and sending data by the cluster members to the cluster head, data is sent Table 6 Finite state machine transition conditions The node has congestion (NC), buffer is empty (BE) The node has congestion (NC), buffer is almost empty (BAE) The node has congestion (NC), buffer is full (BF) The node is on the threshold of congestion (NTC), buffer is empty (BE) The node is on the threshold of congestion (NTC), buffer is almost empty (BAE) The node is on the threshold of congestion (NTC), buffer is full (BF) The node has not congestion (NNC), buffer is empty (BE) The node has not congestion (NNC), buffer is almost empty (BAE) The node has not congestion (NNC), buffer is full (BF) P 9 0 ≤ CS node i < 0.5 0 ≤ BES node i < 33 via inter-cluster heads to reach the destination. Factors such as excess transmission rate, inaccurate routing, inadequate bandwidth and low queue lengths can occur congestion. In this phase, controlling and congestion avoidance inter-cluster heads based on cluster heads priority, calculating waiting time to receive acknowledgment ( WTTR ACK ), back-off timer (BFT), sequence number (SEQ) and retransmission counter (RC) for data sent to cluster head are done. The steps of the second phase are as follows.
Step 1: Cluster head priority In this step, the cluster heads are divided into five categories, and each is given priority (P) according to the type and importance of their services as shown in Table 7. High priority is given to cluster heads that have critical applications and services. Devices such as heart beat sensor, blood pressure sensor, body temperature sensor, monitoring sensor and fire alarming sensor have critical applications and services. There are also cluster heads that their data have less important such as refrigerators, smart TVs, washing machines and room humidity sensors.
According to cluster head's priorities, a back-off timer (BFT) is set for them. The cluster head with higher priority has a shorter back off timer (BFT), because its data are critical and should arrive sooner than the cluster head with lower priority to destination.
Step 2: Send data to the destination by the cluster heads After determining cluster head priority, data should be sent to the destination by cluster heads. The cluster head with the highest priority starts sending packets and   Cluster head with too low priority for sending data wait for T reference in the first transmission. (RC = 0, WTTR ACK = T reference ); if the acknowledgment message (ACK) is received from the destination and the cluster head has other packets to send, it will start sending them. Otherwise if it did not receive the acknowledgment message of the sent packet, we calculate the waiting time to receive acknowledgment ( WTTR ACK ), back-off timer (BFT), sequence number (SEQ) and retransmission counter (RC) for cluster head and resend the packet. The cluster head waits for WTTR ACK to receive ACK. In each resend, if the ACK is received and the cluster head has other packets to send, it will be sending them. But if the ACK is not received in any of the re-sending and the number of specified resending expires, that packet will be deleted. This process continues until all data are sent to the destination. Then, the other cluster heads send their data to the destination in order of priority.
Step 3: Calculate the SEQ and RC To prevent extra overhead in data transfer and congestion control, a parameter called sequence number (SEQ) is used to send data based on the cluster head priority. The cluster head's data with a higher priority are assigned sequence number with more bits number, and the cluster head's data with lower priority are assigned sequence number with less bits number. Therefore, the number of retransmission for cluster head with higher priority is more than the cluster heads with lower priority. The sequence number (SEQ) and the retransmission counter (RC) are calculated by equation (6).
Step 4: Calculate the back-off timer (BFT) The back-off timer (BFT) is the time interval between the two transmissions. In other words, cluster's head waits in a time interval after each sending data to destination and does not send any data. After the back-off timer (BFT), it will start sending data to the destination again. The back-off timer (BFT) for each cluster head was based on the cluster head priority and is calculated by equation (7).
Cluster head with higher priority will have less back-off timer (BFT), because their data are of more importance and must reach its destination earlier. The back-off timer (BFT) for cluster head with lower priority is higher, because their data are less important. Priority and back-off timer (BFT) are inversely related.
Step 5: Calculate the waiting time to receive acknowledgment ( WTTR ACK ) The waiting time to receive acknowledgment ( WTTR ACK ) is the time interval that the node waits to receive acknowledgment (ACK) that it sends from the destination. At this step, waiting time to receive acknowledgment ( WTTR ACK ) based on the number of hops that packet takes to reach its destination and the number of retransmission of cluster head's packet. The waiting time to receive acknowledgment is calculated by Eq. (8). The higher the number of retransmission and the number of hop the longer the waiting time to receiving ACK ( WTTR ACK ). According to Eq. (6), as the number of retransmission is higher for high-priority cluster heads, WTTR ACK is higher for high-priority cluster heads.

Fig. 5
The flowchart of inter-cluster congestion control Figure 5 shows the overall flowchart of the second phase of the proposed method.
In the second phase, the cluster heads are prioritized according to their data type into five categories, and the cluster head's with the highest priority starts sending its packets to the destination. In the first send, if the acknowledgment message is received from the destination and the cluster head has other packet to send, it will be sending them. But if it did not receive the acknowledgment message of the transmitted packet, it calculates waiting time to receive acknowledgment ( WTTR ACK ), backoff timer (BFT), sequence number (SEQ) and retransmission counter (RC), and the cluster head re-sends the same packet in the WTTR ACK time interval. If cluster head receives acknowledgment message in one of re-sending and the cluster head has other packets to send, it will be sent. But if none of the re-sending does not receive the acknowledgment message from the destination, it deletes the packet. If cluster head has other packets, it will send all its data to the destination. Then, cluster heads send its data based on priority.

Simulation and result
The proposed method is simulated by network simulator NS2. In order to evaluate the performance of the proposed method in the internet-of-things (IoT) network, the results of the simulation are compared with three methods: Poddar et al. [7], CoCoA [18] and Swarna et al. [20]. The simulation parameters are shown in Table 8. The results of the simulation are investigated in terms of parameters such as congestion score (CS), packet lost rate, energy consumption and end-to-end delay, which are described below.
Network congestion occurs due to an increase in the rate of input data to the node relative to the rate of output data of the node. Network's congestion reduces quality of service (QOS). Congestion increases the delay and packet lost. Figure 6 shows the network's congestion score (CS) in the proposed method compared to other methods. As can be seen in Fig. 6, the proposed method imposes less congestion on the network than other methods. In the proposed method, intra-cluster congestion control uses the node's congestion score (CS) parameter, which is a hybrid parameter that is calculated based on the number of received packets, the number of sent packets as well as the number of received ACKs. Also another effective parameter used in the intra-cluster communication and a great impact on congestion control is the buffer empty space (BES) of each node. Considering the two parameters, the congestion score (CS) and the buffer empty space (BES) for the nodes different states defined and based on the defined state, the appropriate decision is made to congestion avoidance in the network. In the second phase, the number of packet retransmission is according to their priority, so that more important data are sent first. As shown in Fig. 6, in the proposed method network's congestion score (CS) is lower than other methods, and the congestion score (CS) in the proposed method has decreased with increasing number of sent packets. Parameters such as insufficient bandwidth, incorrect routing and incorrect queue management can increase the rate of packet loss on the network, and one of the most important parameters affecting the rate of packet loss is the phenomenon of congestion, which can cause latency in the network, and as a result of late arrival or failure to receive packets in the destination, elimination should use congestion control strategies to reduce the rate of packet loss on the network. Packet lost rate shows the ratio of the number of packets lost to the total number of sent packets. The proposed method tries to minimize the number of packets lost by avoiding congestion. Packet lost occurs when one or more sent packet through the network's nodes that cannot reach their destination. The packet lost rate in the proposed method compared to the other methods is shown in Fig. 7. As shown in Fig. 7, the proposed method prevents packet lost and thus keeps the packet lost rate at a lower level than the other methods. In addition, considering the buffer empty space (BES) parameter to sending packets in the first phase causes reduction in the number of packets lost due to the buffer being full. The proposed method also considers the back-off timer (BFT) and the number of appropriate retransmission for packets of higher importance in the second phase. As a result, the proposed method performs better in controlling packets lost and reducing packet lost rate. Figure 8 shows the energy consumption of the proposed method compared to other methods. Increasing the number of packets in the network increases the probability of congestion. In case of congestion, the probability of lost packet is increased, which causes the packet lost to be retransmission from the source, thus increasing the energy consumption. In order to reduce packet lost, the proposed method is performed at two-phase intra-cluster and inter-clusters. Intra-cluster congestion control is using appropriate mechanisms, investigating node conditions and making appropriate decisions according to node conditions. In order to inter-cluster congestion control, appropriate mechanism is provided for the data retransmission according to cluster head priority. Therefore, it is suitable to avoid congestion and increase energy consumption between cluster member nodes as well as cluster heads. As shown in Fig. 8, the energy consumption in the network increases as the packets increase, increasing the congestion. However, due to congestion control and the reduction of packet lost rates in the proposed method, as well as the determination of the number of times appropriate to packets retransmission, the energy consumption in the proposed method is lower.
End-to-end delay is the time required between the sent packets from the source node to the destination node. Congestion and delay are directly related, and congestion increase results in more delay. Because congestion on the one hand causes delay   End-to-end delay in data transmission and on the other hand causes packet lost and data retransmission in the network. Retransmission causes delays on the network. Figure 9 shows the end-to-end delay of the proposed method compared to other methods. The proposed method minimizes packet lost as much as possible and reduces the number of packet retransmission in the network. In the inter-cluster phase, data with higher priority are sent faster and more frequently. Therefore, the delay in sending these packets is also reduced. The proposed method is also suitable for real-time applications because important data have faster transmission and, if lost, retransmission with more iterations. In general, the proposed method imposes less delay on the network than other methods.

Conclusion
In this paper, a congestion control method was proposed on the clustered internet of things. The proposed method consists of two phases. The first phase is intra-cluster congestion control and uses two parameters of the congestion score (CS) and buffer empty space (BES). The second phase is inter-cluster congestion control. In this phase, several parameters are used for congestion control, such as back-off timer (BFT), waiting time to receive acknowledgment ( WTTR ACK ), sequence number (SEQ), and retransmission counter (RC). Unlike most existing methods that focus on only one criterion, this method focuses on several criteria and examines them. Simulations show that the proposed method performs better in terms of criteria such as congestion score (CS), packet lost rate, or energy consumption and end-to-end delay. The simulation results show that the proposed method has less congestion than the other methods. Our recommendation for preventing and controlling congestion in the IoT network is to improve the proposed method, that in order to provide methods in the future we can use meta-heuristic algorithms, fuzzy logic, using parameters such as window size, packet survival time in the network, bandwidth and a proper routing.