103
Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks. CPSC 661 Distributed Algorithms Abhishek Gaurav Alok Madhukar

Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

  • Upload
    rocio

  • View
    35

  • Download
    0

Embed Size (px)

DESCRIPTION

Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks. CPSC 661 Distributed Algorithms Abhishek Gaurav Alok Madhukar. Part 1: Leader Election Algorithms for Wireless Ad Hoc Networks. What is a mobile ad hoc network? Use of Leader election in mobile systems - PowerPoint PPT Presentation

Citation preview

Page 1: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks.

CPSC 661 Distributed Algorithms

Abhishek Gaurav

Alok Madhukar

Page 2: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Part 1: Leader Election Algorithms for Wireless Ad Hoc Networks

- What is a mobile ad hoc network?- Use of Leader election in mobile systems- Challenges in making algorithms for mobile ad hoc

network.- Model and Assumptions- Earlier Algorithms- Overview of Leader Election Algorithm- The Algorithm- Conclusion

Page 3: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Wireless Networks – Operating Modes

Infrastructure Mode

Ad Hoc Mode

Page 4: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Wireless Ad Hoc Networks - Characteristics

- Wireless

- Highly Mobile

- No Access Points/Infrastructure

- All nodes are peers

- All nodes are routers

- Network is formed dynamically

Page 5: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Wireless Ad Hoc Networks - Routing

Alok

Ian

Page 6: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Wireless Ad Hoc Networks - Routing

Alok

Ian

Gabriel

Page 7: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Wireless Ad Hoc Networks - Routing

Alok

Ian

Abhishek

Gabriel

Lisa

Page 8: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Use of Leader Election in Mobile Systems

- Useful building block when failures are frequent- Lost Token in Mutual Exclusion- Group Communication Protocols- New Coordinator when Group Membership

changes

Page 9: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Challenges in making Algorithms for Wireless Ad Hoc Networks

- Communication link – function of position, transmission power levels, antenna patterns, co-channel reference levels, etc.

- Frequent and unpredictable Topological Changes- Congested Links

Page 10: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

New Definition Vs Classical Definition

- Classical Definition

1. Eventually there is a leader with termination detection

2. There should never be more than one leader

- New Definition

1. Any component whose topology is static sufficiently long will eventually have a leader with termination detection

2. There should never be more than one leader for any given component

Page 11: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Basic Ideas

- Leader-Oriented DAG

- Partition from Leader

- Merging of Components

- Multiple Topology Changes

Page 12: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

System Model

- N independent mobile nodes

- Message passing over wireless network

- Network – dynamically changing, not necessarily connected, a graph with nodes as vertices and edges between nodes that can communicate

Page 13: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Assumptions on System Model

- Nodes have unique node identifiers

- Communication links are bidirectional, reliable, FIFO

- Link level protocol: aware of the neighbors

- One Topological change at a time

Page 14: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Problem Statement

- For every connected component C of the topology graph, there is a node l in C, s.t. lid

i

= l for each node i in C.

- Eventually, each connected component is a directed acyclic graph with the leader as the single sink (leader-oriented DAG)

Page 15: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Existing Algorithms

- Shortest Path and Adaptive Shortest Path Algorithms- Designed for static and quasi-static hard-wired links- Do not react fast enough to maintain routing- Only 1 path for routing between any source/destination pair

- Link State Algorithms- Maintain multiple path for routing- Time and communication overhead associated with maintaining

full topological knowledge at each router makes them impractical

Page 16: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Introduction of Link Reversal Routing - Objectives

- Executes in a distributed environment- Provides loop-free routes- Provides multiple routes (to alleviate congestion)- Establishes routes quickly- Minimize communication overhead by localizing

algorithmic reaction to topological changes when possible

Page 17: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Link Reversal Routing (LRR) - Approach

- LRR Algorithms maintain only distributed state information sufficient to constitute an Directed Acyclic Graph (DAG), rooted at the destination

- Maintenance of a distributed DAG is desirable, as it guarantees loop-freedom and can provide participating nodes with multiple, redundant routes to the destination

- Route maintenance is triggered when a node i loses the link to its last downstream neighbor

Page 18: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Basis

