### 4.1 System model

In this paper, we consider a heterogeneous UAV-enabled air-to-ground MEC network as depicted in Fig. 1. In the MEC network, there are *K* ground users (Users Devices, i.e., UDs), *W* legitimate UAV nodes (Helpers Devices, i.e., HDs) and an eavesdropper (EV). UDs have low latency and critical tasks to process and so need to seek assistance from HDs under some circumstance. To reduce tasks execution costs while fulfilling demand, UDs need to optimize them offloading decision. Notably, the computing capacity of HDs is more powerful than UDs. Hence, UDs can avail better service quality (e.g., lower delay, lower energy consumption) from HDs in the constraints of the computing capacity of HDs.

At the beginning period, the tasks that need to be processed are generated at the UDs and it has two ways to process them at this time: (1) Computing all tasks locally, (2) Selecting a HD to assist themselves. In some cases, UDs choosing to compute all tasks locally cannot complete the missions under the task delay constraint. Therefore, UDs must offload the tasks to idle HDs at this time. For simplicity, we assume that each UD selects one HD as the helper and a specific HD can assist an unlimited number of UDs under resources constraint. Notably, for multiple UDs choosing the same HD, the computing resources allocated by each UD will reduce.

Nevertheless, the UDs deciding to offload tasks will exploit a single channel to transmit the offloading data and interfere with other UDs occupying the same channel. UDs and HDs finishing the computing tasks will transmit the results of the computing tasks to the logical cluster head (pre-assigned by a specified UAV) for data aggregation.

However, during data offloading, malicious eavesdroppers can obtain the data due to the sharing of wireless channels, which leads to user safety and privacy violations. Therefore, considering security measurement as a factor is essential in making offloading decisions.

UDs and HDs sets are \({\mathcal {K}}\text {=}\left\{ 1,\ldots k,\ldots ,K \right\}\) and \({\mathcal {W}}\text {=}\left\{ 1,\ldots ,w,\ldots ,W \right\}\), respectively, and the set of available channel is \({\mathcal {M}}=\left\{ 1,\ldots ,m,\ldots ,M \right\}\). Besides, suppose there is a multi-antenna eavesdropper EV. EV eavesdrops on multiple channels. We define the position of legitimate UAV *w* as \(\left( {{x}_{w}},{{y}_{w}},H \right) ,w\in {\mathcal {W}}\). Similarly, the position of EV is \(\left( {{x}_{EV}},{{y}_{EV}},H \right)\) and the position of UD *k* is \(\left( {{x}_{k}},{{y}_{k}},0 \right) ,k\in {\mathcal {K}}\). Essentially, UDs can estimate the location of EV [40]. Therefore, we assume that the location of EV is known as a priori. Considering the air-to-ground channel as the line-of-sight (LOS) link, the channels power gain from UD *k* to HD *w* and EV is \({{h}_{k,w}}=\frac{{{\beta }_{0}}}{{{\left( {{x}_{k}}-{{x}_{w}} \right) }^{2}}+{{\left( {{y}_{k}}-{{y}_{w}} \right) }^{2}}+{{H}^{2}}}\) and \({{h}_{k,EV}}=\frac{{{\beta }_{0}}}{{{\left( {{x}_{k}}-{{x}_{EV}} \right) }^{2}}+{{\left( {{y}_{k}}-{{y}_{EV}} \right) }^{2}}+{{H}^{2}}}\). Here, \({{\beta }_{0}}\) represents the channel power at the reference distance \({{d}_{0}}=1\). Thus, the data transmission rate between UD *k* and HD *w* is as follows:

$$\begin{aligned} {{R}_{k,w}}=B{{\log }_{2}}\left( 1+\frac{{{p}_{k,w}}{{h}_{k,w}}}{{{N}_{0}}+\sum \limits _{i\in {\mathcal {K}}\backslash \left\{ k \right\} ,j\in {\mathcal {W}}:{{q}_{i,j}}={{q}_{k,w}}}{{{p}_{i,j}}{{h}_{i,w}}}} \right) . \end{aligned}$$

(1)

Here *B* is the channel bandwidth, \({{N}_{0}}\) denotes the background noise power, and \({p}_{k,w}\) represents transmission power of UD *k*. Similarly, the eavesdropping rate (if it exists) between UD *k* and EV is as follows:

$$\begin{aligned} {{c}_{k}}=B{{\log }_{2}}\left( 1+\frac{{{p}_{k,EV}}{{h}_{k,EV}}}{{{N}_{0}}+\sum \limits _{i\in {\mathcal {K}}\backslash \left\{ k \right\} ,j\in {\mathcal {W}}:{{q}_{i,j}}={{q}_{k,w}}}{{{p}_{i,j}}{{h}_{i,w}}}} \right) . \end{aligned}$$

