Guide to simulation workflow

Any Example provided in the ‘org.cloudbus.cloudsim.example’ Package under the example folder of the CloudSim project follows some standard steps to implement the specified configuration to start a simulation. To understand the working of the CloudSim simulation framework, knowledge about these steps is a must. This article will help you to get an understanding of simulation workflow.

Before you start, It is essential that the cloudsim should already installed/setup on your local computer machine. In case you are yet to install it, you may follow the process of Cloudsim setup using Eclipse IDE

The main() method is the pointer from where the execution of this example starts

public static void main(String[] args)

There are eleven steps that are followed in each example with some variation in them, specified as follows:

  • Set the Number of users for the current simulation. This user count is directly proportional to a number of brokers in the current simulation.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; 
  • Initialize the simulation, provided with the current time, number of users and trace flag.
CloudSim.init(num_user, calendar, trace_flag);
  • Create a Datacenter.
Datacenter datacenter0 = createDatacenter("Datacenter_0");

where the createDatacenter() method itself initializes the various datacenter characteristics along with the host list. This is the most important entity without this there is no way the simulation of hosting the virtual machine is applicable.

private static Datacenter createDatacenter(String name) 
	List<Host> hostList = new ArrayList<Host>();
	List<Pe> peList = new ArrayList<Pe>();
	int mips = 1000;
	peList.add(new Pe(0, new PeProvisionerSimple(mips))); 
	int hostId = 0;
	int ram = 2048; // host memory (MB)
	long storage = 1000000; // host storage
	int bw = 10000;
		new Host(
			new RamProvisionerSimple(ram),
			new BwProvisionerSimple(bw),
			new VmSchedulerTimeShared(peList)
	String arch = "x86"; 
	String os = "Linux"; 
	String vmm = "Xen";
	double time_zone = 10.0; 
	double cost = 3.0; 
	double costPerMem = 0.05; 
	double costPerStorage = 0.001; 	
        double costPerBw = 0.0; 
	LinkedList<Storage> storageList = new LinkedList<Storage>();
	DatacenterCharacteristics characteristics = new 
                    DatacenterCharacteristics(arch, os, vmm, hostList, 
                                              time_zone, cost, costPerMem,
                 				costPerStorage, costPerBw);
	Datacenter datacenter = null;
	try {
		datacenter = new Datacenter(name, characteristics, new 
                                  storageList, 0);
	} catch (Exception e) {
	return datacenter;
  • Create a Datacenter broker.
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();

Where the createBroker() method initializes the entity object from DatacenterBroker class

private static DatacenterBroker createBroker() 
	DatacenterBroker broker = null;
	try {
		broker = new DatacenterBroker("Broker");
	} catch (Exception e) {
		return null;
	return broker;
  • Create a Virtual Machine(s).
vmlist = new ArrayList<Vm>();
int vmid = 0;
int mips = 1000;
long size = 10000;
int ram = 512;
long bw = 1000;
int pesNumber = 1;
String vmm = "Xen";

Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new 

  • Submit Virtual Machine to Datacenter broker.
  • Create Cloudlet(s) by specifying their characteristics.
cloudletList = new ArrayList<Cloudlet>();

int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();

Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, 
                     outputSize, utilizationModel, utilizationModel, 


  • Submit Cloudlets to Datacenter broker.
  • Send call to Start Simulation.
  • Once no more event to execute, send the call to Stop Simulation.
  • Finally, print the final status of the Simulation.
List<Cloudlet> newList = broker.getCloudletReceivedList();

Where printCloudletList() method formats the output to correctly display it on the console.

private static void printCloudletList(List<Cloudlet> list) 
	int size = list.size();
	Cloudlet cloudlet;
	String indent = "    ";
	Log.printLine("========== OUTPUT ==========");
	Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
				+ "Data center ID" + indent + "VM ID" + 
                                   indent + "Time" + indent
				+ "Start Time" + indent + "Finish Time");

	DecimalFormat dft = new DecimalFormat("###.##");
	for (int i = 0; i < size; i++) 
        	cloudlet = list.get(i);
		Log.print(indent + cloudlet.getCloudletId() + indent + 
		if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) 
			Log.printLine(indent + indent + 
				     + indent + indent + indent + 
				     + indent + indent + 
                                     + indent + indent + 
				     + indent + indent + 

Once you Run the example the output for will be displayed like: console output console output

Also, the following video tutorial contains a detailed about and helps you to understand simulation workflow

Learn More

You may subscribe to an online self-paced course named Learn Basics of Cloudsim, The content for this course which will be updated weekly till August 2021. 

Reference link to study material:


Beginners Guide to Cloudsim Project Structure

The Cloudsim Simulation Toolkit is an API that is written using the Java programming language and its classes are structured in a very specific way. This article will serve as a guide to the Cloudsim project structure and will help you understand how the Cloudsim architecture is divided into different packages and their important classes that facilitate the cloud simulation using Cloudsim.

Let us first explore and understand the structure of this simulation project. I assume that you have already set up the cloudsim using Ecplise if not you may follow my previous article on “Cloudsim Setup using Eclipse“.

Let proceed further and your eclipse project explorer should contain 6 folders and 7 files.

Eclipse Project Explorer representing Cloudsim project structure
CloudSim Project Structure

The readme.txt file contains the necessary information about this project, like how to install and run the cloudsim, what is the basic directory structure, if you are not using any IDE then how to build the project source code.

Cloudsim Readme.txt file content
Readme.txt file

Now, let us look at the directory structure in detail and understand the various namespaces available in the “Source” folder

Source Folder namespace/packages
Cloudsim Source folder namespace/package view

There exist 12 namespaces; each namespace has a set of classes with specific correlated functions as discussed below:

  • Org.cloudbus.cloudsim: It contains the model classes of various basic hardware components, their groups, and the allocation/utilization methods, etc. Here, the model means that the classes contain the implementation of the various attributes and behaviors of the real-life cloud computing hardware component as a collection of Java methods. Once these classes initiate during the simulation, they are going to simulate the behavior of the real-life cloud-based system component.
List of org.cloudbus.cloudsim classes
  • Org.cloudbus.cloudsim.core: This namespace contains the implementation of the simulation engine where the class is the main class and is responsible for the start and stop of the simulation process. Similarly, the class is for maintaining the state of the simulated cloud components.,, and are responsible for maintaining the inter-entity(cloud component) related event call during the simulation process.
Class list of org.cloudbus.cloudsim.core
  • Org.cloudbus.cloudsim.core.predicates: contains the classes related to the selection of events from the to be processed during the simulation event processing.
Class List of Org.cloudbus.cloudsim.core.predicates
  • Org.cloudbus.cloudsim.distribution: It contains the implementation of the various distribution function but is not used anywhere in the cloudsim. These classes might be for future purposes.
Class list of Org.cloudbus.cloudsim.distribution
  • Org.cloudbus.cloudsim.lists: It contains the implementation of lists to be used globally during the simulation process. These are the specialized set of classes, where sorting and comparison operation implemented. There exist the list class for the host, processing element, cloudlet, virtual machine, and resources.
Class list of Org.cloudbus.cloudsim.lists
  • it contains the implementation for the network related simulations purpose, and if you are working on a research work based on network optimization techniques then this is the best set of classes to extend for simulation.
Class list of Org.cloudbus.cloudsim.Network
  • This namespace contains the extended implementation of the basic cloud hardware components which can support the simulation of federated cloud functions distributed across the regions.
Class list of Org.cloudbus.cloudsim.Network.datacenter
  • Org.cloudbus.cloudsim.power: This package contains the extended implementation of cloud components, which can simulate the green or power-aware computing scenarios. This namespace implements the VM migration related classes where extensive algorithm codes for virtual machine selection and allocation related to migrations are available.
Class list of Org.cloudbus.cloudsim.power
  • Org.cloudbus.cloudsim.power.lists: This namespace contains only the implementation of, which is an extended version of the class of org.cloudbus.cloudsim.list namespace.
Class list of Org.cloudbus.cloudsim.power.lists
  • Org.cloudbus.cloudsim.power.models: It contains the set of classes that specifies the power configurations of servers as model classes. These classes imitate the actual working of the various server machine brands available in the market and help in determining the power consumption by such machines during the simulation process.
Class list of Org.cloudbus.cloudsim.power.models
  • Org.cloudbus.cloudsim.provisioners: This namespace contains the behavior implementation regarding how the specified cloud component provisioned to requesting virtual resources.
Class list of Org.cloudbus.cloudsim.provisioners
  • Org.cloudbus.cloudsim.util: this namespace contains the implementation of essential calculation functions and a general utility set.
Class list of Org.cloudbus.cloudsim.utils

Now let’s look at the “examples” folder. It contains 7 namespaces, and each namespace contains a particular type of scenario implementations.

Class list of Org.cloudbus.cloudsim.examples and relevant namespaces

Examples.txt gives you an overview of various basic example scenarios that are available in this folder. The file contains the instructions for the compile and execution of example classes.

Workload.planetlab: It contains a real dataset containing a set of CPU utilization traces from PlanetLab VMs collected during the 10 random days in March & April of 2011. The PlanetLab dataset is used as a benchmark dataset for the validation of various research scenarios.

Now let’s move to the other folders:

  • JRE system library: It is automatically created during the first build process of the CloudSim by the eclipse.
cloudsim project JRE automated compiled dependencies.
  • Reference Libraries: It contains the various dependency jars again automatically added by the eclipse during the first build process.
cloudsim reference libraries
  • Docs: Contains the minimalist documentation of the cloudsim class API and is automatically generated from the inline comments.
cloudsim documentation
  • Jars: This folder is supplied with the source zip file and contains the pre-compiled build of the cloudsim 3.0.3. It can be used for creating custom project scenarios whenever required. We will work on this in further blog posts.
cloudsim bundled jar provided with source code.
  • Build.xml is an ANT based XML file used during the console based builds.
  • Changelog.txt contains the history of the changes done to cloudsim during various version releases.
  • License.xml contans GNU-GPL notification.
  • Pom.xml is a maven configuration file used during the setup of cloudsim using eclipse.
  • Releasenotes.txt contains the note from the cloudsim development team.

You may also follow the detailed step by step demo to “Cloudsim Tutorial: Introduction to Package Intro (Part 2)

Learn More

You may subscribe to an online self-paced course named Learn Basics of Cloudsim, The content for this course which will be updated weekly till August 2021.