You are on page 1of 14

Figure 1

(0,0,0)

P1
VP1( __ , __ )
(0,0,0)

P2

M1

M2 M3 a

VP2( __ , __ )
(0,0,0)

P3
VP3( __ , __ )

Initially Vector Time is (0,0,0) at all sites Vector at each site is empty. Note here we have taken size of vector at each site as 2. If You want you can extend it easily upto 3.

Vectors Maintained at each site


This entry gets updated when P1 sends any Message to P3

VP1

( __ , __ )

This entry gets updated when P1 sends any Message to P2

This entry gets updated when P2 sends any Message to P3

VP2

( __ , __ )

This entry gets updated when P2 sends any Message to P1

This entry gets updated when P3 sends any Message to P2

VP3

( __ , __ )

This entry gets updated when P3 sends any Message to P1

Consider Sending of Message M1 from P2 to P1 of Figure 1

1.

Send Step at P2
P2 Sends Message M1 to P1 [ Vector accompanying Message will be represented as VM ( __, __) i.e. empty ]. So P2 sends the Message {( __, __), (0,1,0)} to P1. After Sending Message it updates its own vector VP2. Now P1s corresponding entry in VP2 (i.e. Vector of Process P2) is empty so the pair {P1,(0,1,0)} will be inserted in VP2. So before sending message M1, VP2 is ( __,__) but after sending message M1 , P2s vector VP2 will be updated as {(P1,(0,1,0)), __)}.

2.

Important Point : Message M1 is sent with Earlier VP2 (as VM )i.e. VP2 existing at P2 before sending message M1. VP2 gets updated with new entry after sending Message M1.

Receiving of M1 by P1 at Point y of Figure


