Reliable Mobile Edge Service Ofﬂoading Based on P2P Distributed Networks

: Intelligent vehicles and their applications increasingly demand high computing power and low task delays, which poses signiﬁcant challenges for providing reliable and efﬁcient vehicle services. Mobile edge computing (MEC) is a new model that reduces the completion time of tasks and improves vehicle service by performing computation ofﬂoading near the moving vehicles. Considering the high-speed mobility of the vehicles and the unstable connection of the wireless cellular network, symmetric and geographically distributed edge servers are regarded as peers in a peer-to-peer (P2P) network, and a P2P-based vehicle edge ofﬂoading model is proposed in this paper to determine the optimal ofﬂoading server for the vehicle and the ofﬂoading ratio of tasks to achieve the goal of minimizing execution time. Because the edge computing infrastructure is deployed at the edge of the network, the data in the edge nodes are easily damaged or lost. Therefore, a P2P-based edge node fault tolerance mechanism is proposed to improve the reliability and fault tolerance of the system. The effectiveness of our proposed system have been through simulation experiments, greatly reduces the task completion resources. To this end, we explored the ways in which P2P networks can be used in an MEC environment.


Introduction
In recent years, with the continuous growth of the number of vehicles, road carrying capacity has reached saturation in many cities, and the issues such as traffic safety, travel efficiency, and energy saving have become increasingly prominent. The intelligence and networking of vehicles are generally considered to be an important way to solve the aforementioned traffic problems. As one of the main applications of the Internet of Things (IoT), the Internet of Vehicles (IoV) realizes the information exchange between vehicles and vehicles, between people and vehicles, and also between vehicles and roadside units (RSU), which greatly improves traffic safety. With the continuous popularization of the IoV, many applications are increasingly demanding high computing power and low response delay; however, at present the requirements exceed the computation capacity of the vehicle itself [1,2].
Advances in the IoT and wireless technologies have provided vehicles with more chances and better services (such as autonomous driving), which have made vehicles more intelligent. It also brings more challenges to the resource-constrained vehicles. As a solution, vehicle cloud computing (VCC) improves resource utilization and computing performance, it has unavoidable shortcomings with the increasing quality of service (QoS) requirements for smart vehicles: (1) Cloud servers that perform task are deployed in the centralized cloud center, therefore a large number of concurrent task requests may cause network congestion; (2) Cloud servers are far from the vehicles, and the bandwidth of 1. We have adopted a mobile edge server distributed management solution based on P2P architecture to maintain a reliable network for the mutual cooperation between mobile edge servers and smart vehicles. The P2P network uses a backup mechanism to efficiently use the idle bandwidth, storage capacity, and processing capacity of servers on the edge of the network, which solves the problem of delay in receiving information due to the mobility of vehicles, making it easier for smart vehicles gets the information available from the closest network-connected mobile edge server. 2. We have studied the reliability and fault tolerance of edge nodes in the VEC environment, and proposed a novel VEC offload and fault tolerance scheme based on P2P network, which solves the problems of task timeout and task failure caused by edge node failure, and improves user satisfaction. 3. We propose an efficient task offloading and fault tolerance algorithm. The optimal offloading server is selected for the task and the optimal offloading ratio is determined, minimizing the task execution time and considering the failure of edge nodes.
The P2P-based edge server fault tolerance mechanism proposed in this paper effectively solves the problems of task failure and task timeout caused by edge server failure. For some time-sensitive tasks (such as face recognition, augmented reality, etc.), if an error occurs during the task offloading and cannot be processed in a timely and effective manner, it will greatly affect user experiences and QoS. In the previous research work, in order to avoid data loss caused by failures, different data copy storage methods are used to ensure data availability and reliability [6][7][8][9][10][11], rarely using P2P networks. The reliability, decentralization, and manageability of the network are used to study the fault tolerance of edge computing systems. The method we proposed is also applicable to face recognition, augmented reality, and other application scenarios. The networks we propose saves time, but it comes at the cost of space. We use a distributed P2P network for data backup, which consumes additional storage space. The vehicles need to be equipped with specific designed equipment. In addition to vehicles, the equipment used can be mobile phones, IoT devices, etc.
The rest of this paper is organized as follows: Section 2 summarizes related work about MEC, VEC, task offloading, reliability, and fault tolerance. Section 3 introduces the distribution and management scheme of the mobile edge servers. Section 4 models and analyzes the computing offloading in the P2P-based VEC environment. Section 5 studies the reliability and fault tolerance of edge nodes in the P2P-based VEC environment. Section 6 presents the simulation results and analysis. The final section summarizes the whole paper and discusses future work.

