A Review of Techniques and Methods for IoT Applications in Collaborative Cloud-Fog Environment

School of Computer and Software, Nanjing University of Information Science and Technology, Nanjing, China Jiangsu Collaborative Innovation Center of Atmospheric Environment and Equipment Technology (CICAEET), Nanjing University of Information Science and Technology, Nanjing, China Nanjing Institute of Technology, Nanjing, China Department of Computer Science, King Saud University, Riyadh, Saudi Arabia


Introduction
Over the years, with the rapid development of distributed computing, parallel computing, grid computing, network storage, and virtual machine technique, computing resources have become more abundant, cheaper, and more accessible than ever before. e development of the Information Technology (IT) industry and the influx of electronic devices into the market have increased the demand for computing and storage resources. In this context, a new computing mode called cloud computing was proposed. In this mode, resources (such as networks, computing, storage, and applications) are provided to users to access on demand at any time. Service providers are divided into infrastructure providers that manage cloud platforms and lease resources based on pricing models and service providers that rent resources from infrastructure providers to provide services to users. Because of the maturity of cloud computing technology and its advantages such as low cost, easy access to information, rapid deployment, data backup, and automatic software integration [1,2], cloud has been widely used.
However, in the trend of Internet of everything, the application demand of low latency and high interactivity makes the remote connection between cloud and user devices become the key factor restricting the development. At the same time, the number and types of IoT devices (such as smart headsets, mobile computers, smart home appliances, on-board networking systems, smart traffic control lights, and more connected utilities) are rapidly increasing [3]. Large-scale data transmission poses great challenges to the performance of user devices and the existing network bandwidth. In addition, the security and privacy of personal and enterprise data are questioned, because data are stored centrally in cloud servers far away from users and they cannot determine whether their data is stolen by malicious actors with interest.
Fog computing is a new computing paradigm proposed to solve these challenges. Different from centralized servers in cloud, servers in fog are moved to the edge of the network, known as fog nodes. Some delay-sensitive tasks can be processed on these nodes [4], while some computation-intensive or delay-tolerant tasks are still processed in the cloud. erefore, the user task request will not be sent directly to the remote cloud. Instead, it is received and processed by the neighboring fog nodes [5], which requires lower network bandwidth and user equipment performance than the former. In addition, fog computing also has some other advantages like stable service, high security, and privacy.
However, the practical technology of fog computing is not mature, and some problems that fog computing faces after being integrated into IoT system still need to be solved, such as heterogeneity, mobility, data and equipment management, QoS management, security, and privacy. e article can be described as follows. Based on the introduction of the concepts and characteristics of cloud and fog computing in Section 2, the comparison and collaboration between them are presented in Section 3, while the methods and techniques of task offloading among cloud and fog are emphatically reviewed and analyzed. Challenges that IoT face (e.g., low latency, network bandwidth constraints, resource constraints of devices, stability of service, and security) are discussed in Section 4, which are linked to surveys about fog's contribution to addressing these challenges and some specific solutions that have been proposed. Particularly, methods and technologies to reduce delays and protect security and privacy are scrutinized. In Section 5, the remaining challenges and research directions of fog after integrating into IoT system are discussed. In Section 6, the key role of 5G-based fog computing in the field of intelligent driving and tactile robots is prospected.

Definition of Cloud Computing.
Cloud computing was proposed to support ubiquitous, convenient, and on-demand network access to configurable computing resources like storage space, servers, networks, applications, and services in a shared pool. ese resources can be provisioned and released rapidly with minimal service provider interaction or management effort [6]. Figure 1 shows a structure of cloud computing.
(1) Up-front investment in cloud computing is not needed because it is a pay-as-you-go pricing model that allows service providers to benefit from the cost of renting resources in the cloud without investing in infrastructure. (2) e leasing and management of resources are flexible. Resources in the cloud can be quickly released according to the requirements of users. When service demand is low, service providers can actively release idle resources in the cloud, reducing the pressure of center load and energy consumption, and reduce costs. (3) Data resources received by cloud data center can be collected and analyzed by infrastructure providers. Service providers access the data analysis to discover the potential business trends and determine the growth demand for services, which is the basis for them to expand their service direction and scale. (4) Services in the cloud are easily accessible via the Internet by devices such as mobile phones, computers, and PDAs. proposed as a layered model to support convenient access to a shared continuum of extensible computing resources. is model, consisting of physical or virtual fog nodes which are context-aware, facilitates the deployment of delay-aware and distributed applications and services. Fog nodes are located between intelligent terminal equipment and cloud services, which support common communication system and data management. e organizational form of fog nodes in the cluster is based on the specific working mode. Association and separation are supported by horizontal and vertical distribution, respectively, and can also be supported by the delay distance from the terminal devices to the fog nodes. Fog computing provides network connections to centralized services and local computing resources for terminal devices with minimizing request response time [9]. Figure 2 shows a fog-cloud system with three-layer architecture: cloud layer, fog layer, and IoT/end-users layer. e fog layer can be composed of one or more fog domains which are controlled by the same or different service providers. Each fog domain consists of the nodes including gateways, edge routers, switches, PCs, set-top boxes, and smart phones. e IoT/ end-users layer is formed by two domains which include end-user devices and IoT devices, respectively [10].

