DC Prac
DC Prac
TCP vs UDP:
Server listens for connections, and accept establishes a new connection for each
client, allowing dedicated communication.
Socket Types
Domains:
o UNIX Domain: For local communication.
o Internet Domain: For network communication.
Types:
o Stream Sockets: Use TCP, reliable and continuous data stream.
o Datagram Sockets: Use UDP, unreliable and message-based communication
ASSIGNMENT 2:
RMI (Remote Method Invocation) allows a Java program to invoke methods on an object
located on a remote server, enabling distributed computing. RMI handles communication,
remote object creation, and garbage collection.
1. Remote Interface: Defines the methods a remote object can invoke. It extends
java.rmi.Remote and declares methods that throw RemoteException.
2. Remote Implementation Class: Implements the remote interface. It extends
UnicastRemoteObject, providing the actual logic for remote methods that clients can
call.
The rmic tool, or RMI compiler, generates stub and skeleton classes for remote
objects. The stub acts as a proxy on the client side, forwarding method calls to the
remote server. The skeleton on the server side receives these calls, processes them,
and sends the results back to the client (skeletons are needed in pre-Java 2 versions).
The RMI registry is a simple directory service where remote objects are registered by
name. It allows clients to look up and retrieve remote object references, which they
can use to invoke methods on the server. This registry simplifies discovering and
connecting to remote objects in a distributed environment.
Assignment 3
1)
Transparency:
o Syntactic Transparency: RPC and LPC have the same syntax.
o Semantic Transparency: RPC and LPC have the same meaning.
Elements of RPC:
RPC Process:
Stub Generation:
Marshalling/Unmarshalling:
RPC allows remote execution of procedures with minimal client-side changes, handling
network communication transparently.
rpcgen is a tool used to generate client and server stubs from an Interface Definition
Language (IDL) specification. It automatically creates the necessary code for handling RPC
communication.
Packing: The process of encoding data (arguments and results) into a format suitable for
transmission.
Unpacking: The process of decoding the received message to extract the original data
(arguments and results).
ASSIGNMENT 4
Lamport's Clock:
Clock Skew: The difference in time between two clocks in a distributed system at any given
moment.
Clock Drift: The gradual deviation or inconsistency of a clock over time, causing it to differ
from the correct time or another clock.
Logical Clock to Physical Clock: You cannot directly convert a logical clock to a physical clock
because logical clocks only order events, while physical clocks represent real-world time. To
synchronize physical clocks, protocols like NTP (Network Time Protocol) are used.
A happened-before event is a causal relationship between two events, where one event
causally affects the other. If Event A happens before Event B, then the timestamp of A will be
less than that of B in Lamport's clock.
ASSIGNMENT 5
The Bully Algorithm is used in distributed systems for electing a coordinator (leader). It
ensures that the process with the highest ID becomes the coordinator. The algorithm works as
follows:
When a process notices that the coordinator has failed, it initiates an election.
The process with the highest ID wins the election and becomes the new coordinator.
1. Election Message: Sent by a process to initiate an election when it detects the coordinator
has failed.
2. Reply/Response Message: Sent by a process in response to the election message, either
acknowledging or passing the election to a higher-ID process.
3. Coordinator Message: Sent by the elected coordinator to inform all other processes of the
new coordinator's ID.
Best Case: O(1) (if the initiator is the highest-ID process and no messages are needed).
Average Case: O(n) (if most processes are involved in the election).
Worst Case: O(n) (involves sending messages to all other processes in the system).
The name “Bully” comes from the way the algorithm works: the process with the highest ID
"bullies" or forces others to accept it as the coordinator by dominating the election process.
ASSIGNMENT 6
NFS allows remote file access, making remote files appear local.
1. Server:
o Install and configure NFS.
o Edit /etc/exports to share directories.
o Run exportfs -a and start NFS server with systemctl start nfs-server.
2. Client:
o Install NFS client.
o Create a mount point (mkdir /mnt/nfs).
o Mount remote directory: mount -t nfs <server_ip>:/remote_dir
/mnt/nfs.
1) Mounting: The process of linking a remote or local file system to a directory in the existing
file system, making it accessible.
o Example: mount /dev/sda1 /mnt/usb
2) Unmounting: The process of removing a mounted file system, making it no longer accessible.
o Example: umount /mnt/usb
SMB (Server Message Block): Used for file and printer sharing in Windows networks.
FTP (File Transfer Protocol): Used for transferring files over a network.
AFP (Apple Filing Protocol): Used in macOS for file sharing.
CIFS (Common Internet File System): A version of SMB for cross-platform file sharing.
Cloud Computing:
Virtualization:
Virtualization is the creation of virtual versions of physical resources, like servers, storage, or
networks, allowing multiple virtual instances to run on a single physical system.
VMware is a virtualization platform that creates and manages virtual machines (VMs) on
physical hardware. It uses a hypervisor (software layer) to allocate physical resources to
multiple VMs, each running its own operating system independently.
1. Types of Virtualization:
2. VMware Applications:
The specific cloud computing example is chosen to highlight the flexibility and scalability
of cloud services, where users can access resources like storage, computing power, and
applications over the internet, reducing the need for on-premises infrastructure and enabling
efficient resource management.
Public Cloud: Cloud services provided over the internet by third-party providers (e.g., AWS,
Azure) accessible to anyone.
Private Cloud: Cloud infrastructure dedicated to a single organization, either on-premises or
hosted by a third party.
Distributed Computing involves multiple computers working together on tasks, while Cloud
Computing leverages distributed computing principles to provide scalable, on-demand
resources over the internet.
ASSIGNMENT 9
1. Cluster of Machines:
2. Grid of Machines:
Scientific Simulations: Running complex simulations in fields like physics, chemistry, and
biology.
Data Processing: Handling large datasets in fields like big data analytics and machine
learning.
High-Performance Computing (HPC): For tasks requiring significant computational power,
like weather forecasting and simulations.
ASSIGNMENT 10
Cloud services offer on-demand access to computing resources over the internet:
1. What is AWS?
Public Cloud: Cloud services offered by third-party providers to the general public (e.g., AWS,
Google Cloud).
Private Cloud: Cloud infrastructure dedicated to a single organization.