Related Work
In recent years, the edge computing paradigm has attracted great attention from academia and industry. It has the characteristics of fast processing speed and short response time, which could make cloud computing services closer to end users. Edge computing has provided a powerful driving force for many key technologies [12], such as 5G, IoT, augmented reality, and vehicle-to-vehicle (V2V) communication [13,14], etc. There are three common edge computing models: Cloudlets [15], fog computing [12,16], and mobile edge computing [17].
MEC, as a new architecture that moves service capabilities from the core network to the edge network, has caused extensive research by scholars [5,13]. The key research topics in mobile edge computing include the placement of edge servers [18][19][20], computing migration [21][22][23], and edge caching [24][25][26], etc. As the first step of mobile edge computing deployment, the placement of edge servers is critical. In [18], Li et al. studied the placement of edge servers based on energy-awareness and designed a particle-based Swarm-optimized energy-aware edge server deployment algorithms to find a more efficient low-energy placement scheme.
Computation migration and offloading research are about migration decisions and resource allocation. By migrating mobile device computing tasks/applications to servers in network for execution, it can enhance the computing capabilities of mobile devices and reduce time and energy consumption when running applications on mobile devices. A user-level online offloading framework (ULOOF) was proposed by Neto et al. [22]. The offloading framework uses a decision engine to model execution time and energy consumption based on historical data, and learns the execution time and energy consumption, and then predict the execution behavior to achieve the goal of minimizing remote execution overhead. Deng et al. provided a novel offloading strategy for workflow-type mobile services, and considered the user's location and network connection failure in the offloading strategies, and added a mobility model and fault tolerance mechanism to design and implement an optimization method for offloading decision based on genetic algorithm (GA) [23]. To further reduce the latency and the transmission cost of the computation offloading, Zhang et al. [27], designed a task-file transmission strategy with predictive Vehicle-to-Vehicle (V2V) relay and proposed an optimal predictive combination-mode off-loading scheme, which greatly reduces the offloading cost. Considering computing tasks and load balancing among RSUs in the IoV, a heuristic algorithm is proposed by jointly considering task scheduling among MEC servers and downlink energy consumption of RSUs in [28], aiming to minimize the total energy consumption of RSUs under latency constraints.
Edge caching studies data storage and content delivery technologies. Using MEC servers as edge caching nodes can dynamically optimize content delivery services based on network status and wireless channel load. Since the MEC server is located at the edge of the network, very close to the location of the mobile device, it can combine user mobility and content access logs to optimize the experience. Cui et al. proposed a joint cache and offloading mechanism to solve the problem of minimizing the average total energy constrained by cache and deadline [24]. This mechanism involves task uploading and execution of tasks that do not cache computation results, and downloading the computation results of all tasks at the base station. It effectively uses multi-user diversity and multi-cast opportunities. Hao et al. introduced the new concept of task caching, and proposed the joint optimization of task caching and offloading on the edge cloud to meet the user's latency requirements while minimizing the energy of mobile devices [25].
Extending edge computing capabilities to the edge of the vehicle network, VEC is emerging as a hot research topic. With the development of VEC, a new paradigm of networking has emerged, namely the vehicle edge network [29][30][31]. On heavy roads, the computing power limitations of the MEC server may affect the quality of offloading. To solve this problem, in [32] Zhang et al. proposed a hierarchical cloud-based VEC offloading framework, which introduced a nearby backup server to compensate for the lack of computing capacity of the MEC server. Based on this framework, an optimal multi-stage offloading scheme was designed using the Stackelberg game theory method, so as to ensure the delay constraints of computing tasks while maximizing its benefits. Regarding the problem of offloading the vehicle-connected computing tasks in a high-speed mobile environment, Huang et al. designed an MEC architecture based on software-defined networks (SDN) control to improve the expandability and flexibility of the vehicle-connected system, and use software-defined controllers to simplify the task offloading complexity [33]. Zhang et al. considered the completeness of the task data and the similarity of the geographical district to which the task belongs, and used the coordinated transmission of adjacent multiple vehicles to implement hierarchical data access to improve the data transmission rate of the task offloading [26]. In order to promote the development of VEC, there is another problem that must be solved, and that is security. In order to ensure security and improve network efficiency in VEC, Huang et al. proposed a distributed reputation management system (DREAMS) [34], which uses a VEC server to perform local reputation management tasks of the vehicle. It proposed the concept of reputation-assisted optimization and an optimized resource allocation algorithm was designed for optimizing resource allocation based on reputation in computing offload schemes, and the vehicle with higher reputation value can obtain the better response and improve user satisfaction.
In addition, due to the dynamics, distribution, and heterogeneity of edge systems, node failures (such as hardware and software failures, power failures, and network failures) often occur, resulting in data being unavailable. In order to avoid data loss caused by access failures and node failures, data replicas are usually placed on different nodes to ensure the availability and reliability [9][10][11]. In order to improve the availability of data in the edge computing environment and respond to the fluctuation of user access, Li et al. proposed a dynamic replica creation algorithm (DRC-GM) [9], which dynamically adjusts the number of replicas using the relationship between the access frequency of data blocks and the number of replicas to ensure data availability requirements. In order to find the best location for replica distribution, the replica placement algorithm (RPFNSG) was proposed. If we allocate some spare nodes for each job so that the process that terminated on the failed node can be restarted, considering the magnitude of the expected failure rate, the number of spare nodes allocated for each job will be high, resulting in a lot of resources are wasted. In [10], a dynamic node replacement algorithm was proposed by Prabhakaran et al., which can replace faulty nodes in time with other nodes in good working condition. The algorithm is deployed on the central scheduler and will be triggered when a node fails, which can result in a more efficient usage of resources. With the increasing deployment of mobile edge servers, their centralized management would cause certain performance issues. In order to address these challenges, Tang et al. [21] proposed a P2P-enabled decentralized mobile edge server management scheme for the edge computing environment and a deadline-aware and cost-effective offloading approach, which aims to improve the offloading efficiency among mobile edge servers and allows more tasks to meet their deadlines. This scheme can enable all mobile edge servers to participate in updating information in a decentralized manner; however, it does not take advantage of the reliability and fault tolerance of distributed P2P networks to study the reliability and fault tolerance of edge nodes in the VEC environment, which is considered in this paper.

