Skip to content
Related Articles

Related Articles

Wave and Traversal Algorithm in Distributed System

View Discussion
Improve Article
Save Article
  • Difficulty Level : Expert
  • Last Updated : 04 Mar, 2022

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 event
  • The event of a non-initiator has received the event.

Wave Algorithm:

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 decide 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.

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:

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.

 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|


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!