Characteristics of Fog Computing.
As a supplement to cloud computing, fog computing has several distinct characteristics from cloud computing. Cloud computing is based on social public cloud and IT operator services, while fog computing is based on small clouds such as enterprise, private, and personal clouds. Cloud computing typically consists of clusters of computing devices with high performance, while fog computing consists of more decentralized computers, each with its own function [9]. In addition, the following characteristics of fog computing are also essential.
(1) Location Awareness and Low Latency. Fog nodes are located between terminal devices and the cloud, tightly coupled to network and terminal devices, providing computing resources for them. Since the logical location of the fog node in the system and the cost of communication delays with other nodes are available, when the service requirements and data generated by the terminal device are sent to the network, the nearest available fog node will receive and process these requests and data [11]. Because fog  Figure 2: e structure of fog-cloud system [10].
nodes usually coexist with devices, the latency between them is much lower than the latency in cloud system [9]. (2) Geographical Distribution. Fog nodes provide some form of communication and data management service between the centralized cloud center and the edge of network where the terminal devices reside [3]. For example, high-quality streaming media services are provided to mobile vehicles in fog system by locating fog nodes on tracks and highways, which requires the extensive deployment of applications and target services which can identify location in fog.
In order to deploy the capability to fog, the operation of geographically concentrated or dispersed fog nodes is adopted. Such geographical distribution makes fog system achieve good results in the service based on geographical location [12,13]. (3) Agility. Fog nodes are distributed at the edge of the network, directly interacting with user terminals. e amount of data, network environment, and resource conditions that fog faces change constantly. Fog computing is adaptive in nature, supporting data load changes, flexible computing, resource pool, and network conditions changes at the cluster level and listing some of the adaptive features that are supported [9,14]. (4) Heterogeneity. A large amount of heterogeneous data with different formats and storage forms is generated in terminal devices at the edge of the network [9]. e ability to collect, aggregate, and process these heterogeneous data is critical as the fog node acts as a base station to provide processing and storage services. (5) Interoperability and Federation. Fog computing extends the powerful computing resources of the cloud to the network edge. Although the service requests of user devices can be quickly responded, the computing and storage capacity of each node is far less powerful than that of a centralized cloud center. Services requiring dense computation provided by fog to user devices may require joint support from multiple fog nodes. erefore, interoperability of fog components and cross-domain cooperation among nodes are supported in the fog [10]. (6) Real-Time Interactions. e interaction between user devices and fog nodes is in real time with no long wait and transmission delays. e data sent by the user devices is received and processed by the adjacent fog node immediately. When the processing is completed, the processing results will be timely returned back to the user devices, which allows fog to support time-sensitive applications [9].

Comparison of Cloud and Fog Computing.
As an extension of cloud computing, fog computing has many similarities and differences with cloud computing. e comparison between cloud and fog computing in this paper is made in the following aspects, which can intuitively reflect similarities and differences between them [7].
(1) Reaction Time and Latency. In fog system, timesensitive data is sent to the fog node closest to data source for processing and analysis, rather than being sent directly to the distant cloud center, significantly reducing the service response time. Computationintensive or delay-tolerant tasks can be processed in the dense area of fog nodes, which may take a few seconds. But the time to interact with the cloud can be a few minutes, minutes, or even hours [15,16]. us, faster responses and more flexible choices are provided by fog computing than by cloud computing.
(2) Node Location Distribution. Far away from user devices, the cloud center provides users with resource-intensive computing and storage services in the form of central servers, while the fog is close to the edge of the network in the form of scattered fog nodes. Each fog node can be either individual computing devices or servers with strong capabilities [15]. (3) Service Scope and Location Perception. e service scope of cloud computing covers the whole world, but the cloud center is far away from the user terminal and cannot accurately perceive the location of the service. Unlike cloud computing, there are numbers of fog nodes in fog system with the capability of service location awareness [17][18][19]. Fog domains formed by multiple fog nodes serve user devices in local areas like city blocks. e service scope is usually determined by the density and computing power of fog nodes [15].
(4) Vulnerability and Security. In the cloud system, the user data is stored in the cloud computing center, far away from users and more likely to be attacked centrally. Although Xu et al. [20] proposed a faulttolerant resource allocation method for data-intensive workflow to solve the recovery problem of failed tasks caused by the failure of a certain computing link, the possibility of systematic collapse caused by faster workflow aggregation still exists. Fog nodes are geographically dispersed and close to users, allowing users to protect the security and privacy of their data [1,21].

