## 4 Congestion Control Based on the RED Algorithm
### The Cred Algorithm
In this model, CH (C++ and Otd) represents the compiled languages, while OTcl corresponds to an interpretive language. TclCL facilitates the association of objects and variables between C++ and OTcl [40]. To understand the specific connection between these languages, the NS2 architecture diagram depicted in Figure 7 provides valuable insights. Additionally, Figure 8 presents the simulation flow chart of NS2, offering a comprehensive overview of the operational flow within NS2. Figure 7: NS2 architecture diagram. #### 5.1.2 Design of Simulation Experiments

We primarily utilize NS2 as the simulation tool to analyse the performance of the proposed algorithms. The simulation network topology diagram is presented in Figure 9. From the depicted topology model, it is evident that S1, S2, and S3 function as data-sending nodes, while RO, R2, and R4 serve as data-receiving nodes. Router1 and Router2 are the intermediary routers in the network. The connection between Router1 and the sending nodes exhibits a delay of 10 ms and a bandwidth of 15 Mb/s. On the other hand, the connection between Router2 and each receiving node experiences a delay of 30 ms and a bandwidth of 15 Mb/s. Router1 and 2 possess a delay of 20 ms and a bandwidth of 1 Mb/s. Additional parameters are set as follows: the minimum threshold \(min_{th}\) is set to 10, the maximum threshold \(max_{th}\) is set to 30, the maximum packet loss rate \(max_{p}\) is 0.16, and \(\delta\) is 20. The emulation time is set to 6000 s, and the packet length is fixed at 1000 bytes. Furthermore, the queue length between the routers varies from 10 to 100 packets. \[P=a_{1}\text{avg}^{2}+b_{1}\text{avg}+c_{1} \tag{9}\]0 Simulation flow chart of NS2. #### 5.1.3 Simulation Results and Analysis

The performance simulation data graphs of the RED and CRED algorithms are presented below. Figure 10 clearly demonstrates that as the queue length reaches 25 packets, the packet loss rate of both algorithms starts to diverge. As the queue length continues to increase, the packet loss rate of the CRED algorithm consistently remains lower than that of the RED algorithm. The simulation results depicted in Figure 11 highlight an observable delay disparity between the RED algorithm and the CRED algorithm as the queue length reaches 15 packets. Furthermore, as the queue length continues to increase, the delay time of the CRED algorithm consistently remains lower than that of the RED algorithm. The delay of the CRED algorithm remains stable at around 100 ms and does not exceed this threshold. Based on the NS2 simulation analysis, it becomes apparent that the CRED algorithm outperforms the RED algorithm in terms of both packet loss rate and end-to-end delay. The CRED algorithm consistently demonstrates improved performance compared to the RED algorithm. Therefore, in the subsequent simulation experiments, the CRED algorithm will be utilized in conjunction with the ACA to effectively alleviate short-term congestion, allowing the ACA to continue selecting an optimized path with low delay even during congestion scenarios. \[P=a_{1}\text{avg}^{2}+b_{1}\text{avg}+c_{1} \tag{9}\]1 Packet loss rate versus queue length. \[P=a_{1}\text{avg}^{2}+b_{1}\text{avg}+c_{1} \tag{9}\]2 Network topology model. ### Simulation of Congestion Control Based on the CRED Algorithm

The ACA serves as a mechanism to assess changes in cross paths by comparing the total delay of the optimal path before and after congestion. Upon congestion, it becomes evident that the total delay of the optimal path significantly increases, rendering the suboptimal path inadequate for meeting user requirements. Consequently, congestion must be addressed to establish a new optimal path with lower delay. The primary cause of congestion lies in the diminished data processing capacity of the network nodes, leading to a substantial increase in the average queue length of data packets and a subsequent surge in queue delay. This congestion may propagate, resulting in a considerable increase in the optimal path delay obtained through the ACA.