0% found this document useful (0 votes)
17 views33 pages

Shared Practical File

The document outlines a series of experiments focused on virtualization and cloud computing using Oracle VM VirtualBox and CloudSim. It includes detailed procedures for installing VirtualBox, creating virtual machines, importing/exporting VMs, and running simulations in CloudSim. Each experiment aims to demonstrate different aspects of virtualization, such as guest OS installation, VM migration, and cloudlet execution in a simulated environment.

Uploaded by

Ruchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views33 pages

Shared Practical File

The document outlines a series of experiments focused on virtualization and cloud computing using Oracle VM VirtualBox and CloudSim. It includes detailed procedures for installing VirtualBox, creating virtual machines, importing/exporting VMs, and running simulations in CloudSim. Each experiment aims to demonstrate different aspects of virtualization, such as guest OS installation, VM migration, and cloudlet execution in a simulated environment.

Uploaded by

Ruchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

EXPERIMENT – 1

Aim: Virtualization: Installing Virtualization software (VirtualBox) and creating a


virtual machine with guest OS different from host OS.

Hardware Requirements: Desktop/ Laptop System with Windows 7 operating system

Software Requirements: Virtual Box, Ubuntu iso image

Theory:

Oracle VM Virtual Box (formerly Sun Virtual Box, Sun VM VirtualBox and innotek
VirtualBox) is a virtualization software package for x86 and AMD64/Intel64 based
computers from Oracle Corporation as part of its family of virtualization products. It was
created by innotek GmbH, purchased in 2008 by Sun Microsystems and now developed
by Oracle. It is installed on an existing host operating system as an application; this host
application allows additional guest operating systems, each known as a Guest OS, to be
loaded and run, each with its own virtual environment.

Supported host operating systems include Linux, Mac OSX, Windows XP, Windows
Vista, Windows 7, Windows 8, Solaris and Open Solaris.

Emulated Environment:

VirtualBox can load multiple guest OS under a single host operating system (host OS).
Each guest can be started, paused and stopped independently within its own virtual
machine (VM). The user can independently configure each VM and run it under a choice
of software-based virtualization or hardware assisted virtualization if the underlying host
hardware supports this. The host OS and guest OSs and applications can communicate
with each other through a number of mechanisms including a common clipboard and a
virtualised network facility. Guest VMs can also directly communicate with each other if
configured to do so.

Software-enabled virtualization:

In the absence of hardware-assisted virtualization, VirtualBox adopts a standard


software-based virtualization approach. This mode supports 32 bit guest OSs which run
in rings 0 and 3 of the intel ring architecture.
• The system reconfigures the guest OS code, would normally run in ring 0, to
execute in ring 1 on the host hardware. Because this code contains many
priveleged instructions which cannot run natively in ring 1, VirtualBox employs
a Code Scanning and Analysis Manager (CSAM) to scan the ring 0 code
recursively before its first execution to identify problematic instructions and then
calls the Patch Manager (PATM) to perform insitu patching. This replaces the
instruction with a jump to a VM-safe equivalent compiled code fragment in
hypervisor memory.
• The guest user mode code, running in ring 3, generally runs directly on the host
hardware in ring 3.
• In both cases, VirtualBox uses CSAM and PATM to inspect and patch the
offending instructions whenever a fault occurs. VirtualBox also contains a
dynamic recompile, based on QEMU to recompile any real mode or protected
mode code entirely (e.g. BIOS code, a DOS guest, or any operating system
startup).

Using these techniques, VirtualBox can achieve a performance comparable to that of


Vmware.

Hardware-assisted virtualization:

VirtualBox supports both Intel's VT-x and AMD's AMD-V hardware-virtualization.


Making use of these facilities, VirtualBox can run each guest VM in its own separate
address-space; the guest OS ring 0 code runs on the host at ring 0 in VMX non-root mode
rather than in ring 1.

VirtualBox supports some guests (including 64 bit guests, SMP guests and certain
propreitary OSs ) only on hosts with hardware-assisted virtualization.

PROCEDURE :

A. INSTALLING VIRTUAL BOX

1. Open the downloaded exe file of virtual box which is of around 115 MB. Click on it.
Click yes.
2. Click on install.
Then you see this :
Allow it. Click install. It will start installing again.
3. And it’s done!

