A Novel Fuzzy PID Congestion Control Model Based on Cuckoo Search in WSNs.

Wireless Sensor Networks (WSNs) consist of multiple sensor nodes, each of which has the ability to collect, receive and send data. However, irregular data sources can lead to severe network congestion. To solve this problem, the Proportional Integral Derivative (PID) controller is introduced into the congestion control mechanism to control the queue length of messages in nodes. By running the PID algorithm on cluster head nodes, the effective collection of sensor data is realized. In addition, a fuzzy control algorithm is proposed to solve the problems of slow parameter optimization, limited adaptive ability and poor optimization precision of traditional PID controller. However, the parameter selection of the fuzzy control algorithm relies too much on expert experience and has certain limitations. Therefore, this manuscript proposes the Cuckoo Fuzzy-PID Controller (CFPID), whose core idea is to apply the cuckoo search algorithm to optimize the fuzzy PID controller’s quantization factor and PID parameter increment. Simulation results show that in comparison with the existing methods, the instantaneous queue length and real-time packet loss rate of CFPID are better.


Introduction
Wireless Sensor Networks (WSNs) are one of the important technologies in recent times due to their widespread applications e.g., military, smart phones, disaster management, health care monitoring and other surveillance systems. In these widespread applications, WSNs may face many challenges, in which network congestion is the prominent one [1]. WSNs can connect network nodes in series to transmit data in a "carry-send" mode where each node has the ability to collect, receive and send data, autonomously. WSNs can potentially improve the transmission date volume and throughput of the network [2]. In addition, the deployment area and the number of nodes is generally very large in WSNs. Furthermore, there is no time limit for data acquisition and transmission, so possibly the network nodes may receive a large amount of data in an instant. If such a high quantity of data arrive at each receiving node instantaneously, a huge burden will be caused on the receiving nodes [3]. When the data receiving rate is not synchronized with the data sending rate, the message queue at the node will be filled rapidly, leading to network congestion.
Serious network congestion will greatly affect the data transmission in WSNs. When network congestion occurs, the data at the node cannot be sent out in time, and other data cannot enter the message queue in the node. The message will be continuously discarded and delayed, which will result in increased data loss, increased transmission delay, reduced network throughput and lowered Cho [5] presented an efficient neural network Active Queue Management (AQM) system as a queue controller. The recurrent neural network has a Multi-layer Perceptron-Infinite Impulse Response (MLP-IIR) structure. Three distinct neural AQMs are trained under different network scenarios involving traffic levels. Selecting one of three neural AQMs is based on posterior probability history of traffic level. Liu [6] introduced a new type of neural networks controller based on PSD (proportion, sum and differential) to improve the lack of fixed gain in single neuron adaptive PID. Li [7] presents extensive comparative simulation results for four neural AQM schemes, namely, Neuron PID, Adaptive Neuron AQM (AN-AQM), Fuzzy Assisted PID controller based on Neuron Network (FAPIDNN), Neuron Reinforcement Learning (NRL), versus three traditional AQM schemes together with a modified PI scheme named Intelligent Adaptive Proportional Integral (IAPI) over a wide range of conditions and scenarios.

Related Works
Sensor networks with dense distribution of nodes, are usually divided into clusters according to regions. Each cluster has a cluster head, which is used for data collection and forwarding within the cluster. Cluster heads communicate with each other and can be rotated. The designed algorithm is usually placed on the cluster head nodes to solve the problem of data congestion. For the congestion problem of WSNs, researchers have proposed many congestion control mechanisms. Demura [8] proposed a protocol to send data over less crowded paths. Li [9] proposed time-data-driven sleep scheduling and spatial-data-driven anomaly detection approaches to reduce data redundancy. Rajeswari [10] proposed an improved traffic generation mechanism based on TCP/IP protocol to alleviate network congestion. To reduce energy consumption and data loss due to network congestion, Sangeetha [11] proposed an energy-saving congestion control method which periodically adjusts the degree and topology of sensor nodes according to a certain time interval. Paranjape [12] proposed a congestion control technique for intra-cluster congestion control where cluster heads Cho [5] presented an efficient neural network Active Queue Management (AQM) system as a queue controller. The recurrent neural network has a Multi-layer Perceptron-Infinite Impulse Response (MLP-IIR) structure. Three distinct neural AQMs are trained under different network scenarios involving traffic levels. Selecting one of three neural AQMs is based on posterior probability history of traffic level. Liu [6] introduced a new type of neural networks controller based on PSD (proportion, sum and differential) to improve the lack of fixed gain in single neuron adaptive PID. Li [7] presents extensive comparative simulation results for four neural AQM schemes, namely, Neuron PID, Adaptive Neuron AQM (AN-AQM), Fuzzy Assisted PID controller based on Neuron Network (FAPIDNN), Neuron Reinforcement Learning (NRL), versus three traditional AQM schemes together with a modified PI scheme named Intelligent Adaptive Proportional Integral (IAPI) over a wide range of conditions and scenarios.

