A module placement scheme for fog-based smart farming applications

ABSTRACT


INTRODUCTION
Agriculture 4.0 refers to managing farms through the integration of modern technologies in order to increase productivity and reduce the amount of time farmers spend on performing repetitive tasks [1].In addition, internet of things (IoT) provides cost-effective and sustainable solutions for agriculture due to its highly scalable, interoperable, pervasive, and open nature.Furthermore, IoT technology is also beneficial for farmers, as it allows them to access key information about their farms, such as soil quality, nutrient requirements for healthy plant growth, and water consumption levels.By providing precise data on these parameters, farmers can optimize their farming practices to achieve better yields and reduce waste.
Friha et al. [2] provide a comprehensive review of emerging technologies for IoT-based smart agriculture.Rayhana et al. [3] conducted a study that evaluates both the current technologies used in greenhouse cultivation and the latest advancements in IoT technologies that enable smart greenhouse farming.Beng et al. [4] introduced a wireless sensor network (WSN) system for monitoring the health of livestock.The system utilizes near field communication (NFC) technology to measure essential parameters, including temperature.Table 1 presents several initiatives that harness the power of cloud computing to create solutions for smart agriculture.Through virtualization, the cloud provides a variety of services and options for smart farming applications, including infrastructure-as-a-service (IaaS), platform-as-a-service (PaaS), and software-as-a-service (SaaS) [5].Furthermore, the cloud can be used to aggregate data from IoT sensors such as soil sensors, satellite images, and weather stations to help farmers make better decisions about managing their crops.The cloud also provides enough storage and computing power to analyse the collected data and package it in a form useful to farmers as well as send instructions to some control IoT-based devices such as irrigation systems.However, due to the increasing number of sensors in smart farms and the use of latency-sensitive applications such as agricultural robots (Agribots), drones, and livestock health monitoring systems, transferring all of the collected data to the cloud is not suitable or scalable for these smart farming applications.[24], [25] Generally, the cloud-based smart farming architecture faces several issues, such as high latency, overfull bandwidth, and unavailability of cloud services due to communication failure.Thus, the traditional cloud-based architecture cannot meet the required levels of quality of service (QoS) for real-time smart farming applications.To solve these challenges, a new paradigm called fog computing was proposed.Fog computing is an extension of cloud computing to the edge network, providing computer, storage, and networking services to IoT devices instead of sending data to the cloud for processing.However, due to the resource limitations of fog nodes, designing a module placement scheme is necessary to make full use of fog nodes and meet the real-time requirement of latency-sensitive smart farming applications.
Basically, each IoT application can be divided into several modules that are responsible for performing one specific task on collected data [26].For example, the application model of the IoT-based greenhouse monitoring system consists of many application modules as shown in Figure 1, depending on the number of sensors used in the application and the available resources.Each module has a specific resource requirement (central processing unit (CPU), random access memory (RAM), and bandwidth, in contrast, fog nodes may not have sufficient resources to handle the demands of these modules and the massive data issued from agricultural sensors.Thus, it is important to adopt a module placement algorithm that determines the suitable fog nodes to host smart farming application modules.Thus, avoid situations where some fog nodes are overloaded and others remain under-loaded, which may lead to a decrease in the QoS in terms of latency and network usage.In this paper, we propose a module placement algorithm for fog-based smart farming applications.The main contributions of this paper are as follows: a. Design fog-based architecture for smart farming applications.In the proposed architecture, special nodes called fog controller nodes are integrated in order to manage the resources in the fog layer.b.Introducing an algorithm for placing smart farming application modules on fog devices based on the proposed fog-based architecture.c.The proposed scheme was evaluated using an IoT-based greenhouse monitoring system.The simulation was performed based on a real implementation, which utilized various sensors and actuators, as well as the iFogSim simulator.The rest of this paper is organized as follows.Section 2 presents a summary of related studies.In section 3, we introduce the proposed system architecture.Section 4 presents the proposed module placement algorithm.Section 5 illustrates the implementation and evaluation of simulation results.Finally, a conclusion will be drawn in section 6.

RELATED WORKS
Several studies focus on the role of fog computing in IoT-based smart farming applications.Taneja et al. [27] introduce an innovative system based on fog computing architecture for livestock health monitoring and animal behavior analysis, specifically in dairy farming.The collected sensor data is sent to a fog-based platform for further analysis.The proposed solution focuses on providing early warning alerts by utilizing behavioral analytics to ensure the well-being of the animals.This approach enables the farmer to identify potential diseases in the early stages and take necessary actions.Ammad et al. [28] introduces a new fog-based framework that aims to improve energy efficiency in smart environments enabled by the IoT.This framework includes two new layers, namely a sensor-based energy-efficient hardware layer and a policy layer, which are added to the existing fog-based architecture.The purpose of these layers is to track energy consumption and facilitate energy-aware decision-making.Ribeiro et al. [29] presents a novel method for data collection and storage in smart agriculture environments, along with two distinct approaches for data filtering through the implementation of a fog-based architecture.Two experiments were designed, each utilizing a real dataset comprising humidity and temperature values.In both experiments, fog nodes applied the k-nearest neighbors (k-NN) algorithm to filter the data and categorize it based on its value range.The smart agricultural knowledge discovery system presented in [30] employs the IoT and fog computing paradigm.This system offers users access to real-time information and knowledge, which enhances crop yield performance and reduces resource wastage without compromising quality.The performance of the proposed system has been analyzed and the results show that the proposed system performs superior in terms of latency, scalability, cost, and security of data.Izolan et al. [31] present a cost-effective fog computing platform for soil moisture management that uses a density map of soil moisture to analyze moisture levels across areas, enabling efficient irrigation management.Malik et al. [32] propose a fog-based framework that allows users to simulate custom farming scenarios, covering aspects such as sensor placement, line-of-sight deployment, coverage areas, mobile node mobility models, and data gathering through relay or airborne systems.Alharbi and Aldossary [33], an energy-efficient edge-fog-cloud architecture is suggested for IoT-based smart agriculture.The architecture utilizes edge and fog layers located in close proximity to smart farms, allowing for the collection and processing of diverse sensor data at the fog layer.The main goal is to optimize energy efficiency and improve data management in smart agriculture.One of the main limitations of the mentioned fog -based farming systems is the use of the traditional fog-based architecture without taking into account the limited resources of the fog nodes.Furthermore, it is noticeable that the previous papers did not focus on the module's placement issues.The inefficient management of the fog layer resources and the failure to give priority to delay-sensitive application modules lead to hosting these modules in cloud servers, which increases delay and network usage.

PROPOSED SYSTEM ARCHITECTURE
This section presents an overview of a proposed smart farming architecture based on fog computing, comprising of three distinct layers.The first layer is the IoT layer that contains agricultural sensors such as temperature sensors, nitrogen, phosphorus, and potassium (NPK) sensors, and wearable livestock health monitoring systems.The second layer is the fog computing layer, where the fog nodes (FNs) and fog controller nodes (FCNs) are located.The third layer is the central cloud server, which has more resources for storage and processing compared to the fog layer resources.

IoT layer
This layer consists of IoT sensors, agricultural UAVs, and Agribots that are normally equipped with many sensors capable of sensing the environment and collecting data such as soil moisture, temperature, and soil NPK levels.The sensors used are often heterogeneous and geographically distributed across different smart farms.The collected data is sent to the associated fog node on the next level.

Fog layer
This layer consists of a set of fog nodes that receive data from the sensor layer.At the site closest to the agricultural sensors, this layer has more resources than the sensor layer.Furthermore, compared to some traditional fog-based smart farming architectures, this layer contains FCNs for effective resource management.FCNs play the role of load balancers in the proposed architecture.FCNs are aware of the available FN resources in the fog layer.Thus, overloading or under-loading situations in the fog network can be avoided because FCNs check the availability of resources before assigning modules to the FN.
In our proposed smart farming architecture, applications are classified into two categories: real-time (e.g., Agribots, agricultural drones, and livestock monitoring systems) and near real-time (e.g., irrigation systems, soil monitoring systems, and temperature sensors).FCNs prioritize data from delay-sensitive applications using the algorithm proposed in the next section.
In this paper, we consider that each smart farming application consists of multiple modules that constitute the data processing elements.Each module has resource requirements, such as CPU, RAM, and bandwidth.FCNs decide which FN will run the module based on its requirements and the available resources in the fog layer, using the proposed module placement algorithm.By adopting this strategy, the fog layer resources can be utilized effectively, leading to reduced delays and network usage, thereby improving the performance of various fog-based smart farming systems.

Cloud layer
Fog computing complements the cloud, and therefore, dependence on cloud resources still plays an important role.The cloud has powerful computing and storage capabilities that can support fog in extensive computational analysis and permanent storage of data.This makes data available to farmers in the form of graphs and reports.

PROPOSED MODULE PLACEMENT ALGORITHM
Consider a fog-based smart farming network with a set of fog node controllers FCN, a set of fog nodes F, and set of IoT sensors.The notations used in this paper are presented in Table 2.
where  is the i -th fog node available for IoT sensors.Each FN has a limited capacity of resources (CPU, memory and bandwidth).The capacity of the said fog node  in the proposed architecture is represented as (2).
As mentioned earlier, each smart farming application consists of multiple modules that constitute the data processing elements.Thus, a set of smart farming application modules is denoted by (3).
Each module   has to be placed on fog node and is defined by specific requirements such as CPU, memory, bandwidth and deadline.Thus, the requirement of a smart farming application module mi is denoted by Rmi, where, A fog node fi cannot accept module   beyond its capacity, where, Algorithm 1 provides a summary of the proposed module placement scheme for smart farming applications.This algorithm outlines the step-by-step process for determining the optimal placement of modules within a network of fog nodes to improve the efficiency and effectiveness of smart farming systems.By following the algorithm, farmers can ensure that modules are placed in the optimal locations to maximize performance and minimize delays, ultimately leading to better outcomes for their farms.

Algorithm 1. Module placement scheme for fog based smart farming
Input: M (set of application modules), F (set of fog nodes) Output: Rsp (selected fog node) Function modulePlacement (   , F   ): Sort M and F in order of ( 5) and ( 6 The proposed algorithm is designed to iterate through the available FCNs, taking into account the resources available within the fog layer.By looping through the FCNs, the algorithm can determine which nodes have sufficient resources to process incoming data from the sensor layer in a timely and efficient manner.Additionally, it is important to note that the fog layer is constantly receiving data from the sensor layer.This incoming data stream is a crucial component of the smart farming system, as it provides the algorithm with the necessary inputs to make placement decisions.By continuously monitoring this data stream and iterating through the available FCNs, the algorithm can dynamically adjust module placement to ensure that the system operates optimally at all times.As presented in Figure 2, the modules are classified based on (6) into two main categories: i) modules for delay-sensitive applications and ii) modules for delaytolerant applications.
In the case of the agricultural robot, for example, this application is based on the sense-processactuate model.In other words, the robot's motion depends on the duration of data collection and transmission by the various embedded sensors.Thus, processing the captured data in the cloud, because FNs are overloaded in the fog layer, will make the sense-process-actuate model very slow or unavailable due to communication failure.This algorithm helps by performing the processing of data very close to the agricultural robots, as well as distributing the modules effectively among all FNs, thus meeting the levels of QoS required for this kind of smart agriculture application.
When all FNs in the fog layer are overloaded, and the received modules are intended for latency-sensitive applications, the FCNs will select a FN that hosts delay-tolerant modules randomly and assign the new modules to it.The delay-tolerant modules are then transmitted directly to the cloud.The cloud servers are responsible for receiving processing results from the fog layer for storage, performing further analysis, and enabling farmers to access the data.
This approach ensures that latency-sensitive applications are handled appropriately by assigning them to FNs that can process them quickly, while delay-tolerant modules are routed directly to the cloud to reduce latency.By distributing the modules effectively among the FNs, the system can balance the workload and prevent any FN from becoming overloaded.Overall, this strategy helps to maintain the required levels of QoS for smart agriculture applications and ensures that the processing of data is done efficiently and effectively.