B. UBUNTU INSTALLATION IN VIRTUAL BOX


1. Open virtual box:
It looks like this. Click on NEW blue button on the upper left side.
2. Virtual machine name: Give name to your virtual machine. I gave Ubuntu 14.04.3.
Virtual box will automatically fill the other two options. If you add names like myVirtual
or any customized name then you need to specify the other fields. Click on next.
3. Memory size:
How much memory do you want to give this machine?
It is RAM not secondary memory. I added 768 MB which was default. You can set
according to your system. If your system has 2 GB or less then reduce it 512 MB or if
you have more than 2 like 4,6 or 8 GB, then leave it as 768 MB.
4. Hard Disk: Choose Create a virtual hard disk now (which is default setting). It creates
a virtual hard disk on your machine.
5. Hard disk file type: Choose default setting of Virtual disk image. Click next. 6. Storage
on Physical hard disk: As you work on the virtual machine, you may create files and use
storage. So what you need is to access space to store them. This space could be allocated
once or you may say that it should do automatically when required. When memory
assignment is done dynamically it can grow its size whenever machine needs. It’s good to
opt for dynamically allocated option.

7. File location and size: It’s the size you want to give your machine. (I gave 15 GB)

Then you see a machine named Ubuntu or whatever you gave in left pane. Select this
machine. Click on the settings.

8. Select system tab. Uncheck floppy. Set hard disk first and optical disk second by using
arrows.

9. Select processor tab: If you 4 cores then set it to 1 or more than 4 then set it to
2.Change execution cap to 90%.

10. Switch to display tab. Change the video memory to half of the available or you can
set it to 64 MB.

11. Click on 3d acceleration check box.

12. Switch to storage tab. Click on empty. Now select the cd icon which is present on the
right side. Browse the location where you placed iso image of Ubuntu.
13. Click in OK. All settings are done. Click on the start button to start your newly built
virtual machine. Virtual Machine will start booting process. It takes time. If you
encounter error like ACPI PCC probe failed, do not worry. It is harmless error.

14. Now you see the Ubuntu os asking you to install or try it. Click on try if you want to
try it otherwise install button.

15. Click on erase disk.


16. Select your time zone.
17. Select keyboard layout language:

18. Installation will take time (half an hour or so).


EXPERIMENT 2
AIM: Virtualization: Importing and exporting Virtual Machines between physical
machines.

REQUIREMENTS: 2 Desktop Laptop systems with virtual box installed on both of


them and with windows operating system, pen drive (> 4 GB)

THEORY:
Suppose we need an exact copy of the virtual machine on a different system. In that case,
we need to first clone the machine and then migrate it to other machine.

Some definitions:
1. Cloning: Cloning means making an exact similar copy.
2. Migration: Moving virtual machine from one computer to other.

STEPS:
1. Turn off the virtual machine. You cannot put it to pause. Power it off.

2. Cloning:
A. Select the machine from the left panel which you want to clone. Click ”snapshots”
which is present near upper right side.

B. Click on the sheep button.


C. A wizard will pop up.

It asks for name of clone machine. By default, Virtual box appends word clone to name
of original machine which is being cloned. You can give any other name. But give
different name from original machine. Click next.

D. Type of clone:
You can make two types of clones:
1. Full clone: In this mode you can work with machine without any need of source
Virtual machine. As we are migrating it from one system to other, we will make a full
clone.
2. Linked clone: In this mode new differencing disk images are created where the parent
disk images are the source disk images. If you selected the current state of the source
Virtual Machine as clone point, a new snapshot will be created implicitly.
Select full clone and then click clone.
E. Cloning will start. It took around 2-3 minutes. Then a machine is created. You can see
it in the left pane.

3. Locate the .vdi file of the clone machine. you can find it in Virtual Box Vm folder if
you are on windows.

Copy this file in pen drive and then onto new host system.

4. Create new virtual machine as if you are creating a normal machine, until you see this
step to choose the disk.
In this step, choose the option to use an existing virtual hard disk. Select the .vdi file.
Rest steps are same as if you creating a standard virtual machine. A new machine is
present in the left pane now. Run it. Migrated machine is working.
EXPERIMENT 3
AIM: CloudSim: Installing CloudSim and creating a datacenter with one host and
running one cloudlet.

HARDWARE REQUIREMENTS: Desktop/ Laptop System with Windows operating


system

SOFTWARE REQUIREMENTS: MyEclipse2015

THEORY:
The primary objective of CloudSim 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.
Main Features:
• support for modeling and simulation of large scale Cloud computing data centers
• support for modeling and simulation of virtualized server hosts, with
customizable policies for provisioning host resources to virtual machines
• support for modeling and simulation of energy-aware computational resources
• support for modeling and simulation of data center network topologies and
message-passing applications
• support for modeling and simulation of federated clouds
• support for dynamic insertion of simulation elements, stop and resume of
simulation
• support for user-defined policies for allocation of hosts to virtual machines and
policies for allocation of host resources to virtual machines

PROCEDURE:
(A) INSTALL CLOUD SIM

Step 1- Download CloudSim zip folder from the link given below. After downloading,
unzip the folder.
https://code.google.com/archive/p/cloudsim/downloads
Step 2: Download Apache Commons Math 3.6.1 from the link given below. After
downloading, unzip the folder.

Step 3: Open MyEclipse. Here I have used the version MyEclipse2015


Step 4: Create a new Java project from File > New > Java Project

Step 5: Enter a project name in the window. Also, choose an appropriate version of JRE.
Click on Finish.
Step 6: Right click on your project name and click on export. Select General and then,
file system. Locate your unzipped folder CloudSim 3.0.3. Select all files and click on
Finish.

Step 7: Next, import the common-maths file in the jars folder of our project using the
same steps used above.
Step 8: Now, right click on the project and select properties. Goto Java Build Path >
Libraries > Add jars and select the common-maths jar file imported in step 7.
This ends our CloudSim installation.

(B) RUNNING SAMPLE EXAMPLE

Here, we will run CloudSimExample1.java.


Step 1: Click on your project.
Step 2: Navigate to examples.
Step 3: Select CloudSimExample1.java
Step 4: Click on run.
OUTPUT:
EXPERIMENT 4

AIM: CloudSim: Creating two datacenters with one host each and running one
cloudlet on it.

HARDWARE REQUIREMENTS: Desktop/ Laptop System with Windows operating


system

SOFTWARE REQUIREMENTS: MyEclipse2015

THEORY:
VIRTUAL MACHINE- A virtual machine (VM) is an emulation of a particular
computer system. Virtual machines operate based on the computer architecture and
functions of a real or hypothetical computer and their implementations may involve
specialized hardware, software, or a combination of both.

CLOUDLET- A cloudlet can be viewed as a "data center in a box" whose goal is to


"bring the cloud closer". A cloudlet has four key attributes:
• only soft state: It is does not have any hard state, but may contain cached
state from the cloud. The avoidance of hard state means that each cloudlet
adds close to zero management burden after installation: it is entirely self-
managing.
• powerful, well-connected and safe: It possesses sufficient compute power
(i.e., CPU, RAM, etc.) to offload resource-intensive computations from one or
more mobile devices. It has excellent connectivity to the cloud (typically a
wired Internet connection) and is not limited by finite battery life (i.e., it is
plugged into a power outlet).
• close at hand: It is logically proximate to the associated mobile devices.
"Logical proximity" is defined as low end-to-end latency and high bandwidth
(e.g., one-hop Wi-Fi). Often, logical proximity implies physical proximity.
However, because of "last mile" effects, the inverse may not be true: physical
proximity may not imply logical proximity.
• builds on standard cloud technology: It encapsulates offload code from
mobile devices in virtual machines (VMs), and thus resembles classic cloud
infrastructure such as Amazon EC2 and OpenStack. In addition, each cloudlet
has functionality that is specific to its cloudlet role.

PROCEDURE:
Step 1: Open CloudSimExample2.java
Step 2: Create two virtual machines and four cloudlets in the source code.
Step 3: Click on Run once build completes.
//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);

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

//add the cloudlets to the list


cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);
cloudletList.add(cloudlet3);
cloudletList.add(cloudlet4);

//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 V
OUTPUT:
EXPERIMENT – 5
AIM
Implementing Time Shared and Space Shared Algorithms in CloudSim and comparing
them.

HARDWARE REQUIREMENTS
Desktop/ Laptop System with Windows 7 operating system

SOFTWARE REQUIREMENTS
NetBeans

THEORY
Let us take two VM’s VM1 and VM2 that will execute 8 tasks t1, t2, t3, t4, t5, t6, t7 and
t8. Suppose tasks t1, t2, t3 and t4 are going to be executed by VM VM1 and tasks t5, t6,
t7 and t8 will be executed by VM VM2. Then the various possibilities for their execution
will be:
1. Both VM’s and Tasks will be Space Shared
2. VM’s will be Space Shared and Tasks will be Time Shared
3. VM’s will be Time Shared and Tasks will be Space Shared
4. Both VM’s and Tasks will be Time Shared
PROCEDURE
1. Open CloudSimExample2.java
2. Create two virtual machines and four cloudlets in the source code.
3. Import the following package:
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
4. Change the virtual machine definition to:
Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
cloudletSchedulerSpaceShared());
5. Click on Run once build completes.

SOURCE CODE
A. Changes made for Time shared
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());
vmlist.add(vm1);
vmlist.add(vm2);
broker.submitVmList(vmlist);

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

cloudletList.add(cloudlet1);
cloudletList.add(cloudlet2);
cloudletList.add(cloudlet3);
cloudletList.add(cloudlet4);

broker.submitCloudletList(cloudletList);

B. Changes made for Space shared


import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;

Vm vm1 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerSpaceShared());
Vm vm2 = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerSpaceShared());

OUTPUT
I. TIME SHARED
II. SPACE SHARED
EXPERIMENT 6
AIM: Assigning priority to cloudlets in Cloudsim.

HARDWARE REQUIREMENTS: Desktop/ Laptop System with Windows operating


system

SOFTWARE REQUIREMENTS: MyEclipse2015

THEORY

Prioritizing cloudlets that help to more efficiently prioritize access to origin


infrastructure. By slowing down the number of concurrent users, it can effectively
be ensured that origin infrastructure is not overwhelmed during peak periods. The
idea is straightforward: each process is assigned a priority, and priority is allowed
to run.

PROCEDURE

Step 1: Create a new customized class to assign priority to cloudlets


NewCloudlet.java

package org.cloudbus.cloudsim.examples;

import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.UtilizationModel;

public class NewCloudlet extends Cloudlet {

private int cloudlet_priority=0;

public NewCloudlet(int cloudletId, long cloudletLength, int pesNumber, long


cloudletFileSize,
long cloudletOutputSize, UtilizationModel utilizationModelCpu,
UtilizationModel utilizationModelRam,
UtilizationModel utilizationModelBw) {
super(cloudletId, cloudletLength, pesNumber, cloudletFileSize,
cloudletOutputSize, utilizationModelCpu,
utilizationModelRam, utilizationModelBw);
// TODO Auto-generated constructor stub
}

public NewCloudlet(int cloudletId, long cloudletLength, int pesNumber, long


cloudletFileSize, long cloudletOutputSize, UtilizationModel utilizationModelCpu,
UtilizationModel utilizationModelRam, UtilizationModel utilizationModelBw, int
priority) {
super(cloudletId, cloudletLength, pesNumber, cloudletFileSize,
cloudletOutputSize, utilizationModelCpu, utilizationModelRam,
utilizationModelBw);
this.cloudlet_priority = priority;
}

public int getCloudlet_priority() {


return cloudlet_priority;
}

public void setCloudlet_priority(int cloudlet_priority) {


this.cloudlet_priority = cloudlet_priority;
}
}

Step 2: Import the class created in Step 1 to CloudSimExample8.java

Step 3: Add the following code to schedule cloudlets on the basis of priority in the
class GlobalBroker. Make changes in the other classes as well.

public class CloudSimExample8 {

/** The cloudlet list. */

private static List<NewCloudlet> cloudletList;

private static List<NewCloudlet> createNewCloudlet(int userId, int


cloudlets, int idShift){
// Creates a container to store Cloudlets
LinkedList<NewCloudlet> list = new LinkedList<NewCloudlet>();

//cloudlet parameters
int priority = 1;
UtilizationModel utilizationModel = new UtilizationModelFull();

NewCloudlet[] cloudlet = new NewCloudlet[cloudlets];

for(int i=0;i<cloudlets;i++){
cloudlet[i] = new NewCloudlet(idShift + i, length,
pesNumber, fileSize, outputSize, utilizationModel, utilizationModel,
utilizationModel, priority);
// setting the owner of these Cloudlets
cloudlet[i].setUserId(userId);
list.add(cloudlet[i]);
priority++;
}
return list;
}
public static void main(String[] args) {

cloudletList = createNewCloudlet(brokerId, 10, 0); //


creating 10 cloudlets

// Final step: Print results when simulation is over


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

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" + indent + "Priority");

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())+ indent + cloudlet.getCloudlet_priority() );
}
}

}
public static class GlobalBroker extends SimEntity {

private static final int CREATE_BROKER = 0;


private List<Vm> vmList;
private List<NewCloudlet> cloudletList;

setCloudletList(createNewCloudlet(getBroker().getId(), 10, 100)); //


creating 10 cloudlets
List<NewCloudlet> list1 = getCloudletList();
NewCloudlet temp = null;
int i=0;
//boolean changed = true;
while(i<9) {
// changed = false;
for(int j=i+1; j<10; j++) {

if((list1.get(j).getCloudlet_priority())>(list1.get(i).getCloudlet_priority())) {
temp= list1.get(j);
list1.set(j,list1.get(i));
list1.set(i, temp);
temp= null;
}
}
i++;
}
setCloudletList(list1);
for(i= 0;i<list1.size();i++){
Log.printLine(getCloudletList().get(i).getCloudlet_priority());
}

public List<NewCloudlet> getCloudletList() {


return cloudletList;
}

protected void setCloudletList(List<NewCloudlet> cloudletList) {


this.cloudletList = cloudletList;
}

OUTPUT:
EXPERIMENT 8

AIM: To deploy an application on Google App Engine.

HARDWARE REQUIREMENTS: Desktop/ Laptop System with Linux operating


system

SOFTWARE REQUIREMENTS: Google Engine, Google Cloud SDK

THEORY:
Google App Engine (often referred to as GAE or simply App Engine) is a platform as
a service (PaaS) cloud computing platform for developing and hosting web
applications in Google-managed data centers. Applications are sandboxed and run
across multiple servers. App Engine offers automatic scaling for web applications—
as the number of requests increases for an application, App Engine automatically
allocates more resources for the web application to handle the additional demand.
Google App Engine is free up to a certain level of consumed resources. Fees are
charged for additional storage, bandwidth, or instance hours required by the
application. It was first released as a preview version in April 2008 and came out of
preview in September 2011.

PROCEDURE:
Step 1: Follow the link: https://appengine.google.com and sign up for an account.
Step 2: Next, head over to (Google Developers Console)

https://console.cloud.google.com/project. This page will display all your existing


projects.
Step 3: Click on “Create Project” and enter a project name. I have created project
with the name “cloud-computing-lab”. Note the application ID (project ID) of the
project created.

Step 4: In the following steps, we will be deploying a python app that displays
“Hello, World!” on google app engine. We start with downloading the App Engine
SDK for Python and follow the installation steps.
To install on Linux:
1. Unzip the App Engine SDK file you downloaded
(google_appengine_1.9.36.zip), for example:
unzip google_appengine_1.9.36.zip
2. Add the google_appengine directory to your PATH:
export PATH=$PATH:/path/to/google_appengine/
3. Make sure Python 2.7 is installed on your machine using the following
command:
/usr/bin/env python –V

Step 5: Next, we will test our helloworld application before deploying on the cloud.
For this navigate to your directory from the terminal and enter the following
command.
dev_appserver.py helloworld/
Step 6: The web server is now running, listening for requests on port 8080. Visit
http://localhost:8080/ in web browser to see the app in action.

Step 7: Intialize gcloud to use the project created above. This can be done by
following the command below:
gcloud init
Step 8: Upload your application to Google App Engine by invoking the following
command from inside the helloworld directory.
gcloud preview app deploy
Step 9: Head to http://<YOUR_PROJECT_ID_>.appspot.com/ to see your helloworld

app in action.

You might also like