cse 123b communications softwarecseweb.ucsd.edu/classes/sp02/cse123b/lec3.pdf · cse 123b --...
TRANSCRIPT
CS
E 1
23b
CS
E 1
23b
Com
mun
icat
ions
Sof
twar
eC
omm
unic
atio
ns S
oftw
are
Spr
ing
2002
Spr
ing
2002
Lect
ure
3: R
elia
ble
Com
mun
icat
ions
Lect
ure
3: R
elia
ble
Com
mun
icat
ions
Ste
fan
Sav
age
Ste
fan
Sav
age So
me
slid
es c
oure
sty
Dav
id W
ethe
rall
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on2
Adm
inis
trat
iva
Adm
inis
trat
iva
Hom
e pa
ge is
up
and
wor
king
◆ht
tp://
ww
w-c
se.u
csd.
edu/
clas
ses/
sp02
/cse
123B
/◆
Cla
ss n
otes
incl
uded
◆S
ign
up fo
r the
cla
ss m
ailin
g lis
t (in
stru
ctio
ns o
n th
e W
eb p
age)
Firs
t hom
ewor
k w
ill b
e as
sign
ed n
ext T
uesd
ay
Cla
ss o
n Th
ursd
ay is
***
canc
elle
d***
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on3
Last
Tim
eLa
st T
ime
We
talk
ed a
bout
the
netw
ork
laye
r (IP
) and
in
tern
etw
orki
ng.
We
assu
me:
the
netw
ork
prov
ides
bes
t-effo
rt (i.
e. u
nrel
iabl
e) d
eliv
ery
of p
acke
ts fr
om o
ne
host
to a
noth
er◆
How
that
is d
one,
rout
ing,
is le
ft fo
r a fu
ture
cla
ss
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on4
Tod
ay’s
cla
ssT
oday
’s c
lass
We
begi
n on
the
trans
port
laye
r◆
Bui
lds
on th
e se
rvic
es o
f the
Net
wor
k la
yer
◆C
omm
unic
atio
n be
twee
n pr
oces
ses
runn
ing
on
host
sP
rinci
ple
focu
s◆
How
do
we
ensu
re th
at a
mes
sage
is re
liabl
yco
mm
unic
ated
from
one
hos
t to
anot
her?
Topi
cs◆
AR
Q◆
Slid
ing
win
dow
s◆
Ret
rans
mis
sion
tim
ers
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on5
Tho
ught
exp
erim
ent
Tho
ught
exp
erim
ent
You
wan
t to
send
a lo
ng le
tter t
o yo
ur fr
iend
A
ll yo
u ha
ve (a
nd a
ll yo
ur fr
iend
has
) is
post
card
sP
ostc
ards
get
lost
in th
e m
ail,
dela
yed,
da
mag
edH
ow d
o yo
u se
nd th
e le
tter?
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on6
Rel
iabl
e T
rans
mis
sion
Rel
iabl
e T
rans
mis
sion
How
do
we
relia
bly
send
a m
essa
ge w
hen
pack
ets
can
be lo
st in
the
netw
ork?
Som
e op
tions
◆D
etec
t a lo
ss a
nd re
trans
mit
(Cer
f&K
ahn7
4, a
nd
othe
rs)
◆S
end
redu
ndan
tly (B
yers
et a
l.98,
and
oth
ers)
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on7
Aut
omat
ic R
epea
t R
eque
st
Aut
omat
ic R
epea
t R
eque
st
(AR
Q)
(AR
Q)
Pac
kets
can
be
corr
upte
d or
lost
. How
do
we
add
relia
bilit
y?A
ckno
wle
dgm
ents
(AC
Ks)
and
retra
nsm
issi
ons
afte
r a
timeo
utA
RQ
is g
ener
ic n
ame
for p
roto
cols
bas
ed o
n th
is
stra
tegy
Sen
der
Rec
eive
r
Dat
a ACK
Timeout
Time
Sen
der
Rec
eive
r
Dat
a
Timeout
Dat
a
ACK
Timeout
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on8
The
Nee
d fo
r S
eque
nce
The
Nee
d fo
r S
eque
nce
Num
bers
Num
bers
Sen
der
Rec
eive
rS
ende
rR
ecei
ver
Fram
e
ACK
imeout
Dat
a
ACK
Timeout
Dat
a ACK
imeout
Dat
a
ACK
TimeoutT
T
In th
e ca
se o
f AC
K lo
ss (o
r poo
r cho
ice
of
timeo
ut) t
he re
ceiv
er c
an’t
dist
ingu
ish
this
m
essa
ge fr
om th
e ne
xt◆
Nee
d to
und
erst
and
how
man
y pa
cket
s ca
n be
ou
tsta
ndin
g an
d nu
mbe
r the
pac
kets
; her
e, a
sin
gle
bit w
ill d
o
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on9
Sto
pS
top
-- and
and
-- Wai
tW
ait
Onl
y on
e ou
tsta
ndin
g pa
cket
at
a ti
me
Als
o ca
lled
alte
rnat
ing
bit
prot
ocol
0 1 0 1
Sen
der
Rec
eive
r
0 1 10
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on10
How
doe
s re
ceiv
er r
ecog
nize
H
ow d
oes
rece
iver
rec
ogni
ze
a du
plic
ate?
a du
plic
ate?
Seq
uenc
e #
in p
acke
t is
finite
How
man
y bi
ts d
o w
e ne
ed?
◆O
ne b
it fo
r sto
p an
d w
ait
◆W
on’t
send
seq
#1 u
ntil
rece
ive
AC
K
for s
eq#0
◆O
nly
allo
ws
one
pack
et in
flig
ht
Pkt 0
ACK 0
Timeout
Pkt 0
AC
K 1
1Pk
tA
CK
0
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on11
Wha
t if
pac
kets
are
del
ayed
?W
hat
if p
acke
ts a
re d
elay
ed?
Nev
er re
use
a se
q#?
Fi
nite
…R
equi
re in
ord
er d
eliv
ery?
Pre
vent
ver
y la
te d
eliv
ery?
◆TT
L: D
ecre
men
t hop
cou
nt
per p
acke
t, di
scar
d if
exce
eded
◆S
eq#s
not
reus
ed w
ithin
de
lay
boun
dTr
ust i
ssue
s?
0 110 0Accept!
Reject!
0
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on12
Wha
t ha
ppen
s if
a m
achi
ne
Wha
t ha
ppen
s if
a m
achi
ne
cras
hes?
cras
hes?
How
do
we
dist
ingu
ish
pack
ets
sent
bef
ore
and
afte
r reb
oot?
Whi
ch s
eq#
to u
se?
Sol
utio
ns◆
Res
tart
sequ
ence
# a
t 0?
◆A
ssum
e bo
ot ta
kes
max
pac
ket d
elay
?◆
Cho
ose
seq
# at
rand
om a
nd h
ope?
◆U
se s
tabl
e st
orag
e an
d in
crem
ent h
igh
orde
r bits
of
seq
# on
eve
ry b
oot
Rea
lity:
Peo
ple
don’
t wor
ry a
bout
this
◆S
low
rebo
ots,
exp
licit
conn
ectio
n m
anag
emen
t, to
lera
nt u
sers
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on13
Lim
itat
ions
of
Sto
pLi
mit
atio
ns o
f S
top
-- and
and
-- Wai
tW
ait
Lous
y pe
rform
ance
if w
ire ti
me
<< p
rop.
del
ay◆
How
bad
? W
ant t
o ut
ilize
all
avai
labl
e ba
ndw
idth
◆N
eed
to k
eep
mor
e da
ta “i
n fli
ght”
◆H
ow m
uch?
Rem
embe
r the
ban
dwid
th-d
elay
pr
oduc
t?A
lso
limite
d by
qua
lity
of ti
meo
ut (h
ow lo
ng?)
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on14
Pip
elin
ed t
rans
mis
sion
Pip
elin
ed t
rans
mis
sion
Sen
d m
ultip
le p
acke
ts w
ithou
t w
aitin
g fo
r the
firs
t to
be A
CK
edR
elia
ble,
uno
rder
ed d
eliv
ery:
◆S
end
new
pac
ket a
fter e
ach
AC
K◆
Sen
der k
eeps
list
of u
nAC
K’e
dpa
cket
s an
d re
send
s af
ter t
imeo
ut◆
Rec
eive
r sam
e as
sto
p &
wai
tP
rob:
Wha
t if p
acke
t 2 k
eeps
be
ing
lost
?◆
Rec
eive
r mus
t buf
fer a
ll pa
cket
s af
ter 2
◆P
oten
tial b
uffe
r ove
rflow
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on15
Slid
ing
Win
dow
S
lidin
g W
indo
w ––
Sen
der
Sen
der
Win
dow
bou
nds
outs
tand
ing
data
◆Im
plie
s ne
ed fo
r buf
ferin
g at
sen
der
“Las
t” A
CK
app
lies
to in
-ord
er d
ata
Wha
t to
do o
n a
timeo
ut?
◆G
o-B
ack-
N: o
ne ti
mer
, sen
d al
l una
ckno
wle
dged
da
ta o
n tim
eout
◆S
elec
tive
Rep
eat:
timer
per
pac
ket,
rese
nd a
s ne
eded
≤W
indo
w S
ize
“Las
t” A
CK
Last
Sen
t
……
Sen
der:
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on16
Slid
ing
Win
dow
S
lidin
g W
indo
w ––
Rec
eive
rR
ecei
ver
Rec
eive
r buf
fers
too:
◆da
ta m
ay a
rriv
e ou
t-of-o
rder
◆or
fast
er th
an c
an b
e co
nsum
ed (f
low
con
trol)
Rec
eive
r AC
K c
hoic
es:
◆In
divi
dual
, Cum
ulat
ive
(TC
P),
Sel
ectiv
e (n
ewer
TC
P),
Neg
ativ
e
≤R
ecei
ve W
indo
w
“Las
t” R
ecei
ved
Larg
est A
ccep
ted
……
Rec
eive
r:
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on17
Slid
ing
Win
dow
S
lidin
g W
indo
w ––
Tim
elin
eT
imel
ine
Send
erR
ecei
ver
……
Time
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on18
Slid
ing
Win
dow
Fun
ctio
nsS
lidin
g W
indo
w F
unct
ions
Slid
ing
win
dow
is a
mec
hani
smIt
supp
orts
mul
tiple
func
tions
:
Rel
iabl
e de
liver
yIn
-ord
er d
eliv
ery
Flow
con
trol
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on19
Dec
idin
g W
hen
to R
etra
nsm
itD
ecid
ing
Whe
n to
Ret
rans
mit
How
do
you
know
whe
n a
pack
et h
as b
een
lost
?◆
Ulti
mat
ely
send
er u
ses
timer
s to
dec
ide
whe
n to
re
trans
mit
But
how
long
sho
uld
the
timer
be?
◆To
o lo
ng: i
neffi
cien
t (la
rge
dela
ys, p
oor u
se o
f ba
ndw
idth
)◆
Too
shor
t: m
ay re
trans
mit
unne
cess
arily
(cau
sing
ext
ra
traffi
c)R
ight
tim
er is
bas
ed o
n th
e ro
und
trip
time
(RTT
)◆
Whi
ch v
arie
s gr
eatly
(pat
h le
ngth
and
que
uing
)
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on
A S
impl
e N
etw
ork
Mod
elA
Sim
ple
Net
wor
k M
odel
Buf
fers
at r
oute
rs u
sed
to a
bsor
b bu
rsts
whe
n in
put
rate
> o
utpu
tLo
ss (d
rops
) occ
ur w
hen
send
ing
rate
is p
ersi
sten
tly >
dr
ain
rate
Des
tinat
ion
1.5-
Mbp
s T1
link
Rou
ter
Sou
rce
2
Sou
rce
1
100-
Mbp
s FD
DI
10-M
bps
Ethe
rnet
Pac
kets
que
ued
here
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on21
Eff
ects
of
Ear
ly
Eff
ects
of
Ear
ly
Ret
rans
mis
sion
sR
etra
nsm
issi
ons
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on22
Con
gest
ion
Col
laps
eC
onge
stio
n C
olla
pse
In th
e lim
it, e
arly
retra
nsm
issi
ons
lead
to
cong
estio
n co
llaps
e◆
Sen
ding
mor
e pa
cket
s in
to th
e ne
twor
k w
hen
it is
ov
erlo
aded
exa
cerb
ates
the
prob
lem
of c
onge
stio
n◆
Net
wor
k st
ays
busy
but
ver
y lit
tle u
sefu
l wor
k is
be
ing
done
This
hap
pene
d in
real
life
~19
87◆
Led
to V
an J
acob
son’
s TC
P a
lgor
ithm
s, w
hich
form
th
e ba
sis
of c
onge
stio
n co
ntro
l in
the
Inte
rnet
toda
y[S
ee “C
onge
stio
n A
void
ance
and
Con
trol”,
S
IGC
OM
M’8
8]
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on23
Est
imat
ing
Est
imat
ing
RT
Ts
RT
Ts
Idea
: Ada
pt b
ased
on
rece
nt p
ast m
easu
rem
ents
Sim
ple
algo
rithm
:◆
For e
ach
pack
et, n
ote
time
sent
and
tim
e ac
kre
ceiv
ed◆
Com
pute
RTT
sam
ples
and
ave
rage
rece
nt s
ampl
es fo
r tim
eout
◆E
stim
ated
RTT
= α
x E
stim
ated
RTT
+ (1
-α
) x S
ampl
eRTT
◆Th
is is
an
expo
nent
ially
-wei
ghte
d m
ovin
g av
erag
e th
at
smoo
thes
the
sam
ples
. Typ
ical
ly, α
= 0.
8 to
0.9
.◆
Set
tim
eout
to s
mal
l mul
tiple
(2) o
f the
est
imat
e to
cap
ture
va
riatio
n ar
ound
mea
n.
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on24
Est
imat
ed R
etra
nsm
it T
imer
Est
imat
ed R
etra
nsm
it T
imer
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on25
Kar
nK
arn
/Par
trid
ge A
lgor
ithm
/Par
trid
ge A
lgor
ithm
Pro
blem
: RTT
for r
etra
nsm
itted
pac
kets
am
bigu
ous
Sol
utio
n: D
on’t
mea
sure
RTT
for r
etra
nsm
itted
pac
kets
an
d do
not
rela
x ba
cked
of t
imeo
ut u
ntil
valid
RTT
m
easu
rem
ents
Sen
der
Rec
eive
r
Orig
inal
tran
smis
sion
ACK
SampleRTT
Ret
rans
mis
sion
Sen
der
Rec
eive
r
Orig
inal
tran
smis
sion
ACK
SampleRTT
Ret
rans
mis
sion
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on26
Jaco
bson
/Ja
cobs
on/ K
arel
sK
arel
sA
lgor
ithm
Alg
orit
hmP
robl
em:
◆V
aria
nce
in R
TTs
gets
larg
e as
net
wor
k ge
ts lo
aded
◆S
o an
ave
rage
RTT
isn’
t a g
ood
pred
icto
r whe
n w
e ne
ed it
m
ost
Sol
utio
n: T
rack
var
ianc
e to
o.◆
Diff
eren
ce =
Sam
pleR
TT–
Est
imat
edR
TT◆
Est
imat
edR
TT=
Est
imat
edR
TT+
(δx
Diff
eren
ce)
◆D
evia
tion
= D
evia
tion
+ δ(
|Diff
eren
ce|-
Dev
iatio
n)◆
Tim
eout
= µ
x E
stim
ated
RTT
+ φ
x D
evia
tion
◆In
pra
ctic
e, δ
= 1/
8, µ
= 1
and φ
= 4
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on27
Est
imat
e w
ith
Mea
n +
Est
imat
e w
ith
Mea
n +
Var
ianc
eV
aria
nce
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on28
Can
we
shor
tcut
the
tim
eout
?C
an w
e sh
ortc
ut t
he t
imeo
ut?
Pro
blem
◆If
a pa
cket
is d
ropp
ed in
the
netw
ork,
the
send
er
has
to w
ait u
ntil
timeo
ut o
ccur
s be
fore
reac
ting
If pa
cket
s ar
e us
ually
in o
rder
then
out
-of-r
der
pack
ets
impl
y th
at a
pac
ket w
as lo
st◆
Neg
ativ
e A
CK
»R
ecei
ver r
eque
sts
mis
sing
pac
ket
◆Fa
st re
trans
mit
»R
ecei
ver A
CK
sou
t-of-o
rder
pac
kets
with
seq
# of
last
co
ntig
uous
pac
ket
»W
hen
send
er re
ceiv
es m
ultip
le d
uplic
ate
ackn
owle
dgem
ents
rese
nds
mis
sing
pac
ket
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on29
Fast
ret
rans
mit
Fast
ret
rans
mit
Send
erR
ecei
ver
Time
……1 2 3
1 1
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on30
Alt
erna
tive
s to
ret
rans
mis
sion
?A
lter
nati
ves
to r
etra
nsm
issi
on?
Red
unda
ncy
◆S
end
addi
tiona
l dat
a to
com
pens
ate
for l
ost
pack
ets
Why
not
use
retra
nsm
issi
on◆
Mul
ticas
t»
Lots
of r
ecei
vers
If ea
ch o
ne A
CK
/NA
K th
en h
ard
to s
cale
Lots
of m
essa
ges
Lots
of s
tate
»H
eter
ogen
eous
rece
iver
sM
odem
vs
100M
Bps
con
nect
ed h
osts
◆O
ne-w
ay o
r ver
y lo
ng d
elay
cha
nnel
s (s
pace
craf
t)
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on31
Sim
ples
t ve
rsio
nS
impl
est
vers
ion
Sen
d ev
ery
pack
et tw
ice
Mus
t los
e bo
th p
acke
ts in
a p
air t
o pr
even
t m
essa
ge fr
om b
eing
del
iver
ed
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on32
Gen
eral
izat
ion:
G
ener
aliz
atio
n:
Forw
ard
Err
or C
orre
ctio
n (F
EC
)Fo
rwar
d E
rror
Cor
rect
ion
(FE
C)
Use
era
sure
cod
es to
redu
ndan
tly e
ncod
e k
sour
ce p
acke
ts in
to k
*m e
ncod
ed p
acke
ts◆
Ree
d S
olom
on C
odes
◆To
rnad
o co
des
Mul
ticas
t/bro
adca
st e
ncod
ed p
acke
ts
cont
inua
llyA
ny re
ceiv
er c
an re
cons
truct
mes
sage
from
an
y k
pack
ets
in th
e se
t of k
*m
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on33
Som
etim
es r
efer
red
to a
s a
Som
etim
es r
efer
red
to a
s a
“Dig
ital
Fou
ntai
n”“D
igit
al F
ount
ain”
Use
r 1U
ser 2
Tran
smis
sion
5 ho
urs
4 ho
urs
3 ho
urs
2 ho
urs
1 ho
ur
0 ho
urs
File
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on34
Pro
s an
d C
ons
of F
orw
ard
Pro
s an
d C
ons
of F
orw
ard
Err
or C
orre
ctio
nE
rror
Cor
rect
ion
Pro
◆E
very
pac
ket c
an b
e us
eful
for a
ll cl
ient
s
◆W
ell s
uite
d to
mul
ticas
t situ
atio
n
Con
◆S
ends
mor
e da
ta th
an id
eally
nec
essa
ry
◆N
eed
larg
e bl
ock
size
s fo
r effi
cien
cy
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on35
Sum
mar
yS
umm
ary
Tran
spor
t lay
er a
llow
s pr
oces
ses
to
com
mun
icat
e w
ith s
trong
er g
uara
ntee
s, e
.g.,
relia
bilit
yR
elia
bilit
y m
echa
nism
s◆
AR
Q»
Slid
ing
Win
dow
+ re
trans
mis
sion
for e
ffici
ency
»R
etra
nsm
issi
on ti
mer
mus
t be
adap
tive
◆FE
C»
In re
stric
ted
setti
ngs
April
9, 2
002
CSE
123
b --
Lect
ure
3 –
Rel
iabl
e Tr
ansm
issi
on36
For
next
tim
e…Fo
r ne
xt t
ime…
Rem
embe
r tha
t nex
t tim
e is
a w
eek
from
toda
y
Rea
d C
h 6.
3-6.
4