E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
1
EE 586 Communication andSwitching Networks
Lecture 18
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-2
underline_base
4.1 introduction
4.2 virtual circuit anddatagram networks
4.3 whats inside a router
4.4 IP: Internet Protocol
datagram format
IPv4 addressing
ICMP
IPv6
4.5 routing algorithms
link state
distance vector
hierarchical routing
4.6 routing in the Internet
RIP
OSPF
BGP
4.7 broadcast and multicastrouting
Chapter 4: outline
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-3
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
car_icon_small
iphone_stylized_small
antenna_radiation_stylized
access_point_stylized_small
antenna_radiation_stylized
access_point_stylized_small
antenna_radiation_stylized
cell_tower_radiation copy
antenna_stylized
laptop_keyboard
screen
antenna_stylized
laptop_keyboard
screen
antenna_stylized
laptop_keyboard
screen
desktop_computer_stylized_medium
antenna_stylized
laptop_keyboard
screen
underline_base
Network layer
transport segment fromsending to receiving host
network layer protocolsin every host, router
on sending sideencapsulates segmentsinto datagrams
on receiving side, deliverssegments to transportlayer
router examines headerfields in all datagramspassing through it
application
transport
network
data link
physical
application
transport
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-4
underline_base
Two key network-layer functions
forwarding: move packetsfrom routers input toappropriate routeroutput
routing: determine routetaken by packets fromsource to dest.
routing algorithms
analogy:
routing: process ofplanning trip from sourceto dest
forwarding: process ofgetting through singleinterchange
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-5
Connection, connection-less service
datagram network provides network-layerconnectionless service
virtual-circuit network provides network-layerconnection 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
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-6
Virtual circuits
call setup, teardown for each call before data can flow
each packet carries VC identifier (not destination hostaddress)
every router on source-dest path maintains state foreach passing connection
link, router resources (bandwidth, buffers) may beallocated to VC (dedicated resources = predictableservice)
source-to-dest path behaves much like telephonecircuit
performance-wise
network actions along source-to-dest path
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-7
underline_base
VC forwarding table
12
22
32
1
2
3
VC number
interface
number
Incoming interface    Incoming VC #     Outgoing interface    Outgoing VC #
1                          12                               3                          22
2                          63                               1                          18
3                           7                                2                          17
1                          97                               2                           87
…                          …                                …                            …
forwarding table in
northwest router:
VC routers maintain connection state information!
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-8
1
2
3
underline_base
Datagram forwarding  table
IP destination address in
arriving packets header
routing algorithm
local forwarding table
dest address
output  link
address-range 1
address-range 2
address-range 3
address-range 4
3
2
2
1
4 billion IP addresses, sorather than list individualdestination address
list range of addresses
(aggregate table entries)
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-9
Destination Address Range
11001000 00010111 00010000 00000000
through
11001000 00010111 00010111 11111111
11001000 00010111 00011000 00000000
through
11001000 00010111 00011000 11111111
11001000 00010111 00011001 00000000
through
11001000 00010111 00011111 11111111
otherwise
Link Interface
0
1
2
3
Q: but what happens if ranges dont divide up so nicely?
underline_base
Datagram forwarding  table
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-10
The Internet network layer
forwarding
table
host, router network layer functions:
routing protocols
 path selection
 RIP, OSPF, BGP
IP protocol
 addressing conventions
 datagram format
 packet handling conventions
ICMP protocol
 error reporting
 router signaling
transport layer: TCP, UDP
link layer
physical layer
network
layer
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-11
ver
length
32 bits
data
(variable length,
typically a TCP
or UDP segment)
16-bit identifier
header
 checksum
time to
live
32 bit source IP address
head.
len
type of
service
flgs
fragment
 offset
upper
 layer
32 bit destination IP address
options (if any)
IP datagram format
IP protocol version
number
header length
 (bytes)
