首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
讲解COMP212编程、辅导Java语言程序 讲解留学生Processing|解析C/C++编程
项目预算:
开发周期:
发布时间:
要求地区:
Department of Computer Science
COMP212 - 2021 - CA Assignment 1
Coordination and Leader Election
Simulating and Evaluating Distributed Protocols in Java
Assessment Information
Assignment Number 1 (of 2)
Weighting 15%
Assignment Circulated 15th February 2021
Deadline 15th March 2021, 17:00 UK Time (UTC)
Submission Mode Electronic via CANVAS
Learning outcomes assessed (1) An appreciation of the main principles underlying
distributed systems: processes, communication, naming,
synchronisation, consistency, fault tolerance, and
security. (3) Knowledge and understanding of the essential
facts, concepts, principles and theories relating
to Computer Science in general, and Distributed Computing
in particular. (4) A sound knowledge of the criteria
and mechanisms whereby traditional and distributed
systems can be critically evaluated and analysed to determine
the extent to which they meet the criteria de-
fined for their current and future development.
Purpose of assessment This assignment assesses the understanding of coordination
and leader election in distributed systems and implementing,
simulating, and evaluating distributed protocols
by using the Java programming language.
Marking criteria Marks for each question are indicated under the corresponding
question.
Submission necessary in order No
to satisfy Module requirements?
Late Submission Penalty Standard UoL Policy.
1
1 Overall marking scheme
The coursework for COMP212 consists of two assignments contributing altogether 30% of
the final mark. The contribution of the individual assignments is as follows:
Assignment 1 15%
Assignment 2 15%
TOTAL 30%
2 Objectives
This assignment requires you to implement in Java two distributed algorithms for leader
election in a ring network and then to experimentally validate their correctness and evaluate
their performance.
3 Description of coursework
Throughout this coursework, the network on which our algorithms are to be executed is a
bidirectional ring, as depicted in Figure 1.
Figure 1: A bidirectional ring network on n processors.
In our setting, all processors execute the same algorithm, do not know the number n of
processors in the system in advance, but they do know the structure of the network and
are equipped with unique ids. The ids are not necessarily consecutive and for simplicity
you can assume that they are chosen from {1, 2, . . . , αn}, where α ≥ 1 is a small constant
(e.g., for α = 3, the n processors will be every time assigned unique ids from {1, 2, . . . , 3n −
1, 3n}). Additionally, every processor can distinguish its clockwise from its counterclockwise
neighbour, so that, for example, it can choose to send to only one of them or to send a
2
different message to each of them. Processors execute in synchronous rounds, as in every
example we have discussed so far in class.
3.1 Implementing the LCR Algorithm—30% of the assignment
mark
As a first step, you are required to implement the LCR algorithm for leader election in a
ring. The pseudocode of the non-terminating version of LCR can be found in the lecture
notes and is also given here for convenience (Algorithm 1).
Algorithm 1 LCR (non-terminating version)
Code for processor ui
, i ∈ {1, 2, . . . , n}:
Initially:
ui knows its own unique id stored in myIDi
sendIDi
:= myIDi
statusi
:= “unknown”
1: if round = 1 then
2: send hsendIDii to clockwise neighbour
3: else// round > 1
4: upon receiving hinIDi from counterclockwise neighbour
5: if inID > myIDi then
6: sendIDi
:= inID
7: send hsendIDii to clockwise neighbour
8: else if inID = myIDi then
9: statusi
:= “leader”
10: else if inID < myIDi then
11: do nothing
12: end if
13: end if
You are required to implement a terminating version of the LCR algorithm in
which all processors eventually terminate and know the id of the elected leader.
3.2 Implementing the HS Algorithm—30% of the assignment
mark
Next, you are required to implement another algorithm for leader election on a ring, known
as the HS algorithm. As LCR, HS also elects the processor with the maximum id. The
main difference is that HS instead of trying to send ids all the way around in one direction
(which is what LCR does), it has every processor trying to send its id in both directions some
3
distance away (e.g., k) and then has the ids turn around and come back to the originating
processor. As long as a processor succeeds, it does so repeatedly (in “phases”) to successively
greater distances (doubling the distance to be travelled each time, e.g., 2k). See Figure 2 for
an illustration.
Figure 2: Trajectories of successive “phases” originating at processor u4 (imagine the rest of
the processors doing something similar in parallel, but not depicted here). The id transmitted
by u4 aims to travel some distance out in both directions and then return back. If it succeeds,
then u4 doubles the aimed distance and repeats.
Informally, each processor ui “operates in phases” l = 0, 1, . . . (where each phase l consists
of one or more rounds). In each phase l, processor ui sends out a “token” (i.e., a message)
containing its id idi
in both directions. These are intended to travel distance 2l
(that is,
as in Figure 2, distance 20 = 1 for l = 0, distance 21 = 2 for l = 1, distance 22 = 4 for
l = 2, and so on) and then return to their origin. If both tokens manage to return back then
ui goes to the next phase, otherwise it stops to produce its own tokens (and only performs
from that point on the rest of the algorithm’s operations). A token is discarded if it ever
meets a processor with greater id while travelling outwards (away from its origin). While
travelling inwards (back to its origin), a token is forwarded by all processors without any
check. The termination criterion is as follows: If a token travelling outwards meets its own
origin ui (meaning that this token managed to perform a complete turn of the whole ring
while travelling outwards), then ui elects itself as the leader. Observe that in order for tokens
to know how far they should travel each time and in which direction, this information has to
be included inside the transmitted messages (that is, apart from the id being transmitted,
4
the messages should also contain this auxiliary information).
The pseudocode of the non-terminating version of HS is given in Algorithm 2. As with
LCR, you are required to implement a terminating version of the HS algorithm in
which all processors eventually terminate and know the id of the elected leader.
3.3 Experimental Evaluation, Comparison & Report—40% of the
assignment mark
After implementing the terminating LCR and HS algorithms, the next step is to conduct
an experimental evaluation of their correctness and performance.
Correctness. Execute each algorithm in rings of varying size (e.g., n = 3, 4, . . . , 1000, . . .;
actually, up to a point where simulation does take too much time to complete) and starting
from various different id assignments for each given ring size. For instance, you could
execute them on both specifically constructed id assignments (e.g., ids ascending clockwise
or counterclockwise) and random id assignments. In each execution, your simulator
should check that eventually precisely one leader is elected. Of course, this will not be a
replacement of a formal proof that the algorithms are correct as you won’t be able to test
them on all possible combinations of ring sizes and id assignments, but at least it will be a
first indication that they may do as intended.
Performance. Execute, as above, each algorithm in rings of varying size and starting from
various different id assignments for each given ring size. For each execution, your simulator
should record the number of rounds and the total number of messages transmitted
until termination.
1. Execute both algorithms in rings of varying size for the case in which ids are always
clockwise ordered.
2. Execute both algorithms in rings of varying size for the case in which ids are always
counterclockwise ordered.
3. Execute both algorithms in rings of varying size and various random id assignments
for each given ring size. Note here that both algorithms should be simulated (e.g.,
one after the other) on every given choice of ring size and id assignment, so that a
comparison of their performance makes sense.
In Summary: For both correctness validation and performance evaluation a suggestion
is to simulate both algorithms (for all types of id assignments mentioned above) in rings
containing up to at least 1000 processors. Specifically in the case of random id assignments,
for each ring size n repeat the simulation for many different id assignments (e.g., at least
100 distinct simulations) and record the correctness and the worst, the best, and the average
performance so that you get meaningful results.
5
Algorithm 2 HS (non-terminating version)
Messages are triples of the form hID, direction, hopCounti, where direction ∈ {out, in} and
hopCount positive integer.
Code for processor ui
, i ∈ {1, 2, . . . , n}:
Initially:
ui knows its own unique id stored in myIDi
sendClocki containing a message to be forwarded clockwise or null, initially
sendClocki
:= hmyIDi
, out, 1i
sendCounterclocki containing a message to be forwarded counterclockwise or null, initially
sendCounterclocki
:= hmyIDi
, out, 1i
statusi ∈ {“unknown”,“leader”}, initially statusi
:= “unknown”
phasei recording the current phase number, nonnegative integer, initially phasei = 0
1: upon receiving hinID, out, hopCounti from counterclockwise neighbour
2: if inID > myIDi and hopCount > 1 then
3: sendClocki
:= hinID, out, hopCount − 1i
4: else if inID > myIDi and hopCount = 1 then
5: sendCounterclocki
:= hinID, in, 1i
6: else if inID = myIDi then
7: statusi
:= “leader”
8: end if
9:
10: upon receiving hinID, out, hopCounti from clockwise neighbour
11: if inID > myIDi and hopCount > 1 then
12: sendCounterclocki
:= hinID, out, hopCount − 1i
13: else if inID > myIDi and hopCount = 1 then
14: sendClocki
:= hinID, in, 1i
15: else if inID = myIDi then
16: statusi
:= “leader”
17: end if
18:
19: upon receiving hinID, in, 1i from counterclockwise neighbour, in which inID 6= myIDi
20: sendClocki
:= hinID, in, 1i
21:
6
22: upon receiving hinID, in, 1i from clockwise neighbour, in which inID 6= myIDi
23: sendCounterclocki
:= hinID, in, 1i
24:
25: upon receiving hinID, in, 1i from both clockwise and counterclockwise neighbours, in
both of which inID = myIDi holds
26: phasei
:= phasei + 1
27: sendClocki
:= hmyIDi
, out, 2
phasei i
28: sendCounterclocki
:= hmyIDi
, out, 2
phasei i
29:
30: // The following to be always executed by all processors, i.e.,
31: // also in round 1 in which no message has been received
32: send hsendClockii to clockwise neighbour
33: send hsendCounterclockii to counterclockwise neighbour
After gathering the simulation data, plot them as follows. In each plot, the x-axis will
represent the (increasing) size of the ring and the y-axis will represent the complexity measure
(e.g., number of rounds or number of messages). You may produce individual plots
depicting the performance of each algorithm (possibly comparing against standard complexity
functions, like n, n log n, or n
2
) and you are required to produce plots comparing the
performance of both algorithms in identical settings. For example, when measuring the total
number of messages in the case of counterclockwise increasing ids, a plot would show at
the same time the performance of both algorithms for increasing ring size n, using curves of
different colours and possibly also a legend with explanations. Then, for each given ring size,
the corresponding point of each curve will represent the total number of messages generated
by the algorithm (indicated on the y-axis). You can use gnuplot, JavaPlot or any other
plotting software that you are familiar with.
The final crucial step is to prepare a concise report (at most 5 pages including plots)
clearly describing your main implementation choices, the main functionality of your simulator,
the set of experiments conducted, and the findings of your experimental evaluation
of the above algorithms. In particular, in the latter part you should try to draw conclusions
about (i) the algorithms’ correctness and (ii) the performance (time and messages)
of each algorithm individually (e.g., what was the worst/best/average performance of each
algorithm as a function of n? For example, we know from the lectures that the worst-case
communication complexity of LCR is O(n
2
): can you verify this experimentally?) and when
the two algorithms are being compared against each other (e.g., which one performs better
and in which settings?).
4 Deadline and Submission Instructions
• The deadline for submitting this assignment is Monday, 15th March 2021, 17:00
UK time (UTC).
7
• Submit
(a) The Java source code for all your programs,
(b) A README file (plain text) describing how to compile/run your code to produce
the various results required by the assignment, and
(c) A concise self-contained report (at most 5 pages including everything) describing
your implementation choices, experiments, and conclusions in PDF format.
Compress all of the above files into a single ZIP file (the electronic submission system
won’t accept any other file formats) and specify the filename as Surname-NameID.zip.
It is extremely important that you include in the archive all the files described
above and not just the source code!
• Submission is via the “Assignments” tab of COMP212-202021 course on CANVAS.
Good luck to all!
8
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写infosys 110 digital syst...
2024-12-28
代写fbe 506 quantitative met...
2024-12-28
代做part i: (crazy eddie htm...
2024-12-28
代写infosys 110 digital syst...
2024-12-28
代做stats 769 statistics sec...
2024-12-28
代写ece3700j introduction to...
2024-12-28
代做tcm2301 biochemistry代做...
2024-12-28
代做ece5550: applied kalman ...
2024-12-28
代写mth205 introduction to s...
2024-12-28
代写scicomp project 3 week 4...
2024-12-28
代做business operations anal...
2024-12-28
代写mth205 introduction to s...
2024-12-28
代写socs0100 computational t...
2024-12-28
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!