19dce064 CC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

Cloud Computing - CE443 19DCE064

PRACTICAL - 1
AIM: To implement Cloud-based infrastructures and services, it isrequired
to set up the complete system requirements. Researchers &industry-based
developers can focus on specific system designissues that they want to
investigate, without taking more concerned about the low level details so
the Clousim is very much useful forthese activities and it can support
simulation environment toimplement cloud based infrastructure solutions.
Perform Cloud Computing Set up using Cloudsim Tool:
Introduction to CloudSim tool.
Perform Installation steps of CloudSim on NetBeans.

THEORY:
CloudSim is a simulation toolkit that supports the modeling and simulation of the core
functionality of cloud, like job/task queue, processing of events, creation of cloud
entities(datacenter, datacenter brokers, etc), communication between different entities,
implementation of broker policies, etc. This toolkit allows to:

● Test application services in a repeatable and controllable environment.


● Tune the system bottlenecks before deploying apps in an actual cloud.
● Experiment with different workload mix and resource performance scenarios on
simulated infrastructure for developing and testing adaptive application provisioning
techniques
Core features of CloudSim are:

● The Support of modeling and simulation of large scale computing environment as


federated cloud data centers, virtualized server hosts, with customizable policies for
provisioning host resources to virtual machines and energy-aware computational
resources
● It is a self-contained platform for modeling cloud’s service brokers, provisioning, and
allocation policies.
● It supports the simulation of network connections among simulated system elements.
● Support for simulation of federated cloud environment, that inter-networks resources
from both private and public domains.
● Availability of a virtualization engine that aids in the creation and management of
multiple independent and co-hosted virtual services on a data center node.
● Flexibility to switch between space shared and time shared allocation of processing
cores to virtualized services.

INSTALLATION-STEPS FOR NETBEANS:


You need to have a setup file of the NetBeans JAVA into your setup.

DEPSTAR (CE) 1
Cloud Computing - CE443 19DCE064

If you didn’t have the setup you can download from the following link:
https://netbeans.org/images_www/v6/download/community/8.2

You can download any type of setup as per your requirements from the above mention web
page.
Right-click on the setup or you can Double-Click on the setup by using the mouse.
Click on the next option.

Click on the “Install” button.


Wait for the while till the time the setup is properly Installed into the Computer
After complication of the setup you can click on the “Finish” button or you can also register
the Software, for Further Assistance because it is a Free Software.
Now you can start the NetBeans for further use.

DEPSTAR (CE) 2
Cloud Computing - CE443 19DCE064

INSTALLATION-STEPS FOR CLOUDSIM:


Open Netbeans, Go to file–>>new project.

select “Java with Ant” folder then select first option Java Application, Press next
Now give a name to the project as you wish.

DEPSTAR (CE) 3
Cloud Computing - CE443 19DCE064

Go to library, right click on it, a menu will come, click on “Add jars/Folders”

Now browse the cloudsim folder which you have extracted from zip file .and go to that folder
and select “cloudsim-3.0.3.jar”.

That’s how cloudsim can be installed in Netbeans.

CONCLUSION:
In this practical, we learnt about Netbeans and Cloudsim. We installed both the tools in our
system.

DEPSTAR (CE) 4
Cloud Computing - CE443 19DCE064

PRACTICAL - 2
AIM: Cloud Computing aims for Internet based application services
todeliver reliable, secure, fault-tolerant, scalable infrastructure. It is
atremendous challenging task to model and schedule the
differentapplications and services on real cloud infrastructure which
requiresto handle different workload and energy performance
parameters.Consider the real world analogy into cloudsim and Perform:
following Programs:
Understanding of basic CloudSim Examples.
(1) Write a program in cloudsim using NetBeans IDE to create a datacenter
with one host and run four cloudlet on it.
(2) Write a program in cloudsim using NetBeans IDE to create a datacenter
with three hosts and run three cloudlets on it.
(3) Write a program in cloudsim using NetBeans IDE to create a five
datacenters with five hosts and run cloudlets of five users on them.

CODE:
1st:
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;

DEPSTAR (CE) 5
Cloud Computing - CE443 19DCE064

import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

public class Prac2_A {


/**
* @param args the command line arguments
*/
private static List<Cloudlet> cloudletList;
private static List<Vm> vmlist;
public static void main(String[] args)
{
Log.printLine("Starting Cloudsim ...");
try{
int num_user = 1;
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
CloudSim.init(num_user, calendar, trace_flag);
Datacenter datacenter0 = createDatacenter("Datacenter_0");
DatacenterBroker broker = createBroker("Broker");
int brokerId = broker.getId();
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
CloudletSchedulerTimeShared());
vmlist.add(vm);
broker.submitVmList(vmlist);
cloudletList = new ArrayList<Cloudlet>()
int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet0 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet0.setUserId(brokerId);
cloudlet0.setVmId(vmid);
cloudletList.add(cloudlet0);

DEPSTAR (CE) 6
Cloud Computing - CE443 19DCE064

Cloudlet cloudlet1 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);
cloudlet1.setVmId(vmid);
cloudletList.add(cloudlet1);

Cloudlet cloudlet2 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);
cloudlet2.setVmId(vmid);
cloudletList.add(cloudlet2);

Cloudlet cloudlet3 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet3.setUserId(brokerId);
cloudlet3.setVmId(vmid);
cloudletList.add(cloudlet3);

broker.submitCloudletList(cloudletList);
CloudSim.startSimulation();
CloudSim.stopSimulation();

List<Cloudlet> newList = broker.getCloudletReceivedList();


printCloudletList(newList);
Log.printLine("CloudSim example finished!");
}
catch(Exception ex)
{
ex.printStackTrace();
Log.printLine("Unwanted error occured");
}
}
public 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;
long storage = 1000000;
int bw = 10000;
hostList.add(new Host(hostId, new RamProvisionerSimple(ram), new
BwProvisionerSimple(bw), storage, peList, new VmSchedulerTimeShared(peList)));
String arch = "x86";
String os = "Linux";

DEPSTAR (CE) 7
Cloud Computing - CE443 19DCE064

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
VmAllocationPolicySimple(hostList), storageList, 0);
}
catch(Exception ex) {
ex.printStackTrace();
}
return datacenter;
}
private static DatacenterBroker createBroker(String name) {
DatacenterBroker broker = null;
try{
broker = new DatacenterBroker(name); }
catch(Exception ex) {
ex.printStackTrace() }
return broker;
}
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
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 + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");

DEPSTAR (CE) 8
Cloud Computing - CE443 19DCE064

Log.printLine(indent + indent + cloudlet.getResourceId()


+ indent + indent + indent + cloudlet.getVmId()
+ indent + indent
+ dft.format(cloudlet.getActualCPUTime()) +
indent
+ indent +
dft.format(cloudlet.getExecStartTime())
+ indent + indent
+ dft.format(cloudlet.getFinishTime()));
} } } }

OUTPUT 1:

2nd:
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;

DEPSTAR (CE) 9
Cloud Computing - CE443 19DCE064

import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

public class Prac2_B {

/**
* @param args the command line arguments
*/
private static List<Cloudlet> cloudletList;
private static List<Vm> vmlist;
public static void main(String[] args) {
// TODO code application logic here
Log.printLine("Staring CloudSim ...");
try
{
int num_user = 1;
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
CloudSim.init(num_user, calendar, trace_flag);
Datacenter datacenter0 = createDatacenter("Datacenter_0");
DatacenterBroker broker = createBroker("broker1");
int brokerId = broker.getId();
vmlist = new ArrayList<Vm>();
int vmid = 0;
int mips = 250;
long size = 10000;
int ram = 512;
//int ram = 1024;
long bw = 1000;
int pesNumber = 1;
String vmm = "Xen";
//Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());
Vm vm0 = new Vm(vmid++, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());
Vm vm1 = new Vm(vmid++, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());

DEPSTAR (CE) 10
Cloud Computing - CE443 19DCE064

Vm vm2 = new Vm(vmid++, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared());
//vmlist.add(vm);
vmlist.add(vm0);
vmlist.add(vm1);
vmlist.add(vm2);
broker.submitVmList(vmlist);
cloudletList = new ArrayList<Cloudlet>();
int id = 0;
long length = 400000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();

Cloudlet cloudlet0 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet0.setUserId(brokerId);
cloudlet0.setVmId(0);
cloudletList.add(cloudlet0);

Cloudlet cloudlet1 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);
cloudlet1.setVmId(1);
cloudletList.add(cloudlet1);

Cloudlet cloudlet2 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);
cloudlet2.setVmId(2);
cloudletList.add(cloudlet2);

broker.submitCloudletList(cloudletList);
CloudSim.startSimulation();
CloudSim.stopSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
Log.printLine("Cloudsim finished");
}
catch(Exception ex)
{
ex.printStackTrace();
Log.printLine("Unwanted error occured");
}
}

DEPSTAR (CE) 11
Cloud Computing - CE443 19DCE064

public static Datacenter createDatacenter(String name)


{
List<Host> hostList = new ArrayList<Host>();
List<Pe> peList0 = new ArrayList<Pe>();
List<Pe> peList1 = new ArrayList<Pe>();
List<Pe> peList2 = new ArrayList<Pe>();
int mips = 1000;
peList0.add(new Pe(0, new PeProvisionerSimple(mips)));
peList1.add(new Pe(0, new PeProvisionerSimple(mips)));
peList2.add(new Pe(0, new PeProvisionerSimple(mips)));

int hostId = 0;
int ram = 2048;
long storage = 1000000;
int bw = 10000;
hostList.add(new Host(hostId++, new RamProvisionerSimple(ram), new
BwProvisionerSimple(bw), storage, peList0, new VmSchedulerTimeShared(peList0)));
hostList.add(new Host(hostId++, new RamProvisionerSimple(ram), new
BwProvisionerSimple(bw), storage, peList1, new VmSchedulerTimeShared(peList1)));
hostList.add(new Host(hostId++, new RamProvisionerSimple(ram), new
BwProvisionerSimple(bw), storage, peList2, new VmSchedulerTimeShared(peList2)));

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
VmAllocationPolicySimple(hostList), storageList, 0);
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
return datacenter;
}

DEPSTAR (CE) 12
Cloud Computing - CE443 19DCE064

public static DatacenterBroker createBroker(String name)


{
DatacenterBroker broker = null;
try
{
broker = new DatacenterBroker(name);
}
catch(Exception ex)
{
ex.printStackTrace();
return null;
}
return broker;
}
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;

String indent = " ";


Log.printLine();
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 + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");

Log.printLine(indent + indent + cloudlet.getResourceId()


+ indent + indent + indent + cloudlet.getVmId()
+ indent + indent
+ dft.format(cloudlet.getActualCPUTime()) +
indent
+ indent +
dft.format(cloudlet.getExecStartTime())
+ indent + indent
+ dft.format(cloudlet.getFinishTime()));
} } }}

DEPSTAR (CE) 13
Cloud Computing - CE443 19DCE064

OUTPUT 2:

3rd:
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerSpaceShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;

DEPSTAR (CE) 14
Cloud Computing - CE443 19DCE064

import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
public class Prac2_C {
/**
* @param args the command line arguments
*/
/** The cloudlet lists. */
private static List<Cloudlet> cloudletList1;
private static List<Cloudlet> cloudletList2;
private static List<Cloudlet> cloudletList3;
private static List<Cloudlet> cloudletList4;
private static List<Cloudlet> cloudletList5;
/** The vmlists. */
private static List<Vm> vmlist1;
private static List<Vm> vmlist2;
private static List<Vm> vmlist3;
private static List<Vm> vmlist4;
private static List<Vm> vmlist5;
public static void main(String[] args) {
// TODO code application logic here
Log.printLine("Starting CloudSim ...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 5; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in CloudSim. We need at list one of them
to run a CloudSim simulation
@SuppressWarnings("unused")
Datacenter datacenter0 = createDatacenter("Datacenter_0");
@SuppressWarnings("unused")
Datacenter datacenter1 = createDatacenter("Datacenter_1");
@SuppressWarnings("unused")
Datacenter datacenter2 = createDatacenter("Datacenter_2");
@SuppressWarnings("unused")
Datacenter datacenter3 = createDatacenter("Datacenter_3");
@SuppressWarnings("unused")
Datacenter datacenter4 = createDatacenter("Datacenter_4");
//Third step: Create Brokers
DatacenterBroker broker1 = createBroker(1);
int brokerId1 = broker1.getId();

DEPSTAR (CE) 15
Cloud Computing - CE443 19DCE064

DatacenterBroker broker2 = createBroker(2);


int brokerId2 = broker2.getId();
DatacenterBroker broker3 = createBroker(3);
int brokerId3 = broker3.getId();
DatacenterBroker broker4 = createBroker(4);
int brokerId4 = broker4.getId();
DatacenterBroker broker5 = createBroker(5);
int brokerId5 = broker5.getId();
//Fourth step: Create one virtual machine for each broker/user
vmlist1 = new ArrayList<Vm>();
vmlist2 = new ArrayList<Vm>();
vmlist3 = new ArrayList<Vm>();
vmlist4 = new ArrayList<Vm>();
vmlist5 = new ArrayList<Vm>();
//VM description
int vmid = 0;
//int mips = 250;
int mips = 100;
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create two VMs: the first one belongs to user1
Vm vm1 = new Vm(vmid++, brokerId1, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());
//the second VM: this one belongs to user2
Vm vm2 = new Vm(vmid++, brokerId2, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());
//the third VM: this one belongs to user3
Vm vm3 = new Vm(vmid++, brokerId3, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());
//the forth VM: this one belongs to user4
Vm vm4 = new Vm(vmid++, brokerId4, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());
//the fifth VM: this one belongs to user5
Vm vm5 = new Vm(vmid++, brokerId5, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerTimeShared());
//add the VMs to the vmlists
vmlist1.add(vm1);
vmlist2.add(vm2);
vmlist3.add(vm3);
vmlist4.add(vm4);
vmlist5.add(vm5);
//submit vm list to the broker
broker1.submitVmList(vmlist1);

DEPSTAR (CE) 16
Cloud Computing - CE443 19DCE064

broker2.submitVmList(vmlist2);
broker3.submitVmList(vmlist3);
broker4.submitVmList(vmlist4);
broker5.submitVmList(vmlist5);
//Fifth step: Create two Cloudlets
cloudletList1 = new ArrayList<Cloudlet>();
cloudletList2 = new ArrayList<Cloudlet>();
cloudletList3 = new ArrayList<Cloudlet>();
cloudletList4 = new ArrayList<Cloudlet>();
cloudletList5 = new ArrayList<Cloudlet>();
//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();

Cloudlet cloudlet1 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,


utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId1);
Cloudlet cloudlet2 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId2);
Cloudlet cloudlet3 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet3.setUserId(brokerId3);
Cloudlet cloudlet4 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet4.setUserId(brokerId4);
Cloudlet cloudlet5 = new Cloudlet(id++, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationModel, utilizationModel);
cloudlet5.setUserId(brokerId5);
//add the cloudlets to the lists: each cloudlet belongs to one user
cloudletList1.add(cloudlet1);
cloudletList2.add(cloudlet2);
cloudletList3.add(cloudlet3);
cloudletList4.add(cloudlet4);
cloudletList5.add(cloudlet5);
//submit cloudlet list to the brokers
broker1.submitCloudletList(cloudletList1);
broker2.submitCloudletList(cloudletList2);
broker3.submitCloudletList(cloudletList3);
broker4.submitCloudletList(cloudletList4);
broker5.submitCloudletList(cloudletList5);
// Sixth step: Starts the simulation
CloudSim.startSimulation();

DEPSTAR (CE) 17
Cloud Computing - CE443 19DCE064

// Final step: Print results when simulation is over


List<Cloudlet> newList1 = broker1.getCloudletReceivedList();
List<Cloudlet> newList2 = broker2.getCloudletReceivedList();
List<Cloudlet> newList3 = broker3.getCloudletReceivedList();
List<Cloudlet> newList4 = broker4.getCloudletReceivedList();
List<Cloudlet> newList5 = broker5.getCloudletReceivedList();
CloudSim.stopSimulation();
Log.print("=============> User "+brokerId1+" ");
printCloudletList(newList1);
Log.print("=============> User "+brokerId2+" ");
printCloudletList(newList2);
Log.print("=============> User "+brokerId3+" ");
printCloudletList(newList3);
Log.print("=============> User "+brokerId4+" ");
printCloudletList(newList4);
Log.print("=============> User "+brokerId5+" ");
printCloudletList(newList5);
Log.printLine("CloudSimExample finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
}
private static Datacenter createDatacenter(String name){
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store
// our machine
List<Host> hostList = new ArrayList<Host>();
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
List<Pe> peList0 = new ArrayList<Pe>();
List<Pe> peList1 = new ArrayList<Pe>();
List<Pe> peList2 = new ArrayList<Pe>();
List<Pe> peList3 = new ArrayList<Pe>();
List<Pe> peList4 = new ArrayList<Pe>();
int mips=1000;
// 3. Create PEs and add these into a list.
peList0.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe
id and MIPS Rating
peList1.add(new Pe(1, new PeProvisionerSimple(mips))); // need to store Pe id and
MIPS Rating
peList2.add(new Pe(2, new PeProvisionerSimple(mips))); // need to store Pe id and
MIPS Rating
peList3.add(new Pe(3, new PeProvisionerSimple(mips))); // need to store Pe id and
MIPS Rating

DEPSTAR (CE) 18
Cloud Computing - CE443 19DCE064

peList4.add(new Pe(4, new PeProvisionerSimple(mips))); // need to store Pe id and


MIPS Rating
//4. Create Host with its id and list of PEs and add them to the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;
//in this example, the VMAllocatonPolicy in use is SpaceShared. It means that
only one VM
//is allowed to run on each Pe. As each Host has only one Pe, only one VM
can run on each Host.
hostList.add(
new Host(
hostId++,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList0,
new VmSchedulerSpaceShared(peList0)
)
); // This is our first machine
hostList.add(
new Host(
hostId++,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList1,
new VmSchedulerSpaceShared(peList1)
)
); // This is our second machine
hostList.add(
new Host(
hostId++,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList2,
new VmSchedulerSpaceShared(peList2)
)
); // This is our third machine
hostList.add(
new Host(
hostId++,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),

DEPSTAR (CE) 19
Cloud Computing - CE443 19DCE064

storage,
peList3,
new VmSchedulerSpaceShared(peList3)
)
); // This is our forth machine
hostList.add(
new Host(
hostId++,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList4,
new VmSchedulerSpaceShared(peList4)
)
); // This is our fifth machine
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this
resource
double costPerStorage = 0.001; // the cost of using storage in this
resource
double costPerBw = 0.0; // the cost of using bw in this
resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); //we are
not adding SAN devices by now

