Lecture 5 - Network Layer - 2019
Lecture 5 - Network Layer - 2019
Network Layer
Computer Networks
The slides are made by J.F Kurose and K.W. Ross,
adapted by Phuong Vo
segments to transport
physical physical
network
data link
layer network
physical
application
transport
❖ network layer protocols network
data link
physical
network
data link
network
data link
Routing
Algorithm
control
plane
data
plane
values in arriving
packet header
0111 1
2
3
Remote Controller
control
plane
data
plane
CA
CA CA CA CA
values in arriving
packet header
0111 1
2
3
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet ❖ using header field values, lookup output
see chapter 5 port using forwarding table in input port
memory (“match plus action”)
❖ goal: complete input port processing at
‘line speed’
❖ queuing: if datagrams arrive faster than
forwarding rate into switch fabric
Network Layer: Data Plane 4-12
Input port functions
lookup,
link forwarding
line layer switch
termination protocol fabric
(receive)
queueing
physical layer:
bit-level reception
decentralized switching:
data link layer: ❖ using header field values, lookup output
e.g., Ethernet port using forwarding table in input port
see chapter 5 memory (“match plus action”)
❖ destination-based forwarding: forward based
only on destination IP address (traditional)
❖ generalized forwarding: forward based on
any set of header field values
otherwise 3
otherwise 3
examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 which interface?
Network Layer 5-15
Router architecture overview
two key router functions:
❖ run routing algorithms/protocol (RIP, OSPF, BGP)
❖ forwarding datagrams from incoming to outgoing link
forwarding data
plane (hardware)
high-speed
switching
fabric
memory
switch
switch
fabric
fabric
physical layer
…
in: one large datagram
▪ different link types, out: 3 smaller datagrams
different MTUs
❖ large IP datagram divided
(“fragmented”) within net reassembly
▪ one datagram becomes
several datagrams
▪ “reassembled” only at …
final destination
▪ IP header bits used to
identify, order related
fragments
Network Layer 5-22
IP fragmentation, reassembly
length ID fragflag offset
example: =4000 =x =0 =0
❖ 4000 byte datagram
one large datagram becomes
❖ MTU = 1500 bytes several smaller datagrams
.1 .1 .2 .1 .2 .1
RTA#show ip route
Codes: C - connected,.. <Other codes and gateway information omitted>
C 172.16.0.0/16 is directly connected, Serial0
C 192.168.2.0/24 is directly connected, Ethernet0
RTB#show ip route
Codes: C - connected,.. <Other codes and gateway information omitted>
C 172.16.0.0/16 is directly connected, Serial0
C 192.168.1.0/24 is directly connected, Serial1
RTC#show ip route
Codes: C - connected,.. <Other codes and gateway information omitted>
C 10.0.0.0/8 is directly connected, Ethernet0
C 192.168.1.0/24 is directly connected, Serial1
(*)This slide and next 05 slides is from CCNA 3.0 curriculum. Network Layer 5-25
Directly Connected Networks
and the IP Routing Table
192.168.2.0/24 172.16.0.0/16 192.168.1.0/24 10.1.0.0/16
RTA RTB RTC
e0 s0 s0 s1 s1 e0
.1 .1 .2 .1 .2 .1
RTA#show ip route
C 172.16.0.0/16 is directly connected, Serial0
C 192.168.2.0/24 is directly connected, Ethernet0
RTA#ping 172.16.0.1
!!!!!
RTA#ping 172.16.0.2
!!!!!
RTA#ping 192.168.1.1
.....
RTA#ping 192.168.1.2
.....
RTA#ping 10.1.0.1
.....
.1 .1 .2 .1 .2 .1
Network/subnet route
Intermediate-Address
RTA#show ip route (usually “next-hop”)
Codes: C - connected, S - static,
C 172.16.0.0/16 is directly connected, Serial0
S 192.168.1.0/24 [1/0] via 172.16.0.2
C 192.168.2.0/24 is directly connected, Ethernet0
.1 .1 .2 .1 .2 .1
Network/subnet route
Outgoing interface
RTA#show ip route
Codes: C - connected, S - static,
C 172.16.0.0/16 is directly connected, Serial0
S 192.168.1.0/24 is directly connected, Serial0
C 192.168.2.0/24 is directly connected, Ethernet0
10.1.1.1/24
ISP
❖ Any packets not matching the routes 172.16.0.0/16 or 10.1.1.0/24 are sent to the router 10.1.1.1
– where it is now their “problem.” Network Layer 5-30
Chapter 5: outline
5.1 Overview of Network 5.4 static routing
layer 5.5 routing algorithms
▪ data plane ▪ link state
▪ control plane ▪ distance vector
5.2 What’s inside a router ▪ hierarchical routing
5.3 IP: Internet Protocol 5.6 routing in the Internet
datagram format ▪ RIP
▪ datagram format ▪ OSPF
▪ fragmentation ▪ BGP
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
graph: G = (N,E)
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 predecessor nodes 8
❖ ties can exist (can be broken u 3 w y z
arbitrarily) 2
3
7 4
v
Network Layer 5-38
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
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min
v
{c(x,v) + dv (y) }
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 5-49
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
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 5-50
Distance vector: link cost changes
link cost changes: 1
❖ node detects local link cost change 4
y
1
❖ updates routing info, recalculates x z
distance vector 50
❖ if DV changes, notify neighbors
❖ e.g. , focus on the y’s and z’s entries to
destination x:
“good t0 : y detects link-cost change, updates its DV, informs its
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.
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
C 0 1 1+e 0
1 C C C
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 costs resulting in new costs
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
Network Layer 5-58
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
3c
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 5-61
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.
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
…. …. ....
Network Layer 5-66
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 5-67
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)
backbone
area
border
routers
area 3
internal
routers
area 1
area 2
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