Collaboration between Cloud and Fog Computing.
Cloud center is far away from user terminals, and there are some problems in the application of the emerging IoTs (e.g., delay-sensitive applications). When fog extends the cloud to terminal devices on the edge of the network, these new service demands are met. So how can data sent by IoT devices be processed and analyzed in the collaboration of cloud and fog? is problem is discussed in the next two subsections. Figure 3 shows an example of a cloud-fog-IoT interaction model. What the fog and the cloud need to do, respectively, in the flow of task processing are introduced as follows.

Flow of Task Processing.
(1) e ings Fog Nodes Need to Do. At the network edge, fog nodes receive real-time data from the terminal devices which are usually heterogeneous and dynamic. en the analysis and real-time control of the data are carried out by running the applications supported by the IoT to achieve response within milliseconds [22]. Temporary data storage is also provided by fog nodes which usually lasts about 1 to 2 hours. After the data has been processed and analyzed, data summaries are sent to the cloud center regularly [9]. (2) e ings Cloud Needs to Do. Data digests sent by fog nodes are collected and integrated in the cloud platform. en, an overall analysis and evaluation of these data are made to obtain service growth trends which are helpful for service providers to determine the direction of business development. Finally, new application rules based on the results of business evaluation are formulated by platform which are used to achieve the goal of adjusting service balance [9].

Task Offloading among Fog and Cloud.
Because of the limited resources, the tasks of user devices that cannot be processed locally are sent to the fog nodes. Assuming a situation where the data and service demands generated by the edge devices are only processed in the fog server, when the situation of dense service demands occurs, the computing delay will exceed the allowable range of the requester for the limited resource of fog nodes. In general, two strategies are adopted: (1) Offload tasks to cloud and process them in cloud with rich resources and powerful computing capacity. After the task completed, the required results will be returned. (2) Offload tasks to adjacent fog nodes and complete the user's service demands through distributed collaboration among the selected fog nodes. Figure 4 shows a simple task offloading model that includes both fog-to-fog and fog-to-cloud task offloading. Many scholars have investigated the two offloading strategies. ey have been committed to building efficient architectures or developing smart strategies to decide whether to offload tasks to the cloud or fog nodes. In the latter case, the optimal offloading destination should be found in surrounding nodes.
Sun et al. [23] proposed a generic IoT-fog-cloud architecture. e problems of task offloading, time efficiency calculation, and allocation were turned into the problem of time and energy cost minimization. To solve this problem, they proposed an ETCORA algorithm that significantly reduces energy consumption and request completion time.
Yang et al. [14] and Du et al. [24] proposed joint offloading methods based on the existing fog-cloud framework and took various factors affecting the offloading (such as link bandwidth, latency, and computing capacity of the offloading targets) as parameters to generate mixed-integer programming. e difference is that Yang [14] proposed a greedy algorithm that maximizes operator benefits on the premise of ensuring user performance and security requirements, while Du [24] proposed a low-complexity suboptimal algorithm. e latter obtains offloading decision through randomization and semidefinite relaxation and obtained resource allocation policy using Lagrangian dual decomposition and fractional programming theory, which optimizes the time delay and energy consumption effectively.
Chen et al. [25] proposed an energy-saving offloading method. In this method, energy-saving offloading problem is formulated as a random optimization problem and random optimization technique is used to determine it.
Xu et al. [26] proposed a computation offloading method using blockchain technology. e balanced allocation strategy is generated by nondominant sorting genetic algorithm, and then the optimal offloading strategy is determined by simple additive weighting and multicriterion decision. In this way, overloaded tasks in a node can be offloaded to the most suitable adjacent node for safe and prompt processing.
Chen et al. [27] also proposed an offloading strategy. ey designed an efficient online algorithm that took into account the unnecessary consumption of idle servers, combined with the computation offloading and sleep decisions of node servers, to maximize server quality and reduce energy consumption.
Nassar and Yilmaz [28] formulated the resource allocation problem as a Markov decision process and finally solved it by learning the optimal decision strategy with some reinforcement learning methods, namely, SARSA, Expected SARSA, Q-learning, and Monte Carlo. eir work can make the fog node decide the processing location of service request according to its own resources, realizing the low latency transaction offloading and processing with high performance.
Chen et al. [29] developed an energy-efficient computing offload scheme that comprehensively considers the energyconsumption components at a fog node, including the energy consumption of transmission, local computing, and waiting state. ey proposed an accelerated gradient algorithm to find optimal offloading point with a high speed.
Deng et al. [30] investigated a load allocation problem that can be used to solve the optimal workload allocation between fog and cloud. ey then decomposed the problem into three subproblems by using approximation method. By solving these subproblems separately, the optimal collaboration scheme with low latency and energy consumption is given. Ye et al. [31] proposed an extensible fog computing paradigm and developed a distribution strategy through genetic algorithm. is strategy enables the roadside nodes to offload computing tasks with the minimum cost within the allowable delay. Table 1 is a summary of reviewed techniques or methods about task offloading among fog and cloud which contains each of the solutions and its unique advantages.