Related Works
Sensor networks with dense distribution of nodes, are usually divided into clusters according to regions. Each cluster has a cluster head, which is used for data collection and forwarding within the cluster. Cluster heads communicate with each other and can be rotated. The designed algorithm is usually placed on the cluster head nodes to solve the problem of data congestion. For the congestion problem of WSNs, researchers have proposed many congestion control mechanisms. Demura [8] proposed a protocol to send data over less crowded paths. Li [9] proposed time-data-driven sleep scheduling and spatial-data-driven anomaly detection approaches to reduce data redundancy. Rajeswari [10] proposed an improved traffic generation mechanism based on TCP/IP protocol to alleviate network congestion. To reduce energy consumption and data loss due to network congestion, Sangeetha [11] proposed an energy-saving congestion control method which periodically adjusts the degree and topology of sensor nodes according to a certain time interval. Paranjape [12] proposed a congestion control technique for intra-cluster congestion control where cluster heads actively Sensors 2020, 20, 1862 3 of 16 monitor the congestion according to the information of traffic intensity, buffer occupancy and number of competitors.
The data collection in WSNs is not bounded by time limit and data quantity, that is, the data collection is irregular, and the network topology changes constantly when the nodes move. In such kind of dynamic conditions, the congestion situation of network node is more complicated. Therefore, an efficient and adaptive congestion control scheme is needed. To this end, Zhang [13] proposed the Proportional Integral Derivative (PID) controller to the network congestion control problem. The PID controller has the advantages of strong adaptability, simple operation and high efficiency, which can effectively reduce the length of message queue and limit network congestion. However, the PID controller itself is not perfect, as it has many defects. The predecessors have proposed many kinds of PID controller improvement schemes, but still have the insufficiencies when it is applied to the WSNs. Yan [14] combined the credit allocation Cerebellum Model Articulation Controller (CACMAC) with the PID controller to further improve the measurement effect, but did not consider that the parameters of the PID controller cannot be changed according to the change of the input quantity, which reduces the credibility of the later data. Mahdi [15] presented an improved PID controller, which improves the control effect and reduces the energy consumption without affecting the transmission link quality. However, this method neglects the problem of low precision in PID controller under the control environment with high requirements. Using the excellent global search ability of the meta-heuristic algorithm to improve the adaptive ability of PID controller. Agarwal [16] combined the meta-heuristic Grey Wolf optimization algorithm with PID controller. However, it also ignores the problem that it will fall into the local optimal accuracy problem in later stage. Pradhan [17] put forward the nonlinear Autoregressive Moving Average (ARMA) algorithm to PID control to realize its parameter self-tuning, but the convergence speed of the ARMA itself needs to be improved. Morawski [18] proposed a data transfer method based on evolutionary game among network nodes. In this method, the nodes do not form a fixed path. The set of nodes participating in the data transfer automatically adjusts to the current network condition by playing a game to obtain a low-cost routing option. However, this method of controlling the direction of node movement may not be suitable for highly random scenarios. Mast [19] presents a method to optimize the PID controller by concave-convex programming and to optimize the design problem by means of gridding. However, the complexity of gridding will increase with the increase of control parameters. Ioannou [20] described in detail the node localization protocol in wireless networks in document. Therefore, the application of PID Controller in congestion control of WSNs needs to consider the problems of low adaptive ability and low calculation accuracy.
Aiming at the defects of PID Controller, we propose the Cuckoo Fuzzy-PID Controller (CFPID), whose core idea is to apply the Cuckoo search algorithm to optimize the fuzzy PID controller's quantization factor and PID parameter increment. It can effectively adjust and control the congestion in WSNs by its fast convergence ability. In addition, the parameters of CFPID controller can be adjusted by means of the Fuzzy Control Algorithm to improve its adaptive ability. Then, according to the real-time packet loss rate calculated by the mode and PID control, the on-line optimization is carried out by using the Cuckoo search to obtain the optimal precision of the loss probability, thus controlling the instantaneous queue length. This mechanism improves the adaptive ability and accuracy of the control system.

Fuzzy PID Congestion Control Model Based on Cuckoo Search
We introduce the traditional PID controller into the congestion control of WSNs, and calculate the instantaneous queue length and real-time packet loss rate of message queue. Because of the irregular network environment and data collection, the controller has strong self-adaptive ability. We combine the fuzzy control with the traditional PID controller to realize its parameters self-tuning. The real-time packet loss rate is recalculated, and based on this; a meta-heuristic algorithm with excellent global search ability and fast convergence speed is introduced to optimize the calculation accuracy of the real-time packet loss rate. The proposed algorithm is then used to calculate the real-time packet loss Sensors 2020, 20, 1862 4 of 16 rate of the Cuckoo search. Finally, the length of the instantaneous queue is controlled according to the packet loss rate to achieve the effect of congestion control.
In light of the above ideas, we propose the Cuckoo Fuzzy-PID Controller (CFPID) model, which is divided into two steps: the design of the Fuzzy-PID Controller (FPID) with the queue length of the nodes as the control object, and the optimization of the FPID by the Cuckoo search.

