You are on page 1of 19

Chapter 4: network layer

chapter goals:
v understand principles behind network layer
services:
§ network layer service models
§ forwarding versus routing
§ how a router works
§ routing (path selection)
§ broadcast, multicast
v instantiation, implementation in the Internet

Network Layer 4-1


Chapter 4: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and § link state
datagram networks § distance vector
4.3 what’s inside a router § hierarchical routing
4.4 IP: Internet Protocol 4.6 routing in the Internet
§ datagram format § RIP
§ IPv4 addressing § OSPF
§ ICMP § BGP
§ IPv6 4.7 broadcast and multicast
routing

Network Layer 4-2


Interplay between routing, forwarding
routing algorithm determines
routing algorithm
end-end-path through network
forwarding table determines
local forwarding table
local forwarding at this router
dest address output link
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1

IP destination address in
arriving packet’s header
1
3 2

Network Layer 4-3


Graph abstraction
5
3
v w 5
2
u 2 1 z
3
1 2
graph: G = (N,E) x 1
y

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,x’) = cost of link (x,x’)


e.g., c(w,z) = 5
cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)

key question: what is the least-cost path between u and z ?


routing algorithm: algorithm that finds that least cost path
Network Layer 4-4
Routing algorithm classification
Q: global or decentralized Q: static or dynamic?
information?
static:
global: v routes change slowly over
v all routers have complete time
topology, link cost info dynamic:
v “link state” algorithms
v routes change more
decentralized: quickly
v router knows physically- § periodic update
connected neighbours, link § in response to link
costs to neighbours cost changes
v iterative process of
computation, exchange of
info with neighbours
v “distance vector” algorithms

Network Layer 4-5


A Link-State Routing Algorithm
Dijkstra’s algorithm notation:
v net topology, link costs v c(x,y): link cost from
known to all nodes node x to y; = ∞ if not
§ accomplished via “link state direct neighbours
broadcast” v D(v): current value of
§ all nodes have same info cost of path from source
v computes least cost paths to dest. v
from one node (“source”) v p(v): predecessor node
to all other nodes along path from source to
§ gives forwarding table for v
that node v N': set of nodes whose
v iterative: after k least cost path definitively
iterations, know least cost known
path to k destinations
Network Layer 4-6
Dijkstra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'

See also: Edsger Wybe Dijkstra. A note on two problems in connexion with graphs.
Numerische Mathematik, 1:269–271, 1959. Network Layer 4-7
Dijkstra’s algorithm: example
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
0 u 7,u 3,u 5,u ∞ ∞
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
4 uwxvy 12,y
5 uwxvyz x
9

notes: 5 7
4
v construct shortest path tree by
tracing predecessor nodes 8
v ties can exist (can be broken u
3 w y z
arbitrarily) 2
3
7 4
v
Network Layer 4-8
Dijkstra’s algorithm, discussion
algorithm complexity: n nodes
v each iteration: need to check all nodes, w, not in N
v n(n+1)/2 comparisons: O(n2)
v more efficient implementations possible: O(nlogn)
oscillations possible:
v e.g., support link cost equals amount of carried traffic

Network Layer 4-9


Distance vector algorithm
Bellman-Ford equation (dynamic programming)

let
dx(y) := cost of least-cost path from x to y
then
dx(y) = minv {c(x,v) + dv(y) }

cost from neighbour v to destination y


cost to neighbour v

min taken over all neighbours v of x


Network Layer 4-10
Bellman-Ford example
Q: What is the cost (u,z)?
5

v 3
w
dv(z) = 5, dx(z) = 3, dw(z) = 3
2 5
u 2 1 z Filling in B-F equation:
3
1 2 du(z) = min { c(u,v) + dv(z),
x y
1 c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
node achieving minimum is next
hop in shortest path, used in forwarding table
Network Layer 4-11
Distance vector algorithm
v Dx(y) = estimate of least cost from x to y
§ x maintains distance vector Dx = [Dx(y): y є N ]
v node x:
§ knows cost to each neighbor v: c(x,v)
§ maintains its neighbours’ distance vectors. For
each neighbour v, x maintains
Dv = [Dv(y): y є N ]

Network Layer 4-12


Distance vector algorithm
key idea:
v from time-to-time, each node sends its own
distance vector estimate to neighbours
v when x receives new DV estimate from neighbour,
it updates its own DV using B-F equation:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N

v under minor, natural conditions, the estimate Dx(y)


converge to the actual least cost dx(y)

Network Layer 4-13


Distance vector algorithm
iterative, asynchronous: each node:
each local iteration
caused by:
v local link cost change wait for (change in local link
cost or msg from neighbour)
v DV update message from
neighbour
distributed: recompute estimates
v each node notifies
neighbours only when its
DV changes if DV to any dest has
§ neighbours then notify changed, notify neighbours
their neighbours if
necessary

Network Layer 4-14


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) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to
table x y z x y z
x 0 2 7 x 0 2 3

from
y ∞∞ ∞ y 2 0 1
from

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-15
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) + 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
y ∞∞ ∞ y 2 0 1
from

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

node z cost to cost to cost to


table x y z x y z x y z
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-16
Distance vector: link cost changes
link cost changes: 1
v node detects local link cost change y
4 1
v updates routing info, recalculates x z
distance vector 50
v if DV changes, notify neighbours

“good t0 : y detects link-cost change, updates its DV, informs its


news neighbours.
travels t1 : z receives update from y, updates its table, computes new
fast” least cost to x , sends its neighbours 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.

Network Layer 4-17


Distance vector: link cost changes
link cost changes: 60
v node detects local link cost change y
4 1
v bad news travels slow – “count to x z
infinity” problem! 50
v 44 iterations before algorithm
stabilizes (see book for details)

Network Layer 4-18


Comparison of LS and DV algorithms
message complexity robustness: what happens if
v LS: with n nodes, E links, O(nE) router malfunctions?
msgs sent LS:
v DV: exchange between neighbors § node can advertise incorrect
only link cost
§ convergence time varies § each node computes only its
own table
speed of convergence DV:
v LS: O(n2) algorithm requires
O(nE) msgs § DV node can advertise
incorrect path cost
§ may have oscillations
§ each node’s table used by
v DV: convergence time varies others
§ may be routing loops • errors propagate through
§ count-to-infinity problem network

Network Layer 4-19

You might also like