Open In App

Wave and Traversal Algorithm in Distributed System

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

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:



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.

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:

Properties of waves:

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.

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

Different Wave 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).

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.

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:

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

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:

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 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:

Traversal Algorithm

Wave algorithms have the following two additional properties:

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

Example of Traversing Algorithm:

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

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

The metrics for measuring the efficiency of algorithms are:

Here is a table showing different algorithms with their properties:

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|


Article Tags :