Traditional PID Network Congestion Controller in WSNs
PID is a classical control algorithm which transforms all kinds of algorithms of the active queue management system into the controller. The goal of this algorithm is to keep the value of the control object near the expected value [21]. Compared with the traditional active queue management method, the PID controller has strong robustness and simple model structure which can make the control effect more stable. The principle of PID controller is to combine the proportion of deviation (P), integral (I) and differential (D) to control the controlled object effectively, which makes the controller design more flexible and more selective [22].
We apply the PID controller to WSNs, and take the queue length as the control object. After the adjustment of proportion, integral and differential, the message dropping probability is obtained, and the queue length is controlled by the probability of packet dropping to control the degree of congestion. The PID control schematic diagram is shown in Figure 2.
Sensors 2020, x, x 4 of 16 time packet loss rate of the Cuckoo search. Finally, the length of the instantaneous queue is controlled according to the packet loss rate to achieve the effect of congestion control. In light of the above ideas, we propose the Cuckoo Fuzzy-PID Controller (CFPID) model, which is divided into two steps: the design of the Fuzzy-PID Controller (FPID) with the queue length of the nodes as the control object, and the optimization of the FPID by the Cuckoo search.

Traditional PID Network Congestion Controller in WSNs
PID is a classical control algorithm which transforms all kinds of algorithms of the active queue management system into the controller. The goal of this algorithm is to keep the value of the control object near the expected value [21]. Compared with the traditional active queue management method, the PID controller has strong robustness and simple model structure which can make the control effect more stable. The principle of PID controller is to combine the proportion of deviation (P), integral (I) and differential (D) to control the controlled object effectively, which makes the controller design more flexible and more selective [22].
We apply the PID controller to WSNs, and take the queue length as the control object. After the adjustment of proportion, integral and differential, the message dropping probability is obtained, and the queue length is controlled by the probability of packet dropping to control the degree of congestion. The PID control schematic diagram is shown in Figure 2. In Figure 1, is the expected queue length, is the instantaneous queue length, is the message drop probability, and is the control deviation variable of the queue length which can be expressed as in Equation (1).
According to Figure 1, the expected queue length is the input and the packet loss rate is the output to control the instantaneous queue length.
In the process of using PID controller to control the queue length, the function of each control link is as follows.
(1) Proportional control: Once the deviation signal e is generated; the control system will immediately reflect it in proportion, the fastest speed to reduce the deviation. (2) Integral control: It is mainly used to eliminate the steady-state error and reduce the error rate of the control system. The effect of integral control depends on the integral time constant t in such a way that the smaller the t, the more obvious will be the effect of integral control. (3) Differential control: Differential control can reflect the variation rate and trend of deviation signal. A correction signal is introduced to speed up the operation of the system, and reduce the adjustment time before the deviation signal becomes too large. Therefore, the control law of the PID controller can be expressed as Equation (2).  In Figure 1, y d is the expected queue length, y is the instantaneous queue length, p is the message drop probability, and e is the control deviation variable of the queue length which can be expressed as in Equation (1).
According to Figure 1, the expected queue length y d is the input and the packet loss rate p is the output to control the instantaneous queue length.
In the process of using PID controller to control the queue length, the function of each control link is as follows.
(1) Proportional control: Once the deviation signal e is generated; the control system will immediately reflect it in proportion, the fastest speed to reduce the deviation. (2) Integral control: It is mainly used to eliminate the steady-state error and reduce the error rate of the control system. The effect of integral control depends on the integral time constant t in such a way that the smaller the t, the more obvious will be the effect of integral control. (3) Differential control: Differential control can reflect the variation rate and trend of deviation signal. A correction signal is introduced to speed up the operation of the system, and reduce the adjustment time before the deviation signal becomes too large.

of 16
Therefore, the control law of the PID controller can be expressed as Equation (2).
The incremental form of p(k) can be expressed as Equation (3).

Design of Congestion Controller (FPID) Based on Modulus and PID
In the traditional PID controller design, the proportional, integral and differential parameters are fixed while the adaptive adjustment ability is lacking [23]. In view of this flaw, this article uses the mold and the control technology to add the adjustment to the PID controller's parameter.
The fuzzy control does not need the precise mathematical model of the controlled object, and can be well optimized for the complex control situation of nonlinear change and real-time change [24]. The main work of fuzzy control is to use fuzzy rules to fuzzy control objects and fuzzy reasoning. In this manuscript, we first introduce the mold and control into the PID controller to optimize its parameters, and get the increment of the PID parameters through the mode and rule and the mode and reasoning. Then, new PID parameters are obtained by weighting the initial parameters, so as to realize the parameter self-tuning optimization function of PID. The module and PID control schematic diagram are shown in Figure 3.
The incremental form of can be expressed as Equation (3).

