unit 3
unit 3
unit 3
An application layer protocol defines how the application processes running on different systems,
pass the messages to each other.
o DNS is a directory service that provides a mapping between the name of a host on the
network and its numerical address.
o DNS is required for the functioning of the internet.
o Each node in a tree has a domain name, and a full domain name is a sequence of symbols
specified by dots.
o DNS is a service that translates the domain name into IP addresses. This allows the users of
networks to utilize user-friendly names when looking for other hosts instead of remembering
the IP addresses.
o For example, suppose the FTP site at EduSoft had an IP address of 132.147.165.50, most
people would reach this site by specifying ftp.EduSoft.com. Therefore, the domain name is
more reliable than IP address.
DNS is a TCP/IP protocol used on different platforms. The domain name space is divided into three
different sections: generic domains, country domains, and inverse domain.
Generic Domains
o Each node in a tree defines the domain name, which is an index to the DNS database.
o It uses three-character labels, and these labels describe the organization type.
Label Description
The format of country domain is same as a generic domain, but it uses two-character country
abbreviations (e.g., us for the United States) in place of three character organizational abbreviations.
Inverse Domain
The inverse domain is used for mapping an address to a name. When the server has received a
request from the client, and the server contains the files of only authorized clients. To determine
whether the client is on the authorized list or not, it sends a query to the DNS server and ask for
mapping an address to the name.
Working of DNS
o DNS is a client/server network communication protocol. DNS clients send requests to the.
server while DNS servers send responses to the client.
o Client requests contain a name which is converted into an IP address known as a forward
DNS lookups while requests containing an IP address which is converted into a name known
as reverse DNS lookups.
o DNS implements a distributed database to store the name of all the hosts available on the
internet.
o If a client like a web browser sends a request containing a hostname, then a piece of
software such as DNS resolver sends a request to the DNS server to obtain the IP address of
a hostname. If DNS server does not contain the IP address associated with a hostname, then
it forwards the request to another DNS server. If IP address has arrived at the resolver, which
in turn completes the request over the internet protocol.
2. Events
In distributed systems, events refer to any significant action that occurs within a
process, such as sending or receiving a message, updating a variable, or initiating a
computation. Events are discrete points in time and serve as key markers for ordering
and synchronization.
Types of Events:
o Internal Events: These are events that happen within a single process and
don’t involve interaction with other processes, such as updating local data or
executing a computation.
o External Events: These involve interaction between processes, such as
sending and receiving messages. External events are critical for coordinating
across nodes and often trigger updates to logical clocks.
Event Ordering:
o Causal Ordering: Events are causally ordered if one event influences or
depends on another. For instance, if event A on node 1 causes event B on
node 2, then event A should appear before event B in the causal order. Causal
ordering is tracked using logical clocks.
o Concurrent Events: Events are considered concurrent if they have no causal
relationship, meaning they happen independently. With vector clocks,
concurrency can be detected when neither clock vector is “less than” the
other.
3. Process States
Process State: The process state is the complete set of information that describes a
process at a specific point in time, including its variables, data structures, and other
resources it is holding. A process's state can change over time as it processes internal
events or interacts with other processes.
In distributed systems, the states of individual processes, when combined, represent
the system's global state at a particular moment. However, capturing a global state is
challenging because processes operate asynchronously and there is no instant way to
collect all process states at once.
Capturing Process States and Global State
Snapshots: To capture a global state, snapshot algorithms like the Chandy-Lamport
algorithm record process states and message histories in a way that respects
causality. Snapshots help in understanding the distributed system's behavior and are
essential for debugging, rollback, and fault tolerance.
Consistent Cuts: A consistent cut is a subset of all events and process states that do
not violate causality. For example, if one process’s state reflects receiving a message,
the sender’s state should reflect having sent it. Consistent cuts help create a
coherent snapshot of the system state at any point in time.
States in Fault Tolerance and Recovery
Checkpointing: This is the process of saving the state of a process at regular intervals,
so in the case of a failure, the system can roll back to a known good state.
Checkpointing is essential for fault tolerance and is often combined with snapshot
techniques to ensure that the saved states across processes are consistent.
Event Logs: Systems may also log events to support replaying operations from a
certain point, which aids in recovery and debugging. Event logs help maintain a
sequence of actions that can reconstruct a process’s state at any historical point.
Key Interrelationships
Clocks and Events: Clocks help order events, which is crucial for establishing causality
in distributed systems.
Events and Process States: Events alter process states, so tracking events allows us to
understand how process states evolve over time.
Global State and Consistent Cut: Global state is an aggregate of all process states at a
given time. Consistent cuts ensure a logically coherent global state by tracking
process state changes and message transfers.
In summary, clocks provide a means to order events, events signify changes within or
between processes, and process states reflect the current configuration of a process.
Together, these components help maintain coordination and consistency in distributed
systems.
As the distributed systems has its own clocks. The time among the clocks may also vary. So,
it is possible to synchronize all the clocks in distributed environment.
Types of Clock Synchronization
Physical clock synchronization
Logical clock synchronization
Mutual exclusion synchronization
Physical Synchronization:
In physical clock synchronization, All the computers will have their own clocks.
The physical clocks are needed to adjust the time of nodes. All the nodes in the
system can share their local time with all other nodes in the system.
The time will be set based on UTC (Universal Coordinate Timer).
The time difference between the two computers is known as “Time drift”. Clock drifts
over the time is known as “Skew”. Synchronization is necessary here.
Physical clocks: In physical synchronization, physical clocks are used to time stamp an event
on that computer.
If two events, E1 and E2, having different time stamps t1 and t2, the order of the event
occurring will be considered and not on the exact time or the day at which they are occur.
Several methods are used to attempt the synchronization of the physical clocks in
Distributed synchronization:
1. UTC (Universal coordinate timer)
2. Christian’s algorithm
3. Berkely’s algorithm
UTO - Mean solar time on Greenwich meridian, Obtained from astronomical observation.
UT1 - UTO corrected for polar motion.
UT2 - UT1 corrected for seasonal variations in earth’s rotation.
UTC - Civil time will be measured on an atomic scale.
Christian’s Algorithm:
The simplest algorithm for setting time, it issues a remote procedure call (RPC) to the
time sever and obtains the time.
The machine which send requests to the time server is “d/z” seconds, where d is the
maximum difference between the clock and the UTC.
The time server sends the reply with current UTC when receives the request from the
receiver.
Overview
We start by addressing the question of why process need to coordinate their actions and
agree on values in various scenarios.
1. Consider a mission critical application that requires several computers to
communicate and decide whether to proceed with or abort a mission. Clearly, all
must come to agreement about the fate of the mission.
2. Consider the Berkeley algorithm for time synchronization. One of the participate
computers serves as the coordinator. Suppose that coordinator fails. The remaining
computers must elect a new coordinator.
3. Broadcast networks like Ethernet and wireless must agree on which nodes can send
at any given time. If they do not agree, the result is a collision and no message is
transmitted successfully.
4. Like other broadcast networks, sensor networks face the challenging of agreeing
which nodes will send at any given time. In addition, many sensor network
algorithms require that nodes elect coordinators that take on a server-like
responsibility. Choosing these nodes is particularly challenging in sensor networks
because of the battery constraints of the nodes.
5. Many applications, such as banking, require that nodes coordinate their access of a
shared resource. For example, a bank balance should only be accessed and updated
by one computer at a time.
Mutual Exclusion
The first set of coordination algorithms we'll consider deal with mutual exclusion. How can
we ensure that two (or more) processes do not access a shared resource simultaneously?
This problem comes up in the OS domain and is addressed by negotiating with shared
objects (locks). In a distributed system, nodes must negotiate via message passing.
Each of the following algorithms attempt to ensure the following:
Safety: At most one process may execute in the critical section (CS) at a time.
Liveness: Requests to enter and exit the critical section eventually succeed.
Causal ordering: If one request to enter the CS happened-before another, then entry
to the CS is granted in that order.
Central Server
The first algorithm uses a central server to manage access to the shared resource. To enter a
critical section, a process sends a request to the server. The server behaves as follows:
If no one is in a critical section, the server returns a token. When the process exits
the critical section, the token is returned to the server.
If someone already has the token, the request is queued.
Requests are serviced in FIFO order.
If no failures occur, this algorithm ensures safety and liveness. However, ordering is not
preserved (why?). The central server is also a bottleneck and a single point of failure.
Token Ring
The token ring algorithm arranges processes in a logical ring. A token is passed clockwise
around the ring. When a process receives the token it can enter its critical section. If it does
not need to enter a critical section, it immediately passes the token to the next process.
This algorithm also achieves safety and liveness, but not ordering, in the case when no
failures occur. However, a significant amount of bandwidth is used because the token is
passed continuously even when no process needs to enter a CS.
Multicast and Logical Clocks
Each process has a unique identifier and maintains a logical clock. A process can be in one of
three states: released, waiting, or held. When a process wants to enter a CS it does the
following:
sets its state to waiting
sends a message to all other processes containing its ID and timestamp
once all other processes respond, it can enter the CS
When a message is received from another process, it does the following:
if the receiver process state is held, the message is queued
if the receiver process state is waiting and the timestamp of the message is after the
local timestamp, the message is queued (if the timestamps are the same, the process
ID is used to order messages)
else - reply immediately
When a process exits a CS, it does the following:
sets its state to released
replies to queued requests
This algorithm provides safety, liveness, and ordering. However, it cannot deal with failure
and has problems of scale.
None of the algorithms discussed are appropriate for a system in which failures may occur. In
order to handle this situation, we would need to first detect that a failure has occurred and
then reorganize the processes (e.g., form a new token ring) and reinitialize appropriate state
(e.g., create a new token).
Election
An election algorithm determines which process will play the role of coordinator or server.
All processes need to agree on the selected process. Any process can start an election, for
example if it notices that the previous coordinator has failed. The requirements of an
election algorithm are as follows:
Safety: Only one process is chosen -- the one with the largest identifying value. The
value could be load, uptime, a random number, etc.
Liveness: All process eventually choose a winner or crash.
Ring-based
Processes are arranged in a logical ring. A process starts an election by placing its ID and
value in a message and sending the message to its neighbor. When a message is received, a
process does the following:
If the value is greater that its own, it saves the ID and forwards the value to its
neighbor.
Else if its own value is greater and the it has not yet participated in the election, it
replaces the ID with its own, the value with its own, and forwards the message.
Else if it has already participated it discards the message.
If a process receives its own ID and value, it knows it has been elected. It then sends
an elected message to its neighbor.
When an elected message is received, it is forwarded to the next neighbor.
Safety is guaranteed - only one value can be largest and make it all the way through the ring.
Liveness is guaranteed if there are no failures. However, the algorithm does not work if there
are failures.
Bully
The bully algorithm can deal with crash failures, but not communication failures. When a
process notices that the coordinator has failed, it sends an election message to all higher-
numbered processes. If no one replies, it declares itself the coordinator and sends a new
coordinator message to all processes. If someone replies, it does nothing else. When a
process receives an election message from a lower-numbered process it returns a reply and
starts an election. This algorithm guarantees safety and liveness and can deal with crash
failures.
Consensus
All of the previous algorithms are examples of the consensus problem: how can we get all
processes to agree on a state? Here, we look at when the consensus problem is solvable.
The system model considers a collection of processes pi (i = 1, 2, ..., N). Communication is
reliable, but processes may fail. Failures may be crash failures or byzantine failures.
The goals of consensus are as follows:
Termination: Every correct process eventually decides on a value.
Agreement: All processes agree on a value.
Integrity: If all correct processes propose the same value, that value is the one
selected.
We consider the Byzantine Generals problem. A set of generals must agree on whether to
attack or retreat. Commanders can be treacherous (faulty). This is similar to consensus, but
differs in that a single process proposes a value that the others must agree on. The
requirements are:
Termination: All correct processes eventually decide on a value.
Agreement: All correct processes agree on a value.
Integrity: If the commander is correct, all correct processes agree on what the
commander proposed.
If communication is unreliable, consensus is impossible. Remember the blue army discussion
from the second lecture period. With reliable communication, we can solve consensus in a
synchronous system with crash failures.
We can solve Byzantine Generals in a synchronous system as long as less than 1/3 of the
processes fail. The commander sends the command to all of the generals and each general
sends the command to all other generals. If each correct process chooses the majority of all
commands, the requirements are met. Note that the requirements do not specify that the
processes must detect that the commander is fault.
It is impossible to guarantee consensus in an asynchronous system, even in the presence of
1 crash failure. That means that we can design systems that reach consensus most of the
time, but cannot guarantee that they will reach consensus every time. Techniques for
reaching consensus in an asynchronous system include the following:
Masking faults - Hide failures by using persistent storage to store state and restarting
processes when they crash.
Failure detectors - Treat an unresponsive process (that may still be alive) as failed.
Randomization - Use randomized behavior to confuse byzantine processes.