PERFORMANCE EVALUATION
In this section, we validate the proposed scheme by implementing it in an IoT-based smart greenhouse application.Furthermore, the algorithm was simulated using iFogSim [34].In this experiment, we designed and implemented an IoT-based greenhouse monitoring system case study using many sensors and actuators that are connected wirelessly to evaluate the proposed algorithm with real data.

Implementation of IoT-based smart greenhouse system
Our scenario involves a greenhouse equipped with harvesting robots and distributed sensors and actuators located throughout the facility.During the daytime, each sensor continuously measures specific environmental conditions, such as temperature, humidity, or soil pH, at its specific location and reports these measurements to the fog nodes.By using harvesting robots to collect data from various locations, we can efficiently monitor and optimize the greenhouse environment to improve crop yield and quality.
As depicted in Figure 3, our implementation of the IoT-based greenhouse application utilized a range of sensors for precise data collection and control.In Figure 3(a), we integrated a rain sensor (YL83) to detect precipitation.Figure 3(b) showcases the implementation of a temperature and humidity sensor (DHT11) for monitoring air temperature and humidity levels.An ultrasonic sensor was integrated in Figure 3(c) to enable obstacle avoidance by the agricultural robot.Figure 3(d) illustrates the integration of a gas sensor (MQ2) for monitoring air quality.Lastly, Figure 3(e) presents the incorporation of a soil moisture sensor that enables precision agriculture practices by providing accurate data on soil moisture content.

