Causal Ordering of Messages in Distributed
System
Causal ordering of messages is one of the four semantics of multicast
communication namely unordered, totally ordered, causal, and sync-
ordered communication. Multicast communication methods vary according
to the message’s reliability guarantee and ordering guarantee. The causal
ordering of messages describes the causal relationship between a
message send event and a message receive event.
For example, if send(M1) -> send(M2) then every recipient of both the
messages M1 and M2 must receive the message M1 before receiving the
message M2. In Distributed Systems the causal ordering of messages is
not automatically guaranteed.
Reasons that may lead to violation of causal ordering of messages
1. It may happen due to a transmission delay.
2. Congestion in the network.
3. Failure of a system.
Protocols that are used to provide causal ordering of messages
1. Birman Schipher Stephenson Protocol
2. Schipher Eggli Sandoz Protocol
Birman Schipher Stephenson Protocol : This algorithm is used to
maintain the causal ordering of the messages i.e. the message which is
sent first should be received first. If send (M1)–>send(M2) then for all
processes which receive the messages M1 and M2 should receive M1
before M2. Features :
Broadcast based messaging.
Size of the messages are small.
More no. of messages are sent.
Limited state information.
Key Points :
Each process increases its vector clock by 1 upon sending of
messages.
Message is delivered to a process if the process has received all the
messages preceding to it.
Else buffer the message.
Update the vector clock for the process.
Protocol : Pi sending a message to Pj –
Pi increments Ci[i] and sets the timestamp t m = Ci[i] for message m.
Pj receiving a message from P i –
When Pj, j != i, receives m with timestamp t m, it delays the message’s
delivery until both these conditions are met:
Cj[i] = tm[i] - 1; and
for all k <= n and k != i, Cj[k] >= tm[k].
When the message is delivered to P j, update Pj‘s vector clock.
Check buffer to see if any can be delivered.
Example –
Initial state for all the processes are 000.
M1 is broadcasted from P3 to P1 and P2. e31 updates the vector clock
to (001) and sends P1 and P2.
P2 accepts the M1 with timestamp (001) because when it compares it
with its initial timestamp i.e. (000) it finds that M1 is the 1st message it
is receiving.
Now we consider that before M1 could reach P1, P2 sends M2 to P1
and P3 with time stamp (011).
P1 could not accept M2 because upon comparing the timestamp of M2
with its initial timestamp a discrepancy is found because P1 has no
message with timestamp (001) received earlier, so M2 is stored in
buffer.
Now M1 is received by P1 and accepted.
M2 is removed from buffer and accepted by P1.
M2 is accepted by P3 as there is no discrepancy in the time stamp.
Schiper Eggli Sandoz Protocol is used to maintain the casual ordering
of the messages i.e. the message which is sent first should be received
first. This is the contrast to maintaining a vector clock based on the
number of messages sent to each type of process, this protocol’s vector
clock can be increased at any rate it chooses and is unrelated to the
number of messages that are currently outstanding.
Transmitting a Message:
Before any type of message is sent, There is a list of all the
timestamps of messages sent to other processes is included.
The timestamp of each type of message should be saved in a specific
location.
Received a Message:
1. Any type of message cannot be delivered if it is preceded by a
message which is mentioned in the list of timestamps.
2. Alternately, there are following actions may be taken to convey a
message:
There we Include the following list of timestamps in the message:
o Add knowledge of messages intended for other all processes
to our list of processes. if we did not already know of any
other messages intended for one process. If we timestamp on
the new list which is higher than the one which is previously
saved, that adjusts our timestamp accordingly wise.
We need to Refresh the logical clock in your region.
Now we Check to see if all messages that are locally buffered they can
now be delivered or not.
Here, C3:1 – C3:2, and so they should be received at each receiver in
that order. C1:1 – C3:1, and so they should be received at each receiver
in that order. It is acceptable to receive C3:1 and C2:1 in different orders
at various receivers because they are concurrent.
Advantages:
Some main advantages of using this protocol in the design of distributed
systems are as follows:
1. The goal is to ensure that the same causal relationship between
“message send” and “message receive” events corresponds. (Or, all
messages are handled in the chronological order in which they were
generated.)
2. Upon sending messages, each process raises its vector clock by one.
3. If a process has received all messages before it, then the message has
been delivered to that process.
4. The happened-before relation of the corresponding sendings cannot be
violated by the order in which messages are delivered for any process.
5. A rise in concurrency logical time, which can be tracked with less
infrastructure and expense, could take the place of real-time.
Disadvantages:
Some main Disadvantages of using this protocol in the design of
distributed systems are as follows:
1. Any process that alters the relationship between what happened before
and the corresponding sendings cannot affect the order in which
messages are delivered.
2. A programmer must perform all tasks.
3. It is slower because the connection setup takes some time.
4. Cooperative operations are typically needed for data transfer, which
can be challenging to accomplish.
5. Voice or video calls or other real-time applications cannot be made
using it.