Вы находитесь на странице: 1из 69

Module 9!

Network Layer!

CS655!

9-1!

Please note: Most of these


slides come from this book. Note
their copyright notice below!
part. In return for use,
we only ask the
following:
v If you use these
slides (e.g., in a class)
in substantially
unaltered form, that
you mention their
source (after all, wed
like people to use our
book!)
v If you post any
slides in substantially
Were making these
slides freely available unaltered form on a
www site, that you
to all (faculty,
note that they are
students, readers).
Theyre in PowerPoint adapted from (or
form so you can add, perhaps identical to)
modify, and delete
our slides, and note
slides (including this our copyright of this
one) and slide
material.
content to suit your
Thanks and enjoy!
needs. They
obviously represent a JFK/KWR
lot of work on our

A note on the
use of these
ppt slides:

All
material
copyright
19962010
J.F
Kurose
and K.W.
Ross, All
Rights
Reserved

th

2
0
0
9
.
"
!

5 edition. "
Jim
Kurose,
Keith
Ross"
Computer
Networking: A Addison
Top Down
Wesley,
Approach "
April
CS65 5!

9-2!

Network layer!
ents
trans into
data
port gram
segm s!
ent
from
sendi
ng to
recei
ving
host !

on

sendin
g side
encap
sulate
s
segm

app
licat
ion!
trans
port!
!
data
link

!
n
e
t
w
o
r
k
!
d
a
t
a
l
i
n
k
!
p
h
y
s
i
c
a
l

!
network!
data link!
physical
network!
data link!
physical

!
network!
data link!
physical
!
network!
data link!
physical

m
on en
r t
es
ct
eio
vi
nt
gr
si a
dn
es
, p
do
elr
iv t
el
r a
y
se
sr
e!
g

ni
etn
we
ov
re
kr
ly
ah
yo
es
rt
,
p
rr
oo
tu
ot
ce
or
l!
s

!
netw
ork!
d
a
t
a
li
n
k
!
p
h
y
s
i
c
a
l

!
network!

netw

data link!

physical
data link!
physical
!
network!
!
data link!
network!
physical
data link!
physical
C

data

phys

application!
transport!
!
data link!
physical

Network Layer is Host-to-Host!


client

server

application

application

transport

transport

network

network

network

network

link

link

link

link

physical

physical

physical

physical

router router
CS655!

9-4!

Internet Protocols!
Application! FTP Telnet NFS SMTP HTTP !

Transport!

TCP!

UDP!

Segment!

Network!

Datagram!

Data Link!

X.25! Ethernet! Packet! ATM! FDDI!

Physical!

Radio!
CS655!

9-5!

Frame!

Two Key Network-Layer Functions!


Forwarding: move packets from routers input to appropriate
router output!

Routing: determine route taken by packets from source


to destination. !
routing algorithms!

Connection service: before datagrams flow, two end hosts


and intervening routers establish virtual connection (VC)!
Needed in some network architectures: ATM, frame relay, X.25!

Network vs transport layer connection service:!


network: between

two hosts (may also involve intervening routers in case of

VCs)!
transport: between two processes!

CS655!

9-6!

Interplay Between Routing and


Forwarding!
routing algorithm

local forwarding table


header value output link
0100
0101
0111
1001

3
2
2
1

value in arriving
packets header

0111

3 2
CS655!
9-7!

Network layer connection and


connection-less service!
Datagram network provides network-layer connectionless service!
Virtual
Circuit (VC) network provides network-layer connection
service!
Analogous to the transport-layer services, but:!

s : host-to-host!
e no choice: network provides
r
v one or the other!
i
c implementation: in network
e
core!
CS655!

9-8!

Virtual Circuits!
source-to-destination path behaves much like telephone
circuit!

p formance-wise!
e network actions along
r source-to-destination path!

Vifier (not
each passing
Cdestination host
connection!
call setup, teardown address)!
link, router resources
i
(bandwidth, buffers)
for each call before

every
router
on
d sourcemay be allocated to
data can flow!
e destination
VC (dedicated
maintains resources =
each packet carries nt path
predictable service)!
state for
!

CS655!

9-9!

Datagram networks!
no call setup at network layer!
routers: no state about end-to-end connections!
no network-level concept of connection!

packets forwarded using destination host address!


packets between same source-destination pair may take

different paths!
application!
transport!

application!
transport!
2. Receive data network!
data link!

network! 1. Send data

data link!

physical

physical
CS655!

9-10!

Datagram Forwarding table!


4
billion
IP
addre
sses,
so
rather
than
list

routing algorithm

local forwarding table


dest address output
address-range 1 3 link
address-range 2
range 3
address-range 4

IP destination
address in
arriving
packets

individual
destination
address!
list range
of
addresse
s!
(aggregat
e table
entries)!

2
2
1

h
e
a
d
e

1
3
CS655!

9-11!

Datagram Forwarding table!


Link Interface!
Destination Address Range!
11001000 00010111 00010000 00000000
0!
through
!
11001000 00010111 00010111 11111111
1!
11001000 00010111 00011000 00000000
through!
11001000 00010111 00011000 11111111
2!
11001000 00010111 00011001 00000000
through!
11001000 00010111 00011111 11111111
3!
otherwise

Destination Address Range


11001000 00010111
11001000 00010111
11001000 00010111
CS655!

otherwise

Datagram or VC network: why?!


Internet (datagram)!

data exchange among computers!


elastic service, no strict

timing req. !

smart end systems

(computers)!
can adapt, perform control,
error recovery!
simple inside network,
complexity at edge!

many link types !


different characteristics!
uniform service difficult!

dum

ATM (VC)!

evolved from
telephony!

end

human

syst
ems!

conversation: !

strict

telep

timing,
reliabilit
y
require
ments!

hone
s!
complexity

inside
network!

need for

guaranteed
service!
CS655!

9-13!

Router Architecture Overview!


two key router functions: !

run routing algorithms/protocol (RIP, OSPF, BGP)!


forwarding datagrams from incoming to outgoing link!

switching!
fabric!

!
processor!

router input ports!


CS655!

9-14!

router output ports!

Input Port Functions!


line!
termination!

link !
layer !
protocol!
(receive)!

lookup,!
forwarding!

switch!
fabric!

queueing!

Physical layer:!
bit-level reception!
Data link layer:! e.g., Ethernet!

De
ce
ntr
aliz
ed
swi
tch
ing
:!

given
datagram
destination,

lookup output port


using forwarding
table in input port
memory!

goal: complete input

port processing at line


speed!

queuing:
if datagrams
arrive faster than
forwarding rate into
switch fabric!

CS655!

9-15!

The Internet Network layer!


Host, router network layer functions:!
Transport layer: TCP, UDP!

Network!
layer!

IP protocol!
addressing conventions!

Routing protocols!
path selection!
RIP, OSPF, BGP!

datagram format!
packet handling conventions!

forwarding!
table!

ICMP protocol!
error reporting!
router signaling!

Link layer!
Physical layer!
CS655!

9-16!

IP datagram format!
IP protocol
ve
rsi
on
!
nu
m
be
r
header
l
e
n
g
t
h
!
(
b
y

t
remaining hops!
e
(decremented at
s
! each router)!
)
upper layer

t protocol! to deliver
y payload to!
p
e

o
f
d
a
t
a

m
ax
nu
m
be
r!

32 bits
head.! type of!
ver len service
16-bit identifier
time to!

upper!

live

layer

total datagram!
length (bytes)!

length
fragment!
flgs
offset
header!

for!
fragmentation/!
reassembly!

checksum

32 bit source IP address


32 bit destination IP address
Options (if any)

E.g. timestamp,!
record route!
taken, specify!

data !

(variable length,!

list of routers !

typically a TCP !

to visit.!

or UDP segment)

CS655!

9-17!

IP Fragmentation & Reassembly!


network links have MTU

(maximum transmission
unit): largest possible linklevel
frame.!
different link types,
different MTUs !

large IP datagram
divided (fragmented)
within net!
one datagram

becomes several
datagrams!
reassembled only at

final destination!
IP header bits

us
ed
to
id
en
tify
,
or
de
r
rel
at
ed
fra
g
m

ents!

o
ut
:
3
s
m
al
le

fragmentatio
n: !
in: one large
datagram!
CS655!

9-18!

r
datag
rams!

reassembly!

IP Addressing: introduction!
223.1
.1.1!
IP address: 32-bit
identifier for
host, router
interface !

interface:

connectio
n
between
host/route
r
and
physical
link!

223
.1.1
.2!

223.1
.1.4!
223.1.
2.9!

21.2.1!
2
3
.

223.1.1.3

223.1.3.27!

s
routers typically
have
t
multiple interfaces!

223.1.2.2!

t
y
p
i
c
a
l
l
y
h
a
s

IP addresses associated

with each interface!

223.1.1.1 = 11011111 00000001 00000001 000


223!

1!

1!

Subnets!
IP
add
res
s: !

s
u
b
n
e
t
p
a
r

t
(
h
i
g
h
o
r
d
e
r
b
i
t

s
)
!

host
part
(low
orde
r
bits)
!

Wh
ats a
subn
et ?!

d
e
v
i
c
e
i
n
t
e
r
f
a
c
e
s
w
i

t
h
s
a
m
e
s
u
b
n
e
t
p
a
rt
o
f
I
P
a

dd
re
ss
!

c
a
n
p
h
y
s
i
c
a
l
l
y

r
e
a
c
h
e
a
c
h
o
t
h
e
r
w
i

th
o
ut
in
te
rv
e
ni
n
g
ro
ut
er
!

223.1.1.
1!
223.1.2.1!

223.1.1.
2!

223.
1.1.4

!
223.
1.2.9

!
223.1.1.
3!
223.1.3.2
7!
223.1.2.

2!

!
2
2
3
.
1
.
3
.

Sub
net

1
.

!
(223.1 ) !
.3.0/24
CS6 55!

9-20!

IPv6!
Initial motivation: 32-bit address space soon to be completely allocated.
Additional motivation:!
header format helps speed processing/forwarding!
header changes to facilitate QoS !

IPv6 datagram format: !


fixed-length 40 byte header!
no fragmentation allowed!

CS655!

9-21!

IPv6 Header (Cont)!


Priority: identify priority among datagrams in flow!
Flow Label: identify datagrams in same flow. !
(concept offlow not well defined).!
Next header: identify upper layer protocol for data !
ver! pri!

flow label!

payload len!

next hdr!

source address!
(128 bits)!
destination address!

(128 bits)!

data!

32 bits!
CS655!

9-22!

hop limit!

Other Changes from IPv4!


Checksum: removed entirely to reduce processing time at each hop!
Options: allowed, but outside of header, indicated by Next Header field!
ICMPv6: new version of ICMP!

a tional message types, e.g.


d Packet Too Big!
d multicast group management
i functions!

CS655!

9-23!

Routing Algorithms Interplay between


routing, forwarding!
routing algorithm

local forwarding table


header value output link
0100
0101
0111
1001

3
2
2
1

value in arriving
packets header

0111

3 2
CS655!

9-24!

Graph abstraction!
5
2

Graph: G=(N,E)!

3 w

x!

5
1

z!
2

N: set of routers = {u, v, w, x, y, z}!


E: set of links = {(u,v), (u,x), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z)}!

c(x,y) = cost of link (x,y)!


e.g., c(w,z) = 5!
cost could always be 1, or inversely related to bandwidth, or

inversely related to congestion!

Cost of path (x1, x2, x3,, xp) = c(x1,x2) + c(x2,x3) + + c(xp-1,xp) !

Routing algorithm: algorithm that finds least-cost path!


CS655!

9-25!

Routing Algorithm classification!


Global or
decentralized
information?!

iterative

Global:!

di

process of
computation
, exchange
of info with
neighbors!

all routers have

complete topology,
link cost info!

link state (LS)


algorithms!

Decentralized: !

router knows physicallyconnected neighbors,


link costs to neighbors!
CS655!

9-26!

sta
nc
e
ve
cto
r
(D
V)
alg
ori
th
ms
!

Static or
dynamic?!
Static: !

routes
change slowly
over time!

Dynamic: !

routes
change more
quickly!
periodic
update!
in response
to link cost
changes!

A Link-State Routing Algorithm!


Dijkstras algorithm!

net topology, link costs known to all nodes!


accomplished via link state broadcast !
all nodes have same info!

Dijkstras algorithm: computes least cost paths from one node (source) to
all other nodes!
gives forwarding table for that node!

iterative: after k iterations, know least cost path to k destinations!

CS655!

9-27!

set of nodes whose


least cost path

definitively known!

Dijsktras Algorithm!
current value of cost
of path from source to

1 Initialization:
3
4

8
9
10
11
12
13
14
15

2 N' = {u}
destination v!
for all nodes v
if v adjacent to u
5
then
= c(u,v)
6
else D(v) =
7
Loop
find w not in N' such that D(w) is a minimum
add w to N'
update D(v) for all v adjacent to w and not in N' :
D(v) = min( D(v), D(w) + c(w,v) )
/* new cost to v is either old cost to v or known
shortest path cost to w plus cost from w to v */
until all nodes in N'
CS655!

9-28!

link cost from node


x to y; = if not
direct neighbors!

Dijkstras algorithm: example!


Step
0
1
2
3
4
5

N'
u
ux
uxyv
uxyvw
uxyvwz

D(v),p(v) D(w),p(w)
2,u
5,u
2,u
4,x
2,u
3,y
3,y

D(x),p(x) D(y),p(y) D(z),p(z)

1,u
!

2,x
4,y
4,y
4,y

5
2

x!

1
CS655!

3 w

9-29!

3
1

z!
2

Dijkstras algorithm: example (2) !


Resulting shortest-path tree from u:!
v

z!

x!

Resulting forwarding table in u:!


destination! link!
v! (u,v)! x!
(u,x)!
y! (u,x)!
w! (u,x)!
z! (u,x)!
CS655!

9-30!

Distance Vector Algorithm !


neighbors v of x!
Bellman-Ford Equation

18!

(dynamic programming)!

y!

Define!
dx(y) := cost of least-cost path from x to y!

2
5
!

!
Then!

2!

2
0
!

3!

dx(y) = minv{c(x,v) + dv(y)}!


!
v

where min is taken over all

3!

CS655!

9-31!

Bellman-Ford example !
5
2

3 w

x!

1
3
1

Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3!


5
2

z!

B-F equation says:!


du(z) = min { c(u,v) + dv(z),!
c(u,x) + dx(z),!
c(u,w) + dw(z) }!
= min {2 + 5,!
1 + 3,!

Node that
achieves

min
imu
m

5 + 3} = 4!
is next! hop forwarding
in shortest table!
path
CS655!

9-32!

Distance Vector Algorithm !


Each node x maintains the following!
Its own distance vector Dx = [Dx(y): y $ N ] (N is the set of nodes)!

Dx(y) = estimate of least cost from x to y!


cost to each neighbor v: c(x,v)!

its neighbors distance vectors. For each neighbor v, x maintains "

Dv = [Dv(y): y $ N ]!

from time-to-time, each node sends its own distance vector estimate to
neighbors!

when x receives new DV estimate from neighbor, it updates its own DV


!

using B-F equation:!

Dx(y) minv{c(x,v) + Dv(y)} for each node y N!

Under minor, natural conditions, the estimate Dx(y) converge to the


actual least cost dx(y)!

CS655!

9-33!

Distance Vector Algorithm!


Each
node:
Iterative, asynchronous:
each local iteration caused
by: !

local link cost change !


DV update message
from neighbor!

Distributed:!

wait for
(change in
local link
cost or
msg from

neighbor)

each node notifies neighbors

recompute estimates

only when its DV changes!


neighbors then notify their

neighbors if necessary!

if DV to any dest has


changed, notify neighbors

CS655!

9-34!

t
o
!

Dx(y) = min{c(x,y) + Dy(y),


c(x,z) + Dz(y)} " =
min{2+0 , 7+1} = 2!

node x table!

node y table!

from

cost to!
x y z!
x! ! ! !

y! 2 0 1!
z! !! !

node z table!
c
o
s
t

from

y! 2 0 1!
z! 7 1 0!

from

y! !! !
z! !! !

cost to!
x y z!
x! 0! 2 !3!
!

from

cost to!
x y z!
x! 0 2 7!

z
!
x! !
y! !! !
z! 7! 1! 0!

