Chapter 4
Network Layer
Computer
Networking: A
Top Down
Approach
6th edition
Jim Kurose, Keith
Ross
Addison-Wesley
March 2012
Network Layer 4-1
Connection setup
One important function in some network
architectures:
ATM, frame relay, X.25
before datagrams flow, two end hosts and
intervening routers establish virtual
connection
routers get involved
network vs transport layer connection
service:
network: between two hosts (may also involve
intervening routers in case of VCs)
transport: between two processes
Network Layer 4-2
Connection, connection-less
service
datagram network provides network-
layer connectionless service
virtual-circuit network provides network-
layer connection service
analogous to TCP/UDP connecton-
oriented / connectionless transport-
layer services, but:
service: host-to-host
no choice: network provides one or
the other
implementation: in network core
Network Layer 4-3
Virtual circuits
“source-to-dest path behaves much like
telephone circuit”
performance-wise
network actions along source-to-dest path
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)
Network Layer 4-4
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
Network Layer 4-5
VC forwarding table
12 22 32
1 3
2
VC number
interface
forwarding table in number
northwest router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
C routers maintain connection state informatio
Network Layer 4-6
Virtual circuits: signaling
protocols
used to setup, maintain teardown VC
used in ATM, frame-relay, X.25
not used in today’s Internet
Network Layer 4-7
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
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
Network Layer 4-8
Datagram forwarding
table
4 billion IP
routing algorithm addresses, so rather
than list individual
local forwarding table
destination address
dest address output list range of
address-range 1 3 link
addresses
address-range 2 2 (aggregate table
address-range 3
address-range 4
2
1
entries)
IP destination address in
arriving packet’s header
1
3 2
Network Layer 4-9
Datagram forwarding
table
Destination Address Range Link Interface
11001000 00010111 00010000 00000000
through 0
11001000 00010111 00010111 11111111
11001000 00010111 00011000 00000000
through 1
11001000 00010111 00011000 11111111
11001000 00010111 00011001 00000000
through 2
11001000 00010111 00011111 11111111
otherwise 3
: but what happens if ranges don’t divide up so nicely?
Network Layer 4-10
Longest prefix matching
longest prefix matching
when looking for forwarding table entry
for given destination address, use longest
address prefix that matches destination
address.
Destination Address Range Link interface
11001000 00010111 00010*** ********* 0
11001000 00010111 00011000 ********* 1
11001000 00010111 00011*** ********* 2
otherwise 3
examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 which interface?
Network Layer 4-11
Datagram or VC network:
why?
Internet (datagram) ATM (VC)
data exchange among evolved from
computers telephony
“elastic” service, no human conversation:
strict timing req. strict timing, reliability
requirements
many link types need for guaranteed
different characteristics service
uniform service difficult “dumb” end systems
“smart” end systems telephones
(computers) complexity inside
can adapt, perform network
control, error recovery
simple inside
network, complexity
at “edge”
Network Layer 4-12
The Internet network layer
host, router network layer functions:
transport layer: TCP, UDP
routing protocols IP protocol
• path selection
• addressing conventions
• datagram format
• RIP, OSPF, BGP
network • packet handling conventions
layer forwarding
table
ICMP
protocol
• error reporting
• router “signaling”
link layer
physical layer
Network Layer 4-13
IP datagram format
IP protocol version 32 bits
number total datagram
header length type of length (bytes)
ver head. length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much overhead? data taken, specify
20 bytes of TCP (variable length, list of routers
20 bytes of IP
typically a TCP to visit.
= 40 bytes + app
or UDP segment)
layer overhead
Network Layer 4-14
IP fragmentation,
reassembly
network links have MTU
(max.transfer size) -
largest possible link-
level frame fragmentation:
…
different link types, in: one large datagram
out: 3 smaller datagrams
different MTUs
large IP datagram
divided (“fragmented”)
within net reassembly
one datagram
becomes several
datagrams
“reassembled” only
…
at final destination
IP header bits used to
identify, order related
fragments
Network Layer 4-15
IP fragmentation,
reassembly
length ID fragflag offset
example: =4000 =x =0 =0
4000 byte
datagram one large datagram becomes
several smaller datagrams
MTU = 1500
bytes
1480 bytes in length ID fragflag offset
data field =1500 =x =1 =0
offset = length ID fragflag offset
1480/8 =1500 =x =1 =185
length ID fragflag offset
=1040 =x =0 =370
Network Layer 4-16
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
IPv6 datagram format:
fixed-length 40 byte header
no fragmentation allowed
Network Layer 4-17
IPv6 datagram format
riority: identify priority among datagrams in flow
ow Label: identify datagrams in same “flow.”
(concept of“flow” not well defined).
ext header: identify upper layer protocol for data
ver pri flow label
payload len next hdr hop limit
source address
(128 bits)
destination address
(128 bits)
data
32 bits
Network Layer 4-18
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
Network Layer 4-19
Interplay between routing,
forwarding
routing algorithm determines
routing algorithm
end-end-path through network
forwarding table determines
local forwarding table
local forwarding at this router
dest address output
address-range 1 3 link
address-range 2 2
address-range 3 2
address-range 4 1
IP destination address in
arriving packet’s header
1
3 2
Network Layer 4-20
Types of Routing
Static Routing
Manually routing information needs to
be added in each router
Dynamic Routing
Routers dynamically exchange routing
information and periodically updates
the routing information
RIP, BGP,OSPF
Network Layer 4-21