Design of Congestion Controller (FPID) Based on Modulus and PID
In the traditional PID controller design, the proportional, integral and differential parameters are fixed while the adaptive adjustment ability is lacking [23]. In view of this flaw, this article uses the mold and the control technology to add the adjustment to the PID controller's parameter.
The fuzzy control does not need the precise mathematical model of the controlled object, and can be well optimized for the complex control situation of nonlinear change and real-time change [24]. The main work of fuzzy control is to use fuzzy rules to fuzzy control objects and fuzzy reasoning. In this manuscript, we first introduce the mold and control into the PID controller to optimize its parameters, and get the increment of the PID parameters through the mode and rule and the mode and reasoning. Then, new PID parameters are obtained by weighting the initial parameters, so as to realize the parameter self-tuning optimization function of PID. The module and PID control schematic diagram are shown in Figure 3. where e is the deviation of the queue length in the network node, ec is the deviation rate, and , , are the parameter increments obtained by means of a fuzzy inference. The e and ec are used as the inputs of the die and the controller while , and are used as outputs which result in the final FPID tuning parameter and are expressed as Equations (4)-(6). = , and are the initial values of the proportional-integral-differential parameters. According to the characteristics of the control object and the performance requirements of the control system, the tuning parameters of the PID controller cannot depend on the mathematical model of the controlled object. According to the regulation law of each link, repeated test, and set Where e is the deviation of the queue length in the network node, ec is the deviation rate, and ∆k p , ∆k i , ∆k d are the parameter increments obtained by means of a fuzzy inference. The e and ec are used as the inputs of the die and the controller while ∆k p , ∆k i and ∆k d are used as outputs which result in the final FPID tuning parameter and are expressed as Equations (4)- (6).
where, k p0 , k i0 and k d0 are the initial values of the proportional-integral-differential parameters.
According to the characteristics of the control object and the performance requirements of the control Sensors 2020, 20, 1862 6 of 16 system, the tuning parameters of the PID controller cannot depend on the mathematical model of the controlled object. According to the regulation law of each link, repeated test, and set k p0 = 0.00129, k i0 = 0.00222, k d0 = 0.00095. The parameter increments ∆k p , ∆k i and ∆k d are deduced by the fuzzy rule and model.

The Model and Rule of FPID Controller
In the process of parameter setting, we need to consider the relationship between the parameters. Therefore, the requirements for ∆k p , ∆k i and ∆k d are as follows: (1) When the absolute value of the message queue length offset in the network node |e| is large, ∆k p is a positive number, that is, increase in k p will improve the response speed of regulation; To prevent the occurrence of large overshoot, usually set ∆k i = 0. To prevent the differential saturation caused by the instantaneous change of the queue length deviation e, ∆k d should be smaller than the control range. In order to improve the control effect, we combine the triangular membership function with sigmoid membership function.
The analytic function of the triangular membership function can be represented as Equation (7).
While the analytic function of the sigmoid membership function takes the following form: When the two are combined, the membership function curve of the input and output variables are shown in Figure 4. The PFID Controller's fuzzy rules are shown in Table 1.
While the analytic function of the sigmoid membership function takes the following form: When the two are combined, the membership function curve of the input and output variables are shown in Figure 4. The PFID Controller's fuzzy rules are shown in Table 1.

Deblurring
According to the above protocol, the e, the ec and the resulting output variables are the fuzzy variables which need to be obtained by means of anti-ambiguity. Anti-modulus has a variety of ways, and commonly used is the area of the central method, maximum membership method and area integration method. Here we use the area center method to find the membership degree of the parameter increments , and which are mathematically expressed as Equations (9)-(11). = , After the adjustment of the modulus and the rule, , and can be obtained from the measurement of the queue length deviation e and the deviation rate ec. The mathematical formulas

Deblurring
According to the above protocol, the e, the ec and the resulting output variables are the fuzzy variables which need to be obtained by means of anti-ambiguity. Anti-modulus has a variety of ways, and commonly used is the area of the central method, maximum membership method and area integration method. Here we use the area center method to find the membership degree of the parameter increments ∆k p , ∆k i and ∆k d which are mathematically expressed as Equations (9)-(11). µ ∆k p = min µ NB (e) , µ NB (ec) (9) µ(∆k i ) = min µ NB (e) , µ NB (ec) After the adjustment of the modulus and the rule, ∆k p , ∆k i and ∆k d can be obtained from the measurement of the queue length deviation e and the deviation rate ec. The mathematical formulas are as Equations (12)- (14).
Sensors 2020, 20, 1862 8 of 16 After calculating ∆k p , ∆k i and ∆k d , we can get the parameters of the PID controller, that is, the final parameters of the FPID controller. By substituting these parameters into Equation (2), the updated packet loss rate p can be obtained.

Cuckoo Search for FPID Optimization
Compared with the traditional PID controller, the accuracy of the FPID controller is improved, but there is still room for further improvement. The packet loss rate calculated by FPID is not the optimal one, but tends to the optimal one [25]. To solve this problem, we use the efficient optimization ability of the Cuckoo search to optimize the packet loss rate which lead to get the final accurate value and control the queue length more accurately.
The Cuckoo search is an efficient meta heuristic optimization algorithm that mimics the way cuckoo birds hatch and reproduce [26]. In nature, cuckoos do not build their own nests. Instead, they seek out nests of other birds to lay their eggs and allow other birds to help them hatch. However, the host has a reasonable chance of finding the intruder's eggs, at that point, the host may choose to either eliminate the eggs or abandon the nest. The Cuckoo search meets the following rules: (1) A good host nest will be passed on to the next generation.
(2) The host has a fixed probability of discovery represented by p a such that p a ∈ [0, 1].
(3) Each bird lays only one egg at a time and is placed in a randomly selected host nest with a fixed number of nests.
Based on the above idea, in order to get the best packet loss rate, the message loss probability in the FPID model is taken as the target object and the model of the Cuckoo search-based mode and the CFPID controller (CFPID) is established, as shown in Figure 5. After calculating , and , we can get the parameters of the PID controller, that is, the final parameters of the FPID controller. By substituting these parameters into Equation (2), the updated packet loss rate p can be obtained

