Professional Documents
Culture Documents
Register no:
Name: GUNASEKARAN, D
Course: M TECH (IT)
Roll no: 13MTECHIT002
DEPARTMENT OF
INFORMATION TECHNOLOGY
LABORATORY RECORD
Certified to be the bonafide of work done by GUNASEKARAN, D
at Cloud Computing laboratory during
Staff In-Charge
External Examiner
CONTENTS
Sl
No
Date
Name of the
Experiment
INTERNAL MARKS
Page
No
Marks
Staff
Signature
STAFF INCHARGE
Ex 1
Date :
AIM
ALGORITHM
books are shared through google drive and events are created using google
calendars.
Ex 2
Date:
STUDY ON CLOUDSIM
AIM
To study about the cloud simulator tool CLOUDSIM and to
understand the basics of the tool.
OVERVIEW:
Cloudsim is a framework developed as a project, which is
used mainly for modeling and simulation of cloud computing infrastructure
and services. Recently, cloud computing emerged as the leading
technology for delivering reliable, secure, fault-tolerant, sustainable, and
scalable computational services, which are presented as Software,
Infrastructure, or Platform as services (SaaS, IaaS, PaaS).
The primary objective of this project is to provide a
generalized, and extensible simulation framework that enables seamless
modeling, simulation, and experimentation of emerging Cloud computing
infrastructures and application services. By using CloudSim, researchers
and industry-based developers can focus on specific system design issues
that they want to investigate, without getting concerned about the low level
details related to Cloud-based infrastructures and services. CloudSim is
powered by JProfiler.
ARCHITECTURE:
Ex 3
Date
AIM
To model the cloud computing environments using cloudsim and to
implement the time shared and space shared policy
PROCEDURE:
1)
CODE:
package cloudsimexample;
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;
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 run two
* cloudlets on it. The cloudlets run in
* VMs with the same MIPS requirements.
* The cloudlets will take the same time to
* complete the execution.
*/
public class CloudSimExample {
/** 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 CloudSimExample2...");
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
@SuppressWarnings("unused")
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 two VMs
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw,
size, vmm, new CloudletSchedulerTimeShared());
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;
pesNumber=1;
long length = 250000;
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);
id++;
Cloudlet cloudlet3 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet3.setUserId(brokerId);
id++;
Cloudlet cloudlet4 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet4.setUserId(brokerId);
id++;
Cloudlet cloudlet5 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet5.setUserId(brokerId);
id++;
Cloudlet cloudlet6 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet6.setUserId(brokerId);
id++;
Cloudlet cloudlet7 = new Cloudlet(id, length, pesNumber, fileSize,
SPACE SHARED:
Starting CloudSimExample2...
Initialising...
Starting CloudSim version 3.0
Datacenter_0 is starting...
Broker is starting...
Entities started.
0.0: Broker: Cloud Resource List received with 1 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter_0
0.0: Broker: Trying to Create VM #1 in Datacenter_0
0.1: Broker: VM #0 has been created in Datacenter #2, Host #0
0.1: Broker: VM #1 has been created in Datacenter #2, Host #0
0.1: Broker: Sending cloudlet 0 to VM #0
0.1: Broker: Sending cloudlet 1 to VM #0
0.1: Broker: Sending cloudlet 2 to VM #0
0.1: Broker: Sending cloudlet 3 to VM #0
Finish Time
Start Time
1000.1
1000.1
2000.1
2000.1
3000.1
3000.1
4000.1
4000.1
Finish Time
Ex 4
Date:
AIM
To model the cloud computing environments using cloudsim and to
implement the dvfs and VM Migration policy.
PROCEDURE:
1) Download the cloudsim package from
https://code.google.com/p/cloudsim/downloads/list
2) Extract the package in some folder and store in some place in the
computer
3) Open any IDE such as NetBeans or Eclipse and create a new Java
Project from the menu listed.
4) Import the jar file of the cloudsim package that was
extracted in the previous step.
5) Open the libraries list that shows up in the project
explorer of the IDE.
6) Select the dvfs.java from the
org.cloudbus.cloudsim.examples folder.
7) As per the requirement in the program, create the
cloudlets, number of processors, etc.
8) Run the program and record the output for Dynamic
Voltage and Frequency Scaling and also the VM
Migration
CODE:
package cloudsimexample;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerDynamicWorkload;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModelStochastic;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.PowerDatacenter;
import org.cloudbus.cloudsim.power.PowerHost;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicySimple;
import org.cloudbus.cloudsim.power.models.PowerModelLinear;
import org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/**
* An example of a heterogeneous DVFS-enabled data center: the voltage
* and clock frequency of the CPU are adjusted ideally according
* to current resource requirements.
*/
public class Dvfs {
/** The cloudlet list. */
private static List<Cloudlet> cloudletList;
/** The vm list. */
private static List<Vm> vmList;
private static double hostsNumber = 400;
private static double vmsNumber = 800;
private static double cloudletsNumber = 400;
/**
* Creates main() to run this example.
*
* @param args the args
*/
public static void main(String[] args) {
int totalTotalRequested = 0;
int totalTotalAllocated = 0;
ArrayList<Double> sla = new ArrayList<Double>();
/*int numberOfAllocations = 0;
for (Entry<String, List<List<Double>>> entry :
datacenter.getUnderAllocatedMips().entrySet()) {
List<List<Double>> underAllocatedMips = entry.getValue();
double totalRequested = 0;
double totalAllocated = 0;
for (List<Double> mips : underAllocatedMips) {
if (mips.get(0) != 0) {
numberOfAllocations++;
totalRequested += mips.get(0);
totalAllocated += mips.get(1);
double _sla = (mips.get(0) - mips.get(1)) / mips.get(0) * 100;
if (_sla > 0) {
sla.add(_sla);
}
}
}
totalTotalRequested += totalRequested;
totalTotalAllocated += totalAllocated;
}*/
double averageSla = 0;
if (sla.size() > 0) {
double totalSla = 0;
for (Double _sla : sla) {
totalSla += _sla;
}
averageSla = totalSla / sla.size();
}
Log.printLine();
Log.printLine(String.format("Total simulation time: %.2f sec", lastClock));
Log.printLine(String.format("Energy consumption: %.2f kWh",
datacenter.getPower() / (3600 * 1000)));
Log.printLine(String.format("Number of VM migrations: %d",
datacenter.getMigrationCount()+1));
Log.printLine(String.format("Number of SLA violations: %d", sla.size()));
Log.printLine(String.format("SLA violation: %.2f%%", 100 * ((double)
totalTotalRequested - totalTotalAllocated) / totalTotalRequested));
Log.printLine(String.format("Average SLA violation: %.2f%%",
averageSla));
Log.printLine();
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
Log.printLine("DVFS example finished!");
}
/**
* Creates the cloudlet list.
*
* @param brokerId the broker id
*
* @return the cloudlet list
*/
private static List<Cloudlet> createCloudletList(int brokerId) {
List<Cloudlet> list = new ArrayList<Cloudlet>();
long length = 150; // 10 min on 250 MIPS
int pesNumber = 1;
long fileSize = 300;
long outputSize = 300;
for (int i = 0; i < cloudletsNumber; i++) {
Cloudlet cloudlet = new Cloudlet(i, length, pesNumber, fileSize,
outputSize, new UtilizationModelStochastic(), new UtilizationModelStochastic(), new
UtilizationModelStochastic());
cloudlet.setUserId(brokerId);
cloudlet.setVmId(i);
list.add(cloudlet);
}
return list;
}
/**
* Creates the vms.
*
* @param brokerId the broker id
*
* @return the list< vm>
*/
private static List<Vm> createVms(int brokerId) {
List<Vm> vms = new ArrayList<Vm>();
// VM description
int[] mips = { 250, 500, 750, 1000 }; // MIPSRating
int pesNumber = 1; // number of cpus
int ram = 512; // vm memory (MB)
new PowerHost(
i,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList),
new PowerModelLinear(maxPower, staticPowerPercent)
)
); // This is our machine
}
// 5. Create a DatacenterCharacteristics object that stores the
// properties of a Grid resource: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/PowerPe 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
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
// 6. Finally, we need to create a PowerDatacenter object.
PowerDatacenter powerDatacenter = null;
try {
powerDatacenter = new PowerDatacenter(
name,
characteristics,
new PowerVmAllocationPolicySimple(hostList),
new LinkedList<Storage>(),
600.0);
} catch (Exception e) {
e.printStackTrace();
}
return powerDatacenter;
}
// We strongly encourage users to develop their own broker policies, to
// submit vms and cloudlets according
}
}
OUTPUT:
Ex 5
Date
AIM
To model the cloud computing environments using cloudsim.
PROCEDURE:
1) Download the cloudsim package from
https://code.google.com/p/cloudsim/downloads/list
2) Extract the package in some folder and store in some place in the
computer
3) Open any IDE such as NetBeans or Eclipse and create a new Java
Project from the menu listed.
4) Import the jar file of the cloudsim package that was
extracted in the previous step.
5) Open the libraries list that shows up in the project
explorer of the IDE.
6) Select the CloudSimExample8.java from the
org.cloudbus.cloudsim.examples folder.
7) As per the requirement in the program, get the
cloudlets, number of processors, from the user and then
use them for modeling.
8) Run the program and record the output
PROGRAM:
<!DOCTYPE html>
<!--
OUTPUT:
/>
Ex 7
Date