Open In App

Wave and Traversal Algorithm in Distributed System

Improve
Improve
Like Article
Like
Save
Share
Report

As we know a distributed system is a collection where different processes in order to perform a task communicate with each other. In wave algorithm exchange of messages and decision take place, which depends on the number of messages in each event of a process. As it is important to traverse in a connected network Wave algorithm has applications in many fields such as Distributed Databases, Wireless Networks, etc.  

Notation

  • Computations(C) in a process is denoted ICI
  • Any subset of the process(p) in computation(C) is denoted Cp.
  • The set of all processes is denoted by P’,
  • The set of channels by E.
  • The node from where the process starts is called Initiators or starters.
  • Any Non-initiators node in a network called followers.
  • The event of an initiator is to send an event
  • The event of a non-initiator has received the event.

Wave Algorithm

Message Passing Schemes (Algorithms) are called wave algorithms in means asynchronous message passing no global clock or time.

A wave algorithm exchanges finite number of messages and then makes a decision which depends casually on some event in each process.

An Algorithm that satisfies the three requirements is considered as a Wave Algorithm in a distributed algorithm:

  • Termination: Each computation is finite.
    • ∀C : lC| < ∞
  • Decision: Each computation contains at least one decision event.
    • ∀C: ∃e ∈ C: e is a decisive event.
  • Dependence: In each computation, each decided event is casually preceded by an event in each process.
    • ∀C: ∀e ∈ C : (e is a decide event ⇒ ∀q ∈ P’ ∃f ∈Cq: f ≥ e).

A wave algorithm starts from a particular process and the wave propagates to its neighbors, and neighbors propagate to their neighbors, and so on. When there are no further nodes to propagate wave returns back.

Sample Demonstration of Propagation of Wave

The strength of the Wave Algorithm lies in the asynchronous Communication where there is an equivalence lies between the casual and message chains. In wave algorithms, the existence of message chains is required for the computation of causal dependency. Wave algorithms can differ from each other on the basis of the following properties:

  • Centralization: algorithm differs from each other if they have one initiator or more than one initiator.
    • An algorithm has exactly one initiator in each computation is called centralized,
    • If the algorithm can be started spontaneously by an arbitrary subset of the processes called decentralized.
  • Initial Knowledge: An algorithm differs from one another if they have initial knowledge in the processes.
    • Process Identity: Each process has its unique name.
    • Neighbor Identity: Each process knows his neighbor’s name.
  • Complexity: The complexity of the algorithm considers
    • the number of exchanged messages
    • the number of exchanged bits,
    • the time needed for one computation.
  • Topology: An algorithm may be designed for a specific topology such as ring, tree, clique, etc.
  • Number of decisions: Normally one decision occurs in each process. In some algorithms only one process may execute decide event whereas in some algorithms all processes decide. The tree algorithm cause a decision in exactly two processes.

Properties of waves:

  • Each event in computation is preceded by an event in an initiator.
  • A wave algorithm for arbitrary networks without initial knowledge of the neighbor’s identities. Then algorithm exchanges at least lEI messages in each computation.

Since propagation of packets is done by the wave network of nodes and it can be treated as partial order relation, 

Now, Consider a binary relation ≤* by x ≤* y ⇐⇒ (x * y) = x, i.e.; in the relation ≤* is a partial order on X, i.e., that this relation is transitive, antisymmetric, and reflexive.

  • Transitivity:  We know x≤ y and y≤ z then x≤ z, Assume x ≤* y and y ≤* z; by definition of ≤*, (x*y) = x and (y*z) = y. Using these and associativity we find (x * z) = (x * y) * z = x * (y * z) = x * y = x, i.e., x ≤* z.
  • Antisymmetry: Assume x ≤* y and y ≤* x; by definition of ≤*, x * y = x and y * x = y. Using these and commutativity we find x = y.
  • Reflexivity:  x * x = x, i.e., x ≤* x, the reflexive property can be proved using idempotency.

Since it satisfies all three properties hence we conclude wave algorithm can be treated as the Partial order relation.

Different Wave Algorithm

  • Ring algorithm
  • Polling algorithm
  • Tree algorithm
  • Echo algorithm
  • Phase algorithm
  • Finn’s algorithm

The Ring Algorithm

The channel for the propagation of the process is selected such that it forms a Hamiltonian cycle(all the nodes traversed). In other words, the process (p) and its neighbor (Nextp) is given such that channels selected in this way form a Hamiltonian cycle(all the nodes traversed).

  • It has only one initiator.
  • Each other node passes the message forward.
  • Ring Algorithm is Centralized.
  • The initiator is the deciding node.
For initiator-
begin
send (tok) to Nextp;
receive (tok);
decide;
end
Ring algorithm for non initiator-
begin
receive (tok);
send (tok) to Nextp;
end

The Polling Algorithm

The algorithm will send out a wave that will reach all the nodes and will come back to the originator and when the wave is subsided then the algorithm will terminate.

  • It works on a clique network.
  • It has only one initiator.
  • Polling Algorithm is Centralized.
  • The initiator is the deciding node.

In the polling algorithm, the initiator asks each neighbor to reply with a message and decides after receipt of all messages.

Polling algorithm for Initiator-

var recp: integer init 0;
begin
for all q Neighp
do send (tok)to qf;
while recp<#Neighp do
begin
receive(tok);
recp:= recp + 1;
end
decide
end
// here recp is used as a count variable
Polling algorithm for non Initiator-
begin
receive (tok)from qf;
send (tok) to q;
end

Polling can also be used in a star network in which the initiator is the center.

Note: Wave Algorithm used for all of the fundamental tasks i.e., broadcasting, synchronization, and computing global functions.

The Tree Algorithm

