aggrement protocol

Upload: priya-dharmapandian

Post on 05-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Aggrement Protocol

    1/16

    1

    Agreement Protocols Examples

    Agreeing whether to commit or to abort a transactionin a distributed database management system.

    Agreeing on a common clock value in a distributedsystem.

    In the absence of failures or faulty processors,values (that is to be decided) can be exchanged. Avote can be taken and decision/agreement can bemade based on: majority, minimum vote, mean,

    etc. Presence of failure: processors can fail or

    misbehave intentionally. Several rounds ofmessage exchanges might be needed before

    agreement can be reached.

  • 8/2/2019 Aggrement Protocol

    2/16

    2

    System Model n processors in the system with at most m of

    them being faulty. Processors can exchange messages directly (no

    need to go through another processor). Receiver knows the identity of the sender. Communication medium is reliable: messages are

    delivered without errors.

  • 8/2/2019 Aggrement Protocol

    3/16

    3

    Synchronous Computation Processes run in lock step manner, or in rounds. In each step/round i, processes receive messages

    that were sent in the previous step/round i-1. Processes then do some computation and send out

    messages, that will be received in step/round i+1. Message delays or a slow processor slows down

    the whole system. Agreement protocols to be discussed assume

    synchronous computation. Asynchronous computation: A process can send,

    receive, and perform computation at any time.

  • 8/2/2019 Aggrement Protocol

    4/16

    4

    Other Assumptions/Models Processor can fail in 3 modes:

    Crash fault: functioning stops (timeouts can be used). Omission fault: a processor forgets or omits actions,

    e.g., misses to send a message to 2 out of 5 processors. Malicious fault: a processor can send fictitious

    messages or modify values in a message, intentionally.Also called Byzantine faults.

    Type of messages: Authenticated messages: a faulty processor cannot

    modify a message. Non-authenticated messages: messages can be modify.

  • 8/2/2019 Aggrement Protocol

    5/16

    5

    Types of Agreement Problems Byzantine Agreement Problem

    A single value is to be agreed upon. Initial value to be proposed by an arbitrary processor:

    all non-faulty processors need to agree on that value.

    Consensus Problem Every processor has its own initial value. All non-faulty processors agree on a common value.

    Interactive Consistency Problem

    Every processor has its own initial value. All non-faulty processors agree on a setof common

    values (or) a vector.

    Above three types are closely related. Byzantine agreementproblem forms the basis of other 2 types. We focus on

    Byzantine agreement.

  • 8/2/2019 Aggrement Protocol

    6/16

    6

    Byzantine Agreement Problem An arbitrary source processor broadcasts its

    initial value to all others. If the source processor is faulty, other non-

    faulty processor can agree on anycommon value. Faulty processors values and agreements do not

    matter. If faulty processors are in majority, then non-

    faulty processors cannot reach an agreement. Number of faulty processors, m, cannot exceed:

    trunc[(n-1)/3]. This bound can be relaxed for systems using

    authenticated messages.

  • 8/2/2019 Aggrement Protocol

    7/167

    Impossible Scenario Consider a system with 3 processors: p0, p1, p2. Two possibilities:

    Case 1: p0 (source) is not faulty. p2 is faulty. p1 shouldagree upon 1 as the value. Not possible.

    Case 2: p0 is faulty. p1 may agree on 1 and p2 on 0.

    p0

    p1 p2

    1 11

    0

    Case 1:

    p2

    p1 p0

    1 1

    0

    0

    Case 2:

  • 8/2/2019 Aggrement Protocol

    8/168

    Lamports Algorithm

    Referred to as Oral Message Algorithm: OM(m),m > 0. For 3m + 1 or more processors of which m are

    faulty.

    Recursive Algorithm: Algorithm OM(0)

    Source processor sends its value to every processor. Each processor uses the value it receives from

    source. (If no value received, default value of 0assumed).

  • 8/2/2019 Aggrement Protocol

    9/16

    Lamports Algorithm Algorithm OM(m), m > 0

    Source processor sends its value to every processor. For each processor, let vibe the value received by

    processor i(from the source). Processor i acts asnew source. Initiates OM(m-1). Sends vito each ofother n-2processors.

    Let vjbe the value received by Pifrom Pjin abovestep. (If no value received, vjis assumed to be 0). Piuses majority (v1, v2, ..vn-1).

    9

  • 8/2/2019 Aggrement Protocol

    10/1610

    Lamports Algorithm ... Processors are successively divided into smaller

    groups in step 2 where OM(m-1) is executed. Step 3 is executed during the folding phases of

    recursion where a majorityfunction selects the

    agreed value (among those received in step 2). Note: majorityreturns 0 if one does not exist. Number of messages:

    OM(m) : n- 1 executions of OM(m-1)

    OM(m-1): n-2 executions of OM(m-2).... (n-1)(n-2)(n-3)... (n-k) executions of OM(m-k), k =

    1,2,3,...,m+1. Message complexity: O(n power m).

  • 8/2/2019 Aggrement Protocol

    11/1611

    Lamports Algorithm: Example 1

    System with 4 processors: p0, p1, p2, p3. p0 is source, p2 isfaulty. Assumption: possible values are only 1 and 0. Step 1: p0 initiates the initial value to be 1. (Algorithm

    OM(1), m =1). Step 2: OM(0). p1 sends 1 to {p2, p3}. p3 sends 1 to {p1,p2} p2 (the faulty one) sends 1 to p1 and 0 to p3. Step 3: majority function at p1 and p3 is 1, which is the

    desired result. (Not bothered about p2, the faulty one).p0

    p1 p2

    1 1

    p3

    1

    p0

    p1 p2

    1 1

    p3

    11

    11

    0

    1

    1

  • 8/2/2019 Aggrement Protocol

    12/1612

    Lamports Algorithm: Example 2

    System with 4 processors: p0, p1, p2, p3. p0 is source, and isfaulty. Assumption: possible values are only 1 and 0. Step 1: p0 initiates the initial value to be 1 for p1 and p3. For

    p2, it sends a 0(Algorithm OM(1), m =1). Step 2: OM(0). p1 sends 1 to {p2, p3}. p3 sends 1 to {p1,p2} p2 sends 0 to p1 and p3. Step 3: majority function at p1, p2, p3 is still the same (1),

    which is the desired result.p0

    p1

    1

    0p3

    11

    1

    0

    1

    1

    p2

    0

  • 8/2/2019 Aggrement Protocol

    13/1613

    Fault-tolerant Clock Sync

    Synchronizing distributed clocks: At any time, values of clocks of all non-faulty processes

    must be approximately equal. There is a small bound on amount by which the clock of

    a non-faulty process is changed during re-synchronization.

    Assumptions: A1: All clocks are synchronized to approximately the same

    values. A2: A nonfaulty processs clock run at approximately the

    same rate. (No such assumptions about faulty clocks).

    A3: A nonfaulty process can read the clock value of anothernonfaulty process with at most a small error .

  • 8/2/2019 Aggrement Protocol

    14/1614

    Interactive Convergence

    Each process reads the values of others clocks and sets itsclock to the average of these values. If a clock value differs from its own clock by more than , it

    replaces that by its clock for taking average. (Takes care offaulty clocks).

    Example: Let 2 processes p and q, use Cpr and Cqr as clockvalues of a 3rd process r.

    If r is nonfaulty, then Cpr = Cqr. If r is faulty, then |Cpr -Cqr| 3m, this difference [(3m/n) ] is always less than .

  • 8/2/2019 Aggrement Protocol

    15/1615

    Interactive Convergence ...

    Assumptions: All processes execute the algorithm simultaneously. Error in reading another processs clock is 0.

    This problem (with the assumptions) can be marginalized to acertain extent by: Rather than using absolute clock values, compute the

    average of difference in clock values. Increment local value by this average. Clock differences > , are replaced by 0.

    Added assumption: A nonfaulty process can read thedifference between the clock value of another nonfaultyprocess, and its own with at most a small error of .

    If the clock reading error is , difference in clock valuesread by a process can be as large as + . Clock differences

    larger than + are replaced by 0, while computing theaverage increment.

  • 8/2/2019 Aggrement Protocol

    16/1616

    Interactive Consistency

    Improvements: Median of clock values rather than the mean. More strict conditions for clock reading:

    Any 2 processes obtain approximately the same valuefor a process ps clock.

    Every nonfaulty process obtains approximately thecorrect value of another nonfaulty processs clock.

    If majority of the processes are nonfaulty, median of allclock values is either approximately equal to a good clocksvalue (or) lies between the values of 2 good clocks.