Implementation in iFogSim
In this section, we utilized iFogsim simulator to evaluate the proposed module placement scheme algorithm.iFogSim is a toolkit based on CloudSim and is widely used for simulating IoT, edge, fog, and cloud computing environments.The key performance metrics considered for the simulation of the proposed architecture and algorithm are latency and network usage.The analysis of this implementation was done on a DELL computer with Intel Core i5 CPU and 8 GB of memory running Windows 10-64 bit.For the simulation, we set the parameters (such as CPU length, RAM, and Bandwidth) for each node in the fog layer as shown in Table 3.We divided the computing power of the devices into several levels.Level 0 contains the cloud server, as we find in level 1 the proxy that connects the cloud and FCNs, which are located in level 2, level 3 contains fog nodes, and finally level 4 which contains the various sensors and actuators deployed in the smart greenhouses.During the simulation, the size of the topology configuration was gradually increased by adding more connected sensors to preview its impact on latency and network usage.

Latency
Providing real-time processing is critical for latency-sensitive smart farming applications.The main benefit of the proposed algorithm is that it makes the FCNs aware of the resources available in the fog layer before assigning any modules, ensuring they are placed appropriately.Furthermore, the proposed algorithm prioritizes latency-sensitive data.Figure 4 provides a comparison of the latency between the cloud, fog, and proposed schemes.With an increase in the number of connected sensors in the smart greenhouse, it is observed that the latency significantly increases in the cloud compared to the fog and the proposed scheme.In contrast, the delay in the traditional fog-based implementation increases in comparison to our proposed scheme.That is because when the number of sensors in a network in a smart greenhouse increases, only fog nodes dedicated to that network process data before sending it to the cloud.Thus, due to the absence of FCNs that manage resources in the network, the FNs are overloaded and become the bottleneck in the fog network.Thus, the delay increases compared to our suggestion which may have a negative impact on latency-sensitive smart farming applications.