DatacenterCharacteristics characteristics = new DatacenterCharacteristics(


arch, os, vmm, hostList, time_zone, cost, costPerMem, costPerStorage, costPerBw)
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;}
//We strongly encourage users to develop their own broker policies, to submit vms and
cloudlets according

DEPSTAR (CE) 20
Cloud Computing - CE443 19DCE064

//to the specific rules of the simulated scenario


private static DatacenterBroker createBroker(int id){
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker"+id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/**
* Prints the Cloudlet objects
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;

String indent = " ";


Log.printLine();
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 + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");

Log.printLine( indent + indent + cloudlet.getResourceId() +


indent + indent + indent + cloudlet.getVmId() +
indent + indent +
dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+
indent + indent +
dft.format(cloudlet.getFinishTime()));
}
}
}
}

DEPSTAR (CE) 21
Cloud Computing - CE443 19DCE064

OUTPUT 3:

DEPSTAR (CE) 22
Cloud Computing - CE443 19DCE064

CONCLUSION:
In this practical, we learnt about cloudsim architecture and implemented several different
scenarios using different number of datacenters, hosts and cloudlets.

DEPSTAR (CE) 23
Cloud Computing - CE443 19DCE064

PRACTICAL - 3
AIM:Perform following Programs on network topology using CloudSim:
1. Write a program in cloudsim to create three datacenters with
threehost and a network topology each and run three cloudlets on
them.
2. Write a program in cloudsim to create two datacenters with onehost
each and run cloudlets of two users with network topology on them.
CODE:
1st:
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.NetworkTopology;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* A simple example showing how to create
* a datacenter with one host and a network
* topology and and run one cloudlet on it.
*/
public class NetworkExample1 {

/** The cloudlet list. */


private static List<Cloudlet> cloudletList;

DEPSTAR (CE) 24
Cloud Computing - CE443 19DCE064

/** The vmlist. */


private static List<Vm> vmlist;

/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting NetworkExample1...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in CloudSim. We need at list
one of them to run a CloudSim simulation
Datacenter datacenter0 = createDatacenter("Datacenter_0");
//Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
//Fourth step: Create one virtual machine
vmlist = new ArrayList<Vm>();
//VM description
int vmid = 0;
int mips = 250;
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create VM
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size,
vmm, new CloudletSchedulerTimeShared());
//add the VM to the vmList
vmlist.add(vm1);
//submit vm list to the broker
broker.submitVmList(vmlist);
//Fifth step: Create one Cloudlet
cloudletList = new ArrayList<Cloudlet>();
//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;