upper layer protocol
to deliver payload to
total datagram
length (bytes)
type of data
for
fragmentation/
reassembly
max number
remaining hops
(decremented at
each router)
e.g. timestamp,
record route
taken, specify
list of routers
to visit.
how much overhead?
20 bytes of TCP
20 bytes of IP
= 40 bytes + applayer overhead
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-12
IP fragmentation, reassembly
network links have MTU(max.transfer size) -largest possible link-levelframe
different link types,different MTUs
large IP datagram divided(fragmented) within net
one datagram becomesseveral datagrams
reassembled only atfinal destination
IP header bits used toidentify, order relatedfragments
fragmentation:
in: one large datagram
out: 3 smaller datagrams
reassembly
underline_base
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-13
IP addressing: introduction
IP address: 32-bitidentifier for host, routerinterface
interface: connectionbetween host/router andphysical link
routers typically havemultiple interfaces
host typically has one ortwo interfaces (e.g., wiredEthernet, wireless 802.11)
IP addresses associatedwith each interface
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4
223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2
223.1.3.1
223.1.3.27
223.1.1.1 = 11011111 00000001 00000001 00000001
223
1
1
1
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-14
Subnets
IP address:
subnet part - high orderbits
host part - low orderbits
whats a subnet ?
device interfaces withsame subnet part of IPaddress
can physically reacheach other withoutintervening router
network consisting of 3 subnets
underline_base
223.1.1.1
223.1.1.3
223.1.1.4
223.1.2.9
223.1.3.2
223.1.3.1
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
subnet
223.1.1.2
223.1.3.27
223.1.2.2
223.1.2.1
223.1.1.0/24
223.1.2.0/24
223.1.3.0/24
subnet mask: /24
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-15
underline_base
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 insubnet portion of address
11001000  00010111  00010000  00000000
subnet
part
host
part
200.23.16.0/23
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-16
underline_base
Forming a subnet
Q: how does network get subnet part of IP addr?
A: gets allocated portion of its provider ISPs addressspace
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
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-17
Hierarchical addressing: route aggregation
Send me anything
with addresses
beginning
200.23.16.0/20
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7
Internet
Organization 1
ISPs-R-Us
Send me anything
with addresses
beginning
199.31.0.0/16
200.23.20.0/23
Organization 2
.
.
.
.
.
.
hierarchical addressing allows efficient advertisement of routing
information:
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-18
ISPs-R-Us has a more specific route to Organization 1
Send me anything
with addresses
beginning
200.23.16.0/20
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7
Internet
Organization 1
ISPs-R-Us
Send me anything
with addresses
beginning 199.31.0.0/16
or 200.23.18.0/23
200.23.20.0/23
Organization 2
.
.
.
.
.
.
underline_base
Hierarchical addressing: more specific routes
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-19
underline_base
Longest prefix matching
Destination Address Range
11001000 00010111 00010*** *********
11001000 00010111 00011000 *********
11001000 00010111 00011*** *********
otherwise
DA: 11001000  00010111  00011000  10101010
examples:
DA: 11001000  00010111  00010110  10100001
which interface?
which interface?
when looking for forwarding table entry for givendestination address, use longest address prefix thatmatches destination address.
longest prefix matching
Link interface
0
1
2
3
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-20
 
223.1.1.0/24
223.1.2.0/24
223.1.3.0/24
223.1.1.1
223.1.1.3
223.1.1.4
223.1.2.9
223.1.3.2
223.1.3.1
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
223.1.1.2
223.1.3.27
223.1.2.2
223.1.2.1
DHCP
server
arriving DHCP
client needs
address in this
network
laptop_keyboard
screen
underline_base
DHCP: Dynamic Host Configuration Protocol
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-21
underline_base
DHCP: Dynamic Host Configuration Protocol
goal: allow host to dynamically obtain its IP address from networkserver when it joins network
can renew its lease on address in use
allows reuse of addresses (only hold address whileconnected/on)
support for mobile users who want to join network (moreshortly)
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
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-22
DHCP server: 223.1.2.5
arriving
 client
DHCP discover
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
yiaddr: 223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src:  0.0.0.0, 68
dest::  255.255.255.255, 67
yiaddr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest:  255.255.255.255, 68
yiaddr: 223.1.2.4
transaction ID: 655
lifetime: 3600 secs
laptop_keyboard
screen
DHCP client-server scenario
underline_base
255.255.255.255 isfor broadcast
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-23
DHCP: more than IP addresses
DHCP can return more than just allocated IPaddress on subnet:
address of first-hop router for client
name and IP address of DNS sever
network mask (indicating network versus host portionof address)
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-24
NAT: network address translation
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
138.76.29.7
local network
(e.g., home network)
10.0.0/24
rest of
Internet
datagrams with source or
destination in this network
have 10.0.0/24 address for
source, destination (as usual)
all datagrams leaving local
network have same singlesource NAT IP address:138.76.29.7,different sourceport numbers
underline_base
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-25
10.0.0.1
10.0.0.2
10.0.0.3
S: 10.0.0.1, 3345
D: 128.119.40.186, 80
1
10.0.0.4
138.76.29.7
1: host 10.0.0.1
sends datagram to
128.119.40.186, 80
NAT translation table
WAN side addr        LAN side addr
138.76.29.7, 5001   10.0.0.1, 3345
……                                         ……
S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 138.76.29.7, 5001
D: 128.119.40.186, 80
2
2: NAT router
changes datagram
source addr from
10.0.0.1, 3345 to
138.76.29.7, 5001,
updates table
S: 128.119.40.186, 80
D: 138.76.29.7, 5001
3
3: reply arrives
 dest. address:
 138.76.29.7, 5001