Distribution and Management of Mobile Edge Servers
For certain mobile edge servers, the proportion of offloading tasks remains to be determined. In fact, the offloading scheme should take into account the load status of the candidate edge server. These issues are illustrated in Figure 1. In order to facilitate understanding of system models and algorithms, we list main notations in Table 1.   Whether the task j of the vehicle i is offloaded to the edge server k(=1) or not (=0).
The time required for the vehicle i to reach edge server k The time required for the task j to upload task data to the edge server k The computation time for the task j executed on the edge server k The time required to transfer task result data from the edge server z to the vehicle i

Tx i
The transmission rate of data uploading Tx 0 The transmission rate of data downloading The offloading ratio of the task j The query time for the edge server z to find the computation result on the edge server k The time spent on performing the part of the task locally The actual execution time of the task j without considering the occurrence of edge node errors

Distribution of Mobile Edge Servers
We divide a one-way straight road into m road side units (RSU), and the ID set of all RSU is expressed as R = {r 1 , r 2 , r 3 , . . . , r m }. Many mobile edge servers are distributed along the road, with a mobile edge server at the center of each road unit, and ID number are expressed by E = {1, 2, 3, . . . , m}. Due to the different radio power of each RSU and the change of the wireless environment, the size of the wireless coverage area of these RSU may be different, that is to say, the service range of each edge server is different. The distribution of RSU and mobile edge server, and their service ranges are shown in Figure 2.

