Professional Documents
Culture Documents
CSE 3711 Lecture-No. 5 (Summer 2023)
CSE 3711 Lecture-No. 5 (Summer 2023)
Network Layer
(Sec – 4.1, 4.3, & 5.2)
Instructor: Mohammad Mamun Elahi
Office: 5th Floor (Room # 522)
Email: mmelahi@cse.uiu.ac.bd Computer
Class Location: http://meet.google.com/rca-cwkd-cmh Networking: A Top
Lectures: S W 12:10 pm (Sec A), 2-00 pm (Sec C) Down Approach
Notes derived from “Computer Networking: A Top 7th edition
Down Approach”, Jim Kurose, Keith Ross, Jim Kurose, Keith Ross
Addison-Wesley. Addison-Wesley
March 2017
Slides are adapted from the companion web site of
the book, as modified by A.K.M. Muzahidul
Islam.
Introduction1-1
Network-layer services and protocols
transport segment from sending mobile network
routers: link
physical
datacenter
network
forwarding
routing
Network Layer: 4-3
Network layer: data plane, control plane
The network layer can be decomposed into two interacting parts:
• The data plane and the control plane.
Data plane: Control plane
local, per-router function network-wide logic
Determines how datagram Determines how datagram is
arriving on router input port is routed among routers along end-
forwarded to router output port. end path from source host to
destination host
values in arriving
Two control-plane approaches:
packet header
• traditional routing algorithms:
0111 1 implemented in routers
3
2 • software-defined networking (SDN):
implemented in (remote) serversNetwork Layer: 4-4
Input port functions
lookup,
link
layer forwarding
line switch
protocol fabric
termination
(receive)
queueing
physical layer:
bit-level reception
decentralized switching:
link layer:
using header field values, lookup output port using
e.g., Ethernet
forwarding table in input port memory (“match plus action”)
(chapter 6)
destination-based forwarding: forward based only on
destination IP address (traditional)
generalized forwarding: forward based on any set of header
field values Network Layer: 4-5
• The Internet Control Message Protocol (ICMP) is a
network layer protocol used by network devices to diagnose
Path-selection
IP protocol
• datagram format
algorithms: • addressing
network implemented in • packet handling conventions
• routing protocols forwarding
layer (OSPF, BGP) table ICMP protocol
• SDN controller •used by network devices
• error reporting
• router “signaling”
link layer
physical layer
Network Layer: 4-6
IP Datagram format
32 bits
IP protocol version number total datagram
ver head. type of length length (bytes)
header length(bytes) len service
fragment fragmentation/
“type” of service: 16-bit identifier flgs
diffserv (0:5) offset reassembly
time to upper header
ECN (6:7) header checksum
live layer checksum
TTL: remaining max hops source IP address 32-bit source IP address
(decremented at each router)
Maximum length: 64K bytes
destination IP address 32-bit destination IP address
upper layer protocol (e.g., TCP or UDP) Typically: 1500 bytes or less
options (if any) e.g., timestamp, record
overhead route taken
20 bytes of TCP payload data
20 bytes of IP (variable length,
= 40 bytes + app typically a TCP
layer overhead for or UDP segment)
TCP+IP
Network Layer: 4-7
DHCP: Dynamic Host Configuration
Protocol
Obtaining a Host Address: The Dynamic Host Configuration Protocol Once an organization
has obtained a block of addresses, it can assign individual IP addresses to the host and
router interfaces in its organization.
A system administrator will typically manually configure the IP addresses into the router
(often remotely, with a network management tool). Host addresses can also be configured
manually, but typically this is done using the Dynamic Host Configuration Protocol (DHCP)
[RFC 2131].
DHCP allows a host to obtain (be allocated) an IP address automatically. A network
administrator can configure DHCP so that a given host receives the same IP address each
time it connects to the network, or a host may be assigned a temporary IP address that
will be different each time the host connects to the network.
In addition to host IP address assignment, DHCP also allows a host to learn additional
information, such as its subnet mask, the address of its first-hop router (often called the
default gateway), and the address of its local DNS server.
10.0.0.1
138.76.29.7 10.0.0.4
10.0.0.2
10.0.0.3
all datagrams leaving local network have datagrams with source or destination in
same source NAT IP address: 138.76.29.7, this network have 10.0.0/24 address for
but different source port numbers source, destination (as usual)
Network Layer: 4-11
NAT: network address translation
all devices in local network have 32-bit addresses in a “private” IP
address space (10/8, 172.16/12, 192.168/16 prefixes) that can only
be used in local network
advantages:
just one IP address needed from provider ISP for all devices
can change addresses of host in local network without notifying
outside world
can change ISP without changing addresses of devices in local
network
security: devices inside local net not directly addressable, visible
by outside world
1 10.0.0.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 10.0.0.3
D: 138.76.29.7, 5001 3
S:
D: 4
…
in: one large datagram
• different link types, different MTUs out: 3 smaller datagrams
…
• IP header bits used to identify, order
related fragments
Limitations of IPv4
IPv4 has three major limitations:
• IPv4 address depletion – We have basically run out of IPv4 addressing.
• Lack of end-to-end connectivity – To make IPv4 survive this long, private addressing
and NAT were created. This ended direct communications with public addressing.
• Increased network complexity – NAT was meant as temporary solution and creates
issues on the network as a side effect of manipulating the network headers
addressing. NAT causes latency and troubleshooting issues.
IPv6: motivation
initial motivation: 32-bit IPv4 address space would be
completely allocated
additional motivation:
• speed processing/forwarding: 40-byte fixed length header
• enable different network-layer treatment of “flows”
payload (data)
Payload Length This 16-bit field indicates the length of the data portion or payload of
the IPv6 packet
Next Header I.D.s next level protocol: ICMP, TCP, UDP, etc.
Hop Limit Replaces TTL field Layer 3 hop count
Source IPv4 Address 128 bit source address
Note: This rule only applies to leading 0s, NOT to trailing 0s, otherwise the address would be
ambiguous.
Type Format
A double colon (::) can replace any single, contiguous string of one or
more 16-bit hextets consisting of all zeros.
Example:
• 2001:db8:cafe:1:0:0:0:1 (leading 0s omitted) could be represented as 2001:db8:cafe:1::1
Note: The double colon (::) can only be used once within an address, otherwise there would be
more than one possible resulting address.
Type Format
Preferred 2001 : 0db8 : 0000 : 1111 : 0000 : 0000 : 0000 : 0200
Compressed 2001:db8:0:1111::200
IPv4 Issues
IPv4 and IPv6 Coexistence
Both IPv4 and IPv6 will coexist in the near future and the transition will take several years.
The IETF has created various protocols and tools to help network administrators migrate their
networks to IPv6. These migration techniques can be divided into three categories:
• Dual stack -The devices run both IPv4 and IPv6 protocol stacks simultaneously.
• Tunneling – A method of transporting an IPv6 packet over an IPv4 network. The
IPv6 packet is encapsulated inside an IPv4 packet.
• Translation - Network Address Translation 64 (NAT64) allows IPv6-enabled
devices to communicate with IPv4-enabled devices using a translation
technique similar to NAT for IPv4.
Transition from IPv4 to IPv6
not all routers can be upgraded simultaneously
• no “flag days”
• how will network operate with mixed IPv4 and IPv6 routers?
tunneling: IPv6 datagram carried as payload in IPv4 datagram among
IPv4 routers (“packet within a packet”)
• tunneling used extensively in other contexts (4G/5G)
IPv6 datagram
IPv4 datagram
Network Layer: 4-30
Tunneling
A B IPv4 tunnel E F
connecting IPv6 routers
logical view:
IPv6 IPv6/v4 IPv6/v4 IPv6
A B C D E F
physical view:
IPv6 IPv6/v4 IPv4 IPv4 IPv6/v4 IPv6
A-to-B: E-to-F:
B-to-C: B-to-C: B-to-C:
IPv6 IPv6
IPv6 inside IPv6 inside IPv6 inside
IPv4 IPv4 IPv4
Network Layer: 4-31
Tunneling – Cont’d
Suppose two IPv6 nodes (in this example, B and E in Figure 4.27) want to interoperate using
IPv6 datagrams but are connected to each other by intervening IPv4 routers.
The intervening set of IPv4 routers between two IPv6 routers referred as a tunnel.
With tunneling, the IPv6 node on the sending side of the tunnel (in this example, B) takes the
entire IPv6 datagram and puts it in the data (payload) field of an IPv4 datagram.
This IPv4 datagram is then addressed to the IPv6 node on the receiving side of the tunnel (in
this example, E) and sent to the first node in the tunnel (in this example, C).
The intervening IPv4 routers in the tunnel route this IPv4 datagram among themselves, just as
they would any other datagram, blissfully unaware that the IPv4 datagram itself contains a
complete IPv6 datagram.
The IPv6 node on the receiving side of the tunnel eventually receives the IPv4 datagram (it is
the destination of the IPv4 datagram!), determines that the IPv4 datagram contains an IPv6
datagram (by observing that the protocol number field in the IPv4 datagram is 41 [RFC 4213],
indicating that
• the IPv4 payload is a IPv6 datagram),
• extracts the IPv6 datagram, and
• then routes the IPv6 datagram exactly as it would if it had received the IPv6 datagram from a directlyNetwork Layer: 4-32
IPv6: adoption
Google1: ~ 30% of clients access services via IPv6
NIST: 1/3 of all US government domains are IPv6 capable
https://www.google.com/intl
/en/ipv6/statistics.html
Network Layer: 4-33
IPv6: adoption
Google1: ~ 30% of clients access services via IPv6
NIST: 1/3 of all US government domains are IPv6 capable
Long (long!) time for deployment, use
• 25 years and counting!
• think of application-level changes in last 25 years: WWW, social
media, streaming media, gaming, telepresence, …
• Why?
1
https://www.google.com/intl/en/ipv6/statistics.html
Network Layer: 4-34
Network-layer functions
forwarding: move packets from router’s
input to appropriate router output data plane
routing: determine route taken by
packets from source to destination
control plane
congested” application
transport
routing: a “top-10” networking enterprise
network
link
5 uwxvyz v
notes:
construct least-cost-path tree by tracing predecessor nodes
ties can exist (can be broken arbitrarily)
Network Layer: 5-44
Distance vector algorithm
Dynamic Routing Algorithm.
Find least cost from Source to Destination.
Based on Bellman-Ford (BF) equation (dynamic programming):
• One Routing Table is Created per Node
Bellman-Ford equation
Defines distance at each node.
Let Dx(y): cost of least-cost path from x to y.
Then:
Dx(y) = minv { cx,v + Dv(y) }
Source Destination v’s estimated least-cost-path cost to y
direct cost of link from x to v
min taken over all neighbors v of x
Bellman-Ford Example
Suppose that u’s neighboring nodes, x,v,w, know that for destination z:
Dv(z) = 5 Dw(z) = 3 Bellman-Ford equation says:
5
Du(z) = min { cu,v + Dv(z),
3 w
v 5 cu,x + Dx(z),
2
u 2 1 z cu,w + Dw(z) }
3
1 2
= min {2 + 5,
x 1
y 1 + 3,
5 + 3} = 4
Dx(z) = 3
node achieving minimum (x) is
next hop on estimated least-
Du(Z) = minp { cu,p + Dp(y) } cost path to destination (z)
Network Layer: 5-46
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 any neighbor, it updates its
own DV using B-F equation:
Dx(y) ← minv{cx,v + Dv(y)} for each node y ∊ N
t=0 Da(e) = ∞
Da(f) = ∞ 1 1
Da(g) = ∞
All nodes have
Da(h) = ∞
distance estimates
Da(i) = ∞ A few asymmetries:
to nearest d e f missing link
neighbors (only) 1 1
larger cost
All nodes send
their local
distance vector to 1 1 1
their neighbors
g h i
1 1
a b c
8 1
t=1 1 1
All nodes:
receive distance
vectors from
neighbors d e f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g h i
1 1
a
compute compute
b compute
c
8 1
t=1 1 1
All nodes:
receive distance
vectors from
neighbors d
compute compute
e compute
f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g
compute h
compute compute
i
1 1
a b c
8 1
t=1 1 1
All nodes:
receive distance
vectors from
neighbors d e f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g h i
1 1
a b c
8 1
t=2 1 1
All nodes:
receive distance
vectors from
neighbors d e f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g h i
1 1
compute
a compute
b compute
c
2 1
t=2 1 1
All nodes:
receive distance
vectors from
neighbors d
compute compute
e compute
f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g
compute compute
h compute
i
8 1
a b c
8 1
t=2 1 1
All nodes:
receive distance
vectors from
neighbors d e f
compute their new 1 1
local distance
vector
send their new 1 1 1
local distance
vector to neighbors
g h i
1 1
…. and so on
t=1 Da(e) = ∞
Da(f) = ∞ 1 1
Dc(h) = ∞
Dc(i) = ∞
b receives DVs Da(g) = ∞ DV in e:
from a, c, e Da(h) = ∞ De(a) = ∞
Da(i) = ∞ De(b) = 1
d e f De(c) = ∞
1 1
De(d) = 1
De(e) = 0
De(f) = 1
1 1 1
De(g) = ∞
De(h) = 1
De(i) = ∞
g h i
1 1
t=1 Da(e) = ∞
Da(f) = ∞ 1 1
Dc(h) = ∞
Dc(i) = ∞
b receives DVs Da(g) = ∞ DV in e:
from a, c, e, Da(h) = ∞ De(a) = ∞
computes: e
Da(i) = ∞ De(b) = 1
d e f De(c) = ∞
1
Db(a) = min{cb,a+Da(a), cb,c +Dc(a), cb,e+De(a)} = min{8,∞,∞} =8 1
De(d) = 1
Db(c) = min{cb,a+Da(c), cb,c +Dc(c), c b,e +De(c)} = min{∞,1,∞} = 1
De(e) = 0
Db(d) = min{cb,a+Da(d), cb,c +Dc(d), c b,e +De(d)} = min{9,2,∞} = 2 De(f) = 1
1 1 1
Db(e) = min{cb,a+Da(e), cb,c +Dc(e), c b,e +De(e)} = min{∞,∞,1} = 1 De(g) = ∞
Db(f) = min{cb,a+Da(f), cb,c +Dc(f), c b,e +De(f)} = min{∞,∞,2} = 2
DV in b: De(h) = 1
Db(g) = min{cb,a+Da(g), cb,c +Dc(g), c b,e+De(g)} = min{∞, ∞, ∞} = ∞ Db(a) = 8 Db(f) =2 De(i) = ∞
g h 1Db(c) = 1 Db(g)i = ∞
1 ∞, 2} = 2
Db(h) = min{cb,a+Da(h), cb,c +Dc(h), c b,e+De(h)} = min{∞,
Db(d) = 2 Db(h) = 2
Db(i) = min{cb,a+Da(i), cb,c +Dc(i), c b,e+De(i)} = min{∞, ∞, ∞} = ∞ Db(e) = 1 Db(i) = ∞
Network Layer: 5-58
DV in c:
Distance vector example: computation DV in b:
Db(a) = 8 Db(f) = ∞
Dc(a) = ∞
Db(c) = 1 Db(g) = ∞ Dc(b) = 1
DV in a: Db(d) = ∞ Db(h) = ∞ Dc(c) = 0
Da(a)=0 Db(e) = 1 Db(i) = ∞ Dc(d) = ∞
Da(b) = 8 Dc(e) = ∞
Da(c) = ∞ a b c Dc(f) = ∞
8 1
Da(d) = 1 Dc(g) = ∞
t=1 Da(e) = ∞
Da(f) = ∞ 1 1
Dc(h) = ∞
Dc(i) = ∞
c receives DVs Da(g) = ∞ DV in e:
from b Da(h) = ∞ De(a) = ∞
Da(i) = ∞ De(b) = 1
d e f De(c) = ∞
1 1
De(d) = 1
De(e) = 0
De(f) = 1
1 1 1
De(g) = ∞
De(h) = 1
De(i) = ∞
g h i
1 1
t=1 1 1
Dc(h) = ∞
Dc(i) = ∞
c receives DVs
from b computes:
d b(a}} = 1 + 8 = 9
Dc(a) = min{cc,b+D e f
DV in c:
Dc(b) = min{cc,b+Db(b)} = 1 + 0 = 1
Dc(a) = 9
Dc(d) = min{cc,b+Db(d)} = 1+ ∞ = ∞ Dc(b) = 1
Dc(e) = min{cc,b+Db(e)} = 1 + 1 = 2 Dc(c) = 0
Dc(f) = min{cc,b+Db(f)} = 1+ ∞ = ∞ Dc(d) = 2
Dc(g) = min{cc,b+Db(g)} = 1+ ∞ = ∞ Dc(e) = ∞ * Check out the online interactive
Dc(f) = ∞ exercises for more examples:
g b(h)} = 1+ ∞ = ∞
Dc(h) = min{cbc,b+D h i http://gaia.cs.umass.edu/kurose_ross/interactive/
Dc(g) = ∞
Dc(i) = min{cc,b+Db(i)} = 1+ ∞ = ∞
Dc(h) = ∞
Network Layer: 5-60
Dc(i) = ∞
Distance vector example: computation DV in b:
Db(a) = 8 Db(f) = ∞
Db(c) = 1 Db(g) = ∞
Db(d) = ∞ Db(h) = ∞ DV in e:
DV in d:
Db(e) = 1 Db(i) = ∞ De(a) = ∞
Dc(a) = 1
De(b) = 1
Dc(b) = ∞ a b c De(c) = ∞
Dc(c) = ∞ 8 1
De(d) = 1
Dc(d) = 0
t=1 Dc(e) = 1
1
Q: what is new DV computed in e at
1t=1?
De(e) = 0
De(f) = 1
e receives DVs Dc(f) = ∞
De(g) = ∞
from b, d, f, h Dc(g) = 1
De(h) = 1
Dc(h) = ∞
De(i) = ∞
Dc(i) = ∞ d compute
e f DV in f:
1 1
DV in h: Dc(a) = ∞
Dc(a) = ∞ Dc(b) = ∞
Dc(b) = ∞ Dc(c) = ∞
Dc(c) = ∞ 1 1 1
Dc(d) = ∞
Dc(d) = ∞ Dc(e) = 1
Dc(e) = 1 Dc(f) = 0
Dc(f) = ∞ g h i Dc(g) = ∞
1 1
Dc(g) = 1 Dc(h) = ∞
Dc(h) = 0 Dc(i) = 1 Network Layer: 5-61
Comparison of LS and DV algorithms
message complexity robustness: what happens if router
LS: n routers, O(n2) messages sent malfunctions, or is compromised?
DV: exchange between neighbors; LS:
convergence time varies • router can advertise incorrect link cost
• each router computes only its own
speed of convergence table
LS: O(n2) algorithm, O(n2) messages DV:
• may have oscillations
• DV router can advertise incorrect path
DV: convergence time varies cost (“I have a really low cost path to
• may have routing loops everywhere”): black-holing
• count-to-infinity problem
• each router’s table used by others:
error propagate thru network
intra-AS
3c
routing3a inter-AS routing intra-AS
2c
3b 2a routing
2b
1c
AS3 intra-AS
1a routing 1b AS2
1d
AS1
3c
3a other
2c
3b 2a networks
2b
1c
AS3
other 1a 1b AS2
networks
1d
AS1