(2)

Here \({p}_{k,EV}\) is the transmission power between UD *k* and eavesdropper EV. Though, the exact value of \({h}_{k,EV}\) is difficult to obtain. However, the probability distribution can usually be estimated [41]. Therefore, the value of \({h}_{k,EV}\) can be used as a priori in this paper.

The computing task of UD \(k\left( k\in {\mathcal {K}} \right)\) can be defined as \({{\nu }_{k}}=\left\{ {{\gamma }_{k}},{{\eta }_{k}},{{\tau }_{k}} \right\}\), where \({{\gamma }_{k}}\) is the number of tasks to be processed in UDs, \({{\eta }_{k}}\) represents the number of CPU cycles per byte required for computing when UDs and HDs process tasks, \({{\tau }_{k}}\) is the maximum delay requirements of tasks processing. Let \({{{\mathcal {S}}}_{k}}\text {=}\left\{ {{{\mathcal {D}}}_{k}},{{{\mathcal {Q}}}_{k}} \right\}\) indicate the strategy profile of UD *k*, where \({{{\mathcal {D}}}_{k}}\text {=}\left\{ \rho _{k}^{w}|w\in {\mathcal {W}},0\le \rho _{k}^{w}\le 1 \right\}\) represents the UD *k*’s task assignment and association with HDs. For example, \(\rho _{k}^{w}=0\) when UD *k* decides to process all tasks locally and \(\rho _{k}^{w}=1\) when it transmits all task data to HD *w*. \({{{\mathcal {Q}}}_{k}}\text {=}\left\{ q_{k,w}\right\}\) is the transmission channel between UD *k* and HD *w* when computation offloading exists; note that \(q_{k,w}\) represents the channel selected by UD *k*. Particularly, \(q_{k,w}=0\) represents that UD *k* computes all tasks locally. UD *k*’s work process has five phases, as shown in Fig. 2.

#### 4.1.1 Global information interaction and offloading decision

Above all, all UDs and HDs begin to interact with others after the task generation. Interactive information includes task delay, the size of tasks (only UDs need to provide this information), and computing capacity (of both UDs and HDs). Further, UDs exploit an efficient task offloading mechanism to decide the sub-optimal strategy (including UDs’ offloading rate, offloading object, and transmission channel) and the sub-optimal strategy should improve the energy efficiency and safety of the air-to-ground MEC system as much as possible under the constraints of the tasks delay and the computing capacity.

#### 4.1.2 Tasks offloading

According to (1), the transmission time of task data (offloading part) of UD *k* is:

$$\begin{aligned} t_{k}^{\mathrm{off}}=\frac{{{\gamma }_{k}}\rho _{k}^{w}}{{{R}_{k,w}}}. \end{aligned}$$

(3)

Accordingly, the communication energy consumption of UD *k* is:

$$\begin{aligned} E_{k,w}^{\mathrm{off}}=\frac{{{\gamma }_{k}}{\rho _{k}^{w}}}{{{R}_{k,w}}}\cdot {{p}_{k,w}}. \end{aligned}$$

(4)

The set of UDs helps by HD *w* are \({{{\mathcal {Z}}}_{w}}=\left\{ {{z}_{w,1}},{{z}_{w,2}},\ldots ,{{z}_{w,{{l}_{w}}}} \right\}\) , where \({{l}_{w}}\) is the number of UDs helped by HD *w*. We suppose that each HD equally distributes the computing resources to the assisted UDs.

#### 4.1.3 Remoting computation

The association HD of UD *k* begins to implement computing tasks after task offloading. The time duration in this phase is:

$$\begin{aligned} t_{k}^{\mathrm{remote}}=\frac{{{\gamma }_{k}}{\rho _{k}^{w}}{{\eta }_{k}}}{{{\alpha }_{w}}{{f}_{w}}}. \end{aligned}$$

(5)

Here, \({{f}_{w}}\) is the computing capacity of HD *w* (in GHz) and \({{\alpha }_{w}}=\frac{1}{{{l}_{w}}}\). Then, the overall energy consumption of *w* (HDs only have the computing energy consumption) is as follows:

$$\begin{aligned} E_{w}^{c}={{\kappa }_{w}}\sum \limits _{n\in {{{\mathcal {D}}}_{w}}}{{{\gamma }_{n}}\rho _{n}^{w}{{\eta }_{n}}}{{\alpha }_{w}}^{2}f_{w}^{2}. \end{aligned}$$

(6)

Here \(\kappa {}_{w}\) is a factor indicating the effective capacitance coefficient related to the hardware architecture of the computing units [42].