Management of Mobile Edge Servers
In the edge computing environment, the actual VEC computing offloading usually involves two entities, namely the edge servers and the smart vehicles. Before providing computing offloading for smart vehicles, edge servers must be efficiently managed. It is assumed that each mobile edge server processes task offloading in a first-in-first-out (FIFO) order.

Client/Server (C/S) Architecture for Management of Mobile Edge Servers
The C/S architecture is a typical two-tier architecture, that is, client/server architecture. The centralized management scheme for mobile edge servers based on the C/S architecture is shown in Figure 3. There is a central server in the cloud layer, which is connected to all mobile edge servers through a wired network. Mobile users can establish network communications with edge servers over cellular networks. The central server acts as a proxy to help mobile users query the computing workload of the mobile edge server.
With this management scheme, any user's query request must be proxied through the central server, and it will only be answered after the central server receives query responses from all edge servers. If the central server is under heavy load or some edge servers fail to return a query response in time, the user cannot get an immediate response.
With the increase of smart vehicles and business expansion, the number of mobile edge servers is increasing, and the efficiency and quality of tasks completion in mobile edge servers based on C/S architecture are gradually decreasing. As all data queries need to go through a central server, this makes single-point failures, security management, and authentication issues increasingly prominent.
In contrast to the C/S network architecture, peer-to-peer communication can be performed directly between nodes in a P2P network architecture. Each node simultaneously has the functions of receiving, storing, processing, sending media content, searching, and being searched for media metadata. Nodes can directly cooperate and share various resources. To this end, we explored the ways in which P2P networks can be used in an MEC environment.
Cloud Server MEC Server RSU Base Station

Peer-to-Peer Architecture for Management of Mobile Edge Servers
P2P is a distributed network. Participants in the network share a part of their software and hardware resources (processing power, storage capacity, network connection capacity, content resources, etc.). These shared resources provide services through the network and can be directly accessed by other peer nodes without the involvement of intermediate nodes. The participants in this network are both resource providers (server) and resource acquirers (client) [35,36].
The characteristics of P2P architecture are listed as follows: 1. Compared with the central server, the nodes in the system have obvious autonomy. 2. The system makes full use of resources at the edge of the network, such as storage/computing capabilities and content resources. 3. Dynamic changes of resources are applicable to the edge of the network (new resources are added and existing resources disappear).
With the rapid development of edge computing, there will be a large number of geographically distributed mobile edge servers throughout urban areas. The distributed management scheme of mobile edge servers based on the P2P architecture refers to the fact that the status of each edge server in the network is equal, and each node acts as a server to provide services to other nodes, while also consuming the services provided by other nodes. This distributed management solution can greatly alleviate the pressure on the central server side and single point of failure in a centralized architecture, and can make full use of the spare resources located at the edge of the network.
The main advantages of the distributed management solution for mobile edge servers based on the P2P architecture are summarized as follows: 1. Efficiency: Make full use of the idle bandwidth, storage capacity, and processing capacity of many mobile edge servers on the edge of the network. 2. Reliability: There are a large number of data replicas in the network, and the holders of these replicas are also independently distributed geographically, ensuring the reliability of resources. In addition, because the business is conducted directly between the nodes, the damage to some nodes or networks has little impact on other nodes. On the contrary, there will be no service interruption caused by a single point of failure in the C/S architecture. 3. Decentralization: Information transmission and service implementation in the network are performed directly between nodes, without the intervention of intermediate servers.
In addition, due to the system's error tolerance and load balancing mechanism, it also makes management easier.
We believe that P2P networks enable distributed nodes to collaborate with each other and maintain a reliable network. When a high "churn" rate occurs, that is, when a large number of peer nodes frequently join and leave the network, the P2P network is highly robust. So, it is almost impossible for the entire system to crash. Therefore, P2P networks are a promising solution for decentralized management of mobile edge servers to offload task in an MEC environment, and some efforts have also been made using P2P model in the MEC environment [37][38][39]. The distributed management scheme of mobile edge server based on P2P architecture is shown in Figure 4. The system can theoretically accommodate tens of thousands of nodes. We simulated dozens of nodes through simulation experiments.