- Gafni – Bertsekas Algorithm [1]: 1981- Temporally Ordered Routing Algorithm

(TORA) [2]: 1997

Page 19: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Oriented DAG

fig. A Leader Oriented DAG

Height2

Height1

Reference2

Reference1

Height2 > Height1

Reference2 > Reference1

Page 20: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview

fig. C is in trouble (It has no outgoing link)

A

BC

D

E

Page 21: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. C becomes originator of a new higher reference level

A

B

C

D

E

Page 22: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. E is in trouble and sees that neighbors have different levels

A

B

C

D

E

Page 23: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. E goes to new reference level and selects height just below C

A

B

C

D

E

Page 24: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. Link from C to E is not reversed, but link from D to E is reversed

A

B

C

D

E

Page 25: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. D in trouble

A

B

C

D

E

Page 26: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. D goes to new reference level and selects height just below E

A

B

C

D

E

Page 27: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. Links C to D and E to D are intact but A to D reverse

A

B

C

D

E

Everyone is happy

Page 28: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. Link Break disconnects the component from leader

A

B

C

D

E

Alas!!

Page 29: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. B is in trouble since it has lost all outgoing links

A

B

C

D

E

Page 30: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. B selects new height in new (highest) reference level

A

B

C

D

E

Page 31: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. A is in trouble

A

B

C

D

E

A sees something different !! – All neighbors are in higher level

Page 32: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. A creates higher sublevel within the new sub-level

A

B

C

D

E

{φ}

Page 33: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. All links to A are reversed

A

B

C

D

E

{φ}

Page 34: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. Higher Sub-level is reflected back to C (originator)

A

B

C

D

E

C knows that there is no route to the leader

Page 35: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. C elects itself the leader and propagates the message

A

B

C

D

E

All nodes adjust their height w.r.t. leader

Page 36: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Leader Election Algorithm - An Overview (cont’d…)

fig. The separated component becomes a leader-oriented DAG

A

B

C

D

E

Everyone is happy again

Page 37: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Node Height in LE

The height of node i is an ordered six-tuple (lidi, τi, oidi, ri, δi, i)

- lidi: id of the node believed to be the leader of i’s component

- τi: the “logical time” of link failure, defining a new reference level

- oidi: the unique id of the node that defined the reference level

- ri: a bit used to divide each of the unique reference levels into two unique sub-levels – reflected and unreflected

- δi: a “propagation” ordering parameter

- i: the unique id of the node

(τi, oidi, ri) represents the reference level and (δi, i) represents the “delta” or offset w.r.t. reference level.

The reference level (-1,-1,-1) is used by the leader of a component to ensure that it is a sink.

Page 38: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm

Node i: - Each step is triggered either by the notification of the failure or

formation of an incident link or by the receipt of a message from a neighbor.

- Local variable Ni: to store its neighbors' ids. When an incident link fails, i updates Ni. When an incident link forms, i updates Ni and sends an Update message over the link with its current height.

- The only kind of message sent is an Update message, which contains the sender's height.

- At the end of each step, if i's height has changed, then it sends an Update message with the new height to all its neighbors.

Page 39: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm (cont’d…)

A. When node i has no outgoing links due to a link failure:

1. if node i has no incoming links as well then

2. lidi := i

3. (τi, oidi, ri) := (-1,-1,-1)

4. δi := 0

5. else

6. (τi, oidi, ri) := (t, i, 0) // t is the current time

7. δi := 0

Page 40: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm (cont’d…)

B. When node i has no outgoing links due to a link reversal following reception of an Update message and the reference levels (τj, oidj, rj) are not equal for all j є Ni:

(τi, oidi, ri) := max{(τj, oidj, rj) I j є Ni)

δi := min{δj I j є Ni and (τj, oidj, rj) = (τi, oidi, ri)} - 1

Page 41: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm (cont’d…)

C. When node i has no outgoing links due to a link reversal following reception of an Update message and the reference levels (τj, oidj, rj) are equal with rj = 0 for all j є Ni:

1. (τi, oidi, ri) := (τj, oidj, rj) for any j є Ni)

2. δi := 0

Page 42: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm (cont’d…)