Fog Computing Helps on the New Challenges of IoT
Moving computing, storage, and analysis tasks to the cloud center with powerful resource has been a major solution to meet service needs over the past decades. However, the emergence of many delay-sensitive applications in the IoT has created many new application requirements, such as low latency and real-time interaction which the cloud cannot meet. e fog computing, expanding the cloud to network edge, is a better solution proposed to solve these problems. e challenges of the cloud-based IoTs and fog-based solutions with specific techniques are discussed in this section [7].

Low Latency Requirements.
Nowadays, many life applications and industrial systems require end-to-end communication with low latency, such as smart home applications and virtual reality applications, especially those requiring ultralow latency and affecting personal safety like driverless car [32]. In order to minimize the latency in data transmission, fog nodes are deployed on the edge of network, allowing data to be processed, analyzed, and stored near end-users. Due to the decentralized distribution of IoT devices, computing and service load distribution between fog nodes affect the computing and communication delay of data flows, respectively. To solve this problem, Fan and Ansari [33] proposed a workload-balancing scheme that associates the appropriate fog nodes with user devices, minimizing the data flow latency for data communication and task processing.
Xu et al. [34] introduced 5G into Internet of connected vehicles (IoCV) to improve the transmission rate of roadside equipment. ey innovatively designed an adaptive computation offloading method for the prospective 5G-driven IoCV in which multiobjective evolutionary algorithm is used to generate the available solutions. e optimal solution obtained by utility evaluation effectively optimizes the task response time and resource utilization efficiency.
Li et al. [35] proposed a delay estimation framework for IoT based on fog, which can accurately predict the end-toend delay in cloud-fog-things continuum. Mohammed et al. [36] proposed a data placement strategy for fog architecture.
ey solved the problem of data layout with generalized assignment and developed two solutions. ese solutions reduce latency by about 86% and 60%, respectively, compared with solutions based on cloud.
Naranjo et al. [37] proposed a smart city network architecture based on fog. In order to manage the application under the premise of satisfying QoS, the communication between devices in the architecture is divided into three categories. With this approach, the nodes in the architecture can run in high efficiency and low latency.
Craciunescu et al. [38] and Cao et al. [39] proposed algorithms for medical systems in order to detect individual falls in time. Gu et al. [40] minimized communication time by optimizing resource utilization in the healthcare system.
Dragi et al. [41] proposed a new nature-inspired smart fog architecture. is architecture is a distributed intelligent system modeled using new techniques in the fields of graph theory, multicriteria decision-making, and machine learning. It can provide adaptive resource management and low decision latency by simulating the function of the human brain.
Yousefpour et al. [42] and Elbamby et al. [43] proposed task offloading strategies to reduce service latency. In paper [42], fog-to-fog communication was employed to share workload, while a clustering method was designed in [43], which groups user devices and their service nodes with common task interests and uses a matching game, where computing delay is minimized under delay and reliability constraints.
Diro et al. [44] proposed an aggregated software defined network (SDN) and fog/IoT architecture, which allocates different flow spaces for heterogeneous IoT applications according to flow categories to meet the priority-based QoS requirements. is architecture reduces the impact of packet blocking on QoS delivery through more fine-grained control.
Rahbari et al. [45] proposed a greedy scheduling algorithm based on knapsack, which allocates resource to nodes in fog considering various network parameters. rough simulation experiments, they proved that the proposed algorithm has better performance in the optimization of time delay and energy consumption.
Shi et al. [46] set up a proof-of-concept platform. ey tested the face recognition application and reduced the response time from 900 milliseconds to 169 milliseconds by

Reference
Solution Advantages [23] A generic IoT-fog-cloud architecture Reduces energy consumption and request completion time [14,24] A joint offloading method based on the existing fog-cloud framework Takes various factors affecting the offloading as parameters to generate mixed-integer programming [25] An energy-saving offloading method Uses random optimization technique to solve energy-saving offloading problem [26] A computation offloading method using blockchain Offloads overloaded tasks to the suitable adjacent node with the optimal offloading strategy determined by simple additive weighting and multicriterion decision [27] An efficient online algorithm considering the unnecessary consumption of idle servers Combines the computation offloading and sleep decisions of node servers to maximize server quality and reduces energy consumption [28] An optimal decision strategy with some reinforcement learning methods Makes the fog node decide the processing location itself and realizes lowlatency offloading and high-quality processing [29] An energy-efficient computing offload scheme Proposes an accelerated gradient algorithm to find optimal offloading point with a high speed [30] An optimal collaboration scheme with low latency and energy consumption Decomposes the load allocation problem into three subproblems by using approximation method [31] An extensible fog computing paradigm Develops a distribution strategy based on genetic algorithm to enable the roadside nodes to offload computing tasks with the minimum cost offloading the computing tasks from cloud to the edge. Fog also supports time-sensitive control functions in local physical systems [3]. Table 2 is a summary of techniques or methods about reducing latency based on fog for IoT applications, containing reviewed solutions and their unique advantages.

