Vous êtes sur la page 1sur 19

Uni

t-
2Int
erpr
ocessCommuni
cat
ion

Sylabus:I
l nterpr
ocess Communi cati
on:Introducti
on,The APIf ort he I
nter
net
Protocol
s-The Character
isti
cs ofI nter
pr ocess communi cati
on,Sockets,UDP
Datagram Communi cat
ion, TCP St ream Communi cati
on; External Data
Representat
ion and Mar shalli
ng; Client Ser ver Communi cati
on; Gr oup
Communi cation-IP Multicast-an i mplementation ofgr oup communi cat
ion,
Reli
abil
it
yandOr deri
ngofMul t
icast.

Topi
c01:I
NTRODUCTI
ON

• Thej
avaAPIf
ori
nter
processcommuni
cat
ioni
nthei
nter
netpr
ovi
desbot
h
dat
agram andst
ream communi
cati
on.
§ Thetwocommunicat
ionpat
ter
nst
hataremostcommonl
yusedi
ndi
str
ibut
ed
pr
ograms:

ØCl
i
ent
-Ser
vercommuni cat
ion
• Ther equestandr epl
ymessagesprovi
det
hebasi
sfor
r
emot emet hodinvocat
ion(
RMI)orremot
epr
ocedurecal
l
(
RPC) .
ØGr
oupcommuni cat
ion

• Thesamemessagei
ssentt
osev
eral
processes.

Fi
g:Middl
ewar
elayer
s
• RemoteMethodI
nvocat
ion(RMI)
• Ital
l
owsanobjecttoinv
okeamet
hodi
nanobj
ecti
nar
emot
epr
ocess.
• E.
g.CORBAandJav
aRMI
• Remot
eProcedur
eCall(
RPC)
• I
tal
lowsacli
enttocal
lapr
ocedur
einar
emot
eser
ver
.
§ The appl
i
cat
ion pr
ogr
am i
nter
face

(
API
)toUDPpr
ovi
desamessagepassi
ngabst
ract
ion.

Messagepassi
ngi
sthesi
mpl
estf
orm ofi
nter
processcommuni
cat
ion.

APIenabl
esasendi ngprocesstotransmi tasingl
emessaget oarecei
vingprocess.
ØThei ndependentpacket scontaini
ngthesesmessagesarecalled
datagrams.
ØInt heJavaandUNI XAPI s,
thesenderspecif
iesthedesti
nati
onusinga
socket.
• Soc keti
sani ndi
rectrefer
encet oaparti
cul
arportusedbythe
dest i
nat
ionprocessatadest i
nati
oncomput er
.

• Theappl
i
cat
ionpr
ogr
am i
nter
face(
API
)toTCPpr
ovi
dest
heabst
ract
ionofa
two-waystream betweenpai rsofpr ocesses.
• Thei nfor
mat ioncommuni cat
edconsi stsofastream ofdatai
temswithno
messageboundar i
es.
• Re quest-
replyprotocolsaredesignedt osupportcli
ent-
serv
er
communi cati
oni ntheform ofeitherRMIorRPC.
§ Groupmul t
icastprotocolsaredesignedt osupportgroupcommunicati
on.
• Gr oupmul ti
castisaf orm ofint
erprocesscommuni cati
oninwhichone
processi
nagr oupofpr ocessest r
ansmi t
sthesamemessaget oal
l
member soft hegroup.

Topi
cNo:02:TheAPIf
ort
heI
nter
netPr
otocol
s

SubTopi
c2.
1:TheChar
act
eri
sti
csofI
nter
processCommuni
cat
ion

• Sy
nchr
onousandasy
nchr
onouscommuni
cat
ion
ØI
nt hesynchronousf orm,bot
hsendandreceiv
eareblocki
ngoperati
ons.
• Intheasy nchronousform,t
heuseofthesendoperati
onisnon-
blocki
ng
andther eceiv
eoper ati
oncanhavebl
ockingandnon-bl
ocki
ngvariant
s.

