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.
- 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.
- Process: Pi
- Event: eij , where i:process is number & j: jth event in ith process.
- Tm:vector time stamp for message m.
- Ci vector clock associated with process Pi; jth element is Ci[j] and contains Pi‘s latest value for the current time in process Pj
Pi sending a message to Pj –
- Pi increments Ci[i] and sets the timestamp tm = Ci[i] for message m.
Pj receiving a message from Pi –
- When Pj, j != i, receives m with timestamp tm, it delays the message’s delivery until both as follows.
Cj[i] = tm[i] - 1; and for all k <= n and k != i, Cj[k] <= tm[k].
- When the message is delivered to Pj, update Pj‘s vector clock.
- Check buffer to see if any can be delivered.
- 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.