Network Bandwidth Constraints.
As the number of devices connected to the network is increasing rapidly, the speed of data generation is increasing exponentially [47]. For example, a connected car can generate tens of megabytes of data per second including vehicle status (e.g., wear of vehicle components), vehicle mobility (e.g., driving speeds and routes), vehicle surroundings (e.g., weather conditions and road conditions), and videos recorded by automobile data recorder. A driverless car can generate much more data [48].
e American Smart Grid generates 1,000 gigabytes of data per year. Google trades 1 gigabyte a month and the Library of Congress generates about 2.4 gigabytes of data each month [49]. If all data is transmitted to cloud, ultrahigh-quality network bandwidth is required, which poses a heavy burden on the existing network bandwidth and even leads to congestion, obviously not advisable.
Fog nodes receive and process the data near user devices, filtering out irrelevant or inappropriate data to prevent them from traveling across the whole network [1]. Data generated by user devices is allocated to the nearest fog node for processing instead of being transmitted to cloud center, because much critical analysis does not require powerful computing and storage capabilities of the cloud. ABI Research estimated that 90% of the data generated by endpoints will be stored and processed locally, not in the cloud [47]. e way fog processes data significantly reduces the amount of data sent to the cloud, easing the burden of network bandwidth.

Resource Constraints of Devices.
In IoT system, user devices with limited resources (e.g., computing, network, and storage resources) cannot interact with the cloud directly, for which sending data to the cloud is impractical [50]. It is also unrealistic to update resources for these devices at high cost.
In this case, the functions of cloud cannot be performed well, while fog nodes can handle resource-intensive tasks for these devices without requirement of high performance [51]. Fog nodes are core components in the fog computing architecture, which are either physical components (such as servers, routers, gateways, and switches) or virtual components (such as virtual machines and virtual switches). Fog nodes tightly couple with access networks or intelligent devices and provide computing resource for these devices [9]. erefore, the complexity and resource requirements of terminal devices are reduced.

Stability of Service.
When a stable connection between user device and cloud is not guaranteed, continuous service cannot be obtained from cloud. For example, when a car enters an area not covered by a stable network, the cloud service is intermittently disconnected. Some necessary services are unavailable to the on-board devices and other user devices [3].
But, unlike cloud, fog nodes are distributed geographically. Edge networks created by fog computing are located at different points to extend the isolated infrastructure in cloud. A local system formed by fog nodes which can operate autonomously, with continuous coverage of the service scope, helps to process service demands more quickly and steadily [1]. Location-based mobility requirements and diversified service are supported by the administrators of fog nodes [18,40,52]. Due to the decentralized distribution of IoT devices, computing and service load distribution between fog nodes affect the computing delay and stability of service, respectively. To solve this problem, Fan Qiang and Ansari Nirwan [33] proposed a workload-balancing scheme that associates the appropriate fog nodes with user devices, which minimizes the data flow latency of communication and significantly improves the stability of service.
Yousefpour et al. [53] proposed a dynamic serviceprovisioning framework based on QoS perception for dynamically deploying application services on fog nodes. en a possible formula and two efficient greedy algorithms were given to address the service provision, which can provide stable and continuous service with low latency.

