1 Introduction

With the popularization of smart terminals and the Internet of Things, various terminal applications continue to emerge, which not only bring rich entertainment experience to users, but also consume more computing resources and energy consumption of terminals [1]. The computing capability of the user terminal device is limited, and cannot complete the processing of a large number of computing tasks in a short period of time. Mobile edge computing (MEC) is a new computing model [2]. By deploying computing resources at the edge of the network and spatially adjacent to end users, MEC can reduce service delay and terminal energy consumption [3].Computing offloading technology [4, 5], as one of the key technologies of MEC, transmits compute-intensive terminal applications to adjacent MEC nodes for processing through wireless links, and utilizes sufficient computing resources and energy of MEC servers to reduce the latency and energy consumption of terminal processing tasks, effectively improving service quality and user experience [6]. However, while edge computing provides users with high-quality and convenient computing services, users' personal privacy is also under great threat [7]. During task offloading, mobile devices tend to offload more tasks to the edge server when the wireless channel conditions between the user and the edge server are good, while they tend to perform more computing tasks locally when the wireless channel conditions are poor. The wireless channel condition between the user and the edge server is closely related to the distance between them. The smaller the distance between the user and the edge server, the better the wireless channel condition, and vice versa. Therefore, an untrusted edge server or an attacker can infer the wireless channel information by monitoring the user's task offloading ratio, thereby inferring the user's location information. Most previous studies have only considered the cost of task offloading [8], and there has not been much research on the location privacy issues that may occur in the process of computing offloading. This paper studies the location privacy leakage problem that may occur during computation offloading in edge computing environment, and propose a privacy-preserving edge computing offloading scheme based on whale optimization algorithm (WOPP), which uses the whale optimization algorithm to select the offloading strategy that minimizes the cost while using differential privacy technique to protect the user's real location information to achieve the balance between privacy protection and cost control.

The main contributions of this article are as follows:

  1. 1.

    Aiming at the problem of location privacy leakage that may occur in the process of computing offloading, a privacy protection mechanism is proposed, which uses differential privacy technology to obfuscate the user's real location;

  2. 2.

    The latency and energy consumption cost generated by the computing offloading process are modeled as a convex optimization problem, applying the whale optimization algorithm to solve this optimization problem, and an offloading strategy that minimizes the cost is obtained.

  3. 3.

    The effects of different parameters on the WOPP algorithm are obtained through experiments, and the effectiveness of the WOPP algorithm is verified by comparing it with other classical computing offloading schemes.

2 Related work

At this stage, research schemes on computing offloading are mainly carried out from three different optimization objectives: minimizing delay time, minimizing energy consumption, and balancing delay time and energy consumption [9,10,11]. Jiang et al. [12] studied the multi-user task offloading problem in the multi-server environment in edge computing, and transformed the task offloading problem of minimizing energy consumption into a constrained multi-dimensional multi-knapsack problem, and proposed a multi-pointer network (Multi-pointer network) to solve the problem. Wang et al. [13] developed an intelligent pricing mechanism to coordinate the computational offloading method of multi-layer devices to solve the problems of network congestion and node overload, each MEC server utilizes multi-agent reinforcement learning to determine its offloading strategy and resource allocation, thereby reducing the total energy consumption. Li et al. [14] proposed a task offloading algorithm based on double deep Q-learning net (DDQN) and a federated learning (FL) adaptive task offloading algorithm in MEC. The algorithm combines the QoS model and the deep reinforcement learning algorithm to obtain an optimal offloading policy according to the local link and node state information in the channel coherence time to address the problem of time-varying transmission channels and reduce the computing energy consumption and task processing delay. Lv et al. [15] explored the joint optimization problem of computing offloading and resource allocation for various IoT services in SD-MEC (software defined mobile edge computing) networks. In order to minimize the delay and power consumption of system utilities, a new distributed DL-based computation offloading and power resource allocation algorithm is proposed. However, the above literature mainly aims at reducing the cost of computational offloading and does not consider the privacy leakage that may occur during the computational offloading process. In recent years, people have realized the importance of privacy, and privacy-preserving mechanisms have been applied to various domains to secure users' privacy [16, 17], and some privacy-preserving mechanisms oriented to task offloading have been proposed. Zhao et al. [18] proposed a privacy-preserving computing offloading method based on k-anonymity, aiming at the problem that users' offloading tasks and offloading frequency in mobile edge computing (MEC) may cause users to be locked out by attackers. Considering that most existing blockchain mining service computing offloading frameworks ignore users’ privacy, Nguyen et al. [19] proposed a MEC-based user privacy model for mobile network, in which mobile devices select an efficient offloading decision through a constrained Markov decision process. The literature [20] proposed a privacy and energy co-aware data aggregation computation offloading scheme and used a fog-assisted three-layer secure computing architecture to ensure data offloading security. The WOPP scheme proposed in this paper considers the relationship between user location information and user task offloading decisions, as well as the trade-off between privacy protection and cost control.