Cuckoo Search for FPID Optimization
Compared with the traditional PID controller, the accuracy of the FPID controller is improved, but there is still room for further improvement. The packet loss rate calculated by FPID is not the optimal one, but tends to the optimal one [25]. To solve this problem, we use the efficient optimization ability of the Cuckoo search to optimize the packet loss rate which lead to get the final accurate value and control the queue length more accurately.
The Cuckoo search is an efficient meta heuristic optimization algorithm that mimics the way cuckoo birds hatch and reproduce [26]. In nature, cuckoos do not build their own nests. Instead, they seek out nests of other birds to lay their eggs and allow other birds to help them hatch. However, the host has a reasonable chance of finding the intruder's eggs, at that point, the host may choose to either eliminate the eggs or abandon the nest. The Cuckoo search meets the following rules: (1) A good host nest will be passed on to the next generation.
(2) The host has a fixed probability of discovery represented by such that ∈ 0, 1 .
(3) Each bird lays only one egg at a time and is placed in a randomly selected host nest with a fixed number of nests.
Based on the above idea, in order to get the best packet loss rate, the message loss probability in the FPID model is taken as the target object and the model of the Cuckoo search-based mode and the CFPID controller (CFPID) is established, as shown in Figure 5. The message drop probability changes with the increment of parameter , and , and its expression is recorded as . Taking as the objective function of cuckoo search and using Levis flight as the search path, the maximum value of message packet loss rate is calculated by updating and iterating.
The updated formula for the Cuckoo search path is as Equation (15).
where, represents the position of the packet loss rate of the Kth update at the Tth iteration. Furthermore, is the step factor which follows the normal distribution, so we set = 1. And , represents Levy-flight. A random walk through Levy-flight to get a random nest is formulated as Equation (16).
According to the above process, the Cuckoo search process is divided into four steps.
Step 1: initialize the population size N, the maximum number of iterations M and other parameters. In this manuscript, we set the population size N as 100, the maximum iteration number  The message drop probability p changes with the increment of parameter ∆k p , ∆k i and ∆k d , and its expression is recorded as p(k). Taking p(k) as the objective function of cuckoo search and using Levis flight as the search path, the maximum value of message packet loss rate p(k) is calculated by updating and iterating.
The updated formula for the Cuckoo search path is as Equation (15).
where, p (t) k represents the position of the packet loss rate of the Kth update at the Tth iteration. Furthermore, α is the step factor which follows the normal distribution, so we set α = 1. And Levy(s, λ) represents Levy-flight. A random walk through Levy-flight to get a random nest is formulated as Equation (16).
Sensors 2020, 20, 1862 9 of 16 According to the above process, the Cuckoo search process is divided into four steps.
Step 1: initialize the population size N, the maximum number of iterations M and other parameters. In this manuscript, we set the population size N as 100, the maximum iteration number M as 100 and the probability of discovery as p a such that p a = p (t) k t , and set its initial value as p a = 1. Taking packet loss rate p(k) as the objective function, update the formula for packet loss rate as Equation (17).
Step 2: Calculate the value of each position of p(k) and update the position using Levis's flight Levy(s, λ). Then, calculate the objective function value R for this position and compare it with p a . If R > p a , then record R is the current optimal position and update the nest position, otherwise the position remains unchanged.
Step 3: If the maximum number of iterations is satisfied, proceed to the next step or return to step 2.
Step 4: Output the global optimal solution and determine the best packet loss rate choice. Pseudo code for the Cuckoo search is shown in Algorithm 1. With the best solution and the best location for the solution 10: m ← m + 1 11: end while The loss of packets can lead to an unacceptable increase in the number of packets, resulting in the loss of critical data when a certain amount is reached. In this method, the active packet loss starts earlier, the packet loss is planned and uniform, and the number of lost packets is kept at a low proportion, which can effectively avoid this problem.
The CFPID algorithm is an active queue management method with the ability of self-regulation. In this algorithm, the maximum number of iterations is M, the maximum population size is N, and there are no nested loops. So, the computational complexity of each iteration is less than O(M), and the spatial complexity of the Cuckoo search represented by O(N). In terms of active regulation, Levis Flight Levy(s, λ) is essentially a random walk with a fixed step, which is a Markoff chain. The next state position of the algorithm only depends on the current state and the discovery transition probability p a . Most of the new solutions of the algorithm are derived from far-field randomization, and is far enough from the current optimal solution to ensure that the system does not fall into local optimality.

Simulation
In order to solve the problem of low accuracy in the computation of network congestion in WSNs, this manuscript presents a PID controller with a mold and a Cuckoo search. Furthermore, a mold and PID congestion control mechanism based on Cuckoo search is designed. The proposed CFPID algorithm is compared with the original PID algorithm and Immune clonal simulated annealing based Blue (IBLUE) algorithm [26] in terms of instantaneous queue length, packet loss rate and throughput which verified the feasibility of the improved algorithm.
In the comparison experiment, in order to make a more accurate and fair simulation comparison, the proportional, integral and differential parameters of the PID algorithm are set as the initial proportional, integral and differential parameters of the CFPID algorithm. So, set k p0 = 0.00129, k i0 = 0.00222 and k d0 = 0.00095. IBLUE redefines the queue length and updates the packet loss rate, so the initial queue length and the expected queue length of CFPID algorithm are shared. Furthermore, the queue set value is 150 and the buffer is 220.
For performance comparison of CFPID, PID and IBLUE algorithms in WSN congestion control, this manuscript uses MATLAB R2018a. The experimental parameters are in Table 2.

