{'fraction_non_alphanumeric': 0.027647162807141596, 'fraction_numerical': 0.007671910906841082, 'mean_word_length': 4.692493459448581, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Multilevel Mobile Fog Computing Offloading Model Based on UAV-Assisted and Heterogeneous Network

The mobile fog computing (MFC) network that integrates unmanned aerial vehicles (UAV) fully exerts its advantages of flexible deployment, load balance, and rapid response. Under complex network environment, proposing a reasonable offloading model and according resource optimization of the MFC network is important to satisfy high-requirement offloading standard. In this paper, a multilevel MFC offloading model where UAV and fog nod undertake relay nodes and offloading computing nodes are established for computation-intensive and latency-critical tasks, considering heterogeneous network selection , dynamic channel quality and central cloud access . With the total system utility optimality function including reward function maximization as the goal, the MDP algorithm is applied to solve the best offloading decision of the computing task and the balanced load mode of the MFC network. Finally, the simulation section verifies the excellent performance of the proposed multilevel MFC offloading model in network resource utilization. Simulation results show that the model can optimize the relative position of service nodes in MFC network and ensure the offloading reliability of terminal equipment.


Introduction
In the era of rapid development of mobile communication technology, smart driving, smart home, unmanned detection, and other Internet of Things technologies are constantly changing lifestyles. More and more complex tasks make the computing power, and energy storage of mobile terminals face great challenges. The development of the center cloud of super computing power can make the complex computing task be offloaded and solve the problem of resource limitation of mobile terminal [1]. However, due to the remote location of the central cloud, the limitation of transmission bandwidth and transmission capacity makes the latency-critical tasks unable to complete the calculation and transmission in the effective time [2]. Edge computing brings the computing power of the cloud to the edge of the network and reduces the task response time. In edge computing network, offloading requests are limited to edge equipment and the function of edge computing is limited [3]. The mobile fog computing (MFC) network, the transition layer between central cloud and mobile terminal, solves these problems [4]. The mobile fog computing network can significantly reduce communica-tion delay, improve network capacity, and increase network computing processing capacity.
Fog computing is a highly virtualised platform that provides, computes, stores, and networks services between end devices and traditional cloud computing data centers, typically, but not exclusively located at the edge of network [5]. Compared with edge computing, fog computing contains a large number of physically distributed devices with stronger scalability. Fog computing has a multilevel, multifunctional continuous architecture that transcends edges and central clouds.
In recent years, the research of MFC has attracted more and more attention. For the joint optimization problem of QoE (quality of experience) and energy in integrated fog computing process with fairness, the way of collaborative processing tasks between fog nodes is studied in Reference [6]. Considering fog node energy consumption and task processing delay, [7] applies centralized and distributed system structures to analyze task processing locations. In this paper, a two-tier architecture including the fog nodes (FNs) with less computing resources and energy resources and the fog access points (F-APs) with sufficient computing and energy resources is used to optimize fog computing network resource utilization. Due to the mobility of the terminal equipment, the location of the terminal device and the network connection will migrate, resulting in reduced system utility. In particular, the authors in [8] leverage a follow-me edge concept for enabling lightweight live migration which means services should follow the user mobility. Considering the mobility of users, the paper proposes three mechanisms to ensure the continuity of postmigration services and user experience. In Reference [9], for the request of each mobile user, FN will decide the way to serve the user, that is, whether to compute the task at the edge of the network or to refer the task to the central cloud for saving. A Markov decision process (MDP) is used in the reference to solve resource optimization problems and is validated for system performance and adaptability. In solving resource optimization decision problems, there is an excellent performance for the MDP algorithm (extension of the Lyapunov algorithm), and its application direction is extended to many fields. In addition, the algorithm used to solve the offloading strategy of edge cloud computing and fog computing is the Gauss-Newton iteration method [10].
UAV is a promising solution in carrying communication, monitoring environment, and computing offloading. UAV with FN can provide more flexible and accurate network layout mode for mobile terminal devices. In [11], under the constraints of UAV propulsion energy consumption and joint optimization of UAV's trajectory, speed and acceleration, and FAP uplink transmit power, the paper proposes an iterative algorithm based on successive convex approximation (SCA) to solve this problem. In the three-level fog computing network, Xianglin et al. [12] apply three decision algorithms to solve a joint resource optimization problem, which is formulated that takes the weighted sum of energy consumption and delay experienced by tasks as the objective function. This paper analyzes and demonstrates the distribution scheme of UAV position, mobile device processing frequency, transmission power, and fog node. The multilevel network mode [13] can realize the hierarchical processing of FN and FAP in the MFC and increase the computational offloading efficiency.
The UAV as a FN node should not only assume the function of computing and offloading but also the relay function of task forwarding to FAP. When the UAV assumes relay functions in MFC networks, on the one hand, the reduced energy of UAV processing tasks can support longer operation; on the other hand, the coverage and distance of MFC network are expanded flexibly. By three calculations, [14] optimized the UAV-assisted network resource allocation scheme with the goal of minimizing the total energy consumption including communication-related energy. [15] minimized the weighted sum energy consumption of the UAV and UEs subject to the task constraints, the information-causality constraints, the bandwidth allocation constraints, and the UAV's trajectory constraints. The MFC system, which integrates UAV, exerts the advantages of flexible network distribution in fog computing and enhances the network reliability and task offloading capability. Analyzing the offloading mode, reducing the total delay and reducing the integrated energy cost [16] can increase the network resource utilization.
The central cloud is a nonnegligible part of a MFC network that can take on large amounts of cache and uninstall. In most studies [17], fog computing is connected with the central cloud with wireless network. A few papers studying the relationship between optical fiber and fog computing networks [18] focus on the coordination of optical networks. Fiber-optic central cloud and MFC network are used to optimize the resource and enhance the data processing capability of the network.
The location migration caused by terminal movement is fully analyzed in MFC [19]; however, the change of access network caused by location movement is often ignored. Mobile terminals tend to access low-cost networks (e.g., Wi-Fi networks), which can reduce transmission costs. Low-cost networks at different locations are not the same. When the location of the mobile terminal changes, the lowcost network that the user expects to access changes [20]. To solve the problem of network migration and mobile fog computing offloading, in heterogeneous networks, this paper proposes an integrating UAV multilevel MFC network offloading model (IMMFCM) based on the MDP algorithm. The distinct contributions of this paper are as follows: (i) The multilevel MFC network offloading model containing terminal equipment, UAV, FAP, and central cloud is constructed for remote communication and low-cost coverage scenarios, where UAVs are connected with terminal equipment and FAP through a wireless network, and the central cloud is connected with FAP through optical fiber. Multilevel network structure can classify fog nodes and realize efficient utilization of resources (ii) UAVs undertake relay and FN functions in the integrated MFC network, which realizes the MFC flexible, efficient, and low-cost networking mode. Considering the size of the task itself, the model applies the MDP algorithm to obtain the best resource optimization and offloading decision by an iterative method (iii) Considering the heterogeneous network, this model analyzes the network selection of mobile terminals in the MFC network during migration and obtains the best offloading strategy to realize low-cost network connection

Multilevel MFC System
MFC extends the computing, storage, and network capabilities of the cloud to the edge; solves the problems of network unavailability, over-full bandwidth, and delay time to some extent; and realizes the high-speed and low-delay applications. The MFC network containing UAV and central clouds is suitable for multiple complex application scenarios. When MFC is applied to emergency rescue, the network can realize fast networking and timely transmission of information. When MFC is applied to agricultural data monitoring  [13]. At this point, UAV act as a fog node (FN) in the MFC network to serve mobile terminal equipment. In this paper, the UAV can undertake two functions of task computing offloading or relay forwarding. MFC, as the middle layer of the network [21], cooperates with the central cloud to process tasks, which is an important way of offloading and caching. A multilevel MFC system model considered in this paper is shown in Figure 1.
Considering the environment in which the mobile terminal equipment is located, different wireless technologies (e.g. Wi-Fi networks, cellular networks) are deployed in the access network. Mobile terminal equipment can select the best communication quality network in heterogeneous networks for access and task offloading. Once the mobile terminal equipment has completed the access network selection, the offloading process will adopt the wireless network. FAP is far away from the cloud center and uses optical fiber to transmit information [22].

Multilevel Network
Model. The proposed system is a multilevel MFC network offloading model in this paper, as shown in Figure 1. Zero-level offloading contains mobile terminal devices. At the first-level offloading, UAV with fog node and relay node functions contains certain computing resources. The UAV as the relay node can transmit the computing task to FAPs. At the second-level offloading, FAP has large forwarding capacity and computing resources, which can provide the services of computing offloading and task forwarding. In the third-level offloading, the central cloud has numerous computing resources that can provide processing and caching for very large computing tasks.
Zero-Level Offloading (Level 0). When the hardware resources of the terminal equipment meet the calculation requirements and cache capacity of the task, the task carries on the calculation processing in the terminal equipment. Level 0 offloading is suitable for easier task selection.
First-Level Offloading (Level 1). This level means that when the local resources are not enough to complete the computing task, the terminal equipment offloads the task to the nearby UAV (FN) with computing resources.
Second-Level Offloading (Level 2). When the computing task is so complicated that UAV cannot undertake it or UAV energy is insufficient, the task is offloaded to the FAP. The FAP will process the task and return the result. There are two ways for Level 2. The first way is to offload the task directly to Level 2 through the wireless network. The second way is to offload the task to Level 2 by UAV relay.
Third-level Offloading (Level 3). When the task requires caching or the task complexity exceeds FAP capabilities, the tasks are forwarded through the FAP to the central cloud. There are also two ways for Level 3. The first way is to offload the task to Level 2 and then to Level 3. The second way is to forward the task from the UAV relay to the second unload level and then to the third unload level. The second way is to offload the task to Level 2 by UAV relay and then transfer the task to Level 3.
The task can be offloaded directly by the equipment or relayed through the UAV when Level 2 is selected. The task must pass through the FAP if Level 3 is selected. The multilevel offloading decision algorithm is executed in the terminal equipment, and the execution result will show the offloading level that the task finally selects. The offloading process is shown in Figure 2.
The time delay cost T αβ (Z, R, δ, ω, d) and energy cost E αβ (Z, R, δ, ω, d) of each offloading process are calculated according to the size of the task Z, the computing resources R, the energy consumption state δ, the channel capacity ω, and the transmission distance d, where α = f0, 1, 2, 3g is the offloading level, β = f0, 1, 2g is the way of offloading level. The cost function calculation method references the paper [23]. E and T normalize to E αβ 0 = normalizationðE αβ Þ and T αβ 0 = normalizationðT αβ Þ [24]. The normalized parameters are related to the transmission environment and processing equipment, where the transmission environment parameters are related to the channel bandwidth characteristics [25]. The where φ 1 is the weighted factor to balance the two cost functions. The time delay cost includes task execution delay, transmission delay, and propagation delay. The energy cost includes terminal emission energy, relay energy, equipment operation energy, and task calculation energy.

MFC Network Offloading Algorithm
This part obtains the system utility function by analyzing the offloading state, offloading action, and offloading state transfer. The MDP algorithm is used to implement offloading decision, resource optimization, and utility function solution.
Define the state space S as S = G × L × W, where G represents the offload stage, L represents the area of the mobile terminal equipment, and W represents the connection status of the mobile terminal equipment to the MFC network. The offloading stage G is defined as G = f0, 1, 2, 3, 4, 5, 6, 7g, (g ∈ G), where g = 1 indicates that the task occurs and determines the offloading stage of the task; g = 2 indicates that the task chooses Level 0, α = 0, β = 0; g = 3 indicates that the task is buffered at the first level and judged the offloading level, α = 1, β = 0; g = 4 indicates that the task is buffered at the second level and judged the offloading level, α = 2, β = 0; g = 5 indicates that the task chooses Level 1, α = 1, β = 0; g = 6 indicates that the task chooses Level 2, α = 2, β = 1/2; g = 7 indicates that the task chooses Level 3, α = 3, β = 1/2.
The area L = fL 1 , L 2 , L 3 , ⋯, L NL g of the mobile terminal equipment can be constructed by the map segmentation [26]. The mobile terminal moves arbitrarily in the constructed map. NL demotes the total number of areas the terminal can move. L i = ½l i 1 , l i 2 , l i 3 , ⋯, l i NL represents a vector of adjacent cases. If l j i = 1, the area i is adjacent to area j; otherwise, l j i = 0 represents nonadjacent. W = fW 1 , W 2 , W 3 , ⋯, W NW ,g represents the wireless network vector, where NW denotes the total number of combinations of K network connections in heterogeneous net-works, NW = 2 K :W χ represents χth the network connection combinations. W χ = ½w 1 , w 2 , w 3 , ⋯, w K , where w ζ = 1 means the network can be connected and w ζ = 0 means the network is not connected.
As the task status is in the buffer period (g = 1, 3, 4), the algorithm selects the final offloading level of computing tasks, that is, the policy decision action. The policy decision action will select the offloading path and offloading level of the task. The offloading action is defined as where O YU is the action from the initial state to Level 1; O YA is the action from the initial state to the Level 1 buffer state; O YF is the action from the initial state to the Level 2 buffer state; O AA is the action that the task finally selects the Level 1; O AF is the action from Level 1 to Level 2; O FF is the action that the task finally selects Level 2, O FC is the action from Level 2 to Level 3, and the task finally selects Level 3; D is that the task conducts delay processing.
The policy decision action will affect the stage in which the task is located; that is, the action A will affect the state G. And when the terminal equipment area is known, the connectionable network corresponding to the area is also known. The transition probability from the current state, s = ½g, L i , W χ , to the next state, s ′ = ½g ′ , L j , W χ′ , can be described by P½g ′ | g, a is the transition probability of G in different task stages. τ represents the duration of each decision epoch. We assume that the interarrival rate of the task follows an exponential distribution with mean 1/λ G . Therefore, the transition probability from g = 0 to g = 1 is λ G τ. When the task stage g = 1, 2, 3, 4, 5, 6, 7, and a is determined, the state transition probability P½g′ | g, a = 1. The state transition diagram is as Figure 3. P½L j , W χ ′ | L i , W χ is related to the time that the terminal equipment stays in each area and the heterogeneous network topology. This paper assumes that the residence time of the terminal in the area i (L i ) obeys an exponential distribution with a parameter of 1/η i [21]. Therefore, P½L j , W χ′ | L i , W χ   Wireless Communications and Mobile Computing can be derived as where P ij is the probability that the terminal equipment moves from area i to the area j. When the location area switches, the heterogeneous network to which the mobile terminal can be connected will also change. Different locations and different networks have different network costs. The system will consider choosing the best network for task offloading.
The system utility function is determined by the final stage of the task and the process actions. The system utility function Uðs, aÞ is defined as where Rðs, aÞ represents the reward function that the task is successfully processed during the energy and time delay period [25]. φ 2 is defined as a weighting factor for the balance, the cost function, and the reward function. Hðs, aÞ is the system cost function in the Equation (1).
where r g is the reward value for the offloading stage at the g.
Let vðsÞ be the expected total system utility optimality function when the initial state is s. Then, we can describe vðsÞ as where v π ðsÞ is the expected total system utility optimality function between the first decision epoch and the last deci-sion epoch, when the policy π with an initial state s is given. Note that the expected total system utility optimality function can be maximized when the terminal equipment takes the most beneficial action a, and such an optimal action a in each state s can be obtained by solving the formulated objective function. The optimality equation is given by where ð1 − λÞ is a discounter factor in the MDP model ð0 ≤ ð1 − λÞ < 1Þ. The goal of the algorithm is to find the total system utility optimality function and the optimal computational offloading strategy [20,27] in the multilevel MFC network model. The algorithm is precomputed at the terminal. The calculated offloading strategy is cached in the terminal according to the task size [28].

Simulation
The simulation settings are based on the works in [22,23,29]. The detailed simulation parameters are listed in Table 1 unless specified otherwise.
In Figure 4, the utility function decreases with the increase of the task size. It can be seen that the total utility function of the multilevel mobile fog computing model proposed in this paper is the highest, which shows that the proposed model can realize the effectiveness and reliability of the network. During this simulation environment, the mobile terminal is close to the FAP and the direct communication environment is better. When the computing task is smaller, the utility function of S-ter is close to the S-immfcm. When the task is increased a little, the utility function of S-fap is close to the S-immfcm. And the utility function of S-uav is much different from the S-immfcm. This phenomenon indicates that mobile terminal equipment tends to offload the task directly to the FAP when the communication environment is better. When the task is huge, the utility function of S-cen is close to the S-immfcm. This is due to the excessive system burden and the low utility function caused by huge tasks. The terminal is more expected to transfer tasks to the central cloud for computation.

4.2.
Relation of Transport Distance d to Offloading Policy. The distance between mobile terminal equipment and fog node affects the quality of communication channel. This part will change the distance from terminal equipment to UAV and FAP and analyze the trend of system utility function and offloading decision. The distance relationship is shown in Table 2: In the model, the UAV is always between the terminal equipment and the FAP. And the distance from the terminal device to the FAP is equal to the distance from the terminal equipment to the UAV plus the distance from the UAV to the FAP. The simulation results are shown in the following figure.
As shown in Figure 5, when the task size is certain, among the three distances, the Distes-A utility function is the highest and the Distes-C utility function is the lowest. This phenomenon indicates that the longer the distance between the mobile terminal and the fog node in the MFC network, the worse the service quality and the higher the system resource waste.
As shown in Figure 6, the terminal selection of offloading nodes is different as the task increases. And "0'" is Level 0, "1" is Level 1, "2" is Level 2, "2.5" is UAV relay Level 2, "3" is Level 3, and "3.5" is UAV relay Level 3. As the task increases, under three distance environments, the offloading level   Wireless Communications and Mobile Computing switches from Level 0 to Level 1 at the same time. This is because it is the terminal's own computing resources that restrict the performance of the terminal and is less affected by the communication environment. When the task is larger than a certain value, the terminal cannot undertake the task processing. Compared with Distes-A, Distes-B has a longer distance between the terminal and UAV, and the communication environment becomes worse. The offloading strategy changes from directly Level 2 to UAV relay Level 2. When the distance between the terminal and UAV also increases, the system cost is too high after relaying, and the final task is to offload to the central cloud for calculation. This shows that the multilevel MFC network helps to select a suitable offloading fog node according to the communication environment, which ensures the efficient use of system resources and improves the user's service quality.

Delay Cost Analysis.
In the Internet of Things, the delay problem is the indicator that the terminal pays more attention to. This part will analyze the delay of the MFC network and MEC network in the process of task offloading.
In Figure 7, the time delay in both MFC and MEC networks increases stepwise as the task is increasing. MFC network time delay performance is obviously better than the MEC network for lightweight task offloading. This shows that the MFC network can provide more flexible, balanced, and fast offloading services for most computing tasks. The stepped rise of delay caused by the change of the offloading level in the figure can also illustrate that the multilevel offload model helps reduce the delay in the network.

4.4.
Discussion on φ 1 . The weighting factor φ 1 influences the relationship between the cost function and the total system optimality utility function and affects the system task offloading decision. When the distance relationship between nodes is fixed to Distes-B, the simulation analysis is shown in the following figure.
As shown in Figure 8, when the task is small, the system total utility function with a smaller φ 1 value is higher; when the task size is in the middle value, the system total utility function with a larger φ 1 value is higher; when the task is large, the system total utility function with a smaller φ 1 value is slightly higher. This is because different sizes of tasks choose different offloading locations and have different propensities for delay and energy consumption. When the task is small, the mobile terminal equipment offloads the task to the resource-limited UAV. Since the UAV energy is limited, the system will pay more attention to the cost of energy, so the smaller the φ 1 value, the higher the system total utility function. For the same reason, with the increase of tasks and the change of task offloading position, the different tendencies of the system to energy and time delay will affect the system's total utility function corresponding to different φ 1 values.
In Figure 9, as the task increases, the offloading strategy corresponding to different φ 1 values will be different. When    Wireless Communications and Mobile Computing the value of φ 1 is large (the system pays more attention to the delay cost), the terminal equipment tends to offload the task at a lower level to reduce the offload delay cost. Conversely, when the value of φ 1 is small (the system pays more attention to the cost of energy), the terminal equipment will consider transmitting the task to the central cloud for processing. When the task is very large, the delay cost is too large, and the task will be switched to the first Level 2 with the smallest delay. Figure 10 shows the effect of the weighting factor φ 1 on the utility functions of seven scenarios at a fixed task size. The utility function of S-uav will decrease with the increase of the weight value; in the S-fap, S-refap, and S-cen scenarios, the utility function will increase with the increase of the weighted factor; S-recen and S-ter scenarios are less affected by the value of φ 1 , but the system utility value is very low; the utility function of S-immfcm proposed in this paper is superior to the utility functions of other scenarios and is less affected by φ 1 . The multilevel MFC network model is less affected by the weighting factor, and the utility function is relatively stable. No matter the system is prone to delay or energy, the IMMFM can find a suitable offloading scheme and ensure efficient utilization of system resources.

Conclusion
Aiming at the problem of offloading strategies for computation-intensive and latency-critical tasks in the network, in a heterogeneous network environment, this paper analyzes the system utility functions of delay and energy consumption in the integrating UAV MFC network. In the case where UAV contains relay function and fog node function, an integrating UAV multilevel MFC network offloading model including the central cloud based on the MDP algorithm is proposed. In the multilevel offloading model, each offloading level can flexibly share the offload task, achieve the best use of system resources, ensure the user's QOS, and reduce the computing burden on the terminal equipment. Optimizing the positional relationship between fog nodes can improve the communication quality of the channel and ensure the reliability of task offload, which is also the direction of subsequent research.

Data Availability
The simulation parameter data used to support the findings of this study are included within the article.