Class 4 – Network layer
Instructor Materials
Introduction to Networks v7.0
(ITN)
Learning Targets for today’s lesson…
1. Understand the service model of the network layer and explain the its
three key functions
2. Understand IP address format, the differences between IPv4 and IPv6
and how interworking is performed
3. Understand the basics of DHCP and NAT
4. Calculate Subnet addresses, identify and calculate subnet masks and
understand how they are used in IP routing
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2
Reminder… We
Away are
Pizza her 5
application
Sausage e
Throw transport 4
Not
Do Internet network 3
Please
link 2
Netwo
rk physical 1
Acces
s
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 3
Architectural Principles of the Internet
RFC 1958
“Many members of the Internet community would argue that there is no architecture, but only a tradition,
which was not written down for the first 25 years (or at least not by the IAB). However, in very general terms,
the goal is connectivity, the tool is the Internet
the community believes that
Protocol, and the intelligence is end to end rather than hidden in the
network.”
HTTP SMTP RTP …
QUIC DASH
Three cornerstone beliefs: TCP UDP
simple connectivity IP
intelligence, complexity at network edge Etherne … PPP
IP protocol: that narrow waist tWiF
i
Bluetooth
copper radio fiber
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 4
Network Layer Characteristics
The Network Layer
• Provides services to allow end devices to exchange The Service Model:
data
• IP version 4 and IP version 6 are the principal
network layer communication protocols.
• Connectionless
End-to-end delivery of
?
packets between
• Media Independent (establishes MTU from Link Layer info) sending and receiving
• Best Effort hosts
• Basic operations of the network layer:
1. Encapsulation and De-encapsulation
2. Addressing end devices
3. Forwarding and Routing
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 5
Basic operations of the network layer:
1. Encapsulation and De-encapsulation
2. Addressing end devices
1. Addressing format
2. DHCP
3. Subnetting
4. NAT
3. Forwarding and Routing Tomorrow
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 6
IP addressing: introduction
[Link]
IP address: 32-bit identifier associated with
[Link]
each host or router interface
[Link]
interface: connection between host/router [Link] [Link]
and physical link
router’s typically have multiple interfaces [Link]
[Link]
[Link]
host typically has one or two interfaces
(e.g., wired Ethernet, wireless 802.11)
IP addresses have a hierarchy: [Link] [Link]
A subnet part (higher order bits)
A host part (lower order bits)
dotted-decimal IP address notation:
A special IP Address: [Link] [Link] = 11011111 00000001 00000001 00000001
Can you guess what it’s for?
223 1 1 1
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 9
IP Datagram format
32 bits
IP protocol version number type of total datagram
ver head. length length (bytes)
header length(bytes) len service
fragment fragmentation/
“type” of service: 16-bit identifier flgs
diffserv (0:5) offset reassembly
ECN (6:7) time to upper header
live layer checksum header checksum
TTL: remaining max hops source IP address 32-bit source IP address
(decremented at each router)
destination IP address 32-bit destination IP address
upper layer protocol (e.g., TCP or UDP)
options (if any) e.g., timestamp, record
overhead route taken
20 bytes of TCP payload data
20 bytes of IP (variable length, Maximum length: 64K bytes
= 40 bytes + app typically a TCP Typically: 1500 bytes or less
layer overhead for or UDP segment)
TCP+IP © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 10
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”
"Who the hell knew how much address space we needed?" Vint Cerf (reflecting on
decision to make IPv4 address 32 bits long)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 11
IPv6 datagram format
32 bits
(4 bits) set to 6 (20 bits) identify
for IPV6.. BUT datagrams in same
not 4 for IPV4!! "flow.” (concept of
“flow” not well
defined).
128-bit
IPv6 addresses
What’s missing (compared with IPv4):
no checksum (to speed processing at routers)
no fragmentation/reassembly
no options (available as upper-layer, next-header protocol at router)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 12
Types of IPv6 addresses
Globally
routable
and
reachable in
the IPv6
internet
[Link]
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 13
9780134670584/[Link]
IPv6: adoption ACTIVITY
1. What is the global adoption of IPV6 connectivity
of Google’s users today?
2. What is the adoption in Canada?
3. In the US?
4. In France?
[Link]
[Link] © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 14
Transitioning from IPv4 to IPv6…
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 15
Transition from IPv4 to IPv6
not all routers can be upgraded simultaneously
- no “Day H”: 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”)
IPv4 header fields IPv6 header fields
IPv4 payload
IPv4 source, dest addr IPv6 source dest addr
UDP/TCP payload
IPv6 datagram
IPv4 datagram © 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 16
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
flow: X src:B src:B src:B flow: X
src: A dest: E dest: E src: A
dest: F
dest: E
dest: F
Flow: X Flow: X Flow: X
Src: A Src: A Src: A
Note source data Dest: F Dest: F Dest: F data
and destination
addresses! data data data
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
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 17
IP addressing...
Q: how does an ISP get block of Q: are there enough 32-bit IP
addresses? addresses?
A: ICANN: Internet Corporation for ICANN allocated last chunk of
Assigned Names and Numbers IPv4 addresses to RRs in 2011
[Link] NAT (next) helps IPv4 address
• allocates IP addresses, through 5 space exhaustion
regional registries (RRs) (who may
then allocate to local registries)
IPv6 has 128-bit address space
• manages DNS root zone, including
delegation of individual TLD (.com,
.edu , …) management
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 18
IP addresses: how to get one?
That’s actually two questions:
1. Q: How does a host get IP address within its network (host part of
address)?
2. Q: How does a network get IP address for itself (network part of
address)
How does host get IP address?
hard-coded by sysadmin in config file (e.g., /etc/[Link] in UNIX)
DHCP: Dynamic Host Configuration Protocol: dynamically get address
from as server - “plug-and-play” = “zero-conf”
IPV6 hosts – Stateless Address Autoconfiguration (SLAAC)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 19
Basic operations of the network layer:
1. Encapsulation and De-encapsulation
2. Addressing end devices
1. Addressing format
2. DHCP
3. Subnetting
4. NAT
3. Forwarding and Routing
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 20
DHCP: Dynamic Host Configuration Protocol
goal: host dynamically obtains IP address from network server when it “joins”
network
can renew its lease on address in use
allows reuse of addresses (only hold address while
connected/on)
support for mobile users who join/leave network
DHCP overview:
host broadcasts DHCP discover msg [optional]
DHCP server responds with DHCP offer msg [optional]
host requests IP address: DHCP request msg
DHCP server sends address: DHCP ack msg
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 21
Network Layer: 4-21
DHCP client-server scenario
Typically, DHCP server will be co-
DHCP located in router, serving all
[Link] server subnets to which router is attached
[Link]
[Link]
[Link]
[Link] [Link]
[Link]
[Link] arriving DHCP client needs
[Link] address in this network
[Link] [Link]
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 22
DHCP client-server scenario
DHCP server: [Link] DHCP discover Arriving client
src : [Link], 68
Broadcast: is there a
dest.: [Link],67
DHCP server
yiaddr: 0.0.0.0out
transaction
there? ID: 654
DHCP offer
src: [Link], 67
Broadcast:
dest: I’m 68
[Link], a
DHCP server! Here’s
yiaddr: [Link]
transaction ID: 654
an IP address you can
lifetime: 3600 secs
The two steps above can
DHCP request use be skipped “if a client
src: [Link], 68 remembers and wishes to
dest::
Broadcast:[Link],
OK. I would67 reuse a previously
yiaddr: [Link] allocated network
like to useID:
transaction this
655 IP
address!
lifetime: 3600 secs address” [RFC 2131]
DHCP ACK
src: [Link], 67
dest: [Link], 68
Broadcast:
yiaddr: [Link]
OK.
You’ve gotID:that
655 IP
yiaddr = your internet transaction
address!
lifetime: 3600 secs
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 23
address
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)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 24
Network Layer: 4-24
Basic operations of the network layer:
1. Encapsulation and De-encapsulation
2. Addressing end devices
1. Addressing format
2. DHCP
3. Subnetting
4. NAT
3. Forwarding and Routing
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 27
Subnets IPv4
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 28
Subnets IPv4
Private IPs Ranges
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 29
Subnets IPv4
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 30
Subnets
[Link]
What’s a subnet ? [Link]
• device interfaces that can [Link]
[Link] [Link]
physically reach each other
without passing through an [Link]
[Link]
intervening router [Link]
IP addresses have structure:
• subnet part: devices in same subnet [Link] [Link]
have common high order bits
• host part: remaining low order bits network consisting of 3 subnets
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 31
Subnets subnet [Link]/24
subnet [Link]/24
Recipe for defining subnets:
[Link]
[Link]
detach each interface from its [Link] [Link]
[Link]
host or router, creating
“islands” of isolated networks [Link] [Link]
[Link]
each isolated network is
subnet
called a subnet [Link]/24 [Link] [Link]
subnet mask: /24
(high-order 24 bits: subnet part of IP address)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 32
Subnets [Link]
subnet 223.1.1/24
[Link]
Not just for [Link]
Ethernet LANS with [Link]
hosts
[Link] [Link]
Interconnected subnet 223.1.9/24
subnet 223.1.7/24
routers can also
form subnets! [Link] [Link]
[Link] [Link]
subnet 223.1.2/24 [Link] subnet 223.1.8/24 [Link]
subnet 223.1.3/24
[Link] [Link] [Link] [Link]
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 33
IP addressing: CIDR
CIDR: Classless InterDomain Routing (pronounced “cider”)
• subnet portion of address of arbitrary length
• address format: a.b.c.d/x, where x is # bits in subnet portion of
address subnet host
part part
11001000 00010111 00010000 00000000
[Link]/23
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 34
Network Layer: 4-34
IPv4 Classless example ACTIVITY
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 35
Why longest matching is important
What if Fly-by-night ISP
purchases ISPs-R-Us and
transfers Organization 1 to
ISPs-R-US’s organization?
ISP’s-R-US advertises their
own IP prefix, as well as the
IP prefix of Organization 1
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 36
Subnet an IPv6 Network
IPv6 was designed with subnetting in mind.
• A separate subnet ID field in the IPv6 GUA is used to create subnets.
• The subnet ID field is the area between the Global Routing Prefix and the interface
ID.
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 37
IPv6 Subnetting Example
Given the 2001:db8:acad::/48 global
routing prefix with a 16 bit subnet ID.
• Allows 65,536 /64 subnets
• The global routing prefix is the
same for all subnets.
• Only the subnet ID hextet is
incremented in hexadecimal for
each subnet.
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 38
Subnet an IPv6 Network
IPv6 Subnet Allocation
The example topology requires five subnets, one for each LAN as well as for the serial link
between R1 and R2.
The five IPv6 subnets were allocated, with the subnet ID field 0001 through 0005. Each /64
subnet will provide more addresses than will ever be needed.
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 39
Subnetting activity ACTIVITY
[Link]
• [Link]
[Link] – [Link] (65,536 IP
addresses)
• [Link] – [Link] (1,048,576 IP
addresses)
• [Link] – [Link] (16,777,216 IP
addresses)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 40
NAT
Computer Networking: a Top-Down Approach (
J.F. Kurose, K.W. Ross, Pearson, 2020
[Link]
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 41
NAT: network address translation
NAT: all devices in local network share just one IPv4 address as
far as outside world is concerned
rest of local network (e.g., home
Internet network) 10.0.0/24
[Link]
[Link] [Link]
[Link]
[Link]
all datagrams leaving local network have datagrams with source or destination in
same source NAT IP address: [Link], this network have 10.0.0/24 address for
but different source port numbers source, destination (as usual)
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 42
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
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 43
Network Layer: 4-43
NAT: network address translation
implementation: NAT router must (transparently):
outgoing datagrams: replace (source IP address, port #) of every
outgoing datagram to (NAT IP address, new port #)
• remote clients/servers will respond using (NAT IP address, new port
#) as destination address
remember (in NAT translation table) every (source IP address, port #) to
(NAT IP address, new port #) translation pair
incoming datagrams: replace (NAT IP address, new port #) in destination
fields of every incoming datagram with corresponding (source IP
address, port #) stored in NAT table
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 44
NAT: network address translation
NAT translation table
2: NAT router changes 1: host [Link] sends
WAN side addr LAN side addr datagram to
datagram source address
from [Link], 3345 to [Link], 5001 [Link], 3345 [Link], 80
[Link], 5001, …… ……
updates table
S: [Link], 3345
D: [Link], 80
[Link]
1
S: [Link], 5001
2 D: [Link], 80 [Link]
[Link]
[Link] S: [Link], 80
D: [Link], 3345
4
S: [Link], 80 [Link]
D: [Link], 5001 3
3: reply arrives, destination
address: [Link], 5001
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 45
Thanks
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 46