Network usage
IoT sensors deployed within greenhouses transmit real-time task execution requests to a designated fog device.Subsequently, the assigned fog nodes diligently process and analyze the data streams received from the smart farming sensors, taking into consideration their sensitivity to latency as well as the availability of system resources.This comprehensive approach ensures efficient and timely decision-making while optimizing the utilization of resources, ultimately enhancing the overall performance and productivity of the greenhouse system.
The simulation results presented in Figure 5 demonstrate that the proposed approach has a favorable impact on network usage compared to cloud and fog.Additionally, network usage increases as the number of connected sensors increases.The FCNs, which manage the load distribution in the fog layer based on the proposed algorithm, allow FNs to process the data from the associated sensors, resulting in decreased network usage in our proposal.Moreover, data is only sent to the cloud when nodes are overloaded or when the data is tolerant of delay.By optimizing the resources in the fog layer, the proposed approach meets the requirements of latency-sensitive applications in IoT-based intelligent farming with regards to latency and network usage.

CONCLUSION
Fog computing, as an extension of cloud computing to the edge of the network, offers numerous benefits for IoT-based smart farming applications.In this paper, we presented a module placement scheme for fog-based smart farming applications, which significantly reduces delays and network usage in the proposed fog-based architecture, as demonstrated by our simulation results.In future work, we intend to develop the proposed algorithm taking into account the mobility of IoT-based agricultural robots in the smart farming network.

Figure 1 .
Figure 1.Application model for IoT-based greenhouse monitoring system

Figure 5 .
Figure 5.Comparison of network usage

Table 1 .
Example of IoT based smart farming systems

Table 2 .
sensitive applications, the total time   required for transmission and processing of a module   should be less than the deadline   of this module, where, Notations and description of terms ≤   ; ∀ ∈  and ∀ ∈  A module placement scheme for fog-based smart farming applications (Baghrous Mohamed) 7093 For delay-

Table 3 .
Configuration details of the proposed architecture