# Fuzzy Logic-Based Geographic Routing Protocol for Dynamic Wireless Sensor Networks
## 4 Simulation and Complexity Analysis  
### Feasibility Simulation of FLGR Forwarding Mode  
To verify the feasibility of the FLGR forwarding mode, the performance of the FLGR forwarding mode and GPSR forwarding mode were compared using MATLAB. During simulation, the Random Way Point model was adopted, and 20, 60, 100, and 140 nodes were placed randomly in the two-dimensional plane of \(1000\text{ m}\times 1000\text{ m}\). The maximum speed of the node was set as \(10\text{ m/s}\), \(20\text{ m/s}\), \(30\text{ m/s}\), and \(40\text{ m/s}\), respectively, and the communication radius was set as \(250\text{ m}\). Because the packet transmission process cannot be simulated in the MATLAB simulator, the time interval (\(100\text{ ms}\)) was adopted to represent the packet transmission process. For simplicity, the simulation starting time, randomly selected in [\(0\), \(3\text{ s}\)], is used to represent the time interval in the FLGR forwarding mode. \(h_{F}\) and \(h_{G}\) denote the numbers of routing hops in the FLGR and GPSR forwarding modes, respectively. \(flag_{F}\) and \(flag_{G}\) denotes the flags of the FLGR and GPSR forwarding modes, respectively. Taking the example of \(n=60,v_{\text{max}}=20\text{ m/s}\), details of the simulation process are shown as follows:  
1. 60 nodes are placed randomly in the two-dimensional plane of \(1000\text{ m}\times 1000\text{ m}\). The location information is stored as an initial local network location table. Two nodes are randomly selected as a pair of transceivers. \(h_{F}\), \(h_{G}\), \(flag_{F}\), and \(flag_{G}\) are initialized to \(0\). Next, you move on to step 2. 2. The simulation starting time is randomly selected in [\(0\), \(3\text{ s}\)]. It represents the time interval in formula 1. For the FLGR forwarding mode, according to the random time interval and initial local network location table, the fuzzy region of the destination node can be obtained using formula 1 and formula 2. Next, you move on to step 3 and step 4. Step 3:If \(flag_{F}=0\), according to the node selection algorithm of the FLGR forwarding mode, the next forwarding node can be selected, then \(h_{F}\) adds 1, and go to step 4. Otherwise, go to step 5. If \(flag_{G}=0\), according to the node selection algorithm of the GPSR forwarding mode, the next forwarding node can be selected, then \(h_{G}\) adds 1, and go to step 4. Otherwise, go to step 5. Step 4:If the packet reaches the destination node in the FLGR forwarding mode, \(flag_{F}=1\); otherwise, all nodes move randomly in 100 ms with a speed of [0, 20 m/s]. Similarly, if the packet reaches the destination node in the GPSR forwarding mode, \(flag_{G}=1\); otherwise, all nodes move randomly in 100 ms with a speed of [0, 20 m/s]. Then go to step 3. Step 5:Routing process finishes. To ensure the accuracy of the results, the average value of 1000 trials is rounded as the final result. The seed changes in every trial. In this simulation, the location information of the destination node is assumed to be known. The routing hops for obtaining the location information of the destination node are not included for the GPSR forwarding mode. The simulation results are shown in Figure 8.  
As shown in Figure 8, with a certain node number, the average number of hops increases with an increase in maximum speed for the GPSR forwarding mode, as well as the FLGR forwarding mode. This phenomenon occurs because the network topology changes faster with the increase of node movement speed. For the GPSR forwarding mode, the optimal forwarding node is difficult to find, leading to more hops. Additionally, because the fuzzy location region of the destination node becomes larger, the average number of hops increases under the FLGR mode. Under a certain maximum node speed, the average number of hops decreases with a increase in node number for both the forwarding modes. This phenomenon occurs because there are fewer and fewer void nodes with an increase in node number.