4: NAT router
changes datagram
dest addr from
138.76.29.7, 5001 to 10.0.0.1, 3345
NAT: network address translation
underline_base
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-26
underline_base
NAT traversal problem
client wants to connect toserver with address 10.0.0.1
server address 10.0.0.1 local toLAN (client cant use it asdestination addr)
only one externally visible NATedaddress: 138.76.29.7
solution1: statically configureNAT to forward incomingconnection requests at givenport to server
e.g., (123.76.29.7, port 2500)always forwarded to 10.0.0.1 port25000
10.0.0.1
10.0.0.4
NAT
router
138.76.29.7
client
?
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-27
NAT traversal problem
solution 2: Universal Plug and Play(UPnP) Internet Gateway Device(IGD) Protocol.  Allows NATedhost to:
learn public IP address(138.76.29.7)
add/remove port mappings(with lease times)
i.e., automate static NAT portmap configuration
10.0.0.1
NAT
router
desktop_computer_stylized_medium
desktop_computer_stylized_medium
IGD
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
Network Layer
4-28
NAT traversal problem
solution 3: relaying (used in Skype)
NATed client establishes connection to relay
external client connects to relay
relay bridges packets between to connections
138.76.29.7
client
kw_skype_relay
kw_skype_logo
1. connection to
relay initiated
by NATed host
2. connection to
relay initiated
by client
3. relaying
established
underline_base
NAT
router
desktop_computer_stylized_medium
desktop_computer_stylized_medium
desktop_computer_stylized_medium
skype_logo
10.0.0.1
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-29
ICMP: internet control message protocol
used by hosts & routersto communicate network-level information
error reporting:unreachable host, network,port, protocol
echo request/reply (used byping)
network-layer above IP:
ICMP msgs carried in IPdatagrams
ICMP message: type, codeplus first 8 bytes of IPdatagram causing error
Type  Code  description
0        0         echo reply (ping)
3        0         dest. network unreachable
3        1         dest host unreachable
3        2         dest protocol unreachable
3        3         dest port unreachable
3        6         dest network unknown
3        7         dest host unknown
4        0         source quench (congestion
                     control - not used)
8        0         echo request (ping)
9        0         route advertisement
10      0         router discovery
11      0         TTL expired
12      0         bad IP header
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-30
Traceroute and ICMP
source sends series ofUDP segments to dest
first set has TTL =1
second set has TTL=2, etc.
unlikely port number
when nth set of datagramsarrives to nth router:
router discards datagrams
and sends source ICMPmessages (type 11, code 0)
ICMP messages includesname of router & IP address
when ICMP messagesarrives, source recordsRTTs
stopping criteria:
UDP segment eventuallyarrives at destination host
destination returns ICMPport unreachablemessage (type 3, code 3)
source stops
underline_base
3 probes
3 probes
3 probes
desktop_computer_stylized_medium
desktop_computer_stylized_medium
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-31
IPv6: motivation
initial motivation: 32-bit address space soon to becompletely 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
underline_base
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-32
underline_base
IPv6 datagram format
priority:  identify priority among datagrams in flow
flow Label: identify datagrams in same flow.
                    (concept offlow not well defined).
next header: identify upper layer protocol for data
data
destination address
(128 bits)
source address
(128 bits)
payload len
next hdr
hop limit
flow label
pri
ver
32 bits
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-33
underline_base
Other changes from IPv4
checksum: removed entirely to reduce processingtime at each hop
options: allowed, but outside of header, indicatedby Next Header field
ICMPv6: new version of ICMP
additional message types, e.g. Packet Too Big
multicast group management functions
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-34
Transition from IPv4 to IPv6
not all routers can be upgraded simultaneously
no flag days
how will network operate with mixed IPv4 andIPv6 routers?
tunneling: IPv6 datagram carried as payload in IPv4datagram among IPv4 routers
underline_base
IPv4 source, dest addr
IPv4 header fields
IPv4 datagram
IPv6 datagram
IPv4 payload
UDP/TCP payload
IPv6 source dest addr
IPv6 header fields
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-35
underline_base
Tunneling
physical view:
IPv4
IPv4
A
B
IPv6
IPv6
E
IPv6
IPv6
F
C
D
logical view:
IPv4 tunnel
connecting IPv6 routers
E
IPv6
IPv6
F
A
B
IPv6
IPv6
E l e c t r i c a l    &   C o m p u t e r
Department of
Electrical & Computer Engineering
4-36
flow: X
src: A
dest: F
data
A-to-B:
IPv6
Flow: X
Src: A
Dest: F
data
src:B
dest: E
B-to-C:
IPv6 inside
IPv4
E-to-F:
IPv6
flow: X
src: A
dest: F
data
B-to-C:
IPv6 inside
IPv4
Flow: X
Src: A
Dest: F
data
src:B
dest: E
physical view:
A
B
IPv6
IPv6
E
IPv6
IPv6
F
C
D
logical view:
IPv4 tunnel
connecting IPv6 routers
E
IPv6
IPv6
F
A
B
IPv6
IPv6
underline_base
Tunneling
IPv4
IPv4