## 2 Multilevel Edge Network Task Offloading Model
### Multilevel Network Structure  
This study considers an edge cloud containing heterogeneous networks with different wireless access technologies (e.g., Wi-Fi and cellular networks) deployed in the network.  
The proposed system includes a three-level offloading model of the user, UAV, and G-MEC levels, as shown in Figure 2. The user level includes the monitoring equipment, mobile users, and other terminal equipment. The UAV level contains the UAV with the MEC server and relay functions. The UAV has certain computing resources and the relay ability to transfer the computing task to the G-MEC level. The G-MEC level contains a ground-fixed MEC server close to the user. Moreover, the G-MEC has substantial computing resources and energy, which can provide a powerful computing offloading service.  
Zero-level offloading (Level 0): If the user's available resources can process the computation task within the required QOS wait time, then the user performs local processing. Zero-level offloading applies to tasks that require simple low computing and energy resources.  
First-level offloading (Level 1): The terminal device unloads the task to the nearby UAV, which acts as the MEC server for computing task processing. The first-level offloading is applicable to the local resources that cannot undertake the computation task completion, and the user offloads the problem task to a suitable nearby UAV with the MEC server function.  
Second-level offloading (Level 2): After the terminal device offloads the task to the UAV, the UAV serves as a relay to re-forward the task to a resource-sufficient G-MEC server. The secondary offloading is applicable when the problem task is so complex that neither the mobile terminal nor the UAV can undertake the processing of the computing task. Alternately, when the UAV energy is insufficient, the UAV acts as a relay node to offload the problem task to the G-MEC. The G-MEC processes the task and returns the result.  
If the task cannot be offloaded to any edge server and cannot be computed locally, then the task will be delayed.  
Processing computing tasks at different offloading levels generates different transport and energy costs. As the G-MEC is generally located far from the mobile device and requires relay transmission, the high transmission delay and transmission energy consumption of the computation offloaded to the G-MEC may lead to higher transmission costs. The reliability of the system may be reduced by increasing the BER and interrupt probability due to the relay and distance. However, the task  
Figure 2: Multilevel offloading structure.  
offloaded to the G-MEC has a low computational cost, sufficient computing and energy resources, low computational delay, and the capability to undertake complex tasks. When the computing task is offloaded in the UAV, the delay and transmission costs are small, and the reliability is high because of the close transmission distance. However, given the limited energy of the UAV, the cost of running and calculating the energy consumption is high, and its own energy resource condition affects the reliability of task completion. Transport costs are not required to handle tasks in mobile devices, but local computing delays and energy costs cannot be supported because of hardware constraints.  
The equipment at each terminal deploys a decision engine to implement the offload selection algorithm proposed in this study. The required decision engine determines whether the current task can be performed locally or whether it needs to be unloaded to the appropriate offloading level. Considering the heterogeneous network and UAV mobility and energy finiteness problems, this study chooses to optimize with MDP to obtain the best resource optimization scheme.