Experimental Comparison of Instantaneous Queue Length
Firstly, the changes of message queue length for all the three algorithms are compared. Queue length can directly reflect the smooth transmission of message queue. If the queue length exceeds the expected value, congestion occurs and packet loss adjustments need to be made. However, the queue length is too small which will result in underutilization of network resource. Therefore, queue length should be close to the expected value. To this end, to show the effect of number of network nodes on queue length, we initially set the number of nodes to 100 for which, the length of the node queue changes as shown in Figure 5.
When the data transfer starts, the message queue length of the node will increase rapidly and easily exceed the expected value of the queue length, which causes network congestion. Upon sensing the presence of network congestion, the control mechanism immediately begins to adjust the queue length. As can be seen from the graph in Figure 6, both PID and IBLUE algorithms start to show the control effect when the queue length reaches the highest point, and the convergence speed of the instantaneous queue length to the expected value is relatively slower in the later stage. In comparison, CFPID algorithm can control the length of the instantaneous queue to the expected value with the fastest convergence speed and the smallest oscillation amplitude, which shows the superiority of its control ability.
In order to observe the performance of CFPID algorithm under more complex and dynamic conditions, the number of nodes is adjusted from 100 to 200, which increases the data transmission load of the network and the workload of a single node. Then, we compared the message instantaneous queue length adjusted by CFPID, IBLUE and PID algorithms. The instantaneous queue length curve at 200 nodes is shown in Figure 7.
As the number of nodes increases, the volume of messages transferred and the workload of network nodes increase significantly. As can be seen in Figure 7, due to the increase of data volume, all the three control algorithms have obvious oscillation phenomenon, and the number of packets to be transmitted by a single node per unit time increases, the increase of oscillation amplitude and convergence time is emphasized, especially the change of oscillation amplitude of PID Algorithm. It can be seen in the Figure 7 that the oscillation amplitude of the instantaneous queue length controlled by CFPID algorithm is smaller than that of PID and IBLUE algorithms, and the convergence speed is the fastest. In order to observe the performance of CFPID algorithm under more complex and dynamic conditions, the number of nodes is adjusted from 100 to 200, which increases the data transmission load of the network and the workload of a single node. Then, we compared the message instantaneous queue length adjusted by CFPID, IBLUE and PID algorithms. The instantaneous queue length curve at 200 nodes is shown in Figure 7. As the number of nodes increases, the volume of messages transferred and the workload of network nodes increase significantly. As can be seen in Figure 7, due to the increase of data volume, all the three control algorithms have obvious oscillation phenomenon, and the number of packets to be transmitted by a single node per unit time increases, the increase of oscillation amplitude and convergence time is emphasized, especially the change of oscillation amplitude of PID Algorithm. It can be seen in the Figure 7 that the oscillation amplitude of the instantaneous queue length controlled by CFPID algorithm is smaller than that of PID and IBLUE algorithms, and the convergence speed is the fastest.

Real-Time Packet Loss Rate Comparison
This manuscript compares the real-time packet loss rate of nodes for CFPID, PID and IBLUE algorithms. Generally, when the number of nodes increases, the number of packets to be transmitted also increases, resulting in the lengthening of the instantaneous queue length. When the length of the  In order to observe the performance of CFPID algorithm under more complex and dynamic conditions, the number of nodes is adjusted from 100 to 200, which increases the data transmission load of the network and the workload of a single node. Then, we compared the message instantaneous queue length adjusted by CFPID, IBLUE and PID algorithms. The instantaneous queue length curve at 200 nodes is shown in Figure 7. As the number of nodes increases, the volume of messages transferred and the workload of network nodes increase significantly. As can be seen in Figure 7, due to the increase of data volume, all the three control algorithms have obvious oscillation phenomenon, and the number of packets to be transmitted by a single node per unit time increases, the increase of oscillation amplitude and convergence time is emphasized, especially the change of oscillation amplitude of PID Algorithm. It can be seen in the Figure 7 that the oscillation amplitude of the instantaneous queue length controlled by CFPID algorithm is smaller than that of PID and IBLUE algorithms, and the convergence speed is the fastest.

Real-Time Packet Loss Rate Comparison
This manuscript compares the real-time packet loss rate of nodes for CFPID, PID and IBLUE algorithms. Generally, when the number of nodes increases, the number of packets to be transmitted also increases, resulting in the lengthening of the instantaneous queue length. When the length of the