3 System model and problem definition

3.1 System scenario

This paper assumes that the system consists of a terminal device and a mobile edge server. The terminal device has \(m\) tasks waiting to be processed. The task set of the user terminal is modeled as \(\mathrm{TASK}=\left\{{\mathrm{task}}_{1},{\mathrm{task}}_{2},\dots ,{\mathrm{task}}_{m}\right\}\), and the \(ith\) task is modeled as \({\mathrm{task}}_{i}=\left\{{U}_{i},{D}_{i},{R}_{i},{r}_{i}^{s}\right\}\), where \({U}_{i}\) represents the data volume of the \(ith\) task, \({D}_{i}\) represents the data volume of the processing result of the \(ith\) task, and \({R}_{i}\) represents the number of CPU cycles required by the CPU of the user terminal device or MECS to process each bit task, \({r}_{i}^{s}\) represents the number of MECS resources required to process the \(ith\) task. Model the MECS as \(mecs=\left({f}_{e},{P}^{D},\mathrm{rs}\right)\), where \({f}_{e}\) is the processing capability of the mecs, which can be expressed by the number of CPU cycles per second, \({P}^{D}\) denotes the transmitting power of the MECS, and \(rs\) denotes the number of computational resources owned by the MECS. The user terminal device is modeled as \(User=\left({f}_{l}^{c},{P}_{l},{P}^{U}\right)\), where \({f}_{l}^{c}\) denotes the computing capability of the user terminal, which can be expressed by the number of CPU cycles per second, \({P}_{l}\) denotes the computing power of the user terminal device, and \({P}^{U}\) denotes the transmitting power of the user terminal device to send data to the MECS. The offloading decision of the \(ith\) task is represented by the offloading ratio \({\lambda }_{i}\).

The mobile edge computing model is shown in Fig. 1. The user terminal device can connect wirelessly with the MECS and offload all or part of the tasks to the MECS for processing, and the MECS helps the user terminal device to process and return the results to the user terminal device, which is shown in Fig. 2.

Fig.1
figure 1

Schematic diagram of computational offloading

Fig. 2
figure 2

Privacy protection mechanism process

3.2 Latency model

3.2.1 Local computing latency

When part of the \(ith\) task is allocated to the user device for computation, the local execution time \({T}_{l}^{i}\) of the task can be calculated as in Eq. (1)

$${T}_{l}^{i}=\frac{{\left(1-{\lambda }_{i}\right)U}_{i}*{R}_{i}}{{f}_{l}^{c}}$$
(1)

3.2.2 External computing latency

When part of the task is offloaded to MECS for execution, the delay includes transmission delay \({T}_{u}^{i}\), MECS processing delay \({T}_{c}^{i}\) and result return delay \({T}_{b}^{i}\). Since the result return delay is usually small, it is not considered. According to Shannon's formula, the transmission rate \({V}_{u}\) at which the user terminal equipment sends the task to the MECS and the data transmission rate \({V}_{d}\) at which the MECS sends the result back to the user terminal equipment are shown in Eqs. (2) and (3)

$${V}_{u}=B*{\mathrm{log}}_{2}(1+\frac{{P}^{U}*{d}^{-r}}{{\sigma }^{2}})$$
(2)
$${V}_{d}=B*{\mathrm{log}}_{2}(1+\frac{{P}^{D}*{d}_{ }^{-r}}{{\sigma }^{2}})$$
(3)

where B denotes the bandwidth between the user terminal device and the MECS, \({d}^{-r}\) denotes the channel coefficient between the user terminal device and the MECS, d denotes the distance between the user terminal device and the MECS, \(r\) denotes the fading factor of the channel, and \({\sigma }^{2}\) denotes the noise power of the channel.

