Читать книгу From Traditional Fault Tolerance to Blockchain - Wenbing Zhao - Страница 63
EXAMPLE 2.6
ОглавлениеIn the example shown in Figure 2.18, the distributed system consists of three processes. Both the seq counter and rsn counter are initialized to be 0, and the message log is empty at each process. Process P0 first sends a regular message, <REGULAR,0,?,m0>, to P1. Upon sending the message, P0 increments its seq counter to 1 and log the message in its volatile buffer. At this point, the rsn value for the message is unknown, hence it is denoted as a question mark.
On receiving the regular message <REGULAR,0,?,m0>, P1 assigns the current rsn counter value, which is 0, to this message indicating its receiving order, increments its rsn counter to 1, and sends P0 an ORDER message <ORDER,[m0],0>. When P0 receives this ORDER message, it updates the entry in its message log to reflect the ordering number for message m0, and sends an sc ack message, <ACK,[m0]>, to P1.
Once receiving the ACK message, P1 is permitted to send a regular message, <REGULAR,0,?,m1>, to P2. The handling of the message and the corresponding ORDER and ACK messages are similar to the previous ones.
Figure 2.18 An example normal operation of the sender-based logging protocol.
Subsequently, P0 and P2 send three regular messages m2, m3, m4, nearly concurrently to P0. P1 assigns 1 as the rsn value for the first of the three messages (for m2) and sends an ordering message to P0, and assigns 2 and 3 for the two back-to-back regular messages (for m3 and m4) from P2. For the two messages from P2, P1 can batch the ORDER messages and sends them together to P2, and P2 can batch the corresponding the ACK messages to P1 too. Upon receiving the ACK messages for all three ORDER messages, P1 sends another regular message containing m5 with sequence number 1, updates the seq counter to 2, and log the message.