You are on page 1of 31

MAHENDRA COLLEGE OF ENGINEERING

Mahendra Salem Campus, Minnampalli,


Salem-636106

CLOUD COMPUTING LABORATORY


RECORD NOTE BOOK

Register no:

62 151 351 0002

Name: GUNASEKARAN, D
Course: M TECH (IT)
Roll no: 13MTECHIT002

MAHENDRA COLLEGE OF ENGINEERING


Mahendra Salem Campus, Minnampalli,
Salem-636106

DEPARTMENT OF
INFORMATION TECHNOLOGY
LABORATORY RECORD
Certified to be the bonafide of work done by GUNASEKARAN, D
at Cloud Computing laboratory during

2012-2013 his university register

number is 62 151 351 0002

Head of the Department


Date:

Staff In-Charge

Submitted for the practical examination conducted during ________


At__________
Internal Examiner

External Examiner

CONTENTS
Sl
No

Date

Name of the
Experiment

INTERNAL MARKS

Page
No

Marks

Staff
Signature

STAFF INCHARGE

Ex 1
Date :

COLLABORATIVE ENVIRONMENT - GOOGLE APPS

AIM

To create a collaborative environment for a particular learning topic


using Google Apps.

ALGORITHM

Step 1: Create a gmail account and log in with the proper


username and password.
Step 2: In the top right corner, there is a grid. Click on the grid and
choose the Drive option
Step 3: Google drive page opens up as shown in the following
figure

Step 4: In the left side, there is an option for creating a


presentation, document, spreadsheet, form, etc
Step 5: Choose on the option that is required as per the
requirement specification and then proceed creating.
Step 6: Then finally share that document with your friends.
Step 7: For creating time table or other events, choose the
Calendar option from that grid which appears in the log in page of
the gmail.
Step 8: Provide the date and time of the event and create the event
and share with your friends.

RESULT: Thus the collaborative environment is created using google apps, e-

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

CLOUDSIM- TIME SHARED AND SPACE SHARED

AIM
To model the cloud computing environments using cloudsim and to
implement the time shared and space shared 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 CloudSimExample2.java from the
org.cloudbus.cloudsim.examples folder.
7)
Add the required number of cloudlets(8 as given in the
requirement)
8)
Run the program and record the output for Time Shared
Policy
9)
In the code at the creation of a Virtual Machine step,
change the policy to space shared and run the code
again
10) Now record the output for space shared and compare
the output

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,

outputSize, utilizationModel, utilizationModel, utilizationModel);


cloudlet7.setUserId(brokerId);
id++;
Cloudlet cloudlet8 = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
cloudlet8.setUserId(brokerId);
//add the cloudlets to the list
cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);
cloudletList.add(cloudlet3);
cloudletList.add(cloudlet4);
cloudletList.add(cloudlet5);
cloudletList.add(cloudlet6);
cloudletList.add(cloudlet7);
cloudletList.add(cloudlet8);
//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(),vm1.getId());
broker.bindCloudletToVm(cloudlet3.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet4.getCloudletId(),vm1.getId());
broker.bindCloudletToVm(cloudlet5.getCloudletId(),vm2.getId());
broker.bindCloudletToVm(cloudlet6.getCloudletId(),vm2.getId());
broker.bindCloudletToVm(cloudlet7.getCloudletId(),vm2.getId());
broker.bindCloudletToVm(cloudlet8.getCloudletId(),vm2.getId());
// 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("CloudSimExample2 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;
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
//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");
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()));
}
}
}
}
OUTPUT:
Time- 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
0.1: Broker: Sending cloudlet 4 to VM #1
0.1: Broker: Sending cloudlet 5 to VM #1
0.1: Broker: Sending cloudlet 6 to VM #1
0.1: Broker: Sending cloudlet 7 to VM #1
4000.1: Broker: Cloudlet 0 received

4000.1: Broker: Cloudlet 1 received


4000.1: Broker: Cloudlet 2 received
4000.1: Broker: Cloudlet 3 received
4000.1: Broker: Cloudlet 4 received
4000.1: Broker: Cloudlet 5 received
4000.1: Broker: Cloudlet 6 received
4000.1: Broker: Cloudlet 7 received
4000.1: Broker: All Cloudlets executed. Finishing...
4000.1: Broker: Destroying VM #0
4000.1: Broker: Destroying VM #1
Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter_0 is shutting down...
Broker is shutting down...
Simulation completed.
Simulation completed.
========== OUTPUT ==========
Cloudlet ID STATUS Data center ID VM ID Time Start Time
0
SUCCESS
2
0
4000
0.1
4000.1
1
SUCCESS
2
0
4000
0.1
4000.1
2
SUCCESS
2
0
4000
0.1
4000.1
3
SUCCESS
2
0
4000
0.1
4000.1
4
SUCCESS
2
1
4000
0.1
4000.1
5
SUCCESS
2
1
4000
0.1
4000.1
6
SUCCESS
2
1
4000
0.1
4000.1
7
SUCCESS
2
1
4000
0.1
4000.1
CloudSimExample2 finished!

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

0.1: Broker: Sending cloudlet 4 to VM #1


