Leader Election and Mutual Exclusion Algorithms for Wireless Ad Hoc Networks

Preview:

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

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- Challenges in making algorithms for mobile ad hoc

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

Wireless Networks – Operating Modes

Infrastructure Mode

Ad Hoc Mode

Wireless Ad Hoc Networks - Characteristics

- Wireless

- Highly Mobile

- No Access Points/Infrastructure

- All nodes are peers

- All nodes are routers

- Network is formed dynamically

Wireless Ad Hoc Networks - Routing

Alok

Ian

Wireless Ad Hoc Networks - Routing

Alok

Ian

Gabriel

Wireless Ad Hoc Networks - Routing

Alok

Ian

Abhishek

Gabriel

Lisa

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

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

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

Basic Ideas

- Leader-Oriented DAG

- Partition from Leader

- Merging of Components

- Multiple Topology Changes

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

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

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)

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

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

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

Basis

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

(TORA) [2]: 1997

Leader Oriented DAG

fig. A Leader Oriented DAG

Height2

Height1

Reference2

Reference1

Height2 > Height1

Reference2 > Reference1

Leader Election Algorithm - An Overview

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

A

BC

D

E

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

fig. C becomes originator of a new higher reference level

A

B

C

D

E

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

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

A

B

C

D

E

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

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

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

fig. D in trouble

A

B

C

D

E

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

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

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

fig. Link Break disconnects the component from leader

A

B

C

D

E

Alas!!

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

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

A

B

C

D

E

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

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

A

B

C

D

E

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

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

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

A

B

C

D

E

{φ}

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

fig. All links to A are reversed

A

B

C

D

E

{φ}

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

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

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

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.

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.

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

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

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

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

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

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

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

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

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

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

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

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.

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.

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

Mobile Node Architecture

Application Process

RequestCS ReleaseCS

EnterCS

Mutual Exclusion Process

LinkUP Send(m) Recv(m) LinkDown

Network

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.

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.

Data Structures

Each node i maintains :

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

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

Application requests or releases

Application Process

RequestCS ReleaseCS

Mutual Exclusion Process

Network

Request for CS

Application Process

I Q

Request for CS

Application Process

RequestCS I i Q

Request for CS

Application Process

RequestCS I i Q

tokenHolder = False tokenHolder = True

& |Qi| = 1

ForwardRequest() EnterCS

Release the CS

Application Process

I Q

Release the CS

Application Process

ReleaseCS

I ... Q

Release the CS

Application Process

ReleaseCS

I ... Q

|Qi| > 0

GiveTokenToNext()

Request (h) message received

Application Process

Mutual Exclusion Process

Recv(m) Request(h)

Network

Request (h) msg received

Network

I Q

Request (h) msg received

Network

Request (h) from j

I Q

Request (h) msg received

Network

Request (h) from j

I Q

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

Ignore Update : height[j] = h

Request (h) msg received

Network

Request (h) from j

I j Q j is higher node

Request (h) msg received

Network

Request (h) from j

I j Q

tokenHolder = True & ∣Q∣ > 0

& status = Remainder

GiveTokenToNext()

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()

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()

Token (h) message received

Application Process

Mutual Exclusion Process

Recv(m) Token(h)

Network

Token (h) msg received

Token(h) I Q

J

Token (h) msg received

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

Token (h) msg received

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

I Q

Token (h) msg received

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

I Q

....... LinkInfo()

Token (h) msg received

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

I Q

∣Qi∣ = 0 ∣Q

i∣ > 0

nexti = i GiveTokenToNext()

LinkInfo (h) message received

Application Process

Mutual Exclusion Process

Recv(m) LinkInfo(h)

Network

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

receivedLI[j] = True

height[j] = h

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

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

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

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I forming[j] = false

forming[j] is True and

(myHeight ≠ formHeight[j])

LinkInfo(myHeight) to j

LinkInfo (h) recvd from j

Network

LinkInfo(h)

I

no outgoing links

and tokenHolder = False

height[j] = h

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()

Procedure GiveTokenToNext

I calls GiveTokenToNext

I x Q

Procedure GiveTokenToNext

I calls GiveTokenToNext

I Q

next = x

Procedure GiveTokenToNext

I calls GiveTokenToNext

I Q

next = x

next = i

EnterCS

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)

Procedure GiveTokenToNext

I calls GiveTokenToNext

I ..... Q

|Qi| > 0

Request (myHeight)

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.

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h1 = k+1

h1 = k

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h1 = k+1

h1 = k

Procedure RaiseHeight()

h2 = m+1

h1 = k+2 h2 = m

h2 = m-1

h1 = k+1

h1 = k

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

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.

Correctness Proof

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

node is starved from entering the critical section.

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.

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.

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.

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.

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.

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

Thank You !gaurav@cpsc.ucalgary.ca

madhukar@cpsc.ucalgary.ca

Recommended