Time Stamped Anti-Entropy Protocol
Time Stamped Anti-Entropy Protocol
Time Stamped Anti-Entropy Protocol
Authors: Joan Manuel Marquès, Raúl de la Cruz and José Quiroga, Montserrat Rovira and Antonio González
Distributed Systems course
Autumn 2020
Assignment Outline 2
Time Stamped Anti-Entropy (TSAE) protocol 2
Groups 2
To Deliver 2
D1. First Deliverable 3
1. Phase 1: Theoretical exercise of TSAE protocol 3
1.1 TSAE protocol exercise (no purged log) 3
1.2 TSAE protocol exercise (purged log) 5
1.3 TSAE protocol exercise 5
2. Phase 1: Implementation and testing of Log and TimestampVector data structures 6
Environment 6
2.1. Test locally 6
2.2. Formal evaluation of phase 1 6
2.3. Things to deliver 7
D2. Second Deliverable 8
Option A. Implementation of phases 2 to 4 8
A.1. Phase 2: Implementation of a reduced version of the application and TSAE protocol:
only add operation; no purge of log 8
Your Tasks in Phase 2 10
Run phase 2 Locally 10
Run phase 2 at DSLab (evaluation framework) 11
A.2. Phase 3: Extension of phase 2 to purge log with unsynchronized clocks 13
Your tasks in Phase 3 13
Run phase 3 Locally 13
Run phase 3 at DSLab 13
A.3 Phase 4: Evaluation of TSAE protocol and implementation of Remove recipe operation
14
Phase 4.1 Extend application adding the remove recipe operation 14
Phase 4.2 Evaluation of TSAE protocol 14
Your tasks in Phase 4 14
Run phase 4 15
A.4. Things to deliver 16
Option B. Theoretical exercise 17
Assignment outline 17
Theoretical questions 17
Practical exercises 18
To deliver 19
B.1. Evaluation 19
Annex A. Source code and documentation 20
Annex B. Activity simulation and dynamicity 21
Annex C. Details about the execution 21
Annex D. Headers 22
Distributed Systems TSAE protocol 2
Assignment Outline
The aim of this practical assignment is to implement and evaluate a weak-consistency protocol for
data dissemination.
The project consist on:
Implementing the Time Stamped Anti-Entropy (TSAE) protocol [1] into an application that
stores cooking recipes in a set of replicated servers.
Add a remove operation on the recipes application
Evaluate how TSAE behaves under different conditions.
Groups
Phase 1: should be done individually.
You are strongly advised to do the phases 2 to 4 in groups of 2 students, even though it is also
possible to do it individually.
To Deliver
Two deliverables (more details in each phase):
1. phase 1 (theoretical exercises and practice)
2. phases 2 to 4 or second theoretical exercise
Deadlines are in the course schedule.
Distributed Systems TSAE protocol 3
Exercise 1
Let's suppose that there are 3 hosts (A, B, C) that use TSAE protocol to exchange operations. At the
initial time (t0) all hosts have the same state and their logs and summary vectors are as follow:
Summary A= A3, B3, C2 Log A= A1, A2, A3, B1, B2, B3, C1, C2
Summary B= A3, B3, C2 Log B= A1, A2, A3, B1, B2, B3, C1, C2
Summary C= A3, B3, C2 Log C= A1, A2, A3, B1, B2, B3, C1, C2
A1 stands for first operation from host A, B2 stands for the second operation from host B, and so
on.
Let’s assume that each anti-entropy session starts and ends at the same instant.
1.1 For the following sequence:
Time Operation
1 Host A executes operation A4
2 Host B executes operations B4, B5, B6
3 Host C executes operations C3, C4
4 Host B does an anti-entropy session with host C
5 Host A executes operation A5
6 Host B executes operations B7, B8
7 Host A does an anti-entropy session with host B
8 Host C executes operations C5, C6
9 Host B executes operation B9
10 Host C executes operations C7, C8
11 Host A executes operations A6, A7
12 Host A does an anti-entropy session with host B
13 Host B does an anti-entropy session with host C
14 Host A executes operation A8
Time Operation
1 Host B executes operation B4
2 Host C executes operation C3
3 Host A does an anti-entropy session with host C
4 Host B executes operation B5
5 Host A does an anti-entropy session with host B
6 Host A executes operation A4
7 Host C executes operation C4
8 Host A does an anti-entropy session with host C
9 Host A does an anti-entropy session with host B
Question 2: Describe what are the main fields of a TSAE data structure.
Distributed Systems TSAE protocol 6
Environment
Requires Java 7.
We recommend you to use eclipse as IDE. We will provide you an Eclipse project that contains the
implementation of the cooking recipes application except the parts related to TSAE protocol.
All scripts for running local tests are prepared for Ubuntu-linux but other OS can be used. In that
case, you will be responsible of adapting the scripts to your OS.
Subdirectory Content
/doc Solution theoretical exercise
Report in pdf
/src Log and TimestampVector classes.
Distributed Systems TSAE protocol 8
In this phase:
Distributed Systems TSAE protocol 9
NOTE: be careful with concurrent access to data structures. Two actions issued by different
threads may interleave. Use some synchronization mechanism to avoid interferences.
TSAESessionOriginatorSide
// Send to partner: local's summary and ack
...
Message msg = new MessageAErequest(localSummary, localAck);
out.writeObject(msg);
TSAESessionPartnerSide
// receive originator's summary and ack
msg = (Message) in.readObject();
Distributed Systems TSAE protocol 10
if (msg.type() == MsgType.AE_REQUEST){
...
// send operations
...
out.writeObject(msg);
// receive operations
msg = (Message) in.readObject();
while (msg.type() == MsgType.OPERATION){
...
msg = (Message) in.readObject();
}
Results will be stored in a file named as the groupId from config.properties file (on current path).
--logResults: log results in the following two files:
<groupId1>: log of all executions and the result for each of them.
<groupId2>.data:
◦ in the case that all solutions are equal, contains the final state of data structures.
◦ in the case that NOT all solutions are equal, contains the first two found solutions that
were different.
--nopurge: Log is not purged.
--noremove: no remove operations are issued.
We recommend you to start testing your application using the --menu option, which will allow you
to test the TSAE protocol and data structures at your pace.
Then execute your implementation locally without the --menu parameter to test your application
under similar conditions that the one's that will be used in the formal evaluation.
Finally, once your application runs in local, upload it in DSLab web for its formal evaluation. In
DSLab, your implementation will run in a real distributed environment interacting with instances
(also distributed) of an implementation done by the professors of this course.
(REMEMBER: use DSLab web for its formal evaluation)
1 Name of the file will be the value of groupId property in config.properties file (scripts folder).
2 Value of groupId property in config.properties file (scripts folder) will be the first part of the file name. i.e. file name:
<value of groupId property>.data.
Distributed Systems TSAE protocol 12
Secondly, you are able to built the project in order to use it for the next step.
Submit
Create a new submission selecting the project(s) necessary to submit the task and run it.
Checking results
Once the submission is finished, you can check if the submission was successful or not and view the
details of the submission.
Distributed Systems TSAE protocol 13
Run phase 4
Use the script start.sh explained in previous phases.
In phase 4.1 (extend application adding remove recipe operation), run start.sh script to test your
implementation locally. For its formal evaluation use DSLab web.
$ ./start.sh 20004 15 --logResults -path ../results
Runs 15 Servers and a TestServer locally (and result files are created in ../results folder).
Log is purged.
Simulated activity and dynamism mode.
Remove operations are issued.
In phase 4.2 (evaluation of TSAE protocol), modify parameters of config.properties file (scripts
folder) to evaluate TSAE protocol under different conditions and environments.
Use runN.sh script to run N times start.sh script. Example:
$ ./runN.sh 10 20004 15 --logResults -path ../results
runs 10 times start.sh script with the following parameters:
$ ./start.sh 20004 15 --logResults -path ../results
Modify activitySimulation class only in case that in phase 4 you want to better understand or
modify the modeling of activity and dynamicity (package
recipes_service.activitysimulation).
Phase 4.2 is not evaluated using DSLab. It consists on doing a rapport describing how parameters
and other conditions influence on TSAE performance. Therefore, run TSAE protocol with different
values for parameter and under different conditions.
Distributed Systems TSAE protocol 16
Subdirectory Content
/doc Report in pdf
Document phase4.pdf (in case of phase 4.2)
/src Source code. Eclipse project with your implementation.
/bin All required files to execute your practical assignment. Explained
carefully in the report how to execute it.
Distributed Systems TSAE protocol 17
Assignment outline
The aim of this assignment is to understand the main concepts of the block chain systems.
Block chain systems combine many concepts in order to give a solution to a distributed ledger with
security.
In order to get the basic details of the Block Chain read the following article:
https://www.igvita.com/2014/05/05/minimum-viable-block-chain
Theoretical questions
1. Summarize the building pieces over which the Minimum Viable Block chain is build over.
2. Explain how are the following three properties are ensured by the blockchain:
1. Authentication.
2. Non-repudiation.
3. Integrity.
3. How can you ensure that no double spending will occur?
4. If two users have two different BlockChain, how do we know which is the good one? Which
one does the system keep?
5. If someone wanted to attack a BlockChain system, what should they do? Why is it very
difficult for this to happen?
6. What happens if users validate one block at a time? Who gets the reward?
7. List some use cases for a Block chain?
Distributed Systems TSAE protocol 18
Practical exercises
1. Sketch a network diagram (you can use Dia: https://wiki.gnome.org/action/show/Apps/Dia,
or the alternative that better suits you) highlighting the main actors of the described block
chain. (Delivery should be in PDF format, this is not a UML diagram).
2. Let's say you are a party interested in collecting fees by validating and confirming
transactions. You have received enough transaction notifications (File:
transaction_notifications.csv headers in Annex D) to compensate your proof-of-work costs
so you are willing to generate as many blocks as possible. Now you have to validate all
received transactions (remember to check for double-spends) and aggregate them into
blocks of five transactions each.
NOTE: The balance of each participant at t0 is:
A: 100€
C: 100€
(suppose that all signatures verify correctly).
a) Have you received double-spends? in this case indicate which transactions are not
valid.
b) Show which transactions get aggregated into which blocks.
c) Which fields are required by a ledger.csv to support both transactions and block
annotations?
d) Write a ledger.csv file with the annotations for your blocks and the transactions that
this blocks aggregate. (suppose fees for 0.05% for each transaction in a block)
e) Which is the balance of C at the end of the exercise taking into account the 0.05%
fees? (3 decimals)
a) Verify all signatures and indicate which signatures are correct and which don’t
verify. Remove invalid notifications, if any.
b) Generate your key-pair and sign your block transactions from the previous exercise.
Distributed Systems TSAE protocol 19
To deliver
A zip file named with your campus username in the form
campus_username-blockchain.sd.zip
with the structure:
Files Description
username.pdf Your answers to both theoretical and practical questions.
student.crt Your public key.
ledger.csv The ledger.csv from practical exercise 2.
ledger-XX.signature Specifying the id of each signed block in the file name. This is,
one signature file per signature.
diagram_file.[png|jpg|pdf] The diagram from practical exercise 1.
B.1. Evaluation
Theoretical questions correct: C-
Theoretical questions + Practical exercise, both correct: C+
Distributed Systems TSAE protocol 20
TSAE folder contains all packages and classes required to the practical assignment.
Important: do not implement new classes. Modify only the classes indicated in each phase.
(except if you modify the basic modeling of parameters in phase 4)
Classes that you should modify:
1. package recipes_service.tsae.datastructures:
◦ Log: class that logs operations.
◦ TimestampVector: class to maintain the summary.
◦ TimestampMatrix: class to maintain the acknowledgment matrix of timestamps
2. package recipes_service.tsae.sessions:
◦ TSAESessionOriginatorSide: Originator protocol for TSAE.
◦ TSAESessionPartnerSide: Partner's protocol for TSAE.
3. package recipes_service:
◦ ServerData: contains Server's data structures required by the TSAE protocol (log,
summary, ack) and the application (recipes). You can add any required method to allow
TSAESessionOriginatorSide and TSAESessionPartnerSide manipulate these data
structures.
▪ addRecipe method: adds a new recipe.
▪ removeRecipe method: removes a recipe.
Classes that you should use but NOT modify:
4. package recipes_service.tsae.data_structures:
◦ Timestamp: a timestamp. A timestamp allows the ordering of operations issued from
same host. It is a tuple <hostId, sequenceNumber>. Sequence number is a number that
grows monotonically. The first valid timestamp issued by a host will have an initial
value of 0. A negative sequence number means that the host hasn't issued yet any
operation. Timestamps can not be used to order operations issued in different hosts. Next
timestamp is obtained calling the method nextTimestamp() from class ServerData
(package recipes_service).
5. package recipes_service.data:
◦ AddOperation: an add operation (operations are logged in the Log and exchanged with
other partners).
◦ RemoveOperation: a remove operation (operations are logged in the Log and exchanged
with other partners).
◦ Recipe: a recipe.
◦ Recipes: class that contains all recipes.
Distributed Systems TSAE protocol 21
6. package recipes_service.communication)
◦ MessageAErequest: message sent to request an anti-entropy session.
◦ MessageOperation: message sent for each exchanged operationTimes New Roman
during an anti-entropy session.
◦ MessageEndTSAE: message sent to finish an anti-entropy session.
7. package communication:
◦ ObjectInputStream_DS: class that implements a modification of the ObjectInputStream
to simulate failures. Use the method readObject().
◦ ObjectOutputStream_DS: class that implements a modification of the
ObjectOutputStream to simulate failures. Use the method writeObject().
8. package recipes_service.activitysimulation: Only in case that in phase 4 you want to better
understand or modify the modeling of activity and dynamicity.
Annex D. Headers
ID: The id for this annotation.
SHA-256 checksum: The checksum for this annotation.
From: The code for the sender, if any.
To: The code for the receiver, if any.
What: The origin/s from which the amount for this annotation is obtained.
Time: The moment when this transaction happened.
Value: The amount exchanged in this annotation, if any.
Sign / Verify:
Sign with private key:
openssl dgst -sha256 -sign my.priv.key -out transaction.signature transaction.csv
echo 'Real important text'|openssl dgst -sha256 -sign my.priv.key -out important.signature
Asymmetric encryption
Encrypt w/ public key:
openssl rsautl -encrypt -inkey <(openssl x509 -in my.crt -pubkey -noout) -pubin -in plain.txt -out
cyphered.txt.enc
References
[1] Richard A. Golding (1992, December). Weak-consistency group communication and
membership. Ph.D. thesis, published as technical report UCSC-CRL-92-52. Computer and
Information Sciences Board, University of California. Santa Cruz. (chapter 5)
[2] R. Golding; D. D. E. Long. The performance of weak-consistency replication protocols, UCSC
Technical Report UCSC-CRL-92-30, July 1992.