Task Offloading Model in Vehicle Edge Computing Based on P2P
In our model, each vehicle i usually performs only one computing task. A triple term can be used to describe the task j performed by vehicle i, T j = di i j , do i j , c i j , where di i j represents the amount of data uploaded by the task, do i j represents the amount of data downloaded, and the computation instructions for task j is C i j (in millions of instructions per second, MIPS). In fact, a vehicle cruising on the road may be connected with its nearest edge server geographically. Whenever it continues to move, its geographic location may move away from the previously connected edge server and closer to the next edge server with a strong wireless signal, and the vehicle will disconnect from the previous connection and establish a wireless connection to the new edge server. Because the transportation department has all the information on the highway, each smart vehicle can rely on the service range and computing power of each mobile edge server predetermined by the transportation department, and these edge servers are distributed along the traffic route.
We assume that each vehicle can transfer its current task to a mobile edge server only once, when driving on the road, and we define x i j,k = {0, 1}, when x i j,k = 1, it means that task j of vehicle i is partially or completely offloaded to edge server k, otherwise x i j,k = 0, so we get ∑ m k=1 x i j,k ≤ 1.

Time Cost for Task Offloading without Considering Errors
If a user in a mobile vehicle wants to transfer their computation task to an edge server near them, the time cost consists of five parts: (1) the time it takes for the vehicle traveling smoothly to the vicinity of the edge server that the task needs to be offloaded; (2) the time required to establish a wireless connection between the smart vehicle and the mobile edge serve, and upload the required data for the task to be processed; (3) the time that the smart vehicle waits for the edge server to complete task computation; (4) the time required to find the corresponding result data from the edge server; (5) the time the result data is transmitted back to the mobile vehicle.
Let l i k denote the distance between vehicle i and edge server k, and v i denote the driving speed of vehicle i, then the time required for vehicle i to reach edge server k is denoted by: When the vehicle i arrives near the edge server k, task j of vehicle i starts uploading task data to the edge server. The time required is expressed by: The computation time for the specific task j of the vehicle i executed on the mobile edge server k is: When the mobile edge server k finishes the offloading task, the geographical location of the vehicle may have moved away from the previously connected edge server k and closer to the next edge server z with a strong wireless signal. Time required to transfer task result data from edge server z to the vehicle is denoted by: where Tx i represents the transmission rate of data upload, Tx 0 represents the transmission rate at which the task computation result is transmitted back to the smart vehicle, and α i j,k ∈ [0, 1] represents the offloading ratio of task j.
Then, the time from the start of task j to uploading data to edge server k, and until the smart vehicle receives the result returned by edge server z is: where t f i j,kz is the query time for the mobile edge server z to find the computation result on the edge server k. When k is equal to z, we have t f i j,kz = 0. For task j, the proportion represented by α i j,k is executed on the remote mobile edge server, so the other proportion of the computing task should be executed on the vehicle itself, the time spent is: where C M i indicates the computing power of vehicle i in performing tasks. We assume that tw k denotes the waiting time available for the k-th edge server. Without considering the occurrence of edge node errors, the actual execution time of task j is:

Optimization Function
In this paper, the offloading scheme was designed to pick out the best offloading strategy to minimize time cost. The functions that need to be optimized are as follows: where As shown in the equations above, we need to determine two values to minimize our objective function, one is the offloaded edge server k, and the other is the offloading proportion α i j,k . From the above analysis, we know that if the k is determined, the optimization objective function becomes a unary linear function about α i j,k . Because it is monotonic, we can easily find the optimal offloading ratio α i j,k . Because the number of mobile edge servers on the road side is limited, we can use the traversal method to solve the optimal offloading proportion of tasks performed on each mobile edge server and obtain the task completion time on them. By comparing the execution time of different mobile edge servers, we can find the best offloading mobile edge server k bt and the best offloading ratio α i j,k bt . Figure 5 presents the flow chart of the proposed two-stage offloading algorithm based on P2P architecture. The description of the first stage about selecting the optimal mobile edge server and determining the offloading ratio is shown in Algorithm 1, and the second stage about fault-tolerant offloading algorithm is introduced in the next section.
An error occur?
The error occurred during the data upload phase ?
The error occurred during the task execution phase ?
The error occurred during the data download phase ? Algorithm 1: Optimal mobile edge server selection and offloading ratio determination. Input: The vehicle with computation task T j ; vehicle speed v i ; mobile edge servers set E next to the road and their respective service ranges R and computing power C c . Output: Optimal mobile edge server k bt and corresponding parameter α i j,k bt . 1 k bt ← φ, α i j,k bt ← φ 2 foreach mobile edge server k in R do 3 query its waiting available time tw k ; 4 Minimize F(α i j,k , k) for k with corresponding optimal α i j,k ;

5
Compare the time that each mobile edge server runs at the optimal α i j,k and find the server k bt with the least time spent on all servers and corresponding optimal α i j,k bt ; 6 k bt ← k, α i j,k bt ← α i j,k ; 7 end 8 return k bt , α i j,k bt .

Fault-Tolerant Task Offloading in P2P Architecture
Unlike cloud computing, which has stable infrastructure protection, many edge nodes are exposed to the natural environment; therefore, it is very important to ensure the reliability of edge nodes. For example, computer vision-based public safety solutions need to rely on smart cameras for storage and computing. Because the edge computing infrastructure is located at the edge of the network, there is a lack of effective data backup and recovery measures. If a fault occurs, this will cause the task to time out and seriously reduce QoS and user satisfaction. In the edge computing scenario, once user data are lost or damaged on the edge node/server, and there is no backup of the user data in the cloud, the edge node does not provide an effective mechanism to recover the data. In order to minimize the consequences of this kind of unreliability of edge nodes, we need to design reasonable fault tolerance mechanisms to ensure the reliability of edge nodes and improve the fault tolerance of edge systems.
One of the key reasons why P2P networks are considered as an excellent platform for large-scale distributed systems is that P2P systems have better robustness and survivability than traditional C/S systems, and they have higher performance in elasticity for node failure. This resilience depends on the accurate and timely detection of node failures; therefore, we established the distributed management of mobile edge servers based on the P2P architecture. This management scheme can not only reduce the waiting delay for users to request, but also greatly improve the reliability of edge nodes and the fault tolerance of the system.
The network of P2P architecture enables distributed edge nodes to cooperate with each other and maintain a reliable network, which can quickly return to normal in a limited time when equipment fails or data is damaged or lost; therefore, using P2P networks for decentralized management of mobile edge servers is an effective solution to ensure data security and improve system reliability and fault tolerance.
For non-offload tasks, there is only one state: non-offload execution (SNE). For the offload task, there are three states: upload input data (SU), offloading execution (SOE), and download output data (SD). As mentioned before, because the edge server may suffer from node failure, network congestion or other faults at any time due to poor natural conditions or malicious attacks, the vehicles on the road may malfunction during the SU, SD, and SOE states.
When the mobile edge server fails for various reasons, the fault tolerant process at different error stages is listed as follows: 1. Data uploading stage: select a new best edge server from other edge servers and upload the task again. 2. Execution stage: find and re-calculate the tasks on the edge server where the replica data is stored. 3. Result output stage: find the replica of the result and re-output it at the adjacent edge server in the geographic location.
We assume that after the intelligent vehicle selects the initial optimal offloading server k bt and the optimal offloading ratio α i j,k bt , if an error occurs during the upload of the task, the task computation instructions performed by the task migration to another mobile edge server is the same as before, we just need to select the optimal edge server to offload, and the offloading ratio remains the same; therefore, the execution time of the task offloading with fault tolerance becomes: i,o f f j,k bt z * ts i j,k bt +max{td i j,k bt k * , tw k * }+t i,o f f j,k * z * P i j < ts i j,k bt ts i j,k bt + * tc i j,k bt +F+tc i j,k * +t f i j,k * z * +tr i j,z * ts i j,k bt ≤ P i j < ts i j,k bt + tc i j,k bt ts i j,k bt +tc i j,k bt +t f i j,k bt z + * tr i j,z +G+F+tr i j,z * ts i j,k bt + tc i j,k bt + t f i j,k bt z ≤ P i j < t i,o f f j,k bt z (12) where P i j represents the time from the start of the execution of task j to the occurrence of the error. If P i j ≥ t i,o f f j,k bt z , there was no error in the offloaded task, the execution time of the task is still t i,o f f j,k bt z .
If P i j < t i,o f f j,k bt z , it means a failure occurred before the offload service completed. z * indicates the new mobile edge server that downloads the computation results after the fault occurs, and G indicates the time traveling to the edge server adjacent to z after the fault. * ts i j,k bt indicates the duration from the time when the data were uploaded to the time when the error occurred (if the error occurred during the data upload stage). * tc i j,k bt indicates the duration from the time when the task started to execute on the edge server to the time when the error occurred (if the error occurred during the task computation stage). * tr i j,z indicates the duration from the beginning of downloading result to the time when the error occurred (if the error occurred during the result download stage).
When P i j < ts i j,k bt , it means that the task fails during the SU state, then the new best mobile edge server k * will be chosen for offloading execution, where td i j,k bt k * = l i k * v i − (max{td i j,k bt , tw k bt } + * ts i j,k bt ) represents the time it takes for the vehicle to travel from the original offloaded edge server k bt to the new optimal offloaded edge server k * , and tw k * represents the waiting time for performing the offloaded task on the new edge server k * . t i,o f f j,k * z * indicates the duration from the time when the vehicle uploads the task data to the new edge server k * to the time when it receives the return result. If ts i j,k bt ≤ P i j < ts i j,k bt + tc i j,k bt , the task failure occurs during the SOE state, the mobile edge server that stores the replica data will be found and the offloaded task will be re-calculated on it. F indicates the search time of edge server with backup file based on P2P network after edge server failure. If ts i j,k bt + tc i j,k bt + t f i j,k bt z ≤ P i j < t i,o f f j,k bt z , it indicates that the task failure occurred during the SD state, after the failure occurs, the edge server with a copy of the calculated results will be found and the results will be transmitted by the next mobile edge server adjacent to z in the geographical location.
The total time to complete task j can be expressed as: Objective function for offloading strategy can be expressed as: The description of fault tolerant offloading algorithm for mobile edge server based on P2P architecture is shown in Algorithm 2.