**Local computation:** Then the time for UD *k* to perform local computing is as follows:

$$\begin{aligned} t_{k}^{c}=\frac{{{\gamma }_{k}}{{\eta }_{k}}\left( 1-\rho _{k}^{w} \right) }{{{f}_{k}}}. \end{aligned}$$

(7)

Here \({{f}_{k}}\) denote the CPU frequency of UD *k* (also in GHz). Therefore, the energy consumption of UD *k*’s local computing is:

$$\begin{aligned} E_{k}^{c}={{\kappa }_{k}}{{\gamma }_{k}}{{\eta }_{k}}f_{k}^{2}\left( 1-\rho _{k}^{w} \right) . \end{aligned}$$

(8)

Here \({{\kappa }_{k}}\) is a constant coefficient which reflects the energy consumption of CPU when processing data tasks (same as \({{\kappa }_{w}}\) above). Finally, for the tasks generated by UD *k* , its whole execution time is:

$$\begin{aligned} T_{k}^{\mathrm{total}}=\max \left\{ t_{k}^{\mathrm{off}}+t_{k}^{\mathrm{remote}},t_{k}^{c} \right\} . \end{aligned}$$

(9)

The overall energy consumption of UD *k* (including computing part and communication part) is:

$$\begin{aligned} {{E}_{k}}=E_{k}^{c}+E_{k}^{\mathrm{off}}, \end{aligned}$$

(10)

while the whole energy consumption of HD *w* (only the computing part) is:

$$\begin{aligned} {{E}_{w}}=E_{w}^{c}. \end{aligned}$$

(11)

#### 4.1.4 Results aggregation

After performing all tasks, both UDs and HDs will upload results to the logical cluster head (a pre-specified role, played by a legitimate UAV) for data aggregation. The cluster head will collect the data analysis results or forwarding them to other nodes needing information. Most of the existing research works related to MEC usually ignore the size of the data. Similarly, we do not consider the data size of the results in this study and thus, ignoring the time spent in this phase.

In this paper, we consider a quasi-static scenario in which all mobile devices states have no change during an offloading time block (e.g., within a few hundred milliseconds). In other words, the location relationship between mobile devices is almost unchanged, and the UDs does not need to process the newly arrived task data.

### 4.2 Problem formulation

In this section, the objective is minimizing the weighted sum of system eavesdropping rate and energy consumption under multiple constraints. The optimization problem is as follows:

$$\begin{array}{*{35}{r}} \left( {\mathcal {P}}0 \right) :\underset{{{{\mathcal {D}}}_{k}},{{{\mathcal {Q}}}_{k}},\forall k\in K}{\mathop {\min }}\,{{\varepsilon }_{1}}\left( \sum \limits _{k\in {\mathcal {K}}}{{{C}_{k}}} \right) {+}{{\varepsilon }_{2}}\left( \sum \limits _{k\in {\mathcal {K}}}{{{E}_{k}}+\sum \limits _{w\in {\mathcal {W}}}{{{E}_{w}}}} \right) \\ s.t.\;\; t_{k}^{\mathrm{remote}}+t_{k}^{\mathrm{off}}\le {{T}_{k}},\forall k\in {\mathcal {K}},{\mathbf {C}}1 \\ t_{k}^{c}\le {{T}_{k}},\forall k\in {\mathcal {K}},\qquad {\mathbf {C}}2 \\ \qquad 0\le \rho _{k}^{w}\le 1,\forall k\in {\mathcal {K}},\qquad {\mathbf {C}}3. \\ \end{array}$$

(12)

Here, the \({{E}_{k}}\) and \({{E}_{w}}\) indicate the respective energy consumption of UD *k* and HD *w* and \({\varepsilon }_{1}\) and \({\varepsilon }_{2}\) are weighting factors. \({{C}_{k}}\) represents the eavesdropping rate from UD *k* to the eavesdropper, and \({{C}_{k}}={{c}_{k}}\) . The constraint \({\mathbf {C}}1\) represents that the remote computing and offloading time of UD *k* should less than \({T}_{k}\) (corresponds to the constraints of task delay). The constraint \({\mathbf {C}}2\) indicates that the time of local computing of each UD cannot exceed \({T}_{k}\). Besides, the constraint \({\mathbf {C}}3\) shows that the range for tasks offloading rate of UD *k* should be within \(\left[ 0,1 \right]\). The system energy consumption reduces when UDs offload the data to HDs, but it increases the risk of eavesdropping. Therefore, it is a trade-off between low energy consumption offloading and safe communication. UDs optimize the optimization variables (i.e., offloading rate, offloading object, and offloading channel) to minimize the objective function.