Vous êtes sur la page 1sur 5

1

CCSC 1170/1197
loundaLlons of ulsLrlbuLed CompuLlng / ulsLrlbuLed SysLems: AsslgnmenL 1


Ioundat|ons of D|str|buted Comput|ng
D|str|buted Systems
CCSC 1170]1197


Ass|gnment 1


kemote rocedure Ca|||ng

A|ms


1he purpose of Lhls asslgnmenL ls Lo exempllfy and explore some lmporLanL lssues of remoLe
procedure calllng. 1hls asslgnmenL requlres an undersLandlng of Lhe baslcs of remoLe
procedure calllng.

Method
SLudenLs wlll aLLempL Lhls asslgnmenL lndlvldually.

1|me frame
1lme allocaLed for Lhls pro[ecL: 7 Leachlng weeks (7 calendar weeks)
uue daLe: 16
Lh
Aprll 2014, 9:30 pm

Subm|ss|on
What to subm|t
1. a clear and brlef (less Lhan one page) descrlpLlon of whaL you dld, how your
program works
2. a record of runnlng your program, e.g. produced by Lhe !"#$%& command (for
furLher reference see: ()* !"#$%&), LhaL lncludes Lhe daLe and Llme when Lhe
program ran
3. Lhe source code
Subm|ss|on format
1he preferred formaL ls when each of Lhe above llsLed modules ls ln a separaLe flle. ?ou
can submlL dlrecLorles and subdlrecLorles, buL do noL use more Lhan 3 levels of depLh
ln subdlrecLorles. ?ou may submlL one archlve wlLh all your flles (zlp or Lar).
Subm|ss|on method
Submlsslon ls Lhrough WebLearn. All your flles should be uploaded Lo WebLearn. A zlp
or Lar flle should conLaln all Lhe aforemenLloned flles. No spec|a| cons|derat|on w|||
be g|ven to any student who has not used WebLearn proper|y
2
CCSC 1170/1197
loundaLlons of ulsLrlbuLed CompuLlng / ulsLrlbuLed SysLems: AsslgnmenL 1


D|str|buted Comput|ng

ln Lhls asslgnmenL you wlll lmplemenL a slmulaLlon of a Lram Lracklng sysLem. ?ou wlll produce a
server componenL Lo Lrack locaLlons of Lrams and a cllenL componenL LhaL slmulaLes Lrams.

1he sysLem conslsLs of one server.

art A: 1rack|ng Serv|ce - 1racks |ocat|ons of trams.

1hls server ls a slngleLon.

1rack|ng Serv|ce

1he Lram sLops ln each rouLe are hard coded on Lhe server.

1=1,2,3,4,3
96=23,24,2,34,22
101=123,11,22,34,3,4,7
109=88,87,83,80,9,7,2,1
112=110,123,11,22,34,33,29,4

8ouLe 1 conslsLs of Lrams sLops 1, 2, 3, 4 and 3, and rouLe 96 conslsLs of sLops 23, 24, 2, 34 and 22.
1hls servlce exposes Lwo funcLlons
l. #+&#$+,+-+.&/&0%12 - AccepLs a rouLe ld, Lhe currenL Lram sLop number, whlch ls Lhe lasL
sLop vlslLed by Lhe Lram and Lhe prevlous Lram sLop number. 8eLurns Lhe nexL sLop ln Lhe
rouLe. lf Lhe currenL Lram sLop number ls Lhe lasL one, Lhe nexL wlll be Lhe prevlous one.
1hls slmulaLes Lhe facL LhaL a Lram Lravels up and down a parLlcular rouLe. Cnly Lram
cllenLs are allowed Lo access #+&#$+,+-+.&/&0%12. 1he server should use Lhe currenL sLop
and Lhe prevlous sLop Lo ldenLlfy Lhe dlrecLlon ln whlch Lhe Lram ls Lravelllng.
ll. 3%4)&+5#)(60")&$0*12 - AccepLs a Lram ld and sLop ld, and updaLes Lhe locaLlon deLalls.
Cnly Lram cllenLs are allowed Lo access 3%4)&+5#)(60")&$0*12.

1ram C||ents

1hese cllenLs are used Lo slmulaLe acLual Lrams. 1ram cllenLs conLlnuously updaLe Lhe Lracklng servlce
regardlng Lhelr locaLlons. 8eLween each updaLe requesL, each Lram cllenL sleeps for a Llme lnLerval
LhaL randomly varles beLween 10 Lo 20 seconds. 1hls slmulaLes Lhe Llme Laken by a Lram Lo Lravel
from one sLop Lo anoLher.

updaLlng Lhe locaLlon of a Lram - ConslsLs of Lwo operaLlons.
1. A Lram cllenL reLrleves Lhe nexL sLop from Lhe Lracklng servlce.
2. 1hen, lL updaLes Lhe nexL sLop as Lhe currenL locaLlon of Lhe Lram. A requesL ls senL Lo Lhe
Lracklng servlce Lo perform Lhls. 1he nexL sLop and Lhe currenL Llme should be prlnLed on Lhe
cllenL console before sendlng an updaLe requesL Lo Lhe Lracklng servlce.
3
CCSC 1170/1197
loundaLlons of ulsLrlbuLed CompuLlng / ulsLrlbuLed SysLems: AsslgnmenL 1


Message structure def|n|t|ons

1he followlng message sLrucLures should be used.

!"#" %&'()(*(+)

%378$" "8)!! 9:;<+!!)=+ $(%8+(+*&! /+#$)8$>)78+?
%378$" !&)&$" @$*)8 !A0#& 9BCDB/5 E FG
%378$" !&)&$" @$*)8 !A0#& 9B:6H E IG
%378$" +*3( <+!!)=+5J%+?9BCDB/5K 9B:6HLG
%#$,)&+ <+!!)=+5J%+ (+!!)=+5J%+G
%#$,)&+ 80*= 5#)*!)"&$0*M4 NO &#)*!)"&$0* $4 ON
%#$,)&+ 80*= 9:;M4G NO P807)88J 3*$Q3+ $4+*&$@$+# ON
%#$,)&+ 80*= 9+Q3+!&M4G NO ;8$+*& #+Q3+!& (+!!)=+ "03*&+# ON
%#$,)&+ !A0#& %#0"+43#+M4G NO +R=R1IKSKTKU2 ON
%#$,)&+ /&#$*= "!,V4)&) NO 4)&) )! "0(() !+%)#)&+4 ,)83+!ON
%#$,)&+ !A0#& !&)&3!G
L

,+-."* +' /0#1%"*"

1. 8equesLs senL from a Lram cllenL Lo Lhe Lracklng server Lo lnvoke #+&#$+,+-+.&/&0%12.
#03&+ $4K "3##+*& !&0% *3(7+#K %#+,$03! !&0% *3(7+#

2. 8esponse from Lhe rouLe server Lo a Lram cllenL when #+&#$+,+-+.&/&0%12 ls lnvoked.
*+.& !&0% *3(7+#
lf Lhe nexL sLop number cannoL be reLrleved (l.e. parameLers rouLe ld, currenL sLop number
and prevlous sLop number are lnvalld) -1 should be seL Lo Lhe nexL sLop number.

3. 8equesL from a Lram cllenL Lo Lhe Lracklng server Lo lnvoke 3%4)&+5#)(60")&$0*12R
&#)( $4K !&0% $4

4. 8esponse from Lhe Lracklng server Lo a Lram cllenL when 3%4)&+5#)(60")&$0*12 ls lnvoked.
"!,V4)&) $! +(%&J



Va||dat|ons

8oLh cllenLs and server should make use of Lhe (+!!)=+5J%+ fleld Lo LesL LhaL requesLs
and replles are noL confused (l.e. valldaLlons should be performed aL boLh cllenLs and server).


Lach LransacLlon should have a unlque 5#)*!)"&$0*M4, and server should copy Lhe
5#)*!)"&$0*M4 from Lhe requesL Lo Lhe reply so LhaL lL can be valldaLed by Lhe cllenL.

4
CCSC 1170/1197
loundaLlons of ulsLrlbuLed CompuLlng / ulsLrlbuLed SysLems: AsslgnmenL 1



Lach cllenL should generaLe a new 9:;M4 for each call, and server should copy Lhe
8Cld from a requesL Lo Lhe relevanL reply. CllenLs should valldaLe Lhe 9:;M4 ln each
reply. 9:;M4 ls a globally unlque ldenLlfler, l.e. no Lwo messages ln Lhe sysLem should have
Lhe same 9:;M4, even lf dlfferenL hosLs generaLe Lhem.

Lach cllenL should also generaLe a new 9+Q3+!&M4 for each requesL, and Lhe server
should copy Lhe 9+Q3+!&M4 from a requesL Lo Lhe relevanL reply. CllenLs should valldaLe
Lhe 9+Q3+!&M4 ln each reply. 9+Q3+!&M4 ls used Lo keep Lrack of Lhe number of requesLs lssued
by a cllenL, and each 9+Q3+!&M4 ls unlque wlLhln Lhe lssulng cllenL.

:#0"+43#+M4 ls used Lo ensure LhaL Lhe requesL ls handled by Lhe approprlaLe remoLe
meLhod. 1hls fleld should be valldaLed, a) aL Lhe server before commencemenL of any
processlng, and b) aL cllenLs before processlng any replles.

1he sLaLus parameLer ls used Lo lndlcaLe Lhe sLaLus of a LransacLlon. 0 lndlcaLes
LhaL Lhe LransacLlon was compleLed successfully. A non-zero value lndlcaLes LhaL Lhere was an
error aL a server, and cllenLs should dlsplay sulLable error messages.

Cnly Lhe number of characLers lndlcaLed by Lhe lengLh fleld should be reLrleved
uslng "!,V4)&).

System ropert|es and L|m|ts

1.Lach rouLe wlll have an upper llmlL of 3 Lrams.
2.Lach rouLe wlll have mlnlmum 3 sLops.
3.Lach Lrams sLop should have a unlque ld.
4.Lach Lram should have a unlque ld.
3
CCSC 1170/1197
loundaLlons of ulsLrlbuLed CompuLlng / ulsLrlbuLed SysLems: AsslgnmenL 1


art 8: Marsha|||ng ] Unmarsha|||ng

Make a copy of your lmplemenLaLlon so far. 1hls exerclse requlres you Lo wrlLe your own marshalllng
and unmarshalllng procedures, whlch wlll work on Lop of Lhe marshalllng (SerlallzaLlon) procedures
provlded by !ava 8Ml. 1haL ls, your server and cllenL funcLlons musL be modlfled Lo pass ob[ecLs of
Lype Message over 8Ml.



$(%0#& W),)R$0R/+#$)8$>)78+G


%378$" "8)!! <+!!)=+ $(%8+(+*&! /+#$)8$>)78+?
%#0&+"&+4 7J&+ 4)&)XY E *388G
%#0&+"&+4 $*& 8+*=&A E FG

%378$" ,0$4 ()#!A)819:;<+!!)=+ #%"<+!!)=+2?
L

%378$" )7!&#)"& 9:;<+!!)=+ 3*<)#!A)812?
L
L



When marshalllng, an lnLeger should be sLored ln 4 byLes and a characLer should be sLored ln 2 byLes.
1he lengLh fleld should be used Lo valldaLe marshalled messages.

What to demonstrate

ln your submlsslon lnclude a sample run wlLh Lhe followlng ouLpuL: Lhe resulL senL back Lo Lhe
cllenL by Lhe server LhaL performs operaLlons for several cllenLs, and whlch behaves senslbly
when deallng wlLh excepLlonal condlLlons. (lor recordlng a sesslon, please see Lhe !"#$%&
command under unlx.) no concurrency conLrol needs Lo be lmplemenLed, so users can
lnLerfere wlLh each oLher's operaLlons ln a way LhaL leads Lo error condlLlons, as allowed by
Lhe unlx flle sysLem.
1he record of a sesslon should lnclude daLe and Llme as ouLpuLLed by unlx.
rovlde Lhe resulLs (lncludlng source code) for boLh verslons: wlLh and wlLhouL your own
marshalllng procedures.

1he Lnd