Distributed Systems Distributed Algorithms 1
Brendan Tangney
Distributed Systems(Distributed Algorithms – A Problem Based Learning Approach)
Distributed Systems Distributed Algorithms 2
Topics
Some Problems Some Solutions
Why Are Distributed Algorithms Difficult
The End to End Argument
Naming
File Systems
Historical Perspective on “Distributed Operating Systems”
Distributed Systems Distributed Algorithms 3
Spot The Difference
Distributed Systems Distributed Algorithms 4
Reaching Agreement(The Two Generals Problem) The leaders of 2 armies need to agree upon the time to
attack the castle. They will take it iff they attack together.
The communicate by sending messengers. Messengers can get shot! Design a protocol that will ensure they attack at the
same time!
Distributed Systems Distributed Algorithms 5
The Solution
Distributed Systems Distributed Algorithms 6
Load Balancing
Perform “load balancing” on an intranet of workstations.
Solutions to be presented in class on Wednesday.
Distributed Systems Distributed Algorithms 7
Two Classic Distributed Algorithms
Distributed Systems Distributed Algorithms 8
LAN Media Access Protocols
In ring and tree topology local area networks there is more than one point of access to the media, i.e. there is no one point of control.
But allocation of network bandwidth to nodes must be fair.
How does the token ring protocol control access to the medium?
How does the Ethernet (CSMA/CD) algorithm do it?
Distributed Systems Distributed Algorithms 9
Insight:The Token Passing Mutual Exclusion Algorithm maps easily onto a ring topology with the physical wiring giving the ordering between nodes.
A special frame called a "token" is passed from station to station. Possession of the token constitutes permission to transmit. Sender sizes the token and sends a data packet to the desired destination
address (DA). DA copies the packet and fills in Frame Status byte of frame to indicate ok/error.
Packet is removed by the sender and the token sent on. Very simple access algorithm. Distributed Pessimistic.
Token Ring Access Protocol
Distributed Systems Distributed Algorithms 10
Token Passing
Distributed Systems Distributed Algorithms 11
Errors can occur during operation which would cause the token algorithm to break down.
E.g. a continuously circulating packet can be caused by i) the demise of a node which sent the data packet,ii) noise flipping the T bit.
Error Handling
Distributed Systems Distributed Algorithms 12
The Monitor
One station on the ring is designated to be the ACTIVE MONITOR.
The Monitor sets the M bit in each data frame as it goes by. Stations clear the M bit when they transmit a frame. If a frame arrives at the monitor with the M bit set it must be an
error. Monitor removes the frame. The monitor injects a new token into the ring whenever it detects
the absence of one.
Centralised Algorithm. Moderately Complex. Not invoked too frequently.
Distributed Systems Distributed Algorithms 13
The Monitor is now a single point of failure.
Need a dynamic distributed algorithm for detecting and recovering from Monitor loss.
Monitor Failure
Distributed Systems Distributed Algorithms 14
Monitor Election
Stations may detect a missing monitor via timeouts. The monitor sends out periodic AMP frames.
On detecting the absence of the active monitor nodes elect a new active monitor.
The election algorithm is based on nodes sending Claim Token frames claiming to be the new active monitor but deferring to nodes with higher addresses. (It is not a fair algorithm). Distributed Algorithm. Not fair (highest node always wins).
There is also another protocol for nodes entering the ring to ensure that their own address is unique on the ring and to determine their upstream neighbours’s address (UNA).
Distributed Systems Distributed Algorithms 15
More Complexity ELECTION ALGORITHM
The CT frame contains the node’s own address and that of its Upstream Neighbour (UNA). On receipt of a CT frame a node checks the value of SA and UNA in the frame. IF SA /UNA match its own THEN
it takes over AM functionsELSE IF SA < itself THEN
continue to claim the token ELSE
give up Station with the highest address that is competing to become the new active monitor will take over.
Active Monitor and UNA When the new Monitor sends an AMP frame it sets the A bit to 0 The first station receiving it (the downstream neighbor) records the SA
Sets A and C bits to 1 before repeating the frame
The station knows it immediate upstream neighbor address The A bit equal to 1 informs the other stations that the arriving frame is not from their immediate neighbor After receiving an AMP frame from its upstream neighbor (Monitor)
The station sends and SMP frame with A=0 Its downstream neighbor receives the frame
Record the SA and sets A and C bits to 1
This procedure allows each station to learn its upstream neighbor ‘s address
Network Disruption If a node breaks down, or the ring is broken, one station on the ring will detect garbage or silence on it's input. It transmits a management frame known as a "Beacon". This is addressed to all nodes, and contains the address of its up-stream neighbour (UNA). This enables fault detection.
Distributed Systems Distributed Algorithms 16
Complexity and Frequency of Use of Token Ring Sub-algorithms
Complexity
Frequencyof useMedia
AccessAlgorithm
TokenLoss
MonitorLoss
Fair Not Fair
Distributed Systems Distributed Algorithms 17
Distributed Systems Distributed Algorithms 18
Carrier Sense, Multiple Access, Collision Detect
Origin:University of Hawaii.
Insights:Network is mostly idle. Optimistic approach. Allow simultaneous transmission on the network (should happen rarely) and include a protocol to tidy up when the assumption is wrong.Use of randomness!
Distributed Systems Distributed Algorithms 19
CSMA/CDA B C
A B C
A B C
A B C
A b e g in s txC s ti ll se e s id le n 'w
C b e g in tx
c o llis io n !!n o t n o tic e d b y tx -e rs y e t
n o tic e d b y C
A B Cju s t in c a se th e c o ll is io n is n o tn o tic e d b y B - C tx a ja m
B se e s J a m - re je c ts c u rre n t f ra m e
A a lso tra n sm its a J a m
Distributed Systems Distributed Algorithms 20
When a station has data to transmit
1. If medium idle, transmit.
2. If busy, listen until quiet - then transmit.
3. While transmitting listen to the network. If garbage then a collision has occurred. Transmit a jamming signal (collision enforcement).
4. Wait a random amount of time (backoff) and restart at step 1.
CSMA/CD
Distributed Systems Distributed Algorithms 21
The algorithm used for step 4 is as follow.Attempts := 0; OK := TX(Frame)While (NOT OK) AND (Attempts < Attempt Limit)
K : = Min (Attempts, Backoff Limit)
R : = Random (0, 2k-1)delay : = R * SlotTime; Wait (delay)Attempts++; OK := TX(Frame)
End This algorithm yields a "statistical fairness" in the sharing
of bandwidth. Attempt Limit is 16 and Backoff Limit 10.
Backoff
Distributed Systems Distributed Algorithms 22
Behaviour In The Face Of Failure?
Node failure ? Passive Active
Cable break ?
No centralised points of control=> a very robust algorithm.
Distributed Systems Distributed Algorithms 23
Comparison
CSMA/CD Optimistic. Optimised for
the frequent case of one node transmitting. Complex backoff protocol if incorrect.
Robust in the face of failure.
No overhead in collision free cases.
Use of randomness for distributed control
Token Passing Pessimistic. Assumes
simultaneous transmission and prevents it occurring.
Simple access protocol. Complexity needed to handle failure.
Always incurs a modest overhead on transmission.
Use of token for centralised control.