Chapter 4 Network Layer
Chapter 4 Network Layer
Layer
Computer Networking: A Top-Down
Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
01/22/2024 1
Outline
4. 1 Introduction
4.2 Virtual circuit and datagram networks
4.4 IP: Internet Protocol
Datagram format
IPv4 addressing
IPv6
4.5 Routing algorithms
Link state
Distance Vector
Hierarchical routing
01/22/2024 2
Network layer
• transport segment from sending to
receiving host
• on sending side encapsulates
segment into datagrams
• on receiving side, delivers segments
to transport layer
• network layer protocols in every
host, router
• router examines header fields in all
IP datagrams passing through it
01/22/2024 3
Two Key Network-Layer Functions
• Forwarding: move analogy:
packets from router’s • Routing: process of
input to appropriate planning trip from
router output source to dest
• Routing: determine • Forwarding: process
route taken by of getting through
packets from source single interchange
to dest.
* routing algorithms
01/22/2024 4
Interplay between routing and forwarding
01/22/2024 5
Outline
4. 1 Introduction
4.2 Virtual circuit and datagram networks
4.4 IP: Internet Protocol
Datagram format
IPv4 addressing
IPv6
4.5 Routing algorithms
Link state
Distance Vector
Hierarchical routing
01/22/2024 6
Network layer connection and
connection-less service
• datagram network provides network-layer
connectionless service
• VC network provides network-layer
connection service
• analogous to the transport-layer services,
but:
• service: host-to-host
• no choice: network provides one or the other
• implementation: in network core
01/22/2024 7
Virtual circuits
• Call setup, teardown for each call before data can flow
• each packet carries VC identifier (not destination host address) every router
on source-dest path maintains “state” for each passing connection
• link, router resources (bandwidth, buffers) may be allocated to VC
(dedicated resources = predictable service) “source-to-dest path behaves
much like telephone circuit”
• performance-wise
• network actions along source-to-dest path
01/22/2024 8
VC implementation
a VC consists of:
1. path from source to destination
2. VC numbers, one number for each link along
path
3. entries in forwarding tables in routers along
path
• packet belonging to VC carries VC number (rather than dest address)
• VC number can be changed on each link.
• New VC number comes from forwarding table
01/22/2024 9
VC Forwarding
table
• Forwarding table in
northwest router:
01/22/2024 10
Virtual circuits: signaling protocols
• used to setup, maintain teardown VC
• used in ATM, frame-relay, X.25
• not used in today’s Internet
01/22/2024 11
Datagram networks
• no call setup at network layer
• routers: no state about end-to-end connections
• no network-level concept of “connection”
• packets forwarded using destination host address
• packets between same source-dest pair may take different
paths
01/22/2024 12
Datagram Forwarding
table
01/22/2024 13
Datagram Forwarding table
• Q: but what happens if ranges don’t divide up so nicely?
01/22/2024 14
Longest prefix matching
• when looking for forwarding table entry for given destination address, use
longest address prefix that matches destination address.
• Examples: Which interface?
DA: 11001000 00010111 00011000 10101010
DA: 11001000 00010111 00010110 10100001
01/22/2024 15
Outline
4.1 Introduction
4.2 Virtual circuit and datagram networks
4.4 IP: Internet Protocol
Datagram format
IPv4 addressing
IPv6
4.5 Routing algorithms
Link state
Distance Vector
Hierarchical routing
01/22/2024 16
IP datagram format
01/22/2024 17
IP Fragmentation & Reassembly
• network links have MTU
(max.transfer size) - largest possible
link-level frame.
• different link types, different
MTUs
• large IP datagram divided
(fragmented) within net
• one datagram becomes several
datagrams
• “reassembled” only at final
destination
• IP header bits used to identify,
order related fragments
01/22/2024 18
IP Fragmentation and Reassembly
01/22/2024 19
IP Addressing: introduction
• IP address: 32-bit identifier for
host, router interface
• interface: connection between
host/router and physical link
• router’s typically have
multiple interfaces
• host typically has one
interface
• IP addresses associated
with each interface
01/22/2024 20
Network layer
01/22/2024 21
Subnets
IP address:
subnet part (high
order bits)
host part (low order
bits)
What’s a subnet ?
device interfaces with
same subnet part of IP
address
can physically reach
each other without
intervening router
01/22/2024 22
Subnets
• Recipe to determine the
subnets, detach each
interface from its host or
router, creating islands of
isolated networks, each
isolated network is called a
subnet.
01/22/2024 23
Subnets
01/22/2024 24
IP addressing: CIDR
• CIDR: Classless InterDomain Routing
• subnet portion of address of arbitrary length
• address format: a.b.c.d/x, where x is # bits in
subnet portion of address
01/22/2024 25
IP addresses: how to get one?
• Q: How does a host get IP address?
• hard-coded by system admin in a file
• Windows: control-panel->network->configuration->tcp/ip-
>properties
• UNIX: /etc/rc.config
• DHCP: Dynamic Host Configuration Protocol:
• dynamically get address from as server
• “plug-and-play”
01/22/2024 26
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
• ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
• Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23
• Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23
• Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
• ... ….. …. ….
• Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
01/22/2024 27
Hierarchical addressing: route aggregation
• Hierarchical addressing allows efficient advertisement of routing
information:
01/22/2024 28
Hierarchical addressing: more specific routes
• ISPs-R-Us has a more specific route to Organization 1
01/22/2024 29
IP addressing: the last word...
Q: How does an ISP get block of addresses?
A: ICANN: Internet Corporation for Assigned Names and Numbers
• allocates addresses
• manages DNS
• assigns domain names, resolves disputes
01/22/2024 30
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
01/22/2024 31
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
01/22/2024 32
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
01/22/2024 33
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
01/22/2024 34
Tunneling
01/22/2024 35
Tunneling
01/22/2024 36
Outline
4.1 Introduction
4.2 Virtual circuit and datagram networks
4.4 IP: Internet Protocol
Datagram format
IPv4 addressing
IPv6
4.5 Routing algorithms
Link state
Distance Vector
Hierarchical routing
01/22/2024 37
Interplay between routing, forwarding
01/22/2024 38
Graph abstraction
01/22/2024 39
Graph abstraction: costs
01/22/2024 40
Routing Algorithm classification
01/22/2024 42
Dijsktra’s Algorithm
01/22/2024 43
Dijkstra’s algorithm: example
01/22/2024 44
Distance Vector Algorithm
01/22/2024 45
Bellman-Ford example
01/22/2024 46
Finding Shortest Path to Node 1
01/22/2024 47
Comparison of LS and DV algorithms
Message complexity • Robustness: what happens
LS: with n nodes, E links, • if router malfunctions?
O(nE) msgs sent • LS:
DV: exchange between • node can advertise
neighbors only • incorrect link cost
convergence time varies
• each node computes only
Speed of Convergence
• its own table
LS: O(n
• DV:
2
• DV node can advertise
) algorithm requires
• incorrect path cost
O(nE) msgs
• each node’s table used by
may have oscillations
DV: convergence time varies • others
may be routing loops • • error propagate thru
count-to-infinity problem • network
01/22/2024 48
Hierarchical Routing
Our routing study thus far - idealization
all routers identical
network “flat”
… not true in practice
01/22/2024 49
Hierarchical Routing
aggregate routers into gateway router
regions, “autonomous at “edge” of its own AS
systems” (AS) has link to router in
routers in same AS run
another AS
same routing protocol
“intra-AS” routing
protocol
routers in different AS
can run different intra-
AS routing protocol
01/22/2024 50
Internet inter-AS routing: BGP
BGP (Border Gateway Protocol): the de facto
inter-domain routing protocol
“glue that holds the Internet together”
BGP provides each AS a means to:
eBGP: obtain subnet reachability information from
neighboring ASs.
iBGP: propagate reachability information to all AS-
internal routers.
determine “good” routes to other networks based on
reachability information and policy.
allows subnet to advertise its existence to rest of
Internet: “I am here”
01/22/2024 51
Summary
01/22/2024 52