$${T}_{u}^{i}=\frac{{\lambda }_{i}{U}_{i}}{{V}_{u}}$$
(4)
$${T}_{c}^{i}=\frac{{D}_{i}*{R}_{i}}{{f}_{e}}$$
(5)

Thus, the total delay \({T}_{e}^{i}\) generated by the user terminal device offloading the ith task to the MECS for processing is Eq. (6).

$${T}_{e}^{i}={T}_{u}^{i}+{T}_{c}^{i}+{T}_{b}^{i}$$
(6)

3.2.3 Total delay

Since local execution and external execution are parallel, the total latency should be the greater of the two.

$${T}^{i}=\underset{ }{\mathrm{max}}\left\{{T}_{l}^{i},{T}_{e}^{i}\right\}$$
(7)

3.3 Energy consumption model

3.3.1 Local computing energy consumption

When a task is processed at the user terminal device, the user terminal device CPU generates energy consumption. Assume that the energy consumption of the i-th task of the user terminal equipment processed at the user terminal equipment is \({E}_{l}^{i}\), as shown in Eq. (8)

$${E}_{l}^{i}={T}_{l}^{i}*{P}_{l}$$
(8)

3.3.2 External computing energy consumption

The energy consumption generated when user terminal device offloads the task to the MECS for processing includes the transmission energy consumption generated by the local user terminal device when the user terminal sends tasks to the MECS, the energy consumption generated by the MECS when it processes the task from the user terminal device, and the energy consumption generated by the MECS when it returns computation results to the user terminal device. Since the MECS is always powered, this paper mainly considers the energy consumption generated by the local user terminal device uploading data to the MECS. Assume that the energy consumption of the user terminal device uploading the \(ith\) task is \({E}_{u}^{i}\), as in Eq. (9).

$${E}_{u}^{i}={P}^{U}*{T}_{u}^{i}$$
(9)

3.3.3 Total energy consumption

$${E}^{i}={E}_{l}^{i}+{E}_{u}^{i}$$
(10)

3.4 Problem model

Assume that for the \(ith\) task, the total cost of the system to process the user terminal device task is \({C}^{i}\) as in Eq. (11).

$${C}^{i}=\alpha {T}^{i}+\beta {E}^{i}$$
(11)

In edge computing scenarios, latency and energy consumption are the two most commonly used metrics to measure the performance of offloading schemes [21]. Considering the cost required by the task during execution comprehensively, \(\alpha \) is defined as the weight coefficient of task execution delay, which indicates the user's concern about delay; \(\beta \) is the weight coefficient of task execution energy consumption, which indicates the user's concern about energy consumption, satisfying \(\alpha +\beta =1\). In this paper, the delay and energy consumption are considered comprehensively, and the goal is to minimize the weighted sum of system delay and energy consumption, which is defined as the problem \(Q\).

The problem Q: \(\mathop {{\text{min}}}\limits_{k = 1}^{N} C(\lambda_{{\text{i}}} )\).

4 Privacy protection mechanism

4.1 Mechanism description

In order to protect the user's location privacy, a new distance confusion probability density function is used, which can be used by the user to confuse the real distance between it and the edge server to avoid the leakage of the user's location information. Suppose the real distance between the user and the edge server is \(d\) and the obfuscated distance is \({d}^{*}\), let \({d}_{\mathrm{max}}\) represent the maximum coverage radius of the edge server, \({d}_{1}\) and \({d}_{2}\) represent the upper and lower bounds of the range of the user's obfuscated distance, respectively, \(\Delta d={d}_{2}-{d}_{1}\), with \({d}_{1}<{d}_{2}\) and \({d}_{1,}{d}_{2}\in \left[0,{d}_{\mathrm{max}}\right]\), With the confusion range, the differential privacy mechanism is applied to confuse the distance between the user and the edge server. Existing differential privacy schemes based on Laplace mechanism are difficult to be directly applied to the scenario where task offloading protects user’s location privacy. Therefore, considering the limitation of the confusion range \(\left[{d}_{1},{d}_{2}\right]\),under the condition that the total probability of confusing the distance in the range \(\left[{d}_{1},{d}_{2}\right]\) is guaranteed to be 1, the probability density function of confusing the distance d into the distance \({d}^{*}\) is set as follows:

$$ f\left( {d^{*} } \right) = \left\{ {\begin{array}{*{20}c} {\frac{\epsilon }{2\Delta d}e^{{ - \frac{{\epsilon \left| {d^{*} - d} \right|}}{\Delta d}}} + \frac{{e^{{\frac{{\epsilon \left( {d_{1} - d} \right)}}{\Delta d}}} + e^{{ - \frac{{\epsilon \left( {d_{2} - d} \right)}}{\Delta d}}} }}{2\Delta d} } \\ {0 {\text{, otherwise}}} \\ \end{array} } \right.{,}\,{\text{if}}\,d^{*} \epsilon \left[ {d_{1} ,d_{{2{ }}} } \right] $$
(12)

Accordingly, the user can obfuscate the real distance between himself and the edge server, and the untrustworthy edge server or the attacker can only infer the user's obfuscated location by the user's task offloading ratio at the same time, and at this time, due to the randomness provided by differential privacy for adjacent data sets, it is difficult for an attacker to deduce the user's real location in reverse from the obfuscated location, thereby protecting the user's location information.

The KL divergence (Kullback–Leibler divergence) [22] is used to measure the degree of fit between the mechanism with privacy protection and the mechanism without privacy protection when the real distance between the user and the edge server is d. Suppose \(Q\left({d}^{*}|d\right)\) represents the probability distribution of task offloading by the user according to the real distance without privacy protection,\(P\left({d}^{*}|d\right)\) represents the probability distribution of user obfuscation according to the true distance when a differential privacy mechanism is added to protect privacy, then the degree of fitting \(Q\left({d}^{*}|d\right)\) with \(P\left({d}^{*}|d\right)\) is:

$$ D_{{{\text{KL}}}} \left( {P||Q} \right) = \mathop \smallint \limits_{{d_{1} }}^{{d_{2} }} Q\left( {d^{*} |d} \right)\log \frac{{Q\left( {d^{*} |d} \right)}}{{P\left( {d^{*} |d} \right)}}{\text{dd}}^{*} $$
(13)

According to the definition of KL divergence, if the value of \({D}_{KL}\left(P||Q\right)\) is smaller, it indicates that the higher the degree of fit between \(P\left({d}^{*}|d\right)\) and \(Q\left({d}^{*}|d\right)\), the higher the probability of leakage of information about the true distance between the user and the edge server, and the worse the degree of privacy protection. Therefore, when the real distance between the user and the edge server is \(d\), the degree of privacy leakage of the user is the inverse of the above formula:

$${\mathrm{PL}}_{{d}_{1},{d}_{2}}=-{\int }_{{d}_{1}}^{{d}_{2}}Q\left({d}^{*}|d\right)\mathrm{log}\frac{Q\left({d}^{*}|d\right)}{P\left({d}^{*}|d\right)}{\mathrm{dd}}^{*}$$
(14)

In general, when the wireless network between the user and the edge server is in good condition (closer), the confused distance should be set to be relatively close to the edge server in a high probability, so that after the task offloading decision is made based on the confusion distance, it is guaranteed that the user will offload more tasks to the edge server to save the user's resource consumption at the real location. In order to ensure the effectiveness of the task offloading decision made by the user based on the confusion distance \({d}^{*}\) on the real distance \(d\), it must be ensured that the confused distance \({d}^{*}\) takes values on the left and right sides close to the real distance \(d\), then there is a confusion range \({d}_{1}\le d\le {d}_{2}\), and the closer \({d}_{1}\), \({d}_{2}\) and \(d\) are, the better the decision-making utility of task offloading at the confusion distance. However, when the range \(\Delta d\) between \({d}_{1}\) and \({d}_{2}\) shrinks, although the task offloading decision based on the confusion distance can optimize the user's energy consumption and computational delay at the real distance, the degree of privacy leakage of the user's location information becomes larger. Therefore, before task offloading according to the confused location, the lower and upper bound values of the confusion range should be adjusted to achieve a balance between privacy protection and task offloading utility based on the user's privacy protection needs and the wireless channel between the user and the edge server. The formula for adjusting the lower bound value \({d}_{1}\) and the upper bound value \({d}_{2}\) of the confusion range to balance the utility of privacy protection and task offloading is:

$$\underset{{d}_{1},{d}_{2}}{\mathrm{min}} E+T+\omega \cdot PL$$
(15)

where \(E\) is the user's energy consumption, \(T\) is the user's computational delay cost, and \(\omega \) as an impact factor reflects the user's attention to the degree of privacy leakage. In the most extreme case, users do not pay any attention to the leakage of their location privacy, at this time, \(\omega =0\).

When the user’s confusion range is determined, a confused distance \({d}^{*}\) can be randomly selected from \(\left[{d}_{1},{d}_{2}\right]\) according to the distance confusion probability density function, and a task offloading decision can be made based on the confusion distance to complete the task offloading.

4.2 Theoretical analysis

For the real distance \(d\) between the user and the edge server and its proximity distance \({d}^{^{\prime}}\), it can be proved that after applying the privacy protection mechanism proposed in this paper, the probability \(Pr\left({d}^{*}|d\right)\) of confusion from the real distance \(d\) to \({d}^{*}\) and the probability \(Pr\left({d}^{*}|{d}^{^{\prime}}\right)\) of confusion from the proximity distance \({d}^{^{\prime}}\) to \({d}^{*}\) satisfies the definition of ε-differential privacy.

$$\frac{Pr\left({d}^{*}|d\right)}{Pr\left({d}^{*}|{d}^{\mathrm{^{\prime}}}\right)}=\frac{\frac{\epsilon }{2\Delta d}{e}^{-\frac{\epsilon \left|{d}^{*}-d\right|}{\Delta d}}+\frac{{e}^{\frac{\epsilon \left({d}_{1}-d\right)}{\Delta d}}+{e}^{-\frac{\epsilon \left({d}_{2}-d\right)}{\Delta d}}}{2\Delta d}}{\frac{\epsilon }{2\Delta d}{e}^{-\frac{\epsilon \left|{d}^{*}-{d}^{\mathrm{^{\prime}}}\right|}{\Delta d}}+\frac{{e}^{\frac{\varepsilon \left({d}_{1}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}+{e}^{-\frac{\varepsilon \left({d}_{2}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}}{2\Delta d}}$$
$$=\frac{{e}^{-\frac{\epsilon \left|{d}^{*}-d\right|}{\Delta d}}+\frac{{e}^{\frac{\epsilon \left({d}_{1}-d\right)}{\Delta d}}+{e}^{-\frac{\epsilon \left({d}_{2}-d\right)}{\Delta d}}}{\epsilon }}{{e}^{-\frac{\epsilon \left|{d}^{*}-d\right|}{\Delta d}}+\frac{{e}^{\frac{\epsilon \left({d}_{1}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}+{e}^{-\frac{\epsilon \left({d}_{2}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}}{\epsilon }}$$
$$\le \underset{ }{\mathrm{max}}\left(\frac{{e}^{-\frac{\epsilon \left|{d}^{*}-d\right|}{\Delta d}}}{{e}^{-\frac{\epsilon \left|{d}^{*}-{d}^{\mathrm{^{\prime}}}\right|}{\Delta d}}},\frac{{e}^{\frac{\epsilon \left({d}_{1}-d\right)}{\Delta d}}+{e}^{-\frac{\epsilon \left({d}_{2}-d\right)}{\Delta d}}}{{e}^{\frac{\varepsilon \left({d}_{1}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}+{e}^{-\frac{\varepsilon \left({d}_{2}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}}\right)$$
$$\le \underset{ }{\mathrm{max}}\left({e}^{\frac{\epsilon \left|{d}^{*}-{d}^{\mathrm{^{\prime}}}\right|}{\Delta d}},\underset{ }{\mathrm{max}}\left(\frac{{e}^{\frac{\epsilon \left({d}_{1}-d\right)}{\Delta d}}}{{e}^{\frac{\epsilon \left({d}_{1}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}},\frac{{e}^{-\frac{\epsilon \left({d}_{2}-d\right)}{\Delta d}}}{{e}^{-\frac{\epsilon \left({d}_{2}-{d}^{\mathrm{^{\prime}}}\right)}{\Delta d}}}\right)\right)$$
$$\le \underset{ }{\mathrm{max}}\left({e}^{\epsilon },\underset{ }{\mathrm{max}}\left({e}^{\epsilon },{e}^{\epsilon }\right)\right)$$
$$={e}^{\epsilon }$$

The above proofs show that the privacy protection mechanism proposed in this paper satisfies the definition of ε-differential privacy.

5 Task offloading mechanism

For the selected confusion interval \(\left[{d}_{1},{d}_{2}\right]\), the confusion position \({d}^{*}\) is generated based on the real distance \(d\), and the whale optimization algorithm is used to make a task offloading decision with the objective of minimizing the resource consumption under the confusion location: the unloading ratio \({\lambda }_{i}\).

The whale algorithm simulates a special hunting mechanism of humpback whales—a bubble net foraging method which can be simply expressed as follows: the whale dives around the prey at a water depth of 10 ~ 15 m, swims in a spiral posture around the prey in a gradually contracting range toward the surface, and protrudes bubbles of different sizes while swimming, and the exhaled bubbles form a circular or square bubble net. The bubbles form a ring or a square bubble net, and then the prey will be attacked by the whale. In this paper, the optimal prey is equivalent to the optimal unloading strategy, and the process of searching for the prey around the whale is equivalent to the process of optimizing finding the optimal unloading decision vector.

The three stages of whale predation are mathematically modeled below: (1) random search for prey; (2) surround prey; (3) bubble attack on prey.

5.1 Prey search (global search)

The random search for prey in the initial position corresponds to the global search stage of the whale algorithm. At this time, the coefficient vector |A|> 1, the mathematical model of this stage is as follows:

$$ D = \left| {{\varvec{C}} \cdot {\varvec{X}}_{{{\text{rand}}}} - {\varvec{X}}\left( t \right)} \right| $$
(16)
$$ {\varvec{X}}\left( {t + 1} \right) = {\varvec{X}}_{{{\text{rand}}}} - {\varvec{A}} \cdot D $$
(17)

where \({\varvec{X}}\left(t\right)\) represents the position vector of the current whale, \({{\varvec{X}}}_{rand}\) represents the position of a random whale in the current whale population, A and C represent the coefficient vector, and the calculation formula of the coefficient vector is as follows:

$${\varvec{A}}=2a\cdot {\varvec{r}}-a$$
(18)
$${\varvec{C}}=2{\varvec{r}}$$
(19)
$$a=2-2\cdot \frac{t}{{T}_{\mathrm{max}}}$$
(20)

where \(a\) linearly decreases from 2 to 0 during the iteration; \(r\) is a random vector of \(\left[\mathrm{0,1}\right]\); \(t\) denotes the current number of iterations, and \({T}_{\mathrm{max}}\) represents the maximum number of iterations.

5.2 Encircling prey

In the prey-encircling stage, each whale represents an independent individual in the algorithm, the position of each individual in the search space represents a solution of the optimization process, the optimal prey position is unknown in the search space, and the optimal candidate solution of the WOA (Whale Optimization Algorithm) is location of the optimal whale (prey). After the optimal solution is established, other search agents gradually approach the optimal whale search agent (prey). the way the whale circles its prey is represented by the following mathematical model:

$$D=\left|{\varvec{C}}\cdot {{\varvec{X}}}^{*}\left(t\right)-{\varvec{X}}\left(t\right)\right|$$
(21)
$${\varvec{X}}\left(t+1\right)={{\varvec{X}}}^{*}\left(t\right)-{\varvec{A}}\cdot D$$
(22)

where \(t\) represents the current number of iterations, \(X(t)\) represents the current position vector of the whale, \({X}^{*}(t)\) represents the position of the best whale obtained so far, and \(X(t+1)\) represents the position vector of the target prey.

5.3 Bubble-net attacking method (local search)

The bubble predation method simulates the local search process of whales, when the coefficient vector |A|< 1 in the mathematical model and mathematically models the whale bubble predation. Two strategies for updating the position are designed as follows:

  1. (1)

    Shrinking encircling mechanism

    The update of the whale's position is represented by Eq. (19). When |A|<1, the searcher's next position may exist at any position between the current position and the prey.

  2. (2)

    Spiral predation mechanism

    The whale searches through a spiral motion, and the formula for position update is as follows:

    $${D}^{\mathrm{^{\prime}}}=\left|{{\varvec{X}}}^{*}\left(t\right)-{\varvec{X}}\left(t\right)\right|$$
    (23)
    $${\varvec{X}}\left(t+1\right)={D}^{\mathrm{^{\prime}}}\cdot {e}^{bl}\cdot \mathrm{cos}\left(2\pi l\right)+{{\varvec{X}}}^{*}\left(t\right)$$
    (24)

where indicates the distance of the current whale to the prey (best solution obtained so far), \(b\) is a constant for defining the shape of the logarithmic spiral, l is a random number in \([-\mathrm{1,1}]\).

Both mechanisms are carried out simultaneously during bubble-net attacking period with a probability of 0.5, calculated as follows:

$$X\left(t+1\right)=\left\{\begin{array}{c}{{\varvec{X}}}^{*}\left(t\right)-A\cdot D , p<0.5\\ {D}^{\mathrm{^{\prime}}}\cdot {e}^{bl}\cdot \mathrm{cos}\left(2\pi l\right)+{{\varvec{X}}}^{*}\left(t\right) , p\ge 0.5\end{array}\right.$$
(25)

where \(p\) is a random number between \([\mathrm{0,1}]\).

5.4 Fitness function

In the whale algorithm, the objective function of the problem is usually used as a fitness function to evaluate the pros and cons of each solution. For a certain unloading decision \({\lambda }_{i}\) (candidate solution of the problem), assuming its fitness evaluation function \(f({\lambda }_{i})\). The formula is as follows:

$$f\left({\lambda }_{i}\right)=C\left({\lambda }_{i}\right)$$
(26)

5.5 Algorithm process

Figure 3 depicts the basic flow of the privacy-preserving computing offloading scheme based on whale optimization algorithm (WOPP). The whole scheme is divided into two stages. The first stage is to obfuscate the user's real location to protect the privacy of the location; the second stage is to use WOA to select the offload ratio, and the user can offload tasks according to the optimal offload ratio \({\lambda }_{i}\).

Fig. 3
figure 3

Process flow diagram of WOPP

In order to depict the entire implementation of the algorithm in more detail, the pseudo-code of the algorithm is given here.

figure a

6 Experimental simulation and result analysis

The experimental environment is Windows10 operating system, Intel(R) Core(TM) i5-1135G7, CPU (2. 40 GHz), 16 GB RAM. In order to verify the effectiveness of the WOPP algorithm for computational offloading, experiments were conducted using MATLAB. We utilized the dataset for Shanghai Telecom’s base stations [23,24,25] to simulate the scenario and perform data offloading. The dataset covers 3233 SBSs and 9481 subscribers. Each entry in the dataset consists of a user identifier, traffic flow, session time, location zone number, and sector ID. In addition, each SBS has its own location zone number and sector ID, so we can obtain its geographic location using the Google Map API. The experiments verify the impact of three important indicators, the weight \(\alpha \), the real distance \(d\) between the user and the edge server, and the user privacy leakage impact factor \(\omega \) on the effect of the WOPP algorithm. The effectiveness of the WOPP algorithm is verified by comparing it with PSO (Particle Swarm Optimization) [26], GA (Genetic Algorithm) [27], WOA [28]. The main parameter settings for the simulation experiments are shown in Table 1.

Table 1 Parameter setting

6.1 The relationship between \({\varvec{d}}\) and the cost and privacy leakage

The performance of the WOPP algorithm regarding resource consumption and privacy protection for different real distances \(d\) between users and edge servers is shown in Fig. 3, where the real distance \(d\) between the user and the edge server is randomly taken within \([\mathrm{50,250}]\)m, the privacy leakage impact factor \(\omega \) of the user is 0.002, and the privacy budget \(\varepsilon \) of the user regarding differential privacy is 0.1.

Figure 4a shows that in order to better balance the relationship between user resource overhead and privacy leakage, when the distance between the user and the edge server increases, the lower bound \({d}_{1}\) and the upper bound \({d}_{2}\) of the confusion interval become larger centered on the true distance \(d\). The \(\Delta d\) of the confusion interval \([{d}_{1}, {d}_{2}]\) does not change significantly. When the distance increases, the wireless channel condition between the user and the edge server will gradually become worse, and then the user will perform the task more locally, and the resource cost of the user will gradually increase, and when the distance increases, the degree of privacy leakage increases with the distance after the user selects a suitable confusion interval. It is namely that the degree of privacy leakage does not change significantly with the increase in distance when the size of the confusion interval does not change significantly, as shown in Fig. 4b.

Fig. 4
figure 4

The relationship between \(d\) and the cost and privacy leakage

6.2 The relationship between ω and the cost and the degree of privacy leakage

The performance of the WOPP algorithm regarding resource consumption and privacy leakage with different privacy leakage impact factors ω of users is shown in Fig. 5, where the real distance \(d=150m\) between the user and the edge server, the privacy leakage impact factor \(\omega \) of the user is one of {0.001,0.002,0.003,0.004,0.005}, and the privacy budget \(\varepsilon \) of the user is 0.1.

Fig. 5
figure 5

The relationship between ω and the cost and privacy leakage

Figure 5a shows that the Δd of the confusion intervals \([{d}_{1}, {d}_{2}]\) is getting larger when the user's privacy leakage impact factor \(\omega \) increases, this is because, when the user's privacy leakage impact factor ω increases, the user is more concerned about the leakage of location privacy. Therefore, the privacy leakage is smaller only when the confusion interval is larger. Figure 5b shows that the increasing Δd leads to a progressively larger resource overhead for the user, which is because the utility of the user's task offloading decision based on the confusion distance becomes lower with respect to the true distance when the confusion interval becomes larger. In turn, the larger the confusion interval, the progressively smaller the user's privacy leakage.

6.3 Influence of weight \(\boldsymbol{\alpha }\) on WOPP algorithm

It can be seen from Fig. 6 that in the same experimental environment, when the weight α increases, WOPP is more biased to optimize the latency of user terminal task offloading, and the system produces smaller latency at this time, however, this will weaken the optimization of system energy consumption, so the system energy consumption will increase while reducing the system latency. In addition, in Fig. 6a, we can see that the impact of the weight change on the system latency is not significant when the task volume of the user terminal device is small, because when the task volume is small, the resources of MECS are sufficient, and the tasks are offloaded to MECS for execution at this time, so the resulting latency is similar, but from Fig. 6b, we can see that the impact of the weight change on the system energy consumption at small task sizes is larger than that on the delay, because the channel conditions are different when users send data to each MECS, so the impact of weight on energy consumption is relatively obvious.

Fig. 6
figure 6

Effect of weight on system delay and energy consumption

6.4 The relationship between task volume and delay and energy consumption

Comparing WOPP with PSO, GA, and WOA, under these four schemes, the delay and energy consumption of the system processing user terminal tasks vary with the number of tasks as shown in Fig. 7a, b.

Fig. 7
figure 7

Effect of increasing task volume on total delay and energy consumption

From Fig. 7a, b, it can be seen that the latency and energy consumption generated by the system processing user terminal device tasks increase continuously with the increase in task volume, which is because the workload requires more time for transmission and computation, and the latency and energy consumption of WOA increase less than PSO and GA when the task volume increases, which is because WOA searches the solution space more adequately and can search for the global optimum in the continuous iterative process in order to make the system generate less latency and energy consumption when processing the tasks of all user devices. Considering the cost of privacy protection, the latency and energy consumption of WOPP are higher than those of WOA, but lower than those of PSO and GA.

7 Summary

During the offloading process of mobile edge computing, since there is a certain relationship between the user's offloading decision and the real distance between the user and the edge server, an untrusted edge server or an attacker can infer the wireless channel information by monitoring the user's task offloading ratio, thereby inferring the user’s location information, resulting in location privacy leakage. Aiming at this problem, a privacy-preserving edge computing offloading scheme WOPP based on whale optimization algorithm is proposed. This scheme combines the privacy-preserving mechanism and the offloading ratio optimization selection mechanism, first using differential privacy to obfuscate the user's distance, and then using an optimization algorithm to select the best offloading ratio based on the obfuscated location, which protects the user's location privacy while controlling the offloading cost. It is experimentally verified that the degree of privacy leakage and the computation-offloading cost are closely related to real distance, privacy-preserving impact factor, the respective weights of time delay and energy consumption, which are compared by PSO, GA, WOA, etc. It is shown that the WOPP algorithm is highly usable in controlling the offloading cost.