§ Messagedest inati
ons
ØAl ocalportisamessagedest inati
onwi t
hinacomput er
,speci
fiedasaninteger.
ØApor thasanexact lyonerecei
verbutcanhav emanysender s.
§ Rel
i
abili
ty
ØAr eli
ablecommuni cati
onisdefinedintermsofv ali
dit
yandi nt
egri
ty.
• Apoi nt-
to-
pointmessageserviceisdescribedasreli
ableifmessagesar e
guaranteedtobedel i
ver
eddespi t
ear easonablenumberofpacket sbeing
droppedorl ost
.
• Fori ntegri
ty,messagesmustar r
iveuncorruptedandwi t
houtdupli
cati
on.
• Ordering
• Somea ppl
i
cat
ionsr
equi
ret
hatmessagesbedel
i
ver
edi
nsenderor
der
.
SubTopi
c2.2:Socket
s

• I
nter
netI
PCmechani
sm ofUni
xandot
heroper
ati
ngsy
stems(
BSDUni
x,Sol
ari
s,
Linux,Wi ndowsNT, Maci ntoshOS)
§Processesi ntheabov eOScansendandr ecei
vemessagesv i
aasocket.
• Soc ketsneedt obeboundt oapor tnumberandani nternetaddr
essinorderto
sendandr ecei
vemessages.
§Eachsockethasat ransportprotocol (TCPorUDP) .
• Me ssagessentt osomei nternetaddr essandpor tnumbercanonl ybe
receivedbyapr ocessusi ngasockett hatisboundtot hi
saddressandpor t
number .
§Processescannotshar eports(except i
on: TCPmul ti
cast).
• Bot hformsofcommuni cati
on, UDPandTCP, usethesocketabstract
ion,which
prov i
desandendpoi ntforcommuni cat i
onbetweenpr ocesses.
• Interprocesscommuni cati
onconsi stsoft ransmit
ti
ngamessagebet weena
socketi nonepr ocessandasocketi nanot herpr
ocess.

Fi
gur
e.Socket
sandpor
ts

SubTopi
c2.3:UDPDat agram Communi cati
on
• UDPda tagram pr oper
ti
es
• Nogua ranteeoforderpreser
vati
on
• Me ssagel ossandduplicati
onsarepossi
ble
• Necessaryst eps
• Cr eatingasocket
• Bi ndingasockett oapor tandlocal
Int
ernetaddr
ess

• Acl
i
entbi
ndst
oanyf
reel
ocal
por
t

 Aser
verbi
ndst
oaser
verpor
t

§ Recei
vemet hod
ØItr
eturnsInt
ernetaddressandportofsender
,pl
usmessage.
§Issuesrel
atedtodatagram communi cat
ionsare:

ØMessagesi
ze
IPall
owsf
ormessagesofupt
o216by
tes.

 Mosti
mpl
ement
ati
onsr
est
ri
ctt
hist
oar
ound8kby
tes.
• Anyappl
i
cat
ionr
equi
ri
ngmessagesl
argert
hant
he
maxi
mum mustf
ragment
.
• I
far
ri
vi
ngmessagei
stoobi
gforar
rayal
l
ocat
edt
orecei
ve
messagecont ent,t
runcat
ionoccurs.
ØBl
ocki
ng
 Send:non-blocki
ng
• upona rri
val
,messageisplacedinaqueuef orthe
socketthatisboundtothedestinat
ionport
.
 Recei
ve:blocking
§ Pre-emptionbytimeoutpossibl
e
• I fprocesswishestoconti
nuewhi l
ewaiti
ngf or
packet,useseparatet
hread

ØTi
meout
ØRecei
vef
rom any

§ UDPdat
agr
amssufferf
rom f
oll
owi
ngfail
ures:
ØOmissi
onfai
l
ure
ØMessagesmaybedroppedoccasi
onall
y,
• Order
ing

Jav
aAPIf
orUDPDat
agr
ams

• TheJavaAPIprov
idesdat
agr
am communicat
ionbyt
woclasses:
• Datagr
amPacket
• Itprovi
desaconst
ruct
ort
omakeanar r
ayofbytescompr
isi
ng:
• Messagecont ent
• Lengthofmessage
• Int
ernetaddress
• Localportnumber

• I
tpr
ovi
desanot
hersi
mil
arconst
ruct
orf
orr
ecei
vi
ngamessage.

• Dat
agr
amSocket
• Thi
sclasssuppor
tssocket
sforsendi
ngandr
ecei
vi
ngUDP
dat
agram.
• I
tprovi
desaconstr
uctorwit
hportnumberasar
gument
.
• No-
argumentconst
ructori
susedtochooseafr
eel
ocalpor
t.
• Dat
agramSocketmethodsare:

• sendandrecei
ve
• setSoTi
meout
• connect

