# Effective IoT Congestion Control Algorithm
## 3 The Proposed Algorithm  
This paper proposes an effective CCA that modifies how the congestion avoidance phase is dealt with by changing the parameter updating process. TCP constantly evaluates the capability of a network in order to forward traffic to the destination. This process starts with the initial CWND, which is set to a default maximum segment size of 10 [28]. This algorithm utilizes two variables: alpha and beta. Alpha is responsible for increment in the congestion window at the sending node, while beta represent the decrement factor. It uses delay as a back-off factor (beta) to decrease the sharpness of alpha increment when there is an increase in delay. This limits the increment rate of the congestion window. To explain the working principle of the algorithm, two cases are shown: the first case, when the algorithm running under normal conditions i.e., the link is not congested. In the SS phase, the algorithm behaves as TCP NewReno; when the CWND become equal or greater than the SSThresh value in this case, the algorithm enters into congestion avoidance phase and the behavior of the algorithm is as follows:  
First Case flow:  
Step 1: Set initial parameters alpha = 1, beta = 0.67, deltal = 1//initial value at the connection  
establishment. Step 2: For each packet acknowledgement delta = time.now () - time of last congestion;  
Step 3: calculate throughput = bytes sent * 8/time.now - last send time;  
Step 4: If delta > deltal then calculate difference = delta - deltal;  
Step 5: Update alpha = 1 + 10 * difference + 0.3 * difference * difference;  
Step 6: update min_RTT, max_RTT, RTT of the last acknowledged segments  
Step 6: Refine the increase variable alpha = 2 * (1 - beta) * alpha;  
Step 7: Calculate the increment inc = ((segment size * segment size) + CWND * alpha)/CWND;  
Step 8: update CWND = CWND + inc;  
The second case is when the link is congested and in its congestion avoidance phase. There are two ways to detect TCP congestion. First, there may be TCP congestion when there is no acknowledgement from the receiver to the sender; this means that the sender timeout variable is expired. The second way to detect congestion is when there are three duplicate acknowledgements between the receiver and the sender. When there is a congestion due to RTO expiration, the congestion window returns to one segment size and returns to Slow Start in order to follow TCP NewReno behavior. On the other hand, when the congestion is due to three duplicate acknowledgments, the algorithm follows the behavior described below:  
SSThresh is calculated depending on the current inflight bytes. It is multiplied by beta to leave some space in the pipe and reduce congestion. This factor will increase its friendliness to other CCAs. Beta is only calculated when the increment of throughput is below one-third of the previous throughput; this means that there is no increase in the congestion window by higher values while the link is congested. At each acknowledgement, RTT can be calculated as follows; Equation (1) shows the difference in time between packet send time and its acknowledgement:  
\[\text{RTT\_i}=\text{Ack\_rt}\text{(i)}-\text{Packet\_st}\text{(i)} \tag{1}\]  
where RTT_i is Round Trip Time of the ith packet, Ack_rt (i) is the time of receiving acknowledgement of ith packet and Packet_st (i) is the ith packet delivery time. If the connection is normal and no packet drops due to congestion, throughput can be calculated as follows:  
\[\text{throughput}=\text{(data sent in bytes}\times\text{8)/(current time-last send time)} \tag{2}\]  
where throughput is the current throughput, data sent in bytes is the number of delivered bytes, current time is the current time registered by the sender and last send time is the registered time of the last successful data sent. The increment factor, alpha, is flattenedby the beta factor after being calculated (steps 5 and 6) as stated in the algorithm. With Equations (1) and (2), it would be possible to adjust sending rate to improve performance.