Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012
Network layer
Goals:
understand principles behind network layer
services:
network layer service models
forwarding versus routing
how a router works
routing (path selection)
broadcast, multicast
implementation in the Internet
Outline
Introduction routing algorithms
datagram networks – link state
– distance vector
IP: Internet Protocol
– hierarchical routing
– datagram format
– IPv4 addressing routing in the Internet
– ICMP – RIP
– IPv6 – OSPF
Network layer
application
through it
Two key network-layer functions
• forwarding: move
packets from router’s
input to appropriate
router output
• routing: determine
route taken by
packets from source
to destination
– routing algorithms
Interplay between routing and forwarding
value in arriving
packet’s header
0111 1
3 2
Outline
Introduction routing algorithms
datagram networks – link state
– distance vector
IP: Internet Protocol
– hierarchical routing
– datagram format
– IPv4 addressing routing in the Internet
– ICMP – RIP
– IPv6 – OSPF
– BGP
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
Datagram forwarding table
4 billion IP addresses, so
routing algorithm rather than list individual
destination address
local forwarding table
list range of addresses
dest address output link (aggregate table entries)
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1
IP destination address in
arriving packet’s header
1
3 2
Datagram forwarding table
Destination Address Range Link Interface
otherwise 3
examples:
DA: 11001000 00010111 00010110 10100001 which interface?
DA: 11001000 00010111 00011000 10101010 which interface?
Outline
Introduction routing algorithms
datagram networks – link state
– distance vector
IP: Internet Protocol
– hierarchical routing
– datagram format
– IPv4 addressing routing in the Internet
– ICMP – RIP
– IPv6 – OSPF
– BGP
The Internet network layer
host, router network layer functions:
link layer
physical layer
IP datagram format
IP protocol version 32 bits
number total datagram
header length head. type of length (bytes)
ver service length
(bytes) len
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
(variable length, list of routers
20 bytes of TCP
typically a TCP to visit.
20 bytes of IP
or UDP segment)
= 40 bytes + app
layer overhead
IP fragmentation, reassembly
• network links have MTU
(max.transfer unit) - largest
possible link-level frame fragmentation:
…
– different link types, in: one large datagram
different MTUs out: 3 smaller datagrams
128.10.2.29
IP Address : 32-bit identifier for host/router interface
(decimal notation)
IP addressing: introduction
223.1.1.1
• interface: connection
between host/router and 223.1.1.3
223.1.3.27
Class B 1 0 128.0.0.0 to
Net ID Host ID
191.255.255.255
Class C 1 1 0 192.0.0.0 to
Net ID Host ID
223.255.255.255
Class D 1 1 1 0 224.0.0.0 to
Multicast address 239.255.255.255
IP address:
10101000 11110000 00010100 00100101
Mask:
11111111 11111111 11111111 00000000
Applying Mask:
10101000 11110000 00010100 00000000
00000000
Example Subnet Masks
223.1.1.1 223.1.1.4
how many?
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
172.16.12.12 10.180.30.118
Routing Table
172.16 . 12 . 12 Network Interface
Network Host 172.16.0.0 E0
10.0.0.0 E1
IP Address Classes Exercise
10.2.1.1
128.63.2.100
201.222.5.64
192.6.141.2
130.113.64.16
256.241.201.10
IP Address Classes Exercise Answers
256.241.201.10 Nonexistent
Subnet Mask Exercise
172.16.2.10 255.255.255.0
10.6.24.20 255.255.240.0
10.30.36.12 255.255.255.0
Subnet Mask Exercise Answers
172 16 2 160
201.222.10.60 255.255.255.248
15.16.193.6 255.255.248.0
128.16.32.13 255.255.255.252
153.50.6.27 255.255.255.128
Broadcast Addresses Exercise Answers
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
IP addressing: how to get a block?
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
DHCP client-server scenario
DHCP server: 223.1.2.5 DHCP discover arriving
client
src : 0.0.0.0, 68
dest.: 255.255.255.255,67
yiaddr: 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest: 255.255.255.255, 68
yiaddrr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
DHCP: more than IP addresses
DHCP returns:
IP address
address of first-hop router for client
name and IP address of DNS sever
network mask (indicating network versus host
portion of address)
DHCP: example
DHCP DHCP connecting laptop needs its
DHCP UDP IP address, addr of first-hop
DHCP IP router, addr of DNS server:
DHCP Eth use DHCP
Phy
DHCP request encapsulated
DHCP
in UDP, encapsulated in IP,
DHCP DHCP 168.1.1.1 encapsulated in 802.3
DHCP UDP Ethernet
DHCP IP
DHCP Eth router with DHCP Ethernet frame broadcast
Phy server built into (dest: FFFFFFFFFFFF) on LAN,
router received at router running
DHCP server
Ethernet demuxed to IP
demuxed, UDP demuxed to
DHCP
DHCP: example
DHCP DHCP • DHCP server formulates
DHCP UDP DHCP ACK containing
DHCP IP client’s IP address, IP
DHCP Eth address of first-hop router
Phy for client, name & IP
address of DNS server
encapsulation of DHCP
DHCP
DHCP
DHCP UDP
server, frame forwarded
DHCP IP to client, demuxing up to
DHCP Eth router with DHCP DHCP at client
Phy server built into
DHCP
router client now knows its IP
address, name and IP
address of DNS server, IP
address of its first-hop
router
DHCP: Wireshark Message type: Boot Reply (2)
reply
output (home LAN) Hardware type: Ethernet
Hardware address length: 6
Hops: 0
Transaction ID: 0x6b3a11b7
Seconds elapsed: 0
Message type: Boot Request (1) Bootp flags: 0x0000 (Unicast)
Hardware type: Ethernet Client IP address: 192.168.1.101 (192.168.1.101)
Hardware address length: 6 Your (client) IP address: 0.0.0.0 (0.0.0.0)
Hops: 0
Transaction ID: 0x6b3a11b7
request Next server IP address: 192.168.1.1 (192.168.1.1)
Relay agent IP address: 0.0.0.0 (0.0.0.0)
Seconds elapsed: 0 Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
Bootp flags: 0x0000 (Unicast) Server host name not given
Client IP address: 0.0.0.0 (0.0.0.0) Boot file name not given
Your (client) IP address: 0.0.0.0 (0.0.0.0) Magic cookie: (OK)
Next server IP address: 0.0.0.0 (0.0.0.0) Option: (t=53,l=1) DHCP Message Type = DHCP ACK
Relay agent IP address: 0.0.0.0 (0.0.0.0) Option: (t=54,l=4) Server Identifier = 192.168.1.1
Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a) Option: (t=1,l=4) Subnet Mask = 255.255.255.0
Server host name not given Option: (t=3,l=4) Router = 192.168.1.1
Boot file name not given Option: (6) Domain Name Server
Magic cookie: (OK) Length: 12; Value: 445747E2445749F244574092;
Option: (t=53,l=1) DHCP Message Type = DHCP Request IP Address: 68.87.71.226;
Option: (61) Client identifier IP Address: 68.87.73.242;
Length: 7; Value: 010016D323688A; IP Address: 68.87.64.146
Hardware type: Ethernet Option: (t=15,l=20) Domain Name = "hsd1.ma.comcast.net."
Client MAC address: Wistron_23:68:8a (00:16:d3:23:68:8a)
Option: (t=50,l=4) Requested IP Address = 192.168.1.101
Option: (t=12,l=5) Host Name = "nomad"
Option: (55) Parameter Request List
Length: 11; Value: 010F03062C2E2F1F21F92B
1 = Subnet Mask; 15 = Domain Name
3 = Router; 6 = Domain Name Server
44 = NetBIOS over TCP/IP Name Server
……
NAT: network address translation
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
• NAT is controversial:
– routers should only process up to layer 3
– violates end-to-end argument
• NAT possibility must be taken into account by app
designers, e.g., P2P applications
– address shortage should instead be solved by IPv6
Outline
Introduction routing algorithms
datagram networks – link state
– distance vector
IP: Internet Protocol
– hierarchical routing
– datagram format
– IPv4 addressing routing in the Internet
– ICMP – RIP
– IPv6 – OSPF
– BGP
ICMP: Internet control message protocol
Fragment
Identification Flags
Offset
Next
Payload Length Hop Limit
Header
Time to Live Protocol Header Checksum
Source Address
Destination Address
Source Address
Options Padding
data
32 bits
IPv6 Header
IPv6 datagram
IPv4 datagram
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
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
data data
A-to-B: E-to-F:
IPv6 B-to-C: B-to-C: IPv6
IPv6 inside IPv6 inside
IPv4 IPv4