You are on page 1of 68

Chapter 4

Network Layer

Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012

All material copyright 1996-2013


J.F Kurose and K.W. Ross, All Rights Reserved
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
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
Given a set of routers, with links
connecting the routers:
A routing algorithm finds a “good”
path from source router to
Graph abstraction
A graph is used to formulate 5
routing problems 3
v w
2 5
u 2 1 z
3
1
2
x y
graph: G = (N,E) 1

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) }

aside: graph abstraction is useful in other network contexts, e.g.,


P2P, where N is set of peers and E is set of TCP connections
Graph abstraction: costs
5
c(x,x’) = cost of link (x,x’)
3 e.g., c(w,z) = 5
v w
2 5
u cost could always be 1, or
2
3
1 z inversely related to bandwidth,
1 or inversely related to
2
x y
congestion
1

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
Routing algorithm classification
Q: global or decentralized?
global:
❖ all routers have complete topology, link cost info

❖ Algorithms with global start information: “link state” algorithms


▪ Must be aware of the cost of each link in the network.
decentralized:
❖ router knows physically-connected neighbors, link costs to
neighbors
❖ No node has complete information about the cost of all
network links (begins with knowledge of cost of neighbors)
❖ iterative process of computation, exchange of info with
neighbors
▪ a node gradually calculates the least-cost path to a destination or set of
destinations.
Routing algorithm classification
Q: static or dynamic?
static:
❖ routes change slowly over time (often by human intervention)
❖ Manual editing of a router’s forwarding table
dynamic:

❖ routes change more quickly as the network traffic loads or


topology change.
▪ periodic update
▪ in response to link cost changes
Routing algorithm classification
Q: load sensitive or not?
load-sensitive algorithm:
❖ link costs vary dynamically to reflect the current level of
congestion in the underlying link
❖ ARPAnet routing algorithms

load-insensitive algorithm :
❖ a link’s cost does not explicitly reflect its current (or recent past)
level of congestion
❖ Internet routing algorithms (BGP, RIP, OSPF)
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
A Link-State Routing Algorithm
Dijkstra’s algorithm notation:
❖ net topology, link costs ❖ c(x,y): link cost from
known to all nodes node x to y; = ∞ if not
▪ accomplished via “link state direct neighbors
broadcast” ❖ D(v): current value of
▪ all nodes have same info cost of path from source
❖ computes least cost paths to dest. v
from one node (‘source”) ❖ p(v): predecessor node
to all other nodes along path from source to
▪ gives forwarding table for v
that node ❖ N': set of nodes whose
❖ iterative: after k least cost path definitively
iterations, know least cost known
path to k destination’s
Dijsktra’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'
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
❖ construct shortest path tree by
tracing predecessor nodes 8
❖ ties can exist (can be broken u
3 w y z
arbitrarily) 2
3
7 4

v
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
2 5
u 2 1 z
3
1
2
x y
1
Dijkstra’s algorithm: example (2)
resulting shortest-path tree from u:

v w

u z
x y

resulting forwarding table in u:


destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)
LINK STATE ROUTING
➢ Link state routing has a different philosophy from that of
distance vector routing.
In link state routing, if each node in the domain has the entire
topology of the domain, i.e.,
➢ the list of nodes and links, how they are connected
including the type, cost (metric), and
➢ the condition of the links (up or down)
➢ Then the node can use the Dijkstra algorithm to build a routing
table
➢ In this algorithm, the cost associated with an edge defines the
state of the link
➢ Links with lower costs are preferred to links with higher costs;
➢ if the cost of a link is infinity, it means that the link does not exist
or has been broken.
LINK STATE DataBase (LSDB)
➢ To create a least-cost tree with this method,
➢ each node needs to have a complete map of the
network,
➢ which means it needs to know the state of each
link.

➢ The collection of states for all links is called the link-


state database (LSDB).
LINK STATE DataBase (LSDB)
➢ The LSDB can be represented as a two-dimensional
array(matrix) in which the value of each cell defines the cost of
the corresponding link.
How LSDB is created?
➢ Done by a process called flooding

➢ Each node can send some greeting messages to all its immediate
neighbors (those nodes to which it is connected directly)
➢ to collect two pieces of information for each neighboring
node:
➢ the identity of the node and
➢ the cost of the link.
➢ The combination of these two pieces of information is called the
LS packet (LSP);

➢ the LSP is sent out of each interface


