Unit 4 - Network Layer
Unit 4 - Network Layer
Network Layer
on sending side
data link data link
network
physical physical
data link
network
on receiving side, delivers
network
data link data link
physicalnetwork physical
segments to transport data link
physical
layer network
application
transport
data link network
network layer protocols in network
data link
physical
network
data link data link
physical
every host, router
physical
physical
value in arriving
packet’s header
0111 1
3 2
Guaranteed delivery
This service guarantees that the packet will eventually arrive
at its destination.
Guaranteed delivery with bounded delay
This service not only guarantees delivery of the packet, but
delivery within a specified host-to-host delay bound.
Network Service Model –
Cont…
Services provided by network layer for a flow of packets
between Source and destination:
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application application
transport transport
5. data flow begins 6. receive data
network network
4. call connected 3. accept call
data link 1. initiate call data link
2. incoming call
physical physical
application application
transport 1. send datagrams transport
2. receive datagrams network
network
data link data link
physical physical
IP destination address in
arriving packet’s header
1
3 2
State Information None other than router table Route established at setup, all
containing destination network packets follow same route.
Effect of Router Only on packets lost during All virtual circuits passing through
Failure crash failed router terminated.
Congestion Control Difficult since all packets Simple by pre-allocating enough
routed independently router buffers to each virtual circuit at
resource requirements can setup, since maximum number of
vary. circuits fixed.
high-seed
switching
fabric
physical layer:
bit-level reception
data link layer: decentralized switching:
e.g., Ethernet given datagram dest., lookup output port
see chapter 5 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
Network Layer 4-23
Switching fabrics
It connects the router’s input ports to its
output ports.
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
memory
input output
port port
memory (e.g.,
(e.g.,
Ethernet) Ethernet)
system bus
datagram
switch buffer link
fabric layer line
protocol termination
(send)
queueing
buffering required when datagrams arrive from fabric faster than the
transmission rate Datagram (packets) can be
scheduling discipline chooses among queued datagrams for transmission
lost due to congestion, lack of
buffers
Priority scheduling – who gets best
performance, network neutrality
Network Layer 4-28
Output port queueing
switch switch
fabric fabric
switch switch
fabric fabric
routing IP protocol
protocols • addressing conventions
• path selection • datagram format
network • RIP, OSPF, BGP • packet handling conventions
layer forwarding
ICMP protocol
table • error reporting
• router “signaling”
link layer
physical layer
…
different 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
172 16 254 1
1 10
Fix
Class: D 21 Bit Network ID 8 Bit Host ID
1 11 0
Fix
Class: E Multicast address
1 11 1
Fix Reserved address
Class A: (0.0.0.0 to 127.255.255.255)
0
7 Bit Network ID 24 Bit Host ID
Only 126 addresses are used for network address.
All 0’s and 1’s in Network-ID are dedicated for special
IP address. So, total number of IP address in class A
can be represented:
0.0.0.0 Special IP Address
00000001.0.0.1
1.0.0.2
1.0.0.3
.
224 – 2 are Host IP
.
.
126.255.255.25
4
127.255.255.25 Special IP Address – Loopback
5
Class B: (128.0.0.0 to 191.255.255.255)
1 0
Fix 14 Bit 16 Bit
Network ID Host ID
1 10
Fix 21 Bit Network 8 Bit
ID Host ID
11100000 – 11101111
224 - 239
Class D has IP address rage from 224.0.0.0 to
239.255.255.255.
Class D is reserved for Multicasting.
In multicasting data is not destined for a particular
host, that is why there is no need to extract host
address from the IP address, and Class D does not
have any subnet mask.
Class E: (240.0.0.0 to 255.255.255.255)
This IP Class is reserved for experimental purposes
only for R&D or Study.
IP addresses in this class ranges from 240.0.0.0 to
255.255.255.254.
Like Class D, this class too is not equipped with any
subnet mask.
IP Addressing Summary
Size Default subn
Size
Leadin of networ Number Total et CIDR
of rest Addresses Start
Class g k of addresses End address mask in dot- notatio
bit per network address
bits number networks in class decimal n
field
bit field notation
Class D not
not not not 268,435,456 224.0.0. 239.255.255.25 not
(multicas 1110 define not defined
defined defined defined (228) 0 5 defined
t) d
Class E not
not not not 268,435,456 240.0.0. 255.255.255.25 not
(reserved 1111 define not defined
defined defined defined (228) 0 5 defined
) d
IP addressing: introduction
223.1.1.1
IP address: 32-bit
223.1.2.1
identifier for host,
router interface 223.1.1.2
223.1.1.4 223.1.2.9
interface: connection
between host/router
and physical link 223.1.1.3
223.1.3.27
223.1.2.2
router’s typically have
multiple interfaces
host typically has one or
two interfaces (e.g., 223.1.3.1 223.1.3.2
wired Ethernet, wireless
802.11)
IP addresses associated 223.1.1.1 = 11011111 00000001 00000001 00000001
with each interface
223 1 1 1
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.1.2
223.1.1.4
arriving DHCP
223.1.2.9
client needs
address in this
223.1.2.2
223.1.1.3 223.1.3.27 network
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
Network Layer 4-60
DHCP client-server
scenario
DHCP server: 223.1.2.5 DHCP discover arriving
src : 0.0.0.0, 68
client
Broadcast: is there a
dest.: 255.255.255.255,67
DHCP server
yiaddr: 0.0.0.0out
transaction
there?ID: 654
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server!
yiaddrr:Here’s
223.1.2.4an IP
address youID:can
transaction 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-61
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)
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”
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”
data
32 bits
Network Layer 4-81
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-83
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 inside IPv6
IPv6 inside
IPv4 IPv4 Network Layer 4-85
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
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
4
7
construct shortest path
8
tree by tracing 3
predecessor nodes u w y z
2
ties can exist (can be
broken arbitrarily) 3
7 4
v
Network Layer 4-95
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
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
let
dx(y) := cost of least-cost path from x to
y v
then
cost from neighbor v to destination
dx(y) = min {c(x,v)
cost + dvv(y) }
to neighbor
min taken over all neighbors v of x
Network Layer 4-100
Bellman-Ford example
5
3 clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
u 2 1B-F equation says:
z
3
1
x y 2 du(z) = min { c(u,v) + dv(z),
1
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
node achieving minimum is next 5 + 3} = 4
hop in shortest path, used in forwarding table
Network Layer 4-101
Distance vector algorithm
Dx(y) = estimate of least cost from x to
y
x maintains distance vector Dx = [Dx(y): y є
N]
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 ]
Network Layer 4-102
Distance vector algorithm
key idea:
from time-to-time, each node sends its own
distance vector estimate to neighbors
when 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
under minor, natural conditions, the
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-105
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,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
from
∞∞ ∞ y 2 0 1
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 y 2 7
from
2 0 1 0 1 y 2 0 1
z ∞∞ ∞ z 7 1 0 z 3 1 0
y 2 from y 2 0 1
from
y ∞∞ ∞ 0 1
z z 3 1 0 z 3 1 0
7 1 0
time
Network Layer 4-106
Distance vector: link cost
changes
link cost changes:
node detects local link cost 1
change 4
y
1
updates routing info,
x z
recalculates 50
distance vector
if DV changes, notify
neighbors
t0 : y detects link-cost change, updates its DV, informs its
“good neighbors.
news t1 : z receives update from y, updates its table, computes new
travels least cost to x , sends its neighbors its DV.
fast” t : y receives z’s update, updates its distance table. y’s least costs
2
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-121
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 A 2 5
z B 7
x -- 1
…. …. ....
Network Layer 4-122
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
area 1 routers
area 2
3c
BGP
3a message
3b 2c
AS3 1c
other
2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-130
BGP basics: distributing path
information
using eBGP session between 3a and 1c, AS3 sends prefix
reachability info to AS1.
1c can then use iBGP do distribute new prefix info to all routers in
AS1
1b can then re-advertise new reachability info to AS2 over 1b-to-2a
eBGP session
when router learns of new prefix, it creates entry for prefix
in its forwarding table.
eBGP session
3a iBGP session
3b 2c
AS3 1c
other
2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-131
Path attributes and BGP
routes
advertised prefix includes BGP attributes
prefix + attributes = “route”
two important attributes:
AS-PATH: contains ASs through which prefix
advertisement has passed: e.g., AS 67, AS 17
NEXT-HOP: indicates specific internal-AS router to
next-hop AS. (may be multiple links from current AS
to next-hop-AS)
gateway router receiving route advertisement
uses import policy to accept/decline
e.g., never route through AS x
policy-based routing
routing algorithms
Assume prefix is
entry
local forwarding table
prefix output port
in another AS.
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 2c
AS3 1c
other
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 2c
AS3 1c
other
2a networks
other 1a 2b
networks 1b AS2
AS1 1d
3c router
3a port
3b 2c
AS3 1 other
2 1c
4 2a networks
other 3 2b
networks
1a 1b
1d AS2
AS1
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
3c AS3 AS201 since it is closer
3a
3b 2c
AS3 1c
other
2a networks
other 1a 2b
networks 1b AS2
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: provider
B network
X
W A
customer
C network:
Y
R3 R4 R3 R4
source in-network
duplication duplication
source duplication: how does source
determine recipient addresses?
Network Layer 4-149
In-network duplication
flooding: when node receives broadcast
packet, sends copy to all neighbors
problems: cycles & broadcast storm
controlled flooding: node only broadcasts pkt
if it hasn’t broadcast same packet before
node keeps track of packet ids already broadacsted
or reverse path forwarding (RPF): only forward
packet if it arrived on shortest path between node
and source
spanning tree:
no redundant packets received by any node
B B
c c
D D
F E F E
G G
(a) broadcast initiated at A (b) broadcast initiated at D
dense: sparse:
group members # networks with group
densely packed, in members small wrt #
“close” proximity. interconnected
networks
bandwidth more
plentiful group members “widely
dispersed”
bandwidth not plentiful
Network Layer 4-165
Consequences of sparse-dense
dichotomy:
dense sparse:
group membership by no membership until
routers assumed until routers explicitly join
routers explicitly receiver- driven
prune construction of mcast
data-driven tree (e.g., center-
construction on mcast based)
tree (e.g., RPF) bandwidth and non-
bandwidth and non- group-router
group-router processing
processing profligate conservative