Security and Privacy.
With the purpose of requesting a service, large amounts of data are sent to the network, including personal privacy and corporate data. For example, work logs generated by smart home appliances can be mined to reveal the work and rest rules of users, and important private information (e.g., password and possessions) can be eavesdropped from chat logs. erefore, both the static data and the transmission process in IoT need to be protected, which requires the monitoring and automatic response of malicious attacks in the whole process [13].
In cloud computing, corporate and private data, and even confidential data, are stored centrally in cloud servers far away from users. e security and privacy of personal and enterprise data are questioned by users because they cannot determine whether their data is stolen by malicious actors with interest and whether their data will be lost in the expansion of the cloud center [1].
In fog computing, sensitive data is processed locally rather than being sent to the cloud. Local administrators can inspect and monitor the devices that collect, process, analyze, and store data [13,51]. In the fog system, each fog node can act as a proxy for user devices which cannot adequately protect data due to resource constraints, helping update and manage the security credentials of user devices, to compensate for their security vacancies.
Abbas et al. [54] proposed an innovative fog security service to transfer confidential and sensitive data generated by IoT devices to fog nodes for processing and provide endto-end security between them by using two mature encryption schemes, identity-based signature and identitybased encryption. Local information also can be used to monitor the security status of nearby devices and detect threats immediately to ensure security [3,55].
In recent years, some malicious code detection techniques have been proposed to solve the problem of security detection in fog environment. Zhang et al. [56] used signature-based detection technique and Martignoni et al. [57] proposed a behavior-based detection technique. However, behavior-based detection has a high cost because of resource constraints of fog nodes. Signature-based detection technology is more effective, but it is still difficult to detect variable malicious code in distributed fog nodes. In this case, a hybrid detection technology combining the two technologies was proposed to solve this problem [58]. e behaviorbased detection technology in the cloud is distributed to fog nodes, and suspicious software files are detected and sent to the cloud for analysis. If the malware is new, the analysis result will be saved to the database as a new signature and the malicious signature list of each node will be updated.
Xu et al. [59][60][61] improved the strength Pareto evolutionary algorithm to obtain offloading schemes. e scheme proposed in paper [59] is privacy-aware, which effectively protects the privacy of training tasks offloaded to fog nodes with maintaining overall network performance, while schemes in paper [60,61] are trust-aware. After the balanced scheme is obtained, they used the multicriterion decision technique and similarity prioritization technique of ideal solution to determine the optimal solution, which can effectively protect privacy with minimized service latency. ota et al. [62] proposed efficient centralized security architecture based on fog environment. Patient's medical data is transmitted seamlessly from sensors to edge devices and finally to the cloud for medical staff to access. e architecture effectively protects the privacy of patients and the security of medical data. Chi et al. [17] proposed a service recommendation method based on amplified location-sensitive hash in order to ensure privacy security of distributed quality data from multiple platforms during cross-platform communication and proved its feasibility through experiments.
Viejo et al. [63] used new fog choreography concepts to solve the problem of reduction of service response time caused by resource constraints of the IoT. e security and efficient delivery of the service were realized successfully, which provide effective support for expensive encryption technology.
Mukherjee et al. [64] firstly designed and implemented a middleware featuring end-to-end security for cloud-fog communications. e intermittence and flexibility of middleware were proposed, respectively, by dealing with unreliable network connection and customizing the security configuration required by the application. e middleware can provide fast, light-weight, and resource-aware security for a wide variety of IoT applications.
Li et al. [65] proposed a hierarchical data aggregation scheme for efficient privacy protection. By modifying Paillier encryption, this scheme can not only resist external attacks but also prevent personal privacy data from leaking from internal devices.
Daoud et al. [66] designed a security model based on fog-IoT network. en a comprehensive scheduling process and resource allocation mechanism were proposed based on the model. rough these efforts, they successfully introduced the active security scheme with low latency and ultratrustworthiness into fog-IoT network.

Reference
Solution Advantages [33] A workload-balancing scheme associating the appropriate base stations with user devices Minimizes the data flow latency for data communication and task processing [34] An adaptive computation offloading method for the prospective 5G-driven IoCV Optimizes the task response time and resource utilization efficiency with the optimal solution obtained by utility evaluation [35] A delay estimation framework for IoT based on fog Accurately predicts the end-to-end delay in cloud-fog-things continuum [36] A data placement strategy for fog architecture Solves data layout problem with generalized assignment problem and develops two solutions [37] A smart city network architecture based on fog Divides the communication between devices into three categories to satisfy QoS [38,39] Detection algorithms and fog-based medical information systems Detects individual falls in time [40] A medical cyber-physical system supported by fog computing and a heuristic algorithm with two phases Minimizes communication time by optimizing resource utilization [41] A new nature-inspired smart fog architecture Provides adaptive resource management and low decision latency by simulating the function of the human brain [42] A task offloading strategy to reduce service latency Employs fog-to-fog communication and share workload [43] A clustering method for offloading Groups user devices and nodes and uses a matching game to minimize computing delay [44] An aggregated software defined network and a fog/IoT architecture Reduces the impact of packet blocking on QoS delivery through more fine-grained control [45] A greedy scheduling algorithm based on knapsack Allocates resource to fog nodes considering various network parameters, optimizing time delay and energy consumption Table 3 is a summary of reviewed fog-based techniques or methods to protect security and latency in IoT applications, containing each solution and its unique advantages.

