Blockchain and Fog Based Architecture for Internet of Everything in Smart Cities

: Fog computing (FC) is used to reduce the energy consumption and latency for the heterogeneous communication approaches in the smart cities’ applications of the Internet of Everything (IoE). Fog computing nodes are connected through wired or wireless medium. The goal of smart city applications is to develop the transaction relationship of real-time response applications. There are various frameworks in real-world to support the IoE in smart-cities but they face the issues like security, platform Independence, multi-application assistance, and resource management. This article is motivated from the Blockchain and Fog computing technologies and presents a secured architecture Blockchain and Fog-based Architecture Network (BFAN) for IoE applications in the smart cities. The proposed architecture secures sensitive data with encryption, authentication


Introduction
The origin of smart city stems from the improvement in the quality of life of citizens and optimal resource utilization of the city [1], due to the recent acceleration in the urban living. The improvement in infrastructure and services has upgraded the quality of life. This has been possible due to the Internet, communication and information technology advancements [2]. Some of the expectations derived from the idea of smart cities include efficient public services, and better infrastructure, which is easily accessible and more interactive. The smart city vision has become a reality with the potential of the Internet of things (IoT). As a consequence, the smart city has come out as one of the major drivers for the IoT applications. The entire city is covered with the physical objects, which are interrelated with the IoT system. The four pillars that can be connected with IoT concepts are data, things, people, and processes. The Internet of Everything (IoE) emerged with the people in the IoT paradigm, whereby an interconnected network is aggregated in IoE. Therefore, the vision of a smart city integrated with IoE pillars to facilitate promising services in the future.
The distributed environment used for the IoE's generation of Big Data (BD) has the potential to raise the problems of data storage and data processing. Cloud computing can be a solution; the processing and storage can be acquired on-demand, based on a pay-as-you-go manner.
However, inherent problems are the reason for the inefficient working of the applications in the cloud environment [3]. For example, the traffic monitoring and health monitoring application in the smart cities cannot afford the delay in communication from the origin of data to the cloud data center, and then again, at the end-point application. Therefore, the fog computing concept has emerged recently. It reduces the network traffic and processing time of data by bringing end-user closer to the cloud services at the edge of the network [4].
Cisco [5] has given the FC's primary definition as "Fog Computing is a paradigm that extends Cloud computing and services to the edge of the network." The Fog Node (FN) helps in the execution of IoT application, which is one of the basic fundamental entities in FC. Generally, the FC acts as an intermediate layer between cloud infrastructure and end devices/end users. IoT applications need low latency, geo-distribution, awareness, and mobility support. The proposed BFAN architecture is aimed at improving the mentioned param by processing most of the data near to the end-users or end-devices. The security is enhanced with the Blockchain technology. Blockchain is a chain of blocks that grows with each transaction and is linked through cryptography. The block is a combination of transaction data, timestamp, and previous blocks' cryptographic hash.
It is a new buzzword that is capable of attracting many developers and researchers. Blockchain helps to provide true redundancy and full decentralization. The smart contract resource allocation algorithm helps to provide the on-demand resources and, bills are generated after the usage. The key is managed by the user and fragment stores in the encrypted format. There is no third party involved in controlling and accessing data. Therefore, there is no way to recover the lost private keys.
The monitoring of resource utilization helps in comparing the value of performance metrics in service level agreement (SLA) with real-time values. This helps to provide the quality of service (QoS) to the end-user. The storage cost of Amazon S3 is $25 per TB/month, where Blockchain's cost is approximately $2 per TB/month [6]. Thus, the blockchain has the potential to reduce the storage cost by up to 80%.
The FNs can be chosen as the nearest medium for processing and storage, which can reduce the delay of data transfer at a remote location as well as save energy. The proposed BFAN framework attempts to answer various issues such as: • Security: The security in the smart-cities concerned with cyber-security and physical security. In this article, the protection of data from attacks, computing infrastructure, and network are performed using Blockchain technology.