DEPSTAR (CE) 25
Cloud Computing - CE443 19DCE064

long outputSize = 300;


UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);
//add the cloudlet to the list
cloudletList.add(cloudlet1);
//submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);
//Sixth step: configure network
//load the network topology file
NetworkTopology.buildNetworkTopology("topology.brite");
//maps CloudSim entities to BRITE entities
//PowerDatacenter will correspond to BRITE node 0
int briteNode=0;
NetworkTopology.mapNode(datacenter0.getId(),briteNode);
//Broker will correspond to BRITE node 3
briteNode=3;
NetworkTopology.mapNode(broker.getId(),briteNode);
// Seventh step: Starts the simulation
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("NetworkExample1 finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an
unexpected error");
}
}
private static Datacenter createDatacenter(String name){
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store
// our machine
List<Host> hostList = new ArrayList<Host>();
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
List<Pe> peList = new ArrayList<Pe>();
int mips = 1000;
// 3. Create PEs and add these into a list.
peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id
and MIPS Rating
//4. Create Host with its id and list of PEs and add them to the list of machines

DEPSTAR (CE) 26
Cloud Computing - CE443 19DCE064

int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
); // This is our machine
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this
resource
double costPerStorage = 0.001; // the cost of using storage in this
resource
double costPerBw = 0.0; // the cost of using bw in this
resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); //we are
not adding SAN devices by now
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
//We strongly encourage users to develop their own broker policies, to submit vms
and cloudlets according

DEPSTAR (CE) 27
Cloud Computing - CE443 19DCE064

//to the specific rules of the simulated scenario


private static DatacenterBroker createBroker(){

DatacenterBroker broker = null;


try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

/**
* Prints the Cloudlet objects
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" +
indent + "Start Time" + indent + "Finish Time");

for (int i = 0; i < size; i++) {


cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);

if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");

DecimalFormat dft = new DecimalFormat("###.##");


Log.printLine( indent + indent + cloudlet.getResourceId() +
indent + indent + indent + cloudlet.getVmId() +
indent + indent +
dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+
indent + indent +
dft.format(cloudlet.getFinishTime()));
}
}

DEPSTAR (CE) 28
Cloud Computing - CE443 19DCE064

}
OUTPUT 1:

2nd:
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.NetworkTopology;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;

DEPSTAR (CE) 29
Cloud Computing - CE443 19DCE064

/**
* A simple example showing how to create
* two datacenters with one host and a
* network topology each and run two cloudlets
* on them.
*/
public class NetworkExample2 {
/** The cloudlet list. */
private static List<Cloudlet> cloudletList;
/** The vmlist. */
private static List<Vm> vmlist;
/**
* Creates main() to run this example
*/
public static void main(String[] args) {
Log.printLine("Starting NetworkExample2...");
try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 1; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag);
// Second step: Create Datacenters
//Datacenters are the resource providers in CloudSim. We need at list
one of them to run a CloudSim simulation
Datacenter datacenter0 = createDatacenter("Datacenter_0");
Datacenter datacenter1 = createDatacenter("Datacenter_1");
//Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
//Fourth step: Create one virtual machine
vmlist = new ArrayList<Vm>();
//VM description
int vmid = 0;
int mips = 250;
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = "Xen"; //VMM name
//create two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size,
vmm, new CloudletSchedulerTimeShared());

DEPSTAR (CE) 30
Cloud Computing - CE443 19DCE064

//the second VM will have twice the priority of VM1 and so will
receive twice CPU time
vmid++;
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size,
vmm, new CloudletSchedulerTimeShared());
//add the VMs to the vmList
vmlist.add(vm1);
vmlist.add(vm2);
//submit vm list to the broker
broker.submitVmList(vmlist);
//Fifth step: Create two Cloudlets
cloudletList = new ArrayList<Cloudlet>();
//Cloudlet properties
int id = 0;
long length = 40000;
long fileSize = 300;
long outputSize = 300;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet1.setUserId(brokerId);
id++;
Cloudlet cloudlet2 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet2.setUserId(brokerId);
//add the cloudlets to the list
cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);
//submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);
//bind the cloudlets to the vms. This way, the broker
// will submit the bound cloudlets only to the specific VM
broker.bindCloudletToVm(cloudlet1.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet2.getCloudletId(),vm2.getId());
//Sixth step: configure network
//load the network topology file
NetworkTopology.buildNetworkTopology("topology.brite");
//maps CloudSim entities to BRITE entities
//Datacenter0 will correspond to BRITE node 0
int briteNode=0;
NetworkTopology.mapNode(datacenter0.getId(),briteNode);
//Datacenter1 will correspond to BRITE node 2
briteNode=2;
NetworkTopology.mapNode(datacenter1.getId(),briteNode);
//Broker will correspond to BRITE node 3