Simulation Results and Analysis
The simulation experiment in this paper was implemented by a self-designed edge scheduler written in Java language. By writing a program to simulate the entire process of the vehicle from entering the service range of the mobile edge server to task offloading, and finally receiving the returned results, choosing the best offloading server and offloading ratio according to our proposed offloading strategy, we could take into account the possible failures and errors during the execution of the task, by configuring a certain task error rate and fault-tolerance strategy. The simulation results mainly include the impact of different factors such as task error rate, intelligent vehicle speed, and different traffic congestion conditions on the average task completion time. The average task completion time of the edge node fault tolerance algorithm based on P2P network proposed in this paper was compared with the average task completion time without fault tolerance. Simulation scenario is described as follows: 10 mobile edge servers were randomly located on a road of 1000 m, and the service range of each mobile edge server was distributed in [20,100] m. In our simulation, the average network upload speed was 10 Mb/s and the download speed was 30 Mb/s. We organized mobile edge servers along the road to form an unstructured P2P network. The simulation experiment parameters are shown in Table 2. i,o f f j,k bt z ← ts i j,k bt + * tc i j,k bt + F + tc i j,k * + t f i j,k * z * + tr i j,z * ; 9 end 10 if the error occurred during the data return stage then /* re-transfer on the adjacent server */

FT t
i,o f f j,k bt z ← ts i j,k bt + tc i j,k bt + t f i j,k bt z + * tr i j,z + G + F + tr i j,z * ; 12 end The result of the task completion time of the vehicle at speed of 120 km/h and 25% task error rate under different traffic congestion situations is shown in Figure 6. As shown in this figure, we can see that when the offloading ratio is 0%, that is, the tasks were performed locally and when the offloading ratio was fixed at 25%, the execution time of the vehicle offloading task under different traffic congestion situations was similar. This indicates that at this time, the task completion time is mainly determined by the part of the task executed locally. As the proportion of offloading continues to increase, the average task completion time is declining. When the task offloading ratio reaches 75% or all are completed on the edge server, we found that the time cost of task completion is increasing, indicating that all available mobile edge servers have a high computing workload, and a large amount of task offloading will consume more time because of long waiting times. The effect of traffic congestion on average task completion time on different error rates is presented in Figure 7. In the situation of relatively heavy traffic (0.5 s/car), the average task completion times for different error rates are 8.93, 9.71, 10.48, and 11.38 s, respectively. When the traffic flow is light (2 s/car), the average task completion time for different error rates are 6.76, 7.42, 7.92, and 8.21 s respectively, compared with previous heavy traffic, the task completion time is reduced by more than 2 s. This is because with the reduction of traffic pressure, the time required for vehicle task offloading queue is also continuously reduced, so that in the case of various error rates, the task completion time is also continuously reduced.    Figure 8 shows the effect of vehicle speed on the average task completion time at different error rates. We can see in this figure that as the vehicle speed increases from 60 km/h to 140 km/h, the average task completion time at each error rate also decreases. The average task completion time is reduced by 26.7% when no errors occur, and reduced by 23.6% when the error rate is 25%, and reduced by 20.6% when the error rate is 75%, respectively. This is because the faster the speed, the more mobile edge servers are available to offload, resulting in a reduction in task completion time.
In order to evaluate the impact of fault-tolerant mechanism in the process of vehicle task computation and offloading, we compared the task completion time of our proposed P2P-based fault-tolerant offloading strategy with the non-fault-tolerant offloading strategy in various situations, as shown in Figures 9-11. Figure 9 presents the average task completion time of fault-tolerant (FT) and non-fault-tolerant (without FT) offloading under different error rates measured at the vehicle speed of 120 km/h and a traffic congestion situation of 1.5 s/car. Through this figure, we found that as the error rate increases, the effect of our proposed fault tolerance strategy on reducing task completion time becomes more and more significant. Even at an error rate of 75%, our proposed fault tolerance strategy can save 10.6% of the time. Both the data in Figures 10 and 11 are measured under an error rate of 50%. From Figure 10 we found that when the traffic is relatively congested (0.5 s/car), our fault tolerance strategy obtains good results and can save about 18% of the time. At different speeds and different traffic congestion situations, our proposed fault-tolerant offloading strategy can save about 0.5 s of the time compared to the non-fault-tolerant strategy.     Through previous analysis, we found that traffic congestion and vehicle speed are important factors affecting task completion time. In Figure 12, we compared the impact of vehicle speed and traffic congestion on task completion time (setting the task error rate to 25%). From the figure we can see that when the traffic speed is low and the traffic is congested, the completion time of the task is very high. As the speed of the vehicle increases and the traffic pressure decreases, the completion time of our task also decreases.

Conclusions
In this paper, we made full use of the advantages of distributed P2P networks, and adopted a distributed management solution based on P2P architecture for mobile edge servers to provide efficient offload services for smart vehicles in vehicle edge computing environments. At the same time, in order to solve the problem of task timeout and failure caused by task failures or node failures, a novel task offloading and fault-tolerant strategy for vehicle edge computing based on P2P network was proposed. Simulation experiments have proved that our proposed task offloading and fault tolerance strategy can greatly reduce the average time for task completion and improve user satisfaction. Simulation results indicates that vehicle speed and traffic congestion condition have an impact on the task completion delay of vehicle offloading tasks. The faster the vehicle speed, the less time it takes to complete the task, and the better the traffic conditions, the less time it takes to complete the task.
In future work, we will consider more complex road and vehicle movements, establish a more accurate simulation model to evaluate the service range of the mobile edge server, and enable our proposed offloading fault tolerance strategy to adapt to more complex and dynamic road environments.