## 4 Congestion Control Based on the RED Algorithm
### The Cred Algorithm  
The CRED algorithm is an enhancement to the RED algorithm that specifically addresses its linear packet loss method [38]. This improvement aims to modify the packet loss rate behaviour of the original RED algorithm. In the CRED algorithm, the packet loss rate increases gradually and becomes less sensitive when the congestion level is low. However, once congestion is detected, the packet loss rate accelerates rapidly. This adjustment allows for a more nuanced response to varying congestion degrees, providing a more effective congestion control mechanism. To mathematically model the CRED algorithm, a graphical representation is utilized. This representation includes three points, A, B, and C, placed along the diagonal line. These points are assigned specific coordinates as follows:  
\[(\min_{\text{th}},0);\left(\frac{\min_{\text{th}}+\max_{\text{th}}}{2},\frac{ \max_{p}}{2}\right);\left(\max_{\text{th}},\max_{p}\right) \tag{8}\]  
There are two curves with the following expressions for the quadratic equation:  
\[P=a_{1}\text{avg}^{2}+b_{1}\text{avg}+c_{1} \tag{9}\]  
\[P=a_{2}\text{avg}^{2}+b_{2}\text{avg}+c_{2} \tag{10}\]  
Let us denote point A as the vertex of the curve represented by Equation (9). In this case, the equation for the symmetry axis can be expressed as follows:  
\[-b_{1}/2a_{1}=\min_{\text{th}} \tag{11}\]  
Similarly, if we consider point C as the vertex of the curve described by Equation (10), we can determine the equation of the symmetry axis as follows:  
\[-b_{2}/2a_{2}=\max_{\text{th}} \tag{12}\]  
\[\frac{\min_{\text{th}}+\max_{\text{th}}}{2}=\delta \tag{13}\]  
By substituting points A and B into Equation (9) and combining them with Equations (11) and (13), we can obtain the following result:  
\[P_{a}=0.5\times\max_{p}\times\left(2\times\frac{\text{avg}-\min_{\text{th}}}{ \max_{\text{th}}-\min_{\text{th}}}\right)^{2}\ \ \ \text{avg}\in(\min_{\text{th}},\delta_{\text{th}}) \tag{14}\]By substituting points B and C into Equation (10) and combining them with Equations (12) and (13), we obtain the following results:  
\[P_{a}=max_{p}-2 max_{p}\times\frac{\left(\mathrm{avg}-\mathrm{max}_{\mathrm{th}} \right)^{2}}{\left(\mathrm{max}_{\mathrm{th}}-\mathrm{min}_{\mathrm{th}}\right) ^{2}}\quad\mathrm{avg}\in(\mathrm{ffi}_{\mathrm{th}},\mathrm{max}_{\mathrm{th}}) \tag{15}\]  
Based on the description of the CRED algorithm above, the relevant pseudocode is as follows (Algorithm 2):  
```
1 foreachpacket arrivaldo
2 calculate the new average queue size avg;
3 end if
4 if\(\mathrm{min}_{\mathrm{th}}<\mathrm{avg}<\mathrm{max}_{\mathrm{th}}\)then
5 calculate probability \(P_{a}=0.5\times max_{p}\times\frac{\left(\mathrm{avg}-\mathrm{max}_{\mathrm{ th}}\right)



rate. This characteristic enables the CRED algorithm to effectively handle burst traffic and promptly control congestion in the network. The improved behaviour of the CRED algorithm aligns better with the actual variations in network traffic. It offers greater practical value in managing congestion and enhancing overall network performance. ## 5 Simulation Experiment and Result Analysis

### Comparison and Simulation of the RED and CRED Algorithms

The preceding analysis examines the RED and CRED algorithms, highlighting their effectiveness in alleviating congestion. However, determining the algorithm for controlling the average queue length in combination with the ACA and achieving a low-delay optimized path requires simulation. Theoretical comparisons and analyses alone are insufficient. Therefore, the NS2 platform is used here to simulate and analyse these two algorithms. After conducting the simulation analysis, we concluded that the CRED algorithm outperforms the RED algorithm. Considering its superior performance in terms of packet loss rate and delay, the CRED algorithm is ultimately selected for congestion control. #### 5.1.1 Platform Introduction

NS2 is an object-oriented programming environment and a TCL-OTCL script interpreter. It combines C++ and Otd, which is referred to as the split object model [39].