4 Network Layer
4 Network Layer
Segments
Transport Transport
layer layer
Network Network
service service
Network Network Network Network
layer layer layer layer
End-system
End-system
B
A
value in arriving
packet’s header
0111 1
3 2
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link 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?
Kurose & Ross 4-11
Datagram network: why?
Internet (datagram)
data exchange among computers
“elastic” service, no strict timing req.
forwarding data
plane (hardware)
high-speed
switching
fabric
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet given datagram dest., lookup output port using
see chapter 5 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
Kurose & Ross 4-15
Switching fabrics
transfer packet from input buffer to appropriate output
buffer
switching rate: rate at which packets can be transferred
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
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)
switch
switch
fabric
fabric
switch switch
fabric fabric
link layer
physical layer
…
MTUs in: one large datagram
out: 3 smaller datagrams
large IP datagram divided
(“fragmented”) within net
one datagram becomes
several datagrams
reassembly
“reassembled” only at final
destination
IP header bits used to identify,
order related fragments …
IP addresses associated
with each interface
223.1.1.1 = 11011111 00000001 00000001 00000001
223 1 1 1
223.1.1.2
223.1.1.4 223.1.2.9
223.1.3.27
223.1.1.3
223.1.2.2
is called a subnet
223.1.3.0/24
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
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1
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
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 take
yiaddrr: 223.1.2.4
that IP address!
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
Broadcast: OK. You’ve
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
got that IPID:
transaction address!
655
lifetime: 3600 secs
Kurose & Ross 4-39
DHCP: more than IP addresses
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”
Organization 0
200.23.16.0/23
“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
or 200.23.18.0/23”
200.23.18.0/23
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
2. connection to
relay initiated 1. connection to
relay initiated 10.0.0.1
by client
by NATed host
3. relaying
client established
138.76.29.7 NAT
router
3 probes 3 probes
3 probes
Kurose & Ross 4-57
IPv6: motivation
initial motivation: 32-bit address space soon to be
completely allocated.
additional motivation:
header format helps speed processing/forwarding
header changes to facilitate QoS
data
32 bits
Kurose & Ross 4-59
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
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 inside IPv6 inside
IPv4 IPv4 Kurose & Ross 4-63
IPv6: adoption
US National Institutes of Standards estimate [2013]:
~3% of industry IP routers
~11% of US gov’t routers
IP destination address in
arriving packet’s header
1
3 2
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
Kurose & Ross 4-73
Dijkstra’s algorithm: another example
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
oscillations possible:
e.g., support link cost equals amount of carried traffic:
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 costs resulting in new costs
node x:
knows cost to each neighbor v: c(x,v)
maintains its neighbors’ distance vectors. For each neighbor
v, x maintains
Dv = [Dv(y): y є N ]
4 5
D1 D2 D3 D4 D5
∞ ∞ 1 ∞ 2
(-1) (-1) (6) (-1) (6)
3 6 1 3 2
(1-3-6) (2-5-6) (6) (4-3-6) (6)
3 4 1 3 2
(1-3-6) (2-4-3-6) (6) (4-3-6) (6)
3 4 1 3 2
(1-3-6) (2-4-3-6) (6) (4-3-6) (6)
from
y ∞∞ ∞ y 2 0 1
from
z ∞∞ ∞ z 7 1 0
node y cost to
table x y z y
2 1
x ∞ ∞ ∞
x z
y 2 0 1 7
from
z ∞∞ ∞
node z cost to
table x y z
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Kurose & Ross 4-84
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
y ∞∞ ∞ y 2 0 1
from
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
y 2 0 1 y 2 0 1 7
from
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
y 2 0 1 y 2 0 1
from
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Kurose & Ross 4-85
Distance vector: link cost changes
link cost changes:
node detects local link cost change 1
updates routing info, recalculates y
4 1
distance vector
x z
if DV changes, notify neighbors 50
poisoned reverse:
If Z routes through Y to get to X :
Z tells Y its (Z’s) distance to X is infinite (so Y won’t
route to X via Z)
will this completely solve count to infinity problem?
network “flat”
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b
1d AS1
forwarding table configured
by both intra- and inter-AS
routing algorithm
Intra-AS Inter-AS intra-AS sets entries for
Routing
algorithm
Routing
algorithm
internal dests
inter-AS & intra-AS sets
Forwarding
table
entries for external dests
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
?
Kurose & Ross 4-95
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
…. …. ....
Kurose & Ross 4-100
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
…. …. ....
Kurose & Ross 4-101
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)
routed routed
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
High-level overview
1. Router becomes aware of prefix
2. Router determines output port for prefix
3. Router enters prefix-port in forwarding table
3c
BGP
3a
message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c
BGP
3a
message
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Example: select
3c
3a 111.99.86.55
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c router
3a port
3b
AS3 1 2c other
1c 4 2a networks
2 3
other 1a 2b
networks 1b AS2
AS1 1d
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
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!
wide area
network
Permanent address:
address in home
network, can always be
used to reach mobile
e.g., 128.119.40.186 correspondent
Mobile IP (Terminology)
Permanent address: remains
constant (e.g., 128.119.40.186) visited network: network in
which mobile currently
Care-of-address: address in
resides (e.g., 79.129.13/24)
visited network.
(e.g., 79.29.13.2)
wide area
network
would be impossible
Let routing handle it: Routers advertise permanent address
mobiles as tables
of mobile-nodes-in-residence via usual routing table exchange.
with millions of
to maintain
Routing tables indicate where each mobile located
No changes needed to end-systems
Feasible in practical
mobile goes through home agent, then forwarded to
mobile systems
remote
Direct Routing: correspondent gets foreign address of
mobile, sends directly to mobile
Registering a Mobile outside its Home
Network
home network visited network
1
2
wide area
network
Mobile contacts
Foreign agent contacts home foreign agent on
agent home: “this mobile is entering visited
resident in my network” network
End result:
Foreign agent knows about mobile
Home agent knows location of mobile
Mobile IP (Indirect Routing)
Foreign agent
receives packets,
Home agent intercepts forwards to mobile
packets, forwards to visited
foreign agent network
home
network
3
wide area
network
2
1
4
Correspondent
addresses packets
Mobile replies
using home address of
directly to
mobile
correspondent
Mobile IP (Indirect Routing)
Mobile uses two addresses:
Permanent Address: used by correspondent (hence mobile
location is transparent to correspondent)
Care-of-address: used by home agent to forward datagrams to
mobile
Foreign agent functions may be done by mobile itself
Triangle Routing: Between correspondent-home-network-mobile.
This is actually inefficient if correspondent and mobile happen to be
in the same network.
Mobile IP (Indirect Routing)
Note that even though mobility may force the mobile to change from
one foreign network to another, the on-going connections can be
maintained as the IP addresses do not change! This is important as
disconnecting a flow (e.g. a TCP connection) and setting it up once
again can be very inefficient!
Mobile IP (Direct Routing)
Foreign agent
receives packets,
Correspondent forwards forwards to mobile
to foreign agent visited
network
home
network 4
wide area
2 network
3
Correspondent 1 4
requests, receives
Mobile replies
foreign address of
directly to
mobile
correspondent
Mobile IP (Direct Routing)