*3.3. Proposed C2F2C Framework*

In this paper, a C2F2C framework is proposed for resource allocation in residential areas as shown in Figure 2. The proposed framework is based on the following resources: electricity and its requested entertaining facilities like MG, cloud and fog for smart buildings. Cloud and fog also have some resources such as computation, storage and networking facilities (between the end devices to the service providers). These resources are responsible for managing the demands of consumers in six regions of the world. The whole framework is comprised of a cloud, six fogs within the regions, set of buildings, set of homes, and their load requests. These six regions are considered for the residential energy consumption and management. Each region has one fog for fulfilling its demands. When clusters of the buildings send load requests to the fog server for completing the load demands, this framework uses MGs on first priority to fulfill the load demands of the consumers, otherwise, it communicates to the cloud for exchanging services with the utilities. There are two MGs which are deployed in each region as shown in Figure 2. MGs are based on distributed generation, loads, storage devices, etc. and integrated with the residential buildings. In each region, MGs are installed by the users and managed by the fogs. The proposed framework acts as the automation of the energy management services and requests through fog environment.

**Figure 2.** C2F2C based Framework, Components and Communication Process.

The proposed framework is comprised of three layers: consumers' layer, fog layer and the cloud layer. Cloud and fog layers are used for orchestrating and controlling the cloud and fog resources in consideration of the consumers' requests. Consumers utilize cloud and fog facilities for fulfilling their daily load requirements. Both cloud and fog layers show the cloud and fog admin and developers for maintaining their internal resources as shown in Figure 2. They maintain their services effectively according to the consumers' demands. Data is transferred to the cloud when fog's resources are completely utilized because the fog has limited resources. Fog only communicates to the cloud when all of its resources are utilized and there is an excess demand from the consumers of any region. When requests are sent to the cloud, it does not resolve any of the users' cost and latency issues; however, for resolving the limited resources unavailability, cloud is utilized. Storage resources are not considered in this work. The third layer depicts the set of buildings, number of homes and their load demands in each region.

The communication medium is used as the wi-fi for maintaining the communication among all C2C2F layers and their respective components. When any home in the buildings sends requests, it is first received at the fog server, then the availability of resource is checked. After verifying the availability of the requested resource, it is processed through VMs and is also conveyed to the consumers. Hypervisor is used to monitor the task execution states of VMs at the cloud end as shown in Figure 3. Each fog is responsible for its own region's services. The region may be any continent which lies in the communication range of that fog. The following kinds of the communications are used in this scenario: fog to cloud, consumer to fog, appliance to appliance and vise versa. Sensors Nodes (SNs) are used in each layer for sensing and sharing the information among components.

**Figure 3.** Resource Management in Buildings, Cloud and Fog's DC.

There are three types of consumers who are considered in this framework: traditional consumers, consumers with the Home Energy Management System (HEMS) and the consumers who are integrated with the local generation and HEMS. Traditional consumers do not have HEMS or any local generation whereas the consumers that have HEMS and the on-demand cloud services are referred to as smart consumers. In addition, the consumers having both HEMS and the local generation are considered as prosumers and the smart users in the buildings. Traditional consumers do not participate in the energy management programs.

Figure 3 shows the resource management in the cloud and fog DCs where VMs are used as the resource manager and hypervisor is allocated to monitor the VMs according to their existing status. DCs are considered variable in this work. The required hardware resources for each DC are based on fog specification which are elaborated in Table 1. Two scenarios are used for the resource optimization using this framework. Each scenario is further comprised of two scenarios. One scenario considers the 25 VMs for resource allocation with single DC whereas the second scenario considers the 50 VMs with two DCs for the optimization of the resources in the residential buildings. The extended scenarios are elaborated in the subsequent subsections.


**Table 1.** Input Parameters for both scenarios.