•
Caching: Low-latency is one of the vital aspects of smart-city. To achieve this, caching is used to store more frequent data at different locations in a network. Caching also helps to reduce network congestion by avoiding the flow of repeated data on the network. Fog computing with caching enables a variety of applications in smart cities. • Scalability: This enables elastic services in Fog computing in order to provide the Quality of Service (QoS). Dew computing concepts is applied in the proposed BFAN architecture to provide a fast and scalable cloud-like environment near to the IoE devices. • Sustainability: The energy-efficient frameworks is the current requirement for smart cities using renewable energy sources. The sustainability aim is to reduce carbon footprints. Nowadays, brown sources produce more than 80% of the energy used in data-centers [7,8]. Therefore, we consider sustainability as a major concern in the article. The proposed BFAN framework helps to reduce the carbon footprint, increase the profit and hardware reliability. Context-awareness: An ability to obtains the node locations and information of the environment is called context-awareness. The proposed BFAN framework is context-aware and considers the environment param and node locations to choose the appropriate mode of communication.
This add more meaning to the current state-of-the-art for energy efficiency and services of smart cities.
It is important that the components and services in the smart cities must be equipped with emerging technologies of 4 pillars. The major contributions of the article are listed below:

•
We have devised a smart city architecture with Blockchain and Fog Computing for every device.

•
The resource provisioning model has been presented for FN-to-FN, devices-to-FN and device-devices components.

•
The real dataset has been used to evaluate the performance of our proposed BFAN model in various types of communication.

Related Work
Smart cities and IoT related work has been done by several researchers. The characteristics of smart city services and IoT system characteristics have been introduced by the Padova smart city project [9]. The project [10] constructs an IoT application with a distributed coordination scheme for smart city applications. The integration of cloud and IoT is ensured to develop the frameworks and applications for smart cities. The cloud-based framework [11] has been developed with IoT capabilities.
There are many disadvantages of cloud technology when used with smart cities applications such as congestion in traffic, latency, higher processing, and less throughput. Many of these drawbacks can be addressed by using fog computing, which brings the processing and storage near to the end-users. This improves decision making and analyzing capabilities of the overall system.
The FC with Stack4Things and OpenStacks platform is presented to improve the latency and scalability [12]. FC architecture is designed as being service-oriented for the application of telehealth, using on-site processing of data [13]. In order to optimize these services, three-tier architecture has been proposed. The ambient services and wearable sensors are gathered as the raw data. Data processing and filter are performed in the next stage. The secondary analysis is conducted in the third phase. Two case studies have been done to validate the results-The first one is on Electrocardiography (ECG) and the second is a speech disorder. The review of the existing frameworks has been performed based on application and important param such as security, caching, sustainability, scalability, and context-awareness. Security is concerned with the cyber-security which protects from attacks for data, infrastructure, and network. Cache memory is used to store the more frequent data. This helps to achieve low latency. Then the scalability provides the elastic service for the computing and memory resources. Furthermore, sustainability refers to renewable energy resources for designing the energy-efficient system. Other vital param include content awareness, which gives the information of the node's surrounding environment and its exact location. The comparison of various fog computing developments is demonstrated in Table 1.
Giang et al. [14] developed smart transportation with fog computing. Scalability and content awareness is discussed with the vehicular network. The author has also discussed the current state-of-the-art challenges. Premsankar et al. [15] devised a Road Side Unit (RSU) to reduce the energy consumption and deployment cost. Vehicular application is considered for Quality of Service (QoS) to the end-user.
Fernández-Caramés et al. [16] designed an augmented reality (AR) based three-layered edge computing framework for industries. The real-time implementation was performed to demonstrate the effectiveness of the proposed model. Schneider at al. [17] developed a live support architecture for remote access. The bandwidth was optimized with the compression of videos. Muhammad et al. [18] developed a treatment and assessment framework for voice assistance in edge computing. The inter-operation was supported by this framework. Gia et al. [19] proposed a health monitoring system where notification and joint analysis of ECG could be accessed remotely. The unauthorized access can be restricted with fog assisted gateways.
Kumar et al. [20] developed a Vehicular Delay-tolerant Network (VDTN) and edge computing based smart-grid 4-layer architecture. The mobile devices are considered in the first layer whereas the second layer is composed of routers and gateways. The next layer contains a database server, file server, and authority servers. The fourth layer is cloud computing. Okay et al. [21] integrate fog computing with a smart grid. The qualitative use cases are used for the evaluation of the proposed technique.

Reference
Application Security Caching Sustainability Scalability Context-Awareness [14] smart-transportation [15] smart-transportation [16] Augmented reality [17] Augmented reality [18] Smart-healthcare [19] Smart-healthcare [20] Smart-grid [21] Smart-grid [22] Smart-farming [23] Smart-farming [24] Smart-buildings [25] Smart-gaming Ferrández-Pastor et al. [22] used edge computing for designing the flexible layered IoT assisted architecture for Precision Architecture (PA). Zamora-Izquierdo et al. [23] designed a PA architecture based on 3 planar edge computing. The control module is generic and flexible to exploit the edge layer with Network Function Virtualization (NFV). This architecture has been implemented in Spain's greenhouses to validate the effect of this architecture. Vallati et al. [24] proposed a LTE based architecture for smart-home. The edge servers are placed at different places to identify the effect of edge computing in smart homes. Premsankar et al. [25] presented the edge computing architecture for mobile games. The experiment evaluation demonstrated that communication's low latency and high reliability was achieved for mobile gaming The existing work is carried on the FC and, IoT helps to overcome the problems by keeping smart city vision in view. It also takes the help of cloud data centers for storage and computing. However, very few authors have worked on energy consumption and delay for FN by allocating the job to the most suitable resources from the available resources. Here, we have proposed a Blockchain-based multi-tier framework.

Overview of Smart City Model
The high-level view of the smart city model is shown in Figure 1. It shows how the various elements in a smart city communicate with each other to provide the services in smart cities [26][27][28][29][30]. Different types of components are the part of smart cities which interact with each other through cellular services or Internet services (e.g., ZigBee, Wi-Fi, 3G/4G/5G/6G). The smart energy, smart grid, and smart mobility are the different services in the smart city environment. The macro or microcell objects are the communication devices used to provide on-demand services.

Blockchain and Fog Based Architecture
The Blockchain and Fog based Architecture Network (BFAN) is proposed for the smart cities to connect the Internet of Everything (IoE) and fog nodes [31][32][33][34]. In order to gain high performance and low latency, the distributed form of technology helps to provide on-demand services. It will improve the quality of life of the citizens and meet the expectations of the residents. In order to speed up the data processing, the fog computing paradigm helps the IoE components by giving the low latency. The proposed architecture BFAN is shown in Figure 2, which could offer a better solution for future smart cities.

Storage
Servers Application The proposed architecture consists of two layers. The first layers are of Fog nodes, which decrease the latency by processing the data on fog nodes received from the incoming traffic of IoE. It also helps to meet the user expectation of fast services. A multi-layered architecture has been proposed as shown in Figure 2 for the application related to big data in future smart cities. The first layer in this architecture represents the connected devices with each other and with FN. The intercommunication takes place between connected devices and security is provided with Blockchain technology. The second layer is of FN, and is deployed to reduce the latency by handling the traffic from IoE devices. This helps to meet the service demand of the users.
The working of each layer has been discussed in the following subsections.

Fog Node Layer
The service demand of the users can be met with smart city IoE devices that are connected with a fog computing environment. Blockchain is used to enhance the reliability by adding a new component into the city, after proper permission from the distributed ledger supported technology. The numerous physical servers are combined to make FN, which covers the specific area of diameter. The fog nodes may be connected with wired/wireless media. The FN acts as a small virtual data center to provide the processor, configured hardware resources and network services. Fog Nodes are composed of processor, configured hardware resources and network services. The smart sensors collect the data from the nearby environment and FN performs the real-time analysis of that data and gives intrinsic, which helps in decision making. Furthermore, the radio access network is also facilitated by the FN to provide the unicast wireless communication in a specific range. The concurrent data transmission is supported by the newly developed protocols to transmit the packet to all the destinations or a particular destination. The local database can be embedded in the FN, which provides the storage for the passive applications that reside in the memory. This provides the facility of low processing and loading time for heavy IoT applications. One crucial application is Social IoT (SIoT), it plays a major role in the reliability, bandwidth, optimization of the latency, IoE deployment, and IoE network security. Here, the communication takes place between various FN to pass the essential data.

