Académique Documents
Professionnel Documents
Culture Documents
Chapter 4
Network Layer
Chapter goals:
services:
network
Computer Networking:
A Top Down Approach
4th edition.
Jim Kurose, Keith Ross
Addison-Wesley, July
2007.
Network Layer
4-1
Network Layer
Network layer
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
4-2
RIP
OSPF
BGP
4-3
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
network
data link
data link
physical
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
Network Layer
application
transport
network
data link
physical
4-4
routing algorithm
analogy:
3
2
2
1
value in arriving
packets header
0111
1
3 2
algorithms
Network Layer
4-5
Connection setup
Network Layer
4-6
Network Layer
4-7
4-8
Service
Model
Guarantees ?
Congestion
Bandwidth Loss Order Timing feedback
ATM
VBR
ATM
ABR
ATM
UBR
constant
rate
guaranteed
rate
guaranteed
minimum
none
no
no
no
yes
yes
yes
yes
yes
yes
no
yes
no
no (inferred
via loss)
no
congestion
no
congestion
yes
no
yes
no
no
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Network Layer
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
4-9
Virtual circuits
source-to-dest path behaves much like telephone
circuit
connectionless service
VC network provides network-layer
connection service
analogous to the transport-layer services,
but:
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)
service:
host-to-host
no choice: network provides one or the other
implementation: in network core
Network Layer
performance-wise
network actions along source-to-dest path
4-11
Forwarding table
VC implementation
VC number
a VC consists of:
1.
2.
3.
Forwarding table in
northwest router:
Incoming interface
1
2
3
1
22
12
interface
number
Incoming VC #
12
63
7
97
Outgoing interface
Datagram networks
application
transport 5. Data flow begins
network 4. Call connected
data link 1. Initiate call
physical
data link
physical
22
18
17
87
Outgoing VC #
3
1
2
3
32
application
transport
network
data link 1. Send data
physical
application
transport
2. Receive data network
data link
physical
Network Layer 4-16
Forwarding table
4 billion
possible entries
Link Interface
otherwise
Prefix Match
11001000 00010111 00010
11001000 00010111 00011000
11001000 00010111 00011
otherwise
Link Interface
0
1
2
3
Examples
DA: 11001000 00010111 00010110 10100001
Which interface?
Which interface?
3
Network Layer 4-17
Internet (datagram)
ATM (VC)
evolved from telephony
computers
human conversation:
elastic service, no strict
strict timing, reliability
timing req.
requirements
smart end systems
need for guaranteed
(computers)
service
can adapt, perform
dumb end systems
control, error recovery
telephones
simple inside network,
complexity inside
complexity at edge
network
many link types
different characteristics
uniform service difficult
Network Layer 4-19
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
Physical layer:
bit-level reception
Decentralized switching:
Memory
Output
Port
System Bus
Output Ports
N flows,
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
Network
layer
IP protocol
addressing conventions
datagram format
packet handling conventions
Routing protocols
path selection
RIP, OSPF, BGP
forwarding
table
ICMP protocol
error reporting
router signaling
Link layer
physical layer
IP datagram format
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
IP protocol version
number
header length
(bytes)
type of data
max number
remaining hops
(decremented at
each router)
upper layer protocol
to deliver payload to
fragmentation:
in: one large datagram
out: 3 smaller datagrams
Example
4000 byte
datagram
MTU = 1500 bytes
1480 bytes in
data field
reassembly
offset =
1480/8
type of
ver head.
len service
length
fragment
16-bit identifier flgs
offset
time to upper
header
layer
live
checksum
total datagram
length (bytes)
for
fragmentation/
reassembly
data
(variable length,
typically a TCP
or UDP segment)
E.g. timestamp,
record route
taken, specify
list of routers
to visit.
32 bits
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
IP Addressing: introduction
RIP
OSPF
BGP
IP address: 32-bit
identifier for host,
router interface
interface: connection
between host/router
and physical link
223.1.1.1
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.3.27
IP address:
Whats a subnet ?
223.1.2.1
223.1.1.2
223.1.1.4
223.1.1.3
223.1.2.9
223.1.3.27
223.1.2.2
subnet
223.1.3.1
223.1.3.2
Subnets
223.1.1.1
223.1.2.2
223.1.3.2
223.1.3.1
Subnets
223.1.2.9
Recipe
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.1.0/24
223.1.2.0/24
223.1.3.0/24
10
Subnets
IP addressing: CIDR
223.1.1.2
How many?
223.1.1.1
223.1.1.4
subnet
223.1.1.3
address
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.2.1
223.1.3.27
223.1.2.2
223.1.3.1
223.1.3.2
subnet
part
host
part
DHCP overview:
host broadcasts DHCP discover msg
DHCP server responds with DHCP offer msg
host requests IP address: DHCP request msg
DHCP server sends address: DHCP ack msg
Network Layer 4-44
11
arriving
client
DHCP discover
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
223.1.2.1
DHCP
server
223.1.1.1
223.1.1.2
223.1.1.4
DHCP offer
223.1.2.9
223.1.2.2
223.1.1.3
223.1.3.1
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
Lifetime: 3600 secs
223.1.3.27
223.1.3.2
arriving DHCP
client needs
address in this
network
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
time
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
Lifetime: 3600 secs
200.23.16.0/20
Organization 0
Organization 1
Organization 2
...
200.23.16.0/23
200.23.18.0/23
200.23.20.0/23
.
Organization 7
200.23.30.0/23
200.23.16.0/23
Organization 1
200.23.18.0/23
Organization 2
200.23.20.0/23
Organization 7
.
.
.
.
.
.
Fly-By-Night-ISP
Send me anything
with addresses
beginning
200.23.16.0/20
Internet
200.23.30.0/23
ISPs-R-Us
Send me anything
with addresses
beginning
199.31.0.0/16
Network Layer 4-48
12
200.23.16.0/23
Organization 2
200.23.20.0/23
Organization 7
.
.
.
.
.
.
Fly-By-Night-ISP
Send me anything
with addresses
beginning
200.23.16.0/20
Internet
200.23.30.0/23
Send me anything
with addresses
beginning 199.31.0.0/16
or 200.23.18.0/23
ISPs-R-Us
Organization 1
200.23.18.0/23
local network
(e.g., home network)
10.0.0/24
10.0.0.4
10.0.0.1
10.0.0.2
138.76.29.7
10.0.0.3
13
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
2
remember
incoming
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
1
10.0.0.4
138.76.29.7
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3: Reply arrives
dest. address:
138.76.29.7, 5001
address
IPv6
solution 1: statically
configure NAT to forward
incoming connection
requests at given port to
server
10.0.0.3
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
10.0.0.1
10.0.0.2
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
NAT is controversial:
routers should only process up to layer 3
violates end-to-end argument
1: host 10.0.0.1
sends datagram to
128.119.40.186, 80
10.0.0.1
138.76.29.7
10.0.0.4
NAT
router
14
10.0.0.1
IGD
10.0.0.4
138.76.29.7
NAT
router
2. connection to
relay initiated
by client
Client
1. connection to
relay initiated
by NATted host
3. relaying
established
138.76.29.7
10.0.0.1
NAT
router
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
communicate network-level
information
error reporting:
unreachable host, network,
port, protocol
echo request/reply (used
by ping)
network-layer above IP:
ICMP msgs carried in IP
datagrams
ICMP message: type, code plus
first 8 bytes of IP datagram
causing error
Type
0
3
3
3
3
3
3
4
Code
0
0
1
2
3
6
7
0
8
9
10
11
12
0
0
0
0
0
description
echo reply (ping)
dest. network unreachable
dest host unreachable
dest protocol unreachable
dest port unreachable
dest network unknown
dest host unknown
source quench (congestion
control - not used)
echo request (ping)
route advertisement
router discovery
TTL expired
bad IP header
Network Layer 4-60
15
to nth router:
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
IPv6
Initial motivation: 32-bit address space soon
to be completely allocated.
Additional motivation:
header
16
Tunneling
Logical view:
Physical view:
Tunneling
E
IPv6
IPv6
IPv6
IPv6
IPv6
IPv6
IPv6
IPv6
tunnel
IPv4
IPv4
Logical view:
Physical view:
IPv6
IPv6
IPv6
Flow: X
Src: A
Dest: F
data
A-to-B:
IPv6
Network Layer 4-67
IPv6
IPv6
tunnel
IPv6
IPv4
IPv4
IPv6
Src:B
Dest: E
Src:B
Dest: E
Flow: X
Src: A
Dest: F
Flow: X
Src: A
Dest: F
data
data
B-to-C:
IPv6 inside
IPv4
B-to-C:
IPv6 inside
IPv4
IPv6
Flow: X
Src: A
Dest: F
data
E-to-F:
IPv6
Network Layer 4-68
17
routing algorithm
Link state
Distance Vector
Hierarchical routing
Datagram format
IPv4 addressing
ICMP
IPv6
0100
0101
0111
1001
RIP
OSPF
BGP
3
2
2
1
value in arriving
packets header
0111
3 2
Graph abstraction
5
2
2
1
Graph: G = (N,E)
5
3
w
3
2
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) }
Remark: Graph abstraction is useful in other network contexts
Example: P2P, where N is set of peers and E is set of TCP connections
Network Layer 4-71
w
3
- e.g., c(w,z) = 5
1
2
18
Global or decentralized
information?
Static or dynamic?
Static:
routes change slowly
over time
Dynamic:
routes change more
quickly
periodic update
in response to link
cost changes
Global:
all routers have complete
topology, link cost info
link state algorithms
Decentralized:
router knows physicallyconnected neighbors, link
costs to neighbors
iterative process of
computation, exchange of
info with neighbors
distance vector algorithms
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Dijkstras algorithm
net topology, link costs
Notation:
c(x,y): link cost from node
x to y; = if not direct
neighbors
RIP
OSPF
BGP
Link state
Distance Vector
Hierarchical routing
Dijsktras 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'
Network Layer 4-76
19
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v),p(v) D(w),p(w)
2,u
5,u
2,u
4,x
2,u
3,y
3,y
D(x),p(x)
1,u
D(y),p(y)
2,x
D(z),p(z)
3
1
2
Network Layer 4-77
D
1
0 0
C
e
1+e
e
initially
A
2+e
0
D 1+e 1 B
0
recompute
routing
A
0 0
2+e
1+e
recompute
link
v
x
(u,v)
(u,x)
(u,x)
(u,x)
(u,x)
A
2+e
0
D 1+e 1 B
0
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Oscillations possible:
e.g., link cost = amount of carried traffic
A
z
x
destination
3
5
2
4,y
4,y
4,y
recompute
Network Layer 4-79
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
20
Bellman-Ford example
5
{c(x,v) + dv(y) }
dx(y) = min
v
v
2
Then
w
3
5
2
Basic idea:
Each node periodically sends its own distance
vector estimate to neighbors
When a node x receives new DV estimate from
neighbor, it updates its own DV using B-F equation:
c(x,v)
Node x maintains distance vector Dx =
[Dx(y): y N ]
Node x also maintains its neighbors
distance vectors
For
21
Distributed:
neighbors only when its DV
changes
x
y 2 0 1
z
node z table
cost to
x y z
from
x 0 2 3
y 2 0 1
z 7 1 0
from
recompute estimates
x 0 2 7
y
z
node y table
cost to
x y z
x
y
z
71 0
time
node x table
cost to
x y z
x
y
z
71 0
from
from
from
from
x 0 2 7
y 2 0 1
z 7 1 0
cost to
x y z
x 0 2 7
y 2 0 1
z 3 1 0
= min{2+1 , 7+0} = 3
x 0 2 3
y 2 0 1
z 3 1 0
y
7
distance vector
if DV changes, notify neighbors
cost to
x y z
x 0 2 3
y 2 0 1
z 3 1 0
time
y
7
x 0 2 3
y 2 0 1
z 3 1 0
cost to
x y z
from
from
from
x
y 2 0 1
z
node z table
cost to
x y z
x 0 2 3
y 2 0 1
z 7 1 0
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
cost to
x y z
cost to
x y z
from
from
x 0 2 7
y
z
node y table
cost to
x y z
cost to
x y z
= min{2+1 , 7+0} = 3
cost to
x y z
from
node x table
cost to
x y z
from
Iterative, asynchronous:
Dx(z) = min{c(x,y) +
Dy(z), c(x,z) + Dz(z)}
good
news
travels
fast
y
50
22
60
Message complexity
y
50
Speed of Convergence
LS: O(n2) algorithm requires
If Z routes through Y to
O(nE) msgs
may have oscillations
DV: convergence time varies
may be routing loops
count-to-infinity problem
get to X :
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
DV:
neighbors only
convergence time varies
Poisoned reverse:
Link state
Distance Vector
Hierarchical routing
Hierarchical Routing
RIP
OSPF
BGP
routing tables!
routing table exchange
would swamp links!
administrative autonomy
internet = network of
networks
23
Interconnected ASes
Hierarchical Routing
aggregate routers into
regions, autonomous
systems (AS)
routers in same AS run
same routing protocol
Gateway router
Direct link to router in
another AS
3c
3b
3a
AS3
1a
intra-AS routing
protocol
routers in different AS
can run different intraAS routing protocol
2a
1c
AS2
1b
1d
2c
AS1
Intra-AS
Routing
algorithm
Inter-AS
Routing
algorithm
Forwarding
table
2b
forwarding table
configured by both
intra- and inter-AS
routing algorithm
Inter-AS tasks
AS1 must:
1. learn which dests
reachable through
AS2, which through
AS3
2. propagate this
reachability info to all
routers in AS1
Job of inter-AS routing!
3c
3b
3a
AS3
1a
2a
1c
1d
1b
2c
AS2
3c
3b
2b
3a
AS3
1a
AS1
Network Layer 4-95
x
2a
1c
1d
1b AS1
2c
2b
AS2
Network Layer 4-96
24
3c
3a
3b
AS3
1a
2a
1c
1d
1b
2c
AS2
2b
AS1
Intra-AS Routing
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
Determine from
forwarding table the
interface I that leads
to least-cost gateway.
Enter (x,I) in
forwarding table
OSPF:
IGRP:
25
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Link state
Distance Vector
Hierarchical routing
Datagram format
IPv4 addressing
ICMP
IPv6
RIP
OSPF
BGP
destination hops
u
1
v
2
w
2
x
3
y
3
z
2
x
y
RIP advertisements
distance
RIP: Example
z
C
Destination Network
w
y
z
x
Next Router
....
A
B
B
--
2
2
7
1
Routing table in D
Network Layer 4-103
26
RIP: Example
Dest
w
x
z
.
Next
C
hops
1
1
4
...
Advertisement
from A to D
z
x
Destination Network
w
y
z
x
Next Router
....
A
B
B A
--
2
2
7 5
1
Routing table in D
routed
routed
Transprt
(UDP)
network
(IP)
link
physical
Transprt
(UDP)
forwarding
table
forwarding
table
network
(IP)
link
physical
Network Layer 4-107
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
27
LS packet dissemination
topology map at each node
route computation using Dijkstras algorithm
Hierarchical OSPF
Hierarchical OSPF
28
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
1.
2.
RIP
OSPF
BGP
3.
the de
facto standard
BGP provides each AS a means to:
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
BGP basics
eBGP session
3c
3b
3a
AS3
1a
AS1
iBGP session
2a
1c
1d
1b
eBGP session
3c
2c
AS2
2b
3b
3a
AS3
1a
AS1
iBGP session
2a
1c
1d
1b
2c
AS2
2b
29
4.
BGP messages
legend:
B
W
provider
network
customer
network:
C
Y
30
B
W
provider
network
customer
network:
C
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 Bs customers
B wants to force C to route to w via A
B wants to route only to/from its customers!
Policy:
Inter-AS: admin wants control over how its traffic
routed, who routes through its net.
Intra-AS: single admin, so no policy decisions needed
Scale:
hierarchical routing saves table size, reduced update
traffic
Performance:
Intra-AS: can focus on performance
Inter-AS: policy may dominate over performance
Broadcast Routing
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
R1
R2
R2
R3
duplicate
creation/transmission
R1
duplicate
R4
source
duplication
R3
R4
in-network
duplication
31
In-network duplication
Spanning Tree
tree
Node
spanning tree
No redundant packets received by any node
Or
c
D
F
Center node
Each node sends unicast join message to center
node
A
B
F
1
A
3
c
D
Shared tree
Source-based trees
32
path trees
reverse path forwarding
group-shared tree: group uses one tree
minimal spanning (Steiner)
center-based trees
LEGEND
R1
1
R4
R2
3
algorithm
5
4
R3
6
R7
R6
LEGEND
R1
R5
S: source
R4
R2
R5
R3
R6
R7
33
S: source
R1
R4
R2
P
R5
R3
R6
P
R7
complexity
about entire network needed
monolithic: rerun whenever a router needs to
join/leave
information
Center-based trees
center of tree
to join:
edge router sends unicast join-msg addressed
to center router
join-msg processed by intermediate routers
and forwarded towards center
join-msg either hits existing tree branch for
this center, or arrives at center
path taken by join-msg becomes new branch of
tree for this router
LEGEND
R1
R2
R4
3
2
R5
R3
R6
R7
34
DVMRP: continued
soft
protocol, RFC1075
flood and prune: reverse path forwarding,
source-based tree
RPF
Tunneling
downstream
physical topology
mcast
logical topology
addressed) datagram
Dense:
Sparse:
group members
densely packed, in
close proximity.
bandwidth more
plentiful
35
Dense
Sparse:
group membership by
no membership until
routers assumed until
routers explicitly join
routers explicitly prune receiver- driven
data-driven construction
construction of mcast
on mcast tree (e.g., RPF)
tree (e.g., center-based)
bandwidth and non bandwidth and non-groupgroup-router processing
router processing
center-based approach
router sends join msg
to rendezvous point
(RP)
sender(s):
unicast data to RP,
which distributes down
RP-rooted tree
RP can extend mcast
tree upstream to
source
RP can send stop msg
if no attached
receivers
profligate
conservative
increased performance:
less concentration,
shorter paths
R4
join
intermediate routers
update state and
forward join
R1
R2
R3
join
R5
join
R6
R7
rendezvous
point
no one is listening!
R1
R4
join
R2
R3
join
R5
join
R6
R7
rendezvous
point
36
Chapter 4: summary
4. 1 Introduction
4.2 Virtual circuit and
datagram networks
4.3 Whats inside a
router
4.4 IP: Internet
Protocol
Datagram format
IPv4 addressing
ICMP
IPv6
Link state
Distance Vector
Hierarchical routing
RIP
OSPF
BGP
37