Characteristics of algorithm are as follows:

  • Non centralized wave algorithm for (1) tree network (2) arbitrary network if a spanning tree is available.
  • If a process has received a message via each of incident channel except one, the process sends a message via remaining channel.
  • More than one process may decide.
  • The tree algorithm causes a decision in exactly two process.
Tree Algorithm:

Boolean rec {q} for each q ϵ Neigh
Begin while ≠ {q: recp {q} is false > 1 do
Begin receive <tok> from q : recp [q] = true
End
Send <tok> to q0
Receive <tok> from q0
Recp [q0] = true decide
For all q . Neigh send <tok> to q
End

 Example:

In the tree network shown, there are two process that receives a message via each of their channel and decide. The other processes are still waiting for message with their program counter pointing at x in the terminal configuration.

Tree-algorithm

Tree algorithm

we get rec1(12) = True; rec5(6) = true; rec3(4) = true; rec9(7) = true; rec9(8) = true; rec10(12) = true; rec11(12) = true;

Because the node 1,3,5,7,8,10,11 are terminal node

rec13(12) = true because node 12 sends a message to node 13(as it has received a message via each of its incident channels except one that is (13). Node receives message from each of its incident channel (2,4,6,9) except 13.

The Echo Algorithm

The characteristics of this algorithm are:

  • Centralized wave algorithm for network of arbitrary topology.
  • First notice that wave with one initiator defines as spanning tree take the parent channel to be one through which the first message is received.
  • Initiator send the message to all its neighbor
  • Upon receipt of the first message a non-initiative forward message to all its Neighbour except the one from which the message was received.
  • When the initiator has received echo message from all its Neighbour it decides.
Echo algorithm for initiator:

Begin for all q.neigh do
Send <tok> to q;
While receivesp < Neighp do
Begin receives <tok> ; recp = recp+1 end;
End
Decide
End
Echo algorithm for non-initiators:

Begin receives <tok> from neighbour q ;
Father = q
recp = recp + 1
for all q ϵ neighp : q ≭ fatherp do
Send <tok> to q
While recp < ≭ Neighp do
Begin receives <tok>p
recp = recp + 1
End
Send <tok> to fatherp
End

The Phase Algorithm

It is a decentralized algorithm for network of arbitrary topology.

This can be used as wave algorithm for directed networks.

The algorithm requires that the process know the diameter D of the network.

The algorithm is also correct if the process uses instead of D, a constant D larger than the network diameter. Thus, in order to apply this algorithm, it is not necessary that diameter is known exactly, it suffices if the upper (i.e., N-1) on the network diameter is known.

As it can be used in arbitrary, directed networks where channels can carry messages in one direction only, the Neighbours of node p are:

  • In-Neighbor : Process that can send message to p
  • Out-Neighbor : Process to which p can send messages

In phase algorithm, each process sends exactly D messages to each out-neighbor. Only after I messages have been received from each in-neighbor,(I + 1)th message is sent to each out-neighbor.

The Finn’s Algorithm

This is another wave algorithm that can be used in arbitrary directed networks.

It does not require the diameter of the network to be known in advance but relieve on the availability of the unique identities for the processes.

Set of processes identities are exchanged in messages, which causes the bit complexity of the algorithm to be rather high.

Process p maintains two set of process identities:

  • Incp : Is the set of processes q such that an event in q precedes the most recent event in p.
  • Nincp : Is the set of processes q such that for all neighbors r of q an event in precedes the most recent event in p.

Traversal Algorithm

Wave algorithms have the following two additional properties:

  • the initiator is the only process that decides
  • all events are ordered totally by the participant in cause-effect order.

Wave algorithms with these properties are called traversal algorithms. or Traversal Algorithm if it satisfies these properties:

  • In each computation, there is one initiator, which starts the algorithm by sending out exactly one message.
  • A process, upon receipt of a message, either sends out one message or decides.
  • Each process has sent a message at least once, then the algorithm terminates in the initiator.

Example of Traversing Algorithm:

Sequential Polling Algorithm: Sequence Polling Algorithm is the same as Polling Algorithm.

  • One neighbor is polled at a time.
  • The next neighbor is polled only when the reply of a previous neighbor is received.
Sequential Polling algorithm for Initiator-
var recp: integer init 0;
begin
while recp<#Neighp do
begin
send(tok)to qrecp+1;
receive(tok);
recp:= recp + 1;
end;
decide
end
Sequential Polling algorithm for non Initiator-
begin
receive (tok)from q;
send (tok) to q;
end

Note: Traversal Algorithms are used to construct Election Algorithms.

Topology

  • Ring: It is a circular network structure where each network is connected with exactly two networks.
  • Tree: It is a type of hierarchical topology where the root network is connected to all other networks and there is a minimum of three levels of hierarchy.
  • Clique: Network channel is present between each pair of processes.

The metrics for measuring the efficiency of algorithms are:

  • Time complexity is the number of messages in the longest chain.
  • Message complexity is the number of messages carried out by an algorithm.

Here is a table showing different algorithms with their properties:

  • N is the number of processes
  • lEI the number of channels
  • D the diameter of the network (in hops).
  • DFS – Depth First Search
S.No.

Algorithm

Topology

Centralized(C)/

Decentralized(D)

Traversing

Message Complexity(M)

Time Complexity

01.

Ring

ring

C

no

N

N

02.

Tree

tree

D

no

N

O(D)

03.

Echo

arbitrary

C

no

2|E|

O(N)

04.

Polling

clique

C

no

2N-2

2

05.

Finn

arbitrary

D

no

<=4.N.|E|

O(D)

06.

Sequence Polling

clique

C

yes

2N-2

2N-2

07.

Classical DFS

arbitrary

C

yes

2|E|

2|E|



Last Updated : 07 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads