Network Layer - Part 3
Network Layer - Part 3
Chapter 4
Chapter 4: outline
4.5 routing
4.1 introduction
algorithms
link state
4.2 virtual circuit and datagram networks
distance vector
4.3 what’s inside a router
hierarchical routing
4.4 IP: Internet Protocol
4.6 routing
datagramin the Internet
format
RIP
IPv4 addressing
OSPF
ICMP
BGP
IPv6
4.7 broadcast and multicast routing
IP destination address in
arriving packet’s header
1
3 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) }
notes: 5 7
4
construct shortest path
tree by tracing 8
predecessor nodes 3
u w y z
ties can exist (can be 2
broken arbitrarily)
3
7 4
v
Network Layer 4-11
Dijkstra’s algorithm: another example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0 0
1
C C 0 1
C 1+e C 0
1
e
given these costs, given these costs, given these costs,
initially find new routing…. find new routing….find new routing….
resulting in new costs resulting in new cost
resulting in new costs
Network Layer 4-14
Consider the following network. With the indicated link costs, use
Dijkstra’s shortest-path algorithm to compute the shortest path
from x to all network nodes. Show how the algorithm works by
computing a table.
Consider the network shown . Using Dijkstra’s algorithm, and showing your work using a table,
do the following:
a. Compute the shortest path from t to all network nodes.
b. Compute the shortest path from u to all network nodes.
c. Compute the shortest path from v to all network nodes.
d. Compute the shortest path from w to all network nodes.
e. Compute the shortest path from y to all network nodes.
f. Compute the shortest path from z to all network nodes.
http://gaia.cs.umass.edu/kurose_ross/interactive/dij.php
http://gaia.cs.umass.edu/kurose_ross/interactive/dij_advanced.php
Chapter 4: outline
4.5 routing
4.1 introduction
algorithms
link state
4.2 virtual circuit and datagram networks
distance vector
4.3 what’s inside a router
hierarchical routing
4.4 IP: Internet Protocol
4.6 routing
datagramin the Internet
format
RIP
IPv4 addressing
OSPF
ICMP
BGP
IPv6
4.7 broadcast and multicast routing
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min
v
{c(x,v) + dv(y) }
t=0 Da(c) =
∞ 1 1
Da(d) =
All nodes 1
have distance Da(e) =
estimates to A few asymmetries:
∞ d e f missing link
nearest Da(f) = 1 1
neighbors larger cost
∞
(only)
Da(g) =
∞ 1 1 1
All nodes send
Da(h) =
their local
∞
distance
Da(i) =
vector to their g h i
neighbors ∞ 1 1
Distance vector example:
iteration
a b c
8 1
t=1 1 1
All nodes:
receive
distance
vectors from d e f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g h i
1 1
Distance vector example:
iteration
a
compute compute
b compute
c
8 1
t=1 1 1
All nodes:
receive
distance
vectors from d
compute e
compute compute
f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g
compute h
compute i
compute
1 1
Distance vector example:
iteration
a b c
8 1
t=1 1 1
All nodes:
receive
distance
vectors from d e f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g h i
1 1
Distance vector example:
iteration
a b c
8 1
t=2 1 1
All nodes:
receive
distance
vectors from d e f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g h i
1 1
Distance vector example:
iteration
compute
a compute
b compute
c
2 1
t=2 1 1
All nodes:
receive
distance
vectors from d
compute compute
e compute
f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g
compute compute
h compute
i
8 1
Distance vector example:
iteration
a b c
8 1
t=2 1 1
All nodes:
receive
distance
vectors from d e f
neighbors 1 1
compute their
new local
distance vector 1 1 1
send their new
local distance
vector to
neighbors g h i
1 1
Distance vector example:
iteration
…. and so on
computation
Db(a) = 8 Db(f) = ∞
Db(c) = 1 Db(g) = ∞ Dc(b) = 1
DV in a: Db(d) = ∞ Db(h) = ∞ Dc(c) = 0
Da(a)=0 Db(e) = 1 Db(i) = ∞ Dc(d) = ∞
Da(b) = 8 Dc(e) = ∞
Da(c) = ∞ a bb c Dc(f) = ∞
8 compute 1
Da(d) = 1 Dc(g) = ∞
Dc(h) = ∞
t=1 Da(e) = ∞
Da(f) = ∞ 1 1 Dc(i) = ∞
b receives DVs Da(g) = ∞ DV in e:
from a, c, e, Da(h) = ∞ De(a) = ∞
computes: e
Da(i) = ∞ De(b) = 1
d e f De(c) = ∞
1
Db(a) = min{cb,a+Da(a), cb,c +Dc(a), cb,e+De(a)} = min{8,∞,∞} =8 1
De(d) = 1
Db(c) = min{cb,a+Da(c), cb,c +Dc(c), c b,e +De(c)} = min{∞,1,∞} = 1
De(e) = 0
Db(d) = min{cb,a+Da(d), cb,c +Dc(d), c b,e +De(d)} = min{9,2,∞} = 2 De(f) = 1
1 1 1
Db(e) = min{cb,a+Da(e), cb,c +Dc(e), c b,e +De(e)} = min{∞,∞,1} = 1 De(g) = ∞
Db(f) = min{cb,a+Da(f), cb,c +Dc(f), c b,e +De(f)} = min{∞,∞,2} = 2
DV in b: De(h) = 1
Db(g) = min{cb,a+Da(g), cb,c +Dc(g), c b,e+De(g)} = min{∞, ∞, ∞} = ∞ Db(a) = 8 Db(f) =2 De(i) = ∞
g h 1Db(c) = 1 i =∞
Db(g)
1 ∞, 2} = 2
Db(h) = min{cb,a+Da(h), cb,c +Dc(h), c b,e+De(h)} = min{∞,
Db(d) = 2 Db(h) = 2
Db(i) = min{cb,a+Da(i), cb,c +Dc(i), c b,e+De(i)} = min{∞, ∞, ∞} = ∞ Db(e) = 1 Db(i) = ∞
Distance vector example: DV in b: DV in c:
Dc(a) = ∞
computation
Db(a) = 8 Db(f) = ∞
Db(c) = 1 Db(g) = ∞ Dc(b) = 1
DV in a: Db(d) = ∞ Db(h) = ∞ Dc(c) = 0
Da(a)=0 Db(e) = 1 Db(i) = ∞ Dc(d) = ∞
Da(b) = 8 Dc(e) = ∞
Da(c) = ∞ a b c Dc(f) = ∞
8 1
Da(d) = 1 Dc(g) = ∞
Dc(h) = ∞
t=1 Da(e) = ∞
Da(f) = ∞ 1 1 Dc(i) = ∞
c receives DVs Da(g) = ∞ DV in e:
from b Da(h) = ∞ De(a) = ∞
Da(i) = ∞ De(b) = 1
d e f De(c) = ∞
1 1
De(d) = 1
De(e) = 0
De(f) = 1
1 1 1
De(g) = ∞
De(h) = 1
De(i) = ∞
g h i
1 1
Distance vector example:
computation DV in b:
Db(a) = 8
Db(c) = 1
Db(f) = ∞
Db(g) = ∞
DV in c:
Dc(a) = ∞
Dc(b) = 1
Db(d) = ∞ Db(h) = ∞ Dc(c) = 0
Db(e) = 1 Db(i) = ∞ Dc(d) = ∞
Dc(e) = ∞
a b c
compute Dc(f) = ∞
8 1
Dc(g) = ∞
Dc(h) = ∞
t=1 1 1 Dc(i) = ∞
c receives DVs
from b computes:
d b(a}} = 1 + 8 = 9
Dc(a) = min{cc,b+D e f
DV in c:
Dc(b) = min{cc,b+Db(b)} = 1 + 0 = 1
Dc(a) = 9
Dc(d) = min{cc,b+Db(d)} = 1+ ∞ = ∞ Dc(b) = 1
Dc(e) = min{cc,b+Db(e)} = 1 + 1 = 2 Dc(c) = 0
Dc(f) = min{cc,b+Db(f)} = 1+ ∞ = ∞ Dc(d) = 2
Dc(g) = min{cc,b+Db(g)} = 1+ ∞ = ∞ Dc(e) = ∞ * Check out the online interactive exercises
Dc(f) = ∞ for more examples:
Dc(h) = min{cbc,bg+Db(h)} = 1+ ∞ = ∞ h i http://gaia.cs.umass.edu/kurose_ross/interactive/
Dc(g) = ∞
Dc(i) = min{cc,b+Db(i)} = 1+ ∞ = ∞
Dc(h) = ∞
Dc(i) = ∞
Distance vector example: DV in b:
computation
Db(a) = 8 Db(f) = ∞
Db(c) = 1 Db(g) = ∞
Db(d) = ∞ Db(h) = ∞ DV in e:
DV in d:
Db(e) = 1 Db(i) = ∞ De(a) = ∞
Dc(a) = 1
De(b) = 1
Dc(b) = ∞ a b c De(c) = ∞
Dc(c) = ∞ 8 1
De(d) = 1
Dc(d) = 0
t=1 Dc(e) = 1
1
Q: what is new DV computed in e
at1t=1?
De(e) = 0
De(f) = 1
e receives DVs Dc(f) = ∞
De(g) = ∞
from b, d, f, h Dc(g) = 1
De(h) = 1
Dc(h) = ∞
De(i) = ∞
Dc(i) = ∞ d compute
e f DV in f:
DV in h: 1 1
Dc(a) = ∞
Dc(a) = ∞ Dc(b) = ∞
Dc(b) = ∞ Dc(c) = ∞
Dc(c) = ∞ 1 1 1
Dc(d) = ∞
Dc(d) = ∞ Dc(e) = 1
Dc(e) = 1 Dc(f) = 0
Dc(f) = ∞ g h i Dc(g) = ∞
1 1
Dc(g) = 1 Dc(h) = ∞
Dc(h) = 0 Dc(i) = 1
Dc(i) = 1
Distance vector: state information
diffusion
Iterative communication, computation steps diffuses information through network:
t=0 c’s state at t=0 is at c only
a b c
8 1
c’s state at t=0 has propagated to b, and
t=1 may influence distance vector
computations up to 1 hop away, i.e., at b 1 1 t=1
t=2
c’s state at t=0 may now influence distance
t=2 vector computations up to 2 hops away, i.e.,
d e f
at b and now at a, e as well 1 1
from
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y cost to
table x y z y
2 1
x ∞ ∞ ∞
x z
from
y 2 0 1 7
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Network Layer 4-38
Dx(z) = min{c(x,y) +
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
node y cost to cost to cost to
table x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 x z
from
y 2 0 1 y 2 0 1 7
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Network Layer 4-39
Distance vector: link cost changes
link cost changes: 1
node detects local link cost y
4 1
change
updates routing info,
x z
50
recalculates
distance vector
if DV changes, notify
“good t0 : y detects link-cost change, updates its DV, informs its
neighbors
news neighbors.
travels t1 : z receives update from y, updates its table, computes new
fast” least cost to x , sends its neighbors its DV.
t2 : y receives z’s update, updates its distance table. y’s least costs
do not change, so y does not send a message to z.
http://gaia.cs.umass.edu/kurose_ross/interactive/disVector.php
Comparison of LS and DV algorithms
message complexity robustness: what happens if
LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent LS:
DV: exchange between neighbors node can advertise incorrect
only link cost
convergence time varies each node computes only its
own table
speed of convergence
LS: O(n2) algorithm requires O(nE)
DV:
msgs DV node can advertise
may have oscillations incorrect path cost
each node’s table used by
DV: convergence time varies
others
may be routing loops
error propagate thru
count-to-infinity problem
network
routing protocols
gateway router: at “edge” of its own AS, has link(s) to
3c
3a other
2c
3b 2a networks
2b
1c
AS3
other 1a 1b AS2
networks
1d
AS1
the intra-AS routing protocols running
three ASs: AS1, AS2, and AS3 in AS1, AS2, and AS3 need not be the
same
AS1 has four routers—1a, 1b, 1c, and 1d— which run the
intra-AS routing protocol used within AS1. Thus, each of routers 1b, 1c, 2a, and 3a
these four routers knows how to forward packets along the
optimal path to any destination within AS1
are all gateway routers
Network Layer: 5-48
Example: setting forwarding table in router 1d
suppose AS1 learns (via inter-AS protocol) that subnet x
reachable via AS3 (gateway 1c), but not via AS2
inter-AS protocol propagates reachability info to all internal
routers
router 1d determines from intra-AS routing info that its interface
I is on the least cost path to 1c
installs forwarding table entry (x,I)
3c … x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c … x …
3b
3a …
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 4-50
Example: choosing among multiple ASes
now suppose AS1 learns from inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
to configure forwarding table, router 1d must determine
towards which gateway it should forward packets for dest x
this is also job of inter-AS routing protocol!
hot potato routing: send packet towards closest of two
routers.
same as OSPF
RIP ( Routing Information Protocol)
included in BSD-UNIX distribution in 1982
distance vector algorithm
distance 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)
z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to dest
w A
2
y B
2
z B
7 Network Layer 4-56
RIP: example
A-to-D advertisement
dest next hops
w - 1
x - 1
z C 4
…. … ... z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to dest
w A 2
y B 2
A 5
z B 7
x -- 1
…. …. ....
Network Layer 4-57
RIP: link failure, recovery
if no advertisement heard after 180 sec -->
neighbor/link declared dead
routes via neighbor invalidated
new advertisements sent to neighbors
neighbors in turn send out new advertisements (if tables
changed)
link failure info quickly (?) propagates to entire net
poison reverse used to prevent ping-pong loops (infinite
distance = 16 hops)
transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
intra-AS
3c
routing3a inter-AS routing intra-AS
2c
3b 2a routing
2b
1c
AS3 intra-AS
1a routing 1b AS2
1d
AS1
2a 2c
∂
1b 3b
2d
1a 1c ∂
3a 3c
AS 2
1d 3d
AS 1 eBGP connectivity AS 3
logical iBGP connectivity
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
eBGP session
3a iBGP session
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
scale:
inter-AS: hierarchical routing saves table size,
reduced update traffic Intra-AS routing typically doesn't require such aggregation
performance:
inter-AS: policy may dominate over performance
AS administrators often have to balance routing decisions
based on policy requirements
intra-AS: can focus on performance
best performance, low latency, and efficient resource
utilization can be the primary goal.
Network Layer 4-71
Consider the network shown below. Suppose AS3 and AS2 are running OSPF for
their intra-AS routing protocol. Suppose AS1 and AS4 are running RIP for their intra-
AS routing protocol. Suppose eBGP and iBGP are used for the inter- S routing
protocol. Initially suppose there is no physical link between AS2 and AS4.
a. Router 3c learns about prefix x from which routing protocol: OSPF, RIP, eBGP, or
Ibgp?
b. Router 3a learns about x from which routing protocol?
c. Router 1c learns about x from which routing protocol?
d. Router 1d learns about x from which routing protocol?
Chapter 4: outline
4.5 routing
4.1 introduction
algorithms
link state
4.2 virtual circuit and datagram networks
distance vector
4.3 what’s inside a router
hierarchical routing
4.4 IP: Internet Protocol
4.6 routing
datagramin the Internet
format
RIP
IPv4 addressing
OSPF
ICMP
BGP
IPv6
4.7 broadcast and multicast routing
R3 R4 R3 R4
source in-network
duplication duplication
source duplication: How does it know all
the destinations?
additional protocol mechanisms
(such as a broadcast
membership or destination-
registration protocol) would be Network Layer 4-74
In-network duplication
flooding: when node receives broadcast packet,
sends copy to all neighbors
problems: cycles & broadcast storm
controlled flooding: node only broadcasts pkt if it
hasn’t broadcast same packet before
node keeps track of packet ids already broadcasted
or reverse path forwarding (RPF): only forward packet
if it arrived on shortest path between node and source
spanning tree:
no redundant packets received by any node
A A
B B
c c
D D
F E F E
G G
(a) broadcast initiated at A (b) broadcast initiated at D