How LSDB is created?
➢ after receiving all new LSPs, each node creates the
comprehensive LSDB
➢ This LSDB is the same for each node and shows the whole map
of the internet.
Formation of Least Cost Trees
➢ To create a least-cost tree for itself, using the shared LSDB, each
node needs to run the famous Dijkstra Algorithm.
This iterative algorithm uses the following steps:
1. The node chooses itself as the root of the tree, creating a tree
with a single node, and sets the total cost of each node based on
the information in the LSDB.
2. The node selects one node, among all nodes not in the tree,
which is closest to the root, and adds this to the tree. After this
node is added to the tree, the cost of all other nodes not in the
tree needs to be updated because the paths may have been
changed.
3. The node repeats step 2 until all nodes are added to the tree.

These three steps finally create the least-cost tree


Formation of Least Cost Trees
Formation of Least Cost Trees
Formation of Least Cost Trees
Formation of Least Cost Trees
An initialization step and six iterations to find the least-cost tree
Practice
❖ Time allowed: 20 mins

❖ Find the resulting shortest path tree & forwarding


table using Dijkstra’s algorithm. Show the
complete procedure (all steps).
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
Distance vector algorithm
Bellman-Ford equation

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

cost from neighbor v to destination y


cost to neighbor v

min taken over all neighbors v of x


Bellman-Ford Equation
Bellman-Ford Equation
➢ Heart of distance vector routing

➢ Used to find the least cost (shortest distance) between a source


node, x, and a destination node, y, through some intermediary
nodes (a, b, c, . . .)
➢ When the costs between the source and the intermediary nodes
and the least costs between the intermediary nodes and the
destination are given.
Dxy = min{(cxa + Day), (cxb + Dby), (cxc + Dcy), …}

➢ In distance-vector routing, normally update an existing least cost


with a least cost through an intermediary node, such as z,
➢ if the latter is shorter.
➢ So the equation becomes simpler as Dxy = min{Dxy, (cxz + Dzy)}
Bellman-Ford example
5
3
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w
2 5
u 2 1 z B-F equation says:
3
1 du(z) = min { c(u,v) + dv(z),
2
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
Distance vector algorithm
❖ Dx(y) = estimate of least cost from x to y
▪ x maintains distance vector Dx = [Dx(y): y є N ]
❖ node x:
▪ knows cost to each neighbor v: c(x,v)
▪ maintains its neighbors’ distance vectors. For
each neighbor v, x maintains
Dv = [Dv(y): y є N ]
Distance vector algorithm
key idea:
❖ 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 natural conditions, the estimate Dx(y)


converge to the actual least cost dx(y)
Distance vector algorithm
iterative, asynchronous: each node:
each local iteration
caused by:
❖ local link cost change wait for (change in local link
cost or msg from neighbor)
❖ DV update message from
neighbor
distributed: recompute estimates
❖ each node notifies
neighbors only when its
DV changes if DV to any dest has
▪ neighbors then notify their changed, notify neighbors
neighbors if necessary
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
table x y z x y z
x 0 2 7 x 0 2 3

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
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

from
y 2 0 1
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

from

y 2 0 1 y 2 0 1 7

from
y 2 0 1
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
Distance Vector Corresponding to a Tree

Do these distance vectors represent least-cost paths?

They do, considering the limited information a node has.

When we know only one distance between two nodes, it is the least
cost.
Initial Distance Vector for an internet
Updating Distance Vectors
Count to Infinity
➢ A problem with distance-vector routing is that
➢ any decrease in cost (good news) propagates quickly,
➢ but any increase in cost (bad news) will propagate slowly.

➢ For a routing protocol to work properly, if a link is broken


(cost becomes infinity),
➢ every other router should be aware of it immediately,
➢ but in distance-vector routing, this takes some time.

➢ The problem is referred to as count to infinity


➢ It sometimes takes several updates before the cost for a
broken link is recorded as infinity by all routers.
Count to Infinity: Two node loop

Most implementations define 16 as infinity


Solutions for Two-Node Instability
Split Horizon
➢ Split horizon is a method of preventing a routing loop in a
network.
➢ Simple principle: Information about the routing for a
particular packet is never sent back in the direction from
which it was received.
➢ So, instead of flooding the table through each interface,
each node sends only part of its table through each
interface
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
Hierarchical routing
our routing study thus far - idealization
❖ all routers identical

❖ network “flat”

… not true in practice

scale: with 600 million administrative autonomy


destinations: ❖ internet = network of
❖ can’t store all dest’s in networks
routing tables! ❖ each network admin may
❖ routing table exchange want to control routing in
would swamp links! its own network
Hierarchical routing
❖ aggregate routers into gateway router:
regions, “autonomous ❖ at “edge” of its own AS
systems” (AS) ❖ has link to router in
❖ routers in same AS another AS
run same routing
protocol
▪ “intra-AS” routing
protocol
▪ routers in different AS
can run different intra-
AS routing protocol
Interconnected ASes

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d ❖ forwarding table
configured by both intra-
and inter-AS routing
Intra-AS Inter-AS algorithm
Routing Routing
algorithm algorithm ▪ intra-AS sets entries
Forwarding
for internal dests
table ▪ inter-AS & intra-AS
sets entries for
external dests
Inter-AS tasks
❖ suppose router in AS1 AS1 must:
receives datagram 1. learn which dests are
destined outside of AS1: reachable through AS2,
▪ router should forward which through AS3
packet to gateway 2. propagate this
router, but which one? reachability info to all
routers in AS1
job of inter-AS routing!

3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
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
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
which gateway it should forward packets towards for dest x

3c
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
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.

use routing info determine from


learn from inter-AS hot potato routing: forwarding table the
from intra-AS
protocol that subnet choose the gateway interface I that leads
protocol to determine
x is reachable via that has the to least-cost gateway.
costs of least-cost
multiple gateways smallest least cost Enter (x,I) in
paths to each
of the gateways forwarding table
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
Intra-AS Routing
❖ also known as interior gateway protocols (IGP)
❖ most common intra-AS routing protocols:
▪ RIP: Routing Information Protocol
▪ OSPF: Open Shortest Path First
▪ IGRP: Interior Gateway Routing Protocol
(Cisco proprietary)
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)