0.1: Broker: Sending cloudlet 5 to VM #1
0.1: Broker: Sending cloudlet 6 to VM #1
0.1: Broker: Sending cloudlet 7 to VM #1
1000.1: Broker: Cloudlet 0 received
1000.1: Broker: Cloudlet 4 received
2000.1: Broker: Cloudlet 1 received
2000.1: Broker: Cloudlet 5 received
3000.1: Broker: Cloudlet 2 received
3000.1: Broker: Cloudlet 6 received
4000.1: Broker: Cloudlet 3 received
4000.1: Broker: Cloudlet 7 received
4000.1: Broker: All Cloudlets executed. Finishing...
4000.1: Broker: Destroying VM #0
4000.1: Broker: Destroying VM #1
Broker is shutting down...
Simulation: No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter_0 is shutting down...
Broker is shutting down...
Simulation completed.
Simulation completed.
========== OUTPUT ==========
Cloudlet ID STATUS Data center ID VM ID Time
0
SUCCESS
2
0
1000
0.1
4
SUCCESS
2
1
1000
0.1
1
SUCCESS
2
0
1000
1000.1
5
SUCCESS
2
1
1000
1000.1
2
SUCCESS
2
0
1000
2000.1
6
SUCCESS
2
1
1000
2000.1
3
SUCCESS
2
0
1000
3000.1
7
SUCCESS
2
1
1000
3000.1
CloudSimExample2 finished!

Start Time
1000.1
1000.1
2000.1
2000.1
3000.1
3000.1
4000.1
4000.1

Finish Time

Thus the cloud environment is modeled as per the given


requirements and time shared and space shared policy is implemented.
RESULT:

Ex 4
Date:

CLOUDSIM- DVFS AND VM MIGRATION

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) {

Log.printLine("Starting DVFS example...");


try {
// First step: Initialize the CloudSim package. It should be called
// before creating any entities. We can't run this example without
// initializing CloudSim first. We will get run-time exception
// error.
int num_user = 5; // number of cloud users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace GridSim 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
PowerDatacenter datacenter = createDatacenter("Datacenter_0");
datacenter.setDisableMigrations(true);
// Third step: Create Broker
DatacenterBroker broker = createBroker();
int brokerId = broker.getId();
// Fourth step: Create one virtual machine
vmList = createVms(brokerId);
// submit vm list to the broker
broker.submitVmList(vmList);
// Fifth step: Create one cloudlet
cloudletList = createCloudletList(brokerId);
// submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);
// Sixth step: Starts the simulation
double lastClock = CloudSim.startSimulation();
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
Log.printLine("Received " + newList.size() + " cloudlets");
CloudSim.stopSimulation();
printCloudletList(newList);

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)

long bw = 2500; // bandwidth


long size = 10000; // image size (MB)
String vmm = "Xen"; // VMM name
for (int i = 0; i < vmsNumber; i++) {
vms.add(
new Vm(i, brokerId, mips[i % mips.length], pesNumber, ram, bw,
size, vmm, new CloudletSchedulerSpaceShared()));
}
return vms;
}
/**
* Creates the datacenter.
*
* @param name the name
*
* @return the datacenter
*
* @throws Exception the exception
*/
private static PowerDatacenter createDatacenter(String name) throws Exception {
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create an object of HostList2 to store
// our machine
List<PowerHost> hostList = new ArrayList<PowerHost>();
double maxPower = 500; // 250W
double staticPowerPercent = 0.7; // 70%
int[] mips = { 1000, 2000, 3000 };
int ram = 1000000; // host memory (MB)
long storage = 100000000; // host storage
int bw = 10000000;
for (int i = 0; i < hostsNumber; i++) {
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
// 3. Create PEs and add these into an object of PowerPeList.
List<Pe> peList = new ArrayList<Pe>();
peList.add(new Pe(0, new PeProvisionerSimple(mips[i %
mips.length]))); // need to store PowerPe id and MIPS Rating
// 4. Create PowerHost with its id and list of PEs and add them to the list of
machines
hostList.add(

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

// to the specific rules of the simulated scenario


/**
* Creates the broker.
*
* @return the datacenter broker
*/
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 = "\t";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+ "Resource 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());
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.printLine(indent + "SUCCESS"
+ indent + indent + cloudlet.getResourceId()
+ indent + cloudlet.getVmId()
+ indent + dft.format(cloudlet.getActualCPUTime())
+ indent + dft.format(cloudlet.getExecStartTime())
+ indent + indent + dft.format(cloudlet.getFinishTime())
);
}
}

}
}

OUTPUT:

Thus the cloud environment is modeled as per the given


requirements and dvfs and VM Migration policy is implemented.
RESULT:

Ex 5
Date

CLOUDSIM- MODEL AND SIMULATION

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>
<!--

To change this license header, choose License Headers in Project Properties.


To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SUBMIT JOB</title>
</head>
<body bgcolor="yellow">
<form action="cloudsimServlet" method="POST"><br>
<h1><b>Enter your TASK Details</b> </h1>
<table>
No_of vm
: &nbsp; &nbsp; <input type="text"
name="vmNumber" />
<br />
No_Tasks : &nbsp;&nbsp;&nbsp; <input type="text"
name="cloudlets" />
<br />
File Length : &nbsp;&nbsp;&nbsp;<input type="text"
name="length"
/>
<br />
File size :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="fileSize"
/>
<br />
Pes Number: &nbsp;&nbsp;<input type="text" name="pesNumber"
<br />
</table>
<br><input type="submit" value="SUBMIT" />
</form>
</body>
</html>

OUTPUT:

/>

Thus the cloud environment is modeled as per the given


requirements.
RESULT:

Ex 7
Date

You might also like