Heterogeneity.
In the fog, a large number of heterogeneous platforms and devices are connected to the Internet, and the services or resource requests they send are often heterogeneous, which requires all nodes in the network to dynamically identify all the request information. In fact, there has been some work to classify nodes using labels [67] or to add descriptions to resources to provide solutions for heterogeneous requests. Most of these solutions are based on static recognition and their work depends on the developers of the architecture program [68,69], lacking flexibility and generality. In addition, data or service requests sent by IoT devices may be supported by multiple service providers, each using a mostly inconsistent service description model. More complex heterogeneous data and models will be produced for the addition of new providers, which brings about more burden to programmers.
ere have been also many algorithms proposed in the fog environment to compute the capabilities of fog nodes, some of which consider the resource constraints of different devices and model the differences of capabilities between nodes, while most of which cannot meet the heterogeneous criteria [31,70,71]. Even so, these works are based on the different understanding of heterogeneity of nodes in network. erefore, semantic specifications should be defined in a clear form within the fog domain so that IoT devices or clouds connected to the fog network can share information in a commonly understood manner, which will contribute to the homogeneity of heterogeneous data at the edges and the simplification of data transfer protocols [10].

Mobility.
Mobility presents significant challenges for both IoT devices and fog nodes. A large number of IoT devices are now wirelessly connected to the network and are generally mobile. e coverage of each fog domain is limited, which makes it necessary to consider service migration when the connected IoT device falls out of service scope.
How to migrate the service data from the previous fog domain to the new fog domain without interrupting the service is a challenging task. In the simplest case, IoT devices on a vehicle may move between different fog domains, making the service provided to on-board devices unstable. To solve this problem, Hassan et al. [72] recommended that service metadata be stored in the cloud so that it can be downloaded continuously after the device is migrated. But it will undoubtedly take some time to update the service information after the migration because of the difference of data between the cloud and the device. Another option being considered is to extend the existing fog architecture to support device mobility [73], which still needs to address the migration problem further. In fact, if the real-time moving trajectory of the device is obtained, machine learning technology can be used to analyze it and predict the future trajectory. Based on the predicted results, the next fog domain can update the service information of the device before it reaches the edge of the fog domain.
In addition, how to allocate the available resources/tasks that a fog node carries when it joins/leaves a fog domain is a complex issue. Song et al. [74] investigated this problem, hoping to realize dynamic load balancing in the fog region during node migration. Even so, how to achieve load balancing in a short time with affecting fewest nodes is still an optimal-solution problem to be explored.

Data and Equipment Management.
Billions of devices (e.g., mobile phones, computers, palmtops, and smart appliances) are connected to the fog and the scale is growing. Different faults caused by various heterogeneous devices may occur anywhere. But tracking the fault information of hardware and providing software patches for maintenance in time are complex works, which need a sound fault detection and analysis mechanism and can locate the location Table 3: Work summary of security and privacy based on fog for IoT applications.

Reference
Solution Advantages [54] An innovative fog security service Uses identity-based signature and encryption to effectively protect the sensitive data transmitted to the fog node [56,57] Two detection techniques Detects malicious code attacks stably [58] A hybrid detection technology Extends cloud-based detection technology to fog nodes [59][60][61] Offloading schemes driven by the improved strength Pareto evolutionary algorithm Uses the multicriterion decision technique and similarity prioritization technique to protect privacy with minimized service delay [62] An efficient centralized security architecture based on fog environment Protects the privacy of patients and the security of medical data through the device-edge-cloud transmission route [17] A service recommendation method based on amplified location-sensitive hash Ensures privacy security of distributed quality data during cross-platform communication from multiple platforms [63] A new fog choreography concept Realizes the security and efficient delivery of the service [64] A middleware featuring end-to-end security for cloud-fog communications Uses middleware to provide fast, light-weight, and resource-aware security for a wide variety of IoT applications [65] A hierarchical data aggregation scheme for efficient privacy protection Prevents personal privacy leaks while resisting external attacks [66] A security model based on fog-IoT network Introduces the active security scheme with low latency and ultratrustworthiness into fog-IoT network of the fault in time. In addition, the Internet Data Center (IDC) estimated that the amount of data generated by IoT devices will reach 44 zettabytes in 2020 [75]. How to store such a huge amount of data in fog nodes with limited resources is another problem that must be solved. Open fog suggests using machine learning technology to develop a framework with fault comprehensive feature detection and fault tolerance [76], especially in systems involving critical applications of life, such as anomaly detection in the medical field. ere is also a data management scheme proposed in [67], which uses the labeling method to add labels for different types of data to facilitate access. is method can be used in the management of IoT devices. However, many management schemes do not take the resource availability into account, which has a great impact on the workload that devices can share in fog. erefore, the expected research scheme should be based on the dynamic update of the connected devices, rather than simply assuming that the devices are fixed.