Ø Exampl
e
Ø Theprocesscr
eat
esasocket
,sendsamessaget
oaser
veratpor
t6789and
wai
tst
orecei
vear
epl
y.

i
mpor
tjav
a.net
.*;

i
mpor
tjav
a.i
o.*
;

publ
i
ccl
assUDPCl
i
ent
{

publ
i
cst
ati
cvoi
dmai
n(St
ri
ngar
gs[
])
{

• ar
gsgi
vemessagecont
ent
sanddest
inat
ion
host
nametr
y{

DatagramSocketaSocket=newDatagr
amSocket
();
//cr
eat
e
socketbyt
e[]m =args[0]
.get
Byt
es(
);

I
netAddressaHost=Inet
Addr
ess.
get
ByName(
args[
1])
;//DNS
l
ookupintserv
erPor
t=6789;

Datagr
amPacketrequest=newDatagramPacket(
m, ar
gs[
0].
lengt
h()
,aHost
,ser
ver
Por
t);
aSocket
.send(
request
);/
/sendnessagebyt
e[]buff
er=newby te[
1000]
;

DatagramPacket r epl
y = new Dat agramPacket(
buf f
er,
buffer
.l
ength); aSocket.
recei
ve(
repl
y); //wait for r epl
y
System.out.
pri
ntl
n("
Reply:"+ new St r
ing(
repl
y.
getData())
);
aSocket.
close()
;

}
cat
ch(
Socket
Except
ione)
{Sy
stem.
out
.pr
int
ln(
"Socket
:"+e.
get
Message(
));

}
cat
ch(
IOExcept
ione)
{Sy
stem.
out
.pr
int
ln(
"I
O:"+e.
get
Message(
));
}

}f
inal
l
y{i
f(aSocket!
=nul
l
)aSocket
.cl
ose(
)}

Fi
gur
e.UDPcl
ientsendsamessaget
otheser
verandget
sar
epl
y(Abov
eJav
aCode)

–Exampl
e

Theprocesscr
eat
esasocket
,boundt
oit
sser
verpor
t6789andwai
tst
orecei
vea
r
equestmessagefr
om acl
i
ent.

i
mpor tjava.
net.
*;
i
mpor tjava.
io.
*;
publi
cclassUDPServer{
publi
cst at
icvoi
dmain(St
ri
ngargs[
])
{
DatagramSocketaSocket=nul
l
;
tr
y
{
aSocket=newDat agr amSocket (6789) ;
byte[]buf f
er=newby te[1000];
Whi l
e(true){
Datagr amPacketr equest=newDat agr amPacket (
buffer,
buffer.
lengt h)
;aSocket .receive(request )
;
Datagr amPacketr eply=newDat agramPacket (request.getData()
;
request .
getLengt h(),
request .
get Addr ess()
,request.getPort(
);
aSocket .send(reply)
;
}
}catch( SocketExcept i
one) {
Sy stem. out .
pri
ntl
n("Socket:"+e. getMessage(
));
}catch( I
OExcept ione) {System. out.printl
n("I
O:"+
e.getMessage( ) )
;}}f
inally{
if(aSocket! =null)
aSocket.cl
ose( )
}}
}

Figur
e.UDPser
verr
epeat
edl
yrecei
vesar
equestandsendsi
tbackt
othecl
ient
(AboveJav
aCode)

SubTopi
c2.
4:TCPSt
ream Communi
cat
ion

• TheAPIt
otheTCPprot
ocol
prov
idest
heabst
ract
ionofast
ream ofby
test
obe
wri
tt
entoorr
eadf
rom.

ØChar
act
eri
sti
csoft
hest
ream abst
ract
ion:

 Messagesizes
 Lostmessages
 Fl
owcontrol
 Messagedesti
nat
ions

§ UseofTCP

ØManyservi
cesthatr unoverTCPconnect i
ons,wit
hreser
vedpor
tnumber
ar
e:
 HTTP(Hy pertextTransferProtocol)
 FTP(Fi
l
eTr ansferProtocol
)
 Tel
net
• SMTP( SimpleMai lTransferProtocol
)
• Matchi
ngofdat aitems

ØBl
ocki
ng
ØThr
eads

• Jav
aAPIf
orTCPst
reams

• TheJav
aint
erf
acet
oTCPst
reamsi
spr
ovi
dedi
nthecl
asses:

• Server
Socket
• I ti
susedbyaservert
ocreat
easocketatser
verpor
ttol
i
stenf
or
connectr
equest
sfrom cl
i
ent
s.
• Socket
• Iti
susedbyapai rofprocesseswithaconnecti
on.
• Thecli
entusesaconstructortocreateasocketandconnecti
tto
theremotehostandpor tofaserver.
• Itpr
ovidesmethodsforaccessinginputandoutputst
reams
associ
atedwit
hasocket .

–Exampl
e

NOTheCODEcl
i
ent
….FI
GUREpr
ocesscr
eat
esasocket
,boundt
othehost
nameandser
verpor
t6789.
–Exampl
e

Theserverpr
ocessopensaser
versockett
oit
sser
verpor
t6789andl
i
stensf
or
connectr
equest
s.

i
mpor
tjav
a.net
.*;

i
mpor
tjav
a.i
o.*
;

publ
i
ccl
assTCPSer
ver{

publ
i
cst
ati
cvoi
dmai
n(St
ri
ngar
gs[
]){

t
ry{

i
ntser
ver
Por
t=7896;

Ser
ver
Socketl
i
stenSocket=newSer
ver
Socket
(ser
ver
Por
t);

whi
l
e(t
rue){

Socketcl
i
ent
Socket=l
i
stenSocket
.accept
();

Connect
ionc=newConnect
ion(
cli
ent
Socket
);}

}cat
ch(
IOExcept
ione){
Syst
em.
out
.pr
int
ln(
"Li
stensocket
:"
+e.
get
Message(
));
}

}
Fi
gure:
.TCPser vermakesaconnect
ionf
oreachcl
ientandt
henechoest
he
cl
ientsrequest

cl
assConnect
ionext
endsThr
ead{

Dat
aInput
Str
eam i
n;

Dat
aOut
put
Str
eam out
;

Socketcl
i
ent
Socket
;

publ
i
cConnect
ion(
SocketaCl
i
ent
Socket
){
t
ry{

cl
i
ent
Socket=aCl
i
ent
Socket
;

i
n=new

Dat
aInput
Str
eam(cl
i
ent
Socket
.get
Input
Str
eam(
));
out

=new

Dat
aOut
put
Str
eam(cl
i
ent
Socket
.get
Out
put
Str
eam(
));

t
his.
star
t()
;

}cat
ch(
IOExcept
ione)
{Sy
stem.
out
.pr
int
ln(
"Connect
ion:
"+e.
get
Message(
));
}

publ
i
cvoi
drun(
){

t
ry{ /
/anechoser
ver

St
ri
ngdat
a=i
n.r
eadUTF(
);

out
.wr
it
eUTF(
dat
a);

}cat
ch(
EOFExcept
ione)
{Sy
stem.
out
.pr
int
ln(
"EOF:
"+e.
get
Message(
));

}cat
ch(
IOExcept
ione)
{
Syst
em.
out
.pr
int
ln(
"readl
i
ne:
"+e.
get
Message(
));
}}f
inal
l
y
{
try
{cl
i
ent
Socket
.cl
ose(
);
}cat
ch(
IOExcept
ione)
{/*
closef
ail
ed*
/}}

Fi
gure.TCPservermakesaconnect
ionf
oreachcl
ientandt
henechoest
he
cl
ientsrequest

Topi
cNo3:
Ext
ernalDat
aRepr
esent
ati
on

• Thei
nfor
mat
ionst
oredi
nrunni
ngpr
ogr
amsi
srepr
esent
edasdat
ast
ruct
ures,
wher
east
hei
nfor
mat
ioni
nmessagesconsi
stsofsequencesofby
tes.
• I
rr
espect
iveoft
hef
orm ofcommuni
cat
ionused,
thedat
ast
ruct
uremustbe
convert
edtoasequenceofbytesbeforetr
ansmissi
onandr
ebuil
tonarr
ival
.
• Exter
nalDataRepr
esent
ati
onisanagr eedstandar
dfort
her
epresent
ati
on
ofdatastr
uctur
esandpri
miti
vev al
ues.
§ Dat
arepr
esent
ati
onpr
obl
emsar
e:

§ Usi
ngagr
eedext
ernal
repr
esent
ati
on,
twoconv
ersi
onsnecessar
y

§ Usi
ngsendersorr
ecei
versf
ormatandconv
ertatt
heot
herend

§ Mar
shal
l
ing

• Marshal
l
ingi
stheprocessoftaki
ngacoll
ecti
onofdatait
emsand
assembl
ingt
hem i
ntoaf or
m suit
abl
efort
ransmissi
oninamessage.

§ Unmar
shal
l
ing

• Unmar
shal
l
ingi
sthepr
ocessofdi
sassembl
i
ngacol
l
ect
ionofdat
aon
arr
ivalt
oproduceanequi
val
entcol
l
ect
ionofdat
ait
emsatt
he
desti
nati
on.

§ Thr
eeappr
oachest
oext
ernal
dat
arepr
esent
ati
onandmar
shal
l
ingar
e:

§ CORBA
§ Jav
asobj
ectser
ial
i
zat
ion
§ XML

• Mar
shal
l
ingandunmar
shal
l
ingact
ivi
ti
esi
susual
l
yper
for
med
aut
omatical
l
ybymiddl
ewarelay
er.
• Marshal
l
ingisl
i
kel
yerr
or-
proneifcar
ri
edoutbyhand.

SubTopi
c3.
1:CORBACommonDat
aRepr
esent
ati
on(
CDR)

• CORBACommonDat
aRepresentat
ion(CDR)
• CORBACDRistheext
ernaldatarepr
esent
ati
ondef
inedwi
thCORBA2.
0.
• I
tconsi
sts15pr
imi
ti
vet
ypes:

• Short(16bit)
• Long( 32bit
)
• Unsignedshort
• Unsignedlong
• Fl
oat(32bit)
• Double(64bit)
• Char
• Boolean(TRUE,FALSE)
• Octet(
8bi t
)
• Any(canrepresentanybasi
corconst
ruct
edt
ype)

• Composi
tet
ypear
eshowni
nFi
gur
e
Fi
gur
e.CORBACDRf
orconst
ruct
edt
ypes

• Const
ruct
edt
ypes:
Thepr
imi
ti
vev
aluest
hatcompr
iseeach
constr
uctedtypeareaddedtoasequenceofby tesinaparti
cular
order,
asshowni nabov et
able/Figur
e.
• BelowFigure/tabl
eshowsamessagei nCORBACDRt hat
contai
nsthethreefiel
dsofastructwhoserespect
ivet
y pesare
stri
ng,st
ri
ng,andunsignedlong.

• exampl
e:st
ructwi
thv
alue{Smi
th,
London,
1934}

Fi
gur
e.CORBACDRmessage

Subt
opi
c3.
2:Jav
aobj
ectser
ial
izat
ion

• I
nJav
aRMI
,bot
hobj
ectandpr
imi
ti
vedat
aval
uesmaybepassedas
ar
gument
sandr
esul
tsofmet
hodi
nvocat
ion.
• Anobj
ecti
sani
nst
anceofaJav
acl
ass.
• Exampl
e,t
heJav
acl
assequi
val
entt
othePer
sonst
ruct

Publ
i
ccl
assPer
soni
mpl
ement
sSer
ial
i
zabl
e{

Pr
ivat
eSt
ri
ngname;

Pr
ivat
eSt
ri
ngpl
ace;

Pr
ivat
einty
ear
;

Publ
i
cPer
son(
Str
ingaName,
Str
ingaPl
ace,
int

aYear
){name=aName;

pl
ace=aPl
ace;

y
ear=aYear
;

/
/fol
l
owedbymet
hodsf
oraccessi
ngt
hei
nst
ancev
ari
abl
es

Fi
gur
e.I
ndi
cat
ionofJav
aser
ial
izat
ionf
orm

Remot
eObj
ectRef
erences

• Remot
eobj
ectr
efer
encesar
eneededwhenacl
i
enti
nvokesanobj
ectt
hati
s
l
ocat
edonar
emot
eser
ver
.
• Ar
emot
eobj
ectr
efer
encei
spassedi
nthei
nvocat
ionmessaget
ospeci
fywhi
ch
objectistobei nvoked.
• Re mot eobjectrefer
encesmustbeuni queoverspaceandt i
me.
• I
ngener al,maybemanypr ocesseshostingr
emot eobject
s,sor
emot eobj
ect
refer
encing
mustbeuni queamongal loft
hepr ocessesi
nthev ar
iouscomputer
sina
distr
ibutedsystem.
• gener
icf
ormatf
orr
emot
eobj
ectr
efer
encesi
sshowni
nbel
owFi
gur
e.

Fi
gur
e:Repr
esent
ati
onofar
emot
eobj
ectr
efer
ences

• i
nter
netaddress/por
tnumber
:processwhi
chcreat
edobj
ect
• ti
me: cr
eat
iontime
• obj
ectnumber:local
count
er,
incr
ementedeachti
meanobjecti
s
creat
edinthecr
eati
ngprocess
• i
nterf
ace:howtoaccesstheremoteobj
ect(
ifobj
ectr
efer
encei
s
passedfr
om onecli
enttoanother
)

Topi
cNo4:
Cli
ent
-Ser
verCommuni
cat
ion

• Thecl
ient
-ser
vercommuni
cat
ioni
sdesi
gnedt
osuppor
tther
olesand
messageexchangesi
nty
pical
cli
ent
-ser
veri
nter
act
ions.
• I
nthenor
mal
case,
request
-r
epl
ycommuni
cat
ioni
ssy
nchr
onousbecause
t
hecl
i
entpr
ocessbl
ocksunt
ilt
her
epl
yar
ri
vesf
rom t
heser
ver
.
• Asy
nchr
onousr
equest
-r
epl
ycommuni
cat
ioni
sanal
ter
nat
ivet
hati
susef
ul
wher eclientscanaf fordtor etri
ever epli
eslater.
§ Oftenbui l
tov erUDPdat agrams
• Cl ient-
serverpr otocolconsistsofr equest/responsepair
s,henceno
acknowl edgement satt r
anspor tl
ay erarenecessary
§ Av oidanceofconnect ionest abli
shmentov erhead
§ Noneedf orflowcont rolduet osmal lamount sofdat
aaret r
ansfer
red
• Ther equest -
replyprotocol wasbasedonat r
ioofcommuni cati
on
primiti
ves: doOper at
ion,getRequest , andsendReplyshowni nFi
gure.

Fi
gur
e:.Request
-r
epl
ycommuni
cat
ion
• Thedesi
gnedr
equest
-r
epl
ypr
otocol
mat
chesr
equest
stor
epl
i
es.
• IfUDPdat agramsareused,thedel
iv
eryguaranteesmustbeprovi
dedbyt
he
request
-replyprot
ocol
,whichmayuset heserverrepl
ymessageasan
acknowledgementofthecl i
entr
equestmessage.

• Fi
gur
eout
li
nest
het
hreecommuni
cat
ionpr
imi
ti
ves.

Fi
gur
e:.Oper
ati
onsoft
her
equest
-r
epl
ypr
otocol

• Thei
nfor
mat
iont
obet
ransmi
tt
edi
nar
equestmessageorar
epl
ymessagei
s
showni
nFi
gur
e.

Fi
gur
e:Request
-r
epl
ymessagest
ruct
ure

• I
napr
otocol
message

ØThefir
stfi
eldindi
cateswhethert hemessageisarequestorar
epl
y
message.
ØThesecondf i
eldrequesti
dcont ainsamessageidenti
fi
er.
ØThethir
dfi
eldisar emoteobjectr ef
erence.
ØThefort
hfiel
di sanidenti
fi
erforthemet hodtobeinv
oked.
§ Messagei
dent
if
ier

ØAmessagei
dent
if
ierconsi
stsoft
wopar
ts:

• Ar
equest
Id,
whi
chi
stakenf
rom ani
ncr
easi
ngsequenceof
i
nteger
sbyt
hesendi
ngpr
ocess
• Ani
dent
if
ierf
ort
hesenderpr
ocess,
forexampl
eit
spor
tand
I
nter
netaddress.
§ Fai
l
uremodel
oftherequest
-repl
ypr
otocol

• I
fthethr
eepri
miti
vedoOperat
ion,
getRequest
,andsendRepl
yar
e
i
mplementedoverUDPdatagr
am, t
heyhavethesamecommunicat
ion
f
ail
ures.

§ Omissi
onfai
l
ure
§ Messagesar
enotguar
ant
eedt
obedel
i
ver
edi
nsenderor
der
.

§ RPCexchangepr
otocol
s

ØThr
eepr
otocol
sar
eusedf
ori
mpl
ement
ingv
ari
oust
ypesofRPC.

§ Ther
equest(R)protocol
.
§ Ther
equest-
reply(RR)prot
ocol.
• Therequest-
reply
-acknowledge(RRA)pr
otocol
.

Fi
gur
e.RPCexchangepr
otocol
s

• I
ntheRprot
ocol,
asi
ngl
erequestmessagei
ssentbyt
hecli
enttot
heserver
.
• TheRpr
otocol
maybeusedwhent her
eisnoval
uetober
eturnedf
rom t
he
remotemet hod.
• TheRRpr otocoli
susef
ulformostcli
ent
-serv
erexchangesbecauseitis
basedonr equest
-r
epl
yprotocol
.
• RRAprotocol i
sbasedontheexchangeofthreemessages:
request-
reply
-
acknowl
edger
epl
y.

§ HTTP:
anexampl
eofar
equest
-r
epl
ypr
otocol

• HTTPisar
equest-
repl
ypr
otocol
fortheexchangeofnet
wor
kresour
ces
bet
weenwebcli
entsandwebserver
s.

ØHTTPpr
otocol
stepsar
e:

• Connect
ionest
abl
i
shmentbet
weencl
i
entandser
veratt
hedef
aul
t
serverportorataportspeci
fi
edi
ntheURL
§ cl
ientsendsar equest
§ serversendsar epl
y
§ connectionclosure

ØHTTP1.
1usesper
sist
entconnect
ions.

• Per
sist
entconnect
ionsareconnecti
onsthatr
emainsopenover
aseri
esofrequest
-repl
yexchangesbet
weenclientandser
ver
.

ØResour
cescanhav
eMI
ME-
li
kest
ruct
uresi
nar
gument
sandr
esul
ts.

• AMi
met
ypespeci
fi
esat
ypeandasubt
ype,
forexampl
e:

• t
ext
/pl
ain
§text
/ht
ml
§image/gi
f
§image/j
peg

§ HTTPmet
hods

ØGET

§ Request
sther
esour
ce,
ident
if
iedbyURLasar
gument
.

• I
ftheURLr
efer
stodat
a,t
hent
hewebser
verr
epl
i
esby
retur
ningthedata
• I
ft heURLr ef
erstoaprogr
am, thenthewebser
verr
unst
he
program andretur
nstheoutputtothecl
ient
.

Fi
gur
e:.HTTPr
equestmessage

• HEAD
• Thi
smet
hodi
ssi
mil
art
oGET,
butonl
ymet
adat
aon
r
esour
cei
sret
urned(
li
kedat
eofl
astmodi
fi
cat
ion,
type,
andsize)
ØPOST
• Specifi
est
heURLofaresource(
fori
nst
ance,
aserverpr
ogr
am)
thatcandeal
wit
hthedatasuppl
i
edwithther
equest
.

 Thi
smet
hodi
sdesi
gnedt
odeal
wit
h:

ØPr
ovi
dingabl
ockofdat
atoadat
a-handl
i
ngpr
ocess

ØPosti
ngamessagetoabull
eti
nboar
d,mai
li
ngli
stornews
gr
oup.
ØExtendi
ngadatasetwi
thanappendoper
ati
on

ØPUT

 Suppl
i
eddat
atobest
oredi
nthegi
venURLasi
tsi
dent
if
ier
.

ØDELETE

 Theser
verdel
etesani
dent
if
iedr
esour
cebyt
hegi
venURLont
heser
ver
.

• OPTIONS
• As erversuppli
esthecl
ientwit
hal i
stofmethods.
• Itallowst obeappl i
edt
ot hegi
venURL
• TRACE
• Thes erversendsbacktherequestmessage
• Areplymessagespeci f
ies
• Thepr otocolversi
on
• As tat
uscode
• Re ason
• Somehe aders
• Anopt
ional
messagebody

Topi
cNo5:
GroupCommuni
cat
ion

• Thepair
wiseexchangeofmessagesisnotthebestmodel
forcommuni
cat
ion
fr
om oneprocesstoagroupofotherpr
ocesses.

§ Amul
ti
castoper
ati
oni
smor
eappr
opr
iat
e.

• Mul
ti
castoper
ati
oni
sanoper
ati
ont
hatsendsasi
ngl
emessagef
rom one
pr
ocesst
oeachoft
hemember
sofagr
oupofpr
ocesses.
• Thesimpl
estwayofmul
ti
cast
ing,
prov
idesnoguar
ant
eesaboutmessage
del
iv
eryoror
deri
ng.

§ Mul
ti
cast
inghast
hef
oll
owi
ngchar
act
eri
sti
cs:

§ Faul
ttol
erancebasedonr
epl
i
cat
edser
vices

§ Ar
epl
i
cat
edser
viceconsi
stsofagr
oupofser
ver
s.

• Cl
i
entr
equest
sar
emul
ti
castt
oal
lthemember
soft
hegr
oup,
eachofwhi
chper
for
msani
dent
ical
oper
ati
on.

§ Fi
ndi
ngt
hedi
scov
eryser
ver
sinspont
aneousnet
wor
king

• Mul
ti
castmessagescanbeusedbyser
ver
sandcl
i
ent
stol
ocat
e
avail
abl
edi
scoveryserv
icesi
nor dert
or egi
stert
heiri
nter
facesor
tolookupt
heinterf
acesofotherserv
icesinthedistr
ibut
ed
system.

• Bet
terper
for
mancet
hroughr
epl
i
cat
eddat
a

§ Dataar
erepli
catedtoi
ncreaset
heper
for
manceofaser
vice.
§ Pr
opagat
ionofeventnoti
fi
cat
ions

• Mult
icasttoagroupmaybeusedt
onot
if
ypr
ocesseswhen
somethinghappens.

SubTopi
c5.
1:I
Pmul
ti
cast

• I
Pmul
ti
casti
sbui
l
tont
opoft
heI
nter
netpr
otocol
,I
P.

§I
Pmul
ti
castal
l
owst
hesendert
otr
ansmi
tasi
ngl
eIPpackett
oamul
ti
castgr
oup.

• Amul
ti
castgr
oupi
sspeci
fi
edbycl
assDI
Paddr
essf
orwhi
chf
ir
st
4bit
sar
e1110i nIPv
4.
§Themembershi
pofamul ti
castgroupisdynamic.
• Acomputerbelongstoamul ti
castgroupifoneormor
epr
ocesses
hav
esocketsthatbelongtothemul t
icastgr
oup.

§ Thef
oll
owi
ngdet
ail
sar
especi
fi
ctoI
Pv4:

§ Mul
ti
castI
Prout
ers

• I
Ppacket
scanbemul
ti
castbot
honl
ocal
net
wor
k
andont
hewiderInt
ernet
.
§Local
mul
ti
castusesl
ocalnet
wor
ksuchasEt
her
net
.
• Toli
mitthedist
anceofpropagati
onofamulti
cast
dat
agram,thesendercanspecif
ythenumberofrouter
sit
i
sall
owedt opass-
call
edthetimetoli
ve,
orTTLf orshor
t.

• Mul
ti
castaddr
essal
l
ocat
ion

• Multi
castaddr essingmaybeper manentort emporary.
• Permanentgr oupsexi stevenwhent herearenomember s.
• Multi
castaddr essingbyt empor arygroupsmust
becreatedbef oreuseandceaset oexitwhenall
member shav el ef
t.
• Thesessiondi rectory(sd)program canbeusedt ostar t
orjoi
namul ticastsessi on.
• sessi
on director ypr ovi
des a t oolwi th an i
nteractive
i
nterf
ace that al lows user s t o br owse adv ert
ised
multi
castsessi onsandt oadv ert
isetheirownsessi on,
speci
fyi
ngthet i
meanddur at
ion.

• JavaAPIt
oIPmul
ti
cast

• TheJav aAPIprovidesadat agram int


erfacetoIPmul ti
cast
throught he
classMul ti
castSocket,whichisasubsetofDat agramSocketwith
theaddi t
ionalcapabil
it
yofbei ngabletoj oi
nmul ti
castgroups.
• Thecl assMul t
icastSocketprovidestwoal t
ernati
veconstructor
s,
all
owingsockett obecr eativetouseeitheraspeci fi
edlocalport
,
oranyf reelocalport.
Fi
gur
e:.Mul
ti
castpeerj
oinsagr
oupandsendsandr
ecei
vesdat
agr
ams

• Apr
ocesscanj
oinamul
ti
castgr
oupwi
thagi
venmul
ti
castaddr
essby
i
nv okingt
hejoinGroupmet hodofi tsmulti
castsocket .
• Apr ocesscanleaveaspeci fi
edgr oupbyinvokingt hel
eaveGroup
met hodofit
smul ti
castsocket.
• TheJav aAPIallowst heTTLt obesetf oramul ti
castsocketbymeansof
the
setTimeToLiv
emet hod.Thedef aulti
s1,all
owingt hemulti
castto
propagateonlyont helocalnetwork.

Vous aimerez peut-être aussi