Skip to main content
. 2024 Dec 26;25(1):72. doi: 10.3390/s25010072
Algorithm 4: Congestion-aware fault-tolerant routing.
Input: Positions of UAVs Pi=(xi,yi,zi), velocity of UAVs (Vxi,Vyi,Vzi), residual energy level of UAVs E(i), congestion data from ferry nodes, queue length QL, packet rate PR, and neighbor table NT.
Output: Primary path and secondary path.
# Step 1: Initialize UAV parameters
1: for each UAV i  do:
2: Pi=(xi,yi,zi), Vi=(Vxi,Vyi,Vzi), Ei=Ei, QLi=0, PRi=0, and NTi={ }
3: end for
# Step 2: Periodically send Hello Messages and collect neighbor data
4: for each UAV i  do:
5:   Broadcast (Hello Message)
6: end for
7: for each UAV i  do:
8: Receive Hello Message from neighbor j
9: Update NTi={Pj, Vj, Ej, QLj, PRj}
10: end for# Step 3: Ferry nodes collect global information (density and congestion)11: for each ferry node do:12: Collect positions of all UAVs within communication range
13: Calculate the regional density=Number of UAV in AreaArea size
14: Share the density and congetion level with all UAVs15: end for # Step 4: Eligibility phase based on energy threshold
16: for each UAV i do:
17: Eligible nodes=[ ]18: for each neighbor j of UAV i do:
# Check if neighbor j has sufficient residual energy
19:  if EjEth then
20: Eligible nodes append (j) // Add j to list of eligible nodes
21:  end if
22: end for
23: end for
# Step 5: Fitness evaluation for eligible nodes (primary path)
24: for each UAV i  do:
25:  Best fitness value BFV=1
26:  Selected forwarder=None
27:  for each eligible neighbor j in eligible nodes do
# Predict future position of UAV j based on mobility 
28: Predict the future position using (18)
# Calculate distance from future position to destination
29: Calculate the distance from future position to destination using (19)
# Calculate directionality score (if moving toward destination)
30: Calculate the direction Dirj=(Vj,(destinationPj) 
31:  if Dirj>0 then
32: Calculate the mobility score and load for neighbor j using (20) and (21)
33: Calculate the fitness value using (22)
34:  if FVj>BFV then
35                BFV=FVj and select forwarder node j
36:              end if
37:          end if
38:    end for
39: end for
# Step 6: Congestion monitoring by ferry nodes for secondary path activation
40: for each ferry node do:
41: Collect QL, PL, UD and measure the congestion level by CLnet=f(QL, PL, UD)
42:     for each UAV i in region do
43:Send CL to UAV
44:  end for
45: end for
# Step 7: Decision logic for fault-tolerant secondary path activation
46: for each UAV i  do:
47:  if CLnet>CLth then
48:         Activate ARP=True
49:  else Activate ARP=False
50:  end if
51: end for
# Step 8: Secondary path selection for congestion avoidance (if activated)
52: if activate ARP then
53:  for each eligible neighbour k of UAV i not on the primary path do
54:     Ensure geographic separation from primary path using (24)
55:     if direction seperation k>Ath then
56:    Calculate the load for secondary path candidate k
57:    Calculate the fitness function for secondary path candidate k using (25)
58:    if FFk>BFV then
59:                   BFV=FFk
60:                 end if
61:           end if
62:    end for
63: end if
# Step 9: Forward data via selected paths
64: for each UAV i do:
65: if activate secondary path ARP then
66:    Forward packet (selected forwarder)   // Primary Path
67:    Forward packet (selected secondary forwarder) // Secondary Path
68:   else forward packet (selected forwarder)   // Only Primary Path
69:   end if
70: end for