# Congestion Control in CoAP Observe Group Communication
## 3 CoCo-RED: Congestion Control Random Early Detection  
According to the problems of the CoAP congestion control mechanisms suggested in the previous section, we propose the Congestion Control Random Early Detection (CoCo-RED) mechanism, which emerges from Random Early Detection (RED) gateways [24] for congestion avoidance in packet-switched networks. However, from a standard linear model of the packet drop function, it was found that the packet drop always occurred when the average queue size (_AvgQ_) was higher than the maximum threshold [25]. Thus, all the packets were dropped continuously, which might have some negative effects regarding the efficiency of a network. In this study, we adjusted this operation using an exponential function to lower the drop probability, but this can also cause the buffer to overflow; therefore, consecutive packets would be dropped. Such problems can be addressed by signaling sources to slow down the packet drop at the initial stage, followed by increasing the rate of the packet drop if the queue size is close to the size of the buffer. Our proposed CoCo-RED mechanism was comprised of three major components: an RTO calculation randomly selected from the interval of 2-4 s, buffer management from the client, and retransmission. All the components were under the control of this mechanism in both the client and the server, which is explained in the next paragraph. Regarding the outstanding feature of our CoCo-RED mechanism, it works dynamically, depending on the Revised Random Early Detection algorithm (RevRED), which calculates network density from the _AvgQ_. To illustrate this, as network congestion starts, the RevRED can solve this problem by dropping arriving packets in the system before the queue in the client's buffer overflows. Owing to statistical probabilities corresponding to _AvgQ_ that prevent burst traffic congestion, the buffer queue management of the RevRED algorithm is shown in Figure 4. Another distinctive feature of this mechanism is that when a packet drop occurs in the RevRED algorithm, there is a backoff for the first retransmission or until the packet which had the same previous MID can be sent or acknowledged successfully. The backoff time can be calculated with a Fibonacci Pre-Increment Backoff (FPB) algorithm. The waiting period for retransmission helps to reduce network traffic since the sever nodes at which the packets were dropped cannot communicate. Also, this indirectly causes the queue on the client's buffer to decrease. Figure 5 shows the timing diagram of CoCo-RED and the functions of the CoCo-RED mechanism. The figure is subsequently explained in two parts: the server and the client. * Server: The server starts calculating and determining the RTO timer by randomly selecting in intervals of 2-4 s. Then, it sends the CON message to the client, and the server needs an ACK message response within the period of the RTO timer; otherwise, the server undergoes retransmission. In this manner, the CoCo-RED mechanism allows retransmissions up to four times before considering the notification an error or failure, which was similar to the default CoAP. Moreover, in each retransmission, the FPB (i.e., Fibonacci fib n, n = {1, 2, 3, 5}) was multiplied with the _RTOinit_ to determine the new RTO timer for the next retransmission. The work of FPB is shown in Algorithm 1, and the duration of each retransmission is illustrated in Figure 3. Figure 3 compares the backoff durations for one message transmission and four message retransmissions in the BEB and the FPB, starting with the _RTOinit_ value of 2 s. Notably, the total duration before timeout was 62 s for the BEB and 24 s for the FPB. This means that the fast retransmission of FPB contributes to flexible buffer management and rapid response times. * Client: The client works based on the RevRED algorithm, which is illustrated in Algorithm 2.