iFogsim Entities

What is an Entity? and what is it’s Role?

Entities are the building blocks for the Cloudsim as well as iFogsim simulation toolkit.

The iFogsim simulation toolkit is basically used for simulating the scenarios based on Fog computing, where the workload is supposed to be submitted to the nearest available computing resource, if not possible only then it will be moved to connected cloud for the further processing.

Now to simulate the behavior of the real world Fog computing, iFogsim simulation toolkit, provides a set of API’s which contains a set of classes representing the components available in the real world Fog setup. All these set of classes are known as the Entities, because they actively take part in the simulation process by initiating the process events and passing the messages to share their work with other entities or status of work under processing.

As the iFogsim uses the simulation engine from cloudsim all these entity classes are ultimately derived from the simentity.java class and implements the processEvent() or processOtherEvent() method to support the actions required during the simulation process.

Entities in iFogsim simulation toolkit

There are eight entities available in iFogsim:

  1. FogDevice: This class simulates the computing resource, responsible for the actual computation of the tasks/jobs submitted to the network. The jobs are being shared through the Tuples class instance contains the signature for its sensor & corresponding actuator.
  2. FogBorker: This class simulates the broker/agent node, primarily responsible for the load(job/task) distribution of the computing devices available on the network.
  3. Sensor: This class is the end node and is going to simulate the working of some sort of Hardware, like a camera, temperature measuring device, etc. This is the source from where the tuples are generated representing the job/task and propagate them to the network for their computation
  4. Actuator: This class is again simulating the end node which is again representing some sort of hardware device which will be activated based on the processing of the tuple produced by the sensor class. This can be a storage device, motor, furnace, etc.
  5. EndDevice: This class models the device other than the sensor or actuator and is generally used for the purpose of additional network device simulations.
  6. Switch: This class represents a model of a real-life switch, whose primary role is to propagate the data among the network nodes. Here, in iFogsim, it propagates the tuples across the topology
  7. Link: This class is one of the most important classes as this defines the model of communication medium and defines the connections between the Sensor, FogDevice, FogBroker, Actuator, etc.
  8. Controller: This class is responsible for the simulation of allocation of application modules which are basically simulating over the fog devices and are in-turn processing the tuples through modules. Primarily controller class is going to do the scheduling of AppModules to the network nodes and manage their working.

Entity Class Hierarchy

Here in the above diagram, you can clearly see that SimEntity is the parent class for all the entities. Also in the case of FogBroker, the hierarchy proceeds through the PowerDatacenterBroker followed by DatacenterBroker as well as FogDevice, hierarchy proceeds through PowerDatacenter followed by Datacenter class. So the FogBroker and FogDevice inherits the majority of their features from the basic cloudsim simulation toolkit classes and then extends more features to support the iFogsim based Fog simulation scenarios.

Why SimEntity is inherited?

SimEntity is a class from the basic Cloudsim simulation toolkit and it has an abstract implementation of Cloneable class. This class includes the implementation of core methods used for scheduling events through an entity which are overloaded as schedule() method, startEntity(), shutdowEntity() & processEvent() methods define the default behaviors for the individual entities through overriding in the child classes, the run() method is used to process the events by the entities during the simulation runtime. So using this class as the parent reduces the redundancy of the code required by each individual entity and allows the developers to put up abstraction for the underlying simulation engine.

How does individual entity process events?

Every individual Entity is responsible for its execution of a particular event, whenever its call is made by the other entity through the simulation engine. These events processing are initiated through the inherited run() method from SimEntity class, which ultimately sends a call to the processEvent() method with event instance as a parameter, which inturn sends a call to processOtherEvents() method. These events are unique and defined inside the FogEvents.java class. Now based on the FogEvent the further method/procedure is called to process the desired action corresponding to the specified event. For example: The FogDevice() is supposed to process an event “FogDevice.TUPLE_ARRIVAL” then in this case the method processTupleArrival(ev) will be called for further processing.

Code Snippet of procesOtherEvent() method of FogDevice.java

Therefore, all the FogEvents are associated with procedures and the simulation engine periodically sends the call to individual entities with event details and the further simulation proceedings are done through the entities itself. Once the processing is over the result is sent back to the simulation engine based on which there may be further scheduling of new events to other entities.

Here, we have a video explaining all the details about the entities, this video will help you have a better understanding on how these entities are processing the individual FogEvents.

In case you are interested to learn more about iFogsim simulation scenario implementations. Feel free to have a look at a Unique course prepared to accelerate the learning for the researchers at https://www.superwitsacademy.online/essential-ifogsim-tutorials

iFogsim Project Structure: A Beginners Guide

ifogsim Topology File

The Internet of things(IoT) provides a broad range of services for the end-users with the use of efficient endpoints for application delivery. IoT is still in a very early stage as the large scale infrastructure is yet to be developed. There has been a lot of new research topics that are emerging based especially in scheduling, power, and network load distribution. Testing such use cases is difficult in the absence of a suitable infrastructure. Therefore iFogSim simulator possesses a huge potential to simulate the research-based use case and then corresponding to the promising results can be deployed to the existing system with minimum cost and efforts involved. This article will serve as a guide to understanding the iFogSim project structure API.

iFogSim is a java programming language based API that inherits the established API of Cloudsim to manage its underlying discrete event-based simulation. It also utilizes the API of CloudsimSDN for relevant network-related workload handling. Before we implement any use-case in iFogsim, it is very important that we should be first able to understand its project structure.

This article will enable you to choose the correct namespace for the implementation of our use case as well as any modifications to existing code to effectively simulate the use case. 

Let’s get started…

The iFogSim project contains 7 folders and 1 text file. Following is the default view of the iFogsim project:

iFogSim Project Structure
iFogSim Project Structure

Here the description provided in the sequence as they appear in iFogsim Project Structure,

JRE System Library: This folder contains the default libraries required for the execution of the iFogsim simulation.

iFogSim default imports - iFogSim Project Structure
iFogSim default imports

Src: This folder contains the complete set of Java code files that are arranged in the form of namespaces. Among this, the first 11 packages are being included from the core cloudsim API.  You can read in detail about these set of namespaces from the article “Beginners Guide to Cloudsim Project Structure

Cloudsim API namespaces included in iFogsim project structure
Cloudsim API namespaces included in iFogsim

Then, the next 10 packages are being included from the CloudsimSDN API 

CloudsimSDN API namespaces included in iFogsim project structure
CloudsimSDN API namespaces included in iFogsim

Then brings in the actual packages for the iFogSim model API, there are 13 packages and a topologies package containing the layout for a router. This set of API namespaces is going to contain the actual implementation of the related fog computing-based models and policy implementations.

iFogsim API namespaces - iFogSim Project Structure
iFogsim API namespaces

Referenced Libraries: The folder contains the set of additional JAR libraries that are required for the execution of the iFogsim simulation. This includes the Cloudsim source as well as examples jar. Apaches common math library, JSON processing, etc.

Additional reference JAR libraries included in iFogsim project structure
Additional reference JAR libraries included in iFogsim

Jars: The folder contains the actual JAR files of all the libraries mentioned in point no. 3.

Output folder: In case if you opt to record the put the simulations console output inside a file then it will be stored in this folder.

iFogsim Output log files from the console for a simulation.
iFogsim Output log files from the console for a simulation.

Results folder: The results of the tested simulators are recorded as excel/Openoffice/PDF/Text file and saved in this folder. One interesting thing that the programmer has done is that the charts corresponding to the results were also generated for the quick analysis and this is great if you are doing the simulation to produce some results for the research paper.

iFogsim simulated use-case result files including diagrams
iFogsim simulated use-case result files including diagrams

Topologies: This contains the network layout for any given use-case that is to be simulated using the iFogSim. The format used for saving the layout is JSON based and is utilized by the simulation engine to define the infrastructure for the test simulation.

ifogsim Topology File
ifogsim Topology File

README.md: This file contains the basic introduction regarding the iFogsim project along with the reference link to the Github project page as well as the research references.

Whats else we have for you?

We have been working on a tutorial course titled “Essential iFogsim Tutorials” which right now contains over 2 hours of video content for the beginner level researchers, this course will be a work in progress based on the feedback from its subscribers. We have committed ourselves to update its content until August 2021. I look forward to catching you on the course page.