Dx(z) = min{c(x,y) + " Dy(z), c(x,z) + Dz(z)} !

= min{2+1 , 7+0} = 3!

2 1
CS655!

9-35!

time!

z!

Dx(y) =
min{c(x,y) +
Dy(y), c(x,z)
+ Dz(y)} "
Dx(z) = min{c(x,y) + "
= min{2+0 , 7+1} = 2!

Dy(z), c(x,z) +

node x table!
!from

from

x! 0 2 3!
!from

from

y! !! !
z! !! !

cost to!
x y z!
x! 0 2 7!

z! !! !

node z table!

z!

y!

z!

2 0 1!

7 1 0!
cost to! x y z!
x! 0 2 7!

y!

z!

y!

z!

2 0 1! 7 1 0!
cost to! x y z!
x! 0 2 7!
0!

cost to!
x y

!from

from

node y table! to!


x y z!
x! ! ! !
y! 2 0 1!

= min{2+1 , 7+0
cost to! x y z!

2 0 1!

31

x y z!
x! 0 2 3!

cost to! x
y z!

fro

cost to!

S6

55!

9-36!

z!

3 1 0!
ti
m
e
!

Comparison of LS and DV algorithms!


Message complexity!

LS: with n nodes, E links, O(nE)


messages sent !

DV: exchange between neighbors


only!
convergence time varies!

Speed of Convergence!

LS: O(n2) algorithm requires


O(nE) messages!
may have oscillations!

DV: convergence time varies!


may be routing loops!
count-to-infinity problem!

Robustness:
what
happens if
router
malfunction
s?!
LS: !
node can

advertise
incorrect
link cost!
each
node
computes

only its
own table!

DV:!
DV

nod
e
can
adve
rtise
incor
rect
path
cost!
each
nodes
table

used by others !

error
propagate thru

CS655!

9-37!

network!

Hierarchical Routing!
So far we assumed!

All routers are identical!


Network is flat!
These are not true in practice!
scale: with 200 million destinations:!

cant store all destinations in routing tables!!


routing table exchange would swamp links! !
administrative autonomy!

internet = network of networks!

each network admin may want to control routing in its own network!
!
CS655 !

9-38!

Hierarchical Routing!
aggregate routers into regions, autonomous systems (AS)!

routers in same AS run same routing protocol!

i ra-AS routing protocol!


nrouters in different AS can run
t different intra-AS routing protocol!

gateway router!

at
edge
of
its
own
has
i
another
!
AS!
link to nAS!
router
CS655!

9-39!

RIP (Routing Information Protocol)!


included in BSD-UNIX distribution in 1982!
distance vector algorithm!
d
i
s
t
a
n
c
e

metric: # hops (max = 15 hops), each link has


cost 1!
DVs exchanged with neighbors every 30 sec in
response message (aka advertisement)! each
advertisement: list of up to 25 destination
subnets (in IP addressing sense)!

from router A to

u! v!
A

x! z! C!

B
D

shops!
u 21
w!b 22
n 23
e 24
y! t
25
26

1!
2!
2!
3!
3!
2!

destination subnets:!

RIP: Example !
z!
w!

x!
A!

y!
D!

B!

C!
routing table in router D!
destination subnet

next router

# hops to dest

w
y
z
x

A
B
B
--

2
2
7
1

....

CS655!

9-41!

RIP: Example !
dest
w
x
z
.

w!

A-to-D advertisement!
next hops
1
1
C
4
...

z!

x!
A!

y!
D!

B!

C!
routing table in router D!
destination subnet

next router

# hops to dest

w
y
z
x

A
B
B A
--

2
2
7
1

....

CS655!

9-42!

OSPF (Open Shortest Path First)!


uses Link State
open: publicly available!

OSPF advertisement
carries one entry per
neighbor router!

algorithm !
LS packet
r te computation using
dissemination! o Dijkstras algorithm!
topology map at u
each node!

t to entire AS
advertis e(via flooding)!
ements d
carried in
dissemina

OSPF messages directly


over IP (rather than TCP
or UDP)!
CS655!

9-43!

OSPF advanced features!


(not in RIP)!
security: all OSPF messages authenticated (to
prevent malicious intrusion) !

multiple same-cost paths allowed (only one path in RIP)!


for each link, multiple cost metrics for different TOS (e.g.,
satellite link cost set low for best effort ToS; high for real
time ToS)!

integrated uni- and multicast support: !

Multicast OSPF (MOSPF) uses same topology data base as OSPF!

hierarchical OSPF in large domains.!


CS655!

9-44!

Hierarchical OSPF!
boundary router!
backbone router!
backbone!
area!
border!
routers!

Area 3!
internal!
Area 1!

routers!
Area 2!
CS655!

9-45!

Hierarchical OSPF!
two-level hierarchy: local area, backbone.!

state advertisements only in area !


l
i each nodes has detailed area
n topology; only know direction
k (shortest path) to nets in other
- areas.!

a e to other Area backbone.!


area border dv Border routers.!
boundary
routers:
ebackbone
summarize r
routers: connect
distances to t routers: run
i
nets in own sOSPF routing
to other ASs.!
area,
limited to
CS655!

9-46!

Вам также может понравиться