Professional Documents
Culture Documents
Network Layer
Network Layer
Chapter goals:
r understand principles behind network layer
services:
❖ network layer service models
❖ forwarding versus routing
❖ subnetting and IP addressing
❖ routing algorithms (path selection)
Chapter 4, slide: 1
Network layer
r network layer protocols application
transport
run at network
data link
physical
❖ end systems & network network
data link data link
❖ routers network
data link
physical physical
physical network network
r Sender side: data link data link
physical physical
❖ get segments from
transport layer network
data link
network
data link
physical physical
❖ encapsulates segments network
data link
into IP datagrams physical
application
transport
r router examines header
network
data link network
network
physical data link
fields in all IP datagrams network
data link
data link
physical
physical
physical
r Receiver side:
❖ delivers segments to
transport layer
Chapter 4, slide: 2
Interplay between routing and forwarding
r routing algorithm:
r forwarding routing algorithm
constructs routing
table: a lookup tables
table for local forwarding table
figuring out header value output link
r forwarding process:
output port for 0100 3
0101 2 move pkts from input
each input pkt 0111 2
1001 1 to output
value in arriving
packet’s header
0111 1
Source 3 2
Destination
r routing process: find
route taken by packets
from source to dest.
Chapter 4, slide: 3
Two Key Network-Layer Functions
Chapter 4, slide: 4
Datagram networks
r no call setup at network layer
r no state about end-to-end connections is kept in
routers
❖ no network-level concept of “connection”
r packets forwarded using dest. host address
❖ packets (same source-dest pair) may take different paths
application
application
transport
transport
network
data link 1. Send data 2. Receive data network
data link
physical
physical
Chapter 4, slide: 5
The Internet Network layer
Host, router network layer functions:
Link layer
physical layer
Chapter 4, slide: 6
IP Addressing: introduction
r IP address: 32-bit 223.1.1.1 = 11011111 00000001 00000001 00000001
identifier for 223 1 1 1
❖ host,
❖ router interface
223.1.1.1
223.1.2.1
r interface: connection 223.1.1.2
between host/router and 223.1.1.4 223.1.2.9
Chapter 4, slide: 7
Subnets
r IP address: 223.1.1.1
r What’s a subnet ?
❖ device interfaces with same
subnet part of IP address network consisting of 3 subnets
❖ can physically reach each
other without intervening
router
Chapter 4, slide: 8
Subnets 223.1.1.0/24
223.1.2.0/24
Recipe
r To determine the
subnets, detach each
interface from its
host or router,
creating islands of
isolated networks.
Each isolated network
is called a subnet. 223.1.3.0/24
Chapter 4, slide: 9
IP addressing: CIDR
Classful addressing: A, B, C
❖ A: /8
❖ B: /16
❖ C: /24
Problem: see which class is needed for 300 hosts? Issue?
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23 Chapter 4, slide: 10
IP addresses: how to get one?
Q: How does host get IP address?
Chapter 4, slide: 11
DHCP client-server scenario
Chapter 4, slide: 12
DHCP client-server scenario
Chapter 4, slide: 13
IPv6
r Initial motivation:
❖ 32-bit address space soon to be completely allocated (if not
already!)
r Additional motivation:
❖ header changes to facilitate QoS
Chapter 4, slide: 14
Routing versus forwarding
routing algorithm
value in arriving
packet’s header
0111 1
3 2
Chapter 4, slide: 15
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) }
Chapter 4, slide: 16
Graph abstraction: costs
5
• c(x,x’) = cost of link (x,x’)
3
v w 5
2 - e.g., c(w,z) = 5
u 2 1 z
3 • cost could always be 1, or
1 2 inversely related to bandwidth,
x 1
y
or inversely related to
congestion
Chapter 4, slide: 17
A Link-State Routing Algorithm
Chapter 4, slide: 25
Dijkstra’s algorithm: example
Resulting shortest-path tree from u:
v w
To remember !
r Each node must have
u z complete knowledge of
x y entire network
r Broadcast all link
Resulting forwarding table in u: states
destination link r Each node constructs
v (u,v) its own table
x (u,x)
y (u,x)
w (u,x)
z (u,x)
Chapter 4, slide: 26
Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
r each iteration: need to check all nodes, w, not in N’
r n(n+1)/2 comparisons: O(n2)
Oscillations possible:
r e.g., link cost = amount of carried traffic
r Here: D, C, and B all send to A
1 A A A A
1+e 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 1+e 0 0
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Chapter 4, slide: 27
Distance Vector Algorithm
Bellman-Ford Equation (dynamic programming)
Define
du(z) := cost of least-cost path from u to z
5
Then 3
v w 5
2
u 2 1 z
du(z) = min {c(u,a) + da(z) } 1
3
2
a x 1
y
Chapter 4, slide: 28
Bellman-Ford example
5
3
Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
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 that achieves minimum is next
hop in shortest path ➜ forwarding table
Chapter 4, slide: 29
Distance Vector (DV) Algorithm
r Node x knows cost to each neighbor v: c(x,v)
Chapter 4, slide: 30
Distance vector (DV) algorithm
Basic idea:
r Each node periodically sends its own distance
vector estimate to neighbors
Chapter 4, slide: 31
Distance Vector (DV) Algorithm
Iterative, asynchronous:
each local iteration caused Each node:
by:
❖ local link cost change wait for (change in local link
❖ DV update message from cost or msg from neighbor)
neighbor
recompute estimates
Distributed:
r each node notifies if DV to any dest has
neighbors only when its DV changed, notify neighbors
changes
❖ neighbors then notify their
neighbors if necessary
Chapter 4, slide: 32
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 +
node cost cost
Dy(z), c(x,z) +
x xto y xto y
tablex z 2
0 x z0 2 3 Dz(z)}
y y 2 0
fro
7 = min{2+1 , 7+0} =
fro
∞∞ ∞
m
m
z ∞∞ ∞ z 7
1 1 3
node cost
0
xto y y
y 2 1
tablex z
∞∞∞ x z
y 7
fro
2 0
m
z ∞∞
1 ∞
node cost
z x y
to
tablx z
∞ ∞∞
ey
fro
∞
∞∞ ∞
m
z 71 0
ti Network Layer4-3
me 3
Dx(y) = min{c(x,y) + Dy(y), +
c(x,z) + Dz(y)} Dy(z), c(x,z) +
= min{2+0 , 7+1} = 2 Dz(z)}
node cost cost cost
x xto y xto y xto= min{2+1
y , 7+0} =
tablex 0z 2 x z0 2 3 x 0 z3 2
y 7 y 2 0
fro
fro
∞∞ ∞ y 2 3 0
fro
m
m
z ∞∞ ∞ z 7
1 1 z 13 1
node cost 0cost 0cost
y
y xto y xto y xto y 2 1
tablex z∞∞∞ x 0z 2 x 0 z 2 x z
y 2 0 y 27 0 7
fro
fro
y 2 3 0
fro
m
m
z ∞∞ ∞ z 17 1 z 3
1 1 1
0cost 0cost
node cost
xto y xto y
z x to y
tablx z
∞∞∞ x 0z 2 x 0z 2
y 2 y 23 0
fro
7 0
fro
ey ∞
fro
∞∞ ∞
m
m
m
z 71 0 z 31 1 z 13 1
0 0 ti Network Layer4-3
me 4
cost to w x y z
node w w 0 ∞ 3 ∞
from
table y ∞ ∞ ∞∞
cost to w x y z
x ∞ 0 2 1
node x
y ∞ ∞ ∞∞
from
table
z ∞ ∞ ∞∞ w
3
cost to w x y z
y
3 2 0 5 2 5
y
node y x z
w ∞ ∞ ∞∞
table 1
from
x ∞ ∞ ∞∞
z ∞ ∞ ∞∞
cost to w x y z
z ∞ 1 5 0
node z
x ∞ ∞ ∞∞
from
table
y ∞ ∞ ∞∞
time
Initialization Chapter 4, slide: 35
cost to w x y z cost to w x y z
node w w 0 ∞ 3 ∞ w 0 ∞ 3 ∞
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5
cost to w x y z cost to w x y z
x ∞ 0 2 1 x ∞ 0 2 1
node x
y ∞ ∞ ∞∞ y 3 2 0 5
from
from
table
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞ w
3
cost to w x y z cost to w x y z
y
3 2 0 5 y 3 2 0 5 2 5
y
node y x z
w ∞ ∞ ∞∞ w ∞ ∞ ∞∞
table 1
from
from
x ∞ ∞ ∞∞ x ∞ ∞ ∞∞
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞
y broadcasts DV
cost to w x y z cost to w x y z
to its neighbors x,w,z
z ∞ 1 5 0 z ∞ 1 5 0
node z
x ∞ ∞ ∞∞ x ∞ ∞ ∞∞
from
from
table
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter 4, slide: 36
cost to w x y z cost to w x y z
node w w 0 ∞ 3 ∞ w 0 ∞ 3 ∞
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5
cost to w x y z cost to w x y z
x ∞ 0 2 1 x ∞ 0 2 1
node x
y ∞ ∞ ∞∞ y 3 2 0 5
from
from
table
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞ w
3
cost to w x y z cost to w x y z
y
y 3 2 0 5 2 5
y 3 2 0 5
node y x z
w ∞ ∞ ∞∞ w 0 ∞ 3 ∞
table 1
from
from
x ∞ ∞ ∞∞ x ∞ ∞ ∞∞
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞
w broadcasts DV
cost to w x y z cost to w x y z
to its neighbors y
z ∞ 1 5 0 z ∞ 1 5 0
node z
x ∞ ∞ ∞∞ x ∞ ∞ ∞∞
from
from
table
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter 4, slide: 37
cost to w x y z cost to w x y z
node w 0 ∞ 3 ∞ 0 ∞ 3 ∞
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5
cost to w x y z cost to w x y z
∞ 0 2 1 ∞ 0 2 1
node x
y ∞ ∞ ∞∞ y 3 2 0 5
from
from
table
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞ w
3
cost to w x y z cost to w x y z
y
3 2 0 5 3 2 0 5 2 5
node y x z
w ∞ ∞ ∞∞ w 0 ∞ 3 ∞
table 1
from
from
x ∞ ∞ ∞∞ x ∞ 0 2 1
z ∞ ∞ ∞∞ z ∞ ∞ ∞∞
x broadcasts DV
cost to w x y z cost to w x y z
∞ 1 5 0
to its neighbors y,z
∞ 1 5 0
node z
x ∞ ∞ ∞∞ x ∞ 0 2 1
from
from
table
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter 4, slide: 38
cost to w x y z cost to w x y z
node w 0 ∞ 3 ∞ 0 ∞ 3 ∞
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5
cost to w x y z cost to w x y z
∞ 0 2 1 ∞ 0 2 1
node x
y ∞ ∞ ∞∞ y 3 2 0 5
from
from
table
z ∞ ∞ ∞∞ z ∞ 1 5 0 w
3
cost to w x y z cost to w x y z
y
3 2 0 5 3 2 0 5 2 5
node y x z
w ∞ ∞ ∞∞ w 0 ∞ 3 ∞
table 1
from
from
x ∞ ∞ ∞∞ x ∞ 0 2 1
z ∞ ∞ ∞∞ z ∞ 1 5 0
z broadcasts DV
cost to w x y z cost to w x y z
∞ 1 5 0
to its neighbors x,y
∞ 1 5 0
node z
x ∞ ∞ ∞∞ x ∞ 0 2 1
from
from
table
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter 4, slide: 39
cost to w x y z cost to w x y z
node w 0 ∞ 3 ∞ 0 ∞ 3 ∞
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5
cost to w x y z cost to w x y z
∞ 0 2 1 ∞ 0 2 1
node x
y ∞ ∞ ∞∞ y 3 2 0 5
from
from
table
z ∞ ∞ ∞∞ z ∞ 1 5 0 w
3
cost to w x y z cost to w x y z
y
3 2 0 5 3 2 0 5 2 5
node y x z
w ∞ ∞ ∞∞ w 0 ∞ 3 ∞
table 1
from
from
x ∞ ∞ ∞∞ x ∞ 0 2 1
z ∞ ∞ ∞∞ z ∞ 1 5 0
All neighbor DV
cost to w x y z cost to w x y z
∞ 1 5 0
broadcasts are done
∞ 1 5 0
node z
x ∞ ∞ ∞∞ x ∞ 0 2 1
from
from
table
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter 4, slide: 40
cost to w x y z cost to w x y z cost to w x y z
node w 0 ∞ 3 ∞ 0 ∞ 3 ∞ 0 5 3 8
from
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5 y 3 2 0 5
cost to w x y z cost to w x y z
∞ 0 2 1 ∞ 0 2 1
node x
y 3 2 0 5 Dw(x) = min{c(w,y) + Dy(x)}
y ∞ ∞ ∞∞
from
from
table = min{3+2} = 5
z ∞ ∞ ∞∞ z ∞ 1 5 0
Dw(y) = min{c(w,y) + Dy(y)}
cost to w x y z cost to w x y z = min{3+0} = 3
3 2 0 5 3 2 0 5 Dw(z) = min{c(w,y) + Dy(z)}
node y = min{3+5} = 8
w ∞ ∞ ∞∞ w 0 ∞ 3 ∞
table
from
from
x ∞ ∞ ∞∞ x ∞ 0 2 1
z ∞ ∞ ∞∞ z ∞ 1 5 0 w
3
cost to w x y z cost to w x y z
y
∞ 1 5 0 ∞ 1 5 0 2 5
node z x z
x ∞ ∞ ∞∞ x ∞ 0 2 1
from
from
table 1
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter
Update 4, slide: 41
cost to w x y z cost to w x y z cost to w x y z
node w 0 ∞ 3 ∞ 0 ∞ 3 ∞ 0 5 3 8
from
from
from
table y ∞ ∞ ∞∞ y 3 2 0 5 y 3 2 0 5
from
from
from
table
z ∞ ∞ ∞∞ z ∞ 1 5 0 z ∞ 1 5 0
x ∞ ∞ ∞∞ x ∞ 0 2 1
z ∞ ∞ ∞∞ z ∞ 1 5 0 w
3
cost to w x y z cost to w x y z
y
∞ 1 5 0 ∞ 1 5 0 2 5
node z x z
x ∞ ∞ ∞∞ x ∞ 0 2 1
from
from
table 1
y ∞ ∞ ∞∞ y 3 2 0 5
time
Initialization Exchange Chapter
Update 4, slide: 42
Distance Vector: link cost changes
See what happens when link cost changes:
r node detects local link cost change 1
y
r updates routing info, recalculates 4 1
distance vector x z
50
r if DV changes, notify neighbors
y’s least costs do not change and hence y does not send any
message to z. Chapter 4, slide: 43
Distance Vector: link cost changes
Suppose link cost changes from 4 to 60
Initially: Dy(x) = 4 and Dz(x) = 5 (focus on distance from y & z to x)
r Node y: 60
❖ detects the change, computes its DV y
4 1
❖ what is the new Dy(x) ?
x z
Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{60,1+5}=6 50
❖ sends its new DV to z
r Node z:
Dz(x) stored in
❖ receives the update from y;new Dy(x) = 6
y’s DV from a
❖ computes its DV. What is the new Dz(x) ?
Dz(x) = min{c(z,x), c(z,y)+Dy(x)} = min{50,1+6}=7
Previous update
❖ sends its new DV to y “Dz(x) = 5”
r Node y:
❖ receives the update from z; new Dz(x) = 7 Can you
❖ computes its DV. what is the new Dy(x) ? guess what
Dy(x) = min{c(y,x), c(y,z)+Dz(x)} = min{60,1+7}=8 will happen?
❖ sends its new DV to z again
Chapter 4, slide: 44
Distance Vector: link cost changes
“routing loop” problem
60
y reaches x thru z; z reaches x thru y y
4 1
x z
50
“count to infinity” problem!
44 iterations before algorithm stabilizes:
Imagine what happens if c(z,x) has cost of 10000 instead of 50 !
and c(y,x) changes from 4 to 10010
Chapter 4, slide: 45
Poisoned reverse
60
y
4 1
x z
50
Chapter 4, slide: 46
Comparison of LS and DV algorithms
Message complexity
r LS: with n nodes, E links, O(nE) msgs sent;
each link info should be sent to each node
r DV: exchange between neighbors only
Speed of Convergence
r LS: computation grows at O(n2);
= (n-1) + (n-2) + … + 1 = n(n+1)/2
❖may have oscillations
r DV: computation grows at O(n3); in complete graph
❖ may be routing loops and count-to-infinity problem
r Link state routing converges quickly. Distance vector can take a very long time.
r Link state routing is internally much more complicated. Distance vector is brutally
simple.
r Link state has higher infrastructure requirements. More memory, more peak CPU
load.
Chapter 4, slide: 47
Routing in Internet: Hierarchical Routing
Chapter 4, slide: 48
Hierarchical Routing
r aggregate routers into regions, “autonomous
systems” (AS)
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
Intra-AS Inter-AS
Routing Routing
algorithm algorithm
Forwarding
table
Chapter 4, slide: 49
Hierarchical Routing
Chapter 4, slide: 50
Routing in the Internet: protocols
Intra-AS routing protocols:
r also known as Interior Gateway Protocols (IGP)
r most common Intra-AS routing protocols:
r Distance vector algorithm:
❖ RIP: Routing Information Protocol
Chapter 4, slide: 51
RIP ( Routing Information Protocol)
r Uses Distance Vector routing
Chapter 4, slide: 54
Why different Intra- and Inter-AS routing ?
Policy:
r Inter-AS: admin wants control over how its traffic
routed, who routes through its net.
r Intra-AS: single admin, so no policy decisions needed
Scale:
r hierarchical routing saves table size, reduced update
traffic
Performance:
r Intra-AS: can focus on performance
r Inter-AS: policy may dominate over performance
Chapter 4, slide: 55