CloudSim focuses primarily on the simulation of Infrastructure as a Service (IaaS) model.
CoreAttributes
VirtualEntity
HostEntity
GuestEntity
...
A cloudlet is a task or job submitted to the cloud infrastructure.
Cloudlets represent the user workloads and the simulation tests how these tasks are scheduled and executed by the VMs.
Workflow scheduling
public class Cloudlet {
public enum CloudletStatus {
/** The Cloudlet has been created and added to the CloudletList object. */
CREATED,
/** The Cloudlet has been assigned to a CloudResource object to be executed as planned. */
READY,
/** The Cloudlet has moved to a Cloud node. */
QUEUED,
/** The Cloudlet is in execution in a Cloud node. */
INEXEC,
/** The Cloudlet has been executed successfully. */
SUCCESS,
/** The Cloudlet has failed. */
FAILED,
/** The Cloudlet has been canceled. */
CANCELED,
/** The Cloudlet has been paused. It can be resumed by changing the status into RESUMED. */
PAUSED,
/** The Cloudlet has been resumed from PAUSED state. */
RESUMED,
/** The cloudlet has failed due to a resource failure.*/
FAILED_RESOURCE_UNAVAILABLE;
public static final CloudletStatus[] values = values();
// @NOTE: Convert an int to enum with CloudletStatus.values[i] (mind the array bounds)
}
/**
* The execution status of this Cloudlet.
*/
private CloudletStatus status;
/**
* The cloudlet ID.
*/
private final int cloudletId;
/**
* The User or Broker ID. It is advisable that broker set this ID with its
* own ID, so that CloudResource returns to it after the execution.
*/
private int userId;
/** The Cloudlet UID */
private String uid;
/**
* The execution length of this Cloudlet (Unit: in Million Instructions
* (MI)). According to this length and the power of the processor (in
* Million Instruction Per Second - MIPS) where the cloudlet will be run,
* the cloudlet will take a given time to finish processing. For instance,
* for a cloudlet of 10000 MI running on a processor of 2000 MIPS, the
* cloudlet will spend 5 seconds using the processor in order to be
* completed (that may be uninterrupted or not, depending on the scheduling
* policy).
*
* @see #setNumberOfPes(int)
*/
private long cloudletLength;
/**
* The input file size of this Cloudlet before execution (unit: in byte).
* This size has to be considered the program + input data sizes.
*/
private final long cloudletFileSize;
/**
* The output file size of this Cloudlet after execution (unit: in byte).
* <p>
* //TODO See
* <a href="https://groups.google.com/forum/#!topic/cloudsim/MyZ7OnrXuuI">this
* discussion</a>
*/
private final long cloudletOutputSize;
/**
* The number of Processing Elements (Pe) required to execute this cloudlet
* (job).
*
* @see #setNumberOfPes(int)
*/
private int numberOfPes;
/**
* The execution start time of this Cloudlet. With new functionalities, such
* as CANCEL, PAUSED and RESUMED, this attribute only stores the latest
* execution time. Previous execution time are ignored.
*/
private double execStartTime;
/**
* The time where this Cloudlet completes.
*/
private double execFinishTime;
/** The total time to complete this Cloudlet. */
private double totalCompletionTime;
/**
* The ID of a reservation made for this cloudlet.
* <p>
* //TODO This attribute doesn't appear to be used
*/
private int reservationId = -1;
/**
* Indicates if transaction history records for this Cloudlet is to be
* outputted.
*/
private final boolean record;
/**
* Stores the operating system line separator.
*/
private String newline;
/**
* The cloudlet transaction history.
*/
private StringBuffer history;
/**
* The list of every resource where the cloudlet has been executed. In case
* it starts and finishes executing in a single cloud resource, without
* being migrated, this list will have only one item.
*/
private final List<Resource> resList;
/**
* The index of the last resource where the cloudlet was executed. If the
* cloudlet is migrated during its execution, this index is updated. The
* value -1 indicates the cloudlet has not been executed
* yet.
*/
private int index;
/**
* The classType or priority of this Cloudlet for scheduling on a resource.
*/
private int classType;
/**
* The Type of Service (ToS) of IPv4 for sending Cloudlet over the network.
*/
private int netToS;
/**
* The format of decimal numbers.
*/
private DecimalFormat num;
/**
* The id of the guest entity that is planned to execute the cloudlet.
*/
protected int guestId;
/**
* The id of the container is planned to execute the cloudlet.
* It may be -1, if containers are not in use
*/
// TODO: Remo Andreoli: to be deprecated in favor of guestId
protected int containerId = -1;
/**
* The cost of each byte of bandwidth (bw) consumed.
*/
protected double costPerBw;
/**
* The total bandwidth (bw) cost for transferring the cloudlet by the
* network, according to the {@link #cloudletFileSize}.
*/
protected double accumulatedBwCost;
// Utilization
/**
* The utilization model that defines how the cloudlet will use the VM's
* CPU.
*/
private UtilizationModel utilizationModelCpu;
/**
* The utilization model that defines how the cloudlet will use the VM's
* RAM.
*/
private UtilizationModel utilizationModelRam;
/**
* The utilization model that defines how the cloudlet will use the VM's
* bandwidth (bw).
*/
private UtilizationModel utilizationModelBw;
// Data cloudlet
/**
* The required files to be used by the cloudlet (if any). The time to
* transfer these files by the network is considered when placing the
* cloudlet inside a given VM
*/
private List<String> requiredFiles = null;
Data Centers are the core of cloud infrastructure. In CloudSim, a data center represents the physical machines (hosts) that provide computing resources such as CPU, memory, storage, and bandwidth.
public class Datacenter extends SimEntity {
/** The characteristics. */
private DatacenterCharacteristics characteristics;
/** The regional Cloud Information Service (CIS) name.
* @see org.cloudbus.cloudsim.core.CloudInformationService
*/
private String regionalCisName;
/** The vm provisioner. */
private VmAllocationPolicy vmAllocationPolicy;
/** The last time some cloudlet was processed in the datacenter. */
private double lastProcessTime;
/** The storage list. */
private List<Storage> storageList;
/** The vm list. */
private List<? extends GuestEntity> vmList;
/** The scheduling delay to process each datacenter received event. */
private double schedulingInterval;
}
A Host is a Physical Machine (PM) inside a Datacenter.
A host has a defined policy for provisioning memory and bw, as well as an allocation policy for Pe's to virtual machines.
HddHost
public class Host implements HostEntity {
/** The id of the host. */
private int id;
/** The storage capacity. */
private long storage;
/** The ram provisioner. */
private RamProvisioner ramProvisioner;
/** The bw provisioner. */
private BwProvisioner bwProvisioner;
/** The allocation policy for scheduling VM execution. */
private VmScheduler vmScheduler;
/** The list of VMs assigned to the host. */
private final List<? extends GuestEntity> guestList = new ArrayList<>();
/** The Processing Elements (PEs) of the host, that
* represent the CPU cores of it, and thus, its processing capacity. */
private List<? extends Pe> peList;
/** Tells whether this host is working properly or has failed. */
private boolean failed;
/** The VMs migrating in. */
private final List<? extends GuestEntity> guestsMigratingIn = new ArrayList<>();
/** The datacenter where the host is placed. */
private Datacenter datacenter;
}
VMs are the computing instances in CloudSim.
You can specify the number of VMs to create and allocate resources such as CPU, RAM, and bandwidth to each one. VMs execute tasks (cloudlets) submitted by users and can be migrated between hosts when necessary.
HddVm
public class Vm implements VirtualEntity {
/** The VM unique id. */
private final int id;
/** The user id. */
private int userId;
/** A Unique Identifier (UID) for the VM, that is compounded by the user id and VM id. */
private String uid;
/** The size the VM image size (the amount of storage it will use, at least initially). */
private long size;
/** The MIPS capacity of each VM's PE. */
private double mips;
/** The number of PEs required by the VM. */
private int numberOfPes;
/** The required ram. */
private int ram;
/** The required bw. */
private long bw;
/** The Virtual Machine Monitor (VMM) that manages the VM. */
private String vmm;
/** The Cloudlet scheduler the VM uses to schedule cloudlets execution. */
private CloudletScheduler cloudletScheduler;
/** The Guest scheduler the Vm uses to schedule nested guest entities, such as containers. */
private VmScheduler guestScheduler;
/** The PM that hosts the VM. */
private HostEntity host;
/** Indicates if the VM is in migration process. */
private boolean inMigration;
/** Indicates if the VM is in Pause State (e.g. Stop & copy phase) */
private boolean inPause;
/** Indicates if the VM is waiting for nested guest entities to come. */
private boolean inWaiting;
/** The current allocated storage size. */
private long currentAllocatedSize;
/** The current allocated ram. */
private int currentAllocatedRam;
/** The current allocated bw. */
private long currentAllocatedBw;
/** The current allocated mips for each VM's PE.
* TODO: Maybe replace with a call to getCloudletScheduler().getCurrentMipsShare()
*/
private List<Double> currentAllocatedMips;
/** Indicates if the VM is being instantiated. */
private boolean beingInstantiated;
/** The ram provisioner for (nested) guest entities. */
private RamProvisioner guestRamProvisioner;
/** The bw provisioner for (nested) guest entities. */
private BwProvisioner guestBwProvisioner;
/** The pe list for nested guest entities. */
private List<? extends Pe> peList;
/** The nested guest list. */
private final List<? extends GuestEntity> guestList = new ArrayList<>();
/** The nested guests migrating in. */
private final List<? extends GuestEntity> guestsMigratingIn = new ArrayList<>();
/** Tells whether this VM is working properly (as a host for nested guests) or has failed. */
private boolean failed;
/** The mips allocation history.
* TODO Instead of using a list, this attribute would be
* a map, where the key can be the history time
* and the value the history itself.
* By this way, if one wants to get the history for a given
* time, he/she doesn't have to iterate over the entire list
* to find the desired entry.
*/
private final List<VmStateHistoryEntry> stateHistory = new ArrayList<>();
CloudSim allows you to define different scheduling policies for tasks (cloudlets) and allocation policies for VMs.
These policies determine how resources are distributed across hosts and VMs and how tasks are scheduled for execution.
The broker manages the distribution of tasks (cloudlets) to the VMs. It’s responsible for scheduling, resource allocation, and VM migration if necessary.
CoreAttributes
VirtualEntity
HostEntity
GuestEntity
...