Internet of Everything Layer
This layer is the real environment for the users to deploy the application without any limit. The IoT devices are clustered according to their location and functionality. This helps to reduce energy consumption, throughput, cost, and time overheads. The workload of data centers will be increased because of software and hardware services requiring integration and processing.
The peer-to-peer (P2P) TCP/IP communication occurs between the IoT devices where the distance is short. If they are far from each other, then these devices can use the FN through WiFi, ZigBee, and Bluetooth like technologies.

Blockchain for IoE
The existing IoE works on a centralized model for communication. The centralized cloud servers validate the IoE devices. Therefore, the existing solutions for IoE in smart cities use cloud computing and network resources, which leads to high infrastructure and maintenance costs. In the Smart cities having a scalable environment, the devices are grown or shrink regularly. It implies that smart sensors are added more frequently in smart city infrastructure as adhoc network. The current system does not support large IoE devices due to the scalability issue. As the number of resources increase, the interaction between devices and servers also increases. The cloud servers also face an issue of a single point of failure. In a smart city, a centralized system is a drawback, and therefore, the peer-to-peer model can be more effective.
In the proposed model, we have applied the Blockchain for IoE because it is decentralized and tamper-proof. It is easy to track the million-billion of devices connected in the network. It also reduces the cost of server management and installation. It also saves the smart city IoT devices from man-in-middle attack because there are multiple channels of communication. The smart agreements and contracts are executed based on conditions met. The data received from the smart sensors is stored in Blockchain.

Data Transfer
The target application such as SIoT, has a large amount of data to transfer and this size grows regularly at a fast pace. This also raises the requirement of network bandwidth, data storage, and processing speed. Data is transferred from local storage, web and IoT devices. Data manipulation is applied as per the protocol of the organization such as cleaning, filtering and integrating.
Here, the cloud is employed at the last layer to process the metadata. The FN (an edge or dew computing) analyses the data and make metadata abstract. The proposed BFAN architecture enhances the mobility of IoE applications users with FN and dew computing, further security is provided through Blockchain, which disables the anonymous users' entry in the IoE devices. FN and dew computing provide the application services with the storage on the work for the IoE devices. The communication takes place in the following order:

•
The communication between the local devices with sensing and processing capability is known as primary or inter primary communication. These devices can be sensors, laptops, touch-screen devices and computers used for P2P communications. Wi-Fi is used to communicate between IoE devices, where the distance is medium. The inter primary communication takes place with ZigBee and Bluetooth, while the short distance uses TCP/IP medium for inter primary communications.

•
The communication between dew computing and Fog Nodes takes place with wireless or wired media. The optic fiber, CAT-5/6 is used for TCP/IP for end-to-end connection.
The local wireless connection is used to communicate inter primary and primary communication. There are direct and indirect connection types of communication. The direct hoping system is applied to communicate between FNs. This makes the proposed BFAN architecture minimize the latency rate.
Multi-casting is supported for secondary communication. The characteristics of the communication system are described in Table 2. The inter primary and primary communication QoS improves with high-speed communication, with low latency. As compared to other communication systems, BFAN supports the applications of stream type/pervasive, heterogeneity with secondary connections. The storage devices, servers, and other components are shown in Figure 2. The fog components are connected with the particular server, as shown in Figure 3. The secondary and primary communication is isolated from each other as per the distance of components. The scalability of FNs can be grown or reduced. Primary communication is handled with the local connection while the secondary communication's responsibility is given to external connections. The t2t relationship is a subcategory of primary communication. Blockchain is used to authenticate and authorize the applications. IoE layer of BFAN over the safe communication path is used to avoid congestion. Similarly, this process is followed by for tFNt communication.

Experiment Evaluation
The experiment evaluation is conducted in a real-time scenario for smart cities.

