CC Lab 2

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

Hyper-V

Lab Experiment 2
Name : Chahat Baghele Date : 26 May 2023
Course : Cloud Computing
Id : 191080008
Branch : Information Technology
Aim : To create 2 datacenters with 2 hosts(Each per data center) and 2
VMs (1 on each) in CloudSim. Use the Hypervisor name as "Hyper-V ''

Theory :
Cloud Computing is one of the hottest topics in town. It has completely transformed how
modern-day applications are developed and maintained with high scalability and low latency.
CloudSim is an open-source framework, which is used to simulate cloud computing
infrastructure and services. It is developed by the CLOUDS Lab organization and is written
entirely in Java. It is used for modeling and simulating a cloud computing environment as a
means for evaluating a hypothesis prior to software development in order to reproduce tests and
results.

For example, if you were to deploy an application or a website on the cloud and wanted
to test the services and load that your product can handle and also tune its performance to
overcome bottlenecks before risking deployment, then such evaluations could be performed by
simply coding a simulation of that environment with the help of various flexible and scalable
classes provided by the CloudSim package, free of cost.

Benefits of Simulation over the Actual Deployment:

➔ No capital investment involved. With a simulation tool like CloudSim there is no


installation or maintenance cost.
➔ Easy to use and Scalable. You can change the requirements such as adding or deleting
resources by changing just a few lines of code.
➔ Utilization of real testbeds limits the experiments to the scale of the testbed and makes
the reproduction of results an extremely difficult undertaking. With simulation, you can
test your product against test cases and resolve issues before actual deployment without
any limitations.
➔ No need for try-and-error approaches. Instead of relying on theoretical
➔ and imprecise evaluations which can lead to inefficient service performance and revenue
generation, you can test your services in a repeatable and controlled environment free of
cost with CloudSim.

CloudSim

CloudSim Core Simulation Engine provides interfaces for the management of resources
such as VM, memory and bandwidth of virtualized Datacenters. CloudSim layer manages the
creation and execution of core entities such as VMs, Cloudlets, Hosts etc. It also handles
network-related execution along with the provisioning of resources and their execution and
management. User Code is the layer controlled by the user. The developer can write the
requirements of the hardware specifications in this layer according to the scenario.

Some of the most common classes used during simulation are:

1. Datacenter: used for modeling the foundational hardware equipment of any cloud
environment, that is the Datacenter. This class provides methods to specify the
functional requirements of the Datacenter as well as methods to set the allocation
policies of the VMs etc.
2. Host: this class executes actions related to management of virtual machines. It also
defines policies for provisioning memory and bandwidth to the virtual machines, as well
as allocating CPU cores to the virtual machines.
3. VM: this class represents a virtual machine by providing data members defining a VM’s
bandwidth, RAM, mips (million instructions per second), size while also providing setter
and getter methods for these parameters.
4. Cloudlet: a cloudlet class represents any task that is run on a VM, like a processing task,
or a memory access task, or a file updating task etc. It stores parameters defining the
characteristics of a task such as its length, size, mi (million instructions) and provides
methods similar to VM class while also providing methods that define a task’s execution
time, status, cost and history.
5. DatacenterBroker: is an entity acting on behalf of the user/customer. It is responsible for
functioning of VMs, including VM creation, management, destruction and submission of
cloudlets to the VM.
6. CloudSim: this is the class responsible for initializing and starting the simulation
environment after all the necessary cloud entities have been defined and later stopping
after all the entities have been destroyed.

Features of CloudSim:

CloudSim provides support for simulation and modeling of:

➔ Large scale virtualized Datacenters, servers and hosts.


➔ Customizable policies for provisioning host to virtual machines.
➔ Energy-aware computational resources.
➔ Application containers and federated clouds
➔ Datacenter network topologies and message-passing applications.
➔ Dynamic insertion of simulation entities with stop and resume of simulation.
➔ User-defined allocation and provisioning policies.

Hyper-V Hypervisor:

Microsoft Hyper-V is Microsoft’s virtualization platform, or ‘hypervisor’, which enables


administrators to make better use of their hardware by virtualizing multiple operating systems
to run off the same physical server simultaneously. With Microsoft Hyper-V, you can virtualize
server operating systems in the data center or Windows phone environments on your desktop
and most everything in between. It is also a great tool for developers that want a safe sandbox to
test software.

Benefits of using Hyper-V:

★ Clustering Support
★ Replica
★ Familiar Windows Interfaces
★ Full Support for guest Clusters
★ Migration of running virtual machines; even outside and across clusters.

Code :