D. When node i has no outgoing links due to a link reversal following reception of an Update message and the reference levels (τj, oidj, rj) are equal with rj = 1 for all j є Ni:

1. lidi = i

2. (τi, oidi, ri) := (-1, -1, -1)

3. δi := 0

Page 43: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

The Algorithm (cont’d…)

E. When node i receives an Update message from neighboring node j such that lidi ≠ lidj

1. if lidi > lidj or (oidi = lidj and ri = 1) then

2. lidi = lidj

3. (τi, oidi, ri) := (0, 0, 0)

4. δi := δj + 1

Page 44: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example

(A, -1, -1, -1, 0, A) (F, 2, A, 1, -1, D)

(F, 2, A, 1, 0, B)

(F, 0, 0, 0, 1, E)

(F, -1, -1, -1, 0, F)

(F, 0, 0, 0, 1, H)

(F, 0, 0, 0, 2, G)

fig.1 Node A detects a partition and elects itself as leader

Page 45: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example (cont’d…)

(A, -1, -1, -1, 0, A) (A, 0, 0, 0, 1, D)

(A, 0, 0, 0, 1, B)

(F, 0, 0, 0, 1, E)

(F, -1, -1, -1, 0, F)

(F, 0, 0, 0, 1, H)

(F, 0, 0, 0, 2, G)

fig.2 Nodes B and D update their heights

Update

Update

Page 46: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example (cont’d…)

(A, -1, -1, -1, 0, A)

(A, 0, 0, 0, 1, D)

(A, 0, 0, 0, 1, B)

(A, 0, 0, 0, 2, E)

(F, -1, -1, -1, 0, F)

(F, 0, 0, 0, 1, H)

(F, 0, 0, 0, 2, G)

fig.3 Nodes B and E detect link formation and node E changes leader

Update

Page 47: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example (cont’d…)

(A, -1, -1, -1, 0, A)

(A, 0, 0, 0, 1, D)

(A, 0, 0, 0, 1, B)

(A, 0, 0, 0, 2, E)

(A, 0, 0, 0, 3, F)

(F, 0, 0, 0, 1, H)

(F, 0, 0, 0, 2, G)

fig.4 Node F propagates leader change

Update

Page 48: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example (cont’d…)

(A, -1, -1, -1, 0, A)

(A, 0, 0, 0, 1, D)

(A, 0, 0, 0, 1, B)

(A, 0, 0, 0, 2, E)

(A, 0, 0, 0, 3, F)

(A, 0, 0, 0, 4, H)

(F, 0, 0, 0, 2, G)

fig.5 Node H propagates leader change

Update

Page 49: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Example (cont’d…)

(A, -1, -1, -1, 0, A)

(A, 0, 0, 0, 1, D)

(A, 0, 0, 0, 1, B)

(A, 0, 0, 0, 2, E)

(A, 0, 0, 0, 3, F)

(A, 0, 0, 0, 4, H)

(A, 0, 0, 0, 5, G)

fig.6 Node G propagates leader change

Update

Page 50: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Proof of Correctness

We believe the proof that each component is a leader – oriented DAG with the assumption of one change at a time can be converted to simple graph-theoretic proof and we are working on it.

Page 51: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Problem

To solve mutual exclusion problem in wireless ad hoc networks,

Nodes communicate with each other by message passing over unreliable communication channels,

No shared objects.

Page 52: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Solution Approach

Solution Approach : Maintaining a token Node having the token enters critical section.

Previous solutions Raymond's algorithm not resilient to link

failures. Chang's solution does not consider link

recovery. Dhamdhere and Kulkarni's solution suffer from

starvation

Page 53: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Mobile Node Architecture

Application Process

RequestCS ReleaseCS

EnterCS

Mutual Exclusion Process

LinkUP Send(m) Recv(m) LinkDown

Network

Page 54: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Notion of HeightEach node maintains a 3-tuple height –

(h1,h2,i)Heights for each node are distinct. The node

identifier i achieves this.Heights are compared lexicographically.Links are logically considered to be directed

from higher height node to lower hieght node. Initially node 0 has (0,0,0) and heights for

other nodes are initialized to form a DAG.

Page 55: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Overview of Algorithm

Algorithm is event-driven,Token-holder node enters the critical

section,The token holder ensures lowest height in

the system,Request for tokens from non-token holding

nodes are directed towards the token-holder.

Page 56: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Data Structures

Each node i maintains :

status N myHeight height[j], j ∈ N tokenHolder

Next Q receivedLI [j] Forming [j] formHeight [j]

Page 57: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Application requests or releases

Application Process

RequestCS ReleaseCS

Mutual Exclusion Process

Network

Page 58: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request for CS

Application Process

I Q

Page 59: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request for CS

Application Process

RequestCS I i Q

Page 60: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request for CS

Application Process

RequestCS I i Q

tokenHolder = False tokenHolder = True

& |Qi| = 1

ForwardRequest() EnterCS

Page 61: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Release the CS

Application Process

I Q

Page 62: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Release the CS

Application Process

ReleaseCS

I ... Q

Page 63: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Release the CS

Application Process

ReleaseCS

I ... Q

|Qi| > 0

GiveTokenToNext()

Page 64: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) message received

Application Process

Mutual Exclusion Process

Recv(m) Request(h)

Network

Page 65: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

I Q

Page 66: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I Q

Page 67: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I Q

ReceivedLI(j) = false ReceivedLI(j) = true

Ignore Update : height[j] = h

Page 68: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I j Q j is higher node

Page 69: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I j Q

tokenHolder = True & ∣Q∣ > 0

& status = Remainder

GiveTokenToNext()

Page 70: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I j Q

tokenHolder = false tokenHolder = True & ∣Q∣ > 0 no links & status = Remainder outgoing GiveTokenToNext() RaiseHeight()

Page 71: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Request (h) msg received

Network

Request (h) from j

I j Q tokenHolder = false tokenHolder = True & ∣Q∣ > 0 Q = [j] & status = Remainder no links ForwardRequest() outgoing GiveTokenToNext() RaiseHeight()

Page 72: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) message received

Application Process

Mutual Exclusion Process

Recv(m) Token(h)

Network

Page 73: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) msg received

Token(h) I Q

J

Page 74: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) msg received

Token(h) I Q J tokenHolder = True ; height[j] = h

Page 75: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) msg received

J myHeight.h1 = h.h1 ; myHeight.h2 - 1

I Q

Page 76: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) msg received

J myHeight.h1 = h.h1 ; myHeight.h2 - 1

I Q

....... LinkInfo()

Page 77: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Token (h) msg received

J myHeight.h1 = h.h1 ; myHeight.h2 - 1

I Q

∣Qi∣ = 0 ∣Q

i∣ > 0

nexti = i GiveTokenToNext()

Page 78: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) message received

Application Process

Mutual Exclusion Process

Recv(m) LinkInfo(h)

Network

Page 79: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

Page 80: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

receivedLI[j] = True

height[j] = h

Page 81: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

receivedLI[j] = True height[j] = h

height[j] = h receivedLI[j] = True

Page 82: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I forming[j] = false

forming[j] is True and

(myHeight ≠ formHeight[j])

LinkInfo(myHeight) to j

Page 83: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

no outgoing links

and tokenHolder = False

height[j] = h

Page 84: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

no outgoing links ∣Qi∣ > 0 and

and tokenHolder = False myHeight < height[next]

height[j] = h ForwardRequest()

Page 85: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure GiveTokenToNext

I calls GiveTokenToNext

I x Q

Page 86: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure GiveTokenToNext

I calls GiveTokenToNext

I Q

next = x

Page 87: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure GiveTokenToNext

I calls GiveTokenToNext

I Q

next = x

next = i

EnterCS

Page 88: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure GiveTokenToNext

I calls GiveTokenToNext I Q

next = x tokenHolder = false;

receivedLI=F next = i next ≠ i height[next] =

(myHeight.h1,

myHeight.h2-1, next)

EnterCS Token (myHeight)

Page 89: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure GiveTokenToNext

I calls GiveTokenToNext

I ..... Q

|Qi| > 0

Request (myHeight)

Page 90: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure ForwardRequest ()

Called when a node i does not hold the token and a request message arrives at i.

Next is set to node i's lowest height neighbor i.e.