Experiment Setup
The numerical simulation is conducted for the proposed platform is compared with the existing platforms. The iFogSim simulator is used for the experiment of the proposed BFAN model. This simulator provides a real-time scenario for the smart city fog network [3]. We follow the same network setting as used in the article [35]. The tasks are the incoming traffic of web applications. The incoming workload requires two types of resources such as CPU and network.
The physical proximity of the devices helps to deploy the FN at the distance (e.g., 3 feet, 30 m, 10 m). The served clusters act as a service point for a particular diameter of FN's spatial cluster.
The multi-core processors are deployed in FN to serve the multiple requests at a time for 6 GB RAM, AMD Phenom 6 core processor. In order to gain high performance of processor at low energy, these settings ensure maximum gain in the operating frequency. Every FN has two modes of communication: primary and secondary, which are connected through the Giga Ethernet. The incoming workload has been processed at FN and consumes the electric power. We assume that each core processes the same number of tasks at the frequency of 10 Megabytes per second. We set the idle CPU power at 105 watts and maximum power at 195 watts. The delay is considered as 6, 4 and 2 ms for FN2FN, tFNt, and t2t. Furthermore, the configuration time for wired communication is 10 ms and for wireless 0.5 ms is considered. The experiment is performed for 1000 s in simulation.

Energy-Consumption
The proposed BFAN is validated on the energy consumption (Network and CPU) with D2D [36] with respect to numerous costs in communication as shown in Figure 4.The web-based applications are tested to calculate power consumption. Figure 5 shows the traffic of the real workload, which is further normalized for different communication. Figure 2 shows the distributed and integrated FN. The BFAN's numerical results for the average time and energy report per round are simulated for FN2FN, t2FN, and t2t. The medium of communication can be wireless or wired. As per [36], single-hop D2D for IEEE802.11b is used for t2t communication. The results demonstrate in Figure 6 that the D2D platform is less efficient than the proposed BFAN platform. The D2D platform is affected by the path loss, fading, retransmission of packets and TCP time-out. The primary, interprimary and secondary average power consumption are shown in the Figure 7.

Latency
The impact of proposed framework is evaluated based on latency in service delivery. The sum of task completion time and network propagation is calculated to find the latency of service delivery. The Fog infrastructure brings the computational capacity closer to the data source. This results in the reduction of network delay. The effect of Fog computing would be less if the size of the data source is less. The proposed architecture increases the latency by adding the Blockchain feature. Figure 8 shows the comparison of the proposed architecture latency of service delivery. The users can disable the Blockchain feature in the proposed BFAN architecture. The processing overhead will be increased with the Blockchain feature. The interval of the subsequent task can be managed, which further improves the performance of the proposed BFAN framework.

Research Directions
The big data applications are supported by a wide variety of academic research to visualize, curate, analyze and capture the data [37][38][39]. The system is an integration of learning services, information services, and infrastructure services. In the education system, each student generates new information that needs further input, processing, and analysis [40]. The teaching needs to enhance the existing system using the existing technologies of video, voice and text innovations.
The fundamental changes are needed to be made for innovative and interesting teaching, which can integrate worldwide students. Big data analytics is required for business decisions. The producer's and owner's protocols need to developed by the government, in order to make these decisions better [40]. The massive data volumes need to be analyzed in real-time, to improve the quality of online analytics of data and processing.

Conclusions
The internet of everything applications in the smart city needs to be energy-aware, low latency and scalable. We have designed a new framework named BFAN, to deploy this application securely and optimally. The proposed architecture of BFAN can reduce the FN's average power consumption and make them scalable, and ensure that communication and computation are efficient. The major contributions of the proposed BFAN architecture include an energy-efficient platform for thing-aware wired/wireless TCP/IP connection, intra-primary communication in fog computing and security with Blockchain. The overall performance demonstrates that the proposed BFAN architecture is an efficient solution for urban regions to provide Fog based applications with energy-efficiency, scalability, and security.
This work can be further used in various fields such as 5G/6G in the streaming applications for online games, as well as video chatting in the various areas of the smart cities. Mobile edge computing can be further used with strong dew computing techniques to provide real-time processing.