Chapter 4 V6.11
Chapter 4 V6.11
Network Layer
transport layer
network data link data link
data link physical physical
physical
❖ network layer
protocols in every
host, router
❖ router examines Network Layer 4-4
Two key network-layer
functions
❖ forwarding: move analogy:
packets from
router’s input to ❖ routing: process of
appropriate router planning trip from
output source to dest
❖ routing: determine ❖ forwarding: process
route taken by of getting through
packets from source single interchange
to dest.
▪ routing algorithms
3 2
1 3
2
VC number
interface
forwarding number
table in
northwest
Incoming interface
router: Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … …
…
application application
5. data flow 6. receive
transport transport
network 4.begins
call 3.data
accept
connected
1. initiate call network
data link 2. incoming
call call
data link
physical physical
otherwise 3
examples
: DA: 11001000 00010111 00010110 10100001 which
DA: 11001000 00010111 00011000 10101010 interface?
which
interface?
Network Layer 4-19
Datagram or VC network:
why?
Internet (datagram) ATM (VC)
❖ data exchange among ❖ evolved from
computers telephony
▪ “elastic” service, no ❖ human conversation:
strict timing req. ▪ strict timing, reliability
requirements
❖ many link types ▪ need for guaranteed
▪ different characteristics service
▪ uniform service difficult ❖ “dumb” end systems
❖ “smart” end systems ▪ telephones
▪ complexity inside
(computers) network
▪ can adapt, perform
control, error recovery
▪ simple inside
network, complexity
at “edge”
forwarding data
plane (hardware)
high-seed
switching
fabric
physical layer:
bit-level
reception
data link decentralized switching:
layer: ❖ given datagram dest., lookup
e.g., Ethernet output port using forwarding table
see chapter 5 in input port memory (“match plus
action”)
❖ goal: complete input port
processing at ‘line speed’
❖ queuing: if datagrams arrive faster
than forwarding rate intoNetwork
switchLayer 4-23
Switching fabrics
❖ transfer packet from input buffer to
appropriate output buffer
❖ switching rate: rate at which packets
can be transfer from inputs to outputs
▪ often measured as multiple of input/output line rate
▪ N inputs: switching rate N times line rate desirable
❖ three types of switching fabrics
memor
y
input output
port memory port
(e.g., (e.g.,
Ethernet) Ethernet)
system bus
datagram
switch buffer link
fabric layer line
protocol termination
queueing (send)
switc
switc
h
h
fabric
fabric
switc switc
h h
fabric fabric
routing IP protocol
• addressing conventions
protocols
• datagram format
• path selection
network • RIP, OSPF, BGP
• packet handling
layer forwarding
conventions
table
ICMP
protocol
• error reporting
• router “signaling”
link layer
physical layer
…
possible link-level in: one large datagram
frame out: 3 smaller datagrams
▪ different link
types, different
MTUs reassembly
❖ large IP datagram
divided
(“fragmented”) …
within net
▪ one datagram
becomes several
datagrams
▪ “reassembled” Network Layer 4-35
IP fragmentation,
reassembly
length ID fragflag offset
example: =4000 =x =0 =0
❖ 4000 byte
datagram one large datagram becomes
❖ MTU = 1500 several smaller datagrams
bytes
1480 bytes in length ID fragflag offset
data field =1500 =x =1 =0
6. 223.1.2.2
▪can physically
reach each other
without intervening network consisting of 3
router subnets
❖ each isolated
network is called
223.1.3.0/2
a subnet 4
subnet mask:
/24
Network Layer 4-41
Subnets 223.1.1.2
223.1.1.3
223.1.9.2 223.1.7.0
223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0
223.1.2.6 223.1.3.27
223.1.3.1 223.1.3.2
223.1.3.0/24
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server! Here’s an IP
yiaddrr: 223.1.2.4
transaction
address youID:can
654 use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll
yiaddrr: 223.1.2.4
take that IPID:address!
transaction 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255,
Broadcast: 68
OK. You’ve
yiaddrr: 223.1.2.4
gottransaction
that IPID:address!
655
lifetime: 3600 secs
Network Layer 4-47
DHCP: more than IP
addresses
DHCP can return more than just allocated
IP address on subnet:
▪ address of first-hop router for client
▪ name and IP address of DNS sever
▪ network mask (indicating network versus
host portion of address)
“Send me
anything
Organization with addresses
2 200.23.20.0/23 . Fly-By-Night- beginning
. 200.23.16.0/20”
. . ISP
Interne
.
Organization . t
7
200.23.30.0/23
“Send me anything
ISPs-R-
with addresses
Us
Organization beginning
1 199.31.0.0/16
200.23.18.0/23
or 200.23.18.0/23”
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
2. connection
to 1. connection 10.0.0.1
relay initiated to
by client relay initiated
3. relaying by NATed host
client established
138.76.29.7 NAT
router
data
32 bits
Network Layer 4-68
Other changes from IPv4
❖ checksum: removed entirely to reduce
processing time at each hop
❖ options: allowed, but outside of header,
indicated by “Next Header” field
❖ ICMPv6: new version of ICMP
▪ additional message types, e.g. “Packet Too
Big”
▪ multicast group management functions
IPv6 datagram
IPv4 datagram
Network Layer 4-70
Tunneling
A B IPv4 tunnel E F
connecting IPv6 routers
logical view:
IPv6 IPv6 IPv6 IPv6
A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
A B C D E F
physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
data data
A-to-B: E-to-F:
IPv6 B-to-C: B-to-C: IPv6
IPv6 IPv6
inside inside Network Layer 4-72
IPv4 IPv4
IPv6:
adoption
❖ US National Institutes of Standards
estimate [2013]:
▪ ~3% of industry IP routers
▪ ~11% of US gov’t routers
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-82
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 ) ) ) ) )
1 ux 2,u 5,u 1,u ∞ ∞
2 uxy 2,u 4,x 2,x ∞
3 uxyv 2,u 3,y 4,y
4 uxyvw 3,y 4,y
5 uxyvw 4,y
z
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
resulting forwarding
table in u: destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)
Network Layer 4-84
Dijkstra’s algorithm,
discussion
algorithm complexity: n nodes
❖ each iteration: need to check all nodes, w,
not in N
❖ n(n+1)/2 comparisons: O(n2)
❖ more efficient implementations possible:
O(nlogn)
oscillations possible:
❖ e.g., support link cost equals amount of
A 1+
1 carried A 0 A A
traffic:
2+ 0 2+ 2+ 0
D e
0 0 B D e
1+ 1 B D e
B De
1+ 1 B
0 0
0 e 0 e 0 e
1
C C 0 1
C 1+ C 0
1 e
e
given these given these given these
initially costs, costs, costs,
find new find new find new
routing…. routing…. routing….
Network Layer 4-85
resulting in new resulting in new resulting in new
Chapter 4: outline
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and ▪ link state
datagram networks ▪ distance vector
▪ hierarchical routing
4.3 what’s inside a
router 4.6 routing in the
4.4 IP: Internet Protocol Internet
▪ ▪ RIP
datagram format
▪ ▪ OSPF
IPv4 addressing
▪ ▪ BGP
ICMP
▪ IPv6 4.7 broadcast and
multicast routing
let
dx(y) := cost of least-cost path from x to
y
then v
fro
fro
m
m
z ∞∞ ∞ z 1
7 1
0
node y cost
table x to y y
2 1
x z∞ ∞ ∞
x z
y 2 0 7
fro
m
z 1∞∞ ∞
node cost
z x to y
table z∞ ∞ ∞
x
y ∞∞ ∞
fro
m
z 7 1 0
time
Network Layer 4-92
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 cost cost
table x to y x to y x to y
x z0 2 7 x z0
2 3 x z0 2 3
y ∞∞ ∞ y 2 0 y
fro
2 0
fro
m
m
fro
z ∞∞ ∞ z 1
m
7 1 z 1
3 1 0
0
node y cost cost cost
table x to y x to y xto y y
2 1
x z∞ ∞ ∞ x z0 2 7 z0 2 3
x x z
y 2 0 y 2 0 1 y 2 0 1 7
fro
fro
m
fro
m
z 1∞∞ ∞ z 7 1 z 3 1 0
0
node cost cost cost
z x to y x to y xto y
table
x z∞ ∞ ∞ x z0 2 7 x z0 2 3
y y 2 0 1 y 2 0 1
fro
fro
∞∞ ∞
m
fro
m
m
z z 3 1 0 z 3 1 0
7 1 0
time
Network Layer 4-93
Distance vector: link cost
changes
link cost changes: 1
❖ node detects local link cost y
4 1
change
x z
❖ updates routing info, 5
recalculates 0
distance vector
❖ if DV tchanges,
: y detects notify
link-cost change, updates its DV, informs its
“gooneighbors
0
d neighbors.
news t1 : z receives update from y, updates its table, computes new
trave least cost to x , sends its neighbors its DV.
ls
fast” 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.
3
3a 2c
3b c 2a
AS3 2
1c AS2 b
1a 1b AS1
1d ❖ forwarding table
configured by both
intra- and inter-AS
Intra-AS Inter-AS routing algorithm
Routing Routing
algorith algorith ▪ intra-AS sets
m m
Forwarding
entries for internal
table dests
▪ inter-AS & intra-AS
sets entries for
external dests
Network Layer 4-100
Inter-AS tasks
❖ suppose router in AS1 must:
AS1 receives 1. learn which dests
datagram destined are reachable
outside of AS1: through AS2, which
▪ router should through AS3
forward packet to 2. propagate this
gateway router, reachability info to
but which one? all routers in AS1
job of inter-AS routing!
3c
3a
3b
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
3c … x
3a
3b
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
3c … x …
3b
3a …
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
?
Network Layer 4-103
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 4-108
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-109
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)
forwardin
network forwarding network
g
(IP) table (IP)
table
link link
physical physical
backbon
area e
border
routers
area 3
internal
routers
area 1
area 2
3c
BGP
3a message
3b
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
eBGP
3a session
iBGP
3b
AS3
session 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
routing algorithms
Assume prefix
local forwarding is
entr table
prefix output port
y 138.16.64/22 3
in another AS.
124.12/16 2
212/8 4
………….. …
Dest IP
1
3 2
How does entry get in forwarding
table?
High-level overview
1. Router becomes aware of prefix
2. Router determines output port for prefix
3. Router enters prefix-port in forwarding
table
Router becomes aware of
prefix
3c
BGP
3a message
3b
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
❖ Example:
selec
t
❖ AS2 AS17 to 138.16.64/22
❖ AS3 AS131 AS201 to 138.16.64/22
3c
3a 111.99.86.5
3b
AS3 5 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
Router identifies port for
route
❖ Identifies port along the OSPF shortest
path
❖ Adds prefix-port entry to its forwarding
table:
▪ (138.16.64/22 , port 4)
3c router
3a port
3b
AS3 1 2c other
1c 4 2a network
2 3
other 1a 2b s
network 1b AS2
s AS1 1d
Hot Potato Routing
❖ Suppose there two or more best inter-
routes.
❖ Then choose route with closest NEXT-HOP
▪ Use OSPF to determine which gateway is
closest
▪ Q: From 1c, chose AS3 AS131 or AS2 AS17?
▪ A: route AS3 AS201 since it is closer
3c
3a
3b
AS3 2c other
1c 2a network
other 1a 2b s
network 1b AS2
s AS1 1d
How does entry get in forwarding
table?
Summary
1. Router becomes aware of prefix
▪ via BGP route advertisements from other
routers
2. Determine router output port for prefix
▪ Use BGP route selection to find best inter-AS
route
▪ Use OSPF to find best intra-AS route
leading to best inter-AS route
▪ Router identifies router port for that best
route
3. Enter prefix-port entry in forwarding
table
BGP routing policy
legend provide
B : networ
r
X k
W A
customer
C network
:
Y
❖ A advertises path AW to B
❖ B advertises path BAW to X
❖ Should B advertise path BAW to C?
▪ No way! B gets no “revenue” for routing CBAW since
neither W nor C are B’s customers
▪ B wants to force C to route to w via A
▪ B wants to route only to/from its customers!
R3 R4 R3 R4
source in-network
duplication duplication
A A
B B
c c
D D
F E F E
G G
(a) broadcast initiated at A (b) broadcast initiated at D
A A
3
B B
c c
4
2
D D
F E F E
1 5
G G
(a) stepwise construction of (b) constructed spanning
spanning tree (center: E) tree
Network Layer 4-139
Multicast routing: problem
statement
goal: find a tree (or trees) connecting
routers having local mcast group members
legend
❖ tree: not all paths between routers used group
❖ shared-tree: same tree used by all group members member
not group
❖ source-based: different tree from each member
sender to rcvrs
router
with a
group
member
router
without
group
member
s: source LEGEND
R1 2 router with attached
1 R4
group member
R2 5 router with no attached
3 4 group member
R5
i link used for forwarding,
R3 6
i indicates order link
R6 R7 added by algorithm
LEGEND
mcast tree R6
upstream to all data multicast R7
rendezvous
source from rendezvous point
point
❖ RP can send stop
msg if no
attached
receivers Network Layer 4-156
Chapter 4: done!
4.1 introduction 4.5 routing algorithms
4.2 virtual circuit and ▪ link state, distance
datagram networks vector, hierarchical
routing
4.3 what’s inside a 4.6 routing in the
router Internet
4.4 IP: Internet Protocol ▪ RIP, OSPF, BGP
▪ datagram format, IPv4
4.7 broadcast and
addressing, ICMP, IPv6
multicast routing
❖ understand principles behind network layer
services:
▪ network layer service models, forwarding
versus routing how a router works, routing
(path selection), broadcast, multicast
❖ instantiation, implementation in the Internet
Network Layer 4-157