Real-Time Packet Loss Rate Comparison
This manuscript compares the real-time packet loss rate of nodes for CFPID, PID and IBLUE algorithms. Generally, when the number of nodes increases, the number of packets to be transmitted also increases, resulting in the lengthening of the instantaneous queue length. When the length of the queue exceeds the expected value, the network congestion will be aggravated. Therefore, it is necessary to control the queue length by dropping a certain number of packets through the message dropping probability. The packet loss rate will change with the change in the instantaneous queue length, and the queue length will be controlled near the expected value. However, the unceasing change of packet loss rate will make the queue length change continuously, which will lead to the instability of the network. Therefore, the convergence rate and stability of the instantaneous packet loss rate will determine the performance of the network.
To this end, Figure 8 shows the change in the real-time packet loss rate when the initial number of nodes is set to 100. As can be seen from the graph, the CFPID algorithm can find out the danger more accurately when the message queue grows greatly. After a small amount of oscillation, CFPID will be the fastest to find the balance point, then only a small adjustment can be made to maintain the instantaneous queue length in a relatively stable state of health. loss rate will determine the performance of the network.
To this end, Figure 8 shows the change in the real-time packet loss rate when the initial number of nodes is set to 100. As can be seen from the graph, the CFPID algorithm can find out the danger more accurately when the message queue grows greatly. After a small amount of oscillation, CFPID will be the fastest to find the balance point, then only a small adjustment can be made to maintain the instantaneous queue length in a relatively stable state of health. In order to observe the convergence rate and stability of packet loss rate in complex scenarios, the number of nodes is increased to 200 which lead to further increase in the overall data volume and the number of packets to be transmitted by each node. We compare CFPID, IBLUE and PID congestion control mechanisms in complex case of packet loss rate changes. The change curve is shown in Figure 9.  In order to observe the convergence rate and stability of packet loss rate in complex scenarios, the number of nodes is increased to 200 which lead to further increase in the overall data volume and the number of packets to be transmitted by each node. We compare CFPID, IBLUE and PID congestion control mechanisms in complex case of packet loss rate changes. The change curve is shown in Figure 9.
To this end, Figure 8 shows the change in the real-time packet loss rate when the initial number of nodes is set to 100. As can be seen from the graph, the CFPID algorithm can find out the danger more accurately when the message queue grows greatly. After a small amount of oscillation, CFPID will be the fastest to find the balance point, then only a small adjustment can be made to maintain the instantaneous queue length in a relatively stable state of health. In order to observe the convergence rate and stability of packet loss rate in complex scenarios, the number of nodes is increased to 200 which lead to further increase in the overall data volume and the number of packets to be transmitted by each node. We compare CFPID, IBLUE and PID congestion control mechanisms in complex case of packet loss rate changes. The change curve is shown in Figure 9.  The loss of data packets may cause the increase of the number of data packets and the loss of key data when the data reaches a certain amount. This may lead to the data information not being transmitted to the base station in time and cannot be accepted. In our method, the active packet loss starts earlier, the packet loss is planned and uniform, and the number of lost packets is kept at a low proportion, which can effectively avoid this problem. As the number of nodes increases, the packet loss rate curves for the three methods are shown in Figure 10.
The loss of data packets may cause the increase of the number of data packets and the loss of key data when the data reaches a certain amount. This may lead to the data information not being transmitted to the base station in time and cannot be accepted. In our method, the active packet loss starts earlier, the packet loss is planned and uniform, and the number of lost packets is kept at a low proportion, which can effectively avoid this problem. As the number of nodes increases, the packet loss rate curves for the three methods are shown in Figure 10. As can be seen from the Figure 10, in the process of increasing the node distribution density, the increase of data makes the packet loss rate of the whole network present an upward trend. Among them, the loss rate of PID Algorithm has been kept at a high level, so that the key data cannot be transmitted in time, resulting in the decline of real-time data. The CFPID Algorithm can keep the gentle increasing slope, control the rate of packet loss in a relatively low proportion, and ensure the real-time of data.

Experimental Comparison of Throughput
Finally, we compare the average throughput of the three algorithms when the number of nodes increases. Throughput is an indicator of network performance. Increasing the number of nodes indirectly increases the amount of data passed. The throughput changes are shown in Figure 11. Generally, an increase in the number of nodes will result in an increase in the messages transferred, decrease in the transmission time, and an increase in the throughput. It is clear from the Figure 11 that the throughput of the three congestion control algorithms increases with the increase of the number of nodes. When the number of nodes is small, CFPID algorithm has the highest throughput. With the increase of the number of nodes, the throughput of IBLUE and PID will be surpassed by CFPID, which shows the superiority of CFPID in terms of stability, and adaptive As can be seen from the Figure 10, in the process of increasing the node distribution density, the increase of data makes the packet loss rate of the whole network present an upward trend. Among them, the loss rate of PID Algorithm has been kept at a high level, so that the key data cannot be transmitted in time, resulting in the decline of real-time data. The CFPID Algorithm can keep the gentle increasing slope, control the rate of packet loss in a relatively low proportion, and ensure the real-time of data.