next = l ∈ N : height[l] ≤ height[j], ∀ j ∈ N.Send Request(myHeight) to next.

Page 91: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h1 = k+1

h1 = k

Page 92: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h1 = k+1

h1 = k

Page 93: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h2 = m-1

h1 = k+1

h1 = k

Page 94: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Link Failures (link to j detected at i)Ni = Ni – {j}

Delete (Q, j) ; receivedLI[j] = True; If (not tokenHolder) then

If (no outgoing links) then

CallRaiseHeight() ElseIf (( |Qi| > 0 ) and (next ∉ Ni)) then

ForwardRequest () // If next has failed

send a request

Page 95: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Link formation

Node i detects a new link to node j,Send LinkInfo(myHeight) to j,Set forming[j] to True,Set formHeight[j] to myHeight.

Page 96: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Correctness Proof

To Prove : Algorithm ensures mutual exclusion Algorithm does not suffer from starvation : no

node is starved from entering the critical section.

Page 97: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Correctness Proof(Mutual Exclusion)Theorem 1 : The algorithm ensures mutual

exclusion

This is because there exists only one token in the system at any time.

Page 98: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Correctness Proof contd..(No Starvation) To prove no starvation

After link changes cease, the system will reach a “good” configuration.

Variant function is applied to this “good” configuration to show that eventually the node will enter CS

“Good configuration” = Token-Oriented DAG Token-Oriented DAG : If ∀ node i, i ∈ {0,....,n-1}, ∃ a

directed path originating at node i and terminating at token-holder.

Page 99: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Proof SketchLemma1 : In every configuration, a DAG is token oriented iff

there are no sinks.

(Definitioin 1: A node i is sink if (tokenHolderi = false) and

((myHeighti < height

i[j]), for all j ∈ N

i)

+Lemma 2 : In every execution with a finite number of link

changes, there are finite number of calls to RaiseHeight ().

↓Lemma 3 : After link change ceases, the logical direction on links

imparted by height values will eventually form a token oriented DAG.

Page 100: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Proof Sketch contd..Definition 2: A request chain for node l is defined to be the maximal

length list of nodes through which request has passed. p

1= l → p

2 → .... → p

j is a request chain.

pj is either token-holder,

or a Token messageis in transit to pj,

or a Request message is in transit from pj to next

pj,

or a LinkInfo message is in transit from pj to

nextpj

Lemma 4: Once link changes and calls to RaiseHeight() cease, if a node l's request chain does not include a token holder, then eventually l's request chain will include the token holder.

Page 101: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Proof Sketch contd..

Definition 3: A function Vl for l is defined to be a vector of integers

<v1, v

2,...> having m or m+1 elements such that v

1 is position of

p1 in Q

p1, and for 1 < j ≤ m, v

j is the position of p

j-1 in Q

pj. If a

request message is in transit then vm+1

= n+1.

Lemma 5: Vl is a variant function; When V

l equals <1>, l enters CS.

Vl never has more than n entries.

Request and Token messages decrease Vl

Theorem 2: When Vl equals <1>, l enters CS.

Page 102: Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

References

[1] E. Gafni and D. Bertsekas, “Distributed algorithms for generating loop-free routes in networks with frequently changing topology,” IEEE Transactions on Communications, C-29(1):11-18 , 1981.

[2] Vincent D. Park and M. Scott Corson, “A Highly Adaptive Distributed Routing Algorithm for Mobile Wireless Networks,” Proc. IEEE INFOCOM, April 7-11, 1997.

[3] N. Malpani, J.L. Welch, N. Vaidya, “Leader Election Algorithms for Mobile Ad Hoc Networks,” Proc. of the 4th International Workshop on Discrete Algorithms and Methods for Mobile Computing and Communications, August 2000

[4] J. E. Walter, J. L. Welch, and N. H. Vaidya, “A Mutual Exclusion Algorithm for Ad Hoc Mobile Networks,” ACM and Baltzer Wireless Networks journal, special issue on DialM papers, 2001.

[5] J.E. Walter, G. Cao, M. Mohanty, “A K-Mutual Exclusion Algorithm for Wireless Ad Hoc Networks,” POMC 2001, Newport Rhode Island, USA