1. Receiving of M1 by P1[Note here what P1 has received from P2. Message of form {( __, __), (0,1,0)} i.e. (VM,t). Check If the Accompanying VM contains any entry corresponding to P1, If not receive the message . [This condition is satisfied here]. else (If the condition of step 1 is not satisfied then only go to else part ) Compare time t (Message time stamp) with TP1 (Current Time running at P1). Time running at P1 before receiving the message is (0,0,0). If t < TP1 then receive the message else (if this step is false) Buffer the Message [t >= TP1]

2.

3.

For Figure 1 only Step1 is fulfilled that is why M1 is received at point y at P1. [Assume M3 has not been received at x]

What will happen at P1 when Message is delivered at point y

1.
2.

STEP A Merge VP1 & VM. Update VP1 by values of VM.


If for any process say P (not equal to P1) there exits an entry in VM but does not have any entry in VP1 then that entry has to be inserted in VP1. If for any process say P (not equal to P1) there exists an entry in both VM and VP1 then you have to update the value for that process in VP1 by setting the time =max(a,b) where a is time in VM and b is time in VP1
In our case after receiving Message M1, both VP1 & VM are ( __, __) So there Merge operation will be same i.e. ( __, __) SO VP1 after Merge will be ( __, __ ) i.e. empty

STEP B. Update P1s logical clock so time at P1 will be (1,1,0) STEP C. Check for Buffered Messages at P1 . There is no buffered Messages at P1.

Now Complete State of System after Receiving M1 by P1

is shown as follows

Process
P1 P2

Vector
VP1 ( __, __) [Empty]

Time
(1,1,0) at y (0,1,0)

VP2 : {P1,(0,1,0), __ }. Note that VP2 updated after sending Message M1

P3

VP3 ( __, __) [Empty]

(0,0,0)

Now Consider the case when M2 is sent from P2 to P3


1. Send Step of M2 from P2 to P3 P2 Sends Message M2 to P3. So P2 sends the Message M2 with VM as { P1,(0,1,0), __ } and time stamped as (0,2,0). So the format of sent message looks like { (P1,(0,1,0), __ ), (0,2,0) } After Sending Message it updates its own vector VP1. Here P2s vector entry corresponding to P3 is empty. So now VP2 becomes { (P1,(0,1,0)), (P3,(0,2,0) } . Note that this will be VP2 after sending message M2. So the state of the system looks like as follows

2.

Process

Vector

Time

P1
P2 P3

VP1 ( __, __) [Empty]


VP2 : {P1,(0,1,0), P3,(0,2,0)} After sending M2 VP3 ( __, __) [Empty] P3 has not received M2 yet

(1,1,0) at y
(0,2,0) (0,0,0)

Receiving of M2 by P3 at Point a of Figure


1. Receiving of M2 by P3[Note here what P3 has received from P2. Message of form [{ P1,(0,1,0), __ }, (0,2,0)] i.e. [VM,t] Check If the Accompanying VM contains any entry corresponding to P3, If not receive the message . [This condition is satisfied here. VMs entry for P3 is empty]. else (If the condition of step 1 is not satisfied then only go to else part ) Compare time t which is in the message with time at P1 . Time running at P1 before receiving the message is (0,0,0). If t <= tP1 then receive the message else (if this step is false) Buffer the Message

2.

3.

For Figure 1 only Step1 is fulfilled that is why M2 is received at point a at P3.

What will happen at P3 when Message M2 is delivered at point a

1.
2.

STEP A Merge VP3 & VM. Update VP3 by values of VM.


If for any process say P (not equal to P3) there exists an entry in VM but does not have any entry in VP3 then that entry has to be inserted in VP1. If for any process say P (not equal to P1) there exists an entry in both VM and VP1 then you have to update the value for that process in VP1 by setting the time =max(a,b) where a is time in VM and b is time in VP1

In This case VM is [ {P1,(0,1,0)} , __ ] andVP3 is ( __ , __)

[Note VM contains entry for P1. Step1 condition ] SO VP3 after Merge will be [{P1,(0,1,0)} , __ ]

STEP B. Update P3s logical clock so time at P3 will be (0,2,1) STEP C. Check for Buffered Messages at P3 . There is no buffered Messages at P3.

Now Complete State of System after Receiving M2 by P3

at point a is shown as follows

Process
P1 P2

Vector
VP1 ( __, __) [Empty]

Time
(1,1,0) at y (0,2,0)

VP2 : [ {P1,(0,1,0)},{P2,(0,2,0)}] Note that VP2 updated after sending Message M2

P3

VP3 ({P1,(0,1,0)}, __)

(0,2,1) at a

Now Consider the case when M3 is sent from P3 to P1 at point b of Figure 1


1. Send Step of M3 from P3 to P1 P3 Sends Message M3 to P1. So P3 sends the Message M3 with VM as { P1,(0,1,0), __ } and time stamped as (0,2,2). So the format of sent message looks like { (P1,(0,1,0), __ ), (0,2,2) } After Sending Message M3 P3 updates its own vector VP3. VP3 already contains an entry for P1 so that entry gets simply updated with latest time value. Complete state of system after sending M3 by P3 is shown below.

2.

Process

Vector

Time

P1
P2 P3

VP1 ( __, __) P1 has not received M3 so far


VP2 : {P1,(0,1,0), P3,(0,2,0)} After sending M2 VP3 ( P1,(0,2,2), __) P3 has sent M3

(1,1,0) at y
(0,2,0) (0,2,2) at b

Receiving of M3 by P1 at Point x of Figure1


Receiving of M3 by P1 at point x. [Note here what P1 has received from P3. Message of form [{ P1,(0,1,0), __ }, (0,2,2)] i.e. [VM,t] Check If the Accompanying VM contains any entry corresponding to P1, If not receive the message . [This condition is not true for this case. Because accompanying VM contains an entry corresponding to P1]. else (If the condition of step 1 is not satisfied then only go to else part ) If P1 has received Message M3 at point x then current time at that point will be (0,0,0) which is TP1. The message has come with time stamped t as (0,2,2). Clearly t is > TP1 so the message will be buffered.

1.

2.

What will happen at P3 when Message M2 is delivered at point a

1.
2.

STEP A Merge VP3 & VM. Update VP3 by values of VM.


If for any process say P (not equal to P3) there exists an entry in VM but does not have any entry in VP3 then that entry has to be inserted in VP1. If for any process say P (not equal to P1) there exists an entry in both VM and VP1 then you have to update the value for that process in VP1 by setting the time =max(a,b) where a is time in VM and b is time in VP1

In This case VM is [ {P1,(0,1,0)} , __ ] andVP3 is ( __ , __)

[Note VM contains entry for P1. Step1 condition ] SO VP3 after Merge will be [{P1,(0,1,0)} , __ ]

STEP B. Update P3s logical clock so time at P3 will be (0,2,1) STEP C. Check for Buffered Messages at P3 . There is no buffered Messages at P3.

Now Complete State of System after Receiving M2 by P3

at point a is shown as follows

Process
P1 P2

Vector
VP1 ( __, __) [Empty]

Time
(1,1,0) at y (0,2,0)

VP2 : [ {P1,(0,1,0)},{P2,(0,2,0)}] Note that VP2 updated after sending Message M2

P3

VP3 ({P1,(0,1,0)}, __)

(0,2,1) at a