## 7 Offloading Scheme  
For the proposed VANET, we modified our proposed offloading scheme in [41]. The considered offloading model deploys three main offloading levels in addition to the local execution, and Figure 3 presents the main offloading levels in the proposed VANET. The local execution is represented as zero-level offloading, which illustrates an important mission of the end device's ability to process these tasks without the offloading procedure. This can occur based on obtainable resources offered by the end devices and QoS assigned for each task. The first level of offloading is exemplified in the fog computing server. The mission that cannot be carried out with the help of end devices is offloaded with the help of a suitable communication connection to the RSU's MEC. Depending on the recent obtainable resources at the fog server, the fog server admits or declines the offloading. If the recently obtainable resources of the fog server are not sufficient at that time to manage the offloading workloads, the workload is moved to the second level. The fog server offloads all workloads that cannot be managed to the dedicated RSU's MEC. The MEC unit can admit or decline the offloaded tasks depending on recent obtainable resources besides the QoS needed for these tasks.  
The major offloading decisions are determined through the end devices based on their recent obtainable facilities, e.g., energy, storage, and processing, and the QoS time. Each device's programmed profile determines the size of the workload and the necessary number of processor cycles. The end device's decision engine implements hardware for the proposed offloading mechanism. It collects data from the program profile and data on the resources currently available from the resource's schedule. Additionally, the decision engine gets the maximum permitted time to process the computing work, which indicates the needed QoS time for the recent workload. The decision engine uses these variables to select the offloading. The decision engine initially determines how long it will take to complete the job locally at the vehicle and then decides how to offload in terms of energy and time.  
The energy choice is made by comparing the vehicle's remaining energy after task execution with its threshold energy. The job is passed straight to the fog server if, following local execution, the vehicle's remaining energy is greater than that, provided that offloading is permitted. The execution time and QoS latency are compared to determine the time decision of offloading. The job is offloaded to the fog unit if the decision engine chooses to offload. When the fog server's decision engine receives an offloading request from a vehicle, it determines whether to execute the job internally or to move it to the next level. The decision engine of the fog server determines the execution time needed to complete the requested job before calculating the total time needed to complete it. The decision engine of the fog then determines the binary offloading energy and time decision values. After completing the desired job, leftover energy is compared to the energy threshold to determine the energy decision. The necessary QoS latency and the overall time needed to complete the requested job are compared to determine the time choice.  
Figure 3: Considered offloading levels of the proposed microservice-based VANET.