package Lab1;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.*;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
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;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
/*
*To create x datacenters with x hosts ,x VMs, x cloudlets in Cloud Sim */
public class Exp_1 {
private static List < Cloudlet > cloudletList;
private static List < Vm > vmlist;
private static List < Datacenter > dcList;
public static void main(String[] args) {
int num_user = 1;
Scanner sc = new Scanner(System.in); //System.in is a standard input
stream
//System.out.print("Enterthe number of users "); //number users are
the number
of brokers needed
System.out.println("Enter your roll no. :");
int roll = sc.nextInt();
int input = roll % 10;
num_user = 1;
System.out.print("Enter number of Datacenter:\n");
int dcno = sc.nextInt();
System.out.println("Enter number of Hosts per Data Center:\n" +
input);
int host = input;
//System.out.print("Enterthe PE's per Host: ");
int pe = 2;
System.out.println("Enter the VM's:\n" + input);
int vm = input;
//System.out.print("Enterthe Cloudlet's: ");
int cl = 2;
System.out.print("Enter the Hypervisor to be used :\n");
String vMM = sc.next();
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
CloudSim.init(num_user, calendar, trace_flag);
LinkedList < Datacenter > list = new LinkedList < Datacenter > ();
Datacenter[] dc = new Datacenter[dcno];
//Creating Datacenters - each host and PE as given by input
for (int i = 0; i < dcno; i++) {
Datacenter dc1 = createDatacenter("DC" + i, host, pe);
list.add(dc1);
}
LinkedList < DatacenterBroker > listDCB = new LinkedList <
DatacenterBroker > ();
DatacenterBroker[] dcb = new DatacenterBroker[num_user];
//creating brokers and assigning VM's and Cloudlet to each one
for (int i = 1; i <= num_user; i++) {
DatacenterBroker brk1 = createBroker("broker" + i);
brk1.submitVmList(createVM(brk1.getId(), vm, 1, vMM));
brk1.submitCloudletList(createCloudlet(brk1.getId(), cl, 1));
listDCB.add(brk1);
}
List < Cloudlet > newList = listDCB.get(0).getCloudletReceivedList();
CloudSim.startSimulation();
for (int i = 1; i < listDCB.size(); i++) {
newList.addAll(listDCB.get(i).getCloudletReceivedList());
}
CloudSim.stopSimulation();
printCloudletList(newList);
}
private static List < Vm > createVM(int userId, int vms, int idShift,
String vMM) { //Creates a container to store VMs. This list is passed to
the brokerlater
LinkedList < Vm > list = new LinkedList < Vm > ();
//VM Parameters
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int mips = 1000;
long bw = 1000;
int pesNumber = 1; //number of cpus
String vmm = vMM; //VMM name
//create VMs
Vm[] vm = new Vm[vms];
for (int i = 0; i < vms; i++) {
vm[i] = new Vm(idShift + i, userId, mips, pesNumber, ram, bw, size,
vmm, new CloudletSchedulerSpaceShared());
list.add(vm[i]);
}
return list;
}
private static List < Cloudlet > createCloudlet(int userId, int
cloudlets, int idShift) {
// Creates a container to store Cloudlets
LinkedList < Cloudlet > list = new LinkedList < Cloudlet > ();
//cloudlet
parameters
long length = 100000;
long fileSize = 300;
long outputSize = 300;
int pesNumber
= 1;
UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet[] cloudlet = new Cloudlet[cloudlets];
for (int i = 0; i < cloudlets; i++) {
cloudlet[i] = new Cloudlet(idShift + i, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel, utilizationModel);
// setting the owner of these Cloudlets
cloudlet[i].setUserId(userId);
list.add(cloudlet[i]);
}
return list;
}
private static Datacenter createDatacenter(String name, int hostNumber,
int PE) {
List < Host > hostList = new ArrayList < Host > ();
List < Pe > peList1 = new
ArrayList < Pe > ();
int mips = 1000;
int hostId = 0;
int ram = 16384;
long storage = 1000000;
int bw = 10000;
for (int i = 1; i <= PE; i++) {
peList1.add(new Pe(i, new PeProvisionerSimple(mips)));
}
for (int i = 0; i < hostNumber; i++) {
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList1,
new VmSchedulerSpaceShared(peList1)));
hostId++;
}
String arch = "x86"; // system architecture
String os = "Windows"; // operating system
String vmm = "Hyper-V";
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.1; // the cost of using storage in this
resource
double costPerBw = 0.1; // 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);
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
private static DatacenterBroker createBroker(String name) {
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker(name);
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}
/**
* Prints the Cloudlet objects
*/
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 + 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 + indent +
dft.format(cloudlet.getActualCPUTime()) +
indent + indent +
dft.format(cloudlet.getExecStartTime()) + indent + indent +
indent +
dft.format(cloudlet.getFinishTime()));
}
}
}
}
Output :
Conclusion :
Thus successfully implement the experiment 2 using Hyper -V as hypervisior.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy