0% found this document useful (0 votes)
5 views

labfile cryptography

0to 9

Uploaded by

yt1300572
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

labfile cryptography

0to 9

Uploaded by

yt1300572
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

1-Install VirtualBox/VMware Workstation with different flavours of

Linux or windows OS on top of windows7 or 8.

1. System Requirements
Before starting, ensure your system meets the following requirements:
• Processor: A 64-bit processor with virtualization support (Intel VT-x or
AMD-V enabled in BIOS).
• RAM: Minimum 8 GB (16 GB or more is recommended for running
multiple VMs).
• Disk Space: Enough free space for the VMs (at least 20 GB per VM is
recommended).

2. Install Virtualization Software


A. VirtualBox
1. Download VirtualBox:
o Go to VirtualBox Downloads and download the latest version for
your OS.
2. Install VirtualBox:
o Run the installer and follow the on-screen instructions.
o Select all default options unless you have specific requirements.
B. VMware Workstation
1. Download VMware Workstation:
o For paid: VMware Workstation Pro.
o For free: VMware Workstation Player.
2. Install VMware:
o Run the installer and follow the on-screen instructions.
o Accept the license agreement and choose installation preferences.
3. Prepare OS ISO Files
• Download the ISO files for the Linux or Windows OS Flavors you want to
install:
o Linux: Ubuntu, Fedora, Debian, etc.
o Windows: Microsoft Windows Download.
• Verify the checksums of the downloaded files for integrity.

4. Create Virtual Machines


A. Using VirtualBox
1. Open VirtualBox and click "New".
2. Enter the name and OS type (e.g., Ubuntu, Windows 10).
3. Allocate resources:
o Memory: Assign RAM (at least 2 GB for Linux, 4 GB for Windows).
o Disk: Create a virtual hard disk (minimum 20 GB recommended).
4. Attach the ISO:
o Go to Settings > Storage, click the CD icon, and select Choose a
disk file to add the ISO.
5. Start the VM:
o Click Start, and the VM will boot from the ISO to begin the OS
installation.
B. Using VMware Workstation
1. Open VMware Workstation and click "Create a New Virtual Machine".
2. Choose installation method:
o Select Installer disc image file (ISO) and browse to your ISO.
3. Configure the VM:
o Allocate resources (RAM, CPU cores, and disk size).
o Customize the hardware as needed.
4. Finish setup and power on the VM:
o The VM will boot from the ISO to start the OS installation.

5. Install the OS
1. Follow the on-screen instructions to install the selected OS in the VM.
2. Configure the OS settings (username, password, time zone, etc.).
3. Install additional tools:
o VirtualBox Guest Additions: Enhances VM performance and
enables features like shared folders.
o VMware Tools: Improves VM performance and integration.

6. Test and Manage VMs


• Start and stop VMs as needed.
• Take snapshots to save the VM state before making changes.
• Manage shared resources (network, storage, clipboard sharing).
2-Install a C compiler in the virtual machine created using virtual
box and execute Simple Programs.

Step 1: Install the OS on VirtualBox


• Boot the Virtual Machine with your chosen OS (Linux or Windows) and
complete the OS installation process.
• Ensure the OS is running properly before proceeding.

Step 2: Install a C Compiler


A. For Linux (Ubuntu/Debian-based distributions)
1. Update Package Lists:
Sudo apt update
2. Install GCC (GNU Compiler Collection):
Sudo apt install gcc -y
3. Verify Installation:
gcc --version
This should display the installed GCC version.
B. For Linux (Fedora/CentOS/RHEL-based distributions)
1. Update Packages:
Sudo dnf update
2. Install GCC:
Sudo dnf install gcc -y
3. Verify Installation:
gcc --version
C. For Windows
1. Install MinGW (Minimalist GNU for Windows):
o Download MinGW from MinGW-w64.
o Run the installer and select the required components (e.g., GCC).
2. Set Up Environment Variables:
o Add the MinGW bin directory (e.g., C:\MinGW\bin) to the PATH
environment variable.
3. Verify Installation: Open Command Prompt and type:
gcc --version

Step 3: Write and Execute a Simple C Program


A. Writing the Program
1. Create a new file named hello.c using a text editor:
nano hello.c
2. Add the following code:
#include <stdio.h>

int main() {
printf("Hello, World!\n");
return 0;
}
3. Save the file (Ctrl+O, Enter, Ctrl+X in nano).
B. Compile the Program
• Use GCC to compile the code:
gcc hello.c -o hello
This will create an executable file named hello.

C. Run the Program


• Execute the compiled program:
./hello
The output should display:
Hello, World!

Step 4: Additional Programs


Try writing more C programs to test different features:
1. Simple Addition Program:
#include <stdio.h>

int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum: %d\n", sum);
return 0;
}
2. Compile and run it as described above.
3- Install Google App Engine. Create hello world app and other
simple web applications using python/java.

Step 1: Prerequisites
1. Install Google Cloud SDK:
o Download the Google Cloud SDK from Google Cloud SDK
Downloads.
o Follow the installation instructions for your operating system
(Windows, macOS, or Linux).
2. Set Up a Google Cloud Account:
o Create an account at Google Cloud Platform.
o Create a new project in the Google Cloud Console.
3. Install a Development Environment:
o For Python: Install Python 3.x and a code editor like VS Code or
PyCharm.
o For Java: Install JDK 8+ and an IDE like IntelliJ IDEA or Eclipse.

Step 2: Install Google App Engine


1. Enable the App Engine API:
o In the Google Cloud Console, go to the APIs & Services page and
enable the "App Engine Admin API."
2. Install App Engine Component:
o Run the following command in your terminal or command prompt:
gcloud components install app-engine-python app-engine-java
o Verify installation:
gcloud components list
Step 3: Create a "Hello World" Application
A. Using Python
1. Create a Project Directory:
mkdir hello-world-python
cd hello-world-python
2. Write the Application Code:
o Create a file named main.py:
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
return "Hello, World!"
3. Create an app.yaml Configuration File:
runtime: python39
entrypoint: gunicorn -b :$PORT main:app
4. Run the Application Locally:
o Install Flask:
pip install flask gunicorn
o Start the local server:
flask run
o Visit http://localhost:5000 to see "Hello, World!"
5. Deploy the Application:
o Run:
gcloud app deploy
o Visit the deployed URL provided by Google Cloud.
B. Using Java
1. Create a Project Directory:
mkdir hello-world-java
cd hello-world-java
2. Write the Application Code:
o Create a HelloWorldServlet.java file:
import java.io.IOException;
import javax.servlet.http.*;

public class HelloWorldServlet extends HttpServlet {


@Override
public void doGet(HttpServletRequest req, HttpServletResponse
resp) throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, World!");
}
}
3. Create a web.xml File:
o Place the following in WEB-INF/web.xml:
<web-app>
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
4. Create an appengine-web.xml File:
o Place the following in WEB-INF/appengine-web.xml:
<appengine-web-app
xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
</appengine-web-app>
5. Deploy the Application:
o Package the app using Maven or Gradle, then deploy:
gcloud app deploy
o Visit the deployed URL.

Step 4: Build More Applications


Examples:
1. Simple Calculator (Python):
o Add routes for addition, subtraction, etc., and take user inputs via
query parameters.
2. To-Do App (Java):
o Use servlets and datastore integration to create a simple to-do list
application.
4-Use GAE launcher to launch the web applications.
The Google App Engine (GAE) Launcher was a GUI tool provided by Google to
manage and deploy applications locally and on the cloud. However, Google
discontinued the GAE Launcher and transitioned to the Google Cloud SDK as
the primary interface for managing GAE projects.
If you still want to use a similar approach to launch your web applications
locally and deploy them to App Engine, you can achieve this using the Cloud
SDK Command-Line Tools. Below is an updated guide:

Step 1: Install Google Cloud SDK


1. Download and install the Google Cloud SDK from the Google Cloud SDK
Downloads page.
2. After installation, initialize the SDK:
gcloud init
o Log in with your Google account.
o Select your project or create a new one.

Step 2: Set Up the Development Environment


1. Create a new directory for your application:
mkdir my-app
cd my-app
For Python Web Application:
• Install Flask (if not already installed):
pip install flask
• Create a main.py file:
from flask import Flask

app = Flask(__name__)
@app.route('/')
def home():
return "Hello, GAE with Cloud SDK!"

if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)
• Create an app.yaml file:
runtime: python39
entrypoint: gunicorn -b :$PORT main:app
For Java Web Application:
• Follow the structure outlined earlier with your HelloWorldServlet.java,
web.xml, and appengine-web.xml files in the correct directories.

Step 3: Run Your Application Locally


The Cloud SDK allows you to simulate the App Engine environment on your
local machine.
1. Install the App Engine components:
gcloud components install app-engine-python app-engine-java
2. Use the dev_appserver.py command to run your app locally:
dev_appserver.py app.yaml
3. Visit the local URL (typically http://localhost:8080) in your browser to see
the running app.

Step 4: Deploy the Application to Google App Engine


1. Deploy the app to Google App Engine:
gcloud app deploy
2. Once deployed, access your app using the provided URL:
https://<your-project-id>.appspot.com

Step 5: Alternatives to the GAE Launcher


Although the GAE Launcher is no longer available, tools like the following can
simplify the development workflow:
1. Cloud Shell:
o Accessible from the Google Cloud Console for managing and
deploying projects directly from your browser.
2. Local IDE Integration:
o Use IDEs like PyCharm or IntelliJ IDEA with Google Cloud plugins
for a GUI-like experience.
5-Simulate a cloud scenario using Cloud Sim and run a
scheduling algorithm that is not present in Cloud Sim.
Simulating a cloud scenario with Cloud Sim and running a custom
scheduling algorithm involves the following steps:

Step 1: Set Up CloudSim


1. Download CloudSim:
o Download the latest version of CloudSim from CloudSim Official
Repository.
o Alternatively, download the ZIP file from its GitHub page.
2. Set Up Development Environment:
o Install Java JDK (8 or higher recommended).
o Install an IDE like Eclipse or IntelliJ IDEA.
o Import the CloudSim project as a Java project into your IDE.

Step 2: Understand CloudSim Architecture


CloudSim provides simulation features for cloud environments,
including:
• DataCenter: Represents the physical data center.
• Host: Represents servers within a data center.
• VM (Virtual Machine): Represents virtual machines allocated to
cloudlets.
• Cloudlet: Represents a task or job executed on a VM.
• Broker: Manages resource allocation.

Step 3: Design and Add a Custom Scheduling Algorithm


CloudSim allows custom scheduling by modifying the DatacenterBroker
class or creating your own scheduling policy.
Example: Custom Round-Robin Scheduling Algorithm
1. Create a Custom Broker:
o Extend the DatacenterBroker class:
import org.cloudbus.cloudsim.brokers.DatacenterBrokerSimple;
import org.cloudbus.cloudsim.core.CloudSim;

import java.util.List;

public class RoundRobinBroker extends DatacenterBrokerSimple {


private int vmIndex = 0;

public RoundRobinBroker(CloudSim simulation) {


super(simulation);
}

@Override
protected void defaultVmMapper(List<Cloudlet> cloudletList) {
for (Cloudlet cloudlet : cloudletList) {
cloudlet.setVm(getVmList().get(vmIndex));
vmIndex = (vmIndex + 1) % getVmList().size(); // Round-
robin
}
}
}
2. Integrate the Custom Broker into Your Simulation:
o Use the custom broker in your main simulation file:
import
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicySimpl
e;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.datacenters.DatacenterSimple;
import org.cloudbus.cloudsim.hosts.HostSimple;
import org.cloudbus.cloudsim.resources.Pe;
import
org.cloudbus.cloudsim.utilizationmodels.UtilizationModelDynamic
;
import org.cloudbus.cloudsim.vms.Vm;
import org.cloudbus.cloudsim.cloudlets.Cloudlet;

import java.util.ArrayList;
import java.util.List;

public class CustomSchedulerSimulation {


public static void main(String[] args) {
CloudSim simulation = new CloudSim();

// Create Datacenter
List<Host> hostList = new ArrayList<>();
// Add hosts
hostList.add(new HostSimple(...));
DatacenterSimple datacenter = new
DatacenterSimple(simulation, hostList, new
VmAllocationPolicySimple());
// Create custom broker
RoundRobinBroker broker = new
RoundRobinBroker(simulation);

// Create VMs
List<Vm> vmList = new ArrayList<>();
vmList.add(new Vm(...));
broker.submitVmList(vmList);

// Create cloudlets
List<Cloudlet> cloudletList = new ArrayList<>();
cloudletList.add(new Cloudlet(...));
broker.submitCloudletList(cloudletList);

// Start simulation
simulation.start();

// Print results
broker.getCloudletFinishedList().forEach(System.out::println);
}
}

Step 4: Compile and Run the Simulation


1. Compile the project in your IDE.
2. Run the main simulation class.
3. Observe how tasks are assigned to VMs using your custom Round-Robin
scheduling algorithm.
Step 5: Analyse Results
After running the simulation:
• Check the execution logs for cloudlet execution times and resource
utilization.
• Export results to a file or use visualization tools for deeper analysis.

Step 6: Advanced Customizations


You can extend the simulation by:
• Implementing other scheduling algorithms (e.g., First-Come-First-Serve,
Priority Scheduling).
• Modifying resource allocation policies.
• Adding network and storage considerations.
6. Find a procedure to transfer the files from one virtual machine
to another virtual machine.
Transferring files between virtual machines (VMs) can be done using
several methods depending on the network setup, operating systems,
and tools available.
Below are step-by-step procedures for different scenarios:

Method 1: Using Shared Folders (Host-Managed)

Applicable When Both VMs Are on the Same Host (e.g.,


VirtualBox/VMware)
1. Enable Shared Folders:
o In VirtualBox:
▪ Open the VM settings.
▪ Go to Shared Folders > Add a Shared Folder.
▪ Choose a folder on the host and set it as shared.
o In VMware:
▪ Open the VM settings.
▪ Go to Options > Shared Folders > Always Enabled.
▪ Add a shared folder.
2. Access Shared Folder:
o In Linux: Mount the shared folder (e.g., /media/sf_shared).
o In Windows: It appears as a network drive under This PC.
3. Copy Files:
o Copy the files to the shared folder, and access them from the
other VM via the shared folder.

Method 2: Using SCP (Secure Copy Protocol)


Applicable When Both VMs Are Networked
1. Ensure SSH Server Is Installed and Running:
o On Linux:
sudo apt install openssh-server -y
sudo systemctl start ssh
o On Windows: Use tools like OpenSSH or install an SSH server.
2. Check Network Connectivity:
o Ensure the VMs are on the same virtual network.
o Find the IP of the destination VM:
ifconfig # Linux
ipconfig # Windows
3. Transfer Files:
o From VM1 to VM2:
scp file.txt username@destination_IP:/path/to/destination
o Example:
scp myfile.txt [email protected]:/home/user/

Method 3: Using Rsync


Efficient for Synchronizing Files Between VMs
1. Install Rsync:
o On Linux:
sudo apt install rsync -y
o On Windows: Use tools like Cygwin or Git Bash.
2. Use Rsync Command:
rsync -avz file.txt username@destination_IP:/path/to/destination

Method 4: Using FTP/SFTP


Applicable When Both VMs Support FTP or SFTP
1. Set Up an FTP/SFTP Server:
o On Linux (Destination VM):
sudo apt install vsftpd -y
sudo systemctl start vsftpd
o On Windows: Install an FTP server like FileZilla Server.
2. Connect to the Server:
o Use an FTP client like FileZilla or command-line tools:
ftp destination_IP
3. Transfer Files:
o Use the client to upload/download files between VMs.

Method 5: Using Cloud Storage (e.g., Google Drive, Dropbox)


Applicable When Both VMs Have Internet Access
1. Upload files from one VM to cloud storage.
2. Download the files on the other VM.

Method 6: Using Netcat


Quick File Transfer Over a Network
1. On Destination VM:
nc -l -p 1234 > received_file.txt
2. On Source VM:
cat file.txt | nc destination_IP 1234

Method 7: Using Samba (Windows-Linux or Linux-Linux)


1. Install Samba on Linux:
sudo apt install samba -y
2. Configure Sharing:
o Edit /etc/samba/smb.conf to define shared directories.
3. Access Share from the Other VM:
o Linux: Use smbclient.
o Windows: Use Network Explorer.
7-Find a procedure to launch virtual machine using trystack
(Online Openstack Demo Version)

Step 1: Sign Up for TryStack


1. Access TryStack:
Visit the TryStack Website.
2. Create an Account:
o Sign up using your email or log in with your existing credentials.
o Ensure that you complete any required verification steps.
3. Log In:
o Once registered, log in to the TryStack dashboard.

Step 2: Access the OpenStack Dashboard


1. After logging in, you'll be directed to the OpenStack Horizon Dashboard,
which provides a GUI for managing OpenStack resources.

Step 3: Configure Project and Quotas


1. Select Project:
o Navigate to the project section (usually named Project or
Instances) in the left-hand menu.
o Each project is allocated specific resources (CPU, RAM, storage).
2. Check Quotas:
o Before launching a VM, ensure that your project has enough
resources for the instance you want to create.

Step 4: Launch a Virtual Machine


1. Go to the Instances Page:
o In the left-hand menu, click Compute > Instances.
2. Click Launch Instance:
o Click the Launch Instance button to start the VM creation wizard.
3. Provide Instance Details:
o Instance Name: Give your VM a name (e.g., MyDemoVM).
o Source: Select the image for your VM:
▪ Choose a pre-configured OS image like Ubuntu, CentOS, or
Windows from the available list.
o Flavor: Choose the hardware configuration (CPU, RAM, disk size)
based on your quota and requirements.
4. Networking:
o Attach your instance to a network. If no network is configured, use
the default network provided by TryStack.
5. Key Pair (Optional):
o Add an SSH key pair for secure access:
▪ If you have an existing key pair, upload it.
▪ If not, generate a new key pair and download the private
key for later use.
6. Security Groups:
o Select a security group to control network access to your instance.
o By default, a security group with basic rules (e.g., SSH and ICMP) is
provided.
7. Launch:
o Click Launch to start the instance.

Step 5: Access Your Virtual Machine


1. Check Instance Status:
o The instance will appear in the Instances list. Wait for its status to
change to Running.
2. Access via Console:
o Click the Console tab for the instance to access it directly via the
web interface.
3. Access via SSH (if an SSH key was added):
o Use the instance’s floating IP (if assigned) to connect:
ssh -i your_key.pem username@floating_ip
o Replace your_key.pem with the path to your private key, username
with the default user (e.g., ubuntu or centos), and floating_ip with
the instance’s public IP.

Step 6: Manage Your Virtual Machine


• Start/Stop/Terminate: Use the dashboard to control the instance's state.
• Resize: Adjust the VM’s flavor if required (subject to quota limits).
• Attach Volumes: Add additional storage volumes as needed.

Step 7: Cleanup
• Terminate instances and release resources when done to avoid
exceeding your quotas.
8-Install Hadoop single node cluster and run simple
applications like wordcount.
Installing a Hadoop single-node cluster and running a simple application
like WordCount involves several steps. Below is the detailed procedure:

Step 1: Prepare Your System


1. System Requirements:
o At least 4 GB of RAM.
o Java 8 or higher installed.
2. Install Java:
sudo apt update
sudo apt install openjdk-8-jdk -y
java -version
3. Download Hadoop:
o Visit the Hadoop Downloads page and download the latest stable
version.
o Example (Hadoop 3.x):
wget https://downloads.apache.org/hadoop/common/hadoop-
3.3.5/hadoop-3.3.5.tar.gz
tar -xvzf hadoop-3.3.5.tar.gz
sudo mv hadoop-3.3.5 /usr/local/hadoop

Step 2: Configure Hadoop


1. Set Environment Variables: Add the following lines to ~/.bashrc:
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Reload the .bashrc file:


source ~/.bashrc
2. Edit Configuration Files:
o core-site.xml ($HADOOP_HOME/etc/hadoop/core-site.xml):
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
hdfs-site.xml ($HADOOP_HOME/etc/hadoop/hdfs-site.xml):
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///usr/local/hadoop/hdfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///usr/local/hadoop/hdfs/datanode</value>
</property>
</configuration>
mapred-site.xml ($HADOOP_HOME/etc/hadoop/mapred-
site.xml): Copy and rename mapred-site.xml.template to mapred-
site.xml and add:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
yarn-site.xml ($HADOOP_HOME/etc/hadoop/yarn-site.xml):
<configuration>
<property>
<name>yarn.nodemanager.aux -services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>

Step 3: Format HDFS and Start Hadoop


1. Format the Name Node:
hdfs namenode -format
2. Start Hadoop Services:
start-dfs.sh
start-yarn.sh
3. Verify Services:
o Open your browser and check:
▪ NameNode: http://localhost:9870
▪ ResourceManager: http://localhost:8088

Step 4: Run WordCount Example


1. Create Input Directory in HDFS:
hdfs dfs -mkdir -p /user/input
2. Add Input File to HDFS:
o Create a local file named input.txt with sample text:
echo "Hello Hadoop Hello World" > input.txt
o Copy it to HDFS:
hdfs dfs -put input.txt /user/input
3. Run WordCount Application:
o Use the prebuilt WordCount jar file included with Hadoop:
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-
mapreduce-examples-*.jar wordcount /user/input /user/output
4. View the Output:
o Check the output directory in HDFS:
hdfs dfs -ls /user/output
o View the results:
hdfs dfs -cat /user/output/part-r-00000

Expected Output
For the sample text Hello Hadoop Hello World, the output might look
like:
Hadoop 1
Hello 2
World 1

Step 5: Stop Hadoop Services


After completing your tasks, stop Hadoop services:
stop-dfs.sh
stop-yarn.sh

You might also like