DEPSTAR (CE) 31
Cloud Computing - CE443 19DCE064

briteNode=3;
NetworkTopology.mapNode(broker.getId(),briteNode);
// Sixth step: Starts the simulation
CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
Log.printLine("NetworkExample2 finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an
unexpected error");
}
}
private static Datacenter createDatacenter(String name){
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store
// our machine
List<Host> hostList = new ArrayList<Host>();
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
List<Pe> peList = new ArrayList<Pe>();
int mips = 1000;
// 3. Create PEs and add these into a list
peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to store Pe id
and MIPS Rating
//4. Create Host with its id and list of PEs and add them to the list of machines
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;
//in this example, the VMAllocatonPolicy in use is Time Shared with
priorities. It means that VMs
//receive time shares accroding to their priority.
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
); // This is our machine

DEPSTAR (CE) 32
Cloud Computing - CE443 19DCE064

// 5. Create a DatacenterCharacteristics object that stores the


// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
String arch = "x86"; // system architecture
String os = "Linux"; // operating system
String vmm = "Xen";
double time_zone = 10.0; // time zone this resource located
double cost = 3.0; // the cost of using processing in this resource
double costPerMem = 0.05; // the cost of using memory in this resource
double costPerStorage = 0.001; // the cost of using storage in this resource
double costPerBw = 0.0; // the cost of using bw in this resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); //we are
not adding SAN devices by now
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
// 6. Finally, we need to create a PowerDatacenter object.
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
//We strongly encourage users to develop their own broker policies, to submit vms
and cloudlets according
//to the specific rules of the simulated scenario
private static DatacenterBroker createBroker(){
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/**
* Prints the Cloudlet objects
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = list.size();

DEPSTAR (CE) 33
Cloud Computing - CE443 19DCE064

Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent +
"Data center ID" + indent + "VM ID" + indent + "Time" +
indent + "Start Time" + indent + "Finish Time");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS){
Log.print("SUCCESS");
DecimalFormat dft = new DecimalFormat("###.##");
Log.printLine( indent + indent + cloudlet.getResourceId() +
indent + indent + indent + cloudlet.getVmId() + indent + indent +
dft.format(cloudlet.getActualCPUTime()) + indent + indent +
dft.format(cloudlet.getExecStartTime())+indent + indent +
dft.format(cloudlet.getFinishTime())); } } } }
OUTPUT 2:

CONCLUSION:
In this practical, we learnt about network examples of cloudsim and we run the first two
examples and analysed their code.

DEPSTAR (CE) 34
Cloud Computing - CE443 19DCE064

PRACTICAL 4
AIM:Perform following using Cloud Analyst:
1. Install a Cloud Analyst and Integrate with Netbeans. Monitor the
performance of an Existing Algorithms given in Cloud Analyst.
2. Modify or propose a new load balancing algorithm compatible with
Cloud Analyst.
THEORY:
CloudAnalyst:

● Cloud Analyst is a tool developed at the University of Melbourne whose goal is to


support evaluation of social networks tools according to geographic distribution of
users and data centers.
● In this tool, communities of users and data centers supporting the social networks are
characterized and, based on their location; parameters such as user experience while
using the social network application and load on the data center are obtained/logged.

PRACTICAL:
Download CloudAnalyst from

http://www.cloudbus.org/cloudsim/CloudAnalyst.zip

Extract Files from the Zip file which will give following folder structure.

If you want to Run from Command line then type the following command in cmd.

DEPSTAR (CE) 35
Cloud Computing - CE443 19DCE064

java -cp jars\simjava2.jar;jars\gridsim.jar;jars\iText-2.1.5.jar;classes;.


cloudsim.ext.gui.GuiMain

Click on CONFIGURE Simulation.


Here you can configure:
Data Center Configuration where you can manage Physical Hardware Details of Data center.

We can double click on Datacenter to open Host information.

DEPSTAR (CE) 36
Cloud Computing - CE443 19DCE064

We can click on any host and copy it as many time as we want.

Here we are creating 5 copies of one of them so it will give us total of 6 hosts.

DEPSTAR (CE) 37
Cloud Computing - CE443 19DCE064

We can also configure advanced settings.

We can also customize user base that is models a group of users and generates traffic
representing the users.0

DEPSTAR (CE) 38
Cloud Computing - CE443 19DCE064

You can Save this Configuration as well in case you want to use it later. It is stored as .sim
file. XML data is generated and saved as Sim file.

Saved configuration can be loaded anytime easily into CloudAnalyst.


So you need to enter data each time you want to run simulation.
Once your are done with Configuration; click on Done!!!
We can check bandwidth and delay between regions in “Define Internet Characteristic”

DEPSTAR (CE) 39
Cloud Computing - CE443 19DCE064

Then we can run simulation that would give us overall report of simulation.

We can close it.


Main Window will give all statistics.

DEPSTAR (CE) 40
Cloud Computing - CE443 19DCE064

CONCLUSION:
In this practical, we learnt about cloudAnalyst and simulated a simple case with single
datacenter with 6 hosts and single user base.

DEPSTAR (CE) 41
Cloud Computing - CE443 19DCE064

PRACTICAL - 5
AIM: Develop Cluster application.
Choose any real time Cluster application and make analysis on that.

THEORY:
Cluster Computing:
Everyone might have faced the situation of low-speed services and content criticality. Cluster
computing resolves the need for content criticality and process services in a quicker
approach. As Internet Service Providers look for enhanced availability in a scalable approach,
cluster computing will provide this. And even, this technology is the heavy need for the film
industry as they require this for rendering extended quality of graphics and cartoons.
Implementation of the cluster through the Beowulf method also resolves the requirement of
statistics, fluid dynamics, genetic analysis, astrophysics, economics, neural networks,
engineering, and finance. Many of the organizations and IT giants are implementing this
technology to augment their scalability, processing speed, availability and resource
management at the economic prices.

Cluster computing provides a relatively inexpensive, unconventional to the large server or


mainframe computer solutions. Modernized advancements in both the hardware and software
technologies are probable to allow cluster computing to be completely progressive. Many
predict that the future of cluster computing also gains more prominence.

Advantages of Cluster Computing:


There are numerous advantages of implementing cluster computing in the applications. Few
of them to be discussed are as follows:

Cost efficacy – Even mainframe computers seems to be extremely stable, cluster computing
is more in implementation because of their cost-effectiveness and economical. Also, these
systems provide enhanced performance than that of mainframe computer networks.

Processing speed – The cluster computing systems offer the same processing speed as that of
mainframe computers and the speed is also equal to supercomputers.

Extended resource availability – Computers come across frequent breakdowns, so to


eliminate this failure, cluster computers are available with high availability. So, when one
node gets failed, the other nodes will be active and will function as a proxy for the failed
node. This makes sure for enhanced availability.
Expandability – The next crucial advantage of this cluster computing is its enhanced
scalability and expandability. As they instantiate the prospect to combine multiple additional
resources or the networks to the prevailing computer system.

DEPSTAR (CE) 42
Cloud Computing - CE443 19DCE064

Flexibility – Cluster computing can be upgraded to the superior specification or extended


through the addition of additional nodes (computer systems).

Some of the popular implementations of cluster computing are Google search engine,
Earthquake Simulation, Petroleum Reservoir Simulation, and Weather Forecasting system.
We’re going to focus on Clustering search Engine in this report.

Clustering Search Engines:


Clusters are widely used with respect to the criticality of the data or content handled and the
processing speed expected. Sites and applications which expect extended availability without
downtime and expecting heavy load balancing ability use these cluster concepts to a large
extent.

Clustering Search Engines unlike traditional Search Engines provide clusters that are related
to the original search phrase. Clusters help users see search results by topic so they can zero
in on exactly what they are looking for or discover unexpected relationships between items.
So instead of having to look through pages of search results, the clusters help users find
results they might have missed or that were buried deep in the ranked list.
These suggested clusters provide an interesting way of finding relevant topics to extract
keywords from.

Although this method finds relevant topics, it has some fairly serious shortcomings, some of
which are:
Most search engines do not allow the automated querying of their services.
Automated querying where allowed takes too long.
The clusters generated by clustering search engines are often not Closely Related Themes.
For these reasons the use of clustering search engines is not considered a viable method of
keyword discovery.

Several commercial clustering engines have been launched recently; the most popular one
among them is the Vivisimo engine. Vivisimo won the “best meta-search engine award”
assigned by Search Engine http://watch.com/ from 2001 to 2003

Vivisimo is possibly the most popular commercial clustering search engine. Vivisimo calls
search engines such as Yahoo and Google to extract relevant information (titles, URLs, and
short descriptions) from the result retrieved. It groups documents in the retrieved result based
on summarized information. The Vivisimo search clustering engine was sold to Yippy, Inc. in
2010. Grouper uses snippets obtained by the search engines. It is an interface for the results
of the Husky Search meta-search engine. Grouper uses the Suffix Tree Clustering (STC)
algorithm to cluster together documents that have great common subphrases. Carrot2 is a
clustering search engine solution that uses search results from various search engines
including Yahoo, Google, and MSN. It uses five different clustering algorithms (STC,

DEPSTAR (CE) 43
Cloud Computing - CE443 19DCE064

FussyAnts, Lingo, HAOG-STC, and Rough k-means) where Lingo Algorithm is the default
clustering algorithm used. The output is a flat folder structure; overlapping folders are
revealed when the user places the mouse over a document title. The system presented in is a
meta-search clustering engine, called the Search Clustering System (SCS), which organizes
the results returned by conventional Web search engines into a cluster hierarchy. The
hierarchy is produced by the Cluster Hierarchy Construction Algorithm (CHCA). Unlike
most other clustering algorithms, CHCA operates on nominal data: its input is a set of binary
vectors representing Web documents. Document representations are based either on snippets
or on the full contents of the retrieved pages.

All of the above clustering engines except use snippets that probably contain terms that are
part of the query keywords. Snippets are not necessarily good representative of the whole
document contents, which affects the quality of the clusters. Proposed solution uses whole
documents rather than titles and short snippets, to ensure proper extraction of the semantics
of the retrieved documents. While all of the above clustering engines have been mostly
performed without explicit use of lexical semantics, proposed work takes into consideration
both lexical and semantics similarities.

CONCLUSION:
In this practical, we learnt about cluster computing and its advantages. We analysed the
cluster search engine and different examples of it.

DEPSTAR (CE) 44
Cloud Computing - CE443 19DCE064

PRACTICAL - 6
AIM: Develop Grid application
Choose any one real time Grid Application and analyze its applications.
THEORY:
Grid Computing:
Grid Computing can be defined as a network of computers working together to perform a
task that would rather be difficult for a single machine. All machines on that network work
under the same protocol to act like a virtual supercomputer. The task that they work on may
include analysing huge datasets or simulating situations which require high computing power.
Computers on the network contribute resources like processing power and storage capacity to
the network.

Grid Computing is a subset of distributed computing, where a virtual super computer


comprises of machines on a network connected by some bus, mostly Ethernet or sometimes
the Internet. It can also be seen as a form of Parallel Computing where instead of many CPU
cores on a single machine, it contains multiple cores spread across various locations. The
concept of grid computing isn’t new, but it is not yet perfected as there are no standard rules
and protocols established and accepted by people.

Working:
A Grid computing network mainly consists of these three types of machines

Control Node:
A computer, usually a server or a group of servers which administrates the whole network
and keeps the account of the resources in the network pool.

Provider:
The computer which contributes it’s resources in the network resource pool.

User:
The computer that uses the resources on the network.
When a computer makes a request for resources to the control node, control node gives the
user access to the resources available on the network. When it is not in use it should ideally
contribute it’s resources to the network. Hence a normal computer on the node can swing in
between being a user or a provider based on it’s needs. The nodes may consist of machines
with similar platforms using same OS called homogeneous networks, else machines with
different platforms running on various different OS called heterogeneous networks. This is
the distinguishing part of grid computing from other distributed computing architectures.
For controlling the network and it’s resources a software/networking protocol is used
generally known as Middleware. This is responsible for administrating the network and the

DEPSTAR (CE) 45
Cloud Computing - CE443 19DCE064

control nodes are merely it’s executors. As a grid computing system should use only unused
resources of a computer, it is the job of the control node that any provider is not overloaded
with tasks.

Another job of the middleware is to authorize any process that is being executed on the
network. In a grid computing system, a provider gives permission to the user to run anything
on it’s computer, hence it is a huge security threat for the network. Hence a middleware
should ensure that there is no unwanted task being executed on the network.

The meaning of the term Grid Computing has changed over the years, according to “The
Grid: Blueprint for a new computing infrastructure” by Ian Foster and Carl Kesselman
published in 1999, the idea was to consume computing power like electricity is consumed
from a power grid. This idea is similar to current concept of cloud computing, whereas now
grid computing is viewed as a distributed collaborative network.Currently grid computing is
being used in various institutions to solve a lot of mathematical, analytical and physics
problems.

Advantages of Grid Computing:

● It is not centralized, as there are no servers required, except the control node which is
just used for controlling and not for processing.
● Multiple heterogeneous machines i.e. machines with different Operating Systems can
use a single grid computing network.
● Tasks can be performed parallelly across various physical locations and the users
don’t have to pay for it(with money).

General Applications of Grid Computing

● Distributed Supercomputing
● High-throughput Supercomputing
● On-demand Supercomputing
● Data-intensive Supercomputing
● Collaborative Supercomputing

Applications of Grid Computing Across Different Sectors

● Movie Industry
● Gaming Industry
● Life Sciences
● Engineering and Design
● Government

Distributed Supercomputing:
A distributed supercomputer is a supercomputer with processors spread around the world,
connected via the internet. It’s conceptually the exact same as a classic supercomputer, but
distributed. These processors are located in the desktops and laptops used by average people
every day. In a distributed supercomputer, device owners allow other people to use their

DEPSTAR (CE) 46
Cloud Computing - CE443 19DCE064

processors when they aren’t using them, and the devices are wirelessly connected to the
distributed supercomputer. That’s pretty neat, but there’s a downside. Currently, distributed
supercomputers can only solve certain, very specific, problems.

This is why the future is Hypercomputi2. Write a program in cloudsim to create two
datacenters with onehost each and run cloudlets of two users with network topology on
them.
Hypercomputing is a term we adapted to describe distributed supercomputing that is done
much faster, and in a truly parallel manner. Because it is parallel, Hypernet is not limited in
its computational abilities in the way that other distributed supercomputers are. This means it
can be used for complex parallel processing tasks, like the identification of cancer cells, the
prediction of traffic patterns, or even predicting natural disasters!

the advantage of distributed systems is that relative to supercomputers they are much less
expensive. Many distributed systems make use of cheap, off-the-shelf computers for
processors and memory, which only require minimal cooling costs. In addition, they are
simpler to scale, as adding an additional processor to the system often consists of little more
than connecting it to the network. However, unlike supercomputers, which send data short
distances via sophisticated and highly optimized connections, distributed systems must move
data from processor to processor over slower networks making them unsuitable for many
real-time applications.

Distributed systems are most useful for problems that are not as sensitive to latency. For
example, when NASA’s Jet Propulsion Laboratory (JPL) needed to process high volumes of
image data collected by its Mars rovers, a computer cluster hosted on the Amazon Cloud was
a natural fit. Such tasks are not substantially hindered by small delays in individual
computations, so distributed systems offered the most pragmatic solution. Other distributed
computing applications include large-scale records management and text mining.

CONCLUSION:
In this practical, we learnt about grid computing and listed different applications of it. We
chose distributed supercomputing to analyse in detail.

DEPSTAR (CE) 47

You might also like