QoS Management.
SLA management is an unavoidable direction to study QoS management. ere are a number of cloud-based SLA management schemes that effectively reduce transmission latency, guarantee transmission bandwidth, and reduce packet loss rates (e.g., [77][78][79][80][81][82]) by reducing SLA violation rates or improving QoS.
In the fog, however, few SLA-managed schemes have been proposed, which are critical to maintaining desired QoS in the fog, where distributed services are dynamically provided. Among the papers reviewed in this article, only Yousefpour et al. [53] proposed a dynamic service-provisioning framework based on QoS perception for dynamically deploying application services on fog nodes, while it is only sensitive to the measure of delay, which is the same as many other strategies that meet QoS standards.
Although latency is certainly an important indicator of a system, there are many other important performance indicators to consider, such as bandwidth, resource utilization, and energy consumption. ese indicators should be integrated as targets for future research strategies rather than as constraints alone. For example, Yang et al. [14] and Du et al. [24] proposed a joint offloading method that takes the link bandwidth and latency as parameters, but their method is only an optimization under time delay constraints rather than multiobjective optimization.
In fact, cloud-based QoS management technology has been relatively mature. e new SLA management solution could be an extension of the cloud-based SLA management technology with additional considerations for the uniqueness of fog [10] (such as resource constraints, low latency, and geographic distribution). Although the services are more diversified due to the large amount of heterogeneous data in fog, it is not difficult to solve the fog-based integrated QoS optimization if the semantic specification mentioned in Section 5.1 can be completed to solve the problem of heterogeneity.

Security and Privacy.
As mentioned in Section 4.5, fog nodes act as agents to provide secure selection for resourceconstrained devices and encrypt the transmission before the data leaves the edge [3]. But, to put it in another way, fog nodes are scattered on the edge of network where the environment is much worse than the cloud center [83,84]. Because many fog nodes are in public places, the safety of physical equipment is difficult to guarantee. Moreover, lack of sufficient resources and computing power makes fog nodes unable to perform some complex security algorithms, so fog systems are more vulnerable to attack, such as session hijacking, session riding, and SQL injection [85]. e security and privacy challenges of the fog can be divided into four points: (1) A trust model and mutual authentication trust mechanism are necessary to guarantee the reliability and security of fog network [86]. (2) Traditional certificate and public key infrastructure (PKI) authentication mechanisms are difficult to be used by resourceconstrained devices. [87]. (3) e messages sent by IoT devices cannot be encrypted symmetrically. In addition, asymmetrical encryption technology has great challenges, including resource and environment constraints, overhead constraints, and maintenance of the PKI [86]. (4) Location privacy in fog is vulnerable to leakage. While fog nodes are location-aware, collecting location information of IoT devices has become much easier than before [88]. In addition, frequent interaction among the three layers of fog architecture will increase the possibility of privacy disclosure. Without proper security measures, the performance of fog system may be seriously damaged.

Prospects
e rise of 5G technology promotes the application of fog computing technology. We expect fog computing technology based on 5G network to play a key role in the fields of intelligent driving and tactile robots.
Intelligent driving is an important technology to solve traffic congestion in the future, including automatic driving and human intervention. Fog nodes are distributed on the roadside, which can reduce the delay of data transmission between vehicles and nodes. But 4G network-based communication is far from being capable of transmitting the huge amount of data that cars generate while driving, and the delay is far from the requirement of automatic driving. 5G network is the key enabler to realize intelligent driving in fog system, which can provide ultrastable and ultrafast data transmission. When the vehicle is under automatic driving, roadside sensors and on-board equipment collect real-time road and vehicle information and send it to the roadside fog nodes for processing and analysis. Applying sophisticated machine learning techniques to fog nodes is necessary, which can learn to recognize all possible road conditions and send correct response instructions to driving system. Based on the same principle, the attitude detection of the driver during manual intervention can also help to improve the safety of driving.
Traditional robots are usually operated by command. It is difficult to break the technical bottleneck of remote control for transmission delay. But if the robot system architecture is deployed on the fog, the sensing equipment of the remote robot and the control equipment with tactile sensation are taken as the user terminal equipment, and the service nodes supporting the tactile command processing and analysis of the robot are brought into the fog layer. With the support of 5G ultrahigh transmission rate and tactile Internet [89,90], real-time control of the robot can be realized. is work can be extended to the field of telemedicine and disaster relief with great research prospects. ese works need to be based on completing the challenges of Section 5.

Conclusion
is article surveys the literature on cloud computing, fog computing, and IoT. Based on the concept and characterization description of cloud computing and fog computing, the comparison and collaboration between them are elaborated and some proposed task offloading methods are introduced emphatically. By surveying proposed techniques and methods, the contribution of fog computing to solving the challenges of IoT applications is introduced. en the remaining challenges and research directions of fog after integrating into IoT system are discussed. In addition, the key role of 5G-based fog computing in the field of intelligent driving and tactile robots is prospected.

Data Availability
No data were used to support this study.

Conflicts of Interest
e authors declare that there are no conflicts of interest.