Chapter 4 Network Layer
Chapter 4 Network Layer
Network Layer
transport layer
data link
physical
application
network layer protocols network
data link network
transport
network
in every host, router network
data link
physical data link
physical
data link
physical
router examines header physical
fields in all IP
datagrams passing
through it
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
value in arriving
packet’s header
0111 1
3 2
call setup, teardown for each call before data can flow
each packet carries VC identifier (not destination host
address)
every router on source-dest path maintains “state” for
each passing connection
link, router resources (bandwidth, buffers) may be
allocated to VC (dedicated resources = predictable
service)
1 3
2
VC number
interface
forwarding table in number
northwest router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application
6. receive data application
transport 5. data flow begins transport
network 4. call connected 3. accept call
network
data link 1. initiate call 2. incoming call
data link
physical physical
IP destination address in
arriving packet’s header
1
3 2
otherwise 3
examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 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
(computers) complexity inside
can adapt, perform network
control, error recovery
simple inside
network, complexity
at “edge”
forwarding data
plane (hardware)
high-seed
switching
fabric
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet given datagram dest., 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
memory
input output
port memory port
(e.g., (e.g.,
Ethernet) Ethernet)
system bus
datagram
switch buffer link
fabric layer line
protocol termination
queueing (send)
buffering required when datagrams arrive from fabric faster than the
transmission rate
scheduling discipline chooses among queued datagrams for transmission
Datagra
lost due t
layer forwarding
table
ICMP
protocol
• error reporting
• router “signaling”
link layer
physical layer
…
different link types, in: one large datagram
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 4-32
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
to determine the
223.1.1.2 223.1.2.1
subnets, detach 223.1.1.4 223.1.2.9
each isolated
network is called 223.1.3.0/24
a subnet
subnet mask: /24
Network Layer 4-37
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.2.0/24
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 ID: 654
address you can 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-43
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)
encapsulation of DHCP
DHCP DHCP server, frame
DHCP UDP forwarded to client,
DHCP IP demuxing up to DHCP
DHCP Eth router with DHCP at client
DHCP
Phy server built into client now knows its IP
router address, name and IP
address of DSN server,
IP address of its first-
hop router
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
IP destination address in
arriving packet’s header
1
3 2
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-62
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 5
2
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
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
1
C C 0 1
C 1+e C 0
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 cost
resulting in new costs
Network Layer 4-65
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
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 4-72
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 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
from
y 2 0 1 y 2 0 1 7
from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
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-73
Distance vector: link cost
changes
link cost changes:
1
node detects local link cost y
change 4 1
updates routing info, x z
50
recalculates
distance vector
if DV changes, notify
neighbors
“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.
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-80
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-81
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)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
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
routing algorithms
Assume prefix is
local forwarding table in another AS.
entry prefix output port
138.16.64/22 3
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 networks
other 1a 2b
networks 1b AS2
AS1 1d
NEXT-HOP: 201.44.13.125
Router may receive multiple
routes
3c
BGP
3a message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d