Send TCP hkr - IIT Bombayhemantr/prjt/tcp_ip.pdf · Does not give any effective model Poorly suited...
Transcript of Send TCP hkr - IIT Bombayhemantr/prjt/tcp_ip.pdf · Does not give any effective model Poorly suited...
5/25
/200
5TC
P /
IP1
TCP/IP
Hem
ant K
r Rat
hD
ept o
f Ele
ctric
al E
ngg
IIT-B
omba
yE-
Mai
l: he
man
tr@ee
.iitb
.ac.
in
5/25
/200
5TC
P /
IP2
TCP/IP
Wha
t is
it?
Basi
c co
mm
unic
atio
n la
ngua
ge o
r pro
toco
l of I
nter
net
Use
d as
a c
omm
unic
atio
ns p
roto
col i
n a
priv
ate
netw
ork
Viz.
: Int
rane
t or E
xtra
net
TCP/
IP is
a tw
o-la
yerp
rogr
amTh
e hi
gher
laye
r, Tr
ansm
issi
on C
ontro
l Pro
toco
l (TC
P)M
anag
es th
e as
sem
blin
g of
a m
essa
ge/fi
le in
to s
mal
ler p
acke
ts
The
low
er la
yer,
Inte
rnet
Pro
toco
l(IP
)H
andl
es th
e ad
dres
s pa
rt of
eac
h pa
cket
so
that
it g
ets
to th
e rig
ht d
estin
atio
n
5/25
/200
5TC
P /
IP3
Diff
eren
t Typ
es o
f Ser
vice
s
Sequ
ence
of p
ages
Rel
iabl
e m
essa
ges
stre
am
Dat
abas
e qu
ery
Reg
iste
red
mai
l
Elec
troni
c Ju
nk m
ail
Dig
itize
d Vo
ice
Rem
ote
Logi
nR
elia
ble
byte
stre
am
Unr
elia
ble
Con
nect
ion
Unr
elia
ble
data
gram
Ackn
owle
dged
da
tagr
amR
eque
st-re
ply
Con
nect
ion
Less
Exam
ple
Serv
ices
Con
nect
ion
Orie
nted
5/25
/200
5TC
P /
IP4
Laye
red
Arc
hite
ctur
e
Mes
sage
St
ruct
urin
gTr
ansp
ort
Plac
ing
in C
over
Del
iver
yR
ecep
tion
Dat
a Li
nk +
Ph
ysic
al L
ayer
Mai
l Bag
sVo
ice
Tran
smis
sion
Tran
smis
sion
Net
wor
kSo
rting
Circ
uit
Form
atio
nPa
th A
lloca
tion
Appl
icat
ion
Com
posi
tion
Cal
l Ini
tiatio
nM
essa
ge
Cre
atio
n
Com
pute
rPo
stal
Tele
phon
eSe
rvic
e/La
yer
5/25
/200
5TC
P /
IP5
Why
Lay
ers?
Allo
ws
a di
vide
-and
-con
quer
stra
tegy
Easi
er to
und
erst
and
and
impl
emen
t Im
plem
enta
tion
of o
ne la
yer c
an b
e ch
ange
d w
ithou
t affe
ctin
g ot
her l
ayer
s
Spec
ifica
tion
is s
epar
ated
from
impl
emen
tatio
nR
euse
of f
unct
iona
lity
Upp
er la
yers
sha
re th
e se
rvic
es o
f low
er la
yers
5/25
/200
5TC
P /
IP6
Disa
dvan
tage
s of L
ayer
s
Impl
emen
tatio
n m
ay n
ot b
e th
e m
ost e
ffici
ent
Maj
or c
once
rn in
low
ban
dwid
th n
etw
orks
and
low
po
wer
hos
tsVi
z.: W
irele
ss a
d-ho
c ne
twor
k
Cum
bers
ome
Load
on
laye
rs m
ay n
ot b
e ba
lanc
edTo
o-m
any
laye
rs
5/25
/200
5TC
P /
IP8
Conc
epts
of O
SI M
odel
Serv
ices
prov
ided
by
diffe
rent
laye
rsSe
t of o
pera
tions
that
ala
yer p
rovi
des
to th
e la
yer a
bove
itSa
ys n
othi
ng a
bout
how
thes
e op
erat
ions
are
per
form
ed
by
Inte
rface
betw
een
adja
cent
laye
rsAn
inte
rface
tells
pro
cess
es in
the
high
er la
yer h
ow to
ac
cess
the
unde
rlyin
g la
yer f
or g
ettin
g th
e se
rvic
es
Prot
ocol
sob
eyed
by
diffe
rent
laye
rsA
prot
ocol
is a
set
of r
ules
gove
rnin
g th
e fo
rmat
and
m
eani
ng o
f the
mes
sage
s ex
chan
ged
by p
eer e
ntiti
es
5/25
/200
5TC
P /
IP9
A C
ritiq
ue o
f OSI
Lay
ers
The
Ref
eren
ce M
odel
cam
e be
fore
the
Prot
ocol
sC
reat
ed p
robl
ems
in d
efin
ing
the
func
tiona
litie
sto
be
inco
rpor
ated
in th
e di
ffere
nt la
yers
.
Imba
lanc
eam
ong
the
7 la
yers
with
resp
ect t
o th
eir
rela
tive
func
tiona
litie
sSe
para
te s
ub-la
yers
in th
e D
ata
Link
(MAC
) and
the
Net
wor
k la
yer (
IP)
Sess
ion
and
Pres
enta
tion
laye
rs h
ave
little
sig
nific
ance
5/25
/200
5TC
P /
IP10
TCP/
IP R
efer
ence
Mod
el
The
TCP/
IP re
fere
nce
mod
el e
volv
ed fr
om A
RPA
NET
Mul
tiple
net
wor
ksto
be
inte
rcon
nect
ed in
a s
eam
less
man
ner
The
cruc
ial l
ayer
is th
e In
tern
etLa
yer
Perm
its h
osts
to in
trodu
ce p
acke
ts in
to a
ny n
etw
ork
Use
s In
tern
et P
roto
col (
IP)t
o pe
rform
pac
ket r
outin
gIP
laye
r is
supp
orte
d by
a H
ost-t
o-ne
twor
kla
yer
The
laye
r abo
ve IP
laye
r ena
bles
pee
r ent
ities
on
host
s to
exc
hang
e m
essa
ges
Sim
ilar t
o th
e O
SI T
rans
port
laye
r
5/25
/200
5TC
P /
IP11
OSI
vs.
TCP/
IP L
ayer
s
Phys
ical
Dat
a Li
nk
Net
wor
k
Tran
spor
t
Sess
ion
Pres
enta
tion
App
licat
ion
App
licat
ion
Tran
spor
t
Inte
rnet
Dat
a Li
nk
Phys
ical
OSI
TCP/
IP
5/25
/200
5TC
P /
IP12
A C
ritiq
ue o
f TCP
/IP
Opp
osed
to O
SI
No
diffe
rent
iatio
n be
twee
n sp
ecifi
catio
n an
d im
plem
enta
tion
Doe
s no
t giv
e an
y ef
fect
ive
mod
el
Poor
ly s
uite
d to
des
crib
ing
any
othe
r pro
toco
l sta
ck
Hos
t-to-
netw
ork
laye
r is
not r
eally
a la
yer
It is
an
inte
rface
bet
wee
n ne
twor
k an
d da
ta li
nk la
yers
All p
roto
cols
oth
er th
an T
CP
and
IP a
re a
d-ho
cTC
P/IP
pro
toco
ls a
re w
idel
y us
edO
SI m
odel
is u
sefu
l onl
y fo
r dis
cuss
ing
com
pute
r net
wor
ks
5/25
/200
5TC
P /
IP15
Com
mun
icat
ion
in L
ayer
ing
appl
icat
ion
tran
spor
tne
twor
klin
kph
ysic
al
appl
icat
ion
tran
spor
tne
twor
klin
kph
ysic
al
appl
icat
ion
tran
spor
tne
twor
klin
kph
ysic
al
netw
ork
link
phys
ical
data
data
5/25
/200
5TC
P /
IP17
IP A
ddre
ssin
gEa
ch h
ost n
eeds
to h
ave
a un
ique
IP a
ddre
ssR
ando
m a
ddre
sses
wou
ld m
ake
rout
ing
impo
ssib
leN
eigh
bour
ing
host
s sh
ould
hav
e si
mila
r add
ress
esAr
e hi
erar
chic
al in
nat
ure
Aggr
egat
ion
is p
ossi
ble
IPv4
Add
ress
ing
32-b
it ad
dres
sing
IPv6
Add
ress
ing
128-
bit a
ddre
ssin
g (R
FC 3
513)
Addr
ess
has
two
parts
Net
-idan
d H
ost-i
dN
et-id
s ar
e as
sign
ed b
y a
cent
ral a
utho
rity
5/25
/200
5TC
P /
IP18
IPv4
Add
ress
ing
IP a
ddre
ss is
giv
en in
the
dotte
d de
cim
al n
otat
ion
4 se
ts o
f 8-b
it nu
mbe
rs: A
.B.C
.DVi
z: 1
44.1
6.16
0.2
, 127
.0.0
.1, 1
92,1
68.1
00.1
Type
s of
Add
ress
esU
nica
st, M
ultic
ast,
Broa
dcas
t
Spec
ial A
ddre
sses
All 0
’s --
host
All 1
’s --
limite
d br
oadc
ast
255.
255.
255.
255
(a s
tring
of 1
’s) r
efer
s to
loca
l bro
adca
st12
7.x.
y.z
is u
sed
for l
oop-
back
add
ress
5/25
/200
5TC
P /
IP19
IPv4
Add
ress
es
Cla
ss-A
Addr
ess:
1.0.
0.0
-127
.255
.255
.255
0
+ 7-
bit n
et-id
+ 2
4-bi
t hos
t-id
Cla
ss-B
Addr
ess:
128.
0.0.
0 -1
91.2
55.2
55.2
5510
+ 1
4-bi
t net
-id +
16-
bit h
ost-i
dC
lass
-CAd
dres
s:19
2.0.
0.0
-223
.255
.255
.255
110
+ 21
-bit
net-i
d +
8-bi
t hos
t-id
Cla
ss-D
Addr
ess:
224.
0.0.
0 -2
39.2
55.2
55.2
5511
10 +
28-
bit m
ultic
ast g
roup
Res
erve
d:24
0.0.
0.0
-247
.255
.255
.255
5/25
/200
5TC
P /
IP20
Priv
ate
and
Glo
bal I
P A
ddre
ssPr
ivat
e Ad
dres
sU
sed
for p
rivat
e ne
twor
k : (
viz:
IIT-
Bom
bay)
Uni
que
only
in th
e pr
ivat
e ne
twor
kSh
ould
not
be
adve
rtise
d to
the
outs
ide
wor
ldC
lass
A -
10.0
.0.0
to 1
0.25
5.25
5.25
5C
lass
B -
172.
16.0
.0 to
172
.31.
255.
255
Cla
ss C
-19
2.16
8.0.
0 to
192
.168
.255
.255
Glo
bal A
ddre
ssVi
sibl
e to
out
side
wor
ld a
nd u
niqu
e gl
obal
lyO
utsi
de c
onne
ctiv
ity fo
r the
se a
ddre
sses
is th
roug
hAp
plic
atio
n le
vel p
roxi
esN
etw
ork
Addr
ess
Tran
slat
ion
(NAT
)
5/25
/200
5TC
P /
IP21
IP A
ddre
ss Is
sues
Inef
ficie
nt:w
aste
d ad
dres
ses
Infle
xibl
e:fix
ed in
terp
reta
tion
Not
sca
labl
eN
umbe
r of n
etw
orks
is g
row
ing
Not
eno
ugh
netw
ork
num
bers
Solu
tions
Sub-
netti
ng a
nd S
uper
-net
ting
CID
R:V
aria
ble
inte
rpre
tatio
ns fo
r the
net
wor
k nu
mbe
rD
HC
P:D
ynam
ic h
ost c
onfig
urat
ion
IPv6
:128
-bit
addr
ess
spac
e
5/25
/200
5TC
P /
IP22
Subn
ettin
gBr
eaks
larg
er n
etw
ork
to m
any
smal
ler n
etw
orks
Red
uces
the
broa
dcas
t dom
ain
Hen
ce n
etw
ork
traffi
c w
ithin
a s
ubne
tSi
mpl
ifies
net
wor
k m
anag
emen
t Sm
alle
r net
wor
k =>
sim
pler
man
agem
ent
To c
reat
e su
bnet
wor
kbi
ts fr
om th
e ho
st p
ortio
nof
the
IP a
ddre
ss is
take
n an
d us
ed to
def
ine
subn
ets
For s
ubne
t sch
eme
to w
ork
Ever
y m
achi
ne o
n th
e ne
twor
k m
ust k
now
whi
ch p
art o
f the
ho
st a
ddre
ss w
ill be
use
d as
sub
net m
ask.
Acco
mpl
ishe
d by
ass
igni
ng s
ubne
t mas
k to
eac
h m
achi
ne
5/25
/200
5TC
P /
IP23
Subn
ettin
gW
hen
no s
ubne
tting
: use
def
ault
subn
et m
ask
e.g.
Cla
ss A
: 25
5.0.
0.0
Cla
ss B
: 25
5.25
5.0.
0C
lass
C :
255.
255.
255.
0O
nly
8-bi
ts a
vaila
ble
for h
osts
, pos
sibl
e su
bnet
mas
ks:
1000
0000
= 1
28, 1
1000
000
= 19
2, 1
1100
000
= 22
4, 1
1110
000
= 24
011
1110
00 =
248
, 111
1110
0 =
252,
111
1111
0 =
254
Can
not h
ave
only
1 b
it fo
r sub
netti
ngAl
so n
eed
at le
ast 2
bits
for h
osts
W
ith 1
bit,
you
can
not h
ave
a va
lid h
ost a
ddre
ssTh
e bi
t will
be u
sed
up fo
r net
wor
k id
and
bro
adca
st id
Hen
ce o
nly
valid
sub
net m
asks
are
from
192
to 2
52
5/25
/200
5TC
P /
IP24
Subn
ettin
g
Subn
et id
can
not b
e al
l zer
o or
all
ones
e.
g. If
sub
net i
d is
192
(110
0000
0)Th
en o
nly
subn
et id
(010
0000
0) a
nd (1
0000
000)
are
allo
wed
Exam
ple
subn
et id
: 010
0000
0 (6
4)Th
e su
bnet
id :
0100
0000
= 6
4Fi
rst v
alid
hos
t id
: 010
0000
1 =
65La
st v
alid
hos
t id
: 01
1111
10 =
126
Broa
dcas
t add
ress
: 01
1111
11 =
127
5/25
/200
5TC
P /
IP25
Supe
rnet
ting
Opp
osite
of S
ubne
tting
Mer
ges
seve
ral s
mal
ler b
lock
s of
con
tinuo
us IP
add
ress
es (n
etw
orks
) in
to o
ne la
rger
blo
ck o
f add
ress
es
A si
te m
ay g
et a
con
tinuo
us b
lock
of c
lass
C a
ddre
sses
With
a c
omm
on p
refix
Inst
ead
of a
dver
tisin
g al
l net
wor
ks,
com
mon
pre
fixis
adv
ertis
edR
educ
es th
e si
zes
of ro
utin
g ta
bles
and
mak
ing
the
sear
ch h
iera
rchi
cal
Exam
ple:
IP a
ddre
sses
144
.16.
64.x
, 144
.16.
65.x
, 144
.16.
66.x
and
14
4.16
.67
may
be
club
bed
toge
ther
as
144.
16.6
4.0
Oth
er o
ptio
n is
to a
dver
tise
a pa
irco
nsis
ting
of th
e 1s
t net
wor
k an
d th
e nu
mbe
r of n
etw
orks
Onl
y ne
w ro
uter
s im
plem
ent t
his
5/25
/200
5TC
P /
IP26
Clas
sless
Inte
r Dom
ain R
outin
g (C
IDR)
New
add
ress
ing
sche
me
for t
he In
tern
et
Why
CID
R?
Run
ning
out
of I
P ad
dres
ses
Run
ning
out
of c
apac
ity in
the
glob
al ro
utin
g ta
bles
Med
ium
siz
ed n
etw
orks
cho
ose
clas
s B
addr
esse
s,
lead
ing
to w
aste
d sp
ace
Allo
w w
ays
to re
pres
ent a
set
of c
lass
C a
ddre
sses
as
a bl
ock,
so
that
cla
ss C
spa
ce c
an b
e us
edU
se a
CID
R m
ask
RFC
151
8 an
d 15
19
5/25
/200
5TC
P /
IP28
Add
ress
Res
olut
ion
Prot
ocol
: ARP
NIC
–is
the
inte
rface
for a
PC
to In
tern
etEa
ch N
IC n
eeds
to b
e un
ique
ly (g
loba
lly) i
dent
ified
Phys
ical
Add
ress
or M
AC A
ddre
ss
48-b
it an
d un
ique
The
MAC
Add
ress
can
be
of tw
o ty
pes
Fixe
d an
d C
onfig
urab
leIP
Add
ress
has
to b
e m
appe
d to
the
MAC
Add
ress
N
eede
d fo
r act
ual d
eliv
ery
of fr
ames
Th
is is
cal
led
Addr
ess
Res
olut
ion
W.r.
t. th
e M
AC A
ddre
ss, t
he IP
Add
ress
can
be
Inde
pend
ent,
as in
Eth
erne
t; m
appi
ng is
dyn
amic
Dep
ende
nt, a
s in
pro
NET
-10;
map
ping
can
be
dire
ctly
don
e
5/25
/200
5TC
P /
IP29
Add
ress
Res
olut
ion
Prot
ocol
: ARP
Res
olut
ion
thro
ugh
dire
ct m
appi
ng is
triv
ial
If M
AC a
ddre
ss is
con
figur
ed to
be
the
host
par
t of t
he IP
ad
dres
s
Res
olut
ion
thro
ugh
Dyn
amic
Bin
ding
Req
uire
d be
caus
e N
IC m
ay b
e ch
ange
dEl
se, I
P-M
AC a
ddre
ss m
appi
ngs
on a
ll ho
sts
will
have
to
upda
ted
TCP/
IP u
ses
ARP
whi
ch c
onsi
sts
of th
e fo
llow
ing
step
sBr
oadc
ast I
P Ad
dres
s of
the
dest
inat
ion
Broa
dcas
t nat
ure
of th
e LA
N is
ass
umed
Des
tinat
ion
repl
ies
with
its
MAC
add
ress
Sour
ce m
aint
ains
a c
ache
of I
P-to
-MAC
Add
ress
bin
ding
s
5/25
/200
5TC
P /
IP30
Reve
rse
ARP
: RA
RPTo
obt
ain
an IP
add
ress
, giv
en a
MAC
Add
ress
Use
d by
dis
kles
s ho
sts
to o
btai
n IP
add
ress
esTh
ird p
artie
s ca
n al
so o
btai
n m
appi
ng
Clie
nt b
road
cast
s an
RAR
PR
eque
st w
ith o
wn
MAC
Ad
dr Sam
e as
AR
P fo
rmat
RAR
P se
rver
look
s up
a ta
ble
and
resp
onds
As ro
uter
s do
not
forw
ard
broa
dcas
ts, a
n R
ARP
serv
er is
ne
eded
in e
very
loca
l net
wor
kIf
ther
e ar
e m
ultip
le s
erve
rs, o
nly
prim
ary
repl
ies
If re
ques
t is
rese
nt, s
econ
dary
repl
ies
Poss
ibly
the
prim
ary
is fa
iled
(RFC
903
)
5/25
/200
5TC
P /
IP31
Func
tions
of t
he T
CP P
roto
col
Prov
ides
seq
uenc
ed, r
elia
ble
data
tran
spor
t ser
vice
Usi
ng s
eque
nce
num
bers
, and
retra
nsm
issi
on
Send
er-re
ceiv
er fl
ow c
ontro
lR
ecei
ver a
dver
tises
an
acce
ptab
le w
indo
w o
f pac
kets
Net
wor
k co
nges
tion
cont
rol
Each
con
nect
ion
adap
ts tr
ansm
issi
on w
indo
w
5/25
/200
5TC
P /
IP32
TCP
is Fu
ll D
uple
x an
d Sy
mm
etric
Txra
nd R
xrfo
r eac
h di
rect
ion
of c
omm
unic
atio
nR
xrpr
otoc
ol is
uni
vers
alSa
me
in a
ll co
mm
on im
plem
enta
tions
Diff
eren
t Txr
and
Rxr
impl
emen
tatio
ns c
an c
oexi
stEv
en in
the
sam
e co
nnec
tion
–ne
ed s
ocke
ts
5/25
/200
5TC
P /
IP33
Sock
ets
Wha
t is
it?C
ombi
natio
n of
an
IP a
ddre
ss a
nd a
Por
tC
reat
es a
new
com
mun
icat
ion
end-
poin
tC
onne
ctio
n is
iden
tifie
d as
(soc
ket1
, soc
ket2
)W
hy d
o w
e re
quire
?Fo
r clie
nt-s
erve
r com
mun
icat
ion
Viz.
: Tel
net,
Ftp,
HTT
P et
c.Ty
pes
of S
ocke
tTC
P So
cket
-Stre
am S
ocke
ts a
nd c
onne
ctio
n or
ient
edU
DP
Sock
et-D
atag
ram
Soc
kets
and
con
nect
ion
less
RAW
Soc
ket
Prov
ide
dire
ct a
cces
s to
the
low
er-la
yer p
roto
cols
, Vi
z. IP
and
the
Inte
rnet
Con
trol M
essa
ge P
roto
col (
ICM
P)
5/25
/200
5TC
P /
IP34
Sock
et P
rimiti
ves f
or T
CPBI
ND Atta
ch a
loca
l add
ress
to a
soc
ket
LIST
ENAn
noun
ce w
illing
ness
to a
ccep
t con
nect
ions
; giv
e qu
eue
size
ACC
EPT
Bloc
k th
e ca
ller u
ntil
a co
nnec
tion
atte
mpt
arri
ves
CO
NN
ECT
Activ
ely
atte
mpt
to e
stab
lish
a co
nnec
tion
SEN
DSe
nds
som
e da
ta o
ver t
he c
onne
ctio
nR
ECEI
VER
ecei
ve s
ome
data
ove
r the
con
nect
ion
CLO
SER
elea
se th
e co
nnec
tion
5/25
/200
5TC
P /
IP35
Sock
et P
rogr
amm
ing
Typi
cal s
eque
nce
Allo
cate
Loc
al
Res
ourc
es
Spec
ify c
omm
unic
atio
n En
d Po
ints
(por
ts)
Initi
ate/
List
en fo
r co
nnec
tions
Se
nd/re
ceiv
e da
ta
Term
inat
e co
nnec
tions
gr
acef
ully
R
elea
se re
sour
ces
Des
ign
Issu
es
For s
cala
bilit
y, S
tate
fu
ll/St
atel
ess
serv
ers,
C
oncu
rrent
, Ite
rativ
e se
rvic
e
5/25
/200
5TC
P /
IP36
TCP
Port
Num
bers
Wel
l-kno
wn
ports
(bel
ow 2
56) a
re re
serv
edfo
r sta
ndar
d se
rvic
es: (
Port
no. i
n de
cim
al):
20: F
ile T
rans
fer P
roto
col (
data
)21
File
Tra
nsfe
r Pro
toco
l23
Tel
net
25 S
MTP
(Mai
l Tra
nsfe
r)37
Tim
e42
Hos
t Nam
e Se
rver
53 D
omai
n N
ame
Serv
er79
Fin
ger
119
NN
TP (N
ews
Tran
sfer
Pro
toco
l)
5/25
/200
5TC
P /
IP37
Clie
nt S
erve
r Par
adig
m
appl
icat
ion
tran
spor
tne
twor
klin
kph
ysic
al
appl
icat
ion
tran
spor
tne
twor
klin
kph
ysic
al
netw
ork
link
phys
ical
Rep
ly
Req
uest
5/25
/200
5TC
P /
IP38
TCP
Hea
der
Each
TC
P co
nnec
tion
is b
etw
een
Src
Port
No.
+ S
rcIP
Add
ress
, and
ds
tnPo
rt N
o. +
dst
nIP
Add
ress
Port
num
bers
per
mit
mul
tiple
of s
ever
al c
onne
ctio
ns in
to o
neIP
Ad
dr
5/25
/200
5TC
P /
IP39
TCP
Conn
ectio
n E
stab
lishm
ent
(a) T
CP
conn
ectio
n es
tabl
ishm
ent i
n th
e no
rmal
cas
e(b
) Cal
l col
lisio
n
5/25
/200
5TC
P /
IP40
Thre
e-w
ay H
ands
haki
ng in
TCP
/IP
Serv
er d
oes
a pa
ssiv
e op
en, a
nd C
lient
act
ive
conn
ect
Two
party
wan
ts to
agr
ee o
n a
set o
f par
amet
ers
New
Initi
al S
eque
nce
num
ber f
or b
oth
side
s, M
SS s
ize
Thre
e W
ay H
ands
haki
ng S
teps
Step
1: C
lient
(act
ive
party
) sen
d a
TCP
segm
ent w
ith
flag=
=SYN
and
seq
uenc
e nu
mbe
r = x
, des
tinat
ion
port
num
ber,
MSS
Step
2: S
erve
r res
pond
s w
ith fl
ags
= SY
N +
AC
K, s
eque
nce
num
ber =
y, A
ck=
x+1,
MSS
,St
ep 3
: Clie
nt re
spon
ds w
ith fl
ag =
AC
K, A
ck=
y+1
[ Ack
is s
et 1
+ se
quen
ce n
umbe
r --t
o te
ll w
hat i
s th
e ne
xt s
eque
nce
num
ber
expe
cted
and
that
all
earli
er s
eque
nce
num
ber i
s re
ceiv
ed ]
5/25
/200
5TC
P /
IP41
Thre
e-w
ay H
ands
haki
ng in
TCP
/IP
Why
not
sta
rt w
ith fi
xed
sequ
ence
num
ber?
Sequ
ence
Num
ber (
32 b
it) s
tarts
rand
omly
for e
ach
conn
ectio
n Ta
kes
care
of p
robl
ems
of d
uplic
ate
SYN
s, A
CKs
Com
men
tsIn
itial
seq
uenc
e nu
mbe
r is
not z
ero,
a ra
ndom
32
bit n
umbe
r Th
is is
to a
void
dup
licat
e SY
Ns
Afte
r a c
rash
, hos
t is
requ
ired
to n
ot re
boot
for t
he m
axim
um
pack
et li
fetim
e W
ait f
or M
SL ti
me
befo
re g
ener
atin
g or
resp
ondi
ng a
ny T
CP
cont
rol
mes
sage
like
SYN
or A
CK
This
mak
es p
acke
ts fr
om p
revi
ous
conn
ectio
ns d
ieTh
e se
quen
ce n
umbe
r can
be
rand
omiz
ed b
ased
on
cloc
kC
lock
is a
ssum
ed to
be
runn
ing
even
if h
ost c
rash
es
5/25
/200
5TC
P /
IP42
TCP
Conn
ectio
n Re
leas
e
Serv
erC
lient
FIN
M
AC
K M
+1
FIN
N
AC
K N
+1
Act
ive
clos
ese
gmen
t 1
Hal
f cl
ose
Pass
ive
clos
ese
gmen
t 2da
ta
Segm
ent 4
Segm
ent 3
5/25
/200
5TC
P /
IP43
TCP
Conn
ectio
n Re
leas
e
Two
way
rele
ase
is n
eces
sary
Each
end
of t
he fu
ll-du
plex
con
nect
ion
mus
t be
clos
ed
inde
pend
ently
Eith
er s
ide
can
send
FIN
whe
n it
is d
one
send
ing
data
Both
end
s m
aint
ain
stat
e re
late
d to
con
nect
ion.
O
n en
d of
dat
a co
mm
unic
atio
n th
ese
stat
es s
houl
d be
rele
ased
Hal
f Clo
se (O
ne w
ay c
lose
)Si
de A
sen
ds F
IN(w
ith s
eque
nce
num
ber)
Rec
eive
FIN
-AC
K, s
hut d
own
--> H
alf c
lose
Hal
f clo
se s
tate
Side
A c
anno
t sen
d da
ta to
Sid
e B,
but
vic
e ve
rsa
poss
ible
5/25
/200
5TC
P /
IP44
TCP
Conn
ectio
n Re
leas
eFu
ll cl
ose
(Bot
h w
ay c
lose
)Si
de B
als
o se
nd F
IN(C
an p
iggy
-bac
k on
FIN
-AC
K)Si
de A
Sen
d FI
N-A
CK
in th
e ot
her d
irect
ion
Lost
FIN
S et
c, ta
ken
care
of b
y tim
ers
If FI
N/ F
IN-A
CK
is lo
st a
fter s
ever
al a
ttem
pts,
sen
der (
activ
e cl
oser
) rel
ease
s co
nnec
tion
(oth
er s
ide
will
time-
out a
nd re
leas
e)W
ait f
or s
ome
time
The
activ
e cl
oser
wai
ts fo
r a fi
xed
time
afte
r sen
ding
FIN
-AC
K an
d be
fore
act
ually
clo
sing
con
nect
ion
(twic
e m
ax s
egm
ent l
ifetim
e,
MSL
)
TCP
cann
ot re
allo
cate
the
sock
et p
airt
ill 2M
SL2M
SL w
ait p
rote
cts
agai
nst d
elay
ed s
egm
ents
from
the
prev
ious
“inc
arna
tion”
of t
he c
onne
ctio
n
5/25
/200
5TC
P /
IP45
Stat
e D
iagra
m fo
r TCP
CLO
SED
LIST
EN
ESTA
BLIS
HED
CLO
SIN
GC
LOSE
#W
AIT
(Sta
rt)
CO
NN
ECT
/SYN
LIST
EN/-
SYN
/SYN
+ A
CK
SYN
#R
CVD FIN
#W
AIT
1
TIM
E#W
AIT
LAST
#AC
KFI
N#
WAI
T 2
SYN
#SE
NT
RST
/-
ACK/
-
(Act
ive
clos
e)
FIN
/AC
K
FIN
+ A
CK/
ACK
FIN
/AC
K
ACK/
-
ACK/
-
ACK/
-
SEN
D/S
YN
SYN
/SYN
+ A
CK
(
sim
ulta
neou
s op
en)
(Dat
a tra
nsfe
r sta
te)
SYN
+ A
CK/
ACK#
(Ste
p 3
of th
e th
ree-
way
han
dsha
ke)#
#C
LOSE
/FIN
CLO
SE/F
INFI
N/A
CK
CLO
SE/-
CLO
SE/-
CLO
SE/F
IN
CLO
SED
(Pas
sive
Clo
se)
(Tim
eout
/)
(Go
back
to s
tart)
5/25
/200
5TC
P /
IP48
TCP
Win
dow
Ada
ptat
ion
At tr
ansm
itter
, at t
ime
t, W
(t) =
tran
smitt
er's
con
gest
ion
win
dow
If an
ack
now
ledg
emen
t is
rece
ived
, inc
reas
e W
(t)If
loss
indi
catio
n (i.
e., t
imeo
ut) d
rop
W(t)
Des
irabl
e ro
und-
trip
win
dow
may
be
muc
h la
rger
than
bu
ffers
at e
ach
hop
If st
art w
ith th
e fu
ll w
indo
w, w
ill su
rely
lose
pac
kets
Slow
Sta
rtIn
itial
ly in
crea
se is
fast
(exp
onen
tial),
then
line
arIf
ther
e ar
e m
any
conn
ectio
ns, t
hen
they
sho
uld
shar
eTh
us w
indo
ws
shou
ld a
dapt
whe
n co
nnec
tions
arri
ve o
r dep
art
Adap
tatio
n w
ill be
forc
ed b
y pa
cket
loss
/dup
licat
e ac
ks
5/25
/200
5TC
P /
IP49
TCP
Cong
estio
n Co
ntro
lW
hy C
onge
stio
n?
Nod
es d
o no
t hav
e en
ough
pro
cess
ing
capa
bilit
y / i
ncom
ing
traffi
c is
fast
er th
an o
utgo
ing
traffi
cEf
fect
of C
onge
stio
nD
elay
and
Pac
ket L
oss
in th
e ne
twor
kSo
lutio
nsC
onge
stio
n C
ontro
lC
ontro
l afte
r con
gest
ion
(Rea
ctiv
e), V
iz.:
TCP
Taho
e, T
CP
Ren
o et
c.C
onge
stio
n Av
oida
nce
Con
trol b
efor
e co
nges
tion
(Pro
activ
e), V
iz.:
TCP
Vega
s, R
ED e
tc.
Con
gest
ion
cont
rol s
trate
gies
Adap
tive
Win
dow
Man
agem
ent t
echn
ique
5/25
/200
5TC
P /
IP50
Cong
estio
n Co
ntro
l in
TCP
Fast
-retra
nsm
itFo
r pac
ket l
oss
(tim
e-ou
t) dr
op th
e cw
ndw
indo
w s
ize
to 1
Fo
r 3 d
uplic
ate
acks
, dro
p th
e cw
ndw
indo
w s
ize
as h
alf o
f cw
ndsi
ze
Wth
(t +
) = [W
( t )
/2]
Fast
-reco
very
In c
ase
of fa
st-re
trans
mit,
do
not d
rop
cong
estio
n w
indo
w to
1Se
t it t
o W
th(t
+) =
[W
( t )
/2]
TCP
Ren
o an
d R
eno-
2 In
Ren
o, c
wnd
decr
emen
ted
for e
ach
mar
k (lo
ss o
r 3 d
upac
ks)
In R
eno-
2 cw
nddo
es n
ot d
ecre
men
ted
for e
ach
mar
kD
ecre
men
ted
once
per
win
dow
or R
TT
Ren
o-2
is g
ood
for w
irele
ss li
nk
5/25
/200
5TC
P /
IP52
Ele
men
ts o
f Rou
ting
Perfo
rman
ce C
riter
iaN
umbe
r of h
ops,
Cos
t, D
elay
, Thr
ough
put
Dec
isio
n Ti
me
Pack
ets
(dat
agra
m),
or S
essi
on (v
irtua
l circ
uit)
Dec
isio
n M
akin
g N
ode
Cen
tral (
cent
ralis
ed),
Each
(dis
tribu
ted)
, or O
rigin
atin
g no
deN
etw
ork
Info
rmat
ion
Sour
ceN
one,
Loc
al, A
djac
ent n
ode,
Nod
es a
long
rout
e, o
r All
node
sR
outin
g St
rate
gyFi
xed,
Flo
odin
g, R
ando
m o
r Ada
ptiv
eAd
aptiv
e R
outin
g U
pdat
e Ti
me
Con
tinuo
us, P
erio
dic,
upo
n Lo
ad c
hang
e, o
r upo
n To
polo
gy
5/25
/200
5TC
P /
IP53
Rout
ing
Alg
orith
ms
Use
d to
set
up
the
prop
er ro
utin
g pa
ths
from
sou
rce
node
s to
des
tinat
ion
node
s M
appe
d as
app
ropr
iate
ent
ries
in R
outin
g Ta
bles
mai
ntai
ned
at th
e no
des
of th
e ne
twor
k.D
ecid
es w
hich
out
put l
ine
an in
com
ing
pack
et s
houl
d be
tran
smitt
ed o
n, p
acke
t by
pack
etSh
ould
be
fair,
robu
st, c
orre
ct, s
impl
e, o
ptim
al a
nd
effic
ient
Opt
imis
em
etric
ssu
ch a
s de
lay,
thro
ughp
ut, n
o. o
f ho
psC
an b
e st
atic
or d
ynam
icAd
apts
to c
hang
es in
the
netw
ork
5/25
/200
5TC
P /
IP54
Rout
ing
Mec
hani
smH
op-b
y-ho
p R
outin
gEa
ch ro
uter
sel
ects
its
outp
ut li
nk fo
r the
des
tinat
ion
usin
g its
rout
ing
tabl
eSo
urce
Rou
ting
Sour
ce n
ode
puts
the
com
plet
e ro
ute
e.g.
A –
B –
C –
Efo
r the
pat
h fro
m
A to
E in
the
pack
et h
eade
rH
ot–P
otat
o Fo
rwar
ding
Forw
ards
on
shor
test
out
put q
ueue
Sim
ple,
may
not
reac
h de
stin
atio
nFl
oodi
ngFo
rwar
ds p
acke
t on
all l
inks
exc
ept t
he o
ne it
cam
e on
Very
relia
ble,
exp
onen
tial n
umbe
rof p
acke
tsSe
lect
ive
Floo
ding
Rou
ter d
isca
rds
dupl
icat
es o
f a p
acke
t tra
nsm
itted
onc
e by
labe
lling
ever
y pa
cket
with
sou
rce
id a
nd s
eque
nce
num
ber
Forw
ards
onl
y in
the
right
dire
ctio
n
5/25
/200
5TC
P /
IP55
Inte
rior &
Ext
erio
r Rou
ting
Inte
rior R
outin
gIn
terio
r Rou
ting
occu
rs w
ithin
an
auto
nom
ous
syst
emVi
z.: R
IP a
nd O
SPF
The
basi
c ro
utab
le e
lem
ent i
n th
is c
ase
is th
e IP
net
wor
k or
su
bnet
wor
kEx
terio
r Rou
ting
Exte
rior r
outin
g oc
curs
bet
wee
n au
tono
mou
s sy
stem
sVi
z.: B
GP
The
basi
c ro
utab
le e
lem
ent h
ere
is th
e Au
tono
mou
s Sy
stem
id
entif
ied
by a
n Au
tono
mou
s Sy
stem
Num
ber (
ASN
)W
hile
ther
e m
ay b
e m
any
diffe
rent
inte
rior r
outin
g sc
hem
es, a
sin
gle
exte
rior r
outin
g sy
stem
man
ages
the
glob
al In
tern
et
5/25
/200
5TC
P /
IP56
Rout
ing
Tabl
e: E
xam
ple
[hem
antr@
vani
hem
antr]
$ /s
bin/
rout
e -n
Kern
el IP
rout
ing
tabl
eD
estin
atio
n
Gat
eway
G
enm
ask
Flag
s M
etric
Ref
Use
Ifac
e10
.107
.1.1
3
0.0
.0.0
25
5.25
5.25
5.25
5 U
H
0
0
0
e
th0
10.1
07.1
.12
0
.0.0
.0
255.
255.
255.
255
UH
0
0
0
eth
010
.107
.2.1
0.0.
0.0
255
.255
.255
.255
UH
0
0 0
e
th0
10.1
07.1
.5
0.
0.0.
0
2
55.2
55.2
55.2
55 U
H
0
0
0
eth
010
.107
.1.4
0.0.
0.0
255
.255
.255
.255
UH
0
0 0
e
th0
10.1
07.1
.7
0.
0.0.
0
2
55.2
55.2
55.2
55 U
H
0
0
0
eth
010
.107
.1.6
0.0.
0.0
255
.255
.255
.255
UH
0
0 0
e
th0
10.1
07.1
.3
0.
0.0.
0
2
55.2
55.2
55.2
55 U
H
0
0
0
eth
016
9.25
4.0.
0
0.0
.0.0
25
5.25
5.0.
0
U
0
0
0
e
th0
127.
0.0.
0
0.
0.0.
0
255
.0.0
.0
U
00
0
lo
0.0.
0.0
10.
107.
1.11
0.0.
0.0
U
G
0
0
0
e
th0
5/25
/200
5TC
P /
IP57
Dev
ices
for I
nter
conn
ectio
nR
epea
ter-
Con
nect
s tw
o LA
Ns
at th
e Ph
ysic
al la
yer
leve
l H
ub-M
ulti-
port
Rep
eate
r, i.e
. con
nect
s m
ultip
le L
ANs
Whe
n a
pack
et a
rrive
s at
one
por
t, it
is c
opie
d to
the
othe
r por
ts
so th
at a
ll se
gmen
ts o
f the
LAN
can
see
all
pack
ets
Brid
ge-C
onne
cts
LAN
s at
the
Dat
a Li
nk la
yer l
evel
Con
nect
s tw
o LA
Ns
or tw
o se
gmen
ts o
f the
sam
e LA
NTh
e tw
o LA
Ns
may
be
alik
e or
dis
sim
ilar
e.g.
, a b
ridge
can
con
nect
an
Ethe
rnet
with
a T
oken
-Rin
g LA
NM
ay b
e ne
eded
due
to th
e ph
ysic
al d
ista
nce
betw
een
two
LAN
sM
ay b
e be
caus
e pr
ovid
ing
so m
any
host
s m
ay n
ot b
e po
ssib
le
on o
ne L
ANPr
ovid
es s
ecur
ity a
gain
st p
rom
iscu
ous
mod
e
5/25
/200
5TC
P /
IP58
Dev
ices
for I
nter
conn
ectio
n
Rou
ter-
Con
nect
s ne
twor
ks a
t the
Net
wor
k la
yer
Con
nect
s at
leas
t tw
o ne
twor
ks
Dec
ides
rout
es fo
r pa
cket
s, b
ased
on
dest
inat
ion
addr
ess
and
netw
ork
topo
logy
Exch
ange
s in
form
atio
n w
ith o
ther
rout
ers
To le
arn
netw
ork
topo
logy
Mai
ntai
ns a
Rou
ting
Tabl
eAv
aila
ble
rout
es a
nd th
eir c
ondi
tions
Use
s ta
ble
alon
g w
ith p
ath
cost
alg
orith
ms
Det
erm
ine
the
best
rout
e fo
r a g
iven
pac
ket
5/25
/200
5TC
P /
IP59
Dev
ices
for I
nter
conn
ectio
n
Gat
eway
-Con
nect
s ne
twor
ks a
t Tra
nspo
rt or
hig
her
Gat
eway
can
be
a R
oute
r
A ne
twor
k po
int t
hat a
cts
as a
n en
tranc
e to
ano
ther
net
wor
kO
ften
acts
as
a pr
oxy
serv
er a
nd a
fire
wal
l ser
ver
Switc
h-I
mpl
emen
tatio
n of
a B
ridge
/Rou
ter/G
atew
ay in
si
licon
-as
a L
ayer
2 /
Laye
r 3 /
Laye
r 4…
... S
witc
hW
hen
a pa
cket
arri
ves
at o
ne p
ort,
it is
cop
ied
to th
e ot
her p
orts
so
that
all
segm
ents
of t
he L
AN c
an s
ee a
ll pa
cket
sLa
yer 3
sw
itche
s (IP
sw
itche
s) a
lso
perfo
rm ro
utin
g fu
nctio
ns