Experimental Comparison of Throughput
Finally, we compare the average throughput of the three algorithms when the number of nodes increases. Throughput is an indicator of network performance. Increasing the number of nodes indirectly increases the amount of data passed. The throughput changes are shown in Figure 11.
The loss of data packets may cause the increase of the number of data packets and the loss of key data when the data reaches a certain amount. This may lead to the data information not being transmitted to the base station in time and cannot be accepted. In our method, the active packet loss starts earlier, the packet loss is planned and uniform, and the number of lost packets is kept at a low proportion, which can effectively avoid this problem. As the number of nodes increases, the packet loss rate curves for the three methods are shown in Figure 10. As can be seen from the Figure 10, in the process of increasing the node distribution density, the increase of data makes the packet loss rate of the whole network present an upward trend. Among them, the loss rate of PID Algorithm has been kept at a high level, so that the key data cannot be transmitted in time, resulting in the decline of real-time data. The CFPID Algorithm can keep the gentle increasing slope, control the rate of packet loss in a relatively low proportion, and ensure the real-time of data.

Experimental Comparison of Throughput
Finally, we compare the average throughput of the three algorithms when the number of nodes increases. Throughput is an indicator of network performance. Increasing the number of nodes indirectly increases the amount of data passed. The throughput changes are shown in Figure 11. Generally, an increase in the number of nodes will result in an increase in the messages transferred, decrease in the transmission time, and an increase in the throughput. It is clear from the Figure 11 that the throughput of the three congestion control algorithms increases with the increase of the number of nodes. When the number of nodes is small, CFPID algorithm has the highest throughput. With the increase of the number of nodes, the throughput of IBLUE and PID will be surpassed by CFPID, which shows the superiority of CFPID in terms of stability, and adaptive Generally, an increase in the number of nodes will result in an increase in the messages transferred, decrease in the transmission time, and an increase in the throughput. It is clear from the Figure 11 that the throughput of the three congestion control algorithms increases with the increase of the number of nodes. When the number of nodes is small, CFPID algorithm has the highest throughput. With the increase of the number of nodes, the throughput of IBLUE and PID will be surpassed by CFPID, which shows the superiority of CFPID in terms of stability, and adaptive adjustment in complex cases. As can be seen from the Figure 11, the throughput of the method presented in this manuscript is improved by 4%-8% compared with the comparison method.

Comparison of Running Time under Different Number of Nodes
In this manuscript, our designed CFPID scheme is compared with ARED [27] and Ras algorithms [28] in running time. Generally, a gradually increase in the density of network nodes increases the number of nodes and indirectly increase the overall network data. The running time of the algorithm can directly reflect the load capacity of the algorithm in complex environment. In addition, the short running time can reduce the loss of network resources. The run-time changes are shown in Figure 12.
Sensors 2020, x, x 14 of 16 adjustment in complex cases. As can be seen from the Figure 11, the throughput of the method presented in this manuscript is improved by 4%-8% compared with the comparison method.

Comparison of Running Time under Different Number of Nodes
In this manuscript, our designed CFPID scheme is compared with ARED [27] and Ras algorithms [28] in running time. Generally, a gradually increase in the density of network nodes increases the number of nodes and indirectly increase the overall network data. The running time of the algorithm can directly reflect the load capacity of the algorithm in complex environment. In addition, the short running time can reduce the loss of network resources. The run-time changes are shown in Figure 12. As can be seen from the Figure 12, as the number of sensor nodes in the network increases, the data received by the nodes increases greatly, and the running time of the algorithm also increases. Among them, the running time of CFPID algorithm is the least. This is because the convergence speed of the algorithm is fast and it can find the appropriate packet loss scheme in the shortest time. In addition, CFPID algorithm can control the degree of congestion, so it can effectively save the energy of sensor nodes and prolong the lifetime of sensor network effectively. At the same time, an increase in the number of nodes increases the complexity of the environment but CFPID algorithm can still show good adaptability which reflects the stability of this algorithm.

Conclusion
In this manuscript, a new congestion control mechanism for WSNs is proposed, which combines fuzzy and PID control with Cuckoo search control. The real-time packet loss rate is calculated by PID controller to control the instantaneous queue length of nodes. The parameters of PID are adjusted by mold and control to improve the self-adaptive optimization ability, and the corresponding mold and rules are given. Finally, the Cuckoo search is used to optimize the accuracy of packet loss rate globally. In future, more meta-heuristic optimization algorithms can be combined to optimize the optimization rate of the Cuckoo search and the mode, and the PID controller.  As can be seen from the Figure 12, as the number of sensor nodes in the network increases, the data received by the nodes increases greatly, and the running time of the algorithm also increases. Among them, the running time of CFPID algorithm is the least. This is because the convergence speed of the algorithm is fast and it can find the appropriate packet loss scheme in the shortest time. In addition, CFPID algorithm can control the degree of congestion, so it can effectively save the energy of sensor nodes and prolong the lifetime of sensor network effectively. At the same time, an increase in the number of nodes increases the complexity of the environment but CFPID algorithm can still show good adaptability which reflects the stability of this algorithm.

Conclusions
In this manuscript, a new congestion control mechanism for WSNs is proposed, which combines fuzzy and PID control with Cuckoo search control. The real-time packet loss rate is calculated by PID controller to control the instantaneous queue length of nodes. The parameters of PID are adjusted by mold and control to improve the self-adaptive optimization ability, and the corresponding mold and rules are given. Finally, the Cuckoo search is used to optimize the accuracy of packet loss rate globally. In future, more meta-heuristic optimization algorithms can be combined to optimize the optimization rate of the Cuckoo search and the mode, and the PID controller.