Professional Documents
Culture Documents
Chapter 4: Network Layer
Chapter 4: Network Layer
Chapter 4: Network Layer
Chapter goals:
❒ understand principles behind network layer
services:
❍ network layer service models
❍ forwarding versus routing
❍ how a router works
❍ routing (path selection)
❍ dealing with scale
❍ advanced topics: IPv6, mobility
Network Layer 1
Network Layer 2
Two Key Network-Layer Functions
Network Layer 3
routing algorithm
value in arriving
packet’s header
0111 1
3 2
Network Layer 4
Virtual circuits: signaling protocols
Network Layer 5
Datagram networks
❒ no call setup at network layer
❒ routers: no state about end-to-end connections
❍ no network-level concept of “connection”
application application
transport transport
network 1. Send data 2. Receive data network
data link data link
physical physical
Network Layer 6
Forwarding table
4 billion
possible entries
otherwise 3
Network Layer 7
Examples
Network Layer 8
The Internet Network layer
Host, router network layer functions:
Link layer
physical layer
Network Layer 9
IP datagram format
IP protocol version 32 bits total datagram
number
head. length (bytes)
header length (bytes) ver TOS length
len
for
“Type Of Service” of data 16-bit identifier flgs fragment offset
fragmentation/
TTL - max number of hops time to upper reassembly
live - TTL layer header checksum
(decremented at
each router) 32 bit source IP address
32 bit destination IP address
upper layer protocol
to deliver payload to Options (if any) E.g. timestamp,
record route
how much overhead data
taken, specify
with TCP? (variable length,
list of routers
❒ 20 bytes of TCP typically a TCP to visit.
❒ 20 bytes of IP or UDP segment)
❒ = 40 bytes + app
layer overhead Network Layer 10
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing
Network Layer 11
IP Addressing
223.1.1.1
❒ IP address: 32-bit
identifier for host, 223.1.1.2
223.1.2.1
Network Layer 12
Subnets
223.1.1.1
❒ IP address:
❍ subnet part (high order 223.1.2.1
223.1.1.2
bits) 223.1.1.4 223.1.2.9
❍ host part (low order
223.1.2.2
bits) 223.1.1.3 223.1.3.27
❒ What’s a subnet ?
subnet
❍ device interfaces with
223.1.3.1 223.1.3.2
same subnet part of IP
address
❍ can physically reach
Network Layer 13
Subnets 223.1.1.0/24
223.1.2.0/24
Recipe
❒ To determine the
subnets, detach each
interface from its host
or router, creating
islands of isolated
networks. Each isolated
223.1.3.0/24
network is called a
subnet. Subnet mask: /24
Network Layer 14
Subnets 223.1.1.2
223.1.1.3
223.1.222.2
R1
223.1.222.99
223.1.9.2 223.1.7.2
223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.2
R2 R3
223.1.2.6 223.1.3.27
Network Layer 15
IP fragmentation,
IP reassembly
addressing: CIDR
§ CIDR:
network Classless
links have MTUInterDomain Routing
(max.transfer size) -
❍ subnet portion of address of arbitrary length
largest possible link-level fragmentation:
❍ address format: a.b.c.d/x, where x is in:
frame # one
bits indatagram
…
large
• different
subnetlink types, of address
portion out: 3 smaller datagrams
different MTUs
§ large IP datagram divided
( fragmented ) within net reassembly
• one datagram becomes
several datagrams
subnet host
• reassembled only at
…
part part
final11001000
destination00010111 00010000 00000000
• IP header bits used to
identify, order related
200.23.16.0/23
fragments
Network
Network Layer
Layer: Data 16
Plane 4-33
IP addresses:
IP fragmentation, reassembly
how to get one?
length ID fragflag offset
Q: How does host get IP address?
example: =4000 =x =0 =0
v 4000 byte datagram
one large datagram becomes
v❒ MTU = 1500 by
hard-coded bytes
system admin in a file
several smaller datagrams
❍ Wintel: control-panel->network->configuration->tcp/ip-
>properties
1480 bytes in length ID fragflag offset
data field
❍ UNIX: /etc/rc.config =1500 =x =1 =0
❒ DHCP: Dynamic Host Configuration Protocol: dynamically get address
offset = length ID fragflag offset
from as1480/8
server =1500 =x =1 =185
❍ “plug-and-play”
length ID fragflag offset
=1040 =x =0 =370
Network
Network Layer
Layer: Data 17
Plane 4-34
Examples:
❒ Ex. a) : Consider sending a 3000 byte datagram into a link that
application data?
Network Layer 18
IP addresses: how to get one?
Q: How does network get subnet part of IP addr?
A: gets allocated portion of its provider ISP’s
address space
Network Layer 19
Organization 0
200.23.16.0/23
Organization 1
“Send me anything
200.23.18.0/23
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
Organization 7 ..
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
beginning
199.31.0.0/16”
Network Layer 20
Hierarchical addressing: more specific routes
“Send me anything
with addresses
Organization 2 beginning
200.23.20.0/23 . Fly-By-Night-ISP 200.23.16.0/20”
.
. . Internet
.
Organization 7 .
200.23.30.0/23
“Send me anything
ISPs-R-Us
with addresses
Organization 1 beginning 199.31.0.0/16
200.23.18.0/23 or 200.23.18.0/23”
Network Layer 21
AND
❍ Regional Internet Registries (RIRs)
Network Layer 22
IP addressing: last words...
Network Layer 23
Example
Q: Proponha um esquema que
lhe permita endereçar os
computadores das redes
locais associadas aos
diferentes
encaminhadores a partir
dos seguintes endereços:
193.213.168.0/23 (ou
Net: 193.213.168.0 Mask:
255.255.254.0).
Network Layer 24
TP9 - Routing (submit via elearning platform)
Q: A tabela seguinte
constitui uma parte da
tabela de encaminhamento
do Router R1. Complete-a
de forma a conseguir que
os computadores destas
redes tenham
conectividade IP entre si e
acesso à Internet.
Network Layer 25
R1
I2 - 192.168.1.252 I1 - 192.168.2.249
I1 - 192.168.1.254
192.168.2.250 - Ix IA - 192.168.111.254
R2 R3
I0 - 172.16.2.254 IB - 172.16.192.2
172.16.2.0/24 172.16.192.0/20
How many hosts? How many hosts?
26
NAT: Network Address Translation
Network Layer 27
Network Layer 28
NAT: Network Address Translation
NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
138.76.29.7, 5001 10.0.0.1, 3345
source addr from 128.119.40.186, 80
…… ……
10.0.0.1, 3345 to
S: 10.0.0.1, 3345
138.76.29.7, 5001, D: 128.119.40.186, 80
updates table 10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
4
D: 10.0.0.1, 3345
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: Reply arrives
changes datagram
dest. address:
dest addr from
138.76.29.7, 5001
138.76.29.7, 5001 to 10.0.0.1, 3345
Network Layer 29
Network Layer 30
NAT traversal problem
❒ client want to connect to
server with address 10.0.0.1 10.0.0.1
❍ server address 10.0.0.1 local to Client
LAN (client can’t use it as ?
destination addr) 10.0.0.4
❍ only one externally visible
NATted address: 138.76.29.7 138.76.29.7 NAT
❒ solution 1: statically router
configure NAT to forward
incoming connection requests
at given port to server
❍ e.g., (123.76.29.7, port 2500)
always forwarded to 10.0.0.1
port 25000
Network Layer 31
2. connection to
relay initiated 1. connection to
by client relay initiated
10.0.0.1
3. relaying by NATted host
Client
established
138.76.29.7 NAT
router
Network Layer 33
Network Layer 34
ICMP: Internet Control Message Protocol
Network Layer 35
Network Layer 37
IPv6
❒ Initial motivation: 32-bit address space soon
to be completely allocated.
❒ Additional motivation:
❍ header format helps speed processing/forwarding
❍ header changes to facilitate QoS
IPv6 datagram format:
❍ fixed-length 40 byte header
❍ no fragmentation allowed
Network Layer 38
IPv6 Header (Cont)
Priority: identify priority among datagrams in flow
Flow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
Next header: identify upper layer protocol for data
Network Layer 39
Network Layer 40
Transition From IPv4 To IPv6
❒ Not all routers can be upgraded simultaneous
❍ no “flag days”
❍ How will the network operate with mixed IPv4 and
IPv6 routers?
❒ Tunneling: IPv6 carried as payload in IPv4
datagram among IPv4 routers
Network Layer 41
Tunneling
A B E F
Logical view: tunnel
A B E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
Network Layer 42
Tunneling
A B tunnel
E F
Logical view:
IPv6 IPv6 IPv6 IPv6
A B C D E F
Physical view:
IPv6 IPv6 IPv4 IPv4 IPv6 IPv6
Flow: X Src:B Src:B Flow: X
Src: A Src: A
Dest: E Dest: E
Dest: F Dest: F
Flow: X Flow: X
Src: A Src: A
Dest: F Dest: F
data data
data data
A-to-B: E-to-F:
B-to-C: B-to-C:
IPv6 IPv6
IPv6 inside IPv6 inside
IPv4 IPv4 Network Layer 43
Network Layer 44
Interplay between routing, forwarding
routing algorithm
value in arriving
packet’s header
0111 1
3 2
Network Layer 45
Graph abstraction
5
v 3 w
2 5
u 2 1 z
3
1 2
x y
Graph: G = (N,E) 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) }
Network Layer 46
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
1 • cost could always be 1, or
x y 2
1 inversely related to bandwidth,
or inversely related to
congestion
Cost of path (x1, x2, x3,…, xp) = c(x1,x2) + c(x2,x3) + … + c(xp-1,xp)
Network Layer 47
Decentralized: Dynamic:
❒ router knows physically- ❒ routes change more
connected neighbors, link costs
to neighbors
quickly
❒ iterative process of computation,
❍ periodic update
exchange of info with neighbors ❍ in response to link
❒ “distance vector” algorithms
cost changes
Network Layer 48
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing
Network Layer 49
Network Layer 50
Dijsktra’s 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 51
5
3
v w 5
2
u 2 1 z
3
1 2
x y
1
Network Layer 52
Dijkstra’s algorithm: example (2)
Resulting shortest-path tree from u:
v w
u z
x y
Oscillations possible:
❒ e.g., link cost = amount of carried traffic
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 B
0 0 1+e 1
0 e 0 0 1 1+e 0 e
1 C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 54
Chapter 4: Network Layer
❒ 4. 1 Introduction ❒ 4.5 Routing algorithms
❍ Link state
❒ 4.2 Virtual circuit and
❍ Distance Vector
datagram networks ❍ Hierarchical routing
❒ 4.3 What’s inside a
❒ 4.6 Routing in the
router
Internet
❒ 4.4 IP: Internet ❍ RIP
Protocol ❍ OSPF
❍ Datagram format ❍ BGP
❍ IPv4 addressing ❒ 4.7 Broadcast and
❍ ICMP
❍ IPv6
multicast routing
Network Layer 55
Then
Network Layer 57
Network Layer 58
Distance vector algorithm (4)
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:
Dx(y) ← minv{c(x,v) + Dv(y)} for each node y ∊ N
Network Layer 59
Distributed:
❒ each node notifies neighbors if DV to any dest has
only when its DV changes changed, notify neighbors
❍ neighbors then notify their
neighbors if necessary
Network Layer 60
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
Dx(z) = min{c(x,y) +
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
node y table
cost to
x y z y
2 1
x ∞ ∞ ∞ x z
y 2 0 1 7
from
z ∞∞ ∞
node z table
cost to
x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 71 0
time
Network Layer 61
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)}
node x table = min{2+1 , 7+0} = 3
cost to cost to cost to
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 table
cost to cost to cost to
x y z x y z x y z y
2 1
x ∞ ∞ ∞ x 0 2 7 x 0 2 3 z
x
from
y 2 0 1 y 2 0 1 7
from
from
y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
node z table
cost to cost to cost to
x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 71 0 z 3 1 0 z 3 1 0
time
Network Layer 62