from router A to destination subnets:


u v subnet hops Next
w u 1 ---
A B
v 2 B
w 2 B
x x 3 C
z C D y 3 C
y z 2 C
Routing Information Protocol
➢ The destination in a routing table is a network, which
means the first column defines a network address

➢ The metric used is distance (hop count) which is defined


as the number of links (networks) to reach the destination.

➢ If a packet passes through 10 networks to reach the


destination, the total cost is 10 hop counts.

➢ Infinity is defined as 16, which means that any route in an


autonomous system using RIP cannot have more than 15
hops.

➢ The next-node column defines the address of the router to


which the packet is to be sent to reach its destination
RIP Operation
➢ Router sends update message to neighbors every
30 sec
➢ A router expects to receive an update message
from each of its neighbors within 180 seconds in
the worst case
➢ If router does not receive update message from
neighbor X within this limit, it assumes the link to
X has failed and sets the corresponding minimum
cost to 16 (infinity)
➢ Based on convergence speeded up by triggered
updates
➢ neighbors notified immediately of changes in
distance vector table
RIP: example

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
x -- 1
…. …. ....
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
…. …. ....
Another Example: A domain using RIP
Another Example: A domain using RIP
➢Autonomous system with
➢seven networks and
➢four routers with table of each router.

➢Routing table for Rl has seven entries to show how


to reach each network in the autonomous system.

➢Router Rl is directly connected to networks
130.10.0.0 and 130.11.0.0 which means that there
are no next-hop entries for these two networks.
RIP Updating Algorithm
Receive a response RIP message

1. Add one hop to the hop count for each advertised destination.

2. Repeat the following steps for each advertised destination:


If (destination is not in the routing table)
Add the advertised information to the table.
Else
If (next-hop field is the same)
Replace entry in the table with the new one.
Else
If (new hop count < the one in the table)
Replace entry in the routing table.
Example of updating a routing table
Initial routing tables in a small
autonomous system
Final routing tables (previous figure)
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
RIP table processing
❖ RIP routing tables managed by application-level
process called route-d (daemon)
❖ advertisements sent in UDP packets, periodically
repeated
routed routed

transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
OSPF (Open Shortest Path First)
❖ “open”: publicly available
❖ uses link state algorithm
▪ LS packet dissemination
▪ topology map at each node
▪ route computation using Dijkstra’s algorithm
❖ OSPF advertisement carries one entry per neighbor
❖ advertisements flooded to entire AS
▪ carried in OSPF messages directly over IP (rather than
TCP or UDP
❖ IS-IS routing protocol: nearly identical to OSPF
Hierarchical OSPF
boundary router
backbone router

backbone
area
border
routers

area 3

internal
routers
area 1
area 2
Hierarchical OSPF
❖ two-level hierarchy: local area, backbone.
▪ link-state advertisements only in area
▪ each nodes has detailed area topology; only know
direction (shortest path) to nets in other areas.
❖ area border routers: “summarize” distances to nets in
own area, advertise to other Area Border routers.
❖ backbone routers: run OSPF routing limited to
backbone.
❖ boundary routers: connect to other AS’s.

You might also like